v0.48.1 deaab59

prompt_input_test.go RawHistoryFolder

1package agent
2
3import (
4	"os"
5	"testing"
6)
7
8func TestArgsForStdinSelectsPrintModeForPipe(t *testing.T) {
9	args, err := ParseArgs(argsForStdin([]string{"summarize"}, os.ModeNamedPipe))
10	if err != nil {
11		t.Fatal(err)
12	}
13	if args.Mode != ModePrint || args.Prompt != "summarize" {
14		t.Fatalf("Mode=%q Prompt=%q, want print mode with prompt", args.Mode, args.Prompt)
15	}
16}
17
18func TestArgsForStdinPreservesTerminalAndExplicitModes(t *testing.T) {
19	tests := []struct {
20		name string
21		in   []string
22		mode os.FileMode
23		want Mode
24	}{
25		{name: "terminal stays interactive", mode: os.ModeCharDevice, want: ModeInteractive},
26		{name: "explicit stream overrides pipe default", in: []string{"--stream", "prompt"}, mode: os.ModeNamedPipe, want: ModeStream},
27		{name: "explicit json overrides redirected file default", in: []string{"--json", "prompt"}, want: ModeJSON},
28		{name: "explicit rpc overrides pipe default", in: []string{"--rpc"}, mode: os.ModeNamedPipe, want: ModeRPC},
29	}
30	for _, tc := range tests {
31		t.Run(tc.name, func(t *testing.T) {
32			args, err := ParseArgs(argsForStdin(tc.in, tc.mode))
33			if err != nil {
34				t.Fatal(err)
35			}
36			if args.Mode != tc.want {
37				t.Fatalf("Mode=%q, want %q", args.Mode, tc.want)
38			}
39		})
40	}
41}
42
43func TestArgsForStdinAllowsPrintStats(t *testing.T) {
44	args, err := ParseArgs(argsForStdin([]string{"--stats", "stats.json"}, os.ModeNamedPipe))
45	if err != nil {
46		t.Fatal(err)
47	}
48	if args.Mode != ModePrint || args.StatsPath != "stats.json" {
49		t.Fatalf("Mode=%q StatsPath=%q, want print mode with stats path", args.Mode, args.StatsPath)
50	}
51}
52
53func TestCombinePromptInput(t *testing.T) {
54	tests := []struct {
55		name       string
56		stdin      string
57		positional string
58		want       string
59	}{
60		{name: "stdin and instruction", stdin: "input text\n", positional: "summarize it", want: "input text\nsummarize it"},
61		{name: "stdin only", stdin: " input text\n", want: "input text"},
62		{name: "positional only", positional: " summarize it ", want: "summarize it"},
63		{name: "empty", stdin: " \n", positional: " ", want: ""},
64	}
65
66	for _, tc := range tests {
67		t.Run(tc.name, func(t *testing.T) {
68			if got := combinePromptInput(tc.stdin, tc.positional); got != tc.want {
69				t.Fatalf("combinePromptInput(%q, %q) = %q, want %q", tc.stdin, tc.positional, got, tc.want)
70			}
71		})
72	}
73}

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 476

↑↓ moveenter openesc close