Skip to content

Commit 41488bd

Browse files
committed
fix: keep inline tool call open while selecting text
Drag-selecting text inside an expanded ToolCallView or ExecuteToolView released on the outer Box, which fired the toggle's onClick and collapsed the card before the selection could be copied. Guard the handler with window.getSelection(), matching the existing pattern in SessionView. Generated-By: PostHog Code Task-Id: ee883416-a83f-4b1d-b097-6164d01f04fe
1 parent 180b915 commit 41488bd

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

apps/code/src/renderer/features/sessions/components/session-update/ExecuteToolView.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ export function ExecuteToolView({
4545
const isExpandable = hasOutput;
4646

4747
const handleClick = () => {
48-
if (isExpandable) {
49-
setIsExpanded(!isExpanded);
50-
}
48+
if (!isExpandable) return;
49+
const selection = window.getSelection();
50+
if (selection && selection.toString().length > 0) return;
51+
setIsExpanded(!isExpanded);
5152
};
5253

5354
return (

apps/code/src/renderer/features/sessions/components/session-update/ToolCallView.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@ export function ToolCallView({
8888
const isExpandable = !!fullInput || hasOutput;
8989

9090
const handleClick = () => {
91-
if (isExpandable) {
92-
setIsExpanded(!isExpanded);
93-
}
91+
if (!isExpandable) return;
92+
const selection = window.getSelection();
93+
if (selection && selection.toString().length > 0) return;
94+
setIsExpanded(!isExpanded);
9495
};
9596

9697
return (

0 commit comments

Comments
 (0)