v0.38.0 58133ea

session_info_test.go RawHistoryFolder

1package modes
2
3import (
4	"context"
5	"path/filepath"
6	"strings"
7	"testing"
8
9	"github.com/bnema/zut/packages/core"
10	"github.com/bnema/zut/packages/provider"
11	"github.com/bnema/zut/packages/tui"
12)
13
14func TestRunInfoShowsCurrentSessionDetails(t *testing.T) {
15	root := t.TempDir()
16	sessionPath := filepath.Join(root, "state", "session.jsonl")
17	cwd := filepath.Join(root, "workspace")
18	agent := &core.Agent{}
19	if err := agent.BindSessionID("session-123"); err != nil {
20		t.Fatal(err)
21	}
22	i := &Interactive{
23		agent: agent,
24		cfg: InteractiveConfig{
25			CWD:                cwd,
26			Provider:           "openai-codex",
27			Model:              "gpt-5.6",
28			CurrentSessionPath: func() string { return sessionPath },
29		},
30	}
31
32	i.runSlash(context.Background(), "/INFO")
33
34	if len(i.sessionInfoBlocks) != 1 {
35		t.Fatalf("/info blocks = %d, want 1", len(i.sessionInfoBlocks))
36	}
37	got := strings.Join(i.sessionInfoBlocks[0].lines, "\n")
38	for _, want := range []string{
39		"session info",
40		"session-123",
41		sessionPath,
42		cwd,
43		"openai-codex",
44		"gpt-5.6",
45	} {
46		if !strings.Contains(got, want) {
47			t.Fatalf("/info output missing %q:\n%s", want, got)
48		}
49	}
50	if len(i.helpBlock) != 0 {
51		t.Fatalf("/info retained help block: %#v", i.helpBlock)
52	}
53	if got := len(agent.Messages()); got != 0 {
54		t.Fatalf("/info added %d messages to provider context", got)
55	}
56}
57
58func TestRunInfoAppendsEachInvocation(t *testing.T) {
59	i := &Interactive{}
60
61	i.runSlash(context.Background(), "/info")
62	i.runSlash(context.Background(), "/info")
63
64	if got := len(i.sessionInfoBlocks); got != 2 {
65		t.Fatalf("/info blocks = %d, want one per invocation", got)
66	}
67}
68
69func TestInfoScrollsWithTranscript(t *testing.T) {
70	agent := &core.Agent{}
71	agent.SetMessages([]provider.Message{{
72		Role:    provider.RoleAssistant,
73		Content: []provider.Content{provider.TextBlock{Text: "before info"}},
74	}})
75	i := &Interactive{agent: agent, view: &tui.View{}}
76
77	i.runSlash(context.Background(), "/info")
78	agent.SetMessages(append(agent.Messages(), provider.Message{
79		Role:    provider.RoleUser,
80		Content: []provider.Content{provider.TextBlock{Text: "after info"}},
81	}))
82
83	i.mu.Lock()
84	got := strings.Join(i.buildChatLocked(80), "\n")
85	i.mu.Unlock()
86	before := strings.Index(got, "before info")
87	info := strings.Index(got, "session info")
88	after := strings.Index(got, "after info")
89	if before < 0 || info < before || after < info {
90		t.Fatalf("/info did not stay at its transcript position:\n%s", got)
91	}
92}
93
94func TestRenderSessionInfoMarksUnavailableValues(t *testing.T) {
95	got := strings.Join(renderSessionInfoBlock(tui.Theme{}, 80, "", "", "", "", ""), "\n")
96	if count := strings.Count(got, "unavailable"); count != 5 {
97		t.Fatalf("unavailable value count = %d, want 5:\n%s", count, got)
98	}
99}

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