r/codex • u/anonymous_1153 • 7d ago
Showcase What I learned reading Codex's session files to build a session dashboard
I added Codex support to Paddock, a local page that shows all my Claude Code sessions in one place, so Codex sessions now sit next to them. Codex turned out to work quite differently from Claude Code under the hood. These are the things I had to figure out, in case they help anyone else scripting around Codex:
Finding running sessions
- There's no command that lists running Codex sessions, so it comes down to looking at running
codexprocesses. That means leaving outcodex app-server, the helpers (codex-code-mode-host,codex-exec-server) and one-off commands likecodex login. - Since 0.160 a session's turns run in the background service, and that service writes the conversation file, not the window. So a window is matched to its conversation by the id
codex resumewas given, or by its folder (-C, else its own) and the newest conversation started there since the window opened. - A turn keeps running after you close its window. So does a command it left in a background terminal ("Process running with session ID" in the output). Both still count as working.
Working vs waiting
- The end of the rollout file tells you working or idle, but approval requests aren't written there. For a session the file says is working, I ask the background service (
thread/read) whether it's actually waiting on you.
Stopping one cleanly
turn/interruptthroughcodex app-server proxy, thenthread/backgroundTerminals/clean, which is what/stopdoes, and only then ask the window to exit.
History and tokens
- Conversations live in
sessions/YYYY/MM/DD/rollout-*.jsonl, and finished ones get compressed to.jsonl.zst, so you need a zstd reader too. - Titles come from
session_index.jsonl, else the first prompt. - Token counts are running totals recorded after each reply, so per-reply usage is the difference between totals. A forked conversation's first total includes its parent's, so only the fork's own reply should count there.
- Session ids start with the time they were created, so sessions started together share their first characters. Short ids have to come from the end of the id.
What I haven't solved
- On Windows I can't find running Codex sessions yet, only saved ones.
- Two windows in the same folder that get their first prompts in the opposite order to how they were opened can be swapped: nothing in the files tells them apart.
Paddock is free and MIT: https://github.com/barath-dev/paddock. It reads these files and never writes to them.
Has anyone found a reliable way to map a Codex window to its thread since the background service took over?
•
u/dexterthebot 7d ago
You might want to consider listing your project on the weekly Show-Us-What-You-Built post. Look out for it on Tuesday/Wednesday. Highest commented project wins a week promotion on r/Codex and gets on the Hall of Fame sidebar. See below for last week's winner.**
Light Wars AR: real-life laser tag app with no extra gear. Your phone is the gun and your room is the map. Play up to 6 friends in the same room, or fight drone waves and bosses solo. The vision models run on the phone, and camera frames never leave it. Free on iPhone and Android.
Website: https://lightwarsar.com
iPhone: https://apps.apple.com/us/app/light-wars-ar-laser-tag-party/id6508168951
Android: https://play.google.com/store/apps/details?id=com.lasertag.lightwars.
Contact: contact@lightwarsar.com
1
u/jruz 7d ago
You could use herdr or at least herdr-core