detached 4cbf000

refactor(coordinator): decouple navigation.go and tab.go from webkit

commit
4cbf000ca6b87a02de8ed855e7b526694f1d1881
author
brice · · 2026-03-15 16:44 UTC
parent
bcab118
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +13 -13
M internal/ui/coordinator/navigation.go +8 -8
@@ -5,9 +5,9 @@ import (
55 "fmt"
66 "time"
77
8+ "github.com/bnema/dumber/internal/application/port"
89 "github.com/bnema/dumber/internal/application/usecase"
910 "github.com/bnema/dumber/internal/domain/entity"
10- "github.com/bnema/dumber/internal/infrastructure/webkit"
1111 "github.com/bnema/dumber/internal/logging"
1212 )
1313
@@ -210,9 +210,9 @@ func (c *NavigationCoordinator) OpenDevTools(ctx context.Context) error {
210210
211211 log.Debug().Uint64("webview_id", uint64(wv.ID())).Msg("opening devtools")
212212
213- // Type assert to access ShowDevTools (not in port.WebView interface)
214- if webkitWV, ok := interface{}(wv).(*webkit.WebView); ok {
215- return webkitWV.ShowDevTools()
213+ if opener, ok := wv.(port.DevToolsOpener); ok {
214+ opener.OpenDevTools()
215+ return nil
216216 }
217217
218218 return fmt.Errorf("webview does not support devtools")
@@ -230,9 +230,9 @@ func (c *NavigationCoordinator) PrintPage(ctx context.Context) error {
230230
231231 log.Debug().Uint64("webview_id", uint64(wv.ID())).Msg("opening print dialog")
232232
233- // Type assert to access Print (not in port.WebView interface)
234- if webkitWV, ok := interface{}(wv).(*webkit.WebView); ok {
235- return webkitWV.Print()
233+ if printer, ok := wv.(port.Printer); ok {
234+ printer.PrintPage()
235+ return nil
236236 }
237237
238238 return fmt.Errorf("webview does not support printing")
@@ -269,7 +269,7 @@ func (c *NavigationCoordinator) ClearPaneHistory(paneID entity.PaneID) {
269269 }
270270
271271 // ActiveWebView returns the WebView for the active pane (for zoom operations).
272-func (c *NavigationCoordinator) ActiveWebView(ctx context.Context) *webkit.WebView {
272+func (c *NavigationCoordinator) ActiveWebView(ctx context.Context) port.WebView {
273273 return c.contentCoord.ActiveWebView(ctx)
274274 }
275275
@@ -5,9 +5,9 @@ import (
5 "fmt"5 "fmt"
6 "time"6 "time"
7 7
8+ "github.com/bnema/dumber/internal/application/port"
8 "github.com/bnema/dumber/internal/application/usecase"9 "github.com/bnema/dumber/internal/application/usecase"
9 "github.com/bnema/dumber/internal/domain/entity"10 "github.com/bnema/dumber/internal/domain/entity"
10- "github.com/bnema/dumber/internal/infrastructure/webkit"
11 "github.com/bnema/dumber/internal/logging"11 "github.com/bnema/dumber/internal/logging"
12 )12 )
13 13
@@ -210,9 +210,9 @@ func (c *NavigationCoordinator) OpenDevTools(ctx context.Context) error {
210 210
211 log.Debug().Uint64("webview_id", uint64(wv.ID())).Msg("opening devtools")211 log.Debug().Uint64("webview_id", uint64(wv.ID())).Msg("opening devtools")
212 212
213- // Type assert to access ShowDevTools (not in port.WebView interface)213+ if opener, ok := wv.(port.DevToolsOpener); ok {
214- if webkitWV, ok := interface{}(wv).(*webkit.WebView); ok {214+ opener.OpenDevTools()
215- return webkitWV.ShowDevTools()215+ return nil
216 }216 }
217 217
218 return fmt.Errorf("webview does not support devtools")218 return fmt.Errorf("webview does not support devtools")
@@ -230,9 +230,9 @@ func (c *NavigationCoordinator) PrintPage(ctx context.Context) error {
230 230
231 log.Debug().Uint64("webview_id", uint64(wv.ID())).Msg("opening print dialog")231 log.Debug().Uint64("webview_id", uint64(wv.ID())).Msg("opening print dialog")
232 232
233- // Type assert to access Print (not in port.WebView interface)233+ if printer, ok := wv.(port.Printer); ok {
234- if webkitWV, ok := interface{}(wv).(*webkit.WebView); ok {234+ printer.PrintPage()
235- return webkitWV.Print()235+ return nil
236 }236 }
237 237
238 return fmt.Errorf("webview does not support printing")238 return fmt.Errorf("webview does not support printing")
@@ -269,7 +269,7 @@ func (c *NavigationCoordinator) ClearPaneHistory(paneID entity.PaneID) {
269 }269 }
270 270
271 // ActiveWebView returns the WebView for the active pane (for zoom operations).271 // ActiveWebView returns the WebView for the active pane (for zoom operations).
272-func (c *NavigationCoordinator) ActiveWebView(ctx context.Context) *webkit.WebView {272+func (c *NavigationCoordinator) ActiveWebView(ctx context.Context) port.WebView {
273 return c.contentCoord.ActiveWebView(ctx)273 return c.contentCoord.ActiveWebView(ctx)
274 }274 }
275 275
M internal/ui/coordinator/tab.go +5 -5
@@ -3,10 +3,10 @@ package coordinator
33 import (
44 "context"
55
6+ "github.com/bnema/dumber/internal/application/port"
67 "github.com/bnema/dumber/internal/application/usecase"
78 "github.com/bnema/dumber/internal/domain/entity"
89 "github.com/bnema/dumber/internal/infrastructure/config"
9- "github.com/bnema/dumber/internal/infrastructure/webkit"
1010 "github.com/bnema/dumber/internal/logging"
1111 "github.com/bnema/dumber/internal/ui/component"
1212 "github.com/bnema/dumber/internal/ui/window"
@@ -23,8 +23,8 @@ type TabCoordinator struct {
2323 onTabCreated func(ctx context.Context, tab *entity.Tab)
2424 onTabSwitched func(ctx context.Context, tab *entity.Tab)
2525 onQuit func()
26- onAttachPopupToTab func(ctx context.Context, tabID entity.TabID, pane *entity.Pane, wv *webkit.WebView) // For popup tabs
27- onStateChanged func() // For session snapshots
26+ onAttachPopupToTab func(ctx context.Context, tabID entity.TabID, pane *entity.Pane, wv port.WebView) // For popup tabs
27+ onStateChanged func() // For session snapshots
2828 }
2929
3030 // TabCoordinatorConfig holds configuration for TabCoordinator.
@@ -335,7 +335,7 @@ func (c *TabCoordinator) GetTabBar() *component.TabBar {
335335 }
336336
337337 // SetOnAttachPopupToTab sets the callback for attaching popup WebViews to tabs.
338-func (c *TabCoordinator) SetOnAttachPopupToTab(fn func(ctx context.Context, tabID entity.TabID, pane *entity.Pane, wv *webkit.WebView)) {
338+func (c *TabCoordinator) SetOnAttachPopupToTab(fn func(ctx context.Context, tabID entity.TabID, pane *entity.Pane, wv port.WebView)) {
339339 c.onAttachPopupToTab = fn
340340 }
341341
@@ -344,7 +344,7 @@ func (c *TabCoordinator) SetOnAttachPopupToTab(fn func(ctx context.Context, tabI
344344 func (c *TabCoordinator) CreateWithPane(
345345 ctx context.Context,
346346 pane *entity.Pane,
347- wv *webkit.WebView,
347+ wv port.WebView,
348348 initialURL string,
349349 ) (*entity.Tab, error) {
350350 log := logging.FromContext(ctx)
@@ -3,10 +3,10 @@ package coordinator
3 import (3 import (
4 "context"4 "context"
5 5
6+ "github.com/bnema/dumber/internal/application/port"
6 "github.com/bnema/dumber/internal/application/usecase"7 "github.com/bnema/dumber/internal/application/usecase"
7 "github.com/bnema/dumber/internal/domain/entity"8 "github.com/bnema/dumber/internal/domain/entity"
8 "github.com/bnema/dumber/internal/infrastructure/config"9 "github.com/bnema/dumber/internal/infrastructure/config"
9- "github.com/bnema/dumber/internal/infrastructure/webkit"
10 "github.com/bnema/dumber/internal/logging"10 "github.com/bnema/dumber/internal/logging"
11 "github.com/bnema/dumber/internal/ui/component"11 "github.com/bnema/dumber/internal/ui/component"
12 "github.com/bnema/dumber/internal/ui/window"12 "github.com/bnema/dumber/internal/ui/window"
@@ -23,8 +23,8 @@ type TabCoordinator struct {
23 onTabCreated func(ctx context.Context, tab *entity.Tab)23 onTabCreated func(ctx context.Context, tab *entity.Tab)
24 onTabSwitched func(ctx context.Context, tab *entity.Tab)24 onTabSwitched func(ctx context.Context, tab *entity.Tab)
25 onQuit func()25 onQuit func()
26- onAttachPopupToTab func(ctx context.Context, tabID entity.TabID, pane *entity.Pane, wv *webkit.WebView) // For popup tabs26+ onAttachPopupToTab func(ctx context.Context, tabID entity.TabID, pane *entity.Pane, wv port.WebView) // For popup tabs
27- onStateChanged func() // For session snapshots27+ onStateChanged func() // For session snapshots
28 }28 }
29 29
30 // TabCoordinatorConfig holds configuration for TabCoordinator.30 // TabCoordinatorConfig holds configuration for TabCoordinator.
@@ -335,7 +335,7 @@ func (c *TabCoordinator) GetTabBar() *component.TabBar {
335 }335 }
336 336
337 // SetOnAttachPopupToTab sets the callback for attaching popup WebViews to tabs.337 // SetOnAttachPopupToTab sets the callback for attaching popup WebViews to tabs.
338-func (c *TabCoordinator) SetOnAttachPopupToTab(fn func(ctx context.Context, tabID entity.TabID, pane *entity.Pane, wv *webkit.WebView)) {338+func (c *TabCoordinator) SetOnAttachPopupToTab(fn func(ctx context.Context, tabID entity.TabID, pane *entity.Pane, wv port.WebView)) {
339 c.onAttachPopupToTab = fn339 c.onAttachPopupToTab = fn
340 }340 }
341 341
@@ -344,7 +344,7 @@ func (c *TabCoordinator) SetOnAttachPopupToTab(fn func(ctx context.Context, tabI
344 func (c *TabCoordinator) CreateWithPane(344 func (c *TabCoordinator) CreateWithPane(
345 ctx context.Context,345 ctx context.Context,
346 pane *entity.Pane,346 pane *entity.Pane,
347- wv *webkit.WebView,347+ wv port.WebView,
348 initialURL string,348 initialURL string,
349 ) (*entity.Tab, error) {349 ) (*entity.Tab, error) {
350 log := logging.FromContext(ctx)350 log := logging.FromContext(ctx)

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close