fix: add error toasts and failure test for sidebar archive#576
fix: add error toasts and failure test for sidebar archive#576ColeMurray merged 1 commit intomainfrom
Conversation
Follow-up to #570. Show a toast when archiving fails instead of silently logging to console. Add a failure-path test, clarify the split cache responsibility with a comment, and narrow the dialog onConfirm type.
📝 WalkthroughWalkthroughThis PR modifies archive session functionality by narrowing the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
Terraform Validation Results
Pushed by: @ColeMurray, Action: |
There was a problem hiding this comment.
Summary
PR Title and number: fix: add error toasts and failure test for sidebar archive (#576)
Author: @ColeMurray
Files changed count, additions/deletions: 4 files changed, +50 / -4
This follow-up cleanly replaces silent archive failures with user-visible toasts, adds coverage for the failure path, and clarifies the sidebar cache split without changing the underlying archive flow. I reviewed the changed files and did not find any blocking correctness, security, performance, or maintainability issues.
Critical Issues
None.
Suggestions
None.
Nitpicks
None.
Positive Feedback
- The failure-path test covers the key regression risk from the original sidebar archive change.
- Narrowing
ArchiveSessionDialog.onConfirmmatches how the dialog is actually used and keeps the prop surface simpler. - The cache-responsibility comment in
handleSessionArchivedmakes the SWR versus local-state split much easier to follow.
Questions
None.
Verdict (for GitHub PRs)
Approve: Ready to merge, no blocking issues.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/web/src/components/session-sidebar.test.tsx (1)
260-301: Consider asserting the error toast as well.This test covers the “session remains visible” part of the failure path, but it doesn’t verify the new user-facing
toast.error(...)behavior. Adding that assertion would cover the regression end-to-end.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/web/src/components/session-sidebar.test.tsx` around lines 260 - 301, The test currently verifies the session stays visible on archive failure but doesn't assert the user-facing error toast; update the test in session-sidebar.test.tsx to also mock/spyon the toast.error function (or import the toast mock used elsewhere) and assert it was called with the expected error message after the failed POST to "/api/sessions/session-1/archive" (the existing fetchMock and the interactions around SessionSidebar, MOBILE_LONG_PRESS_MS, and the "Archive" confirmation button should remain unchanged) so the test verifies both visibility and that toast.error was invoked.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/web/src/components/session-sidebar.test.tsx`:
- Around line 260-301: The test currently verifies the session stays visible on
archive failure but doesn't assert the user-facing error toast; update the test
in session-sidebar.test.tsx to also mock/spyon the toast.error function (or
import the toast mock used elsewhere) and assert it was called with the expected
error message after the failed POST to "/api/sessions/session-1/archive" (the
existing fetchMock and the interactions around SessionSidebar,
MOBILE_LONG_PRESS_MS, and the "Archive" confirmation button should remain
unchanged) so the test verifies both visibility and that toast.error was
invoked.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a835f705-4fe2-4077-8206-6168006cd593
📒 Files selected for processing (4)
packages/web/src/components/archive-session-dialog.tsxpackages/web/src/components/session-sidebar.test.tsxpackages/web/src/components/session-sidebar.tsxpackages/web/src/lib/archive-session.ts
…y#576) ## Summary Follow-up to ColeMurray#570. Addresses review feedback: - **Error toasts**: Replace silent `console.error` calls in `archiveSession()` with `toast.error()` so users see feedback when archiving fails - **Failure-path test**: Add test that verifies the session stays in the sidebar when the archive API returns 500 - **Clarifying comment**: Document the split cache responsibility in `handleSessionArchived` (SWR cache vs local `extraSessions` state) - **Type narrowing**: Change `ArchiveSessionDialog.onConfirm` from `() => void | Promise<void>` to `() => void` since the dialog never awaits it ## Test plan - [x] `npm test -w @open-inspect/web` — 192 tests pass (including new failure-path test) - [x] `npm run typecheck -w @open-inspect/web` — clean - [x] `npm run lint -w @open-inspect/web` — clean <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Improvements** * Enhanced error notifications when session archiving fails, now displaying user-friendly messages instead of silent failures. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary
Follow-up to #570. Addresses review feedback:
console.errorcalls inarchiveSession()withtoast.error()so users see feedback when archiving failshandleSessionArchived(SWR cache vs localextraSessionsstate)ArchiveSessionDialog.onConfirmfrom() => void | Promise<void>to() => voidsince the dialog never awaits itTest plan
npm test -w @open-inspect/web— 192 tests pass (including new failure-path test)npm run typecheck -w @open-inspect/web— cleannpm run lint -w @open-inspect/web— cleanSummary by CodeRabbit