Skip to content

fix(mobile): iOS swipe-back returns to the session; render HTML and SVG in file preview - #29096

Open
david828019-oss wants to merge 3 commits into
stablyai:mainfrom
david828019-oss:claude/trusting-darwin-pjchu2
Open

david828019-oss wants to merge 3 commits into
stablyai:mainfrom
david828019-oss:claude/trusting-darwin-pjchu2

Conversation

@david828019-oss

@david828019-oss david828019-oss commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

On iPhone, swiping right from the file browser (or any screen opened from a session) threw you all the way back to the home screen instead of back to the session. Now the swipe goes back one screen, just like the Back button. The file preview also shows HTML pages and SVG images rendered, instead of only their source code.

What Changed

Swipe-back

  • Before: from the session, opening files, a file preview, source control/PR, review, or agent history, then swiping right, landed on Home. The on-screen Back chevron worked correctly.
  • After: the swipe pops one screen: preview → files → session.
  • Mechanism: the host screens are a native stack nested inside the root stack's h screen, and on iOS both stacks arm an edge-swipe pop. The root's pop could win and remove the whole h group. The root stack now enables its swipe on h only while the host stack is on its first screen (rootOwnsHostGroupBackGesture, read from the h route's nested state). When a screen is pushed inside the host stack, the swipe is left to that stack.

File preview

  • Before: .html/.htm and .svg opened as syntax-highlighted source only.
  • After (native builds): they render through the existing MobileHtmlPreview WebView, the same component the session file tab already uses, with a Preview/Source toggle.
    • HTML renders with navigation locked to the inline document; links open externally.
    • SVG is still read as text, then drawn as an <img> data URI inside the WebView. The file's scripts never run, and WebKit renders what React Native's <Image> cannot.
    • A file:line target, or a truncated SVG (invalid XML), still opens on the source view.
  • The hybrid web-shell page keeps the source view through MobileFileHtmlPreview.web.tsx. The file preview route's page closure, grants, and bundle chunks stay as they are. It is registered in web-entry/web-overrides.json.

Why

  • Swipe: one gate at the root covers every host sub-screen at once. It doesn't change navigation history, which is already correct (the chevron's router.back() works). I considered moving screens out of the nested stack, or replacing pushes, but both would change the stack topology that notifications, Resume and the tablet split view rely on.
  • Preview: I reused MobileHtmlPreview rather than adding a new renderer. I chose a WebView <img> for SVG over react-native-svg, which only covers a subset of SVG/CSS. Keeping the web shell on source avoids adding externalNavigation to the file preview route's manifest grants.

Linked Issue

Fixes #

Visual Proof

TODO: attach before/after recordings from an iPhone:

  1. A right-swipe from the file browser back to the session.
  2. An .html and an .svg file opened from the file browser.

Testing

  • I manually tested these changes locally

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

  • New: host-group-back-gesture.test.ts. It covers the gate logic, including partial deep-link state, and pins its use in app/_layout.tsx.

  • New: mobile-file-svg-preview-document.test.ts. It covers data-URI embedding and that the content cannot break out of the src attribute.

  • Updated: file-tree.test.ts (isSvgPath), mobile-file-preview-request.test.ts (svg read path and kind: 'svg'), and mobile-file-preview-retry.test.tsx (mock for the new component).

  • CI on the fork is green on this head:

    • Mobile verify: mobile typecheck, oxlint with 0 errors, and the full mobile vitest suite (1,004 files and 10,202 tests passed).
    • Static analysis and typecheck, including the anti-slop rules.
    • Mobile web app bundle.
    • PR checks passed.
  • Not yet run on a device or simulator.

AI Disclosure

Written with Claude Code.

Review

Agent skill upstream boundary

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

Notes

  • Mobile-only: no host, RPC or wire changes, so SSH and remote hosts and mixed client/host versions are unaffected.
  • Android: gestureEnabled doesn't affect the hardware Back key, which already pops the innermost stack.
  • Tablet split view: the host stack uses animation: 'none' there, so whether an interactive swipe is available at depth > 1 is still unverified.
  • HTML relative assets: sibling CSS and images next to the HTML file do not load. This is unchanged from the session file tab.

Checklist

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

Swiping right from a screen opened over the session (files, file preview,
source control, review, agent history) popped the whole host group back to
Home, while the on-screen Back chevron correctly returned to the session.

The host routes are a native stack nested in the root stack's `h` screen,
and both arm an iOS edge-swipe pop. The root's could win and pop `h`. The
root stack now enables its swipe on `h` only while the host stack is on its
first screen, so a deeper swipe is left to the host stack's own pop.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hux3xXUvL1AYotqw5pUKtn
The file preview showed .html/.htm and .svg files as source text only.
Native builds now render them through the existing MobileHtmlPreview
WebView, with a Preview/Source toggle:

- HTML renders as-is, with navigation locked to the inline document.
- SVG is read as text and drawn as an <img> data URI in the WebView, so
  its scripts never run and WebKit renders what RN <Image> cannot.
- A line target, or a truncated SVG, still opens on the source view.

The web-shell page keeps the source view through a .web sibling, so the
file preview route's closure, grants and bundle chunks are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hux3xXUvL1AYotqw5pUKtn
Name the `h` route shape the options callback hands the gate instead of
taking a bare `object`, which the anti-slop lint rejects.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hux3xXUvL1AYotqw5pUKtn
@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

The change adds SVG path classification and preview rendering for native and web. Native previews can display HTML and complete SVG content through a WebView, with source text available as an alternative. SVG content is wrapped in an HTML document and encoded as an image data URI. The h route now sets back-gesture availability based on the focused index of the host stack.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to b1b57

Opening a worktree HTML file can run its scripts and make network requests. Disable scripts for file previews before merging.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 14 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check Warning The description explains the user impact, implementation, rationale, testing, and known limitations. However, the required linked issue is incomplete (Fixes #), and the required visual proof remains… Add the actual linked issue number to the Fixes # section. Attach before-and-after screenshots or recordings for the swipe-back and HTML/SVG preview changes, or mark the section N/A with a valid explanation if visual proof is not applic…
Passed Passed checks: 3 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly summarizes both primary changes: the iOS swipe-back fix and native HTML/SVG file preview rendering. It is concise and specific.
Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 14 files. (1 skipped: 1 unsupported.)

Full details: Description check

Explanation

The description explains the user impact, implementation, rationale, testing, and known limitations. However, the required linked issue is incomplete (Fixes #), and the required visual proof remains a TODO for these UI and behavior changes.

Resolution

Add the actual linked issue number to the Fixes # section. Attach before-and-after screenshots or recordings for the swipe-back and HTML/SVG preview changes, or mark the section N/A with a valid explanation if visual proof is not applicable.

  • Fix all pre-merge checks with AI
  • 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: ad074cbe-6af3-4da3-8c79-1f306a6a3fed
📥 Commits

Reviewing files that changed from the base of the PR and between e9199bd and b1b57ee.

📒 Files selected for processing: 15
  • mobile/app/_layout.tsx
  • mobile/src/files/MobileFileHtmlPreview.tsx
  • mobile/src/files/MobileFileHtmlPreview.web.tsx
  • mobile/src/files/MobileFilePreviewBody.tsx
  • mobile/src/files/file-tree.test.ts
  • mobile/src/files/file-tree.ts
  • mobile/src/files/mobile-file-preview-request.test.ts
  • mobile/src/files/mobile-file-preview-response.ts
  • mobile/src/files/mobile-file-preview-retry.test.tsx
  • mobile/src/files/mobile-file-svg-preview-document.test.ts
  • mobile/src/files/mobile-file-svg-preview-document.ts
  • mobile/src/navigation/host-group-back-gesture.test.ts
  • mobile/src/navigation/host-group-back-gesture.ts
  • mobile/src/session/mobile-artifact-kind.ts
  • mobile/web-entry/web-overrides.json

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

/>
)
// Why: a line target asks for source, and a truncated SVG is invalid XML that renders blank.
if (props.initialLine !== undefined || (props.kind === 'svg' && props.truncated)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '1,110p' mobile/src/files/MobileFileHtmlPreview.tsx
rg -n 'function MobileHtmlPreview|javaScriptEnabled|onShouldStartLoadWithRequest|MobileHtmlPreview' mobile/src

Repository: stablyai/orca

Length of output: 5043


🏁 Script executed:

set +e
nl -ba mobile/src/components/MobileHtmlPreview.tsx | sed -n '1,130p'
printf '%s\n' '--- web ---'
nl -ba mobile/src/components/MobileHtmlPreview.web.tsx | sed -n '1,150p'
printf '%s\n' '--- callers ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'MobileFileHtmlPreview' -e 'MobileFilePreview' mobile/src
printf '%s\n' '--- session reader ---'
nl -ba mobile/src/session/MobileSessionFileReader.tsx | sed -n '260,330p'
printf '%s\n' '--- diff ---'
git diff --no-ext-diff --unified=25 f6d5086c7d397707d760a5c0e42182a8573469a2 b1b57ee3651c26274e9a9a3d19d2f25852c4e2a4 -- mobile/src/files mobile/src/components/MobileHtmlPreview.tsx mobile/src/session/MobileSessionFileReader.tsx | sed -n '1,500p'

Repository: stablyai/orca

Length of output: 41686


Disable scripts for worktree file previews.

The new file-browser path passes untrusted worktree HTML to MobileHtmlPreview, whose native WebView has javaScriptEnabled enabled. The navigation callback only handles navigations; scripts can still run and issue network requests. Add a per-preview script policy so existing trusted/intentional HTML previews keep their behavior while worktree file previews use javaScriptEnabled={false}.

Suggested fix
 export type MobileHtmlPreviewProps = {
   html: string
+  javaScriptEnabled?: boolean
   // Rendered when the user flips to "Source" (the existing syntax view).
   renderSource: () => React.ReactNode
 }
 
-export function MobileHtmlPreview({ html, renderSource }: MobileHtmlPreviewProps) {
+export function MobileHtmlPreview({
+  html,
+  javaScriptEnabled = true,
+  renderSource
+}: MobileHtmlPreviewProps) {
...
-          javaScriptEnabled
+          javaScriptEnabled={javaScriptEnabled}
     <MobileHtmlPreview
       html={props.kind === 'svg' ? svgPreviewDocument(props.content) : props.content}
+      javaScriptEnabled={false}
       renderSource={() => source}
     />

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.

2 participants