recent_route_snapshot.go RawHistoryFolder

1package daemon
2
3import (
4	"github.com/bnema/vev/internal/domain"
5	"github.com/bnema/vev/internal/protocol"
6)
7
8func activeRouteEntryForLifecycle(snapshot protocol.RecentRouteSnapshot, lifecycle domain.SessionLifecycleID) (protocol.RecentRouteEntry, bool) {
9	active := snapshot.ActiveEntry
10	activeRef := protocol.RouteRef{Key: active.Key, Generation: active.Generation}
11	if lifecycle == (domain.SessionLifecycleID{}) || active.Target.LifecycleID != lifecycle || snapshot.Active != activeRef {
12		return protocol.RecentRouteEntry{}, false
13	}
14	return active, true
15}
16
17func recentRoutePresentationsFromSnapshot(snapshot protocol.RecentRouteSnapshot) []recentRoutePresentation {
18	if snapshot.Entries == nil {
19		return nil
20	}
21	out := make([]recentRoutePresentation, len(snapshot.Entries))
22	for i, entry := range snapshot.Entries {
23		kind := recentRouteLocal
24		if entry.Kind == protocol.RouteKindRemote {
25			kind = recentRouteRemote
26		}
27		out[i] = recentRoutePresentation{
28			name:      entry.Name,
29			hostLabel: domain.RemoteDisplayOrigin(entry.HostLabel),
30			kind:      kind,
31			ephemeral: entry.Ephemeral,
32			attention: entry.Attention,
33		}
34	}
35	return out
36}
37
38// historyRouteSnapshot keeps the routes the status-bar history and
39// jump-recent ranks show: every route this client attached to, plus every
40// route that rings. Attention is shared by all clients, so a fresh client
41// still sees a bell on a session it never visited. Visited routes lead the
42// snapshot, so their ranks are unaffected by ringing ones. The palette and
43// attention jumps keep the full snapshot.
44func historyRouteSnapshot(snapshot protocol.RecentRouteSnapshot) protocol.RecentRouteSnapshot {
45	if snapshot.Entries == nil {
46		return snapshot
47	}
48	history := make([]protocol.RecentRouteEntry, 0, len(snapshot.Entries))
49	for _, entry := range snapshot.Entries {
50		if entry.Visited || entry.Attention {
51			history = append(history, entry)
52		}
53	}
54	snapshot.Entries = history
55	return snapshot
56}
57
58func formatRecentRouteSnapshot(snapshot protocol.RecentRouteSnapshot) []recentRouteDisplay {
59	return formatRecentRoutePresentations(recentRoutePresentationsFromSnapshot(snapshot))
60}

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 12

Tags 11

↑↓ moveenter openesc close