@devries-cameron20 / t3code Mirror · read-only / commits / 48cba7d93c
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 24, 16:30 UTC

fix(web): restore the Archive action in the default sidebar thread menu (#6526)

Lars Nieuwenhuis committed Aug 15, 2026 at 12:44 UTC 48cba7d93c8c63508f31cce2544d480ace86f929
4 files changed +95 -1
apps/web/src/components/Sidebar.tsx
+34
@@ -1622,6 +1622,7 @@ export default function Sidebar() {
1622 const autoSettleAfterDays = useClientSettings((s) => s.sidebarAutoSettleAfterDays);
1623 const autoSettleOnMerge = useClientSettings((s) => s.sidebarAutoSettleOnMerge);
1624 const confirmThreadDelete = useClientSettings((s) => s.confirmThreadDelete);
1625 + const confirmThreadArchive = useClientSettings((s) => s.confirmThreadArchive);
1626 const sidebarProjectSortOrder = useClientSettings((s) => s.sidebarProjectSortOrder);
1627 const timestampFormat = useClientSettings((s) => s.timestampFormat);
1628 const projectGroupingSettings = useClientSettings(selectProjectGroupingSettings);
@@ -1633,6 +1634,7 @@ export default function Sidebar() {
1634 pinThread,
1635 unpinThread,
1636 reorderPinnedThread,
1637 + archiveThread,
1638 deleteThread,
1639 } = useThreadActions();
1640 const updateThreadMetadata = useAtomCommand(threadEnvironment.updateMetadata, {
@@ -2990,6 +2992,8 @@ export default function Sidebar() {
2992 isSnoozed,
2993 canSnoozeNow: canSnooze(thread, { now: new Date().toISOString() }),
2994 isRegeneratingTitle,
2995 + isRunning:
2996 + thread.session?.status === "running" && thread.session.activeTurnId != null,
2997 supports: {
2998 settlement: supportsSettlement,
2999 snooze: supportsSnooze,
@@ -3093,6 +3097,34 @@ export default function Sidebar() {
3097 case "copy-thread-id":
3098 copyThreadIdToClipboard(thread.id, { threadId: thread.id });
3099 return;
3100 + case "archive": {
3101 + if (confirmThreadArchive) {
3102 + const confirmed = await settlePromise(() =>
3103 + api.dialogs.confirm(`Archive thread "${thread.title}"?`),
3104 + );
3105 + if (confirmed._tag === "Failure" || !confirmed.value) return;
3106 + }
3107 + let didArchive = false;
3108 + const result = await archiveThread(threadRef, {
3109 + onArchived: () => {
3110 + didArchive = true;
3111 + },
3112 + });
3113 + if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
3114 + const error = squashAtomCommandFailure(result);
3115 + toastManager.add(
3116 + stackedThreadToast({
3117 + type: "error",
3118 + title: didArchive
3119 + ? "Thread archived, but navigation failed"
3120 + : "Failed to archive thread",
3121 + description: error instanceof Error ? error.message : "An error occurred.",
3122 + }),
3123 + );
3124 + return;
3125 + }
3126 + return;
3127 + }
3128 case "delete": {
3129 if (confirmThreadDelete) {
3130 const confirmed = await settlePromise(() =>
@@ -3126,12 +3158,14 @@ export default function Sidebar() {
3158 })();
3159 },
3160 [
3161 + archiveThread,
3162 attemptPin,
3163 attemptSettle,
3164 attemptSnooze,
3165 attemptUnpin,
3166 attemptUnsettle,
3167 attemptUnsnooze,
3168 + confirmThreadArchive,
3169 confirmThreadDelete,
3170 copyBranchToClipboard,
3171 copyPathToClipboard,
apps/web/src/components/threadActionMenu.logic.test.ts
+26 -1
@@ -9,6 +9,7 @@ const baseState: ThreadActionMenuState = {
9 isSnoozed: false,
10 canSnoozeNow: true,
11 isRegeneratingTitle: false,
12 + isRunning: false,
13 supports: { settlement: true, snooze: true, pinning: true, titleRegeneration: true },
14 snoozePresets: [
15 { id: "hour", label: "In 1 hour", whenLabel: "3:00 PM", snoozedUntil: "2026-08-07T15:00:00Z" },
@@ -26,7 +27,7 @@ describe("buildThreadActionMenuItems", () => {
27 ...baseState,
28 supports: { settlement: false, snooze: false, pinning: false, titleRegeneration: false },
29 }),
29 - ).toEqual(["rename", "mark-unread", "copy-path", "copy-thread-id", "delete"]);
30 + ).toEqual(["rename", "mark-unread", "copy-path", "copy-thread-id", "archive", "delete"]);
31 });
32
33 it("includes branch items only for threads with a branch", () => {
@@ -63,4 +64,28 @@ describe("buildThreadActionMenuItems", () => {
64 const items = buildThreadActionMenuItems({ ...baseState, branch: "main" });
65 expect(items.at(-1)).toMatchObject({ id: "delete", destructive: true });
66 });
67 +
68 + it("offers archive as a non-destructive action right before delete", () => {
69 + const items = buildThreadActionMenuItems(baseState);
70 + const archiveItem = items.at(-2);
71 + expect(archiveItem?.id).toBe("archive");
72 + expect(archiveItem?.destructive).toBeFalsy();
73 + expect(items.at(-1)?.id).toBe("delete");
74 + });
75 +
76 + it("keeps archive available even when the environment lacks every other capability", () => {
77 + expect(
78 + ids({
79 + ...baseState,
80 + supports: { settlement: false, snooze: false, pinning: false, titleRegeneration: false },
81 + }),
82 + ).toContain("archive");
83 + });
84 +
85 + it("disables archive while the thread is running", () => {
86 + const archiveItem = buildThreadActionMenuItems({ ...baseState, isRunning: true }).find(
87 + (item) => item.id === "archive",
88 + );
89 + expect(archiveItem?.disabled).toBe(true);
90 + });
91 });
apps/web/src/components/threadActionMenu.logic.ts
+9
@@ -21,6 +21,7 @@ export type ThreadActionMenuId =
21 | "copy-path"
22 | "copy-branch"
23 | "copy-thread-id"
24 + | "archive"
25 | "delete";
26
27 export interface ThreadActionMenuState {
@@ -30,6 +31,8 @@ export interface ThreadActionMenuState {
31 readonly isSnoozed: boolean;
32 readonly canSnoozeNow: boolean;
33 readonly isRegeneratingTitle: boolean;
34 + /** Archive rejects a thread with an active turn, so disable it here rather than let the action fail. */
35 + readonly isRunning: boolean;
36 readonly supports: {
37 readonly settlement: boolean;
38 readonly snooze: boolean;
@@ -102,6 +105,12 @@ export function buildThreadActionMenuItems(
105 { id: "copy-path", label: "Copy path", icon: "copy" },
106 ...(state.branch ? [{ id: "copy-branch" as const, label: "Copy branch", icon: "copy" }] : []),
107 { id: "copy-thread-id", label: "Copy thread ID", icon: "copy" },
108 + // Archive removes the thread from the sidebar while keeping its
109 + // conversation under Settings > Archived threads — distinct from Settle
110 + // (stays visible in the Settled shelf) and Delete (clears history for
111 + // good), so it sits beside Delete without borrowing its destructive
112 + // styling.
113 + { id: "archive", label: "Archive thread", disabled: state.isRunning },
114 { id: "delete", label: "Delete", destructive: true, icon: "trash" },
115 ];
116 }
apps/web/src/hooks/useThreadActionMenu.ts
+26
@@ -72,6 +72,7 @@ export function useThreadActionMenu(input: {
72 unsnoozeThread,
73 pinThread,
74 unpinThread,
75 + archiveThread,
76 deleteThread,
77 } = useThreadActions();
78 const updateThreadMetadata = useAtomCommand(threadEnvironment.updateMetadata, {
@@ -82,6 +83,7 @@ export function useThreadActionMenu(input: {
83 const autoSettleAfterDays = useClientSettings((s) => s.sidebarAutoSettleAfterDays);
84 const autoSettleOnMerge = useClientSettings((s) => s.sidebarAutoSettleOnMerge);
85 const confirmThreadDelete = useClientSettings((s) => s.confirmThreadDelete);
86 + const confirmThreadArchive = useClientSettings((s) => s.confirmThreadArchive);
87 const timestampFormat = useClientSettings((s) => s.timestampFormat);
88 const { copyToClipboard: copyPathToClipboard } = useCopyToClipboard<{ path: string }>({
89 onCopy: ({ path }) => {
@@ -139,6 +141,7 @@ export function useThreadActionMenu(input: {
141 isSnoozed: supports.snooze && effectiveSnoozed(thread, { now: now.toISOString() }),
142 canSnoozeNow: canSnooze(thread, { now: now.toISOString() }),
143 isRegeneratingTitle,
144 + isRunning: thread.session?.status === "running" && thread.session.activeTurnId != null,
145 supports,
146 snoozePresets,
147 });
@@ -253,6 +256,27 @@ export function useThreadActionMenu(input: {
256 case "copy-thread-id":
257 copyThreadIdToClipboard(thread.id, { threadId: thread.id });
258 return;
259 + case "archive": {
260 + if (confirmThreadArchive) {
261 + const confirmed = await settlePromise(() =>
262 + api.dialogs.confirm(`Archive thread "${thread.title}"?`),
263 + );
264 + if (confirmed._tag === "Failure" || !confirmed.value) return;
265 + }
266 + let didArchive = false;
267 + const result = await archiveThread(threadRef, {
268 + onArchived: () => {
269 + didArchive = true;
270 + },
271 + });
272 + if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
273 + failureToast(
274 + didArchive ? "Thread archived, but navigation failed" : "Failed to archive thread",
275 + squashAtomCommandFailure(result),
276 + );
277 + }
278 + return;
279 + }
280 case "delete": {
281 if (confirmThreadDelete) {
282 const confirmed = await settlePromise(() =>
@@ -285,9 +309,11 @@ export function useThreadActionMenu(input: {
309 })();
310 },
311 [
312 + archiveThread,
313 autoSettleAfterDays,
314 autoSettleOnMerge,
315 changeRequestState,
316 + confirmThreadArchive,
317 confirmThreadDelete,
318 copyBranchToClipboard,
319 copyPathToClipboard,