Skip to content

fix(gitinfo): capture worktree path at double-click time & broadcast PATH on install - #59

Merged
jongio merged 4 commits into
mainfrom
fix/worktree-change-dir
May 14, 2026
Merged

jongio merged 4 commits into
mainfrom
fix/worktree-change-dir

Conversation

@jongio

@jongio jongio commented May 14, 2026

Copy link
Copy Markdown
Owner

Summary

Two fixes:

  1. Worktree change-directory bug — Double-clicking a worktree in the gitinfo panel and selecting Change directory from the first-use confirmation did nothing because background data reloads reset the tab cursor while the modal was open. Now the worktree path is captured at double-click time into a \pendingPath\ field (matching the standalone worktrees panel pattern).

  2. mage install PATH propagation — After adding the bin directory to User PATH, broadcast \WM_SETTINGCHANGE\ so new terminals pick up the change immediately. Also adds an early-return check if User PATH already contains the entry.

Testing

  • Added regression test \TestDoAction_FirstUseWorktreeCursorReset\
  • All existing tests pass

Resolves #58

jongio and others added 2 commits May 13, 2026 16:43
…e flow

The gitinfo panel's doAction() did not store the worktree path before
showing the first-use confirmation modal. If a data reload (fsnotify,
auto-fetch) reset the cursor while the modal was displayed, the
subsequent executeRightClickAction would read the wrong item (cursor 0)
or silently return nil.

Fix: store pendingPath on the panel when the first-use or right-click
picker modal is shown for a worktree item. requestWorktreeSwitch() and
the other worktree actions now prefer pendingPath over re-reading from
the cursor, matching the pattern already used by the standalone
worktrees panel.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ensurePath now:
- Checks User PATH before attempting to modify (avoids redundant writes)
- Broadcasts WM_SETTINGCHANGE after modifying persistent PATH so new
  terminals pick up the change without requiring a reboot
- Prints a refresh hint when PATH was just added for the first time

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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

Fixes two unrelated issues: (1) a worktree change-directory bug in the gitinfo panel where async data reloads reset the tab cursor while the first-use confirmation modal was open, causing the wrong/empty path to be used; and (2) mage install not broadcasting environment changes so newly-spawned terminals could pick up the updated PATH without a reboot.

Changes:

  • Adds a pendingPath field on the gitinfo Panel, captured at right-click/double-click time and restored across modal round-trips so worktree actions use the originally-clicked path.
  • Adds a regression test covering the cursor-reset scenario.
  • Adds an early-return when User PATH already contains the bin directory, and broadcasts WM_SETTINGCHANGE after persistent PATH updates.
Show a summary per file
File Description
internal/panels/gitinfo/gitinfo.go Captures worktree path at double-click/right-click; restores it through handleModalResult so executeRightClickAction and requestWorktreeSwitch can use it.
internal/panels/gitinfo/gitinfo_test.go Adds TestDoAction_FirstUseWorktreeCursorReset regression test simulating cursor reset during modal display.
magefile.go Adds User-PATH precheck, calls new broadcastPathChange (PowerShell P/Invoke of SendMessageTimeout) after PATH mutation, and prints a one-liner for the current shell.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 4

Comment thread internal/panels/gitinfo/gitinfo.go
Comment thread magefile.go Outdated
Comment thread magefile.go Outdated
Comment thread internal/panels/gitinfo/gitinfo.go
…e pendingPath

- Only call broadcastPathChange() when a PATH update actually succeeded
- Log error if WM_SETTINGCHANGE broadcast fails (PowerShell unavailable)
- Clear pendingPath for non-worktree right-clicks to prevent stale state

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 2

Comment thread magefile.go Outdated
Comment thread internal/panels/gitinfo/gitinfo.go
- Only show 'To use in this terminal' on PATH success; warn on failure
- Clear pendingPath for non-worktree items in doAction (matches rightclick)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new

@jongio
jongio merged commit 8c3093c into main May 14, 2026
3 checks passed
@jongio
jongio deleted the fix/worktree-change-dir branch May 14, 2026 16:06
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.

Worktree change-directory does nothing after first-use confirmation

2 participants