Skip to content

feat: Add a button to archive sessions from the sidebar#570

Merged
ColeMurray merged 6 commits intoColeMurray:mainfrom
kartikye:feat/archive-session-from-sidebar
Apr 29, 2026
Merged

feat: Add a button to archive sessions from the sidebar#570
ColeMurray merged 6 commits intoColeMurray:mainfrom
kartikye:feat/archive-session-from-sidebar

Conversation

@kartikye
Copy link
Copy Markdown
Contributor

@kartikye kartikye commented Apr 27, 2026

  • 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

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.

kartikye and others added 4 commits April 27, 2026 14:36
(cherry picked from commit ebb4b313c52be5ef2811f4e1eb4bfd3d7fbfa238)
(cherry picked from commit 8edb0ffefbd6923915ca3b5d54e0726413e107ca)
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d91fa930-f0cd-45cd-b347-2fd5cd61ab72

📥 Commits

Reviewing files that changed from the base of the PR and between c58d10b and 2bae3db.

📒 Files selected for processing (1)
  • packages/web/src/lib/archive-session.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/web/src/lib/archive-session.ts

📝 Walkthrough

Walkthrough

Adds 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

Cohort / File(s) Summary
Archive Dialog Component
packages/web/src/components/archive-session-dialog.tsx
New client component ArchiveSessionDialog (typed props) rendering a controlled AlertDialog with cancel/confirm actions.
Archive Session Utilities
packages/web/src/lib/archive-session.ts, packages/web/src/lib/session-list.ts
Added archiveSession(sessionId) to POST /api/sessions/{id}/archive, handle errors, and mutate SWR SIDEBAR_SESSIONS_KEY; added removeSessionFromList helper to filter sessions.
Page & Action Bar Refactor
packages/web/src/app/(app)/session/[id]/page.tsx, packages/web/src/components/action-bar.tsx
Page delegates archive calls to archiveSession; action-bar replaces inline AlertDialog with ArchiveSessionDialog and forwards confirm handler.
Sidebar Integration & Tests
packages/web/src/components/session-sidebar.tsx, packages/web/src/components/session-sidebar.test.tsx
Session items gain Archive action and dialog state; onArchive callback plumbed through items; router navigation handles currently viewed archived sessions; tests added/updated for mobile archive flow and fetch mocking.

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated Code Review Effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I hopped in with a tiny dialog, bright,
Pressed Confirm, sent the session to night,
Cache shook a paw, the sidebar sighed,
Router nudged me gently aside,
Hooray — archived, and all feels right! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% 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 PR title accurately describes the main change: adding an archive button to the sidebar for sessions, which is the primary feature across all modified components.
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 unit tests (beta)
  • Create PR with unit tests

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

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

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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6a4fdc7 and c58d10b.

📒 Files selected for processing (7)
  • packages/web/src/app/(app)/session/[id]/page.tsx
  • packages/web/src/components/action-bar.tsx
  • 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
  • packages/web/src/lib/session-list.ts

Comment thread packages/web/src/lib/archive-session.ts Outdated
@ColeMurray ColeMurray merged commit 8c6efdc into ColeMurray:main Apr 29, 2026
18 checks passed
ColeMurray added a commit that referenced this pull request 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

- [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 -->
MartinRoberts-Fountain pushed a commit to MartinRoberts-Fountain/background-agents that referenced this pull request Apr 29, 2026
- 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>
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.

2 participants