fix(config): register HideTabBarWhenSingleTab default in viper loader
- commit
- 33854501b875f2b2e9bb580c42de9e44a1f5048d
- author
- brice · · 2025-12-11 21:53 UTC
- committer
- brice · · 2025-12-11 20:01 UTC
- parent
- 73b7a8d
- signature
- unsigned
3 files · +19 -7
M internal/infrastructure/config/loader.go +1 -0
| @@ -345,6 +345,7 @@ func (m *Manager) setDefaults() { | |||
| 345 | 345 | m.viper.SetDefault("workspace.tabs.next_tab", defaults.Workspace.Tabs.NextTab) | |
| 346 | 346 | m.viper.SetDefault("workspace.tabs.previous_tab", defaults.Workspace.Tabs.PreviousTab) | |
| 347 | 347 | m.viper.SetDefault("workspace.tab_bar_position", defaults.Workspace.TabBarPosition) | |
| 348 | + | m.viper.SetDefault("workspace.hide_tab_bar_when_single_tab", defaults.Workspace.HideTabBarWhenSingleTab) | |
| 348 | 349 | m.viper.SetDefault("workspace.popups.behavior", string(defaults.Workspace.Popups.Behavior)) | |
| 349 | 350 | m.viper.SetDefault("workspace.popups.placement", defaults.Workspace.Popups.Placement) | |
| 350 | 351 | m.viper.SetDefault("workspace.popups.open_in_new_pane", defaults.Workspace.Popups.OpenInNewPane) | |
| @@ -345,6 +345,7 @@ func (m *Manager) setDefaults() { | |||||
| 345 | m.viper.SetDefault("workspace.tabs.next_tab", defaults.Workspace.Tabs.NextTab) | 345 | m.viper.SetDefault("workspace.tabs.next_tab", defaults.Workspace.Tabs.NextTab) | ||
| 346 | m.viper.SetDefault("workspace.tabs.previous_tab", defaults.Workspace.Tabs.PreviousTab) | 346 | m.viper.SetDefault("workspace.tabs.previous_tab", defaults.Workspace.Tabs.PreviousTab) | ||
| 347 | m.viper.SetDefault("workspace.tab_bar_position", defaults.Workspace.TabBarPosition) | 347 | m.viper.SetDefault("workspace.tab_bar_position", defaults.Workspace.TabBarPosition) | ||
| 348 | + | m.viper.SetDefault("workspace.hide_tab_bar_when_single_tab", defaults.Workspace.HideTabBarWhenSingleTab) | |||
| 348 | m.viper.SetDefault("workspace.popups.behavior", string(defaults.Workspace.Popups.Behavior)) | 349 | m.viper.SetDefault("workspace.popups.behavior", string(defaults.Workspace.Popups.Behavior)) | ||
| 349 | m.viper.SetDefault("workspace.popups.placement", defaults.Workspace.Popups.Placement) | 350 | m.viper.SetDefault("workspace.popups.placement", defaults.Workspace.Popups.Placement) | ||
| 350 | m.viper.SetDefault("workspace.popups.open_in_new_pane", defaults.Workspace.Popups.OpenInNewPane) | 351 | m.viper.SetDefault("workspace.popups.open_in_new_pane", defaults.Workspace.Popups.OpenInNewPane) | ||
M internal/ui/app.go +15 -7
| @@ -405,25 +405,33 @@ func (a *App) handleCloseTab(ctx context.Context) error { | |||
| 405 | 405 | func (a *App) updateTabBarVisibility(ctx context.Context) { | |
| 406 | 406 | log := logging.FromContext(ctx) | |
| 407 | 407 | ||
| 408 | + | // Debug: trace entry | |
| 409 | + | hideEnabled := true | |
| 410 | + | if a.deps.Config != nil { | |
| 411 | + | hideEnabled = a.deps.Config.Workspace.HideTabBarWhenSingleTab | |
| 412 | + | } | |
| 413 | + | log.Debug().Bool("hide_enabled", hideEnabled).Msg("updateTabBarVisibility called") | |
| 414 | + | ||
| 408 | 415 | // Check if feature is enabled | |
| 409 | 416 | if a.deps.Config != nil && !a.deps.Config.Workspace.HideTabBarWhenSingleTab { | |
| 417 | + | log.Debug().Msg("tab bar auto-hide disabled by config") | |
| 410 | 418 | return | |
| 411 | 419 | } | |
| 412 | 420 | ||
| 413 | - | if a.mainWindow == nil || a.mainWindow.TabBar() == nil { | |
| 421 | + | if a.mainWindow == nil { | |
| 422 | + | log.Debug().Msg("mainWindow is nil, skipping visibility update") | |
| 423 | + | return | |
| 424 | + | } | |
| 425 | + | if a.mainWindow.TabBar() == nil { | |
| 426 | + | log.Debug().Msg("tabBar is nil, skipping visibility update") | |
| 414 | 427 | return | |
| 415 | 428 | } | |
| 416 | 429 | ||
| 417 | 430 | tabCount := a.tabs.Count() | |
| 418 | 431 | shouldShow := tabCount > 1 | |
| 419 | 432 | ||
| 433 | + | log.Debug().Int("tab_count", tabCount).Bool("should_show", shouldShow).Msg("setting tab bar visibility") | |
| 420 | 434 | a.mainWindow.TabBar().SetVisible(shouldShow) | |
| 421 | - | ||
| 422 | - | if shouldShow { | |
| 423 | - | log.Debug().Int("tab_count", tabCount).Msg("tab bar visible") | |
| 424 | - | } else { | |
| 425 | - | log.Debug().Msg("tab bar hidden (single tab)") | |
| 426 | - | } | |
| 427 | 435 | } | |
| 428 | 436 | ||
| 429 | 437 | // handleNextTab switches to the next tab. | |
| @@ -405,25 +405,33 @@ func (a *App) handleCloseTab(ctx context.Context) error { | |||||
| 405 | func (a *App) updateTabBarVisibility(ctx context.Context) { | 405 | func (a *App) updateTabBarVisibility(ctx context.Context) { | ||
| 406 | log := logging.FromContext(ctx) | 406 | log := logging.FromContext(ctx) | ||
| 407 | 407 | ||||
| 408 | + | // Debug: trace entry | |||
| 409 | + | hideEnabled := true | |||
| 410 | + | if a.deps.Config != nil { | |||
| 411 | + | hideEnabled = a.deps.Config.Workspace.HideTabBarWhenSingleTab | |||
| 412 | + | } | |||
| 413 | + | log.Debug().Bool("hide_enabled", hideEnabled).Msg("updateTabBarVisibility called") | |||
| 414 | + | ||||
| 408 | // Check if feature is enabled | 415 | // Check if feature is enabled | ||
| 409 | if a.deps.Config != nil && !a.deps.Config.Workspace.HideTabBarWhenSingleTab { | 416 | if a.deps.Config != nil && !a.deps.Config.Workspace.HideTabBarWhenSingleTab { | ||
| 417 | + | log.Debug().Msg("tab bar auto-hide disabled by config") | |||
| 410 | return | 418 | return | ||
| 411 | } | 419 | } | ||
| 412 | 420 | ||||
| 413 | - | if a.mainWindow == nil || a.mainWindow.TabBar() == nil { | 421 | + | if a.mainWindow == nil { |
| 422 | + | log.Debug().Msg("mainWindow is nil, skipping visibility update") | |||
| 423 | + | return | |||
| 424 | + | } | |||
| 425 | + | if a.mainWindow.TabBar() == nil { | |||
| 426 | + | log.Debug().Msg("tabBar is nil, skipping visibility update") | |||
| 414 | return | 427 | return | ||
| 415 | } | 428 | } | ||
| 416 | 429 | ||||
| 417 | tabCount := a.tabs.Count() | 430 | tabCount := a.tabs.Count() | ||
| 418 | shouldShow := tabCount > 1 | 431 | shouldShow := tabCount > 1 | ||
| 419 | 432 | ||||
| 433 | + | log.Debug().Int("tab_count", tabCount).Bool("should_show", shouldShow).Msg("setting tab bar visibility") | |||
| 420 | a.mainWindow.TabBar().SetVisible(shouldShow) | 434 | a.mainWindow.TabBar().SetVisible(shouldShow) | ||
| 421 | - | ||||
| 422 | - | if shouldShow { | |||
| 423 | - | log.Debug().Int("tab_count", tabCount).Msg("tab bar visible") | |||
| 424 | - | } else { | |||
| 425 | - | log.Debug().Msg("tab bar hidden (single tab)") | |||
| 426 | - | } | |||
| 427 | } | 435 | } | ||
| 428 | 436 | ||||
| 429 | // handleNextTab switches to the next tab. | 437 | // handleNextTab switches to the next tab. | ||
M internal/ui/component/tab_bar.go +3 -0
| @@ -159,6 +159,9 @@ func (tb *TabBar) ActiveTabID() entity.TabID { | |||
| 159 | 159 | ||
| 160 | 160 | // SetVisible shows or hides the tab bar. | |
| 161 | 161 | func (tb *TabBar) SetVisible(visible bool) { | |
| 162 | + | if tb.box == nil { | |
| 163 | + | return | |
| 164 | + | } | |
| 162 | 165 | tb.box.SetVisible(visible) | |
| 163 | 166 | } | |
| 164 | 167 | ||
| @@ -159,6 +159,9 @@ func (tb *TabBar) ActiveTabID() entity.TabID { | |||||
| 159 | 159 | ||||
| 160 | // SetVisible shows or hides the tab bar. | 160 | // SetVisible shows or hides the tab bar. | ||
| 161 | func (tb *TabBar) SetVisible(visible bool) { | 161 | func (tb *TabBar) SetVisible(visible bool) { | ||
| 162 | + | if tb.box == nil { | |||
| 163 | + | return | |||
| 164 | + | } | |||
| 162 | tb.box.SetVisible(visible) | 165 | tb.box.SetVisible(visible) | ||
| 163 | } | 166 | } | ||
| 164 | 167 | ||||