feat(archive): Add undo button to task archived toast#2665
Conversation
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
packages/ui/src/features/archive/useArchiveTask.ts:181-183
After the `recreateBranch` retry, if `restore` still returns `"branch-not-found"`, the condition `outcome.kind === "error"` is false so no toast is shown — the undo silently fails with no user feedback. The `RestoreOutcome` union has exactly three variants (`"restored"`, `"branch-not-found"`, `"error"`), so a `"branch-not-found"` result after the retry needs to be treated as an error for the user.
```suggestion
if (outcome.kind === "error") {
toast.error(`Failed to restore task: ${outcome.message}`);
} else if (outcome.kind === "branch-not-found") {
toast.error(`Failed to restore task: branch '${outcome.branchName}' not found`);
}
```
Reviews (1): Last reviewed commit: "add undo button to task archived toast" | Re-trigger Greptile |
There was a problem hiding this comment.
The unresolved bot comment identifies a real silent-failure bug: after the recreateBranch retry, if restore still returns "branch-not-found", neither the "branch-not-found" branch (already consumed) nor the "error" branch applies, so the undo silently fails with no user feedback. The current diff leaves this gap unaddressed.
There was a problem hiding this comment.
The bot-flagged silent-failure path is handled in the current code: outcome is let-reassigned after the retry, and the subsequent block re-checks outcome.kind === "branch-not-found" to show an error toast. Both bot reviews target an older commit and the concern is addressed. All other changes are additive and low-risk.
New commits pushed (delta classified non_trivial_delta) — stamphog approval dismissed; re-review running automatically.
There was a problem hiding this comment.
The bot-flagged silent-failure path is fully addressed in the current code — outcome is let-reassigned after the retry and the subsequent branch-not-found check emits an error toast. Tests explicitly cover the retry-still-fails case. All changes are additive UI-layer additions with no boundary violations.
New commits pushed (delta classified non_trivial_delta) — stamphog approval dismissed; re-review running automatically.
There was a problem hiding this comment.
No showstoppers. The previously flagged silent-failure path (branch still missing after retry) is correctly handled in the current code — outcome is reassigned after the retry and the subsequent branch-not-found check emits an error toast. Tests explicitly cover this case. The changes are additive UI-layer additions that respect package boundaries.
New commits pushed (delta classified non_trivial_delta) — stamphog approval dismissed; re-review running automatically.
There was a problem hiding this comment.
The previously flagged silent-failure path (branch still missing after retry) is correctly handled: after the retry, the code checks for "restored" and falls through to a unified error-toast block that covers both "branch-not-found" and "error" outcomes. Tests explicitly verify this case. All changes are additive UI-layer additions within @posthog/ui with no boundary violations.

Problem
Archiving a task is easy to trigger by accident, and the only way to reverse it is to open the Archived tasks page and unarchive from there. There is no quick in-place undo.
Changes
useUnarchiveTask().restore()flow, no new API or server changesdurationoption totoast.successand keep the archived toast up ~8s for reaction timeHow did you test this?
pnpm --filter @posthog/ui typecheckpassespnpm exec biome linton both changed files is clean (also enforced by the pre-commit hook)Automatic notifications