Skip to content

fix(native-chat): alert when a structured chat asks for approval or input mid-turn - #25766

Merged
brennanb2025 merged 28 commits into
mainfrom
brennanb2025/nc-prompt-attention
Oct 6, 2026
Merged

brennanb2025 merged 28 commits into
mainfrom
brennanb2025/nc-prompt-attention

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 35 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​4028 $\color{#cf222e}{\Huge{\mathbf{−}}}$​134 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3894
Prod 61 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1646 $\color{#cf222e}{\Huge{\mathbf{−}}}$​291 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1355

ELI5

When a built-in Claude or Codex chat stopped mid-task to ask for approval or a question, Orca stayed silent: no desktop notification, no unread dot, no phone alert. Only a finished turn alerted you, so an agent could sit waiting for hours while you were in another workspace. Terminal agents already alert in this situation; native chat did not.

After this change you get the same alerts for a mid-turn question that you already get for a finished turn: the unread dot, the desktop notification (with your existing notification settings), and a push to phones paired with the machine running the agent. Reading the chat, using Mark read / Mark all read, or answering the question withdraws that alert. A read never withdraws a newer question you have not seen yet.

What Changed

  • Prompt alerts come from the host that runs the agent. Its existing alert feed now announces a prompt when it becomes pending (updated clients opt in; older clients keep receiving finished-turn events only). Revisions of the same prompt, restored history and an already-announced prompt beside a finished turn stay quiet. A failed turn still alerts.
  • The host sends its own phone push, so phones paired with the machine running the agent are alerted even when no desktop chat is open. A local desktop does not push the same alert twice. For a chat on a remote host, the desktop keeps relaying alerts to phones paired with the desktop, as it does today.
  • Reading withdraws exactly what you had seen. A read records the transcript position you had reached and withdraws only alerts up to that position, on the desktop, on desktop-relayed phone alerts and on the host's phone alerts. Mark read, Mark all read and the Agent Dashboard acknowledge cover every alert the desktop had already shown for that chat at the moment you clicked, even if the chat was never opened. Automatic reads from simply viewing a chat stay bounded to what was on screen.
  • Answering or cancelling withdraws the alert. The host withdraws its phone alert when the prompt stops pending (answered, denied, turn cancelled, chat closed, agent crash, or cancelled during restart recovery). For a remote chat, the desktop withdraws the phone alert it relayed once that host's live status shows the chat is no longer waiting. It never does this from cached status after losing contact with the host.
  • Older hosts keep today's behaviour. Alerts from a host that predates this change carry no transcript position, so reading the chat withdraws them for the whole chat, as it does on main.
  • Existing notification settings, labels, wording and phone-history limits are reused. No new notice, toast or wording.

Why

The missing event belongs in the host's existing feed, because that host owns the session, knows when a prompt starts and ends, and owns its paired-phone delivery. A renderer-derived alert would add a second producer without the prompt identity needed to withdraw the right alert. A session-wide "read" would let a delayed read remove a newer question; bounding each read by the transcript position the user actually reached prevents that without a stored read flag or a retry obligation. Withdrawal of relayed remote alerts is derived from the host status the desktop already mirrors, so no new wire field is needed.

Differences from the common pattern:

  • Intended: alerts send at the update that raises the prompt, without a coalescing delay; withdrawal is driven by the host's current pending state and by actual reads.
  • Intended: reading withdraws alerts across devices. This is Orca's existing behaviour for finished turns; the bounded read position keeps it safe for prompts.
  • Intended: remote chat alerts keep the existing desktop-to-phone relay, and its withdrawal is derived from the remote host's mirrored status. Removing the relay would change other notification flows beyond this fix.
  • Intended: existing unread and notification surfaces provide the feedback; nothing new is shown.
  • Temporary: a headless folder workspace uses its folder name without a project-group prefix in its phone label. Follow-up: supply project-group metadata on the execution host.

Known limits (each has a workaround: open the chat, or swipe the phone alert):

  • A remote prompt relayed to a desktop-paired phone and then answered elsewhere stays on that phone until the chat is read or the 7-day phone history expires if the desktop reloaded or the chat tab closed in between (the relay remembers owed alerts in memory only). Follow-up: derive owed relayed alerts from the saved delivery history.
  • A phone paired with both the desktop and a remote host gets two alerts for a remote chat (host push plus desktop relay).
  • An older desktop paired with an updated remote host cannot withdraw that host's phone alerts by reading.
  • Older socket-only phones may need the push gateway or a reconnect for immediate withdrawal across a host restart.

Linked Issue

N/A — maintainer change from a native chat audit.

Visual Proof

Remote Electron QA ran on a separate Mac (M4Air) against the PR branch, with an isolated test profile and a scripted Codex stand-in that raises a real approval request mid-turn through the actual chat host. Dev builds on that machine cannot show macOS banners, so notification and phone delivery were checked through main-process logs plus the rendered app.

Background chat asks for approval: the workspace is marked as needing input (round 2, final head)
02b-S1-background-prompt-unread.jpg

After opening the chat and clicking in it, the alert is withdrawn while the approval is still pending (round 2, final head; log showed the read at journal position 14 and the phone alert withdrawn)
04b-S3-after-click.jpg

Activity Mark read on a chat that is not open withdraws its alerts (round 1)
07-S4-activity-unread.jpg
08-S4-after-mark-read.jpg

Answering the approval withdraws the prompt alert (round 1)
04-S5-answered.jpg

After restart, nothing re-alerts for resolved prompts (round 1)
11-S6-after-restart.jpg

Testing

Final head: 29d0bcebebd6578ac5ab56ff34b7c27cdbfa2db3 (includes current main cc6006779ff).

  • tc-gate pnpm tc:node, tc:web and tc:cli pass.

  • 153 explicit test files / 1410 tests pass, including new production-path tests for: Mark read and Mark all read on never-opened chats, older-host alerts, remote prompts answered elsewhere / cancelled / host restart, status frames arriving out of order, failed withdrawal retry, dashboard click vs. watch intent, and the chat read tracker surviving a tab move. Each new test failed before its fix. Mobile typecheck and test-type checks pass.

  • Cross-version wire suites pass (session 41, registered agents 8, attention frames 4). Saved delivery history survives upgrade, rollback and re-upgrade (10/10, real main and PR store code against one file).

  • Changed-code quality: zero new findings across 96 files; oxlint and React Doctor pass; no lockfile or dependency change.

  • CI on the final head: 16 passed, 16 skipped, 0 failed (one unrelated timing test, terminal-history-gc.test.ts, failed once and passed on re-run).

  • Remote Electron QA (M4Air, isolated profile, scripted Codex stand-in, CDP-driven hidden window): a background mid-turn approval produced one desktop alert request and one phone push under the prompt's identity; answering withdrew it; Activity Mark read on an unopened chat withdrew all of its alerts; a normal background turn still alerted once as finished; restart did not re-alert. Round 1 found that opening a chat did not withdraw its alert; the cause was a real bug (fixed, see Review) plus the existing "user is away" check, which treats an untouched test machine as idle. Round 2 on the final head confirmed that a real click in the opened chat withdraws the pending prompt's phone alert. Not run in round 2: withdrawing a finished-turn alert by reading (the test app was closed by an outside quit of every dev Electron app on that machine); covered by automated tests. Not verified: a real phone receiving or clearing a push, a real macOS banner, foreground focus suppression, Windows/WSL, SSH remote hosts.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Review rounds found and fixed 21 proven issues (1 P1, 13 P2, 7 P3). The P1 was the headless host failing to load because the new phone producer imported desktop-only code. The P2s cover alert identity, delayed and out-of-order reads, restart withdrawal, older-host compatibility, Mark read on unopened chats, and withdrawal of remote alerts relayed to phones, and a chat losing track of what was read after a tab move. A final readiness review of all eight release categories found no release-blocking issue. Details, deferred items and what was not verified are in the review comment.

Agent skill upstream boundary

  • Not applicable; no upstream skill-installer content is copied or translated.

Notes

Draft, unmerged, auto-merge disabled.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • 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
  • Required checks pass or are covered by CI

…nput mid-turn

A structured Claude or Codex chat that stopped mid-turn to ask for approval or a
question raised no OS notification, no phone push and no unread dot: the host's
attention feed only fired when a turn settled. The host now announces each newly
pending prompt once, from the same feed, and owns the phone push for its own
structured sessions; desktops keep presentation only.

- host feed: a `prompt` edge per pending approval/question, opt-in on the
  existing stream; a clean settle that only restates an announced prompt is not
  re-announced to prompt-aware clients; failures always are
- host push: an in-process subscriber pushes the host's paired phones with
  labels from in-memory metadata, and withdraws a prompt's alert once answered
- one attention identity for desktop banner, phone push, dedupe and retirement;
  delivery dedupes on it instead of the per-workspace burst window
- agentSession.acknowledgeAttention routes reading a chat to its owning host,
  which retires what it pushed for that session via its dismissal record
@brennanb2025

brennanb2025 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

Review summary (final head 29d0bcebebd6578ac5ab56ff34b7c27cdbfa2db3)

This replaces the earlier interim note in this comment.

The problem

When a built-in Claude or Codex chat stopped mid-turn to ask for approval or a question, Orca sent nothing: no desktop notification, no unread dot, no phone push. Only a finished turn alerted. A user who had switched away could leave the agent waiting indefinitely. Terminal agents already alert in this situation.

What changes for the user

  • A mid-turn approval or question now raises the same alerts a finished turn does: the unread dot, the desktop notification (existing settings apply) and a push to phones paired with the machine running the agent.
  • Reading the chat, Mark read / Mark all read (even on a chat never opened), the Agent Dashboard acknowledge, or answering the prompt withdraws that alert on the desktop and the phone. A read never withdraws a newer question the user hasn't seen.
  • For a chat on a remote host, the phone alert the desktop relayed is withdrawn once that host's live status shows the chat is no longer waiting.
  • Alerts from hosts that predate this change keep today's behaviour: reading the chat withdraws them.
  • No new notices, toasts or wording.

What review found and fixed (21 proven issues)

  • P1 (1): the headless/SSH host could not load, because the new phone producer imported desktop-only code. Fixed by giving the existing notification formatter an optional translator with an English fallback.
  • P2 (13):
    • a prompt raised in the same update as a finished turn was alerted under the turn's identity, so answering it didn't withdraw it;
    • a delayed read withdrew a newer, unseen prompt;
    • a restart sent withdrawals under the wrong identity;
    • a prompt cancelled during restart recovery kept its alert;
    • reading a second pending prompt didn't withdraw it;
    • a failed withdrawal blocked later reads;
    • a late prompt event re-alerted after the chat was read;
    • a missing read position skipped the structured-session admission check;
    • alerts from older hosts could never be withdrawn;
    • Mark read on a chat that wasn't open withdrew nothing;
    • relayed remote prompt alerts were never withdrawn when answered elsewhere or cancelled;
    • that relay withdrawal could fire early when status arrived out of order;
    • the chat's read tracker dropped out of its registry after a tab move or a dev-mode effect re-run, so opening the chat cleared the dot but withdrew nothing. This one was found by remote QA.
  • P3 (7):
    • a saved delivery record from a newer build was discarded on downgrade;
    • the acknowledgment call was renamed v2 → v1, takes a required read position and lost its dead fallback (it never shipped);
    • a session-wide withdrawal method with no callers was deleted;
    • the host's withdrawal check now runs only when a prompt stops pending, not on every update;
    • automatic Activity and Dashboard reads were counted as clicks;
    • a status that arrived while a withdrawal was in flight was dropped.
  • Eleven of these came from earlier review fixes in this loop; each was caught and fixed here.
  • The final readiness review of all eight release categories (no counsel step) found no release-blocking issue.
  • The architecture challenger's verdict: keep the design, don't split. Neither half lands safely alone: the host half would double-push local completions, and the desktop half still needs the whole read machinery.

Deferred (known limits, each with a workaround: open the chat or swipe the phone alert)

  • P2: if the desktop reloads or the chat tab closes after relaying a remote prompt, and the prompt is then answered elsewhere, the relayed phone alert stays until the chat is read or the 7-day phone history expires. The desktop remembers owed relayed alerts in memory only. Follow-up: derive them from the saved delivery history.
  • P3:
    • a phone paired with both the desktop and a remote host gets two alerts for a remote chat;
    • writes to the saved delivery history are synchronous on a full store (pre-existing store design);
    • a resolution in the same millisecond as the prompt, or a rewind, delays the relayed withdrawal to the next status update.
  • Residual, unproven: if the host's phone subscriber ever threw, the feed would drop it until restart. No throwing input was found.
  • Broader than the issue, flagged for the reviewer: phone push for structured chats now comes from the execution host. Local chats push without an open tab, and headless hosts push finished turns too. This follows from having one phone producer per session.

Verified

  • tc-gate node, web and cli; mobile typecheck and test-type checks.
  • 153 explicit test files / 1410 tests, with new production-path tests that failed before each fix.
  • Cross-version wire suites (41/8/4), and saved delivery history across upgrade, rollback and re-upgrade (10/10).
  • Changed-code quality (0 new findings), oxlint, React Doctor.
  • Final merge of current main (cc6006779ff): one import-only conflict, resolved keeping both sides; a fresh reviewer compared every file both sides changed and found nothing lost. tc-gate node/web/cli, 269 targeted test files, cross-version suites (41/8/4) and localization checks pass after the merge.
  • CI on the final head: 16 passed, 16 skipped, 0 failed. The first run had one failed test out of 21,756, src/main/terminal-history-gc.test.ts (a timing check that got exactly 5 timer ticks where it wanted more than 5). That file isn't touched by this PR; the re-run passed.
  • Remote Electron QA on a separate Mac (isolated profile; a scripted Codex stand-in raising a real mid-turn approval through the real chat host; delivery checked via main-process logs, since dev builds there can't show banners):
    • a background prompt alerts once under its own identity;
    • answering withdraws it;
    • Mark read on an unopened chat withdraws all of its alerts;
    • a finished turn still alerts once;
    • restart doesn't re-alert;
    • on the final head, a real click in the opened chat withdrew the pending prompt's phone alert.
  • The machine's real agent config files were unchanged by the runs. Screenshots are in the PR body.

Not verified

  • Withdrawing a finished-turn alert by reading, in the app. The second QA round's test app was closed by an outside quit of every dev Electron app on that machine; automated tests cover it.
  • A real phone receiving or clearing a push.
  • A real macOS banner, and focus suppression with a truly focused window.
  • Windows/WSL, and SSH remote hosts.
  • The QA worktree on the remote Mac couldn't be a child of the local one (lineage is per host), so it was created standalone.

- Mark read and Mark all read on a chat that was never opened, or is hidden,
  now cover what lit its row: the read boundary is the later of the transcript
  cursor and the newest edge the tab was handed, captured at the click. The
  one boundary closes the banners, retires relayed phone alerts and drives the
  host acknowledgement; an edge after the click stays live.
- An alert from a host older than journal cursors has no position, so a pane
  read retires it again, banner and relayed phone push, as before this change.
- A desktop-relayed prompt alert for a remote chat is withdrawn once that
  host's live status stops reporting attention (answered elsewhere, cancelled,
  host restart); cached status after loss of contact never settles it.
- The attention acknowledgement is agent-session.attention-ack.v1 with a
  required journal cursor and strict params; the cursorless no-op is gone.
- The dismissal store keeps a record whose origin a newer build wrote,
  dropping only that origin.
- Host reconciliation runs on restore and when a prompt leaves the pending
  set, not on every journal commit.
- Remove unused session-wide retirement (retire, retireMatching,
  retireMobileNotificationsMatching) and test-only store lookups.
…view

- A remote chat's status and its prompt edges arrive on separate sockets, so a
  status row queued before the prompt could land after it and withdraw a
  relayed alert that was still pending. Settlement now needs a live,
  non-attention row whose host updatedAt (the journal's latest row time, never
  decreasing) is later than the prompt's host raisedAt. The owed prompt is
  cleared only once the settle call succeeds, so a failed call retries on the
  next qualifying row.
- An acknowledgement without captured reads now reads as a view. Mark read,
  Mark all read, the hover-card jump and both dashboard acks pass 'explicit';
  Activity's automatic per-turn read stays a view.
…g is a view

- Settlement is one check of the current mirror, run on each status row, after
  each settle call returns, and when a prompt edge arrives. A row that lands
  while a call is out is no longer dropped, and an edge that arrives after its
  own resolution settles at once. A rejected call is retried only once the
  mirror holds a different row, so a failing call cannot loop.
- The Agent Dashboard's card click acknowledges as explicit; watching the open
  dialog acknowledges as a view, through both the in-window drawer and the
  pop-out relay, and no longer re-acks the state the click just read.
A chat pane memoizes its read owner. When every holder let go in one commit and
the same owner was picked up again (React StrictMode's effect re-run in
development, or a pane remounted in one commit, as on a tab move), the release
dropped it from the registry and nothing put it back. The attention bridge then
found no owner, so a view read carried no cursor: the unread dot cleared but
the banner and phone alerts stayed. An owner now names its key again whenever
it gains an activation or a subscriber and the key is free, never over a
different live owner.
Main moved these types into agent-session-turn-completion-wire.ts while this branch moved them into agent-session-attention-wire.ts. They now live at main's path with this branch's additions (journal cursor, prompt attention, prompt arm); the unused completion key is dropped.
@brennanb2025
brennanb2025 marked this pull request as ready for review October 6, 2026 23:13
@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

Walkthrough

The change adds prompt events to structured agent-session attention streams and adds APIs for acknowledging reads. The renderer captures view and explicit reads, while host services use read cursors and prompt state to retire desktop and mobile notifications. Mobile delivery records structured origins and preserves the original delivery identity when retiring alerts. Notification wording uses the active desktop translation where available.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 29d0b

Prompt alerts mostly work as intended. However, when an agent raises several approvals at the same moment, only one alert may appear. A rare delivery error could also stop phone alerts until the app restarts. Both fixes are small and local.

🚥 Pre-merge checks | ✅ 4 | ❓ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ❓ Inconclusive Docstring coverage is 13.64% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 44 functions across 50 files. (45 skipped… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: alerts for approval or input requests during a structured chat turn.
Description check ✅ Passed The description is detailed and mostly complete. It covers the user impact, changes, rationale, testing, visual proof, review findings, known limits, and cross-platform considerations. The maintainer-…
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 13.64% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 44 functions across 50 files. (45 skipped: 45 over the file limit.)

✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c22eb892-d3b4-4407-8a73-88040f8420b8
📥 Commits

Reviewing files that changed from the base of the PR and between cc60067 and 29d0bce.

⛔ Files ignored due to path filters (1)
  • src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by !**/*.generated.*
📒 Files selected for processing (95)
  • mobile/src/notifications/desktop-notification-events.ts
  • mobile/src/notifications/push-original-delivery-retirement.test.ts
  • mobile/src/notifications/push-socket-dismissal.ts
  • src/main/host/electron-runtime-desktop-surface.ts
  • src/main/host/structured-attention-localization.test.ts
  • src/main/ipc/dashboard-popout.test.ts
  • src/main/ipc/dashboard-popout.ts
  • src/main/ipc/notification-options.ts
  • src/main/ipc/notifications-subject-retirement.test.ts
  • src/main/ipc/notifications-test-harness.ts
  • src/main/ipc/notifications.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-client-delivery.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-host.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-status-feed.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-turn-completion-feed.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-turn-completion-feed.ts
  • src/main/notifications/announced-notification-registry.test.ts
  • src/main/notifications/announced-notification-registry.ts
  • src/main/notifications/notification-delivery-service.test.ts
  • src/main/notifications/notification-delivery-service.ts
  • src/main/runtime/mobile-notification-dismissal-store.test.ts
  • src/main/runtime/mobile-notification-dismissal-store.ts
  • src/main/runtime/orca-runtime-get-worktree-ps.ts
  • src/main/runtime/push/push-delivery-policy.test.ts
  • src/main/runtime/push/push-dispatcher.ts
  • src/main/runtime/rpc/methods/structured-agent-session-attention-ack.test.ts
  • src/main/runtime/rpc/methods/structured-agent-session-rpc.test-fixture.ts
  • src/main/runtime/rpc/methods/structured-agent-session-schemas.ts
  • src/main/runtime/rpc/methods/structured-agent-session-turn-completion-stream.test.ts
  • src/main/runtime/rpc/methods/structured-agent-session-turn-completion-stream.ts
  • src/main/runtime/rpc/methods/structured-agent-session.test.ts
  • src/main/runtime/runtime-desktop-surface.ts
  • src/main/runtime/runtime-mobile-notification-controller.ts
  • src/main/runtime/runtime-service-command-surface.ts
  • src/main/runtime/structured-agent-session-mobile-attention.test.ts
  • src/main/runtime/structured-agent-session-mobile-attention.ts
  • src/main/runtime/structured-agent-session-mobile-restore.test.ts
  • src/main/runtime/structured-agent-session-mobile-retirement.test.ts
  • src/main/runtime/structured-agent-session-runtime.ts
  • src/main/runtime/structured-attention-original-delivery.test-fixture.ts
  • src/preload/api/dashboard-api.ts
  • src/preload/api/dashboard-bridge.ts
  • src/preload/api/notifications-bridge.ts
  • src/preload/api/os-permission-api.ts
  • src/renderer/src/attention/agent-subject-read-actions.ts
  • src/renderer/src/components/activity/activity-auto-mark-read-loop.react185.test.tsx
  • src/renderer/src/components/activity/activity-thread-actions.test.ts
  • src/renderer/src/components/activity/activity-thread-actions.ts
  • src/renderer/src/components/activity/activity-thread-hover-card-summary.tsx
  • src/renderer/src/components/activity/use-activity-thread-action-bindings.test.tsx
  • src/renderer/src/components/activity/use-activity-thread-action-bindings.ts
  • src/renderer/src/components/dashboard-popout/AgentKanbanBoard.test.tsx
  • src/renderer/src/components/dashboard-popout/AgentKanbanBoard.tsx
  • src/renderer/src/components/dashboard/AgentDashboardDrawer.tsx
  • src/renderer/src/components/dashboard/useDashboardPopoutBridge.ts
  • src/renderer/src/components/native-chat/StructuredAgentSessionAttentionBridge.test.tsx
  • src/renderer/src/components/native-chat/StructuredAgentSessionAttentionBridge.tsx
  • src/renderer/src/components/native-chat/structured-agent-session-read-owner-registry.ts
  • src/renderer/src/components/native-chat/structured-agent-session-read-owner.ts
  • 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/native-chat/structured-attention-read-observation.ts
  • src/renderer/src/components/native-chat/use-structured-agent-session-read.ts
  • src/renderer/src/components/native-chat/use-structured-agent-session-transport.ts
  • src/renderer/src/hooks/agent-auto-ack-surfaces.ts
  • src/renderer/src/hooks/useAutoAckViewedAgent.ts
  • src/renderer/src/runtime/structured-agent-session-client.ts
  • src/renderer/src/runtime/structured-agent-session-turn-completion-feed.test.ts
  • src/renderer/src/runtime/structured-agent-session-turn-completion-feed.ts
  • src/renderer/src/store/slices/ui/ui-slice-activity-actions.ts
  • src/renderer/src/store/slices/ui/ui-slice-contract-core.ts
  • src/renderer/src/web/preload-api/web-notifications-api.ts
  • src/shared/agent-session-attention-capabilities.ts
  • src/shared/agent-session-attention.ts
  • src/shared/agent-session-turn-completion-wire.ts
  • src/shared/mobile-notification-identity.ts
  • src/shared/notification-settings-types.ts
  • src/shared/protocol-version.ts
  • src/shared/rpc-contract/structured-agent-session-identifiers.ts
  • src/shared/rpc-contract/structured-agent-session-params.ts
  • src/shared/structured-agent-session-projection.ts
  • src/shared/structured-agent-session-surface-capabilities.ts
  • tests/e2e/__mocks__/structured-attention-read-surfaces.ts
  • tests/e2e/cross-version-wire/cross-version-agent-session-wire.unit.test.ts
  • tests/e2e/cross-version-wire/cross-version-structured-attention-frames.unit.test.ts
  • tests/e2e/cross-version-wire/structured-agent-session-surface-execution.ts
  • tests/e2e/cross-version-wire/structured-agent-session-surface-manifest.ts
  • tests/e2e/structured-attention-explicit-read.unit.test.ts
  • tests/e2e/structured-attention-headless-delivery.unit.test.ts
  • tests/e2e/structured-attention-host-read-retirement.unit.test.ts
  • tests/e2e/structured-attention-prompt-relay.unit.test.ts
  • tests/e2e/structured-attention-read-owner-lifecycle.unit.test.ts
  • tests/e2e/structured-attention-read-retirement.test-fixture.tsx
  • tests/e2e/structured-attention-read-retirement.unit.test.ts
  • tests/e2e/structured-attention-relay-settlement.unit.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

Comment on lines +143 to +170
// An answered prompt leaves the set, so only a prompt not pending last commit is news.
const raised = state.pendingPromptIds.find((id) => !baseline.prompts.has(id))
baseline.prompts = prompts
const completion = this.settledCompletion(sessionId, session, state, baseline)
if (completion) {
completion.journalCursor = cursor
const restatesPrompt = completion.awaitingUser === true && completion.outcome === 'success'
this.broadcast({ type: 'completion', completion }, restatesPrompt ? 'legacy' : 'all')
if (!restatesPrompt) {
return
}
}
if (raised === undefined) {
return
}
this.broadcast(
{
type: 'prompt',
prompt: {
scope: session.params.location,
sessionId,
promptId: raised,
journalCursor: cursor,
raisedAt: this.deps.now()
}
},
'prompt-aware'
)

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Announce every prompt that a commit adds, not only the first one.

raised uses find, so it holds at most one new prompt id. Line 145 then adds every pending id to baseline.prompts. If one commit adds two prompts, for example two parallel subagent approvals in one batch, only the first gets a prompt edge. The second id never gets one, because later commits treat it as already seen.

There is a second consequence. The host's phone delivery and the desktop alert exist only for the first prompt. When the user answers that prompt, publishState reports the second prompt as still pending. reconcileStructuredPromptAttention then withdraws the first alert, so no alert is left while the agent still waits for input.

Send one prompt edge for each new id. Each id already has its own attention key, so delivery dedupe and retirement keep working.

🐛 Proposed fix
-    const raised = state.pendingPromptIds.find((id) => !baseline.prompts.has(id))
+    const raised = state.pendingPromptIds.filter((id) => !baseline.prompts.has(id))
     baseline.prompts = prompts
@@
-    if (raised === undefined) {
-      return
-    }
-    this.broadcast(
-      {
-        type: 'prompt',
-        prompt: {
-          scope: session.params.location,
-          sessionId,
-          promptId: raised,
-          journalCursor: cursor,
-          raisedAt: this.deps.now()
-        }
-      },
-      'prompt-aware'
-    )
+    for (const promptId of raised) {
+      this.broadcast(
+        {
+          type: 'prompt',
+          prompt: {
+            scope: session.params.location,
+            sessionId,
+            promptId,
+            journalCursor: cursor,
+            raisedAt: this.deps.now()
+          }
+        },
+        'prompt-aware'
+      )
+    }

The doc comment on observe ("at most one event per subscriber") would need the same update.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// An answered prompt leaves the set, so only a prompt not pending last commit is news.
const raised = state.pendingPromptIds.find((id) => !baseline.prompts.has(id))
baseline.prompts = prompts
const completion = this.settledCompletion(sessionId, session, state, baseline)
if (completion) {
completion.journalCursor = cursor
const restatesPrompt = completion.awaitingUser === true && completion.outcome === 'success'
this.broadcast({ type: 'completion', completion }, restatesPrompt ? 'legacy' : 'all')
if (!restatesPrompt) {
return
}
}
if (raised === undefined) {
return
}
this.broadcast(
{
type: 'prompt',
prompt: {
scope: session.params.location,
sessionId,
promptId: raised,
journalCursor: cursor,
raisedAt: this.deps.now()
}
},
'prompt-aware'
)
// An answered prompt leaves the set, so only a prompt not pending last commit is news.
const raised = state.pendingPromptIds.filter((id) => !baseline.prompts.has(id))
baseline.prompts = prompts
const completion = this.settledCompletion(sessionId, session, state, baseline)
if (completion) {
completion.journalCursor = cursor
const restatesPrompt = completion.awaitingUser === true && completion.outcome === 'success'
this.broadcast({ type: 'completion', completion }, restatesPrompt ? 'legacy' : 'all')
if (!restatesPrompt) {
return
}
}
for (const promptId of raised) {
this.broadcast(
{
type: 'prompt',
prompt: {
scope: session.params.location,
sessionId,
promptId,
journalCursor: cursor,
raisedAt: this.deps.now()
}
},
'prompt-aware'
)
}

Comment on lines +311 to +318
emit: (event) => {
if (event.type === 'end') {
return
}
const sessionId =
event.type === 'prompt' ? event.prompt.sessionId : event.completion.sessionId
delivery.deliver(event, installed.readStatusSummary(sessionId))
},

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Keep one failed delivery from removing the host phone subscriber permanently.

When emit throws, the feed's broadcast catches the error and deletes the subscriber. Nothing subscribes host-attention-delivery again, so this host sends no phone alerts until the process restarts. Nothing is logged. emit runs readStatusSummary, buildNotificationOptions, getRuntimeDesktopSurface().isAwayForMobileNotifications and controller.dispatch. A throw from any of them costs every later alert on this host, not only the current one.

Catch the error inside the callback and log it, so one bad edge is dropped and the subscription survives.

🛡️ Proposed fix
       emit: (event) => {
         if (event.type === 'end') {
           return
         }
         const sessionId =
           event.type === 'prompt' ? event.prompt.sessionId : event.completion.sessionId
-        delivery.deliver(event, installed.readStatusSummary(sessionId))
+        try {
+          delivery.deliver(event, installed.readStatusSummary(sessionId))
+        } catch (error) {
+          // One edge's failure must not unsubscribe host delivery for the rest of the run.
+          deps.logger.warn('structured attention delivery failed', {
+            scope: 'attention-delivery',
+            sessionId,
+            error
+          })
+        }
       },

The PR summary already lists this as a deferred limitation. The fix is local and small.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
emit: (event) => {
if (event.type === 'end') {
return
}
const sessionId =
event.type === 'prompt' ? event.prompt.sessionId : event.completion.sessionId
delivery.deliver(event, installed.readStatusSummary(sessionId))
},
emit: (event) => {
if (event.type === 'end') {
return
}
const sessionId =
event.type === 'prompt' ? event.prompt.sessionId : event.completion.sessionId
try {
delivery.deliver(event, installed.readStatusSummary(sessionId))
} catch (error) {
// One edge's failure must not unsubscribe host delivery for the rest of the run.
deps.logger.warn('structured attention delivery failed', {
scope: 'attention-delivery',
sessionId,
error
})
}
},

@brennanb2025
brennanb2025 merged commit 35e173a into main Oct 6, 2026
77 of 79 checks passed
Jinwoo-H added a commit that referenced this pull request Oct 6, 2026
#26010)

#25888 and #25766 added tests that import the orchestration database or the
structured session runtime without registering them in the Node runtime list,
so vitest-sqlite-runtime-boundary fails on main and every PR.
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