Skip to content

fix(bots): let paired desktops read bot handoff outcomes - #49960

Merged
nwparker merged 1 commit into
stablyai:mainfrom
lafraia:fix/paired-desktop-handoff
Nov 26, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
lafraia:fix/paired-desktop-handoff

Conversation

@lafraia

@lafraia lafraia commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When a bot chat is opened from a paired desktop and that bot hands work to another bot, the handoff card kept spinning even after the other bot had replied. The computer running the bots refused to tell a paired desktop how the handoff ended, and the card treats a refused read as "still pending". It now answers a person's paired desktop the same way it answers the host's own windows and paired phones.

What Changed

  • Before: bots.request.outcome threw invalid_argument ("Bot requests are read on the computer that runs the bots.") for every paired caller that was not a phone. On a paired desktop the handoff card never got an outcome, so it kept the pending spinner, including after reopening the chat.
  • After: the handler refuses only an agent calling over a device pairing (caller.kind === 'paired-device' && caller.agent). People's paired desktops and phones get the outcome, answer and mail ids, exactly as they already read the sending chat itself. The host's own windows and local CLI keep their access. The onClient path is unchanged.
  • Mechanism: the gate now keys off the caller identity (person vs agent) instead of the pairing scope (phone vs computer). src/main/runtime/rpc/methods/bots-request-outcome.ts, with a regression test in bots-request-outcome.test.ts.

Why

The outcome is the sending chat's own mail, and a paired desktop can already read that chat in full, so hiding the outcome from it protected nothing. It only left the card stuck. Changing the server-side gate fixes the bug for current desktops without a new client capability, new params or a renderer change, so an older paired desktop talking to an updated host is fixed too. The alternative from #49960 (scoped card lookups plus a new capability and renderer polling) was much more code for the same result.

Linked Issue

Fixes #49937

Original fix by @lafraia in #49960; final version reworked during the bug bash.

Reported by @lafraia

Visual Proof

N/A. This is a host-side RPC permission fix and the card UI is unchanged; the only visible effect is that the existing spinner resolves. A live paired-desktop-to-server capture needs two paired Orca installs and was not recorded. The before/after evidence is the regression test below, which fails on main with the exact invalid_argument error from the issue and passes on this branch.

Testing

  • Repro (unit level): bots-request-outcome.test.ts calls the handler as a paired desktop (runtime-paired scope), a paired phone, the host desktop and the local CLI. On main the paired desktop case throws InvalidArgumentError: Bot requests are read on the computer that runs the bots.; on this branch all four return { outcome: 'answered', answer: 'Done.', mailIds: ['msg_2'] }. An agent over a device pairing is still refused.

  • pnpm exec vitest run src/main/runtime/rpc/methods/bots-request-outcome.test.ts src/main/runtime/rpc/methods/orchestration/federation/paired-server-asks.test.ts: 2 files, 29 tests pass (macOS).

  • oxlint (anti-slop, code-quality native plugins), ast-grep, oxfmt and the changed-code quality gate pass on the changed files.

  • I manually tested these changes locally

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

  • Every added test fails without this change and avoids the test anti-patterns

Performance

None. The guard went from one constant-time check to another (both measured in the tens of nanoseconds per call, within noise of each other). A paired desktop now runs the same three indexed SQLite reads the host's own windows already run for this card. The card already rereads only when the bot's chat activity changes. There is no new polling, subprocess or sync file I/O.

Risk

Level: Low. The riskiest part is widening who may read a bot request outcome: paired desktops (people, not agents) can now read it. They could already read the sending chat that contains the same answer. Agents over a pairing are still refused. An updated desktop paired to an older host still sees the spinner until the host updates. To back out, revert the commit; no data or settings change.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Security: only agent callers over a device pairing stay blocked; people keep the same view of the chat they already have. Cross-platform, SSH and mobile: no platform or path code; the mobile path behaves as before.

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)
  • I stated the risk: what could break, for whom, and how to back it out
  • 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)

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The outcome handler now rejects paired-device callers when their agent value is truthy. Other callers continue to the existing outcome lookup, while client requests retain the existing client outcome path. Tests cover paired desktop, paired phone, desktop, local CLI, and paired-device agent callers.

Severity of issue fixed: Medium

Merge Risk: Moderate · up to 7606f

Paired desktops can now read bot handoff outcomes, but the host does not appear to confirm the handoff belongs to the requesting chat, card, or workspace. A paired desktop that supplies another handoff's ID could read its answer. Add the per-handoff ownership check and a test that rejects unrelated handoffs before merging.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive [#49937] requires that a paired desktop sending chat read its own handoff outcome, so the card shows the recorded reply. At head 7606fda, bots-request-outcome.ts removes the rule that rejected paired… Provide evidence for the following: (1) the BotRequestOutcomeParams schema at head and any sendingCard or sender binding, (2) whether a non-agent paired-device caller can read answer text for a messageId that is not its own sending card, an…
Passed Passed checks: 3 passed

Check name Status Explanation
Out of Scope Changes check Passed The reviewed handler hunk changes only the bots.request.outcome authorization branch and the paired-device error message. It reads the same outcome path that #49937 names. No unrelated change was foun…
Title check Passed The title "fix(bots): let paired desktops read bot handoff outcomes" matches the main change. The raw summary and PR description both say the handler now lets paired desktops read bot request outcomes…
Description check Passed The description follows the repository template closely. It covers ELI5, What Changed (before and after, plus mechanism), Why (including alternatives considered), Linked Issue (Fixes #49937), Visual P…
Full details: Out of Scope Changes check

Explanation

The reviewed handler hunk changes only the bots.request.outcome authorization branch and the paired-device error message. It reads the same outcome path that #49937 names. No unrelated change was found in the inspected hunks. The raw summary lists the test file as covering paired desktop, paired phone, desktop, CLI, and agent-denied cases, which supports the same path. Other files in the whole-PR diff were not inspected, so this result covers only the inspected hunks.

Full details: Title check

Explanation

The title "fix(bots): let paired desktops read bot handoff outcomes" matches the main change. The raw summary and PR description both say the handler now lets paired desktops read bot request outcomes, while agents over device pairings stay blocked. The title is specific, short, and follows a conventional commit style.

Full details: Description check

Explanation

The description follows the repository template closely. It covers ELI5, What Changed (before and after, plus mechanism), Why (including alternatives considered), Linked Issue (Fixes #49937), Visual Proof (N/A with reason), Testing with a regression test description, Performance with a reason, Risk with level and rollback, AI Disclosure, the upstream boundary checkbox, and the checklist. The AI Disclosure section is left empty, which is acceptable for an internal contributor. The Review and Notes sections are present. Overall the description is complete.

Full details: Linked Issues check

Explanation

[#49937] requires that a paired desktop sending chat read its own handoff outcome, so the card shows the recorded reply. At head 7606fda, bots-request-outcome.ts removes the rule that rejected paired-device callers unless callerScope.kind was mobile. Only paired-device callers with a truthy agent value are now rejected. Non-agent paired desktops reach the existing getBotRequest and getMessageById lookup. This addresses the reported invalid_argument path. However, the handler does not bind the read to the sending card or sending session. It takes only messageId and onClient, and it returns answer and mailIds for any bot request. The PR description states that the host checks the card, sender, and workspace. The earlier sendingCard path described in the previous assessment does not appear in this file's diff against the merge base. The issue also limits scope to the sender's own outcome and excludes reply contents. Other gating may exist in the params schema, the method permission ('workspace'), or the renderer. I could not inspect those in the available checks. NativeChatBotRequestCard.tsx returned an empty diff, so the renderer routing claimed earlier cannot be confirmed here. The regression test was not run.

Resolution

Provide evidence for the following: (1) the BotRequestOutcomeParams schema at head and any sendingCard or sender binding, (2) whether a non-agent paired-device caller can read answer text for a messageId that is not its own sending card, and (3) the renderer change that sends the sending session and card identifiers, including the path where it lives. If the handler lacks the card, sender, and workspace checks, add them before the paired read returns status or answer.

  • 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

A bot chat opened from a paired desktop kept showing a pending spinner on
a handoff card after the receiving bot had replied. bots.request.outcome
refused every paired non-mobile caller with invalid_argument, and the card
treats a failed read as still pending.

The handler now refuses only agents calling over a device pairing. People's
paired desktops and phones read the outcome the same way they already read
that chat, and the host's own windows and CLI keep their access.

Fixes stablyai#49937

Co-authored-by: Daniel Lafraia <[email protected]>
@nwparker
nwparker force-pushed the fix/paired-desktop-handoff branch from 8f09742 to 7606fda Compare November 26, 2026 17:53
@nwparker nwparker changed the title Fix bot handoff spinner on paired desktops fix(bots): let paired desktops read bot handoff outcomes Nov 26, 2026

@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

  • 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: 12af762d-9edf-4c98-8017-a4a96c22ff09
Commits

Reviewing files that changed from the base of the PR and between 8f09742 and 7606fda.

Files selected for processing: 2

  • src/main/runtime/rpc/methods/bots-request-outcome.test.ts
  • src/main/runtime/rpc/methods/bots-request-outcome.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.

if (pairedDeviceId !== undefined && callerScope?.kind !== 'mobile') {
throw new InvalidArgumentError('Bot requests are read on the computer that runs the bots.')
// People's paired windows and phones read it as they read that chat; an agent over a device's pairing does not.
if (context.caller?.kind === 'paired-device' && context.caller.agent) {

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.

Major · Security & Privacy · Heavy lift

Limit paired-desktop handoff reads to the sender's own handoff.

The new guard admits a paired desktop that is not an agent. The handler then looks up the supplied messageId and returns the answer body, mail IDs, and chat ID. The lookup does not check that the handoff belongs to the calling sending session, saved card, or workspace. The workspace permission admits the method for paired desktops, and the store query matches message_id alone. A paired desktop that supplies another sender's messageId can therefore read that handoff's answer.

The linked issue limits this read to the sender's own handoff, and the PR states that unrelated cards are rejected. The current code does not enforce either limit. The test double also returns a record for any identifier, so it does not cover rejection of an unrelated handoff.

For a paired desktop request, the host must confirm that the handoff belongs to the calling sending session, card, and workspace before it returns any reading. It must reject any other handoff. Keep the existing owner and phone read behavior unchanged.

@nwparker
nwparker merged commit f25a91a into stablyai:main Nov 26, 2026
57 of 58 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.

[Bug]: Answered bot handoffs keep spinning in a paired desktop chat

2 participants