Skip to content

[Windows][Desktop] Microsoft Store update can overwrite local-projects with empty state and mirror it to .bak #37927

Open

Description

@jesseedcp

What version of the Codex App are you using (From “About Codex” dialog)?

The second occurrence happened while the Windows package was updating from:

OpenAI.Codex 26.803.5235.0

to:

OpenAI.Codex 26.803.10989.0

The restored state has remained intact across two clean relaunches on 26.803.10989.0.

What subscription do you have?

ChatGPT Pro

What platform is your computer?

Microsoft Windows NT 10.0.26200.0 x64

The app is installed as the Microsoft Store/MSIX package OpenAI.Codex.

What issue are you seeing?

Codex Desktop has twice removed every registered local project from the Projects view during an in-app Microsoft Store update. The project folders and thread data were not deleted. The local-projects registry in %USERPROFILE%\.codex\.codex-global-state.json was replaced with an empty map, and the same empty state was then written to .codex-global-state.json.bak.

This is distinct from a derived thread-catalog-only failure:

  • Immediately before the second update, the global state contained 12 registered local projects.
  • All 12 corresponding folders still existed and remained readable.
  • After the update, the Projects view showed no local projects and both the primary global-state file and its .bak contained zero local projects.
  • Restoring only the project registry and its related ordering/assignment atoms from a known-good snapshot restored all 12 projects. No project source files or thread database rows needed to be recreated.
  • The restored registry survived closing the app, a second launch, and a later live state save by the new version.

Correlated Windows update timeline for the second occurrence

All times below are local time on 2026-08-11:

10:43:01  Old 26.803.5235.0 desktop process launched.
10:43:45  Windows AppX deployment began removing/de-staging the old package.
10:44:12  The preferred package version changed to 26.803.10989.0.
10:44:45  .codex-global-state.json was rewritten with local project count 12 -> 0.
10:45:04  The new package completed staging/registration activity.

The Microsoft Store event source for this update included:

Update;ChatGPT-SearchForUpdatesWithPausedAddAsync
StageButDoNotInstall=1
status=BlockedOnUser

The first occurrence showed the same user-visible result during a previous AppX update: a known-good temporary global-state write was left behind while the active state subsequently contained no projects.

Backup behavior

Inspection of the installed desktop bundle's state persistence path indicates that it atomically writes the primary global-state file and then writes the same serialized in-memory state to .bak. Consequently, if the in-memory local-projects map is empty during an update/lifecycle race, both the primary file and the nominal backup are overwritten with the same empty project registry. The .bak is therefore not a previous known-good generation in this failure mode.

No raw global-state file is attached because it contains private project names, absolute paths, thread IDs, UI history, and other local metadata.

What steps can reproduce the bug?

This has occurred twice, but the update race is timing-dependent rather than deterministic.

  1. Use Codex Desktop on Windows with multiple registered local projects and keep the desktop process running.
  2. Confirm that %USERPROFILE%\.codex\.codex-global-state.json contains a non-empty local-projects registry.
  3. Let the app's in-app Microsoft Store update flow search for and stage a newer OpenAI.Codex package while the old desktop process is still active.
  4. During package removal/de-staging and new-version staging, allow the old/new lifecycle to complete normally.
  5. Launch or return to the newly registered version.
  6. Observe that the Projects section is empty even though every project folder still exists.
  7. Inspect the primary global-state file and .bak: both contain zero local projects.

The cleanest observed reproduction updated 26.803.5235.0 to 26.803.10989.0 and produced the exact event/state timeline above.

What is the expected behavior?

  • App updates must preserve registered local projects, their ordering, and thread-project assignments.
  • The updater should quiesce all old-version state writers before de-staging the old package or allowing the new version to load/write shared state.
  • A transition from a non-empty on-disk project registry to zero projects should not be persisted unless it is tied to an explicit user deletion transaction.
  • .codex-global-state.json.bak should retain the previous known-good generation. It should not be overwritten with the same newly serialized state during the same save operation.
  • If an update detects an empty/missing registry while valid prior state or valid project roots exist, the app should recover automatically or offer a supported project-index rebuild action.

Additional information

The recovery was validated as follows:

Expected registered projects: 12
Restored projects:             12
Existing project roots:        12/12
First launch after recovery:   12/12
After first clean exit:        12/12
Second launch:                 12/12
Current live app state:        12/12

This report is related to the same broad symptom described in:

The additional mechanism-level evidence here is:

  1. the exact AppX/MS Store update timeline;
  2. a direct local-projects transition from 12 to 0 while all roots remained valid;
  3. the primary file and .bak being overwritten with the same empty state; and
  4. restoration succeeding by repairing the project registry without modifying project files or authoritative thread data.

I can provide sanitized Windows AppX event excerpts, state-key counts, timestamps, and hashes if a maintainer identifies the preferred secure channel. I will not post raw state, authentication files, databases, or logs publicly because they contain private local metadata.

Activity

  1. added
    bug
    app
    windows-os
    session
    on Aug 11, 2026
  2. github-actions commented on Aug 11, 2026

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

  3. jesseedcp commented on Aug 11, 2026

    @jesseedcp
    Author

    Thanks — #37212 is related at the symptom level, but this appears to be a distinct persistence failure mode.

    In #37212, both global-state files contained NUL bytes and failed JSON parsing after update plus re-login. In this report, both files remained valid JSON, but local-projects changed from 12 entries to 0 during the AppX/MS Store update window, and the same valid empty state was mirrored to .bak. No sign-out/re-login occurred. Restoring the project registry alone restored all 12 projects across two relaunches.

    I am keeping this issue open because it adds a separate, timestamp-correlated update/write-race mechanism and demonstrates that the backup can be overwritten with the same empty state.

  4. cyfomix-ui commented on Sep 3, 2026

    @cyfomix-ui

    Additional evidence: MSIX force-termination interrupts the global-state write

    I reproduced the same failure family on another Windows machine across two consecutive Microsoft Store/MSIX updates. The second occurrence left unusually direct timing and file-system evidence that the package update terminated Codex while it was writing global state.

    Environment

    • Windows x64, Microsoft Store/MSIX package OpenAI.Codex
    • First affected update: 26.825.4187.0 -> 26.831.1445.0
    • Second observed update: 26.831.2377.0 -> 26.901.1978.0

    First occurrence (projects disappeared)

    Local time on 2026-09-02:

    07:19:38       Old desktop version detected an available update.
    07:30:45       A Codex task was still active.
    07:32:02.163   AppX deployment registered the new package using
                   ForceTargetApplicationShutdownOption.
    07:32:02.220   AppX event 9643: TerminateApplications succeeded.
    07:32:03.965   The new Codex version launched.
    07:32:04.019   Codex logged: [global-state] Failed to load global state
    07:32:04.028   Parse detail: Unexpected token '\u0000' ... is not valid JSON
    

    Immediately afterward, all 7 registered local projects disappeared from the Projects sidebar and 110 task-to-project assignments were absent from the global-state registry. The project folders and task records were not deleted. state_5.sqlite passed PRAGMA integrity_check and still contained all 7 projects and 110 assignments.

    Second occurrence (interrupted-write artifact)

    Local time on 2026-09-03:

    07:15:22.966   Codex created a temporary global-state file.
    07:15:23.040   Last modification of that temporary file.
    07:15:23.302   AppX force-terminated the application for the package update.
    

    The leftover temp file was exactly 524,288 bytes. It contained no NUL padding, but JSON parsing failed with an unterminated string near offset 522,084. The force-termination therefore occurred about 0.34 seconds after temporary-state creation and about 0.26 seconds after its last recorded write, leaving a truncated serialization artifact.

    This narrows the mechanism from a general migration/indexing failure to an update/shutdown race: the Store/MSIX updater can force-terminate the old process before the global-state write and atomic replacement sequence has safely completed. On the first occurrence, the next version then loaded invalid JSON and initialized/persisted an incomplete project registry.

    Recovery result

    With Codex fully closed, rebuilding only the project registry and task assignments from the intact SQLite records restored all 7 projects and all 110 assignments. The repaired state remained valid after relaunch. No project source files or task content required restoration.

    Suggested safeguards

    • Do not acknowledge update readiness until every global-state write has completed and file handles are flushed/closed.
    • Preserve a previous known-good generation that is not overwritten during the same save transaction.
    • If primary global state is invalid, recover from the last valid backup or reconstruct project metadata from the intact project/task store instead of persisting an empty registry.
    • On startup, surface a recovery warning rather than presenting an empty Projects section as if the user deleted everything.

    Raw state, databases, and full logs are intentionally not attached because they contain local paths, task IDs, and private metadata. Sanitized AppX and Codex log excerpts can be provided if maintainers request them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    appbugsessionwindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions