feat(terminal): report Claude Code status; fix stuck Codex sessions - #690
Open
noih wants to merge 1 commit into
Open
feat(terminal): report Claude Code status; fix stuck Codex sessions#690noih wants to merge 1 commit into
noih wants to merge 1 commit into
Conversation
Instrument Claude Code terminals with UserPromptSubmit / Stop / Notification / SessionEnd hooks injected as inline --settings JSON, generalizing the Codex-only notify path. Emit terminal:idle when a tailer loses its terminal so a quit CLI no longer sits on "in progress", key the signal file by terminal id so a reopened terminal cannot lose it to the outgoing tailer, and treat subagent permission prompts as attention.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
UserPromptSubmit/Stop/Notification/SessionEndhooks injected as inline--settingsJSON, leaving the user's own~/.claude/settings.jsonuntouchedinject_codex_notifyintoinject_lifecycle_hookand add aterminal:idleeventterminal:idlewhen a tailer loses its terminal, so quitting either CLI no longer pins the session to "in progress" until the app restartsworker_permission_promptas attention, so subagent prompts surface like top-level ones--settingsor-c notify=Builds on #634, which added this mechanism for Codex.
Why
Codex's
notifyonly firesagent-turn-complete, so nothing reports the CLI exiting — andclear_attention_on_inputreads the Enter that submits/exitas a prompt submit, flipping the session to working right before the CLI dies. Terminal sessions have no run transcript, so that stale flag is the only thing driving their badge; it stayed on "in progress" until the app restarted.The signal file was keyed by session but deleted by a thread that lives and dies with its terminal, so reopening a session terminal inside the outgoing tailer's 200 ms poll window let the old thread unlink the new terminal's file.
Test plan
bun run check:all— typecheck, lint, rustfmt, clippy-D warnings, 2116 frontend tests, 1116 Rust testsworker_permission_promptterminal:working/attention/idlehandlers, sound and notification suppressiongit diff --checkManual test
/exit, then with Ctrl-C twice; the session returns to idle instead of staying "in progress". Repeat with Codex.Tested on macOS. Windows + WSL is untested and likely still silent: the
#[cfg(windows)]hook commands are handed to a Linux hook runner when the terminal routes throughwsl.exe. That predates this change and needs its own issue.