Skip to content

Commit 589bce8

Browse files
fix(mobile): saved home-relative mentions open the home file again
Tapping a saved mention joined every non-absolute path onto the file route root, so ~/.agents/AGENTS.md opened <checkout>/~/.agents/AGENTS.md. Home-relative mention paths now pass through unchanged, as on main. AI-assisted; verified with the tests and tools listed above.
1 parent 99ab184 commit 589bce8

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

‎apps/mobile/src/features/files/filePath.test.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
fileRoutePathSegments,
55
needsWorkspaceFileContents,
66
resolveFileLinkPath,
7+
resolveMentionFilePath,
78
resolveNestedFileLinkPath,
89
resolveWorkspaceRelativeFilePath,
910
} from "./filePath";
@@ -26,6 +27,17 @@ describe("resolveNestedFileLinkPath", () => {
2627
});
2728
});
2829

30+
describe("resolveMentionFilePath", () => {
31+
it.each([
32+
["/home/alice/repo", "src/a.ts", "/home/alice/repo/src/a.ts"],
33+
["/home/alice/repo", "~/.agents/AGENTS.md", "~/.agents/AGENTS.md"],
34+
["/home/alice/repo", "/etc/hosts", "/etc/hosts"],
35+
[null, "src/a.ts", "src/a.ts"],
36+
])("resolves mention %s + %s", (root, path, expected) => {
37+
expect(resolveMentionFilePath(root, path)).toBe(expected);
38+
});
39+
});
40+
2941
describe("resolveFileLinkPath", () => {
3042
it.each([
3143
["/home/maria/project", "~/.agents/AGENTS.md", "/home/maria/.agents/AGENTS.md"],

‎apps/mobile/src/features/files/filePath.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ export function resolveNestedFileLinkPath(
9191
return relativePath === null ? null : resolveWorkspaceFilePath(root, relativePath);
9292
}
9393

94+
// Saved mentions are relative to the file route's root; home-relative ones stay as they are.
95+
export function resolveMentionFilePath(root: string | null | undefined, path: string): string {
96+
if (!root || path === "~" || path.startsWith("~/") || path.startsWith("~\\")) return path;
97+
return resolveWorkspaceFilePath(root, path);
98+
}
99+
94100
export function resolveWorkspaceRelativeFilePath(
95101
workspaceRoot: string | null | undefined,
96102
targetPath: string,

‎apps/mobile/src/features/threads/ThreadFeed.tsx‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ import { useAtomCommand } from "../../state/use-atom-command";
260260
import { useV2ItemSupport } from "../../state/v2-item-support";
261261
import {
262262
fileRoutePathSegments,
263+
resolveMentionFilePath,
263264
resolveNestedFileLinkPath,
264265
resolveWorkspaceFilePath,
265266
resolveWorkspaceRelativeFilePath,
@@ -2985,9 +2986,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
29852986
),
29862987
onLinkPress: onMarkdownLinkPress,
29872988
onMentionPress: (path) =>
2988-
onMarkdownLinkPress(
2989-
props.fileRouteRoot ? resolveWorkspaceFilePath(props.fileRouteRoot, path) : path,
2990-
),
2989+
onMarkdownLinkPress(resolveMentionFilePath(props.fileRouteRoot, path)),
29912990
linkCustomization: enrichedThreadLinkCustomization,
29922991
onImagePress: (href) => onMarkdownLinkPress(href, true),
29932992
resolveImageSource,

0 commit comments

Comments
 (0)