fix: preserve popup tab names before tab bar insertion
- keep caller-supplied tab names from CreateWithPane - run onTabCreated before adding popup tabs to the tab bar
- commit
- cccb5fe798638a598d4f08ea5f23e68a1ee1805c
- author
- brice · · 2026-04-28 18:26 UTC
- parent
- 5509537
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +14 -9
M internal/ui/app.go +7 -4
| @@ -2126,11 +2126,14 @@ func (a *App) initTabCoordinator(ctx context.Context) { | |||
| 2126 | 2126 | } | |
| 2127 | 2127 | // Set a window-scoped default title so "Tab N" doesn't use global position. | |
| 2128 | 2128 | // Count only live tabs owned by this window via the helper. | |
| 2129 | - | count := a.tabCountForBrowserWindow(bw) | |
| 2130 | - | if count <= 0 { | |
| 2131 | - | count = 1 | |
| 2129 | + | // Only assign a default name if the creator did not supply one. | |
| 2130 | + | if strings.TrimSpace(tab.Name) == "" { | |
| 2131 | + | count := a.tabCountForBrowserWindow(bw) | |
| 2132 | + | if count <= 0 { | |
| 2133 | + | count = 1 | |
| 2134 | + | } | |
| 2135 | + | tab.Name = defaultTabName(count) | |
| 2132 | 2136 | } | |
| 2133 | - | tab.Name = defaultTabName(count) | |
| 2134 | 2137 | a.createWorkspaceView(ctx, tab) | |
| 2135 | 2138 | }) | |
| 2136 | 2139 | a.tabCoord.SetOnTabSwitched(func(ctx context.Context, tab *entity.Tab) { | |
| @@ -2126,11 +2126,14 @@ func (a *App) initTabCoordinator(ctx context.Context) { | |||||
| 2126 | } | 2126 | } | ||
| 2127 | // Set a window-scoped default title so "Tab N" doesn't use global position. | 2127 | // Set a window-scoped default title so "Tab N" doesn't use global position. | ||
| 2128 | // Count only live tabs owned by this window via the helper. | 2128 | // Count only live tabs owned by this window via the helper. | ||
| 2129 | - | count := a.tabCountForBrowserWindow(bw) | 2129 | + | // Only assign a default name if the creator did not supply one. |
| 2130 | - | if count <= 0 { | 2130 | + | if strings.TrimSpace(tab.Name) == "" { |
| 2131 | - | count = 1 | 2131 | + | count := a.tabCountForBrowserWindow(bw) |
| 2132 | + | if count <= 0 { | |||
| 2133 | + | count = 1 | |||
| 2134 | + | } | |||
| 2135 | + | tab.Name = defaultTabName(count) | |||
| 2132 | } | 2136 | } | ||
| 2133 | - | tab.Name = defaultTabName(count) | |||
| 2134 | a.createWorkspaceView(ctx, tab) | 2137 | a.createWorkspaceView(ctx, tab) | ||
| 2135 | }) | 2138 | }) | ||
| 2136 | a.tabCoord.SetOnTabSwitched(func(ctx context.Context, tab *entity.Tab) { | 2139 | a.tabCoord.SetOnTabSwitched(func(ctx context.Context, tab *entity.Tab) { | ||
M internal/ui/coordinator/tab.go +7 -5
| @@ -496,6 +496,13 @@ func (c *TabCoordinator) CreateWithPane( | |||
| 496 | 496 | // Set new tab as active | |
| 497 | 497 | c.tabs.SetActive(output.Tab.ID) | |
| 498 | 498 | ||
| 499 | + | // Notify app before adding tab to the visible tab bar. | |
| 500 | + | // The app assigns window ownership and the scoped default name here, | |
| 501 | + | // and TabBar.AddTab reads tab.Title() immediately when creating the button. | |
| 502 | + | if c.onTabCreated != nil { | |
| 503 | + | c.onTabCreated(ctx, output.Tab) | |
| 504 | + | } | |
| 505 | + | ||
| 499 | 506 | // Update tab bar | |
| 500 | 507 | if c.mainWindow != nil && c.mainWindow.TabBar() != nil { | |
| 501 | 508 | c.mainWindow.TabBar().AddTab(output.Tab) | |
| @@ -505,11 +512,6 @@ func (c *TabCoordinator) CreateWithPane( | |||
| 505 | 512 | // Update tab bar visibility | |
| 506 | 513 | c.UpdateBarVisibility(ctx) | |
| 507 | 514 | ||
| 508 | - | // Notify app to create workspace view | |
| 509 | - | if c.onTabCreated != nil { | |
| 510 | - | c.onTabCreated(ctx, output.Tab) | |
| 511 | - | } | |
| 512 | - | ||
| 513 | 515 | // Attach the popup WebView to the new tab's workspace | |
| 514 | 516 | if c.onAttachPopupToTab != nil { | |
| 515 | 517 | c.onAttachPopupToTab(ctx, output.Tab.ID, pane, wv) | |
| @@ -496,6 +496,13 @@ func (c *TabCoordinator) CreateWithPane( | |||||
| 496 | // Set new tab as active | 496 | // Set new tab as active | ||
| 497 | c.tabs.SetActive(output.Tab.ID) | 497 | c.tabs.SetActive(output.Tab.ID) | ||
| 498 | 498 | ||||
| 499 | + | // Notify app before adding tab to the visible tab bar. | |||
| 500 | + | // The app assigns window ownership and the scoped default name here, | |||
| 501 | + | // and TabBar.AddTab reads tab.Title() immediately when creating the button. | |||
| 502 | + | if c.onTabCreated != nil { | |||
| 503 | + | c.onTabCreated(ctx, output.Tab) | |||
| 504 | + | } | |||
| 505 | + | ||||
| 499 | // Update tab bar | 506 | // Update tab bar | ||
| 500 | if c.mainWindow != nil && c.mainWindow.TabBar() != nil { | 507 | if c.mainWindow != nil && c.mainWindow.TabBar() != nil { | ||
| 501 | c.mainWindow.TabBar().AddTab(output.Tab) | 508 | c.mainWindow.TabBar().AddTab(output.Tab) | ||
| @@ -505,11 +512,6 @@ func (c *TabCoordinator) CreateWithPane( | |||||
| 505 | // Update tab bar visibility | 512 | // Update tab bar visibility | ||
| 506 | c.UpdateBarVisibility(ctx) | 513 | c.UpdateBarVisibility(ctx) | ||
| 507 | 514 | ||||
| 508 | - | // Notify app to create workspace view | |||
| 509 | - | if c.onTabCreated != nil { | |||
| 510 | - | c.onTabCreated(ctx, output.Tab) | |||
| 511 | - | } | |||
| 512 | - | ||||
| 513 | // Attach the popup WebView to the new tab's workspace | 515 | // Attach the popup WebView to the new tab's workspace | ||
| 514 | if c.onAttachPopupToTab != nil { | 516 | if c.onAttachPopupToTab != nil { | ||
| 515 | c.onAttachPopupToTab(ctx, output.Tab.ID, pane, wv) | 517 | c.onAttachPopupToTab(ctx, output.Tab.ID, pane, wv) | ||