Repository navigation
fix(gitinfo): capture worktree path at double-click time & broadcast PATH on install - #59
Merged
Merged
Conversation
…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>
There was a problem hiding this comment.
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
pendingPathfield on the gitinfoPanel, 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_SETTINGCHANGEafter 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
…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>
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two fixes:
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).
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
Resolves #58