fix(mobile): Windows image paths and non-ASCII file links open like desktop#25802

merged3
main
t3/mobile-chat-host-paths
opened5d agobyTtheo
View on GitHubTwo-way sync enabledPR last imported 5d ago

Problem

On mobile, an agent's Markdown with a host path did not always work like desktop:

  • ![shot](C:\work\.t3\shot.png) showed "Image unavailable". Markdown read \. and \_ as escapes, so the app asked for C:\work.t3\shot.png. Web already keeps these paths. Mobile lost that when it moved to the native Markdown renderer.
  • [exam](pastexam/線性代數/考試.pdf) was a plain web link, not a file chip. The shared link parser only accepted ASCII names. This also affected web.

Fix

  • Mobile rewrites Windows image and link destinations before parsing, so the JS parser and the native md4c parser both get the path as written, the same as web. A cheap regex check skips the extra parse for messages without a Windows destination.
  • The shared relative-path patterns accept any script (\p{L}\p{M}\p{N}). Mobile drops its ASCII-only folder fallback and uses the shared parser only.

Server file access is unchanged.

Fixes #23722 Fixes #16096

Refs #17668. With the iOS app on main, host-path images outside the project render (screenshot below), matching the maintainer's result on the issue. This PR does not change that path.

Supersedes #23750. Its idea of rewriting parsed destinations before the native parse is reused in a smaller form, credited to @amv146 with a co-author line.

Proof

Focused tests fail on main and pass here: markdownHtml.test.ts (real md4c WASM parser plus the JS parser) and markdownLinks.test.ts. vp run check:changed passes.

iPhone 17 Pro simulator, iOS dev client, isolated dev server on a Linux host:

  • Windows image: on main, "Copy full path" gave C:\work.t3_build\shot.png. Now it gives C:\work\.t3\_build\shot.png.
  • Non-ASCII link, left to right: main (plain link), this branch (file chip), and the file opened from the chip.

Before, after, opened file

Windows image path in the long-press menu

These closed issues still work on device: ~/.bashrc link (#18327), Example.md:314 in a subfolder (#17830), and a shots/ folder link (#21257).

Follow-ups, not in this PR:

  • Mobile inline code chips (ENRICHED_INLINE_FILE_LINK_REGEX) still accept only ASCII bare relative paths.
  • Windows paths in plain prose on mobile lose separators (open #21454).
  • File names with CJK punctuation (・, ()).

Council review

Rounds: 3

DelegateRound 1Round 2Round 3
Claude Opus 5.57/109/109/10
Codex GPT-6.1 Sol9/108/109.5/10

Created with Claude Opus 5.5 in Claude Code, running in T3 Code.

🤖 Generated with Claude Code

Checks

25 successful · 11 skipped
All checks passed
23121d9

Added 3 commits

  • fix(mobile): keep Windows separators next to ampersands and in quoted destinations23121d9
  • fix(mobile): Windows Markdown image paths and non-ASCII file links resolve on mobilea1bc5f0
  • fix(mobile): only reparse messages with Windows destinations; Unicode file extensionsb84e453
Synced from GitHub

Approvability

Verdict: Approved at 23121d9

Macroscope's review found this PR approvable — This is a localized Markdown compatibility fix for Windows destinations and non-ASCII file links, with focused regression tests and no changes to product defaults or static-analysis configuration. Its runtime effects are confined to existing link and image parsing paths.

You can add or adjust custom eligibility rules. Learn more.

Synced from GitHub

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ProviderMetricMain baselineThis PRImpactPR ceiling
CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
CodexLive turn WebSocket wire1.3 KiB1.3 KiB0 B (0.0%)2.0 KiB✅
CodexLive turn WebSocket decoded21.6 KiB21.6 KiB0 B (0.0%)24.4 KiB✅
CodexLive turn messages220 (0.0%)8✅
ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
ClaudeLive turn WebSocket wire1.3 KiB1.3 KiB0 B (0.0%)2.0 KiB✅
ClaudeLive turn WebSocket decoded21.9 KiB21.9 KiB0 B (0.0%)24.4 KiB✅
ClaudeLive turn messages220 (0.0%)8✅

Baseline: 96fc7b9 · PR result: 23121d9 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

Synced from GitHub

Review in Change Stack →

No actionable comments were generated in the recent review.

External image Recent review info
External image Run configuration
External image Commits

Reviewing files that changed from the base of the PR and between 96fc7b955196637605cbf3b415152ce4dd0e2294 and 23121d95c41e8ddcbdf789b6d34faa4edababa06.

External image Files selected for processing: 7
  • apps/mobile/src/lib/markdownDocument.ts
  • apps/mobile/src/lib/markdownHtml.test.ts
  • apps/mobile/src/lib/markdownInlineFileLinks.test.ts
  • apps/mobile/src/lib/markdownLinks.ts
  • apps/mobile/src/native/EnrichedMarkdownText.tsx
  • packages/shared/src/markdownLinks.test.ts
  • packages/shared/src/markdownLinks.ts

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

Walkthrough

Mobile Markdown preprocessing now normalizes Windows path destinations. Shared relative file-link matching now accepts Unicode characters in paths and filenames.

Changes: Markdown path handling

Layer / File(s)Summary
Windows destination normalization
apps/mobile/src/lib/markdownDocument.ts, apps/mobile/src/native/EnrichedMarkdownText.tsx, apps/mobile/src/lib/markdownHtml.test.ts, apps/mobile/src/lib/markdownInlineFileLinks.test.ts
Native parsing and rendering use preprocessing that converts HTML and normalizes Windows destinations. Regression tests cover Markdown and HTML image and link paths.
Relative file-link recognition
packages/shared/src/markdownLinks.ts, packages/shared/src/markdownLinks.test.ts, apps/mobile/src/lib/markdownLinks.ts
Relative path patterns accept Unicode letters, marks, and numbers. Mobile file presentation no longer falls back to a directory-like path match when parsing rejects the target.

Priority: External image Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related PRs

Suggested reviewers: juliusmarminge, macodev00, flamboh

Merge Risk: External image Minimal · up to 23121

The reviewed changes preserve the checked Windows destinations and relative directory links while recognizing the reported non-ASCII paths. No issue identified here needs to block merging.

Pre-merge checks: Passed 4
Check nameStatusExplanation
Title checkPassedThe title clearly and concisely describes the two main fixes: Windows image paths and non-ASCII file links on mobile.
Description checkPassedThe description covers the problem, fix, scope, linked issues, focused verification, device testing, screenshots, and agent details. The “Fix” and “Proof” headings differ from the template’s “Change” …
Linked Issues checkPassedThe PR meets the coding requirements for both active linked issues. For #23722, markdownForNativeParsing detects Windows destinations, preserves backslashes before native parsing, and is used by bot…
Out of Scope Changes checkPassedThe changes stay within the linked issue scope. The modified mobile parser, link presentation logic, shared path patterns, and regression tests directly support #23722 and #16096. The inline-file-link…
Full details: Description check

Explanation

The description covers the problem, fix, scope, linked issues, focused verification, device testing, screenshots, and agent details. The “Fix” and “Proof” headings differ from the template’s “Change” and “Verification” headings, but the required information is present.

Full details: Linked Issues check

Explanation

The PR meets the coding requirements for both active linked issues. For #23722, markdownForNativeParsing detects Windows destinations, preserves backslashes before native parsing, and is used by both mobile parsing paths. The regression test covers Windows image and link destinations, including backslashes, parentheses, ampersands, HTML, and blockquotes. Forward-slash destinations remain supported by the existing path handling. For #16096, the shared relative-path patterns now accept Unicode letters, marks, and numbers. The shared tests cover Chinese path components, accented names, and decoded spaces. Mobile now relies on parseMarkdownFileLink and removes its ASCII-only fallback.

Full details: Out of Scope Changes check

Explanation

The changes stay within the linked issue scope. The modified mobile parser, link presentation logic, shared path patterns, and regression tests directly support #23722 and #16096. The inline-file-link test update keeps its assertion on the shared test parser after the native parser normalization change. No unrelated product behavior or server file access changes are shown in the whole-PR diff.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.