Skip to content

fix(mecatui): handle model selection in worktrees better - #1567

Merged
kantord merged 3 commits into
mainfrom
mecatui-model-default-per-repo-worktrees
Sep 16, 2026
Merged

kantord merged 3 commits into
mainfrom
mecatui-model-default-per-repo-worktrees

Conversation

@kantord

@kantord kantord commented Sep 15, 2026

Copy link
Copy Markdown
Member

Summary

  • /models persisted its pick keyed by the literal workspace realpath, so every git worktree of one repo got its own independent entry in models.yaml.
  • A worktree switch is no more a model-relevant event than a branch switch in a single checkout, which never changes the model — so this unifies model-selection identity across a repo's worktrees.
  • A workspace inside a git linked worktree now resolves its models.yaml key to the main checkout's root (read from git's on-disk worktree pointer files, no git subprocess). An ordinary checkout keeps its own realpath key, unchanged — existing entries for a main checkout are not invalidated.

Test plan

  • task lint — 0 issues
  • task test — full suite green (-race)
  • task docs:check — 0 broken links
  • New tests: worktrees of one repo share a single entry; ordinary (non-worktree) checkouts remain isolated as before

Fully or partially written by an AI agent.

🤖 Generated with Claude Code

/models persisted its pick keyed by the literal workspace realpath, so
every git worktree of one repo got its own independent entry — a
worktree switch is no more a model-relevant event than a branch switch
in a single checkout, which never changes the model.

A workspace inside a git linked worktree now resolves its models.yaml
key to the main checkout's root (read from git's on-disk worktree
pointer files, no `git` subprocess), so a pick made in any worktree
lands on the same entry as the others. An ordinary checkout keeps its
own realpath key, unchanged, so existing entries aren't invalidated.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@kantord kantord changed the title fix(mecatui): share model-selection identity across a repo's worktrees fix(mecatui): handle model selection in worktrees better Sep 15, 2026
@kantord
kantord marked this pull request as ready for review September 15, 2026 13:36
Comment thread cmd/mecatui/state.go Resolved
Comment thread cmd/mecatui/state.go Resolved
kantord and others added 2 commits September 16, 2026 10:50
…loss

Two bugs samuv flagged on the worktree-identity unification:

- A worktree of a BARE repository resolved to the parent of the bare
  repo's own directory, since a bare repo has no working-tree root.
  Worktrees of any two bare repos sharing a parent directory then
  collided onto one entry. Detect bareness from the repo's own
  "config" (git's own bare=true marker) and fall back to the
  worktree's own realpath when bare.

- A workspace nested below a linked worktree's root collapsed onto
  the bare main checkout root, discarding its offset — while the
  identical nested path under the main checkout kept its own distinct
  entry. Rejoin the workspace's offset below the discovered worktree
  root onto the main root, so a nested launch directory keeps the
  same identity it would have under the main checkout directly.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
samuv's follow-up: bareTrueRE only matched the literal string "true",
so "core.bare = yes" (a valid git boolean-true spelling git itself
accepts) still collided worktrees of different bare repos onto one
entry.

Replace it with a conservative check: unify onto the common dir's
parent ONLY when config names an explicit false-equivalent value
("false"/"no"/"off"/"0"); every true-equivalent spelling, a missing
key, and any unrecognized value fail closed as bare. Covered by a new
isBareGitDir table test plus a "bare = yes" regression on top of the
existing bare-repo test.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@kantord
kantord merged commit 8227371 into main Sep 16, 2026
62 of 64 checks passed
@kantord
kantord deleted the mecatui-model-default-per-repo-worktrees branch September 16, 2026 09:52
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Sep 21, 2026
2 tasks
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.

2 participants