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 21, 11:00 UTC
fix(shared): inline code paths like `docker/Dockerfile` become file chips (#32402)
Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Felix Laga committed
Nov 15, 2026 at 16:00 UTC
79e47e90963c010ceedb0ae82ad1e88e6cfd9a7a
5 files changed
+21
-5
apps/mobile/src/lib/enrichedLinkPresentation.test.ts
+2
@@ -34,6 +34,8 @@ describe("Enriched link presentation", () => {
34
"https://example.com/app.tsx",
35
"x + y",
36
"README.md",
37
+ "Dockerfile",
38
+ "docker/Dockerfiles",
39
"/app/settings",
40
]) {
41
expect(ENRICHED_INLINE_FILE_LINK_REGEX.test(text), text).toBe(false);
apps/mobile/src/lib/enrichedLinkPresentation.ts
+9
-2
@@ -17,6 +17,7 @@ import {
17
parseComposerContextHref,
18
} from "@t3tools/shared/composerContextReferences";
19
import { hasThreadLinks, parseThreadLinkHref } from "@t3tools/shared/threadLinks";
20
+import { EXTENSIONLESS_FILE_NAMES } from "@t3tools/shared/markdownLinks";
21
22
export function enrichedContextLinkPresentation(
23
href: string,
@@ -91,8 +92,14 @@ export function enrichedLinkVariantPattern(url: string) {
92
return `^${url.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`;
93
}
94
94
-export const ENRICHED_INLINE_FILE_LINK_REGEX =
95
- /^(?!\S*:\/\/)(?:(?:\.{1,2}[\\/]|~[\\/]|\/(?:Users|home|tmp|var|etc|opt|mnt|Volumes|private|root|usr|bin|sbin|lib|lib64|srv|dev|proc|sys|run|boot|media|workspace|workspaces)\/|[A-Za-z]:[\\/])[^\s`]+|(?:[\p{L}\p{M}\p{N}._-]+[\\/])+[\p{L}\p{M}\p{N}._-]+\.[A-Za-z0-9_-]+(?::\d+(?::\d+|-\d+)?)?|[\p{L}\p{M}\p{N}._-]+\.[A-Za-z0-9_-]+:\d+(?::\d+|-\d+)?)$/u;
95
+const EXTENSIONLESS_FILE_NAME_PATTERN = [...EXTENSIONLESS_FILE_NAMES]
96
+ .map((name) => name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))
97
+ .join("|");
98
+
99
+export const ENRICHED_INLINE_FILE_LINK_REGEX = new RegExp(
100
+ String.raw`^(?!\S*:\/\/)(?:(?:\.{1,2}[\\/]|~[\\/]|\/(?:Users|home|tmp|var|etc|opt|mnt|Volumes|private|root|usr|bin|sbin|lib|lib64|srv|dev|proc|sys|run|boot|media|workspace|workspaces)\/|[A-Za-z]:[\\/])[^\s\x60]+|(?:[\p{L}\p{M}\p{N}._-]+[\\/])+(?:[\p{L}\p{M}\p{N}._-]+\.[A-Za-z0-9_-]+|(?:${EXTENSIONLESS_FILE_NAME_PATTERN}))(?::\d+(?::\d+|-\d+)?)?|[\p{L}\p{M}\p{N}._-]+\.[A-Za-z0-9_-]+:\d+(?::\d+|-\d+)?)$`,
101
+ "u",
102
+);
103
104
export function enrichedSkillLinkRegex(skills?: ReadonlyArray<SelectableMarkdownSkill>) {
105
const names = [...new Set(skills?.map((skill) => skill.name) ?? [])].filter(Boolean);
apps/mobile/src/lib/markdownInlineFileLinks.test.ts
+7
-1
@@ -93,7 +93,13 @@ describe("inline code that names a file", () => {
93
expect(rewrite("See `src/math.ts:2` and `./README.md`.")).toBe(
94
"See [src/math.ts:2](<src/math.ts:2>) and [./README.md](<./README.md>).",
95
);
96
- for (const path of ["src/數學.ts:2", "數學/math.ts:2", "數學.ts:2", "src/數學.ts:2-4"]) {
96
+ for (const path of [
97
+ "src/數學.ts:2",
98
+ "數學/math.ts:2",
99
+ "數學.ts:2",
100
+ "src/數學.ts:2-4",
101
+ "docker/Dockerfile",
102
+ ]) {
103
expect(rewrite(`See \`${path}\`.`), path).toBe(`See [${path}](<${path}>).`);
104
}
105
});
packages/shared/src/markdownLinks.test.ts
+1
@@ -32,6 +32,7 @@ describe("inlineCodeFilePathCandidate", () => {
32
["origin/main", null],
33
["z-ai/glm-5.3", null],
34
["share/man/ls.1", "share/man/ls.1"],
35
+ ["docker/Dockerfile", "docker/Dockerfile"],
36
["src/main.ts/", null],
37
["./patches/", "./patches/"],
38
// regression: #30757 an agent's shortened path is not a file
packages/shared/src/markdownLinks.ts
+2
-2
@@ -68,7 +68,7 @@ const POSIX_FILE_ROOT_PREFIXES = [
68
"/workspaces/",
69
] as const;
70
71
-const EXTENSIONLESS_FILE_NAMES = new Set([
71
+export const EXTENSIONLESS_FILE_NAMES: ReadonlySet<string> = new Set([
72
"Makefile",
73
"makefile",
74
"GNUmakefile",
@@ -202,7 +202,7 @@ export function inlineCodeFilePathCandidate(codeText: string): string | null {
202
.at(-1) ?? "";
203
if (VERSION_SUFFIX_PATTERN.test(basename)) return null;
204
if (!FILE_EXTENSION_PATTERN.test(basename)) {
205
- if (!hasPosition) return null;
205
+ if (!hasPosition) return EXTENSIONLESS_FILE_NAMES.has(basename) ? candidate : null;
206
// A `:line` suffix alone does not make `I/W217:220` a file reference.
207
if (
208
withoutPosition.includes("/") &&