Skip to content

Commit c9db6e9

Browse files
fix(app): show running shell command (#38080)
Co-authored-by: Luke Parker <10430890+Hona@users.noreply.github.com>
1 parent 130038e commit c9db6e9

3 files changed

Lines changed: 22 additions & 3 deletions

File tree

packages/app/e2e/regression/session-timeline-lifecycle-state.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,23 @@ for (const expanded of [false, true]) {
3232
})
3333
}
3434

35+
test("shows and expands a running shell command without shimmering it", async ({ page }) => {
36+
const id = "prt_shell_running_command"
37+
const command = "sleep 10 && echo done"
38+
await setupTimeline(page, {
39+
messages: [userMessage(), assistantMessage([shell(id, "running", "still running", command)], { completed: false })],
40+
settings: { shellToolPartsExpanded: false },
41+
})
42+
43+
const tool = page.locator(`[data-timeline-part-id="${id}"]`)
44+
await expect(tool.locator('[data-component="text-shimmer"]')).toHaveAttribute("data-active", "true")
45+
await expect(tool.locator('[data-component="shell-submessage"]')).toHaveText(command)
46+
await expect(tool.locator('[data-component="shell-submessage"] [data-component="text-shimmer"]')).toHaveCount(0)
47+
await tool.locator('[data-slot="collapsible-trigger"]').click()
48+
await expect(tool.locator('[data-slot="collapsible-trigger"]')).toHaveAttribute("aria-expanded", "true")
49+
await expect(tool.locator('[data-slot="bash-pre"]')).toContainText("still running")
50+
})
51+
3552
test("transitions thinking and hidden reasoning through busy to idle", async ({ page }) => {
3653
const reasoningID = "prt_reasoning_hidden"
3754
const assistant = assistantMessage([reasoningPart(reasoningID, "## Inspecting stability")], { completed: false })

packages/session-ui/src/components/basic-tool.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export interface BasicToolProps {
3232
open?: boolean
3333
onOpenChange?: (open: boolean) => void
3434
forceOpen?: boolean
35+
allowOpenWhilePending?: boolean
3536
defer?: boolean
3637
locked?: boolean
3738
animated?: boolean
@@ -176,7 +177,7 @@ export function BasicTool(props: BasicToolProps) {
176177
})
177178

178179
const handleOpenChange = (value: boolean) => {
179-
if (pending()) return
180+
if (pending() && !props.allowOpenWhilePending) return
180181
if (props.locked && !value) return
181182
setOpen(value)
182183
}
@@ -247,7 +248,7 @@ export function BasicTool(props: BasicToolProps) {
247248
</Switch>
248249
</div>
249250
</div>
250-
<Show when={hasChildren() && !props.hideDetails && !props.locked && !pending()}>
251+
<Show when={hasChildren() && !props.hideDetails && !props.locked && (!pending() || props.allowOpenWhilePending)}>
251252
<Collapsible.Arrow />
252253
</Show>
253254
</div>

packages/session-ui/src/components/message-part.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2126,13 +2126,14 @@ ToolRegistry.register({
21262126
<BasicTool
21272127
{...props}
21282128
icon="console"
2129+
allowOpenWhilePending
21292130
trigger={(open) => (
21302131
<div data-slot="basic-tool-tool-info-structured">
21312132
<div data-slot="basic-tool-tool-info-main">
21322133
<span data-slot="basic-tool-tool-title">
21332134
<TextShimmer text={i18n.t("ui.tool.shell")} active={pending()} />
21342135
</span>
2135-
<Show when={!pending() && !open() && props.input.command}>
2136+
<Show when={!open() && props.input.command}>
21362137
<ShellSubmessage text={props.input.command} animate={sawPending} />
21372138
</Show>
21382139
</div>

0 commit comments

Comments
 (0)