Skip to content

Commit ba7ce1f

Browse files
committed
fix(tui): address review feedback on tool elapsed time
- Show shell duration next to the command line in ShellDisplay (BlockTool only renders elapsed for title/path blocks) - Revert FileTool wrapper around apply_patch/edit file list; show duration in per-file trigger actions instead - Rework elapsed snapshot test to avoid real Bun.sleep timing dependence
1 parent b30b9cc commit ba7ce1f

3 files changed

Lines changed: 13 additions & 9 deletions

File tree

‎packages/session-ui/src/tools/tool-renderer.tsx‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2280,8 +2280,7 @@ ToolRegistry.register({
22802280
return (
22812281
<div data-component="apply-patch-tool">
22822282
<Show when={files().length > 0} fallback={<FileTool {...props} title={title()} count={0} />}>
2283-
<FileTool {...props} title={title()} count={files().length}>
2284-
<FileAccordionGroup>
2283+
<FileAccordionGroup>
22852284
<Index each={files()}>
22862285
{(file) => {
22872286
const value = () => file().path
@@ -2338,6 +2337,7 @@ ToolRegistry.register({
23382337
/>
23392338
</Match>
23402339
</Switch>
2340+
<ToolElapsed time={props.time} running={props.status === "running"} />
23412341
<Icon name="chevron-grabber-vertical" size="small" />
23422342
</div>
23432343
</div>
@@ -2364,7 +2364,6 @@ ToolRegistry.register({
23642364
}}
23652365
</Index>
23662366
</FileAccordionGroup>
2367-
</FileTool>
23682367
</Show>
23692368
</div>
23702369
)

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2965,6 +2965,14 @@ function ShellDisplay(props: {
29652965
const collapsed = createMemo(() => collapseShellOutput(input(), output(), maxLines, maxChars()))
29662966
const limitedInput = createMemo(() => (expanded() ? input() : collapsed().input))
29672967
const limitedOutput = createMemo(() => (expanded() ? output() : collapsed().output))
2968+
const elapsed = createToolElapsed(
2969+
() => props.part?.time,
2970+
() => isRunning() || props.status === "running",
2971+
)
2972+
const elapsedText = createMemo(() => {
2973+
const value = elapsed()
2974+
return value === undefined ? undefined : Locale.duration(value)
2975+
})
29682976
const expandable = createMemo(() => Boolean(props.shellID) || collapsed().overflow)
29692977
const toggle = () => {
29702978
const next = !expanded()
@@ -2994,6 +3002,7 @@ function ShellDisplay(props: {
29943002
maxHeight={expanded() ? undefined : 2}
29953003
>
29963004
{limitedInput()}
3005+
<Show when={elapsedText()}>{(value) => <span>{` · ${value()}`}</span>}</Show>
29973006
</text>
29983007
}
29993008
>
@@ -3007,6 +3016,7 @@ function ShellDisplay(props: {
30073016
minWidth={0}
30083017
>
30093018
{limitedInput()}
3019+
<Show when={elapsedText()}>{(value) => <span>{` · ${value()}`}</span>}</Show>
30103020
</text>
30113021
</box>
30123022
</Show>

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ async function renderFrame(component: () => JSX.Element, options: { width: numbe
132132
}
133133

134134
describe("TUI inline tool wrapping", () => {
135-
test("tool elapsed ticks from ran and freezes at completed", async () => {
135+
test("tool elapsed shows ran and freezes at completed", async () => {
136136
setSystemTime(10_000)
137137
const [state, setState] = createStore<{ completed?: number; running: boolean }>({ running: true })
138138
const component = () => {
@@ -162,11 +162,6 @@ describe("TUI inline tool wrapping", () => {
162162
)
163163
}
164164
expect(await renderFrame(component, { width: 72, height: 3 })).toContain("Shell sleep 5 · 3.0s")
165-
setSystemTime(12_000)
166-
await Bun.sleep(1100)
167-
await testSetup!.renderOnce()
168-
await testSetup!.renderOnce()
169-
expect(testSetup!.captureCharFrame()).toContain("Shell sleep 5 · 5.0s")
170165
setState({ running: false, completed: 12_500 })
171166
setSystemTime(30_000)
172167
await testSetup!.renderOnce()

0 commit comments

Comments
 (0)