Prevent worktree switch when selecting text on hovercards

Check for active text selection in the card click handler and bail
out, so selecting text in PR/issue/comment hovercards doesn't
accidentally switch the active worktree.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Neil
2026-03-21 16:50:44 -07:00
co-authored by Claude Opus 4.6
parent 80414a94ca
commit ae0f656e08
@@ -144,11 +144,12 @@ const WorktreeCard = React.memo(function WorktreeCard({
}
}, [repo, worktree.linkedIssue, issue, fetchIssue, issueCacheKey])
// Stable click handler
const handleClick = useCallback(
() => setActiveWorktree(worktree.id),
[worktree.id, setActiveWorktree]
)
// Stable click handler – ignore clicks that are really text selections
const handleClick = useCallback(() => {
const selection = window.getSelection()
if (selection && selection.toString().length > 0) return
setActiveWorktree(worktree.id)
}, [worktree.id, setActiveWorktree])
const handleToggleUnreadQuick = useCallback(
(event: React.MouseEvent<HTMLButtonElement>) => {