fix: window-scoped default tab names instead of global position
Default tab titles like "Tab N" now count tabs within the current window only, so the second window starts at Tab 1.
- commit
- e6ff2cc59928f9eb88f785b186de307134e40ada
- author
- brice · · 2026-04-28 07:01 UTC
- parent
- 429492c
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +18 -1
M internal/ui/app.go +18 -1
| @@ -63,6 +63,12 @@ func EnsureAdwaitaInitialized() { | |||
| 63 | 63 | }) | |
| 64 | 64 | } | |
| 65 | 65 | ||
| 66 | + | // defaultTabName returns a window-scoped default tab name. | |
| 67 | + | // index is the 1-based tab position within the window. | |
| 68 | + | func defaultTabName(index int) string { | |
| 69 | + | return fmt.Sprintf("Tab %d", index) | |
| 70 | + | } | |
| 71 | + | ||
| 66 | 72 | // App wraps the GTK Application and manages the browser lifecycle. | |
| 67 | 73 | type App struct { | |
| 68 | 74 | deps *Dependencies | |
| @@ -2086,9 +2092,20 @@ func (a *App) initCoordinators(ctx context.Context) { | |||
| 2086 | 2092 | a.tabCoord.SetOnTabCreated(func(ctx context.Context, tab *entity.Tab) { | |
| 2087 | 2093 | // Assign ownership BEFORE creating workspace view so windowForTab is set | |
| 2088 | 2094 | // for scope filtering and browserWindowForTab resolution. | |
| 2089 | - | if bw := a.lastFocusedBrowserWindow(); bw != nil { | |
| 2095 | + | bw := a.lastFocusedBrowserWindow() | |
| 2096 | + | if bw != nil { | |
| 2090 | 2097 | a.setBrowserWindowForTab(tab.ID, bw) | |
| 2091 | 2098 | } | |
| 2099 | + | // Set a window-scoped default title so "Tab N" doesn't use global position. | |
| 2100 | + | // Count tabs already owned by this window (excluding the one just added). | |
| 2101 | + | windowTabCount := 0 | |
| 2102 | + | for _, owner := range a.windowForTab { | |
| 2103 | + | if owner == bw { | |
| 2104 | + | windowTabCount++ | |
| 2105 | + | } | |
| 2106 | + | } | |
| 2107 | + | // windowTabCount includes the tab just added, so it equals the 1-based index. | |
| 2108 | + | tab.Name = defaultTabName(windowTabCount) | |
| 2092 | 2109 | a.createWorkspaceView(ctx, tab) | |
| 2093 | 2110 | }) | |
| 2094 | 2111 | a.tabCoord.SetOnTabSwitched(func(ctx context.Context, tab *entity.Tab) { | |
| @@ -63,6 +63,12 @@ func EnsureAdwaitaInitialized() { | |||||
| 63 | }) | 63 | }) | ||
| 64 | } | 64 | } | ||
| 65 | 65 | ||||
| 66 | + | // defaultTabName returns a window-scoped default tab name. | |||
| 67 | + | // index is the 1-based tab position within the window. | |||
| 68 | + | func defaultTabName(index int) string { | |||
| 69 | + | return fmt.Sprintf("Tab %d", index) | |||
| 70 | + | } | |||
| 71 | + | ||||
| 66 | // App wraps the GTK Application and manages the browser lifecycle. | 72 | // App wraps the GTK Application and manages the browser lifecycle. | ||
| 67 | type App struct { | 73 | type App struct { | ||
| 68 | deps *Dependencies | 74 | deps *Dependencies | ||
| @@ -2086,9 +2092,20 @@ func (a *App) initCoordinators(ctx context.Context) { | |||||
| 2086 | a.tabCoord.SetOnTabCreated(func(ctx context.Context, tab *entity.Tab) { | 2092 | a.tabCoord.SetOnTabCreated(func(ctx context.Context, tab *entity.Tab) { | ||
| 2087 | // Assign ownership BEFORE creating workspace view so windowForTab is set | 2093 | // Assign ownership BEFORE creating workspace view so windowForTab is set | ||
| 2088 | // for scope filtering and browserWindowForTab resolution. | 2094 | // for scope filtering and browserWindowForTab resolution. | ||
| 2089 | - | if bw := a.lastFocusedBrowserWindow(); bw != nil { | 2095 | + | bw := a.lastFocusedBrowserWindow() |
| 2096 | + | if bw != nil { | |||
| 2090 | a.setBrowserWindowForTab(tab.ID, bw) | 2097 | a.setBrowserWindowForTab(tab.ID, bw) | ||
| 2091 | } | 2098 | } | ||
| 2099 | + | // Set a window-scoped default title so "Tab N" doesn't use global position. | |||
| 2100 | + | // Count tabs already owned by this window (excluding the one just added). | |||
| 2101 | + | windowTabCount := 0 | |||
| 2102 | + | for _, owner := range a.windowForTab { | |||
| 2103 | + | if owner == bw { | |||
| 2104 | + | windowTabCount++ | |||
| 2105 | + | } | |||
| 2106 | + | } | |||
| 2107 | + | // windowTabCount includes the tab just added, so it equals the 1-based index. | |||
| 2108 | + | tab.Name = defaultTabName(windowTabCount) | |||
| 2092 | a.createWorkspaceView(ctx, tab) | 2109 | a.createWorkspaceView(ctx, tab) | ||
| 2093 | }) | 2110 | }) | ||
| 2094 | a.tabCoord.SetOnTabSwitched(func(ctx context.Context, tab *entity.Tab) { | 2111 | a.tabCoord.SetOnTabSwitched(func(ctx context.Context, tab *entity.Tab) { | ||