Skip to content

fix: add error toasts and failure test for sidebar archive#576

Merged
ColeMurray merged 1 commit intomainfrom
fix/archive-session-followup
Apr 29, 2026
Merged

fix: add error toasts and failure test for sidebar archive#576
ColeMurray merged 1 commit intomainfrom
fix/archive-session-followup

Conversation

@ColeMurray
Copy link
Copy Markdown
Owner

@ColeMurray ColeMurray commented Apr 29, 2026

Summary

Follow-up to #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

  • npm test -w @open-inspect/web — 192 tests pass (including new failure-path test)
  • npm run typecheck -w @open-inspect/web — clean
  • npm run lint -w @open-inspect/web — clean

Summary by CodeRabbit

  • Improvements
    • Enhanced error notifications when session archiving fails, now displaying user-friendly messages instead of silent failures.

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.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

📝 Walkthrough

Walkthrough

This PR modifies archive session functionality by narrowing the onConfirm callback type signature, replacing console error logging with Sonner toast notifications in error handling, and adding a test that verifies sessions remain visible when archive requests fail.

Changes

Cohort / File(s) Summary
Dialog Type Contract
packages/web/src/components/archive-session-dialog.tsx
Narrowed onConfirm callback signature from () => void | Promise<void> to strictly () => void, removing Promise support.
Error Handling & Notifications
packages/web/src/lib/archive-session.ts
Replaced console error logging with Sonner toast notifications for failed archive requests; error details no longer captured in catch block.
Session Sidebar
packages/web/src/components/session-sidebar.tsx, packages/web/src/components/session-sidebar.test.tsx
Added inline documentation describing cache behavior in handleSessionArchived for first-page vs. paginated sessions; added test validating session remains visible after failed archive attempt (500 response).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

  • background-agents#570: Introduces the shared archiveSession helper and archive dialog, with this PR refining its type contract and error handling.

Suggested reviewers

  • open-inspect

Poem

🐰 A hop and a skip through archive land,
Where types grow strict and toasts expand,
Failed requests now speak so clear,
With gentle nudges in your ear! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: adding error toasts for failed archive operations and a test for the failure path in the sidebar archive feature.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/archive-session-followup

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.

❤️ Share
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

Terraform Validation Results

Step Status
Format
Init
Validate

Note: Terraform plan was skipped because secrets are not configured. This is expected for external contributors. See docs/GETTING_STARTED.md for setup instructions.

Pushed by: @ColeMurray, Action: pull_request

Copy link
Copy Markdown
Contributor

@open-inspect open-inspect Bot left a comment

Choose a reason for hiding this comment

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

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.onConfirm matches how the dialog is actually used and keeps the prop surface simpler.
  • The cache-responsibility comment in handleSessionArchived makes the SWR versus local-state split much easier to follow.

Questions

None.

Verdict (for GitHub PRs)

Approve: Ready to merge, no blocking issues.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 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

📥 Commits

Reviewing files that changed from the base of the PR and between 8c6efdc and d9bc44b.

📒 Files selected for processing (4)
  • packages/web/src/components/archive-session-dialog.tsx
  • packages/web/src/components/session-sidebar.test.tsx
  • packages/web/src/components/session-sidebar.tsx
  • packages/web/src/lib/archive-session.ts

@ColeMurray ColeMurray merged commit 891abe3 into main Apr 29, 2026
18 checks passed
@ColeMurray ColeMurray deleted the fix/archive-session-followup branch April 29, 2026 05:25
MartinRoberts-Fountain pushed a commit to MartinRoberts-Fountain/background-agents that referenced this pull request Apr 29, 2026
…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 -->
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.

1 participant