Compact inflated AI session transcripts#48
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.
Summary
This PR fixes the root cause of inflated AI session transcripts in
.neverwrite/sessions/*/transcript.jsonl.NeverWrite already used
session-meta.jsonandindex.jsonas the logical source of truth, but the physical JSONL transcript could keep accumulating obsolete versions of updatedtool/statusmessages. Long ACP sessions, especially Codex sessions with many tool/status updates, could therefore leave hundreds of MB of duplicated transcript rows even when the indexed conversation was much smaller.Changes
crates/ai/src/persistence.rsfor all AI runtimes, not just Codex.transcript.jsonlfiles using only the messages currently referenced byindex.json.compact-state.jsonso interrupted compactions can be rolled back safely on the next load/save.Impact
The user-visible chat history is preserved. This only removes obsolete physical JSONL rows that represented intermediate versions of messages already superseded by the transcript index.
This should reduce disk growth, I/O, memory pressure, and crash/freeze risk from long AI conversations while keeping restore/history behavior unchanged.
Validation
cargo test -p neverwrite-aicargo build -p neverwrite-native-backendgit diff --check