Windows app: pasted clipboard images spin forever in history after Temp files are deleted
What version of the Codex App are you using (From “About Codex” dialog)?
26.707.8168.0
What subscription do you have?
Paid ChatGPT subscription (exact tier not included in this report).
What platform is your computer?
Microsoft Windows NT 10.0.26200.8655 x64 (Windows 11 25H2)
What issue are you seeing?
Images pasted from the Windows clipboard are processed successfully when the message is sent, but older images in the same Codex Desktop thread later display an infinite loading spinner.
A local inspection of the affected rollout JSONL shows two representations of each pasted image:
- The
response_itemmessage contains an embeddedinput_imagewith a completedata:image/png;base64,...URL. - The corresponding
event_msg.user_messagecontains only alocal_imagesentry pointing to:C:\Users\<user>\AppData\Local\Temp\codex-clipboard-<uuid>.png
In the affected thread:
- 17 unique clipboard images were sent.
- All 17 have embedded
data:imagecontent in the rollout JSONL. - 16 of the 17 referenced
codex-clipboard-*.pngTemp files no longer exist. - The only image whose Temp file still exists is the newest image.
- The missing historical images show an infinite spinner in the UI.
- The model successfully processed the images at send time, so this is not an upload or inference failure.
This strongly suggests that the history renderer uses event_msg.payload.local_images paths and does not fall back to the already persisted embedded image data when the temporary clipboard files have been cleaned up.
No API gateway, account, or inference error is involved.
What steps can reproduce the bug?
- Open the Codex Windows desktop app.
- Paste a screenshot from the clipboard into a thread.
- Send the message and confirm that Codex can process the image.
- Repeat with several screenshots.
- Restart Codex and/or allow the Windows Temp directory to be cleaned.
- Reopen the thread and scroll to the older pasted screenshots.
- Observe that the image placeholders spin indefinitely when their
codex-clipboard-*.pngfiles no longer exist.
Diagnostic confirmation:
- Inspect the rollout JSONL under
~/.codex/sessions/. - The message has embedded
input_imageBase64 data, but the UI-facing event retains a path under%LOCALAPPDATA%\Temp. - Delete or lose that Temp file, then reopen the thread.
What is the expected behavior?
Pasted image attachments should remain visible in thread history after restarting the app or after Windows cleans the Temp directory.
The app should either:
- copy clipboard images to durable app storage before persisting the message,
- render from the embedded image data already stored in the rollout, or
- show a clear missing-attachment error instead of an infinite spinner.
Additional information
The image data appears recoverable from the rollout JSONL, so the underlying content has not been lost. The failure is in attachment persistence/history rendering.
The affected paths and thread identifiers have been redacted. A screenshot of the spinner and additional redacted diagnostics can be provided if needed.
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
- #31590
Powered by Codex Action
A durable-storage design can prevent clipboard images from becoming unrecoverable after temporary files disappear:
- validate and decode bounded PNG/JPEG/WebP inputs before accepting the send;
- atomically copy the image into app-managed durable storage before committing the UI event;
- retain lightweight attachment metadata and provenance in history rather than duplicating large base64 payloads;
- preserve that metadata across thread refreshes;
- reject invalid or oversized images explicitly;
- apply a bounded retention policy.
A useful authoritative attachment record could contain:
attachment_id
mime_type
content_hash
durable_blob_or_path
embedded_fallback
source = clipboard
persistence_state
Suggested recovery/render order:
- durable app-managed blob/path;
- already-persisted embedded
input_imagedata; - typed
attachment_missingcard with repair/export action — never an infinite spinner.
For existing affected rollouts, a migration/recovery pass could rebuild missing durable attachments from embedded response_item.input_image data and rewrite the event reference. This is an architectural suggestion, not a claim about the upstream app’s current implementation.
Independent reproduction on a different Windows 11 machine, plus a few details that I think narrow the fix down.
Still reproduces at HEAD, and it is the steady state rather than an edge case
-
Desktop app
26.818.5345.0, Windows 11 26200. -
Latest affected message: 2026-08-12,
cli_version 0.147.0-alpha.6.6,originator: "Codex Desktop"— the event still recordslocal_images: ["C:\Users\<user>\AppData\Local\Temp\codex-clipboard-<uuid>.png"]withimages: []. -
Scanned the whole local store (424 rollouts under
~/.codex/sessions+archived_sessions, spanning 2026-06-10 → 2026-08-12):sessions containing images 32 local_imagesrefs total50 refs under %TEMP%50 / 50 refs still resolvable on disk 0 / 50 input_imagebase64 copies in the same rollouts196 affected sessions recoverable from base64 18 / 18 (100%) So every pasted image older than the temp-cleanup window is broken, not just the ones in one long thread. On Windows 11 this is default-on behavior, not something the user did: Storage Sense ships enabled with "delete temporary files that my apps aren't using" (
HKCU\...\StorageSense\Parameters\StoragePolicy,01=1,04=1), so%TEMP%is swept automatically.
Root cause is one function, and it is unchanged on main
ThreadHistoryBuilder::build_user_inputs maps the persisted event straight through with no existence check and no fallback:
https://github.com/openai/codex/blob/fb0781b9eee6d2da741b984bed9dde95834d909d/codex-rs/app-server-protocol/src/protocol/thread_history.rs#L1502-L1507
for (idx, path) in payload.local_images.iter().enumerate() {
content.push(UserInput::LocalImage {
path: path.clone(),
detail: payload.local_image_details.get(idx).copied().flatten(),
});
}
Verified present at main @ fb0781b (2026-08-24, after rust-v0.149.1). The model-facing path does degrade gracefully — Prompt::from_user_input falls back to local_media_error_placeholder when std::fs::read fails (codex-rs/protocol/src/models.rs) — but the UI-facing path has no equivalent, which is why the result is an infinite spinner instead of an error card.
Also worth noting: nothing under codex-rs/ ever copies an image into CODEX_HOME. The TUI writes clipboard images to the system temp dir via tempfile() (codex-rs/tui/src/clipboard_paste.rs, prefix codex-clipboard-), and the desktop frontend writes a UUID-named file to the same place. The durable copy is a design gap on the write side, not a cleanup race.
The durable attachment store already exists — it is just text-only
~/.codex/attachments/ is already used today, but only for pasted text:
~/.codex/attachments/<uuid>/pasted-text.txt
~/.codex/attachments/pasted-text-attachments.json # index with excerpts + pendingRemovalPaths
Pasted images could reuse exactly this directory and lifecycle instead of %TEMP%, which makes the "copy to durable app storage" option in the original report considerably cheaper than it looks — no new storage mechanism, retention policy, or migration surface is needed.
There is already a precedent for the render-side half, in the same function
#34385 ("Preserve audio across history and tool outputs", 6f78563, 2026-07-20) added exactly this kind of preservation for audio in thread_history.rs, including local audio in legacy user-message events. Images never got the same treatment. Making LocalImage fall back to the already-persisted response_item input_image data URL when the path is gone would bring images to parity and would fix existing rollouts, not just new ones.
Existing data is fully recoverable
Because the base64 copy is always present in the response_item, a migration pass can rebuild every missing attachment with no data loss — 196/196 images in my store, covering 18/18 affected sessions. I extracted them all with a ~40-line script that walks the rollouts and decodes payload.content[].image_url; happy to attach it if useful.
Possibly relevant to triage
#31590 ("Codex app stores pasted image file paths instead of copying bytes") was closed as completed on 2026-08-09, but the 2026-08-12 messages above still recorded a %TEMP% path in local_images. Whatever landed there does not appear to cover the desktop paste path or the history-rendering half tracked here.
Additional evidence: Windows PC migration and recovery of 585 historical images
After migrating my Codex environment from an old Windows 11 PC to a new Windows 11 PC, conversation text remained available, but historical uploaded images displayed an indefinite spinner. This appears closely related to this issue.
Observed evidence
- Rollout JSONL retained input_image.image_url payloads beginning with data:image/...;base64,... . Direct decoding produced viewable images.
- Projected user messages referenced localImage.path under %LOCALAPPDATA%\Temp\codex-clipboard-{UUID}.{ext}; those files were missing.
- Migrating a test thread from legacy to paginated history did not resolve its spinner.
- Restoring one missing image from the matched rollout payload to its exact referenced Temp path immediately restored its display.
- Batch recovery restored 585 missing files. After restarting Codex Desktop, historical images appeared normally. This was a user-observed UI check, not an automated visual assertion for every file.
Final precise scan and actual recovery
| Metric | Final scan | Recovery |
|---|---|---|
| Rollout files scanned | 147 | 147 |
| Canonical user message records | 3,030 | — |
| Valid path/image pairs | 692 | 692 |
| Unique target images | 586 | 586 |
| Missing / restored | 585 missing | 585 restored |
| Existing files | 1 | 1 |
| Base64 decode errors | 0 | 0 |
| JSON parse errors | 0 | — |
| Hash conflicts | 0 | — |
| Write errors | — | 0 |
| Restore size / written | 101.57 MiB | 101.57 MiB |
The final method inspected only response_item records with payload.type=message and payload.role=user, pairing an input_text containing exactly one clipboard filename occurrence with the immediately following input_image. Targets were deduplicated by filename and checked for conflicting payload hashes. Counts cover this matched subset, not every possible attachment.
Reproduction / diagnostic sequence
The migration was observed; this isolated sequence is proposed for engineering verification:
- Paste and send a non-sensitive test image in a disposable Windows 11 Codex environment. Verify rendering and preserved inline rollout data.
- Close the app and migrate local Codex session/history data to another Windows environment without the source Temp cache.
- Open the migrated thread. Expected: the recoverable historical image renders. Observed here: an indefinite spinner.
- Check the projected localImage.path and decode its correctly matched rollout payload.
- Restore only that test image at the exact referenced path and refresh the view. The single-file test in this incident immediately restored display.
- Check legacy and paginated history separately; changing history mode alone did not repair the observed missing-image condition.
Relevant structure: %USERPROFILE%.codex\sessions...\rollout-*.jsonl; response_item -> payload(type=message, role=user) -> content[] -> input_image.image_url. Projected reference: localImage.path = %LOCALAPPDATA%\Temp\codex-clipboard-{UUID}.{ext}.
Interpretation and limits
The single-file before/after test strongly supports a missing local-file dependency in the affected history-rendering path despite recoverable inline data. It does not establish the exact responsible component or behavior of every rendering path. This is one local migration/recovery, not an independently repeated clean-install reproduction. Exact incident-time Desktop, bundled Codex, and Windows build numbers were not captured in the supplied evidence. Versions from other reports should not be attributed to this incident.
Requested follow-up
Please support automatic rendering or re-materialization from the correctly associated durable inline image when localImage.path is missing, using app-managed storage and updating references as needed. Separate durable user data from reconstructable cache. If recovery is impossible, show a clear missing-attachment state rather than an indefinite spinner.
Please also consider an official Backup / Migration / Restore workflow with completeness checks, path remapping, compatible history migration, and a readable recovery summary. Codex accumulates long-term project context, conversations, and visual references. Requiring ordinary users to analyze .codex, rollout JSONL, SQLite, history modes, and Temp caches to migrate or recover that environment is not realistic.
Please advise whether an existing fix repairs historical attachments as well as newly pasted images. Usernames, actual user-specific paths, private thread IDs, and original image content have been omitted; no raw rollouts or databases are attached.
Adding Linux evidence for the same class of historical clipboard-image failure.
Environment: Arch Linux (x86_64), Codex desktop package 26.915.31029, checked on 2026-09-20.
A local audit of 841 session JSONL files, including archived sessions, found 47 unique clipboard-image paths whose files no longer exist, referenced by 35 regular tasks (excluding internal agent tasks). These counts are deduplicated by file path, rather than counting inherited copies of messages separately.
The missing paths were distributed as follows:
- 40 under
/tmp/codex-clipboard-* - 6 under
~/.local/state/codex-desktop/tmp/codex-clipboard-* - 1 under
/run/user/<uid>/codex-desktop/tmp/codex-clipboard-*
The missing files were checked outside the sandbox to rule out namespace visibility as the explanation. On this machine, /tmp is a tmpfs, so files there cannot survive a reboot. The other temporary directories were also gone, but I have not established the deletion mechanism for every file.
The image data is still recoverable: all 47 missing clipboard files had corresponding embedded input_image.image_url data URLs in raw user response_item records. All 47 successfully passed base64 decoding and actual image decoding. Meanwhile, the history attachment references still pointed to the missing local files. This was a filesystem/session-data audit; I did not manually reopen every affected task in the UI.
The installed desktop bundle's persistImageFileToTemp implementation constructs clipboard filenames using os.tmpdir() plus codex-clipboard-${randomUUID()}, then writes the image there. This makes the temporary-file lifetime relevant on Linux too.
Workaround verified for a new paste: after redirecting the app's TMPDIR to a persistent directory under ~/.local/share/chatgpt/persistent-tmp/, a newly pasted screenshot was written there. Both the message's image path and the completed user-message attachment reference used that persistent path. The directory is on the persistent filesystem. This verifies path redirection for a new attachment; it is not an end-to-end reboot test and does not repair existing history.
This appears broader than Windows. A durable attachment store, plus recovery from the already-embedded image data for older sessions, would address the Linux case as well.
macOS reproduction of the same history failure (Codex Desktop 26.1007.41230, build 20324):
- Clipboard images were processed on send.
- After reopening history, thumbnails stayed in the loading state. Desktop logs showed
Failed to inline local imagewithENOENTfor paths of the form/var/folders/.../T/codex-clipboard-<uuid>.png. - The affected images were recoverable from their corresponding rollout
response_itemimage payloads; restoring the missing temp-path files made the thumbnails render. This points to history image projection/rendering, not upload or inference.
The installed macOS bundle's clipboard writer saves to os.tmpdir() using codex-clipboard-<uuid>. In the legacy history projection, UserMessageEvent.local_images becomes UserInput::LocalImage without falling back to the embedded data:image/... payload in the matching user ResponseItem. I verified a fallback keyed by the image path tag; the codex-app-server-protocol suite passed (317 passed, 1 ignored), with regression coverage for mixed remote and two clipboard images.
This confirms the same temp-path/history-rendering failure on macOS.
@74726 Your report says the original picture content is still in the conversation, even though the temporary clipboard files are gone. Context Attachment Manager builds its image list from that local conversation history, so its separate thumbnail and preview panel may be useful here. I'm the author.
It's free and open source, now v0.9.1 with 560 GitHub Stars. People facing similar image-history problems are using it and sharing feedback. You can browse earlier pictures, zoom previews, search by remembered visual details, and choose which references stay selected.
After installing and restarting Codex, automatic selection is on by default: the assistant retrieves original pictures when needed, including after compaction, instead of carrying every old picture into each turn. Original quality and conversation records are preserved. Management stays on your machine; the plugin doesn't separately collect or upload your pictures or chats.
https://github.com/chipfighter/context-attachment-manager The page includes setup steps. Once you're comfortable with the plugin, you can ask Codex or Claude Code to install it for you. It supports Codex Desktop and the local Code tab in Claude Desktop.
If you try it on that conversation, I'd be interested to hear whether you can browse those earlier screenshots through the panel.
I reproduced this on macOS 14.6.1 with Codex Desktop 26.1029.61003. Clipboard images were visible when sent, but older messages later showed failed thumbnails. The desktop log reported Failed to inline local image with ENOENT for the corresponding codex-clipboard-*.png paths in the macOS temporary directory.
Across the local checks, I restored 645 distinct missing clipboard-image paths from the embedded image data in their corresponding session records. This included 520 paths whose image data was found in compressed .jsonl.zst session files. I matched the image data to the original path recorded in the message, restored the missing files, and verified all 645 restored files against the recovered data by SHA-256. I confirmed that a representative image rendered again in its original message after the restore. The 645 figure counts verified file restorations.
Could the Codex team confirm the intended fix for existing conversations, as well as for new attachments? In particular, when an old message references a missing temporary file but its session still contains the embedded image data, will Codex recover the image automatically after an update, including for compressed sessions? If recovery requires a migration or repair command, what is the supported process?
Additional macOS evidence, verified locally on 2026-11-20: the historical-image failure remains present in desktop version 26.1111.71025 (build 28661).
Environment
- macOS 26.5.1, Apple Silicon / arm64.
- Local Codex conversations in the macOS desktop app (installed bundle name: ChatGPT.app).
- Bundled executable reports
codex-cli 0.169.0-alpha.11.1. - App version/build were read from the installed bundle metadata.
Observed behavior and read-only findings
When revisiting older conversations, image attachments display red-bordered “失败” (“Failed”) placeholders. A newly attached image remains readable.
Inspection of persisted userMessage items in ~/.codex/thread_history_1.sqlite found:
| Measurement | Result |
|---|---|
| Local image references inspected | 824 |
| References whose source files no longer exist | 798 |
| Distinct missing source paths | 788 |
| Conversations containing missing references | 121 |
Missing references to codex-clipboard-*.png/jpg temporary files |
666 |
The other missing references include third-party temporary image paths. Reading a representative missing clipboard-image path returned ENOENT / No such file or directory. The persisted UI item still contains { "type": "localImage", "path": "<original temporary path>" }.
For one representative conversation, all 12 missing image references could be matched by their explicit image path tags to embedded response_item / input_image data URLs in its rollout JSONL. All 12 passed strict Base64 decoding, PNG chunk CRC checks, and IDAT decompression in memory. Thus, at least this sample's image content is still intact despite the failed history previews.
Read-only inspection of the installed desktop bundle also found persistImageFileToTemp() writing clipboard images under os.tmpdir(), and the local-conversation renderer's codex.localConversation.userImageAttachmentFailedShort state corresponding to the visible failure cards.
Limits of this verification
- This establishes missing source files and recoverable embedded content for the sample; it does not establish which process removed the files or when.
- No controlled deletion/restart experiment was performed.
- No conversation database or image file was modified/restored, so this report does not claim a successful UI recovery test.
- The 798 figure counts references, not unique images. Full recovery validation was limited to the 12-image sample.
Could the team investigate durable storage for newly sent image attachments and a supported recovery/fallback path for existing localImage.path references when embedded image content still exists in the corresponding session? An explicit “Failed” card avoids the earlier endless spinner, but the user still cannot view retained images.
Only aggregate diagnostics are included here; original images, conversation text/titles/IDs, account details, and identifying local paths are omitted.