Skip to content

Commit 4da1996

Browse files
authored
feat(tui): add onClick handler to InlineTool and Task components (#16187)
1 parent 9cccaa6 commit 4da1996

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

  • packages/opencode/src/cli/cmd/tui/routes/session

packages/opencode/src/cli/cmd/tui/routes/session/index.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,11 +1625,14 @@ function InlineTool(props: {
16251625
spinner?: boolean
16261626
children: JSX.Element
16271627
part: ToolPart
1628+
onClick?: () => void
16281629
}) {
16291630
const [margin, setMargin] = createSignal(0)
16301631
const { theme } = useTheme()
16311632
const ctx = use()
16321633
const sync = useSync()
1634+
const renderer = useRenderer()
1635+
const [hover, setHover] = createSignal(false)
16331636

16341637
const permission = createMemo(() => {
16351638
const callID = sync.data.permission[ctx.sessionID]?.at(0)?.tool?.callID
@@ -1639,6 +1642,7 @@ function InlineTool(props: {
16391642

16401643
const fg = createMemo(() => {
16411644
if (permission()) return theme.warning
1645+
if (hover() && props.onClick) return theme.text
16421646
if (props.complete) return theme.textMuted
16431647
return theme.text
16441648
})
@@ -1656,6 +1660,12 @@ function InlineTool(props: {
16561660
<box
16571661
marginTop={margin()}
16581662
paddingLeft={3}
1663+
onMouseOver={() => props.onClick && setHover(true)}
1664+
onMouseOut={() => setHover(false)}
1665+
onMouseUp={() => {
1666+
if (renderer.getSelection()?.getSelectedText()) return
1667+
props.onClick?.()
1668+
}}
16591669
renderBefore={function () {
16601670
const el = this as BoxRenderable
16611671
const parent = el.parent
@@ -1999,6 +2009,11 @@ function Task(props: ToolProps<typeof TaskTool>) {
19992009
complete={props.input.description}
20002010
pending="Delegating..."
20012011
part={props.part}
2012+
onClick={() => {
2013+
if (props.metadata.sessionId) {
2014+
navigate({ type: "session", sessionID: props.metadata.sessionId })
2015+
}
2016+
}}
20022017
>
20032018
{content()}
20042019
</InlineTool>

0 commit comments

Comments
 (0)