chore(history): tighten sidebar host safeguards
- commit
- 933fcaf3cce76e4ead344d6c98a62e7579e1f97a
- author
- brice · · 2026-06-13 08:10 UTC
- parent
- a3edf91
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
3 files · +8 -0
M .mockery.yaml +1 -0
| @@ -65,6 +65,7 @@ packages: | |||
| 65 | 65 | EntryInputTarget: {} | |
| 66 | 66 | HomepageFavorites: {} | |
| 67 | 67 | HomepageHistory: {} | |
| 68 | + | HistorySidebarHistory: {} | |
| 68 | 69 | AllKeybindingsResetter: {} | |
| 69 | 70 | KeybindingResetter: {} | |
| 70 | 71 | KeybindingSetter: {} | |
| @@ -65,6 +65,7 @@ packages: | |||||
| 65 | EntryInputTarget: {} | 65 | EntryInputTarget: {} | ||
| 66 | HomepageFavorites: {} | 66 | HomepageFavorites: {} | ||
| 67 | HomepageHistory: {} | 67 | HomepageHistory: {} | ||
| 68 | + | HistorySidebarHistory: {} | |||
| 68 | AllKeybindingsResetter: {} | 69 | AllKeybindingsResetter: {} | ||
| 69 | KeybindingResetter: {} | 70 | KeybindingResetter: {} | ||
| 70 | KeybindingSetter: {} | 71 | KeybindingSetter: {} | ||
M internal/ui/window/main_window.go +3 -0
| @@ -199,6 +199,9 @@ func (mw *MainWindow) ContentArea() *gtk.Box { | |||
| 199 | 199 | // SetContent replaces the current content widget in the main content area | |
| 200 | 200 | // (the vertical box that holds workspace tab content). | |
| 201 | 201 | func (mw *MainWindow) SetContent(widget *gtk.Widget) { | |
| 202 | + | if mw == nil || mw.mainContentBox == nil { | |
| 203 | + | return | |
| 204 | + | } | |
| 202 | 205 | if mw.currentContent != nil { | |
| 203 | 206 | mw.mainContentBox.Remove(mw.currentContent) | |
| 204 | 207 | mw.currentContent = nil | |
| @@ -199,6 +199,9 @@ func (mw *MainWindow) ContentArea() *gtk.Box { | |||||
| 199 | // SetContent replaces the current content widget in the main content area | 199 | // SetContent replaces the current content widget in the main content area | ||
| 200 | // (the vertical box that holds workspace tab content). | 200 | // (the vertical box that holds workspace tab content). | ||
| 201 | func (mw *MainWindow) SetContent(widget *gtk.Widget) { | 201 | func (mw *MainWindow) SetContent(widget *gtk.Widget) { | ||
| 202 | + | if mw == nil || mw.mainContentBox == nil { | |||
| 203 | + | return | |||
| 204 | + | } | |||
| 202 | if mw.currentContent != nil { | 205 | if mw.currentContent != nil { | ||
| 203 | mw.mainContentBox.Remove(mw.currentContent) | 206 | mw.mainContentBox.Remove(mw.currentContent) | ||
| 204 | mw.currentContent = nil | 207 | mw.currentContent = nil | ||
M internal/ui/window/main_window_sidebar.go +4 -0
| @@ -41,6 +41,10 @@ func (mw *MainWindow) SetSidebarWidth(cfg SidebarWidthConfig) { | |||
| 41 | 41 | if cfg.WidthPx == 0 { | |
| 42 | 42 | cfg.WidthPx = defaults.WidthPx | |
| 43 | 43 | } | |
| 44 | + | if cfg.MinPx > cfg.MaxPx { | |
| 45 | + | mw.logger.Warn().Int("min_px", cfg.MinPx).Int("max_px", cfg.MaxPx).Msg("invalid sidebar width bounds; swapping") | |
| 46 | + | cfg.MinPx, cfg.MaxPx = cfg.MaxPx, cfg.MinPx | |
| 47 | + | } | |
| 44 | 48 | clamped := cfg.WidthPx | |
| 45 | 49 | if clamped < cfg.MinPx { | |
| 46 | 50 | clamped = cfg.MinPx | |
| @@ -41,6 +41,10 @@ func (mw *MainWindow) SetSidebarWidth(cfg SidebarWidthConfig) { | |||||
| 41 | if cfg.WidthPx == 0 { | 41 | if cfg.WidthPx == 0 { | ||
| 42 | cfg.WidthPx = defaults.WidthPx | 42 | cfg.WidthPx = defaults.WidthPx | ||
| 43 | } | 43 | } | ||
| 44 | + | if cfg.MinPx > cfg.MaxPx { | |||
| 45 | + | mw.logger.Warn().Int("min_px", cfg.MinPx).Int("max_px", cfg.MaxPx).Msg("invalid sidebar width bounds; swapping") | |||
| 46 | + | cfg.MinPx, cfg.MaxPx = cfg.MaxPx, cfg.MinPx | |||
| 47 | + | } | |||
| 44 | clamped := cfg.WidthPx | 48 | clamped := cfg.WidthPx | ||
| 45 | if clamped < cfg.MinPx { | 49 | if clamped < cfg.MinPx { | ||
| 46 | clamped = cfg.MinPx | 50 | clamped = cfg.MinPx | ||