Skip to content

feat(native-chat): notify on every settled structured turn - #22105

Merged
brennanb2025 merged 5 commits into
mainfrom
brennanb2025/a1-pr3-notifications
Sep 23, 2026
Merged

brennanb2025 merged 5 commits into
mainfrom
brennanb2025/a1-pr3-notifications

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​417 $\color{#cf222e}{\Huge{\mathbf{−}}}$​31 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​386
Prod 11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​257 $\color{#cf222e}{\Huge{\mathbf{−}}}$​72 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​185

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:

how the turn settled what the notification says unread markers
success "finished" yes
failure "stopped" yes
cancellation "stopped" yes
outcome the host never stated nothing no

Failure and cancellation ride the agentInterrupted flag 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.

  1. One decision now drives both halves. structured-attention-dispatch.ts called applyAgentAttentionUnread, the half of the shared attention seam that only writes unread markers. It now calls applyAgentAttention and supplies requestDelivery, so the single resolveAgentAttention verdict 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 to renderer/src/attention/agent-attention-notification-delivery.ts and 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.

  2. Clicking a chat notification opens the chat. A structured session's pane key has a synthetic leaf minted from the session id, so ui:focusTerminal hunted a split-layout leaf that is not in any layout and the click silently did nothing. The dispatch request now carries surface ('terminal' | 'agent-session', absent meaning terminal, which is every sender that predates structured chat), and an agent-session click sends ui:focusEditorTab with 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, because ui:activateWorktree is sent first and lands asynchronously, so the active id read a moment later is still the old one. The payload gained userInitiated?: 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 no repoId:: prefix — a folder workspace (folder:<id>) has none, so the terminal route skips binding there, but the chat route selects its workspace itself through ui:focusEditorTab and needs no repo id.

  3. A banner raised before the row's start moves is still dismissible. A notification's id is minted from the status row's stateStartedAt at dispatch, and that field moves afterwards in two ways: a completion can outrun the settled re-projection (the working start moves into stateHistory), 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.ts records 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:dismiss takes an optional paneKeys alongside 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:

  • Notify only on success. Rejected because the CLI lane already notifies on every settled turn, and a cancelled or failed turn is precisely the case where you most want to know you are no longer waiting. Silence for a failure reads as "still working".
  • A new wire field or i18n key for "stopped". Rejected: agentInterrupted at notification-options.ts:78 already produces that wording for terminal agents. A second vocabulary for the same user-visible sentence is a divergence waiting to drift.
  • A per-event mobile dedupe beside the burst cooldown. Rejected: only one renderer mounts the structured attention bridge, the completion feed is live-only and never replays, and an in-process duplicate lands inside the existing 5s per-workspace burst cooldown, which already collapses mobile and desktop alike. A second gate would defend a sequence that does not occur.
  • A second "do not alert me about what I am watching" suppression. Rejected and deliberately not written. Focus already answers this, twice: the surface adapter's viewed gates in the renderer, and suppressWhenFocused + browserWindow.isFocused() in notification-delivery-service.ts (which returns suppressed-focus for desktop while still letting the paired phone through, because desktop focus only means this computer sees the workspace).
  • Seeding the notification id from the completion instead of the status row. Rejected on measurement, not taste: completedAt is the completion feed's own clock (structured-agent-session-turn-completion-feed.ts:141, deps.now()), while the row's settled stateStartedAt is summary.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.
  • Recording dispatched ids in the renderer's delivery tail. Shipped in an earlier revision of this PR and replaced. The renderer only knows what it asked for; whether a banner or phone alert actually went out is decided in main after the burst cooldown and focus gates, so a renderer record also retires ids that were never announced, and misses nothing main knows. Recording where the announcement happens keeps one owner for the fact.
  • Persisting the subject registry. Deferred to a follow-up: desktop banners do not survive an app restart, so only phone alerts are affected. After a restart the renderer's row rebuild retires a phone alert only while its row has not moved since it was announced; one whose row re-stamped (for example after a cancel) stays on the phone until it expires, which is also what happens on main today. Closing that needs the subject persisted with the mobile dismissal record, which carries its own expiry, so it is kept out of this PR.
  • Rebuilding ids from every episode in the row's history. Tried first and dropped: it cannot recover a start the settled re-stamp overwrote without a history entry, and after an unacknowledge it rebuilt up to 21 ids per pane, each a disk write plus a push to every paired device, for banners that were mostly never raised.
  • A new IPC channel for the notification click instead of 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

  • "The settled outcomes are exactly success / failure / cancellation." Not a hand-written list — the guard tests membership in AGENT_JOURNAL_TURN_OUTCOMES, the shipped as const tuple at src/shared/agent-session-journal-types.ts:191 that AgentJournalTurnOutcome is derived from. A new outcome arm added there is admitted automatically and typechecks at the call site; nothing in this PR needs updating.
  • "Every existing ui:focusEditorTab sender omits userInitiated and is unchanged." grep -rn "focusEditorTab" src over 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 at runtime-window-lifecycle.ts:167, whose only callers are orca-runtime-get-worktree-ps.ts:219 and orca-runtime-perform-mobile-session-pty-records-refresh.ts:239 and :243), and the direct webContents.send this PR touches at native-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 real NotificationDispatchRequest come out. Covers success (agentInterrupted: false), failure and cancellation (both light everything and set agentInterrupted: true), and a completion from a host that predates the outcome field (lights nothing, dispatches nothing).
  • notifications-retention-lifecycle.test.ts — a structured click sends ui:activateWorktree then ui:focusEditorTab with userInitiated, and never ui:focusTerminal. The pane key is minted by the real structuredAgentSessionPaneKey, 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 sends ui:focusEditorTab, and sends no ui:activateWorktree because 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 its stateStartedAt (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: dropping paneKeys from the dismiss call in ui-slice-activity-actions.ts fails both cases (and the three existing acknowledgement-dismissal tests in ui-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 the notifications:dismiss handler 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 when userInitiated is 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):

  • Forcing the surface === 'agent-session' branch to false fails 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 status showing zero residue.

max-lines was checked separately with a full pnpm exec oxlint over 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 explicit any) confirming the instrument reports.

Local: pnpm tc clean; pnpm run check:code-quality:changed passes with 0 findings; vitest green across native-chat, hooks, attention, preload, shared, main/notifications and main/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.ts and untouched here.

  • I manually tested these changes locally — not in a running app: raising a real notification would take over the desktop, which this repo's Electron validation rules forbid. Verified through the automated coverage above instead.
  • Automated tests added/updated, or explained why not below

Notes

  • Remote / SSH. Deliberate: the subject is addressed by tab.worktreeId, not completion.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.
  • Backwards compatibility. paneKeys on notifications:dismiss is optional on a same-build preload channel; the mobile wire is unchanged. Both new fields (surface on the dispatch request, userInitiated on 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 omits outcome is treated as unknown and lights nothing, which is the conservative arm.
  • Mobile. Unchanged in shape and gating — structured completions ride the same per-workspace burst cooldown as terminal ones.
  • Folder workspaces. Covered, not assumed: structured chat is supported there, unread lighting is tested on a 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).
  • Performance. One bounded in-memory map (≤256 panes × 20 ids); acknowledgement dismisses only ids that were raised, so no extra mobile dismiss writes or pushes.

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

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.
@coderabbitai

coderabbitai Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

The 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 5efa7

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 30 functions across 26 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning 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… Add the required issue reference in the Linked Issue section, preferably using the required Fixes #<issue-number> format. If plan-only tracking is allowed, update the repository template or provide an approved tracking reference instead o…
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main change: notifications for every settled structured-chat turn.
Full details: Description check

Explanation

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 Fixes #&lt;issue-number&gt; format. If plan-only tracking is allowed, update the repository template or provide an approved tracking reference instead of leaving the issue unlinked.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 24bd8d4d-df52-42e4-883b-ad2883219b19

📥 Commits

Reviewing files that changed from the base of the PR and between 6dc0070 and c9d463c.

📒 Files selected for processing (16)
  • src/main/ipc/native-notification-delivery.ts
  • src/main/ipc/notifications-retention-lifecycle.test.ts
  • src/main/notifications/notification-delivery-service.test.ts
  • src/main/notifications/notification-delivery-service.ts
  • src/preload/api/ui-bridge-terminal-and-session-tabs.ts
  • src/preload/api/ui-command-event-api.ts
  • src/renderer/src/attention/agent-attention-notification-delivery.ts
  • src/renderer/src/components/native-chat/StructuredAgentSessionAttentionBridge.test.tsx
  • src/renderer/src/components/native-chat/structured-attention-dispatch.test.ts
  • src/renderer/src/components/native-chat/structured-attention-dispatch.ts
  • src/renderer/src/components/terminal-pane/use-notification-dispatch.ts
  • src/renderer/src/hooks/ipc-events-test-harness.ts
  • src/renderer/src/hooks/ipc-events/terminal-ui-routing-ipc-bridge.ts
  • src/renderer/src/hooks/structured-session-completion-focus.test.ts
  • src/shared/notification-event-dedupe.ts
  • src/shared/notification-settings-types.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 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.ts moves from applyAgentAttentionUnread to applyAgentAttention with a requestDelivery, so resolveAgentAttention decides both. Success says "finished", failure/cancellation say "stopped" via agentInterrupted; 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 mobileDedupeKey is reserved at most once in notification-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 to ui:focusEditorTab, and userInitiated lets that reveal survive the not-yet-active workspace the preceding ui:activateWorktree leaves 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?

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using 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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.ts becomes an ask/record pair (wasNotificationEventSeen / rememberNotificationEvent), with the record committed inside the cooldown-admitted branch of notification-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 — collectAcknowledgedAgentNotificationId becomes ...Ids, iterating the row's current and historical startedAt starts. agent-status-live-entry-builder.ts:93-101 preserves the outgoing working stateStartedAt in stateHistory, 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.

Pullfrog  | View workflow run | Using 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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 — deliverNativeNotification computes repoId and chatTarget independently, so an agent-session dispatch attaches a click handler even when the workspace id (folder:<id>) has no repo:: prefix, sending only ui:focusEditorTab. That handler activates the workspace itself through setActiveWorktree, 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, the notification-delivery-service peek/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: StructuredAgentSessionAttentionBridge mounts only from AppBackgroundServices (AppBackgroundServices.tsx:41), which is rendered once in App.tsx:96 (the dashboard popout uses DashboardPopoutRoot), 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.

Pullfrog  | View workflow run | Using 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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.ts holds a bounded per-subject map (256 subjects × 20 ids; dedupe within a subject; least-recently-notified eviction via Map re-insertion). deliverAgentAttentionNotification records (request.paneKey, request.notificationId) before the dispatch promise.
  • Acknowledgement retires the raised ids — ui-slice-activity-actions.ts takes 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 — collectAcknowledgedAgentNotificationIds and the stateHistory scan are gone; ui-slice-agent-notification-acknowledgement.ts is 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 working and a done row, 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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.ts is a bounded per-pane map (256 panes × 20 ids, deduped, least-recently-announced eviction). notification-delivery-service.ts gains recordAnnounced, fired once per path that actually announced: the desktop banner after deliverNative reports delivered, 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:dismiss retires by subject — the handler takes an optional paneKeys, 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.ts now passes the acknowledged pane keys alongside the rebuilt ids.
  • Renderer map deleted — attention/dispatched-agent-notification-ids.ts and 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).

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: ready for merge

Head: 5efa7c1e05. CI is green (no failing or pending checks) and the PR is mergeable.

Review loops

  1. Loop 1 (4414b47a04):
    • Removed the mobile event dedupe gate. It guarded nothing, because only one window ever dispatches.
    • Fixed notification clicks for chats in folder workspaces, which have no repo id.
  2. Loop 2 (fbac1f0f79): found two problems.
    • Acknowledging a chat sent more dismissals than needed.
    • A "stopped" banner could stay up after a cancel re-stamped the row.
  3. Architecture pass: the same problem came back in the "retire the right notification" area, so the design was challenged. The fix moved ownership into the main process. Main now records the notifications it actually showed for each pane (desktop banner or phone alert), and acknowledging a pane retires exactly those. The renderer-side record was deleted, and the id rebuilt from the row remains only as a fallback after a restart.
  4. Loop 3 (5efa7c1e05): implemented that refactor, with tests for the bounded registry and for retirement by pane.
  5. Loop 4: clean. A suspected race when a click reveals a chat is not real, because activating the workspace re-derives the visible tab as that chat.

Readiness checklist

Passed at the start and at the end.

Electron QA (hidden window, OS banner stubbed, structured chat flags on)

# Check Result
1 A settled structured turn sends a notification for the chat (not the terminal), and the sidebar shows unread PASS
2 Cancelling a turn produces the "stopped" wording PASS
3 Clicking the notification reveals the chat tab without focusing or showing the window PASS
4 Viewing the chat clears unread and dismisses by pane PASS
5 Terminal-lane completion Not exercised (its path is unchanged here and covered by unit tests)

Unread on a background workspace after a settled turn:
01-sidebar-unread-settled-turn

A notification click reveals the chat:
03-notification-click-reveals-chat

Unread clears after viewing:
04-unread-cleared-after-view

Planned follow-ups (not in this PR)

  • Cancel notifications: stop notifying when the user cancels a turn themselves. This will cover both native chat and terminal-based agents, because today both notify, and this PR keeps that behavior.
  • Phone notifications after a restart: persist the retirement record in the mobile dismissal store. Until then, after a restart, a re-stamped row's phone notification stays until it expires, the same as on main today.
  • Terminal clicks in folder workspaces: clicking a terminal notification in a folder workspace doesn't work. That was already true before this PR.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 0fff4e89-e83c-4992-a341-4b70e126f1ec

📥 Commits

Reviewing files that changed from the base of the PR and between 4414b47 and 5efa7c1.

📒 Files selected for processing (12)
  • src/main/ipc/notifications-subject-retirement.test.ts
  • src/main/ipc/notifications-test-harness.ts
  • src/main/ipc/notifications.ts
  • src/main/notifications/announced-notification-registry.test.ts
  • src/main/notifications/announced-notification-registry.ts
  • src/main/notifications/notification-delivery-service.ts
  • src/preload/api/notifications-bridge.ts
  • src/preload/api/os-permission-api.ts
  • src/renderer/src/components/native-chat/StructuredAgentSessionAttentionBridge.test.tsx
  • src/renderer/src/components/native-chat/structured-attention-dispatch.ts
  • src/renderer/src/store/slices/ui-agent-send-target.test.ts
  • src/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 : []) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 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))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 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 -260

Repository: 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 -180

Repository: 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.

@brennanb2025
brennanb2025 merged commit 1b85be6 into main Sep 23, 2026
36 checks passed
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