feat(api): exclude archived sessions from GET /api/chats

Merged
AR
5mo ago
+22-5

Summary

GET /api/chats (and the get_chats MCP tool) now skips chats whose owning session is archived. Archive (PATCH /api/sessions/{id} { status: \"archived\" }) is already the soft-delete path for sessions; the listing was still surfacing those chats, which made archive feel like a no-op and blocks the chat sidebar from using archive as the user-visible delete action.

Behavior added: selectChatsWithSessions applies .neq(\"session.status\", \"archived\") and projects session.status. JSDoc on the route handler and MCP tool note the exclusion.

Test plan

  • On a Vercel preview, GET /api/chats returns the caller's chats minus any whose session is archived.
  • Archive a session via PATCH /api/sessions/{id} { status: \"archived\" } and confirm its chats disappear from the next GET /api/chats response.
  • Unarchive (status: \"running\") and confirm the chats re-appear.
  • get_chats MCP tool returns the same filtered set.

Summary by cubic

Exclude chats from archived sessions in GET /api/chats and the get_chats MCP tool so archive acts as soft-delete and the chat sidebar can treat archive as delete. Unarchiving makes the chats visible again.

  • New Features
    • Apply .neq("session.status", "archived") in selectChatsWithSessions and project session.status.
    • Document the exclusion in getChatsHandler and the get_chats tool JSDoc.
    • Add tests to assert the filter is always applied and that status is projected.

Summary by CodeRabbit

  • Bug Fixes
    • Chats from archived sessions are now excluded from chat retrieval and the get_chats tool results.