Skip to content

Add go command for existing worktrees#47

Open
cmalherbe-atlassian wants to merge 5 commits into
kunchenguid:mainfrom
cmalherbe-atlassian:fm/treehouse-go-sessions-m8
Open

Add go command for existing worktrees#47
cmalherbe-atlassian wants to merge 5 commits into
kunchenguid:mainfrom
cmalherbe-atlassian:fm/treehouse-go-sessions-m8

Conversation

@cmalherbe-atlassian

Copy link
Copy Markdown

Problem

Treehouse can create or lease worktrees, but there is no quick way to see existing sessions and jump back into one from an arbitrary directory. Users need a navigation command that works globally across managed pools, not just from the repository that owns a specific pool.

Implementation summary

  • Adds treehouse go [target].
  • With no target, lists all existing Treehouse-managed worktrees under the user-level Treehouse root and prompts for a numeric selection.
  • With a target, resolves a unique existing worktree by exact path, basename, Treehouse state name, or unique substring.
  • Opens a shell in the selected worktree using the same shell spawning path as treehouse get.
  • Does not acquire a new worktree and does not return the selected worktree to the pool when the shell exits.
  • Reuses Treehouse state/list primitives instead of adding another state source.
  • Shows the interactive choices in a table with status, project, and location.
  • Truncates long project names to keep the table readable while leaving full locations visible.

Examples

Interactive navigation from anywhere:

treehouse go

Example output:

🌳 Treehouse worktrees:
#   Status       Project               Location
--  -----------  --------------------  --------
1   [available]  jira                  ~/.treehouse/jira-abc123/1/jira
2   [leased   ]  treehouse             ~/.treehouse/treehouse-def456/2/treehouse  (held by claude)
3   [available]  otherrepo-with-a-...  ~/.treehouse/otherrepo-with-a-very-long-name-c2a333/1/otherrepo-with-a-very-long-name
Choose a worktree:

Direct navigation by basename:

treehouse go jira

Direct navigation by unique substring:

treehouse go auth-refactor

Direct navigation by path:

treehouse go ~/.treehouse/treehouse-def456/2/treehouse

Ambiguous targets fail clearly instead of choosing silently:

Error: target "tree" is ambiguous; matches: t1 (...), t2 (...)

Validation

  • go test ./internal/pool ./cmd -run 'Test(ListNavigation|ResolveNavigation|Go)'
  • go test ./cmd -run TestGoInteractiveListsGlobalWorktreesAndOpensSelection
  • go test ./cmd -run 'Test(TruncateTableCell|GoInteractiveListsGlobalWorktreesAndOpensSelection)'
  • go test ./...
  • GOOS=windows go build ./...
  • Lightweight code review by subagent for the changed Go files.

Risks

  • The project label is derived from the managed pool directory name. This mirrors Treehouse's existing pool layout and strips the generated hash suffix for readability.
  • The command opens an interactive shell, so automated tests use the existing test shell shim rather than launching a real user shell.

Follow-ups

  • Consider adding a non-interactive --json or --plain list mode if scripts need to consume the global session list later.
  • Consider optional path truncation if the location column becomes too wide in terminals.

@cmalherbe-atlassian cmalherbe-atlassian marked this pull request as ready for review June 30, 2026 07:53
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.

1 participant