Repository navigation
fix(mobile): iOS swipe-back returns to the session; render HTML and SVG in file preview - #29096
david828019-oss wants to merge 3 commits into
Conversation
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
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
ad074cbe-6af3-4da3-8c79-1f306a6a3fed
📒 Files selected for processing: 15
mobile/app/_layout.tsxmobile/src/files/MobileFileHtmlPreview.tsxmobile/src/files/MobileFileHtmlPreview.web.tsxmobile/src/files/MobileFilePreviewBody.tsxmobile/src/files/file-tree.test.tsmobile/src/files/file-tree.tsmobile/src/files/mobile-file-preview-request.test.tsmobile/src/files/mobile-file-preview-response.tsmobile/src/files/mobile-file-preview-retry.test.tsxmobile/src/files/mobile-file-svg-preview-document.test.tsmobile/src/files/mobile-file-svg-preview-document.tsmobile/src/navigation/host-group-back-gesture.test.tsmobile/src/navigation/host-group-back-gesture.tsmobile/src/session/mobile-artifact-kind.tsmobile/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)) { |
There was a problem hiding this comment.
🔒 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/srcRepository: 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}
/>
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
hscreen, and on iOS both stacks arm an edge-swipe pop. The root's pop could win and remove the wholehgroup. The root stack now enables its swipe onhonly while the host stack is on its first screen (rootOwnsHostGroupBackGesture, read from thehroute's nested state). When a screen is pushed inside the host stack, the swipe is left to that stack.File preview
.html/.htmand.svgopened as syntax-highlighted source only.MobileHtmlPreviewWebView, the same component the session file tab already uses, with a Preview/Source toggle.<img>data URI inside the WebView. The file's scripts never run, and WebKit renders what React Native's<Image>cannot.file:linetarget, or a truncated SVG (invalid XML), still opens on the source view.MobileFileHtmlPreview.web.tsx. The file preview route's page closure, grants, and bundle chunks stay as they are. It is registered inweb-entry/web-overrides.json.Why
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.MobileHtmlPreviewrather than adding a new renderer. I chose a WebView<img>for SVG overreact-native-svg, which only covers a subset of SVG/CSS. Keeping the web shell on source avoids addingexternalNavigationto the file preview route's manifest grants.Linked Issue
Fixes #
Visual Proof
TODO: attach before/after recordings from an iPhone:
.htmland an.svgfile 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 inapp/_layout.tsx.New:
mobile-file-svg-preview-document.test.ts. It covers data-URI embedding and that the content cannot break out of thesrcattribute.Updated:
file-tree.test.ts(isSvgPath),mobile-file-preview-request.test.ts(svg read path andkind: 'svg'), andmobile-file-preview-retry.test.tsx(mock for the new component).CI on the fork is green on this head:
PR checks passed.Not yet run on a device or simulator.
AI Disclosure
Written with Claude Code.
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
gestureEnableddoesn't affect the hardware Back key, which already pops the innermost stack.animation: 'none'there, so whether an interactive swipe is available at depth > 1 is still unverified.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)