Răsfoiți Sursa

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

Dax 1 lună în urmă
părinte
comite
4da199697b
1 a modificat fișierele cu 15 adăugiri și 0 ștergeri
  1. 15 0
      packages/opencode/src/cli/cmd/tui/routes/session/index.tsx

+ 15 - 0
packages/opencode/src/cli/cmd/tui/routes/session/index.tsx

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