Skip to content

fix(notifications): tapping a phone push opens the agent that sent it - #31773

Merged
AmoabaKelvin merged 3 commits into
mainfrom
notification-opens-agent-pane
Oct 24, 2026
Merged

AmoabaKelvin merged 3 commits into
mainfrom
notification-opens-agent-pane

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​45 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​38
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​30 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​26

Fixes #29141

What changes for users

Before: tapping an "agent finished" or "needs input" push on iOS or Android opened the right workspace but landed on its default tab. In a workspace with several agents you then had to find the one that sent it.

Now: the tap opens the agent that sent the push. This works for pushes from a desktop window, from headless orca serve and windowless agents, and from native chats. If that agent has since closed, the workspace opens as before.

Root cause

The phone, the push gateway and the session page all route on a push's paneKey already. The host never put one in. MobileNotificationDispatchEvent had no pane field, so all three producers dropped it, and push-dispatcher.ts had nothing to forward. The original push rollout (#19951) sent it; the revert (#20040) removed it, and the re-land (#20068) brought back only the gateway and phone halves.

The fix

  • The mobile event and PushSendNotification carry paneKey, and the dispatcher copies it into the gateway send.
  • Desktop window path (notification-delivery-service.ts): sends the pane from the same request the desktop uses for its own banner click. A terminal on a paired server shows up in the window under a web-terminal-… mirror tab id, which the server never names. The push carries the server's own key instead (new toHostSessionPaneKey, built on the existing toHostSessionTabId), because the phone asks the server for tabs.
  • Headless serve (terminal-agent-phone-push.ts): sends the pane it already has.
  • Native chat (structured-agent-session-mobile-attention.ts): sends structuredAgentSessionPaneKey(structuredAgentSessionTabId(sessionId), sessionId). The host has no window tab id, and the phone's notificationPaneTab already matches this key.
  • Phone (use-notification-pane-navigation.ts): a pane missing from the loaded tab list is held until a fresh list names it, instead of being dropped. A workspace screen kept from before a reconnect can show a list that predates the agent.

Mixed versions: the gateway contract has accepted paneKey since #20066. Older phones ignore it, and older hosts never send it, so those phones keep opening the workspace.

Left out: the optional "Agent no longer available" toast. The page can't tell whether a tab list is fresh or a stale one kept from before a reconnect. Showing the toast safely would need new snapshot plumbing, and without it the toast would fire wrongly after a reconnect.

Verification

  • Focused tests that fail on main: the desktop path through the real push dispatcher (including a remote-server terminal's key), the headless serve producer, the native-chat producer, and the hook opening a pane that arrives in a later tab list.
  • Changed-file oxlint, react-doctor and the mobile typecheck pass.
  • Simulator check (iOS 27): I paired a hidden dev host from this branch and opened two terminals, "Agent one" (the default tab) and "Agent two". I generated the APNs body by running the delivery service, push dispatcher and the gateway's buildPushDelivery, once on main's host files and once on this branch, and delivered each with xcrun simctl push. The simulator would not take a synthetic tap on a system banner, so a temporary, uncommitted listener called the app's own tap handler with the delivered notification. Routing and the pane switch after that are the real code.

Visual Proof

Before (main's payload, no paneKey): the tap opens the workspace on Agent one.

(screenshot removed: contained real product data)

After (this branch's payload): the tap opens Agent two, the agent that finished.

(screenshot removed: contained real product data)

The host's mobile notification event had no pane, so desktop, headless
serve and native-chat pushes reached the phone without the paneKey it
already routes on. Carry it from each producer through the push
dispatcher, and tell the user when the named agent has since closed.
A terminal on a paired server reaches the window under a mirror tab id
the server never names, so the phone could not find it. Push the
server's own pane key, and keep a missing pane pending until a fresh
tab list names it instead of dropping it against a stale list.
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

Mobile notifications now carry pane identifiers for structured sessions and terminal notifications. Mobile delivery converts present pane keys to host-session pane keys and forwards them through push payloads. The mobile navigation hook keeps a request pending when its pane is absent and switches tabs when an updated tab list includes that pane.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🔵 Low · up to aaaf1

A narrow legacy terminal-notification case may open the workspace without selecting the tapped terminal; filter invalid pane keys before dispatch.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 12 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main user-facing change: tapping a phone push opens the agent that generated it.
Description check Passed The description covers the user impact, root cause, implementation, fallback behavior, linked issue, testing, visual proof, compatibility, and out-of-scope work. It does not reproduce every template h…
Linked Issues check Passed Issue #29141 requires that a mobile notification tap open the agent that sent the notification. It also requires a fallback to the workspace when that agent no longer exists. The toast is optional. Th…
Out of Scope Changes check Passed All changed files relate to the notification pane identity. The changes cover the event and gateway types, the push dispatcher forwarding, the three producers, the shared toHostSessionPaneKey helper…
Full details: Description check

Explanation

The description covers the user impact, root cause, implementation, fallback behavior, linked issue, testing, visual proof, compatibility, and out-of-scope work. It does not reproduce every template heading, but it provides the required information in equivalent sections.

Full details: Linked Issues check

Explanation

Issue #29141 requires that a mobile notification tap open the agent that sent the notification. It also requires a fallback to the workspace when that agent no longer exists. The toast is optional. The PR adds paneKey to MobileNotificationDispatchEvent and PushSendNotification. PushDispatcher.planSend forwards it to the gateway. Each producer sets it: desktop delivery (notification-delivery-service.ts) uses toHostSessionPaneKey, headless serve (terminal-agent-phone-push.ts) sends its existing pane key, and native chat (structured-agent-session-mobile-attention.ts) builds the key from the session. On the phone, use-notification-pane-navigation.ts at the reviewed head switches to the named tab once terminalsLoaded is true. A pane missing from the current tab list stays pending. It is applied when a later list includes it. If the pane never appears, the workspace keeps its existing default tab. Focused tests cover the desktop dispatcher path, the headless and native-chat producers, and the delayed tab-list hook case. Limit: the incremental diff tool returned no diff text. The hook behavior was checked from the file at the reviewed head, not from an incremental diff.

Full details: Out of Scope Changes check

Explanation

All changed files relate to the notification pane identity. The changes cover the event and gateway types, the push dispatcher forwarding, the three producers, the shared toHostSessionPaneKey helper, the mobile pane-navigation hook, and their tests. The toHostSessionPaneKey helper maps a mirrored web-terminal tab to the server's host-session tab. This supports the desktop producer. The optional toast is not implemented, and the PR states this reason. The reviewed file shows no unrelated production behavior.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · 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: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 41e4365e-1340-44b1-8842-621a145a7129
📥 Commits

Reviewing files that changed from the base of the PR and between 84cafff and e420669.

📒 Files selected for processing: 12
  • mobile/src/session/use-notification-pane-navigation.test.tsx
  • mobile/src/session/use-notification-pane-navigation.ts
  • src/main/notifications/notification-delivery-service.test.ts
  • src/main/notifications/notification-delivery-service.ts
  • src/main/runtime/push/push-dispatcher.ts
  • src/main/runtime/push/push-gateway-client.ts
  • src/main/runtime/runtime-mobile-notification-controller.ts
  • src/main/runtime/structured-agent-session-mobile-attention.test.ts
  • src/main/runtime/structured-agent-session-mobile-attention.ts
  • src/main/runtime/terminal-agent-phone-push.test.ts
  • src/main/runtime/terminal-agent-phone-push.ts
  • src/shared/terminal-surface-id.ts

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

Comment thread src/shared/terminal-surface-id.ts Resolved
…nt tab

A mirror tab named for a server surface decodes to `tab::leaf`, which
made the pane key throw inside dispatch and dropped the desktop banner
too. Send the parent tab, which is what the phone matches.

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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟡 Minor · Stop forwarding a pane key that mobile cannot parse. · terminal-agent-phone-push.ts:173-207

src/main/runtime/terminal-agent-phone-push.ts:173-207
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Stop forwarding a pane key that mobile cannot parse.

buildEvent forwards the paneKey argument unchanged into the dispatch request and the returned event. The terminal producer builds that key with makeRuntimePaneKey, which returns ${leaf.tabId}:${leaf.paneRuntimeId} when leaf.leafId is not a UUID. The legacy-ingress path accepts that key. Mobile then calls the shared parsePaneKey, which returns null for a non-UUID leaf, so the tap cannot resolve the terminal from the key.

Keep the existing paneKey for buildAgentNotificationId and readLabels. Limit the change to the emitted paneKey field, and emit it only when parsePaneKey accepts it. This addresses only non-UUID leaves. Parseable per-surface mirror keys are a separate issue.


ℹ️ Review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 05e773a2-f459-48ae-b9b4-ffc90298662b
📥 Commits

Reviewing files that changed from the base of the PR and between e420669 and aaaf195.

📒 Files selected for processing: 2
  • src/main/notifications/notification-delivery-service.test.ts
  • src/shared/terminal-surface-id.ts
🚧 Files skipped from review as they are similar to previous changes: 1
  • src/main/notifications/notification-delivery-service.test.ts

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

@AmoabaKelvin
AmoabaKelvin merged commit 33bd67e into main Oct 24, 2026
41 checks passed
@AmoabaKelvin
AmoabaKelvin deleted the notification-opens-agent-pane branch October 24, 2026 02:34
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.

[Feature]: Mobile notification should deep-link to the specific agent that finished, not the first agent in the project

1 participant