Skip to content

fix(mobile): explain Open in Session refusal on headless hosts - #23357

Open
Meapri wants to merge 2 commits into
stablyai:mainfrom
Meapri:fix/mobile-headless-file-fallback
Open

Meapri wants to merge 2 commits into
stablyai:mainfrom
Meapri:fix/mobile-headless-file-fallback

Conversation

@Meapri

@Meapri Meapri commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When the phone is paired to an Orca host with no desktop window (orca serve on a server), tapping Open in Session on the diff review screen used to surface the raw renderer_unavailable error. Now it explains "This host has no desktop to open tabs in. The diff is shown here instead." and the action stays enabled, so each tap asks the host again.

What Changed

  • Before: On a headless host, Open in Session showed the raw renderer_unavailable code.
  • After: It shows a plain explanation and leaves the action enabled. Every tap asks the host again, so a host that gains a window (or a replaced connection) can still open the tab on the next tap.
  • Mechanism: The review screen's Open in Session checks the reply with upstream's isRendererUnavailableReply. On that refusal it shows the explanation instead of the raw code; there is no other tab to open because the screen the user is on already shows the diff. The message goes through translate like the other strings in the file; the new key is session.useDiffReviewInteractions.sessionTabsUnavailable in en.json (other locales fall back to English).

Rebase note

This PR originally also added on-device fallbacks for tapping a changed file and a file path on headless hosts. Upstream has since covered both (the changed-file tap always opens the on-device review screen, and the file tap already falls back to the file preview), so those commits were dropped in the rebase onto current main. What remains is only the Open in Session explanation above.

Why

Upstream only hides Open in Session for routed execution hosts (useWorkspaceOnPairedHost), which doesn't cover a paired headless host. Showing the raw refusal code tells the user nothing; the explanation says why, and keeping the action enabled avoids latching off a host that may gain a window while the screen is open.

Linked Issue

Part of #22186 (the Open in Session part). #14315 is now covered upstream.

Testing

  • use-mobile-diff-review-open-in-session.test.ts (ported during the rebase; mounts the interactions hook directly): a renderer_unavailable reply shows the explanation and doesn't return to the session, and the action stays enabled. When the host can open the tab on the next tap, the user goes back to the session. A desktop host's successful open returns to the session.
  • The ported test was not run locally in the rebase environment (no node_modules); CI is green on the current head.

AI Disclosure

Claude Opus 5.5 (via Claude Code) wrote the fix and the tests, directed by a human. The rebase port was also done with Claude Code.

Review

  • Cross-platform (iOS / Android): Shared TypeScript logic, no platform branches.
  • SSH / remote / local: Phone-only change, no RPC or field added. Desktop hosts never send this refusal, so nothing changes there.
  • Performance: No extra requests; each tap makes the same single request as before.
  • UI quality: One line of explanation text; the action stays available.
  • Security: No new permissions or inputs; the phone only reads a refusal code.

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.

Author

X: @mea_pri

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 — the only UI change is one line of explanation text; the original screenshots covered the dropped fallbacks and were removed with them
  • 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). Left to CI after the rebase port; CI is green on the current head.

🤖 Generated with Claude Code

@Meapri
Meapri marked this pull request as ready for review September 27, 2026 08:07
Copilot AI lite review requested due to automatic review settings September 27, 2026 08:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@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 — the two fixes are correct and well-tested. One related surface is left unaddressed, noted below; nothing blocks merge.

Reviewed changes

  • Shared refusal recognizer — new mobile/src/transport/renderer-unavailable-refusal.ts matches both the runtime_error + renderer_unavailable message shape current hosts send and a bare renderer_unavailable code, and mobile-markdown-disk-fallback.ts now delegates to it.
  • Session changed-file open — the diff-tab / edit-tab fallback moved out of use-mobile-source-control-openers.ts into a testable chooseSessionDiffOpen + openSessionChangedFile, with a new device-review outcome that routes to the phone's review screen (git.diff) when the host refuses for having no renderer.
  • Terminal / chat file tap — mobile-file-tap-open.ts now pushes the source: 'worktree' file-preview route when files.open is refused with renderer_unavailable, instead of reporting the open as failed.

I verified the extraction is behavior-preserving for every case the old inline code could reach (request order, which operation interprets, error wrapping, mounted/openingPathRef handling), and that the recognizer matches the wire shape the host actually produces (orca-runtime-file-commands.ts throws new Error('renderer_unavailable'); mapRuntimeError flattens it to code: 'runtime_error'). No reachable reply is misrouted: renderer_unavailable cannot collide with the forbidden/method_not_found edit-tab predicate, and sibling-worktree / line-column taps are intercepted earlier.

ℹ️ Open in Session still surfaces the raw renderer refusal on a headless host

This PR newly makes the review screen reachable on a rendererless host (the device-review route), and one action on that screen still shows the same raw renderer_unavailable the PR is removing elsewhere. openInSession calls files.openDiff and interprets the reply without the fallback, so tapping Open in Session on a headless host sets the action error to renderer_unavailable. The other unchanged caller (use-mobile-session-content-create-actions.ts:71, create markdown note) is already called out as out of scope in the PR body, so this may be intentional too — raising it only so the coverage decision is explicit.

Technical details
# `openInSession` has no renderer fallback

## Affected sites
- `mobile/src/session/use-mobile-diff-review-interactions.ts:188-198` — `openInSession` requests `files.openDiff` and calls `sourceFileDiffOpenRun.interpret` directly; a `renderer_unavailable` refusal reaches `setActionError` verbatim.
- `mobile/src/components/MobileDiffReviewDrawers.tsx:143-148` — the "Open in Session" action is enabled whenever there is a non-branch current item, so it is tappable on the review screen the new fallback opens.

## Required outcome
- Decide the headless behavior for this action: hide/disable it, route through the new `isRendererUnavailableRefusal`, or explicitly leave it failing. No wire change is involved either way.

## Open questions for the human (optional)
- Is "Open in Session" meant to remain available on a host that has no session tab to open?

ℹ️ Nitpicks

  • mobile/src/source-control/session-changed-file-open.ts:53 reuses chooseSessionDiffOpen on the edit reply, where the returned 'edit-tab' value is meaningless and only 'device-review' is consumed; calling isRendererUnavailableRefusal(editReply) directly would read more plainly.

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

@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The mobile review interaction now detects renderer-unavailable replies when opening a diff in the desktop session. It sets translated fallback text and returns without interpreting the reply or selecting the session diff. Added tests cover this response, a later successful attempt, and the arguments sent for a successful open.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 594f1

When a host has no desktop renderer, Open in Session now explains this and stays available for retry. Tests cover the refusal and success paths. No merge-blocking risk is identified.

Security architecture risk: Low · up to d526e

The fallback reuses existing phone views and preserves the selected worktree and file. No introduced authorization bypass was established. Host-side read authorization was not fully verified, leaving limited uncertainty around the new fallback paths.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The effective change makes existing device readers reachable from additional file-opening gestures on renderer-less hosts. Inspected fallback inputs remain bound to the selected or resolved worktree; the host-side enforcement determines the ultimate readable scope.

Trust Boundaries and Controls

  • observed — Absolute terminal artifacts retain a separate grant-bound preview route. The existing preview test asserts that these reads carry absolutePath and grantId through files.readTerminalArtifact rather than using ordinary files.read.
  • observed — The inspected RPC boundary exposes the runtime enforcement calls, but does not establish whether read authorization and path containment are equivalent to renderer-opening operations. This remains a proof gap, not an observed bypass.

Resilience and Maintainability Implications

  • observed — Open in Session uses direct requests without a response-generation check, so overlapping or client-replacement requests can complete out of order. This request model predates the PR; sequential retry is tested, but concurrency and replacement behavior remain unverified. No introduced security or persistent-state consequence was established.
Pre-merge checks: Passed 4

Check name Status Explanation
Linked Issues check Passed The only directly linked issue, #14315, is closed. The issue is marked as historical context only. Its acceptance criteria are not requirements for this pull request, so no active coding requirements …
Out of Scope Changes check Passed The described changes stay within the renderer_unavailable fallback scope. They include: a shared isRendererUnavailableRefusal check; routing of session changed-file opens in session-changed-file-open…
Title check Passed The title names the main change: on headless hosts, Open in Session now explains the renderer_unavailable refusal. It also uses the conventional fix(mobile) prefix. The changeset matches: a new sessio…
Description check Passed The description follows the repository template closely. It has ELI5, What Changed (before and after plus mechanism), Why, Linked Issue (partial, 'Part of #22186'), Testing, Performance, Risk, AI Disc…
Full details: Linked Issues check

Explanation

The only directly linked issue, #14315, is closed. The issue is marked as historical context only. Its acceptance criteria are not requirements for this pull request, so no active coding requirements apply. The pull request still addresses the same user-facing failure: the changed-file diff refusal with renderer_unavailable. The PR description and the changes since the previous review show a host-refusal fallback to the device review screen. The previous assessment reached the same result, and the later Open in Session change does not alter it.

Full details: Out of Scope Changes check

Explanation

The described changes stay within the renderer_unavailable fallback scope. They include: a shared isRendererUnavailableRefusal check; routing of session changed-file opens in session-changed-file-open.ts to the device review screen; a file-tap fallback to the file preview; reuse of the check in the markdown-tab disk fallback; and an Open in Session explanation on the review screen, backed by SESSION_TABS_UNAVAILABLE_MESSAGE and an en.json string. Each change connects to the refusal handling. The new tests cover these same paths. The review did not read the full diff. The judgment relies on the PR description and the partial change summary, which show no unrelated file or behavior.

Full details: Title check

Explanation

The title names the main change: on headless hosts, Open in Session now explains the renderer_unavailable refusal. It also uses the conventional fix(mobile) prefix. The changeset matches: a new sessionTabsUnavailable message, a SESSION_TABS_UNAVAILABLE_MESSAGE constant, and a refusal branch in use-mobile-diff-review-interactions.ts with tests. The PR objectives mention broader changes (file fallbacks), but those were dropped in the rebase, so the title stays accurate.

Full details: Description check

Explanation

The description follows the repository template closely. It has ELI5, What Changed (before and after plus mechanism), Why, Linked Issue (partial, 'Part of #22186'), Testing, Performance, Risk, AI Disclosure, Review, and Checklist. The Visual Proof section gives a reason for lacking visuals rather than a before/after pair, which is a gap for a UI-visible text change. The Risk section has no 'Level' value filled in, and the 'Fixes #' line is replaced by 'Part of #22186'. The Testing section says the ported test was not run locally, and the lint/typecheck checkbox is unchecked. These gaps are minor relative to the overall completeness.

Resolution

Consider these additions: (1) a before/after visual for the one-line message change, or a short written before/after view for the Visual Proof section; (2) set the Risk 'Level' value (for example, Low); (3) state the rollback path in the Risk section; (4) run or confirm the ported test locally, or record the CI run that covers it.

  • 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

Recent 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: ed89f496-f0da-4ed5-bf43-1b2178923547
Commits

Reviewing files that changed from the base of the PR and between d526e8c and 594f181.

Files selected for processing: 3

  • mobile/src/i18n/locales/en.json
  • mobile/src/source-control/review/diff-actions/use-mobile-diff-review-interactions.ts
  • mobile/src/source-control/review/diff-actions/use-mobile-diff-review-open-in-session.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.

@Meapri

Meapri commented Sep 27, 2026

Copy link
Copy Markdown
Contributor Author

@pullfrog thanks. Both points are addressed in a512ece1d3.

  1. Open in Session on a headless host: it now checks the reply to files.openDiff with isRendererUnavailableRefusal. On that refusal it doesn't return to the session. It shows "This host has no desktop to open tabs in. The diff is shown here instead." and disables the action for the rest of that review screen (sessionTabsUnavailable, read by the drawer's disabled).
    • I disable it after the refusal rather than hiding it in advance, for the same reason as the rest of the PR: there is no capability that says a host is headless, and the refusal is the only signal every existing headless host sends. Desktop hosts never send it, so they keep the action.
    • I didn't fall back to anything else here, because the screen the user is on already is the device-side diff view.
    • New use-mobile-diff-review-open-in-session.test.ts runs the real review controller. Its headless case fails without the change, because the screen shows the raw renderer_unavailable, and passes with it. A desktop-host case checks that a successful open still returns to the session.
  2. Nitpick: taken. The edit-reply check in session-changed-file-open.ts now calls isRendererUnavailableRefusal(editReply) directly.

Re-verified: the mobile session, source-control, transport and components suites (452 files, 3754 tests), mobile typecheck/lint/check:tests-typecheck, root pnpm tc, check:code-quality:changed upstream/main, audit:anti-slop and oxlint on the changed files. The PR description is updated where this changes it. The screenshots are unchanged.

@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: 4e266291-c52a-45f4-905a-b1f5c13eac04

📥 Commits

Reviewing files that changed from the base of the PR and between 43d55a3b58da2c25ee4c5a3104467f2f73682c71 and a512ece1d3607a8c8f80cfbe85b823e2b726d003.

📒 Files selected for processing (4)
  • mobile/src/components/MobileDiffReviewDrawers.tsx
  • mobile/src/session/use-mobile-diff-review-interactions.ts
  • mobile/src/session/use-mobile-diff-review-open-in-session.test.ts
  • mobile/src/source-control/session-changed-file-open.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 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 new issues found.

Reviewed changes

  • Open in Session refusal guard — openInSession now checks isRendererUnavailableRefusal, and on a headless refusal sets a clear "no desktop to open tabs in" message instead of surfacing the raw renderer_unavailable code.
  • Action disabled after refusal — the review overflow menu's "Open in Session" gains controller.sessionTabsUnavailable in its disabled condition, so it turns off for the rest of the screen once the host refuses.
  • Edit-tab leg nitpick fixed — session-changed-file-open.ts replaced chooseSessionDiffOpen(editReply) === 'device-review' with a direct isRendererUnavailableRefusal(editReply); behavior is identical.
  • Controller-level test added — use-mobile-diff-review-open-in-session.test.ts drives the real review controller for the headless refusal (exact message + flag) and the desktop success path (returns to the session).

Both points from the prior review are addressed by this delta, and the new test would fail without the guard (the refusal would reach setActionError as the raw code). The remaining raw-refusal caller (create markdown note) stays explicitly out of scope in the PR body. Note: mobile dependencies are not installed in this review sandbox, so the new tests were checked statically rather than executed.

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

Since the prior pullfrog review (43d55a3b58), commit a512ece1d3 addressed both points raised:

  • Open in Session on a host with no renderer — use-mobile-diff-review-interactions.ts:199 now checks isRendererUnavailableRefusal on the files.openDiff reply, sets SESSION_TABS_UNAVAILABLE_MESSAGE, and returns before onOpenSession(). The new sessionTabsUnavailable state is exposed through the controller and read by MobileDiffReviewDrawers.tsx:149 for the action's disabled.
  • Edit-tab fallback uses the shared check — session-changed-file-open.ts:53 now calls isRendererUnavailableRefusal(editReply) directly rather than routing the edit reply through chooseSessionDiffOpen.
  • Coverage — new use-mobile-diff-review-open-in-session.test.ts mounts the real controller: the headless case asserts the explanation message is shown, onOpenSession is not called, and the action is turned off; the desktop case asserts a successful open still returns to the session and leaves the action enabled. I re-ran it alongside the other touched suites (25 tests, all pass).

I verified the disabled flag flows through the controller's ...interactions spread, and that the added test would fail without the fix (the raw renderer_unavailable would reach actionError and onOpenSession would still not be called, so the headless assertion on the message is real).

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

Since the prior pullfrog review (a512ece1d3), commit c7e680c352 reworked the headless Open in Session behavior:

  • Removed the latched sessionTabsUnavailable state — openInSession still recognizes the renderer-unavailable refusal and shows SESSION_TABS_UNAVAILABLE_MESSAGE, but no longer turns the action off; each tap re-requests files.openDiff, so a serve host promoted by gaining a window (attachWindow exists in src/main/runtime/orca-runtime-attach-window.ts), or a client replaced mid-screen, can still open the tab.
  • Dropped the MobileDiffReviewDrawers.tsx disabled condition back to upstream, so that file leaves the diff.
  • Strengthened the controller test — use-mobile-diff-review-open-in-session.test.ts now mounts the real MobileDiffReviewDrawers with the real controller and drives the actual "Review Actions" sheet: it asserts the action stays enabled after a refusal, then returns to the session on the second tap, and that a desktop success returns on the first.

I verified no dangling sessionTabsUnavailable references remain (grep across mobile/ is clean), the reverted use-mobile-diff-review-interactions.ts has no unused imports, and the new test is falsifiable: without the isRendererUnavailableRefusal guard the raw code would reach actionError, and against the latched a512ece version the disabled assertion fails. All four prior concerns (run 1's raw-refusal surfacing, run 1's edit-tab nitpick, run 2's coverage, and CodeRabbit's stale-flag risk) are addressed by this head.

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

@Meapri
Meapri force-pushed the fix/mobile-headless-file-fallback branch from c7e680c to d526e8c Compare October 2, 2026 09:51
@Meapri

Meapri commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

Hi @Jinwoo-H, rebased on the latest main to resolve merge conflicts. All tests and Pullfrog checks have passed cleanly. Could you please take a look when you have a moment? Thank you!

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

Related scope review for #22186: I checked the exact renderer_unavailable fallback in mobile-file-tap-open.ts, the shared refusal predicate, and the diff-review fallback. Thank you @Meapri for fixing existing-file/diff navigation while preserving older-host compatibility, and for explicitly identifying new Markdown notes as remaining work.

#31291 addresses that separate new-note creation/open/read/save reproduction on updated headless hosts. It credits and cross-references this PR; your older-host device fallback and #14315 diff behavior remain distinct. This is a scoped code comparison; I have not rerun this branch's simulator suite.

nwparker added a commit that referenced this pull request Oct 21, 2026
Create, read, and save Markdown notes on headless hosts through authorized file operations and persisted editor tabs.

Addresses the Markdown-note reproduction in #22186, reported by @shota46. Thanks to @Jinwoo-H (#31101), @brennanb2025 (#25436), and @Meapri (#23357) for related community implementations and regression coverage. Those PRs retain broader/distinct scope.

Validation: focused tests, paired-headless E2E, iPhone simulator proof, and all CI checks passed.
Meapri and others added 2 commits November 27, 2026 21:28
…enderer

The review screen is now where a headless host's diffs open, so its
Open in Session action reaches files.openDiff there too, and showed the
raw renderer_unavailable. On that refusal it now says the host has no
desktop to open tabs in and disables the action for the screen.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tching it off

A review screen can outlive both the client it started with (useHostClient
swaps it on refresh or reconnect) and the host's headless state (a serve
host gains a window when it is promoted), so disabling the action after
one renderer_unavailable could strand it off. Show the explanation on each
refusal and leave the action enabled.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Meapri
Meapri force-pushed the fix/mobile-headless-file-fallback branch from d526e8c to 594f181 Compare November 27, 2026 12:41
@Meapri Meapri changed the title fix(mobile): render files and diffs on the device when the host has no renderer fix(mobile): explain Open in Session refusal on headless hosts Nov 28, 2026
@Meapri

Meapri commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

Hi @nwparker, gentle ping. Rebased onto the latest main and CI is green.
Small one (3 files): on a paired headless host, "Open in Session" now explains
the renderer_unavailable refusal instead of surfacing the raw error, and asks
the host again on each tap rather than latching off. Note the first commit of
the original PR was dropped in the rebase, since upstream already covers the
file-tap fallback. Thanks for a look when you have a moment!

This branch has not been deployed

No deployments
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.

3 participants