Artifact 3f5b5e1916479e800744ec025d1d6b0f5bff9a61436fc6514b31c55fc3f11f29:
- File docs/design/session-delete.md — part of check-in [ec96d68bbf] at 2026-11-24 10:34:17 on branch session-delete — Delete conversations, with undo and a 30-day purge (user: dmestas, size: 3204) [annotate] [blame] [check-ins using] [more...]
Deleting conversations
Status: built 2026-11-24. Tier: core (src/trash.c: the record, restore and the purge, which keeps
the journal's invariants). Clock: durability. Record: one pic_trash row per deleted conversation
(schema 20). Default: on; purged 30 days after deleting.
Why
There was no way to delete a conversation, at the terminal or from a phone. People delete the wrong one and do not remember commands, so deleting is one key where conversations are listed, and undoing it is as easy.
The shape
- Delete hides. A
pic_trash(session_id, deleted_ms, purged_ms)row hides a conversation from every list and fromlatest(PIC_LISTED_SQL); admission into it is refused inchoose_session. Restoring deletes the row. No other table changes, so delete and restore are one small transaction each and need no lease. - Running is refused. Deleting checks, in its transaction, that the conversation has no admitted request and that no other process holds its lease. A request admitted after the delete commits is refused, so nothing starts in it between the look and the row.
- Purge empties, it does not remove.
pic_checkcounts on rows staying: entries are numbered without gaps, every finished tool call keeps one result, a delivered message's text equals its entry's, and other processes (pic attach, the phone) keep entry numbers as cursors, which a removed row would let SQLite hand out again. So a purge keeps every row and blanks the text: the prompt, entry bodies and provider content (an assistant entry keeps one empty stub per tool call), tool input and output, bash messages, hook context, verify output, error text, the file history's paths and the hashes that keep stored bytes, attachments, settled inbox commands, and the conversation's name, system prompt and tools. Usage and cost stay, sopic usagestill adds up. Freed pages are overwritten (secure_deletefor the purge);pic prunethen drops image and file bytes nothing names. - Forks share entries. A fork's path runs through the entries of the conversation it came from, so a purge empties only the requests of purged conversations that no other conversation's path (listed, or deleted and still restorable) reaches. The rest stay whole until that conversation is purged too; each later purge looks again.
- Never under a running pic. A purge takes each conversation's lease without waiting and skips
one that is held or has an unfinished request; it runs with the hourly retention in
pic_open(for those deleted 30 or more days ago) and frompic sessions empty-trash(all of them).
The phone
delete_session and restore_session are pic's own commands in a command envelope (the
protocol note's amendments); pic remote runs them on the narrow open, and the next sessions
list leaves the conversation out or has it again.
Not done
- Exports made before (
pic export,~/.pic/pic.sqlite's Pi lines, ctx's archive) keep their copies; the manual says so. - Pi's
app.session.deletebinding (Ctrl+D) stays accepted with no view: Ctrl+D quits on an empty editor, and the picker's keys ared, Delete and Backspace.