Skip to content

Commit 6ba29c0

Browse files
t3dotggclaude
andcommitted
fix(web): an empty shelf no longer flattens the approval drawer's top
With nothing to show, the shelf stayed in the DOM (hidden), and the attachment rules joined the next card to it: the approval, question or plan drawer lost its top border and corners. The shelf now renders nothing when given nothing, and a hidden shelf no longer joins the next attachment. Also tests the goal token labels (412K / 2M with a budget, 1.3M tokens without). Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 2f21f36 commit 6ba29c0

3 files changed

Lines changed: 55 additions & 1 deletion

File tree

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
import { InfoIcon } from "lucide-react";
22
import { expect, it } from "vite-plus/test";
33

4+
import "~/index.css";
5+
46
import { render } from "../../../test/render";
7+
import { ComposerBanner } from "./ComposerBanner";
58
import { ComposerBannerStack, type ComposerBannerStackItem } from "./ComposerBannerStack";
69

710
function notice(title: string, group?: ComposerBannerStackItem["group"]): ComposerBannerStackItem {
811
return { id: title, variant: "default", icon: <InfoIcon />, title, ...(group ? { group } : {}) };
912
}
1013

14+
function EmptyQueue() {
15+
return null;
16+
}
17+
1118
it("keeps rows in fixed groups whatever order the notices arrive in", async () => {
1219
await using screen = await render(
1320
<ComposerBannerStack
@@ -25,3 +32,18 @@ it("keeps rows in fixed groups whatever order the notices arrive in", async () =
2532
"OfflineBranch changedGoalTasksQueued",
2633
);
2734
});
35+
36+
it("leaves the next attachment its own top edge when the shelf has nothing to show", async () => {
37+
await using screen = await render(
38+
<ComposerBanner.Column>
39+
<ComposerBannerStack items={[]} queue={<EmptyQueue />} />
40+
<ComposerBanner.Attachment>
41+
<ComposerBanner.Root data-testid="drawer">Approval</ComposerBanner.Root>
42+
</ComposerBanner.Attachment>
43+
</ComposerBanner.Column>,
44+
);
45+
46+
const surface = getComputedStyle(screen.getByTestId("drawer").element(), "::before");
47+
expect(surface.borderTopWidth).toBe("1px");
48+
expect(surface.borderTopLeftRadius).not.toBe("0px");
49+
});

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,20 @@ const GROUPS = ["environment", "attention", "activity"] as const;
4141
* behind another card, nothing floating over the transcript.
4242
*/
4343
export function ComposerBannerStack({ items, activity, queue }: ComposerBannerStackProps) {
44+
if (items.length === 0 && !activity && !queue) return null;
4445
const bands = GROUPS.map((group) => ({
4546
group,
4647
items: items.filter((item) => (item.group ?? "attention") === group),
4748
}));
4849
return (
4950
<ComposerBanner.Attachment
5051
data-composer-banner-stack="true"
51-
className="not-has-[[data-composer-shelf-band]:not(:empty)]:hidden"
52+
className={cn(
53+
"not-has-[[data-composer-shelf-band]:not(:empty)]:hidden",
54+
// A hidden shelf must not join the next attachment to it (the queue can render nothing).
55+
"not-has-[[data-composer-shelf-band]:not(:empty)]:[&+[data-slot=composer-banner-attachment]_[data-composer-banner-surface=attached]]:before:rounded-t-2xl",
56+
"not-has-[[data-composer-shelf-band]:not(:empty)]:[&+[data-slot=composer-banner-attachment]_[data-composer-banner-surface=attached]]:before:border-t",
57+
)}
5258
>
5359
<ComposerBanner.Root
5460
role="region"

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
deriveRunlessWorkStartedAt,
2626
deriveThreadActivityRun,
2727
deriveThreadRuntime,
28+
presentProviderGoal,
2829
threadRuntimeHasInterruptibleRun,
2930
} from "./threadExecution.ts";
3031

@@ -393,3 +394,28 @@ describe("provider-reported model selection", () => {
393394
).toBeNull();
394395
});
395396
});
397+
398+
describe("presentProviderGoal", () => {
399+
it("shortens the token count against a budget and keeps the unit without one", () => {
400+
const budgeted = presentProviderGoal(
401+
{
402+
objective: "Ship it",
403+
status: "active",
404+
tokensUsed: 412_000,
405+
tokenBudget: 2_000_000,
406+
timeUsedSeconds: 1_460,
407+
checks: 3,
408+
},
409+
true,
410+
);
411+
expect(budgeted.tokens).toBe("412K / 2M");
412+
expect(budgeted.usage).toBe("412K / 2M tokens · 24m 20s · 3 checks");
413+
414+
const unbudgeted = presentProviderGoal(
415+
{ objective: "Ship it", status: "active", tokensUsed: 1_250_000 },
416+
true,
417+
);
418+
expect(unbudgeted.tokens).toBe("1.3M tokens");
419+
expect(unbudgeted.usage).toBe("1.3M tokens");
420+
});
421+
});

0 commit comments

Comments
 (0)