v0.50.0 c4ec31f

rescue_dialog_test.go RawHistoryFolder

1package modes
2
3import (
4	"errors"
5	"strings"
6	"testing"
7
8	"github.com/bnema/zut/packages/tui"
9)
10
11func TestRescueErrorPreservesFullDiagnostic(t *testing.T) {
12	msg := `opencode-go: http 403: {"type":"error","error":{"type":"DataPolicyError","message":"` + strings.Repeat("policy details ", 30) + `review consent at https://example.com/workspace/go"}}`
13	ok, reason := classifyRescueError(errors.New(msg))
14	if !ok || !strings.Contains(reason, msg) {
15		t.Fatalf("diagnostic was truncated: %q", reason)
16	}
17}
18
19func TestRescueDialogFullErrorView(t *testing.T) {
20	d := newRescueDialog()
21	reason := strings.Repeat("diagnostic 界 details ", 100) + "FINAL-DIAGNOSTIC"
22	d.Open("", nil, "opencode-go", "example", reason, "prompt")
23	d.HandleKey(tui.Key{Kind: tui.KeyTab})
24	const width, height = 40, 10
25	rows := d.Render(tui.Theme{}, width, height)
26	assertRowsFitWidth(t, rows, width)
27	if len(rows) > height+2 {
28		t.Fatalf("error view exceeds viewport: %d", len(rows))
29	}
30	if !strings.Contains(strings.Join(rows, "\n"), "diagnostic") {
31		t.Fatal("missing start of error")
32	}
33	for n := 0; n < 100; n++ {
34		d.HandleKey(tui.Key{Kind: tui.KeyPageDown})
35		rows = d.Render(tui.Theme{}, width, height)
36	}
37	if !strings.Contains(strings.Join(rows, "\n"), "FINAL-DIAGNOSTIC") {
38		t.Fatal("cannot scroll to end of error")
39	}
40	d.HandleKey(tui.Key{Kind: tui.KeyHome})
41	rows = d.Render(tui.Theme{}, width, height)
42	if !strings.Contains(strings.Join(rows, "\n"), "diagnostic") {
43		t.Fatal("cannot return to start")
44	}
45	if act := d.HandleKey(tui.Key{Kind: tui.KeyEnter}); act.Select || act.Close {
46		t.Fatal("error view must not retry a model")
47	}
48	d.HandleKey(tui.Key{Kind: tui.KeyEsc})
49	if !d.Active() || d.details {
50		t.Fatal("escape should return to picker")
51	}
52	d.HandleKey(tui.Key{Kind: tui.KeyEsc})
53	if d.Active() {
54		t.Fatal("escape should dismiss picker")
55	}
56}

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 1

Tags 477

↑↓ moveenter openesc close