detached 619aabb

Merge pull request #74 from bnema/fix/tui-vertical-shake

fix(tui): throttle tool event redraws
commit
619aabbd8f91b49191a32586731ac42ee8182879
author
bnema · · 2026-08-08 03:57 UTC
committer
GitHub · · 2026-08-08 03:57 UTC
merge of
b3affb0 + 3bed827 · diff against the first parent
signature
GPG UnverifiedB5690EEEBB952194 The key is unknown
refs
tag: v0.11.2
2 files · +31 -4
M packages/agent/modes/interactive.go +3 -4
@@ -1342,10 +1342,9 @@ func (i *Interactive) requestRendererTheme(theme tui.Theme) {
13421342
13431343 func (i *Interactive) invalidate() {
13441344 i.renderRevision.Add(1)
1345- if scheduler := i.renderScheduler.Load(); scheduler != nil {
1346- scheduler.request(false, false)
1347- return
1348- }
1345+ // Keep ordinary state changes on the main-loop throttle. The scheduler
1346+ // owns terminal output, but scheduling it here would bypass
1347+ // redrawMinInterval and paint every intermediate tool-event frame.
13491348 select {
13501349 case i.dirty <- struct{}{}:
13511350 default:
@@ -1342,10 +1342,9 @@ func (i *Interactive) requestRendererTheme(theme tui.Theme) {
1342 1342
1343 func (i *Interactive) invalidate() {1343 func (i *Interactive) invalidate() {
1344 i.renderRevision.Add(1)1344 i.renderRevision.Add(1)
1345- if scheduler := i.renderScheduler.Load(); scheduler != nil {1345+ // Keep ordinary state changes on the main-loop throttle. The scheduler
1346- scheduler.request(false, false)1346+ // owns terminal output, but scheduling it here would bypass
1347- return1347+ // redrawMinInterval and paint every intermediate tool-event frame.
1348- }
1349 select {1348 select {
1350 case i.dirty <- struct{}{}:1349 case i.dirty <- struct{}{}:
1351 default:1350 default:
M packages/agent/modes/interactive_render_test.go +28 -0
@@ -65,6 +65,34 @@ func TestLatestFrameSchedulerKeepsNewestRequest(t *testing.T) {
6565 }
6666 }
6767
68+func TestToolEventBurstUsesThrottledInvalidationPath(t *testing.T) {
69+ scheduler := newLatestFrameScheduler()
70+ i := &Interactive{
71+ dirty: make(chan struct{}, 1),
72+ toolCalls: make(map[string]*tui.ToolCallView),
73+ toolGate: make(map[string]int),
74+ }
75+ i.renderScheduler.Store(scheduler)
76+
77+ i.handleEventForPresentation(core.EvToolUseStart{ID: "call", Name: "bash"})
78+ i.handleEventForPresentation(core.EvToolUseArgs{ID: "call", Delta: `{"command":"pwd"}`})
79+ i.handleEventForPresentation(core.EvToolUseEnd{ID: "call"})
80+
81+ if got := len(scheduler.wake); got != 0 {
82+ t.Fatalf("tool events bypassed the main-loop redraw throttle: %d direct request", got)
83+ }
84+ select {
85+ case <-i.dirty:
86+ default:
87+ t.Fatal("tool events did not wake the throttled redraw path")
88+ }
89+ select {
90+ case <-i.dirty:
91+ t.Fatal("tool event burst queued more than one throttled redraw")
92+ default:
93+ }
94+}
95+
6896 func TestStableChatCacheTracksViewInvalidation(t *testing.T) {
6997 i := &Interactive{
7098 view: &tui.View{
@@ -65,6 +65,34 @@ func TestLatestFrameSchedulerKeepsNewestRequest(t *testing.T) {
65 }65 }
66 }66 }
67 67
68+func TestToolEventBurstUsesThrottledInvalidationPath(t *testing.T) {
69+ scheduler := newLatestFrameScheduler()
70+ i := &Interactive{
71+ dirty: make(chan struct{}, 1),
72+ toolCalls: make(map[string]*tui.ToolCallView),
73+ toolGate: make(map[string]int),
74+ }
75+ i.renderScheduler.Store(scheduler)
76+
77+ i.handleEventForPresentation(core.EvToolUseStart{ID: "call", Name: "bash"})
78+ i.handleEventForPresentation(core.EvToolUseArgs{ID: "call", Delta: `{"command":"pwd"}`})
79+ i.handleEventForPresentation(core.EvToolUseEnd{ID: "call"})
80+
81+ if got := len(scheduler.wake); got != 0 {
82+ t.Fatalf("tool events bypassed the main-loop redraw throttle: %d direct request", got)
83+ }
84+ select {
85+ case <-i.dirty:
86+ default:
87+ t.Fatal("tool events did not wake the throttled redraw path")
88+ }
89+ select {
90+ case <-i.dirty:
91+ t.Fatal("tool event burst queued more than one throttled redraw")
92+ default:
93+ }
94+}
95+
68 func TestStableChatCacheTracksViewInvalidation(t *testing.T) {96 func TestStableChatCacheTracksViewInvalidation(t *testing.T) {
69 i := &Interactive{97 i := &Interactive{
70 view: &tui.View{98 view: &tui.View{

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