8000 feat: read an agent's turn from its hook, its spinner or quiet output by aorumbayev · Pull Request #124 · kagan-sh/kagan · GitHub
[go: up one dir, main page]

Skip to content

feat: read an agent's turn from its hook, its spinner or quiet output - #124

Merged
aorumbayev merged 8 commits into
mainfrom
feat/cursor-turn-signal
Nov 11, 2026
Merged

aorumbayev merged 8 commits into
mainfrom
feat/cursor-turn-signal

Conversation

@aorumbayev
Copy link
Copy Markdown
Member

Branch feat/cursor-turn-signal.

Reviewed by a fresh reviewer, fixed, and re-checked (SHIP). Gate: fmt, clippy -D warnings, workspace tests, scripts.

… or quiet output

A turn was read only from the window title spinner, so a program that draws
no spinner (Cursor Agent) never told its parent that its turn ended.

Each run now has one turn source. Claude gets a per-thread settings file that
calls `kg thread turn start|end` from its UserPromptSubmit, Stop and StopFailure
hooks. Other programs keep the spinner. A known agent with neither gets a quiet
turn that opens on submit and ends after 15 seconds without output change.
Hook runs also end after 120 seconds of silence, because Claude does not fire
Stop when Esc is pressed.

The turn rules are a pure state machine (thread/turn_state.rs) with table tests.
The watch loop and the hook op feed it. Size ceiling raised by 316 lines for the
state machine, the hook op and its tests.
…rm turn hook

A hook turn could close on its first tick because the title's plain clock
outlived the turn before it. The state machine now owns all turn timing, and
a plain title closes a hook turn only after a spinner was seen in that turn.

A submit now opens a quiet turn only when visible text changes within 3
seconds, so an empty Enter opens nothing. A quiet turn ends when the visible
text stops changing, not when the terminal redraws.

The Claude hook runs kg directly with arguments instead of a shell string.
kg thread turn sends to a running app and never starts one or fails.
clippy flagged the hook helper for taking an unused owned Op and returning a
Result that is always Ok. It now borrows the op and returns nothing; the
caller still exits 0.
The first redraw after a line was counted as output even when the visible
text had not changed, so an Enter that only repainted opened a quiet turn.
# Conflicts:
#	.config/size-budget.txt
#	docs/behaviour.md
#	docs/decisions.md
# Conflicts:
#	.config/size-budget.txt
#	crates/domain/src/lib.rs
#	crates/domain/src/op/check.rs
#	docs/decisions.md
@aorumbayev
aorumbayev merged commit 1e4a36e into main Nov 11, 2026
19 checks passed
@aorumbayev
aorumbayev deleted the feat/cursor-turn-signal branch November 11, 2026 02:40
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

0