fix(window): fallback title for wails windows
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run

This commit is contained in:
Virgil 2026-04-02 20:26:27 +00:00
parent 29dc0d9877
commit 0204540b20
2 changed files with 23 additions and 3 deletions

View file

@ -45,7 +45,7 @@ func (wp *WailsPlatform) GetWindows() []PlatformWindow {
out := make([]PlatformWindow, 0, len(all))
for _, w := range all {
if wv, ok := w.(*application.WebviewWindow); ok {
out = append(out, &wailsWindow{w: wv})
out = append(out, &wailsWindow{w: wv, title: wv.Name()})
}
}
return out
@ -58,8 +58,16 @@ type wailsWindow struct {
title string
}
func (ww *wailsWindow) Name() string { return ww.w.Name() }
func (ww *wailsWindow) Title() string { return ww.title }
func (ww *wailsWindow) Name() string { return ww.w.Name() }
func (ww *wailsWindow) Title() string {
if ww.title != "" {
return ww.title
}
if ww.w != nil {
return ww.w.Name()
}
return ""
}
func (ww *wailsWindow) Position() (int, int) { return ww.w.Position() }
func (ww *wailsWindow) Size() (int, int) { return ww.w.Size() }
func (ww *wailsWindow) IsVisible() bool { return ww.w.IsVisible() }

View file

@ -178,6 +178,18 @@ func TestWailsWindow_DevToolsToggle_Good(t *testing.T) {
assert.False(t, ww.w.DevToolsOpen())
}
func TestWailsPlatform_GetWindows_TitleFallback_Good(t *testing.T) {
app := application.NewApp()
platform := NewWailsPlatform(app)
pw := platform.CreateWindow(PlatformWindowOptions{Name: "fallback"})
require.NotNil(t, pw)
windows := platform.GetWindows()
require.Len(t, windows, 1)
assert.Equal(t, "fallback", windows[0].Title())
}
// --- StateManager Tests ---
// newTestStateManager creates a clean StateManager with a temp dir for testing.