fix: use canonical worktree context across linked checkouts - #30
Conversation
|
Claude encountered an error after 0s —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 486e2fc72f
ℹ️ 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".
486e2fc to
1a2dbde
Compare
|
Claude encountered an error after 0s —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1a2dbde376
ℹ️ 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".
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #30 +/- ##
==========================================
+ Coverage 81.76% 81.90% +0.13%
==========================================
Files 97 97
Lines 20839 20935 +96
Branches 4546 4581 +35
==========================================
+ Hits 17040 17147 +107
+ Misses 3799 3788 -11 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Preserve primary checkout classification, propagate configured base branches, clamp worktree paths, and save through the canonical local config.
|
Claude encountered an error after 0s —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: adf495b639
ℹ️ 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".
| const mainWorktree = getMainWorktree(cwd); | ||
| if (!mainWorktree) { | ||
| return false; |
There was a problem hiding this comment.
Preserve linked-worktree detection for non-default bases
In a bare-container repository configured with a base such as develop and no main checkout, this calls getMainWorktree without the configured base, so it returns null and isWorktree returns false for every linked feature checkout. For feature paths that do not match the .prN naming shortcut, detectWorktreeType consequently reports main_worktree; newpr then skips its PR-worktree warning and can proceed in non-interactive mode from the linked checkout. Preserve detection from the current worktree entry or propagate the resolved base branch here.
Useful? React with 👍 / 👎.
| const localSource = loadSingleConfigFile(localPath, 'local', false); | ||
| return localSource?.config.baseBranch === worktree.branch; |
There was a problem hiding this comment.
Keep local config discoverable after changing its base branch
When a bare layout has a local-only baseBranch: "develop", editing that value to trunk now saves back to the canonical develop/.worktreerc.local, but this predicate subsequently rejects the file because its declared branch no longer equals the checkout branch. From any other linked checkout, bootstrap then falls back to the default/global base, misses the edited file, and silently loses all local overrides. The new canonical editor save path makes this reproducible, so changing the base branch must either relocate the local file or retain a way to discover it after the value changes.
Useful? React with 👍 / 👎.
| worktreePattern: config.worktreePattern, | ||
| baseBranch: config.baseBranch, |
There was a problem hiding this comment.
Forward canonical list options into interactive refreshes
The main-menu flow uses the configured pattern and base branch for its initial gather, but passes a fresh options object without either value to runInteractiveMode. After an action requests refresh, src/lib/lswt/interactive.ts re-runs gatherWorktreeInfo with that incomplete object, so a bare layout using develop or a custom PR pattern immediately reclassifies its canonical and PR worktrees incorrectly. Pass the same configured options into the interactive loop.
Useful? React with 👍 / 👎.
|
/approve |
|
🎉 This PR is included in version 1.15.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
wt configedits back to the canonical active configuration file instead of creating a shadow config in the invoking linked checkout.Diagnosis
In SyRF's nested layout, the main checkout is
/home/chris/workspace/syrf/main, while its repository-local configuration resolves the canonical worktree parent to/home/chris/workspace/syrf/pr. Commands invoked from another linked worktree previously lost that local tier, could misclassify the invoking worktree asmain, and could fall back to an assumed.worktreeslocation.The fix is layout-driven rather than SyRF-specific: canonical checkout discovery, config resolution, listing, checkout, editing, and placement now share the same configured base-branch context.
No SyRF checkout or worktree was modified while testing.
Validation
.bare + main + prlayout, placing the new worktree under the configuredpr/parent with no.worktreesdirectory.develop-only layout with a locally configured base branch and a non-.bareshared repository name.pnpm run buildpnpm run lint(0 errors; existing warnings only)pnpm run format:checkgit diff --checkReview follow-up
All seven Codex review findings were addressed in
adf495b, replied to with evidence, and resolved.