Windows desktop launch can be blocked by stale main processes and shared SQLite locks; add safer health diagnostics
Summary
Codex Desktop on Windows can get into a state where a later launch fails or appears to fail because local Codex state is still held by another process. I have repeatedly seen two related patterns:
- a stale/hung Codex desktop main process remains after the window is closed, with no renderer/window attached, and can keep the singleton/startup state blocked;
- a separate Codex
app-server/ extension process can hold shared~/.codexSQLite state (state_5.sqlite,logs_2.sqlite, plus-wal/-shmsidecars), which can then conflict with the desktop app startup path.
This overlaps with existing Windows reports such as:
- https://github.com/openai/codex/issues/21782
- https://github.com/openai/codex/issues/22428
- https://github.com/openai/codex/issues/23814
- https://github.com/openai/codex/issues/24598
I am opening this issue instead of an unsolicited PR because openai/codex currently asks external contributors to start with issue analysis and only submit code when invited.
Why this matters
The first failed launch is often the first domino. A user sees Codex not starting, then tries Store repair/reset/update/reinstall flows. Those Store/AppX operations can hang or make the situation harder to diagnose, while the original blocker may have been a much smaller stale-process or lock-state problem.
A conservative built-in Windows health check could avoid that escalation by showing a clear diagnosis before the user reaches for destructive repair steps.
Reproduction pattern / observed states
The failure mode I have observed is roughly:
- Run Codex Desktop on Windows.
- Close the visible Codex window.
- A Codex main process can remain without a renderer/window, or an extension/app-server process can keep shared Codex SQLite files open.
- Launch Codex Desktop again.
- Startup fails, silently exits, or appears blocked by local file/process state.
I do not think a generic taskkill codex.exe workaround is safe. The Codex CLI and extension/app-server processes can also be legitimate, and background tasks may still be active even when no window is visible.
What I think would help upstream
A Windows-specific doctor / startup-health path could report these states before attempting repair:
- enumerate Codex-related processes with executable-path-aware classification, not substring matching;
- distinguish desktop main process vs Electron renderer/helper processes using
--type=where available; - detect a stale main process only when it has no renderer descendant and is older than a short threshold;
- detect shared SQLite lock sidecars and relevant app-server processes;
- avoid touching the node-based Codex CLI unless explicitly requested;
- warn if the process tree is still active rather than assuming "no window" means idle;
- suggest next steps without automatically killing or resetting Store/AppX state.
If an actual repair path is added, I would strongly recommend a conservative gate:
- never run SQLite maintenance while any relevant Codex process is active;
- before killing a windowless process, check process-tree CPU activity so ongoing background work is not interrupted;
- keep Store/AppX repair as a later, explicit path after the local process/lock diagnosis has been exhausted.
Reference implementation / diagnostic prototype
I built an unofficial local Windows tray + CLI utility that implements these ideas as a reference/prototype:
https://github.com/dev-bricks/CareCenter-for-Codex
Relevant pieces in that project:
- process classification:
src/codex_logdatenbank_wartung/processes.py - startup diagnosis:
src/codex_logdatenbank_wartung/health.py - conservative watchdog tick:
src/codex_logdatenbank_wartung/watchdog.py - safe SQLite maintenance boundaries:
src/codex_logdatenbank_wartung/maintenance.py - Store/AppX repair lessons and timeouts:
src/codex_logdatenbank_wartung/repair_workflow.py,repair_live.py
This is not proposed as a drop-in upstream dependency. It is an external prototype that may be useful as empirical design input.
Current local verification for that prototype:
182 pytest tests passed on Windows / Python 3.12
The test coverage includes:
- exact executable-path matching rather than loose substring matching;
- rejecting the node-based Codex CLI as a desktop-maintenance target;
- detecting Electron helper process types;
- detecting stale main process + missing renderer cases;
- refusing to repair active desktop sessions;
- refusing to act when a windowless Codex process tree is still CPU-active;
- creating backups before SQLite maintenance;
- handling Store/AppX repair timeouts as blockers rather than continuing to stack repair operations.
Privacy / safety note
I am intentionally not attaching raw local Codex logs or SQLite files here. They may contain prompts, local paths, command history, or workspace details. I can provide sanitized diagnostics or specific excerpts if maintainers say what would be most useful.
Proposed next step
If this direction aligns with the Codex Windows roadmap, I can extract a much smaller upstream-oriented proposal or invited PR focused only on Windows startup diagnostics, without the external tray app, branding, or Store tooling.
3 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Thanks for the duplicate suggestion. I reviewed #26327. It is related at the helper/app-server lifecycle level, but I do not think this issue is a duplicate.
#26327 focuses on long-session performance degradation from accumulated Node REPL/MCP/stdio app-server helper stacks, and it was later retracted by its author pending a cleaner trigger isolation.
This issue is scoped to Windows Desktop startup/launch health: stale desktop main processes, shared SQLite locks, and a conservative diagnostic path before users reach for Store/AppX repair flows. The overlap is useful context, but the requested upstream surface here is narrower: startup-health diagnostics and safe process/lock classification.
I’m seeing a recurring Windows Codex Desktop local state/profile recovery issue that looks related to stale Codex/app-server processes and locked
~/.codexSQLite state.Environment
OpenAI.Codex_26.601.2237.0_x64__2p2nqsd0c76g0OpenAI.Codex_26.602.3474.0_x64__2p2nqsd0c76g0C:\Users\<user>\AppData\Local\Packages\OpenAI.Codex_2p2nqsd0c76g0C:\Users\<user>\.codexFailure pattern
Codex Desktop can fail to launch with:
This did not look like a simple install/version issue. After closing the visible Codex window, I observed stale
Codex.exe/codex.exe app-serverprocesses still running. While those processes were alive, these shared SQLite files under~/.codexremained locked or failed to open cleanly:Other observations:
logs_2.sqlitehad grown to about854 MB.7.2 MB, and startup/exit behavior improved.Codex.exehang:AppHangTransient2026-06-01 12:55:33git.exehang around2026-06-03 22:49:25.Latest update/reset observation
After updating again, Codex Desktop could not open after the update. A normal restart was not enough. Resetting Codex from Windows Settings made it launch successfully.
I did not capture the stale-process / SQLite-lock state before resetting this time, so I cannot confirm the exact same lock condition recurred. But the recovery pattern was similar: update/restart left the app unable to open, and a full Windows app reset restored it.
Current state after reset:
Workarounds
The Windows Settings reset path works, but it is heavy:
In my case, resetting Codex from Windows Settings made the app launch successfully again. The same heavy reset can also be done with:
Before doing a full reset, smaller targeted workarounds are:
Expected behavior
Codex Desktop should recover from stale local state automatically, or provide a targeted recovery action instead of requiring a full Windows app reset.
Possible recovery actions:
Codex.exe/codex.exe app-serverprocesses;logs_2.sqlite;codex doctor-style check for stale processes, locked SQLite files, oversized logs DBs, and Chromium profile locks.This looks closest to the stale-process / local-state recovery problem in this issue. It may also be related to the helper-process accumulation described in #26327 as a contributing factor, but the direct failure mode here is startup/profile recovery after stale or inconsistent local state.