Skip to content

fix: make Codex Desktop worktree setup Windows-safe - #1565

Merged
BigSimmo merged 6 commits into
mainfrom
codex/fix-windows-worktree-setup
Aug 1, 2026
Merged

fix: make Codex Desktop worktree setup Windows-safe#1565
BigSimmo merged 6 commits into
mainfrom
codex/fix-windows-worktree-setup

Conversation

@BigSimmo

@BigSimmoBigSimmo commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • add a Windows-safe Codex Desktop worktree bootstrap that runs before node_modules exists
  • reuse dependencies only from a complete worktree with a byte-identical lockfile, otherwise run locked npm ci --include=dev
  • validate Node 24, npm 11, installed lock parity, and Git hooks after setup
  • document the Desktop versus Cloud setup boundary and protect it with focused tests

Why

The Database Codex environment was configured to invoke the Linux-only Cloud Bash setup from Windows. Codex launched that command through WSL outside the Windows worktree, so new worktrees were left without dependencies and repeatedly failed. The effective local Codex environment selection has also been corrected to use the Windows launcher; this PR makes the durable repository contract available to every future worktree after merge.

Files and areas

  • scripts/setup-codex-worktree.mjs
  • tests/setup-codex-worktree.test.ts
  • package.json
  • AGENTS.md, README.md, docs/codex-cloud.md, docs/scripts-index.md

Verification

  • disposable fresh detached worktree: setup PASS; Node 24.18.0/npm 11.17.0 runtime PASS; installed-lock parity PASS
  • node scripts/run-vitest.mjs run tests/setup-codex-worktree.test.ts tests/installed-lock-parity.test.ts --reporter=dot: 2 files passed, 11 tests passed
  • node scripts/setup-codex-worktree.mjs --dry-run: existing dependencies match package-lock.json
  • focused ESLint on the new setup script and test: PASS
  • npm run format: exit 0; whole tree unchanged
  • npm run format:changed: PASS
  • npm run verify:pr-local -- --files ...: runtime, installed-lock parity, formatting, full lint, and typecheck completed; the repository-wide Vitest phase stopped producing progress and never emitted a verdict, so the task-owned run was terminated

Checks not completed

  • the full Vitest suite did not complete locally; because verify:pr-local is sequential, its later build and RAG fixture steps were not reached
  • no browser, provider-backed, API, deployment, or production checks were run; they are not relevant to this local setup change

RAG impact: no retrieval behaviour change — worktree setup, tests, and documentation only.

Risk and follow-up

The generated Codex Desktop environment TOML is machine-local and intentionally not committed. This machine's effective Database environment selection now points to the durable Windows launcher, while the tracked setup script and instructions prevent the Linux Cloud command from being reused for future Windows worktrees.

Summary by CodeRabbit

  • New Features

    • Added a guided Codex Desktop worktree setup command.
    • Automatically reuses valid local dependencies or performs a locked installation when needed.
    • Added runtime, lockfile, and installation checks, plus dry-run support.
  • Documentation

    • Clarified Windows Desktop setup requirements and database environment verification.
    • Distinguished Windows Desktop setup from Linux-based Codex Cloud instructions.
    • Updated the scripts index to reflect the new setup utility.

@supabase

supabaseBot commented Aug 1, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai

coderabbitaiBot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in:12 minutes

Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4cacd43e-9251-4bfe-9210-dd564c236e05

📥 Commits

Reviewing files that changed from the base of the PR and between e1d928f and 5e1ef7e.

📒 Files selected for processing (2)
  • docs/codex-cloud.md
  • tests/setup-codex-worktree.test.ts
📝 Walkthrough

Walkthrough

Added a Codex Desktop worktree setup command. It validates runtimes and lockfiles, reuses complete matching dependencies, falls back to locked installation, installs hooks, and documents Windows and Cloud setup boundaries.

Changes

Codex Desktop worktree setup

Layer / File(s)Summary
Setup contract and runtime validation
scripts/setup-codex-worktree.mjs, package.json
Added the setup:codex-worktree command. The script validates worktree data, lockfile parity, installed dependencies, npm resolution, and Node/npm versions.
Dependency reuse and installation flow
scripts/setup-codex-worktree.mjs, tests/setup-codex-worktree.test.ts
Added complete dependency reuse, guarded copying, locked npm ci --include=dev fallback, dry-run handling, hook installation, post-install verification, and test coverage.
Platform setup guidance
AGENTS.md, README.md, docs/codex-cloud.md, docs/scripts-index.md
Documented Windows Codex Desktop setup, Cloud Bash limitations, dependency reuse rules, and updated script counts.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested labels:codex

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
Title check✅ PassedThe title clearly and concisely describes the main change: making Codex Desktop worktree setup safe on Windows.
Description check✅ PassedThe description covers the change, rationale, affected files, verification results, incomplete checks, risks, and scope with sufficient detail.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@ecc-tools

ecc-toolsBot commented Aug 1, 2026

Copy link
Copy Markdown

🔒 Upgrade Required

Private repository analysis requires Pro or Enterprise.

Upgrade: https://ecc.tools/pricing?plan=pro


ECC Tools keeps the core app open, and puts private repos, team features, and enterprise controls behind paid tiers.

@github-actions

Copy link
Copy Markdown
Contributor

CI triage

CI failed on this PR. Automated classification of the 2 failed job(s):

  • Unit coverageneeds investigation: inspect the failing step and uploaded diagnostics; rerun only after classifying the cause.
  • PR requiredneeds investigation: inspect the failing step and uploaded diagnostics; rerun only after classifying the cause.

Compared with main CI run #7739 (cancelled).

Classification is evidence routing, not permission to ignore a failure. Exact quarantined Playwright identities remain governed by the flake ledger.

@BigSimmo
BigSimmo marked this pull request as ready for review August 1, 2026 18:06
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@ecc-tools

ecc-toolsBot commented Aug 1, 2026

Copy link
Copy Markdown

🔒 Upgrade Required

Private repository analysis requires Pro or Enterprise.

Upgrade: https://ecc.tools/pricing?plan=pro


ECC Tools keeps the core app open, and puts private repos, team features, and enterprise controls behind paid tiers.

@BigSimmo
BigSimmo enabled auto-merge (squash) August 1, 2026 18:06
@BigSimmo
BigSimmo disabled auto-merge August 1, 2026 18:07

@devin-ai-integrationdevin-ai-integrationBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 1 additional finding in Devin Review.

Open in Devin Review

Comment threadtests/setup-codex-worktree.test.ts
Comment threadscripts/setup-codex-worktree.mjs

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:e1d928f292

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadscripts/setup-codex-worktree.mjs
@BigSimmo

Copy link
Copy Markdown
OwnerAuthor

@codex resolve actionable Codex review findings for this pull request and current head using the repository instructions. This is the pull request's single automatic repair pass: do not perform a fresh review, create new standalone findings, or request another review. Work only the existing unresolved Codex threads on the current head. The only repository destination is BigSimmo/Database, and the only branch destination is the pull request head branch codex/fix-windows-worktree-setup at starting commit e1d928f; never publish fixes to a detached or synthetic work branch and never create a stacked pull request. Use the authenticated GitHub connector to commit each approved fix to BigSimmo/Database:codex/fix-windows-worktree-setup, then verify that the pull request head contains the published commit before reporting success. Always fix P0 and P1 findings. For P2 and lower findings, fix only clear, scoped, low-risk issues; otherwise disposition them with a concise reason. For a fixed thread, reply with as the first line and as the second line. For a no-code disposition, use followed by . These result markers authorize the workflow to close that exact thread only after it verifies a fixed commit is the pull request head; a local-only commit is not a fix. If publication or verification fails, do not use either result marker, do not claim success, and leave the thread open with the blocker. If human input or new authorization is required, do the same. Finish only after every actionable thread is fixed or dispositioned and closed, or explicitly left open for a human decision. Do not update the branch from main, address unrelated reviews, broaden scope, or create more than one scoped fix commit. Do not use external APIs, paid services, credentials, dependency changes, or broad refactors unless explicitly authorized. Add targeted tests where behavior changes and run the narrowest relevant validation.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit:e1d928f292

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/scripts-index.md (1)

1-9: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add setup-codex-worktree.mjs to the itemized script list.

The header states: "Every top-level .mjs/.ts/.cjs script is named below; the remaining files are fixtures, SQL, subfolder helpers, and small shared helpers grouped rather than itemised." The new scripts/setup-codex-worktree.mjs is a top-level .mjs script, but it isn't named in any category in this file, even though the counts on line 3 were bumped to include it. This breaks the document's own stated completeness contract. It fits naturally alongside check-installed-lock-parity.mjs and install-git-hooks.mjs in "Runner & guard infrastructure [infra]," since it calls both.

📝 Proposed addition to the Runner & guard infrastructure table
 | `check-installed-lock-parity.mjs`, `phone-chrome-plan.mjs`, `verify-phone-chrome.mjs`, `playwright-browser-preflight.mjs` | Lock-trust preflight, change-scoped phone contracts, and Playwright browser-binary preflight before build |
+| `setup-codex-worktree.mjs` | Windows Codex Desktop worktree bootstrap: validates Node/npm, reuses a byte-identical local install or runs locked `npm ci`, then installs Git hooks |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/scripts-index.md` around lines 1 - 9, Add setup-codex-worktree.mjs to
the itemized “Runner & guard infrastructure [infra]” table in
docs/scripts-index.md, alongside check-installed-lock-parity.mjs and
install-git-hooks.mjs. Preserve the existing counts and table organization while
ensuring the top-level script is explicitly listed.
🧹 Nitpick comments (2)
README.md (1)

23-27: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Reference AGENTS.md instead of restating the Cloud-script prohibition.

Lines 26-27 restate the same policy that AGENTS.md's codex-desktop-worktree-setup section already states: don't run the Cloud-only Bash setup script on Windows Desktop. Having the same rule phrased separately in two files risks the two drifting apart if the policy changes later.

As per coding guidelines, "Treat AGENTS.md as the single source of truth for repository rules; orientation documents must not duplicate policy, and conflicts defer to AGENTS.md." README.md is the onboarding/orientation document here, so it should link to the AGENTS.md section rather than restate the rule.

♻️ Proposed rewording to reference AGENTS.md
-Codex Desktop worktrees use `npm run setup:codex-worktree`. The local bootstrap-reuses dependencies only from a complete worktree with a byte-identical lockfile,-then validates the installed metadata. It falls back to the locked install above-when no safe local donor exists. Do not configure Windows Desktop worktrees to run-the Cloud-only Bash setup script.+Codex Desktop worktrees use `npm run setup:codex-worktree`. The local bootstrap+reuses dependencies only from a complete worktree with a byte-identical lockfile,+then validates the installed metadata. It falls back to the locked install above+when no safe local donor exists. See `AGENTS.md`'s Codex Desktop worktree setup+section for the Windows-vs-Cloud setup boundary.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@README.md` around lines 23 - 27, Update the README guidance around Codex
Desktop worktree setup to remove the duplicated Windows Cloud-only Bash
prohibition and instead reference the `codex-desktop-worktree-setup` section in
`AGENTS.md` as the authoritative policy. Preserve the surrounding setup and
fallback instructions.

Source: Coding guidelines

tests/setup-codex-worktree.test.ts (1)

6-13: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Consider covering assertRuntime, copyDependencies, and main().

Only parseWorktreeList, lockDigest, installedMetadataMatches, installationIsComplete, findDependencyDonor, and resolveNpmCli are imported and tested here. assertRuntime, copyDependencies, removePartialInstall, and main are not exported from scripts/setup-codex-worktree.mjs, so they cannot be unit-tested directly. These functions encode the runtime-validation and donor-copy guarantees the PR is built around (Node/npm version matching, Windows robocopy vs. POSIX cpSync exclusions, post-copy verification). Exporting them for direct testing, or adding an integration-level test that mocks spawnSync/filesystem calls, would close this gap.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@tests/setup-codex-worktree.test.ts` around lines 6 - 13, Expand coverage for
the untested assertRuntime, copyDependencies, removePartialInstall, and main
flows in setup-codex-worktree.mjs. Either export these symbols for direct unit
tests or add integration tests that mock spawnSync and filesystem operations,
covering runtime version validation, platform-specific donor copying and
exclusions, partial-install cleanup, and post-copy verification.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/setup-codex-worktree.test.ts`:
- Around line 81-83: Gate the resolveNpmCli() assertion in the test so it runs
only on Windows, where the npm JavaScript entrypoint expectation applies.
Preserve the existing regex assertion for Windows and skip it on Unix platforms
where resolveNpmCli() may return null.
---
Outside diff comments:
In `@docs/scripts-index.md`:
- Around line 1-9: Add setup-codex-worktree.mjs to the itemized “Runner & guard
infrastructure [infra]” table in docs/scripts-index.md, alongside
check-installed-lock-parity.mjs and install-git-hooks.mjs. Preserve the existing
counts and table organization while ensuring the top-level script is explicitly
listed.
---
Nitpick comments:
In `@README.md`:
- Around line 23-27: Update the README guidance around Codex Desktop worktree
setup to remove the duplicated Windows Cloud-only Bash prohibition and instead
reference the `codex-desktop-worktree-setup` section in `AGENTS.md` as the
authoritative policy. Preserve the surrounding setup and fallback instructions.
In `@tests/setup-codex-worktree.test.ts`:
- Around line 6-13: Expand coverage for the untested assertRuntime,
copyDependencies, removePartialInstall, and main flows in
setup-codex-worktree.mjs. Either export these symbols for direct unit tests or
add integration tests that mock spawnSync and filesystem operations, covering
runtime version validation, platform-specific donor copying and exclusions,
partial-install cleanup, and post-copy verification.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: efd6c771-cb1f-473d-a959-6d8b263ede7c

📥 Commits

Reviewing files that changed from the base of the PR and between 66b5f95 and e1d928f.

📒 Files selected for processing (7)
  • AGENTS.md
  • README.md
  • docs/codex-cloud.md
  • docs/scripts-index.md
  • package.json
  • scripts/setup-codex-worktree.mjs
  • tests/setup-codex-worktree.test.ts

Comment threadtests/setup-codex-worktree.test.ts
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@ecc-tools

ecc-toolsBot commented Aug 1, 2026

Copy link
Copy Markdown

🔒 Upgrade Required

Private repository analysis requires Pro or Enterprise.

Upgrade: https://ecc.tools/pricing?plan=pro


ECC Tools keeps the core app open, and puts private repos, team features, and enterprise controls behind paid tiers.

@ecc-tools

ecc-toolsBot commented Aug 1, 2026

Copy link
Copy Markdown

🔒 Upgrade Required

Private repository analysis requires Pro or Enterprise.

Upgrade: https://ecc.tools/pricing?plan=pro


ECC Tools keeps the core app open, and puts private repos, team features, and enterprise controls behind paid tiers.

@BigSimmo
BigSimmo enabled auto-merge (squash) August 1, 2026 18:28
@ecc-tools

ecc-toolsBot commented Aug 1, 2026

Copy link
Copy Markdown

🔒 Upgrade Required

Private repository analysis requires Pro or Enterprise.

Upgrade: https://ecc.tools/pricing?plan=pro


ECC Tools keeps the core app open, and puts private repos, team features, and enterprise controls behind paid tiers.

@ecc-tools

ecc-toolsBot commented Aug 1, 2026

Copy link
Copy Markdown

🔒 Upgrade Required

Private repository analysis requires Pro or Enterprise.

Upgrade: https://ecc.tools/pricing?plan=pro


ECC Tools keeps the core app open, and puts private repos, team features, and enterprise controls behind paid tiers.

@BigSimmo
BigSimmo merged commit 3100e40 into mainAug 1, 2026
25 checks passed
@BigSimmo
BigSimmo deleted the codex/fix-windows-worktree-setup branch August 1, 2026 18:58
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@BigSimmo