Skip to content

Commit 15be9a5

Browse files
committed
fix: older servers' thread reads still decode, and mobile's failure alert is tested
titleRegenerationFailure is optional in the orchestrator MCP thread detail, so the CLI and other readers still decode thread reads from servers that predate it. The mobile thread list test now checks that a regeneration watches the command it dispatched and alerts its failure.
1 parent 2bb52b8 commit 15be9a5

2 files changed

Lines changed: 36 additions & 5 deletions

File tree

‎apps/mobile/src/features/home/useThreadListActions.test.ts‎

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,22 @@ const state = vi.hoisted(() => ({
2323
requests: [] as {
2424
action: string;
2525
environmentId: string;
26-
input: { threadId: string; orderKey?: string; snoozedUntil?: string; reason?: string };
26+
input: {
27+
threadId: string;
28+
orderKey?: string;
29+
snoozedUntil?: string;
30+
reason?: string;
31+
commandId?: string;
32+
};
2733
}[],
2834
dialogs: [] as { onConfirm: () => void }[],
2935
alerts: [] as {
3036
title: string;
37+
message?: string;
3138
buttons?: { text: string; onPress?: () => void }[];
3239
}[],
40+
titleFailure: null as string | null,
41+
watchedTitleRequests: [] as string[],
3342
afterRequest: undefined as (() => void) | undefined,
3443
}));
3544

@@ -48,8 +57,8 @@ vi.mock("expo-haptics", () => ({
4857
ImpactFeedbackStyle: { Light: "light" },
4958
}));
5059
vi.mock("../../components/ui/Dialog", () => ({
51-
alert: (title: string, _message: string, buttons?: { text: string; onPress?: () => void }[]) =>
52-
state.alerts.push({ title, buttons }),
60+
alert: (title: string, message: string, buttons?: { text: string; onPress?: () => void }[]) =>
61+
state.alerts.push({ title, message, buttons }),
5362
confirm: (dialog: { onConfirm: () => void }) => state.dialogs.push(dialog),
5463
}));
5564
vi.mock("../archive/useArchivedThreadSnapshots", () => ({
@@ -121,7 +130,10 @@ vi.mock("../../state/thread-order", () => ({
121130
}));
122131
vi.mock("../../lib/uuid", () => ({ uuidv4: () => "command" }));
123132
vi.mock("../../state/threads", () => ({
124-
watchThreadTitleRegeneration: () => ({ failure: Promise.resolve(null), cancel: () => {} }),
133+
watchThreadTitleRegeneration: (_ref: unknown, requestId: string) => {
134+
state.watchedTitleRequests.push(requestId);
135+
return { failure: Promise.resolve(state.titleFailure), cancel: () => {} };
136+
},
125137
environmentThreadShells: {
126138
threadShellsAtom: "thread-shells",
127139
navigationThreadShellsAtom: "thread-shells",
@@ -201,6 +213,8 @@ beforeEach(() => {
201213
state.shells = [];
202214
state.dialogs = [];
203215
state.alerts = [];
216+
state.titleFailure = null;
217+
state.watchedTitleRequests = [];
204218
state.afterRequest = undefined;
205219
});
206220

@@ -244,6 +258,23 @@ describe("thread list operation permissions", () => {
244258
});
245259
});
246260

261+
describe("thread title regeneration", () => {
262+
it("alerts why the request it dispatched kept the title", async () => {
263+
state.titleFailure = "Claude CLI command failed: OAuth session expired";
264+
265+
await useThreadListActions().regenerateThreadTitle(makeThread());
266+
await Promise.resolve();
267+
268+
expect(state.watchedTitleRequests).toEqual([state.requests[0]?.input.commandId]);
269+
expect(state.alerts).toEqual([
270+
expect.objectContaining({
271+
title: "Could not regenerate title",
272+
message: "Claude CLI command failed: OAuth session expired",
273+
}),
274+
]);
275+
});
276+
});
277+
247278
describe("pinned thread operation permissions", () => {
248279
it("checks every materialization target before writing any keys", async () => {
249280
const moved = makeThread({ pinnedAt: "2026-09-02T00:00:00.000Z" });

‎packages/contracts/src/orchestratorMcp.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ export const OrchestratorMcpThreadDetail = Schema.Struct({
439439
linkedPullRequest: Schema.NullOr(ThreadLinkedPullRequest),
440440
pullRequests: Schema.optional(Schema.Array(OrchestratorMcpThreadPullRequest)),
441441
titleRegeneration: Schema.NullOr(ThreadTitleRegeneration),
442-
titleRegenerationFailure: Schema.NullOr(ThreadTitleRegenerationFailure),
442+
titleRegenerationFailure: Schema.optional(Schema.NullOr(ThreadTitleRegenerationFailure)),
443443
branch: Schema.NullOr(Schema.String),
444444
worktreePath: Schema.NullOr(Schema.String),
445445
parentThreadId: Schema.NullOr(ThreadId),

0 commit comments

Comments
 (0)