feat: Add a button to archive sessions from the sidebar#570
feat: Add a button to archive sessions from the sidebar#570ColeMurray merged 6 commits intoColeMurray:mainfrom
Conversation
(cherry picked from commit ebb4b313c52be5ef2811f4e1eb4bfd3d7fbfa238)
(cherry picked from commit 8edb0ffefbd6923915ca3b5d54e0726413e107ca)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a dedicated archive flow: a new ArchiveSessionDialog component, an archiveSession utility that POSTs and mutates SWR cache, session-list helper, integration of archive UI/logic into the sidebar (including router handling and mobile support), and test coverage updates. Changes
Sequence DiagramsequenceDiagram
actor User
participant Sidebar as SessionSidebar
participant Dialog as ArchiveSessionDialog
participant Utility as archiveSession()
participant API as API_Server
participant Cache as SWR_Cache
participant Router as Router
User->>Sidebar: Long-press / click "Archive"
Sidebar->>Dialog: open(onConfirm handler)
User->>Dialog: Confirm
Dialog->>Sidebar: call onConfirm
Sidebar->>Utility: archiveSession(sessionId)
Utility->>API: POST /api/sessions/{id}/archive
API-->>Utility: 200 OK
Utility->>Cache: mutate SIDEBAR_SESSIONS_KEY (remove session)
Utility-->>Sidebar: return success
Sidebar->>Sidebar: update local state (remove item)
Sidebar->>Router: navigate away if archived session was active
Router-->>User: redirect
Estimated Code Review Effort🎯 4 (Complex) | ⏱️ ~45 minutes 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 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/web/src/lib/archive-session.ts`:
- Around line 25-34: The function archiveSession currently can throw (e.g.,
fetch/network errors) which breaks its boolean contract; wrap the body of
archiveSession in a try/catch so any thrown errors (from fetch or subsequent
await removeSessionFromSidebarCache) are caught, log the error with context, and
return false in the catch branch; keep the existing response.ok check and return
true only after successful archive and cache removal.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 415f6913-61ab-46e1-8976-8856004e20ba
📒 Files selected for processing (7)
packages/web/src/app/(app)/session/[id]/page.tsxpackages/web/src/components/action-bar.tsxpackages/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.tspackages/web/src/lib/session-list.ts
## 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 - [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 -->
- add an `Archive` action to sidebar session rows - reuse a shared archive dialog between the sidebar and the session page - add `archiveSession` as the shared archive helper - keep sidebar state in sync after archiving - add/update focused sidebar coverage for the archive flow <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Archive sessions directly from the session sidebar. * Confirmation dialog when archiving sessions. * Mobile-optimized archive workflow via long-press. * Archived sessions are removed from the sidebar immediately; archive action is disabled while processing. * **Tests** * Added coverage for the mobile archive flow and confirmation/workflow behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Kartikye <kartikye@dots.dev>
…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 -->
Archiveaction to sidebar session rowsarchiveSessionas the shared archive helperSummary by CodeRabbit
New Features
Tests