Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions tsunami/app/defaultclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ import (
"os"

"github.com/wavetermdev/waveterm/tsunami/engine"
"github.com/wavetermdev/waveterm/tsunami/util"
"github.com/wavetermdev/waveterm/tsunami/vdom"
)

const TsunamiCloseOnStdinEnvVar = "TSUNAMI_CLOSEONSTDIN"
const MaxShortDescLen = 120

type AppMeta engine.AppMeta

func DefineComponent[P any](name string, renderFn func(props P) any) vdom.Component[P] {
return engine.DefineComponentEx(engine.GetDefaultClient(), name, renderFn)
}
Expand Down Expand Up @@ -146,6 +149,12 @@ func QueueRefOp(ref *vdom.VDomRef, op vdom.VDomRefOperation) {
client.Root.QueueRefOp(op)
}

func SetAppMeta(meta AppMeta) {
meta.ShortDesc = util.TruncateString(meta.ShortDesc, MaxShortDescLen)
client := engine.GetDefaultClient()
client.SetAppMeta(engine.AppMeta(meta))
}

func SetTitle(title string) {
client := engine.GetDefaultClient()
m := client.GetAppMeta()
Expand All @@ -154,9 +163,7 @@ func SetTitle(title string) {
}

func SetShortDesc(shortDesc string) {
if len(shortDesc) > MaxShortDescLen {
shortDesc = shortDesc[0:MaxShortDescLen-3] + "..."
}
shortDesc = util.TruncateString(shortDesc, MaxShortDescLen)
client := engine.GetDefaultClient()
m := client.GetAppMeta()
m.ShortDesc = shortDesc
Expand Down
6 changes: 4 additions & 2 deletions tsunami/demo/cpuchart/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import (
"github.com/wavetermdev/waveterm/tsunami/vdom"
)

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

// Global atoms for config and data
var (
Expand Down
6 changes: 4 additions & 2 deletions tsunami/demo/githubaction/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ import (
"github.com/wavetermdev/waveterm/tsunami/vdom"
)

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

// Global atoms for config and data
var (
Expand Down
6 changes: 4 additions & 2 deletions tsunami/demo/modaltest/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import (
"github.com/wavetermdev/waveterm/tsunami/vdom"
)

const AppTitle = "Modal Test (Tsunami Demo)"
const AppShortDesc = "Test alert and confirm modals in Tsunami"
var AppMeta = app.AppMeta{
Title: "Modal Test (Tsunami Demo)",
ShortDesc: "Test alert and confirm modals in Tsunami",
}

var App = app.DefineComponent("App", func(_ struct{}) any {
// State to track modal results
Expand Down
6 changes: 4 additions & 2 deletions tsunami/demo/pomodoro/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import (
"github.com/wavetermdev/waveterm/tsunami/vdom"
)

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

type Mode struct {
Name string `json:"name"`
Expand Down
6 changes: 4 additions & 2 deletions tsunami/demo/recharts/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import (
"github.com/wavetermdev/waveterm/tsunami/vdom"
)

const AppTitle = "Recharts Demo"
const AppShortDesc = "Interactive charts and data visualization using Recharts"
var AppMeta = app.AppMeta{
Title: "Recharts Demo",
ShortDesc: "Interactive charts and data visualization using Recharts",
}

// Global atoms for config and data
var (
Expand Down
6 changes: 4 additions & 2 deletions tsunami/demo/tabletest/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import (
"github.com/wavetermdev/waveterm/tsunami/vdom"
)

const AppTitle = "Table Test Demo"
const AppShortDesc = "Testing table component with sortable columns and pagination"
var AppMeta = app.AppMeta{
Title: "Table Test Demo",
ShortDesc: "Testing table component with sortable columns and pagination",
}

// Sample data structure for the table
type Person struct {
Expand Down
6 changes: 4 additions & 2 deletions tsunami/demo/todo/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import (
"github.com/wavetermdev/waveterm/tsunami/vdom"
)

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

// Basic domain types with json tags for props
type Todo struct {
Expand Down
6 changes: 4 additions & 2 deletions tsunami/demo/tsunamiconfig/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ import (
"github.com/wavetermdev/waveterm/tsunami/vdom"
)

const AppTitle = "Tsunami Config Manager"
const AppShortDesc = "Configuration editor for remote servers with JSON validation"
var AppMeta = app.AppMeta{
Title: "Tsunami Config Manager",
ShortDesc: "Configuration editor for remote servers with JSON validation",
}

// Global atoms for config
var (
Expand Down
3 changes: 1 addition & 2 deletions tsunami/templates/app-main.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ func main() {
subDistFS, _ := fs.Sub(distFS, "dist")
subStaticFS, _ := fs.Sub(staticFS, "static")
app.RegisterEmbeds(subDistFS, subStaticFS, nil)
app.SetTitle(AppTitle)
app.SetShortDesc(AppShortDesc)
app.SetAppMeta(AppMeta)

if len(os.Args) == 2 && os.Args[1] == "--manifest" {
app.PrintAppManifest()
Expand Down
10 changes: 10 additions & 0 deletions tsunami/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,3 +283,13 @@ func ParseJSONTag(field reflect.StructField) (JsonFieldInfo, bool) {
Options: opts,
}, true
}

// TruncateString truncates a string to maxLen runes (not bytes).
// If the string is longer than maxLen, it truncates to maxLen-3 and appends "...".
func TruncateString(s string, maxLen int) string {
runes := []rune(s)
if len(runes) <= maxLen {
return s
}
return string(runes[0:maxLen-3]) + "..."
}
Loading