main 5041353

navigate.go RawHistoryFolder

1package usecase
2
3import (
4	"context"
5	"fmt"
6	"math"
7
8	"github.com/bnema/dumber/internal/application/port"
9	"github.com/bnema/dumber/internal/domain/entity"
10	"github.com/bnema/dumber/internal/logging"
11)
12
13// NavigateUseCase handles URL navigation with zoom application.
14type NavigateUseCase struct {
15	defaultZoom float64
16}
17
18// NewNavigateUseCase creates a new navigation use case.
19// defaultZoom is the zoom level to use when no per-domain zoom is saved (typically from config).
20func NewNavigateUseCase(defaultZoom float64) *NavigateUseCase {
21	if defaultZoom <= 0 || math.IsNaN(defaultZoom) || math.IsInf(defaultZoom, 0) {
22		defaultZoom = entity.ZoomDefault
23	}
24
25	return &NavigateUseCase{defaultZoom: defaultZoom}
26}
27
28// NavigateInput contains parameters for navigation.
29type NavigateInput struct {
30	URL     string
31	PaneID  string
32	WebView port.PageNavigator
33}
34
35// NavigateOutput contains the result of navigation.
36type NavigateOutput struct {
37	AppliedZoom float64
38}
39
40// Execute navigates to a URL.
41// Zoom is applied later via LoadCommitted event in ContentCoordinator.
42func (uc *NavigateUseCase) Execute(ctx context.Context, input NavigateInput) (*NavigateOutput, error) {
43	log := logging.FromContext(ctx)
44	log.Debug().
45		Str("url", logging.RedactURL(input.URL)).
46		Str("pane_id", input.PaneID).
47		Msg("navigating to URL")
48
49	// Navigate to URL (zoom will be applied on LoadCommitted to avoid shift)
50	// History is recorded on LoadCommitted when URI is guaranteed correct
51	if err := input.WebView.LoadURI(ctx, input.URL); err != nil {
52		return nil, fmt.Errorf("failed to load URL: %w", err)
53	}
54
55	log.Info().
56		Str("url", logging.RedactURL(input.URL)).
57		Msg("navigation initiated")
58
59	return &NavigateOutput{
60		AppliedZoom: uc.defaultZoom,
61	}, nil
62}
63
64// Reload reloads the current page.
65func (uc *NavigateUseCase) Reload(ctx context.Context, webview port.PageNavigator, bypassCache bool) error {
66	log := logging.FromContext(ctx).With().Float64("default_zoom", uc.defaultZoom).Logger()
67	log.Debug().Bool("bypass_cache", bypassCache).Msg("reloading page")
68
69	if bypassCache {
70		return webview.ReloadBypassCache(ctx)
71	}
72	return webview.Reload(ctx)
73}
74
75// Stop stops the current page load.
76func (uc *NavigateUseCase) Stop(ctx context.Context, webview port.PageNavigator) error {
77	log := logging.FromContext(ctx).With().Float64("default_zoom", uc.defaultZoom).Logger()
78	log.Debug().Msg("stopping page load")
79	return webview.Stop(ctx)
80}

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