Skip to content

fix: use canonical worktree context across linked checkouts - #30

Merged
chrissena merged 2 commits into
mainfrom
feat/fix-nested-workspace-worktree-path-resolution-4gntzs
Aug 28, 2026
Merged

chrissena merged 2 commits into
mainfrom
feat/fix-nested-workspace-worktree-path-resolution-4gntzs

Conversation

@chrissena

@chrissena chrissena commented Aug 28, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Resolve one canonical checkout/configuration context across conventional repositories and bare-container workspaces, including non-default base branches stored only in repository-local configuration.
  • Propagate the configured base branch through worktree listing and remote-PR checkout flows so the real base checkout is classified and used consistently.
  • Anchor worktree placement to the detected bare-repository container, support custom bare-directory names, and clamp both leading and embedded relative-path traversal.
  • Save wt config edits 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 as main, and could fall back to an assumed .worktrees location.

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

  • Full local suite: 124 test files and 3,700 tests passed.
  • Focused regression suite: 9 files and 424 tests passed.
  • Disposable CLI fixture: created and listed worktrees in a real nested .bare + main + pr layout, placing the new worktree under the configured pr/ parent with no .worktrees directory.
  • Custom bare-container integration fixture: bootstrapped a develop-only layout with a locally configured base branch and a non-.bare shared repository name.
  • pnpm run build
  • pnpm run lint (0 errors; existing warnings only)
  • pnpm run format:check
  • git diff --check
  • GitHub CI matrix passed on Ubuntu, macOS, and Windows for the supported Node versions.

Review follow-up

All seven Codex review findings were addressed in adf495b, replied to with evidence, and resolved.

@claude

claude Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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: 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".

Comment thread src/lib/git.ts Outdated
Comment thread src/lib/lswt/worktree-info.ts Outdated
Comment thread src/lib/config.ts Outdated
Comment thread src/lib/config.ts
@chrissena
chrissena force-pushed the feat/fix-nested-workspace-worktree-path-resolution-4gntzs branch from 486e2fc to 1a2dbde Compare August 28, 2026 01:25
@claude

claude Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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: 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".

Comment thread src/lib/config.ts
Comment thread src/lib/lswt/action-executors.ts Outdated
Comment thread src/lib/config.ts Outdated
@codecov

codecov Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.20000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.90%. Comparing base (4087f41) to head (adf495b).
⚠️ Report is 4 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/lib/config.ts 94.44% 4 Missing ⚠️
src/lib/git.ts 85.71% 2 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Preserve primary checkout classification, propagate configured base branches, clamp worktree paths, and save through the canonical local config.
@claude

claude Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

@chrissena chrissena added the bug Something isn't working label Aug 28, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot 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: 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".

Comment thread src/lib/git.ts
Comment on lines +453 to +455
const mainWorktree = getMainWorktree(cwd);
if (!mainWorktree) {
return false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Comment thread src/lib/config.ts
Comment on lines +512 to +513
const localSource = loadSingleConfigFile(localPath, 'local', false);
return localSource?.config.baseBranch === worktree.branch;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Comment on lines +271 to +272
worktreePattern: config.worktreePattern,
baseBranch: config.baseBranch,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@chrissena
chrissena merged commit 94a99ca into main Aug 28, 2026
30 of 31 checks passed
@chrissena

Copy link
Copy Markdown
Member Author

/approve

@github-actions github-actions Bot 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.

Approved by repository admin via /approve command.

@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.15.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

bug Something isn't working released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant