The best way to control Claude Code, Codex and more from any computer or phone
fix(mobile): file links in question cards open the file viewer (#29151)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Nov 10, 2026 at 22:18 UTC
a03d9bce026ef11930b35e9855adc1cdb5ea6eb7
4 files changed
+179
-3
apps/mobile/src/features/threads/PendingUserInputCard.test.tsx
new
+142
@@ -0,0 +1,142 @@
1
+import type { EnvironmentId, RuntimeRequestId, ThreadId } from "@t3tools/contracts";
2
+import type { ReactNode } from "react";
3
+import { act } from "react";
4
+import { createRoot } from "react-dom/client";
5
+import { expect, it, vi } from "vite-plus/test";
6
+
7
+import type { PendingUserInput } from "../../lib/threadActivity";
8
+
9
+const harness = vi.hoisted(() => ({
10
+ navigate: [] as Array<[string, object | undefined]>,
11
+ openedUrls: [] as string[],
12
+}));
13
+
14
+type Children = { children?: ReactNode };
15
+
16
+vi.mock("react-native", () => ({
17
+ Platform: { OS: "ios" },
18
+ View: ({ children }: Children) => <div>{children}</div>,
19
+ ScrollView: ({ children }: Children) => <div>{children}</div>,
20
+ Pressable: ({ children, onPress }: Children & { onPress?: () => void }) => (
21
+ <div onClick={onPress}>{children}</div>
22
+ ),
23
+}));
24
+vi.mock("react-native-reanimated", () => {
25
+ const animation = { duration: () => ({ easing: () => ({}) }) };
26
+ return {
27
+ default: { View: ({ children }: Children) => <div>{children}</div> },
28
+ Easing: { out: () => () => 0, cubic: () => 0 },
29
+ FadeInUp: animation,
30
+ FadeOutDown: animation,
31
+ useAnimatedStyle: () => ({}),
32
+ useSharedValue: (value: number) => ({ value, set: () => {} }),
33
+ };
34
+});
35
+vi.mock("../../components/ui/AppSymbol", () => ({ SymbolView: () => null }));
36
+vi.mock("../../components/ui/AppText", () => ({
37
+ AppText: ({ children }: Children) => <span>{children}</span>,
38
+}));
39
+vi.mock("../../components/ui/ControlPill", () => ({ ControlPill: () => null }));
40
+vi.mock("../../components/ui/Button", () => ({ Button: () => null }));
41
+vi.mock("./QuestionAttachments", () => ({ QuestionAttachments: () => null }));
42
+vi.mock("../files/FileMarkdownPreview", () => ({
43
+ useMarkdownPreviewStyles: () => ({ nativeTextStyle: {} }),
44
+}));
45
+vi.mock("../../native/SelectableMarkdownText", () => ({
46
+ SelectableMarkdownText: (props: { markdown: string; onLinkPress?: (href: string) => void }) => (
47
+ <p>
48
+ {[...props.markdown.matchAll(/\[([^\]]+)\]\(([^)]+)\)/g)].map(([, label, href]) => (
49
+ <button key={href} type="button" onClick={() => props.onLinkPress?.(href!)}>
50
+ {label}
51
+ </button>
52
+ ))}
53
+ </p>
54
+ ),
55
+}));
56
+vi.mock("../../state/entities", () => ({
57
+ useLiveThreadLinkLabels: (markdown: string) => markdown,
58
+}));
59
+vi.mock("../../native/useOpenPullRequest", () => ({
60
+ useOpenPullRequest: () => async (url: string) => {
61
+ harness.openedUrls.push(url);
62
+ return true;
63
+ },
64
+}));
65
+vi.mock("@react-navigation/native", () => ({
66
+ useNavigation: () => ({
67
+ navigate: (name: string, params?: object) => harness.navigate.push([name, params]),
68
+ }),
69
+}));
70
+
71
+import { PendingUserInputCard } from "./PendingUserInputCard";
72
+
73
+function setup(questionMarkdown: string) {
74
+ (globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
75
+ harness.navigate = [];
76
+ harness.openedUrls = [];
77
+
78
+ const pendingUserInput = {
79
+ requestId: "request-1" as RuntimeRequestId,
80
+ responseCapability: "resumable",
81
+ questions: [
82
+ {
83
+ id: "question-1",
84
+ header: "Review",
85
+ question: questionMarkdown,
86
+ options: [],
87
+ allowCustomAnswer: false,
88
+ },
89
+ ],
90
+ } as unknown as PendingUserInput;
91
+ const container = document.createElement("div");
92
+ const root = createRoot(container);
93
+ act(() =>
94
+ root.render(
95
+ <PendingUserInputCard
96
+ environmentId={"env-1" as EnvironmentId}
97
+ threadId={"thread-1" as ThreadId}
98
+ workspaceRoot="/repo"
99
+ canOperateThread
100
+ pendingUserInput={pendingUserInput}
101
+ maxHeight={{ value: 600 } as never}
102
+ cardProgress={{ value: 1, set: () => {} } as never}
103
+ cardCoverage={{ value: 0, set: () => {} } as never}
104
+ collapsed={false}
105
+ onToggleCollapsed={() => {}}
106
+ drafts={{}}
107
+ answers={null}
108
+ respondingUserInputId={null}
109
+ onSelectOption={() => {}}
110
+ onChangeCustomAnswer={() => {}}
111
+ onSubmit={async () => {}}
112
+ onDismiss={async () => {}}
113
+ />,
114
+ ),
115
+ );
116
+ return {
117
+ async pressLink(label: string) {
118
+ const link = [...container.querySelectorAll("button")].find(
119
+ (button) => button.textContent === label,
120
+ );
121
+ if (!link) throw new Error(`No link labelled ${label}`);
122
+ await act(async () => link.click());
123
+ },
124
+ [Symbol.dispose]() {
125
+ act(() => root.unmount());
126
+ },
127
+ };
128
+}
129
+
130
+it("opens a workspace file link in a question in the thread's file viewer", async () => {
131
+ using screen = setup("Should I update [probe.md](docs/probe.md:12)?");
132
+
133
+ await screen.pressLink("probe.md");
134
+
135
+ expect(harness.openedUrls).toEqual([]);
136
+ expect(harness.navigate).toEqual([
137
+ [
138
+ "ThreadFile",
139
+ { environmentId: "env-1", threadId: "thread-1", path: ["docs", "probe.md"], line: "12" },
140
+ ],
141
+ ]);
142
+});
apps/mobile/src/features/threads/PendingUserInputCard.tsx
+34
-3
@@ -1,12 +1,13 @@
1
import { Button } from "../../components/ui/Button";
2
import { QuestionAttachments } from "./QuestionAttachments";
3
-import type { EnvironmentId, RuntimeRequestId } from "@t3tools/contracts";
3
+import type { EnvironmentId, RuntimeRequestId, ThreadId } from "@t3tools/contracts";
4
import type { ThreadUserInputQuestion } from "@t3tools/client-runtime/state/thread-requests";
5
import {
6
markdownProseDirection,
7
textDirection,
8
type TextDirection,
9
} from "@t3tools/shared/textDirection";
10
+import { useNavigation } from "@react-navigation/native";
11
import { useRef } from "react";
12
import { Platform, Pressable, ScrollView, View, type LayoutChangeEvent } from "react-native";
13
import Animated, {
@@ -20,9 +21,15 @@ import { SymbolView } from "../../components/ui/AppSymbol";
21
import { AppText as Text } from "../../components/ui/AppText";
22
import { ControlPill } from "../../components/ui/ControlPill";
23
import { cn } from "../../lib/cn";
24
+import { resolveMarkdownLinkPresentation } from "../../lib/markdownLinks";
25
import { SelectableMarkdownText } from "../../native/SelectableMarkdownText";
26
import { useOpenPullRequest } from "../../native/useOpenPullRequest";
27
import { useMarkdownPreviewStyles } from "../files/FileMarkdownPreview";
28
+import {
29
+ fileRoutePathSegments,
30
+ resolveFileLinkPath,
31
+ resolveWorkspaceRelativeFilePath,
32
+} from "../files/filePath";
33
import { useLiveThreadLinkLabels } from "../../state/entities";
34
import {
35
isPendingUserInputOptionSelected,
@@ -32,6 +39,8 @@ import type { PendingUserInput } from "../../lib/threadActivity";
39
40
export interface PendingUserInputCardProps {
41
readonly environmentId: EnvironmentId;
42
+ readonly threadId: ThreadId;
43
+ readonly workspaceRoot: string | null;
44
readonly canOperateThread: boolean;
45
readonly pendingUserInput: PendingUserInput;
46
readonly maxHeight: DerivedValue<number>;
@@ -69,11 +78,31 @@ function proseDirectionStyle(text: string, setDirection: TextDirection | undefin
78
function QuestionText(props: {
79
readonly markdown: string;
80
readonly environmentId: EnvironmentId;
81
+ readonly threadId: ThreadId;
82
+ readonly workspaceRoot: string | null;
83
readonly setDirection: TextDirection | undefined;
84
}) {
85
const styles = useMarkdownPreviewStyles();
86
const markdown = useLiveThreadLinkLabels(props.markdown, props.environmentId);
76
- const openLink = useOpenPullRequest();
87
+ const navigation = useNavigation();
88
+ const openPullRequest = useOpenPullRequest();
89
+ const openLink = (href: string) => {
90
+ const link = resolveMarkdownLinkPresentation(href);
91
+ if (link.kind !== "file") {
92
+ void openPullRequest(href);
93
+ return;
94
+ }
95
+ const path = resolveFileLinkPath(props.workspaceRoot, link.path);
96
+ if (path === null) return;
97
+ navigation.navigate("ThreadFile", {
98
+ environmentId: String(props.environmentId),
99
+ threadId: String(props.threadId),
100
+ path: fileRoutePathSegments(
101
+ resolveWorkspaceRelativeFilePath(props.workspaceRoot, path) ?? path,
102
+ ),
103
+ ...(link.line ? { line: String(link.line) } : {}),
104
+ });
105
+ };
106
return (
107
<SelectableMarkdownText
108
markdown={markdown}
@@ -83,7 +112,7 @@ function QuestionText(props: {
112
textAlign={
113
Platform.OS === "android" ? undefined : props.setDirection === "rtl" ? "right" : "left"
114
}
86
- onLinkPress={(href) => void openLink(href)}
115
+ onLinkPress={openLink}
116
/>
117
);
118
}
@@ -239,6 +268,8 @@ export function PendingUserInputCard(props: PendingUserInputCardProps) {
268
<QuestionText
269
markdown={question.question}
270
environmentId={props.environmentId}
271
+ threadId={props.threadId}
272
+ workspaceRoot={props.workspaceRoot}
273
setDirection={setDirection}
274
/>
275
<View className="gap-2">
apps/mobile/src/features/threads/ThreadDetailScreen.tsx
+2
@@ -1765,6 +1765,8 @@ function ThreadDetailBody(
1765
{props.activePendingUserInput ? (
1766
<PendingUserInputCard
1767
environmentId={props.environmentId}
1768
+ threadId={props.selectedThread.id}
1769
+ workspaceRoot={props.threadCwd}
1770
canOperateThread={props.canOperateThread}
1771
pendingUserInput={props.activePendingUserInput}
1772
maxHeight={pendingUserInputMaxHeight}
apps/mobile/vite.config.ts
+1
@@ -30,6 +30,7 @@ const reactTests = [
30
"src/features/threads/ThreadMarkdownImage.test.tsx",
31
"src/components/ui/FilePreviewSession.test.tsx",
32
"src/features/threads/UsageLimitRecoveryCard.test.tsx",
33
+ "src/features/threads/PendingUserInputCard.test.tsx",
34
"src/features/threads/NewTaskDraftRouteScreen.test.tsx",
35
"src/native/NativeHeaderToolbar.test.tsx",
36
"src/components/ComposerEditor.ios.test.tsx",