main 5041353

history_changes.go RawHistoryFolder

1package ui
2
3import (
4	"context"
5
6	"github.com/bnema/dumber/internal/application/dto"
7	"github.com/bnema/dumber/internal/application/port"
8	"github.com/bnema/dumber/internal/logging"
9)
10
11var _ port.HistoryChangeSink = (*historyChangeAdapter)(nil)
12
13type historySidebarReloader interface {
14	RequestReloadIfVisible(reason string)
15}
16
17type historyChangeAdapter struct {
18	app *App
19}
20
21func newHistoryChangeAdapter(app *App) *historyChangeAdapter {
22	return &historyChangeAdapter{app: app}
23}
24
25func (h *historyChangeAdapter) OnHistoryChanged(ctx context.Context, change dto.HistoryChange) {
26	if h == nil || h.app == nil {
27		return
28	}
29	app := h.app
30	run := func() {
31		app.refreshVisibleHistorySidebars(change)
32	}
33	if app.dispatchOnMainThread == nil {
34		logging.FromContext(ctx).Warn().
35			Msg("history sidebar refresh skipped: main-thread dispatcher unavailable")
36		return
37	}
38	result := app.dispatchOnMainThread("ui.history_sidebar_refresh", run)
39	if !result.Completed() {
40		logging.FromContext(ctx).Warn().
41			Str("status", string(result.Status)).
42			Dur("elapsed", result.Elapsed).
43			Msg("history sidebar refresh dispatch did not complete")
44	}
45}
46
47func (a *App) refreshVisibleHistorySidebars(change dto.HistoryChange) {
48	if a == nil {
49		return
50	}
51	reason := historyChangeReasonLabel(change)
52	for _, bw := range a.browserWindows {
53		if bw == nil || !bw.sidebarVisible {
54			continue
55		}
56		reloader := bw.historySidebarReloader
57		if reloader == nil {
58			reloader = bw.historySidebar
59		}
60		if reloader == nil {
61			continue
62		}
63		reloader.RequestReloadIfVisible(reason)
64	}
65}
66
67func historyChangeReasonLabel(change dto.HistoryChange) string {
68	if len(change.Reasons) == 0 {
69		return "history-change"
70	}
71	return string(change.Reasons[0])
72}

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