@@ -23,13 +23,22 @@ const state = vi.hoisted(() => ({ |
23 | 23 | requests: [] as { |
24 | 24 | action: string; |
25 | 25 | 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 | + }; |
27 | 33 | }[], |
28 | 34 | dialogs: [] as { onConfirm: () => void }[], |
29 | 35 | alerts: [] as { |
30 | 36 | title: string; |
| 37 | + message?: string; |
31 | 38 | buttons?: { text: string; onPress?: () => void }[]; |
32 | 39 | }[], |
| 40 | + titleFailure: null as string | null, |
| 41 | + watchedTitleRequests: [] as string[], |
33 | 42 | afterRequest: undefined as (() => void) | undefined, |
34 | 43 | })); |
35 | 44 |
|
@@ -48,8 +57,8 @@ vi.mock("expo-haptics", () => ({ |
48 | 57 | ImpactFeedbackStyle: { Light: "light" }, |
49 | 58 | })); |
50 | 59 | 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 }), |
53 | 62 | confirm: (dialog: { onConfirm: () => void }) => state.dialogs.push(dialog), |
54 | 63 | })); |
55 | 64 | vi.mock("../archive/useArchivedThreadSnapshots", () => ({ |
@@ -121,7 +130,10 @@ vi.mock("../../state/thread-order", () => ({ |
121 | 130 | })); |
122 | 131 | vi.mock("../../lib/uuid", () => ({ uuidv4: () => "command" })); |
123 | 132 | 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 | + }, |
125 | 137 | environmentThreadShells: { |
126 | 138 | threadShellsAtom: "thread-shells", |
127 | 139 | navigationThreadShellsAtom: "thread-shells", |
@@ -201,6 +213,8 @@ beforeEach(() => { |
201 | 213 | state.shells = []; |
202 | 214 | state.dialogs = []; |
203 | 215 | state.alerts = []; |
| 216 | + state.titleFailure = null; |
| 217 | + state.watchedTitleRequests = []; |
204 | 218 | state.afterRequest = undefined; |
205 | 219 | }); |
206 | 220 |
|
@@ -244,6 +258,23 @@ describe("thread list operation permissions", () => { |
244 | 258 | }); |
245 | 259 | }); |
246 | 260 |
|
| 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 | + |
247 | 278 | describe("pinned thread operation permissions", () => { |
248 | 279 | it("checks every materialization target before writing any keys", async () => { |
249 | 280 | const moved = makeThread({ pinnedAt: "2026-09-02T00:00:00.000Z" }); |
|