From 8c6e1fa7807b96c00e7ca385190ccb0d81a6ed3d Mon Sep 17 00:00:00 2001 From: Dotta <34892728+cryppadotta@users.noreply.github.com> Date: Thu, 3 Dec 2026 21:10:14 -0600 Subject: [PATCH] fix(ui): omit task archive success toasts --- doc/PRODUCT.md | 7 +-- ui/src/components/SidebarRecentTasks.tsx | 1 - ui/src/hooks/useTaskArchiveAction.ts | 21 +------- ui/src/pages/Inbox.tsx | 19 +------ ui/src/pages/IssueDetail.tsx | 54 +------------------- ui/src/pages/TaskListPagination.test.tsx | 64 ++++++++++++++++++------ 6 files changed, 56 insertions(+), 110 deletions(-) diff --git a/doc/PRODUCT.md b/doc/PRODUCT.md index 13cc4b36c7b..93453fd5478 100644 --- a/doc/PRODUCT.md +++ b/doc/PRODUCT.md @@ -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 diff --git a/ui/src/components/SidebarRecentTasks.tsx b/ui/src/components/SidebarRecentTasks.tsx index 3547b2df6ee..60c5eba140f 100644 --- a/ui/src/components/SidebarRecentTasks.tsx +++ b/ui/src/components/SidebarRecentTasks.tsx @@ -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", diff --git a/ui/src/hooks/useTaskArchiveAction.ts b/ui/src/hooks/useTaskArchiveAction.ts index 4446aa2c6be..66a335e79fe 100644 --- a/ui/src/hooks/useTaskArchiveAction.ts +++ b/ui/src/hooks/useTaskArchiveAction.ts @@ -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)), diff --git a/ui/src/pages/Inbox.tsx b/ui/src/pages/Inbox.tsx index 0ad400ac917..bd2ea4df335 100644 --- a/ui/src/pages/Inbox.tsx +++ b/ui/src/pages/Inbox.tsx @@ -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); - }, - }, - }); - } }, }); diff --git a/ui/src/pages/IssueDetail.tsx b/ui/src/pages/IssueDetail.tsx index c7cc629ebbd..32397df64b3 100644 --- a/ui/src/pages/IssueDetail.tsx +++ b/ui/src/pages/IssueDetail.tsx @@ -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?.(); diff --git a/ui/src/pages/TaskListPagination.test.tsx b/ui/src/pages/TaskListPagination.test.tsx index eb4f66a898b..5c90e0ec3ad 100644 --- a/ui/src/pages/TaskListPagination.test.tsx +++ b/ui/src/pages/TaskListPagination.test.tsx @@ -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(), 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 }) => {children}, })); -vi.mock("@/components/TaskList", async importOriginal => ({ ...await importOriginal(), TaskList: ({ items }: { items: { issue: Issue }[] }) => <>{items.map(({ issue }) => {issue.title})} })); +vi.mock("@/components/TaskList", async importOriginal => ({ ...await importOriginal(), TaskList: ({ items, getArchiveAction }: { + items: { issue: Issue }[]; + getArchiveAction?: (issue: Issue) => IssueRowArchiveAction | undefined; +}) => <>{items.map(({ issue }) => )} })); 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 }) => {issue.title} })); +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 {issue.title}{onArchive && }; +} + 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" ? : ); + 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(); +});