jianxunzhang1101/recover-codex-images
À propos
Recover images Codex generated but failed to save or display.
Design et médiasProgression mesurée des étoiles
- in 24h
- 0
- in 7 days
- +1
- in 15 days
- +1
- in 1 month
- +1
Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.
README.md
OriginalRecover Codex Images
Codex image generation not working? Image generated but not showing, not saved, or rendering as a blank image? This Skill recovers the image that Codex already generated — directly from your local task records. No regeneration, no API calls, fully offline.
recover-codex-images is a local compatibility workaround for a known Codex bug (#32153, previously #28422): the generated image arrives on your machine as complete, valid base64 data inside the task JSONL, but Codex never writes it to ~/.codex/generated_images, never sets a saved_path, and the UI shows nothing or a blank/broken image box.
Symptoms
You likely have this bug if any of these is true:
- Codex says the image was generated, but no image is shown in the conversation
- Codex Desktop shows a blank or broken image placeholder
~/.codex/generated_imageshas no new file after a generation- The task JSONL contains
image_generation_callwith a huge base64result, butstatusis stuck at"generating"and there is nosaved_path - Image editing / regeneration requests appear to succeed but nothing is displayed
Affected versions observed: Codex CLI 0.144.x, Codex Desktop 26.707.x (macOS and Windows reports). The image is not lost — it is sitting in your local session records.
Quick Install (macOS / Linux)
curl -fsSL https://raw.githubusercontent.com/jianxunzhang1101/recover-codex-images/main/install.sh | bash
The same command also upgrades an existing installation. Then open a new Codex task (or restart Codex Desktop).
Or install from inside Codex:
Use $skill-installer to install this Skill:
https://github.com/jianxunzhang1101/recover-codex-images/tree/main/skills/recover-codex-images
Manual install (incl. Windows PowerShell)
git clone https://github.com/jianxunzhang1101/recover-codex-images.git
mkdir -p ~/.codex/skills
cp -R recover-codex-images/skills/recover-codex-images ~/.codex/skills/
chmod +x ~/.codex/skills/recover-codex-images/scripts/recover_last_generated_image.py
git clone https://github.com/jianxunzhang1101/recover-codex-images.git
New-Item -ItemType Directory -Force "$HOME\.codex\skills" | Out-Null
Copy-Item -Recurse -Force ".\recover-codex-images\skills\recover-codex-images" "$HOME\.codex\skills\"
To upgrade an existing Windows checkout after a fix is published:
git -C ".\recover-codex-images" pull --ff-only
$source = Resolve-Path ".\recover-codex-images\skills\recover-codex-images"
$dest = Join-Path $HOME ".codex\skills\recover-codex-images"
New-Item -ItemType Directory -Force $dest | Out-Null
Copy-Item -Recurse -Force "$source\*" $dest
Use
Just ask Codex to generate or edit an image, as usual:
Generate a photorealistic lighthouse at sunrise.
The Skill is designed for implicit use with every image generation or editing request: after the image tool returns, it recovers the new image from the task JSONL, verifies it, saves it to ~/.codex/generated_images/, and displays it with a local path.
Explicit invocation is more deterministic:
Use $recover-codex-images after generating the image.
You can also recover the last generated image at any time — including images generated before installing this Skill:
python3 ~/.codex/skills/recover-codex-images/scripts/recover_last_generated_image.py --json
Windows: recover from an explicit large task record
Passing the exact JSONL avoids session-directory discovery. --verbose writes progress to stderr while stdout remains valid JSON:
python "$HOME\.codex\skills\recover-codex-images\scripts\recover_last_generated_image.py" `
--session "C:\full\path\rollout-task.jsonl" `
--wait-seconds 10 `
--verbose `
--json
The scanner filters raw lines before JSON parsing, validates only the newest usable result, and remembers its byte offset while waiting so unchanged multi-megabyte records are not parsed repeatedly.
See docs/troubleshooting.md for a full diagnostic guide: how to confirm the image data reached your machine, where Codex stores it, and how to recover it by hand.
What It Does
- Runs recovery immediately after the image tool returns; supports multi-turn edit/regenerate flows
- Recovers only image data already present in the local task JSONL (
image_generation_call/image_generation_end) - Prefers an explicit session or thread ID and uses session-directory discovery only as a fallback
- Filters non-image lines before JSON parsing and reads only newly appended bytes while waiting
- Validates the newest complete result first, avoiding duplicate decoding of matching call/end records
- Supports PNG, JPEG, and WebP; validates base64 and image structure (incl. PNG chunk/CRC) before saving
- Writes atomically, verifies SHA-256 after saving, and deduplicates identical images
- Reuses a valid official
saved_pathwhen Codex provides one — harmless to keep installed after the official fix - Uses a generation-start timestamp so a failed edit can never silently return an older image as the new result
It does not call an image API, regenerate an image, modify the source JSONL, or send anything over the network.
Why This Happens (root cause background)
Codex's persistence logic historically only saved images whose status was "completed", but the server can deliver the full image while status remains "generating" — so the save step is skipped (#28422, fixed in PR #28656). In July 2026 the image-generation pipeline was replaced with an extension-based architecture (#31596, #31597, #29711), and the same symptom returned (#32153). This Skill works regardless of which side of the handoff fails, because it reads the data that already reached your disk.
FAQ
Is my image lost? Almost certainly not. If Codex said generation succeeded, the base64 data is in ~/.codex/sessions/.../rollout-*.jsonl. This Skill (or the one-liner above) extracts it.
Does this regenerate the image / cost tokens? No. It is read-only recovery of data already on your machine.
Will it conflict with the official fix? No. When Codex starts writing saved_path again, the Skill detects and reuses it.
Does implicit triggering always work? No — Skill selection is model-driven. Explicit $recover-codex-images is 100% reliable; the direct script call works even outside Codex.
Privacy And Safety
The script reads local Codex task JSONL files and writes recovered images locally. Review the script before installation, especially on shared machines. Do not publish your own ~/.codex/sessions, databases, logs, account files, or generated images when contributing diagnostics.
Development
Python standard library only.
python3 -m unittest discover -s tests -v
License
MIT
Explorer des projets similaires
Chargement…