v0.3.0 99dc266

reconnect.go RawHistoryFolder

1package client
2
3import (
4	"errors"
5	"time"
6
7	"github.com/bnema/vev/internal/ports"
8)
9
10type reconnectBackoff struct {
11	initial time.Duration
12	max     time.Duration
13}
14
15var defaultReconnectBackoff = reconnectBackoff{initial: 100 * time.Millisecond, max: 2 * time.Second}
16
17// errLinkOffline is returned by an attach attempt when the transport link reaches the
18// Offline state. It is retryable so Run re-dials over ssh with the resume token
19// at ~30s of silence instead of waiting the full Dead timeout at 60s.
20var errLinkOffline = errors.New("vev: link offline; reconnecting")
21
22type reconnectStage int
23
24const (
25	reconnectStageDegraded reconnectStage = iota
26	reconnectStageProbingUDP
27	reconnectStageSSH
28	reconnectStageOfflineRetrying
29)
30
31func stageForLinkState(state ports.LinkState) reconnectStage {
32	switch state {
33	case ports.LinkStateDegraded:
34		return reconnectStageDegraded
35	case ports.LinkStateProbing:
36		return reconnectStageProbingUDP
37	case ports.LinkStateOffline, ports.LinkStateDead:
38		return reconnectStageOfflineRetrying
39	default:
40		return reconnectStageSSH
41	}
42}
43
44func nextReconnectBackoff(cur, limit time.Duration) time.Duration {
45	cur *= 2
46	if cur > limit {
47		return limit
48	}
49	return cur
50}
51
52func resumeNeedsExactAttach(err error) bool {
53	if errors.Is(err, errRouteTargetChanged) {
54		return true
55	}
56	protocolErr, ok := errors.AsType[*ProtocolError](err)
57	return ok && (protocolErr.Code == ports.ErrNoSuchSession || protocolErr.Code == ports.ErrNoSuchTarget)
58}
59
60func shouldReconnect(err error) bool {
61	if err == nil {
62		return false
63	}
64	if _, ok := errors.AsType[*ProtocolError](err); ok {
65		return false
66	}
67	_, ok := errors.AsType[*DetachedError](err)
68	return !ok
69}

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