A CLI that stops reading its keys blocks the crew screen: Keys() writes to the pty inside Update #13

Closed
opened 2026-12-02 12:07:04 +00:00 by titan · 1 comment
Member

Purpose (defect): the crew screen keeps drawing and answering the owner when a Claude Code member's CLI has stopped reading its terminal.

crewScreen.Update hands one member's keys to its CLI with live.Keys → terminal.Write → tty.Write, on the program's own loop (cmd/lazymartha/crew.go). A pty write blocks when the pty's input buffer is full and the child is not reading it, so a CLI that is busy, hung, or waiting on anything but its terminal holds Update — and the whole screen with it — until it reads again, if it ever does. Nothing drains or drops those keys.

This is the one path left of the shape #11 r=2 removed everywhere else (caa38f1): work done from inside Update that waits for the program's own loop. There it froze the screen on ctrl+a, on Enter for a turn and on any terminal resize with a CLI pane; the keys were left synchronous because Keys only writes.

Suggested fix: give each terminal one writer of its own — the keys go to a command or a small queue the writer drains — so the loop never waits on a pty write, and a CLI that stops reading cannot stop the screen.

Not blocking anything: no evidence run hit it, because every stand-in CLI in the tests and the pty driver reads every line it is given. Noted by Mars on the #11 r=2 pass, optional then.

Refs #11

Purpose (defect): the crew screen keeps drawing and answering the owner when a Claude Code member's CLI has stopped reading its terminal. `crewScreen.Update` hands one member's keys to its CLI with `live.Keys` → `terminal.Write` → `tty.Write`, on the program's own loop (cmd/lazymartha/crew.go). A pty write blocks when the pty's input buffer is full and the child is not reading it, so a CLI that is busy, hung, or waiting on anything but its terminal holds `Update` — and the whole screen with it — until it reads again, if it ever does. Nothing drains or drops those keys. This is the one path left of the shape #11 r=2 removed everywhere else (caa38f1): work done from inside `Update` that waits for the program's own loop. There it froze the screen on ctrl+a, on Enter for a turn and on any terminal resize with a CLI pane; the keys were left synchronous because `Keys` only writes. Suggested fix: give each terminal one writer of its own — the keys go to a command or a small queue the writer drains — so the loop never waits on a pty write, and a CLI that stops reading cannot stop the screen. Not blocking anything: no evidence run hit it, because every stand-in CLI in the tests and the pty driver reads every line it is given. Noted by Mars on the #11 r=2 pass, optional then. Refs #11
Author
Member

Folded into #14, which has landed: main is 876f0fb9 (PR 15, run 7020 green).

What this issue asked for — a CLI that stops reading its keys must not block the crew screen — is in that commit: internal/terminal's Keys enqueues into a bounded queue (64 batches) drained by one writer goroutine, and a full queue answers "the CLI is not reading its keys", named by member on screen; Write is gone and the tests use Keys.

Closing here, with #14.

Folded into #14, which has landed: main is 876f0fb9 (PR 15, run 7020 green). What this issue asked for — a CLI that stops reading its keys must not block the crew screen — is in that commit: internal/terminal's `Keys` enqueues into a bounded queue (64 batches) drained by one writer goroutine, and a full queue answers "the CLI is not reading its keys", named by member on screen; `Write` is gone and the tests use `Keys`. Closing here, with #14.
titan closed this issue 2026-12-02 15:42:41 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
martha-ai/lazymartha#13
No description provided.