Skip to content

feat(terminals): per-tab activity indicators - #944

Merged
brennanb2025 merged 3 commits into
mainfrom
brennanb2025/notif-on-pane
Apr 24, 2026
Merged

brennanb2025 merged 3 commits into
mainfrom
brennanb2025/notif-on-pane

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Apr 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Per-tab activity indicator (amber wash + bottom accent strip + bell glyph on the tab) driven by the agent working→idle title transition, reflecting that BEL alone is too ambiguous to drive cross-surface attention.

The signal: agent working→idle

  • Mark path: onAgentBecameIdle in pty-connection.ts fires markWorktreeUnread, markTerminalTabUnread, and dispatchNotification({ source: 'agent-task-complete' }) on the single per-task transition Claude/Gemini/Codex emit via OSC title.
  • Clear path: setActiveTab / activateTab / focusGroup clear the dot, all guarded on the active worktree. Tab-close and worktree-teardown also clean up.
  • Visible-group guard: markTerminalTabUnread skips marking when the tab is the active tab of any visible split group in the active worktree — no spurious dots on panes the user can already see.

Why not BEL

We iterated through two BEL-based designs before settling on the title-transition approach:

  1. BEL for all panes — undismissable dot. Claude Code emits BEL on every render frame; clicking cleared the dot, the next repaint re-flagged it.
  2. BEL for shells, suppressed on agent panes (via a persisted wasAgentPane latch + in-memory paneIsInAgentMode) — spurious bells on every pane click. Root cause: xterm.js honors DECSET 1004 (focus-event reporting) when a TUI requests it, and Orca's daemon persists xterm.js state across app restarts by design. If the TUI exits uncleanly (Orca restart while Claude is running, SIGKILL, crash), the mode bit stays set. Every subsequent click emits \e[I/\e[O into the shell, zsh rings its undefined-key bell, and the bell detector flagged it correctly — but the BELs were noise, not attention.

Terminals with ephemeral state (no cross-restart persistence) dodge the stuck-DECSET problem because closing a tab destroys the Terminal and new tabs start clean. Orca keeps daemon-backed persistence, so the signal source has to be the unambiguous agent title transition instead of BEL.

Full rationale lives in the long-form comment above onAgentBecameIdle in src/renderer/src/components/terminal-pane/pty-connection.ts.

What was removed

  • onBell handler in pty-connection.ts + all plumbing in pty-dispatcher.ts, pty-transport.ts, pty-connection-types.ts, use-terminal-pane-lifecycle.ts, TerminalPane.tsx.
  • paneIsInAgentMode / seedClearEligible in-memory BEL-suppression state.
  • Persisted wasAgentPane latch from TerminalTab, workspaceSessionSchema, and hydration backfill.
  • clearTabAgentMode store action + dependency threading.
  • src/renderer/src/components/terminal-pane/bell-detector.ts (now orphaned).
  • [notif] diagnostic console.log traces from pty-connection.ts, pty-transport.ts, terminals.ts, agent-detection.ts.
  • tests/e2e/terminal-attention-restart.spec.ts — validated the wasAgentPane hydration path that no longer exists.

What stayed

  • 2s reattach grace window in pty-transport.ts that suppresses catch-up working→idle transitions from the daemon's eager-buffer flush. Fixes phantom unread at startup when a prior-session agent's replayed OSC titles would otherwise look like a fresh completion.
  • markTerminalTabUnread visible-group guard — still needed for the agent-idle signal in split-group layouts.
  • hasStrongAgentSignal helper (now scoped to terminal-helpers.ts for "reset stale agent title on hydration"; no longer gates BEL).

Test plan

Unit tests

  • pty-connection.test.ts — regression guard that onBell is never wired; onAgentBecameIdle fires worktree unread + tab unread + OS notification; onAgentExited clears the prompt-cache countdown.
  • pty-transport.test.ts — reattach grace suppresses replayed catch-up idle transitions; replay does not fire onAgentBecameWorking for historical titles; post-flush live working transitions still fire.
  • tabs.test.ts / terminals-hydration.test.ts / terminal-helpers.test.ts — unread clears on tab activation / group focus / tab close / worktree teardown; hydration resets stale agent titles.

E2E tests (tests/e2e/terminal-attention.spec.ts)

  • Positive: agent working→idle on a background tab raises the dot; focusing the tab clears it.
  • Negative (basic): raw BEL bursts on a background tab do NOT raise tab attention.
  • Negative (original bug reproduction): DECSET 1004 + \e[O/\e[I focus-escapes + BEL bursts (the exact byte pattern from the user's console) do NOT raise tab attention.

Regression-guard verification

Temporarily re-wired onBell → markTerminalTabUnread in pty-connection.ts + naive BEL detection in pty-transport.ts to simulate the regression. Verified:

  • Unit: pty-connection.test.ts › does not wire an onBell handler through to the transport → failed (as expected).
  • E2E: Terminal attention › a raw BEL does not raise tab attention → failed (as expected).
  • E2E: Terminal attention › DECSET 1004 focus-escape BEL churn does not raise tab attention → failed (as expected).
  • E2E: Terminal attention › an agent completion marks a background tab unread and clears on focus → still passed (positive case unaffected by the break).

Restored the fix; all 22 unit tests in the affected files and all 3 e2e tests pass.

Manual verification

  • User confirmed: clicking between panes in a shell with stuck DECSET 1004 no longer produces phantom bells.
  • User confirmed: Claude/Gemini/Codex completions still raise the tab dot; the dot clears on focus.
  • Same user repro (cat showing ^[[I/^[[O on inter-tab clicks) confirmed stuck DECSET 1004 is a universal "TUI killed uncleanly" issue, not specific to our terminal — it's just hidden in terminals without cross-restart persistence.

Follow-ups (not in this PR)

  • DECSET reset on PTY reconnect in pty-transport.ts to clear mode bits leaked by crashed TUIs. Lower priority with BEL no longer driving attention, but still worth doing — stuck 1004 still puts visible ^[[I/^[[O chars into cat-like foreground processes.
  • Dead-code removal for the terminalBell notification setting (NotificationsPane.tsx, settings.terminalBell branch in main/ipc/notifications.ts). Touches settings schema + migration so deferred for a separate pass.

@brennanb2025 brennanb2025 changed the title feat(terminals): Ghostty-style per-tab activity indicators feat(terminals): Per-tab activity indicators Apr 22, 2026
@brennanb2025 brennanb2025 changed the title feat(terminals): Per-tab activity indicators feat(terminals): per-tab activity indicators Apr 22, 2026
@brennanb2025
brennanb2025 force-pushed the brennanb2025/notif-on-pane branch from d1fe4df to 87e3a51 Compare April 22, 2026 18:14
Per-tab activity indicator (amber wash + bottom accent strip + bell
glyph on the tab) driven by the agent working→idle title transition.

- Mark path: `onAgentBecameIdle` in `pty-connection.ts` fires
  `markWorktreeUnread`, `markTerminalTabUnread`, and
  `dispatchNotification({ source: 'agent-task-complete' })` on the
  single per-task transition Claude/Gemini/Codex emit via OSC title.
- Clear path: `setActiveTab` / `activateTab` / `focusGroup` clear the
  dot, all guarded on the active worktree. Tab-close and worktree
  teardown also clean up.
- Visible-group guard: `markTerminalTabUnread` skips marking when the
  tab is the active tab of any visible split group in the active
  worktree.
- 2s reattach grace window in `pty-transport.ts` suppresses catch-up
  working→idle transitions from the daemon's eager-buffer flush.
- Restored `bell-detector.ts` for BEL-driven attention signal on
  non-agent panes.

See PR #944 for full rationale and the BEL-based alternatives that
were considered and rejected.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/notif-on-pane branch from 85c9b60 to 7c45464 Compare April 24, 2026 18:57
Keep the amber background wash and bell icon as the unread signal — drop
the bottom accent bar so the tab bar reads less noisy.
@brennanb2025
brennanb2025 merged commit 861f21f into main Apr 24, 2026
2 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/notif-on-pane branch April 24, 2026 21:05
nwparker added a commit that referenced this pull request Apr 28, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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.

1 participant