Skip to content

[Windows][Codex Desktop] Existing task retains deleted workspace path after project folder is moved #41776

Open

Description

@develmax

Summary

On Windows, an existing Codex Desktop task keeps its original workspace path after the project directory is moved or renamed outside Codex. Restarting the desktop application restores the same task with the stale path instead of detecting that the workspace moved or asking the user to select its new location.

This leaves the task in a partially functional state:

  • commands without an explicit working directory fail because the persisted cwd no longer exists;
  • commands with an explicit new working directory can still run;
  • file inspection, builds, and tests may work against the new directory;
  • the managed patch editor rejects files in the new ordinary directory with a misleading path contains a reparse point error;
  • restarting the application does not repair or rebind the task.

No repository, username, private path, credentials, or project-specific content is included in this report.

Environment

  • Surface: Codex Desktop
  • Platform: Windows x64
  • OS family observed: Windows 10
  • Workspace type: local directory
  • Date observed: 2026-08-31
  • The old and new directories were on the same local NTFS volume.
  • Neither project directory was intended to be a symlink or junction.

Steps to reproduce

  1. Open a local project directory in Codex Desktop, for example:
    D:\Workspace\OldProjectName
  2. Start a task and perform normal file/build operations.
  3. Move or rename the project directory outside Codex:
    D:\Workspace\OldProjectName → D:\Workspace\NewProjectName
  4. Continue the existing task.
  5. Restart Codex Desktop and reopen the same task.
  6. Ask the task to run a command without an explicit working directory.
  7. Ask it to edit a file under the new directory using the managed patch mechanism.

Actual behavior

The task remains bound to the deleted original path.

A command using the task default cwd fails before the shell starts:

CreateProcessAsUserW failed: 267 (The directory name is invalid.)
cwd=D:\Workspace\OldProjectName

When an explicit workdir=D:\Workspace\NewProjectName is supplied, shell commands can read, build, and test the moved project successfully.

However, the managed patch operation against a normal file under the new directory fails with:

Failed to read file to update D:\Workspace\NewProjectName\README.md:
path contains a reparse point

Independent filesystem inspection shows that the new project directory and its parents are ordinary directories, not reparse points.

Restarting the application restores the same stale workspace binding. Repeated restarts do not prompt for the new location and do not update the task cwd.

Expected behavior

When reopening an existing task whose workspace path no longer exists, Codex Desktop should:

  1. detect the missing workspace before starting tool execution;
  2. offer to locate/rebind the moved project;
  3. validate and persist the newly selected canonical path;
  4. update the task cwd and managed filesystem scope together;
  5. distinguish an out-of-workspace path from an actual symlink/junction/reparse point;
  6. avoid restoring the task into a partially functional state.

If automatic rebinding is unsafe, the task should fail closed with an actionable message such as:

The original workspace no longer exists. Select the project's new location or create a new task.

Impact

Long-running tasks lose practical continuity after a legitimate local project rename or product rebranding. Users can still run some explicit-workdir commands, which makes the task appear usable, but managed edits remain blocked and error messages incorrectly suggest filesystem indirection.

This can also leave the old directory locked while the task is open, complicating cleanup and making diagnosis confusing.

Suggested hardening

  • Persist a stable workspace identity in addition to the raw path where possible.
  • On resume, verify that the canonical workspace exists before restoring the task.
  • Add an explicit Rebind workspace action for existing tasks.
  • Update command cwd, sandbox roots, trust state, file-edit scope, watchers, and UI project metadata atomically.
  • Report separate errors for:
    • missing original workspace;
    • path outside the authorized workspace;
    • actual reparse point;
    • stale watcher or task binding.
  • Add a Windows integration test covering same-volume directory rename followed by app restart and task resume.

Workaround

Create a new Codex task opened directly on the renamed project directory. Restarting the existing task or application is not sufficient.

Activity

  1. added
    bugSomething isn't working
    appIssues related to the Codex desktop app
    windows-osIssues related to Codex on Windows systems
    sessionIssues involving session (thread) management, resuming, forking, naming, archiving
    sandboxIssues related to permissions or sandboxing
    on Aug 31, 2026
  2. github-actions commented on Aug 31, 2026

    @github-actions
    Contributor

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

    Powered by Codex Action

  3. develmax commented on Aug 31, 2026

    @develmax
    Author

    Additional findings from local investigation:

    • The stale binding is persisted in %USERPROFILE%\.codex\state_5.sqlite, table threads, column cwd.
    • The desktop UI also keeps a duplicate in %USERPROFILE%\.codex\sqlite\codex-dev.db, table local_thread_catalog, column cwd.
    • The renamed project itself was already registered correctly in projects / project_roots; only the existing task/thread rows still referenced the removed directory.
    • There were many auxiliary/service thread rows using the old workspace, so a global path replacement would be unsafe. The repair had to target the exact user task.
    • After backing up both SQLite databases, updating that task's cwd and project_id in both stores, and restarting Codex Desktop, the original task resumed successfully in the renamed directory.
    • A command executed without an explicit workdir then started in the new workspace, and the solution file was accessible.

    This confirms the problem is persisted task/catalog metadata rather than an NTFS reparse point. It also suggests a rebind operation needs to update both stores atomically (plus any sandbox/file-edit authorization state), ideally through a supported UI action rather than manual database edits.

    Manual SQLite editing is only a diagnostic workaround and should not be recommended as a normal recovery path, especially while Codex Desktop is running.

  4. develmax commented on Aug 31, 2026

    @develmax
    Author

    Thanks. I reviewed #41508. The two reports are related at the workspace-refresh/rebinding layer, but they are not duplicates:

    • [Windows][GUI] Cannot create a task in a USB-drive project after reconnecting the drive #41508 involves an external USB drive that is temporarily disconnected and then reconnected at the same path. The failure occurs when creating a new task without restarting the app.
    • This issue involves a permanent same-volume rename/move between two ordinary directories on an internal NTFS drive. An existing long-running task keeps the old cwd even after Codex Desktop is restarted.
    • In this case, commands work when the new workdir is supplied explicitly, while the managed editor reports a misleading reparse-point error.
    • Local investigation confirmed that the stale path remained in both the task store and the desktop catalog. A targeted update of the exact task's cwd and project_id in both stores, followed by an app restart, restored the original task.

    The issues may share missing workspace-state invalidation, but they require different recovery behavior: #41508 should refresh a temporarily unavailable path, while this issue needs an explicit and atomic rebind from an obsolete path to a new canonical path. I therefore believe this issue should remain separate.

  5. martinabel234 commented on Oct 13, 2026

    @martinabel234

    Independent Windows reproduction on 2026-10-13: stale project cwd also prevents Chrome control

    This adds browser-runtime impact to #41776. The user explicitly requested escalation after repeated unsuccessful recovery attempts and chats inheriting the obsolete project directory.

    The user is currently continuing work in another open chat using a temporary workaround tied to an existing folder. They explicitly request that reporting/diagnosis must not restart the app, terminate helpers, change connector configuration or otherwise interrupt that working chat. This workaround is not evidence of a general product fix.

    Environment verified

    • Windows x64, native PowerShell execution.
    • Desktop version 26.1007.21434, build 13901, prod channel.
    • Microsoft Store package OpenAI.Codex 26.1007.2314.0.
    • Bundled CLI 0.162.0-alpha.17.2; the separately installed CLI on PATH is 0.128.0 and was not used for app-server recovery.
    • Desktop updater reports up_to_date for the configured channel.
    • Chrome is running and the official extension is installed and enabled.
    • The original project directory was removed. It remains absent; it was not recreated for this reproduction.

    Observations

    1. An existing desktop chat retains the nonexistent original project cwd. A second chat opened from the same saved project also inherits that path.
    2. Basic shell/file operations work when an existing workdir is explicitly supplied.
    3. Even a minimal official Node REPL call fails before evaluating JavaScript:
    nodeRepl.write({cwd: nodeRepl.cwd});
    failed to start Node runtime: El nombre del directorio no es válido. (os error 267)
    
    1. Explicitly setting the MCP server launch cwd to an existing stable directory allows MCP initialize/tools-list, but does not repair the chat's runtime cwd. Handshake success is not browser-access success.
    2. The desktop regenerates its canonical node_repl table at startup and removes a manually added cwd. A separately named server using the same official executable/environment and stable launch cwd survives provisioning but still fails for the obsolete chat cwd.
    3. In a separate diagnostic chat with a valid existing directory, the app-managed cua_repl interface successfully listed real Chrome tabs and read two authenticated pages. No page/account mutations were performed. This establishes that the extension can work on this installation; it does not repair the affected chats.
    4. The separately named node_repl server also reported an EPERM chdir/trusted-process failure in that valid diagnostic chat. This is a distinct error and is not asserted to have the same cause as error 267.
    5. Official app-server thread/resume with only a corrected cwd for the affected live chat was rejected by active-writer protection. No database edits, sandbox bypasses, credentials changes, extension reinstall or signed binary patches were performed.

    Requested resolution

    Please provide a supported way to rebind an existing chat and the saved project to an existing folder while preserving history and effective permissions. Detect missing directories before accepting browser work, and keep browser-helper launch directories independent of user projects. New chats should not silently inherit a nonexistent source directory. Verify recovery with a real Chrome tab read in the affected chat, across restart and subsequent chats; MCP initialization alone is insufficient.

    Related reports reviewed: #44736 (helper cwd erased by startup), #48534 (versioned CUA cache invalidates workaround), and #50143 (deleted helper cwd breaks browser policy bridge on Linux; related mechanism, not the same Windows reproduction).

    This report excludes personal file paths, project/song names, account identifiers, raw conversation logs and credentials.

  6. k-kostin commented on Oct 17, 2026

    @k-kostin

    Additional macOS evidence for #41776: correcting saved cwd is necessary but can leave stale Desktop write grants.

    Environment observed on 2026-10-17: ChatGPT Desktop host 26.1007.71326 (build 20398), bundled Codex CLI 0.162.0-alpha.17.2; a separate PATH CLI was 0.163.0. Both used the same local Codex home.

    We recovered 21 existing, explicitly selected ordinary project chats after a project move from <HOME>/Documents/ProjectA to <HOME>/Projects/ProjectA. The old directory no longer existed. The Desktop project association, thread cwd, explicit tool workdir, and effective filesystem permissions had to be checked separately. We did not rerun a clean project-move reproduction, so this reports a recovered existing state rather than proof of the initiating UI action.

    Useful findings:

    • Resuming the same ID through the installed app-server protocol with an explicit new cwd and runtimeWorkspaceRoots persisted the new cwd without rewriting the transcript or manually editing SQLite mirrors.
    • Desktop retained additional per-chat write grants in thread-writable-roots in .codex-global-state.json. On return to Desktop, the old project path and an unrelated project path were present again in effective write scope, despite the cwd repair. This is not evidence of unauthorized file access; these were existing retained grants whose intended scope we explicitly narrowed.
    • A separate permission cleanup preserved the current project and all required visualization roots. The retained-state JSON change was narrowly scoped and performed only with Desktop exited and target writer locks released. No global path replacement or live database editing was used.
    • Some real Desktop-assigned project chats had NULL threads.project_id; joining only on that column would have missed them. We also found many internal rows carrying the old cwd, which were excluded from the migration allowlist.
    • Managed worktree chats were excluded and verified unchanged.

    Acceptance after reopening Desktop: all 21 selected chats ran a default-cwd command without an explicit workdir and performed temporary write/read/delete probes in intended roots. Latest per-turn effective write profiles and retained grants were checked for removed paths and broader writable ancestors. The same IDs and original logical transcript prefixes were preserved. Read permission was not revoked or claimed to be revoked.

    Suggested regression contract for a supported rebind action:

    1. Keep the same thread ID and transcript; validate the newly selected directory.
    2. Show cwd and retained additional write roots separately, with an explicit permission diff. Do not silently remove unrelated grants merely because a project moved.
    3. Preserve visualization grants and managed-worktree bindings.
    4. After restart, default command cwd, managed edits, runtime roots and UI association must agree.
    5. Migration must target selected user chats, including legacy assignments, without rewriting every auxiliary row matching a path.

    Related worktree case: #41835 . We did not reproduce that remote-worktree bug locally. Raw private state/transcripts are intentionally omitted.

  7. k-kostin commented on Oct 17, 2026

    @k-kostin

    Follow-up to my earlier macOS report: two additional legacy CLI chats exposed a project-association gap during recovery.

    Same environment, observed on 2026-10-17: ChatGPT Desktop host 26.1007.71326 (build 20398), bundled Codex CLI 0.162.0-alpha.17.2. These two chats originated in CLI 0.104.0 and had no Desktop project assignment.

    Their cwd recovery succeeded while preserving both original thread IDs and history. In Desktop, both subsequently executed commands in the intended default directory and passed temporary write/read/delete probes without a workdir override or escalation. Project registration remained a separate step:

    • The bundled app-server accepted project/create for the existing destination directory and thread/metadata/update to assign its returned projectId to both chats. Responses showed the intended membership and cwd. Repeating project creation with the same idempotency key was separately checked in an isolated fixture and returned the same ID.
    • Desktop’s list_projects tool did not list that project at the point checked. The native move_thread_to_project tool refused the legacy chats with “The task's source project could not be safely determined.”
    • Recovery then included a narrowly scoped offline update of Desktop’s legacy project catalog, ID mapping and selected-chat assignments, with the app fully exited, backups and drift checks. After reopening, Desktop’s project/thread listings confirmed the project and both memberships. Original transcript prefixes matched for both chats; seven excluded managed-worktree chats remained unchanged. No manual SQLite or transcript edits were made.

    We did not test restarting between API assignment and the legacy-catalog update, so this does not show that the catalog update was necessary or that restart alone would have failed. We also have not established a contract requiring app-server-created projects to appear automatically in Desktop.

    This is an observed interoperability gap, not a proven shared root cause or a supported workaround. A supported recovery flow should handle legacy unassigned chats and verify cwd, effective permissions, project registration and Desktop membership together while preserving history.

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

    appIssues related to the Codex desktop appbugSomething isn't workingsandboxIssues related to permissions or sandboxingsessionIssues involving session (thread) management, resuming, forking, naming, archivingwindows-osIssues related to Codex on Windows systems

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions