Skip to content

[Fix] Remove a switch's leftover route when TypeScript build info sits beside its install - #532

Merged
juanmaguitar merged 1 commit into
trunkfrom
fix/leftover-tsbuildinfo
Sep 25, 2026
Merged

juanmaguitar merged 1 commit into
trunkfrom
fix/leftover-tsbuildinfo

Conversation

@juanmaguitar

Copy link
Copy Markdown
Collaborator

Why

#530 does not fix #529 on a real site. A Windows pass on the trunk artifact (e0a3faa) of the v1.2.0 candidate, on a Gutenberg site switching from its issue branch to pr/76292, still failed Apply and rebuild with ENOENT ... routes\dashboard\package.json. The leftover routes\dashboard\ held node_modules and tsconfig.tsbuildinfo and tsconfig.test.tsbuildinfo, which trunk's tsc --build writes there and Gutenberg ignores. #530 removes the directory only when it holds nothing but node_modules, so it kept it. Nothing was running during the switch. Any site whose trunk types were built has these files, on either platform; the macOS pass for #530 most likely ran on a site that did not.

What changes

Root cause: the "holds only an install" rule was narrower than what a build leaves in a route.

holdsOnlyInstalls in src/ticket-branches.js also accepts *.tsbuildinfo files. They are TypeScript's incremental cache, rewritten by the next build, and the name is TypeScript's convention, not Gutenberg's. Every other guard stays: the directory must be missing from the new tree, and otherPaths still refuses anything untracked and not ignored, so a .tsbuildinfo the destination does not ignore keeps the directory (and #521 excludes it).

Deliberately not: accepting any ignored file. Ignored files include a contributor's .env or local config, and this code deletes.

How to test this

Platforms: Windows is where it was seen; either reproduces it. Build: the Buildkite artifact for this PR's head.

Starting state: a Gutenberg site on trunk, installed and built, no pull request checked out, no changes; routes\dashboard\ holds node_modules and the two .tsbuildinfo files. A site already on pr/76292 with the leftover is not healed: go back to trunk first, or delete routes\dashboard\.

  1. Check out pull request 76292 (by number, or through a linked issue). Let the install finish.
  2. In the site: Get-ChildItem routes (PowerShell) or ls routes. Expected: no dashboard.
  3. Click Apply and rebuild. Expected: the build succeeds.
  4. Revert the PR / go back to trunk and let the install run. Expected: routes/dashboard/node_modules/ is back and the site reports no changes.

What must not have happened: other routes/* directories touched; the root node_modules rebuilt by the switch itself.

On the old code, TypeScript build info beside the install goes with it (issue #529) in tests/unit/ticket-branches.integration.test.cjs fails (checked: removed is []) and passes here. TypeScript build info the destination does not ignore keeps the directory (issue #529) pins the guard.

Risks and limitations

  • Anything else a build writes into a route (say a build/ beside the install) still keeps the directory, as before. Not seen; widen only on evidence.
  • Blocks v1.2.0: the release waits on this PR's Windows pass.

Related

Follow-up to #530. Fixes #529 for sites with built types.


Review outcome (required, see AGENTS.md)
  • Review: completed. Fresh-context Explore subagent running .github/instructions/code-review.instructions.md step 3; head c7ec033 / base e0a3faa; npm run lint clean, npm test 1667 pass 0 fail. 0 [fix here] · 0 [follow-up]. Checked: otherPaths still gates non-ignored build info; readdir Dirent.isFile() is false for symlinks and junctions on Windows, so a link named *.tsbuildinfo keeps the directory; both tests fail if their half of the rule breaks. Nit not taken: holdsOnlyInstalls no longer names everything it accepts.
  • Since review: none.

🤖 Generated with Claude Code

…s beside its install

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: WordPress/contributor-toolkit/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: f741564f-4f1f-4f06-a00c-ccef58900866

📥 Commits

Reviewing files that changed from the base of the PR and between e0a3faa and c7ec033.

📒 Files selected for processing (2)
  • src/ticket-branches.js
  • tests/unit/ticket-branches.integration.test.cjs

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The leftover-install check now treats .tsbuildinfo files as allowable directory contents. The integration tests verify that switching removes a route directory when the destination ignores those files, and retains the directory and build-info file when the destination does not ignore them.

Objective Addressed Explanation
Remove stale route directories left after switching to an older pull request when their remaining contents are ignored files [#529] ✅

Assessment against linked issues — out-of-scope changes: No out-of-scope changes were identified.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to c7ec0

The change allows stale route cleanup when only build-info files remain, while preserving directories with non-ignored files. The supplied evidence identifies no remaining merge-blocking risk.

Security Architecture Review

Security architecture risk: 🔵 Low · up to c7ec0

The change is limited to cleanup of leftover route directories. Existing checks still protect routes in the destination branch and files that the destination does not ignore. No new production entrypoint or material security issue was established, though deletion remains a consequential operation.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed deletion eligibility is confined to candidate directories in the switched worktree; the supplied evidence does not show a new cross-service dependency or production entrypoint.

Trust Boundaries and Controls

  • observed — The deletion sink remains behind destination-tree, filesystem-type, content, and untracked-path checks. The changed test helper supplies fixed fixture files and does not grant a production caller new authority.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description covers the cause, implementation, tests, risks, related issues, and review outcome. It clearly states the intended behavior and limitations.
Linked Issues check ✅ Passed The description identifies #530 as the follow-up and #529 as the fixed issue. This matches the stated objectives and historical issue context.
Out of Scope Changes check ✅ Passed The changes are limited to route cleanup logic and integration tests for TypeScript build-info files. No unrelated changes are identified.
Title check ✅ Passed The title uses the required action-first format and identifies the route cleanup scenario and TypeScript build-info cause.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@juanmaguitar

Copy link
Copy Markdown
Collaborator Author

Manual pass on Windows (UTM VM), Buildkite artifact for c7ec033, on a new Gutenberg site created on trunk (25 Sep):

  • A fresh wizard build leaves no .tsbuildinfo in routes\dashboard\, only node_modules and the sources. Checking out 76292 from there removed the leftover and the build passed (400 s): the [Fix] Remove directories a switch leaves holding only an ignored install #530 case, on Windows.
  • Back on trunk, the two files created by hand in routes\dashboard\ (tsconfig.tsbuildinfo, tsconfig.test.tsbuildinfo), git status clean, so ignored. Checking out 76292 again: Test-Path routes\dashboard is False, build passed (320 s). This is the case that failed on the e0a3faa artifact with ENOENT routes\dashboard\package.json.
  • Revert this PR: on trunk, routes\dashboard\ back with node_modules and its sources, git status --short empty, no changes in the app.

The earlier site most likely got its .tsbuildinfo from a build watch (tsc --build), which the wizard's one-shot build does not run.

@juanmaguitar

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@juanmaguitar
juanmaguitar merged commit 4c3b05a into trunk Sep 25, 2026
8 checks passed
@juanmaguitar
juanmaguitar deleted the fix/leftover-tsbuildinfo branch September 25, 2026 07:47
juanmaguitar added a commit that referenced this pull request Sep 25, 2026
## Why

`v1.2.0-beta.2` shipped on 23 September. Five commits reach trunk since
then: #524, #528, #530 and #532 fix what the beta.2 testing turned up
(files another branch ignored counted as changes after a switch,
`NODE_OPTIONS` lost in the macOS shims, and a trunk-only Gutenberg route
left behind by a switch to an older pull request, which broke
`wp-build`), and #531 makes the manual **Real WordPress setup** workflow
pass again, green on both platforms and both targets on trunk's app
code. Milestone `v1.2.0` holds only the umbrella #251.

`electron-builder` derives artifact names from `package.json`, so the
version has to move before the tag and the artifacts exist. This is a
stable release: it takes `releases/latest` from `v1.1.0`.

## What changes

Only the version. All three package-version fields in `package.json` and
`package-lock.json` move together from `1.2.0-beta.2` to `1.2.0`. No
dependency versions change, and there is no application behaviour change
in this PR.

## How to test this

Platforms: any for the suite; macOS and Windows for the artifact checks
that follow the merge.

1. `npm run lint` is clean and `npm test` passes, from the repository
root.
2. `node -e "console.log(require('./package.json').version)"` prints
`1.2.0`.
3. `python3 -c "import
json;d=json.load(open('package-lock.json'));print(d['version'],
d['packages']['']['version'])"` prints `1.2.0 1.2.0`.

**What must not have happened:** no dependency version may change. `git
diff` must show exactly three changed lines, all of them the root
package version.

After merge, the release build must produce artifacts named
`wordpress-contributor-toolkit-1.2.0-*`; the asar root must be exactly
`node_modules`, `package.json`, `src`, with npm 11 under
`node_modules/npm` and no `.codesigning` directory; on macOS
`CFBundleShortVersionString` reads `1.2.0`.

## Risks and limitations

No UI change. The risk is a mis-scoped edit in `package-lock.json`,
where dependencies also carry version fields; the replacement was
confined to the first 2000 bytes of the file, which hold the two root
entries and nothing else, and both files were re-parsed as JSON
afterwards.

Manual passes on what reached trunk after beta.2: #528 and #530 on macOS
in their PRs; #530 plus #532 on Windows on #532's artifact (c7ec033),
including the case that failed on e0a3faa.

## Related

Part of #251. Release notes follow on the release; docs publish for the
tag per #487.

---

<details>
<summary>Review outcome (required, see AGENTS.md)</summary>

0 [fix here] · 0 [follow-up]. Deterministic layer only: lint clean, 1667
tests pass, both files valid JSON, diff confined to the three root
version fields. No judgement pass was run: this change has no logic to
review.

- **Review:** completed, deterministic layer, in session; head is the
single bump commit / base `4c3b05a` (trunk); evidence above; outcome:
nothing to fix.
- **Since review:** none.

</details>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to 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.

Switching to an older Gutenberg pull request leaves trunk-only directories that break wp-build

1 participant