- {showCollapsedStackCap && firstStackedItem ? (
-
- ) : null}
+
{
+ setStackExpanded(false);
+ const activeElement = document.activeElement;
+ if (
+ activeElement instanceof HTMLElement &&
+ noticesRef.current?.contains(activeElement)
+ ) {
+ activeElement.blur();
+ }
}}
>
{hasStack ? (
{
+ if (event.pointerType !== "touch") setStackExpanded(true);
+ }}
+ onPointerLeave={(event) => {
+ if (!event.currentTarget.contains(document.activeElement)) setStackExpanded(false);
+ }}
+ onFocusCapture={() => setStackExpanded(true)}
+ onBlurCapture={(event) => {
+ if (
+ !event.currentTarget.contains(event.relatedTarget) &&
+ !event.currentTarget.matches(":hover")
+ ) {
+ setStackExpanded(false);
+ }
+ }}
+ onKeyDown={(event) => {
+ if (event.key !== "Escape") return;
+ event.stopPropagation();
+ peekRef.current?.focus({ preventScroll: true });
+ setStackExpanded(false);
+ }}
>
-
-
- {stackedItems.map((item) => (
-
- requestDismiss(item)}
- />
-
- ))}
+ {showCollapsedStackCap && firstStackedItem ? (
+
{
+ event.currentTarget.focus({ preventScroll: true });
+ setStackExpanded(true);
+ }}
+ className={cn(stackExpanded && "opacity-0")}
+ />
+ ) : null}
+
+
+
+ {stackedItems.map((item) => (
+
+ requestDismiss(item)}
+ />
+
+ ))}
+
) : null}
-
+
);
}
@@ -187,50 +218,59 @@ function ComposerBannerStackAlert({
exiting,
onDismissRequest,
}: {
- readonly item: ComposerBannerStackItem;
+ readonly item: ComposerBannerStackEntry;
readonly attached: boolean;
readonly exiting: boolean;
readonly onDismissRequest: () => void;
}) {
- const dismissOnly = item.onDismiss && !item.actions;
+ if ("content" in item) {
+ return (
+
+ {item.content}
+
+ );
+ }
return (
-
- {item.icon}
- {item.title}
- {item.description ? {item.description} : null}
- {item.actions || item.onDismiss ? (
-
- {item.actions}
- {item.onDismiss ? (
-
-
-
+
+ {item.icon}
+ {item.title}
+ {item.actions || item.onDismiss ? (
+
+ {item.actions}
+ {item.onDismiss ? (
+
+ ) : null}
+
+ ) : null}
+
+ {item.description || item.children ? (
+
+ {item.description ? (
+
+
+
+ {item.description}
+
+
) : null}
-
+ {item.children}
+
) : null}
-
+
);
}
diff --git a/apps/web/src/components/chat/ComposerCommandMenu.test.tsx b/apps/web/src/components/chat/ComposerCommandMenu.test.tsx
index cf0a1747dd..6435820c2e 100644
--- a/apps/web/src/components/chat/ComposerCommandMenu.test.tsx
+++ b/apps/web/src/components/chat/ComposerCommandMenu.test.tsx
@@ -19,8 +19,6 @@ describe("ComposerCommandMenu", () => {
);
expect(markup).toContain('data-composer-command-drawer="true"');
- expect(markup).toContain("chat-composer-drawer-surface");
- expect(markup).toContain("chat-composer-drawer-attached");
expect(markup).not.toContain("dropdown-glass");
});
diff --git a/apps/web/src/components/chat/ComposerCommandMenu.tsx b/apps/web/src/components/chat/ComposerCommandMenu.tsx
index 72267fcc99..74cd98f361 100644
--- a/apps/web/src/components/chat/ComposerCommandMenu.tsx
+++ b/apps/web/src/components/chat/ComposerCommandMenu.tsx
@@ -24,6 +24,7 @@ import { cn } from "~/lib/utils";
import { Badge } from "../ui/badge";
import { Command, CommandGroup, CommandItem, CommandList } from "../ui/command";
import { PierreEntryIcon } from "./PierreEntryIcon";
+import { ComposerBanner } from "./ComposerBanner";
export type ComposerCommandItem =
| {
@@ -88,9 +89,9 @@ export const ComposerCommandMenu = memo(function ComposerCommandMenu(props: {
);
}}
>
-
{props.items.length > 0 ? (
@@ -125,7 +126,7 @@ export const ComposerCommandMenu = memo(function ComposerCommandMenu(props: {
)}
-
+
);
});
diff --git a/apps/web/src/components/chat/ComposerPendingApprovalPanel.tsx b/apps/web/src/components/chat/ComposerPendingApprovalPanel.tsx
index 5c6aedb040..deb5ba54c5 100644
--- a/apps/web/src/components/chat/ComposerPendingApprovalPanel.tsx
+++ b/apps/web/src/components/chat/ComposerPendingApprovalPanel.tsx
@@ -31,7 +31,7 @@ export const ComposerPendingApprovalPanel = memo(function ComposerPendingApprova
: "File change";
return (
-
) : null}
-
+
);
});
diff --git a/apps/web/src/components/chat/ComposerPendingUserInputPanel.tsx b/apps/web/src/components/chat/ComposerPendingUserInputPanel.tsx
index c121110bb3..596fd93a68 100644
--- a/apps/web/src/components/chat/ComposerPendingUserInputPanel.tsx
+++ b/apps/web/src/components/chat/ComposerPendingUserInputPanel.tsx
@@ -5,9 +5,10 @@ import {
derivePendingUserInputProgress,
type PendingUserInputDraftAnswer,
} from "../../pendingUserInput";
-import { CheckIcon, ChevronDownIcon } from "lucide-react";
+import { CheckIcon } from "lucide-react";
import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from "../ui/collapsible";
import { cn } from "~/lib/utils";
+import { ComposerBanner } from "./ComposerBanner";
interface PendingUserInputPanelProps {
pendingUserInputs: PendingUserInput[];
@@ -167,58 +168,40 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
return (
{
setCollapsedQuestionId(open ? null : activeQuestion.id);
}}
>
- {/* The trigger's wrapper is inset less than the card's text column, and
- the trigger pays the difference back as padding: the hover background
- and focus ring bleed 10px past that column on both sides, while the
- header label and the chevron still line up with the left and right
- edges of the question text below. The negative block margin keeps the
- taller hit area from pushing the panel down. */}
-
-
-
+ } />}
+ title={
+ isCollapsed ? "Show the question and its options" : "Hide the question and its options"
+ }
+ data-pending-user-input-toggle={isCollapsed ? "collapsed" : "expanded"}
+ >
+
+
+
{activeQuestion.header}
+ {isCollapsed ? (
+
+ {activeQuestion.question}
+
+ ) : null}
+
+
{prompt.questions.length > 1 ? (
{questionIndex + 1}/{prompt.questions.length}
) : null}
- {/* Collapsed, the header is otherwise just a section label and a
- counter, so the question itself is echoed here as a one-line
- reminder of what is being asked. */}
- {isCollapsed ? (
-
- {activeQuestion.question}
-
- ) : null}
- {/* The chevron points at the body: down while it is open below the
- header, up while it is collapsed into it. */}
-
-
-
- {/* The panel carries the horizontal padding itself: it clips its content
- while the height animates, so the option buttons have to sit inside
- that padding or their focus rings get shaved off at the edges. */}
-
-
+
+
+
+
+
{activeQuestion.question}
{activeQuestion.multiSelect ? (
Select one or more options.
@@ -276,7 +259,7 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
);
})}
-
+
);
diff --git a/apps/web/src/components/chat/ComposerPlanFollowUpBanner.tsx b/apps/web/src/components/chat/ComposerPlanFollowUpBanner.tsx
index b734a9eaea..aeffd96380 100644
--- a/apps/web/src/components/chat/ComposerPlanFollowUpBanner.tsx
+++ b/apps/web/src/components/chat/ComposerPlanFollowUpBanner.tsx
@@ -1,4 +1,5 @@
import { memo } from "react";
+import { ComposerBanner } from "./ComposerBanner";
export const ComposerPlanFollowUpBanner = memo(function ComposerPlanFollowUpBanner({
planTitle,
@@ -6,16 +7,14 @@ export const ComposerPlanFollowUpBanner = memo(function ComposerPlanFollowUpBann
planTitle: string | null;
}) {
return (
-
-
- Plan ready
+
+
+
+ Plan ready
{planTitle ? (
- {planTitle}
+ {planTitle}
) : null}
-
- {/*
- Review the plan
-
*/}
-
+
+
);
});
diff --git a/apps/web/src/components/chat/ComposerServerUpdateStatus.tsx b/apps/web/src/components/chat/ComposerServerUpdateStatus.tsx
new file mode 100644
index 0000000000..4133bde44b
--- /dev/null
+++ b/apps/web/src/components/chat/ComposerServerUpdateStatus.tsx
@@ -0,0 +1,49 @@
+import type { ServerUpdateState } from "@t3tools/client-runtime/state/server";
+import { useId, useState } from "react";
+
+import { serverUpdateStageLabel } from "../ServerUpdateAction";
+import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
+import { ComposerBanner } from "./ComposerBanner";
+
+/** One text line, clipped at the end so the error detail never squeezes its title. */
+export function ComposerServerUpdateStatus({
+ state,
+ serverLabel = "server",
+}: {
+ readonly state: Exclude
;
+ readonly serverLabel?: string;
+}) {
+ const [detailsOpen, setDetailsOpen] = useState(false);
+ const triggerId = useId();
+ const title = `${state.status === "failed" ? "Could not update" : "Updating"} ${serverLabel}`;
+ const detail = state.status === "failed" ? state.message : serverUpdateStageLabel(state.stage);
+ return (
+
+
+ setDetailsOpen(true)}
+ >
+ {title}
+
+ {detail}
+
+ }
+ />
+
+ {title}: {detail}
+
+
+
+ );
+}
diff --git a/apps/web/src/components/chat/ComposerStashBadge.test.tsx b/apps/web/src/components/chat/ComposerStashBadge.test.tsx
deleted file mode 100644
index 0e3839e6e0..0000000000
--- a/apps/web/src/components/chat/ComposerStashBadge.test.tsx
+++ /dev/null
@@ -1,68 +0,0 @@
-import { renderToStaticMarkup } from "react-dom/server";
-import { describe, expect, it } from "vite-plus/test";
-
-import { ComposerStashBadge } from "./ComposerStashBadge";
-
-describe("ComposerStashBadge", () => {
- it("renders as an attached composer tab instead of a floating pill", () => {
- const markup = renderToStaticMarkup(
- {}}
- />,
- );
-
- expect(markup).toContain("chat-composer-stash-tab");
- expect(markup).toContain("rounded-t-xl");
- expect(markup).toContain("border-b-0");
- expect(markup).toContain("items-center");
- expect(markup).not.toContain("items-start");
- expect(markup).not.toContain("rounded-full");
- expect(markup).not.toContain("opacity-70");
- expect(markup).not.toContain("border-border");
- expect(markup).toContain('aria-expanded="false"');
- });
-
- it("reports when the stash drawer is open", () => {
- const markup = renderToStaticMarkup(
- {}}
- />,
- );
-
- expect(markup).toContain('aria-expanded="true"');
- expect(markup).toContain("text-foreground");
- expect(markup).toContain("pointer-events-none");
- expect(markup).not.toContain("invisible");
- });
-
- it("keeps a compact inline entry point when a drawer occupies the tab", () => {
- const markup = renderToStaticMarkup(
- {}}
- />,
- );
-
- expect(markup).toContain('data-slot="button"');
- expect(markup).toContain("rounded-sm");
- expect(markup).toContain("focus-visible:ring-2");
- expect(markup).toContain("pointer-coarse:after:min-h-11");
- expect(markup).toContain("Stashed prompts: 3. Open stash.");
- expect(markup).toContain('aria-expanded="true"');
- expect(markup).not.toContain("chat-composer-stash-tab");
- expect(markup).not.toContain("rounded-t-xl");
- expect(markup).not.toContain(" pointer-events-none ");
- });
-});
diff --git a/apps/web/src/components/chat/ComposerStashBadge.tsx b/apps/web/src/components/chat/ComposerStashBadge.tsx
index 7682ab562f..6817839825 100644
--- a/apps/web/src/components/chat/ComposerStashBadge.tsx
+++ b/apps/web/src/components/chat/ComposerStashBadge.tsx
@@ -2,12 +2,11 @@ import { BookmarkIcon } from "lucide-react";
import { memo } from "react";
import { cn } from "~/lib/utils";
-import { Button } from "../ui/button";
+import { ComposerBanner } from "./ComposerBanner";
/**
- * Bookmark control that shows the stash count and opens the stash menu. It
- * sits behind the composer's shoulder unless another drawer needs that space,
- * then moves into the composer's existing controls.
+ * Bookmark tab that shows the stash count beside the composer's other attachments
+ * and opens the stash menu.
*
* On save the badge gives one quiet acknowledgement: it lifts to full
* opacity and the count ticks over. `pulseKey` changes per stash, remounting
@@ -16,72 +15,47 @@ import { Button } from "../ui/button";
export const ComposerStashBadge = memo(function ComposerStashBadge(props: {
count: number;
menuOpen: boolean;
- placement?: "inline" | "tab";
pulseKey: number;
pulsing: boolean;
onToggleMenu: () => void;
}) {
if (props.count === 0) return null;
- const inline = props.placement === "inline";
const count = (
-
{props.count}
-
+
);
- if (inline) {
- return (
-
+ }
data-prompt-stash-badge="true"
aria-label={`Stashed prompts: ${props.count}. Open stash.`}
aria-expanded={props.menuOpen}
className={cn(
- "shrink-0 gap-1 px-1.5",
- (props.menuOpen || props.pulsing) &&
- "[--control-icon-color:currentColor] text-foreground",
+ "transition-colors duration-200",
+ props.menuOpen && "pointer-events-none",
+ props.menuOpen || props.pulsing
+ ? "text-foreground"
+ : "text-muted-foreground hover:text-foreground",
)}
onPointerDown={(event) => event.preventDefault()}
onClick={props.onToggleMenu}
>
-
- {count}
-
- );
- }
-
- return (
- {
- // Keep composer focus so Escape/typing flows stay intact.
- event.preventDefault();
- }}
- onClick={props.onToggleMenu}
- >
-
- Stash
- {count}
-
+
+
+
+ Stash
+ {count}
+
+
);
});
diff --git a/apps/web/src/components/chat/ComposerStashMenu.test.tsx b/apps/web/src/components/chat/ComposerStashMenu.test.tsx
index 517a027d88..47b59a7f59 100644
--- a/apps/web/src/components/chat/ComposerStashMenu.test.tsx
+++ b/apps/web/src/components/chat/ComposerStashMenu.test.tsx
@@ -5,41 +5,6 @@ import { describe, expect, it } from "vite-plus/test";
import { ComposerStashMenu } from "./ComposerStashMenu";
describe("ComposerStashMenu", () => {
- it("renders saved prompts as an attached composer drawer", () => {
- const markup = renderToStaticMarkup(
- {}}
- onDelete={() => {}}
- onClose={() => {}}
- />,
- );
-
- expect(markup).toContain('data-composer-stash-drawer="true"');
- expect(markup).toContain("chat-composer-drawer-surface");
- expect(markup).toContain("chat-composer-drawer-attached");
- expect(markup).toContain('aria-label="Close stash"');
- expect(markup).not.toContain("dropdown-glass");
- expect(markup).not.toContain("Stashed prompts");
- expect(markup).toContain("Press Ctrl+S with a prompt in the composer to stash it.");
- });
-
- it("does not advertise a shortcut when stash is unbound", () => {
- const markup = renderToStaticMarkup(
- {}}
- onDelete={() => {}}
- onClose={() => {}}
- />,
- );
-
- expect(markup).toContain("Nothing stashed yet.");
- expect(markup).not.toContain("Press");
- });
-
it("shows saved image thumbnails and incomplete image states", () => {
const markup = renderToStaticMarkup(
{
expect(markup).toContain('src="data:image/png;base64,AA=="');
expect(markup).toContain("1 image dropped");
expect(markup).toContain("saving 1 image");
- expect(markup).not.toContain("absolute top-1/2 right-2");
- expect(markup).toContain("pointer-events-none");
- expect(markup).toContain("pointer-coarse:pointer-events-auto");
- expect(markup).toContain("pointer-coarse:opacity-100");
- expect(markup).not.toContain("bg-popover!");
- expect(markup).toContain("[--control-icon-color:currentColor]");
- expect(markup).toContain("size-3.5 stroke-2");
- expect(markup).not.toContain("bg-background/90");
});
it("labels mixed file and image stashes without treating images as files", () => {
@@ -129,7 +86,6 @@ describe("ComposerStashMenu", () => {
);
expect(markup).toContain("(2 attachments)");
- expect(markup).toContain("size-3.5 text-secondary-label");
expect(markup).not.toContain("(2 files)");
});
});
diff --git a/apps/web/src/components/chat/ComposerStashMenu.tsx b/apps/web/src/components/chat/ComposerStashMenu.tsx
index f719e563d2..d769c9823a 100644
--- a/apps/web/src/components/chat/ComposerStashMenu.tsx
+++ b/apps/web/src/components/chat/ComposerStashMenu.tsx
@@ -1,11 +1,10 @@
-import { FileIcon, XIcon } from "lucide-react";
+import { BookmarkIcon, FileIcon, FileTextIcon } from "lucide-react";
import { memo, useEffect, useRef, useState } from "react";
import { formatRelativeTimeLabel } from "../../timestampFormat";
import { cn } from "~/lib/utils";
import { type PromptStashEntry } from "../../promptStashStore";
-import { Command, CommandGroup, CommandItem, CommandList } from "../ui/command";
-import { Button } from "../ui/button";
+import { ComposerBanner } from "./ComposerBanner";
const SNIPPET_MAX_CHARS = 90;
@@ -30,7 +29,7 @@ function stashEntrySnippet(entry: PromptStashEntry): string {
}
/**
- * Popover listing the stashed prompts. Keyboard-first: opened by ⌘S on an
+ * Attached banner listing the stashed prompts. Keyboard-first: opened by ⌘S on an
* empty composer, navigated with arrows, restored with Enter, dismissed
* with Escape. The listener runs capture-phase on window so it wins over
* the Lexical editor's handlers while the menu is open.
@@ -64,13 +63,6 @@ export const ComposerStashMenu = memo(function ComposerStashMenu(props: {
return () => document.removeEventListener("pointerdown", closeOnOutsidePointer, true);
}, [onClose]);
- useEffect(() => {
- if (entries.length === 0) return;
- if (!entries.some((entry) => entry.id === highlightedId)) {
- setHighlightedId(entries[0]?.id ?? null);
- }
- }, [entries, highlightedId]);
-
useEffect(() => {
const handler = (event: KeyboardEvent) => {
if (event.key === "Escape") {
@@ -83,11 +75,17 @@ export const ComposerStashMenu = memo(function ComposerStashMenu(props: {
if (entries.length === 0) return;
event.preventDefault();
event.stopPropagation();
- const currentIndex = entries.findIndex((entry) => entry.id === highlightedId);
+ const currentIndex = entries.findIndex((entry) => entry.id === highlightedEntry?.id);
const offset = event.key === "ArrowDown" ? 1 : -1;
const normalizedIndex = currentIndex >= 0 ? currentIndex : offset === 1 ? -1 : 0;
const nextIndex = (normalizedIndex + offset + entries.length) % entries.length;
setHighlightedId(entries[nextIndex]?.id ?? null);
+ const nextButton =
+ drawerRef.current?.querySelectorAll("[data-stash-restore]")[nextIndex];
+ nextButton?.scrollIntoView({ block: "nearest" });
+ if (drawerRef.current?.contains(document.activeElement)) {
+ nextButton?.focus({ preventScroll: true });
+ }
return;
}
if (event.key === "Enter") {
@@ -111,64 +109,77 @@ export const ComposerStashMenu = memo(function ComposerStashMenu(props: {
};
window.addEventListener("keydown", handler, true);
return () => window.removeEventListener("keydown", handler, true);
- }, [entries, highlightedEntry, highlightedId, onClose, onDelete, onRestore]);
+ }, [entries, highlightedEntry, onClose, onDelete, onRestore]);
return (
-
-
+
}
+ aria-label="Close stash"
+ aria-expanded="true"
+ onPointerDown={(event) => event.preventDefault()}
+ onClick={onClose}
>
-
- event.preventDefault()}
- onClick={onClose}
- >
-
-
-
-
-
- {entries.length === 0 ? (
-
+
+
+
+ Stash
+
+ {entries.length}
+
+
+
+
+ } aria-label="Stashed prompts">
+ {entries.length === 0 ? (
+ }>
+
+
Nothing stashed yet.
{stashShortcutLabel
? ` Press ${stashShortcutLabel} with a prompt in the composer to stash it.`
: null}
-
- ) : (
- entries.map((entry) => (
- {
- if (highlightedId !== entry.id) setHighlightedId(entry.id);
- }}
- onMouseDown={(event) => {
- event.preventDefault();
- }}
- onClick={() => {
- onRestore(entry);
- }}
- >
-
+
+
+ ) : (
+ entries.map((entry) => (
+ }
+ key={entry.id}
+ data-stash-entry={entry.id}
+ data-highlighted={highlightedEntry?.id === entry.id || undefined}
+ className={cn(
+ "relative rounded-sm",
+ highlightedEntry?.id === entry.id && "bg-accent text-accent-foreground",
+ )}
+ onMouseMove={() => {
+ if (highlightedId !== entry.id) setHighlightedId(entry.id);
+ }}
+ onFocus={() => setHighlightedId(entry.id)}
+ >
+
+
+
+
+ event.preventDefault()}
+ onClick={() => onRestore(entry)}
+ >
{stashEntrySnippet(entry)}
-
+
+
+
{entry.pendingImageCount ? (
-
+
saving {entry.pendingImageCount} image
{entry.pendingImageCount === 1 ? "" : "s"}…
) : missingImageCount(entry) > 0 ? (
-
+
{missingImageCount(entry)} image
{missingImageCount(entry) === 1 ? "" : "s"} dropped
@@ -181,38 +192,35 @@ export const ComposerStashMenu = memo(function ComposerStashMenu(props: {
src={attachment.dataUrl}
alt=""
aria-hidden="true"
- className="size-5 rounded border border-border/70 object-cover"
+ className="size-4 rounded border border-border/70 object-cover"
/>
))}
) : null}
{(entry.files?.length ?? 0) > 0 ? (
-
-
+
+
{entry.files!.length}
) : null}
-
- {formatRelativeTimeLabel(entry.createdAt)}
-
- {
- event.stopPropagation();
- onDelete(entry);
- }}
+
-
-
-
- ))
- )}
-
-
-
-
+ {formatRelativeTimeLabel(entry.createdAt)}
+
+ event.preventDefault()}
+ onClick={() => onDelete(entry)}
+ />
+
+
+ ))
+ )}
+
+
+
);
});
diff --git a/apps/web/src/components/chat/ComposerSurface.tsx b/apps/web/src/components/chat/ComposerSurface.tsx
new file mode 100644
index 0000000000..80a9a6c2d5
--- /dev/null
+++ b/apps/web/src/components/chat/ComposerSurface.tsx
@@ -0,0 +1,99 @@
+import type { ComponentProps } from "react";
+
+import { cn } from "~/lib/utils";
+
+/** One glass backdrop until a top attachment needs the composer to cover its overlap. */
+function Shell({
+ contextStrip = false,
+ className,
+ ...props
+}: ComponentProps<"div"> & { contextStrip?: boolean }) {
+ return (
+
+ );
+}
+
+const outlineClasses =
+ "after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] after:border after:border-(--chat-composer-outline) dark:after:shadow-[inset_0_1px_var(--chat-composer-highlight)]";
+
+// The bottom strip continues the outline, so leave the seam between its corners open.
+const contextSeamClasses =
+ "group-data-with-context/composer-surface:after:[clip-path:polygon(0_0,100%_0,100%_100%,calc(100%-22px)_100%,calc(100%-22px)_calc(100%-2px),22px_calc(100%-2px),22px_100%,0_100%)]";
+
+function Host({ className, ...props }: ComponentProps<"div">) {
+ return (
+
+ );
+}
+
+function Main({ className, ...props }: ComponentProps<"div">) {
+ return (
+
+ );
+}
+
+function ContextStrip({ className, ...props }: ComponentProps<"div">) {
+ return (
+
+ );
+}
+
+export const ComposerSurface = { Shell, Host, Main, ContextStrip };
diff --git a/apps/web/src/components/chat/ComposerTasksBadge.test.tsx b/apps/web/src/components/chat/ComposerTasksBadge.test.tsx
deleted file mode 100644
index 3f17143e53..0000000000
--- a/apps/web/src/components/chat/ComposerTasksBadge.test.tsx
+++ /dev/null
@@ -1,190 +0,0 @@
-import { renderToStaticMarkup } from "react-dom/server";
-import { describe, expect, it } from "vite-plus/test";
-
-import { ComposerTasksBadge, ComposerTasksDrawer } from "./ComposerTasksBadge";
-
-const progress = {
- step: "Attach task progress",
- completedSteps: 1,
- totalSteps: 3,
-};
-const steps = [
- { durationMs: 4_000, step: "Inspect the composer", status: "completed" as const },
- { step: "Attach task progress", status: "inProgress" as const },
- { step: "Verify the result", status: "pending" as const },
-];
-
-describe("ComposerTasksBadge", () => {
- it("renders active progress as an attached composer tab", () => {
- const markup = renderToStaticMarkup(
- undefined}
- onToggle={() => undefined}
- progress={progress}
- steps={steps}
- />,
- );
-
- expect(markup).toContain('data-composer-tasks-badge="true"');
- expect(markup).toContain('aria-expanded="false"');
- expect(markup).toContain("chat-composer-shoulder-tab");
- expect(markup).toContain("chat-composer-tasks-tab");
- expect(markup).toContain("rounded-t-xl");
- expect(markup).toContain("border-b-0");
- expect(markup).toContain("left-5.5");
- expect(markup).toContain("right-5.5");
- expect(markup).toContain('data-composer-task-current="true"');
- expect(markup).toContain("min-w-0 flex-1 truncate");
- expect(markup).toContain("w-20");
- expect(markup).toContain("Tasks");
- expect(markup).toContain("Attach task progress");
- expect(markup).not.toContain("·");
- expect(markup).toContain("1/3");
- expect(markup).toContain("Current task: Attach task progress");
- expect(markup).toContain("lucide-list-todo");
- expect(markup).toContain('aria-label="Dismiss tasks for this turn"');
- expect(markup).toContain("lucide-x");
- expect(markup).not.toContain("lucide-chevron");
- expect(markup).toContain("bg-success");
- expect(markup).toContain("bg-primary");
- expect(markup).toContain("bg-muted-foreground/25");
- });
-
- it("leaves room for the stash tab when both shoulders are present", () => {
- const markup = renderToStaticMarkup(
- undefined}
- onToggle={() => undefined}
- progress={progress}
- steps={steps}
- />,
- );
-
- expect(markup).toContain("right-30");
- expect(markup).not.toContain("right-5.5");
- });
-
- it("has a compact inline fallback for occupied composer shoulders", () => {
- const markup = renderToStaticMarkup(
- undefined}
- onToggle={() => undefined}
- placement="inline"
- progress={progress}
- steps={steps}
- />,
- );
-
- expect(markup).toContain("rounded-sm");
- expect(markup).toContain("1/3");
- expect(markup).not.toContain("chat-composer-shoulder-tab");
- expect(markup).not.toContain("rounded-t-xl");
- });
-
- it("expands into a read-only attached task list", () => {
- const markup = renderToStaticMarkup(
- undefined}
- onDismiss={() => undefined}
- progress={progress}
- steps={steps}
- />,
- );
-
- expect(markup).toContain('data-chat-composer-tasks-drawer="true"');
- expect(markup).toContain('data-chat-composer-collapsed-controls="true"');
- expect(markup).not.toContain("data-variant");
- expect(markup).toContain('aria-expanded="true"');
- expect(markup).toContain('aria-label="Collapse tasks. 1 of 3 complete."');
- expect(markup).toContain('aria-label="Task list. 1 of 3 complete."');
- expect(markup).toContain('role="list"');
- expect(markup).toContain('data-composer-tasks-list="true"');
- expect(markup).toContain('tabindex="0"');
- expect(markup).toContain("max-h-[min(24rem,40dvh)]");
- expect(markup).toContain("overflow-y-auto");
- expect(markup).toContain("overscroll-contain");
- expect(markup).toContain("focus-visible:ring-2");
- expect(markup).toContain("focus-visible:ring-inset");
- expect(markup).toContain("Inspect the composer");
- expect(markup).toContain('data-composer-task-duration="true"');
- expect(markup).toContain("ml-auto w-10");
- expect(markup).toContain("4.0s");
- expect(markup).toContain("now");
- expect(markup).toContain("Attach task progress");
- expect(markup).toContain("Verify the result");
- expect(markup).toContain("lucide-list-todo");
- expect(markup).toContain("lucide-chevron-down");
- expect(markup).toContain('aria-label="Dismiss tasks for this turn"');
- expect(markup).not.toContain("bg-success");
- expect(markup).not.toContain("bg-primary");
- expect(markup).not.toContain("bg-muted-foreground/25");
- });
-
- it("drops the step segments when they would render as a blank gap", () => {
- const manySteps = Array.from({ length: 24 }, (_, index) => ({
- step: `Step ${index + 1}`,
- status: "pending" as const,
- }));
- const tab = renderToStaticMarkup(
- undefined}
- onToggle={() => undefined}
- progress={{ ...progress, totalSteps: manySteps.length }}
- steps={manySteps}
- />,
- );
- const inline = renderToStaticMarkup(
- undefined}
- onToggle={() => undefined}
- placement="inline"
- progress={{ ...progress, totalSteps: manySteps.length }}
- steps={manySteps}
- />,
- );
-
- expect(tab).not.toContain("w-20");
- expect(tab).toContain("1/24");
- expect(inline).not.toContain("w-10");
- expect(inline).toContain("1/24");
- });
-
- it("keeps every long-list task inside the bounded scroll region", () => {
- const longSteps = Array.from({ length: 20 }, (_, index) => ({
- step: `Task ${index + 1}`,
- status: index === 0 ? ("inProgress" as const) : ("pending" as const),
- }));
- const markup = renderToStaticMarkup(
- undefined}
- onDismiss={() => undefined}
- progress={{ step: "Task 1", completedSteps: 0, totalSteps: longSteps.length }}
- steps={longSteps}
- />,
- );
-
- const listStart = markup.indexOf('data-composer-tasks-list="true"');
- expect(listStart).toBeGreaterThan(markup.indexOf('aria-label="Collapse tasks.'));
- expect(markup.slice(listStart)).toContain("Task 20");
- });
-
- it("does not render an empty task count", () => {
- const markup = renderToStaticMarkup(
- undefined}
- onToggle={() => undefined}
- progress={{ ...progress, totalSteps: 0 }}
- steps={steps}
- />,
- );
-
- expect(markup).toBe("");
- });
-});
diff --git a/apps/web/src/components/chat/ComposerTasksBadge.tsx b/apps/web/src/components/chat/ComposerTasksBadge.tsx
index d73ce819d8..049e6b79f0 100644
--- a/apps/web/src/components/chat/ComposerTasksBadge.tsx
+++ b/apps/web/src/components/chat/ComposerTasksBadge.tsx
@@ -1,9 +1,9 @@
-import { ChevronDownIcon, ListTodoIcon, XIcon } from "lucide-react";
-import { memo } from "react";
+import { ListTodoIcon } from "lucide-react";
+import { memo, type ComponentProps } from "react";
import { formatDuration } from "../../session-logic";
import { cn } from "~/lib/utils";
-import { Button } from "../ui/button";
+import { ComposerBanner } from "./ComposerBanner";
export interface ComposerTasksProgress {
readonly step: string;
@@ -56,18 +56,51 @@ function TaskSegments({
);
}
+function TaskSummary({
+ expanded,
+ progress,
+ steps,
+}: {
+ readonly expanded: boolean;
+ readonly progress: ComposerTasksProgress;
+ readonly steps: readonly ComposerTaskStep[];
+}) {
+ return (
+ <>
+
+
+
+
+ Tasks
+
+ {progress.step}
+
+
+
+ = progress.totalSteps ? "text-success" : undefined}
+ data-composer-task-progress="true"
+ >
+ {progress.completedSteps}/{progress.totalSteps}
+
+
+
+
+ >
+ );
+}
+
export const ComposerTasksBadge = memo(function ComposerTasksBadge({
expanded,
- hasTrailingShoulder = false,
- onDismiss,
onToggle,
placement = "tab",
progress,
steps,
}: {
readonly expanded: boolean;
- readonly hasTrailingShoulder?: boolean;
- readonly onDismiss: () => void;
readonly onToggle: () => void;
readonly placement?: "inline" | "tab";
readonly progress: ComposerTasksProgress;
@@ -75,186 +108,112 @@ export const ComposerTasksBadge = memo(function ComposerTasksBadge({
}) {
if (progress.totalSteps <= 0) return null;
- const allDone = progress.completedSteps >= progress.totalSteps;
- const label = `Tasks: ${progress.completedSteps} of ${progress.totalSteps} complete. Current task: ${progress.step}`;
- if (placement === "inline") {
- return (
-
- event.preventDefault()}
- >
-
- Tasks
-
-
- {progress.completedSteps}/{progress.totalSteps}
-
-
- event.preventDefault()}
- >
-
-
-
- );
- }
-
- return (
-
}
+ aria-expanded={expanded}
+ aria-label={`${expanded ? "Collapse tasks" : "Tasks"}: ${progress.completedSteps} of ${progress.totalSteps} complete. Current task: ${progress.step}`}
data-composer-tasks-badge="true"
+ onClick={onToggle}
+ onPointerDown={(event) => event.preventDefault()}
>
- event.preventDefault()}
- >
-
- Tasks
-
- {progress.step}
-
-
- {progress.completedSteps}/{progress.totalSteps}
-
-
-
- event.preventDefault()}
- >
-
-
-
);
});
-export const ComposerTasksDrawer = memo(function ComposerTasksDrawer({
- onDismiss,
- onCollapse,
+export const ComposerTasksContent = memo(function ComposerTasksContent({
+ expanded,
+ onToggle,
progress,
steps,
}: {
- readonly onDismiss: () => void;
- readonly onCollapse: () => void;
+ readonly expanded: boolean;
+ readonly onToggle: () => void;
readonly progress: ComposerTasksProgress;
readonly steps: readonly ComposerTaskStep[];
}) {
return (
-
- event.preventDefault()}
- >
-
- Tasks
-
- {progress.completedSteps}/{progress.totalSteps}
-
-
-
- event.preventDefault()}
- >
-
-
-
-
- {keyedTaskSteps(steps).map(({ key, step }) => (
-
-
- {step.status === "completed" ? "✓" : step.status === "inProgress" ? "●" : "○"}
-
-
- {step.step}
-
-
- {step.durationMs !== undefined
- ? formatDuration(step.durationMs)
- : step.status === "inProgress"
- ? "now"
- : null}
-
-
- ))}
-
+
+ {expanded ? (
+
+ }
+ aria-label={`Task list. ${progress.completedSteps} of ${progress.totalSteps} complete.`}
+ data-composer-tasks-list="true"
+ >
+ {keyedTaskSteps(steps).map(({ key, step }) => (
+ }>
+
+ {step.status === "completed" ? "✓" : step.status === "inProgress" ? "●" : "○"}
+
+
+ {step.step}
+
+
+
+ {step.durationMs !== undefined
+ ? formatDuration(step.durationMs)
+ : step.status === "inProgress"
+ ? "now"
+ : null}
+
+
+
+ ))}
+
+
+ ) : null}
);
});
+
+export const ComposerTasksDrawer = memo(function ComposerTasksDrawer({
+ onCollapse,
+ ...props
+}: Omit