Skip to content

feat(archive): Add undo button to task archived toast#2665

Merged
charlesvien merged 5 commits into
mainfrom
feat/archive-toast-undo
Jun 14, 2026
Merged

feat(archive): Add undo button to task archived toast#2665
charlesvien merged 5 commits into
mainfrom
feat/archive-toast-undo

Conversation

@charlesvien

@charlesvien charlesvien commented Jun 14, 2026

Copy link
Copy Markdown
Member

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

  1. Add an Undo action to the "Task archived" toast that restores the task in place
  2. Reuse the existing useUnarchiveTask().restore() flow, no new API or server changes
  3. On the rare branch-not-found case, auto-retry with branch recreation and surface a toast error only on hard failure
  4. Add a duration option to toast.success and keep the archived toast up ~8s for reaction time

How did you test this?

  • pnpm --filter @posthog/ui typecheck passes
  • pnpm exec biome lint on both changed files is clean (also enforced by the pre-commit hook)
  • Manual in-app verification (archive then Undo from the sidebar) not yet run; the Undo reuses the same restore path the Archived tasks page already uses

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Copy link
Copy Markdown
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@charlesvien charlesvien changed the title add undo button to task archived toast feat(archive): Add undo button to task archived toast Jun 14, 2026
@charlesvien charlesvien marked this pull request as ready for review June 14, 2026 03:18
@github-actions

github-actions Bot commented Jun 14, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit bb14f24.

@greptile-apps

greptile-apps Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
Fix 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

Comment thread packages/ui/src/features/archive/useArchiveTask.ts Outdated
@charlesvien charlesvien added the Stamphog This will request an autostamp by stamphog on small changes label Jun 14, 2026

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@stamphog stamphog Bot removed the Stamphog This will request an autostamp by stamphog on small changes label Jun 14, 2026
@charlesvien charlesvien added the Stamphog This will request an autostamp by stamphog on small changes label Jun 14, 2026
github-actions[bot]
github-actions Bot previously approved these changes Jun 14, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@github-actions github-actions Bot dismissed their stale review June 14, 2026 04:48

New commits pushed (delta classified non_trivial_delta) — stamphog approval dismissed; re-review running automatically.

github-actions[bot]
github-actions Bot previously approved these changes Jun 14, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@github-actions github-actions Bot dismissed their stale review June 14, 2026 04:55

New commits pushed (delta classified non_trivial_delta) — stamphog approval dismissed; re-review running automatically.

github-actions[bot]
github-actions Bot previously approved these changes Jun 14, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@github-actions github-actions Bot dismissed their stale review June 14, 2026 04:59

New commits pushed (delta classified non_trivial_delta) — stamphog approval dismissed; re-review running automatically.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@charlesvien charlesvien merged commit 149bee4 into main Jun 14, 2026
24 checks passed
@charlesvien charlesvien deleted the feat/archive-toast-undo branch June 14, 2026 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Stamphog This will request an autostamp by stamphog on small changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant