Skip to content

Commit 7f22eb0

Browse files
authored
use AppMeta instead of AppTitle/AppShortDesc (#2551)
1 parent 7ac2f25 commit 7f22eb0

File tree

11 files changed

+53
-21
lines changed

11 files changed

+53
-21
lines changed

tsunami/app/defaultclient.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ import (
1212
"os"
1313

1414
"github.com/wavetermdev/waveterm/tsunami/engine"
15+
"github.com/wavetermdev/waveterm/tsunami/util"
1516
"github.com/wavetermdev/waveterm/tsunami/vdom"
1617
)
1718

1819
const TsunamiCloseOnStdinEnvVar = "TSUNAMI_CLOSEONSTDIN"
1920
const MaxShortDescLen = 120
2021

22+
type AppMeta engine.AppMeta
23+
2124
func DefineComponent[P any](name string, renderFn func(props P) any) vdom.Component[P] {
2225
return engine.DefineComponentEx(engine.GetDefaultClient(), name, renderFn)
2326
}
@@ -146,6 +149,12 @@ func QueueRefOp(ref *vdom.VDomRef, op vdom.VDomRefOperation) {
146149
client.Root.QueueRefOp(op)
147150
}
148151

152+
func SetAppMeta(meta AppMeta) {
153+
meta.ShortDesc = util.TruncateString(meta.ShortDesc, MaxShortDescLen)
154+
client := engine.GetDefaultClient()
155+
client.SetAppMeta(engine.AppMeta(meta))
156+
}
157+
149158
func SetTitle(title string) {
150159
client := engine.GetDefaultClient()
151160
m := client.GetAppMeta()
@@ -154,9 +163,7 @@ func SetTitle(title string) {
154163
}
155164

156165
func SetShortDesc(shortDesc string) {
157-
if len(shortDesc) > MaxShortDescLen {
158-
shortDesc = shortDesc[0:MaxShortDescLen-3] + "..."
159-
}
166+
shortDesc = util.TruncateString(shortDesc, MaxShortDescLen)
160167
client := engine.GetDefaultClient()
161168
m := client.GetAppMeta()
162169
m.ShortDesc = shortDesc

tsunami/demo/cpuchart/app.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ import (
99
"github.com/wavetermdev/waveterm/tsunami/vdom"
1010
)
1111

12-
const AppTitle = "CPU Usage Monitor"
13-
const AppShortDesc = "Real-time CPU usage monitoring and charting"
12+
var AppMeta = app.AppMeta{
13+
Title: "CPU Usage Monitor",
14+
ShortDesc: "Real-time CPU usage monitoring and charting",
15+
}
1416

1517
// Global atoms for config and data
1618
var (

tsunami/demo/githubaction/app.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ import (
1515
"github.com/wavetermdev/waveterm/tsunami/vdom"
1616
)
1717

18-
const AppTitle = "GitHub Actions Monitor"
19-
const AppShortDesc = "Real-time GitHub Actions workflow monitoring and status tracking"
18+
var AppMeta = app.AppMeta{
19+
Title: "GitHub Actions Monitor",
20+
ShortDesc: "Real-time GitHub Actions workflow monitoring and status tracking",
21+
}
2022

2123
// Global atoms for config and data
2224
var (

tsunami/demo/modaltest/app.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import (
55
"github.com/wavetermdev/waveterm/tsunami/vdom"
66
)
77

8-
const AppTitle = "Modal Test (Tsunami Demo)"
9-
const AppShortDesc = "Test alert and confirm modals in Tsunami"
8+
var AppMeta = app.AppMeta{
9+
Title: "Modal Test (Tsunami Demo)",
10+
ShortDesc: "Test alert and confirm modals in Tsunami",
11+
}
1012

1113
var App = app.DefineComponent("App", func(_ struct{}) any {
1214
// State to track modal results

tsunami/demo/pomodoro/app.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ import (
88
"github.com/wavetermdev/waveterm/tsunami/vdom"
99
)
1010

11-
const AppTitle = "Pomodoro Timer (Tsunami Demo)"
12-
const AppShortDesc = "Productivity timer with work and break intervals"
11+
var AppMeta = app.AppMeta{
12+
Title: "Pomodoro Timer (Tsunami Demo)",
13+
ShortDesc: "Productivity timer with work and break intervals",
14+
}
1315

1416
type Mode struct {
1517
Name string `json:"name"`

tsunami/demo/recharts/app.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ import (
88
"github.com/wavetermdev/waveterm/tsunami/vdom"
99
)
1010

11-
const AppTitle = "Recharts Demo"
12-
const AppShortDesc = "Interactive charts and data visualization using Recharts"
11+
var AppMeta = app.AppMeta{
12+
Title: "Recharts Demo",
13+
ShortDesc: "Interactive charts and data visualization using Recharts",
14+
}
1315

1416
// Global atoms for config and data
1517
var (

tsunami/demo/tabletest/app.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ import (
88
"github.com/wavetermdev/waveterm/tsunami/vdom"
99
)
1010

11-
const AppTitle = "Table Test Demo"
12-
const AppShortDesc = "Testing table component with sortable columns and pagination"
11+
var AppMeta = app.AppMeta{
12+
Title: "Table Test Demo",
13+
ShortDesc: "Testing table component with sortable columns and pagination",
14+
}
1315

1416
// Sample data structure for the table
1517
type Person struct {

tsunami/demo/todo/app.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ import (
88
"github.com/wavetermdev/waveterm/tsunami/vdom"
99
)
1010

11-
const AppTitle = "Todo App (Tsunami Demo)"
12-
const AppShortDesc = "Feature-rich todo list with component composition and state management"
11+
var AppMeta = app.AppMeta{
12+
Title: "Todo App (Tsunami Demo)",
13+
ShortDesc: "Feature-rich todo list with component composition and state management",
14+
}
1315

1416
// Basic domain types with json tags for props
1517
type Todo struct {

tsunami/demo/tsunamiconfig/app.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ import (
1414
"github.com/wavetermdev/waveterm/tsunami/vdom"
1515
)
1616

17-
const AppTitle = "Tsunami Config Manager"
18-
const AppShortDesc = "Configuration editor for remote servers with JSON validation"
17+
var AppMeta = app.AppMeta{
18+
Title: "Tsunami Config Manager",
19+
ShortDesc: "Configuration editor for remote servers with JSON validation",
20+
}
1921

2022
// Global atoms for config
2123
var (

tsunami/templates/app-main.go.tmpl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ func main() {
1818
subDistFS, _ := fs.Sub(distFS, "dist")
1919
subStaticFS, _ := fs.Sub(staticFS, "static")
2020
app.RegisterEmbeds(subDistFS, subStaticFS, nil)
21-
app.SetTitle(AppTitle)
22-
app.SetShortDesc(AppShortDesc)
21+
app.SetAppMeta(AppMeta)
2322

2423
if len(os.Args) == 2 && os.Args[1] == "--manifest" {
2524
app.PrintAppManifest()

0 commit comments

Comments
 (0)