Skip to content

feat(worktree): suggest reparenting when Claude cd's into a worktree#101

Merged
nek0der merged 1 commit into
mainfrom
feat/worktree-move-suggest
May 31, 2026
Merged

feat(worktree): suggest reparenting when Claude cd's into a worktree#101
nek0der merged 1 commit into
mainfrom
feat/worktree-move-suggest

Conversation

@nek0der
Copy link
Copy Markdown
Owner

@nek0der nek0der commented May 31, 2026

Summary

When Claude cds into a worktree the source tab doesn't own, surface a
bottom-anchored banner asking whether to move the tab there. Accept
reparents the source tab so the running pty follows the cd — no respawn,
no --resume. Useful when you tell Claude "make a worktree and work
there" and end up with the agent operating from a different cwd than the
tab that owns it.

  • CwdChanged hook subscriptionclaude-shim/limpid-hook writes
    per-pane {oldCwd, newCwd, updatedAt} records into a new cwd-events
    directory; CwdEventTracker watches with DispatchSource (same shape
    as the existing agent / session trackers).
  • 3-state matcherRegisteredMatch enum distinguishes
    noRegisteredWorktreeContains (fall through to a git worktree list
    shell-out for unregistered worktrees), alreadyInsideSourceWorktree
    (no-op, no shell-out), and reparentTo(Kind) (surface the banner).
    Conflating the first two with a single nil would have produced
    duplicate worktree rows when the agent navigates around inside its
    own worktree.
  • Active-tab gating — banner only surfaces while the source tab is
    the active tab. If a cd lands while the user is on a different tab,
    the suggestion is parked under that tab's id; landing on it later
    surfaces it. Leaving the tab while a banner is visible re-parks.
  • didClosePane wiringTabActions.closeTab / closeActivePane
    now route into CwdEventTracker and SessionTrackers carries a
    cwdEvent slot. A lazy sweep on activeTabDidChange catches close
    paths that don't thread the tracker through.

Related issue

Skip.

Checklist

  • Builds locally (make build)
  • Tests pass (make test)
  • Tests added or updated where applicable
  • Verified the change manually on macOS 26 (Tahoe)
  • Code comments are in English
  • CHANGELOG.md updated (under [Unreleased]) if user-visible

Subscribe to Claude Code's CwdChanged hook and surface a bottom
banner when the agent moves into a directory that belongs to a
different worktree from the source tab's container. Accept reparents
the source tab so the running pty follows; no respawn, no resume.

Handles three transitions: registered worktree (reparent), unknown
git worktree of a tracked project (attach then reparent), and inside
the source tab's own worktree (no-op). Banner gates on the active
tab so the "which tab is this about?" ambiguity stays closed.
@nek0der nek0der enabled auto-merge (squash) May 31, 2026 09:36
@nek0der nek0der merged commit 2271297 into main May 31, 2026
6 checks passed
@nek0der nek0der deleted the feat/worktree-move-suggest branch May 31, 2026 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant