Skip to content

fix: keep inline tool call open while selecting text#2216

Merged
thmsobrmlr merged 2 commits into
mainfrom
posthog-code/fix-tool-toggle-text-selection
May 19, 2026
Merged

fix: keep inline tool call open while selecting text#2216
thmsobrmlr merged 2 commits into
mainfrom
posthog-code/fix-tool-toggle-text-selection

Conversation

@thmsobrmlr
Copy link
Copy Markdown
Contributor

@thmsobrmlr thmsobrmlr commented May 19, 2026

TL;DR: I want to be able to select text from AskUserQuestion, but can't because it toggles when i release the mouse button

Summary

  • 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 user could copy.
  • Move the onClick, cursor-pointer, and group classes onto the header <Flex> so the expanded content is a sibling, not a child — matches the pattern already used by ReadToolView/FetchToolView/SearchToolView.
  • Cursor is now an I-beam over selectable output (instead of a pointer), and selection just works without any window.getSelection() guard.
  • Only these two views were affected; the other expandable tool views already used this layout, and Edit/Think/Subagent use dedicated <button> / IconButton for the toggle.

Test plan

  • pnpm --filter code typecheck
  • pnpm --filter code test (1244 tests pass)
  • Manual: trigger an ExecuteToolView (any Bash) or ToolCallView (unrecognized agent tool, e.g. AskUserQuestion), expand it, drag-select text in the body — card stays open, cursor shows I-beam.
  • Manual: click on the header (no selection) — card still toggles as before, cursor shows pointer.

Created with PostHog Code

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
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 19, 2026

Reviews (1): Last reviewed commit: "fix: keep inline tool call open while se..." | Re-trigger Greptile

@adboio adboio self-assigned this May 19, 2026
Move onClick onto the header Flex so the expanded content is a sibling, matching ReadToolView/FetchToolView/SearchToolView. Drops the window.getSelection() guard and makes the text cursor behave correctly over selectable output.

Generated-By: PostHog Code
Task-Id: 5e50fa6d-be32-4c59-8f3f-32682196f1d7
@adboio
Copy link
Copy Markdown
Contributor

adboio commented May 19, 2026

thanks!! this is a good improvement, but i made a small change - i like to select text by triple clicking and that doesn't work here, + (to me) the cursor staying as pointer didn't make it clear that text was selectable

what do you think about this? updated so the click target is only the top of the card, and the expanded stuff is treated normally

tool.call.clicking.mp4

@adboio
Copy link
Copy Markdown
Contributor

adboio commented May 19, 2026

@thmsobrmlr feel free to merge if you like this 🫡

@thmsobrmlr thmsobrmlr merged commit 304c9e8 into main May 19, 2026
15 checks passed
@thmsobrmlr thmsobrmlr deleted the posthog-code/fix-tool-toggle-text-selection branch May 19, 2026 19:31
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.

2 participants