Skip to content

feat(agent): delete chats softly and take deletes from the phone - #277

Open
geoolekom wants to merge 1 commit into
phone-chats-into-recordsfrom
soft-chat-delete
Open

geoolekom wants to merge 1 commit into
phone-chats-into-recordsfrom
soft-chat-delete

Conversation

@geoolekom

@geoolekom geoolekom commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #271 (phone-chats-into-records); the base moves to main when that one merges.

What changed

A chat deleted on the computer is no longer erased. It keeps its records and gets a mark that says it was deleted, and when.

  • Computer. chat-delete <id> and chat-delete all mark the chat deleted instead of removing it. The chat drops out of chat-list, and chat-get and chat-send answer "unknown conversation" for it. chat-delete counts only the chats it newly marked, so a second delete answers 0.
  • Phone, reading. sync-chats gives a deleted chat as an item with deleted: true and deleted_at, an empty title, a count of 0 and no turns. The chats token changes on a delete, so the phone copies the list again.
  • Phone, deleting. The new sync-delete-chat command ({"cmd", "id", "time"}) marks the chat the same way, with the time the phone gives. The first time stays if the chat was deleted already. A delete of a chat the computer does not have writes a mark with nothing else, so what the phone sends of it later is refused. It answers invalid sync request for a request of another shape, invalid chat for a bad id, erasing during "Delete everything", and busy while an answer runs in that chat. The delete takes the same guard as "Delete everything" and checks for an erasure once it holds it, so a delete cannot write a mark after an erasure has begun, the same way a push cannot write records then.
  • Never back. A push for a deleted chat adds nothing and answers deleted: true, with no fork. The same goes for a push whose fork was deleted. A resent push cannot bring the chat back.
  • Format. The sync FORMAT goes from 2 to 3 (deleted and deleted_at on a chat, sync-delete-chat, deleted on a push answer when it is true).

The mark is one hidden chat_deleted call with its noted result in the chat's own record file, the same way the chat origin and the other markers are kept. It is hidden from a model and from the earlier-conversation hand-off, like the other markers.

Delete everything

"Delete everything" still removes every chat, its records and its mark. The mark lives in the chat's own record file, so removing the files removes the mark too; there is no second store and agent/src/erase.rs needs no change. A test deletes chats from both sides, runs the erase and scans the data folder: no chat, no mark, no read position, no record text is left.

Time tracker and fact learning

I chose to keep what was already counted or learned, and to refuse new records for a deleted chat, so nothing is counted or learned twice.

  • The records stay, so nothing already counted or learned is lost. The Time tracker never counted app-chat records: the activity store leaves out records of the chat source. The delete mark therefore changes nothing there.
  • A deleted chat takes no new records: a push adds none and chat-send is refused. Nothing new reaches the recorder or the fact observer, and a resent push cannot make them hear the same turn again.
  • The observer only hears first-time user turns, so what it learned before the delete is not asked again. The mark is told to the recorder as a hidden call and result, which no activity counts.

I did not pick the other way (erase the records on delete and subtract what was counted). It would lose what the person did and learned, and it would need a second list of what to take back.

What ran

  • cargo test --locked --workspace --no-fail-fast: 1404 passed, 1 failed: the timing test named below, which passes alone.
  • cargo clippy --all-targets --locked -- -D warnings (whole workspace): clean.
  • cargo fmt --check and pre-commit run --all-files: clean.

On a busy machine, a_backoff_is_not_cut_short_by_a_new_prompt (agent/tests/manage.rs) can fail once in a while: it checks with fixed sleeps that no call goes out in 400 ms of an 800 ms pause, and a starved test thread can overshoot that. This change does not touch that code (only a doc comment in the same crate), and it passes on a rerun.

New tests show that:

  • a chat deleted on the computer is gone from chat-list and marked deleted in sync-chats;
  • a chat deleted from the test phone does the same, and the first delete time stays;
  • the chats token changes on a delete;
  • sending a deleted chat's turns again (after either kind of delete) does not bring it back, makes no fork and adds no record;
  • a chat the computer does not have is marked, and what the phone sends of it is refused;
  • bad deletes are refused and mark nothing, and a delete that meets an erasure, one running or one that began after the command started, is refused with erasing and marks nothing;
  • a deleted chat is not learned from or recorded again, and what was learned stays;
  • "Delete everything" leaves no chat, no mark and no record.

@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e1f8c705-9da0-4886-a368-6922522cbc2c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Signed-off-by: Yehor Komarov <10210242+geoolekom@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant