Skip to content

Commit e0350de

Browse files
t3dotggclaude
andcommitted
fix(web): background command details open above their button
The details popup measured the full unscrolled text, so a long command flipped beside its button and covered it, which made hover flicker. Background command labels also showed the shell wrapper. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 575579d commit e0350de

5 files changed

Lines changed: 57 additions & 7 deletions

File tree

‎apps/web/src/components/chat/ComposerBannerStack.browser.test.tsx‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { InfoIcon } from "lucide-react";
22
import type { ReactNode } from "react";
33
import { expect, it, vi } from "vite-plus/test";
4+
import { page, userEvent } from "vite-plus/test/browser";
45

56
import "~/index.css";
67

@@ -123,3 +124,28 @@ it("shows the details button while text or nested text is cut, until it fits aga
123124
await screen.rerender(<ComposerBanner.Root>{noticeRow("4rem", "Ready")}</ComposerBanner.Root>);
124125
await expect.element(details).not.toBeInTheDocument();
125126
});
127+
128+
it("opens the details of a long notice right above its button", async () => {
129+
const viewport = { width: window.innerWidth, height: window.innerHeight };
130+
await page.viewport(1280, 800);
131+
await using _viewport = {
132+
[Symbol.asyncDispose]: () => page.viewport(viewport.width, viewport.height),
133+
};
134+
const script = Array.from({ length: 400 }, (_, line) => `echo "line ${line}"`).join("\n");
135+
const container = document.createElement("div");
136+
container.style.cssText = "position: fixed; bottom: 4rem; right: 4rem;";
137+
await using screen = await render(noticeRow("40rem", script), { container });
138+
const details = screen.getByRole("button", { name: "Show details" });
139+
await userEvent.hover(details);
140+
const popup = page.getByLabelText("Notice details");
141+
await expect.element(popup).toBeVisible();
142+
143+
// A positioner sized to the unscrolled text flips beside the button and covers it.
144+
await vi.waitFor(() => {
145+
const gap =
146+
details.element().getBoundingClientRect().top -
147+
popup.element().getBoundingClientRect().bottom;
148+
expect(gap).toBeGreaterThanOrEqual(0);
149+
expect(gap).toBeLessThan(8);
150+
});
151+
});

‎apps/web/src/components/chat/ComposerBannerStack.tsx‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,7 @@ export function NoticeText({
155155
side="top"
156156
className="max-w-[min(30rem,calc(100vw-2rem))] whitespace-normal wrap-anywhere [--inline-button-text-align:start] [--inline-button-white-space:normal] [&_[data-slot=inline-button]]:max-w-full"
157157
>
158-
<ComposerBanner.Scroll className="max-h-[min(var(--available-height),24rem,40dvh)]">
159-
{children}
160-
</ComposerBanner.Scroll>
158+
<ComposerBanner.Scroll>{children}</ComposerBanner.Scroll>
161159
</PopoverPopup>
162160
</Popover>
163161
) : null}

‎apps/web/src/components/chat/ThreadActivityBanners.tsx‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,14 @@ export function backgroundWorkNowItem(input: {
191191
icon: rows.every(isCommand) ? <TerminalIcon /> : <CircleDashedIcon />,
192192
title: only ? (
193193
<>
194-
{verb} <span className={cn(isCommand(only) && "font-mono")}>{only.task.label}</span>
194+
{verb}{" "}
195+
<span
196+
className={cn(
197+
isCommand(only) && "font-mono in-data-[slot=popover-popup]:whitespace-pre-wrap",
198+
)}
199+
>
200+
{only.task.label}
201+
</span>
195202
</>
196203
) : (
197204
presentation.title

‎packages/client-runtime/src/state/threadExecution.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
deriveRunlessWorkStartedAt,
2626
deriveThreadActivityRun,
2727
deriveThreadRuntime,
28+
presentPendingBackgroundWork,
2829
presentProviderGoal,
2930
presentRunStop,
3031
threadRuntimeHasInterruptibleRun,
@@ -488,3 +489,16 @@ describe("presentProviderGoal", () => {
488489
).toBe("1m / 1m tokens");
489490
});
490491
});
492+
493+
describe("presentPendingBackgroundWork", () => {
494+
it("names a command by its script, not the shell that wraps it", () => {
495+
const presentation = presentPendingBackgroundWork([
496+
{
497+
taskId: "call_1",
498+
kind: "command",
499+
description: `/bin/zsh -lc "mv a.ts b.ts\ncat > b.ts <<'EOF'\nexport {};\nEOF"`,
500+
},
501+
]);
502+
expect(presentation?.items[0]?.label).toBe("mv a.ts b.ts\ncat > b.ts <<'EOF'\nexport {};\nEOF");
503+
});
504+
});

‎packages/client-runtime/src/state/threadExecution.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
type ThreadStructure,
3434
type ThreadStructureRuntime,
3535
} from "./models.ts";
36+
import { commandDisplayText } from "../work-log/commandLabel.ts";
3637
import { formatSubagentDisplayTitle } from "./subagentDisplay.ts";
3738

3839
const ACTIVITY_RUN_STATUSES = new Set(["preparing", "starting", "running", "waiting"]);
@@ -370,9 +371,13 @@ export function presentPendingBackgroundWork(
370371
.map((task): PendingBackgroundWorkItem => {
371372
const description = task.description?.trim();
372373
const label =
373-
task.kind === "subagent" && description !== undefined
374-
? formatSubagentDisplayTitle(description).trim()
375-
: description;
374+
description === undefined
375+
? undefined
376+
: task.kind === "subagent"
377+
? formatSubagentDisplayTitle(description).trim()
378+
: task.kind === "command" || task.kind === "monitor"
379+
? commandDisplayText(description)
380+
: description;
376381
return {
377382
taskId: task.taskId,
378383
kind: task.kind,

0 commit comments

Comments
 (0)