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 22, 02:00 UTC
fix(mobile): group settled PR threads in the continue menu (#27941)
Co-authored-by: Orin <orin@orin.ws> Co-authored-by: maria-rcks <maria@kuuro.net>
Arif Ali committed
Nov 7, 2026 at 13:53 UTC
0080084c7109b0c0e9dff2904674b2ce75f76f2a
8 files changed
+151
-47
apps/mobile/src/features/pull-requests/PullRequestAgentRow.tsx
+3
-5
@@ -19,15 +19,13 @@ export function PullRequestAgentRow(props: {
19
title={props.title ?? action.title}
20
icon="sparkles"
21
accessibilityLabel={props.title ?? action.title}
22
- menu={agent.threads.length > 1}
22
+ menu={agent.chooseThread && !action.attributes.disabled}
23
onPress={
24
- action.attributes.disabled || agent.threads.length > 1
25
- ? undefined
26
- : () => agent.start(props.task)
24
+ action.attributes.disabled || agent.chooseThread ? undefined : () => agent.start(props.task)
25
}
26
/>
27
);
30
- if (agent.threads.length <= 1 || action.attributes.disabled) return row;
28
+ if (!agent.chooseThread || action.attributes.disabled) return row;
29
return (
30
<Menu
31
title={props.title ?? action.title}
apps/mobile/src/features/pull-requests/PullRequestControls.tsx
+24
-24
@@ -3,6 +3,7 @@ import Animated from "react-native-reanimated";
3
import { PR_ROW_LAYOUT } from "./pullRequestAnimations";
4
import { useNavigation } from "@react-navigation/native";
5
import type { PullRequestDetail } from "@t3tools/contracts";
6
+import type { MenuAction } from "@react-native-menu/menu";
7
import type { ReactNode } from "react";
8
import { Platform, Pressable, View } from "react-native";
9
import { useSafeAreaInsets } from "react-native-safe-area-context";
@@ -128,7 +129,7 @@ export function PullRequestActionToolbar(props: {
129
).changeRequest;
130
const threadLabel = agent.threads.length ? "Continue thread" : `Work on ${shortLabel}`;
131
const primaryLabel = pendingReview ? `Submit review · ${draft.comments.length}` : threadLabel;
131
- const chooseThread = agent.threads.length > 1;
132
+ const chooseThread = agent.chooseThread;
133
const agentActions = agent.actions.filter((action) => action.task !== "ask");
134
const open = (mode: "review" | "comment") =>
135
navigation.navigate("PullRequestReview", { ...props.params, mode });
@@ -193,17 +194,6 @@ export function PullRequestActionToolbar(props: {
194
</View>
195
);
196
}
196
- const nativeThreadItems = threadMenuItems.map((item) => (
197
- <Toolbar.MenuAction
198
- key={item.id}
199
- icon={item.image}
200
- subtitle={"subtitle" in item ? item.subtitle : undefined}
201
- disabled={"attributes" in item && item.attributes.disabled}
202
- onPress={() => agent.select(item.id)}
203
- >
204
- <Toolbar.Label>{item.title}</Toolbar.Label>
205
- </Toolbar.MenuAction>
206
- ));
197
const primaryControl = showPrimary ? (
198
!pendingReview && chooseThread ? (
199
<Toolbar.Menu
@@ -222,7 +212,7 @@ export function PullRequestActionToolbar(props: {
212
disabled={primaryDisabled}
213
separateBackground
214
>
225
- {nativeThreadItems}
215
+ {renderThreadMenuItems(threadMenuItems, agent.select)}
216
</Toolbar.Menu>
217
) : (
218
<Toolbar.Button
@@ -256,17 +246,7 @@ export function PullRequestActionToolbar(props: {
246
{agentActions.map((action) =>
247
chooseThread && !action.disabled ? (
248
<Toolbar.Menu key={action.task} title={action.title} icon={action.icon}>
259
- {agent.threadActions(action.task).map((item) => (
260
- <Toolbar.MenuAction
261
- key={item.id}
262
- icon={item.image}
263
- subtitle={"subtitle" in item ? item.subtitle : undefined}
264
- disabled={"attributes" in item && item.attributes.disabled}
265
- onPress={() => agent.select(item.id)}
266
- >
267
- <Toolbar.Label>{item.title}</Toolbar.Label>
268
- </Toolbar.MenuAction>
269
- ))}
249
+ {renderThreadMenuItems(agent.threadActions(action.task), agent.select)}
250
</Toolbar.Menu>
251
) : (
252
<Toolbar.MenuAction
@@ -308,3 +288,23 @@ export function PullRequestActionToolbar(props: {
288
</Toolbar>
289
);
290
}
291
+
292
+function renderThreadMenuItems(items: MenuAction[], select: (id: string) => void): ReactNode {
293
+ return items.map((item) =>
294
+ item.subactions ? (
295
+ <Toolbar.Menu key={item.id} title={item.title} icon={item.image}>
296
+ {renderThreadMenuItems(item.subactions, select)}
297
+ </Toolbar.Menu>
298
+ ) : (
299
+ <Toolbar.MenuAction
300
+ key={item.id}
301
+ icon={item.image}
302
+ subtitle={item.subtitle}
303
+ disabled={item.attributes?.disabled}
304
+ onPress={() => item.id && select(item.id)}
305
+ >
306
+ <Toolbar.Label>{item.title}</Toolbar.Label>
307
+ </Toolbar.MenuAction>
308
+ ),
309
+ );
310
+}
apps/mobile/src/features/pull-requests/pullRequestAgentTasks.test.ts
+24
@@ -3,6 +3,7 @@ import {
3
appendPullRequestAgentPrompt,
4
pullRequestAgentPrompt,
5
pullRequestAgentThread,
6
+ pullRequestAgentThreadActions,
7
} from "./pullRequestAgentTasks";
8
import { IsoDateTime, ProjectId, ThreadId } from "@t3tools/contracts";
9
import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
@@ -27,7 +28,30 @@ describe("PR agent tasks", () => {
28
archivedAt: IsoDateTime.make("2026-10-09T10:00:00.000Z"),
29
};
30
expect(pullRequestAgentThread([thread, archived])).toBeUndefined();
31
+ expect(pullRequestAgentThread([archived])).toBeUndefined();
32
+ const settled = { ...thread, settled: true };
33
+ expect(pullRequestAgentThread([settled])).toBeUndefined();
34
+ expect(pullRequestAgentThread([settled], settled.id)).toBe(settled);
35
+ expect(pullRequestAgentThread([thread, { ...settled, id: archived.id }])).toBeUndefined();
36
expect(pullRequestAgentThread([thread, archived], archived.id)).toBe(archived);
37
+ const actions = pullRequestAgentThreadActions([settled, archived], "ask", true);
38
+ expect(actions.map((action) => action.title)).toEqual([
39
+ "Start a new thread",
40
+ "Existing work",
41
+ "Settled threads",
42
+ ]);
43
+ expect(actions[2]?.subactions).toMatchObject([
44
+ { id: `ask:${settled.id}`, subtitle: "Settled thread" },
45
+ ]);
46
+ expect(pullRequestAgentThreadActions([thread], "ask", false)).toMatchObject([
47
+ { id: `ask:${thread.id}`, subtitle: "Continue thread" },
48
+ ]);
49
+ expect(
50
+ pullRequestAgentThreadActions([settled], "feedback", false)[0]?.subactions,
51
+ ).toMatchObject([{ id: `feedback:${settled.id}`, attributes: { disabled: false } }]);
52
+ expect(pullRequestAgentThreadActions([archived], "feedback", true)[1]).toMatchObject({
53
+ attributes: { disabled: true },
54
+ });
55
});
56
it("replaces the helper's own text when switching tasks, keeping user edits", () => {
57
const first = appendPullRequestAgentPrompt("My question", "explain", GITHUB);
apps/mobile/src/features/pull-requests/pullRequestAgentTasks.ts
+34
-1
@@ -2,6 +2,7 @@ import {
2
sourceControlClients,
3
type ChangeRequestTerminology,
4
} from "@t3tools/client-runtime/source-control-clients";
5
+import type { MenuAction } from "@react-native-menu/menu";
6
import type { PullRequestDetail, PullRequestLinkedThreadsResult } from "@t3tools/contracts";
7
8
export type PullRequestAgentTask = "ask" | "explain" | "feedback" | "conflicts" | "watch";
@@ -11,7 +12,39 @@ export function pullRequestAgentThread(
12
threadId?: string,
13
) {
14
if (threadId) return threads.find((thread) => thread.id === threadId);
14
- return threads.length === 1 ? threads[0] : undefined;
15
+ return threads.length === 1 && !threads[0]?.settled && !threads[0]?.archivedAt
16
+ ? threads[0]
17
+ : undefined;
18
+}
19
+
20
+export function pullRequestAgentThreadActions(
21
+ threads: PullRequestLinkedThreadsResult["threads"],
22
+ task: PullRequestAgentTask,
23
+ canAsk: boolean,
24
+): MenuAction[] {
25
+ const active: MenuAction[] = [];
26
+ const settled: MenuAction[] = [];
27
+ for (const thread of threads) {
28
+ const action = {
29
+ id: `${task}:${thread.id}`,
30
+ title: thread.title,
31
+ subtitle: thread.archivedAt
32
+ ? "Archived thread"
33
+ : thread.settled
34
+ ? "Settled thread"
35
+ : "Continue thread",
36
+ image: "bubble.left.and.bubble.right",
37
+ attributes: { disabled: task !== "ask" && Boolean(thread.archivedAt) },
38
+ };
39
+ (thread.settled ? settled : active).push(action);
40
+ }
41
+ return [
42
+ ...(canAsk ? [{ id: `${task}:new`, title: "Start a new thread", image: "plus" }] : []),
43
+ ...active,
44
+ ...(settled.length
45
+ ? [{ id: `${task}:settled`, title: "Settled threads", subactions: settled }]
46
+ : []),
47
+ ];
48
}
49
50
export function pullRequestAgentPrompt(
apps/mobile/src/features/pull-requests/usePullRequestAgentActions.ts
+20
-12
@@ -1,7 +1,9 @@
1
+import { Platform } from "react-native";
2
import type { PullRequestDetail } from "@t3tools/contracts";
3
import {
4
pullRequestAgentActions,
5
pullRequestAgentThread,
6
+ pullRequestAgentThreadActions,
7
type PullRequestAgentTask,
8
} from "./pullRequestAgentTasks";
9
import type { PullRequestParams } from "./usePullRequestDiff";
@@ -28,24 +30,30 @@ export function usePullRequestAgentActions(
30
if (!links.canAsk || actions.find((action) => action.task === task)?.disabled) return;
31
void links.ask(thread?.archivedAt ? undefined : thread, task);
32
};
31
- const threadActions = (task: PullRequestAgentTask) => [
32
- ...links.threads.map((thread) => ({
33
- id: `${task}:${thread.id}`,
34
- title: thread.title,
35
- subtitle: thread.archivedAt ? "Archived thread" : "Continue thread",
36
- image: "bubble.left.and.bubble.right",
37
- attributes: { disabled: task !== "ask" && Boolean(thread.archivedAt) },
38
- })),
39
- ...(links.canAsk ? [{ id: `${task}:new`, title: "Start a new thread", image: "plus" }] : []),
40
- ];
33
+ const chooseThread =
34
+ links.threads.length > 1 || links.threads.some((thread) => thread.settled || thread.archivedAt);
35
+ const threadActions = (task: PullRequestAgentTask) =>
36
+ pullRequestAgentThreadActions(links.threads, task, links.canAsk);
37
const menuAction = (task: PullRequestAgentTask) => {
38
const action = actions.find((action) => action.task === task);
39
+ const items = threadActions(task);
40
+ // Android supports only one submenu level beneath each helper action.
41
+ const subactions =
42
+ Platform.OS === "android"
43
+ ? items.flatMap(
44
+ (item) =>
45
+ item.subactions?.map((child) => ({
46
+ ...child,
47
+ title: `Settled: ${child.title}`,
48
+ })) ?? [item],
49
+ )
50
+ : items;
51
return {
52
id: task,
53
title: action?.title ?? "Open thread",
54
image: action?.icon,
55
attributes: { disabled: disabled || !links.canAsk || action?.disabled },
48
- ...(links.threads.length > 1 ? { subactions: threadActions(task) } : {}),
56
+ ...(chooseThread ? { subactions } : {}),
57
};
58
};
59
const select = (event: string) => {
@@ -55,5 +63,5 @@ export function usePullRequestAgentActions(
63
if (action)
64
start(action.task, event === action.task ? undefined : event.slice(action.task.length + 1));
65
};
58
- return { ...links, actions, disabled, start, threadActions, menuAction, select };
66
+ return { ...links, actions, disabled, chooseThread, start, threadActions, menuAction, select };
67
}
apps/server/src/pullRequest/linkedThreads.test.ts
+33
-3
@@ -9,7 +9,7 @@ import { listLinkedPullRequestThreads } from "./linkedThreads.ts";
9
const encodePayload = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown));
10
11
it.effect(
12
- "finds active and archived threads for exactly one pull request, excluding deleted, dismissed, and side chat links",
12
+ "finds active, settled, and archived threads for exactly one pull request, excluding deleted, dismissed, and side chat links",
13
() =>
14
Effect.gen(function* () {
15
const sql = yield* SqlClient.SqlClient;
@@ -46,6 +46,14 @@ it.effect(
46
number: 7,
47
source: "manual",
48
},
49
+ { id: "settled", host: "github.com", repository: "acme/web", number: 7, source: "manual" },
50
+ {
51
+ id: "auto-settled",
52
+ host: "github.com",
53
+ repository: "acme/web",
54
+ number: 7,
55
+ source: "manual",
56
+ },
57
{ id: "active", host: "github.com", repository: "acme/web", number: 7, source: "manual" },
58
{
59
id: "archived",
@@ -94,6 +102,8 @@ it.effect(
102
for (const fixture of fixtures) {
103
const payload = yield* encodePayload({
104
linkedPullRequest: null,
105
+ settledOverride: ["settled", "archived"].includes(fixture.id) ? "settled" : null,
106
+ settledAt: fixture.id === "auto-settled" ? archivedAt : null,
107
...(fixture.id === "side-chat" ? { lineage: { sideChat: true } } : {}),
108
pullRequests: [{ ...fixture, linkedAt: createdAt, snapshot: null, stack: null }],
109
});
@@ -165,8 +175,28 @@ it.effect(
175
});
176
expect(result).toEqual({
177
threads: [
168
- { id: "archived", projectId: "project-1", title: "archived", archivedAt },
169
- { id: "active", projectId: "project-1", title: "active", archivedAt: null },
178
+ { id: "archived", projectId: "project-1", title: "archived", archivedAt, settled: true },
179
+ {
180
+ id: "active",
181
+ projectId: "project-1",
182
+ title: "active",
183
+ archivedAt: null,
184
+ settled: false,
185
+ },
186
+ {
187
+ id: "auto-settled",
188
+ projectId: "project-1",
189
+ title: "auto-settled",
190
+ archivedAt: null,
191
+ settled: true,
192
+ },
193
+ {
194
+ id: "settled",
195
+ projectId: "project-1",
196
+ title: "settled",
197
+ archivedAt: null,
198
+ settled: true,
199
+ },
200
],
201
});
202
assert.deepStrictEqual(
apps/server/src/pullRequest/linkedThreads.ts
+12
-2
@@ -23,13 +23,17 @@ export const listLinkedPullRequestThreads = Effect.fn("listLinkedPullRequestThre
23
projectId: string;
24
title: string;
25
archivedAt: string | null;
26
+ settled: number;
27
host: string;
28
repository: string;
29
number: number;
30
url: string;
31
}>`
32
SELECT t.thread_id AS id, t.project_id AS "projectId", t.title,
32
- t.archived_at AS "archivedAt", json_extract(link.value, '$.host') AS host,
33
+ t.archived_at AS "archivedAt",
34
+ (json_extract(t.payload_json, '$.settledAt') IS NOT NULL
35
+ OR json_extract(t.payload_json, '$.settledOverride') IS 'settled') AS settled,
36
+ json_extract(link.value, '$.host') AS host,
37
json_extract(link.value, '$.repository') AS repository,
38
json_extract(link.value, '$.number') AS number,
39
json_extract(link.value, '$.url') AS url,
@@ -44,7 +48,13 @@ export const listLinkedPullRequestThreads = Effect.fn("listLinkedPullRequestThre
48
`.pipe(NodeSqliteClient.readOnly);
49
const threads = rows
50
.filter((row) => threadPullRequestKeysEqual(row, key))
47
- .map(({ id, projectId, title, archivedAt }) => ({ id, projectId, title, archivedAt }));
51
+ .map(({ id, projectId, title, archivedAt, settled }) => ({
52
+ id,
53
+ projectId,
54
+ title,
55
+ archivedAt,
56
+ settled: settled === 1,
57
+ }));
58
return yield* decodeLinkedThreads({ threads });
59
},
60
Effect.mapError(
packages/contracts/src/pullRequest.ts
+1
@@ -453,6 +453,7 @@ export const PullRequestLinkedThreadsResult = Schema.Struct({
453
projectId: ProjectId,
454
title: Schema.String,
455
archivedAt: Schema.NullOr(IsoDateTime),
456
+ settled: Schema.optionalKey(Schema.Boolean),
457
}),
458
),
459
});