fix(ui): omit task archive success toasts

This commit is contained in:
Dotta authored and GitHub committed 2026-12-03 21:10:14 -06:00
1 parent 3f882fc589
commit 8c6e1fa780
6 files changed
+56 -110

No files matched your search

+4 -3
View File
@@ -595,9 +595,10 @@ order per person and company. Old `/inbox/*` links redirect to their Tasks view.
Archive is personal. Use it from Mine, Unread, or a task-table row to
remove a task from your Mine and Unread views. All tasks and its status views
still include archived tasks. Use Undo after archiving, or open **Archived**
from the Views menu and restore a task. New replies from other people, mentions,
and other inbox activity such as a new decision request can bring a task back.
still include archived tasks. Press **U** to undo a recent archive in Mine or
Unread. You can also open **Archived** from the Views menu and restore a task.
New replies from other people, mentions, and other inbox activity such as a new
decision request can bring a task back.
### Combined Inbox + Task List
-1
View File
@@ -162,7 +162,6 @@ function RecentTasksList({
await queryClient.invalidateQueries({
queryKey: queryKeys.sidebarBadges(companyId),
});
toastActions?.pushToast({ title: "Task archived from inbox", tone: "success" });
} catch (error) {
toastActions?.pushToast({
title: "Task archive failed",
+2 -19
View File
@@ -14,7 +14,7 @@ import {
invalidateTaskArchiveQueries,
} from "@/lib/inboxArchiveCache";
type ArchiveChange = { companyId: string; issueId: string; reference: string; archive: boolean; owner: string };
type ArchiveChange = { companyId: string; issueId: string; archive: boolean; owner: string };
function changeKey({ companyId, issueId, owner }: ArchiveChange) {
return JSON.stringify([companyId, issueId, owner]);
@@ -54,27 +54,10 @@ export function useTaskArchiveAction(companyId: string | null, userId: string |
async function submit(input: ArchiveChange) {
const key = changeKey(input);
if (inFlight.current.has(key)) return;
const account = bindAccount(client);
inFlight.current.add(key);
setPending(new Set(inFlight.current));
try {
await change.mutateAsync(input);
if (input.archive && account.isCurrentAccount()) {
toast?.pushToast({
id: `archive:${input.companyId}:${input.issueId}`,
dedupe: false,
title: "Task archived",
body: input.reference,
tone: "success",
ttlMs: 8000,
action: {
label: "Undo",
onClick: () => {
if (account.isCurrentAccount()) void submit({ ...input, archive: false });
},
},
});
}
} catch {
return;
} finally {
@@ -85,7 +68,7 @@ export function useTaskArchiveAction(companyId: string | null, userId: string |
return (issue: Issue): IssueRowArchiveAction | undefined => {
if (!companyId || !userId || issue.companyId !== companyId || issue.isArchivedForMe === undefined) return;
const input = { companyId, issueId: issue.id, reference: issue.identifier ?? issue.id, archive: !issue.isArchivedForMe, owner: userId };
const input = { companyId, issueId: issue.id, archive: !issue.isArchivedForMe, owner: userId };
return {
archived: issue.isArchivedForMe,
disabled: pending.has(changeKey(input)),
+1 -18
View File
@@ -2151,25 +2151,8 @@ function StreamlinedInbox({
if (presence !== "unknown") confirmLocalInboxArchive(context.companyId, id);
}
},
onSuccess: (_data, id, context) => {
onSuccess: (_data, id) => {
setUndoableArchiveIssueIds((prev) => [...prev.filter((issueId) => issueId !== id), id]);
if (surfaceLabel === "Tasks" && context?.account) {
const { account } = context;
pushToast({
id: `archive:${context.companyId}:${id}`,
dedupe: false,
title: "Task archived",
body: issueById.get(id)?.identifier ?? id,
tone: "success",
ttlMs: 8000,
action: {
label: "Undo",
onClick: () => {
if (account.isCurrentAccount()) unarchiveIssueMutation.mutate(id);
},
},
});
}
},
});
+1 -53
View File
@@ -182,7 +182,6 @@ import {
beginLocalInboxArchive,
boundLocalInboxArchive,
cancelInboxIssueQueries,
clearLocalInboxArchive,
confirmLocalInboxArchive,
invalidateInboxIssueQueries,
getIssuePresenceInActiveInboxCaches,
@@ -4596,43 +4595,6 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS
});
}
}, [queryClient, selectedCompanyId]);
const undoInboxArchive = useCallback(
async (
id: string,
companyId: string | undefined,
previousData: InboxIssueCacheSnapshot,
) => {
if (companyId) {
await cancelInboxIssueQueries(queryClient, companyId);
clearLocalInboxArchive(companyId, id);
restoreIssueToInboxCaches(queryClient, previousData, id);
}
try {
await issuesApi.unarchiveFromInbox(id);
pushToast({ title: "Task restored to inbox", tone: "success" });
} catch (error) {
if (companyId) {
beginLocalInboxArchive(companyId, id);
removeIssueFromInboxCaches(queryClient, companyId, id);
boundLocalInboxArchive(companyId, id);
}
pushToast({
title: "Undo failed",
body:
error instanceof Error
? error.message
: "Unable to restore this task to the inbox",
tone: "error",
});
} finally {
if (companyId) {
await invalidateInboxIssueQueries(queryClient, companyId);
}
}
},
[pushToast, queryClient],
);
const upsertInteractionInCache = useCallback(
(interaction: IssueThreadInteraction) => {
invalidateInteractionRecordViews(queryClient, interaction.companyId, interaction);
@@ -6102,7 +6064,7 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS
removeIssueFromInboxCaches(queryClient, selectedCompanyId, id);
return { companyId: selectedCompanyId, previousData, account, release };
},
onSuccess: (_data, id, context) => {
onSuccess: (_data, id) => {
if (selectedCompanyId) {
removeIssueFromInboxCaches(queryClient, selectedCompanyId, id);
}
@@ -6113,20 +6075,6 @@ export function TaskDetailSurface({ conversation, tasksTab }: { tasksTab?: TaskS
: "/inbox",
{ replace: true },
);
pushToast({
title: "Task archived from inbox",
tone: "success",
action: {
label: "Undo",
onClick: () => {
void undoInboxArchive(
id,
context?.companyId,
context?.previousData ?? [],
);
},
},
});
},
onError: (err, id, context) => {
context?.release?.();
+48 -16
View File
@@ -6,6 +6,7 @@ import { afterEach, beforeEach, expect, it, vi } from "vitest";
import type { Issue } from "@paperclipai/shared";
import { queryKeys } from "@/lib/queryKeys";
import { Inbox } from "./Inbox";
import type { IssueRowArchiveAction } from "@/components/IssueRow";
import { defaultIssueFilterState } from "@/lib/issue-filters";
import { CoordinatorTasks } from "./CoordinatorTasks";
import { Issues } from "./Issues";
@@ -13,15 +14,18 @@ import { BlockedInboxView } from "@/components/BlockedInboxView";
import { TaskListPagination } from "@/components/TaskListPagination";
const api = vi.hoisted(() => ({ compact: vi.fn(), inboxMine: vi.fn(), list: vi.fn(), taskIndex: vi.fn(), agents: vi.fn(), projects: vi.fn(), directory: vi.fn(), labels: vi.fn() }));
const archive = vi.hoisted(() => ({ mutate: vi.fn(), pushToast: vi.fn() }));
const route = vi.hoisted(() => ({ params: new URLSearchParams("view=all"), navigate: vi.fn(), setParams: vi.fn(), setBreadcrumbs: vi.fn(), autoScroll: false, streamlined: false, pathname: "/issues" }));
vi.mock("@/api/issues", () => ({ issuesApi: { listCompact: api.compact, inboxMine: api.inboxMine, list: api.list, listLabels: api.labels } }));
vi.mock("@/api/issues", () => ({ issuesApi: { listCompact: api.compact, inboxMine: api.inboxMine, list: api.list, listLabels: api.labels, archiveFromInbox: archive.mutate } }));
vi.mock("@/api/attention", () => ({ attentionApi: { taskIndex: api.taskIndex } }));
vi.mock("@/api/agents", () => ({ agentsApi: { list: api.agents } }));
vi.mock("@/api/projects", () => ({ projectsApi: { list: api.projects } }));
vi.mock("@/api/access", () => ({ accessApi: { listUserDirectory: api.directory } }));
vi.mock("@/context/ToastContext", () => ({ useToastActions: () => ({ pushToast: vi.fn() }) }));
vi.mock("@/context/ToastContext", () => ({
useToastActions: () => ({ pushToast: archive.pushToast }),
useOptionalToastActions: () => ({ pushToast: archive.pushToast }),
}));
vi.mock("@/context/SidebarContext", () => ({ useSidebar: () => ({ isMobile: false }) }));
vi.mock("@/hooks/useAccountBoundMutation", () => ({ useAccountBoundMutation: () => ({ mutate: vi.fn(), reset: vi.fn(), isPending: false, error: null }) }));
vi.mock("@/hooks/usePreloadTaskChats", async importOriginal => ({ ...await importOriginal<typeof import("@/hooks/usePreloadTaskChats")>(), usePreloadTaskChats: () => {} }));
vi.mock("@/context/CompanyContext", () => ({ useCompany: () => ({ selectedCompanyId: "company-1" }) }));
vi.mock("@/context/BreadcrumbContext", () => ({ useBreadcrumbs: () => ({ setBreadcrumbs: route.setBreadcrumbs }) }));
@@ -34,7 +38,6 @@ vi.mock("@/hooks/usePageContentReady", () => ({ usePageContentReady: () => {} })
vi.mock("@/context/DesignSandboxContext", () => ({ useDesignSandbox: () => false }));
vi.mock("@/hooks/useWarmTaskDetailCode", () => ({ useWarmTaskDetailCode: () => {} }));
vi.mock("@/hooks/useUpdateIssueMutation", () => ({ useUpdateIssueMutation: () => ({ mutate: vi.fn() }) }));
vi.mock("@/hooks/useTaskArchiveAction", () => ({ useTaskArchiveAction: () => () => undefined }));
vi.mock("@/hooks/useTaskCancellation", () => ({ useTaskCancellation: () => vi.fn(), TaskCancellationDismissedError: class extends Error {} }));
vi.mock("@/hooks/useIssueRowDetails", () => ({ useIssueRowDetails: () => ({ enrichIssueRow: (issue: Issue) => issue }) }));
vi.mock("@/hooks/useSharedPolling", () => ({ useSharedPollingQuery: () => ({ enabled: false }), usePublishSharedQueryData: () => {} }));
@@ -43,7 +46,10 @@ vi.mock("@/lib/router", () => ({
useLocation: () => ({ pathname: route.pathname, search: `?${route.params}`, hash: "" }),
Link: ({ children }: { children: ReactNode }) => <a>{children}</a>,
}));
vi.mock("@/components/TaskList", async importOriginal => ({ ...await importOriginal<typeof import("@/components/TaskList")>(), TaskList: ({ items }: { items: { issue: Issue }[] }) => <>{items.map(({ issue }) => <span data-task key={issue.id}>{issue.title}</span>)}</> }));
vi.mock("@/components/TaskList", async importOriginal => ({ ...await importOriginal<typeof import("@/components/TaskList")>(), TaskList: ({ items, getArchiveAction }: {
items: { issue: Issue }[];
getArchiveAction?: (issue: Issue) => IssueRowArchiveAction | undefined;
}) => <>{items.map(({ issue }) => <ArchiveTestRow key={issue.id} issue={issue} onArchive={getArchiveAction?.(issue)?.onClick} />)}</> }));
vi.mock("@/components/TaskListToolbar", () => ({ TaskListToolbar: () => null }));
vi.mock("@/components/IssuesList", () => ({ IssuesList: ({ issues, pagedIssuesProvided, hasMoreIssues, isLoadingMoreIssues, onLoadMoreIssues, loadMoreIssuesError, onRetryLoadMoreIssues }: {
issues: Issue[]; pagedIssuesProvided: boolean; hasMoreIssues?: boolean; isLoadingMoreIssues?: boolean; onLoadMoreIssues?: () => void;
@@ -60,11 +66,15 @@ vi.mock("@/components/IssuesList", () => ({ IssuesList: ({ issues, pagedIssuesPr
vi.mock("@/components/KanbanBoard", () => ({ KanbanBoard: () => null }));
vi.mock("@/components/TruncatedText", () => ({ TruncatedTextMarqueeProvider: ({ children }: { children: ReactNode }) => children }));
vi.mock("@/components/ui/flyout", () => ({ FlyoutAppearanceProvider: ({ children }: { children: ReactNode }) => children }));
vi.mock("@/components/IssueRow", () => ({ IssueRow: ({ issue }: { issue: Issue }) => <span data-task>{issue.title}</span> }));
vi.mock("@/components/IssueRow", () => ({ IssueRow: ArchiveTestRow }));
vi.mock("@/components/QueryView", () => ({ useQueryView: (query: { data?: unknown; error?: unknown; refetch: unknown }) => ({
kind: query.error ? "error" : query.data ? "ready" : "loading", error: query.error, retry: query.refetch,
}) }));
function ArchiveTestRow({ issue, onArchive }: { issue: Issue; onArchive?: () => void }) {
return <span data-task>{issue.title}{onArchive && <button onClick={onArchive}>Archive</button>}</span>;
}
let client: QueryClient;
let root: Root;
let container: HTMLDivElement;
@@ -189,6 +199,19 @@ it.each([false, true])("waits for manual retry after automatic paging fails with
});
function seedInboxQueries(streamlined: boolean) {
client.setDefaultOptions({ queries: { retry: false, staleTime: Infinity } });
client.setQueryData(queryKeys.auth.session, { user: { id: "user-1" }, session: { userId: "user-1" } });
client.setQueryData(queryKeys.instance.experimentalSettings, { enableIsolatedWorkspaces: false, enableExternalObjects: false });
for (const key of [queryKeys.agents.list("company-1"), queryKeys.projects.list("company-1", { includeArchived: true }),
queryKeys.issues.labels("company-1"), queryKeys.approvals.list("company-1"), queryKeys.access.joinRequests("company-1"),
queryKeys.inboxDismissals("company-1"), queryKeys.liveRuns("company-1"),
[...queryKeys.heartbeats("company-1"), streamlined ? "inbox-failures" : "limit", 200],
]) client.setQueryData(key, []);
client.setQueryData(queryKeys.access.companyUserDirectory("company-1"), { users: [] });
client.setQueryData(queryKeys.dashboard("company-1"), { agents: { error: 0 }, costs: { monthBudgetCents: 0, monthUtilizationPercent: 0 } });
}
it.each([
{ streamlined: false, tab: "mine" }, { streamlined: true, tab: "mine" },
{ streamlined: false, tab: "recent" }, { streamlined: true, tab: "recent" },
@@ -200,16 +223,7 @@ it.each([
const tasks = Array.from({ length: pageSize + 3 }, (_, index) => createIssue({
id: `task-${index}`, companyId: "company-1", title: `Task ${index}`, parentId: null,
}));
client.setDefaultOptions({ queries: { retry: false, staleTime: Infinity } });
client.setQueryData(queryKeys.auth.session, { user: { id: "user-1" }, session: { userId: "user-1" } });
client.setQueryData(queryKeys.instance.experimentalSettings, { enableIsolatedWorkspaces: false, enableExternalObjects: false });
for (const key of [queryKeys.agents.list("company-1"), queryKeys.projects.list("company-1", { includeArchived: true }),
queryKeys.issues.labels("company-1"), queryKeys.approvals.list("company-1"), queryKeys.access.joinRequests("company-1"),
queryKeys.inboxDismissals("company-1"), queryKeys.liveRuns("company-1"),
[...queryKeys.heartbeats("company-1"), streamlined ? "inbox-failures" : "limit", 200],
]) client.setQueryData(key, []);
client.setQueryData(queryKeys.access.companyUserDirectory("company-1"), { users: [] });
client.setQueryData(queryKeys.dashboard("company-1"), { agents: { error: 0 }, costs: { monthBudgetCents: 0, monthUtilizationPercent: 0 } });
seedInboxQueries(streamlined);
api.inboxMine.mockResolvedValue({ userId: "user-1", issues: tasks.slice(0, pageSize), contextIssues: [], failureRuns: [], failureIssueIds: [] });
api.compact.mockImplementation(async (_company, filters) => filters.touchedByUserId
? tasks.slice(filters.offset ?? 0, (filters.offset ?? 0) + filters.limit) : []);
@@ -228,3 +242,21 @@ it.each([
expect({ ...firstPage, offset: pageSize }).toEqual(laterPage);
}
});
it.each(["Inbox", "Tasks", "All tasks"] as const)("archives a task without a toast in %s", async surface => {
route.streamlined = true;
route.pathname = "/inbox/mine";
seedInboxQueries(true);
const task = createIssue({ id: `task-to-archive-${surface}`, companyId: "company-1", isArchivedForMe: false });
api.inboxMine.mockResolvedValue({ userId: "user-1", issues: [task], contextIssues: [], failureRuns: [], failureIssueIds: [] });
api.compact.mockResolvedValue([task]);
archive.mutate.mockResolvedValue(undefined);
await render(surface === "All tasks" ? <CoordinatorTasks /> : <Inbox surfaceLabel={surface} />);
const archiveButton = () => [...container.querySelectorAll("button")].find(button => button.textContent === "Archive");
await vi.waitFor(() => expect(archiveButton()).toBeDefined());
await act(async () => archiveButton()!.click());
expect(archive.mutate).toHaveBeenCalledExactlyOnceWith(task.id);
await act(async () => vi.waitFor(() => expect(client.isMutating()).toBe(0)));
expect(archive.pushToast).not.toHaveBeenCalled();
});