Repository navigation
feat(mobile): render interactive visuals in a sandboxed webview - #695
Merged
Merged
Conversation
Visual items on mobile now mount the same compiled document and CSP as the web inside a trusted shell in react-native-webview 14.0.1. The shell relays the frame's port messages in a per-mount token envelope; the app parses them through the inbox shared with the web. One live WebView, lazy mount, 5 s release off screen, full screen, Save/Share HTML, Copy spec, Cite visual and the version picker. Builds without the module keep the text card.
This was referenced Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces the mobile text-only visual card (#688) with an interactive renderer in
react-native-webview14.0.1 (the version SDK 58 pins). It ships in the same native build as #659. Do not merge it alone into a released build: it changes the native fingerprint.How it works
GetVisual(Connect), validates it again and compiles it withcompileVisualin frame mode. The WebView getssource={{ html }}with nobaseUrl(an opaqueabout:blankdocument). It holds a trusted shell (@canopy/domain/visual-shell) that mounts the visual in<iframe sandbox="allow-scripts" srcdoc>, like the web.WebMessageListenerwith*, and iOS exposeswebkit.messageHandlersto all frames. So the shell wraps each port message in a per-mount token envelope that the frame never sees. The app drops anything without the token and anything over 8 KiB plus the envelope. The rest goes throughVisualFrameInbox(new in@canopy/domain/visuals), which the webframe-host.tsnow uses too: 10 msg/s, 4 heights/s, strict parser, local state checked against the spec. Host messages (theme, visibility, reduced motion) go in throughpostMessagewith the same token. The shell accepts them only when there is noevent.source, so a frame can't forge them.SandboxedWebView.tsx):incognito, no shared or third-party cookies, no DOM storage (the kit doesn't use it), no cache.setSupportMultipleWindows={false}, a no-oponOpenWindow,javaScriptCanOpenWindowsAutomatically={false}. The shell also disableswindow.open,alert,confirmandprompt.injectedJavaScript.originWhitelist={["*"]}sends every URL toonShouldStartLoadWithRequest. The library's default list would pass other schemes toLinking. That callback allows only the first top-frameabout:blankand the child'sabout:srcdoc.Paths.cache.TurboModuleRegistry.get("RNCWebViewModule")is checked before the renderer is imported (lazily), so on a build without the module the JS never touches the native component. Those builds keep feat(agents): summarize visuals on mobile until the webview renderer #688'sVisualSummarycard.compileVisualExportnow builds the "Download HTML" file for both the web BFF route and mobile.Verified statically
bun install,gen:check,typecheck,lint(oxlint),format:check,check:tmp: 2974 pass, 175 skip, 0 fail, nothing left in the temp dir. Web build passes.packages/domain/src/visuals/host.test.ts:window.parent.ReactNativeWebView→ SecurityError.window.open→ blocked (noallow-popups);alert→ ignored (noallow-modals).top.location→ SecurityError;localStorageanddocument.cookie→ SecurityError; originnull.readywas relayed.expo exportfor iOS and Android passes; the shell is in the Hermes bundle.expo prebuild --no-install --cleanin a temp copy passes:RNCWebViewFileProviderand payment<queries>; we turn payment requests off and have no file inputs.rncoreAutolinkingConfig).e332d33:bun install --frozen-lockfileis clean, the mobile typecheck passes, andexpo exportpasses for iOS (3320 modules) and Android (3314 modules).expo prebuild --no-install --cleanin a temp copy passes, and both sides apply together:expo-video,canopy-media-stream,canopy-file-intakeandcanopy-pinned-fetch(Expo modules) plusreact-native-webview(RN community).media-networkplugin writesres/xml/canopy_media_network.xml, andexpo-videoadds noUIBackgroundModes.Fingerprint (
@expo/fingerprint):5a2f1ebbf02efbeb8f57f05a91e105b8f4f7c935138e0c6b171c82b4933e86808cdfef56da73b8c643b7842311f5520084c7fcfcbce1b1df23da45ec906dc944f94eb8333fa384ed9f198834fdd30d13The "dev with feat(mobile): play video attachments #659" values come from a temporary worktree that shared this checkout's
node_modules. Use the right-hand column for the scheduled native build.expo linton the new files reports the same rule patterns that already fail across the app (react-hooks/refsforviewport.ref,set-state-in-effectfor claiming the slot). Mobile ESLint is not a CI gate and already reports 104 errors on dev.Security review follow-ups (P3)
allowInitialLoadno longer blocks the newabout:blank(VisualWebView.tsx).visual-state.json, in memory and on disk (clearVisualCachesinsession.tsx). A read started before a clear can't restore old entries.docs/agent-visuals.md(mobile section) records the accepted residual risks: bridge flooding from frame code, and unchecked child-frame http(s) navigation on Android (the sandbox and CSP stay the boundary).bun run typecheck, mobiletsc, andexpo exportfor iOS and Android. JS-only change, so the fingerprints are unchanged.Needs on-device checks (the device host is broken)
WebMessageListenerand iOSwebkit.messageHandlerscalls from the frame are dropped. Also confirm that no file or content URL loads.shouldOverrideUrlLoadingdoesn't see http(s) navigations of child frames, and it allows the load if JS doesn't answer within 250 ms. The sandbox and CSP remain the boundary there; the kit never navigates.scrollEnabled={false}on the shell, AndroidnestedScrollEnabled). Light and dark, theme changes while open, phone width, long titles.Copy audit (docs/copy.md §8)
No new glossary terms.