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 23, 23:00 UTC
fix(clients): keep backslashes in copied Codex citations (#12243)
Co-authored-by: Simone <185146821+Lucenx9@users.noreply.github.com>
Simone committed
Sep 21, 2026 at 03:29 UTC
2efb8178d83f4f7c4ccc3ae1165f2a2ded0b2742
2 files changed
+20
packages/client-runtime/src/codexFileCitations.ts
+1
@@ -44,6 +44,7 @@ function markdownLabel(value: string): string {
44
45
function markdownDestination(value: string): string {
46
return value
47
+ .replaceAll("\\", "%5C")
48
.replaceAll("<", "%3C")
49
.replaceAll(">", "%3E")
50
.replaceAll("\r", "%0D")
packages/client-runtime/src/codexMarkdownDirectives.test.ts
+19
@@ -8,6 +8,7 @@ import {
8
renderCodexFileCitationsAsMarkdown,
9
splitCodexArtifactTemplateMarkdown,
10
} from "./codexMarkdownDirectives.js";
11
+import { parseMarkdownFileLink } from "./markdownLinks.js";
12
13
interface TestNode {
14
readonly type: string;
@@ -89,6 +90,24 @@ describe("remarkCodexDirectives", () => {
90
});
91
});
92
93
+describe.each([
94
+ { name: "renderCodexDirectivesForCopy", render: renderCodexDirectivesForCopy },
95
+ { name: "renderCodexFileCitationsAsMarkdown", render: renderCodexFileCitationsAsMarkdown },
96
+])("$name file citation round trips", ({ render }) => {
97
+ it.each([
98
+ "C:\\Users\\test\\[draft]\\report.md",
99
+ "\\\\server\\share\\report.md",
100
+ "outputs/report.md",
101
+ "/tmp/report%5C.md",
102
+ ])("preserves the literal path and line: %s", (path) => {
103
+ const markdown = render(`:codex-file-citation{path="${path}" line_range_start="7"}`);
104
+ const link = parseOrdinaryMarkdown(markdown).children?.[0]?.children?.[0];
105
+
106
+ expect(link?.type).toBe("link");
107
+ expect(parseMarkdownFileLink(link?.url ?? "")).toEqual({ path, line: 7 });
108
+ });
109
+});
110
+
111
describe("native Markdown adapters", () => {
112
it("uses the same parser to render file citations as portable links", () => {
113
expect(renderCodexFileCitationsAsMarkdown(`Created ${FILE_CITATION}.`)).toBe(