feat(tui): add onClick handler to InlineTool and Task components (#16187)

This commit is contained in:
Dax 2026-03-05 10:02:30 -05:00 committed by GitHub
parent 9cccaa693a
commit 4da199697b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1625,11 +1625,14 @@ function InlineTool(props: {
spinner?: boolean
children: JSX.Element
part: ToolPart
onClick?: () => void
}) {
const [margin, setMargin] = createSignal(0)
const { theme } = useTheme()
const ctx = use()
const sync = useSync()
const renderer = useRenderer()
const [hover, setHover] = createSignal(false)
const permission = createMemo(() => {
const callID = sync.data.permission[ctx.sessionID]?.at(0)?.tool?.callID
@ -1639,6 +1642,7 @@ function InlineTool(props: {
const fg = createMemo(() => {
if (permission()) return theme.warning
if (hover() && props.onClick) return theme.text
if (props.complete) return theme.textMuted
return theme.text
})
@ -1656,6 +1660,12 @@ function InlineTool(props: {
<box
marginTop={margin()}
paddingLeft={3}
onMouseOver={() => props.onClick && setHover(true)}
onMouseOut={() => setHover(false)}
onMouseUp={() => {
if (renderer.getSelection()?.getSelectedText()) return
props.onClick?.()
}}
renderBefore={function () {
const el = this as BoxRenderable
const parent = el.parent
@ -1999,6 +2009,11 @@ function Task(props: ToolProps<typeof TaskTool>) {
complete={props.input.description}
pending="Delegating..."
part={props.part}
onClick={() => {
if (props.metadata.sessionId) {
navigate({ type: "session", sessionID: props.metadata.sessionId })
}
}}
>
{content()}
</InlineTool>