Skip to content

Commit 4c6be13

Browse files
committed
feat(tui): give every tool call the time, duration and message ID footer
A tool call's finish time and duration were easy to lose: a block tool appended them to its title, so a long multi-line title such as a plugin tool's prompt argument pushed them to the end of its last line, and an inline row whose arguments span lines did the same. The message ID had no place on tool calls at all. Tool calls now take footer.time, footer.duration and footer.message_id the same way the other entries do, whatever renders them - built-in, generic, plugin or MCP tools: toolFooter in session/index.tsx feeds formatToolTimestamp, which adds the message the call belongs to. A block tool puts them on its own last line; an inline row keeps them after its text unless the arguments span lines (footerBelow), in which case they get their own line. Defaults still show nothing. AI-Tool: opencode 1.18.34-vt-168-907b3bc518 AI-Model: anthropic/claude-opus-5-5 AI-Variant: high AI-Platform: linux AI-Harness: Vibeterm 18dc0eb AI-Session-ID: ses_ee68aab01ffei41gwUGJ5ESj6W
1 parent 8a940a7 commit 4c6be13

4 files changed

Lines changed: 62 additions & 22 deletions

File tree

‎packages/tui/src/config/index.tsx‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ export const Footer = Schema.Struct({
195195
[
196196
"When an entry happened: the time of day if today, the date and time otherwise.",
197197
"Applies to: user (prompt sent), assistant (turn finished, in its footer), text (text block finished, below it),",
198-
"reasoning (thinking block finished), tool (tool call finished), error (turn failed, in its error box),",
198+
"reasoning (thinking block finished), tool (every tool call, plugin and MCP tools included, when it finished),",
199+
"error (turn failed, in its error box),",
199200
"compaction (compaction started, in its divider).",
200201
"Default: the legacy timestamps list when set; otherwise prompts and turns follow /timestamps and /turn-times",
201202
"(turn_timing.time for turns) and the other types are hidden.",
@@ -204,7 +205,7 @@ export const Footer = Schema.Struct({
204205
duration: footerElement(
205206
[
206207
"How long an entry took. Applies to: assistant (the turn's own message), reasoning (the thinking block),",
207-
"tool (the tool call).",
208+
"tool (every tool call).",
208209
"Default: reasoning; turns follow /turn-durations (turn_timing.duration); tool calls when the legacy",
209210
"timestamps list includes 'tool'.",
210211
].join(" "),
@@ -213,7 +214,7 @@ export const Footer = Schema.Struct({
213214
"Time from the prompt to the end of the turn. Applies to: assistant, and only on a turn's final message, so 'important' and 'assistant' select the same footers as 'all'. Default: all.",
214215
),
215216
message_id: footerElement(
216-
"The message ID (msg_...), selectable for drag-to-copy, at the end of the footer. Applies to: user, assistant. Default: none.",
217+
"The message ID (msg_...), selectable for drag-to-copy, at the end of the footer. Applies to: user, assistant, tool (the message the call belongs to). Default: none.",
217218
),
218219
}).annotate({
219220
description: [

‎packages/tui/src/routes/session/index.tsx‎

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2179,7 +2179,13 @@ function GenericTool(props: ToolProps) {
21792179
<Show
21802180
when={props.output && ctx.showGenericToolOutput()}
21812181
fallback={
2182-
<InlineTool icon="⚙" pending="Writing command…" complete={true} part={props.part}>
2182+
<InlineTool
2183+
icon="⚙"
2184+
pending="Writing command…"
2185+
complete={true}
2186+
part={props.part}
2187+
footerBelow={input(props.input).includes("\n")}
2188+
>
21832189
{props.tool} {input(props.input)}
21842190
</InlineTool>
21852191
}
@@ -2209,6 +2215,7 @@ function InlineTool(props: {
22092215
failure?: string
22102216
spinner?: boolean
22112217
separate?: boolean
2218+
footerBelow?: boolean
22122219
children: JSX.Element
22132220
part: ToolPart
22142221
onClick?: () => void
@@ -2238,10 +2245,7 @@ function InlineTool(props: {
22382245

22392246
const failed = createMemo(() => Boolean(error() && !denied()))
22402247
const timestamp = createMemo(() =>
2241-
formatToolTimestamp(props.part.state, {
2242-
time: ctx.footer("time", "tool", props.part.messageID, props.part.id),
2243-
duration: ctx.footer("duration", "tool", props.part.messageID, props.part.id),
2244-
}),
2248+
formatToolTimestamp(props.part.state, toolFooter(ctx, props.part)),
22452249
)
22462250
const clickable = createMemo(() => Boolean(props.onClick || failed()))
22472251
const fg = createMemo(() => {
@@ -2269,6 +2273,7 @@ function InlineTool(props: {
22692273
failure={props.failure}
22702274
spinner={props.spinner}
22712275
separate={props.separate}
2276+
footerBelow={props.footerBelow}
22722277
timestamp={timestamp()}
22732278
timestampColor={theme.textMuted}
22742279
onMouseOver={() => clickable() && setHover(true)}
@@ -2302,6 +2307,7 @@ export function InlineToolRow(props: {
23022307
failure?: string
23032308
spinner?: boolean
23042309
separate?: boolean
2310+
footerBelow?: boolean
23052311
timestamp?: string
23062312
timestampColor?: RGBA
23072313
children: JSX.Element
@@ -2357,11 +2363,16 @@ export function InlineToolRow(props: {
23572363
attributes={props.denied ? TextAttributes.STRIKETHROUGH : undefined}
23582364
>
23592365
{props.failed && !props.complete ? (props.failure ?? props.children) : props.children}
2360-
<Show when={props.timestamp}>
2366+
<Show when={!props.footerBelow && props.timestamp}>
23612367
<span style={{ fg: props.timestampColor }}> · {props.timestamp}</span>
23622368
</Show>
23632369
</text>
23642370
</box>
2371+
<Show when={props.footerBelow && props.timestamp}>
2372+
<box paddingLeft={INLINE_TOOL_ICON_WIDTH}>
2373+
<text fg={props.timestampColor}>{props.timestamp}</text>
2374+
</box>
2375+
</Show>
23652376
</Show>
23662377
</Match>
23672378
</Switch>
@@ -2387,12 +2398,7 @@ function BlockTool(props: {
23872398
const [hover, setHover] = createSignal(false)
23882399
const error = createMemo(() => (props.part?.state.status === "error" ? props.part.state.error : undefined))
23892400
const timestamp = createMemo(() =>
2390-
props.part
2391-
? formatToolTimestamp(props.part.state, {
2392-
time: ctx.footer("time", "tool", props.part.messageID, props.part.id),
2393-
duration: ctx.footer("duration", "tool", props.part.messageID, props.part.id),
2394-
})
2395-
: undefined,
2401+
props.part ? formatToolTimestamp(props.part.state, toolFooter(ctx, props.part)) : undefined,
23962402
)
23972403
return (
23982404
<box
@@ -2421,7 +2427,6 @@ function BlockTool(props: {
24212427
fallback={
24222428
<text paddingLeft={3} fg={theme.textMuted}>
24232429
{title()}
2424-
{timestamp() ? ` · ${timestamp()}` : ""}
24252430
</text>
24262431
}
24272432
>
@@ -2433,8 +2438,10 @@ function BlockTool(props: {
24332438
<Show when={error()}>
24342439
<text fg={theme.error}>{error()}</text>
24352440
</Show>
2436-
<Show when={!props.title && timestamp()}>
2437-
<text fg={theme.textMuted}>{timestamp()}</text>
2441+
<Show when={timestamp()}>
2442+
<text paddingLeft={props.title ? 3 : 0} fg={theme.textMuted}>
2443+
{timestamp()}
2444+
</text>
24382445
</Show>
24392446
</box>
24402447
)
@@ -2707,11 +2714,25 @@ function Task(props: ToolProps) {
27072714
)
27082715
}
27092716

2710-
export function formatToolTimestamp(state: ToolPart["state"], show = { time: true, duration: true }) {
2717+
// The footer elements every tool call takes, whichever renderer draws it.
2718+
function toolFooter(ctx: ReturnType<typeof use>, part: ToolPart) {
2719+
const shows = (element: TuiConfig.FooterElement) => ctx.footer(element, "tool", part.messageID, part.id)
2720+
return {
2721+
time: shows("time"),
2722+
duration: shows("duration"),
2723+
messageID: shows("message_id") ? part.messageID : undefined,
2724+
}
2725+
}
2726+
2727+
export function formatToolTimestamp(
2728+
state: ToolPart["state"],
2729+
show: { time: boolean; duration: boolean; messageID?: string } = { time: true, duration: true },
2730+
) {
27112731
if (state.status !== "completed" && state.status !== "error") return
27122732
const details = [
27132733
show.time && Locale.todayTimeOrDateFirst(state.time.end),
27142734
show.duration && Locale.duration(Math.max(0, state.time.end - state.time.start)),
2735+
show.messageID,
27152736
].flatMap((detail) => (detail ? [detail] : []))
27162737
return details.length ? details.join(" · ") : undefined
27172738
}

‎packages/tui/test/cli/tui/inline-tool-wrap-snapshot.test.tsx‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,20 @@ describe("TUI inline tool wrapping", () => {
254254
expect(frame).toContain("→ Read src/index.ts · 1:07 PM · 1.2s")
255255
})
256256

257+
test("puts the tool footer on its own line when the row spans lines", async () => {
258+
const frame = await renderFrame(
259+
() => (
260+
<InlineToolRow icon="⚙" complete={true} pending="" footerBelow={true} timestamp="1:07 PM · 1.2s">
261+
{"vtps [prompt=first line\nsecond line]"}
262+
</InlineToolRow>
263+
),
264+
{ width: 72, height: 4 },
265+
)
266+
const lines = frame.split("\n").map((line) => line.trim())
267+
expect(lines).toContain("second line]")
268+
expect(lines).toContain("1:07 PM · 1.2s")
269+
})
270+
257271
test("formats a finished tool call's end time and duration", () => {
258272
const end = new Date()
259273
end.setHours(13, 7, 0, 0)
@@ -275,6 +289,10 @@ describe("TUI inline tool wrapping", () => {
275289
expect(formatToolTimestamp({ status: "error", input, error: "boom", time: { start, end: end.getTime() } })).toBe(
276290
`${time} · 1.2s`,
277291
)
292+
const completed = { status: "completed" as const, input, output: "", title: "", metadata: {}, time: { start, end: end.getTime() } }
293+
expect(formatToolTimestamp(completed, { time: false, duration: true, messageID: "msg_1" })).toBe("1.2s · msg_1")
294+
expect(formatToolTimestamp(completed, { time: false, duration: false, messageID: "msg_1" })).toBe("msg_1")
295+
expect(formatToolTimestamp(completed, { time: false, duration: false })).toBeUndefined()
278296
})
279297

280298
test("filters malformed nested tool wire data", () => {

‎packages/web/src/content/docs/tui.mdx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,19 +478,19 @@ Use `OPENCODE_TUI_CONFIG` to load a custom TUI config path.
478478
| `time` | When the entry happened | `user`, `assistant`, `text`, `reasoning`, `tool`, `error`, `compaction` | see below |
479479
| `duration` | How long the entry took | `assistant`, `reasoning`, `tool` | `"reasoning"` |
480480
| `total` | Time from your prompt to the end of the turn | `assistant`, final message of a turn only | `"all"` |
481-
| `message_id` | The message ID (`msg_...`), which you can select with the mouse to copy | `user`, `assistant` | `"none"` |
481+
| `message_id` | The message ID (`msg_...`), which you can select with the mouse to copy | `user`, `assistant`, `tool` | `"none"` |
482482

483483
| Type | Where |
484484
| ------------ | ------------------------------------------------------------- |
485485
| `user` | Below the prompt |
486486
| `assistant` | In the turn footer |
487487
| `text` | Below an assistant text block, when it finished |
488488
| `reasoning` | In the thinking block header |
489-
| `tool` | After a tool call, when it finished and how long it ran |
489+
| `tool` | Every tool call, plugin and MCP tools included |
490490
| `error` | In the error box of a failed turn |
491491
| `compaction` | In the compaction divider, when compaction started |
492492

493-
A type a key does not apply to has no effect, so `"all"` and `"important"` select only the entries listed under _Applies to_. A turn's last message always has a footer; `time`, `duration` and `message_id` also give its earlier messages, such as tool-call steps, a footer once they finish. A time from today shows the time of day; an older one shows the date, then the time.
493+
A type a key does not apply to has no effect, so `"all"` and `"important"` select only the entries listed under _Applies to_. A turn's last message always has a footer; `time`, `duration` and `message_id` also give its earlier messages, such as tool-call steps, a footer once they finish. A time from today shows the time of day; an older one shows the date, then the time. On a tool call, `time`, `duration` and `message_id` follow the call on one line, `· 9:16 PM · 1.5s · msg_...`; a call drawn as a block, or one whose arguments span lines, puts them on its own last line so a long command or prompt cannot push them out of sight. `message_id` there is the ID of the message the call belongs to.
494494

495495
```json title="tui.json"
496496
{

0 commit comments

Comments
 (0)