v0.27.1 131edba

confirmation_events_test.go RawHistoryFolder

1package agent
2
3import (
4	"reflect"
5	"testing"
6
7	"github.com/bnema/zut/packages/agent/extproto"
8	"github.com/bnema/zut/packages/core"
9)
10
11type rememberingDetailedConfirmer struct {
12	calls []core.ToolCallConfirmation
13}
14
15func (c *rememberingDetailedConfirmer) Confirm(string, string) core.ConfirmDecision {
16	panic("Confirm called instead of ConfirmToolCall")
17}
18
19func (c *rememberingDetailedConfirmer) ConfirmToolCall(call core.ToolCallConfirmation) core.ConfirmDecision {
20	c.calls = append(c.calls, call)
21	return core.ConfirmDecision{Allow: true, RememberTool: true}
22}
23
24func TestConfirmationEventConfirmerEmitsOnlyWhenPrompting(t *testing.T) {
25	inner := &rememberingDetailedConfirmer{}
26	var events []extproto.EventFromHost
27	notifier := &confirmationEventConfirmer{
28		inner: inner,
29		emit: func(event extproto.EventFromHost) {
30			events = append(events, event)
31		},
32	}
33	gate := core.NewConfirmGate(notifier)
34	call := core.ToolCallConfirmation{
35		ID:      "call-1",
36		Name:    "edit",
37		Summary: "main.go",
38		Content: "-old\n+new\n",
39	}
40
41	if allowed, _, _ := gate.CheckToolCall(call); !allowed {
42		t.Fatal("first call should be allowed")
43	}
44	if allowed, _, _ := gate.CheckToolCall(core.ToolCallConfirmation{Name: "edit", Summary: "other.go"}); !allowed {
45		t.Fatal("remembered tool should be allowed")
46	}
47
48	if len(events) != 1 {
49		t.Fatalf("events = %d, want 1", len(events))
50	}
51	want := extproto.EventFromHost{
52		Event:       "tool_confirmation_requested",
53		ToolID:      "call-1",
54		ToolName:    "edit",
55		ToolPreview: "main.go",
56	}
57	if !reflect.DeepEqual(events[0], want) {
58		t.Fatalf("event = %+v, want %+v", events[0], want)
59	}
60	if len(inner.calls) != 1 || inner.calls[0] != call {
61		t.Fatalf("inner calls = %+v, want [%+v]", inner.calls, call)
62	}
63}

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