Skip to content

Commit 6221df1

Browse files
fix(web): settle supersedes older pin and snooze Undo; valueless contenteditable counts as editable
Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent f2e86aa commit 6221df1

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

‎apps/web/src/hooks/useThreadActions.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,10 @@ export function useThreadActions() {
655655
const pinOrderKey = resolved?.thread.pinnedAt != null ? resolved.thread.pinOrderKey : null;
656656
const wasPinned = resolved?.thread.pinnedAt != null;
657657
const snoozedUntil = resolved?.thread.snoozedUntil ?? null;
658+
// An older unpin/snooze Undo would re-pin or re-snooze, and the server
659+
// treats either as a promotion that un-settles; settling supersedes them.
660+
ThreadUndo.invalidate("pin", scopedThreadKey(target));
661+
ThreadUndo.invalidate("snooze", scopedThreadKey(target));
658662
const action = ThreadUndo.begin("settle", scopedThreadKey(target));
659663
const result = await settleThreadMutation({
660664
environmentId: target.environmentId,

‎apps/web/src/hooks/useThreadActions.undo.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,17 @@ describe("settle and snooze Undo", () => {
199199
});
200200
});
201201

202+
it("expires an older unpin Undo when the thread is settled", async () => {
203+
const add = vi.spyOn(toastManager, "add").mockReturnValue("toast");
204+
vi.spyOn(toastManager, "close").mockImplementation(() => {});
205+
const actions = useThreadActions();
206+
await actions.unpinThread(target);
207+
const staleUnpinUndo = undoOf(add, 0);
208+
await actions.settleThread(target);
209+
await staleUnpinUndo();
210+
expect(commands.pin).not.toHaveBeenCalled();
211+
});
212+
202213
it("stays silent for batch settles", async () => {
203214
const add = vi.spyOn(toastManager, "add").mockReturnValue("toast");
204215
await useThreadActions().settleThread(target, { undoToast: false });

‎apps/web/src/lib/editableFocus.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const EDITABLE_SELECTOR = [
22
"input",
33
"textarea",
44
"select",
5+
'[contenteditable=""]',
56
'[contenteditable="true"]',
67
'[contenteditable="plaintext-only"]',
78
'[role="textbox"]',

0 commit comments

Comments
 (0)