feat(api): exclude archived sessions from GET /api/chats
Merged
AR
5mo ago+22+22+01234567890123456789-5-5-0123456789
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/chatsreturns 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 nextGET /api/chatsresponse. - Unarchive (
status: \"running\") and confirm the chats re-appear. -
get_chatsMCP 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")inselectChatsWithSessionsand projectsession.status. - Document the exclusion in
getChatsHandlerand theget_chatstool JSDoc. - Add tests to assert the filter is always applied and that
statusis projected.
- Apply
Summary by CodeRabbit
- Bug Fixes
- Chats from archived sessions are now excluded from chat retrieval and the get_chats tool results.