Skip to content

fix(ui): stop deleted archived tasks from reappearing in sidebar#3144

Open
igennova wants to merge 2 commits into
PostHog:mainfrom
igennova:fix/3143
Open

fix(ui): stop deleted archived tasks from reappearing in sidebar#3144
igennova wants to merge 2 commits into
PostHog:mainfrom
igennova:fix/3143

Conversation

@igennova

@igennova igennova commented Jul 4, 2026

Copy link
Copy Markdown

Summary

  • Invalidate the workspaces cache when an archived task is deleted, so the sidebar no longer shows the task after delete.
  • Consolidate restore/delete post-action refresh into one helper that invalidates workspaces, archive, and tasks together.

Fixes #3143

Problem

Deleting a task from the Archived tasks view removes its local archives and workspaces rows, but the UI only refreshed archive and tasks caches. Sidebar visibility depends on both archivedTaskIds and workspaces, so after delete the app briefly had:

  • not archived (refreshed)
  • still has workspace (stale)

That made the task reappear in the sidebar until workspaces refetched for another reason.

Restore already invalidated workspaces via invalidateOnRestore; delete used a separate helper that did not.

Solution

Include WORKSPACE_QUERY_KEY invalidation in invalidateArchiveQueries, which runs after archived-task delete (and is shared with restore).

Video

Screen.Recording.2026-07-04.at.12.23.57.PM.mov

@trunk-io

trunk-io Bot commented Jul 4, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@greptile-apps

greptile-apps Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Comments Outside Diff (1)

  1. packages/ui/src/features/archive/useUnarchiveTask.ts, line 43-61 (link)

    P2 invalidateOnRestore is now a one-liner that just delegates to invalidateArchiveQueries with no additional logic. Since both restore and delete paths call the same function, this wrapper is superfluous and can be eliminated by calling invalidateArchiveQueries directly.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Reviews (1): Last reviewed commit: "fix(ui): refresh workspaces cache after ..." | Re-trigger Greptile

@pauldambra pauldambra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QA Swarm review complete. See inline comments.

@@ -34,16 +34,12 @@ export function useUnarchiveTask(): UseUnarchiveTask {

const invalidateArchiveQueries = useCallback(async () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 Automated comment by QA Swarm — not written by a human

[convergent: qa-team + paul + xp] 🟢 LOW

invalidateArchiveQueries now also invalidates WORKSPACE_QUERY_KEY and refetches ["tasks"], not just archive queries — the name undersells its scope. A future reader deciding whether to reuse or extend it will assume it's archive-only. Consider a name like invalidateAfterArchiveMutation or invalidateTaskListCaches. Not blocking.


const invalidateArchiveQueries = useCallback(async () => {
await Promise.all([
queryClient.invalidateQueries({ queryKey: WORKSPACE_QUERY_KEY }),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 Automated comment by QA Swarm — not written by a human

[convergent: qa-team/reliability + paul] 🟡 MEDIUM

The bug this PR fixes existed because the restore and delete paths' invalidation sets silently drifted apart (delete never invalidated WORKSPACE_QUERY_KEY, so the sidebar kept showing deleted archived tasks). Nothing added here prevents that drift from recurring. Worth a small regression test asserting the delete/remove outcome invalidates WORKSPACE_QUERY_KEYworkspaceQueryKey.test.ts and useWorkspaceMutations.test.tsx already show the pattern (real QueryClient + tRPC options proxy, assert partial-key match / invalidation spy).

@@ -78,7 +74,7 @@ export function useUnarchiveTask(): UseUnarchiveTask {
hasTask,
);
if (outcome.kind === "restore" && outcome.outcome.kind === "restored") {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 Automated comment by QA Swarm — not written by a human

[qa-team/generalist] ⚪ NIT

Both branches of this outcome check now call the identical invalidateArchiveQueries; the if/else if could collapse into a single predicate ((restore && restored) || (delete && deleted)). Fine to keep as-is if you prefer the explicit outcome-kind documentation.

@pauldambra

Copy link
Copy Markdown
Member

Note

🤖 Automated comment by QA Swarm — not written by a human

Multi-perspective review: qa-team (specialists + generalists), paul-reviewer, xp-reviewer, security-audit

Verdict: 💬 APPROVE WITH NITS (round 1 @ 6291f0a)

The fix is correct and well-targeted: the delete path never invalidated the sidebar's workspace query, so deleted archived tasks kept reappearing. Folding that invalidation into the shared invalidateArchiveQueries (and removing the now-redundant invalidateOnRestore wrapper) fixes it cleanly for both restore and delete. A couple of minor, non-blocking suggestions below.

Key findings

  • 🟡 MEDIUM — the restore/delete invalidation sets drifted apart once before (that's the bug this PR fixes); no regression test pins it against drifting apart again
  • 🟢 LOW — invalidateArchiveQueries now also touches the workspace cache and refetches tasks; the name undersells its scope
  • ⚪ NIT — runContextMenuAction's two identical-outcome branches could collapse into one predicate

Convergence

  • Naming (invalidateArchiveQueries scope) — independently flagged by qa-team, paul, and xp
  • Missing regression test — independently flagged by qa-team and paul

Reviewer summaries

Reviewer Assessment
🔍 qa-team Correct fix, verified against PR head; suggests a regression test and a scope-honest rename
👤 paul The invalidation fix is the right call; flags the same naming and test-coverage points
📐 xp Good OnceAndOnlyOnce move removing the wrapper; same naming nit
🛡 security-audit Pure frontend cache-invalidation change, no user-controlled data flow — zero findings

Automated by QA Swarm — not a human review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deleted archived task reappears in sidebar until workspaces cache refreshes

2 participants