v0.45.0 cb619f7

time_aware_test.go RawHistoryFolder

1package core
2
3import (
4	"testing"
5	"time"
6
7	"github.com/bnema/zut/packages/provider"
8)
9
10func TestSessionPersistsAndReplaysToolTiming(t *testing.T) {
11	session, err := NewSession(t.TempDir(), "/workspace", "provider", "model", "test")
12	if err != nil {
13		t.Fatal(err)
14	}
15	started := time.Date(2026, 8, 8, 12, 0, 0, 0, time.FixedZone("UTC-4", -4*60*60))
16	timing := &provider.ToolTiming{
17		StartedAt:   started,
18		CompletedAt: started.Add(250 * time.Millisecond),
19		Duration:    250 * time.Millisecond,
20	}
21	if err := session.AppendMessage(provider.Message{
22		Role:    provider.RoleAssistant,
23		Content: []provider.Content{provider.ToolCallBlock{ID: "call-1", Name: "echo"}},
24	}); err != nil {
25		t.Fatal(err)
26	}
27	if err := session.AppendMessage(provider.Message{
28		Role: provider.RoleTool,
29		Content: []provider.Content{provider.ToolResultBlock{
30			CallID:  "call-1",
31			Content: []provider.Content{provider.TextBlock{Text: "ok"}},
32			Timing:  timing,
33		}},
34	}); err != nil {
35		t.Fatal(err)
36	}
37	path := session.Path
38	if err := session.Close(); err != nil {
39		t.Fatal(err)
40	}
41
42	snapshot, err := ReadSessionSnapshot(path)
43	if err != nil {
44		t.Fatal(err)
45	}
46	result, ok := snapshot.Messages[1].Content[0].(provider.ToolResultBlock)
47	if !ok {
48		t.Fatalf("replayed content = %T, want ToolResultBlock", snapshot.Messages[1].Content[0])
49	}
50	if result.Timing == nil {
51		t.Fatal("replayed tool result lost timing")
52	}
53	if !result.Timing.StartedAt.Equal(timing.StartedAt) || !result.Timing.CompletedAt.Equal(timing.CompletedAt) || result.Timing.Duration != timing.Duration {
54		t.Fatalf("replayed timing = %#v, want %#v", result.Timing, timing)
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 476

↑↓ moveenter openesc close