Repository navigation
feat(native-chat): notify on every settled structured turn - #22105
Conversation
A structured chat that finished while you were elsewhere lit the sidebar but never raised an OS notification, and a notification that did arrive for one could not open the chat it came from. Unread and delivery now come out of the single resolveAgentAttention decision the terminal lane already uses: the structured dispatcher calls applyAgentAttention instead of applyAgentAttentionUnread, so the same policy that decides what to light also decides what to deliver, through the same sound and blocked-permission tail. Every settled turn notifies, as the CLI lane does. Success says "finished"; failure and cancellation say "stopped" through the shipped agentInterrupted flag rather than a second vocabulary. A turn whose outcome the host never stated stays unknown and lights nothing. The host now dedupes mobile fan-out by event identity (scope, session, turn) beside the existing per-workspace burst cooldown, so a completion two windows both saw reaches the phone once while each window still decides its own banner. Clicking a structured notification reveals the chat tab: its pane key's leaf is synthetic, so focusTerminal would hunt a split-layout leaf that does not exist.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 📝 WalkthroughWalkthroughThe change adds shared renderer notification delivery for terminal and structured agent-session notifications. Settled agent turns now notify for known failure and cancellation outcomes. Main tracks announced notification IDs by pane key for subject-based dismissal. Notification clicks route agent sessions to editor tabs and other notifications to terminal panes. Focus requests distinguish user-initiated navigation. Priority: ➖ Normal Merge Risk: 🔵 Low · up to Notification retirement can consume unnecessary main-process resources for malformed IPC input. Bound pane-key arrays and notification key lengths before merging. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description is detailed and covers the requested behavior, rationale, testing, visual proof, compatibility, and checklist items. However, the required Linked Issue is missing; it explicitly states that no GitHub issue exists. Resolution Add the required issue reference in the Linked Issue section, preferably using the required
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 24bd8d4d-df52-42e4-883b-ad2883219b19
📒 Files selected for processing (16)
src/main/ipc/native-notification-delivery.tssrc/main/ipc/notifications-retention-lifecycle.test.tssrc/main/notifications/notification-delivery-service.test.tssrc/main/notifications/notification-delivery-service.tssrc/preload/api/ui-bridge-terminal-and-session-tabs.tssrc/preload/api/ui-command-event-api.tssrc/renderer/src/attention/agent-attention-notification-delivery.tssrc/renderer/src/components/native-chat/StructuredAgentSessionAttentionBridge.test.tsxsrc/renderer/src/components/native-chat/structured-attention-dispatch.test.tssrc/renderer/src/components/native-chat/structured-attention-dispatch.tssrc/renderer/src/components/terminal-pane/use-notification-dispatch.tssrc/renderer/src/hooks/ipc-events-test-harness.tssrc/renderer/src/hooks/ipc-events/terminal-ui-routing-ipc-bridge.tssrc/renderer/src/hooks/structured-session-completion-focus.test.tssrc/shared/notification-event-dedupe.tssrc/shared/notification-settings-types.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.
There was a problem hiding this comment.
ℹ️ No critical issues — one minor suggestion inline, plus a folder-workspace note.
Reviewed changes
A settled structured (native-chat) turn now raises the same OS notification the terminal lane does, and clicking it opens the chat.
- One decision drives unread and delivery —
structured-attention-dispatch.tsmoves fromapplyAgentAttentionUnreadtoapplyAgentAttentionwith arequestDelivery, soresolveAgentAttentiondecides both. Success says "finished", failure/cancellation say "stopped" viaagentInterrupted; an absent outcome still lights and dispatches nothing. - Shared delivery tail extracted — the success sound and blocked-permission fallback move to
attention/agent-attention-notification-delivery.ts; the terminal lane calls the same code. - Mobile fan-out deduped per event — a new optional
mobileDedupeKeyis reserved at most once innotification-delivery-service.ts, seated beside the existing burst cooldown, so two windows no longer double-notify the paired phone while each window keeps its own banner. - Clicking a chat notification reveals the chat — optional
surface: 'agent-session'routes the click toui:focusEditorTab, anduserInitiatedlets that reveal survive the not-yet-active workspace the precedingui:activateWorktreeleaves behind. - Tests — end-to-end bridge, delivery-service event/cooldown separation, click routing, focus bypass, and the ack round trip all covered and green locally (46/46).
ℹ️ Folder-workspace chat notifications still cannot be clicked
The notes claim folder workspaces are "covered, not assumed" because "a folder workspace's id contains :: like a git worktree's". It does not: folderWorkspaceKey is folder:<id> (src/shared/workspace-scope.ts:11), a single colon. The click binding is attached only when args.worktreeId.includes('::') (src/main/ipc/native-notification-delivery.ts:76), so for a folder workspace no click handler is registered at all and the banner is inert — the opposite of the PR's "clicking it takes you to the chat". This guard is pre-existing (the terminal lane has the same hole), so fixing it may be out of scope here, but the note is inaccurate and the new feature is unreachable in that workspace kind.
Technical details
# Folder-workspace structured-chat click is unreachable
## Affected sites
- `src/main/ipc/native-notification-delivery.ts:76` — `args.worktreeId.includes('::')` gates the entire `notification.on('click', ...)` registration.
- `src/shared/workspace-scope.ts:11` — `folderWorkspaceKey(id)` returns `folder:<id>`.
- `src/renderer/src/components/native-chat/structured-attention-dispatch.ts:102` — sends `worktreeId: request.workspaceId`, i.e. `tab.worktreeId`, which for a folder tab is `folder:<id>`.
## Required outcome
- Either make the click path work for `folder:*` ids, or correct the PR note to say folder workspaces are not covered by the click.
## Open questions for the human
- Is `ui:activateWorktree` able to resolve a `folder:<id>` id (no repoId), or does the guard need a folder-specific branch before it can be lifted?DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…fies Two review findings on the structured-chat notification lane, both real. The mobile event gate consumed its reservation before the per-workspace burst cooldown ran. Two chats in one workspace share that cooldown key, so the second chat's completion could burn its event key and then lose the cooldown to the first chat — never announced, yet permanently marked as announced, so a later window dispatching it could no longer reach the phone. The gate now peeks first and records the event at dispatch, which also keeps a known duplicate from burning the cooldown slot. A notification id is minted from the status row's stateStartedAt, and the row re-projects that field as the turn settles: the working episode's start moves into stateHistory and the settled start takes its place. A banner raised in the window before that re-projection therefore carried an id acknowledgement never rebuilt, leaving it on screen for good. Acknowledgement now collects ids for the row's left episodes too — the same episodes the unread check beside it already scanned, so the two halves finally read the same turns. Lane-neutral: the terminal lane mints its ids the same way and had the same gap.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
A follow-up commit fixes the mobile-gate regression and the acknowledgement-id interleaving raised in the prior review.
- Mobile gates now spend themselves only when they act —
notification-event-dedupe.tsbecomes an ask/record pair (wasNotificationEventSeen/rememberNotificationEvent), with the record committed inside the cooldown-admitted branch ofnotification-delivery-service.ts, so a completion the workspace cooldown turned away can still reach the phone from a later window. The cooldown is confirmed not to mutate on rejection (notification-burst-cooldown.ts:30-32), so the retry path the new test exercises is real. - Acknowledgement dismisses every episode the row has left —
collectAcknowledgedAgentNotificationIdbecomes...Ids, iterating the row's current and historicalstartedAtstarts.agent-status-live-entry-builder.ts:93-101preserves the outgoing workingstateStartedAtinstateHistory, which is exactly the value a pre-re-projection banner was minted from, so the gap the prior review flagged is closed. The change is lane-neutral and benefits the terminal lane's identical id minting. - Tests — a two-chats-one-workspace case proving a cooldown-rejected completion lands after the window, plus a settled-after-working case asserting both the working-start and settled-start ids are dismissed.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…lder workspaces
The per-event mobile dedupe defended against one completion being
dispatched by several Orca windows. Only one renderer mounts the
structured attention bridge, the completion feed is live-only with no
replay, and any in-process duplicate lands inside the existing 5s
per-workspace burst cooldown, which already collapses mobile and
desktop alike. The gate never acted on a real sequence, so the wire
field, the shared ledger and its tests go; mobile delivery is back to
main's behavior.
A folder workspace id ("folder:<id>") has no "repoId::" prefix, so the
click binding was skipped and clicking a chat notification there did
nothing. The chat route selects its workspace itself through
ui:focusEditorTab, so it now binds without a repoId; the terminal
route is unchanged.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Commit 4414b47 settles both concerns left open by the earlier reviews: it drops the per-event mobile dedupe gate and makes a chat notification clickable in a folder workspace.
- Folder-workspace chat clicks now bind —
deliverNativeNotificationcomputesrepoIdandchatTargetindependently, so anagent-sessiondispatch attaches a click handler even when the workspace id (folder:<id>) has norepo::prefix, sending onlyui:focusEditorTab. That handler activates the workspace itself throughsetActiveWorktree, which handles folder keys (set-active-worktree.ts:125-132,274-276); the terminal route still requires a repo id and is unchanged. Two new main-process tests pin both payloads. - Per-event mobile gate reverted —
mobileDedupeKey,shared/notification-event-dedupe.ts, thenotification-delivery-servicepeek/record wiring and the tests that exercised them are removed, so mobile fan-out again rides the per-workspace burst cooldown alone. The rationale checks out:StructuredAgentSessionAttentionBridgemounts only fromAppBackgroundServices(AppBackgroundServices.tsx:41), which is rendered once inApp.tsx:96(the dashboard popout usesDashboardPopoutRoot), and the completion feed is deliberately live-only with no catch-up (structured-agent-session-turn-completion-feed.ts:3-10). Removing the gate cannot reintroduce the cooldown-burn bug it had fixed, since there is no longer an event key to burn.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…s rebuilt from a moved row A banner's id is minted from the status row's stateStartedAt at dispatch, and that field moves afterwards: a completion can outrun the settled re-projection, and a settled structured row is re-stamped with no history entry by any later journal row (a cancel appends a status note after the turn settles). Rebuilding ids from the row's episodes at acknowledgement missed the second case and fanned out up to 21 mobile dismissals per pane for ids never raised. The shared delivery tail now records each dispatched id per subject; acknowledgement retires those plus the current-row rebuild it always had. The acknowledgement collector is back to main's single-field form.
… main Main now records, per pane, the ids it actually announced (a desktop banner shown or a phone alert sent) and an acknowledgement passes the acknowledged pane keys so main retires all of them. This replaces the renderer-side record of dispatched ids: main is where the announcement happens, so it records only real announcements, including phone alerts whose desktop banner focus suppressed. The id rebuilt from the current row stays as the fallback after a restart empties the in-memory record.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Commit fbac1f0 replaces the basis of the acknowledgement-id fix: instead of rebuilding candidate ids from the row's episode history, the delivery tail now records the ids it actually hands to main, which also covers a settled row re-stamped with no history entry.
- Dispatched ids are recorded, not rebuilt — new
attention/dispatched-agent-notification-ids.tsholds a bounded per-subject map (256 subjects × 20 ids; dedupe within a subject; least-recently-notified eviction viaMapre-insertion).deliverAgentAttentionNotificationrecords(request.paneKey, request.notificationId)before the dispatch promise. - Acknowledgement retires the raised ids —
ui-slice-activity-actions.tstakes the recorded ids for each acknowledged pane and folds them into the dismiss set beside the unchanged current-row rebuild, so a banner whose row start moved after dispatch (working→done, or a done→done re-stamp with no history entry) is now dismissed. - The history rebuild is reverted —
collectAcknowledgedAgentNotificationIdsand thestateHistoryscan are gone;ui-slice-agent-notification-acknowledgement.tsis back to its base shape. The terminal lane shares the delivery tail, so it gains the same record-based dismissal. - Tests — the bridge test dispatches against a
workingand adonerow, moves the row's start, then acknowledges and asserts the raised id is dismissed; a new unit test pins dedupe, the 20-id cap and least-recently-notified eviction.
I also traced the record's window locality: every acknowledgeAgents caller that can reach a native banner runs in the main renderer, including the dashboard path, which acks through onAckAgent in this window (useDashboardPopoutBridge.ts:148). The per-renderer map therefore introduces no cross-window dismissal gap, and an empty map after reload falls back to the current-row rebuild exactly as before.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Commit 5efa7c1 relocates the announced-notification record from the renderer to the main process, so retirement is driven by what main actually announced rather than ids the renderer hands over.
- Main owns the record — new
main/notifications/announced-notification-registry.tsis a bounded per-pane map (256 panes × 20 ids, deduped, least-recently-announced eviction).notification-delivery-service.tsgainsrecordAnnounced, fired once per path that actually announced: the desktop banner afterdeliverNativereportsdelivered, and the mobile send inside the cooldown-admitted branch, so a focus-suppressed phone alert is still retired and a cooldown-rejected request records nothing. notifications:dismissretires by subject — the handler takes an optionalpaneKeys, folds each subject's recorded ids into the dismiss set beside the renderer's rebuilt ids, then closes the banners and sends the mobile dismissals.ui-slice-activity-actions.tsnow passes the acknowledged pane keys alongside the rebuilt ids.- Renderer map deleted —
attention/dispatched-agent-notification-ids.tsand its test are gone; both lanes keep sharing the delivery tail, and main's record is now cross-window and survives a renderer reload. - Tests — three new main-process cases drive the real IPC handlers: a shown banner retired by subject alone, a focus-suppressed phone alert still retired, and a cooldown-rejected request recording nothing. The unit test pins dedupe, the per-subject cap and LRU eviction.
I traced the announce semantics for both lanes: the terminal request (use-notification-dispatch.ts:170) and the structured request (structured-attention-dispatch.ts:103) both carry paneKey and notificationId, and both only record after a real announcement, so nothing is dismissed that was never raised. The registry is recreated per registerNotificationHandlers, which is called once at startup (register-core-handlers.ts:167).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 0fff4e89-e83c-4992-a341-4b70e126f1ec
📒 Files selected for processing (12)
src/main/ipc/notifications-subject-retirement.test.tssrc/main/ipc/notifications-test-harness.tssrc/main/ipc/notifications.tssrc/main/notifications/announced-notification-registry.test.tssrc/main/notifications/announced-notification-registry.tssrc/main/notifications/notification-delivery-service.tssrc/preload/api/notifications-bridge.tssrc/preload/api/os-permission-api.tssrc/renderer/src/components/native-chat/StructuredAgentSessionAttentionBridge.test.tsxsrc/renderer/src/components/native-chat/structured-attention-dispatch.tssrc/renderer/src/store/slices/ui-agent-send-target.test.tssrc/renderer/src/store/slices/ui/ui-slice-activity-actions.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/renderer/src/components/native-chat/structured-attention-dispatch.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.
| ) | ||
| // Why: an acknowledged subject retires everything announced for it, including ids minted | ||
| // from a row start that has since moved and so can no longer be rebuilt by the renderer. | ||
| for (const paneKey of Array.isArray(paneKeys) ? paneKeys : []) { |
There was a problem hiding this comment.
🔒 Security & Privacy | 🛡️ Detected with Advanced Tier | 🟡 Minor | ⚡ Quick win
Denial of Service
Reachability: External
Exploitability: Difficult
CWE: CWE-400 — Uncontrolled Resource Consumption
Reachability path
● Entry
src/main/ipc/notifications-subject-retirement.test.ts:31
registerNotificationHandlers: oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: these paths read only getSettings; Store is a class, so a struc…
│
▼
● Sink
src/main/ipc/notifications.ts
Limit paneKeys before the retirement loop.
An untrusted renderer can invoke notifications:dismiss with an arbitrarily large paneKeys array. The type guard accepts it, and this loop runs once per element on the main-process thread. A compromised renderer can stall the application. Reject or cap the array to the registry subject limit before this loop.
Based on learnings, main-process IPC data must be validated and sanitized as untrusted renderer input.
| ids.push(notificationId) | ||
| // Re-insert so eviction drops the subject least recently announced, not the first ever seen. | ||
| idsBySubject.delete(paneKey) | ||
| idsBySubject.set(paneKey, ids.slice(-maxIdsPerSubject)) |
There was a problem hiding this comment.
🔒 Security & Privacy | 🛡️ Detected with Advanced Tier | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
sed -n '1,190p' src/main/notifications/announced-notification-registry.ts
sed -n '1,230p' src/main/notifications/notification-delivery-service.ts
rg -n "notifications:dispatch|notifications\\.dispatch|NotificationDispatchRequest|recordAnnounced" src/preload src/main src/renderer --glob '!node_modules' | head -260Repository: stablyai/orca
Length of output: 21754
🏁 Script executed:
#!/bin/bash
set -eu
sed -n '1,110p' src/preload/api/notifications-bridge.ts
rg -n "export (type|interface).*NotificationDispatchRequest|NotificationDispatchRequest|paneKey|notificationId" src/shared src/preload src/main/ipc --glob '*.ts' | head -180Repository: stablyai/orca
Length of output: 24817
Denial of Service
Reachability: External
Exploitability: Difficult
CWE: CWE-400 — Uncontrolled Resource Consumption
Bound renderer-controlled notification keys before recording them. The preload bridge forwards notifications.dispatch arguments directly to main IPC, and the main handler records paneKey and notificationId after delivery. The registry limits only subject and ID counts, so it can retain up to 256 subjects and 20 IDs per subject with arbitrary string sizes. Enforce maximum string lengths before calling announced.record.




ELI5
If you start a chat with an agent inside Orca and then go do something else, the app used to quietly highlight the chat in the sidebar and leave it at that. Your computer never told you the agent was done, so you had to keep checking. Now you get the same desktop notification you already get for agent work run in a terminal — and clicking it takes you to the chat.
What Changed
Before. A structured (non-terminal) chat that finished while you were looking elsewhere lit the sidebar unread markers and nothing else. No banner, no sound, no phone notification. And in the one case where a notification for a chat did reach you, clicking it did nothing — it tried to focus a terminal pane that does not exist for a chat.
After. Every turn that settles raises one notification, exactly as the terminal lane does:
Failure and cancellation ride the
agentInterruptedflag that already produces "stopped" wording for terminal agents, so there is no second vocabulary and no new translation string. A turn with no outcome stays unknown — nothing here turns that absence into a success.The mechanism. Three changes, all of them removing a divergence rather than adding a branch.
One decision now drives both halves.
structured-attention-dispatch.tscalledapplyAgentAttentionUnread, the half of the shared attention seam that only writes unread markers. It now callsapplyAgentAttentionand suppliesrequestDelivery, so the singleresolveAgentAttentionverdict decides both what lights up and what gets delivered. The delivery tail itself (success sound, blocked-permission fallback toast, warning on a rejected dispatch) was inline in the terminal hook; it moved torenderer/src/attention/agent-attention-notification-delivery.tsand both lanes now call it. The terminal hook's behaviour is unchanged — it is the same code, relocated.The structured lane deliberately does not route through
dispatchTerminalNotification. That function's first half arbitrates PTY evidence — a committed terminal title against a hook status snapshot, with staleness and pane-reuse rules — because a terminal can only ever infer that a turn ended. A structured session does not infer: the execution host derived the completion from its own journal commit and handed us an explicit outcome. Everything after that arbitration is shared.Clicking a chat notification opens the chat. A structured session's pane key has a synthetic leaf minted from the session id, so
ui:focusTerminalhunted a split-layout leaf that is not in any layout and the click silently did nothing. The dispatch request now carriessurface('terminal' | 'agent-session', absent meaning terminal, which is every sender that predates structured chat), and anagent-sessionclick sendsui:focusEditorTabwith the unified tab id from the same key. That reveal path already existed but had a guard that drops a reveal for a workspace that is not currently active — correct for the courtesy reveal it was written for, wrong for a click, becauseui:activateWorktreeis sent first and lands asynchronously, so the active id read a moment later is still the old one. The payload gaineduserInitiated?: boolean, set only by the notification click; every existing sender omits it and behaves exactly as before. The click binds even when the workspace id has norepoId::prefix — a folder workspace (folder:<id>) has none, so the terminal route skips binding there, but the chat route selects its workspace itself throughui:focusEditorTaband needs no repo id.A banner raised before the row's start moves is still dismissible. A notification's id is minted from the status row's
stateStartedAtat dispatch, and that field moves afterwards in two ways: a completion can outrun the settled re-projection (the working start moves intostateHistory), and a settled chat row is re-stamped with no history entry by any later journal row — a cancel appends a status note after the turn settles, so the "stopped" banner's start is simply gone. Acknowledgement rebuilt ids from the row as it stands, so either case left the banner, and its mobile push, undismissed.Main now retires by subject. The delivery service reports each request it actually announced — a desktop banner shown, or a phone alert sent (including one whose desktop banner focus suppressed) — and
notifications.tsrecords its id under the request's pane key in a bounded in-memory registry (announced-notification-registry.ts, 256 panes × 20 ids, least recently announced evicted).notifications:dismisstakes an optionalpaneKeysalongside the ids; for each key it closes every recorded banner, sends the mobile dismissal for every recorded id, and drops the entry. The renderer's acknowledgement passes the acknowledged pane keys, and still sends the ids it rebuilds from the current row, which is the fallback after an app restart empties the registry — main's behaviour today. The acknowledgement collector is unchanged from main.This reaches the terminal lane too, since every lane acknowledges through the same action: terminal banners are now retired by the id they were announced with as well. Only ids main actually announced are recorded, so nothing is dismissed that was never shown, and a subject with nothing recorded costs a map lookup and no mobile writes.
Why
The gap was not "structured chat has no notification feature". The seam, the policy, the four store sinks, the surface adapter and the whole delivery tail already shipped. One call site asked for the unread half only, and delivery was never requested. Adding a parallel notifier for the structured lane would have meant a second suppression rule, a second sound policy and a second acknowledgement id to keep in sync with the terminal lane forever; supplying the argument the seam was designed to take costs one function and keeps exactly one implementation of each.
Alternatives considered and rejected:
agentInterruptedatnotification-options.ts:78already produces that wording for terminal agents. A second vocabulary for the same user-visible sentence is a divergence waiting to drift.suppressWhenFocused+browserWindow.isFocused()innotification-delivery-service.ts(which returnssuppressed-focusfor desktop while still letting the paired phone through, because desktop focus only means this computer sees the workspace).completedAtis the completion feed's own clock (structured-agent-session-turn-completion-feed.ts:141,deps.now()), while the row's settledstateStartedAtissummary.updatedAt=journal.lastActivityAt() || deps.now()(structured-agent-session-status-feed.ts:264). They are different values, so seeding from the completion relocates the mismatch instead of removing it.userInitiated. Rejected: the reveal logic is identical, only the authority behind it differs. A boolean on the existing payload leaves every current sender untouched; a new channel would duplicate the routing.How the exhaustive claims were enumerated
AGENT_JOURNAL_TURN_OUTCOMES, the shippedas consttuple atsrc/shared/agent-session-journal-types.ts:191thatAgentJournalTurnOutcomeis derived from. A new outcome arm added there is admitted automatically and typechecks at the call site; nothing in this PR needs updating.ui:focusEditorTabsender omitsuserInitiatedand is unchanged."grep -rn "focusEditorTab" srcover the whole tree, then splitting the hits by role. There are exactly two routes onto the channel: the notifier contract (runtime-notifier-contract.ts:97, implemented atruntime-window-lifecycle.ts:167, whose only callers areorca-runtime-get-worktree-ps.ts:219andorca-runtime-perform-mobile-session-pty-records-refresh.ts:239and:243), and the directwebContents.sendthis PR touches atnative-notification-delivery.ts:100. The contract's signature is(tabId, worktreeId)— it has no third parameter to pass — so every pre-existing sender structurally cannot set the flag. On the receiving side there is one real consumer,terminal-ui-routing-ipc-bridge.ts:148; the other matches are the preload bridge and test stubs.Linked Issue
No GitHub issue — this is PR 3 of the A1 structured-chat attention track, tracked in the track's own plan rather than an issue. The work supersedes closed PR #21408.
Visual Proof
N/A — the changed surface is an OS-level notification banner and its click target. Capturing it would require raising a real notification on the desktop, which the repo's Electron validation rules forbid (hidden renderers and CDP screenshots only, never OS input or focus stealing). The banner's rendering is unchanged: this PR routes an existing notification shape through an existing delivery path, and does not touch
buildNotificationOptions, which owns the wording and layout. Behaviour is pinned by automated tests at every hop instead — see below.Testing
Automated, covering each hop rather than only the endpoints:
StructuredAgentSessionAttentionBridge.test.tsx— the end-to-end frame, with only the transport and the preload bridge mocked. A host completion goes in; the unread indicators and one realNotificationDispatchRequestcome out. Covers success (agentInterrupted: false), failure and cancellation (both light everything and setagentInterrupted: true), and a completion from a host that predates the outcome field (lights nothing, dispatches nothing).notifications-retention-lifecycle.test.ts— a structured click sendsui:activateWorktreethenui:focusEditorTabwithuserInitiated, and neverui:focusTerminal. The pane key is minted by the realstructuredAgentSessionPaneKey, so the synthetic leaf asserted against is the one a chat actually produces.notifications-retention-lifecycle.test.ts(cont.) — a structured click in a folder workspace (folder:fw-1) still sendsui:focusEditorTab, and sends noui:activateWorktreebecause there is no repo id to send. Ablated: restoring the repo-id-only binding fails exactly this test.StructuredAgentSessionAttentionBridge.test.tsx—retires the banner it raised after a {working,done} row moves its start: dispatch from the row, then move itsstateStartedAt(the re-projection and the done→done re-stamp), and assert the rebuilt id no longer names the banner while the acknowledgement hands main the chat's pane key. Ablated: droppingpaneKeysfrom the dismiss call inui-slice-activity-actions.tsfails both cases (and the three existing acknowledgement-dismissal tests inui-agent-send-target.test.ts).notifications-subject-retirement.test.ts— through the real IPC handlers: a shown banner is closed and its phone alert dismissed by pane key alone, and a second dismissal of the same key does nothing; a phone alert whose desktop banner focus suppressed is still retired; a request turned away by the burst cooldown on both paths is never recorded. Ablated: deleting the subject loop in thenotifications:dismisshandler fails the first two; deleting the record after the mobile send fails the focus-suppressed case.announced-notification-registry.test.ts— ids are handed back once then forgotten, de-duplicated, capped per pane, and the least recently announced pane is evicted first.structured-session-completion-focus.test.ts— the reveal survives the not-yet-active workspace whenuserInitiatedis set, and the existing courtesy reveal still declines without it.Each new mechanism was ablated rather than merely observed, re-proven at the final head (the pre-commit hook runs
oxfmt, so evidence taken before it has moved):surface === 'agent-session'branch tofalsefails the new click test while the pre-existing terminal-lane click test stays green.Each ablation asserted a match count of 1 before running, and each restoration was verified by
git statusshowing zero residue.max-lineswas checked separately with a fullpnpm exec oxlintover the changed files rather than the changed-lines gate, which anchors that diagnostic at EOF and cannot see it. Exit 0, with a positive control (a throwaway file containing an explicitany) confirming the instrument reports.Local:
pnpm tcclean;pnpm run check:code-quality:changedpasses with 0 findings; vitest green acrossnative-chat,hooks,attention,preload,shared,main/notificationsandmain/ipc.Platforms: the changed code is platform-neutral. macOS locally. The notification permission path it rides is the existing one, already platform-branched in
notification-delivery-service.tsand untouched here.Notes
tab.worktreeId, notcompletion.scope.workspaceId. The scope names the workspace on the execution host, which for a remote host is not the id this store addresses tabs and unread markers by.paneKeysonnotifications:dismissis optional on a same-build preload channel; the mobile wire is unchanged. Both new fields (surfaceon the dispatch request,userInitiatedon the focus payload) are optional and additive. A sender that omits them gets exactly today's behaviour: the terminal click route and the courtesy-reveal guard. An older host that omitsoutcomeis treated as unknown and lights nothing, which is the conservative arm.folder:id, and the notification click reveals the chat without needing a repo id (terminal-lane clicks in a folder workspace are unchanged by this PR).Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)