Repository navigation
A chat's visuals and sent images live as long as the chat - #30413
Conversation
A chat's scratch folder was deleted once the chat had gone 30 days unused, so an old chat's inline visuals turned into "Visualization unavailable" while the chat and its history stayed. The common pattern keeps a chat's files for as long as the chat and never deletes them on an "unused for N days" timer. The sweep now removes only folders no chat record maps to, plus leftover .expired folders older builds parked. Everything that existed only to make the age rule safe goes with it: the per-folder save lock and its expiry candidates, the session-lane idle check, the journal last-activity query, and the migration's fresh-window timestamp. The visuals skill no longer tells agents the folder is temporary.
…chat A local chat's pasted images lived in one paste folder that deleted every file older than 30 days, sent or not, so an old chat's images turned into label chips. Paired-server chats already keep pastes in the host's attachment store, where the send that names a file claims it for its chat and only unclaimed files are ever swept: the common pattern. A local composer paste now goes into this machine's own attachment store (starting the local chat host first), so its send claims it the same way. The old paste folder is no longer written or swept: messages sent before this change may name its files. Restored drafts still read it. An unclaimed upload now waits 30 days instead of one before the sweep takes it. A draft names its image by this path, so the window is how long an unsent draft keeps its image; 30 days is what local drafts had, and it outlasts the host's send-id window so a resent draft still finds its image. A chat folder an older build set aside as unused (<hash>.expired) goes back to its chat instead of being deleted.
A terminal-backed chat has no journal, so no send claims its pastes and nothing can tell a sent one from an abandoned one. Its pastes therefore stay in the paste folder, which is no longer swept, rather than in the attachment store, whose sweep would take them after 30 days unclaimed. Only a local structured chat's paste (forStructuredChat) goes to the store, where its send claims it.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🔵 Low · up to
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 Minor · Reject stale scratch selectors before file mutations. · native-chat-visuals-sweep.ts:79-83
src/main/native-chat/native-chat-visuals-sweep.ts:79-83
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick winReject stale scratch selectors before file mutations.
A stale
path:<scratch-folder>selector can passresolveChatScratchSelectorFolderafter its chat row is gone. The sweep can then remove the folder beforefiles.writereaches the provider. Since the local provider does not recreate the parent directory, the write can fail.The sweep should keep removing unheld folders. Validate that the scratch selector still maps to a held chat before accepting the mutation target.
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
b6146e64-021a-49d9-bf3f-7d0db1eec0c4
📒 Files selected for processing: 2
src/renderer/src/components/tab-bar/TabSessionSurfaceSwitchMenuItems.test.tsxsrc/shared/agent-session-attachments.ts
🚧 Files skipped from review as they are similar to previous changes: 1
- src/shared/agent-session-attachments.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
A draft checks its pasted images once, when its composer comes back. Every chat in an open workspace mounts its composer at launch, so that check ran before the store sweep (60 s after host start, then every 6 h) deleted an expired unsent upload, and nothing checked again: the chip lost its picture with no Not kept feedback and Send stayed enabled. The sweep now reports each removal attempt; the main process forwards it to its window, and the draft store starts a fresh finite check for every loaded local draft image in that folder, mounted or not. A notice is a reason to check, never proof of absence.
…es-live-with-chat # Conflicts: # src/main/ipc/filesystem/filesystem-write-handlers.ts # src/main/runtime/files/file-mutations.ts
startNativeChatDraftLoad dropped the unsubscribe for the upload-removal listener, so each recovery through the root error boundary's Retry remounted App and added another listener. Return it so the effect's cleanup removes it.
|
An old chat could retain its messages while cleanup deleted the sent pasted images and inline charts those messages needed. Files now stay while their chat owns them. Cleanup still removes known abandoned uploads and folders whose chat is gone; uncertain filesystem reads preserve files and ownership. The full loop completed three source rounds and resumed round 4 on the final correction and main-merge resolutions. Review fixes preserve claims after failed reads, recover folders set aside by older cleanup before first use, and give each restored image its own finite check. Real Electron QA found an expired unsent image could disappear after its startup check while Send remained enabled. Host removal notices now trigger a fresh check, including drafts not on screen, so the image shows Not kept and Send is disabled. Readiness also caught a listener retained after an app Retry; the final cleanup returns its unsubscribe to the app mount effect, and independent narrow review verified it. No confirmed finding remains open. Deferred: ownership-selector cost in unusually large workspaces has not been measured; no failing input or observed slowdown was established. The final correction adds no setting, saved field, remote operation, or retention policy. Verified through Real Electron QA used admitted machines, isolated profiles, and real Codex. The earlier main comparison reproduced lost sent images/charts. The Limits: the earlier shared-machine comparison recorded an unattributed configuration-hash change. A Windows attempt stopped when Codex hooks failed in its isolated profile; no PR attribution was established, and it is not passing Windows evidence. Paired servers, SSH, mixed versions, terminal-backed retention, and other operating systems were not validated in rendered QA. The exact Retry-remount cleanup has source proof; the final runtime check used startup and renderer reload. For Brennan's review Main after aging a chat's files 31 days:
PR image and chart retention (
Final head: the same open draft before and after cleanup:
Final head: the sent image survives, and the expired draft's feedback survives reload:
Recovered chart (
Three deliberate boundaries:
|







ELI5
When you open a native chat you haven't used for a month, its charts and diagrams show "Visualization unavailable", and in a local chat the images you pasted and sent show as a grey label instead of the picture. The chat and its history are still there; only its files were deleted, by two 30-day timers. This PR keeps a chat's own files for as long as the chat exists, which is the common pattern. Only files no chat owns are still cleaned up: pastes that were never sent, and leftovers whose chat is gone.
What Changed
Before
<state>/chat-scratch/<hash>) was deleted once the chat had gone 30 days without a new message or file change. Old chats then showed "Visualization unavailable".<userData>/native-chat-pastes) that deleted every image older than 30 days at startup, including images already sent and still shown in the transcript.After
<hash>.expired) is put back for its chat.What the mechanism is now
Hosts
Why
Linked Issue
N/A (maintainer PR; Brennan asked for it directly).
Visual Proof
Real Electron app, files aged 31 days on disk, then the app restarted.
Before (main): the sent image is a grey label and the chart says "Visualization unavailable".

After (this PR): the same kind of chat keeps its sent image and its chart.

Unsent draft whose image the cleanup removes while the chat is open: before the cleanup it still shows the picture; after it, without touching the chat, it shows "Not kept" and Send is disabled.


A chart whose folder an older build had set aside for deletion comes back when the chat opens.

Re-checked on the final head (after a small cleanup fix to the window's listener): the open old draft turns "Not kept" with Send disabled when the cleanup runs, the 31-day-old sent image still shows, and a page reload keeps it that way.




Testing
Named test files run locally (10 files, 103 tests):
Lint and typecheck are left to CI.
Real Electron QA (agent-driven through the app's debugging port, real signed-in Codex, isolated test profiles), with files aged 31 days on disk:
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
Notes
path.joinand the store's existing Windows rename retry. The claim matcher already handles Windows case and separators.Author: @BrennanKB5
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)