feat(tui): ring a turn-done notification when the terminal is unfocused - #233
Merged
Conversation
Max17190
marked this pull request as ready for review
August 27, 2026 03:53
The bell fired only on the needs-approval edge, so a turn finishing while the user was in another window ended silently and long turns meant polling the terminal. Track terminal focus from focus-change reports (None until the terminal sends one, so terminals without focus reporting stay silent rather than ringing at a watching user), and on the working-to-idle edge while known unfocused emit an OSC 9 notification plus a bell. The needs-approval bell keeps its unconditional ring.
Max17190
force-pushed
the
tui-turn-end-notification
branch
from
August 27, 2026 03:55
65caef1 to
32c4c1e
Compare
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.
Why
A turn finishing while the user is in another window ends silently; the bell fires only when an approval arrives, so long turns mean polling the terminal.
Summary
Track terminal focus from focus-change reports (
term_focus: Option<bool>, None until the terminal sends one). On the working-to-idle presence edge while known unfocused, emit an OSC 9 notification plus a bell. Terminals that never report focus stay silent rather than ringing at a watching user; the needs-approval bell keeps its unconditional ring.EnableFocusChangeis symmetric with the other terminal modes on init and every exit path.Test Plan
turn_done_ring_fires_only_on_the_unfocused_working_to_idle_edge: full truth table for the ring decision (shown red with the decision neutered).focus_reports_track_terminal_focus: focus events update the tracked state (shown red with tracking neutered).cargo test --workspaceandcargo clippy --workspace --all-targetsclean.Greptile Summary
This change tracks terminal focus and rings when an unfocused turn becomes idle. The normal shutdown path disables focus reporting, but the panic cleanup path does not, so a crash can leave the shell receiving terminal focus escape sequences after OpenMax exits. The TUI binary test suite passed with 246 tests.
Confidence Score: 4/5
Not merge-safe until panic cleanup disables terminal focus reporting.
There is one independent P1 finding, and it is not a security issue; the required scoring table assigns a score of 4.
Files Needing Attention: crates/tui/src/main.rs: add focus-reporting cleanup to the panic path.
What T-Rex did
Comments Outside Diff (1)
crates/tui/src/main.rs, line 1115-1116 (link)Focus reporting is enabled before
app::run, but it is disabled only afterapp::runreturns normally. A panic runs this hook and unwinds past the normal cleanup at line 1081; the hook restores Ratatui and the title without emittingDisableFocusChange. A compatible terminal therefore continues sending focus escape sequences to the restored shell after an OpenMax panic. Disable focus reporting in this panic cleanup path as well, or use an unwind-safe cleanup guard.Artifacts
Rust harness for focus-reporting panic cleanup
Panic cleanup output without panic-hook focus disable
Panic cleanup output with panic-hook focus disable
Prompt To Fix With AI
Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "feat(tui): ring a turn-done notification..." | Re-trigger Greptile