The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 14:30 UTC
fix(mobile): Windows paths in messages keep their backslashes (#21454)
Co-authored-by: OhadC <OhadC@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 27, 2026 at 16:42 UTC
294981fa724eb281c37763e11a0c5b0b2c645317
12 files changed
+91
-57
apps/mobile/deps/README.md
+1
-1
@@ -1,3 +1,3 @@
1
-The Enriched Markdown tarball comes from Julius's [`fork/t3-mobile` branch](https://github.com/pingdotgg/enriched-markdown/tree/fork/t3-mobile). Its `t3-fork.json` records the exact source commit and upstream base. React block renderers and signed image sources (`renderers`, `resolveImageSource`) are upstream. The fork carries native streaming memory bounds (an 8 MiB measurement-key budget and coalesced pending renders), plus changes with an open upstream PR: the `onLinksChange` link list that link pills and iOS link menus read ([#1088](https://github.com/software-mansion/enriched-markdown/pull/1088)), Android inline image alignment ([#1089](https://github.com/software-mansion/enriched-markdown/pull/1089)), clipboard link metadata ([#962](https://github.com/software-mansion/enriched-markdown/pull/962)), and development-host autolinks ([#961](https://github.com/software-mansion/enriched-markdown/pull/961)).
1
+The Enriched Markdown tarball comes from Julius's [`fork/t3-mobile` branch](https://github.com/pingdotgg/enriched-markdown/tree/fork/t3-mobile). Its `t3-fork.json` records the exact source commit and upstream base. React block renderers and signed image sources (`renderers`, `resolveImageSource`) are upstream. The fork carries native streaming memory bounds (an 8 MiB measurement-key budget and coalesced pending renders), plus changes with an open upstream PR: the `onLinksChange` link list that link pills and iOS link menus read ([#1088](https://github.com/software-mansion/enriched-markdown/pull/1088)), Android inline image alignment ([#1089](https://github.com/software-mansion/enriched-markdown/pull/1089)), clipboard link metadata ([#962](https://github.com/software-mansion/enriched-markdown/pull/962)), development-host autolinks ([#961](https://github.com/software-mansion/enriched-markdown/pull/961)), and `md4cFlags.preserveWindowsPaths`, which keeps backslashes in Windows drive paths in prose ([#1105](https://github.com/software-mansion/enriched-markdown/pull/1105), after [md4c#5](https://github.com/software-mansion-labs/md4c/pull/5)).
2
3
To replace it, commit the fork changes, run `yarn install --immutable` and `yarn workspace react-native-enriched-markdown prepare` in the fork checkout, then `node scripts/pack-t3.mjs /path/to/t3code/apps/mobile/deps`. Keep the package version aligned with Julius's `fork/t3-mobile` branch. Rename the archive to include the first eight characters of the source commit, such as `react-native-enriched-markdown-1.2.0-t3.16-8d2f84a8.tgz`, so each build has a distinct dependency path without version bumps. Update the tarball path in `apps/mobile/package.json` and `pnpm-workspace.yaml`'s `allowBuilds`, and run `vp i` to update the lockfile. Native clients need rebuilding when this dependency changes.
apps/mobile/deps/react-native-enriched-markdown-1.2.0-t3.16-29ddd424.tgz
Binary files /dev/null and b/apps/mobile/deps/react-native-enriched-markdown-1.2.0-t3.16-29ddd424.tgz differ
apps/mobile/deps/react-native-enriched-markdown-1.2.0-t3.16-558767d9.tgz
Binary files a/apps/mobile/deps/react-native-enriched-markdown-1.2.0-t3.16-558767d9.tgz and /dev/null differ
apps/mobile/package.json
+1
-1
@@ -121,7 +121,7 @@
121
"react-dom": "catalog:",
122
"react-native": "0.88.0",
123
"react-native-blob-util": "0.25.1",
124
- "react-native-enriched-markdown": "file:deps/react-native-enriched-markdown-1.2.0-t3.16-558767d9.tgz",
124
+ "react-native-enriched-markdown": "file:deps/react-native-enriched-markdown-1.2.0-t3.16-29ddd424.tgz",
125
"react-native-gesture-handler": "~3.3.0",
126
"react-native-image-viewing": "^0.2.2",
127
"react-native-keyboard-controller": "1.22.8",
apps/mobile/src/lib/markdownDocument.ts
+2
-1
@@ -2,9 +2,10 @@ import type { Root, RootContent } from "mdast";
2
import { unified, type Processor } from "unified";
3
import remarkParse from "remark-parse";
4
import remarkGfm from "remark-gfm";
5
+import { remarkKeepWindowsProsePaths } from "@t3tools/shared/markdownWindowsPaths";
6
import { isWindowsAbsolutePath } from "@t3tools/shared/path";
7
7
-const parser = unified().use(remarkParse).use(remarkGfm);
8
+const parser = unified().use(remarkParse).use(remarkGfm).use(remarkKeepWindowsProsePaths);
9
export type MarkdownNode = Root | RootContent;
10
11
interface MarkdownEdit {
apps/mobile/src/lib/markdownHtml.test.ts
+8
@@ -330,3 +330,11 @@ describe("Windows paths in native Markdown", () => {
330
expect(markdownImageSources(markdown)).toEqual([image, paren, amp, htmlAmp]);
331
});
332
});
333
+
334
+it("keeps backslashes in drive paths in mobile Markdown prose", () => {
335
+ const path = String.raw`Saved to C:\Users\me\.t3\_build\shot.png and C:/work\.config.`;
336
+
337
+ expect(parseMarkdownDocument(String.raw`${path} Then \*this\*.`).children).toMatchObject([
338
+ { type: "paragraph", children: [{ type: "text", value: `${path} Then *this*.` }] },
339
+ ]);
340
+});
apps/mobile/src/native/EnrichedMarkdownText.tsx
+1
@@ -337,6 +337,7 @@ export function MobileEnrichedMarkdownText(props: SelectableMarkdownTextProps) {
337
latexMath: mathRenderingEnabled,
338
hardSoftBreaks: props.preserveSoftBreaks ?? false,
339
admonitions: true,
340
+ preserveWindowsPaths: true,
341
}}
342
enableTaskListItemToggle={false}
343
enableCodeBlockWrapToggle
packages/shared/package.json
+4
@@ -463,6 +463,10 @@
463
"types": "./src/proposedPlanText.ts",
464
"import": "./src/proposedPlanText.ts"
465
},
466
+ "./markdownWindowsPaths": {
467
+ "types": "./src/markdownWindowsPaths.ts",
468
+ "import": "./src/markdownWindowsPaths.ts"
469
+ },
470
"./markdownPipeline": {
471
"types": "./src/markdownPipeline.ts",
472
"import": "./src/markdownPipeline.ts"
packages/shared/src/markdownPipeline.ts
+1
-48
@@ -1,6 +1,5 @@
1
import type { Paragraph, PhrasingContent, Root, RootContent } from "mdast";
2
-import type { Processor } from "unified";
3
-import { isWindowsAbsolutePath } from "./path.ts";
2
+import { remarkKeepWindowsPaths } from "./markdownWindowsPaths.ts";
3
import type { PluggableList } from "unified";
4
import rehypeRaw from "rehype-raw";
5
import rehypeSanitize, { defaultSchema } from "rehype-sanitize";
@@ -302,52 +301,6 @@ function remarkNormalizeLinksAndTagInlineCode() {
301
};
302
}
303
305
-interface DestinationCompileContext {
306
- readonly stack: ReadonlyArray<{ readonly type: string; url?: string }>;
307
- resume(): string;
308
- sliceSerialize(token: unknown): string;
309
-}
310
-
311
-function keepWindowsPathDestination(this: DestinationCompileContext, token: unknown) {
312
- const decoded = this.resume();
313
- const authored = this.sliceSerialize(token);
314
- const node = this.stack.at(-1);
315
- // Character references still need decoding, so those destinations keep the parsed URL.
316
- if (node)
317
- node.url = isWindowsAbsolutePath(authored) && !authored.includes("&") ? authored : decoded;
318
-}
319
-
320
-const UNFINISHED_DRIVE_PATH = /(?:^|\W)[A-Za-z]:(?:[\\/]\S*)?$/;
321
-
322
-interface EscapeCompileContext {
323
- readonly stack: ReadonlyArray<{
324
- readonly type: string;
325
- children?: Array<{ type: string; value?: string }>;
326
- }>;
327
-}
328
-
329
-function keepWindowsPathEscape(this: EscapeCompileContext) {
330
- const text = this.stack.at(-1)?.children?.at(-1);
331
- if (text?.type !== "text" || text.value === undefined) return;
332
- const before = text.value.slice(0, -1);
333
- if (UNFINISHED_DRIVE_PATH.test(before)) text.value = `${before}\\${text.value.slice(-1)}`;
334
-}
335
-
336
-/**
337
- * CommonMark treats backslashes as escapes; preserve them as separators in Windows destinations
338
- * and drive-path prose. Prose paths end at whitespace so later escapes still work.
339
- */
340
-function remarkKeepWindowsPaths(this: Processor) {
341
- const data = this.data();
342
- (data.fromMarkdownExtensions ??= []).push({
343
- exit: {
344
- resourceDestinationString: keepWindowsPathDestination,
345
- definitionDestinationString: keepWindowsPathDestination,
346
- characterEscape: keepWindowsPathEscape,
347
- },
348
- });
349
-}
350
-
304
export function shouldPreserveAssistantLineBreaks(text: string): boolean {
305
return /^★ Insight(?:\s|─)/mu.test(text);
306
}
packages/shared/src/markdownWindowsPaths.ts
new
+67
@@ -0,0 +1,67 @@
1
+import type { Processor } from "unified";
2
+import { isWindowsAbsolutePath } from "./path.ts";
3
+
4
+interface DestinationCompileContext {
5
+ readonly stack: ReadonlyArray<{ readonly type: string; url?: string }>;
6
+ resume(): string;
7
+ sliceSerialize(token: unknown): string;
8
+}
9
+
10
+function keepWindowsPathDestination(this: DestinationCompileContext, token: unknown) {
11
+ const decoded = this.resume();
12
+ const authored = this.sliceSerialize(token);
13
+ const node = this.stack.at(-1);
14
+ // Character references still need decoding, so those destinations keep the parsed URL.
15
+ if (node)
16
+ node.url = isWindowsAbsolutePath(authored) && !authored.includes("&") ? authored : decoded;
17
+}
18
+
19
+// A drive path that has not reached whitespace yet: `C:`, `C:\Users\me`, `C:/work`.
20
+const UNFINISHED_DRIVE_PATH = /(?:^|\W)[A-Za-z]:(?:[\\/]\S*)?$/;
21
+
22
+interface EscapeCompileContext {
23
+ readonly stack: ReadonlyArray<{
24
+ readonly type: string;
25
+ children?: Array<{ type: string; value?: string }>;
26
+ }>;
27
+}
28
+
29
+function keepWindowsPathEscape(this: EscapeCompileContext) {
30
+ const text = this.stack.at(-1)?.children?.at(-1);
31
+ if (text?.type !== "text" || text.value === undefined) return;
32
+ const before = text.value.slice(0, -1);
33
+ if (UNFINISHED_DRIVE_PATH.test(before)) {
34
+ text.value = `${before}\\${text.value.slice(-1)}`;
35
+ }
36
+}
37
+
38
+function keepWindowsProsePathEscape(this: EscapeCompileContext) {
39
+ // Destinations, titles, and labels are buffered in a fragment.
40
+ if (this.stack.at(-1)?.type !== "fragment") keepWindowsPathEscape.call(this);
41
+}
42
+
43
+/**
44
+ * Keeps escapes inside drive paths in prose only, for parsers that already escape Windows
45
+ * destinations themselves. Prose paths end at whitespace: past that, nothing tells a path
46
+ * from a sentence, and `C:\x and \*this\*` must still read `*this*`.
47
+ */
48
+export function remarkKeepWindowsProsePaths(this: Processor) {
49
+ (this.data().fromMarkdownExtensions ??= []).push({
50
+ exit: { characterEscape: keepWindowsProsePathEscape },
51
+ });
52
+}
53
+
54
+/**
55
+ * CommonMark reads the `\.` in `C:\me\.t3\shot.png` as an escape. Every backslash in a
56
+ * Windows path is a separator, so link, image, and definition destinations that are
57
+ * Windows paths keep the text as written, and so do escapes inside drive paths.
58
+ */
59
+export function remarkKeepWindowsPaths(this: Processor) {
60
+ (this.data().fromMarkdownExtensions ??= []).push({
61
+ exit: {
62
+ resourceDestinationString: keepWindowsPathDestination,
63
+ definitionDestinationString: keepWindowsPathDestination,
64
+ characterEscape: keepWindowsPathEscape,
65
+ },
66
+ });
67
+}
pnpm-lock.yaml
+5
-5
@@ -732,8 +732,8 @@ importers:
732
specifier: 0.25.1
733
version: 0.25.1(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
734
react-native-enriched-markdown:
735
- specifier: file:deps/react-native-enriched-markdown-1.2.0-t3.16-558767d9.tgz
736
- version: file:apps/mobile/deps/react-native-enriched-markdown-1.2.0-t3.16-558767d9.tgz(katex@0.16.47)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
735
+ specifier: file:deps/react-native-enriched-markdown-1.2.0-t3.16-29ddd424.tgz
736
+ version: file:apps/mobile/deps/react-native-enriched-markdown-1.2.0-t3.16-29ddd424.tgz(katex@0.16.47)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
737
react-native-gesture-handler:
738
specifier: 3.3.0
739
version: 3.3.0(patch_hash=abe20e1d1c23549297cbbc818e14fe479b41455930d9663135d6b40fe359b626)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
@@ -10824,8 +10824,8 @@ packages:
10824
react: '*'
10825
react-native: '*'
10826
10827
- react-native-enriched-markdown@file:apps/mobile/deps/react-native-enriched-markdown-1.2.0-t3.16-558767d9.tgz:
10828
- resolution: {integrity: sha512-Dl8Raid4175mHijMpsIRLB3yXBZ1s04YxaQoIdHwy64KPHBVdt26x2OYRhYyjMM3VEo4U24AAYNXUh271zYDQw==, tarball: file:apps/mobile/deps/react-native-enriched-markdown-1.2.0-t3.16-558767d9.tgz}
10827
+ react-native-enriched-markdown@file:apps/mobile/deps/react-native-enriched-markdown-1.2.0-t3.16-29ddd424.tgz:
10828
+ resolution: {integrity: sha512-Ru0Uuhq4QBphcC73ney0fgNnvr6Lfv+31H2Ij1qxvDejwVyFh/Romc1a1ot9i8/jnmgvAzTZzbPQcdGtQNFayw==, tarball: file:apps/mobile/deps/react-native-enriched-markdown-1.2.0-t3.16-29ddd424.tgz}
10829
version: 1.2.0-t3.16
10830
peerDependencies:
10831
katex: '>=0.16.0'
@@ -21087,7 +21087,7 @@ snapshots:
21087
react: 19.3.0
21088
react-native: 0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6)
21089
21090
- react-native-enriched-markdown@file:apps/mobile/deps/react-native-enriched-markdown-1.2.0-t3.16-558767d9.tgz(katex@0.16.47)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0):
21090
+ react-native-enriched-markdown@file:apps/mobile/deps/react-native-enriched-markdown-1.2.0-t3.16-29ddd424.tgz(katex@0.16.47)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0):
21091
dependencies:
21092
react: 19.3.0
21093
react-native: 0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6)
pnpm-workspace.yaml
+1
-1
@@ -23,7 +23,7 @@ allowBuilds:
23
node-pty: true
24
# Ships N-API prebuilds; its install script only rebuilds from source.
25
objc-js: false
26
- "react-native-enriched-markdown@file:apps/mobile/deps/react-native-enriched-markdown-1.2.0-t3.16-558767d9.tgz": true
26
+ "react-native-enriched-markdown@file:apps/mobile/deps/react-native-enriched-markdown-1.2.0-t3.16-29ddd424.tgz": true
27
sharp: true
28
"@tsc-rs/typescript": true
29
utf-8-validate: false