@devries-cameron20 / t3code Mirror · read-only / commits / 1fa250eb1f
Fork 0

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 21, 23:30 UTC

fix(mobile): un-settle while a settle is pending is no longer ignored (#26578)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Nov 11, 2026 at 11:52 UTC 1fa250eb1f62614c540ee0ffee68330d28ffb931
2 files changed +26 -4
apps/mobile/src/features/home/useThreadListActions.test.ts
+20
@@ -31,6 +31,7 @@ const state = vi.hoisted(() => ({
31 buttons?: { text: string; onPress?: () => void }[];
32 }[],
33 afterRequest: undefined as (() => void) | undefined,
34 + heldActions: new Map<string, Promise<void>>(),
35 }));
36
37 vi.mock("react", () => ({
@@ -145,6 +146,7 @@ vi.mock("../../state/threads", () => ({
146 input: { threadId: string; orderKey?: string };
147 }) => {
148 state.requests.push({ action, ...request });
149 + await state.heldActions.get(action);
150 if (!state.scopes.get(request.environmentId)?.has(AuthOrchestrationOperateScope)) {
151 return AsyncResult.failure(Cause.fail(new Error("Thread operation denied")));
152 }
@@ -200,6 +202,7 @@ beforeEach(() => {
202 state.dialogs = [];
203 state.alerts = [];
204 state.afterRequest = undefined;
205 + state.heldActions = new Map();
206 });
207
208 afterEach(() => {
@@ -406,6 +409,23 @@ describe("thread action undo", () => {
409 expect(state.archivedRefreshes).toEqual([primaryEnvironmentId]);
410 });
411
412 + it("sends a different action while one is pending for the same thread", async () => {
413 + const actions = useThreadListActions();
414 + const thread = makeThread();
415 + const settleResponse = Promise.withResolvers<void>();
416 + state.heldActions.set("settle", settleResponse.promise);
417 +
418 + const pending = [
419 + actions.settleThread(thread),
420 + actions.unsettleThread(thread),
421 + actions.settleThread(thread),
422 + ];
423 + settleResponse.resolve();
424 +
425 + expect(await Promise.all(pending)).toEqual([true, true, true]);
426 + expect(state.requests.map(({ action }) => action)).toEqual(["settle", "unsettle", "settle"]);
427 + });
428 +
429 it("restores pin placement and snooze after settling, only once", async () => {
430 const thread = makeThread({
431 pinnedAt: "2026-09-02T00:00:00.000Z",
apps/mobile/src/features/home/useThreadListActions.ts
+6 -4
@@ -91,7 +91,7 @@ function useThreadActionExecutor(
91 const deleteMutation = useAtomCommand(threadEnvironment.delete, { reportFailure: false });
92 const settleMutation = useAtomCommand(threadEnvironment.settle, { reportFailure: false });
93 const unsettleMutation = useAtomCommand(threadEnvironment.unsettle, { reportFailure: false });
94 - const inFlightThreadKeys = useRef(new Set<string>());
94 + const latestPendingActions = useRef(new Map<string, { readonly action: ThreadListAction }>());
95
96 const executeAction = async (
97 action: ThreadListAction,
@@ -100,11 +100,13 @@ function useThreadActionExecutor(
100 ) => {
101 if (!checkThreadOperationPermission(thread, actionFailureTitle(action))) return false;
102 const key = scopedThreadKey(thread.environmentId, thread.id);
103 - if (inFlightThreadKeys.current.has(key)) {
103 + // Drop only a repeat of the latest pending action; Settle → Un-settle → Settle must all send.
104 + if (latestPendingActions.current.get(key)?.action === action) {
105 return false;
106 }
107
107 - inFlightThreadKeys.current.add(key);
108 + const pending = { action };
109 + latestPendingActions.current.set(key, pending);
110 selectionHaptic();
111 const succeeded = await (async () => {
112 if (
@@ -163,7 +165,7 @@ function useThreadActionExecutor(
165 onCompleted?.(action, thread);
166 return true;
167 })();
166 - inFlightThreadKeys.current.delete(key);
168 + if (latestPendingActions.current.get(key) === pending) latestPendingActions.current.delete(key);
169 return succeeded;
170 };
171