refactor(ui): replace webkit fields in Dependencies with Engine
Replace concrete webkit fields (WebContext, Pool, Factory, Settings, Injector, MessageRouter) in ui.Dependencies with a single Engine port.Engine field. Add engine/wkEngine fields to App struct with a type assertion to *webkit.Engine for webkit-specific operations. FilterManager kept in deps pending port.FilterApplier integration.
- commit
- f36a1c533aafa00ecf99f31922ecef081afdb58a
- author
- brice · · 2026-03-15 16:41 UTC
- parent
- 4f0e3ae
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
3 files · +28 -26
M cmd/dumber/main.go +2 -7
| @@ -514,8 +514,7 @@ func buildUIDependencies( | |||
| 514 | 514 | currentSessionID entity.SessionID, | |
| 515 | 515 | startupCrashReports []string, | |
| 516 | 516 | ) *ui.Dependencies { | |
| 517 | - | // Type-assert to *webkit.Engine to access concrete types for ui.Dependencies. | |
| 518 | - | // This bridge will be removed when ui.Dependencies is updated to use port.Engine (M4). | |
| 517 | + | // Type-assert to *webkit.Engine to access FilterManager (not yet on port.Engine). | |
| 519 | 518 | wkEngine := engine.(*webkit.Engine) | |
| 520 | 519 | ||
| 521 | 520 | return &ui.Dependencies{ | |
| @@ -528,11 +527,7 @@ func buildUIDependencies( | |||
| 528 | 527 | ColorResolver: colorResolver, | |
| 529 | 528 | AdwaitaDetector: adwaitaDetector, | |
| 530 | 529 | XDG: xdg.New(), | |
| 531 | - | WebContext: wkEngine.InternalContext(), | |
| 532 | - | Pool: wkEngine.InternalPool(), | |
| 533 | - | Settings: wkEngine.InternalSettings(), | |
| 534 | - | Injector: wkEngine.InternalInjector(), | |
| 535 | - | MessageRouter: wkEngine.InternalMessageRouter(), | |
| 530 | + | Engine: engine, | |
| 536 | 531 | FilterManager: wkEngine.InternalFilterManager(), | |
| 537 | 532 | HistoryRepo: repos.history, | |
| 538 | 533 | FavoriteRepo: repos.favorite, | |
| @@ -514,8 +514,7 @@ func buildUIDependencies( | |||||
| 514 | currentSessionID entity.SessionID, | 514 | currentSessionID entity.SessionID, | ||
| 515 | startupCrashReports []string, | 515 | startupCrashReports []string, | ||
| 516 | ) *ui.Dependencies { | 516 | ) *ui.Dependencies { | ||
| 517 | - | // Type-assert to *webkit.Engine to access concrete types for ui.Dependencies. | 517 | + | // Type-assert to *webkit.Engine to access FilterManager (not yet on port.Engine). |
| 518 | - | // This bridge will be removed when ui.Dependencies is updated to use port.Engine (M4). | |||
| 519 | wkEngine := engine.(*webkit.Engine) | 518 | wkEngine := engine.(*webkit.Engine) | ||
| 520 | 519 | ||||
| 521 | return &ui.Dependencies{ | 520 | return &ui.Dependencies{ | ||
| @@ -528,11 +527,7 @@ func buildUIDependencies( | |||||
| 528 | ColorResolver: colorResolver, | 527 | ColorResolver: colorResolver, | ||
| 529 | AdwaitaDetector: adwaitaDetector, | 528 | AdwaitaDetector: adwaitaDetector, | ||
| 530 | XDG: xdg.New(), | 529 | XDG: xdg.New(), | ||
| 531 | - | WebContext: wkEngine.InternalContext(), | 530 | + | Engine: engine, |
| 532 | - | Pool: wkEngine.InternalPool(), | |||
| 533 | - | Settings: wkEngine.InternalSettings(), | |||
| 534 | - | Injector: wkEngine.InternalInjector(), | |||
| 535 | - | MessageRouter: wkEngine.InternalMessageRouter(), | |||
| 536 | FilterManager: wkEngine.InternalFilterManager(), | 531 | FilterManager: wkEngine.InternalFilterManager(), | ||
| 537 | HistoryRepo: repos.history, | 532 | HistoryRepo: repos.history, | ||
| 538 | FavoriteRepo: repos.favorite, | 533 | FavoriteRepo: repos.favorite, | ||
M internal/ui/app.go +24 -11
| @@ -99,6 +99,10 @@ type App struct { | |||
| 99 | 99 | // Floating pane sessions keyed by tab and profile session ID. | |
| 100 | 100 | floatingSessions map[floatingSessionKey]*floatingWorkspaceSession | |
| 101 | 101 | ||
| 102 | + | // Engine (port-level and concrete for webkit-specific operations) | |
| 103 | + | engine port.Engine | |
| 104 | + | wkEngine *webkit.Engine | |
| 105 | + | ||
| 102 | 106 | // Web content (managed by ContentCoordinator) | |
| 103 | 107 | pool *webkit.WebViewPool | |
| 104 | 108 | webViewFactory *webkit.WebViewFactory | |
| @@ -179,13 +183,18 @@ func New(deps *Dependencies) (*App, error) { | |||
| 179 | 183 | panesUC: deps.PanesUC, | |
| 180 | 184 | workspaceViews: make(map[entity.TabID]*component.WorkspaceView), | |
| 181 | 185 | floatingSessions: make(map[floatingSessionKey]*floatingWorkspaceSession), | |
| 182 | - | pool: deps.Pool, | |
| 183 | - | injector: deps.Injector, | |
| 184 | - | router: deps.MessageRouter, | |
| 185 | - | settings: deps.Settings, | |
| 186 | + | engine: deps.Engine, | |
| 186 | 187 | configManager: config.GetManager(), | |
| 187 | 188 | cancel: cancel, | |
| 188 | 189 | } | |
| 190 | + | // Type-assert engine to concrete *webkit.Engine for webkit-specific operations. | |
| 191 | + | if wke, ok := deps.Engine.(*webkit.Engine); ok { | |
| 192 | + | app.wkEngine = wke | |
| 193 | + | app.pool = wke.InternalPool() | |
| 194 | + | app.injector = wke.InternalInjector() | |
| 195 | + | app.router = wke.InternalMessageRouter() | |
| 196 | + | app.settings = wke.InternalSettings() | |
| 197 | + | } | |
| 189 | 198 | if app.router == nil { | |
| 190 | 199 | app.router = webkit.NewMessageRouter(ctx) | |
| 191 | 200 | } | |
| @@ -563,7 +572,7 @@ func (a *App) registerAccentHandlers(ctx context.Context) { | |||
| 563 | 572 | func (a *App) initDownloadHandler(ctx context.Context) { | |
| 564 | 573 | log := logging.FromContext(ctx) | |
| 565 | 574 | ||
| 566 | - | if a.deps == nil || a.deps.WebContext == nil { | |
| 575 | + | if a.deps == nil || a.wkEngine == nil { | |
| 567 | 576 | log.Debug().Msg("WebContext not available, skipping download handler") | |
| 568 | 577 | return | |
| 569 | 578 | } | |
| @@ -599,7 +608,7 @@ func (a *App) initDownloadHandler(ctx context.Context) { | |||
| 599 | 608 | ||
| 600 | 609 | // Create and wire the download handler. | |
| 601 | 610 | handler := webkit.NewDownloadHandler(downloadPath, eventAdapter, prepareDownloadUC) | |
| 602 | - | a.deps.WebContext.SetDownloadHandler(ctx, handler) | |
| 611 | + | a.wkEngine.InternalContext().SetDownloadHandler(ctx, handler) | |
| 603 | 612 | ||
| 604 | 613 | log.Info().Str("path", downloadPath).Msg("download handler initialized") | |
| 605 | 614 | } | |
| @@ -1482,8 +1491,8 @@ func (a *App) onShutdown(ctx context.Context) { | |||
| 1482 | 1491 | for _, tabID := range tabIDs { | |
| 1483 | 1492 | a.releaseFloatingSessionsForTab(ctx, tabID) | |
| 1484 | 1493 | } | |
| 1485 | - | if a.deps.Pool != nil { | |
| 1486 | - | a.deps.Pool.Close(ctx) | |
| 1494 | + | if a.pool != nil { | |
| 1495 | + | a.pool.Close(ctx) | |
| 1487 | 1496 | } | |
| 1488 | 1497 | // Close idle inhibitor to release D-Bus connection | |
| 1489 | 1498 | if a.deps.IdleInhibitor != nil { | |
| @@ -1507,8 +1516,8 @@ func (a *App) initCoordinators(ctx context.Context) { | |||
| 1507 | 1516 | ||
| 1508 | 1517 | // Create FaviconAdapter with service and WebKit FaviconDatabase | |
| 1509 | 1518 | var faviconDB *webkit.FaviconDatabase | |
| 1510 | - | if a.deps.WebContext != nil { | |
| 1511 | - | faviconDB = a.deps.WebContext.FaviconDatabase() | |
| 1519 | + | if a.wkEngine != nil { | |
| 1520 | + | faviconDB = a.wkEngine.InternalContext().FaviconDatabase() | |
| 1512 | 1521 | } | |
| 1513 | 1522 | a.faviconAdapter = adapter.NewFaviconAdapter(a.deps.FaviconService, faviconDB) | |
| 1514 | 1523 | ||
| @@ -1592,8 +1601,12 @@ func (a *App) initCoordinators(ctx context.Context) { | |||
| 1592 | 1601 | a.wsCoord.SetOnStateChanged(a.MarkDirty) | |
| 1593 | 1602 | ||
| 1594 | 1603 | // Wire popup handling | |
| 1604 | + | var wkCtx *webkit.WebKitContext | |
| 1605 | + | if a.wkEngine != nil { | |
| 1606 | + | wkCtx = a.wkEngine.InternalContext() | |
| 1607 | + | } | |
| 1595 | 1608 | a.webViewFactory = webkit.NewWebViewFactory( | |
| 1596 | - | a.deps.WebContext, | |
| 1609 | + | wkCtx, | |
| 1597 | 1610 | a.settings, | |
| 1598 | 1611 | a.pool, | |
| 1599 | 1612 | a.injector, | |
| @@ -99,6 +99,10 @@ type App struct { | |||||
| 99 | // Floating pane sessions keyed by tab and profile session ID. | 99 | // Floating pane sessions keyed by tab and profile session ID. | ||
| 100 | floatingSessions map[floatingSessionKey]*floatingWorkspaceSession | 100 | floatingSessions map[floatingSessionKey]*floatingWorkspaceSession | ||
| 101 | 101 | ||||
| 102 | + | // Engine (port-level and concrete for webkit-specific operations) | |||
| 103 | + | engine port.Engine | |||
| 104 | + | wkEngine *webkit.Engine | |||
| 105 | + | ||||
| 102 | // Web content (managed by ContentCoordinator) | 106 | // Web content (managed by ContentCoordinator) | ||
| 103 | pool *webkit.WebViewPool | 107 | pool *webkit.WebViewPool | ||
| 104 | webViewFactory *webkit.WebViewFactory | 108 | webViewFactory *webkit.WebViewFactory | ||
| @@ -179,13 +183,18 @@ func New(deps *Dependencies) (*App, error) { | |||||
| 179 | panesUC: deps.PanesUC, | 183 | panesUC: deps.PanesUC, | ||
| 180 | workspaceViews: make(map[entity.TabID]*component.WorkspaceView), | 184 | workspaceViews: make(map[entity.TabID]*component.WorkspaceView), | ||
| 181 | floatingSessions: make(map[floatingSessionKey]*floatingWorkspaceSession), | 185 | floatingSessions: make(map[floatingSessionKey]*floatingWorkspaceSession), | ||
| 182 | - | pool: deps.Pool, | 186 | + | engine: deps.Engine, |
| 183 | - | injector: deps.Injector, | |||
| 184 | - | router: deps.MessageRouter, | |||
| 185 | - | settings: deps.Settings, | |||
| 186 | configManager: config.GetManager(), | 187 | configManager: config.GetManager(), | ||
| 187 | cancel: cancel, | 188 | cancel: cancel, | ||
| 188 | } | 189 | } | ||
| 190 | + | // Type-assert engine to concrete *webkit.Engine for webkit-specific operations. | |||
| 191 | + | if wke, ok := deps.Engine.(*webkit.Engine); ok { | |||
| 192 | + | app.wkEngine = wke | |||
| 193 | + | app.pool = wke.InternalPool() | |||
| 194 | + | app.injector = wke.InternalInjector() | |||
| 195 | + | app.router = wke.InternalMessageRouter() | |||
| 196 | + | app.settings = wke.InternalSettings() | |||
| 197 | + | } | |||
| 189 | if app.router == nil { | 198 | if app.router == nil { | ||
| 190 | app.router = webkit.NewMessageRouter(ctx) | 199 | app.router = webkit.NewMessageRouter(ctx) | ||
| 191 | } | 200 | } | ||
| @@ -563,7 +572,7 @@ func (a *App) registerAccentHandlers(ctx context.Context) { | |||||
| 563 | func (a *App) initDownloadHandler(ctx context.Context) { | 572 | func (a *App) initDownloadHandler(ctx context.Context) { | ||
| 564 | log := logging.FromContext(ctx) | 573 | log := logging.FromContext(ctx) | ||
| 565 | 574 | ||||
| 566 | - | if a.deps == nil || a.deps.WebContext == nil { | 575 | + | if a.deps == nil || a.wkEngine == nil { |
| 567 | log.Debug().Msg("WebContext not available, skipping download handler") | 576 | log.Debug().Msg("WebContext not available, skipping download handler") | ||
| 568 | return | 577 | return | ||
| 569 | } | 578 | } | ||
| @@ -599,7 +608,7 @@ func (a *App) initDownloadHandler(ctx context.Context) { | |||||
| 599 | 608 | ||||
| 600 | // Create and wire the download handler. | 609 | // Create and wire the download handler. | ||
| 601 | handler := webkit.NewDownloadHandler(downloadPath, eventAdapter, prepareDownloadUC) | 610 | handler := webkit.NewDownloadHandler(downloadPath, eventAdapter, prepareDownloadUC) | ||
| 602 | - | a.deps.WebContext.SetDownloadHandler(ctx, handler) | 611 | + | a.wkEngine.InternalContext().SetDownloadHandler(ctx, handler) |
| 603 | 612 | ||||
| 604 | log.Info().Str("path", downloadPath).Msg("download handler initialized") | 613 | log.Info().Str("path", downloadPath).Msg("download handler initialized") | ||
| 605 | } | 614 | } | ||
| @@ -1482,8 +1491,8 @@ func (a *App) onShutdown(ctx context.Context) { | |||||
| 1482 | for _, tabID := range tabIDs { | 1491 | for _, tabID := range tabIDs { | ||
| 1483 | a.releaseFloatingSessionsForTab(ctx, tabID) | 1492 | a.releaseFloatingSessionsForTab(ctx, tabID) | ||
| 1484 | } | 1493 | } | ||
| 1485 | - | if a.deps.Pool != nil { | 1494 | + | if a.pool != nil { |
| 1486 | - | a.deps.Pool.Close(ctx) | 1495 | + | a.pool.Close(ctx) |
| 1487 | } | 1496 | } | ||
| 1488 | // Close idle inhibitor to release D-Bus connection | 1497 | // Close idle inhibitor to release D-Bus connection | ||
| 1489 | if a.deps.IdleInhibitor != nil { | 1498 | if a.deps.IdleInhibitor != nil { | ||
| @@ -1507,8 +1516,8 @@ func (a *App) initCoordinators(ctx context.Context) { | |||||
| 1507 | 1516 | ||||
| 1508 | // Create FaviconAdapter with service and WebKit FaviconDatabase | 1517 | // Create FaviconAdapter with service and WebKit FaviconDatabase | ||
| 1509 | var faviconDB *webkit.FaviconDatabase | 1518 | var faviconDB *webkit.FaviconDatabase | ||
| 1510 | - | if a.deps.WebContext != nil { | 1519 | + | if a.wkEngine != nil { |
| 1511 | - | faviconDB = a.deps.WebContext.FaviconDatabase() | 1520 | + | faviconDB = a.wkEngine.InternalContext().FaviconDatabase() |
| 1512 | } | 1521 | } | ||
| 1513 | a.faviconAdapter = adapter.NewFaviconAdapter(a.deps.FaviconService, faviconDB) | 1522 | a.faviconAdapter = adapter.NewFaviconAdapter(a.deps.FaviconService, faviconDB) | ||
| 1514 | 1523 | ||||
| @@ -1592,8 +1601,12 @@ func (a *App) initCoordinators(ctx context.Context) { | |||||
| 1592 | a.wsCoord.SetOnStateChanged(a.MarkDirty) | 1601 | a.wsCoord.SetOnStateChanged(a.MarkDirty) | ||
| 1593 | 1602 | ||||
| 1594 | // Wire popup handling | 1603 | // Wire popup handling | ||
| 1604 | + | var wkCtx *webkit.WebKitContext | |||
| 1605 | + | if a.wkEngine != nil { | |||
| 1606 | + | wkCtx = a.wkEngine.InternalContext() | |||
| 1607 | + | } | |||
| 1595 | a.webViewFactory = webkit.NewWebViewFactory( | 1608 | a.webViewFactory = webkit.NewWebViewFactory( | ||
| 1596 | - | a.deps.WebContext, | 1609 | + | wkCtx, |
| 1597 | a.settings, | 1610 | a.settings, | ||
| 1598 | a.pool, | 1611 | a.pool, | ||
| 1599 | a.injector, | 1612 | a.injector, | ||
M internal/ui/deps.go +2 -8
| @@ -12,7 +12,6 @@ import ( | |||
| 12 | 12 | "github.com/bnema/dumber/internal/infrastructure/config" | |
| 13 | 13 | "github.com/bnema/dumber/internal/infrastructure/favicon" | |
| 14 | 14 | "github.com/bnema/dumber/internal/infrastructure/filtering" | |
| 15 | - | "github.com/bnema/dumber/internal/infrastructure/webkit" | |
| 16 | 15 | "github.com/bnema/dumber/internal/ui/theme" | |
| 17 | 16 | ) | |
| 18 | 17 | ||
| @@ -37,13 +36,8 @@ type Dependencies struct { | |||
| 37 | 36 | // XDG paths | |
| 38 | 37 | XDG port.XDGPaths | |
| 39 | 38 | ||
| 40 | - | // WebKit infrastructure | |
| 41 | - | WebContext *webkit.WebKitContext | |
| 42 | - | Pool *webkit.WebViewPool | |
| 43 | - | Factory port.WebViewFactory | |
| 44 | - | Settings *webkit.SettingsManager | |
| 45 | - | Injector *webkit.ContentInjector | |
| 46 | - | MessageRouter *webkit.MessageRouter | |
| 39 | + | // Engine (replaces individual webkit fields) | |
| 40 | + | Engine port.Engine | |
| 47 | 41 | ||
| 48 | 42 | // Repositories | |
| 49 | 43 | HistoryRepo repository.HistoryRepository | |
| @@ -12,7 +12,6 @@ import ( | |||||
| 12 | "github.com/bnema/dumber/internal/infrastructure/config" | 12 | "github.com/bnema/dumber/internal/infrastructure/config" | ||
| 13 | "github.com/bnema/dumber/internal/infrastructure/favicon" | 13 | "github.com/bnema/dumber/internal/infrastructure/favicon" | ||
| 14 | "github.com/bnema/dumber/internal/infrastructure/filtering" | 14 | "github.com/bnema/dumber/internal/infrastructure/filtering" | ||
| 15 | - | "github.com/bnema/dumber/internal/infrastructure/webkit" | |||
| 16 | "github.com/bnema/dumber/internal/ui/theme" | 15 | "github.com/bnema/dumber/internal/ui/theme" | ||
| 17 | ) | 16 | ) | ||
| 18 | 17 | ||||
| @@ -37,13 +36,8 @@ type Dependencies struct { | |||||
| 37 | // XDG paths | 36 | // XDG paths | ||
| 38 | XDG port.XDGPaths | 37 | XDG port.XDGPaths | ||
| 39 | 38 | ||||
| 40 | - | // WebKit infrastructure | 39 | + | // Engine (replaces individual webkit fields) |
| 41 | - | WebContext *webkit.WebKitContext | 40 | + | Engine port.Engine |
| 42 | - | Pool *webkit.WebViewPool | |||
| 43 | - | Factory port.WebViewFactory | |||
| 44 | - | Settings *webkit.SettingsManager | |||
| 45 | - | Injector *webkit.ContentInjector | |||
| 46 | - | MessageRouter *webkit.MessageRouter | |||
| 47 | 41 | ||||
| 48 | // Repositories | 42 | // Repositories | ||
| 49 | HistoryRepo repository.HistoryRepository | 43 | HistoryRepo repository.HistoryRepository | ||