Skip to content

Commit 032fb41

Browse files
authored
feat(tui): add UI for skill tool in session view (anomalyco#11561)
1 parent d5955da commit 032fb41

1 file changed

Lines changed: 22 additions & 15 deletions

File tree

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

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

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import type { ApplyPatchTool } from "@/tool/apply_patch"
4343
import type { WebFetchTool } from "@/tool/webfetch"
4444
import type { TaskTool } from "@/tool/task"
4545
import type { QuestionTool } from "@/tool/question"
46+
import type { SkillTool } from "@/tool/skill"
4647
import { useKeyboard, useRenderer, useTerminalDimensions, type JSX } from "@opentui/solid"
4748
import { useSDK } from "@tui/context/sdk"
4849
import { useCommandDialog } from "@tui/component/dialog-command"
@@ -1447,6 +1448,9 @@ function ToolPart(props: { last: boolean; part: ToolPart; message: AssistantMess
14471448
<Match when={props.part.tool === "question"}>
14481449
<Question {...toolprops} />
14491450
</Match>
1451+
<Match when={props.part.tool === "skill"}>
1452+
<Skill {...toolprops} />
1453+
</Match>
14501454
<Match when={true}>
14511455
<GenericTool {...toolprops} />
14521456
</Match>
@@ -1797,7 +1801,7 @@ function Task(props: ToolProps<typeof TaskTool>) {
17971801

17981802
return (
17991803
<Switch>
1800-
<Match when={props.metadata.summary?.length}>
1804+
<Match when={props.input.description || props.input.subagent_type}>
18011805
<BlockTool
18021806
title={"# " + Locale.titlecase(props.input.subagent_type ?? "unknown") + " Task"}
18031807
onClick={
@@ -1809,7 +1813,7 @@ function Task(props: ToolProps<typeof TaskTool>) {
18091813
>
18101814
<box>
18111815
<text style={{ fg: theme.textMuted }}>
1812-
{props.input.description} ({props.metadata.summary?.length} toolcalls)
1816+
{props.input.description} ({props.metadata.summary?.length ?? 0} toolcalls)
18131817
</text>
18141818
<Show when={current()}>
18151819
<text style={{ fg: current()!.state.status === "error" ? theme.error : theme.textMuted }}>
@@ -1818,22 +1822,17 @@ function Task(props: ToolProps<typeof TaskTool>) {
18181822
</text>
18191823
</Show>
18201824
</box>
1821-
<text fg={theme.text}>
1822-
{keybind.print("session_child_cycle")}
1823-
<span style={{ fg: theme.textMuted }}> view subagents</span>
1824-
</text>
1825+
<Show when={props.metadata.sessionId}>
1826+
<text fg={theme.text}>
1827+
{keybind.print("session_child_cycle")}
1828+
<span style={{ fg: theme.textMuted }}> view subagents</span>
1829+
</text>
1830+
</Show>
18251831
</BlockTool>
18261832
</Match>
18271833
<Match when={true}>
1828-
<InlineTool
1829-
icon="◉"
1830-
iconColor={color()}
1831-
pending="Delegating..."
1832-
complete={props.input.subagent_type ?? props.input.description}
1833-
part={props.part}
1834-
>
1835-
<span style={{ fg: theme.text }}>{Locale.titlecase(props.input.subagent_type ?? "unknown")}</span> Task "
1836-
{props.input.description}"
1834+
<InlineTool icon="#" pending="Delegating..." complete={props.input.subagent_type} part={props.part}>
1835+
{props.input.subagent_type} Task {props.input.description}
18371836
</InlineTool>
18381837
</Match>
18391838
</Switch>
@@ -2038,6 +2037,14 @@ function Question(props: ToolProps<typeof QuestionTool>) {
20382037
)
20392038
}
20402039

2040+
function Skill(props: ToolProps<typeof SkillTool>) {
2041+
return (
2042+
<InlineTool icon="→" pending="Loading skill..." complete={props.input.name} part={props.part}>
2043+
Skill "{props.input.name}"
2044+
</InlineTool>
2045+
)
2046+
}
2047+
20412048
function normalizePath(input?: string) {
20422049
if (!input) return ""
20432050
if (path.isAbsolute(input)) {

0 commit comments

Comments
 (0)