orca/mobile/scripts
Wooseong Kim a7ed5a45c2
fix(mobile): render Mermaid diagrams in MobileMarkdown (#11185)
* fix(mobile): render Mermaid diagrams in MobileMarkdown (#11141)

Co-Authored-By: Grok Companion <noreply@x.ai>

* fix(mobile): keep streaming mermaid fences as raw code until the fence closes

* perf(mobile): memoize MermaidDiagram and add a CDN load watchdog

* fix(mobile): escape mermaid source before embedding in WebView script

JSON.stringify leaves </script>, &, and U+2028/U+2029 raw, so a diagram
source containing </script> broke out of the inline script and ran
arbitrary WebView JS. Diagram source is untrusted (agent output, PR/chat
content), and this component now renders from chat and markdown preview,
not just the PR sidebar. Escape those chars to \uXXXX; the literal still
parses back to the exact source. Adds an adversarial buildHtml test.

* fix(mobile): embed the mermaid engine instead of fetching it from a CDN

The diagram WebView loaded mermaid from jsdelivr at runtime: offline and
constrained-network renders always fell back, the stalled-load watchdog
existed only to paper over that, and an unpinned floating-major CDN script
with no integrity check ran inside the WebView. Embed the lockfile-pinned
package's prebuilt bundle via a postinstall generator (same mechanism as
the terminal WebView engine) so the document loads nothing external; the
watchdog is removed as obsolete and a no-external-URL gate pins it.

* chore(deps): align mermaid at 11.16.0 across desktop and mobile

Desktop floated ^11.15.0 while the mobile embedded engine resolved 11.16.0.
Raise the desktop floor so both lockfiles resolve the same version, and pin
mobile exact: the generated WebView engine embeds the package bytes, so an
implicit range bump would silently change what ships.

* fix(mobile): block Mermaid diagram network requests

Mermaid image-node URLs can initiate subresource requests even with the engine embedded. Keep the WebView offline by restricting resource types through its document CSP.

* style(mobile): format Mermaid routing test

* fix(mobile): use stable keys for Mermaid diagrams

* fix(mobile): keep duplicate Mermaid keys distinct

Combine each diagram source with its sibling occurrence so identical diagrams remain unique while source edits still remount the WebView and later streaming prose does not.

* fix(mobile): keep Mermaid transitive within release-age policy

---------

Co-authored-by: Grok Companion <noreply@x.ai>
Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com>
2026-08-03 20:05:16 -07:00
..
build-mermaid-webview-engine.mjs fix(mobile): render Mermaid diagrams in MobileMarkdown (#11185) 2026-08-03 20:05:16 -07:00
build-terminal-webview-engine.mjs Fix blank mobile terminal on Android devices with outdated WebViews or blocked CDN (#7186) 2026-07-03 15:22:00 -07:00
mobile-expo-cli.mjs refs/heads/handle-mobile-pull-request-issues (#6598) 2026-06-28 00:58:17 -07:00
mobile-lag-scenario.ts Fix mobile workspace parity (#6207) 2026-06-23 17:07:28 -07:00
mock-server-account-rpc.ts feat(mobile): add safe Codex rate-limit resets (#9394) 2026-07-24 14:42:04 -07:00
mock-server-account-state.ts feat(mobile): add safe Codex rate-limit resets (#9394) 2026-07-24 14:42:04 -07:00
mock-server-encryption.ts
mock-server-file-preview-data.ts Show full workspace file tree on mobile (#7289) 2026-07-06 15:41:51 -07:00
mock-server-git-state.ts feat(mobile): combine PR sidebar and checks parity (#5641) 2026-06-17 22:52:12 -07:00
mock-server-key-pair.ts fix(mobile): harden native chat send budgets, streams, and stop (#10814) 2026-07-26 22:08:38 -07:00
mock-server-native-chat-scenario.ts fix(mobile): harden native chat send budgets, streams, and stop (#10814) 2026-07-26 22:08:38 -07:00
mock-server-rpc-handlers.ts fix(mobile): route external mouse click and drag to the terminal (#11473) 2026-07-31 00:54:40 -07:00
mock-server-session-tabs-fixture.ts fix(mobile): route external mouse click and drag to the terminal (#11473) 2026-07-31 00:54:40 -07:00
mock-server-terminal-fixtures.ts feat(mobile): add safe Codex rate-limit resets (#9394) 2026-07-24 14:42:04 -07:00
mock-server-terminal-stream.ts fix(mobile): route external mouse click and drag to the terminal (#11473) 2026-07-31 00:54:40 -07:00
mock-server.ts fix(mobile): harden native chat send budgets, streams, and stop (#10814) 2026-07-26 22:08:38 -07:00
prepare-android-release.mjs fix(mobile): keep Android release versionCode committed (#7271) 2026-07-03 15:26:11 -07:00
repro-mobile-foreground-stall.sh fix(mobile): redial when the app resumes mid-dial (#12344) 2026-08-03 13:53:59 -07:00
repro-terminal-colors.ts
repro-workspace-picker-lag.ts feat(mobile): combine PR sidebar and checks parity (#5641) 2026-06-17 22:52:12 -07:00
repro-worktree-startup-stream.ts
start-emulator-pairing-runtime.mjs fix(mobile): harden native chat send budgets, streams, and stop (#10814) 2026-07-26 22:08:38 -07:00
start-emulator.mjs Revert "fix(memory): bound OOM-prone accumulators (#10179)" (#10255) 2026-07-23 18:35:31 -07:00
start-expo.mjs chore(lint): adopt unicorn/prefer-import-meta-properties (error) (#6847) 2026-06-29 23:37:30 -07:00
test-subscribe.ts