Skip to content

Commit e3a787a

Browse files
authored
tui: use arrow indicator for active tool execution (#15887)
1 parent 74ebb41 commit e3a787a

1 file changed

Lines changed: 31 additions & 29 deletions

File tree

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

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

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ export function Session() {
241241
const logo = UI.logo(" ").split(/\r?\n/)
242242
return exit.message.set(
243243
[
244-
``,
245244
`${logo[0] ?? ""}`,
246245
`${logo[1] ?? ""}`,
247246
`${logo[2] ?? ""}`,
@@ -1897,10 +1896,8 @@ function Read(props: ToolProps<typeof ReadTool>) {
18971896
</InlineTool>
18981897
<For each={loaded()}>
18991898
{(filepath) => (
1900-
<box paddingLeft={3}>
1901-
<text paddingLeft={3} fg={theme.textMuted}>
1902-
↳ Loaded {normalizePath(filepath)}
1903-
</text>
1899+
<box paddingLeft={5}>
1900+
<text fg={theme.textMuted}>⤷ Loaded {normalizePath(filepath)}</text>
19041901
</box>
19051902
)}
19061903
</For>
@@ -1994,33 +1991,32 @@ function Task(props: ToolProps<typeof TaskTool>) {
19941991
return assistant - first
19951992
})
19961993

1994+
const content = createMemo(() => {
1995+
if (!props.input.description) return ""
1996+
let content = [`Task ${props.input.description}`]
1997+
1998+
if (isRunning() && tools().length > 0) {
1999+
// content[0] += ` · ${tools().length} toolcalls`
2000+
if (current()) content.push(`└ ${Locale.titlecase(current()!.tool)} ${(current()!.state as any).title}`)
2001+
else content.push(`└ Running...`)
2002+
}
2003+
2004+
if (props.part.state.status === "completed") {
2005+
content.push(`└ ${tools().length} toolcalls · ${Locale.duration(duration())}`)
2006+
}
2007+
2008+
return content.join("\n")
2009+
})
2010+
19972011
return (
19982012
<InlineTool
1999-
icon=""
2013+
icon=""
20002014
spinner={isRunning()}
20012015
complete={props.input.description}
20022016
pending="Delegating..."
20032017
part={props.part}
20042018
>
2005-
{props.input.description}
2006-
<Show when={isRunning() && tools().length > 0}>
2007-
{" "}
2008-
· {tools().length} toolcalls
2009-
<Show fallback={"\n└ Running..."} when={current()}>
2010-
{(item) => {
2011-
const title = createMemo(() => (item().state as any).title)
2012-
return (
2013-
<>
2014-
{"\n"}{Locale.titlecase(item().tool)} {title()}
2015-
</>
2016-
)
2017-
}}
2018-
</Show>
2019-
</Show>
2020-
<Show when={duration() && props.part.state.status === "completed"}>
2021-
{"\n "}
2022-
{tools().length} toolcalls · {Locale.duration(duration())}
2023-
</Show>
2019+
{content()}
20242020
</InlineTool>
20252021
)
20262022
}
@@ -2240,10 +2236,16 @@ function Diagnostics(props: { diagnostics?: Record<string, Record<string, any>[]
22402236

22412237
function normalizePath(input?: string) {
22422238
if (!input) return ""
2243-
if (path.isAbsolute(input)) {
2244-
return path.relative(process.cwd(), input) || "."
2245-
}
2246-
return input
2239+
2240+
const cwd = process.cwd()
2241+
const absolute = path.isAbsolute(input) ? input : path.resolve(cwd, input)
2242+
const relative = path.relative(cwd, absolute)
2243+
2244+
if (!relative) return "."
2245+
if (!relative.startsWith("..")) return relative
2246+
2247+
// outside cwd - use absolute
2248+
return absolute
22472249
}
22482250

22492251
function input(input: Record<string, any>, omit?: string[]): string {

0 commit comments

Comments
 (0)