Skip to content

feat(chat): archive the session for sidebar "Delete chat"#1762

Closed
arpitgupta1214 wants to merge 1 commit into
feat/sidebar-delete-rename-session-scopedfrom
feat/archive-session-instead-of-delete-chat
Closed

feat(chat): archive the session for sidebar "Delete chat"#1762
arpitgupta1214 wants to merge 1 commit into
feat/sidebar-delete-rename-session-scopedfrom
feat/archive-session-instead-of-delete-chat

Conversation

@arpitgupta1214

@arpitgupta1214 arpitgupta1214 commented May 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

Switches the sidebar's "Delete chat" action to soft-delete by archiving the owning session instead of deleting the chat row. The api (api#630) filters chats from archived sessions out of GET /api/chats, so the row disappears from the sidebar; archive also triggers the existing sandbox-teardown lifecycle, and the whole thing is reversible from the admin side.

This also unblocks deleting the last chat in a session — the previous chat-row delete refused with 400 Cannot delete the only chat in a session, while archive has no such constraint.

  • New lib/sessions/archiveSession.tsPATCH /api/sessions/{sid} { status: "archived" }.
  • useDeleteChat calls it (drops the chatId arg).
  • DeleteConfirmationModal no longer passes chatId.
  • Remove the now-unused lib/chats/deleteChat.ts.

Caveat

If a session ever has >1 chat, archiving from one row hides the others too. Today every sidebar row maps 1:1 to its own session (each POST /api/sessions mints a session + single chat), so this is a no-op in practice — but worth knowing before we add a UI that creates additional chats inside an existing session.

Dependencies

  • Base: chat#1758 (feat/sidebar-delete-rename-session-scoped). Stacked so the file moves don't conflict.
  • Requires api#630 live; until then, archived sessions still appear in the chat list.

Test plan

  • On a Vercel preview with api#630 live, click a sidebar chat → ⋮ → Delete → Confirm. Row disappears after refetch. Verify the underlying session is now status: "archived" via GET /api/sessions/{sid}.
  • Bulk delete multiple rows. All disappear.
  • Delete a chat that was previously the "only chat in its session" (used to 400). Now succeeds.

Summary by cubic

Switch the sidebar “Delete chat” to archive the session instead of deleting the chat. The row disappears, sandbox teardown runs, deleting the last chat now works, and the action is reversible.

  • New Features

    • Archive sessions via lib/sessions/archiveSession.ts (PATCH /api/sessions/{sid} with { status: "archived" }).
    • Update useDeleteChat and DeleteConfirmationModal to use session archive (no chatId).
    • Remove lib/chats/deleteChat.ts.
    • Archiving a session hides all its chats.
  • Dependencies

    • Requires api#630 to filter archived sessions from GET /api/chats; until live, archived sessions still appear.
    • Stacked on chat#1758 (feat/sidebar-delete-rename-session-scoped).

Written for commit f6af28f. Summary will update on new commits.

Review in cubic

Switch the sidebar's delete action to soft-delete via session archive
instead of removing the chat row. The api side filters chats whose
session is `archived` out of `GET /api/chats` (api#630), so the row
disappears from the sidebar; archive also triggers the existing
`stopSandboxOnArchive` lifecycle path on the api so we stop running
sandboxes for chats the user told us they're done with.

This also unblocks deleting the last chat in a session, which the
api previously refused with `400 Cannot delete the only chat in a
session` — archive has no such constraint.

- New `lib/sessions/archiveSession.ts` → `PATCH /api/sessions/{sid}
  { status: "archived" }`.
- `useDeleteChat` calls it (drops the `chatId` arg).
- `DeleteConfirmationModal` no longer passes `chatId`.
- Remove the now-unused `lib/chats/deleteChat.ts`.

Caveat for reviewers: if a session ever has >1 chat, archiving from
one row will hide the others too. Today every sidebar row corresponds
1:1 with its own session (each `POST /api/sessions` mints a session +
single chat), so this is a no-op in practice — but worth knowing
before we add a UI that creates additional chats inside an existing
session.

Depends on api#630 for the filter; until that lands, archived sessions
will still show up in the chat list.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented May 31, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chat Ready Ready Preview May 31, 2026 9:45pm

Request Review

@coderabbitai

coderabbitai Bot commented May 31, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (2)
  • main
  • test

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 12d88d56-9760-42e2-a7dd-97b096863e10

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/archive-session-instead-of-delete-chat

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.

@cubic-dev-ai cubic-dev-ai 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 issues found across 4 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Requires human review: This change alters the core chat deletion logic to archive sessions instead, introducing a new API call and modifying the backend behavior, which requires human review to ensure data integrity, handle the caveat about multiple chats per session, and verify the dependency on api#630 is properly met.

Re-trigger cubic

@arpitgupta1214

Copy link
Copy Markdown
Collaborator Author

Folded into #1758 — that PR was about to wire up a chat-row DELETE that this one immediately replaced, so it was throwaway code. Consolidating into a single PR that ships rename (session-scoped PATCH /api/sessions/{sid}/chats/{cid}) and delete-as-archive (PATCH /api/sessions/{sid} { status: "archived" }) together. Branch feat/archive-session-instead-of-delete-chat no longer needed.

@arpitgupta1214 arpitgupta1214 deleted the feat/archive-session-instead-of-delete-chat branch May 31, 2026 22:06
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