Skip to content

fix(send): redraw when the agent finder answers, so Send asks without a key press - #175

Merged
backnotprop merged 1 commit into
mainfrom
fix/send-label-redraw
Nov 20, 2026
Merged

backnotprop merged 1 commit into
mainfrom
fix/send-label-redraw

Conversation

@backnotprop

Copy link
Copy Markdown
Contributor

When a review is opened on its own in a Rex or Herdr pane (nothing names an agent), the Send button read "Copy 0 new (E)" until the next key press, then switched to "Send 0 new ▸ choose agent (E)".

Cause: the agent finder thread (Reach::start_with in ui/agent_picker.rs) stored its answer in an atomic and told no one. The document loop (cli.rs event_loop) only redraws after a key or a poll that reports a change, and the code review's Screen::tick never checked the finder.

Fix:

  • Reach records when the first look answers. Reach::poll returns true once for that answer, and Reach::looking says whether the look is still running.
  • Document review: App::poll_background collects every background poll (layout, file search, disk, Pi, finder) and the loop redraws when any of them changed something. The loop cannot be woken from another thread, so while the finder looks it waits 25 ms instead of 250 ms, the same as it already does for background layout and file search. After the answer it goes back to 250 ms.
  • Code review: the finder pokes the loop's wake channel, and Screen::tick includes Reach::poll, so the header updates right away.
  • The background layout merge (DocLayout::poll) also reports a change now. It was the only other background result whose change the loop ignored. Pi notes and the "changed on disk" notice already reported theirs.

Tests: new Unix-only tests for document and code reviews, against the fake rex and herdr scripts. A gate holds the first look open while the header reads "Copy 0 new"; the gate opens, the loop's poll (or wake) reports the change with no key, the header then reads "Send 0 new ▸ choose agent", and later polls are quiet. The layout poll also has a test.

Checked in the real binary in tmux, using fake rex and herdr and a scratch HOME and data folder. Header 0.5 s after opening, with no key pressed:

before after
Rex, document Copy 0 new (E) Send 0 new ▸ choose agent (E)
Rex, code review Copy 0 new (E) Send 0 new ▸ choose agent (E)
Herdr, document Copy 0 new (E) Send 0 new ▸ choose agent (E)
Herdr, code review Copy 0 new (E) Send 0 new ▸ choose agent (E)

Idle CPU after the fix: no CPU time used over 10 s, in both the document and the code review.

@backnotprop
backnotprop added this pull request to the merge queue Nov 20, 2026
@backnotprop
backnotprop removed this pull request from the merge queue due to a manual request Nov 20, 2026
… a key press

A review opened on its own inside Rex or Herdr showed "Copy 0 new (E)" until the next
key, then switched to "Send 0 new ▸ choose agent (E)". The agent finder thread stored
its answer in an atomic and nothing told the event loop: the document loop only redrew
after a key or a poll that reported a change, and the code review's tick did not look
at the finder.

Reach now records when the first look answers. Both loops take that as a screen change
(App::poll_background, Screen::tick). The code review's finder pokes the loop's wake
channel, so the header updates at once; the document loop cannot be woken from another
thread, so it waits 25 ms instead of 250 ms while the finder looks, as it already does
for the background layout and file search, and goes back to 250 ms once it answers.

The background layout merge now also reports a change, so its frame is drawn without
waiting for a key. Pi notes and the "changed on disk" notice already reported theirs.
@backnotprop
backnotprop force-pushed the fix/send-label-redraw branch from 7fe81c4 to a72e947 Compare November 20, 2026 03:44
@backnotprop
backnotprop added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit 7aa9727 Nov 20, 2026
3 checks passed
@backnotprop
backnotprop deleted the fix/send-label-redraw branch November 20, 2026 04:38
@backnotprop backnotprop mentioned this pull request Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant