Repository navigation
fix: Include main worktree in wt go menu and name resolution - #41
Conversation
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).
There was a problem hiding this comment.
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
mainkey toresolveWorktreeByName(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.
| entries, err := listWorktreeEntries() | ||
| if err != nil { | ||
| return "", "", false, false, err | ||
| return "", "", false, err | ||
| } |
There was a problem hiding this comment.
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)
Meta
daqjexcludes
fab/,docs/· generated by fab-kit v2.15.5Pipeline: 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, andwt go mainfailed outright, contradictingwt list's convention of displaying main asmainpinned to row 1. This change drops the exclusion in the sharedselectWorktreehelper, pins main as row 1 across all three callers (wt go,wt openno-arg,wt open --select), and teachesresolveWorktreeByNamea stablemainkey (exact-basename match still takes precedence).Changes
selectWorktreeincludes the main worktree, pinned to row 1resolveWorktreeByNamelearns a stablemainkey (exact-basename precedence)