Skip to content

Commit 014b686

Browse files
voltcrashclaude
andcommitted
feat(web): delete archived threads from the archive page
Archived thread rows only offered Unarchive as a button; Delete was hidden in the right-click menu. Add a Delete button after Unarchive that uses the same confirm-and-delete path, and pass the row's title so the confirmation names the thread instead of "this thread". Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 4af6618 commit 014b686

2 files changed

Lines changed: 73 additions & 62 deletions

File tree

‎apps/web/src/components/settings/SettingsPanels.tsx‎

Lines changed: 70 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@ import { useScopedSettingsWriteAllowed } from "./useScopedSettings";
44
import { Spinner } from "~/components/ui/spinner";
55
import { NotificationSettings } from "./NotificationSettings";
66
import { PRIVACY_POLICY_URL } from "../../legalLinks";
7-
import { ArchiveIcon, ArchiveX, CheckIcon, ChevronRightIcon, SettingsIcon } from "lucide-react";
7+
import {
8+
ArchiveIcon,
9+
ArchiveX,
10+
CheckIcon,
11+
ChevronRightIcon,
12+
SettingsIcon,
13+
Trash2Icon,
14+
} from "lucide-react";
815
import { Link, useNavigate } from "@tanstack/react-router";
916
import type { CSSProperties, ReactNode } from "react";
1017
import { useEffect, useEffectEvent, useRef, useState } from "react";
@@ -3425,8 +3432,41 @@ export function ArchivedThreadsPanel() {
34253432
return { groups: sortedGroups, hasMultipleEnvironments };
34263433
})();
34273434

3435+
const handleUnarchiveThread = async (threadRef: ScopedThreadRef) => {
3436+
const result = await unarchiveThread(threadRef);
3437+
if (result._tag === "Success") {
3438+
refreshArchivedThreads();
3439+
} else if (!isAtomCommandInterrupted(result)) {
3440+
const error = squashAtomCommandFailure(result);
3441+
toastManager.add(
3442+
stackedThreadToast({
3443+
type: "error",
3444+
title: "Failed to unarchive thread",
3445+
description: error instanceof Error ? error.message : "An error occurred.",
3446+
}),
3447+
);
3448+
}
3449+
};
3450+
3451+
const handleDeleteThread = async (threadRef: ScopedThreadRef, title: string) => {
3452+
const result = await confirmAndDeleteThread(threadRef, title);
3453+
if (result._tag === "Success") {
3454+
refreshArchivedThreads();
3455+
} else if (!isAtomCommandInterrupted(result)) {
3456+
const error = squashAtomCommandFailure(result);
3457+
toastManager.add(
3458+
stackedThreadToast({
3459+
type: "error",
3460+
title: "Failed to delete thread",
3461+
description: error instanceof Error ? error.message : "An error occurred.",
3462+
}),
3463+
);
3464+
}
3465+
};
3466+
34283467
const handleArchivedThreadContextMenu = async (
34293468
threadRef: ScopedThreadRef,
3469+
title: string,
34303470
position: { x: number; y: number },
34313471
) => {
34323472
const api = readLocalApi();
@@ -3440,36 +3480,9 @@ export function ArchivedThreadsPanel() {
34403480
);
34413481

34423482
if (clicked === "unarchive") {
3443-
const result = await unarchiveThread(threadRef);
3444-
if (result._tag === "Success") {
3445-
refreshArchivedThreads();
3446-
} else if (!isAtomCommandInterrupted(result)) {
3447-
const error = squashAtomCommandFailure(result);
3448-
toastManager.add(
3449-
stackedThreadToast({
3450-
type: "error",
3451-
title: "Failed to unarchive thread",
3452-
description: error instanceof Error ? error.message : "An error occurred.",
3453-
}),
3454-
);
3455-
}
3456-
return;
3457-
}
3458-
3459-
if (clicked === "delete") {
3460-
const result = await confirmAndDeleteThread(threadRef);
3461-
if (result._tag === "Success") {
3462-
refreshArchivedThreads();
3463-
} else if (!isAtomCommandInterrupted(result)) {
3464-
const error = squashAtomCommandFailure(result);
3465-
toastManager.add(
3466-
stackedThreadToast({
3467-
type: "error",
3468-
title: "Failed to delete thread",
3469-
description: error instanceof Error ? error.message : "An error occurred.",
3470-
}),
3471-
);
3472-
}
3483+
await handleUnarchiveThread(threadRef);
3484+
} else if (clicked === "delete") {
3485+
await handleDeleteThread(threadRef, title);
34733486
}
34743487
};
34753488

@@ -3519,6 +3532,7 @@ export function ArchivedThreadsPanel() {
35193532
const result = await settlePromise(() =>
35203533
handleArchivedThreadContextMenu(
35213534
scopeThreadRef(thread.environmentId, thread.id),
3535+
thread.title,
35223536
{
35233537
x: event.clientX,
35243538
y: event.clientY,
@@ -3548,37 +3562,33 @@ export function ArchivedThreadsPanel() {
35483562
</span>
35493563
}
35503564
control={
3551-
<Button
3552-
type="button"
3553-
variant="outline"
3554-
size="sm"
3555-
className="shrink-0"
3556-
onClick={() => {
3557-
void (async () => {
3558-
const result = await unarchiveThread(
3565+
<div className="flex shrink-0 items-center gap-2">
3566+
<Button
3567+
type="button"
3568+
variant="outline"
3569+
size="sm"
3570+
onClick={() => {
3571+
void handleUnarchiveThread(scopeThreadRef(thread.environmentId, thread.id));
3572+
}}
3573+
>
3574+
<ArchiveX className="size-3.5" />
3575+
<span>Unarchive</span>
3576+
</Button>
3577+
<Button
3578+
type="button"
3579+
variant="destructive-outline"
3580+
size="sm"
3581+
onClick={() => {
3582+
void handleDeleteThread(
35593583
scopeThreadRef(thread.environmentId, thread.id),
3584+
thread.title,
35603585
);
3561-
if (result._tag === "Success") {
3562-
refreshArchivedThreads();
3563-
return;
3564-
}
3565-
if (!isAtomCommandInterrupted(result)) {
3566-
const error = squashAtomCommandFailure(result);
3567-
toastManager.add(
3568-
stackedThreadToast({
3569-
type: "error",
3570-
title: "Failed to unarchive thread",
3571-
description:
3572-
error instanceof Error ? error.message : "An error occurred.",
3573-
}),
3574-
);
3575-
}
3576-
})();
3577-
}}
3578-
>
3579-
<ArchiveX className="size-3.5" />
3580-
<span>Unarchive</span>
3581-
</Button>
3586+
}}
3587+
>
3588+
<Trash2Icon className="size-3.5" />
3589+
<span>Delete</span>
3590+
</Button>
3591+
</div>
35823592
}
35833593
/>
35843594
))}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -864,14 +864,15 @@ export function useThreadActions() {
864864
return result;
865865
};
866866

867-
const confirmAndDeleteThread = async (target: ScopedThreadRef) => {
867+
// Archived threads are not in the live store, so callers that list them pass the title.
868+
const confirmAndDeleteThread = async (target: ScopedThreadRef, knownTitle?: string) => {
868869
const permissionFailure = threadOperationFailure(target);
869870
if (permissionFailure) return permissionFailure;
870871
const localApi = readLocalApi();
871872
const resolved = resolveThreadTarget(target);
872873

873874
if (confirmThreadDelete && localApi) {
874-
const title = resolved?.thread.title ?? "this thread";
875+
const title = resolved?.thread.title ?? knownTitle ?? "this thread";
875876
const confirmationResult = await settlePromise(() =>
876877
localApi.dialogs.confirm(
877878
[

0 commit comments

Comments
 (0)