The best way to control Claude Code, Codex and more from any computer or phone
fix(mobile): open transcript file links at the resolved path (#21403)
maria committed
Oct 21, 2026 at 00:04 UTC
afc33ff6bf0e64fc31e472869602dd09b503e0ca
12 files changed
+295
-57
apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx
+83
-18
@@ -60,6 +60,9 @@ import { WorkspaceFileWebPreview } from "./WorkspaceFileWebPreview";
60
import {
61
basename,
62
fileHeaderSubtitle,
63
+ fileRoutePathSegments,
64
+ resolveWorkspaceFilePath,
65
+ resolveWorkspaceRelativeFilePath,
66
isAudioPreviewFile,
67
isMarkdownPreviewFile,
68
isSvgImagePreviewFile,
@@ -587,6 +590,32 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
590
const { cwd, environmentId, projectName, selectedThread, threadId } = useThreadFilesWorkspace(
591
props.route.params,
592
);
593
+ const fileAccessSession = useEnvironmentQuery(
594
+ environmentId !== null ? environmentSession.sessionStateAtom(environmentId) : null,
595
+ );
596
+ const fileEnvironment = useEnvironmentPresentation(environmentId);
597
+ const fileAccess = resolveFilesystemReadAccess({
598
+ isCatalogReady: fileEnvironment.isReady,
599
+ connection: fileEnvironment.presentation?.connection ?? null,
600
+ session: fileAccessSession.data,
601
+ sessionError: fileAccessSession.error,
602
+ });
603
+ const { canReadFiles } = fileAccess;
604
+ const targetPath =
605
+ cwd !== null && relativePath !== null ? resolveWorkspaceFilePath(cwd, relativePath) : null;
606
+ const metadata = useEnvironmentQuery(
607
+ canReadFiles && environmentId !== null && targetPath !== null
608
+ ? projectEnvironment.fileMetadata({ environmentId, input: { path: targetPath } })
609
+ : null,
610
+ );
611
+ const metadataPending = !metadata.isSuccess && metadata.error === null;
612
+ const directoryPath = metadata.data?.kind === "directory" ? targetPath : null;
613
+ const [searchQuery, setSearchQuery] = useState("");
614
+ const entriesQuery = useFileTreeEntries({
615
+ environmentId,
616
+ cwd: canReadFiles ? directoryPath : null,
617
+ searchQuery,
618
+ });
619
const [modeOverride, setModeOverride] = useState<{
620
readonly path: string;
621
readonly mode: FileViewMode;
@@ -614,7 +643,11 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
643
const resolvedActiveMode =
644
isVideoFile || isAudioFile ? "preview" : canPreview ? activeMode : "source";
645
const assetPreviewPath =
617
- isBrowserFile || isImageFile || isVideoFile || isAudioFile ? relativePath : null;
646
+ !metadataPending &&
647
+ directoryPath === null &&
648
+ (isBrowserFile || isImageFile || isVideoFile || isAudioFile)
649
+ ? relativePath
650
+ : null;
651
const assetPreview = useWorkspaceFileAssetUrlState({
652
cwd,
653
environmentId,
@@ -665,21 +698,12 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
698
void assetPreview.refresh().finally(() => setPreviewRevision((current) => current + 1));
699
};
700
const needsFileContents =
701
+ !metadataPending &&
702
+ directoryPath === null &&
703
relativePath !== null &&
704
!isVideoFile &&
705
!isAudioFile &&
706
(resolvedActiveMode === "source" || isMarkdownPreviewFile(relativePath));
672
- const fileAccessSession = useEnvironmentQuery(
673
- environmentId !== null ? environmentSession.sessionStateAtom(environmentId) : null,
674
- );
675
- const fileEnvironment = useEnvironmentPresentation(environmentId);
676
- const fileAccess = resolveFilesystemReadAccess({
677
- isCatalogReady: fileEnvironment.isReady,
678
- connection: fileEnvironment.presentation?.connection ?? null,
679
- session: fileAccessSession.data,
680
- sessionError: fileAccessSession.error,
681
- });
682
- const { canReadFiles } = fileAccess;
707
const fileQuery = useEnvironmentQuery(
708
canReadFiles &&
709
environmentId !== null &&
@@ -695,7 +719,11 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
719
const fileData = fileQuery.data as ProjectReadFileResult | null;
720
721
const handleSelectFile = (path: string) => {
698
- const segments = path.split("/").filter(Boolean);
722
+ const targetPath =
723
+ directoryPath === null ? path : resolveWorkspaceFilePath(directoryPath, path);
724
+ const segments = fileRoutePathSegments(
725
+ resolveWorkspaceRelativeFilePath(cwd, targetPath) ?? targetPath,
726
+ );
727
// A draft has no thread. `ThreadFile` would stringify null and then wait forever for a
728
// thread to resolve, so a draft stays on its own route and carries its workspace along.
729
if (threadId === null) {
@@ -709,20 +737,22 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
737
);
738
return;
739
}
712
- navigation.navigate("ThreadFile", {
740
+ const destination = {
741
environmentId: String(environmentId),
742
threadId: String(threadId),
743
path: segments,
716
- });
744
+ };
745
+ if (directoryPath !== null) navigation.dispatch(StackActions.push("ThreadFile", destination));
746
+ else navigation.navigate("ThreadFile", destination);
747
};
748
const renderInspector = (headerInset: number) =>
749
fileInspector.supported && environmentId !== null && cwd !== null ? (
750
<ThreadFileNavigatorPane
721
- cwd={cwd}
751
+ cwd={directoryPath ?? cwd}
752
environmentId={environmentId}
753
headerInset={headerInset}
724
- projectName={projectName}
725
- selectedPath={relativePath}
754
+ projectName={directoryPath ?? projectName}
755
+ selectedPath={directoryPath === null ? relativePath : null}
756
onSelectFile={handleSelectFile}
757
/>
758
) : undefined;
@@ -885,6 +915,41 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
915
);
916
}
917
918
+ if (metadataPending) {
919
+ return <LoadingScreen message="Opening file..." messagePlacement="above-spinner" />;
920
+ }
921
+ if (directoryPath !== null) {
922
+ return (
923
+ <View className={Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 bg-sheet"}>
924
+ <FilesBrowserHeader
925
+ projectName={directoryPath}
926
+ searchQuery={searchQuery}
927
+ onSearchQueryChange={setSearchQuery}
928
+ onRefresh={entriesQuery.refresh}
929
+ onBack={handleBack}
930
+ />
931
+ <ScreenContent>
932
+ <FileTreeBrowser
933
+ key={JSON.stringify([environmentId, directoryPath])}
934
+ entries={entriesQuery.entries}
935
+ loadingDirectories={entriesQuery.loadingDirectories}
936
+ onLoadDirectory={entriesQuery.loadDirectory}
937
+ error={entriesQuery.error}
938
+ isPending={entriesQuery.isPending}
939
+ isRefreshing={entriesQuery.isRefreshing}
940
+ searchQuery={searchQuery}
941
+ searchResultPaths={entriesQuery.searchResultPaths}
942
+ searchTruncated={entriesQuery.searchTruncated}
943
+ selectedPath={null}
944
+ onRefresh={entriesQuery.refresh}
945
+ onSelectFile={handleSelectFile}
946
+ />
947
+ <FilesToolbarBottomFade />
948
+ </ScreenContent>
949
+ </View>
950
+ );
951
+ }
952
+
953
const headerSubtitle = fileHeaderSubtitle(projectName, relativePath);
954
955
return (
apps/mobile/src/features/files/filePath.test.ts
+27
@@ -2,6 +2,7 @@ import { describe, expect, it } from "vite-plus/test";
2
3
import {
4
fileRoutePathSegments,
5
+ resolveFileLinkPath,
6
isSvgImagePreviewFile,
7
resolveWorkspaceRelativeFilePath,
8
fileHeaderSubtitle,
@@ -16,6 +17,23 @@ describe("fileRoutePathSegments", () => {
17
});
18
});
19
20
+describe("resolveFileLinkPath", () => {
21
+ it.each([
22
+ ["/home/maria/project", "~/.agents/AGENTS.md", "/home/maria/.agents/AGENTS.md"],
23
+ ["/Users/maria/project", "~/notes.md", "/Users/maria/notes.md"],
24
+ ["C:\\Users\\maria\\project", "~\\.agents\\AGENTS.md", "C:\\Users\\maria\\.agents\\AGENTS.md"],
25
+ ])("expands a home link from %s", (cwd, path, expected) => {
26
+ expect(resolveFileLinkPath(cwd, path)).toBe(expected);
27
+ expect(fileRoutePathSegments(expected).join("/")).toBe(expected);
28
+ });
29
+
30
+ it("does not turn an unresolved home into a workspace path", () => {
31
+ expect(resolveFileLinkPath("/repo", "~/notes.md")).toBeNull();
32
+ expect(resolveFileLinkPath(null, "~/notes.md")).toBeNull();
33
+ expect(resolveFileLinkPath("/repo", "../notes.md")).toBeNull();
34
+ });
35
+});
36
+
37
describe("resolveWorkspaceRelativeFilePath", () => {
38
it("keeps normalized workspace-relative paths", () => {
39
expect(resolveWorkspaceRelativeFilePath("/repo", "./src/../src/main.ts")).toBe("src/main.ts");
@@ -30,6 +48,15 @@ describe("resolveWorkspaceRelativeFilePath", () => {
48
);
49
});
50
51
+ it("recognizes home links inside the workspace", () => {
52
+ expect(resolveWorkspaceRelativeFilePath("/home/maria/project", "~/project/src/main.ts")).toBe(
53
+ "src/main.ts",
54
+ );
55
+ expect(
56
+ resolveWorkspaceRelativeFilePath("/home/maria/project", "~/.agents/AGENTS.md"),
57
+ ).toBeNull();
58
+ });
59
+
60
it("rejects paths outside the workspace", () => {
61
expect(resolveWorkspaceRelativeFilePath("/repo", "/other/main.ts")).toBeNull();
62
expect(resolveWorkspaceRelativeFilePath("/repo", "../other/main.ts")).toBeNull();
apps/mobile/src/features/files/filePath.ts
+17
-6
@@ -1,3 +1,4 @@
1
+import { resolvePathLinkTarget } from "@t3tools/shared/fileLinks";
2
import {
3
isWorkspaceAudioPreviewPath,
4
isWorkspaceVideoPreviewPath,
@@ -66,16 +67,26 @@ function normalizeRelativePath(value: string): string | null {
67
return segments.length > 0 ? segments.join("/") : null;
68
}
69
69
-export function resolveWorkspaceRelativeFilePath(
70
+export function resolveFileLinkPath(
71
workspaceRoot: string | null | undefined,
72
targetPath: string,
73
): string | null {
73
- if (!isAbsolutePath(targetPath)) {
74
- if (targetPath.startsWith("~/") || targetPath.startsWith("~\\")) {
75
- return null;
76
- }
77
- return normalizeRelativePath(targetPath);
74
+ if (targetPath.startsWith("~/") || targetPath.startsWith("~\\")) {
75
+ if (!workspaceRoot) return null;
76
+ const expanded = resolvePathLinkTarget(targetPath, workspaceRoot);
77
+ return isAbsolutePath(expanded) ? expanded : null;
78
}
79
+ return isAbsolutePath(targetPath) ? targetPath : normalizeRelativePath(targetPath);
80
+}
81
+
82
+export function resolveWorkspaceRelativeFilePath(
83
+ workspaceRoot: string | null | undefined,
84
+ targetPath: string,
85
+): string | null {
86
+ const resolved = resolveFileLinkPath(workspaceRoot, targetPath);
87
+ if (resolved === null) return null;
88
+ targetPath = resolved;
89
+ if (!isAbsolutePath(targetPath)) return targetPath;
90
if (!workspaceRoot) {
91
return null;
92
}
apps/mobile/src/features/threads/ThreadFeed.tsx
+127
-27
@@ -28,6 +28,7 @@ import { resolveUserMessagePresentation } from "@t3tools/client-runtime/user-mes
28
import { canForkProjectedAssistantItem } from "@t3tools/client-runtime/state/thread-workflows";
29
import type { WorkflowOpening } from "@t3tools/client-runtime/state/subagentRuntime";
30
import {
31
+ AuthFilesystemReadScope,
32
type OrchestrationMessageContext,
33
ThreadId,
34
type ChatAttachment,
@@ -57,7 +58,11 @@ import {
58
import { resolveAssetUrl } from "@t3tools/client-runtime/state/assets";
59
import { isMarkdownFileLinkLabel } from "@t3tools/shared/markdownLinks";
60
import { formatAttachmentSize } from "@t3tools/client-runtime/state/attachments";
60
-import { settlePromise, squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
61
+import {
62
+ executeAtomQuery,
63
+ settlePromise,
64
+ squashAtomCommandFailure,
65
+} from "@t3tools/client-runtime/state/runtime";
66
import {
67
classifyMarkdownImageSource,
68
markdownImageSourceFragment,
@@ -218,7 +223,13 @@ import {
223
useRefreshAssetUrl,
224
} from "../../state/assets";
225
import { useAtomQueryRunner } from "../../state/use-atom-query-runner";
221
-import { usePreparedConnection } from "../../state/session";
226
+import { readEnvironmentScope, usePreparedConnection } from "../../state/session";
227
+import { projectEnvironment } from "../../state/projects";
228
+import {
229
+ needsWorkspaceBasenameLookup,
230
+ pickWorkspaceBasenameMatch,
231
+ WORKSPACE_BASENAME_LOOKUP_LIMIT,
232
+} from "@t3tools/client-runtime/workspace-basename-lookup";
233
import { useLiveThreadLinkLabels } from "../../state/entities";
234
import { useThreadSelection } from "../../state/use-thread-selection";
235
import { composerDocumentAttachmentRecord } from "../../lib/composerContext";
@@ -230,7 +241,8 @@ import { useAtomCommand } from "../../state/use-atom-command";
241
import { useV2ItemSupport } from "../../state/v2-item-support";
242
import {
243
fileRoutePathSegments,
233
- isAbsolutePath,
244
+ resolveFileLinkPath,
245
+ resolveWorkspaceFilePath,
246
resolveWorkspaceRelativeFilePath,
247
} from "../files/filePath";
248
import { waitForThreadShellReady } from "./threadForkNavigation";
@@ -1740,6 +1752,19 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
1752
const { copiedRowId, expandedWorkGroups, expandedWorkRows, expandedTurnIds } = interactionState;
1753
const [expandedFile, setExpandedFile] = useState<FilePreviewSource | null>(null);
1754
const [expandedVideo, setExpandedVideo] = useState<VideoPreviewSource | null>(null);
1755
+ const markdownLinkRequest = useRef<AbortController | null>(null);
1756
+ useFocusEffect(useCallback(() => () => markdownLinkRequest.current?.abort(), []));
1757
+ const markdownLinkScope = JSON.stringify([
1758
+ props.environmentId,
1759
+ props.threadId,
1760
+ props.contentPresentation.kind,
1761
+ ]);
1762
+ const previousMarkdownLinkScope = useRef(markdownLinkScope);
1763
+ useLayoutEffect(() => {
1764
+ if (previousMarkdownLinkScope.current === markdownLinkScope) return;
1765
+ previousMarkdownLinkScope.current = markdownLinkScope;
1766
+ markdownLinkRequest.current?.abort();
1767
+ }, [markdownLinkScope]);
1768
const fileShareSourceIdentifier = useId();
1769
const shareFileChip = useFileChipShare(
1770
props.environmentId,
@@ -1806,6 +1831,9 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
1831
);
1832
};
1833
const onMarkdownLinkPress = (href: string, imageEmbed = false) => {
1834
+ markdownLinkRequest.current?.abort();
1835
+ const request = new AbortController();
1836
+ markdownLinkRequest.current = request;
1837
const skill = enrichedSkillReference(href, props.skills);
1838
if (skill) {
1839
const instructionsPath = enrichedSkillInstructionsPath(skill);
@@ -1828,41 +1856,111 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
1856
});
1857
if (media) {
1858
void Haptics.selectionAsync();
1831
- if (media.kind === "video") {
1832
- setExpandedVideo((current) => current ?? media.source);
1833
- } else {
1834
- setExpandedFile((current) => current ?? media.source);
1835
- }
1859
+ const openPreview = () => {
1860
+ if (request.signal.aborted) return;
1861
+ if (media.kind === "video") {
1862
+ setExpandedVideo((current) => current ?? media.source);
1863
+ } else {
1864
+ setExpandedFile((current) => current ?? media.source);
1865
+ }
1866
+ };
1867
+ const resource = "resource" in media.source ? media.source.resource : null;
1868
+ const mediaPath = resource && "path" in resource ? resource.path : null;
1869
+ if (
1870
+ typeof mediaPath === "string" &&
1871
+ readEnvironmentScope(props.environmentId, AuthFilesystemReadScope)
1872
+ ) {
1873
+ void executeAtomQuery(
1874
+ appAtomRegistry,
1875
+ projectEnvironment.fileMetadata({
1876
+ environmentId: props.environmentId,
1877
+ input: { path: mediaPath },
1878
+ }),
1879
+ { signal: request.signal, reportFailure: false, reportDefect: false },
1880
+ ).then((result) => {
1881
+ if (request.signal.aborted) return;
1882
+ if (result._tag === "Success" && result.value?.kind === "directory") {
1883
+ navigation.navigate("ThreadFile", {
1884
+ environmentId: String(props.environmentId),
1885
+ threadId: String(props.threadId),
1886
+ path: fileRoutePathSegments(mediaPath),
1887
+ });
1888
+ } else openPreview();
1889
+ }, openPreview);
1890
+ } else openPreview();
1891
return;
1892
}
1893
1894
const presentation = resolveMarkdownLinkPresentation(href);
1895
if (presentation.kind === "file") {
1841
- const relativePath = resolveWorkspaceRelativeFilePath(props.workspaceRoot, presentation.path);
1842
- if (relativePath) {
1896
+ const path = resolveFileLinkPath(props.workspaceRoot, presentation.path);
1897
+ if (path === null) return;
1898
+ const relativePath = resolveWorkspaceRelativeFilePath(props.workspaceRoot, path);
1899
+ const openAt = (target: string) => {
1900
+ if (request.signal.aborted) return;
1901
void Haptics.selectionAsync();
1902
navigation.navigate("ThreadFile", {
1903
environmentId: String(props.environmentId),
1904
threadId: String(props.threadId),
1847
- path: fileRoutePathSegments(relativePath),
1905
+ path: fileRoutePathSegments(target),
1906
...(presentation.line ? { line: String(presentation.line) } : {}),
1907
});
1850
- return;
1851
- }
1852
- }
1853
-
1854
- if (presentation.kind === "file" && isAbsolutePath(presentation.path)) {
1855
- void Haptics.selectionAsync();
1856
- navigation.navigate("ThreadFile", {
1857
- environmentId: String(props.environmentId),
1858
- threadId: String(props.threadId),
1859
- path: fileRoutePathSegments(presentation.path),
1860
- ...(presentation.line ? { line: String(presentation.line) } : {}),
1861
- });
1908
+ };
1909
+ if (
1910
+ props.workspaceRoot &&
1911
+ relativePath &&
1912
+ !/[\\/]$/.test(presentation.path) &&
1913
+ needsWorkspaceBasenameLookup(relativePath) &&
1914
+ readEnvironmentScope(props.environmentId, AuthFilesystemReadScope)
1915
+ ) {
1916
+ const originalPath = resolveWorkspaceFilePath(props.workspaceRoot, relativePath);
1917
+ void executeAtomQuery(
1918
+ appAtomRegistry,
1919
+ projectEnvironment.searchEntries({
1920
+ environmentId: props.environmentId,
1921
+ input: {
1922
+ cwd: props.workspaceRoot,
1923
+ query: relativePath,
1924
+ kind: "file",
1925
+ limit: WORKSPACE_BASENAME_LOOKUP_LIMIT,
1926
+ },
1927
+ }),
1928
+ { signal: request.signal, reportFailure: false, reportDefect: false },
1929
+ ).then(
1930
+ (result) => {
1931
+ const match =
1932
+ result._tag === "Success"
1933
+ ? pickWorkspaceBasenameMatch(relativePath, result.value.entries)
1934
+ : null;
1935
+ if (!match || match === relativePath) {
1936
+ openAt(relativePath);
1937
+ return;
1938
+ }
1939
+ if (request.signal.aborted) return;
1940
+ void executeAtomQuery(
1941
+ appAtomRegistry,
1942
+ projectEnvironment.fileMetadata({
1943
+ environmentId: props.environmentId,
1944
+ input: { path: originalPath },
1945
+ }),
1946
+ { signal: request.signal, reportFailure: false, reportDefect: false },
1947
+ ).then(
1948
+ (metadata) =>
1949
+ openAt(
1950
+ metadata._tag === "Success" && metadata.value?.kind !== "directory"
1951
+ ? match
1952
+ : relativePath,
1953
+ ),
1954
+ () => openAt(relativePath),
1955
+ );
1956
+ },
1957
+ () => openAt(relativePath),
1958
+ );
1959
+ } else openAt(relativePath ?? path);
1960
return;
1961
}
1962
1865
- if (presentation.kind !== "file" && presentation.href) {
1963
+ if (presentation.href) {
1964
if (/^https?:\/\//i.test(presentation.href) && isPdfFile({ name: presentation.href })) {
1965
setExpandedFile(
1966
(current) => current ?? { kind: "pdf", uri: presentation.href!, name: "Document.pdf" },
@@ -1971,7 +2069,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
2069
unavailable={false}
2070
alt={image.alt}
2071
actionsSource={media?.source.actionsSource}
1974
- onPressPreview={(source) => setExpandedFile((current) => current ?? source)}
2072
+ onPressPreview={onPressPreview}
2073
/>
2074
);
2075
}
@@ -1989,7 +2087,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
2087
alt={image.alt}
2088
srcFragment={markdownImageSourceFragment(image.href)}
2089
actionsSource={media?.source.actionsSource}
1992
- onPressPreview={(source) => setExpandedFile((current) => current ?? source)}
2090
+ onPressPreview={onPressPreview}
2091
/>
2092
);
2093
};
@@ -2018,7 +2116,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
2116
? { ...actionsSource, resource: viewedImage.resource }
2117
: undefined
2118
}
2021
- onPressPreview={(source) => setExpandedFile((current) => current ?? source)}
2119
+ onPressPreview={onPressPreview}
2120
/>
2121
) : null;
2122
};
@@ -2353,9 +2451,11 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
2451
};
2452
2453
const onPressPreview = (source: FilePreviewSource) => {
2454
+ markdownLinkRequest.current?.abort();
2455
setExpandedFile((current) => current ?? source);
2456
};
2457
const onPressVideo = (attachment: ChatFileAttachment, sourceIdentifier: string) => {
2458
+ markdownLinkRequest.current?.abort();
2459
setExpandedVideo(
2460
(current) =>
2461
current ?? attachmentVideoPreviewSource(props.environmentId, attachment, sourceIdentifier),
apps/mobile/src/features/threads/fileChipMenu.test.ts
+13
@@ -37,6 +37,19 @@ describe("resolveFileChipTarget", () => {
37
expect(resolveFileChipTarget("src/app.ts", null)).toEqual({ relativePath: "src/app.ts" });
38
});
39
40
+ it("resolves home links for navigation and menu actions", () => {
41
+ expect(resolveFileChipTarget("~/.agents/AGENTS.md:314", "/home/maria/repo")).toEqual({
42
+ fullPath: "/home/maria/.agents/AGENTS.md",
43
+ });
44
+ expect(resolveFileChipTarget("~/repo/src/main.ts:12", "/home/maria/repo")).toEqual({
45
+ fullPath: "/home/maria/repo/src/main.ts",
46
+ relativePath: "src/main.ts",
47
+ });
48
+ expect(resolveFileChipTarget("~/.agents/AGENTS.md", "C:\\Users\\maria\\repo")).toEqual({
49
+ fullPath: "C:\\Users\\maria\\.agents\\AGENTS.md",
50
+ });
51
+ });
52
+
53
it("ignores links that are not files or cannot be opened", () => {
54
expect(resolveFileChipTarget("https://example.com/app.ts", "/repo")).toBeNull();
55
expect(resolveFileChipTarget("~/report.md", "/repo")).toBeNull();
apps/mobile/src/features/threads/fileChipMenu.ts
+6
-3
@@ -7,6 +7,7 @@ import { hostPreviewMimeTypeFromExtension } from "@t3tools/shared/filePreview";
7
8
import {
9
isAbsolutePath,
10
+ resolveFileLinkPath,
11
resolveWorkspaceFilePath,
12
resolveWorkspaceRelativeFilePath,
13
} from "../files/filePath";
@@ -30,9 +31,11 @@ export function resolveFileChipTarget(
31
): FileChipTarget | null {
32
const presentation = resolveMarkdownLinkPresentation(href);
33
if (presentation.kind !== "file") return null;
33
- const relativePath = resolveWorkspaceRelativeFilePath(workspaceRoot, presentation.path);
34
- const fullPath = isAbsolutePath(presentation.path)
35
- ? presentation.path
34
+ const path = resolveFileLinkPath(workspaceRoot, presentation.path);
35
+ if (path === null) return null;
36
+ const relativePath = resolveWorkspaceRelativeFilePath(workspaceRoot, path);
37
+ const fullPath = isAbsolutePath(path)
38
+ ? path
39
: workspaceRoot && relativePath
40
? resolveWorkspaceFilePath(workspaceRoot, relativePath)
41
: undefined;
apps/mobile/src/lib/markdownLinks.test.ts
+11
@@ -14,6 +14,17 @@ describe("resolveMarkdownLinkIcon", () => {
14
});
15
16
describe("resolveMarkdownLinkPresentation", () => {
17
+ it("opens relative directory links as workspace paths", () => {
18
+ expect(resolveMarkdownLinkPresentation("src/")).toMatchObject({
19
+ kind: "file",
20
+ path: "src/",
21
+ });
22
+ expect(resolveMarkdownLinkPresentation("docs/My Folder/")).toMatchObject({
23
+ kind: "file",
24
+ path: "docs/My Folder/",
25
+ });
26
+ });
27
+
28
it("keeps thread-link hrefs for in-app navigation", () => {
29
const href = "t3-thread://v1/thread-1";
30
expect(resolveMarkdownLinkPresentation(href)).toEqual({ kind: "link", href });
apps/mobile/src/lib/markdownLinks.ts
+5
-1
@@ -273,7 +273,11 @@ export function resolveMarkdownLinkPresentation(href: string): MarkdownLinkPrese
273
}
274
} catch {}
275
276
- const target = parseMarkdownFileLink(normalized);
276
+ const target =
277
+ parseMarkdownFileLink(normalized) ??
278
+ (/^(?:[A-Za-z0-9._-]+(?: +[A-Za-z0-9._-]+)*\/)+$/.test(normalized)
279
+ ? { path: normalized }
280
+ : null);
281
if (target) {
282
return {
283
kind: "file",
apps/web/src/components/ChatMarkdown.tsx
+1
-1
@@ -219,7 +219,7 @@ import {
219
pickWorkspaceBasenameMatch,
220
stripRepeatedWorkspacePrefix,
221
WORKSPACE_BASENAME_LOOKUP_LIMIT,
222
-} from "../workspaceBasenameLookup";
222
+} from "@t3tools/client-runtime/workspace-basename-lookup";
223
import {
224
parseChangeRequestUrl,
225
pullRequestCandidateUrlFromReferenceAutolink,
apps/web/src/workspaceBasenameLookup.test.ts
+1
-1
@@ -4,7 +4,7 @@ import {
4
claimWorkspaceBasenameLookup,
5
needsWorkspaceBasenameLookup,
6
pickWorkspaceBasenameMatch,
7
-} from "./workspaceBasenameLookup";
7
+} from "@t3tools/client-runtime/workspace-basename-lookup";
8
9
describe("needsWorkspaceBasenameLookup", () => {
10
it("flags bare filenames", () => {
packages/client-runtime/package.json
+4
@@ -3,6 +3,10 @@
3
"private": true,
4
"type": "module",
5
"exports": {
6
+ "./workspace-basename-lookup": {
7
+ "types": "./src/workspaceBasenameLookup.ts",
8
+ "default": "./src/workspaceBasenameLookup.ts"
9
+ },
10
"./composerThreadItems": {
11
"types": "./src/composerThreadItems.ts",
12
"default": "./src/composerThreadItems.ts"