Skip to content

fix: Include main worktree in wt go menu and name resolution - #41

Merged
sahil-noon merged 4 commits into
mainfrom
260718-daqj-go-include-main-worktree
Jul 18, 2026
Merged

sahil-noon merged 4 commits into
mainfrom
260718-daqj-go-include-main-worktree

Conversation

@sahil-noon

Copy link
Copy Markdown
Collaborator

Meta

Change ID Type Confidence Plan Review
daqj fix 4.5/5.0 8/8 tasks, 12/12 acceptance ✓ ✓ 2 cycles
Impact +/− Net
raw +921 / −160 +761
true +233 / −61 +172
└ impl +64 / −44 +20
└ tests +169 / −17 +152

excludes fab/, docs/ · generated by fab-kit v2.15.5

Pipeline: intake ✓ → apply ✓ → review ✓ → hydrate ✓ → ship → review-pr

Summary

wt go's selection menu excluded the main worktree, so the most common navigation — back to the main repo — was unreachable from the menu, and wt go main failed outright, contradicting wt list's convention of displaying main as main pinned to row 1. This change drops the exclusion in the shared selectWorktree helper, pins main as row 1 across all three callers (wt go, wt open no-arg, wt open --select), and teaches resolveWorktreeByName a stable main key (exact-basename match still takes precedence).

Changes

  • selectWorktree includes the main worktree, pinned to row 1
  • The pre-selected menu default stays the newest worktree (NOT main)
  • resolveWorktreeByName learns a stable main key (exact-basename precedence)
  • The "No worktrees found." path becomes the one-row menu
  • Spec and memory amendments (this change IS the spec amendment)

sahil87 added 2 commits July 18, 2026 14:01
selectWorktree filtered out the main repo, so wt go's menu couldn't
navigate back to it and wt go main failed, contradicting wt list's
main-pinned-row-1 convention. Drop the filter, pin main as row 1,
and teach resolveWorktreeByName a stable "main" key (exact-basename
match still takes precedence).
@sahil-noon
sahil-noon marked this pull request as ready for review July 18, 2026 08:41
@sahil-noon
sahil-noon requested a review from Copilot July 18, 2026 08:42

Copilot AI 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.

Pull request overview

Updates the wt go / wt open worktree selection and name-resolution behavior to make the main worktree reachable and consistently addressable as main, aligning the menu and resolver semantics with wt list’s convention.

Changes:

  • Include the main worktree in the shared selection menu, pinned to row 1, while keeping the default selection on the newest non-main worktree.
  • Add a stable main key to resolveWorktreeByName (with exact-basename precedence preserved).
  • Update unit/integration tests and specs/memory docs to reflect the new menu + resolver contract and retire the prior “No worktrees found.” path.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/cmd/wt/open.go Pins main in shared selector; adds stable main resolver key; updates callers for new selector signature.
src/cmd/wt/open_test.go Updates menu-order assertions and adds wt open main resolution coverage.
src/cmd/wt/integration_test.go Updates wt go menu ordering expectations and adds end-to-end wt go main coverage from a sibling worktree.
src/cmd/wt/go.go Updates selector call site for new signature; simplifies cancel handling.
src/cmd/wt/go_test.go Replaces “no worktrees” test with one-row main-menu behavior; adds main key resolution tests.
fab/changes/260718-daqj-go-include-main-worktree/plan.md Captures requirements/tasks/acceptance criteria for the change.
fab/changes/260718-daqj-go-include-main-worktree/intake.md Documents rationale, decisions, and scope boundaries for the change.
fab/changes/260718-daqj-go-include-main-worktree/.status.yaml Tracks fab pipeline status/metrics for the change.
fab/changes/260718-daqj-go-include-main-worktree/.history.jsonl Records fab stage transition history for the change.
docs/specs/launcher-contract.md Documents main name-resolution semantics for wt open.
docs/specs/cli-surface.md Updates user-facing CLI surface for menu contents/defaulting and main resolution.
docs/memory/wt-cli/recency-ordering-contract.md Amends recency/menu ordering contract to account for pinned main row and shifted default index.
docs/memory/wt-cli/menu-navigation-contract.md Updates selectWorktree signature reference while keeping navigation contract unchanged.
docs/memory/wt-cli/index.md Updates memory index summary for the wt go contract changes.
docs/memory/wt-cli/go-command-contract.md Updates go-command contract for pinned main row, stable main key, and retired no-worktrees split.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/cmd/wt/open.go
Comment on lines 384 to 387
entries, err := listWorktreeEntries()
if err != nil {
return "", "", false, false, err
return "", "", false, err
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed — selectWorktree now fails fast when git worktree list returns zero entries, so it can no longer build a zero-option menu whose empty-input default (defaultIdx=1) would panic at options[choice-1]. (This path is defensive/unreachable in a validated git repo, which always yields the main worktree, but the guard removes the invalid menu state entirely.) (7a292f9)

@sahil-noon
sahil-noon merged commit c83fdeb into main Jul 18, 2026
2 checks passed
@sahil-noon
sahil-noon deleted the 260718-daqj-go-include-main-worktree branch July 18, 2026 11:32
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.

3 participants