Repository navigation
feat(tui): notify when background work blocks or stops while away - #687
Merged
Merged
Conversation
Forge had no way to reach an operator who is looking at another window. `notify.rs` is that path: when a background task blocks on approval or reaches a terminal state, and the terminal does not have focus, a notification goes out naming the task. Two channels, and they are not equivalents. OSC 9 (`ESC ] 9 ; text BEL`) asks the terminal for a desktop notification carrying the text; Ghostty, Kitty, iTerm2 and WezTerm forward it to the OS notification centre, several of them over SSH. Everywhere else it is ignored. BEL rings the bell: universal, and says nothing. Neither can be probed, so the mode and the terminal's identity decide, exactly as Claude Code does with its Ghostty/Kitty/iTerm2 allowlist. `[tui] notify = "auto" | "bell" | "osc9" | "both" | "off"`, default `auto`. `auto` is silent — not the bell — on an unrecognised terminal, because an unexpected audible bell is worse than no notification. The value is installed into a thread-local rather than carried on `TuiRuntimeConfig`, following theme's precedent: the config is read in one place, and a new field there would have touched every one of its 121 call sites. Focus arrives via `EnableFocusChange`, which the TUI did not previously request; `dispatch_terminal_event` now handles `FocusGained`/`FocusLost` instead of swallowing them. Default focus is *focused*, so a terminal that never reports focus changes never notifies. Notification text is sanitized rather than trusted: labels come from the model, and an embedded ESC or BEL would terminate the sequence early and leave the rest to be read as terminal commands. Also drops the duplicated setup in the approval-naming test in favour of a shared helper. Tests: channel resolution per mode and terminal, control-character stripping, truncation, sequence framing, both focus gates, and an app-level test that a blocking subagent notifies an away operator while staying silent when watched.
mohitranka
added a commit
that referenced
this pull request
Sep 14, 2026
…ions (#688) The design system described the footer's counts-only chip and referred per-item detail to "the task view", which did not exist as a named surface. The strip now renders (#685, #686) and notifies (#687), so the rules that shipped — and the reason each exists — belong in the design language rather than only in the code. Adds §9.12 (the strip) and §9.13 (out-of-band notification), and points Row 1 of §9.3 at them. The rules recorded are the ones that are load-bearing and easy to undo by accident: the derived height that keeps the transcript's floor, the ordering that stops truncation hiding a failure, `cancelled` staying distinct from `done`, the one-minute expiry, and the focus gate on the notification.
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.
Completes the background-activity work from #685 and #686. Those made work visible and made a block legible in the app; this makes it reach an operator who is looking at another window.
The gap
Forge had no out-of-band path at all — the only OSC escape in the codebase was OSC 52 for the clipboard, and
dispatch_terminal_eventswallowedFocusGained/FocusLostin its_ => {}arm, so the TUI could not even tell whether anyone was watching.What changed
Two channels, and they are not equivalents:
ESC ] 9 ; text BEL) asks the terminal for a desktop notification carrying the text. Ghostty, Kitty, iTerm2 and WezTerm forward it to the OS notification centre, several of them over SSH. Everywhere else it is ignored.Neither can be probed, so the mode and the terminal's identity decide — exactly what Claude Code does with its Ghostty/Kitty/iTerm2 allowlist.
autois silent, not the bell, on an unrecognised terminal: an unexpected audible bell is worse than no notification.bellis the opt-in universal fallback,bothis for tmux/SSH where one channel gets swallowed.Also:
EnableFocusChange(newly requested), withFocusGained/FocusLosthandled rather than ignored. Default focus is focused, so a terminal that never reports focus changes never notifies.TuiRuntimeConfig, followingtheme's precedent — a new field there would have touched every one of its 121 call sites to carry a value read in one place.Notes for the reviewer
TuiConfigFiletest literals gained the new field;a_subagent_stopping_for_approval_names_itselfnow uses a shared helper instead of duplicating 30 lines of setup.Verification
cargo fmt --all -- --checkandcargo clippy --workspace --all-targets --locked -- -D warningsclean. New tests cover channel resolution per mode and terminal, control-character stripping, truncation, sequence framing, both focus gates, and an app-level test that a blocking subagent notifies an away operator while staying silent when watched.One test initially asserted that
autostays silent because the test environment has no allowlistedTERM_PROGRAM. That was wrong — the localTERM_PROGRAMis on the list — so it now tests the mode gate and leavesauto's resolution to the purechannels_fortests, which do not depend on the terminal they run in.