v0.21.0 73bf644

deps.go RawHistoryFolder

1// Package ui provides the GTK4 presentation layer for the dumber browser.
2package ui
3
4import (
5	"context"
6
7	"github.com/bnema/dumber/internal/application/port"
8	"github.com/bnema/dumber/internal/application/usecase"
9	"github.com/bnema/dumber/internal/domain/entity"
10	"github.com/bnema/dumber/internal/domain/repository"
11	"github.com/bnema/dumber/internal/infrastructure/config"
12	"github.com/bnema/dumber/internal/infrastructure/favicon"
13	"github.com/bnema/dumber/internal/infrastructure/filtering"
14	"github.com/bnema/dumber/internal/infrastructure/webkit"
15	"github.com/bnema/dumber/internal/ui/theme"
16)
17
18// Dependencies holds all injected dependencies for the UI layer.
19// This struct is created once at startup and passed to UI components.
20type Dependencies struct {
21	// Core context and configuration
22	Ctx              context.Context
23	Config           *config.Config
24	InitialURL       string // URL to open on startup (optional)
25	RestoreSessionID string // Session ID to restore on startup (optional)
26
27	// Theme management
28	Theme *theme.Manager
29
30	// WebKit infrastructure
31	WebContext    *webkit.WebKitContext
32	Pool          *webkit.WebViewPool
33	Factory       port.WebViewFactory
34	Settings      *webkit.SettingsManager
35	Injector      *webkit.ContentInjector
36	MessageRouter *webkit.MessageRouter
37
38	// Repositories
39	HistoryRepo  repository.HistoryRepository
40	FavoriteRepo repository.FavoriteRepository
41	ZoomRepo     repository.ZoomRepository
42	FilterRepo   repository.ContentWhitelistRepository
43
44	// Use Cases
45	TabsUC      *usecase.ManageTabsUseCase
46	PanesUC     *usecase.ManagePanesUseCase
47	NavigateUC  *usecase.NavigateUseCase
48	ZoomUC      *usecase.ManageZoomUseCase
49	FavoritesUC *usecase.ManageFavoritesUseCase
50	HistoryUC   *usecase.SearchHistoryUseCase
51	CopyURLUC   *usecase.CopyURLUseCase
52
53	// Infrastructure Adapters
54	Clipboard      port.Clipboard
55	FaviconService *favicon.Service
56	FilterManager  *filtering.Manager
57	IdleInhibitor  port.IdleInhibitor
58
59	// Session management
60	SessionStateRepo repository.SessionStateRepository
61	SessionRepo      repository.SessionRepository
62	CurrentSessionID entity.SessionID
63	SnapshotUC       *usecase.SnapshotSessionUseCase
64
65	// Update management
66	CheckUpdateUC *usecase.CheckUpdateUseCase
67	ApplyUpdateUC *usecase.ApplyUpdateUseCase
68}
69
70// Validate checks that all required dependencies are set.
71func (d *Dependencies) Validate() error {
72	if d.Ctx == nil {
73		return ErrMissingDependency("Ctx")
74	}
75	if d.Config == nil {
76		return ErrMissingDependency("Config")
77	}
78	// WebKit dependencies are optional for testing without WebViews
79	// Use cases are optional - can be nil if not needed
80	return nil
81}
82
83// DependencyError indicates a missing required dependency.
84type DependencyError struct {
85	Name string
86}
87
88func (e DependencyError) Error() string {
89	return "missing required dependency: " + e.Name
90}
91
92// ErrMissingDependency creates a new DependencyError.
93func ErrMissingDependency(name string) error {
94	return DependencyError{Name: name}
95}

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