Skip to content

fix(tui): make steer, escape, enter, and double ctrl-c work under extended-keys#31

Merged
mike-diff merged 1 commit into
mainfrom
fix/issue-30-control-plane
Jun 19, 2026
Merged

fix(tui): make steer, escape, enter, and double ctrl-c work under extended-keys#31
mike-diff merged 1 commit into
mainfrom
fix/issue-30-control-plane

Conversation

@mike-diff

Copy link
Copy Markdown
Owner

Closes #30.

The interactive control plane did not reliably drive a running turn: a typed steer only took effect at the next iteration boundary, and Escape, Enter, and Ctrl+C did nothing under terminals using the extended-keys (CSI-u) keyboard protocol (e.g. tmux with extended-keys on). In that mode those keys arrive as key sequences through the input stream rather than a bare byte or an OS signal, so the existing handlers never saw them:

  • Escape -> ESC[27u
  • Enter -> ESC[57414u (kitty functional) or ESC[13u
  • Ctrl+C -> ESC[99;5u (never delivered as SIGINT)

What changed

  • steer: typing during a turn now cancels the in-flight turn at once and runs the queued text as the next turn; the queued note is highlighted in cyan. A sticky abort flag closes the between-iteration window where a cancel was previously dropped, so Escape also aborts the judge and worker phases.
  • escape: bare-Escape detection keys off the sequence introducer ([/O) rather than a fragile timer, and the CSI-u Escape (ESC[27u) is decoded and routed to cancel.
  • enter: the CSI-u Enter (codepoint 13 or kitty functional 57414) is normalized back to a plain Return so the single submit/steer path handles it; a modified Enter (Shift/Alt) still inserts a newline.
  • ctrl+c: force-exit no longer blocks on the kill grace period; the CSI-u Ctrl+C (ESC[99;5u) and a raw 0x03 are routed to the same quit path as the OS signal, so a double press exits even under extended-keys.
  • /stop: a new command, the typed twin of Escape (aborts the turn, queues nothing).
  • The proc tool now threads the turn context so it shares bash's cancellable contract.

Verification

  • gofmt, go vet, go build ./..., go test ./... all clean; race detector clean on the touched packages.
  • New behavior tests for each path (steer-cancel, sticky-abort gap, escIsBare introducer detection, CSI-u Escape/Enter/Ctrl+C decode, /stop, no-block force-exit), each with a nameable one-line breaker.
  • Verified live in tmux (extended-keys on): steer, Escape, Enter, /stop, and double Ctrl+C all confirmed working; the exact key sequences were captured during debugging and pinned by the decode helpers.

agent/ is untouched; all changes live in harness/.

…ended-keys

The interactive control plane did not reliably drive a running turn. A
typed steer only took effect at the next iteration boundary, and Escape,
Enter, and Ctrl-C did nothing under terminals using the extended-keys
(CSI-u) keyboard protocol, where those keys arrive as ESC[27u, ESC[57414u
(kitty functional Enter) or ESC[13u, and ESC[99;5u key sequences rather
than a bare byte or an OS signal.

- steer: typing during a turn now cancels the in-flight turn at once and
  runs the queued text as the next turn; the queued note is highlighted in
  cyan. A sticky abort flag closes the between-iteration window where a
  cancel was previously dropped, so Escape aborts the judge and worker
  phases too.
- escape: detection keys off the sequence introducer rather than a fragile
  timer, and the CSI-u Escape (ESC[27u) is decoded and routed to cancel.
- enter: the CSI-u Enter (codepoint 13 or kitty functional 57414) is
  normalized back to a plain Return so the one submit/steer path handles
  it; a modified Enter still inserts a newline.
- ctrl-c: force-exit no longer blocks on the kill grace period; the CSI-u
  Ctrl-C (ESC[99;5u) and a raw 0x03 are routed to the same quit path as the
  OS signal, so a double press exits even under extended-keys.
- add a /stop command (the typed twin of Escape) and an opt-in SESH_DEBUG
  trace of the control-plane events. The proc tool now threads the turn
  context so it shares bash's cancellable contract.
@mike-diff mike-diff merged commit 33cb3ae into main Jun 19, 2026
2 checks passed
@mike-diff mike-diff deleted the fix/issue-30-control-plane branch June 19, 2026 02:31
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.

[bug] long-running backgrounded bash makes TUI unresponsive to escape / ctrl+c / queued steer

1 participant