Select and delete chat conversations in bulk - #362
Merged
Merged
Conversation
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Select and delete chat conversations in bulk (#362)
The chat package's rail deletes conversations one at a time. Until it can select several, the Studio adds a Select chats row to the rail, under New chat and Attachments, which opens a panel in the main pane like the package's Attachments page.
The panel. Every conversation with a checkbox, its date, and message count; All (or All shown, when filtered); a title filter; shift-click to set a range; Delete N, which asks for confirmation on the page and then removes them in one request. Clicking a title opens that conversation. If the open conversation is among those deleted, the view returns to a new chat. Done, or any rail navigation, closes the panel.
Who can delete what. Only the viewer's own conversations, or ones with no owner. Under shared history the viewer can see others' conversations; those rows are listed but cannot be selected, and the server applies the same rule:
POST /api/chat/conversations/deletewith{ids}deletes what the caller owns, removes those transcripts from the knowledge base, reindexes once, and returns{deleted, skipped}.The rail row. The package has no slot for extra rail rows, so the row is portaled into the group that holds New chat, styled like its neighbors, with its label class copied from New chat so it collapses with the rail; a mutation observer re-attaches it if the package re-renders that group.
Conversation history is saved atomically. The server rewrote
conversations.jsonin place, so a crash, or a read, in the middle of a save saw an empty file, andload()treats an unreadable file as having no conversations; the next save would have kept it empty. It now writes a temporary file and renames it into place. The new bulk-delete test found this: it read the file during a save, about one run in twenty-five.Verified in headless Chrome against a seeded instance: the row appears in the rail, eight conversations listed, a shift range selects four, the confirmation names the count, deletion leaves the rest in the panel, the rail, and on the server, with no page errors. Two new server tests (the ownership rule with shared history on, and refusal of an empty list); 40 consecutive runs of the bulk-delete test pass. All server and web tests pass.