Skip to content

Commit e2cc16e

Browse files
committed
fix(web): restore archive action in default sidebar thread menu
Archive was dropped from the new sidebar's per-thread menu when it became the default, leaving Delete as the only way to remove a thread from the sidebar even though Delete permanently clears history. Add Archive back to buildThreadActionMenuItems (the shared source for the sidebar row menu and chat header menu) and wire it through both surfaces, reusing the existing archiveThread mutation and confirmThreadArchive setting the legacy sidebar already relies on.
1 parent 2fab18e commit e2cc16e

4 files changed

Lines changed: 64 additions & 1 deletion

File tree

‎apps/web/src/components/Sidebar.tsx‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,6 +1600,7 @@ export default function Sidebar() {
16001600
const keybindings = useAtomValue(primaryServerKeybindingsAtom);
16011601
const autoSettleAfterDays = useClientSettings((s) => s.sidebarAutoSettleAfterDays);
16021602
const confirmThreadDelete = useClientSettings((s) => s.confirmThreadDelete);
1603+
const confirmThreadArchive = useClientSettings((s) => s.confirmThreadArchive);
16031604
const sidebarProjectSortOrder = useClientSettings((s) => s.sidebarProjectSortOrder);
16041605
const timestampFormat = useClientSettings((s) => s.timestampFormat);
16051606
const projectGroupingSettings = useClientSettings(selectProjectGroupingSettings);
@@ -1611,6 +1612,7 @@ export default function Sidebar() {
16111612
pinThread,
16121613
unpinThread,
16131614
reorderPinnedThread,
1615+
archiveThread,
16141616
deleteThread,
16151617
} = useThreadActions();
16161618
const updateThreadMetadata = useAtomCommand(threadEnvironment.updateMetadata, {
@@ -3065,6 +3067,27 @@ export default function Sidebar() {
30653067
case "copy-thread-id":
30663068
copyThreadIdToClipboard(thread.id, { threadId: thread.id });
30673069
return;
3070+
case "archive": {
3071+
if (confirmThreadArchive) {
3072+
const confirmed = await settlePromise(() =>
3073+
api.dialogs.confirm(`Archive thread "${thread.title}"?`),
3074+
);
3075+
if (confirmed._tag === "Failure" || !confirmed.value) return;
3076+
}
3077+
const result = await archiveThread(threadRef);
3078+
if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
3079+
const error = squashAtomCommandFailure(result);
3080+
toastManager.add(
3081+
stackedThreadToast({
3082+
type: "error",
3083+
title: "Failed to archive thread",
3084+
description: error instanceof Error ? error.message : "An error occurred.",
3085+
}),
3086+
);
3087+
return;
3088+
}
3089+
return;
3090+
}
30683091
case "delete": {
30693092
if (confirmThreadDelete) {
30703093
const confirmed = await settlePromise(() =>
@@ -3098,12 +3121,14 @@ export default function Sidebar() {
30983121
})();
30993122
},
31003123
[
3124+
archiveThread,
31013125
attemptPin,
31023126
attemptSettle,
31033127
attemptSnooze,
31043128
attemptUnpin,
31053129
attemptUnsettle,
31063130
attemptUnsnooze,
3131+
confirmThreadArchive,
31073132
confirmThreadDelete,
31083133
copyBranchToClipboard,
31093134
copyPathToClipboard,

‎apps/web/src/components/threadActionMenu.logic.test.ts‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe("buildThreadActionMenuItems", () => {
2626
...baseState,
2727
supports: { settlement: false, snooze: false, pinning: false, titleRegeneration: false },
2828
}),
29-
).toEqual(["rename", "mark-unread", "copy-path", "copy-thread-id", "delete"]);
29+
).toEqual(["rename", "mark-unread", "copy-path", "copy-thread-id", "archive", "delete"]);
3030
});
3131

3232
it("includes branch items only for threads with a branch", () => {
@@ -63,4 +63,21 @@ describe("buildThreadActionMenuItems", () => {
6363
const items = buildThreadActionMenuItems({ ...baseState, branch: "main" });
6464
expect(items.at(-1)).toMatchObject({ id: "delete", destructive: true });
6565
});
66+
67+
it("offers archive as a non-destructive action right before delete", () => {
68+
const items = buildThreadActionMenuItems(baseState);
69+
const archiveItem = items.at(-2);
70+
expect(archiveItem?.id).toBe("archive");
71+
expect(archiveItem?.destructive).toBeFalsy();
72+
expect(items.at(-1)?.id).toBe("delete");
73+
});
74+
75+
it("keeps archive available even when the environment lacks every other capability", () => {
76+
expect(
77+
ids({
78+
...baseState,
79+
supports: { settlement: false, snooze: false, pinning: false, titleRegeneration: false },
80+
}),
81+
).toContain("archive");
82+
});
6683
});

‎apps/web/src/components/threadActionMenu.logic.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export type ThreadActionMenuId =
2121
| "copy-path"
2222
| "copy-branch"
2323
| "copy-thread-id"
24+
| "archive"
2425
| "delete";
2526

2627
export interface ThreadActionMenuState {
@@ -102,6 +103,12 @@ export function buildThreadActionMenuItems(
102103
{ id: "copy-path", label: "Copy path", icon: "copy" },
103104
...(state.branch ? [{ id: "copy-branch" as const, label: "Copy branch", icon: "copy" }] : []),
104105
{ id: "copy-thread-id", label: "Copy thread ID", icon: "copy" },
106+
// Archive removes the thread from the sidebar while keeping its
107+
// conversation under Settings > Archived threads — distinct from Settle
108+
// (stays visible in the Settled shelf) and Delete (clears history for
109+
// good), so it sits beside Delete without borrowing its destructive
110+
// styling.
111+
{ id: "archive", label: "Archive thread" },
105112
{ id: "delete", label: "Delete", destructive: true, icon: "trash" },
106113
];
107114
}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export function useThreadActionMenu(input: {
7272
unsnoozeThread,
7373
pinThread,
7474
unpinThread,
75+
archiveThread,
7576
deleteThread,
7677
} = useThreadActions();
7778
const updateThreadMetadata = useAtomCommand(threadEnvironment.updateMetadata, {
@@ -81,6 +82,7 @@ export function useThreadActionMenu(input: {
8182
const markThreadUnread = useUiStateStore((s) => s.markThreadUnread);
8283
const autoSettleAfterDays = useClientSettings((s) => s.sidebarAutoSettleAfterDays);
8384
const confirmThreadDelete = useClientSettings((s) => s.confirmThreadDelete);
85+
const confirmThreadArchive = useClientSettings((s) => s.confirmThreadArchive);
8486
const timestampFormat = useClientSettings((s) => s.timestampFormat);
8587
const { copyToClipboard: copyPathToClipboard } = useCopyToClipboard<{ path: string }>({
8688
onCopy: ({ path }) => {
@@ -251,6 +253,16 @@ export function useThreadActionMenu(input: {
251253
case "copy-thread-id":
252254
copyThreadIdToClipboard(thread.id, { threadId: thread.id });
253255
return;
256+
case "archive": {
257+
if (confirmThreadArchive) {
258+
const confirmed = await settlePromise(() =>
259+
api.dialogs.confirm(`Archive thread "${thread.title}"?`),
260+
);
261+
if (confirmed._tag === "Failure" || !confirmed.value) return;
262+
}
263+
await reportFailure("Failed to archive thread", () => archiveThread(threadRef));
264+
return;
265+
}
254266
case "delete": {
255267
if (confirmThreadDelete) {
256268
const confirmed = await settlePromise(() =>
@@ -283,8 +295,10 @@ export function useThreadActionMenu(input: {
283295
})();
284296
},
285297
[
298+
archiveThread,
286299
autoSettleAfterDays,
287300
changeRequestState,
301+
confirmThreadArchive,
288302
confirmThreadDelete,
289303
copyBranchToClipboard,
290304
copyPathToClipboard,

0 commit comments

Comments
 (0)