feat(chats): archive chats instead of hard-deleting them#22406
Merged
feat(chats): archive chats instead of hard-deleting them#22406
Conversation
Contributor
Documentation CheckUpdates Needed
Automated review via Coder Tasks |
The UI has always labeled the action as 'Archive agent' but the backend
was performing a hard DELETE, permanently destroying chats and messages.
This change replaces the hard delete with a soft archive:
- Add 'archived' boolean column to chats table (migration 000423)
- Replace DeleteChatByID with ArchiveChatByID/UnarchiveChatByID queries
- Filter archived chats from GetChatsByOwnerID (archived = false)
- Replace DELETE /chats/{chat} with POST /chats/{chat}/archive
- Add POST /chats/{chat}/unarchive endpoint (API only, no UI yet)
- Update chatd daemon to archive chat trees instead of deleting them
- Update SDK with ArchiveChat/UnarchiveChat client methods
- Frontend calls POST .../archive instead of DELETE
This follows the same pattern used by template versions, which also use
an archived boolean column with dedicated /archive and /unarchive routes.
db5c3fe to
5069ea9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The UI has always labeled the action as "Archive agent" but the backend was performing a hard
DELETE, permanently destroying chats and all their messages.This change replaces the hard delete with a soft archive, consistent with the pattern used by template versions.
Changes
Database
archived boolean DEFAULT false NOT NULLcolumn tochatstableDeleteChatByIDquery withArchiveChatByID(UPDATE SET archived = true)UnarchiveChatByIDquery (UPDATE SET archived = false)GetChatsByOwnerID(WHERE archived = false)API
DELETE /api/experimental/chats/{chat}POST /api/experimental/chats/{chat}/archive— archives a chat and all its descendantsPOST /api/experimental/chats/{chat}/unarchive— unarchives a single chat (API only, no UI yet)Backend
archiveChatTree()recursively archives child chats (replacesdeleteChatTree()which hard-deleted)ArchiveChat()archives the full chat tree in a transactionActionUpdateinstead ofActionDeleteSDK
DeleteChat()withArchiveChat()andUnarchiveChat()Archivedfield toChatstructFrontend
archiveChatAPI call usesPOST .../archiveinstead ofDELETEDesign Decision
This follows the template version archive pattern (Pattern B in the codebase):
archived booleancolumn (notdeleted boolean)POST .../archiveandPOST .../unarchiveroutes (not repurposingDELETE)