Skip to content

The Open Standard for Generative UI

AgentInterface: collapsed rail, pill composer, ChatHeader and welcome refresh (#1327)

shubham-thesys86da07f62668
diff --git a/.changeset/agent-interface-redesign.md b/.changeset/agent-interface-redesign.md
new file mode 100644
index 000000000..b3bf1db1a
--- /dev/null
+++ b/.changeset/agent-interface-redesign.md
@@ -0,0 +1,5 @@
+---
+"@openuidev/react-ui": patch
+---
+
+Refresh the AgentInterface shell: a collapsed sidebar rail with a History menu and a draggable, remembered width; a pill composer and a shared ~72ch reading column; a centred welcome screen with starter tabs and a `card` starter variant; `AgentInterface.ThreadHeader` gains `start` / `center` / `end` slots, the chat title and a Rename/Delete menu; a Rename option in the thread menu; a shared menu style for Select, ModelSwitcher and dropdowns; a mascot loader in place of the dot-matrix loader; an exported `WelcomeMascot` (blinks, follows the cursor, squishes on click); an `AgentInterface.SidebarFooter` slot with `AgentInterface.ThemeModeToggle`, backed by the new `useThemeModePreference` hook; a redesigned tool call timeline with animated tool glyphs, plain-language labels (`toolLabel`, `ToolLabelsProvider`) and a live "Working" row; `defaultLabel` is deprecated in favour of `toolLabel`; and server-rendering support: the saved sidebar and theme preferences are restored just after hydration, before paint, with the interface's contents hidden until then so the first visible frame is already correct.
diff --git a/.changeset/tool-call-before-result.md b/.changeset/tool-call-before-result.md
new file mode 100644
index 000000000..a3a20c4a9
--- /dev/null
+++ b/.changeset/tool-call-before-result.md
@@ -0,0 +1,5 @@
+---
+"@openuidev/react-headless": patch
+---
+
+Publish a tool call before its result: `processStreamedMessage` flushes the pending assistant update before a tool result arrives, so a server-side tool's result never shows up ahead of (or without) its call.
diff --git a/docs/app/chat/_components/agent-surfaces/cloud-agent-surface.tsx b/docs/app/chat/_components/agent-surfaces/cloud-agent-surface.tsx
index 7d5b8c674..3eab417a1 100644
--- a/docs/app/chat/_components/agent-surfaces/cloud-agent-surface.tsx
+++ b/docs/app/chat/_components/agent-surfaces/cloud-agent-surface.tsx
@@ -168,9 +168,16 @@ export function CloudAgentSurface() {
/>
}
/>
- <AgentInterface.ThreadHeader className={styles.cloudThreadHeader}>
- <DemoAwareModelSwitcher selectedModel={selectedModel} onModelChange={handleModelChange} />
- </AgentInterface.ThreadHeader>
+ <AgentInterface.ThreadHeader
+ className={styles.cloudThreadHeader}
+ showChatTitle={false}
+ start={
+ <DemoAwareModelSwitcher
+ selectedModel={selectedModel}
+ onModelChange={handleModelChange}
+ />
+ }
+ />
<AgentInterface.Welcome
title="Good to see you"
description="What's on your mind today?"
diff --git a/docs/app/chat/chat-page.module.css b/docs/app/chat/chat-page.module.css
index 5f27bd221..c9e15f1e1 100644
--- a/docs/app/chat/chat-page.module.css
+++ b/docs/app/chat/chat-page.module.css
@@ -283,16 +283,6 @@
}
}
-.cloudThreadHeader :global(.openui-agent-thread-header__title) {
- display: none;
-}
-
-.cloudThreadHeader :global(.openui-agent-thread-header__actions) {
- min-width: 0;
- flex: 1 1 auto;
- justify-content: space-between;
-}
-
.modelSwitcher {
min-width: 0;
}
diff --git a/docs/app/components/config/guide.ts b/docs/app/components/config/guide.ts
index 642344cfa..3474f2ae8 100644
--- a/docs/app/components/config/guide.ts
+++ b/docs/app/components/config/guide.ts
@@ -315,7 +315,7 @@ const DEFAULT_CSS: Record<string, string> = {
"--openui-highlight": "oklch(0.097 0 0 / 0.04)",
"--openui-highlight-strong": "oklch(0.097 0 0 / 0.08)",
"--openui-text-neutral-primary": "oklch(0.097 0 0 / 1)",
- "--openui-text-neutral-secondary": "oklch(0.097 0 0 / 0.5)",
+ "--openui-text-neutral-secondary": "oklch(0.097 0 0 / 0.6)",
"--openui-text-neutral-tertiary": "oklch(0.097 0 0 / 0.2)",
"--openui-border-default": "oklch(0.097 0 0 / 0.06)",
"--openui-border-interactive": "oklch(0.097 0 0 / 0.12)",
diff --git a/docs/content/docs/agent/customize/welcome-and-starters.mdx b/docs/content/docs/agent/customize/welcome-and-starters.mdx
index 47af58915..80481b858 100644
--- a/docs/content/docs/agent/customize/welcome-and-starters.mdx
+++ b/docs/content/docs/agent/customize/welcome-and-starters.mdx
@@ -30,7 +30,7 @@ export default function App() {
}
```
-Each entry is `{ displayText, prompt, icon? }`. Clicking a starter sends its `prompt` as a user message, exactly as if the user typed it, so write `prompt` as a full instruction. Omit `icon` for a default lightbulb, pass a React node for a custom glyph, or pass `<></>` for none. `starterVariant` is `"short"` (compact pills) or `"long"` (a vertical list with icons).
+Each entry is `{ displayText, prompt, icon? }`. Clicking a starter sends its `prompt` as a user message, exactly as if the user typed it, so write `prompt` as a full instruction. Omit `icon` for a default lightbulb, pass a React node for a custom glyph, or pass `<></>` for none. `starterVariant` is `"short"` (compact pills), `"long"` (a vertical list with icons) or `"card"` (a row of cards, each showing its icon).
<Callout type="info">
`starters` and `starterVariant` set on `AgentInterface` flow down to the Welcome and Composer
diff --git a/docs/content/docs/agent/reference/agentinterface-props.mdx b/docs/content/docs/agent/reference/agentinterface-props.mdx
index a347a21f7..8fb0a9a08 100644
--- a/docs/content/docs/agent/reference/agentinterface-props.mdx
+++ b/docs/content/docs/agent/reference/agentinterface-props.mdx
@@ -22,7 +22,7 @@ The only required prop is `llm`. Everything else is optional and falls back to a
| `logoUrl` | `string` | No | none |
| `agentName` | `string` | No | none |
| `starters` | `ConversationStarterProps[]` | No | none |
-| `starterVariant` | `"short" \| "long"` | No | — |
+| `starterVariant` | `"short" \| "long" \| "card"` | No | — |
| `path` | `string` | No | — (uncontrolled) |
| `defaultPath` | `string` | No | thread view (`undefined`) |
| `onNavigate` | `(next: string \| undefined) => void` | No | — (uncontrolled) |
@@ -129,10 +129,10 @@ These feed the default `SidebarHeader` and `MobileHeader`. To go further, replac
Conversation starters are the suggested prompts shown on the welcome screen and in the composer.
-| Prop | Type | Required | Default | Description |
-| ---------------- | ---------------------------- | -------- | ------- | ---------------------------------------------- |
-| `starters` | `ConversationStarterProps[]` | No | none | Suggested prompts to seed a conversation. |
-| `starterVariant` | `"short" \| "long"` | No | — | Layout variant for how starters are presented. |
+| Prop | Type | Required | Default | Description |
+| ---------------- | ----------------------------- | -------- | ------- | ---------------------------------------------- |
+| `starters` | `ConversationStarterProps[]` | No | none | Suggested prompts to seed a conversation. |
+| `starterVariant` | `"short" \| "long" \| "card"` | No | — | Layout variant for how starters are presented. |
Each starter is `{ displayText: string; prompt: string; icon?: ReactNode }` — `displayText` is the label on the suggestion chip and `prompt` is the message sent when it is clicked. These props set the defaults for the `Welcome` and `Composer` slots; either slot can also take its own `starters` / `starterVariant`. See [Welcome & starters](/docs/agent/customize/welcome-and-starters).
diff --git a/docs/content/docs/agent/reference/components.mdx b/docs/content/docs/agent/reference/components.mdx
index 9168eeced..f1d823fc8 100644
--- a/docs/content/docs/agent/reference/components.mdx
+++ b/docs/content/docs/agent/reference/components.mdx
@@ -1,6 +1,6 @@
---
title: Components
-description: Reference for the slots and primitive statics on AgentInterface — Sidebar, ThreadHeader, Welcome, Composer, Workspace, SidebarItem, Route, and the rest.
+description: Reference for the slots and primitive statics on AgentInterface — Sidebar, SidebarFooter, ThreadHeader, Welcome, Composer, Workspace, SidebarItem, Route, ThemeModeToggle, and the rest.
---
Every customizable region of `AgentInterface` is exposed as a **compound static** — a component hung off `AgentInterface` (e.g. `AgentInterface.Welcome`, `AgentInterface.SidebarItem`). You compose the interface by placing these as children:
@@ -27,7 +27,7 @@ There are two kinds:
- **A — omit:** the built-in default renders.
- **B — props:** the default structure renders with your values swapped into specific pieces.
- **C — children:** your children replace the region entirely (children win over props; a dev warning fires if you pass both).
-- **Primitives / statics** — building blocks you place _inside_ slots (or, for `Route`, at the top level) to assemble custom layouts: `SidebarItem`, `SidebarContent`, `SidebarSeparator`, `ArtifactNav`, `Route`, `NewChatButton`, `ThreadList`, `Messages`, `MessageLoading`, `ScrollArea`.
+- **Primitives / statics** — building blocks you place _inside_ slots (or, for `Route`, at the top level) to assemble custom layouts: `SidebarItem`, `SidebarContent`, `SidebarSeparator`, `ArtifactNav`, `Route`, `NewChatButton`, `HistoryButton`, `ThemeModeToggle`, `ThreadList`, `Messages`, `MessageLoading`, `ScrollArea`.
All of these are also reachable as named exports from `@openuidev/react-ui`, but the compound-static form (`AgentInterface.X`) is the documented usage.
@@ -39,6 +39,7 @@ Pass these at the top level of `<AgentInterface>` to override a layout region. T
| ------------------------------ | ---------------------------------------------------- | ------- |
| `AgentInterface.Sidebar` | The entire left sidebar | A, C |
| `AgentInterface.SidebarHeader` | Header at the top of the sidebar | A, B, C |
+| `AgentInterface.SidebarFooter` | Footer pinned to the bottom of the sidebar | C |
| `AgentInterface.MobileHeader` | Top bar shown on mobile in place of the sidebar | A, B, C |
| `AgentInterface.ThreadHeader` | Header above the active conversation | A, C |
| `AgentInterface.Welcome` | Empty-state screen shown before a thread starts | A, B, C |
@@ -83,6 +84,25 @@ The header strip at the top of the sidebar — brand logo, agent name, and the c
| `children` | `ReactNode` | Mode C — replaces the header body. |
| `className` | `string` | |
+### `AgentInterface.SidebarFooter`
+
+Pinned to the bottom of the sidebar, below the thread list: a place for controls like [`ThemeModeToggle`](#agentinterfacethememodetoggle). Nothing renders there unless you pass children. **Mode C.**
+
+| Prop | Type | Notes |
+| ----------- | ----------- | --------------------- |
+| `children` | `ReactNode` | The footer's content. |
+| `className` | `string` | |
+
+```tsx
+const { mode, setPreference } = useThemeModePreference();
+
+<AgentInterface llm={llm} theme={{ mode }}>
+ <AgentInterface.SidebarFooter>
+ <AgentInterface.ThemeModeToggle mode={mode} onModeChange={setPreference} />
+ </AgentInterface.SidebarFooter>
+</AgentInterface>;
+```
+
### `AgentInterface.MobileHeader`
The top bar shown on mobile viewports in place of the (collapsed) sidebar. **Modes A, B, C.**
@@ -99,26 +119,35 @@ The top bar shown on mobile viewports in place of the (collapsed) sidebar. **Mod
### `AgentInterface.ThreadHeader`
-Header bar above the active conversation. **Modes A, C.**
+Desktop header above the active conversation: leading content, the chat title in the centre, then the workspace toggle and a Rename/Delete menu. Hidden on mobile (use `MobileHeader`). **Modes A, B.**
-| Prop | Type | Notes |
-| ----------- | ----------- | ----------------------------- |
-| `children` | `ReactNode` | Mode C — replaces the header. |
-| `className` | `string` | |
+| Prop | Type | Notes |
+| ----------------- | ----------- | ----------------------------------------------- |
+| `start` | `ReactNode` | Leading content, e.g. a model switcher. |
+| `center` | `ReactNode` | Replaces the chat title. |
+| `end` | `ReactNode` | Trailing content, before the workspace toggle. |
+| `children` | `ReactNode` | Shorthand for `end`. |
+| `showChatTitle` | `boolean` | Show the selected chat's title. Default `true`. |
+| `showChatActions` | `boolean` | Show the Rename/Delete menu. Default `true`. |
+| `className` | `string` | |
### `AgentInterface.Welcome`
The empty-state screen shown before the first message of a thread. **Modes A, B, C.** As with every slot, `children` (mode C) win over the content props (mode B) and a dev warning fires if you pass both.
-| Prop | Type | Notes |
-| ---------------- | ------------------------------ | -------------------------------------------------------------------------------------------------------------- |
-| `title` | `string` | Greeting/title text. |
-| `description` | `string` | Sub-text under the title. |
-| `image` | `{ url: string } \| ReactNode` | `{ url }` renders a styled 64×64 rounded `<img>`; a `ReactNode` is rendered as-is. |
-| `starters` | `ConversationStarterProps[]` | Conversation starters. Inherits from `<AgentInterface starters>` when omitted. |
-| `starterVariant` | `"short" \| "long"` | Layout for the starters. Inherits from `<AgentInterface starterVariant>`. |
-| `children` | `ReactNode` | Mode C — replaces the screen; when passed, `title`/`description`/`image`/`starters` are ignored (dev warning). |
-| `className` | `string` | |
+| Prop | Type | Notes |
+| ------------------ | ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `title` | `string` | Greeting/title text. |
+| `description` | `string` | Sub-text under the title. |
+| `image` | `{ url: string } \| ReactNode` | `{ url }` renders a styled 64×64 rounded `<img>`; a `ReactNode` is rendered as-is. |
+| `starters` | `ConversationStarterProps[]` | Conversation starters. Inherits from `<AgentInterface starters>` when omitted. |
+| `starterVariant` | `"short" \| "long" \| "card"` | Layout for the starters; `card` shows each as a card with its icon. Inherits from `<AgentInterface starterVariant>`. |
+| `promptTemplates` | `PromptTemplate[]` | Fill-in-the-blank templates shown as tabs between the composer and the starters. Picking one drops its prompt stem into the composer and lists its completions. |
+| `startersTabLabel` | `string` | Label of the leading tab that lists the default starters (shown with `promptTemplates`). Default `"Getting started"`. |
+| `startersTabIcon` | `ReactNode` | Icon of that leading tab. |
+| `glowAnimation` | `boolean` | Plays the one-time welcome entrance and dither around the composer. Default `false`. |
+| `children` | `ReactNode` | Mode C — replaces the screen; when passed, `title`/`description`/`image`/`starters` are ignored (dev warning). |
+| `className` | `string` | |
```tsx
<AgentInterface.Welcome
@@ -136,13 +165,13 @@ Each entry in `starters` is a `ConversationStarterProps`: `{ displayText: string
The message input at the bottom of the thread. **Modes A, B, C.**
-| Prop | Type | Notes |
-| ---------------- | ---------------------------- | ------------------------------------------------------------------------------------------------------ |
-| `placeholder` | `string` | Input placeholder. |
-| `starters` | `ConversationStarterProps[]` | Starter chips shown above the input when the chat is empty. Inherits from `<AgentInterface starters>`. |
-| `starterVariant` | `"short" \| "long"` | Inherits from `<AgentInterface starterVariant>`. |
-| `children` | `ReactNode` | Mode C — fully replaces the composer area; auto-starter rendering is then disabled. |
-| `className` | `string` | |
+| Prop | Type | Notes |
+| ---------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------ |
+| `placeholder` | `string` | Input placeholder. |
+| `starters` | `ConversationStarterProps[]` | Starter chips shown above the input when the chat is empty. Inherits from `<AgentInterface starters>`. |
+| `starterVariant` | `"short" \| "long" \| "card"` | Inherits from `<AgentInterface starterVariant>`. |
+| `children` | `ReactNode` | Mode C — fully replaces the composer area; auto-starter rendering is then disabled. |
+| `className` | `string` | |
### `AgentInterface.Workspace`
@@ -172,6 +201,8 @@ Place these inside slots — or, for `Route`, at the top level — to build cust
| `AgentInterface.ArtifactNav` | Sidebar nav into the global artifact browser. |
| `AgentInterface.Route` | Top-level exact-path view that replaces the thread region. |
| `AgentInterface.NewChatButton` | Button that starts a fresh thread. |
+| `AgentInterface.HistoryButton` | Thread-history menu on the collapsed sidebar rail. |
+| `AgentInterface.ThemeModeToggle` | Light/dark toggle, made for `SidebarFooter`. |
| `AgentInterface.ThreadList` | List of the user's threads from `storage.thread`. |
| `AgentInterface.Messages` | The active thread's messages + streaming message. |
| `AgentInterface.MessageLoading` | Default "assistant is thinking" indicator. |
@@ -278,6 +309,24 @@ A styled button that starts a fresh thread (clears the active thread and returns
<AgentInterface.NewChatButton />
```
+### `AgentInterface.HistoryButton`
+
+A shortcut to the thread history for the collapsed sidebar rail. It opens a menu of threads beside the rail, and picking one switches to it without expanding the sidebar. It renders only on the collapsed desktop rail, since the expanded sidebar already lists threads. The default sidebar includes it.
+
+| Prop | Type | Notes |
+| ----------- | -------- | ----- |
+| `className` | `string` | |
+
+### `AgentInterface.ThemeModeToggle`
+
+A round button that flips between light and dark, made for [`SidebarFooter`](#agentinterfacesidebarfooter). It shows the mode it switches to (a moon in light mode, a sun in dark) and works on the collapsed rail too. Pair it with `useThemeModePreference`, which saves the choice and returns the `mode` to pass to `<AgentInterface theme={{ mode }}>`.
+
+| Prop | Type | Notes |
+| -------------- | ----------------------------------- | ---------------------------------------- |
+| `mode` | `"light" \| "dark"` | The mode currently shown. |
+| `onModeChange` | `(next: "light" \| "dark") => void` | Called with the other mode when pressed. |
+| `className` | `string` | |
+
### `AgentInterface.ThreadList`
Renders the list of the user's threads from `storage.thread` (one row per thread). Clicking a row opens that thread and **auto-clears the current path** (returning to the thread view from any Route or the artifact browser).
@@ -296,13 +345,13 @@ Renders the list of the user's threads from `storage.thread` (one row per thread
Renders the active thread's messages, including the in-flight streaming message and the loading indicator. Used inside a custom thread region (typically wrapped in `ScrollArea`).
-| Prop | Type | Notes |
-| ------------------ | --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `loader` | `ReactNode` | Custom loading indicator shown while a response is pending. Defaults to `MessageLoading`. |
-| `assistantMessage` | component | Override for rendering the turn's assistant answer. Mirrors `components.AssistantMessage` on `<AgentInterface>`. |
-| `userMessage` | component | Override for rendering user messages. Mirrors `components.UserMessage`. |
-| `toolCallTimeline` | component | Override for the turn's tool timeline from the first activity onward. Mirrors `components.ToolCallTimeline` |
-| `className` | `string` | |
+| Prop | Type | Notes |
+| ------------------ | ----------- | ---------------------------------------------------------------------------------------------------------------- |
+| `loader` | `ReactNode` | Custom loading indicator shown while a response is pending. Defaults to `MessageLoading`. |
+| `assistantMessage` | component | Override for rendering the turn's assistant answer. Mirrors `components.AssistantMessage` on `<AgentInterface>`. |
+| `userMessage` | component | Override for rendering user messages. Mirrors `components.UserMessage`. |
+| `toolCallTimeline` | component | Override for the turn's tool timeline from the first activity onward. Mirrors `components.ToolCallTimeline` |
+| `className` | `string` | |
```tsx
<AgentInterface.ScrollArea>
diff --git a/packages/react-headless/src/stream/__tests__/processStreamedMessageToolStatus.test.ts b/packages/react-headless/src/stream/__tests__/processStreamedMessageToolStatus.test.ts
index 2fde83492..18ea3db56 100644
--- a/packages/react-headless/src/stream/__tests__/processStreamedMessageToolStatus.test.ts
+++ b/packages/react-headless/src/stream/__tests__/processStreamedMessageToolStatus.test.ts
@@ -60,6 +60,41 @@ describe("processStreamedMessage — tool status + errors", () => {
expect(cleared).toEqual(["tc-1"]);
});
+ it("publishes a call before its result, even while the assistant update is debounced", async () => {
+ // Server-side tools stream their call and result back to back. The second
+ // call only reaches the store through the debounced update, so without a
+ // flush its result would land first and pair with no call (a nameless tool).
+ let published: AssistantMessage | null = null;
+ const callIdsWhenResultLanded: string[][] = [];
+
+ await processStreamedMessage({
+ response: new Response(""),
+ createMessage: (m) => {
+ if (m.role === "assistant") published = m as AssistantMessage;
+ if (m.role === "tool") {
+ callIdsWhenResultLanded.push(published?.toolCalls?.map((tc) => tc.id) ?? []);
+ }
+ },
+ updateMessage: (m) => {
+ if (m.role === "assistant") published = m as AssistantMessage;
+ },
+ adapter: adapterFromEvents([
+ { type: EventType.TOOL_CALL_START, toolCallId: "tc-1", toolCallName: "get_weather" },
+ { type: EventType.TOOL_CALL_START, toolCallId: "tc-2", toolCallName: "web_search" },
+ {
+ type: EventType.TOOL_CALL_RESULT,
+ toolCallId: "tc-2",
+ content: "results",
+ messageId: "tm-2",
+ role: "tool",
+ },
+ ]),
+ });
+ await flush();
+
+ expect(callIdsWhenResultLanded).toEqual([["tc-1", "tc-2"]]);
+ });
+
it("surfaces isError/error from TOOL_CALL_RESULT onto ToolMessage.error", async () => {
const created: Message[] = [];
diff --git a/packages/react-headless/src/stream/processStreamedMessage.ts b/packages/react-headless/src/stream/processStreamedMessage.ts
index ed1235bd9..4f00945cc 100644
--- a/packages/react-headless/src/stream/processStreamedMessage.ts
+++ b/packages/react-headless/src/stream/processStreamedMessage.ts
@@ -220,6 +220,17 @@ export const processStreamedMessage = async ({
clearToolExecuting(event.toolCallId);
inFlightToolCallIds.delete(event.toolCallId);
+ // The call this result answers may still be waiting on the debounced
+ // assistant update (server-side tools stream their call and result
+ // back to back). Publish it first, or the result briefly pairs with no
+ // call and renders as a nameless tool — for as long as the frame is
+ // deferred, which in a background tab is until it's shown again.
+ if (rafId !== null) {
+ cancelAnimationFrame(rafId);
+ rafId = null;
+ updateMessage(currentMessage);
+ }
+
// Surface a failure onto the @ag-ui/core ToolMessage.error field. The
// TOOL_CALL_RESULT schema is `passthrough`, so adapters may carry an
// `isError` flag and/or `error` string; map either onto `error` so the
diff --git a/packages/react-ui/src/components/AgentInterface/AgentInterface.tsx b/packages/react-ui/src/components/AgentInterface/AgentInterface.tsx
index 47ddeea57..abcf7b503 100644
--- a/packages/react-ui/src/components/AgentInterface/AgentInterface.tsx
+++ b/packages/react-ui/src/components/AgentInterface/AgentInterface.tsx
@@ -51,13 +51,22 @@ import { ArtifactViewPage } from "./ArtifactViewPage";
import { Composer } from "./Composer";
import { Container } from "./Container";
import { type ConversationStarterVariant } from "./ConversationStarter";
+import { HistoryButton } from "./HistoryButton";
import { MobileHeader } from "./MobileHeader";
import { NewChatButton } from "./NewChatButton";
import { Route } from "./Route";
-import { SidebarContainer, SidebarContent, SidebarHeader, SidebarSeparator } from "./Sidebar";
+import {
+ SidebarContainer,
+ SidebarContent,
+ SidebarFooter,
+ SidebarHeader,
+ SidebarSeparator,
+} from "./Sidebar";
import { SidebarItem } from "./SidebarItem";
import { SidebarSlot } from "./SidebarSlot";
-import { MessageLoading, Messages, ScrollArea, ThreadContainer, ThreadHeader } from "./Thread";
+import { ThemeModeToggle } from "./ThemeModeToggle";
+import { MessageLoading, Messages, ScrollArea, ThreadContainer } from "./Thread";
+import { ThreadHeader } from "./ThreadHeader";
import { ThreadList } from "./ThreadList";
import { WelcomeGlow } from "./WelcomeGlow";
import { WelcomeScreen } from "./WelcomeScreen";
@@ -111,6 +120,7 @@ export interface AgentInterfaceProps extends Omit<ChatProviderProps, "children">
interface ExtractedSlots {
sidebar?: ReactElement;
sidebarHeader?: ReactElement;
+ sidebarFooter?: ReactElement;
mobileHeader?: ReactElement;
threadHeader?: ReactElement;
welcome?: ReactElement;
@@ -125,6 +135,7 @@ type SingleSlotKey = Exclude<keyof ExtractedSlots, "rest" | "routes">;
const SLOT_KEY_BY_TYPE = new Map<unknown, SingleSlotKey>([
[SidebarSlot, "sidebar"],
[SidebarHeader, "sidebarHeader"],
+ [SidebarFooter, "sidebarFooter"],
[MobileHeader, "mobileHeader"],
[ThreadHeader, "threadHeader"],
[WelcomeScreen, "welcome"],
@@ -170,6 +181,8 @@ interface AgentInterfaceComponent extends FC<AgentInterfaceProps> {
SidebarHeader: typeof SidebarHeader;
SidebarContent: typeof SidebarContent;
SidebarSeparator: typeof SidebarSeparator;
+ SidebarFooter: typeof SidebarFooter;
+ ThemeModeToggle: typeof ThemeModeToggle;
SidebarItem: typeof SidebarItem;
ArtifactNav: typeof ArtifactNav;
Workspace: typeof Workspace;
@@ -180,6 +193,7 @@ interface AgentInterfaceComponent extends FC<AgentInterfaceProps> {
WelcomeGlow: typeof WelcomeGlow;
Composer: typeof Composer;
NewChatButton: typeof NewChatButton;
+ HistoryButton: typeof HistoryButton;
ThreadList: typeof ThreadList;
Messages: typeof Messages;
MessageLoading: typeof MessageLoading;
@@ -420,12 +434,14 @@ const AgentInterfaceBody = ({
{slots.sidebarHeader ?? <SidebarHeader />}
<div className="openui-agent-sidebar-primary-actions">
<NewChatButton />
+ <HistoryButton />
<ArtifactNav className="openui-agent-sidebar-artifact-nav" />
</div>
</div>
<SidebarContent>
<ThreadList />
</SidebarContent>
+ {slots.sidebarFooter}
</>
)}
</SidebarContainer>
@@ -488,6 +504,8 @@ AgentInterface.Sidebar = SidebarSlot;
AgentInterface.SidebarHeader = SidebarHeader;
AgentInterface.SidebarContent = SidebarContent;
AgentInterface.SidebarSeparator = SidebarSeparator;
+AgentInterface.SidebarFooter = SidebarFooter;
+AgentInterface.ThemeModeToggle = ThemeModeToggle;
AgentInterface.SidebarItem = SidebarItem;
AgentInterface.ArtifactNav = ArtifactNav;
AgentInterface.Workspace = Workspace;
@@ -498,6 +516,7 @@ AgentInterface.Welcome = WelcomeScreen;
AgentInterface.WelcomeGlow = WelcomeGlow;
AgentInterface.Composer = Composer;
AgentInterface.NewChatButton = NewChatButton;
+AgentInterface.HistoryButton = HistoryButton;
AgentInterface.ThreadList = ThreadList;
AgentInterface.Messages = Messages;
AgentInterface.MessageLoading = MessageLoading;
diff --git a/packages/react-ui/src/components/AgentInterface/ArtifactBrowserPage.tsx b/packages/react-ui/src/components/AgentInterface/ArtifactBrowserPage.tsx
index a3c82259a..82d70164a 100644
--- a/packages/react-ui/src/components/AgentInterface/ArtifactBrowserPage.tsx
+++ b/packages/react-ui/src/components/AgentInterface/ArtifactBrowserPage.tsx
@@ -9,11 +9,11 @@ import {
import { Boxes, Search, X } from "lucide-react";
import { useEffect, useRef, useState, type ReactNode } from "react";
import { Button } from "../Button";
-import { DotMatrixLoader } from "../DotMatrixLoader";
import { IconButton } from "../IconButton";
import { artifactListPath, artifactViewPath } from "./_shared/artifactPaths";
import { useAgentInterfaceLabels } from "./_shared/labelsContext";
import { useNav } from "./_shared/navContext";
+import { MascotLoader } from "./components/MascotLoader";
const SEARCH_DEBOUNCE_MS = 300;
@@ -281,7 +281,7 @@ export const ArtifactBrowserPage = ({ categoryName }: { categoryName?: string })
})}
{isLoading && (
<div className="openui-agent-artifact-browser__loading">
- <DotMatrixLoader />
+ <MascotLoader size={40} />
</div>
)}
{!isLoading && nextCursor !== undefined && (
diff --git a/packages/react-ui/src/components/AgentInterface/ArtifactViewPage.tsx b/packages/react-ui/src/components/AgentInterface/ArtifactViewPage.tsx
index ee8d3d1aa..52d159662 100644
--- a/packages/react-ui/src/components/AgentInterface/ArtifactViewPage.tsx
+++ b/packages/react-ui/src/components/AgentInterface/ArtifactViewPage.tsx
@@ -9,10 +9,10 @@ import {
import { ArrowLeft, MessageSquare } from "lucide-react";
import { useEffect, useMemo, useRef, useState } from "react";
import { Button } from "../Button";
-import { DotMatrixLoader } from "../DotMatrixLoader";
import { IconButton } from "../IconButton";
import { artifactListPath } from "./_shared/artifactPaths";
import { useNav } from "./_shared/navContext";
+import { MascotLoader } from "./components/MascotLoader";
/**
* Full-page artifact view (reserved path `artifacts/{category}/{id}`),
@@ -102,7 +102,7 @@ export const ArtifactViewPage = ({
} else if (!artifact) {
body = (
<div className="openui-agent-artifact-view__loading">
- <DotMatrixLoader />
+ <MascotLoader size={40} />
</div>
);
} else if (!renderer) {
diff --git a/packages/react-ui/src/components/AgentInterface/Composer.tsx b/packages/react-ui/src/components/AgentInterface/Composer.tsx
index fa7a6bdcd..397b1690e 100644
--- a/packages/react-ui/src/components/AgentInterface/Composer.tsx
+++ b/packages/react-ui/src/components/AgentInterface/Composer.tsx
@@ -1,6 +1,6 @@
import { useThread } from "@openuidev/react-headless";
import clsx from "clsx";
-import type { ReactNode } from "react";
+import { useCallback, useRef, type ReactNode } from "react";
import type { ConversationStarterProps } from "../../types/ConversationStarter";
import { useStartersFromContext } from "./_shared/startersContext";
import { isChatEmpty } from "./_shared/utils";
@@ -18,6 +18,34 @@ export interface ComposerProps {
children?: ReactNode;
}
+/**
+ * Publishes the composer slot's height on its panel as
+ * `--openui-agent-composer-slot-height`, so the scroll area (which runs behind
+ * the floating composer) can pad and fade by exactly that much. A callback ref
+ * re-attaches the observer whenever the slot element is replaced.
+ */
+const useComposerSlotHeight = () => {
+ const disposeRef = useRef<(() => void) | null>(null);
+ return useCallback((slot: HTMLDivElement | null) => {
+ // React 18 detaches by calling the ref with null; React 19 calls the
+ // returned cleanup instead. Either path disconnects the observer.
+ disposeRef.current?.();
+ disposeRef.current = null;
+ if (!slot) return;
+ const update = () =>
+ slot.parentElement?.style.setProperty(
+ "--openui-agent-composer-slot-height",
+ `${slot.offsetHeight}px`,
+ );
+ update();
+ const observer = new ResizeObserver(update);
+ observer.observe(slot);
+ const dispose = () => observer.disconnect();
+ disposeRef.current = dispose;
+ return dispose;
+ }, []);
+};
+
export const Composer = ({
className,
placeholder,
@@ -28,9 +56,14 @@ export const Composer = ({
const fromCtx = useStartersFromContext();
const messages = useThread((s) => s.messages);
const isLoadingMessages = useThread((s) => s.isLoadingMessages);
+ const slotRef = useComposerSlotHeight();
if (children != null) {
- return <div className={clsx("openui-agent-composer-slot", className)}>{children}</div>;
+ return (
+ <div ref={slotRef} className={clsx("openui-agent-composer-slot", className)}>
+ {children}
+ </div>
+ );
}
const effectiveStarters = ownStarters ?? fromCtx.starters;
@@ -41,7 +74,7 @@ export const Composer = ({
effectiveStarters.length > 0;
return (
- <div className={clsx("openui-agent-composer-slot", className)}>
+ <div ref={slotRef} className={clsx("openui-agent-composer-slot", className)}>
{showStarters && (
<ConversationStarter starters={effectiveStarters!} variant={effectiveVariant} />
)}
diff --git a/packages/react-ui/src/components/AgentInterface/Container.tsx b/packages/react-ui/src/components/AgentInterface/Container.tsx
index e236c5e77..e0d865b6a 100644
--- a/packages/react-ui/src/components/AgentInterface/Container.tsx
+++ b/packages/react-ui/src/components/AgentInterface/Container.tsx
@@ -1,10 +1,12 @@
import * as Tooltip from "@radix-ui/react-tooltip";
import clsx from "clsx";
-import { useRef } from "react";
+import { useEffect, useRef, useState } from "react";
import { LayoutContextProvider } from "../../context/LayoutContext";
import { useElementSize } from "../../hooks/useElementSize";
import { ShellStoreProvider } from "../_shared/store";
-import { AgentInterfaceStoreProvider } from "./_shared/store";
+import { useIsomorphicLayoutEffect } from "../Charts/hooks/core/useIsomorphicLayoutEffect";
+import { AgentInterfaceStoreProvider, useAgentInterfaceStore } from "./_shared/store";
+import { AmbientLoader } from "./components/AmbientLoader";
interface ContainerProps {
children?: React.ReactNode;
@@ -32,21 +34,90 @@ export const Container = ({ children, logoUrl, agentName, className }: Container
delay and skip-delay behavior are shared across all tooltips
(instead of each tooltip mounting its own provider). */}
<Tooltip.Provider delayDuration={250}>
- <div
- className={clsx(
- "openui-agent-container",
- {
- "openui-agent-container--mobile": isMobile,
- },
- className,
- )}
- ref={ref}
- >
+ <ContainerSurface surfaceRef={ref} isMobile={isMobile} className={className}>
{children}
- </div>
+ </ContainerSurface>
</Tooltip.Provider>
</LayoutContextProvider>
</ShellStoreProvider>
</AgentInterfaceStoreProvider>
);
};
+
+const SETTLING_ATTRIBUTE = "data-openui-settling";
+/** Keep in step with the loader fade in agentInterface.scss. */
+const LOADER_FADE_MS = 200;
+
+/**
+ * The interface's surface. Its contents stay hidden, under a loader that then
+ * fades out, until the saved preferences are restored (just after hydration,
+ * before paint), so a server-rendered page never shows the defaults and then
+ * switches. `visibility` (not `display`) keeps the layout measurable while
+ * hidden.
+ */
+const ContainerSurface = ({
+ surfaceRef,
+ isMobile,
+ className,
+ children,
+}: {
+ surfaceRef: React.RefObject<HTMLDivElement | null>;
+ isMobile: boolean;
+ className?: string;
+ children?: React.ReactNode;
+}) => {
+ const isRestoring = useAgentInterfaceStore((state) => !state.isHydrated);
+ // The loader outlives the restore by its fade-out, then unmounts.
+ const [showLoader, setShowLoader] = useState(true);
+ useEffect(() => {
+ if (isRestoring) return;
+ const id = setTimeout(() => setShowLoader(false), LOADER_FADE_MS);
+ return () => clearTimeout(id);
+ }, [isRestoring]);
+
+ // Transitions stay off until the restored state has settled. The server
+ // HTML was already styled with the defaults, so applying the saved state
+ // would otherwise animate (e.g. the sidebar growing open). Set on the DOM
+ // node directly so hydration never sees it.
+ useIsomorphicLayoutEffect(() => {
+ const el = surfaceRef.current;
+ if (!el) return;
+ if (isRestoring) {
+ el.setAttribute(SETTLING_ATTRIBUTE, "");
+ return;
+ }
+ // After the restore's follow-up renders: take the final styles with
+ // transitions still off, then turn them back on.
+ const id = setTimeout(() => {
+ void el.offsetWidth;
+ el.removeAttribute(SETTLING_ATTRIBUTE);
+ }, 0);
+ return () => clearTimeout(id);
+ }, [isRestoring]);
+
+ return (
+ <div
+ className={clsx(
+ "openui-agent-container",
+ {
+ "openui-agent-container--mobile": isMobile,
+ "openui-agent-container--restoring": isRestoring,
+ },
+ className,
+ )}
+ ref={surfaceRef}
+ >
+ {children}
+ {showLoader && (
+ <div
+ className={clsx("openui-agent-container__restore-loader", {
+ "openui-agent-container__restore-loader--exiting": !isRestoring,
+ })}
+ aria-hidden={!isRestoring || undefined}
+ >
+ <AmbientLoader label="" />
+ </div>
+ )}
+ </div>
+ );
+};
diff --git a/packages/react-ui/src/components/AgentInterface/ConversationStarter.tsx b/packages/react-ui/src/components/AgentInterface/ConversationStarter.tsx
index d5576d813..0381d8ca8 100644
--- a/packages/react-ui/src/components/AgentInterface/ConversationStarter.tsx
+++ b/packages/react-ui/src/components/AgentInterface/ConversationStarter.tsx
@@ -6,7 +6,7 @@ import { ConversationStarterIcon, ConversationStarterProps } from "../../types/C
import { Carousel, CarouselContent } from "../Carousel";
import { isChatEmpty } from "./_shared/utils";
-export type ConversationStarterVariant = "short" | "long";
+export type ConversationStarterVariant = "short" | "long" | "card";
interface ConversationStarterItemProps extends ConversationStarterProps {
onClick: () => void;
@@ -61,6 +61,21 @@ const ConversationStarterItem = ({
);
}
+ if (variant === "card") {
+ return (
+ <button
+ type="button"
+ className="openui-agent-conversation-starter-item-card"
+ onClick={onClick}
+ >
+ {shouldRenderIcon && (
+ <span className="openui-agent-conversation-starter-item-card__icon">{renderedIcon}</span>
+ )}
+ <span className="openui-agent-conversation-starter-item-card__text">{displayText}</span>
+ </button>
+ );
+ }
+
// Long variant (detailed list style)
return (
<button type="button" className="openui-agent-conversation-starter-item-long" onClick={onClick}>
@@ -84,6 +99,7 @@ export interface ConversationStarterContainerProps {
* Variant of the conversation starter
* - "short": Pill-style horizontal buttons (default)
* - "long": Vertical list items with icons and hover arrow
+ * - "card": A row of equal-width cards, icon above text
*/
variant?: ConversationStarterVariant;
/**
@@ -162,7 +178,7 @@ export const ConversationStarter = ({
>
{starters.map((item, index) => (
<Fragment key={`${item.displayText}-${index}`}>
- {index > 0 && (
+ {index > 0 && variant === "long" && (
<div className="openui-agent-conversation-starter__separator" aria-hidden="true" />
)}
<ConversationStarterItem
diff --git a/packages/react-ui/src/components/AgentInterface/HistoryButton.tsx b/packages/react-ui/src/components/AgentInterface/HistoryButton.tsx
new file mode 100644
index 000000000..19796573a
--- /dev/null
+++ b/packages/react-ui/src/components/AgentInterface/HistoryButton.tsx
@@ -0,0 +1,86 @@
+import { useThreadList } from "@openuidev/react-headless";
+import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
+import clsx from "clsx";
+import { Clock } from "lucide-react";
+import { useState } from "react";
+import { useLayoutContext } from "../../context/LayoutContext";
+import { useOptionalSidebarVisualState } from "./Sidebar";
+import { SidebarTooltip } from "./SidebarTooltip";
+import { useOptionalNav } from "./_shared/navContext";
+import { useAgentInterfaceStore } from "./_shared/store";
+
+/**
+ * Collapsed-rail shortcut to the thread history. Opens a menu of threads beside
+ * the rail; picking one switches to it without expanding the sidebar. The
+ * expanded sidebar already lists threads, so the button only renders on the
+ * collapsed desktop rail.
+ */
+export const HistoryButton = ({ className }: { className?: string }) => {
+ const { isSidebarOpen } = useAgentInterfaceStore((state) => ({
+ isSidebarOpen: state.isSidebarOpen,
+ }));
+ const sidebarVisualState = useOptionalSidebarVisualState();
+ const isCollapsed = sidebarVisualState ? sidebarVisualState.isCollapsedLayout : !isSidebarOpen;
+ const { layout } = useLayoutContext();
+ const threads = useThreadList((s) => s.threads);
+ const isLoadingThreads = useThreadList((s) => s.isLoadingThreads);
+ const selectThread = useThreadList((s) => s.selectThread);
+ const selectedThreadId = useThreadList((s) => s.selectedThreadId);
+ const nav = useOptionalNav();
+ const [open, setOpen] = useState(false);
+
+ if (layout === "mobile" || !isCollapsed) return null;
+
+ const handleSelect = (id: string) => {
+ selectThread(id);
+ if (nav && nav.path !== undefined) {
+ nav.navigate(undefined);
+ }
+ };
+
+ return (
+ <DropdownMenu.Root open={open} onOpenChange={setOpen} modal={false}>
+ <SidebarTooltip content="History" disabled={open}>
+ <DropdownMenu.Trigger asChild>
+ <button
+ type="button"
+ className={clsx("openui-agent-history-button", className)}
+ aria-label="Chat history"
+ >
+ <Clock size="1em" aria-hidden="true" />
+ </button>
+ </DropdownMenu.Trigger>
+ </SidebarTooltip>
+ <DropdownMenu.Portal>
+ <DropdownMenu.Content
+ className="openui-agent-history-menu"
+ side="right"
+ align="start"
+ sideOffset={8}
+ collisionPadding={12}
+ >
+ <DropdownMenu.Label className="openui-agent-history-menu__label">
+ Recent chats
+ </DropdownMenu.Label>
+ {threads.length === 0 ? (
+ <div className="openui-agent-history-menu__empty">
+ {isLoadingThreads ? "Loading…" : "No chats yet"}
+ </div>
+ ) : (
+ threads.map((thread) => (
+ <DropdownMenu.Item
+ key={thread.id}
+ className={clsx("openui-agent-history-menu__item", {
+ "openui-agent-history-menu__item--selected": thread.id === selectedThreadId,
+ })}
+ onSelect={() => handleSelect(thread.id)}
+ >
+ <span className="openui-agent-history-menu__title">{thread.title}</span>
+ </DropdownMenu.Item>
+ ))
+ )}
+ </DropdownMenu.Content>
+ </DropdownMenu.Portal>
+ </DropdownMenu.Root>
+ );
+};
diff --git a/packages/react-ui/src/components/AgentInterface/MobileHeader.tsx b/packages/react-ui/src/components/AgentInterface/MobileHeader.tsx
index c47b05b6f..b3fb90001 100644
--- a/packages/react-ui/src/components/AgentInterface/MobileHeader.tsx
+++ b/packages/react-ui/src/components/AgentInterface/MobileHeader.tsx
@@ -1,6 +1,6 @@
import { useThreadList } from "@openuidev/react-headless";
import clsx from "clsx";
-import { Menu, SquarePen } from "lucide-react";
+import { PanelLeft, SquarePen } from "lucide-react";
import type { ReactNode } from "react";
import { IconButton } from "../IconButton";
import { useAgentInterfaceStore } from "./_shared/store";
@@ -50,9 +50,9 @@ export const MobileHeader = ({
const defaultMenuButton = (
<IconButton
size="medium"
- icon={<Menu size="1em" />}
+ icon={<PanelLeft size="1em" strokeWidth={2} />}
onClick={() => setIsSidebarOpen(true)}
- variant="secondary"
+ variant="tertiary"
aria-label="Open sidebar"
/>
);
@@ -61,12 +61,14 @@ export const MobileHeader = ({
<span className="openui-agent-mobile-header-agent-name">{ctxAgentName}</span>
);
+ // The same filled round button as the collapsed rail's New chat.
const defaultNewChatButton = (
<IconButton
size="medium"
icon={<SquarePen size="1em" />}
+ className="openui-agent-mobile-header-new-chat"
onClick={switchToNewThread}
- variant="secondary"
+ variant="primary"
aria-label="New chat"
/>
);
diff --git a/packages/react-ui/src/components/AgentInterface/NewChatButton.tsx b/packages/react-ui/src/components/AgentInterface/NewChatButton.tsx
index 26ae5db95..a551c08f0 100644
--- a/packages/react-ui/src/components/AgentInterface/NewChatButton.tsx
+++ b/packages/react-ui/src/components/AgentInterface/NewChatButton.tsx
@@ -11,6 +11,8 @@ import { useAgentInterfaceStore } from "./_shared/store";
export const NewChatButton = ({ className }: { className?: string }) => {
const switchToNewThread = useThreadList((s) => s.switchToNewThread);
+ // A fresh chat has no thread yet, so the New Chat row is the current place.
+ const isNewChatActive = useThreadList((s) => !s.selectedThreadId);
const { isSidebarOpen } = useAgentInterfaceStore((state) => ({
isSidebarOpen: state.isSidebarOpen,
}));
@@ -51,7 +53,10 @@ export const NewChatButton = ({ className }: { className?: string }) => {
type="button"
className={clsx(
"openui-agent-new-chat-button",
- { "openui-agent-new-chat-button--collapsed": !showExpandedButton },
+ {
+ "openui-agent-new-chat-button--collapsed": !showExpandedButton,
+ "openui-agent-new-chat-button--selected": isNewChatActive,
+ },
className,
)}
onClick={handleNewChat}
diff --git a/packages/react-ui/src/components/AgentInterface/README.md b/packages/react-ui/src/components/AgentInterface/README.md
index 843705072..addc661bd 100644
--- a/packages/react-ui/src/components/AgentInterface/README.md
+++ b/packages/react-ui/src/components/AgentInterface/README.md
@@ -86,7 +86,7 @@ See `stories/AgentInterface.stories.tsx` (`Default`, `WithWelcome`, `Routing`, `
## The slot / compound-component model
-`AgentInterface` is a function component with ~17 **static members** attached
+`AgentInterface` is a function component with ~21 **static members** attached
(`AgentInterface.Sidebar`, `AgentInterface.Composer`, …). At render time it walks
`props.children` once (`extractSlots`, in `AgentInterface.tsx`) and routes each child by the
**identity of its element type**:
@@ -95,6 +95,7 @@ See `stories/AgentInterface.stories.tsx` (`Default`, `WithWelcome`, `Routing`, `
const SLOT_KEY_BY_TYPE = new Map<unknown, SingleSlotKey>([
[SidebarSlot, "sidebar"],
[SidebarHeader, "sidebarHeader"],
+ [SidebarFooter, "sidebarFooter"],
[MobileHeader, "mobileHeader"],
[ThreadHeader, "threadHeader"],
[WelcomeScreen, "welcome"],
@@ -123,25 +124,28 @@ A child is recognized **only** if `child.type === <the exact component reference
The full list of static members and whether each is a top-level slot:
-| Member | Top-level slot? | Role |
-| --------------------------------- | ------------------- | -------------------------------------------------- |
-| `AgentInterface.Sidebar` | ✅ `sidebar` | Replace the whole sidebar; you compose its insides |
-| `AgentInterface.SidebarHeader` | ✅ `sidebarHeader`¹ | Default sidebar's header (logo + name + collapse) |
-| `AgentInterface.MobileHeader` | ✅ `mobileHeader` | Top bar on mobile |
-| `AgentInterface.ThreadHeader` | ✅ `threadHeader` | Thread region header (actions, workspace toggle) |
-| `AgentInterface.Welcome` | ✅ `welcome` | Empty-state hero (`WelcomeScreen`) |
-| `AgentInterface.Composer` | ✅ `composer` | Message input |
-| `AgentInterface.Workspace` | ✅ `workspace` | Per-thread artifact rail |
-| `AgentInterface.Route` | ✅ `routes[]` | Custom routable view (see Routing) |
-| `AgentInterface.SidebarContent` | ❌ building block | Scrollable region inside a custom Sidebar |
-| `AgentInterface.SidebarSeparator` | ❌ building block | Divider inside a custom Sidebar |
-| `AgentInterface.SidebarItem` | ❌ building block | Styled nav row (also exported standalone) |
-| `AgentInterface.ArtifactNav` | ❌ building block | Artifact-category nav rows |
-| `AgentInterface.NewChatButton` | ❌ building block | "New chat" affordance |
-| `AgentInterface.ThreadList` | ❌ building block | Date-grouped thread history |
-| `AgentInterface.Messages` | ❌ building block | The message list itself |
-| `AgentInterface.MessageLoading` | ❌ building block | Streaming loader row |
-| `AgentInterface.ScrollArea` | ❌ building block | Auto-scroll container |
+| Member | Top-level slot? | Role |
+| --------------------------------- | ------------------- | ------------------------------------------------------------------------------------------------- |
+| `AgentInterface.Sidebar` | ✅ `sidebar` | Replace the whole sidebar; you compose its insides |
+| `AgentInterface.SidebarHeader` | ✅ `sidebarHeader`¹ | Default sidebar's header (logo + name + collapse) |
+| `AgentInterface.SidebarFooter` | ✅ `sidebarFooter` | Pinned below the thread list (e.g. theme toggle) |
+| `AgentInterface.MobileHeader` | ✅ `mobileHeader` | Top bar on mobile |
+| `AgentInterface.ThreadHeader` | ✅ `threadHeader` | Floating desktop header: `start`/`center`/`end`, chat title, Rename/Delete menu, workspace toggle |
+| `AgentInterface.Welcome` | ✅ `welcome` | Empty-state hero (`WelcomeScreen`) |
+| `AgentInterface.Composer` | ✅ `composer` | Message input |
+| `AgentInterface.Workspace` | ✅ `workspace` | Per-thread artifact rail |
+| `AgentInterface.Route` | ✅ `routes[]` | Custom routable view (see Routing) |
+| `AgentInterface.SidebarContent` | ❌ building block | Scrollable region inside a custom Sidebar |
+| `AgentInterface.SidebarSeparator` | ❌ building block | Divider inside a custom Sidebar |
+| `AgentInterface.SidebarItem` | ❌ building block | Styled nav row (also exported standalone) |
+| `AgentInterface.ArtifactNav` | ❌ building block | Artifact-category nav rows |
+| `AgentInterface.NewChatButton` | ❌ building block | "New chat" affordance |
+| `AgentInterface.HistoryButton` | ❌ building block | Thread-history menu on the collapsed rail |
+| `AgentInterface.ThemeModeToggle` | ❌ building block | Light/dark toggle for `SidebarFooter` |
+| `AgentInterface.ThreadList` | ❌ building block | Date-grouped thread history |
+| `AgentInterface.Messages` | ❌ building block | The message list itself |
+| `AgentInterface.MessageLoading` | ❌ building block | Streaming loader row |
+| `AgentInterface.ScrollArea` | ❌ building block | Auto-scroll container |
¹ Only honored at top level when no `Sidebar` slot is present; otherwise nest it inside `Sidebar`.
@@ -178,7 +182,7 @@ Defined as `AgentInterfaceProps` in `AgentInterface.tsx`. It `extends Omit<ChatP
| `logoUrl` | `string` | `""` | Brand logo (default `SidebarHeader` + `MobileHeader`) |
| `agentName` | `string` | `""` | Agent display name |
| `starters` | `ConversationStarterProps[]` | — | Global starters inherited by Welcome (if active) or the Composer |
-| `starterVariant` | `"short" \| "long"` | — | Layout variant for inherited starters |
+| `starterVariant` | `"short" \| "long" \| "card"` | — | Layout variant for inherited starters |
| `path` | `string` | — | **Controlled** current path (pair with `onNavigate`); `undefined` = thread view |
| `defaultPath` | `string` | — | **Uncontrolled** initial path (ignored when `onNavigate` is set) |
| `onNavigate` | `(next: string \| undefined) => void` | — | Presence selects controlled mode |
@@ -206,16 +210,18 @@ and avatar). Resolution order, per message kind:
### Named exports (from `index.ts`)
-| Export | Kind | Purpose |
-| ------------------------------------------------------------------------------ | ---------------- | ------------------------------------------ |
-| `AgentInterface` | component | The compound root |
-| `AgentInterfaceProps`, `AgentInterfaceComponents`, `ToolCallTimelineComponent` | types | Root props / override map |
-| `SidebarItem`, `SidebarItemProps` | component + type | Standalone nav row |
-| `ArtifactNav`, `ArtifactNavProps` | component + type | Artifact-category nav |
-| `useNav`, `NavContextValue` | hook + type | Read/drive navigation from inside the tree |
-| `RouteProps` | type | `<AgentInterface.Route>` props |
-| `WorkspaceProps` | type | `<AgentInterface.Workspace>` props |
-| `artifactListPath`, `artifactViewPath` | functions | Build reserved `artifacts/…` paths |
+| Export | Kind | Purpose |
+| ------------------------------------------------------------------------------ | ---------------- | ------------------------------------------------------ |
+| `AgentInterface` | component | The compound root |
+| `AgentInterfaceProps`, `AgentInterfaceComponents`, `ToolCallTimelineComponent` | types | Root props / override map |
+| `SidebarItem`, `SidebarItemProps` | component + type | Standalone nav row |
+| `ArtifactNav`, `ArtifactNavProps` | component + type | Artifact-category nav |
+| `useNav`, `NavContextValue` | hook + type | Read/drive navigation from inside the tree |
+| `RouteProps` | type | `<AgentInterface.Route>` props |
+| `WorkspaceProps` | type | `<AgentInterface.Workspace>` props |
+| `ThreadHeaderProps` | type | `<AgentInterface.ThreadHeader>` props |
+| `ThemeModeToggle`, `ThemeModeToggleProps` | component + type | Light/dark toggle (pair with `useThemeModePreference`) |
+| `artifactListPath`, `artifactViewPath` | functions | Build reserved `artifacts/…` paths |
---
@@ -271,7 +277,7 @@ Most slots support three levels of customization (the codebase comments call the
When you go Mode C on the Sidebar, compose it from the building-block members:
`SidebarHeader`, `SidebarContent`, `SidebarSeparator`, `SidebarItem`, `ArtifactNav`, `NewChatButton`,
-`ThreadList`.
+`HistoryButton`, `ThreadList`, and `SidebarFooter` + `ThemeModeToggle` at the bottom.
---
@@ -295,15 +301,33 @@ Mounted by `<ChatProvider>`. Read via hooks:
Two **separate** zustand stores are mounted in `Container.tsx`. They are _not_ the same store and
serve different consumers:
-| Store | File | Holds | Read with | Used by |
-| ----------------------- | --------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------ |
-| **AgentInterfaceStore** | `_shared/store/store.tsx` | `isSidebarOpen` (default **true**), `isWorkspaceOpen` (default **false**), `agentName`, `logoUrl` | `useAgentInterfaceStore` | All AgentInterface chrome (sidebar, workspace toggles, header) |
-| **ShellStore** | `../_shared/store/store.tsx` (library-wide, shared with `OpenUIChat`) | `isSidebarOpen`, `isWorkspaceOpen` (default **true**), `agentName`, `logoUrl`, `showAssistantLogo` | `useShellStore` | The GenUI assistant-message components, which read `agentName`/`logoUrl`/`showAssistantLogo` from here |
+| Store | File | Holds | Read with | Used by |
+| ----------------------- | --------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------ |
+| **AgentInterfaceStore** | `_shared/store/store.tsx` | `isSidebarOpen` (default **false**), `isHydrated`, `isWorkspaceOpen` (default **false**), `agentName`, `logoUrl` | `useAgentInterfaceStore` | All AgentInterface chrome (sidebar, workspace toggles, header) |
+| **ShellStore** | `../_shared/store/store.tsx` (library-wide, shared with `OpenUIChat`) | `isSidebarOpen`, `isWorkspaceOpen` (default **true**), `agentName`, `logoUrl`, `showAssistantLogo` | `useShellStore` | The GenUI assistant-message components, which read `agentName`/`logoUrl`/`showAssistantLogo` from here |
Both are seeded from the same `logoUrl`/`agentName` and kept in sync to props via effects, but
their `isWorkspaceOpen` defaults differ and they are **not** cross-synced. See
[Gotchas](#gotchas--known-rough-edges).
+### Saved preferences & server rendering
+
+Saved UI preferences go through one helper, `utils/preferences.ts` (`readPreference` /
+`writePreference`: JSON values, never throws, so blocked or full storage just means nothing is
+kept). Each is read once after hydration, before paint, so server HTML and the client's first
+render match.
+
+- **Sidebar open** (`openui-agent-sidebar-open`): read and written by `SidebarContainer` (desktop
+ only, so opening the drawer on mobile isn't remembered on desktop). The store holds just the
+ live `isSidebarOpen`; once `isHydrated` is set, `SidebarContainer` restores the saved choice
+ without animating.
+- **Sidebar width** (`openui-agent-sidebar-width`): read and written by `SidebarResizeEdge`, which
+ sets it straight on the container as a CSS variable.
+- **Theme** (`openui-theme-mode`): `ThemeProvider/useThemeModePreference.ts`.
+- **Reveal:** until `isHydrated` is set, `Container` hides its contents (`visibility`, so
+ layout still measures) under a fading loader, and keeps transitions off until the restored
+ styles settle.
+
Plus three React contexts:
- **`NavContext`** (`_shared/navContext.tsx`) — `{ path, navigate }`. `useNav()` (throws outside the
@@ -535,27 +559,32 @@ AgentInterface/
├ AgentInterface.tsx Root: props, extractSlots, provider stack, AgentInterfaceBody view switch
├ Container.tsx Flex shell; width→layout mode; mounts the two stores + LayoutContext + Tooltip.Provider
├ Route.tsx Slot marker for routable views (renders null; consumed by parent)
-├ Sidebar.tsx SidebarContainer/Header/Content/Separator + collapse/expand state machine
+├ Sidebar.tsx SidebarContainer/Header/Content/Separator/Footer + collapse/expand state machine
+├ SidebarResizeEdge.tsx Draggable sidebar edge (220–420px, snaps shut below 150px; width saved in the store)
+├ HistoryButton.tsx Collapsed-rail thread-history menu
+├ ThemeModeToggle.tsx Light/dark toggle for SidebarFooter
├ SidebarItem.tsx Styled, nav-aware clickable row (exported)
├ SidebarSlot.tsx The <AgentInterface.Sidebar> slot marker
├ SidebarTooltip.tsx Collapsed-sidebar tooltip (right/center, fixed offset)
-├ ThreadList.tsx Date-grouped thread history + per-thread menu
-├ Thread.tsx ThreadContainer, ScrollArea, Messages, RenderMessage, ThreadHeader, ThreadError, loader
+├ ThreadList.tsx Date-grouped thread history + per-thread menu (Rename/Delete)
+├ RenameChatDialog.tsx Rename dialog shared by ThreadList and ThreadHeader
+├ Thread.tsx ThreadContainer, ScrollArea, Messages, RenderMessage, WorkspaceToggleButton, ThreadError, loader
+├ ThreadHeader.tsx Floating desktop header (start/center/end, chat title, actions menu)
├ UserMessageContent.tsx Full AG-UI InputContent union renderer (+ URL/data allowlists, file chips)
├ MobileHeader.tsx Mobile top bar
├ NewChatButton.tsx New-chat affordance
├ Composer.tsx Thin re-export of components/Composer
-├ ConversationStarter.tsx Starter chips ("short" | "long" variant)
-├ WelcomeScreen.tsx Empty-state hero (title/description/image/starters or children)
+├ ConversationStarter.tsx Starters ("short" | "long" | "card" variant)
+├ WelcomeScreen.tsx Empty-state hero (title/description/image/starters, prompt-template tabs, or children)
├ Workspace.tsx Per-thread artifact rail (tabs, sections, mobile drawer)
├ ArtifactBrowserPage.tsx Global searchable artifact list (also exports preview/format helpers)
├ ArtifactNav.tsx Sidebar category nav into the browser (exported)
├ ArtifactViewPage.tsx Full-page artifact view
├ ResizableSeparator.tsx Keyboard+ARIA resize handle for the detailed-view split
├ useDetailedViewResize.ts Drag/keyboard resize logic (writes panel width imperatively)
-├ components/ Composer + DesktopWelcomeComposer (and their SCSS)
+├ components/ Composer, DesktopWelcomeComposer, AmbientLoader, Mascot/MascotLoader, WelcomeMascot (and their SCSS)
├ _shared/
-│ ├ store/ AgentInterfaceStore (sidebar/workspace/agentName/logoUrl)
+│ ├ store/ AgentInterfaceStore (sidebar + saved preferences/workspace/agentName/logoUrl)
│ ├ navContext.tsx NavProvider / useNav / useOptionalNav
│ ├ startersContext.tsx StartersProvider / useStartersFromContext
│ ├ artifactPaths.ts Reserved artifacts/… path build+parse
diff --git a/packages/react-ui/src/components/AgentInterface/RenameChatDialog.tsx b/packages/react-ui/src/components/AgentInterface/RenameChatDialog.tsx
new file mode 100644
index 000000000..fd297c4d7
--- /dev/null
+++ b/packages/react-ui/src/components/AgentInterface/RenameChatDialog.tsx
@@ -0,0 +1,80 @@
+import { useThreadList } from "@openuidev/react-headless";
+import * as Dialog from "@radix-ui/react-dialog";
+import { FormEvent, useEffect, useRef, useState } from "react";
+import { Button } from "../Button";
+import { Input } from "../Input";
+
+export interface RenameChatDialogProps {
+ /** The chat (thread) to rename. */
+ threadId: string;
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+}
+
+/**
+ * Small dialog for renaming a chat: a title field prefilled with the current
+ * name, Save / Cancel. Enter saves, Escape closes. Shared by the sidebar thread
+ * menu and the ThreadHeader actions menu.
+ */
+export const RenameChatDialog = ({ threadId, open, onOpenChange }: RenameChatDialogProps) => {
+ const thread = useThreadList((s) => s.threads.find((t) => t.id === threadId));
+ const updateThread = useThreadList((s) => s.updateThread);
+ const [title, setTitle] = useState(thread?.title ?? "");
+ const inputRef = useRef<HTMLInputElement>(null);
+
+ // Re-seed the field from the current title each time the dialog opens.
+ useEffect(() => {
+ if (open) setTitle(thread?.title ?? "");
+ }, [open, thread?.title]);
+
+ const trimmed = title.trim();
+ const canSave = !!thread && trimmed.length > 0 && trimmed !== thread.title;
+
+ const handleSubmit = (e: FormEvent) => {
+ e.preventDefault();
+ if (!thread) return;
+ if (canSave) updateThread({ ...thread, title: trimmed });
+ onOpenChange(false);
+ };
+
+ return (
+ <Dialog.Root open={open} onOpenChange={onOpenChange}>
+ <Dialog.Portal>
+ <Dialog.Overlay className="openui-agent-rename-dialog__overlay" />
+ <Dialog.Content
+ className="openui-agent-rename-dialog"
+ aria-describedby={undefined}
+ onOpenAutoFocus={(e) => {
+ e.preventDefault();
+ inputRef.current?.focus();
+ inputRef.current?.select();
+ }}
+ >
+ <form className="openui-agent-rename-dialog__form" onSubmit={handleSubmit}>
+ <Dialog.Title className="openui-agent-rename-dialog__title">Rename chat</Dialog.Title>
+ <Input
+ ref={inputRef}
+ value={title}
+ onChange={(e) => setTitle(e.target.value)}
+ aria-label="Chat title"
+ placeholder="Chat title"
+ className="openui-agent-rename-dialog__input"
+ />
+ <div className="openui-agent-rename-dialog__actions">
+ <Dialog.Close asChild>
+ <Button type="button" variant="tertiary" size="small">
+ Cancel
+ </Button>
+ </Dialog.Close>
+ <Button type="submit" variant="primary" size="small" disabled={!canSave}>
+ Save
+ </Button>
+ </div>
+ </form>
+ </Dialog.Content>
+ </Dialog.Portal>
+ </Dialog.Root>
+ );
+};
+
+export default RenameChatDialog;
diff --git a/packages/react-ui/src/components/AgentInterface/Sidebar.tsx b/packages/react-ui/src/components/AgentInterface/Sidebar.tsx
index af244dec2..124bab42a 100644
--- a/packages/react-ui/src/components/AgentInterface/Sidebar.tsx
+++ b/packages/react-ui/src/components/AgentInterface/Sidebar.tsx
@@ -3,10 +3,20 @@ import clsx from "clsx";
import { PanelLeft } from "lucide-react";
import { createContext, useContext, useEffect, useMemo, useRef, useState } from "react";
import { useLayoutContext } from "../../context/LayoutContext";
+import { readPreference, writePreference } from "../../utils/preferences";
+import { useIsomorphicLayoutEffect } from "../Charts/hooks/core/useIsomorphicLayoutEffect";
import { IconButton } from "../IconButton";
+import { SidebarResizeEdge } from "./SidebarResizeEdge";
import { AgentInterfaceTooltip } from "./_shared/AgentInterfaceTooltip";
import { useAgentInterfaceStore } from "./_shared/store";
+/**
+ * The saved desktop open/closed choice. Mobile never writes it, so opening the
+ * drawer on a phone isn't remembered on desktop.
+ */
+const SIDEBAR_OPEN_KEY = "openui-agent-sidebar-open";
+const readSavedDesktopOpen = () => readPreference<boolean>(SIDEBAR_OPEN_KEY) === true;
+
const SIDEBAR_FADE_DURATION_MS = 90;
const SIDEBAR_RESIZE_DURATION_MS = 160;
@@ -26,9 +36,10 @@ export const SidebarContainer = ({
children?: React.ReactNode;
className?: string;
}) => {
- const { isSidebarOpen, setIsSidebarOpen } = useAgentInterfaceStore((state) => ({
+ const { isSidebarOpen, setIsSidebarOpen, isHydrated } = useAgentInterfaceStore((state) => ({
isSidebarOpen: state.isSidebarOpen,
setIsSidebarOpen: state.setIsSidebarOpen,
+ isHydrated: state.isHydrated,
}));
const { isDetailedViewActive } = useActiveDetailedView();
const { layout } = useLayoutContext() || {};
@@ -39,6 +50,7 @@ export const SidebarContainer = ({
);
const animationTimeoutsRef = useRef<Array<ReturnType<typeof setTimeout>>>([]);
const previousIsMobileRef = useRef<boolean | null>(null);
+ const appliedRestoreRef = useRef(false);
const clearAnimationTimeouts = () => {
animationTimeoutsRef.current.forEach((timeoutId) => clearTimeout(timeoutId));
@@ -51,20 +63,40 @@ export const SidebarContainer = ({
};
}, []);
+ // Once hydrated, restore the saved desktop choice: once, before paint and
+ // without animating, as if the sidebar had started that way. The effect
+ // below then finds it already in place.
+ useIsomorphicLayoutEffect(() => {
+ if (!isHydrated || appliedRestoreRef.current) return;
+ appliedRestoreRef.current = true;
+ const savedOpen = readSavedDesktopOpen();
+ if (isMobile || isSidebarOpen === savedOpen) return;
+ setIsSidebarOpen(savedOpen);
+ setIsCollapsedLayout(!savedOpen);
+ setVisualState(savedOpen ? "expanded" : "collapsed");
+ }, [isHydrated, isMobile]);
+
useEffect(() => {
clearAnimationTimeouts();
+ const isFirstRun = previousIsMobileRef.current === null;
const justSwitchedLayout = previousIsMobileRef.current !== isMobile;
previousIsMobileRef.current = isMobile;
+ // Mobile always starts closed; coming back from mobile restores the
+ // desktop choice.
if (justSwitchedLayout) {
- const targetOpen = !isMobile;
+ const targetOpen = isMobile ? false : isFirstRun ? isSidebarOpen : readSavedDesktopOpen();
if (isSidebarOpen !== targetOpen) {
setIsSidebarOpen(targetOpen);
return;
}
}
+ // Desktop only (mobile always starts closed), and only once hydrated so
+ // the collapsed default never overwrites the saved choice.
+ if (!isMobile && isHydrated) writePreference(SIDEBAR_OPEN_KEY, isSidebarOpen);
+
if (isMobile) {
setIsCollapsedLayout(!isSidebarOpen);
setVisualState(isSidebarOpen ? "expanded" : "collapsed");
@@ -110,7 +142,7 @@ export const SidebarContainer = ({
);
}, SIDEBAR_FADE_DURATION_MS),
);
- }, [isMobile, isSidebarOpen]);
+ }, [isMobile, isSidebarOpen, isHydrated]);
const contextValue = useMemo(
() => ({
@@ -142,13 +174,9 @@ export const SidebarContainer = ({
className,
)}
data-sidebar-visual-state={visualState}
- onClick={() => {
- if (!isMobile && isCollapsedLayout) {
- setIsSidebarOpen(true);
- }
- }}
>
{children}
+ {!isMobile && <SidebarResizeEdge />}
</div>
</SidebarVisualStateContext.Provider>
);
@@ -270,6 +298,20 @@ export const SidebarContent = ({
);
};
+/**
+ * Pinned to the bottom of the sidebar, below the thread list. Holds controls
+ * like `ThemeModeToggle`.
+ */
+export const SidebarFooter = ({
+ children,
+ className,
+}: {
+ children?: React.ReactNode;
+ className?: string;
+}) => {
+ return <div className={clsx("openui-agent-sidebar-footer", className)}>{children}</div>;
+};
+
export const SidebarSeparator = () => {
return <div className="openui-agent-sidebar-separator" />;
};
diff --git a/packages/react-ui/src/components/AgentInterface/SidebarResizeEdge.tsx b/packages/react-ui/src/components/AgentInterface/SidebarResizeEdge.tsx
new file mode 100644
index 000000000..5af15d193
--- /dev/null
+++ b/packages/react-ui/src/components/AgentInterface/SidebarResizeEdge.tsx
@@ -0,0 +1,134 @@
+import { useLayoutEffect, useRef, type PointerEvent } from "react";
+import { readPreference, writePreference } from "../../utils/preferences";
+import { useAgentInterfaceStore } from "./_shared/store";
+
+/* Keep DEFAULT in step with $sidebar-width in sidebar.scss. */
+const DEFAULT_WIDTH = 272;
+const MIN_WIDTH = 220;
+const MAX_WIDTH = 420;
+/* Dragged narrower than this, the sidebar snaps shut; dragged wider from the
+ rail, it snaps open at MIN_WIDTH or wider. */
+const COLLAPSE_AT = 150;
+/* Lands on the default width when released within this many px of it. */
+const SNAP_DISTANCE = 14;
+const SAVE_DELAY_MS = 300;
+const WIDTH_KEY = "openui-agent-sidebar-width";
+const WIDTH_VAR = "--openui-agent-sidebar-width";
+
+const isValidWidth = (width: unknown): width is number =>
+ typeof width === "number" && width >= MIN_WIDTH && width <= MAX_WIDTH;
+
+const fitWidth = (raw: number) => {
+ const width = Math.min(Math.max(raw, MIN_WIDTH), MAX_WIDTH);
+ return Math.abs(width - DEFAULT_WIDTH) <= SNAP_DISTANCE ? DEFAULT_WIDTH : width;
+};
+
+/**
+ * The sidebar's right edge, draggable. It has no look of its own beyond the
+ * resize cursor. The width lives in a CSS variable on the sidebar container,
+ * written straight to the element so a drag doesn't re-render the tree, and is
+ * saved as a preference once the pointer settles.
+ */
+export const SidebarResizeEdge = () => {
+ const { isSidebarOpen, setIsSidebarOpen } = useAgentInterfaceStore((state) => ({
+ isSidebarOpen: state.isSidebarOpen,
+ setIsSidebarOpen: state.setIsSidebarOpen,
+ }));
+ const edgeRef = useRef<HTMLDivElement>(null);
+ const widthRef = useRef(DEFAULT_WIDTH);
+ const openRef = useRef(isSidebarOpen);
+ openRef.current = isSidebarOpen;
+ const dragRef = useRef<{ startX: number; startWidth: number; restoreWidth: number } | null>(null);
+ const saveTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
+
+ const container = () => edgeRef.current?.parentElement ?? null;
+
+ const applyWidth = (width: number) => {
+ widthRef.current = width;
+ container()?.style.setProperty(WIDTH_VAR, `${width}px`);
+ };
+
+ const scheduleSave = () => {
+ if (saveTimeoutRef.current) clearTimeout(saveTimeoutRef.current);
+ saveTimeoutRef.current = setTimeout(
+ () => writePreference(WIDTH_KEY, widthRef.current),
+ SAVE_DELAY_MS,
+ );
+ };
+
+ // Before paint, so the sidebar opens at its saved width rather than the
+ // default and then jumping: apply it with transitions off, force the style
+ // to settle, then let transitions back on.
+ useLayoutEffect(() => {
+ const saved = readPreference<number>(WIDTH_KEY);
+ const el = container();
+ if (el && isValidWidth(saved)) {
+ el.classList.add("openui-agent-sidebar-container--resizing");
+ widthRef.current = saved;
+ el.style.setProperty(WIDTH_VAR, `${saved}px`);
+ void el.offsetWidth;
+ el.classList.remove("openui-agent-sidebar-container--resizing");
+ }
+ return () => {
+ if (saveTimeoutRef.current) clearTimeout(saveTimeoutRef.current);
+ container()?.style.removeProperty(WIDTH_VAR);
+ };
+ }, []);
+
+ const handlePointerDown = (event: PointerEvent<HTMLDivElement>) => {
+ if (event.button !== 0) return;
+ const el = container();
+ if (!el) return;
+ event.preventDefault();
+ event.currentTarget.setPointerCapture(event.pointerId);
+ dragRef.current = {
+ startX: event.clientX,
+ startWidth: openRef.current ? widthRef.current : el.getBoundingClientRect().width,
+ restoreWidth: widthRef.current,
+ };
+ el.classList.add("openui-agent-sidebar-container--resizing");
+ document.body.style.cursor = "col-resize";
+ document.body.style.userSelect = "none";
+ };
+
+ const handlePointerMove = (event: PointerEvent<HTMLDivElement>) => {
+ const drag = dragRef.current;
+ if (!drag) return;
+ const raw = drag.startWidth + event.clientX - drag.startX;
+
+ if (raw < COLLAPSE_AT) {
+ // Snapping shut keeps the width it had, so it reopens the same size
+ // rather than at whatever the drag passed through on the way.
+ applyWidth(drag.restoreWidth);
+ if (openRef.current) setIsSidebarOpen(false);
+ return;
+ }
+
+ if (!openRef.current) setIsSidebarOpen(true);
+ applyWidth(fitWidth(raw));
+ };
+
+ const endDrag = (event: PointerEvent<HTMLDivElement>) => {
+ if (!dragRef.current) return;
+ dragRef.current = null;
+ if (event.currentTarget.hasPointerCapture(event.pointerId)) {
+ event.currentTarget.releasePointerCapture(event.pointerId);
+ }
+ container()?.classList.remove("openui-agent-sidebar-container--resizing");
+ document.body.style.cursor = "";
+ document.body.style.userSelect = "";
+ scheduleSave();
+ };
+
+ return (
+ <div
+ ref={edgeRef}
+ aria-hidden="true"
+ className="openui-agent-sidebar-resize-edge"
+ onPointerDown={handlePointerDown}
+ onPointerMove={handlePointerMove}
+ onPointerUp={endDrag}
+ onPointerCancel={endDrag}
+ />
+ );
+};
diff --git a/packages/react-ui/src/components/AgentInterface/ThemeModeToggle.tsx b/packages/react-ui/src/components/AgentInterface/ThemeModeToggle.tsx
new file mode 100644
index 000000000..61d6d20a6
--- /dev/null
+++ b/packages/react-ui/src/components/AgentInterface/ThemeModeToggle.tsx
@@ -0,0 +1,39 @@
+import clsx from "clsx";
+import { Moon, Sun } from "lucide-react";
+import type { ThemeMode } from "../ThemeProvider/types";
+import { SidebarTooltip } from "./SidebarTooltip";
+
+export interface ThemeModeToggleProps {
+ /** The mode currently shown. Pair with `useThemeModePreference`. */
+ mode: ThemeMode;
+ /** Called with the other mode when the button is pressed. */
+ onModeChange: (next: ThemeMode) => void;
+ className?: string;
+}
+
+/**
+ * Round icon button that flips between light and dark, for the sidebar footer.
+ * It shows the mode it switches to (a moon in light mode, a sun in dark), the
+ * same in the expanded sidebar and on the collapsed rail.
+ */
+export const ThemeModeToggle = ({ mode, onModeChange, className }: ThemeModeToggleProps) => {
+ const next: ThemeMode = mode === "dark" ? "light" : "dark";
+ const label = `Switch to ${next} theme`;
+
+ return (
+ <SidebarTooltip content={label}>
+ <button
+ type="button"
+ className={clsx("openui-agent-theme-toggle", className)}
+ aria-label={label}
+ onClick={() => onModeChange(next)}
+ >
+ {next === "dark" ? (
+ <Moon size="1em" aria-hidden="true" />
+ ) : (
+ <Sun size="1em" aria-hidden="true" />
+ )}
+ </button>
+ </SidebarTooltip>
+ );
+};
diff --git a/packages/react-ui/src/components/AgentInterface/Thread.tsx b/packages/react-ui/src/components/AgentInterface/Thread.tsx
index aac419953..afa5edf93 100644
--- a/packages/react-ui/src/components/AgentInterface/Thread.tsx
+++ b/packages/react-ui/src/components/AgentInterface/Thread.tsx
@@ -8,7 +8,7 @@ import {
useToolActivities,
} from "@openuidev/react-headless";
import clsx from "clsx";
-import React, { memo, useId, useMemo, useRef } from "react";
+import React, { memo, useId, useLayoutEffect, useMemo, useRef } from "react";
import { useLayoutContext } from "../../context/LayoutContext";
import { ScrollVariant, useScrollToBottom } from "../../hooks/useScrollToBottom";
import {
@@ -18,6 +18,7 @@ import {
readMessage,
} from "../../utils/messages";
import { ToolCallTimeline, type TimelineStep } from "../ToolCall";
+import { TimelineWorkingIndicator } from "../ToolCall/ToolCallTimeline";
import {
DetailedViewOverlay,
DetailedViewPanel,
@@ -33,7 +34,6 @@ import type {
} from "./_shared/types";
import { Callout } from "../Callout";
-import { DotMatrixLoader } from "../DotMatrixLoader";
import { IconButton } from "../IconButton";
import { MarkDownRenderer } from "../MarkDownRenderer";
import { AgentInterfaceTooltip } from "./_shared/AgentInterfaceTooltip";
@@ -85,20 +85,21 @@ export const ThreadContainer = ({
className={clsx("openui-agent-thread-container", className, {
"openui-agent-thread-container--detailed-view-active": isDetailedViewActive,
})}
- style={{
- visibility: isLoadingMessages ? "hidden" : undefined,
- }}
>
- {/* Full-screen loading state while a thread's messages load. The
- container above hides via `visibility` (keeps layout + scroll state);
- this overlay opts back in with `visibility: visible`. */}
+ {/* Loading state while a thread's messages load. Only the content below
+ hides (via `visibility`, which keeps layout + scroll state), so the
+ card itself stays on screen around the spinner. */}
{isLoadingMessages && (
<AmbientLoader
className="openui-agent-thread-container__loading"
label="Loading conversation…"
/>
)}
- <div className="openui-agent-thread-wrapper" ref={containerRef}>
+ <div
+ className="openui-agent-thread-wrapper"
+ ref={containerRef}
+ style={{ visibility: isLoadingMessages ? "hidden" : undefined }}
+ >
{/* Chat panel - always visible */}
<div
ref={chatPanelRef}
@@ -313,7 +314,7 @@ export const RenderMessage = memo(
export const MessageLoading = () => {
return (
<div className="openui-agent-thread-message-loading">
- <DotMatrixLoader variant="compact" />
+ <TimelineWorkingIndicator />
</div>
);
};
@@ -542,6 +543,103 @@ const RenderGroup = ({
);
};
+/**
+ * Lifts a freshly sent user message up from the composer into its place in the
+ * thread. Runs on the bubble's DOM node (no wrapper), so custom `UserMessage`
+ * renderers animate too and the scroll anchor's sibling checks stay intact.
+ * History loads and thread switches never animate; reduced motion skips it.
+ */
+const USER_MESSAGE_SELECTOR =
+ ".openui-agent-thread-message-user, .openui-shell-thread-message-user";
+
+const SEND_ANIMATION_MAX_OFFSET = 48;
+
+function useUserMessageSendAnimation(
+ containerRef: React.RefObject<HTMLDivElement | null>,
+ messages: Message[],
+ isRunning: boolean,
+) {
+ const lastMessage = messages[messages.length - 1];
+ const sentId = isRunning && lastMessage?.role === "user" ? lastMessage.id : null;
+ const animatedId = useRef<string | null>(null);
+
+ useLayoutEffect(() => {
+ if (!sentId || animatedId.current === sentId) return;
+ animatedId.current = sentId;
+
+ const container = containerRef.current;
+ const bubble = Array.from(
+ container?.querySelectorAll<HTMLElement>(USER_MESSAGE_SELECTOR) ?? [],
+ ).pop();
+ const composer = container
+ ?.closest(".openui-agent-thread-chat-panel")
+ ?.querySelector<HTMLElement>(".openui-agent-thread-composer__input-wrapper");
+ if (!bubble || !composer || typeof bubble.animate !== "function") return;
+ if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
+
+ // Hide now, start two frames later: the scroll anchor measures the bubble's
+ // resting position in a passive effect, and a transform would skew it.
+ bubble.style.opacity = "0";
+ let frame = requestAnimationFrame(() => {
+ frame = requestAnimationFrame(() => {
+ bubble.style.opacity = "";
+ // Rise toward the composer, but only a short hop so it reads as a lift.
+ const distance = composer.getBoundingClientRect().top - bubble.getBoundingClientRect().top;
+ const offset = Math.min(Math.max(distance, 0), SEND_ANIMATION_MAX_OFFSET);
+ bubble.animate(
+ [
+ { transform: `translateY(${offset}px) scale(0.96)`, opacity: 0 },
+ { opacity: 1, offset: 0.3 },
+ { transform: "none", opacity: 1 },
+ ],
+ { duration: 360, easing: "cubic-bezier(0.22, 1, 0.36, 1)" },
+ );
+ });
+ });
+ return () => {
+ cancelAnimationFrame(frame);
+ bubble.style.opacity = "";
+ };
+ }, [sentId, containerRef]);
+}
+
+/**
+ * Flags user bubbles whose text wraps (`data-multiline`) so they can take
+ * roomier vertical padding while a single line stays a compact pill. Works on
+ * the DOM so the default and GenUI user renderers are both covered.
+ */
+const USER_BUBBLE_CONTENT_SELECTOR =
+ ".openui-agent-thread-message-user__content, .openui-shell-thread-message-user__content";
+
+function useMultilineUserBubbles(
+ containerRef: React.RefObject<HTMLDivElement | null>,
+ messages: Message[],
+) {
+ useLayoutEffect(() => {
+ const container = containerRef.current;
+ if (!container || typeof ResizeObserver === "undefined") return;
+
+ const update = (bubble: HTMLElement) => {
+ const style = getComputedStyle(bubble);
+ const lineHeight = Number.parseFloat(style.lineHeight) || 0;
+ const textHeight =
+ bubble.clientHeight -
+ Number.parseFloat(style.paddingTop) -
+ Number.parseFloat(style.paddingBottom);
+ bubble.toggleAttribute("data-multiline", lineHeight > 0 && textHeight > lineHeight * 1.5);
+ };
+
+ const observer = new ResizeObserver((entries) => {
+ entries.forEach((entry) => update(entry.target as HTMLElement));
+ });
+ container.querySelectorAll<HTMLElement>(USER_BUBBLE_CONTENT_SELECTOR).forEach((bubble) => {
+ update(bubble);
+ observer.observe(bubble);
+ });
+ return () => observer.disconnect();
+ }, [containerRef, messages]);
+}
+
export const Messages = ({
className,
loader,
@@ -567,8 +665,12 @@ export const Messages = ({
// shimmer survives trailing tool messages.
const lastAssistantId = useMemo(() => getLastAssistantMessageId(messages), [messages]);
+ const messagesRef = useRef<HTMLDivElement>(null);
+ useUserMessageSendAnimation(messagesRef, messages, isRunning);
+ useMultilineUserBubbles(messagesRef, messages);
+
return (
- <div className={clsx("openui-agent-thread-messages", className)}>
+ <div ref={messagesRef} className={clsx("openui-agent-thread-messages", className)}>
{groups.map((group) => (
<RenderGroup
key={group.messages[0]!.id}
@@ -588,25 +690,7 @@ export const Messages = ({
);
};
-export const ThreadHeader = ({
- children,
- className,
-}: {
- children?: React.ReactNode;
- className?: string;
-}) => {
- return (
- <div className={clsx("openui-agent-thread-header", className)}>
- <div className="openui-agent-thread-header__title">{/* Thread title hidden for now. */}</div>
- <div className="openui-agent-thread-header__actions">
- {children}
- <WorkspaceToggleButton />
- </div>
- </div>
- );
-};
-
-const WorkspaceToggleButton = () => {
+export const WorkspaceToggleButton = () => {
const artifacts = useArtifactList();
const { isDetailedViewActive } = useActiveDetailedView();
const { workspaceToggle } = useAgentInterfaceLabels();
diff --git a/packages/react-ui/src/components/AgentInterface/ThreadHeader.tsx b/packages/react-ui/src/components/AgentInterface/ThreadHeader.tsx
new file mode 100644
index 000000000..79506ee0b
--- /dev/null
+++ b/packages/react-ui/src/components/AgentInterface/ThreadHeader.tsx
@@ -0,0 +1,136 @@
+import { useThreadList } from "@openuidev/react-headless";
+import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
+import clsx from "clsx";
+import { EllipsisIcon, PencilIcon, Trash2Icon } from "lucide-react";
+import { useState, type ReactNode } from "react";
+import { IconButton } from "../IconButton";
+import { RenameChatDialog } from "./RenameChatDialog";
+import { WorkspaceToggleButton } from "./Thread";
+
+export interface ThreadHeaderProps {
+ /** Content pinned to the leading edge (e.g. a model switcher). */
+ start?: ReactNode;
+ /** Content centred in the header; defaults to the selected chat's title. */
+ center?: ReactNode;
+ /** Content pinned to the trailing edge, before the chat actions menu. */
+ end?: ReactNode;
+ /** Shorthand for `end`, so existing trailing children keep their place. */
+ children?: ReactNode;
+ /**
+ * Show the selected chat's title in the centre (when `center` is unset).
+ * @default true
+ */
+ showChatTitle?: boolean;
+ /**
+ * Show a trailing "…" menu with chat actions for the selected chat: Delete,
+ * plus Rename while the chat title is shown (`showChatTitle` and no
+ * `center`).
+ * @default true
+ */
+ showChatActions?: boolean;
+ className?: string;
+}
+
+const useSelectedThread = () => {
+ const selectedThreadId = useThreadList((s) => s.selectedThreadId);
+ const threads = useThreadList((s) => s.threads);
+ if (!selectedThreadId) return null;
+ return threads.find((thread) => thread.id === selectedThreadId) ?? null;
+};
+
+const ChatTitle = ({ title }: { title: string }) => (
+ <div className="openui-agent-thread-header__title" title={title}>
+ <span className="openui-agent-thread-header__title-text">{title}</span>
+ </div>
+);
+
+const ChatActions = ({ threadId, canRename }: { threadId: string; canRename: boolean }) => {
+ const deleteThread = useThreadList((s) => s.deleteThread);
+ const [isRenameOpen, setIsRenameOpen] = useState(false);
+
+ return (
+ <>
+ <DropdownMenu.Root>
+ <DropdownMenu.Trigger asChild>
+ <IconButton
+ className="openui-agent-thread-header__actions-trigger"
+ icon={<EllipsisIcon size="1em" />}
+ size="small"
+ variant="tertiary"
+ aria-label="Chat actions"
+ />
+ </DropdownMenu.Trigger>
+ <DropdownMenu.Portal>
+ <DropdownMenu.Content
+ className="openui-agent-thread-header__actions-menu"
+ side="bottom"
+ align="end"
+ sideOffset={4}
+ // Let the rename dialog keep focus instead of returning it here.
+ onCloseAutoFocus={(e) => {
+ if (isRenameOpen) e.preventDefault();
+ }}
+ >
+ {canRename && (
+ <DropdownMenu.Item
+ className="openui-agent-thread-header__actions-item"
+ onSelect={() => setIsRenameOpen(true)}
+ >
+ <PencilIcon size={14} aria-hidden />
+ Rename
+ </DropdownMenu.Item>
+ )}
+ <DropdownMenu.Item
+ className="openui-agent-thread-header__actions-item openui-agent-thread-header__actions-item--destructive"
+ onSelect={() => deleteThread(threadId)}
+ >
+ <Trash2Icon size={14} aria-hidden />
+ Delete
+ </DropdownMenu.Item>
+ </DropdownMenu.Content>
+ </DropdownMenu.Portal>
+ </DropdownMenu.Root>
+ {canRename && (
+ <RenameChatDialog threadId={threadId} open={isRenameOpen} onOpenChange={setIsRenameOpen} />
+ )}
+ </>
+ );
+};
+
+/**
+ * Desktop header for the thread card. Its 32px row shares a vertical centre
+ * with the sidebar's logo row, and its leading inset matches its top inset,
+ * so controls placed here line up with the rail's brand mark. Lays out
+ * `start` content on the left, the selected chat's title in the centre, and
+ * the workspace toggle plus a chat actions menu on the right. Hidden on
+ * mobile (use `MobileHeader`).
+ */
+export const ThreadHeader = ({
+ start,
+ center,
+ end,
+ children,
+ showChatTitle = true,
+ showChatActions = true,
+ className,
+}: ThreadHeaderProps) => {
+ const thread = useSelectedThread();
+ // Rename only edits what the header shows, so it goes when the title does.
+ const isTitleShown = center === undefined && showChatTitle;
+
+ return (
+ <header className={clsx("openui-agent-thread-header", className)}>
+ <div className="openui-agent-thread-header__start">{start}</div>
+ <div className="openui-agent-thread-header__center">
+ {center ?? (isTitleShown && thread?.title && <ChatTitle title={thread.title} />)}
+ </div>
+ <div className="openui-agent-thread-header__end">
+ {end ?? children}
+ <WorkspaceToggleButton />
+ {showChatActions && thread && <ChatActions threadId={thread.id} canRename={isTitleShown} />}
+ </div>
+ </header>
+ );
+};
+
+export default ThreadHeader;
diff --git a/packages/react-ui/src/components/AgentInterface/ThreadList.tsx b/packages/react-ui/src/components/AgentInterface/ThreadList.tsx
index 22c0bfef3..b1b93085f 100644
--- a/packages/react-ui/src/components/AgentInterface/ThreadList.tsx
+++ b/packages/react-ui/src/components/AgentInterface/ThreadList.tsx
@@ -1,7 +1,7 @@
import { useThreadList } from "@openuidev/react-headless";
import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
import clsx from "clsx";
-import { EllipsisIcon, Trash2Icon } from "lucide-react";
+import { EllipsisIcon, MessageCircle, PencilIcon, Trash2Icon } from "lucide-react";
import { useCallback, useEffect, useRef, useState } from "react";
import { useLayoutContext } from "../../context/LayoutContext";
import { Button } from "../Button";
@@ -9,6 +9,7 @@ import { IconButton } from "../IconButton";
import { Skeleton } from "../Skeleton";
import { useOptionalNav } from "./_shared/navContext";
import { useAgentInterfaceStore } from "./_shared/store";
+import { RenameChatDialog } from "./RenameChatDialog";
const THREAD_SKELETON_WIDTHS = ["78%", "62%", "86%", "70%"];
@@ -53,6 +54,7 @@ export const ThreadButton = ({
const { layout } = useLayoutContext();
const nav = useOptionalNav();
const [isActionsOpen, setIsActionsOpen] = useState(false);
+ const [isRenameOpen, setIsRenameOpen] = useState(false);
return (
<div
@@ -78,7 +80,8 @@ export const ThreadButton = ({
}
}}
>
- {title}
+ <MessageCircle className="openui-agent-thread-button-icon" size="1em" aria-hidden="true" />
+ <span className="openui-agent-thread-button-label">{title}</span>
</button>
<DropdownMenu.Root open={isActionsOpen} onOpenChange={setIsActionsOpen}>
<DropdownMenu.Trigger asChild>
@@ -96,7 +99,20 @@ export const ThreadButton = ({
side="bottom"
align="start"
sideOffset={4}
+ onCloseAutoFocus={(e) => {
+ if (isRenameOpen) e.preventDefault();
+ }}
>
+ <DropdownMenu.Item asChild onSelect={() => setIsRenameOpen(true)}>
+ <Button
+ className="openui-agent-thread-button-dropdown-menu-item"
+ iconLeft={<PencilIcon size="1em" />}
+ size="extra-small"
+ variant="tertiary"
+ >
+ Rename
+ </Button>
+ </DropdownMenu.Item>
<DropdownMenu.Item
asChild
onSelect={() => {
@@ -116,6 +132,7 @@ export const ThreadButton = ({
</DropdownMenu.Content>
</DropdownMenu.Portal>
</DropdownMenu.Root>
+ <RenameChatDialog threadId={id} open={isRenameOpen} onOpenChange={setIsRenameOpen} />
</div>
);
};
diff --git a/packages/react-ui/src/components/AgentInterface/WelcomeDither.tsx b/packages/react-ui/src/components/AgentInterface/WelcomeDither.tsx
new file mode 100644
index 000000000..7d8244933
--- /dev/null
+++ b/packages/react-ui/src/components/AgentInterface/WelcomeDither.tsx
@@ -0,0 +1,229 @@
+import { useEffect, useRef } from "react";
+
+/* A port of the docs site's "Faded Dither" (docs/app/(home)/components/
+ * FadedDither): a soft sine wave run through a Bayer 8x8 ordered dither.
+ * The site renders it with the `shaders` package, which is WebGPU only and too
+ * heavy to ship in this library, so this is the same maths in one WebGL
+ * fragment shader with the preset's values.
+ *
+ * Only the stipple is drawn. The site lays the dither over a solid base that
+ * matches its band; here the page itself is the base, so the canvas stays
+ * transparent and the stipple colour comes from CSS (`color` on the canvas),
+ * which lets it follow the theme.
+ */
+
+const WAVE = {
+ angle: 24,
+ frequency: 0.5,
+ amplitude: 0.15,
+ thickness: 0.4,
+ softness: 0.7,
+ speed: 1.2,
+ position: { x: 0.69, y: 0.7 },
+};
+/* How far, in CSS px, the ink reaches out from the composer as it appears.
+ Over the canvas's CSS animation this pulls in to nothing, so the dots run
+ toward the input and merge into it. */
+const FALLOFF = 360;
+/* >1 holds the spread a beat, then pulls in fast. */
+const CONVERGE_EASE = 1.6;
+
+const DITHER = { threshold: 0.41, spread: 1, pixelSize: 4 };
+
+const VERTEX = `
+attribute vec2 a_position;
+void main() {
+ gl_Position = vec4(a_position, 0.0, 1.0);
+}
+`;
+
+const FRAGMENT = `
+precision highp float;
+
+uniform vec2 u_resolution;
+uniform float u_pixel;
+uniform float u_time;
+uniform vec4 u_color;
+// The composer's box in canvas pixels (centre xy, half size zw), y up.
+uniform vec4 u_box;
+uniform float u_falloff;
+
+const float TAU = 6.28318530718;
+
+float bayerQuad(float a, float b) {
+ return b * 3.0 + a * 2.0 - a * b * 4.0;
+}
+
+float bayer8(vec2 coord) {
+ vec2 t = mod(coord, 8.0);
+ vec2 c2 = mod(t, 2.0);
+ vec2 c4 = floor(mod(t, 4.0) / 2.0);
+ vec2 c8 = floor(t / 4.0);
+ return (bayerQuad(c2.x, c2.y) * 16.0 + bayerQuad(c4.x, c4.y) * 4.0 + bayerQuad(c8.x, c8.y)) / 64.0;
+}
+
+float sineWave(vec2 uv) {
+ float aspect = u_resolution.x / max(u_resolution.y, 1e-6);
+ vec2 p = vec2(uv.x * aspect - ${WAVE.position.x.toFixed(4)} * aspect, uv.y - (1.0 - ${WAVE.position.y.toFixed(4)}));
+ float a = radians(${WAVE.angle.toFixed(4)});
+ vec2 r = vec2(p.x * cos(a) - p.y * sin(a), p.x * sin(a) + p.y * cos(a));
+ float wave = sin(r.x * ${WAVE.frequency.toFixed(4)} * TAU + u_time) * ${WAVE.amplitude.toFixed(4)};
+ float d = abs(r.y - wave);
+ float halfThickness = ${(WAVE.thickness / 2).toFixed(4)};
+ float halfSoftness = ${(WAVE.softness / 2).toFixed(4)};
+ return 1.0 - smoothstep(halfThickness - halfSoftness, halfThickness + halfSoftness, d);
+}
+
+void main() {
+ vec2 coord = floor(gl_FragCoord.xy / u_pixel);
+ vec2 uv = (coord + 0.5) * u_pixel / u_resolution;
+ // Ink thickens towards the composer: distance to its box drives a ramp,
+ // and the site's wave only modulates it, so the motion stays but the
+ // picture reads as a gradient into the input.
+ vec2 q = abs((coord + 0.5) * u_pixel - u_box.xy) - u_box.zw;
+ float d = length(max(q, 0.0)) + min(max(q.x, q.y), 0.0);
+ float ramp = 1.0 - smoothstep(0.0, u_falloff, d);
+ float luminance = ramp * ramp * mix(0.65, 1.0, sineWave(uv));
+ float threshold = 0.5 + (bayer8(coord) - 0.5) * ${DITHER.spread.toFixed(4)};
+ float on = step(threshold, luminance + ${(DITHER.threshold - 0.5).toFixed(4)});
+ gl_FragColor = vec4(u_color.rgb * u_color.a * on, u_color.a * on);
+}
+`;
+
+/* getComputedStyle hands back rgb()/rgba() or, for color-mix, color(srgb ...);
+ both list the channels in order, rgb as 0-255 and srgb as 0-1. */
+function readColor(el: Element): [number, number, number, number] {
+ const value = getComputedStyle(el).color;
+ const nums = (value.match(/[\d.]+/g) ?? []).map(Number);
+ if (value.startsWith("color(")) {
+ const [r = 0, g = 0, b = 0, a = 1] = nums;
+ return [r, g, b, a];
+ }
+ const [r = 0, g = 0, b = 0, a = 1] = nums;
+ return [r / 255, g / 255, b / 255, a];
+}
+
+function compile(gl: WebGLRenderingContext, type: number, source: string) {
+ const shader = gl.createShader(type);
+ if (!shader) return null;
+ gl.shaderSource(shader, source);
+ gl.compileShader(shader);
+ if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
+ gl.deleteShader(shader);
+ return null;
+ }
+ return shader;
+}
+
+/**
+ * Draws the dither every frame until unmounted. The caller owns when it shows
+ * and fades (through CSS on `className`); this only draws frames.
+ */
+export const WelcomeDither = ({
+ className,
+ onDone,
+}: {
+ className?: string;
+ /** Fires when the canvas's CSS animation ends, so drawing can stop. */
+ onDone?: () => void;
+}) => {
+ const canvasRef = useRef<HTMLCanvasElement>(null);
+
+ useEffect(() => {
+ const canvas = canvasRef.current;
+ // Hidden by CSS under reduced motion, where no animationend would come.
+ if (!canvas || window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
+ const gl = canvas.getContext("webgl", { premultipliedAlpha: true, antialias: false });
+ if (!gl) return;
+
+ const vertex = compile(gl, gl.VERTEX_SHADER, VERTEX);
+ const fragment = compile(gl, gl.FRAGMENT_SHADER, FRAGMENT);
+ const program = gl.createProgram();
+ if (!vertex || !fragment || !program) return;
+ gl.attachShader(program, vertex);
+ gl.attachShader(program, fragment);
+ gl.linkProgram(program);
+ if (!gl.getProgramParameter(program, gl.LINK_STATUS)) return;
+ gl.useProgram(program);
+
+ const buffer = gl.createBuffer();
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW);
+ const position = gl.getAttribLocation(program, "a_position");
+ gl.enableVertexAttribArray(position);
+ gl.vertexAttribPointer(position, 2, gl.FLOAT, false, 0, 0);
+
+ const uResolution = gl.getUniformLocation(program, "u_resolution");
+ const uPixel = gl.getUniformLocation(program, "u_pixel");
+ const uTime = gl.getUniformLocation(program, "u_time");
+ const uColor = gl.getUniformLocation(program, "u_color");
+ const uBox = gl.getUniformLocation(program, "u_box");
+ const uFalloff = gl.getUniformLocation(program, "u_falloff");
+
+ let width = 0;
+ let height = 0;
+ const resize = () => {
+ const dpr = window.devicePixelRatio || 1;
+ const rect = canvas.getBoundingClientRect();
+ width = Math.max(1, Math.round(rect.width * dpr));
+ height = Math.max(1, Math.round(rect.height * dpr));
+ canvas.width = width;
+ canvas.height = height;
+ gl.viewport(0, 0, width, height);
+ gl.uniform2f(uResolution, width, height);
+ gl.uniform1f(uPixel, DITHER.pixelSize * dpr);
+ gl.uniform4f(uColor, ...readColor(canvas));
+ // The canvas sits inside the composer's wrapper, so that is the box.
+ const box = canvas.parentElement?.getBoundingClientRect() ?? rect;
+ gl.uniform4f(
+ uBox,
+ (box.left + box.width / 2 - rect.left) * dpr,
+ (rect.bottom - (box.top + box.height / 2)) * dpr,
+ (box.width / 2) * dpr,
+ (box.height / 2) * dpr,
+ );
+ };
+ resize();
+ const observer = new ResizeObserver(resize);
+ observer.observe(canvas);
+
+ // Converge over the same window as the CSS fade (delay + duration).
+ const style = getComputedStyle(canvas);
+ const delayMs = (parseFloat(style.animationDelay) || 0) * 1000;
+ const durationMs = (parseFloat(style.animationDuration) || 1) * 1000;
+
+ let frame = 0;
+ const start = performance.now();
+ const draw = (now: number) => {
+ const progress = Math.min(Math.max((now - start - delayMs) / durationMs, 0), 1);
+ const dpr = window.devicePixelRatio || 1;
+ gl.uniform1f(uFalloff, Math.max(FALLOFF * (1 - progress ** CONVERGE_EASE), 1) * dpr);
+ gl.uniform1f(uTime, ((now - start) / 1000) * WAVE.speed);
+ gl.clearColor(0, 0, 0, 0);
+ gl.clear(gl.COLOR_BUFFER_BIT);
+ gl.drawArrays(gl.TRIANGLES, 0, 3);
+ frame = requestAnimationFrame(draw);
+ };
+ frame = requestAnimationFrame(draw);
+
+ return () => {
+ cancelAnimationFrame(frame);
+ observer.disconnect();
+ gl.deleteBuffer(buffer);
+ gl.deleteProgram(program);
+ gl.deleteShader(vertex);
+ gl.deleteShader(fragment);
+ };
+ }, []);
+
+ return (
+ <canvas
+ ref={canvasRef}
+ aria-hidden="true"
+ className={className}
+ onAnimationEnd={(event) => {
+ if (event.target === event.currentTarget) onDone?.();
+ }}
+ />
+ );
+};
diff --git a/packages/react-ui/src/components/AgentInterface/WelcomeGlow.tsx b/packages/react-ui/src/components/AgentInterface/WelcomeGlow.tsx
index 997a7c456..6c410999a 100644
--- a/packages/react-ui/src/components/AgentInterface/WelcomeGlow.tsx
+++ b/packages/react-ui/src/components/AgentInterface/WelcomeGlow.tsx
@@ -1,8 +1,12 @@
import clsx from "clsx";
-import { createContext, useContext, type ReactNode } from "react";
+import { createContext, useContext, useEffect, useState, type ReactNode } from "react";
+import { WelcomeDither } from "./WelcomeDither";
const WelcomeGlowContext = createContext(false);
+// Per page load, shared by every WelcomeGlow.
+let ditherPlayed = false;
+
export const WelcomeGlowProvider = ({
children,
enabled,
@@ -22,6 +26,14 @@ export interface WelcomeGlowProps {
*/
export const WelcomeGlow = ({ children, className }: WelcomeGlowProps) => {
const enabled = useContext(WelcomeGlowContext);
+ // The dither greets the first home screen of a visit only: not every new
+ // chat or thread switch that lands back on the welcome. Unmounting it once
+ // played also stops the frame loop.
+ const [ditherDone, setDitherDone] = useState(ditherPlayed);
+ // Marked as soon as it starts, so leaving mid-animation doesn't replay it.
+ useEffect(() => {
+ if (enabled) ditherPlayed = true;
+ }, [enabled]);
if (!enabled) {
return <>{children}</>;
@@ -29,14 +41,12 @@ export const WelcomeGlow = ({ children, className }: WelcomeGlowProps) => {
return (
<div className={clsx("openui-agent-welcome-glow", className)}>
- <span
- aria-hidden="true"
- className="openui-agent-welcome-glow__blob openui-agent-welcome-glow__blob--accent"
- />
- <span
- aria-hidden="true"
- className="openui-agent-welcome-glow__blob openui-agent-welcome-glow__blob--foreground"
- />
+ {!ditherDone && (
+ <WelcomeDither
+ className="openui-agent-welcome-glow__dither"
+ onDone={() => setDitherDone(true)}
+ />
+ )}
{children}
</div>
);
diff --git a/packages/react-ui/src/components/AgentInterface/WelcomeScreen.tsx b/packages/react-ui/src/components/AgentInterface/WelcomeScreen.tsx
index f4a25bcb9..c8a111dc2 100644
--- a/packages/react-ui/src/components/AgentInterface/WelcomeScreen.tsx
+++ b/packages/react-ui/src/components/AgentInterface/WelcomeScreen.tsx
@@ -52,6 +52,17 @@ interface WelcomeScreenWithContentProps extends WelcomeScreenBaseProps {
* completion sends the completed prompt immediately.
*/
promptTemplates?: PromptTemplate[];
+ /**
+ * Label of the leading tab (shown with `promptTemplates`) that lists the
+ * default starters.
+ * @default "Getting started"
+ */
+ startersTabLabel?: string;
+ /**
+ * Icon of the leading starters tab.
+ * @default <Rocket />
+ */
+ startersTabIcon?: ReactNode;
/**
* Children are not allowed when using props-based content
*/
@@ -70,6 +81,8 @@ interface WelcomeScreenWithChildrenProps extends WelcomeScreenBaseProps {
starters?: never;
starterVariant?: never;
promptTemplates?: never;
+ startersTabLabel?: never;
+ startersTabIcon?: never;
}
export type WelcomeScreenProps = WelcomeScreenWithContentProps | WelcomeScreenWithChildrenProps;
@@ -133,7 +146,8 @@ export const WelcomeScreen = (props: WelcomeScreenProps) => {
}
// Props-based content
- const { title, description, image } = props as WelcomeScreenWithContentProps;
+ const { title, description, image, startersTabLabel, startersTabIcon } =
+ props as WelcomeScreenWithContentProps;
const renderImage = () => {
if (!image) return null;
@@ -167,6 +181,13 @@ export const WelcomeScreen = (props: WelcomeScreenProps) => {
});
};
+ const handleStartersClick = () => {
+ if (isRunning || !selectedChip) return;
+ // Drop the chip's stem only if the user hasn't extended it.
+ if (draft === selectedChip.prompt) setDraft("");
+ setSelectedChip(null);
+ };
+
const handleContextualSelect = (starter: ConversationStarterProps) => {
submitStarterPrompt(processMessage, draft, starter.prompt);
// Clear at submit time like the composer's own submit path — the
@@ -205,7 +226,7 @@ export const WelcomeScreen = (props: WelcomeScreenProps) => {
{/* Desktop-only welcome composer */}
<div
className="openui-agent-welcome-screen__composer-starters-container"
- data-has-prefill-chips={(hasChips && draft.length === 0) || undefined}
+ data-has-prefill-chips={(hasChips && (draft.length === 0 || !!selectedChip)) || undefined}
>
<div className="openui-agent-welcome-screen__desktop-composer">
<WelcomeGlow>
@@ -229,6 +250,9 @@ export const WelcomeScreen = (props: WelcomeScreenProps) => {
draft={draft}
selectedChip={selectedChip}
onChipClick={handleChipClick}
+ onStartersClick={handleStartersClick}
+ startersLabel={startersTabLabel}
+ startersIcon={startersTabIcon}
onContextualSelect={handleContextualSelect}
disabled={isRunning}
/>
diff --git a/packages/react-ui/src/components/AgentInterface/__tests__/WelcomePrefillChips.ssr.test.tsx b/packages/react-ui/src/components/AgentInterface/__tests__/WelcomePrefillChips.ssr.test.tsx
index e20616548..2f52fb577 100644
--- a/packages/react-ui/src/components/AgentInterface/__tests__/WelcomePrefillChips.ssr.test.tsx
+++ b/packages/react-ui/src/components/AgentInterface/__tests__/WelcomePrefillChips.ssr.test.tsx
@@ -27,6 +27,7 @@ describe("WelcomePrefillChips SSR", () => {
draft=""
selectedChip={null}
onChipClick={() => undefined}
+ onStartersClick={() => undefined}
onContextualSelect={() => undefined}
disabled={false}
/>,
@@ -39,7 +40,7 @@ describe("WelcomePrefillChips SSR", () => {
expect(html).not.toContain("data-hidden");
});
- it("hides layer 1 when drafting and shows contextual starters for the selected chip", () => {
+ it("keeps the tab row and swaps in contextual starters for the selected chip", () => {
const html = render(
<WelcomePrefillChips
chips={CHIPS}
@@ -48,12 +49,32 @@ describe("WelcomePrefillChips SSR", () => {
draft="Create a presentation about "
selectedChip={CHIPS[0]!}
onChipClick={() => undefined}
+ onStartersClick={() => undefined}
onContextualSelect={() => undefined}
disabled={false}
/>,
);
- expect(html).toContain("data-hidden");
+ expect(html).not.toContain("data-hidden");
+ expect(html).toContain('aria-selected="true"');
expect(html).toContain("Our Q2 business review");
+ expect(html).not.toContain("Quarterly deck");
+ });
+
+ it("hides the tab row while free typing", () => {
+ const html = render(
+ <WelcomePrefillChips
+ chips={CHIPS}
+ starters={STARTERS}
+ starterVariant="long"
+ draft="Something else"
+ selectedChip={null}
+ onChipClick={() => undefined}
+ onStartersClick={() => undefined}
+ onContextualSelect={() => undefined}
+ disabled={false}
+ />,
+ );
+ expect(html).toContain("data-hidden");
});
it("disables chips while running", () => {
@@ -65,6 +86,7 @@ describe("WelcomePrefillChips SSR", () => {
draft=""
selectedChip={null}
onChipClick={() => undefined}
+ onStartersClick={() => undefined}
onContextualSelect={() => undefined}
disabled={true}
/>,
diff --git a/packages/react-ui/src/components/AgentInterface/_column.scss b/packages/react-ui/src/components/AgentInterface/_column.scss
new file mode 100644
index 000000000..bc54695f8
--- /dev/null
+++ b/packages/react-ui/src/components/AgentInterface/_column.scss
@@ -0,0 +1,8 @@
+// One reading column for the agent interface: conversation messages, the
+// in-thread composer, and the welcome screen (greeting, composer, tabs,
+// starters) all share it, so their edges line up at every width.
+//
+// ≈ 72ch of the 16px Inter body text, a comfortable reading measure. Kept in
+// px (not ch) so it resolves to the same width on elements with other font
+// sizes.
+$content-width: 728px;
diff --git a/packages/react-ui/src/components/AgentInterface/_shared/store/store.tsx b/packages/react-ui/src/components/AgentInterface/_shared/store/store.tsx
index 8bb6d5db0..d48ab6c07 100644
--- a/packages/react-ui/src/components/AgentInterface/_shared/store/store.tsx
+++ b/packages/react-ui/src/components/AgentInterface/_shared/store/store.tsx
@@ -1,9 +1,15 @@
import { createContext, useContext, useEffect, useMemo } from "react";
import { create } from "zustand";
import { useShallow } from "zustand/react/shallow";
+import { useIsomorphicLayoutEffect } from "../../../Charts/hooks/core/useIsomorphicLayoutEffect";
interface AgentInterfaceState {
isSidebarOpen: boolean;
+ /**
+ * True once hydrated (set before the first paint). Saved preferences are
+ * read from then on, so server and client first renders match.
+ */
+ isHydrated: boolean;
isWorkspaceOpen: boolean;
agentName: string;
logoUrl: string;
@@ -21,7 +27,10 @@ export const createAgentInterfaceStore = ({
agentName: string;
}) =>
create<AgentInterfaceState>((set) => ({
- isSidebarOpen: true,
+ // Collapsed until hydrated, so the server and the client's first render
+ // produce the same markup; SidebarContainer then restores the saved choice.
+ isSidebarOpen: false,
+ isHydrated: false,
isWorkspaceOpen: false,
agentName: agentName,
logoUrl: logoUrl,
@@ -55,6 +64,12 @@ export const AgentInterfaceStoreProvider = ({
}) => {
const shellStore = useMemo(() => createAgentInterfaceStore({ agentName, logoUrl }), []);
+ // Hydrated, before paint: SidebarContainer restores the saved sidebar state
+ // and Container reveals its contents.
+ useIsomorphicLayoutEffect(() => {
+ shellStore.setState({ isHydrated: true });
+ }, [shellStore]);
+
useEffect(() => {
const { setAgentName, setLogoUrl } = shellStore.getState();
setAgentName(agentName);
diff --git a/packages/react-ui/src/components/AgentInterface/agentInterface.scss b/packages/react-ui/src/components/AgentInterface/agentInterface.scss
index 99f1209ea..7e7cfd391 100644
--- a/packages/react-ui/src/components/AgentInterface/agentInterface.scss
+++ b/packages/react-ui/src/components/AgentInterface/agentInterface.scss
@@ -1,7 +1,11 @@
@use "../../cssUtils" as cssUtils;
@use "./sidebar.scss";
+@use "./historyMenu.scss";
+@use "./themeModeToggle.scss";
@use "./threadlist.scss";
@use "./thread.scss";
+@use "./threadHeader.scss";
+@use "./renameChatDialog.scss";
@use "./mobileHeader.scss";
@use "./resizableSeparator.scss";
@use "./conversationStarter.scss";
@@ -11,10 +15,32 @@
@use "./components/welcomePrefillChips.scss";
@use "./components/composer.scss";
@use "./components/ambientLoader.scss";
+@use "./components/mascotLoader.scss";
+@use "./components/welcomeMascot.scss";
@use "./artifactBrowser.scss";
@use "./workspaceSidebar.scss";
@use "./_shared/shared.scss";
+// Covers the interface while saved preferences are restored, on the
+// container's own surface, then fades out to reveal it (see Container.tsx).
+.openui-agent-container__restore-loader {
+ position: absolute;
+ inset: 0;
+ z-index: 1;
+ display: flex;
+ background: inherit;
+ transition: opacity 200ms ease-out;
+
+ &--exiting {
+ opacity: 0;
+ pointer-events: none;
+ }
+
+ @media (prefers-reduced-motion: reduce) {
+ transition: none;
+ }
+}
+
.openui-agent-container {
display: flex;
position: relative;
@@ -22,7 +48,11 @@
width: 100dvw;
overflow: hidden;
- background: cssUtils.$foreground;
+ // Shell surface the sidebar sits on: the card surface pulled 40% toward the
+ // page background, so it reads as a faint grey under the white thread card
+ // in light mode and as a darker well under the card in dark mode (see
+ // thread.scss). Mobile stays a single flat surface.
+ background: color-mix(in oklch, cssUtils.$background 40%, cssUtils.$foreground);
box-sizing: border-box;
& * {
box-sizing: border-box;
@@ -30,6 +60,30 @@
&.openui-agent-container--mobile {
padding: 0;
+ background: cssUtils.$foreground;
+ }
+
+ // Until saved preferences are restored (see Container.tsx).
+ &.openui-agent-container--restoring > :not(.openui-agent-container__restore-loader) {
+ visibility: hidden;
+ }
+
+ // Until the restored state has settled (see Container.tsx).
+ // The restore loader keeps its fade-out.
+ &[data-openui-settling],
+ &[data-openui-settling] *:not(.openui-agent-container__restore-loader) {
+ transition: none !important;
+ }
+}
+
+// Collapsed rail spacing: mark, then a 12px gap to the round actions.
+.openui-agent-sidebar-container--collapsed {
+ .openui-agent-sidebar-actions {
+ gap: cssUtils.$space-m;
+ }
+
+ .openui-agent-sidebar-primary-actions {
+ gap: cssUtils.$space-m;
}
}
@@ -118,6 +172,49 @@
opacity: 0;
overflow: hidden;
}
+
+ // Collapsed rail: the primary action is a filled round button.
+ .openui-agent-new-chat-button__icon {
+ width: 32px;
+ height: 32px;
+ margin: 0;
+ border-radius: cssUtils.$radius-full;
+ background-color: cssUtils.$inverted-background;
+ color: cssUtils.$foreground;
+ font-size: 14px;
+ }
+
+ &:hover .openui-agent-new-chat-button__icon {
+ background-color: cssUtils.$inverted-background;
+ opacity: 0.85;
+ }
+ }
+}
+
+// Collapsed rail: secondary round button that opens the thread history.
+.openui-agent-history-button {
+ @include cssUtils.button-reset;
+
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 32px;
+ height: 32px;
+ flex-shrink: 0;
+ border-radius: cssUtils.$radius-full;
+ background-color: cssUtils.$sunk-deep;
+ color: cssUtils.$text-neutral-primary;
+ font-size: 14px;
+ cursor: pointer;
+ transition: background-color 90ms cubic-bezier(0.22, 1, 0.36, 1);
+
+ &:hover {
+ background-color: cssUtils.$highlight-strong;
+ }
+
+ &:focus-visible {
+ outline: 2px solid cssUtils.$border-interactive;
+ outline-offset: 2px;
}
}
@@ -128,6 +225,20 @@
z-index: 1;
}
+// Same filled neutral treatment as the collapsed-rail New chat button.
+.openui-agent-container .openui-agent-new-chat-floating-button.openui-button-base {
+ border-color: transparent;
+ border-radius: cssUtils.$radius-full;
+ background-color: cssUtils.$inverted-background;
+ color: cssUtils.$foreground;
+
+ &:not(:disabled):hover,
+ &:not(:disabled):active {
+ background-color: cssUtils.$inverted-background;
+ opacity: 0.85;
+ }
+}
+
.openui-agent-tooltip,
.openui-agent-sidebar-tooltip {
@include cssUtils.typography(label, extra-small);
diff --git a/packages/react-ui/src/components/AgentInterface/artifactBrowser.scss b/packages/react-ui/src/components/AgentInterface/artifactBrowser.scss
index 7caf68932..3e44cb453 100644
--- a/packages/react-ui/src/components/AgentInterface/artifactBrowser.scss
+++ b/packages/react-ui/src/components/AgentInterface/artifactBrowser.scss
@@ -50,6 +50,7 @@
@include cssUtils.typography(heading, large);
color: cssUtils.$text-neutral-primary;
font-weight: 500;
+ font-variation-settings: normal;
margin: 0;
padding-left: 4px;
min-width: 0;
diff --git a/packages/react-ui/src/components/AgentInterface/components/AmbientLoader.tsx b/packages/react-ui/src/components/AgentInterface/components/AmbientLoader.tsx
index ba2e16eae..10963725f 100644
--- a/packages/react-ui/src/components/AgentInterface/components/AmbientLoader.tsx
+++ b/packages/react-ui/src/components/AgentInterface/components/AmbientLoader.tsx
@@ -1,24 +1,20 @@
import clsx from "clsx";
-import { DotMatrixLoader } from "../../DotMatrixLoader";
+import { MascotLoader } from "./MascotLoader";
/**
- * Ambient loading state for AgentInterface surfaces: two blurred glow blobs
- * drift and breathe behind a centered dot-matrix loader with a contextual
- * label. Fills whatever panel hosts it (min 280px tall), adapts to light/dark
- * through the theme tokens, and freezes under `prefers-reduced-motion`.
+ * Loading state for AgentInterface surfaces: the OpenUI mascot loader, centred
+ * in whatever panel hosts it (min 280px tall), with a contextual label for
+ * screen readers. Holds still under `prefers-reduced-motion`.
*
* The label is required on purpose — every loading surface should say what is
* actually happening ("Loading artifacts…"), never a bare "Loading…".
*/
export const AmbientLoader = ({ label, className }: { label: string; className?: string }) => (
<div className={clsx("openui-agent-ambient-loader", className)} role="status" aria-live="polite">
- <div className="openui-agent-ambient-loader__glow openui-agent-ambient-loader__glow--a" />
- <div className="openui-agent-ambient-loader__glow openui-agent-ambient-loader__glow--b" />
- {/* The matrix carries its own status role; hide it so the label below is
- the single announcement for this surface. */}
- <span aria-hidden="true">
- <DotMatrixLoader />
+ <span className="openui-agent-ambient-loader__status">
+ <MascotLoader size={40} />
+ {/* Announced, not shown: the mascot alone is the visible state. */}
+ <span className="openui-agent-ambient-loader__label">{label}</span>
</span>
- <span className="openui-agent-ambient-loader__label">{label}</span>
</div>
);
diff --git a/packages/react-ui/src/components/AgentInterface/components/Composer.tsx b/packages/react-ui/src/components/AgentInterface/components/Composer.tsx
index e834db995..3c1e2d8df 100644
--- a/packages/react-ui/src/components/AgentInterface/components/Composer.tsx
+++ b/packages/react-ui/src/components/AgentInterface/components/Composer.tsx
@@ -13,7 +13,7 @@ export interface ComposerProps {
placeholder?: string;
}
-export const Composer = ({ className, placeholder = "Type your query here" }: ComposerProps) => {
+export const Composer = ({ className, placeholder = "Ask anything..." }: ComposerProps) => {
const { textContent, setTextContent } = useComposerState();
const processMessage = useThread((s) => s.processMessage);
const cancelMessage = useThread((s) => s.cancelMessage);
@@ -59,7 +59,7 @@ export const Composer = ({ className, placeholder = "Type your query here" }: Co
// Reset to 0 (not "auto") so scrollHeight reflects content, not container
input.style.height = "0px";
- input.style.height = `${Math.max(input.scrollHeight, 24)}px`;
+ input.style.height = `${Math.max(input.scrollHeight, 32)}px`;
updateInputOverflow();
}, [textContent, updateInputOverflow]);
@@ -98,7 +98,7 @@ export const Composer = ({ className, placeholder = "Type your query here" }: Co
<IconButton
onClick={isRunning ? cancelMessage : handleSubmit}
icon={isRunning ? <Square size="1em" fill="currentColor" /> : <ArrowUp size="1em" />}
- size="extra-small"
+ size="small"
variant="primary"
aria-label={isRunning ? "Cancel message" : "Send message"}
className="openui-agent-thread-composer__submit-button"
diff --git a/packages/react-ui/src/components/AgentInterface/components/DesktopWelcomeComposer.tsx b/packages/react-ui/src/components/AgentInterface/components/DesktopWelcomeComposer.tsx
index fbd0f8f45..bbfd287ca 100644
--- a/packages/react-ui/src/components/AgentInterface/components/DesktopWelcomeComposer.tsx
+++ b/packages/react-ui/src/components/AgentInterface/components/DesktopWelcomeComposer.tsx
@@ -30,7 +30,7 @@ export interface DesktopWelcomeComposerProps {
export const DesktopWelcomeComposer = ({
className,
- placeholder = "Type your query here",
+ placeholder = "Ask anything...",
value,
onChange,
drafting,
@@ -73,7 +73,7 @@ export const DesktopWelcomeComposer = ({
// Reset to 0 (not "auto") so scrollHeight reflects content, not container
input.style.height = "0px";
- input.style.height = `${Math.max(input.scrollHeight, 24)}px`;
+ input.style.height = `${Math.max(input.scrollHeight, 32)}px`;
}, [textContent, textareaRef]);
return (
@@ -101,7 +101,7 @@ export const DesktopWelcomeComposer = ({
disabled={!textContent.trim() && !isRunning}
aria-label={isRunning ? "Cancel" : "Send"}
icon={isRunning ? <Square size="1em" fill="currentColor" /> : <ArrowUp size="1em" />}
- size="extra-small"
+ size="small"
variant="primary"
className="openui-agent-desktop-welcome-composer__submit-button"
/>
diff --git a/packages/react-ui/src/components/AgentInterface/components/Mascot.tsx b/packages/react-ui/src/components/AgentInterface/components/Mascot.tsx
new file mode 100644
index 000000000..714007292
--- /dev/null
+++ b/packages/react-ui/src/components/AgentInterface/components/Mascot.tsx
@@ -0,0 +1,34 @@
+import clsx from "clsx";
+import { MASCOT_BODY_PATHS, MASCOT_EYES, MASCOT_VIEWBOX } from "./mascotPaths";
+
+/** The mascot's paths: body outline, then the eyes and their glints on top. */
+export const MascotArt = () => (
+ <>
+ {MASCOT_BODY_PATHS.map((p, i) => (
+ <path key={i} d={p.d} fill={p.fill} />
+ ))}
+ {MASCOT_EYES.map((eye, i) => (
+ <g key={i}>
+ <path d={eye.eye} fill="black" />
+ <path d={eye.glint} fill="white" />
+ </g>
+ ))}
+ </>
+);
+
+/**
+ * The OpenUI mascot at full strength, standing still. Decorative only. For the
+ * pulsing grey loader, use {@link MascotLoader}.
+ */
+export const Mascot = ({ size = 28, className }: { size?: number; className?: string }) => (
+ <svg
+ viewBox={MASCOT_VIEWBOX}
+ width={size}
+ height={(size * 161) / 201}
+ fill="none"
+ aria-hidden="true"
+ className={clsx("openui-agent-mascot", className)}
+ >
+ <MascotArt />
+ </svg>
+);
diff --git a/packages/react-ui/src/components/AgentInterface/components/MascotLoader.tsx b/packages/react-ui/src/components/AgentInterface/components/MascotLoader.tsx
new file mode 100644
index 000000000..1354ccc36
--- /dev/null
+++ b/packages/react-ui/src/components/AgentInterface/components/MascotLoader.tsx
@@ -0,0 +1,39 @@
+import clsx from "clsx";
+import { useRef } from "react";
+import { useIsomorphicLayoutEffect } from "../../Charts/hooks/core/useIsomorphicLayoutEffect";
+import { MascotArt } from "./Mascot";
+import { MASCOT_VIEWBOX } from "./mascotPaths";
+
+/** Keep in sync with the pulse duration in mascotLoader.scss. */
+const PULSE_MS = 1600;
+
+/**
+ * The OpenUI mascot as a loader: a light grey (low-opacity) mascot whose
+ * opacity pulses on a loop; the eyes stay still. Decorative only, so callers
+ * own the status semantics. Holds still under `prefers-reduced-motion`.
+ *
+ * Every instance pulses on the same clock, so when one loader hands off to
+ * another (the reply loader to the "Working" row) the pulse carries on
+ * instead of restarting.
+ */
+export const MascotLoader = ({ size = 28, className }: { size?: number; className?: string }) => {
+ const bodyRef = useRef<SVGGElement>(null);
+ // Set on the node, not in render, so server-rendered markup hydrates cleanly.
+ useIsomorphicLayoutEffect(() => {
+ bodyRef.current?.style.setProperty("animation-delay", `${-(performance.now() % PULSE_MS)}ms`);
+ }, []);
+ return (
+ <svg
+ viewBox={MASCOT_VIEWBOX}
+ width={size}
+ height={(size * 161) / 201}
+ fill="none"
+ aria-hidden="true"
+ className={clsx("openui-agent-mascot-loader", className)}
+ >
+ <g ref={bodyRef} className="openui-agent-mascot-loader__body">
+ <MascotArt />
+ </g>
+ </svg>
+ );
+};
diff --git a/packages/react-ui/src/components/AgentInterface/components/WelcomeMascot.tsx b/packages/react-ui/src/components/AgentInterface/components/WelcomeMascot.tsx
new file mode 100644
index 000000000..78992aa1b
--- /dev/null
+++ b/packages/react-ui/src/components/AgentInterface/components/WelcomeMascot.tsx
@@ -0,0 +1,151 @@
+import clsx from "clsx";
+import { useEffect, useRef, useState } from "react";
+import { MASCOT_BODY_PATHS, MASCOT_EYES, MASCOT_VIEWBOX } from "./mascotPaths";
+
+// Width of the mascot's viewBox, used to map eye centres to screen pixels.
+const VIEWBOX_WIDTH = 201;
+// How far (in viewBox units) the eyes may drift from rest.
+const MAX_OFFSET = 2;
+// The eyes only follow the cursor within this distance (CSS px) of the mascot.
+const NEAR_PX = 180;
+// Fraction of the remaining distance covered per frame. Lower is lazier.
+const EASE = 0.08;
+// The white glint drifts this much further than the eye, for a hint of depth.
+const GLINT_EXTRA = 0.35;
+
+const prefersReducedMotion = () => window.matchMedia("(prefers-reduced-motion: reduce)").matches;
+
+/**
+ * The OpenUI mascot for the welcome screen: it blinks once when it appears,
+ * its eyes gently follow the cursor while it is nearby, and it squishes when
+ * clicked. Static under `prefers-reduced-motion`. Pass it as
+ * `<AgentInterface.Welcome image={<WelcomeMascot />} />`.
+ */
+export const WelcomeMascot = ({
+ className,
+ label = "OpenUI",
+}: {
+ className?: string;
+ /** Accessible name for the image. */
+ label?: string;
+}) => {
+ const svgRef = useRef<SVGSVGElement>(null);
+ const eyeRefs = useRef<(SVGGElement | null)[]>([]);
+ const glintRefs = useRef<(SVGPathElement | null)[]>([]);
+ const [blinking, setBlinking] = useState(false);
+ const [squish, setSquish] = useState(0);
+
+ useEffect(() => {
+ const svg = svgRef.current;
+ if (!svg || prefersReducedMotion()) return;
+
+ const target = MASCOT_EYES.map(() => ({ x: 0, y: 0 }));
+ const current = MASCOT_EYES.map(() => ({ x: 0, y: 0 }));
+ let frame = 0;
+
+ const tick = () => {
+ let moving = false;
+ current.forEach((c, i) => {
+ const t = target[i]!;
+ c.x += (t.x - c.x) * EASE;
+ c.y += (t.y - c.y) * EASE;
+ if (Math.abs(t.x - c.x) > 0.01 || Math.abs(t.y - c.y) > 0.01) moving = true;
+ eyeRefs.current[i]?.setAttribute(
+ "transform",
+ `translate(${c.x.toFixed(3)} ${c.y.toFixed(3)})`,
+ );
+ glintRefs.current[i]?.setAttribute(
+ "transform",
+ `translate(${(c.x * GLINT_EXTRA).toFixed(3)} ${(c.y * GLINT_EXTRA).toFixed(3)})`,
+ );
+ });
+ frame = moving ? requestAnimationFrame(tick) : 0;
+ };
+ const kick = () => {
+ if (!frame) frame = requestAnimationFrame(tick);
+ };
+
+ const onMove = (e: PointerEvent) => {
+ const rect = svg.getBoundingClientRect();
+ const near =
+ Math.hypot(
+ e.clientX - (rect.left + rect.width / 2),
+ e.clientY - (rect.top + rect.height / 2),
+ ) < NEAR_PX;
+ const scale = rect.width / VIEWBOX_WIDTH;
+ MASCOT_EYES.forEach((eye, i) => {
+ if (!near) {
+ target[i] = { x: 0, y: 0 };
+ return;
+ }
+ const dx = e.clientX - (rect.left + eye.cx * scale);
+ const dy = e.clientY - (rect.top + eye.cy * scale);
+ const dist = Math.hypot(dx, dy) || 1;
+ const reach = Math.min(dist / NEAR_PX, 1) * MAX_OFFSET;
+ target[i] = { x: (dx / dist) * reach, y: (dy / dist) * reach };
+ });
+ kick();
+ };
+
+ const onLeave = () => {
+ target.forEach((t) => {
+ t.x = 0;
+ t.y = 0;
+ });
+ kick();
+ };
+
+ // A single hello blink shortly after the mascot first appears.
+ const timers = [
+ setTimeout(() => setBlinking(true), 600),
+ setTimeout(() => setBlinking(false), 760),
+ ];
+
+ window.addEventListener("pointermove", onMove, { passive: true });
+ document.documentElement.addEventListener("pointerleave", onLeave);
+ return () => {
+ window.removeEventListener("pointermove", onMove);
+ document.documentElement.removeEventListener("pointerleave", onLeave);
+ cancelAnimationFrame(frame);
+ timers.forEach(clearTimeout);
+ };
+ }, []);
+
+ const onPress = () => {
+ if (prefersReducedMotion()) return;
+ // Bumping the key restarts the squish animation on every click.
+ setSquish((n) => n + 1);
+ };
+
+ return (
+ <svg
+ ref={svgRef}
+ viewBox={MASCOT_VIEWBOX}
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ role="img"
+ aria-label={label}
+ className={clsx("openui-agent-welcome-mascot", className)}
+ onPointerDown={onPress}
+ >
+ <g key={squish} className={squish ? "openui-agent-welcome-mascot__body--squish" : undefined}>
+ {MASCOT_BODY_PATHS.map((p, i) => (
+ <path key={i} d={p.d} fill={p.fill} />
+ ))}
+ {MASCOT_EYES.map((eye, i) => (
+ <g
+ key={i}
+ className="openui-agent-welcome-mascot__lid"
+ style={{ transformOrigin: `${eye.cx}px ${eye.cy}px` }}
+ data-blinking={blinking || undefined}
+ >
+ <g ref={(el) => void (eyeRefs.current[i] = el)}>
+ <path d={eye.eye} fill="black" />
+ <path ref={(el) => void (glintRefs.current[i] = el)} d={eye.glint} fill="white" />
+ </g>
+ </g>
+ ))}
+ </g>
+ </svg>
+ );
+};
diff --git a/packages/react-ui/src/components/AgentInterface/components/WelcomePrefillChips.tsx b/packages/react-ui/src/components/AgentInterface/components/WelcomePrefillChips.tsx
index c00d82a18..ae89dd608 100644
--- a/packages/react-ui/src/components/AgentInterface/components/WelcomePrefillChips.tsx
+++ b/packages/react-ui/src/components/AgentInterface/components/WelcomePrefillChips.tsx
@@ -1,21 +1,32 @@
+import { Rocket } from "lucide-react";
+import { ReactNode } from "react";
import { ConversationStarterProps } from "../../../types/ConversationStarter";
import { PromptTemplate } from "../../../types/PromptTemplate";
import { ConversationStarter, ConversationStarterVariant } from "../ConversationStarter";
-interface PrefillChipButtonProps {
- chip: PromptTemplate;
+interface PrefillTabProps {
+ label: string;
+ icon?: ReactNode;
+ selected: boolean;
disabled: boolean;
onClick: () => void;
}
-const PrefillChipButton = ({ chip, disabled, onClick }: PrefillChipButtonProps) => (
- <button type="button" className="openui-agent-prefill-chip" disabled={disabled} onClick={onClick}>
- {chip.icon && (
+const PrefillTab = ({ label, icon, selected, disabled, onClick }: PrefillTabProps) => (
+ <button
+ type="button"
+ role="tab"
+ aria-selected={selected}
+ className="openui-agent-prefill-chip"
+ disabled={disabled}
+ onClick={onClick}
+ >
+ {icon && (
<span className="openui-agent-prefill-chip__icon" aria-hidden>
- {chip.icon}
+ {icon}
</span>
)}
- <span className="openui-agent-prefill-chip__label">{chip.displayText}</span>
+ <span className="openui-agent-prefill-chip__label">{label}</span>
</button>
);
@@ -26,15 +37,22 @@ export interface WelcomePrefillChipsProps {
draft: string;
selectedChip: PromptTemplate | null;
onChipClick: (chip: PromptTemplate) => void;
+ /** Selects the leading starters tab (clears a chip selection). */
+ onStartersClick: () => void;
onContextualSelect: (starter: ConversationStarterProps) => void;
disabled: boolean;
+ /** Label of the leading tab that shows the default starters. */
+ startersLabel?: string;
+ /** Icon of the leading starters tab. */
+ startersIcon?: ReactNode;
}
/**
- * Chip row + grid-stacked starters layers for the prefill-chips welcome.
- * Layer 1 (chips + default starters) hides via `visibility` while drafting so
- * the layout doesn't jump; layer 2 shows the selected chip's contextual
- * starters, which submit the completed prompt (see WelcomeScreen).
+ * Tab row + starters for the prefill-chips welcome. A leading tab shows the
+ * default starters; each prompt template is a tab that drops its stem into the
+ * composer and swaps in its completions, which submit the completed prompt
+ * (see WelcomeScreen). Free typing hides the row via `visibility` so the
+ * layout doesn't jump.
*/
export const WelcomePrefillChips = ({
chips,
@@ -43,39 +61,53 @@ export const WelcomePrefillChips = ({
draft,
selectedChip,
onChipClick,
+ onStartersClick,
onContextualSelect,
disabled,
+ startersLabel = "Getting started",
+ startersIcon = <Rocket size={14} />,
}: WelcomePrefillChipsProps) => {
- const isDraftEmpty = draft.length === 0;
+ const isFreeTyping = draft.length > 0 && !selectedChip;
+ const contextualVariant: ConversationStarterVariant = starterVariant === "card" ? "card" : "long";
return (
<div className="openui-agent-welcome-screen__desktop-starters openui-agent-welcome-screen__starters-layers">
<div
className="openui-agent-welcome-screen__starters-layer"
- data-hidden={!isDraftEmpty || undefined}
- aria-hidden={!isDraftEmpty || undefined}
+ data-hidden={isFreeTyping || undefined}
+ aria-hidden={isFreeTyping || undefined}
>
- <div className="openui-agent-welcome-screen__chip-row">
+ <div className="openui-agent-welcome-screen__chip-row" role="tablist">
+ {starters.length > 0 && (
+ <PrefillTab
+ label={startersLabel}
+ icon={startersIcon}
+ selected={!selectedChip}
+ disabled={disabled}
+ onClick={onStartersClick}
+ />
+ )}
{chips.map((chip, index) => (
- <PrefillChipButton
+ <PrefillTab
key={`${chip.displayText}-${index}`}
- chip={chip}
+ label={chip.displayText}
+ icon={chip.icon}
+ selected={selectedChip === chip}
disabled={disabled}
onClick={() => onChipClick(chip)}
/>
))}
</div>
- <ConversationStarter starters={starters} variant={starterVariant} />
- </div>
- {selectedChip && (
- <div className="openui-agent-welcome-screen__starters-layer">
+ {selectedChip ? (
<ConversationStarter
starters={selectedChip.completions}
- variant="long"
+ variant={contextualVariant}
onSelect={onContextualSelect}
/>
- </div>
- )}
+ ) : (
+ <ConversationStarter starters={starters} variant={starterVariant} />
+ )}
+ </div>
</div>
);
};
diff --git a/packages/react-ui/src/components/AgentInterface/components/ambientLoader.scss b/packages/react-ui/src/components/AgentInterface/components/ambientLoader.scss
index 09b7e4678..0423fa4a1 100644
--- a/packages/react-ui/src/components/AgentInterface/components/ambientLoader.scss
+++ b/packages/react-ui/src/components/AgentInterface/components/ambientLoader.scss
@@ -1,86 +1,31 @@
@use "../../../cssUtils" as cssUtils;
-// Ambient loading state (components/AmbientLoader.tsx): blurred glow blobs
-// breathing behind a centered dot-matrix loader. Fills the hosting panel.
+// Loading state (components/AmbientLoader.tsx): the mascot loader, centred in
+// the hosting panel; the label is for screen readers only.
.openui-agent-ambient-loader {
- position: relative;
display: flex;
- flex-direction: column;
align-items: center;
justify-content: center;
- gap: cssUtils.$space-m;
flex: 1 1 auto;
width: 100%;
height: 100%;
min-height: 280px;
- overflow: hidden;
- // Keep the negative-z glows inside this stacking context.
- isolation: isolate;
-}
-
-.openui-agent-ambient-loader__glow {
- position: absolute;
- width: min(340px, 55%);
- aspect-ratio: 1;
- border-radius: 50%;
- filter: blur(64px);
- pointer-events: none;
- z-index: -1;
- will-change: transform;
-
- &--a {
- top: 4%;
- left: 6%;
- // Neutral themes render this as soft luminance depth; branded themes
- // (a colored accent token) tint the glow automatically. Opacity lives in
- // the keyframes so the glow breathes as it drifts.
- background: cssUtils.$interactive-accent-default;
- opacity: 0.14;
- animation: openui-agent-ambient-loader-drift-a 7s ease-in-out infinite alternate;
- }
-
- &--b {
- right: 4%;
- bottom: 4%;
- background: cssUtils.$chat-user-response-bg;
- opacity: 0.75;
- animation: openui-agent-ambient-loader-drift-b 9.5s ease-in-out infinite alternate;
- }
-}
-
-@keyframes openui-agent-ambient-loader-drift-a {
- from {
- transform: translate(-14%, -10%) scale(0.92);
- opacity: 0.09;
- }
-
- to {
- transform: translate(22%, 26%) scale(1.35);
- opacity: 0.2;
- }
}
-@keyframes openui-agent-ambient-loader-drift-b {
- from {
- transform: translate(12%, 10%) scale(1.28);
- opacity: 0.85;
- }
-
- to {
- transform: translate(-22%, -20%) scale(0.85);
- opacity: 0.5;
- }
-}
-
-.openui-agent-ambient-loader__label {
- @include cssUtils.typography(label, small);
-
+.openui-agent-ambient-loader__status {
+ display: inline-flex;
+ align-items: center;
+ gap: cssUtils.$space-s;
color: cssUtils.$text-neutral-secondary;
}
-@media (prefers-reduced-motion: reduce) {
- .openui-agent-ambient-loader__glow {
- animation: none;
- }
+// Screen-reader only.
+.openui-agent-ambient-loader__label {
+ position: absolute;
+ width: 1px;
+ height: 1px;
+ overflow: hidden;
+ clip: rect(0 0 0 0);
+ white-space: nowrap;
}
diff --git a/packages/react-ui/src/components/AgentInterface/components/composer.scss b/packages/react-ui/src/components/AgentInterface/components/composer.scss
index c85d67c6b..0cd386606 100644
--- a/packages/react-ui/src/components/AgentInterface/components/composer.scss
+++ b/packages/react-ui/src/components/AgentInterface/components/composer.scss
@@ -1,10 +1,16 @@
@use "../../../cssUtils" as cssUtils;
+@use "../column";
$thread-content-inline-padding: cssUtils.$space-m-l;
+// Same reading column as the messages (see ../_column.scss), so the input's
+// edges line up with the conversation above it.
$thread-content-max-width: calc(
- 768px + #{$thread-content-inline-padding} + #{$thread-content-inline-padding}
+ #{column.$content-width} + #{$thread-content-inline-padding} + #{$thread-content-inline-padding}
);
+// Pill composer: one row of input + round send button. The radius is half the
+// 56px resting height, so it reads as a pill on one line and eases into a
+// rounded rectangle as the draft grows.
.openui-agent-thread-composer {
max-width: $thread-content-max-width;
width: 100%;
@@ -13,7 +19,7 @@ $thread-content-max-width: calc(
.openui-agent-container--mobile & {
margin: 0;
- padding: cssUtils.$space-m cssUtils.$space-m cssUtils.$space-m-l;
+ padding: cssUtils.$space-m $thread-content-inline-padding cssUtils.$space-m-l;
}
.openui-agent-thread-container--detailed-view-active & {
@@ -21,15 +27,26 @@ $thread-content-max-width: calc(
}
&__input-wrapper {
- background-color: cssUtils.$foreground;
- border: 1px solid cssUtils.$border-interactive;
- border-radius: cssUtils.$radius-3xl;
- box-shadow: cssUtils.$shadow-l;
+ // A shade above the card in dark mode (a no-op on the white light surface).
+ background-color: color-mix(in oklch, cssUtils.$foreground, cssUtils.$text-white 3%);
+ // 0.5px hairline ring hugging the outside edge (transparent 1px border keeps
+ // the 56px resting height unchanged), very faint so it reads as an edge.
+ border: 1px solid transparent;
+ border-radius: cssUtils.$radius-6xl;
+ box-shadow:
+ 0 0 0 0.5px color-mix(in oklch, #{cssUtils.$text-neutral-primary} 8%, transparent),
+ 0 4px 16px oklch(0 0 0 / 0.06);
overflow: clip;
display: flex;
- flex-direction: column;
- gap: cssUtils.$space-s;
- padding: cssUtils.$space-m;
+ flex-direction: row;
+ // Bottom-align so the send button stays on the last line as the draft
+ // grows; input and button share a 32px row height, so one line still
+ // reads as vertically centred.
+ align-items: flex-end;
+ gap: cssUtils.$space-m;
+ min-height: 56px;
+ // 11px + a 32px row + 11px + 2px border = the 56px resting height.
+ padding: 11px cssUtils.$space-m 11px cssUtils.$space-xl;
&[data-overflow-top],
&[data-overflow-bottom] {
@@ -80,7 +97,9 @@ $thread-content-max-width: calc(
border-radius: cssUtils.$radius-full;
}
- padding: 0 cssUtils.$space-3xs;
+ flex: 1;
+ min-width: 0;
+ padding: 6px 0;
resize: none;
max-height: 200px;
outline: none;
@@ -88,6 +107,8 @@ $thread-content-max-width: calc(
background: transparent;
overflow-y: auto;
@include cssUtils.typography(body, default);
+ font-size: 15px;
+ line-height: 20px;
color: cssUtils.$text-neutral-primary;
&::placeholder {
@@ -98,9 +119,22 @@ $thread-content-max-width: calc(
&__action-bar {
display: flex;
align-items: center;
+ flex-shrink: 0;
}
+}
- &__submit-button {
- margin-left: auto;
+// Round, neutral send button. Scoped under the composer root (plus the
+// IconButton class) so it outranks IconButton's square/primary rules.
+.openui-agent-thread-composer .openui-agent-thread-composer__submit-button.openui-icon-button {
+ border-color: transparent;
+ border-radius: cssUtils.$radius-full;
+ background-color: cssUtils.$inverted-background;
+ box-shadow: none;
+ color: cssUtils.$foreground;
+
+ &:not(:disabled):hover,
+ &:not(:disabled):active {
+ background-color: cssUtils.$inverted-background;
+ opacity: 0.85;
}
}
diff --git a/packages/react-ui/src/components/AgentInterface/components/desktopWelcomeComposer.scss b/packages/react-ui/src/components/AgentInterface/components/desktopWelcomeComposer.scss
index 907b673e1..719df2ed5 100644
--- a/packages/react-ui/src/components/AgentInterface/components/desktopWelcomeComposer.scss
+++ b/packages/react-ui/src/components/AgentInterface/components/desktopWelcomeComposer.scss
@@ -1,18 +1,32 @@
@use "../../../cssUtils" as cssUtils;
+@use "../column";
+// Pill composer: one row of input + round send button. The radius is half the
+// 56px resting height, so it reads as a pill on one line and eases into a
+// rounded rectangle as the draft grows.
.openui-agent-desktop-welcome-composer {
- background-color: cssUtils.$foreground;
- border: 1px solid cssUtils.$border-interactive;
- border-radius: cssUtils.$radius-3xl;
- box-shadow: cssUtils.$shadow-s;
+ // A shade above the card in dark mode (a no-op on the white light surface).
+ background-color: color-mix(in oklch, cssUtils.$foreground, cssUtils.$text-white 3%);
+ // 0.5px hairline ring hugging the outside edge (transparent 1px border keeps
+ // the 56px resting height unchanged), very faint so it reads as an edge.
+ border: 1px solid transparent;
+ border-radius: cssUtils.$radius-6xl;
+ box-shadow:
+ 0 0 0 0.5px color-mix(in oklch, #{cssUtils.$text-neutral-primary} 8%, transparent),
+ 0 4px 16px oklch(0 0 0 / 0.06);
overflow: clip;
display: flex;
- flex-direction: column;
+ flex-direction: row;
+ // Bottom-align so the send button stays on the last line as the draft
+ // grows; input and button share a 32px row height, so one line still
+ // reads as vertically centred.
+ align-items: flex-end;
gap: cssUtils.$space-m;
- padding: cssUtils.$space-m;
+ // 11px + a 32px row + 11px + 2px border = the 56px resting height.
+ padding: 11px cssUtils.$space-m 11px cssUtils.$space-xl;
width: 100%;
- max-width: 768px;
- min-height: calc(cssUtils.$space-3xl + cssUtils.$space-3xl + cssUtils.$space-m);
+ max-width: column.$content-width; // same as the in-thread input
+ min-height: 56px;
&__input {
scrollbar-width: thin;
@@ -31,16 +45,19 @@
border-radius: cssUtils.$radius-full;
}
- padding: 0 cssUtils.$space-3xs;
+ padding: 6px 0;
flex: 1;
+ min-width: 0;
resize: none;
max-height: 200px;
- min-height: 24px;
outline: none;
border: none;
background: transparent;
overflow-y: auto;
@include cssUtils.typography(body, default);
+ font-size: 15px;
+ line-height: 20px;
+ min-height: 32px;
color: cssUtils.$text-neutral-primary;
&::placeholder {
@@ -51,13 +68,28 @@
&__action-bar {
display: flex;
align-items: center;
+ flex-shrink: 0;
}
+}
- &__submit-button {
- margin-left: auto;
+// Round, neutral send button. Scoped under the composer root (plus the
+// IconButton class) so it outranks IconButton's square/primary rules.
+.openui-agent-desktop-welcome-composer
+ .openui-agent-desktop-welcome-composer__submit-button.openui-icon-button {
+ border-color: transparent;
+ border-radius: cssUtils.$radius-full;
+ background-color: cssUtils.$inverted-background;
+ box-shadow: none;
+ color: cssUtils.$foreground;
- &:disabled {
- filter: grayscale(1);
- }
+ &:not(:disabled):hover,
+ &:not(:disabled):active {
+ background-color: cssUtils.$inverted-background;
+ opacity: 0.85;
+ }
+ &:disabled {
+ background-color: cssUtils.$inverted-background;
+ color: cssUtils.$foreground;
+ cursor: default;
}
}
diff --git a/packages/react-ui/src/components/AgentInterface/components/mascotLoader.scss b/packages/react-ui/src/components/AgentInterface/components/mascotLoader.scss
new file mode 100644
index 000000000..76c354045
--- /dev/null
+++ b/packages/react-ui/src/components/AgentInterface/components/mascotLoader.scss
@@ -0,0 +1,37 @@
+// The still mascot (components/Mascot.tsx).
+.openui-agent-mascot {
+ display: block;
+ flex-shrink: 0;
+ overflow: visible;
+}
+
+// Mascot loader (components/MascotLoader.tsx). Drawn at low opacity so it reads
+// as a light grey, and the whole mascot breathes by pulsing that opacity. The
+// eyes stay still.
+
+.openui-agent-mascot-loader {
+ display: block;
+ flex-shrink: 0;
+ overflow: visible;
+}
+
+.openui-agent-mascot-loader__body {
+ opacity: 0.4;
+ animation: openui-agent-mascot-pulse 1.6s ease-in-out infinite;
+}
+
+@keyframes openui-agent-mascot-pulse {
+ 0%,
+ 100% {
+ opacity: 0.25;
+ }
+ 50% {
+ opacity: 0.55;
+ }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .openui-agent-mascot-loader__body {
+ animation: none;
+ }
+}
diff --git a/packages/react-ui/src/components/AgentInterface/components/mascotPaths.ts b/packages/react-ui/src/components/AgentInterface/components/mascotPaths.ts
new file mode 100644
index 000000000..6baf793bf
--- /dev/null
+++ b/packages/react-ui/src/components/AgentInterface/components/mascotPaths.ts
@@ -0,0 +1,78 @@
+// OpenUI mascot outline, from templates/openui-cloud/public/brand-logo.svg.
+// The eyes are kept separate so the loader and welcome mascot can animate them.
+export const MASCOT_VIEWBOX = "0 0 201 161";
+export const MASCOT_BODY_PATHS: { d: string; fill: "white" | "black" }[] = [
+ {
+ fill: "white",
+ d: "M96.4693 0.0613982C100.562 -0.219889 106.03 0.898654 109.884 2.21486C117.608 4.85218 124.079 10.4283 126.85 18.3106C127.19 19.2787 127.872 18.5635 128.573 18.4644C136.202 15.6827 148.792 15.4108 150.447 25.8528C150.513 26.2731 150.412 28.7583 150.697 28.8864C155.135 30.8727 159.282 33.1515 162.545 36.9059C166.623 41.6167 168.774 47.558 168.855 53.8056C169.304 54.1242 171.225 55.0501 171.614 55.2496C175.688 57.3331 176.488 61.8369 179.29 65.0357C180.628 66.565 182.827 67.826 184.55 69.0379C189.451 72.4869 193.642 76.9365 196.353 82.3631C199.779 89.3389 201.567 97.4106 199.038 104.999C197.192 110.537 193.967 115.109 188.757 117.766C188.158 120.59 187.065 123.281 185.53 125.715C182.361 130.836 177.823 134.519 171.974 135.893C166.904 142.521 160.628 144.118 153.733 140.503L152.546 140.751C149.317 151.404 138.983 156.496 128.47 154.582C122.339 160.568 110.531 162.36 103.702 156.111C102.74 155.231 102.108 153.842 101.436 152.736H99.0202C98.3476 153.842 97.7156 155.231 96.7537 156.111C89.9252 162.36 78.1165 160.568 71.9857 154.582C61.4727 156.496 51.1384 151.404 47.9095 140.751L46.7231 140.503C46.0678 140.85 45.489 141.143 44.8004 141.42C40.8754 143.024 36.4788 142.961 32.6 141.245C28.1603 139.273 25.3065 135.718 23.5846 131.214C14.741 129.106 10.1854 120.216 9.84284 111.579C6.87102 109.965 4.21197 107.496 2.776 104.37C-6.3609 84.4855 10.846 63.5524 26.3452 53.1434C27.5095 52.4257 28.8011 51.778 30.0434 51.2027C31.409 50.5703 30.9789 49.9574 31.0286 48.6109C31.3227 40.6495 38.2656 33.8866 44.7334 30.2176C46.3827 29.2819 48.0742 28.7881 49.6889 27.9407L49.7988 27.8817C50.3649 23.935 50.8901 22.0402 54.0668 19.2296C60.7483 13.3185 68.7135 11.5534 77.3721 11.9984C77.5784 11.0305 77.7828 10.073 78.1929 9.17118C81.2998 2.33927 89.8871 0.464817 96.4693 0.0613982Z",
+ },
+ {
+ fill: "black",
+ d: "M35.22 56.1054C36.0722 56.0298 37.0061 56.289 37.6916 56.8144C38.4148 57.3647 38.8908 58.1852 39.0134 59.093C39.4319 62.3292 34.7522 64.289 32.5668 65.9633C28.1359 69.3919 24.1968 73.4275 20.8623 77.9543C16.5888 83.8445 9.42184 97.0259 17.1465 102.728C17.9347 100.931 19.0394 98.3543 20.8943 97.4531C22.4875 96.6773 24.6151 97.6001 24.578 99.5551C24.5573 100.643 23.9348 101.592 23.6416 102.649C22.5829 106.465 22.4085 110.587 23.8168 114.337C24.3074 115.638 25.5758 117.362 26.87 117.864C28.402 118.459 28.7642 116.878 30.0786 116.375C30.6077 116.174 31.288 115.96 31.8305 116.238C33.9925 117.305 33.5192 119.553 33.8751 121.51C34.4045 124.42 36.1071 127.642 39.0184 128.681C40.3714 129.163 41.3128 128.702 42.5049 128.122C41.0569 123.876 40.8024 120.76 41.9716 115.958C42.605 113.04 46.705 103.862 50.4181 108.876C51.1835 109.909 49.6543 112.771 49.2625 113.91C47.815 118.605 48.128 123.86 50.7971 128.108C51.5821 129.279 52.5988 129.863 52.7832 131.382C53.0308 133.42 51.974 134.861 49.9105 135.044C48.222 135.194 47.1043 134.381 45.8443 133.363C44.5654 134.983 42.7863 136.167 40.7649 136.563C38.2539 137.042 35.6582 136.49 33.548 135.031C30.3707 132.858 28.7823 129.481 28.0622 125.779C24.2127 125.966 21.289 124.411 18.9903 121.291C15.8886 117.084 15.2782 112.168 15.9659 107.119C9.74687 107.185 6.85479 100.621 6.21362 95.2646C5.2211 86.9741 9.84089 77.8936 14.8574 71.6183C19.0338 66.3939 28.5941 56.8471 35.22 56.1054Z",
+ },
+ {
+ fill: "black",
+ d: "M165.437 60.0763C169.256 59.6682 170.852 63.294 172.365 66.1435C174.847 70.8213 178.95 72.6358 182.914 75.7209C188.802 80.3019 193.342 87.8382 194.18 95.378C194.737 100.275 193.325 105.193 190.263 109.023C188.455 111.278 186.389 113.004 183.474 113.323C182.675 121.677 176.975 130.01 168.468 130.65C166.221 136.864 160.081 140.014 155.692 133.712C153.894 135.433 150.011 137.782 148.066 134.723C146.485 132.235 149.707 130.338 150.849 128.626C151.809 127.135 152.311 124.95 152.263 123.14C152.029 121.181 151.454 119.166 150.661 117.16C150.006 115.062 148.001 111.541 150.606 110.344C153.3 109.105 155.094 112.277 155.984 114.422C158.939 119.291 160.11 124.623 158.787 129.298C159.9 129.76 160.651 129.943 161.602 129.514C163.713 128.475 164.426 125.973 164.776 123.143C164.844 122.584 165.441 121.846 165.937 121.694C166.843 121.425 167.632 121.857 168.488 122.394C168.659 122.344 168.83 122.285 168.999 122.217C173.759 120.52 176.526 113.48 176.555 108.662C176.568 106.716 175.686 104.911 176.5 103.271C176.817 102.664 177.424 102.104 178.103 101.947C181.319 101.207 182.257 104.475 182.851 106.737C188.584 100.767 184.155 89.6212 179.098 84.7382C176.523 82.2523 173.684 80.1378 171.251 77.5406C168.585 74.6932 166.977 70.984 165.076 67.6217C164.103 65.8603 162.018 64.0912 163.13 61.9175C163.664 60.8745 164.41 60.4597 165.437 60.0763Z",
+ },
+ {
+ fill: "black",
+ d: "M98.4249 91.3168C100.49 91.1288 103.577 91.5127 105.568 92.0618C112.098 93.8619 109.45 100.186 105.374 102.941C104.5 103.531 103.878 103.883 102.895 104.349C104.577 108.267 109.117 111.39 113.38 110.988C115.121 110.823 117.12 110.116 118.276 108.719C118.816 108.066 119.213 107.273 119.776 106.631C120.309 106.012 121.068 105.639 121.878 105.599C122.655 105.559 123.497 105.878 124.03 106.446C126.175 108.734 124.431 111.94 122.605 113.731C119.756 116.524 116.307 117.456 112.455 117.445C112.12 124.563 108.264 131.524 100.94 132.958C100.575 133.022 100.088 133.067 99.7149 133.083C96.5674 133.234 93.4909 132.103 91.1724 129.941C87.7146 126.74 86.1925 121.949 85.9834 117.314C83.4248 117.194 81.5963 116.937 79.1567 115.71C76.3601 114.303 72.6921 110.508 74.3701 107.056C74.6972 106.383 75.3873 105.731 76.1544 105.518C79.6501 104.586 79.5824 108.454 82.0749 109.786C87.5562 112.717 93.101 109.459 96.0075 104.316C94.9605 103.751 94.0702 103.229 93.1282 102.47C90.8158 100.605 88.1737 96.4834 90.6425 93.7377C92.3901 91.7941 95.9527 91.4763 98.4249 91.3168Z",
+ },
+ {
+ fill: "white",
+ d: "M101.066 112.085C103.109 114.174 104.478 115.069 107.074 116.308C106.654 119.12 106.446 121.175 105.131 123.72C103.966 125.736 102.371 127.263 99.9798 127.566C98.2895 127.796 96.5792 127.312 95.2516 126.226C92.3485 123.876 91.743 119.708 91.3723 116.224C94.1137 115.07 95.2618 114.177 97.433 112.21C97.6866 113.896 97.2857 118.429 98.2287 119.468C101.256 122.804 101.051 113.068 101.066 112.085Z",
+ },
+ {
+ fill: "black",
+ d: "M95.2916 6.21179C102.108 5.38821 111.021 8.30294 116.052 12.9727C119.479 16.1543 121.765 20.4547 121.89 25.2344C121.985 28.9537 121.135 36.6044 116.353 37.0784C115.889 37.1148 115.278 36.9164 114.951 36.551C113.752 35.2109 114.403 33.4858 114.482 31.8653C114.093 19.9816 103.509 13.6921 92.638 14.5432C90.0691 14.7444 86.5017 16.4929 84.2984 14.7722C82.8937 13.6752 83.31 11.423 84.4439 10.2383C87.115 7.44746 91.6352 6.54492 95.2916 6.21179Z",
+ },
+ {
+ fill: "black",
+ d: "M55.081 130.708C57.9218 130.548 57.7961 133.273 59.0147 135.3C61.3794 139.232 66.2028 141.456 70.684 140.853C72.6319 140.592 74.3201 138.897 76.3197 139.573C77.7745 140.109 78.5039 142.08 79.5042 143.201C80.7214 144.566 81.8535 145.42 83.5117 146.151C84.9789 146.782 86.5325 147.184 88.1191 147.342C88.7882 147.401 90.1961 147.42 90.7659 147.632C94.5882 149.049 93.3245 151.869 90.5034 153.282C88.3115 154.102 85.6481 154.312 83.3512 153.914C79.111 153.176 76.3151 151.303 73.8406 147.824C70.226 149.294 66.7301 149.618 62.9641 148.463C59.2927 147.326 56.2156 144.762 54.4066 141.331C53.3959 139.38 52.9387 137.346 52.9554 135.152C52.9707 133.15 53.1515 131.651 55.081 130.708Z",
+ },
+ {
+ fill: "black",
+ d: "M141.631 33.8967C143.027 33.7227 144.974 33.918 146.347 34.2033C151.864 35.3903 156.692 38.7445 159.774 43.5309C167.994 56.3762 155.824 65.5136 152.103 59.0344C151.258 56.6258 152.348 54.954 154.183 53.509C154.007 49.6426 152.029 46.8088 148.985 44.5485C146.115 42.4172 142.52 41.5099 138.995 41.7879C137.098 41.9374 134.659 43.2975 132.97 41.9238C132.357 41.4234 131.967 40.696 131.884 39.903C131.48 35.7075 138.674 34.1624 141.631 33.8967Z",
+ },
+ {
+ fill: "black",
+ d: "M72.0157 18.0605C74.6789 17.7752 78.0049 18.1958 80.5872 18.836C85.3372 20.0136 89.873 22.836 92.4376 27.1397C93.1716 28.4576 93.7795 29.6683 93.4198 31.2183C93.0869 32.653 91.2418 33.9386 89.8453 33.4613C88.436 32.9796 86.8454 31.3889 85.5554 30.4837C83.5273 29.0606 81.7428 28.2112 79.3831 27.4636C73.7544 25.882 68.2085 26.3072 62.8998 28.7113C61.688 29.0848 60.3962 30.3492 59.1715 30.5246C55.239 31.0884 54.9684 26.9335 57.0107 24.7317C60.9193 20.5175 66.4981 18.5697 72.0157 18.0605Z",
+ },
+ {
+ fill: "black",
+ d: "M145.375 130.708C142.534 130.548 142.66 133.273 141.441 135.3C139.076 139.232 134.253 141.456 129.772 140.853C127.824 140.592 126.136 138.897 124.136 139.573C122.681 140.109 121.952 142.08 120.952 143.201C119.734 144.566 118.602 145.42 116.944 146.151C115.477 146.782 113.923 147.184 112.337 147.342C111.668 147.401 110.26 147.42 109.69 147.632C105.868 149.049 107.131 151.869 109.952 153.282C112.144 154.102 114.808 154.312 117.105 153.914C121.345 153.176 124.141 151.303 126.615 147.824C130.23 149.294 133.726 149.618 137.492 148.463C141.163 147.326 144.24 144.762 146.049 141.331C147.06 139.38 147.517 137.346 147.5 135.152C147.485 133.15 147.304 131.651 145.375 130.708Z",
+ },
+ {
+ fill: "black",
+ d: "M57.9869 32.4154C61.0803 32.1932 64.9846 32.8784 67.5663 34.7846C69.1159 35.9288 69.7723 38.1746 68.4165 39.7853C66.9821 41.4891 64.9287 40.6457 63.0985 40.5766C56.3421 40.3214 49.4865 44.0218 45.2155 49.1875C43.5551 51.3235 41.1305 54.2193 38.1886 51.8361C35.029 49.2764 38.2265 43.7736 40.2441 41.4224C44.7932 36.1211 51.0825 32.9899 57.9869 32.4154Z",
+ },
+ {
+ fill: "black",
+ d: "M137.003 22.8467C137.75 22.7899 138.333 22.8823 139.136 22.8816C142.233 22.8788 146.176 25.5757 143.798 28.936C142.753 30.4106 140.517 29.8315 138.901 29.9251C133.62 30.231 129.344 32.9901 125.929 36.8713C125.265 37.8226 124.489 38.9617 123.286 39.1549C121.87 39.3825 120.352 38.0627 120.316 36.631C120.246 33.8766 122.164 30.8245 123.871 28.8586C127.251 24.9667 131.986 23.1497 137.003 22.8467Z",
+ },
+ {
+ fill: "black",
+ d: "M149.884 88.2145C156.566 87.5173 164.292 104.85 158.384 109.424C156.153 110.295 154.381 109.041 154.265 106.788C154.036 102.385 152.923 98.5091 150.556 94.7768C149.945 93.5954 148.647 92.4492 148.143 91.2314C147.57 89.8449 148.794 88.6725 149.884 88.2145Z",
+ },
+ {
+ fill: "black",
+ d: "M49.2778 86.8344C50.519 86.7194 51.7894 87.0691 52.2428 88.3998C52.7233 89.8102 51.3898 91.0532 50.5584 92.0341C48.087 94.9484 46.1105 98.3879 45.0707 102.098C44.3558 104.57 44.6661 106.785 41.7475 107.509C36.316 107.254 39.0389 99.06 40.4495 96.2802C42.258 92.7165 45.4048 88.1993 49.2778 86.8344Z",
+ },
+];
+
+export const MASCOT_EYES = [
+ {
+ cx: 75.2,
+ cy: 80.3,
+ eye: "M73.7214 71.8676C83.7387 71.0222 85.5635 86.8699 75.4493 88.6643C71.2227 89.1109 67.9506 86.2354 67.1669 82.1089C66.7187 79.6993 67.2337 77.2087 68.5988 75.1843C69.8864 73.3007 71.5174 72.2857 73.7214 71.8676Z",
+ glint:
+ "M74.1109 74.2802C75.2342 74.0686 76.3163 74.8128 76.5366 75.9485C76.7568 77.0843 76.0332 78.1873 74.9143 78.422C74.1804 78.577 73.4214 78.3195 72.9266 77.7489C72.4319 77.1786 72.2776 76.3831 72.5226 75.6656C72.7675 74.9479 73.374 74.419 74.1109 74.2802Z",
+ },
+ {
+ cx: 125.6,
+ cy: 80.3,
+ eye: "M125.08 71.8691C126.727 71.7515 128.362 72.2122 129.712 73.1736C135.478 77.2789 134.071 87.4996 126.283 88.7973C121.912 88.9989 118.722 86.0186 118.125 81.6916C117.798 79.2684 118.429 76.8132 119.88 74.8593C121.234 73.0455 122.895 72.19 125.08 71.8691Z",
+ glint:
+ "M124.672 74.4084C125.787 74.1129 126.928 74.7914 127.216 75.9223C127.505 77.0531 126.831 78.206 125.714 78.4954C124.601 78.7824 123.468 78.1046 123.181 76.9781C122.895 75.8519 123.56 74.7027 124.672 74.4084Z",
+ },
+];
diff --git a/packages/react-ui/src/components/AgentInterface/components/welcomeMascot.scss b/packages/react-ui/src/components/AgentInterface/components/welcomeMascot.scss
new file mode 100644
index 000000000..6c94fb935
--- /dev/null
+++ b/packages/react-ui/src/components/AgentInterface/components/welcomeMascot.scss
@@ -0,0 +1,53 @@
+// Welcome mascot (components/WelcomeMascot.tsx): blink, cursor-following eyes
+// and a squish on click. All motion is off under prefers-reduced-motion.
+
+.openui-agent-welcome-mascot {
+ display: block;
+ width: 98px;
+ height: auto;
+ overflow: visible;
+ cursor: pointer;
+ -webkit-tap-highlight-color: transparent;
+
+ .openui-agent-container--mobile & {
+ width: 72px;
+ }
+}
+
+.openui-agent-welcome-mascot__lid {
+ transform-box: view-box;
+ transition: transform 90ms ease-in;
+
+ &[data-blinking] {
+ transform: scaleY(0.1);
+ }
+}
+
+.openui-agent-welcome-mascot__body--squish {
+ transform-box: view-box;
+ transform-origin: 100px 158px;
+ animation: openui-agent-mascot-squish 600ms ease-in-out;
+}
+
+@keyframes openui-agent-mascot-squish {
+ 0% {
+ transform: scale(1, 1);
+ }
+ 30% {
+ transform: scale(1.025, 0.97);
+ }
+ 60% {
+ transform: scale(0.99, 1.012);
+ }
+ 100% {
+ transform: scale(1, 1);
+ }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .openui-agent-welcome-mascot__lid,
+ .openui-agent-welcome-mascot__body--squish {
+ transition: none;
+ animation: none;
+ }
+}
diff --git a/packages/react-ui/src/components/AgentInterface/components/welcomePrefillChips.scss b/packages/react-ui/src/components/AgentInterface/components/welcomePrefillChips.scss
index e093ad33b..e93c5fecd 100644
--- a/packages/react-ui/src/components/AgentInterface/components/welcomePrefillChips.scss
+++ b/packages/react-ui/src/components/AgentInterface/components/welcomePrefillChips.scss
@@ -15,7 +15,7 @@
grid-area: 1 / 1;
flex-direction: column;
align-items: center;
- gap: cssUtils.$space-2xl;
+ gap: cssUtils.$space-m;
width: 100%;
&[data-hidden] {
@@ -24,36 +24,45 @@
}
}
+// Centred tab row: a leading starters tab plus one tab per prompt template.
.openui-agent-welcome-screen__chip-row {
display: flex;
- justify-content: flex-start;
+ justify-content: center;
flex-wrap: wrap;
- gap: cssUtils.$space-s;
+ gap: cssUtils.$space-3xs;
width: 100%;
- max-width: 768px;
}
+$prefill-tab-muted: color-mix(in oklch, #{cssUtils.$text-neutral-primary} 60%, transparent);
+
.openui-agent-prefill-chip {
appearance: none;
display: inline-flex;
align-items: center;
- gap: cssUtils.$space-xs;
- padding: cssUtils.$space-s cssUtils.$space-m;
- border: 1px solid cssUtils.$border-interactive;
+ height: 32px;
+ padding: 0 cssUtils.$space-m;
+ border: none;
border-radius: cssUtils.$radius-full;
- background: cssUtils.$highlight-subtle;
- color: cssUtils.$text-neutral-secondary;
- @include cssUtils.typography(label, small);
+ background: transparent;
+ color: $prefill-tab-muted;
+ font-family: inherit;
+ font-size: 12px;
+ font-weight: 400;
+ font-variation-settings: cssUtils.$font-variation-regular;
+ line-height: 12px;
cursor: pointer;
transition:
background-color 0.15s ease,
- border-color 0.15s ease,
box-shadow 0.15s ease,
color 0.15s ease;
&:not(:disabled):hover {
- background: cssUtils.$highlight;
- border-color: cssUtils.$border-interactive-emphasis;
+ color: cssUtils.$text-neutral-primary;
+ }
+
+ &[aria-selected="true"] {
+ background-color: cssUtils.$foreground; // same surface as the card
+ box-shadow: inset 0 0 0 1px cssUtils.$border-default;
color: cssUtils.$text-neutral-primary;
}
@@ -72,9 +81,17 @@
align-items: center;
justify-content: center;
flex-shrink: 0;
+ width: 14px;
+ height: 14px;
+
+ & > svg {
+ width: 14px;
+ height: 14px;
+ }
}
&__label {
+ padding: 0 cssUtils.$space-xs;
white-space: nowrap;
}
}
diff --git a/packages/react-ui/src/components/AgentInterface/conversationStarter.scss b/packages/react-ui/src/components/AgentInterface/conversationStarter.scss
index 3f4765d44..92366112a 100644
--- a/packages/react-ui/src/components/AgentInterface/conversationStarter.scss
+++ b/packages/react-ui/src/components/AgentInterface/conversationStarter.scss
@@ -1,12 +1,12 @@
@use "../../cssUtils" as cssUtils;
+@use "./column";
// Container styles
.openui-agent-conversation-starter {
width: 100%;
- // Starters sit above the composer input, so track the composer's 768px
- // column (see components/composer.scss), not the 880px thread column —
- // otherwise the row starts left of the input once both hit max-width.
- max-width: calc(768px + cssUtils.$space-m-l * 2);
+ // Starters sit above the composer input, so track the composer's
+ // column (see components/composer.scss) so the row lines up with the input.
+ max-width: calc(#{column.$content-width} + #{cssUtils.$space-m-l} * 2);
margin: 0 auto;
padding: 0 cssUtils.$space-m-l cssUtils.$space-m;
box-sizing: border-box;
@@ -32,6 +32,14 @@
margin-bottom: cssUtils.$space-m;
}
+ // Card variant - a row of equal-width cards, inset from the composer edges.
+ &--card {
+ display: flex;
+ align-items: stretch;
+ gap: cssUtils.$space-xs;
+ padding: 0 cssUtils.$space-m;
+ }
+
&__carousel-content {
gap: cssUtils.$space-xs;
}
@@ -180,3 +188,67 @@
background-color: cssUtils.$highlight-subtle;
}
}
+
+// Card variant item (icon above wrapping text)
+$starter-muted: color-mix(in oklch, #{cssUtils.$text-neutral-primary} 60%, transparent);
+.openui-agent-conversation-starter-item-card {
+ appearance: none;
+ display: flex;
+ flex: 1 1 0;
+ min-width: 0;
+ flex-direction: column;
+ align-items: flex-start;
+ gap: cssUtils.$space-m;
+ padding: cssUtils.$space-m-l;
+ background-color: cssUtils.$sunk-light;
+ border: none;
+ border-radius: cssUtils.$radius-3xl;
+ cursor: pointer;
+ transition: background-color 0.15s ease;
+ font-family: inherit;
+ font-size: 14px;
+ line-height: 20px;
+ color: $starter-muted;
+ text-align: left;
+
+ &__icon {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ flex-shrink: 0;
+ width: 16px;
+ height: 16px;
+ color: $starter-muted;
+
+ & > svg {
+ width: 16px;
+ height: 16px;
+ }
+ }
+
+ // Two lines max; longer copy ends with an ellipsis.
+ &__text {
+ display: -webkit-box;
+ min-width: 0;
+ overflow: hidden;
+ -webkit-box-orient: vertical;
+ -webkit-line-clamp: 2;
+ line-clamp: 2;
+ }
+
+ &:not(:disabled):hover {
+ background-color: cssUtils.$sunk;
+ color: cssUtils.$text-neutral-primary;
+ }
+
+ &:focus-visible {
+ outline: none;
+ box-shadow: 0 0 0 2.5px cssUtils.$border-default;
+ }
+}
+
+// The welcome screen zeroes starter padding; keep the card row's inset.
+.openui-agent-welcome-screen__desktop-starters
+ .openui-agent-conversation-starter.openui-agent-conversation-starter--card {
+ padding: 0 cssUtils.$space-m;
+}
diff --git a/packages/react-ui/src/components/AgentInterface/historyMenu.scss b/packages/react-ui/src/components/AgentInterface/historyMenu.scss
new file mode 100644
index 000000000..5fcc27d75
--- /dev/null
+++ b/packages/react-ui/src/components/AgentInterface/historyMenu.scss
@@ -0,0 +1,53 @@
+@use "../../cssUtils" as cssUtils;
+@use "../menu";
+
+// Thread history menu opened from the collapsed rail, in the shared menu look.
+.openui-agent-history-menu {
+ z-index: 10000;
+ width: min(283px, calc(100vw - 32px));
+ max-height: min(420px, var(--radix-dropdown-menu-content-available-height, 420px));
+ overflow: auto;
+ outline: none;
+ @include menu.surface;
+
+ &__label {
+ @include menu.label;
+ }
+
+ &__item {
+ @include cssUtils.typography(label, small);
+
+ @include menu.item;
+ // Secondary like the sidebar's thread titles; the highlighted and the open
+ // thread step up to primary.
+ color: cssUtils.$text-neutral-secondary;
+ cursor: pointer;
+ user-select: none;
+
+ &[data-highlighted] {
+ background-color: cssUtils.$highlight;
+ color: cssUtils.$text-neutral-primary;
+ }
+
+ &--selected,
+ &--selected[data-highlighted] {
+ background-color: cssUtils.$sunk;
+ color: cssUtils.$text-neutral-primary;
+ }
+ }
+
+ &__title {
+ min-width: 0;
+ flex: 1 1 auto;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ &__empty {
+ @include cssUtils.typography(label, small);
+
+ padding: cssUtils.$space-s menu.$inset-x;
+ color: cssUtils.$text-neutral-secondary;
+ }
+}
diff --git a/packages/react-ui/src/components/AgentInterface/index.ts b/packages/react-ui/src/components/AgentInterface/index.ts
index c749db8bd..2b180da04 100644
--- a/packages/react-ui/src/components/AgentInterface/index.ts
+++ b/packages/react-ui/src/components/AgentInterface/index.ts
@@ -7,8 +7,12 @@ export { AgentInterface } from "./AgentInterface";
export type { AgentInterfaceComponents, AgentInterfaceProps } from "./AgentInterface";
export { ArtifactNav } from "./ArtifactNav";
export type { ArtifactNavProps } from "./ArtifactNav";
+export { WelcomeMascot } from "./components/WelcomeMascot";
export type { RouteProps } from "./Route";
export { SidebarItem } from "./SidebarItem";
export type { SidebarItemProps } from "./SidebarItem";
+export { ThemeModeToggle } from "./ThemeModeToggle";
+export type { ThemeModeToggleProps } from "./ThemeModeToggle";
+export type { ThreadHeaderProps } from "./ThreadHeader";
export { WelcomeGlow } from "./WelcomeGlow";
export type { WorkspaceProps } from "./Workspace";
diff --git a/packages/react-ui/src/components/AgentInterface/mobileHeader.scss b/packages/react-ui/src/components/AgentInterface/mobileHeader.scss
index e2aa2571d..962d651bb 100644
--- a/packages/react-ui/src/components/AgentInterface/mobileHeader.scss
+++ b/packages/react-ui/src/components/AgentInterface/mobileHeader.scss
@@ -40,3 +40,17 @@
align-items: center;
gap: cssUtils.$space-s;
}
+
+// Matches the collapsed rail's round New chat button.
+.openui-agent-container .openui-agent-mobile-header-new-chat.openui-icon-button {
+ border-color: transparent;
+ border-radius: cssUtils.$radius-full;
+ background-color: cssUtils.$inverted-background;
+ color: cssUtils.$foreground;
+
+ &:not(:disabled):hover,
+ &:not(:disabled):active {
+ background-color: cssUtils.$inverted-background;
+ opacity: 0.85;
+ }
+}
diff --git a/packages/react-ui/src/components/AgentInterface/renameChatDialog.scss b/packages/react-ui/src/components/AgentInterface/renameChatDialog.scss
new file mode 100644
index 000000000..4a2046778
--- /dev/null
+++ b/packages/react-ui/src/components/AgentInterface/renameChatDialog.scss
@@ -0,0 +1,76 @@
+@use "../../cssUtils" as cssUtils;
+
+.openui-agent-rename-dialog__overlay {
+ position: fixed;
+ inset: 0;
+ z-index: 10000;
+ // 30% of the theme overlay: a light dim in light mode, a deeper one in dark.
+ background: color-mix(in oklch, cssUtils.$overlay 30%, transparent);
+}
+
+// Same soft surface as the shared menus (ring + layered shadow, no border).
+.openui-agent-rename-dialog {
+ position: fixed;
+ top: 50%;
+ left: 50%;
+ z-index: 10001;
+ width: min(400px, calc(100vw - 32px));
+ transform: translate(-50%, -50%);
+ padding: cssUtils.$space-m-l;
+ border-radius: cssUtils.$radius-3xl;
+ background-color: color-mix(in oklch, cssUtils.$foreground, cssUtils.$text-white 6%);
+ color: cssUtils.$text-neutral-primary;
+ box-shadow:
+ 0 0 0 1px color-mix(in oklch, #{cssUtils.$text-neutral-primary} 6%, transparent),
+ 0 4px 12px -2px oklch(0 0 0 / 0.05),
+ 0 24px 48px -12px oklch(0 0 0 / 0.12);
+
+ &:focus {
+ outline: none;
+ }
+
+ &__form {
+ display: flex;
+ flex-direction: column;
+ gap: cssUtils.$space-m;
+ }
+
+ &__title {
+ margin: 0;
+ font-size: 16px;
+ font-weight: 500;
+ font-variation-settings: normal;
+ line-height: 24px;
+ }
+
+ &__input {
+ width: 100%;
+ }
+
+ &__actions {
+ display: flex;
+ justify-content: flex-end;
+ gap: cssUtils.$space-s;
+ }
+
+ // Neutral black primary, matching the composer's send button (no brand blue).
+ &__actions .openui-button-base.openui-button-base-primary {
+ border-color: transparent;
+ border-radius: cssUtils.$radius-full;
+ background-color: cssUtils.$inverted-background;
+ color: cssUtils.$foreground;
+
+ &:not(:disabled):hover {
+ background-color: cssUtils.$inverted-background;
+ opacity: 0.85;
+ }
+
+ &:disabled {
+ opacity: 0.3;
+ }
+ }
+
+ &__actions .openui-button-base-tertiary {
+ border-radius: cssUtils.$radius-full;
+ }
+}
diff --git a/packages/react-ui/src/components/AgentInterface/sidebar.scss b/packages/react-ui/src/components/AgentInterface/sidebar.scss
index cd88d6c24..785d86772 100644
--- a/packages/react-ui/src/components/AgentInterface/sidebar.scss
+++ b/packages/react-ui/src/components/AgentInterface/sidebar.scss
@@ -5,10 +5,16 @@ $sidebar-padding-y: cssUtils.$space-m-l;
$sidebar-padding-x: cssUtils.$space-m;
$sidebar-header-inline-offset: 0px;
$sidebar-collapsed-control-size: 32px;
+// Expanded nav rows (New Chat) run a step smaller than the rail's buttons, to
+// match the 12px nav type.
+$sidebar-nav-row-height: 28px;
+$sidebar-nav-icon-size: 14px;
$sidebar-logo-size: 30px;
+$sidebar-collapsed-padding-x: 18px;
+$sidebar-collapsed-mark-width: 36px;
$sidebar-collapsed-width: calc(
- #{$sidebar-collapsed-control-size} + #{$sidebar-padding-x} + #{$sidebar-padding-x} +
- #{$sidebar-header-inline-offset}
+ #{$sidebar-collapsed-control-size} + #{$sidebar-collapsed-padding-x} +
+ #{$sidebar-collapsed-padding-x} + #{$sidebar-header-inline-offset}
);
$sidebar-mobile-width: 294px;
$sidebar-mobile-padding-y: cssUtils.$space-l;
@@ -17,18 +23,21 @@ $sidebar-fade-duration: 90ms;
$sidebar-resize-duration: 160ms;
$sidebar-mobile-slide-duration: 400ms;
$sidebar-motion-ease: cubic-bezier(0.22, 1, 0.36, 1);
-$sidebar-shadow: inset -10px 0 18px -18px cssUtils.$sunk-deep;
+// The brand and toggle cross-fade a touch slower than the body text so the
+// swap between mascot and wordmark reads as one move, not a blink.
+$sidebar-header-fade-duration: 140ms;
.openui-agent-sidebar-container {
- border-right: 1px solid cssUtils.$border-default;
+ position: relative;
height: 100%;
- width: $sidebar-width;
+ // Set by SidebarResizeEdge when the edge is dragged.
+ width: var(--openui-agent-sidebar-width, #{$sidebar-width});
padding: $sidebar-padding-y $sidebar-padding-x;
display: flex;
flex-direction: column;
gap: cssUtils.$space-2xl;
- background-color: cssUtils.$highlight-subtle;
- box-shadow: $sidebar-shadow;
+ // Sits directly on the shell surface; the thread card provides the edge.
+ background-color: transparent;
z-index: 999;
transition:
width $sidebar-resize-duration $sidebar-motion-ease,
@@ -51,9 +60,10 @@ $sidebar-shadow: inset -10px 0 18px -18px cssUtils.$sunk-deep;
&--collapsed {
width: $sidebar-collapsed-width;
+ padding: cssUtils.$space-m-l $sidebar-collapsed-padding-x;
transform: translateX(0);
- background-color: cssUtils.$foreground;
- cursor: e-resize;
+ background-color: transparent;
+ cursor: default;
.openui-agent-container--mobile & {
width: $sidebar-mobile-width;
@@ -68,6 +78,11 @@ $sidebar-shadow: inset -10px 0 18px -18px cssUtils.$sunk-deep;
display: none;
}
+ // Follow the pointer while the edge is dragged, no easing.
+ &--resizing {
+ transition: none;
+ }
+
&[data-sidebar-visual-state="collapsing"],
&[data-sidebar-visual-state="expanding"] {
.openui-agent-sidebar-content,
@@ -78,6 +93,21 @@ $sidebar-shadow: inset -10px 0 18px -18px cssUtils.$sunk-deep;
opacity: 0;
pointer-events: none;
}
+
+ // The wordmark eases in from where the mascot sat.
+ .openui-agent-sidebar-header__agent-name {
+ transform: translateX(-6px);
+ }
+
+ // Mascot and toggle both stand aside while the width moves: the mascot
+ // fades before the rail grows and fades back once it has shrunk, and the
+ // toggle appears only once it has reached its resting edge, instead of
+ // popping in at the rail and sliding across.
+ .openui-agent-sidebar-header__logo,
+ .openui-agent-sidebar-header__toggle-button {
+ opacity: 0;
+ pointer-events: none;
+ }
}
}
@@ -110,7 +140,7 @@ $sidebar-shadow: inset -10px 0 18px -18px cssUtils.$sunk-deep;
align-self: flex-start;
flex-shrink: 0;
border-radius: cssUtils.$radius-s;
- transition: opacity $sidebar-fade-duration $sidebar-motion-ease;
+ transition: opacity $sidebar-header-fade-duration $sidebar-motion-ease;
.openui-agent-container--mobile & {
width: 36px;
@@ -128,7 +158,9 @@ $sidebar-shadow: inset -10px 0 18px -18px cssUtils.$sunk-deep;
color: cssUtils.$text-neutral-primary;
text-overflow: ellipsis;
white-space: nowrap;
- transition: opacity $sidebar-fade-duration $sidebar-motion-ease;
+ transition:
+ opacity $sidebar-header-fade-duration $sidebar-motion-ease,
+ transform $sidebar-header-fade-duration $sidebar-motion-ease;
.openui-agent-sidebar-container--collapsed & {
display: none;
@@ -137,6 +169,25 @@ $sidebar-shadow: inset -10px 0 18px -18px cssUtils.$sunk-deep;
.openui-agent-container--mobile & {
@include cssUtils.typography(label, large);
}
+
+ // An image wordmark (e.g. `agentName={<img … />}`) at the row's height.
+ img {
+ display: block;
+ height: 28px;
+ width: auto;
+ }
+ }
+
+ // The logo is the collapsed rail's mark; expanded, the agent name takes its
+ // place, inset to line up with the New Chat icon below it.
+ &:not(&--collapsed) {
+ .openui-agent-sidebar-header__logo {
+ display: none;
+ }
+
+ .openui-agent-sidebar-header__agent-name {
+ padding-left: cssUtils.$space-s;
+ }
}
&--collapsed {
@@ -157,6 +208,17 @@ $sidebar-shadow: inset -10px 0 18px -18px cssUtils.$sunk-deep;
left: 0;
}
+ // The brand mark is wider than the 32px control column; centre it on
+ // the column so it lines up with the round actions below.
+ .openui-agent-sidebar-header__logo {
+ width: $sidebar-collapsed-mark-width;
+ max-width: none;
+ height: auto;
+ margin-left: 0;
+ left: calc((#{$sidebar-collapsed-control-size} - #{$sidebar-collapsed-mark-width}) / 2);
+ border-radius: 0;
+ }
+
// Hide the toggle button at rest ONLY when a logo fills the slot (detected
// with :has) — the logo is the resting face and the button appears on hover.
// With no logo the slot is empty, so the button stays visible at rest
@@ -169,7 +231,7 @@ $sidebar-shadow: inset -10px 0 18px -18px cssUtils.$sunk-deep;
}
.openui-agent-sidebar-content {
- width: calc(#{$sidebar-width} - (#{$sidebar-padding-x} * 2));
+ width: calc(var(--openui-agent-sidebar-width, #{$sidebar-width}) - (#{$sidebar-padding-x} * 2));
flex: 1;
min-height: 0;
@@ -200,20 +262,21 @@ $sidebar-shadow: inset -10px 0 18px -18px cssUtils.$sunk-deep;
}
.openui-agent-sidebar-header__toggle-button {
- transition: opacity $sidebar-fade-duration $sidebar-motion-ease;
+ transition: opacity $sidebar-header-fade-duration $sidebar-motion-ease;
.openui-agent-container--mobile & {
display: none;
}
}
-// Collapsed rail: logo at rest, open button on hover or keyboard focus. Key off
-// the binary --collapsed class (the same isCollapsedLayout state that hides the
-// button above), never data-sidebar-visual-state — its transitional values open
+// Collapsed rail: logo at rest, open button on hovering the logo's slot (not
+// the whole rail) or keyboard focus. Key off the binary --collapsed class (the
+// same isCollapsedLayout state that hides the button above), never
+// data-sidebar-visual-state — its transitional values open
// a window where the button is hidden but cannot be revealed. Keyboard focus is
// matched via :focus-visible so the residual focus a mouse click leaves on the
// toggle doesn't pin the button over the logo at rest.
-.openui-agent-sidebar-container--collapsed:hover,
+.openui-agent-sidebar-container--collapsed .openui-agent-sidebar-header__top-row:hover,
.openui-agent-sidebar-container--collapsed:has(:focus-visible) {
.openui-agent-sidebar-header__logo {
opacity: 0;
@@ -261,7 +324,7 @@ $sidebar-shadow: inset -10px 0 18px -18px cssUtils.$sunk-deep;
.openui-agent-sidebar-item {
@include cssUtils.button-reset;
- @include cssUtils.typography(label, small);
+ @include cssUtils.typography(label, extra-small);
display: flex;
align-items: center;
@@ -288,7 +351,7 @@ $sidebar-shadow: inset -10px 0 18px -18px cssUtils.$sunk-deep;
&--selected,
&--selected:not(:disabled):hover {
- background-color: cssUtils.$sunk;
+ background-color: cssUtils.$sunk-deep;
}
.openui-agent-sidebar-container--collapsed & {
@@ -309,13 +372,13 @@ $sidebar-shadow: inset -10px 0 18px -18px cssUtils.$sunk-deep;
background-color: transparent;
.openui-agent-sidebar-item__icon {
- background-color: cssUtils.$sunk;
+ background-color: cssUtils.$sunk-deep;
}
}
&.openui-agent-sidebar-item--selected:not(:disabled):hover {
.openui-agent-sidebar-item__icon {
- background-color: cssUtils.$sunk;
+ background-color: cssUtils.$sunk-deep;
}
}
}
@@ -377,3 +440,105 @@ $sidebar-shadow: inset -10px 0 18px -18px cssUtils.$sunk-deep;
opacity: 0;
}
}
+
+// SidebarFooter: pinned under the thread list. The container's 36px gap is
+// pulled in to 8px so the footer sits close to the list's faded bottom edge.
+.openui-agent-sidebar-footer {
+ display: flex;
+ flex-direction: column;
+ gap: cssUtils.$space-2xs;
+ flex-shrink: 0;
+ margin-top: calc(#{cssUtils.$space-s} - #{cssUtils.$space-2xl});
+
+ .openui-agent-container--mobile & {
+ margin-top: 0;
+ padding: 0 cssUtils.$space-m-l;
+ }
+}
+
+// Draggable right edge (SidebarResizeEdge). No visual of its own.
+.openui-agent-sidebar-resize-edge {
+ position: absolute;
+ top: 0;
+ right: -4px;
+ bottom: 0;
+ width: 8px;
+ z-index: 1;
+ cursor: col-resize;
+ touch-action: none;
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .openui-agent-sidebar-container,
+ .openui-agent-sidebar-header__logo,
+ .openui-agent-sidebar-header__agent-name,
+ .openui-agent-sidebar-header__toggle-button {
+ transition: none;
+ }
+
+ .openui-agent-sidebar-container[data-sidebar-visual-state]
+ .openui-agent-sidebar-header__agent-name {
+ transform: none;
+ }
+}
+
+// Expanded New Chat is a plain nav item laid out like a thread row: its icon
+// shares the thread icons' column and its label the thread titles' column.
+// The 28px box is pulled 1px left so the 14px glyph inside it lands on that
+// column, and the 1px gap puts the label on the titles' column. It shows as
+// selected while on a fresh chat.
+.openui-agent-sidebar-container
+ .openui-agent-new-chat-button:not(.openui-agent-new-chat-button--collapsed) {
+ @include cssUtils.typography(label, small);
+
+ // Bleed 6px past the column each side (padding puts the content back) so
+ // the selected/hover rect has room around the icon and label.
+ width: calc(100% + 12px);
+ height: $sidebar-nav-row-height;
+ // The 2px top and bottom keep its centre level with the rail's 32px button.
+ margin: 2px -6px;
+ padding-left: 6px;
+ gap: 1px;
+ border-radius: calc(cssUtils.$radius-s + 3px);
+
+ &.openui-agent-new-chat-button--selected,
+ &.openui-agent-new-chat-button--selected:hover {
+ background-color: cssUtils.$sunk-deep;
+ }
+
+ .openui-agent-new-chat-button__icon {
+ width: $sidebar-nav-row-height;
+ height: $sidebar-nav-row-height;
+ margin: 0 0 0 -1px;
+ font-size: $sidebar-nav-icon-size;
+ }
+}
+
+// Open sidebar uses the rail's 12px gap under the header too, so New Chat
+// sits at the same height whether the sidebar is open or collapsed.
+.openui-agent-container:not(.openui-agent-container--mobile) .openui-agent-sidebar-actions {
+ gap: cssUtils.$space-m;
+}
+
+// Tighter step from the actions (New Chat) down to the Threads list.
+.openui-agent-container:not(.openui-agent-container--mobile) .openui-agent-sidebar-container {
+ gap: cssUtils.$space-l;
+}
+
+// Room for the thread rows' 6px bleed: the content area and the thread list
+// both clip, so each grows 6px past the column with padding putting their
+// children back in place.
+.openui-agent-container:not(.openui-agent-container--mobile) {
+ .openui-agent-sidebar-content:not(.openui-agent-sidebar-content--collapsed) {
+ width: calc(
+ var(--openui-agent-sidebar-width, #{$sidebar-width}) - (#{$sidebar-padding-x} * 2) + 12px
+ );
+ margin: 0 -6px;
+ padding: 0 6px;
+ }
+
+ .openui-agent-sidebar-content .openui-agent-thread-list {
+ margin: 0 -6px;
+ padding: 0 6px;
+ }
+}
diff --git a/packages/react-ui/src/components/AgentInterface/themeModeToggle.scss b/packages/react-ui/src/components/AgentInterface/themeModeToggle.scss
new file mode 100644
index 000000000..bdd9feb9c
--- /dev/null
+++ b/packages/react-ui/src/components/AgentInterface/themeModeToggle.scss
@@ -0,0 +1,39 @@
+@use "../../cssUtils" as cssUtils;
+
+// ThemeModeToggle (ThemeModeToggle.tsx): a round 32px icon button, the rail's
+// button size, in the sidebar footer. Expanded, it is pulled 3px left so its
+// glyph sits on the nav icons' column; on the collapsed rail it fills the
+// control column like the buttons above it.
+.openui-agent-theme-toggle {
+ @include cssUtils.button-reset;
+
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 32px;
+ height: 32px;
+ margin-left: -3px;
+ flex-shrink: 0;
+ border-radius: cssUtils.$radius-full;
+ color: cssUtils.$text-neutral-secondary;
+ font-size: 14px;
+ cursor: pointer;
+ transition:
+ background-color 90ms cubic-bezier(0.22, 1, 0.36, 1),
+ color 90ms cubic-bezier(0.22, 1, 0.36, 1);
+
+ &:hover {
+ background-color: cssUtils.$highlight-strong;
+ color: cssUtils.$text-neutral-primary;
+ }
+
+ &:focus-visible {
+ outline: 2px solid cssUtils.$border-interactive;
+ outline-offset: 2px;
+ }
+
+ .openui-agent-sidebar-container--collapsed &,
+ .openui-agent-container--mobile & {
+ margin-left: 0;
+ }
+}
diff --git a/packages/react-ui/src/components/AgentInterface/thread.scss b/packages/react-ui/src/components/AgentInterface/thread.scss
index 58a7ff1e1..2b18763b1 100644
--- a/packages/react-ui/src/components/AgentInterface/thread.scss
+++ b/packages/react-ui/src/components/AgentInterface/thread.scss
@@ -1,4 +1,5 @@
@use "../../cssUtils" as cssUtils;
+@use "./column";
// =============================================================================
// Thread Layout Structure
@@ -13,6 +14,15 @@
overflow: hidden;
display: flex;
flex-direction: column;
+
+ // Desktop: the thread is a rounded card inset from the shell, with the
+ // sidebar rail sitting on the shell beside it.
+ .openui-agent-container:not(.openui-agent-container--mobile) > & {
+ margin: cssUtils.$space-2xs cssUtils.$space-2xs cssUtils.$space-2xs 0;
+ border-radius: cssUtils.$radius-3xl;
+ outline: 1px solid cssUtils.$sunk; // 4% ink: a light edge on the shell
+ background-color: cssUtils.$foreground;
+ }
}
// Full-screen loading overlay while a thread's messages load. The container
@@ -132,7 +142,7 @@ $top-mask-height: calc(cssUtils.$space-l + cssUtils.$space-3xs);
$bottom-mask-height: calc(cssUtils.$space-2xl + cssUtils.$space-2xl);
$thread-content-inline-padding: cssUtils.$space-m-l;
$thread-content-max-width: calc(
- 880px + #{$thread-content-inline-padding} + #{$thread-content-inline-padding}
+ #{column.$content-width} + #{$thread-content-inline-padding} + #{$thread-content-inline-padding}
);
.openui-agent-thread-scroll-container {
@@ -335,16 +345,24 @@ $thread-content-max-width: calc(
padding-right: 0;
}
+ // Filled pill (same fill as the send and New chat buttons), one type step
+ // down (body small). The radius is half a single-line bubble's height, so
+ // one line reads as a full pill and longer messages keep rounded corners.
&__content {
- @include cssUtils.typography(body, default);
- padding: cssUtils.$space-s cssUtils.$space-m calc(cssUtils.$space-s + 1px) cssUtils.$space-m;
- background-color: cssUtils.$chat-user-response-bg;
- color: cssUtils.$chat-user-response-text;
- border-radius: cssUtils.$radius-xl;
+ @include cssUtils.typography(body, small);
+ padding: cssUtils.$space-s cssUtils.$space-m-l calc(cssUtils.$space-s + 1px);
+ background-color: cssUtils.$inverted-background;
+ color: cssUtils.$foreground;
+ border-radius: cssUtils.$radius-4xl;
white-space: pre-wrap;
overflow-wrap: break-word;
max-width: 100%;
height: fit-content;
+
+ // Wrapped text gets more room above and below; one line stays a pill.
+ &[data-multiline] {
+ padding-block: cssUtils.$space-m;
+ }
}
// Attachments rendered inside the user bubble (images, audio/video, file chips)
@@ -424,49 +442,26 @@ $thread-content-max-width: calc(
}
}
-// =============================================================================
-// Thread Header
-// =============================================================================
-$thread-header-action-min-height: 32px;
-
-.openui-agent-thread-header {
+.openui-agent-thread-message-loading {
display: flex;
align-items: center;
- justify-content: space-between;
- gap: cssUtils.$space-m;
- padding: cssUtils.$space-m-l cssUtils.$space-m-l cssUtils.$space-xs;
- flex-shrink: 0;
-
- .openui-agent-container--mobile & {
- display: none;
- }
-
- &__title {
- @include cssUtils.typography(label, small);
-
- flex: 1;
- min-width: 0;
- overflow: hidden;
- color: cssUtils.$text-neutral-primary;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
-
- &__actions {
- display: flex;
- align-items: center;
- gap: cssUtils.$space-s;
- flex-shrink: 0;
- min-height: $thread-header-action-min-height;
- }
+ // Same line box as the "Working" row (toolCall.scss toggle), so the mascot
+ // sits at the same spot when that row takes over.
+ @include cssUtils.typography(body, small);
+ min-height: 1lh;
+}
- .openui-agent-thread-container--detailed-view-active &__workspace-toggle-button {
- display: none;
- }
+// The timeline belongs to the answer below it, so it sits closer to that answer
+// than the list's gap between messages.
+.openui-agent-thread-messages > .openui-behind-the-scenes {
+ margin-block-end: calc(#{cssUtils.$space-m} - 2 * #{cssUtils.$space-l});
}
-.openui-agent-thread-message-loading {
- display: flex;
+// A live "Working" timeline already shows the mascot in its own row, so the
+// separate loader below it would be a duplicate.
+.openui-agent-thread-messages:has(.openui-behind-the-scenes--working)
+ .openui-agent-thread-message-loading {
+ display: none;
}
// =============================================================================
@@ -546,3 +541,110 @@ $thread-header-action-min-height: 32px;
overflow-wrap: break-word;
min-width: 0;
}
+
+// =============================================================================
+// Full-height conversation scroll
+// =============================================================================
+// In a conversation the scroll area runs the full height of the panel: the
+// chat header floats over its top and the composer over its bottom. The
+// scroll content pads by their heights so the first and last messages still
+// clear them, and a mask softly fades messages out as they pass beneath.
+// (The welcome screen keeps the stacked layout.)
+$floating-fade: 40px;
+// The header floats over the messages: they stay visible beneath it, dimmed
+// to $floating-top-min-alpha at the very top and fully opaque just below it.
+$floating-top-fade: 12px;
+$floating-top-min-alpha: 0.3;
+
+// Eased fade: alpha stops along a smooth S-curve, so content dissolves
+// gradually instead of along a hard linear ramp.
+$fade-curve: 0, 0.03, 0.1, 0.22, 0.4, 0.6, 0.78, 0.9, 0.97, 1;
+
+@function eased-stops($from, $to, $reverse: false, $min: 0) {
+ $stops: ();
+ $count: length($fade-curve) - 1;
+ @for $i from 0 through $count {
+ $alpha: $min + (1 - $min) * nth($fade-curve, $i + 1);
+ @if $reverse {
+ $alpha: 1 - $alpha;
+ }
+ $stops: append(
+ $stops,
+ rgba(0, 0, 0, $alpha) calc(#{$from} + (#{$to} - #{$from}) * #{$i / $count}),
+ comma
+ );
+ }
+ @return $stops;
+}
+$floating-header-height: 48px;
+
+// Scoped under the containers so these win over the stacked-layout padding
+// rules above.
+.openui-agent-container
+ .openui-agent-thread-container
+ .openui-agent-thread-chat-panel:not(:has(.openui-agent-welcome-screen)) {
+ --openui-agent-floating-top: 0px;
+ --openui-agent-floating-bottom: var(--openui-agent-composer-slot-height, 88px);
+
+ > .openui-agent-thread-header {
+ position: absolute;
+ top: 0;
+ left: 0;
+ right: 0;
+ z-index: 3;
+ background: transparent;
+ }
+
+ > .openui-agent-composer-slot {
+ position: absolute;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ z-index: 3;
+ }
+
+ .openui-agent-thread-scroll-container {
+ flex-grow: 1;
+
+ // The mask below replaces the solid overlay fades.
+ &::before,
+ &::after {
+ display: none;
+ }
+ }
+
+ .openui-agent-thread-scroll-area {
+ // Rest the first and last messages just inside the fully opaque band.
+ padding-top: calc(var(--openui-agent-floating-top) + #{$floating-top-fade});
+ padding-bottom: calc(var(--openui-agent-floating-bottom) + #{$floating-fade});
+ scroll-padding-top: calc(var(--openui-agent-floating-top) + #{$floating-top-fade});
+ scroll-padding-bottom: calc(var(--openui-agent-floating-bottom) + #{$floating-fade});
+ // Dimmed (not hidden) behind the header row, reaching full opacity just
+ // below it; at the bottom, fully hidden by the composer's top edge.
+ $top-end: calc(var(--openui-agent-floating-top) + #{$floating-top-fade});
+ $bottom-start: calc(100% - var(--openui-agent-floating-bottom) - #{$floating-fade});
+ $bottom-end: calc(100% - var(--openui-agent-floating-bottom) + 8px);
+ $mask: linear-gradient(
+ to bottom,
+ eased-stops(0px, $top-end, false, $floating-top-min-alpha),
+ eased-stops($bottom-start, $bottom-end, true),
+ transparent 100%
+ );
+ mask-image: $mask;
+ -webkit-mask-image: $mask;
+ }
+
+ .openui-agent-thread-scroll-latest {
+ bottom: calc(var(--openui-agent-floating-bottom) + #{cssUtils.$space-s});
+ }
+}
+
+// Reserve the header's height only on desktop; on mobile the chat header is
+// hidden and the in-flow mobile header sits above the scroll area instead.
+.openui-agent-container:not(.openui-agent-container--mobile)
+ .openui-agent-thread-container
+ .openui-agent-thread-chat-panel:not(:has(.openui-agent-welcome-screen)):has(
+ > .openui-agent-thread-header
+ ) {
+ --openui-agent-floating-top: #{$floating-header-height};
+}
diff --git a/packages/react-ui/src/components/AgentInterface/threadHeader.scss b/packages/react-ui/src/components/AgentInterface/threadHeader.scss
new file mode 100644
index 000000000..c00ce7fb3
--- /dev/null
+++ b/packages/react-ui/src/components/AgentInterface/threadHeader.scss
@@ -0,0 +1,93 @@
+@use "../../cssUtils" as cssUtils;
+@use "../menu";
+
+// Sidebar padding-y minus the thread card's top inset (see thread.scss), so
+// the header row centres on the sidebar logo row; used for the side inset too.
+$thread-header-inset: calc(#{cssUtils.$space-m-l} - #{cssUtils.$space-2xs});
+$thread-header-row-height: 32px;
+
+.openui-agent-thread-header {
+ display: grid;
+ grid-template-columns: 1fr auto 1fr;
+ align-items: center;
+ gap: cssUtils.$space-m;
+ min-height: calc(#{$thread-header-row-height} + #{$thread-header-inset});
+ padding: $thread-header-inset $thread-header-inset 0;
+ flex-shrink: 0;
+
+ .openui-agent-container--mobile & {
+ display: none;
+ }
+
+ &__start,
+ &__center,
+ &__end {
+ display: flex;
+ align-items: center;
+ gap: cssUtils.$space-s;
+ min-width: 0;
+ min-height: $thread-header-row-height;
+ }
+
+ &__start {
+ justify-content: flex-start;
+ }
+
+ &__center {
+ justify-content: center;
+ }
+
+ &__end {
+ justify-content: flex-end;
+ }
+
+ // Selected chat title, centred and truncated.
+ &__title {
+ display: flex;
+ align-items: center;
+ gap: cssUtils.$space-xs;
+ min-width: 0;
+ max-width: 360px;
+ color: cssUtils.$text-neutral-primary;
+ font-size: 14px;
+ line-height: 20px;
+ }
+
+ &__title-text {
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ &__actions-trigger {
+ border-radius: cssUtils.$radius-full;
+ }
+
+ .openui-agent-thread-container--detailed-view-active &__workspace-toggle-button {
+ display: none;
+ }
+}
+
+.openui-agent-thread-header__actions-menu {
+ min-width: 180px;
+ z-index: 9999;
+ @include menu.surface;
+}
+
+.openui-agent-thread-header__actions-item {
+ @include menu.item;
+ gap: cssUtils.$space-s;
+ font-size: 14px;
+ color: cssUtils.$text-neutral-primary;
+ cursor: default;
+ user-select: none;
+
+ &[data-highlighted] {
+ background-color: cssUtils.$highlight;
+ }
+
+ &--destructive {
+ color: cssUtils.$text-danger-primary;
+ }
+}
diff --git a/packages/react-ui/src/components/AgentInterface/threadlist.scss b/packages/react-ui/src/components/AgentInterface/threadlist.scss
index 6e2c259e3..8d8d42dcc 100644
--- a/packages/react-ui/src/components/AgentInterface/threadlist.scss
+++ b/packages/react-ui/src/components/AgentInterface/threadlist.scss
@@ -1,4 +1,5 @@
@use "../../cssUtils" as cssUtils;
+@use "../menu";
$thread-list-mask-height: cssUtils.$space-xl;
@@ -98,8 +99,8 @@ $thread-list-mask-height: cssUtils.$space-xl;
display: flex;
padding-left: cssUtils.$space-xs;
padding-bottom: cssUtils.$space-xs;
- color: cssUtils.$text-neutral-tertiary;
- @include cssUtils.typography(label, small);
+ color: cssUtils.$text-neutral-secondary;
+ @include cssUtils.typography(label, extra-small);
&:not(:first-child) {
padding-top: cssUtils.$space-xs;
@@ -141,11 +142,19 @@ $thread-list-mask-height: cssUtils.$space-xl;
display: flex;
align-items: center;
justify-content: space-between;
- width: 100%;
- border-radius: calc(cssUtils.$radius-s + 1px);
+ // Same 6px bleed and radius as the New Chat row, so selected and hover
+ // rects have room around the icon and title.
+ width: calc(100% + 12px);
+ margin: 0 -6px;
+ border-radius: calc(cssUtils.$radius-s + 3px);
+
+ .openui-agent-container--mobile & {
+ width: 100%;
+ margin: 0;
+ }
&--selected {
- background-color: cssUtils.$sunk;
+ background-color: cssUtils.$sunk-deep;
}
&--actions-open {
@@ -169,24 +178,38 @@ $thread-list-mask-height: cssUtils.$space-xl;
}
&--selected:hover {
- background-color: cssUtils.$sunk;
+ background-color: cssUtils.$sunk-deep;
}
&--selected.openui-agent-thread-button--actions-open {
- background-color: cssUtils.$sunk;
+ background-color: cssUtils.$sunk-deep;
}
}
.openui-agent-thread-button-title {
@include cssUtils.button-reset;
@include cssUtils.typography(label, small);
- color: cssUtils.$text-neutral-primary;
+ display: flex;
+ align-items: center;
+ gap: cssUtils.$space-s;
+ // Titles sit back in secondary; the open thread and the hovered row step up
+ // to primary.
+ color: cssUtils.$text-neutral-secondary;
+ transition: color 120ms ease;
+
+ .openui-agent-thread-button:hover &,
+ .openui-agent-thread-button:focus-within &,
+ .openui-agent-thread-button--actions-open &,
+ .openui-agent-thread-button--selected & {
+ color: cssUtils.$text-neutral-primary;
+ }
padding: cssUtils.$space-xs;
+ padding-left: calc(cssUtils.$space-xs + 6px);
width: 100%;
+ min-width: 0;
text-align: left;
cursor: pointer;
white-space: nowrap;
- text-overflow: ellipsis;
overflow: hidden;
.openui-agent-container--mobile & {
@@ -197,6 +220,21 @@ $thread-list-mask-height: cssUtils.$space-xl;
}
}
+.openui-agent-thread-button-icon {
+ flex-shrink: 0;
+ font-size: 14px;
+
+ .openui-agent-container--mobile & {
+ font-size: 16px;
+ }
+}
+
+.openui-agent-thread-button-label {
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+
.openui-agent-thread-button-dropdown-trigger {
position: absolute;
top: 50%;
@@ -225,15 +263,21 @@ $thread-list-mask-height: cssUtils.$space-xl;
display: flex;
flex-direction: column;
min-width: 180px;
- padding: cssUtils.$space-xs;
- border: 1px solid cssUtils.$border-default;
- border-radius: cssUtils.$radius-l;
- background-color: cssUtils.$foreground;
+ @include menu.surface;
transform: translateX(-4px);
z-index: 9999;
}
-.openui-agent-thread-button-dropdown-menu-item {
- outline: none;
+// Shared menu row: 32px, edge to edge, plain highlight.
+.openui-agent-thread-button-dropdown-menu-item.openui-button-base {
+ @include menu.item;
width: 100%;
+ justify-content: flex-start;
+ border: none;
+
+ &:hover,
+ &:focus-visible,
+ &[data-highlighted] {
+ background-color: cssUtils.$highlight;
+ }
}
diff --git a/packages/react-ui/src/components/AgentInterface/useDetailedViewResize.ts b/packages/react-ui/src/components/AgentInterface/useDetailedViewResize.ts
index ade9a3c84..d296bb077 100644
--- a/packages/react-ui/src/components/AgentInterface/useDetailedViewResize.ts
+++ b/packages/react-ui/src/components/AgentInterface/useDetailedViewResize.ts
@@ -50,20 +50,27 @@ export const useDetailedViewResize = ({
// steps and ARIA can read it without measuring (which would be wrong mid-transition).
const widthRef = useRef<number>(INITIAL_CHAT_WIDTH);
+ // Detail view state on the previous run, so the sidebar is only moved on a
+ // real open/close of the detail view, never on mount (where it would
+ // override the sidebar state the user left).
+ const wasDetailedViewActiveRef = useRef(false);
+
// Handle sidebar visibility and panel widths when detailed-view state changes
useEffect(() => {
if (isMobile) return;
+ const changed = wasDetailedViewActiveRef.current !== isDetailedViewActive;
+ wasDetailedViewActiveRef.current = isDetailedViewActive;
if (isDetailedViewActive) {
// Desktop view active: close sidebar and set chat width to 420px
- setIsSidebarOpen(false);
+ if (changed) setIsSidebarOpen(false);
if (chatPanelRef.current) {
chatPanelRef.current.style.width = `${INITIAL_CHAT_WIDTH}px`;
}
widthRef.current = INITIAL_CHAT_WIDTH;
} else {
// Desktop view inactive: open sidebar and reset chat width
- setIsSidebarOpen(true);
+ if (changed) setIsSidebarOpen(true);
if (chatPanelRef.current) {
chatPanelRef.current.style.width = "100%";
}
diff --git a/packages/react-ui/src/components/AgentInterface/welcomeGlow.scss b/packages/react-ui/src/components/AgentInterface/welcomeGlow.scss
index 0ded03a03..2c955a57a 100644
--- a/packages/react-ui/src/components/AgentInterface/welcomeGlow.scss
+++ b/packages/react-ui/src/components/AgentInterface/welcomeGlow.scss
@@ -28,86 +28,35 @@
z-index: 1;
}
- &::before,
- &::after,
- &__blob {
+ // The docs site's Faded Dither (see WelcomeDither.tsx), played once: it
+ // appears around the composer and quickly pulls in to merge into it.
+ &__dither {
position: absolute;
z-index: 0;
+ top: -220px;
+ bottom: -120px;
+ left: 50%;
+ width: min(1180px, 100vw);
+ transform: translateX(-50%);
pointer-events: none;
opacity: 0;
- }
-
- &::before {
- content: "";
- top: -180px;
- left: 50%;
- width: 620px;
- height: 210px;
- border-radius: 50%;
- background: radial-gradient(
- ellipse,
- color-mix(in oklch, var(--openui-interactive-accent-default) 38%, transparent) 0%,
- color-mix(in oklch, var(--openui-interactive-accent-default) 20%, transparent) 45%,
- transparent 75%
+ // Stipple colour, read by the shader. A touch under the site's light
+ // tone (#e6e6e6 on #f8f8f8, about 7% ink) so it stays in the background.
+ color: var(
+ --openui-agent-welcome-dither-color,
+ color-mix(in srgb, var(--openui-text-neutral-primary) 6%, transparent)
);
- filter: blur(40px);
- animation: openui-agent-welcome-glow-drop 1.5s linear
- calc(var(--openui-agent-welcome-settle-delay) + 0.5s) 1 both;
- }
-
- &::after {
- content: "";
- inset: -2px;
- box-sizing: border-box;
- border: 8px solid color-mix(in oklch, var(--openui-interactive-accent-default) 90%, transparent);
- border-radius: 18px;
- background: transparent;
- filter: blur(8px);
- -webkit-mask-image: radial-gradient(closest-side, black 35%, transparent 100%);
- mask-image: radial-gradient(closest-side, black 35%, transparent 100%);
+ -webkit-mask-image: radial-gradient(closest-side, black 30%, transparent 100%);
+ mask-image: radial-gradient(closest-side, black 30%, transparent 100%);
-webkit-mask-repeat: no-repeat;
mask-repeat: no-repeat;
- -webkit-mask-position: 50% -30px;
- mask-position: 50% -30px;
- animation: openui-agent-welcome-glow-halo 1.5s linear
- calc(var(--openui-agent-welcome-settle-delay) + 0.5s) 1 both;
- }
-
- &__blob {
- top: -150px;
- left: 50%;
- border-radius: 50%;
- animation: openui-agent-welcome-glow-blob-drop 1.5s linear 1 both;
-
- &--accent {
- --openui-agent-welcome-blob-x: -200px;
- --openui-agent-welcome-blob-peak: 0.2;
-
- width: 360px;
- height: 160px;
- background: radial-gradient(
- ellipse,
- color-mix(in oklch, var(--openui-interactive-accent-default) 42%, transparent) 0%,
- transparent 70%
- );
- filter: blur(30px);
- animation-delay: calc(var(--openui-agent-welcome-settle-delay) + 0.6s);
- }
-
- &--foreground {
- --openui-agent-welcome-blob-x: 90px;
- --openui-agent-welcome-blob-peak: 1;
-
- width: 240px;
- height: 110px;
- background: radial-gradient(
- ellipse,
- color-mix(in oklch, var(--openui-foreground) 100%, transparent) 0%,
- transparent 70%
- );
- filter: blur(24px);
- animation-delay: calc(var(--openui-agent-welcome-settle-delay) + 0.55s);
- }
+ -webkit-mask-position: 50% 62%;
+ mask-position: 50% 62%;
+ -webkit-mask-size: 100% 100%;
+ mask-size: 100% 100%;
+ // WelcomeDither reads this delay and duration to time the pull-in.
+ animation: openui-agent-welcome-dither 1.4s linear
+ calc(var(--openui-agent-welcome-settle-delay) + 0.3s) 1 both;
}
}
@@ -123,92 +72,18 @@
}
}
-@keyframes openui-agent-welcome-glow-blob-drop {
+@keyframes openui-agent-welcome-dither {
0% {
opacity: 0;
- transform: translate(calc(-50% + var(--openui-agent-welcome-blob-x) * 0.3), -220px) scale(0.8);
- animation-timing-function: cubic-bezier(0.45, 0, 0.65, 0.5);
- }
-
- 12% {
- opacity: calc(var(--openui-agent-welcome-blob-peak) * 0.3);
- }
-
- 30% {
- opacity: var(--openui-agent-welcome-blob-peak);
- transform: translate(calc(-50% + var(--openui-agent-welcome-blob-x)), 2px) scale(1);
- animation-timing-function: ease-in-out;
- }
-
- 52%,
- 100% {
- opacity: 0;
- transform: translate(calc(-50% + var(--openui-agent-welcome-blob-x) * 0.6), 44px)
- scale(0.85, 0.5);
}
-}
-@keyframes openui-agent-welcome-glow-drop {
- 0% {
- opacity: 0;
- transform: translate(-50%, -240px) scale(0.8);
- animation-timing-function: cubic-bezier(0.45, 0, 0.65, 0.5);
- }
-
- 10% {
- opacity: 0.18;
- }
-
- 22% {
- opacity: 0.35;
- }
-
- 30% {
- opacity: 0.65;
- transform: translate(-50%, 4px) scale(1);
- animation-timing-function: ease-in-out;
- }
-
- 52%,
- 100% {
- opacity: 0;
- transform: translate(-50%, 52px) scale(0.9, 0.45);
- }
-}
-
-@keyframes openui-agent-welcome-glow-halo {
- 0%,
- 30% {
- opacity: 0;
- -webkit-mask-size: 480px 110px;
- mask-size: 480px 110px;
- }
-
- 38% {
- opacity: 0.85;
- -webkit-mask-size: 700px 150px;
- mask-size: 700px 150px;
- animation-timing-function: ease-out;
- }
-
- 48% {
- opacity: 0.85;
- -webkit-mask-size: 1400px 380px;
- mask-size: 1400px 380px;
- animation-timing-function: ease-out;
- }
-
- 62% {
- opacity: 0.75;
- -webkit-mask-size: 2200px 760px;
- mask-size: 2200px 760px;
- animation-timing-function: ease-in-out;
+ 12%,
+ 90% {
+ opacity: 1;
}
100% {
opacity: 0;
- -webkit-mask-size: 2500px 860px;
- mask-size: 2500px 860px;
}
}
@@ -221,11 +96,7 @@
}
}
- .openui-agent-welcome-glow {
- &::before,
- &::after,
- &__blob {
- animation: none;
- }
+ .openui-agent-welcome-glow__dither {
+ display: none;
}
}
diff --git a/packages/react-ui/src/components/AgentInterface/welcomeScreen.scss b/packages/react-ui/src/components/AgentInterface/welcomeScreen.scss
index 777b92299..05393004a 100644
--- a/packages/react-ui/src/components/AgentInterface/welcomeScreen.scss
+++ b/packages/react-ui/src/components/AgentInterface/welcomeScreen.scss
@@ -1,6 +1,15 @@
@use "../../cssUtils" as cssUtils;
+@use "./column";
+@use "./threadHeader" as threadHeader;
$center-align-spacing: calc(32px + cssUtils.$space-s);
+// Single centred column shared by the greeting, composer, chips and starters.
+// Matches the in-thread input width (see _column.scss) so the new-chat input
+// has the same edges as the conversation's.
+$welcome-column-width: column.$content-width;
+// Optical lift: the composer sits this far above the card's true centre,
+// which reads as centred (extra bottom padding moves the centre up by half).
+$welcome-optical-lift: 36px;
.openui-agent-welcome-screen {
display: flex;
@@ -11,7 +20,7 @@ $center-align-spacing: calc(32px + cssUtils.$space-s);
align-items: center;
width: 100%;
height: 100%;
- max-width: 880px;
+ max-width: calc(#{column.$content-width} + 2 * #{$center-align-spacing});
margin: 0 auto;
padding: cssUtils.$space-m $center-align-spacing cssUtils.$space-2xl;
@@ -26,14 +35,14 @@ $center-align-spacing: calc(32px + cssUtils.$space-s);
padding-right: cssUtils.$space-m;
}
- // Header section (icon + title/description)
+ // Header section (icon + title/description), centred above the composer
&__header {
display: flex;
flex-direction: column;
- align-items: flex-start;
- gap: cssUtils.$space-xl;
+ align-items: center;
+ gap: cssUtils.$space-l;
width: 100%;
- max-width: 748px;
+ max-width: $welcome-column-width;
}
// Image container - minimal wrapper, styling handled by consumer
@@ -56,11 +65,11 @@ $center-align-spacing: calc(32px + cssUtils.$space-s);
&__content {
display: flex;
flex-direction: column;
- align-items: flex-start;
- gap: cssUtils.$space-m;
+ align-items: center;
+ gap: cssUtils.$space-s;
width: 100%;
max-width: 748px;
- text-align: left;
+ text-align: center;
}
// Title/greeting text
@@ -69,7 +78,14 @@ $center-align-spacing: calc(32px + cssUtils.$space-s);
width: 100%;
color: cssUtils.$text-neutral-primary;
margin: 0;
- font-weight: 500;
+ font-size: 24px;
+ font-weight: 400;
+ font-variation-settings: cssUtils.$font-variation-regular;
+ line-height: 1.25;
+
+ .openui-agent-container--mobile & {
+ font-size: 20px;
+ }
}
// Description text
@@ -79,6 +95,7 @@ $center-align-spacing: calc(32px + cssUtils.$space-s);
margin: 0;
max-width: 800px;
font-weight: 500;
+ font-variation-settings: normal;
}
&__composer-starters-container {
@@ -86,13 +103,21 @@ $center-align-spacing: calc(32px + cssUtils.$space-s);
flex-direction: column;
gap: cssUtils.$space-2xl;
width: 100%;
+ max-width: $welcome-column-width;
+
+ // Everything in the column fills it, so edges line up with the composer.
+ .openui-agent-welcome-glow,
+ .openui-agent-desktop-welcome-composer,
+ .openui-agent-conversation-starter {
+ max-width: 100%;
+ }
}
// Prefill-chips welcome (chips mode only): tighter gap while the chip row
// is visible; when drafting hides the layers, collapse the reserved space.
// Scoped by __starters-layers so welcomes without chips are unaffected.
&__composer-starters-container[data-has-prefill-chips] {
- gap: cssUtils.$space-l;
+ gap: cssUtils.$space-xl;
}
&__composer-starters-container:not([data-has-prefill-chips])
@@ -145,7 +170,7 @@ $center-align-spacing: calc(32px + cssUtils.$space-s);
// When welcome screen has the desktop composer variant
&--with-composer {
// Adjust gap for desktop layout
- gap: cssUtils.$space-3xl;
+ gap: cssUtils.$space-2xl;
// On mobile, use normal gap
.openui-agent-container--mobile & {
@@ -185,3 +210,65 @@ $center-align-spacing: calc(32px + cssUtils.$space-s);
}
}
}
+
+// Desktop: pin the composer to the exact centre of the thread card. The
+// greeting fills the top 1fr row and the starters the bottom one, so their
+// heights (and chip swaps) never push the composer off-centre.
+.openui-agent-container:not(.openui-agent-container--mobile)
+ .openui-agent-welcome-screen--with-composer {
+ display: grid;
+ grid-template-rows: 1fr auto 1fr;
+ // One full-width column (the base rule's justify-content: center would
+ // otherwise shrink it to the content).
+ grid-template-columns: minmax(0, 1fr);
+ justify-items: center;
+ gap: 0;
+ // Same column box as the in-thread composer (column width + 16px gutters,
+ // see components/composer.scss) so the input edges match at every width.
+ max-width: calc(#{$welcome-column-width} + 2 * #{cssUtils.$space-m-l});
+ padding-left: cssUtils.$space-m-l;
+ padding-right: cssUtils.$space-m-l;
+ padding-bottom: calc(#{cssUtils.$space-m} + 2 * #{$welcome-optical-lift});
+
+ .openui-agent-welcome-screen__header {
+ grid-row: 1;
+ align-self: end;
+ margin-bottom: cssUtils.$space-2xl;
+ }
+
+ // Lift the composer and starters into the grid so the composer owns row 2.
+ .openui-agent-welcome-screen__composer-starters-container {
+ display: contents;
+ }
+
+ .openui-agent-welcome-screen__desktop-composer,
+ .openui-agent-welcome-screen__desktop-starters {
+ width: 100%;
+ max-width: $welcome-column-width;
+ }
+
+ .openui-agent-welcome-screen__desktop-composer {
+ grid-row: 2;
+ }
+
+ .openui-agent-welcome-screen__desktop-starters {
+ grid-row: 3;
+ align-self: start;
+ margin: cssUtils.$space-2xl 0 0;
+ }
+
+ [data-has-prefill-chips] .openui-agent-welcome-screen__desktop-starters {
+ margin-top: cssUtils.$space-xl;
+ }
+}
+
+// The chat header row sits above the welcome; pad the bottom by its height so
+// the centre row lines up with the card's centre, not the space below it.
+.openui-agent-container:not(.openui-agent-container--mobile)
+ .openui-agent-thread-chat-panel:has(> .openui-agent-thread-header)
+ > .openui-agent-welcome-screen--with-composer {
+ padding-bottom: calc(
+ #{cssUtils.$space-m} + #{threadHeader.$thread-header-row-height} +
+ #{threadHeader.$thread-header-inset} + 2 * #{$welcome-optical-lift}
+ );
+}
diff --git a/packages/react-ui/src/components/Charts/FunnelChart/funnelChart.scss b/packages/react-ui/src/components/Charts/FunnelChart/funnelChart.scss
index 73067ca6b..4118ad2dd 100644
--- a/packages/react-ui/src/components/Charts/FunnelChart/funnelChart.scss
+++ b/packages/react-ui/src/components/Charts/FunnelChart/funnelChart.scss
@@ -51,6 +51,7 @@
@include cssUtils.typography(label, small);
fill: cssUtils.$text-neutral-primary;
font-weight: 600;
+ font-variation-settings: normal;
}
.#{brand.$prefix}-funnel-chart-label {
@@ -65,6 +66,7 @@
@include cssUtils.typography(label, extra-small);
fill: cssUtils.$background;
font-weight: 700;
+ font-variation-settings: normal;
}
.#{brand.$prefix}-funnel-chart-pct-pill {
diff --git a/packages/react-ui/src/components/CompositeCardBlock/compositeCardBlock.scss b/packages/react-ui/src/components/CompositeCardBlock/compositeCardBlock.scss
index b41830248..a453ea81c 100644
--- a/packages/react-ui/src/components/CompositeCardBlock/compositeCardBlock.scss
+++ b/packages/react-ui/src/components/CompositeCardBlock/compositeCardBlock.scss
@@ -67,6 +67,7 @@
strong em,
em strong {
font-weight: cssUtils.$font-weight-medium;
+ font-variation-settings: cssUtils.$font-variation-medium;
}
em,
diff --git a/packages/react-ui/src/components/ModelSwitcher/modelSwitcher.scss b/packages/react-ui/src/components/ModelSwitcher/modelSwitcher.scss
index 539424228..207612e9c 100644
--- a/packages/react-ui/src/components/ModelSwitcher/modelSwitcher.scss
+++ b/packages/react-ui/src/components/ModelSwitcher/modelSwitcher.scss
@@ -3,32 +3,73 @@
.openui-model-switcher {
min-width: 0;
- &-trigger {
+ // Compact pill: 32px, filled, flat (no border or shadow); small logo, 12px
+ // name, faint chevron.
+ & &-trigger {
display: flex;
- height: 36px;
+ height: 32px;
width: auto;
max-width: 240px;
align-items: center;
justify-content: flex-start;
- gap: cssUtils.$space-2xs;
- border-radius: cssUtils.$radius-l;
- border: 1px solid cssUtils.$border-interactive;
- background-color: cssUtils.$foreground;
- padding-inline: cssUtils.$space-s;
+ gap: cssUtils.$space-xs;
+ border: none;
+ border-radius: cssUtils.$radius-full;
+ background-color: cssUtils.$highlight;
+ padding: 0 cssUtils.$space-m;
color: cssUtils.$text-neutral-primary;
- box-shadow: cssUtils.$shadow-s;
- @include cssUtils.typography(label, small);
+ box-shadow: none;
+ font-size: 12px;
+ font-weight: 400;
+ font-variation-settings: cssUtils.$font-variation-regular;
+ line-height: 12px;
+
+ &:hover,
+ &[data-state="open"] {
+ background-color: cssUtils.$highlight-strong;
+ color: cssUtils.$text-neutral-primary;
+ }
+
+ .openui-model-switcher-logo {
+ width: 14px;
+ height: 14px;
+ }
+
+ // The badge dot doesn't fit the pill; the name and logo carry the model.
+ .openui-model-switcher-badge-trigger {
+ display: none;
+ }
+
+ .openui-select-trigger-icon {
+ width: 12px;
+ height: 12px;
+ flex-shrink: 0;
+ opacity: 0.4;
+ }
}
- &-content {
- max-height: 360px;
- width: min(360px, calc(100vw - 32px));
+ // Menu look (ring, shadow, 32px edge-to-edge rows, labels) comes from the
+ // shared Select styles; only size it here.
+ &-content.openui-select-content {
+ // Fill the space Radix reports below the trigger, ending 12px above the
+ // thread card's bottom edge so the menu's insets match ThreadHeader's 12px
+ // inset from the card's top-left (Radix already reserves the viewport margin).
+ max-height: calc(var(--radix-select-content-available-height, 376px) - 6px);
+ width: min(283px, calc(100vw - 32px));
overflow: auto;
- border-radius: cssUtils.$radius-xl;
}
- &-item {
- border-radius: cssUtils.$radius-m;
+ // Row badge ("Free"): a small pill rather than the default sm Tag.
+ &-row .openui-tag.openui-tag-sm {
+ height: 18px;
+ padding: 0 cssUtils.$space-s;
+ border-radius: cssUtils.$radius-full;
+ flex-shrink: 0;
+
+ .openui-tag-text {
+ font-size: 11px;
+ line-height: 18px;
+ }
}
&-row {
diff --git a/packages/react-ui/src/components/OpenUIChat/assistantMessage.scss b/packages/react-ui/src/components/OpenUIChat/assistantMessage.scss
index 87bc0e887..f44ecd6b2 100644
--- a/packages/react-ui/src/components/OpenUIChat/assistantMessage.scss
+++ b/packages/react-ui/src/components/OpenUIChat/assistantMessage.scss
@@ -56,14 +56,21 @@
justify-content: flex-end;
padding: 0;
+ // Filled pill (same fill as the send and New chat buttons), one type step
+ // down (body small). The radius is half a single-line bubble's height, so
+ // one line reads as a full pill and longer messages keep rounded corners.
&__content {
- @include cssUtils.typography(body, default);
- padding: cssUtils.$space-s cssUtils.$space-m;
- background-color: cssUtils.$chat-user-response-bg;
- color: cssUtils.$chat-user-response-text;
- border-radius: cssUtils.$radius-xl;
+ @include cssUtils.typography(body, small);
+ padding: cssUtils.$space-s cssUtils.$space-m-l;
+ background-color: cssUtils.$inverted-background;
+ color: cssUtils.$foreground;
+ border-radius: cssUtils.$radius-4xl;
overflow-wrap: break-word;
max-width: 100%;
height: fit-content;
+ // Wrapped text gets more room above and below; one line stays a pill.
+ &[data-multiline] {
+ padding-block: cssUtils.$space-m;
+ }
}
}
diff --git a/packages/react-ui/src/components/Select/select.scss b/packages/react-ui/src/components/Select/select.scss
index d10f41ce5..1b38d5296 100644
--- a/packages/react-ui/src/components/Select/select.scss
+++ b/packages/react-ui/src/components/Select/select.scss
@@ -1,4 +1,5 @@
@use "../../cssUtils" as cssUtils;
+@use "../menu";
.openui-select-trigger {
box-sizing: border-box;
@@ -70,18 +71,14 @@
max-height: 372px;
min-width: var(--radix-select-trigger-width);
overflow: hidden;
- border-radius: cssUtils.$radius-xl;
- background-color: cssUtils.$foreground;
- border: 1px solid cssUtils.$border-default;
- box-shadow: cssUtils.$shadow-m;
+ @include menu.surface;
+ padding: 0; // the viewport carries the vertical padding
color: cssUtils.$text-neutral-primary;
transform-origin: top center;
animation: select-show 0.18s ease-out forwards;
}
.openui-select-content-sm {
- border-radius: cssUtils.$radius-l;
-
.openui-select-label,
.openui-select-item,
.openui-select-item-text,
@@ -104,7 +101,7 @@
.openui-select-viewport {
box-sizing: border-box;
- padding: 4px;
+ padding: menu.$gutter 0;
&[data-position="popper"] {
width: 100%;
@@ -119,9 +116,8 @@
.openui-select-label {
box-sizing: border-box;
- padding: cssUtils.$space-3xs cssUtils.$space-xs;
@include cssUtils.typography(body, default);
- color: cssUtils.$text-neutral-tertiary;
+ @include menu.label;
}
.openui-select-item {
@@ -132,21 +128,12 @@
user-select: none;
align-items: center;
justify-content: space-between;
- border-radius: cssUtils.$radius-s;
- padding-top: cssUtils.$space-2xs;
- padding-bottom: cssUtils.$space-2xs;
@include cssUtils.typography(body, default);
+ @include menu.item;
color: cssUtils.$text-neutral-primary;
- outline: 0;
- // Variants based on showTick
+ // Room for the check indicator on the trailing edge.
&--with-tick {
- padding-left: cssUtils.$space-xs;
- padding-right: cssUtils.$space-xl;
- }
-
- &--without-tick {
- padding-left: cssUtils.$space-xs;
padding-right: cssUtils.$space-xl;
}
@@ -172,8 +159,6 @@
&[data-state="checked"] {
background-color: cssUtils.$highlight;
- outline: 1px solid cssUtils.$border-interactive;
- outline-offset: -1px;
}
// Check indicator
@@ -203,7 +188,7 @@
.openui-select-separator {
box-sizing: border-box;
- margin: 4px -4px;
+ @include menu.separator;
height: 1px;
border-top: 1px solid cssUtils.$border-default;
}
diff --git a/packages/react-ui/src/components/ThemeProvider/defaultTheme.ts b/packages/react-ui/src/components/ThemeProvider/defaultTheme.ts
index 7ab5e4e78..c1bd6a497 100644
--- a/packages/react-ui/src/components/ThemeProvider/defaultTheme.ts
+++ b/packages/react-ui/src/components/ThemeProvider/defaultTheme.ts
@@ -133,7 +133,8 @@ const createColorTheme = ({
const overlayBase = isDark ? swatch(neutral, 25) : swatch(neutral, 1000);
const neutralPrimary = isDark ? swatch(neutral, 50) : swatch(neutral, 1000);
- const neutralSecondary = withAlpha(neutralPrimary, 0.5);
+ // 0.6 keeps secondary text at 4.5:1 or better on both the page and card surfaces.
+ const neutralSecondary = withAlpha(neutralPrimary, 0.6);
const neutralTertiary = withAlpha(neutralPrimary, 0.2);
const accentText =
@@ -331,7 +332,21 @@ const FONT_HEADING = '"Inter", sans-serif';
const FONT_LABEL = '"Inter", sans-serif';
const FONT_NUMBERS = '"Inter", sans-serif';
-const typographyTheme: TypographyTheme = {
+// Inter is a variable font. font-weight stays at 400 / 560 as the fallback,
+// and the "wght" axis is set through font-variation-settings: Regular 440 in
+// light mode, eased to 420 in dark mode where light-on-dark text reads
+// heavier, and Medium 560. Every non-code style tracks -1%.
+const TRACKING = "-0.01em";
+
+const createTypographyTheme = ({
+ regular,
+ medium,
+ regularAxis,
+}: {
+ regular: string;
+ medium: string;
+ regularAxis: string;
+}): TypographyTheme => ({
fontBody: FONT_BODY,
fontCode: FONT_CODE,
fontHeading: FONT_HEADING,
@@ -349,94 +364,97 @@ const typographyTheme: TypographyTheme = {
fontSize4xl: "32px",
fontSize5xl: "36px",
- fontWeightRegular: "375",
- fontWeightMedium: "475",
+ fontWeightRegular: regular,
+ fontWeightMedium: medium,
fontWeightBold: "600",
fontWeightHeavy: "700",
+ fontVariationRegular: `"wght" ${regularAxis}`,
+ fontVariationMedium: `"wght" ${medium}`,
+
lineHeightBody: "1.5",
lineHeightHeading: "1.25",
lineHeightHeadingLarge: "1.1",
lineHeightLabel: "1.25",
lineHeightCode: "1.5",
- letterSpacingNormal: "0",
+ letterSpacingNormal: TRACKING,
letterSpacingTight: "-0.1px",
letterSpacingTighter: "-0.2px",
// Body
- textBodyXs: `400 12px/1.5 ${FONT_BODY}`,
- textBodyXsLetterSpacing: "0",
- textBodyXsHeavy: `500 12px/1.5 ${FONT_BODY}`,
- textBodyXsHeavyLetterSpacing: "0",
- textBodySm: `400 14px/1.5 ${FONT_BODY}`,
- textBodySmLetterSpacing: "0",
- textBodySmHeavy: `500 14px/1.5 ${FONT_BODY}`,
- textBodySmHeavyLetterSpacing: "0",
- textBodyDefault: `400 16px/1.5 ${FONT_BODY}`,
- textBodyDefaultLetterSpacing: "0",
- textBodyDefaultHeavy: `500 16px/1.5 ${FONT_BODY}`,
- textBodyDefaultHeavyLetterSpacing: "0",
- textBodyLg: `400 18px/1.5 ${FONT_BODY}`,
- textBodyLgLetterSpacing: "0",
- textBodyLgHeavy: `500 18px/1.5 ${FONT_BODY}`,
- textBodyLgHeavyLetterSpacing: "0",
+ textBodyXs: `${regular} 12px/1.5 ${FONT_BODY}`,
+ textBodyXsLetterSpacing: TRACKING,
+ textBodyXsHeavy: `${medium} 12px/1.5 ${FONT_BODY}`,
+ textBodyXsHeavyLetterSpacing: TRACKING,
+ textBodySm: `${regular} 14px/1.5 ${FONT_BODY}`,
+ textBodySmLetterSpacing: TRACKING,
+ textBodySmHeavy: `${medium} 14px/1.5 ${FONT_BODY}`,
+ textBodySmHeavyLetterSpacing: TRACKING,
+ textBodyDefault: `${regular} 16px/1.5 ${FONT_BODY}`,
+ textBodyDefaultLetterSpacing: TRACKING,
+ textBodyDefaultHeavy: `${medium} 16px/1.5 ${FONT_BODY}`,
+ textBodyDefaultHeavyLetterSpacing: TRACKING,
+ textBodyLg: `${regular} 18px/1.5 ${FONT_BODY}`,
+ textBodyLgLetterSpacing: TRACKING,
+ textBodyLgHeavy: `${medium} 18px/1.5 ${FONT_BODY}`,
+ textBodyLgHeavyLetterSpacing: TRACKING,
// Heading
textHeadingXs: `600 16px/1.25 ${FONT_HEADING}`,
- textHeadingXsLetterSpacing: "0",
+ textHeadingXsLetterSpacing: TRACKING,
textHeadingSm: `600 18px/1.25 ${FONT_HEADING}`,
- textHeadingSmLetterSpacing: "0",
+ textHeadingSmLetterSpacing: TRACKING,
textHeadingMd: `600 24px/1.1 ${FONT_HEADING}`,
- textHeadingMdLetterSpacing: "0",
+ textHeadingMdLetterSpacing: TRACKING,
textHeadingLg: `600 28px/1.1 ${FONT_HEADING}`,
textHeadingLgLetterSpacing: "-0.1px",
textHeadingXl: `700 32px/1.1 ${FONT_HEADING}`,
textHeadingXlLetterSpacing: "-0.1px",
// Label
- textLabelXs: `400 12px/1.25 ${FONT_LABEL}`,
- textLabelXsLetterSpacing: "0",
- textLabelXsHeavy: `500 12px/1.25 ${FONT_LABEL}`,
- textLabelXsHeavyLetterSpacing: "0",
- textLabelSm: `400 14px/1.25 ${FONT_LABEL}`,
- textLabelSmLetterSpacing: "0",
- textLabelSmHeavy: `500 14px/1.25 ${FONT_LABEL}`,
- textLabelSmHeavyLetterSpacing: "0",
- textLabelDefault: `400 16px/1.25 ${FONT_LABEL}`,
- textLabelDefaultLetterSpacing: "0",
- textLabelDefaultHeavy: `500 16px/1.25 ${FONT_LABEL}`,
- textLabelDefaultHeavyLetterSpacing: "0",
- textLabelLg: `400 18px/1.25 ${FONT_LABEL}`,
- textLabelLgLetterSpacing: "0",
- textLabelLgHeavy: `500 18px/1.25 ${FONT_LABEL}`,
- textLabelLgHeavyLetterSpacing: "0",
+ textLabelXs: `${regular} 12px/1.25 ${FONT_LABEL}`,
+ textLabelXsLetterSpacing: TRACKING,
+ textLabelXsHeavy: `${medium} 12px/1.25 ${FONT_LABEL}`,
+ textLabelXsHeavyLetterSpacing: TRACKING,
+ textLabelSm: `${regular} 14px/1.25 ${FONT_LABEL}`,
+ textLabelSmLetterSpacing: TRACKING,
+ textLabelSmHeavy: `${medium} 14px/1.25 ${FONT_LABEL}`,
+ textLabelSmHeavyLetterSpacing: TRACKING,
+ textLabelDefault: `${regular} 16px/1.25 ${FONT_LABEL}`,
+ textLabelDefaultLetterSpacing: TRACKING,
+ textLabelDefaultHeavy: `${medium} 16px/1.25 ${FONT_LABEL}`,
+ textLabelDefaultHeavyLetterSpacing: TRACKING,
+ textLabelLg: `${regular} 18px/1.25 ${FONT_LABEL}`,
+ textLabelLgLetterSpacing: TRACKING,
+ textLabelLgHeavy: `${medium} 18px/1.25 ${FONT_LABEL}`,
+ textLabelLgHeavyLetterSpacing: TRACKING,
// Numbers
- textNumbersXs: `400 12px/1.5 ${FONT_NUMBERS}`,
- textNumbersXsLetterSpacing: "0",
- textNumbersXsHeavy: `500 12px/1.5 ${FONT_NUMBERS}`,
- textNumbersXsHeavyLetterSpacing: "0",
- textNumbersSm: `400 14px/1.5 ${FONT_NUMBERS}`,
- textNumbersSmLetterSpacing: "0",
- textNumbersSmHeavy: `500 14px/1.5 ${FONT_NUMBERS}`,
- textNumbersSmHeavyLetterSpacing: "0",
- textNumbersDefault: `400 16px/1.5 ${FONT_NUMBERS}`,
- textNumbersDefaultLetterSpacing: "0",
- textNumbersDefaultHeavy: `500 16px/1.5 ${FONT_NUMBERS}`,
- textNumbersDefaultHeavyLetterSpacing: "0",
- textNumbersLg: `400 18px/1.5 ${FONT_NUMBERS}`,
- textNumbersLgLetterSpacing: "0",
- textNumbersLgHeavy: `500 18px/1.5 ${FONT_NUMBERS}`,
- textNumbersLgHeavyLetterSpacing: "0",
+ textNumbersXs: `${regular} 12px/1.5 ${FONT_NUMBERS}`,
+ textNumbersXsLetterSpacing: TRACKING,
+ textNumbersXsHeavy: `${medium} 12px/1.5 ${FONT_NUMBERS}`,
+ textNumbersXsHeavyLetterSpacing: TRACKING,
+ textNumbersSm: `${regular} 14px/1.5 ${FONT_NUMBERS}`,
+ textNumbersSmLetterSpacing: TRACKING,
+ textNumbersSmHeavy: `${medium} 14px/1.5 ${FONT_NUMBERS}`,
+ textNumbersSmHeavyLetterSpacing: TRACKING,
+ textNumbersDefault: `${regular} 16px/1.5 ${FONT_NUMBERS}`,
+ textNumbersDefaultLetterSpacing: TRACKING,
+ textNumbersDefaultHeavy: `${medium} 16px/1.5 ${FONT_NUMBERS}`,
+ textNumbersDefaultHeavyLetterSpacing: TRACKING,
+ textNumbersLg: `${regular} 18px/1.5 ${FONT_NUMBERS}`,
+ textNumbersLgLetterSpacing: TRACKING,
+ textNumbersLgHeavy: `${medium} 18px/1.5 ${FONT_NUMBERS}`,
+ textNumbersLgHeavyLetterSpacing: TRACKING,
textNumbersHeadingSm: `600 18px/1.25 ${FONT_NUMBERS}`,
- textNumbersHeadingSmLetterSpacing: "0",
+ textNumbersHeadingSmLetterSpacing: TRACKING,
textNumbersHeadingMd: `600 24px/1.1 ${FONT_NUMBERS}`,
- textNumbersHeadingMdLetterSpacing: "0",
+ textNumbersHeadingMdLetterSpacing: TRACKING,
textNumbersHeadingLg: `600 28px/1.1 ${FONT_NUMBERS}`,
- textNumbersHeadingLgLetterSpacing: "0",
+ textNumbersHeadingLgLetterSpacing: TRACKING,
textNumbersHeadingXl: `600 32px/1.1 ${FONT_NUMBERS}`,
- textNumbersHeadingXlLetterSpacing: "0",
+ textNumbersHeadingXlLetterSpacing: TRACKING,
// Code
textCodeSm: `400 12px/1.5 ${FONT_CODE}`,
@@ -447,7 +465,18 @@ const typographyTheme: TypographyTheme = {
textCodeDefaultLetterSpacing: "0",
textCodeDefaultHeavy: `700 14px/1.5 ${FONT_CODE}`,
textCodeDefaultHeavyLetterSpacing: "0",
-};
+});
+
+const lightTypographyTheme = createTypographyTheme({
+ regular: "400",
+ medium: "560",
+ regularAxis: "440",
+});
+const darkTypographyTheme = createTypographyTheme({
+ regular: "400",
+ medium: "560",
+ regularAxis: "420",
+});
// ---------------------------------------------------------------------------
// Effects – resolved from shadows.css (light values)
@@ -487,7 +516,7 @@ const darkEffectTheme: EffectTheme = {
export const defaultLightTheme: Theme = Object.freeze({
...lightColorTheme,
...layoutTheme,
- ...typographyTheme,
+ ...lightTypographyTheme,
...lightEffectTheme,
});
@@ -501,6 +530,6 @@ export const defaultLightTheme: Theme = Object.freeze({
export const defaultDarkTheme: Theme = Object.freeze({
...darkColorTheme,
...layoutTheme,
- ...typographyTheme,
+ ...darkTypographyTheme,
...darkEffectTheme,
});
diff --git a/packages/react-ui/src/components/ThemeProvider/index.ts b/packages/react-ui/src/components/ThemeProvider/index.ts
index 813e6693c..0f87fb433 100644
--- a/packages/react-ui/src/components/ThemeProvider/index.ts
+++ b/packages/react-ui/src/components/ThemeProvider/index.ts
@@ -3,4 +3,10 @@ export * from "./swatches";
export * from "./ThemeProvider";
export * from "./types";
export { useSystemThemeMode } from "./useSystemThemeMode";
+export {
+ THEME_MODE_ATTRIBUTE,
+ THEME_MODE_STORAGE_KEY,
+ useThemeModePreference,
+} from "./useThemeModePreference";
+export type { ThemeModePreference } from "./useThemeModePreference";
export { createTheme } from "./utils";
diff --git a/packages/react-ui/src/components/ThemeProvider/types.ts b/packages/react-ui/src/components/ThemeProvider/types.ts
index 2fc8832b5..993e659c4 100644
--- a/packages/react-ui/src/components/ThemeProvider/types.ts
+++ b/packages/react-ui/src/components/ThemeProvider/types.ts
@@ -211,6 +211,10 @@ export interface TypographyTheme {
fontWeightBold?: string;
fontWeightHeavy?: string;
+ // Font variation settings ("wght" axis) for Regular and Medium
+ fontVariationRegular?: string;
+ fontVariationMedium?: string;
+
// Line heights
lineHeightBody?: string;
lineHeightHeading?: string;
diff --git a/packages/react-ui/src/components/ThemeProvider/useThemeModePreference.ts b/packages/react-ui/src/components/ThemeProvider/useThemeModePreference.ts
new file mode 100644
index 000000000..2dc544898
--- /dev/null
+++ b/packages/react-ui/src/components/ThemeProvider/useThemeModePreference.ts
@@ -0,0 +1,62 @@
+"use client";
+
+import { useCallback, useState } from "react";
+import { readPreference, writePreference } from "../../utils/preferences";
+import { useIsomorphicLayoutEffect } from "../Charts/hooks/core/useIsomorphicLayoutEffect";
+import type { ThemeMode } from "./types";
+import { useSystemThemeMode } from "./useSystemThemeMode";
+
+/** A user's theme choice: a fixed mode, or follow the OS. */
+export type ThemeModePreference = ThemeMode | "system";
+
+/** localStorage key the preference is saved under (unset means "system"). */
+export const THEME_MODE_STORAGE_KEY = "openui-theme-mode";
+
+/**
+ * Attribute set on <html> while a mode is pinned. The default token sheet
+ * (openui-defaults) reads it, so pages outside AgentInterface follow the
+ * chosen mode too.
+ */
+export const THEME_MODE_ATTRIBUTE = "data-openui-theme";
+
+const isPreference = (value: unknown): value is ThemeModePreference =>
+ value === "light" || value === "dark" || value === "system";
+
+/**
+ * The user's Light / Dark / System choice, saved to localStorage and mirrored
+ * onto <html> as `data-openui-theme`. Returns the choice, a setter, and the
+ * resolved `mode` to pass to `<ThemeProvider mode>` (or `theme={{ mode }}`).
+ */
+export function useThemeModePreference(storageKey: string = THEME_MODE_STORAGE_KEY): {
+ preference: ThemeModePreference;
+ setPreference: (next: ThemeModePreference) => void;
+ mode: ThemeMode;
+} {
+ const systemMode = useSystemThemeMode();
+ // "system" for the first render (as on the server), then the saved choice
+ // before paint, so server-rendered markup hydrates cleanly.
+ const [preference, setPreferenceState] = useState<ThemeModePreference>("system");
+ useIsomorphicLayoutEffect(() => {
+ const saved = readPreference(storageKey);
+ setPreferenceState(isPreference(saved) ? saved : "system");
+ }, [storageKey]);
+
+ const setPreference = useCallback(
+ (next: ThemeModePreference) => {
+ setPreferenceState(next);
+ writePreference(storageKey, next === "system" ? undefined : next);
+ },
+ [storageKey],
+ );
+
+ const mode: ThemeMode = preference === "system" ? systemMode : preference;
+
+ useIsomorphicLayoutEffect(() => {
+ const root = document.documentElement;
+ if (preference === "system") root.removeAttribute(THEME_MODE_ATTRIBUTE);
+ else root.setAttribute(THEME_MODE_ATTRIBUTE, preference);
+ root.style.colorScheme = mode;
+ }, [preference, mode]);
+
+ return { preference, setPreference, mode };
+}
diff --git a/packages/react-ui/src/components/ToolCall/TimelineToolCard.tsx b/packages/react-ui/src/components/ToolCall/TimelineToolCard.tsx
index 14b0cdf79..dc438a533 100644
--- a/packages/react-ui/src/components/ToolCall/TimelineToolCard.tsx
+++ b/packages/react-ui/src/components/ToolCall/TimelineToolCard.tsx
@@ -1,8 +1,9 @@
import type { ToolActivity } from "@openuidev/react-headless";
-import { ChevronDown } from "lucide-react";
+import { ChevronRight } from "lucide-react";
import { memo } from "react";
import { SourceIcon } from "./SourceIcon";
-import { ToolCall, toolIcon } from "./ToolCallPrimitives";
+import { ToolCall, isToolRunning } from "./ToolCallPrimitives";
+import { TIMELINE_GLYPH, toolIcon } from "./ToolGlyphs";
import { extractToolSources, type ToolResultSource } from "./toolSources";
/** Favicon + title rows for the links a tool's result carries (see
@@ -33,7 +34,7 @@ const ToolSources = ({ sources }: { sources: ToolResultSource[] }) => {
* Timeline-shaped composition of the compound {@link ToolCall} parts: one row —
* tool glyph, status label, chevron — that expands into either the result's
* sources or a SINGLE block holding the request and the response together. The
- * running affordances (glyph blink, label shimmer) are
+ * running affordances (animated glyph, label shimmer) are
* `(streaming|executing) && isLast`, derived from the lifecycle status rather
* than a separate `isThinking` flag. `ToolCall.Root` is the single
* `.openui-tool-call` container, so we compose *inside* it.
@@ -44,16 +45,25 @@ export const TimelineToolCard = memo(function TimelineToolCard({
activity,
isLast,
isRunning = true,
+ inProgress,
+ open,
+ onOpenChange,
}: {
activity: ToolActivity;
isLast: boolean;
- /** Whether the owning thread is still running — gates the running shimmer/spin
- * so a closed-args call with no result doesn't animate forever after the run ends. */
+ /** Whether the owning thread is still running — gates the running shimmer/glyph
+ * animation so a closed-args call with no result doesn't animate forever after
+ * the run ends. */
isRunning?: boolean;
+ /** Show the in-progress look (animated glyph, shimmer) whatever the status — e.g.
+ * while a timeline is still on this step after a server-side tool already finished. */
+ inProgress?: boolean;
+ /** Controlled expand state; leave unset for the row to manage its own. */
+ open?: boolean;
+ onOpenChange?: (open: boolean) => void;
}) {
const Icon = toolIcon(activity.toolName, activity.status);
- const running =
- (activity.status === "streaming" || activity.status === "executing") && isLast && isRunning;
+ const running = inProgress ?? (isToolRunning(activity.status) && isLast && isRunning);
// Links speak for themselves; the raw block would only repeat them. A failure
// always falls back to it, since that's where the error text lives.
const sources =
@@ -67,20 +77,13 @@ export const TimelineToolCard = memo(function TimelineToolCard({
isLast={isLast}
running={isRunning}
defaultOpen={activity.isError}
+ open={open}
+ onOpenChange={onOpenChange}
>
<ToolCall.Trigger className="openui-tool-call__title-row">
- <ToolCall.StatusIcon
- render={(_state, props) => (
- <span
- className={`openui-tool-call__icon-wrapper${
- props["data-spin"] ? " openui-tool-call__icon--blinking" : ""
- }`}
- data-status={props["data-status"] as string}
- >
- <Icon size={14} className="openui-tool-call__icon" />
- </span>
- )}
- />
+ <span className="openui-tool-call__icon-wrapper" data-status={activity.status}>
+ <Icon {...TIMELINE_GLYPH} animate={running} className="openui-tool-call__icon" />
+ </span>
<ToolCall.StatusText
render={(_state, props) => (
<span
@@ -97,7 +100,8 @@ export const TimelineToolCard = memo(function TimelineToolCard({
</span>
)}
/>
- <ChevronDown size={14} className="openui-tool-call__chevron" />
+ {/* Points right while closed and turns down when open (see toolCall.scss). */}
+ <ChevronRight size={14} className="openui-tool-call__chevron" />
</ToolCall.Trigger>
<ToolCall.Content className="openui-tool-call__content">
diff --git a/packages/react-ui/src/components/ToolCall/ToolCallPrimitives.tsx b/packages/react-ui/src/components/ToolCall/ToolCallPrimitives.tsx
index 06fb72332..f8edab2e9 100644
--- a/packages/react-ui/src/components/ToolCall/ToolCallPrimitives.tsx
+++ b/packages/react-ui/src/components/ToolCall/ToolCallPrimitives.tsx
@@ -1,7 +1,8 @@
import type { ToolActivity, ToolCallStatus } from "@openuidev/react-headless";
import clsx from "clsx";
-import { AlertCircle, Blocks, Globe, ImageIcon, SquareCode } from "lucide-react";
import { createContext, createElement, useContext, useId, useState, type ReactNode } from "react";
+import { toolIcon } from "./ToolGlyphs";
+import { toolLabel, useToolLabels } from "./toolLabels";
/**
* Compound, reusable building blocks for rendering one tool call + its result.
@@ -24,7 +25,7 @@ interface ToolCallContextValue {
isLast: boolean;
/**
* Whether the owning thread is still running. The in-progress affordances
- * (icon spin, name shimmer) require this so a tool call that closed its args
+ * (glyph animation, name shimmer) require this so a tool call that closed its args
* but never received a result does NOT animate forever after the run ends.
* Defaults to `true` for standalone (thread-less) primitive use.
*/
@@ -64,31 +65,11 @@ function renderPart<State, Props extends Record<string, unknown>>(
return createElement(tag, defaultProps);
}
-const isRunning = (status: ToolCallStatus) => status === "streaming" || status === "executing";
+/** Whether a tool call is still in flight (arguments streaming or executing). */
+export const isToolRunning = (status: ToolCallStatus) =>
+ status === "streaming" || status === "executing";
-// ── Shared label / formatting helpers ──
-
-const LABELS: Record<ToolCallStatus, (name: string) => string> = {
- streaming: (n) => `Calling the ${n} tool`,
- executing: (n) => `Running the ${n} tool`,
- complete: (n) => `Called the ${n} tool`,
- error: (n) => `${n} failed`,
-};
-
-// Used when the tool name is empty/blank — avoids the doubled-word "tool tool"
-// that an interpolated `${name || "tool"}` fallback would produce.
-const NAMELESS_LABELS: Record<ToolCallStatus, string> = {
- streaming: "Calling the tool",
- executing: "Running the tool",
- complete: "Called the tool",
- error: "Tool failed",
-};
-
-/** Default human label for a status + tool name. @category Functions */
-export function defaultLabel(status: ToolCallStatus, name: string): string {
- if (!name || !name.trim()) return NAMELESS_LABELS[status];
- return LABELS[status](name);
-}
+// ── Shared formatting helpers ──
/** Pretty-prints a JSON result string, falling back to the raw string. @category Functions */
export function prettyResult(value?: string): string {
@@ -138,18 +119,6 @@ function resolveLegacyResponse(activity: ToolActivity): unknown {
return value != null ? value : undefined;
}
-// Built-in tool families that get their own glyph. Matched on the name
-const TOOL_ICONS: { match: RegExp; icon: typeof SquareCode }[] = [
- { match: /image[_-]?search/i, icon: ImageIcon },
- { match: /web[_-]?search/i, icon: Globe },
- { match: /artifact|generate[_-]?report/i, icon: Blocks },
-];
-
-export function toolIcon(toolName: string, status: ToolCallStatus): typeof SquareCode {
- if (status === "error") return AlertCircle;
- return TOOL_ICONS.find((entry) => entry.match.test(toolName))?.icon ?? SquareCode;
-}
-
// ── Parts ──
interface PartProps<State> {
@@ -163,6 +132,8 @@ function Root({
isLast = false,
running = true,
defaultOpen = false,
+ open,
+ onOpenChange,
className,
children,
}: {
@@ -170,11 +141,21 @@ function Root({
isLast?: boolean;
/** Whether the owning thread is still running (gates the in-progress animations). */
running?: boolean;
+ /** Initial expand state when uncontrolled. */
defaultOpen?: boolean;
+ /** Controlled expand state, e.g. so a list can keep one call open at a time. */
+ open?: boolean;
+ /** Called with the requested expand state; pair with `open`. */
+ onOpenChange?: (open: boolean) => void;
className?: string;
children: ReactNode;
}) {
- const [isOpen, setOpen] = useState(defaultOpen);
+ const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
+ const isOpen = open ?? uncontrolledOpen;
+ const setOpen = (value: boolean) => {
+ if (open === undefined) setUncontrolledOpen(value);
+ onOpenChange?.(value);
+ };
const panelId = useId();
const triggerId = useId();
return (
@@ -191,23 +172,23 @@ function Root({
);
}
-const StatusIcon = ({ render, className }: PartProps<{ status: ToolCallStatus }>) => {
+const StatusIcon = ({
+ render,
+ className,
+ size = 14,
+}: PartProps<{ status: ToolCallStatus }> & { size?: number }) => {
const { activity, isLast, running } = useToolCall();
- const spin = isRunning(activity.status) && isLast && running;
+ const spin = isToolRunning(activity.status) && isLast && running;
const Icon = toolIcon(activity.toolName, activity.status);
return renderPart(
render,
"span",
{ status: activity.status },
{
- className: clsx(
- "openui-tool-call__icon-wrapper",
- { "openui-tool-call__icon--blinking": spin },
- className,
- ),
+ className: clsx("openui-tool-call__icon-wrapper", className),
"data-status": activity.status,
"data-spin": spin,
- children: <Icon size={14} className="openui-tool-call__icon" />,
+ children: <Icon size={size} animate={spin} className="openui-tool-call__icon" />,
},
);
};
@@ -230,8 +211,9 @@ const StatusText = ({
className,
}: PartProps<{ status: ToolCallStatus; label: string }>) => {
const { activity, isLast, running } = useToolCall();
- const label = activity.statusMessage ?? defaultLabel(activity.status, activity.toolName);
- const shimmer = isRunning(activity.status) && isLast && running;
+ const labels = useToolLabels();
+ const label = activity.statusMessage ?? toolLabel(activity.status, activity.toolName, labels);
+ const shimmer = isToolRunning(activity.status) && isLast && running;
return renderPart(
render,
"span",
diff --git a/packages/react-ui/src/components/ToolCall/ToolCallTimeline.tsx b/packages/react-ui/src/components/ToolCall/ToolCallTimeline.tsx
index bde46e296..4bf2ff753 100644
--- a/packages/react-ui/src/components/ToolCall/ToolCallTimeline.tsx
+++ b/packages/react-ui/src/components/ToolCall/ToolCallTimeline.tsx
@@ -1,11 +1,22 @@
import { useThread, type ToolActivity } from "@openuidev/react-headless";
import clsx from "clsx";
-import { ChevronDown, ChevronUp } from "lucide-react";
-import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
+import { ChevronRight } from "lucide-react";
+import {
+ useCallback,
+ useEffect,
+ useId,
+ useLayoutEffect,
+ useRef,
+ useState,
+ type ReactNode,
+} from "react";
+import { Mascot } from "../AgentInterface/components/Mascot";
import { MarkDownRenderer } from "../MarkDownRenderer";
import { TimelineEntry } from "../_shared/tool-renderer/TimelineEntry";
import type { ToolDetailedViewPanel } from "../_shared/tool-renderer/ToolActivityRenderer";
-import { defaultLabel } from "./ToolCallPrimitives";
+import { isToolRunning } from "./ToolCallPrimitives";
+import { TIMELINE_GLYPH, ThinkingGlyph, toolIcon } from "./ToolGlyphs";
+import { toolLabel, useToolLabels } from "./toolLabels";
/**
* One display row of the timeline: a tool activity, or a thinking-text step
@@ -17,38 +28,204 @@ export type TimelineStep =
const stepKey = (step: TimelineStep) =>
step.type === "text" ? `text-${step.id}` : step.activity.id;
+/**
+ * A thinking-text step as a timeline row: brain glyph and label, expanding into
+ * the prose. Same markup and classes as {@link TimelineToolCard}'s row, so the
+ * two line up and share styles.
+ */
+const ThoughtRow = ({
+ text,
+ live,
+ open,
+ onOpenChange,
+}: {
+ text: string;
+ /** This is the step the run is on right now. */
+ live: boolean;
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+}) => {
+ const triggerId = useId();
+ const panelId = useId();
+ return (
+ <div className="openui-tool-call openui-tool-call--thought">
+ <button
+ type="button"
+ id={triggerId}
+ className="openui-tool-call__title-row"
+ aria-expanded={open}
+ aria-controls={panelId}
+ onClick={() => onOpenChange(!open)}
+ >
+ <span className="openui-tool-call__icon-wrapper">
+ <ThinkingGlyph {...TIMELINE_GLYPH} animate={live} className="openui-tool-call__icon" />
+ </span>
+ <span
+ className={clsx("openui-tool-call__name", { "openui-tool-call__name--shimmer": live })}
+ >
+ {live ? "Thinking" : "Thought it through"}
+ </span>
+ <ChevronRight size={14} className="openui-tool-call__chevron" />
+ </button>
+ {open && (
+ <div
+ id={panelId}
+ role="region"
+ aria-labelledby={triggerId}
+ className="openui-tool-call__content"
+ >
+ <MarkDownRenderer
+ textMarkdown={text}
+ className="openui-tool-call-timeline__text-step-body"
+ />
+ </div>
+ )}
+ </div>
+ );
+};
+
const TimelineStepRow = ({
step,
isLast,
+ live,
detailedViewPanel,
forceDefault,
+ open,
+ onOpenChange,
}: {
step: TimelineStep;
isLast: boolean;
+ /** The newest step while the run is live: shown in progress whatever its status. */
+ live: boolean;
detailedViewPanel?: ToolDetailedViewPanel;
forceDefault: boolean;
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
}) => {
if (step.type === "text") {
- return (
- <div className="openui-tool-call-timeline__text-step">
- <MarkDownRenderer
- textMarkdown={step.text}
- className="openui-tool-call-timeline__text-step-body"
- />
- </div>
- );
+ return <ThoughtRow text={step.text} live={live} open={open} onOpenChange={onOpenChange} />;
}
return (
<TimelineEntry
activity={step.activity}
isLast={isLast}
+ inProgress={live || undefined}
detailedViewPanel={detailedViewPanel}
forceDefault={forceDefault}
+ open={open}
+ onOpenChange={onOpenChange}
/>
);
};
-const REVEAL_INTERVAL = 600;
+/**
+ * What the collapsed header shows for the step in progress: its glyph and label,
+ * animated for as long as the step holds the header (server-side tools can
+ * finish before the reveal reaches them, so the status alone isn't enough).
+ */
+const LiveStepSummary = ({ step }: { step: TimelineStep }) => {
+ const labels = useToolLabels();
+ if (step.type === "text") {
+ return (
+ <>
+ <span className="openui-behind-the-scenes__glyph">
+ <ThinkingGlyph {...TIMELINE_GLYPH} animate />
+ </span>
+ <span className="openui-behind-the-scenes__toggle-label openui-behind-the-scenes__toggle-label--shimmer">
+ Thinking
+ </span>
+ </>
+ );
+ }
+ const { activity } = step;
+ const Glyph = toolIcon(activity.toolName, activity.status);
+ const label = activity.statusMessage ?? toolLabel(activity.status, activity.toolName, labels);
+ return (
+ <>
+ <span className="openui-behind-the-scenes__glyph">
+ <Glyph {...TIMELINE_GLYPH} animate />
+ </span>
+ <span className="openui-behind-the-scenes__toggle-label openui-behind-the-scenes__toggle-label--shimmer">
+ {label}
+ </span>
+ </>
+ );
+};
+
+/**
+ * The timeline's header in its "Working" state, on its own: the mascot and a
+ * shimmering label. The thread shows it from the moment a message is sent
+ * until a tool call or the answer arrives, and it sits exactly where the
+ * timeline's header will, so the hand-over doesn't move anything.
+ */
+export const TimelineWorkingIndicator = () => (
+ <div className="openui-behind-the-scenes">
+ <div
+ className="openui-behind-the-scenes__toggle openui-behind-the-scenes__toggle--static"
+ role="status"
+ >
+ <span className="openui-behind-the-scenes__ticker">
+ <span className="openui-behind-the-scenes__ticker-item">
+ <span className="openui-behind-the-scenes__glyph">
+ <Mascot size={28} className="openui-behind-the-scenes__mascot" />
+ </span>
+ <span className="openui-behind-the-scenes__toggle-label openui-behind-the-scenes__toggle-label--shimmer">
+ Working
+ </span>
+ </span>
+ </span>
+ </div>
+ </div>
+);
+
+/** Keep in sync with the ticker animation duration in toolCall.scss. */
+const TICKER_SLIDE_MS = 320;
+
+/**
+ * One line of header content. When `itemKey` changes, the previous line slides
+ * up and out while the new one slides up into place.
+ */
+const HeaderTicker = ({ itemKey, children }: { itemKey: string; children: ReactNode }) => {
+ const [leaving, setLeaving] = useState<{ key: string; node: ReactNode } | null>(null);
+ const last = useRef({ key: itemKey, node: children });
+
+ useEffect(() => {
+ if (last.current.key === itemKey) return;
+ setLeaving(last.current);
+ const t = setTimeout(() => setLeaving(null), TICKER_SLIDE_MS);
+ return () => clearTimeout(t);
+ }, [itemKey]);
+
+ // Remember what is on screen now, so the next change can slide it out.
+ useEffect(() => {
+ last.current = { key: itemKey, node: children };
+ });
+
+ return (
+ <span className="openui-behind-the-scenes__ticker">
+ {leaving && (
+ <span
+ key={`out-${leaving.key}`}
+ className="openui-behind-the-scenes__ticker-item openui-behind-the-scenes__ticker-item--out"
+ aria-hidden="true"
+ >
+ {leaving.node}
+ </span>
+ )}
+ <span
+ key={itemKey}
+ className={clsx("openui-behind-the-scenes__ticker-item", {
+ "openui-behind-the-scenes__ticker-item--in": leaving,
+ })}
+ >
+ {children}
+ </span>
+ </span>
+ );
+};
+
+// How long each step holds the header before the next one slides in.
+const REVEAL_INTERVAL = 1000;
const NO_FADE: { top: boolean; bottom: boolean } = { top: false, bottom: false };
@@ -59,8 +236,7 @@ const NO_FADE: { top: boolean; bottom: boolean } = { top: false, bottom: false }
const OVERFLOW_SLACK = 8;
const EDGE_SLACK = 4;
-/** Visually hidden but available to screen readers; inline so we don't depend on
- * scss (a sibling agent owns the stylesheet). */
+/** Visually hidden but available to screen readers. */
const VISUALLY_HIDDEN = {
position: "absolute",
width: 1,
@@ -73,15 +249,20 @@ const VISUALLY_HIDDEN = {
margin: -1,
} as const;
-const isRunning = (a: ToolActivity) => a.status === "streaming" || a.status === "executing";
-
/**
- * The "Working / Behind the scenes" timeline wrapper, driven by
- * {@link ToolActivity}[] from `useToolActivities`. Reveals the run's steps
- * one-by-one and keeps every revealed one on screen, holds the tray open across
- * the tool-result → first-token gap (`awaitingResponse`), and lets a manual
- * close stick for the rest of the run. "Running" is read from each activity's
- * status, not an `isThinking` prop.
+ * The "Working / Behind the scenes" timeline, driven by {@link ToolActivity}[]
+ * from `useToolActivities`.
+ *
+ * - **Header.** Collapsed while a run is live, it shows the step in progress
+ * (its animated glyph and label), and each new step slides the previous one
+ * up and out. Otherwise it shows the mascot with "Working" or "Behind the
+ * scenes".
+ * - **List.** Expanding shows every revealed step as rows in one card. One row
+ * is open at a time.
+ *
+ * Steps are revealed one by one at a readable pace, the run counts as live
+ * across the tool-result → first-token gap (`awaitingResponse`), and "running"
+ * is read from each activity's status rather than an `isThinking` prop.
*
* (Animations are CSS-only — framer-motion is intentionally not a dependency.)
*
@@ -103,8 +284,8 @@ export function ToolCallTimeline({
/** Render every row as the raw default card (e.g. so matched tools' raw
* request/response stay inspectable here while their rich preview renders elsewhere). */
forceDefault?: boolean;
- /** Hold the compact "Working…" tray open across the tool-result → first-token
- * gap instead of collapsing the instant the last result lands. */
+ /** Keep the run "live" across the tool-result → first-token gap instead of
+ * settling the instant the last result lands. */
awaitingResponse?: boolean;
}) {
const displaySteps: TimelineStep[] =
@@ -112,34 +293,35 @@ export function ToolCallTimeline({
// "Thinking" while the last activity is still running (or its results are in
// but the response hasn't started), on the live message, and the thread is
// actually running — so a closed-args call with no result stops showing
- // "Working..." once the run ends.
+ // "Working" once the run ends.
const isThreadRunning = useThread((s) => s.isRunning);
+ const labels = useToolLabels();
const thinking =
isThreadRunning &&
isLast &&
activities.length > 0 &&
- (isRunning(activities[activities.length - 1]!) || awaitingResponse);
+ (isToolRunning(activities[activities.length - 1]!.status) || awaitingResponse);
+ // Collapsed by default; the header carries the live step instead.
const [expanded, setExpanded] = useState(false);
- // A user close mid-run sticks until the next run.
- const [userCollapsed, setUserCollapsed] = useState(false);
+ // The one open row in the list, by step key.
+ const [openStep, setOpenStep] = useState<string | null>(null);
// Live message reveals from the first step; historical reveals them all so
- // it never animates "Working…" on mount.
+ // it never animates "Working" on mount.
const [revealedCount, setRevealedCount] = useState(() =>
isLast ? 1 : Math.max(displaySteps.length, 1),
);
- // Reset on each run edge: a rising `thinking` restarts the reveal and clears
- // any prior expand/collapse; a falling `thinking` reveals everything.
+ // Reset on each run edge: a rising `thinking` restarts the reveal and
+ // collapses the list; a falling `thinking` reveals everything.
const prevThinking = useRef(thinking);
useEffect(() => {
if (!prevThinking.current && thinking) {
setRevealedCount(1);
setExpanded(false);
- setUserCollapsed(false);
+ setOpenStep(null);
followRef.current = true;
} else if (prevThinking.current && !thinking) {
- setExpanded(false);
setRevealedCount(displaySteps.length);
}
prevThinking.current = thinking;
@@ -162,10 +344,9 @@ export function ToolCallTimeline({
setFade((prev) => (prev.top === next.top && prev.bottom === next.bottom ? prev : next));
}, []);
// Measured on every render of THIS component, which covers rows streaming in —
- // but a row expanding or collapsing is the child's own state, so the list can
- // grow past its cap and drop back under it without the timeline re-rendering
- // at all. Observing the element covers that: its box is content-sized until
- // the cap, so it changes on the way in and on the way back out.
+ // but a row expanding or collapsing changes the list's height too, and so
+ // does the list opening. Observing the element covers those: its box is
+ // content-sized until the cap, so it changes on the way in and back out.
const observerRef = useRef<ResizeObserver | null>(null);
const attachItems = useCallback(
(el: HTMLDivElement | null) => {
@@ -184,11 +365,6 @@ export function ToolCallTimeline({
measureEdges();
});
- const itemsClassName = clsx("openui-behind-the-scenes__items", {
- "openui-behind-the-scenes__items--fade-top": fade.top,
- "openui-behind-the-scenes__items--fade-bottom": fade.bottom,
- });
-
const handleItemsScroll = useCallback(() => {
const el = itemsRef.current;
if (el && distanceFromBottom(el) < 24) followRef.current = true;
@@ -203,7 +379,7 @@ export function ToolCallTimeline({
}, []);
useLayoutEffect(() => {
- if (!thinking || !followRef.current) return;
+ if (!thinking || !expanded || !followRef.current) return;
const el = itemsRef.current;
if (!el || distanceFromBottom(el) < 1) return;
const reduceMotion =
@@ -230,8 +406,8 @@ export function ToolCallTimeline({
// Robustness: once the thread stops running, reveal everything. The
// incremental reveal only advances while `isLast`, so a run that ends
- // mid-reveal (or a tray that mounted after `thinking` already fell) would
- // otherwise stay stuck showing "Working…". This is independent of the
+ // mid-reveal (or a timeline that mounted after `thinking` already fell)
+ // would otherwise stay stuck showing "Working". This is independent of the
// rising/falling `thinking` edge, so it settles regardless of mount timing.
useEffect(() => {
if (!isThreadRunning && revealedCount < displaySteps.length) {
@@ -245,24 +421,24 @@ export function ToolCallTimeline({
if (activities.length === 0 || displaySteps.length === 0) return null;
const revealing = revealedCount < displaySteps.length;
- const showCompact = (thinking || revealing) && !expanded && !userCollapsed;
- const isOpen = expanded || showCompact;
+ const working = thinking || revealing;
const current = displaySteps[Math.min(revealedCount - 1, displaySteps.length - 1)]!;
+ // Collapsed while live, the header shows the newest revealed step until the
+ // run settles; open, the list shows it instead.
+ const liveStep = working && !expanded ? current : null;
// Persistent live announcement reflecting the current step's status — driven by
// the same fallback the primitives use so SRs hear status changes as content
- // updates (the keyed reveal wrapper remounts and never announces on its own).
+ // updates (the header ticker remounts its line and never announces on its own).
const liveLabel =
current.type === "text"
? current.text
: (current.activity.statusMessage ??
- defaultLabel(current.activity.status, current.activity.toolName));
+ toolLabel(current.activity.status, current.activity.toolName, labels));
// Once settled, surface a failure count on the toggle so errors aren't hidden
// behind a collapsed "Behind the scenes".
- const settled = !thinking && !revealing;
- const failedCount = settled ? activities.filter((a) => a.status === "error").length : 0;
- const working = thinking || revealing;
+ const failedCount = working ? 0 : activities.filter((a) => a.status === "error").length;
const toggleLabel = working
? "Working"
: failedCount > 0
@@ -270,7 +446,14 @@ export function ToolCallTimeline({
: "Behind the scenes";
return (
- <div className="openui-behind-the-scenes">
+ <div
+ className={clsx("openui-behind-the-scenes", {
+ // While working, the mascot in this row stands in for the thread loader.
+ "openui-behind-the-scenes--working": working,
+ // Once the run is over, the header steps back (see toolCall.scss).
+ "openui-behind-the-scenes--settled": !working,
+ })}
+ >
<div role="status" aria-live="polite" style={VISUALLY_HIDDEN}>
{liveLabel}
</div>
@@ -278,95 +461,69 @@ export function ToolCallTimeline({
<button
className="openui-behind-the-scenes__toggle"
type="button"
- aria-expanded={isOpen}
- onClick={() => {
- // Anything open → close it (sticky for the rest of the run via
- // userCollapsed); otherwise reopen the full list.
- if (isOpen) {
- setExpanded(false);
- setUserCollapsed(true);
- } else {
- setExpanded(true);
- }
- }}
+ aria-expanded={expanded}
+ onClick={() => setExpanded((open) => !open)}
>
- <span
- className={clsx("openui-behind-the-scenes__toggle-label", {
- // While the run is live the label itself shimmers, matching the
- // running tool rows below it.
- "openui-behind-the-scenes__toggle-label--shimmer": working,
- })}
- >
- {toggleLabel}
- </span>
- {isOpen ? (
- <ChevronUp size={14} className="openui-behind-the-scenes__toggle-icon" />
- ) : (
- <ChevronDown size={14} className="openui-behind-the-scenes__toggle-icon" />
- )}
+ <HeaderTicker itemKey={liveStep ? stepKey(liveStep) : "summary"}>
+ {liveStep ? (
+ <LiveStepSummary step={liveStep} />
+ ) : (
+ <>
+ <span className="openui-behind-the-scenes__glyph">
+ <Mascot size={28} className="openui-behind-the-scenes__mascot" />
+ </span>
+ <span
+ className={clsx("openui-behind-the-scenes__toggle-label", {
+ "openui-behind-the-scenes__toggle-label--shimmer": working,
+ })}
+ >
+ {toggleLabel}
+ </span>
+ </>
+ )}
+ </HeaderTicker>
+ {/* Points right while collapsed and turns down when open (see toolCall.scss). */}
+ <ChevronRight size={16} className="openui-behind-the-scenes__toggle-icon" />
</button>
- {isLast && !expanded && (
- <div
- className={clsx("openui-behind-the-scenes__compact", {
- "openui-behind-the-scenes__compact--closed": !showCompact,
- })}
- inert={!showCompact}
- >
- <div className="openui-behind-the-scenes__compact-inner">
- {/* All revealed steps ACCUMULATE (scrollable past the cap) — each
- new step appends and only IT animates in (keyed by stepKey, so
- prior rows stay mounted). Showing one card at a time here made
- the tray look like it reopened on every step. */}
- <div
- className={itemsClassName}
- ref={attachItems}
- onScroll={handleItemsScroll}
- onWheel={handleItemsWheel}
- onTouchMove={handleItemsTouchMove}
- >
- {/* The run accumulates: every revealed step stays on screen and only
- the newest is `isLast`, so just that one shimmers and blinks.
- Keyed per step, so each row plays the fade-in once, on mount. */}
- {displaySteps.slice(0, revealedCount).map((step, idx) => (
- <div
- key={stepKey(step)}
- className="openui-behind-the-scenes__reveal-item"
- style={{ width: "100%" }}
- >
+ <div
+ className={clsx("openui-behind-the-scenes__collapse", {
+ "openui-behind-the-scenes__collapse--open": expanded,
+ })}
+ inert={!expanded}
+ >
+ <div className="openui-behind-the-scenes__collapse-inner">
+ <div
+ className={clsx("openui-behind-the-scenes__items", {
+ "openui-behind-the-scenes__items--fade-top": fade.top,
+ "openui-behind-the-scenes__items--fade-bottom": fade.bottom,
+ })}
+ ref={attachItems}
+ onScroll={handleItemsScroll}
+ onWheel={handleItemsWheel}
+ onTouchMove={handleItemsTouchMove}
+ >
+ {/* Keyed per step, so each new row plays its fade-in once, on mount. */}
+ {displaySteps.slice(0, revealedCount).map((step, idx) => {
+ const key = stepKey(step);
+ const newest = idx === revealedCount - 1;
+ return (
+ <div key={key} className="openui-behind-the-scenes__item">
<TimelineStepRow
step={step}
- isLast={idx === revealedCount - 1}
+ isLast={isLast && newest}
+ live={working && newest}
detailedViewPanel={detailedViewPanel}
forceDefault={forceDefault}
+ open={openStep === key}
+ onOpenChange={(open) => setOpenStep(open ? key : null)}
/>
</div>
- ))}
- </div>
+ );
+ })}
</div>
</div>
- )}
-
- {expanded && (
- <div
- className={itemsClassName}
- ref={attachItems}
- onScroll={handleItemsScroll}
- onWheel={handleItemsWheel}
- onTouchMove={handleItemsTouchMove}
- >
- {displaySteps.map((step, idx) => (
- <div key={stepKey(step)} style={{ width: "100%" }}>
- <TimelineStepRow
- step={step}
- isLast={isLast && idx === displaySteps.length - 1}
- detailedViewPanel={detailedViewPanel}
- forceDefault={forceDefault}
- />
- </div>
- ))}
- </div>
- )}
+ </div>
</div>
);
}
diff --git a/packages/react-ui/src/components/ToolCall/ToolGlyphs.tsx b/packages/react-ui/src/components/ToolCall/ToolGlyphs.tsx
new file mode 100644
index 000000000..bc18be23f
--- /dev/null
+++ b/packages/react-ui/src/components/ToolCall/ToolGlyphs.tsx
@@ -0,0 +1,191 @@
+import type { ToolCallStatus } from "@openuidev/react-headless";
+import clsx from "clsx";
+import type { ComponentType, ReactNode } from "react";
+
+/**
+ * Animated line-art glyphs for tool calls.
+ *
+ * Shapes and motion follow lucide-animated (https://lucide-animated.com): each
+ * glyph is the Lucide icon of the same name on a 24-unit grid, with its hover
+ * animation looped while the call runs. Motion is CSS-only (see
+ * `toolCall.scss`, `.openui-tool-glyph`) and stops under
+ * `prefers-reduced-motion`.
+ *
+ * @category Components
+ */
+export interface ToolGlyphProps {
+ /** Rendered width and height in px. */
+ size?: number;
+ /** Loop the glyph's animation (e.g. while its tool call is running). */
+ animate?: boolean;
+ /** Stroke width on the 24-unit grid. Lucide's default is 2. */
+ strokeWidth?: number;
+ className?: string;
+}
+
+/** A tool glyph component. @category Types */
+export type ToolGlyph = ComponentType<ToolGlyphProps>;
+
+/**
+ * How the timeline draws its glyphs: 20px in a 24px slot, with a stroke lighter
+ * than Lucide's 2 so they carry the same weight as the mascot's ink lines.
+ */
+export const TIMELINE_GLYPH = { size: 20, strokeWidth: 1.6 } as const;
+
+function GlyphFrame({
+ name,
+ size = 14,
+ animate = false,
+ strokeWidth = 2,
+ className,
+ children,
+}: ToolGlyphProps & { name: string; children: ReactNode }) {
+ return (
+ <svg
+ viewBox="0 0 24 24"
+ width={size}
+ height={size}
+ fill="none"
+ stroke="currentColor"
+ strokeWidth={strokeWidth}
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ aria-hidden="true"
+ className={clsx(
+ "openui-tool-glyph",
+ `openui-tool-glyph--${name}`,
+ { "openui-tool-glyph--animate": animate },
+ className,
+ )}
+ >
+ {children}
+ </svg>
+ );
+}
+
+/** Web search — Lucide `search`; the lens hops up, across and home. */
+export const SearchGlyph = (props: ToolGlyphProps) => (
+ <GlyphFrame name="search" {...props}>
+ <g className="openui-tool-glyph__lens">
+ <circle cx="11" cy="11" r="8" />
+ <path d="m21 21-4.3-4.3" />
+ </g>
+ </GlyphFrame>
+);
+
+/** Image search — Lucide `image`; the sun pops in and the hill draws across. */
+export const ImageSearchGlyph = (props: ToolGlyphProps) => (
+ <GlyphFrame name="image" {...props}>
+ <rect x="3" y="3" width="18" height="18" rx="2" />
+ <circle className="openui-tool-glyph__sun" cx="9" cy="9" r="2" />
+ <path
+ className="openui-tool-glyph__hill"
+ pathLength={1}
+ d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"
+ />
+ </GlyphFrame>
+);
+
+const SUN_RAYS = [
+ "M12 2v2",
+ "m4.93 4.93 1.41 1.41",
+ "M20 12h2",
+ "m19.07 4.93-1.41 1.41",
+ "M15.947 12.65a4 4 0 0 0-5.925-4.128",
+];
+
+/** Weather — Lucide `cloud-sun`; the cloud wiggles and the rays light up in turn. */
+export const WeatherGlyph = (props: ToolGlyphProps) => (
+ <GlyphFrame name="weather" {...props}>
+ {SUN_RAYS.map((d, i) => (
+ <path
+ key={d}
+ className="openui-tool-glyph__ray"
+ style={{ animationDelay: `${(i + 1) * 0.1}s` }}
+ d={d}
+ />
+ ))}
+ <path className="openui-tool-glyph__cloud" d="M13 22H7a5 5 0 1 1 4.9-6H13a3 3 0 0 1 0 6Z" />
+ </GlyphFrame>
+);
+
+/** Artifacts and reports — Lucide `blocks`; the loose block slides into the corner and back. */
+export const ArtifactGlyph = (props: ToolGlyphProps) => (
+ <GlyphFrame name="artifact" {...props}>
+ <path d="M10 21V8a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1H3" />
+ <rect className="openui-tool-glyph__block" x="14" y="3" width="7" height="7" rx="1" />
+ </GlyphFrame>
+);
+
+/** Any other tool — Lucide `terminal`; the cursor blinks after the prompt. */
+export const TerminalGlyph = (props: ToolGlyphProps) => (
+ <GlyphFrame name="terminal" {...props}>
+ <path className="openui-tool-glyph__prompt" d="m4 17 6-6-6-6" />
+ <path className="openui-tool-glyph__cursor" d="M12 19h8" />
+ </GlyphFrame>
+);
+
+/** Thinking steps — Lucide `brain`; the folds breathe in and out. */
+export const ThinkingGlyph = (props: ToolGlyphProps) => (
+ <GlyphFrame name="brain" {...props}>
+ <path className="openui-tool-glyph__fold" pathLength={1} d="M12 18V5" />
+ <path
+ className="openui-tool-glyph__fold openui-tool-glyph__fold--side"
+ pathLength={1}
+ d="M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4"
+ />
+ <path
+ className="openui-tool-glyph__fold openui-tool-glyph__fold--top"
+ pathLength={1}
+ d="M12 5A3 3 0 1 1 17.598 6.5"
+ />
+ <path
+ className="openui-tool-glyph__fold openui-tool-glyph__fold--top"
+ pathLength={1}
+ d="M12 5A3 3 0 1 0 6.402 6.5"
+ />
+ <path d="M17.997 5.125a4 4 0 0 1 2.526 5.77" />
+ <path
+ className="openui-tool-glyph__fold openui-tool-glyph__fold--lower"
+ pathLength={1}
+ d="M18 18a4 4 0 0 0 2-7.464"
+ />
+ <path d="M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517" />
+ <path
+ className="openui-tool-glyph__fold openui-tool-glyph__fold--lower"
+ pathLength={1}
+ d="M6 18a4 4 0 0 1-2-7.464"
+ />
+ <path d="M6.003 5.125a4 4 0 0 0-2.526 5.77" />
+ </GlyphFrame>
+);
+
+/** Failed calls — Lucide `badge-alert`; the badge swells and shakes. */
+export const ErrorGlyph = (props: ToolGlyphProps) => (
+ <GlyphFrame name="error" {...props}>
+ <g className="openui-tool-glyph__badge">
+ <path d="M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z" />
+ <path d="M12 8v4" />
+ <path d="M12 16h.01" />
+ </g>
+ </GlyphFrame>
+);
+
+// Built-in tool families that get their own glyph, matched on the tool name.
+// Anything else falls back to the terminal glyph.
+const TOOL_GLYPHS: { match: RegExp; glyph: ToolGlyph }[] = [
+ { match: /image[_-]?search/i, glyph: ImageSearchGlyph },
+ { match: /web[_-]?search/i, glyph: SearchGlyph },
+ { match: /weather/i, glyph: WeatherGlyph },
+ { match: /artifact|generate[_-]?report/i, glyph: ArtifactGlyph },
+];
+
+/**
+ * Picks the glyph for a tool call from its name and status.
+ *
+ * @category Functions
+ */
+export function toolIcon(toolName: string, status: ToolCallStatus): ToolGlyph {
+ if (status === "error") return ErrorGlyph;
+ return TOOL_GLYPHS.find((entry) => entry.match.test(toolName))?.glyph ?? TerminalGlyph;
+}
diff --git a/packages/react-ui/src/components/ToolCall/__tests__/toolLabels.test.ts b/packages/react-ui/src/components/ToolCall/__tests__/toolLabels.test.ts
new file mode 100644
index 000000000..fda416c79
--- /dev/null
+++ b/packages/react-ui/src/components/ToolCall/__tests__/toolLabels.test.ts
@@ -0,0 +1,32 @@
+import { describe, expect, it } from "vitest";
+import { humanizeToolName, toolLabel } from "../toolLabels";
+
+describe("toolLabel", () => {
+ it("uses on-brand copy for built-in tool families", () => {
+ expect(toolLabel("executing", "web_search")).toBe("Searching the web");
+ expect(toolLabel("complete", "web_search")).toBe("Searched the web");
+ expect(toolLabel("streaming", "thesys_image_search")).toBe("Finding images");
+ expect(toolLabel("complete", "get_weather")).toBe("Checked the weather");
+ expect(toolLabel("error", "generate_report")).toBe("Couldn't build the artifact");
+ });
+
+ it("turns unknown tool names into words", () => {
+ expect(toolLabel("executing", "lookup_order_status")).toBe("Using lookup order status");
+ expect(toolLabel("complete", "openui-sendEmail")).toBe("Used send email");
+ expect(toolLabel("error", "lookup_order_status")).toBe("Lookup order status failed");
+ expect(toolLabel("complete", " ")).toBe("Used a tool");
+ });
+
+ it("lets overrides replace any stage, matched case-insensitively", () => {
+ const labels = { Get_Weather: { done: "Checked the forecast" } };
+ expect(toolLabel("complete", "get_weather", labels)).toBe("Checked the forecast");
+ expect(toolLabel("executing", "get_weather", labels)).toBe("Checking the weather");
+ });
+});
+
+describe("humanizeToolName", () => {
+ it("drops vendor prefixes and separators", () => {
+ expect(humanizeToolName("thesys_image_search")).toBe("image search");
+ expect(humanizeToolName("getWeather")).toBe("get weather");
+ });
+});
diff --git a/packages/react-ui/src/components/ToolCall/index.ts b/packages/react-ui/src/components/ToolCall/index.ts
index 450bf8978..7af7cfd10 100644
--- a/packages/react-ui/src/components/ToolCall/index.ts
+++ b/packages/react-ui/src/components/ToolCall/index.ts
@@ -6,6 +6,27 @@ export { ToolCallComponent, type ToolCallProps } from "./ToolCall";
export { DefaultToolCard } from "./DefaultToolCard";
export { SourceIcon } from "./SourceIcon";
export { TimelineToolCard } from "./TimelineToolCard";
-export { ToolCall, defaultLabel, prettyResult, toolIcon, useToolCall } from "./ToolCallPrimitives";
+export { ToolCall, prettyResult, useToolCall } from "./ToolCallPrimitives";
export { ToolCallTimeline, type TimelineStep } from "./ToolCallTimeline";
+export {
+ ArtifactGlyph,
+ ErrorGlyph,
+ ImageSearchGlyph,
+ SearchGlyph,
+ TerminalGlyph,
+ ThinkingGlyph,
+ WeatherGlyph,
+ toolIcon,
+ type ToolGlyph,
+ type ToolGlyphProps,
+} from "./ToolGlyphs";
+export {
+ ToolLabelsProvider,
+ defaultLabel,
+ humanizeToolName,
+ toolLabel,
+ useToolLabels,
+ type ToolLabel,
+ type ToolLabels,
+} from "./toolLabels";
export { extractToolSources, type ToolResultSource } from "./toolSources";
diff --git a/packages/react-ui/src/components/ToolCall/toolCall.scss b/packages/react-ui/src/components/ToolCall/toolCall.scss
index b9e9f9535..d6c9d8ad2 100644
--- a/packages/react-ui/src/components/ToolCall/toolCall.scss
+++ b/packages/react-ui/src/components/ToolCall/toolCall.scss
@@ -31,26 +31,31 @@
// ── "Behind the scenes" wrapper ──
+// Rows inside the card are inset by this much; the card is pulled out by the
+// same amount (plus its border) so row glyphs and labels sit in the same
+// columns as the header's.
+$timeline-row-inset: cssUtils.$space-m;
+// Glyph slot shared by the header and every row (glyphs draw at 20px in it).
+$timeline-glyph-slot: 24px;
+
.openui-behind-the-scenes {
display: flex;
flex-direction: column;
align-items: flex-start;
- gap: cssUtils.$space-s;
+ gap: cssUtils.$space-3xs;
width: 100%;
- // Closes the whole run off from the answer that follows it.
- padding-block-end: cssUtils.$space-m;
+ // Spaces the run from the answer that follows it; no divider line.
margin-block-end: cssUtils.$space-m;
- border-block-end: 1px solid cssUtils.$border-default;
&__toggle {
@include cssUtils.button-reset;
display: flex;
align-items: center;
gap: cssUtils.$space-s;
- // Flush with the message content — the tray carries no chrome of its own.
- padding: 0;
+ // Flush with the message content — the header carries no chrome of its own.
+ padding: cssUtils.$space-2xs 0;
@include cssUtils.typography(body, small);
- color: cssUtils.$text-neutral-secondary;
+ color: cssUtils.$text-neutral-primary;
cursor: pointer;
background-color: transparent;
text-align: start;
@@ -58,9 +63,78 @@
// button-reset strips chrome, so restore a visible keyboard focus ring.
@include focus-ring;
- &:hover .openui-behind-the-scenes__toggle-label {
- color: cssUtils.$text-neutral-primary;
+ // Collapsed, the chevron only shows on hover or keyboard focus. Open, it
+ // stays visible and turns down.
+ &:hover .openui-behind-the-scenes__toggle-icon,
+ &:focus-visible .openui-behind-the-scenes__toggle-icon {
+ opacity: 1;
+ }
+
+ &[aria-expanded="true"] .openui-behind-the-scenes__toggle-icon {
+ opacity: 1;
+ transform: rotate(90deg);
+ }
+ }
+
+ // A finished run's collapsed header steps back: label and mascot in the
+ // secondary tone (the mascot is drawn in black, so it takes secondary's 60%
+ // alpha as opacity). Opening it brings the label back to primary.
+ &--settled &__toggle[aria-expanded="false"] {
+ .openui-behind-the-scenes__toggle-label {
+ color: cssUtils.$text-neutral-secondary;
}
+
+ .openui-behind-the-scenes__mascot {
+ opacity: 0.6;
+ }
+ }
+
+ // TimelineWorkingIndicator: the same header, but nothing to toggle yet.
+ &__toggle--static {
+ cursor: default;
+ }
+
+ // One line of header content; a new line slides up into place as the old one
+ // slides up and out (HeaderTicker in ToolCallTimeline.tsx).
+ &__ticker {
+ display: inline-grid;
+ overflow: hidden;
+ // A little room on every side so the clip doesn't crop the mascot's
+ // overhang or a glyph's animation (the search lens hops past its box).
+ padding: cssUtils.$space-2xs;
+ margin: calc(-1 * #{cssUtils.$space-2xs});
+ }
+
+ &__ticker-item {
+ grid-area: 1 / 1;
+ display: inline-flex;
+ align-items: center;
+ gap: cssUtils.$space-s;
+ white-space: nowrap;
+ }
+
+ // Keep the durations in sync with TICKER_SLIDE_MS in ToolCallTimeline.tsx.
+ &__ticker-item--in {
+ animation: openui-behind-the-scenes-slide-in 0.32s cubic-bezier(0.2, 0.7, 0.2, 1) both;
+ }
+
+ &__ticker-item--out {
+ animation: openui-behind-the-scenes-slide-out 0.32s cubic-bezier(0.4, 0, 0.6, 1) both;
+ }
+
+ &__glyph {
+ display: grid;
+ place-items: center;
+ flex-shrink: 0;
+ width: $timeline-glyph-slot;
+ height: $timeline-glyph-slot;
+ color: cssUtils.$text-neutral-secondary;
+ }
+
+ // Slightly wider than the slot; it overhangs evenly so labels stay aligned.
+ &__mascot {
+ max-width: none;
+ margin-inline: -2px;
}
&__toggle-label {
@@ -68,21 +142,49 @@
}
&__toggle-label--shimmer {
- @include text-shimmer(cssUtils.$text-neutral-tertiary, cssUtils.$text-neutral-secondary);
+ @include text-shimmer(cssUtils.$text-neutral-primary, cssUtils.$foreground);
}
&__toggle-icon {
flex-shrink: 0;
color: cssUtils.$text-neutral-secondary;
- transition: transform 0.2s ease;
+ opacity: 0;
+ transition:
+ transform 0.2s ease,
+ opacity 0.15s ease;
+ }
+
+ // Opens to the list's height (grid-rows 0fr → 1fr). Pulled out by the row
+ // inset so the card's rows line up with the header.
+ &__collapse {
+ display: grid;
+ grid-template-rows: 0fr;
+ opacity: 0;
+ width: calc(100% + #{$timeline-row-inset} + 1px);
+ margin-inline-start: calc(-1 * (#{$timeline-row-inset} + 1px));
+ transition:
+ grid-template-rows 0.25s ease,
+ opacity 0.2s ease;
+
+ &--open {
+ grid-template-rows: 1fr;
+ opacity: 1;
+ }
+ }
+
+ &__collapse-inner {
+ overflow: hidden;
+ min-height: 0;
}
+ // The steps, as rows in one card split by dotted rules.
&__items {
display: flex;
flex-direction: column;
- align-items: flex-start;
- gap: cssUtils.$space-xs;
width: 100%;
+ border: 1px dashed cssUtils.$border-interactive;
+ border-radius: cssUtils.$radius-2xl;
+ background-color: cssUtils.$foreground;
// Long runs must not push the conversation far down the page: past this
// height the timeline scrolls internally. Overridable per app via the
// custom property.
@@ -97,8 +199,6 @@
display: none;
}
- padding-inline-end: cssUtils.$space-s;
-
// Each edge dissolves only while a row is hidden behind it. Widths come from
// JS (CSS can't ask about scroll position); at 0 the mask is a no-op.
--openui-timeline-fade-top: 0px;
@@ -112,6 +212,31 @@
);
-webkit-mask-image: $edges;
mask-image: $edges;
+
+ .openui-tool-call__title-row {
+ padding: cssUtils.$space-xs $timeline-row-inset;
+ }
+
+ // Details sit under the label, inside the row's own section.
+ .openui-tool-call__content {
+ margin: 0;
+ padding: 0 $timeline-row-inset cssUtils.$space-s-m
+ calc(#{$timeline-row-inset} + #{$timeline-glyph-slot} + #{cssUtils.$space-s});
+ }
+
+ // The card is already the frame: no second card inside it.
+ .openui-tool-call__sources,
+ .openui-tool-call__block {
+ border: 0;
+ border-radius: 0;
+ background-color: transparent;
+ padding: 0;
+ }
+
+ // Sources line up with the label above them.
+ .openui-tool-call__source {
+ padding-inline: 0;
+ }
}
&__items--fade-top {
@@ -122,42 +247,47 @@
--openui-timeline-fade-bottom: 2rem;
}
- // Graceful auto-close of the compact "Working…" tray
- &__compact {
- display: grid;
- grid-template-rows: 1fr;
- width: 100%;
- transition:
- grid-template-rows 0.2s ease,
- opacity 0.2s ease;
+ // Opacity only, so a new row doesn't jump while the list follows it.
+ &__item {
+ animation: openui-behind-the-scenes-reveal 0.25s ease;
- &--closed {
- grid-template-rows: 0fr;
- opacity: 0;
+ & + & {
+ border-top: 1px dashed cssUtils.$border-interactive;
}
}
+}
- &__compact-inner {
- overflow: hidden;
- min-height: 0;
+@keyframes openui-behind-the-scenes-reveal {
+ from {
+ opacity: 0;
}
-
- // Opacity only: the list already slides as it follows the newest row, and a
- // rise on top of that reads as two competing motions.
- &__reveal-item {
- animation: openui-behind-the-scenes-reveal 0.25s ease;
+ to {
+ opacity: 1;
}
}
-@keyframes openui-behind-the-scenes-reveal {
+@keyframes openui-behind-the-scenes-slide-in {
from {
+ transform: translateY(100%);
opacity: 0;
}
to {
+ transform: translateY(0);
opacity: 1;
}
}
+@keyframes openui-behind-the-scenes-slide-out {
+ from {
+ transform: translateY(0);
+ opacity: 1;
+ }
+ to {
+ transform: translateY(-100%);
+ opacity: 0;
+ }
+}
+
// ── Timeline item (each tool call) ──
.openui-tool-call {
@@ -187,8 +317,21 @@
color: cssUtils.$text-neutral-primary;
}
+ // Collapsed, the chevron only shows on hover or keyboard focus. Open, it
+ // stays visible and turns down.
+ .openui-tool-call__chevron {
+ color: cssUtils.$text-neutral-secondary;
+ opacity: 0;
+ }
+
+ &:hover .openui-tool-call__chevron,
+ &:focus-visible .openui-tool-call__chevron {
+ opacity: 1;
+ }
+
&[aria-expanded="true"] .openui-tool-call__chevron {
- transform: rotate(180deg);
+ opacity: 1;
+ transform: rotate(90deg);
}
}
@@ -219,21 +362,23 @@
display: flex;
align-items: center;
justify-content: center;
- opacity: 0.3;
+ min-width: $timeline-glyph-slot;
+ min-height: $timeline-glyph-slot;
}
&__icon {
flex-shrink: 0;
- color: cssUtils.$text-neutral-primary;
+ color: cssUtils.$text-neutral-secondary;
}
+ // Legacy ToolCallComponent only; the glyphs animate themselves.
&__icon--blinking {
animation: openui-tool-call-icon-blink 1.5s ease-in-out infinite;
}
&__name {
@include cssUtils.typography(body, small);
- color: cssUtils.$text-neutral-secondary;
+ color: cssUtils.$text-neutral-primary;
-webkit-text-fill-color: currentColor;
white-space: nowrap;
overflow: hidden;
@@ -244,7 +389,7 @@
}
&__name--shimmer {
- @include text-shimmer(cssUtils.$text-neutral-tertiary, cssUtils.$text-neutral-secondary);
+ @include text-shimmer(cssUtils.$text-neutral-primary, cssUtils.$foreground);
}
&__connector {
@@ -257,7 +402,8 @@
// 6px offset = half of 14px icon - half of 1px border
margin-inline-start: 6px;
- border-inline-start: 1px solid cssUtils.$border-interactive;
+ // Kept as a transparent rail so the indent holds; no visible line.
+ border-inline-start: 1px solid transparent;
}
&__connector--last {
@@ -328,7 +474,7 @@
&__source-title {
@include cssUtils.typography(label, small);
- color: cssUtils.$text-neutral-secondary;
+ color: cssUtils.$text-neutral-primary;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
@@ -336,7 +482,7 @@
&__source-desc {
@include cssUtils.typography(label, small);
- color: cssUtils.$text-neutral-tertiary;
+ color: cssUtils.$text-neutral-secondary;
// Let the description shrink + truncate so it never squeezes the title.
flex: 1 1 25%;
min-width: 0;
@@ -408,10 +554,6 @@
// Glyph + label alone, no border or fill. The one status to skip the muted
// icon — a failure has to be legible.
&--error {
- .openui-tool-call__icon-wrapper {
- opacity: 1;
- }
-
.openui-tool-call__icon {
color: cssUtils.$text-danger-primary;
}
@@ -527,8 +669,6 @@
}
}
-// Shares an element with the wrapper's resting 0.3, so it replaces that rather
-// than compounding — these are the running glyph's real opacity.
@keyframes openui-tool-call-icon-blink {
0%,
100% {
@@ -549,47 +689,254 @@
}
// ── Timeline thinking steps ──
-// Prose the model emitted alongside its tool calls, rendered as a timeline
-// step so it reads as part of the run instead of a loose paragraph. Geometry
-// mirrors .openui-tool-call's title row: same start padding, 14px glyph, same
-// gap — the text column lines up with tool names.
-.openui-tool-call-timeline {
- &__text-step {
- display: flex;
- align-items: flex-start;
- gap: cssUtils.$space-s;
- // Flush with the tool rows: prose is their peer, not an indented aside.
- padding-inline-start: 0;
- // Breathing room against the neighboring timeline entries.
- margin-block: cssUtils.$space-s;
- width: 100%;
+// Prose the model emitted alongside its tool calls, shown when its "Thought
+// process" row is opened. Doubled-up selector so these rules WIN over
+// `.openui-markdown-renderer`'s own class and tag rules (body/default
+// typography, primary color on p/strong/…) regardless of which stylesheet
+// lands later in the build.
+.openui-tool-call-timeline__text-step-body.openui-tool-call-timeline__text-step-body {
+ @include cssUtils.typography(body, small);
+ color: cssUtils.$text-neutral-secondary;
+ min-width: 0;
+
+ * {
+ margin: 0;
+ font: inherit;
+ color: inherit !important;
+ line-height: inherit;
+ }
+}
+
+// ── Tool glyphs (ToolGlyphs.tsx) ──
+// Lucide shapes looped with lucide-animated's motion while `--animate` is set.
+
+.openui-tool-glyph {
+ display: block;
+ flex-shrink: 0;
+ overflow: visible;
+
+ * {
+ transform-box: fill-box;
+ transform-origin: center;
}
- // Doubled-up selector so these rules WIN over `.openui-markdown-renderer`'s
- // own class and tag rules (body/default typography, primary color on
- // p/strong/…) regardless of which stylesheet lands later in the build.
- &__text-step &__text-step-body {
- @include cssUtils.typography(body, small);
- color: cssUtils.$text-neutral-primary;
- min-width: 0;
- flex: 1;
+ // Draw-on strokes (pathLength = 1).
+ .openui-tool-glyph__hill,
+ .openui-tool-glyph__fold {
+ stroke-dasharray: 1 1;
+ stroke-dashoffset: 0;
+ }
- * {
- margin: 0;
- font: inherit;
- color: inherit !important;
- line-height: inherit;
- }
+ // Masks the sun's rays behind the cloud.
+ .openui-tool-glyph__cloud {
+ fill: cssUtils.$foreground;
+ }
+}
+
+.openui-tool-glyph--animate {
+ // search: x [0, 0, -3, 0], y [0, -4, 0, 0]
+ .openui-tool-glyph__lens {
+ animation: openui-tool-glyph-hop 2s ease-in-out infinite;
+ }
+
+ // image: the sun pops, then the hill draws across
+ .openui-tool-glyph__sun {
+ animation: openui-tool-glyph-pop 2.4s ease-out infinite;
+ }
+
+ .openui-tool-glyph__hill {
+ animation: openui-tool-glyph-draw 2.4s ease-in-out infinite;
+ }
+
+ // cloud-sun: x/y [-1, 1, -1, 1, 0]; rays fade in by index (inline delays)
+ .openui-tool-glyph__cloud {
+ animation: openui-tool-glyph-wiggle 2.4s ease-in-out infinite;
+ }
+
+ .openui-tool-glyph__ray {
+ animation: openui-tool-glyph-fade-in 2.4s ease-out infinite;
+ }
+
+ // blocks: the loose block travels [-4, 4] and back
+ .openui-tool-glyph__block {
+ animation: openui-tool-glyph-slot-in 2.4s cubic-bezier(0.45, 0, 0.3, 1) infinite;
+ }
+
+ // terminal: cursor opacity [1, 0, 1]
+ .openui-tool-glyph__cursor {
+ animation: openui-tool-glyph-blink 0.8s steps(1) infinite;
+ }
+
+ // brain: each fold's pathLength / pathOffset breathe, mirrored
+ .openui-tool-glyph__fold {
+ animation: openui-tool-glyph-fold-stem 1.4s ease-in-out infinite alternate;
+ }
+
+ .openui-tool-glyph__fold--side {
+ animation-name: openui-tool-glyph-fold-side;
+ }
+
+ .openui-tool-glyph__fold--top {
+ animation-name: openui-tool-glyph-fold-top;
+ }
+
+ .openui-tool-glyph__fold--lower {
+ animation-name: openui-tool-glyph-fold-lower;
+ }
+
+ // badge-alert: scale [1, 1.1, …, 1], rotate [0, -3, 3, -2, 2, 0]
+ .openui-tool-glyph__badge {
+ animation: openui-tool-glyph-shake 2.4s ease-in-out infinite;
+ }
+}
+
+@keyframes openui-tool-glyph-hop {
+ 0% {
+ transform: translate(0, 0);
+ }
+ 16% {
+ transform: translate(0, -4px);
+ }
+ 33% {
+ transform: translate(-3px, 0);
+ }
+ 50%,
+ 100% {
+ transform: translate(0, 0);
+ }
+}
+
+@keyframes openui-tool-glyph-pop {
+ 0% {
+ transform: scale(0);
+ }
+ 14% {
+ transform: scale(1.25);
+ }
+ 22%,
+ 100% {
+ transform: scale(1);
+ }
+}
+
+@keyframes openui-tool-glyph-draw {
+ 0%,
+ 10% {
+ stroke-dashoffset: 1;
+ }
+ 45%,
+ 100% {
+ stroke-dashoffset: 0;
+ }
+}
+
+@keyframes openui-tool-glyph-wiggle {
+ 0%,
+ 50%,
+ 100% {
+ transform: translate(0, 0);
+ }
+ 10%,
+ 30% {
+ transform: translate(-1px, -1px);
+ }
+ 20%,
+ 40% {
+ transform: translate(1px, 1px);
+ }
+}
+
+@keyframes openui-tool-glyph-fade-in {
+ 0% {
+ opacity: 0;
+ }
+ 12%,
+ 100% {
+ opacity: 1;
+ }
+}
+
+@keyframes openui-tool-glyph-slot-in {
+ 0%,
+ 12%,
+ 84%,
+ 100% {
+ transform: translate(0, 0);
+ }
+ 36%,
+ 60% {
+ transform: translate(-4px, 4px);
+ }
+}
+
+@keyframes openui-tool-glyph-blink {
+ 0%,
+ 100% {
+ opacity: 1;
+ }
+ 50% {
+ opacity: 0;
+ }
+}
+
+@keyframes openui-tool-glyph-fold-stem {
+ to {
+ stroke-dasharray: 0.4 1;
+ stroke-dashoffset: -0.25;
+ }
+}
+
+@keyframes openui-tool-glyph-fold-side {
+ to {
+ stroke-dasharray: 0.5 1;
+ stroke-dashoffset: -0.25;
+ }
+}
+
+@keyframes openui-tool-glyph-fold-top {
+ to {
+ stroke-dasharray: 0.8 1;
+ stroke-dashoffset: -0.07;
+ }
+}
+
+@keyframes openui-tool-glyph-fold-lower {
+ to {
+ stroke-dasharray: 0.8 1;
+ stroke-dashoffset: -0.14;
+ }
+}
+
+@keyframes openui-tool-glyph-shake {
+ 0%,
+ 25%,
+ 100% {
+ transform: scale(1) rotate(0);
+ }
+ 5% {
+ transform: scale(1.1) rotate(-3deg);
+ }
+ 10% {
+ transform: scale(1.1) rotate(3deg);
+ }
+ 15% {
+ transform: scale(1.1) rotate(-2deg);
+ }
+ 20% {
+ transform: scale(1.1) rotate(2deg);
}
}
// ── Reduced motion ──
-// Honor `prefers-reduced-motion: reduce`: stop the infinite icon blink + text
+// Honor `prefers-reduced-motion: reduce`: stop the looping glyphs and text
// shimmer (the shimmer also paints text via a clipped gradient, so reset it to a
-// solid fill or it would freeze half-transparent), drop the staggered reveal
-// fade, and disable the decorative chevron/hover transitions.
+// solid fill or it would freeze half-transparent), drop the row fade-in and the
+// header slide, and disable the decorative chevron/hover transitions.
@media (prefers-reduced-motion: reduce) {
- .openui-behind-the-scenes__reveal-item,
+ .openui-behind-the-scenes__item,
+ .openui-behind-the-scenes__ticker-item--in,
+ .openui-behind-the-scenes__ticker-item--out,
+ .openui-tool-glyph.openui-tool-glyph--animate *,
.openui-tool-call__icon--blinking {
animation: none;
}
@@ -607,7 +954,7 @@
}
.openui-behind-the-scenes__toggle-icon,
- .openui-behind-the-scenes__compact,
+ .openui-behind-the-scenes__collapse,
.openui-tool-call__chevron,
.openui-tool-call__source,
.openui-tool-code-block,
diff --git a/packages/react-ui/src/components/ToolCall/toolLabels.tsx b/packages/react-ui/src/components/ToolCall/toolLabels.tsx
new file mode 100644
index 000000000..d61d6a763
--- /dev/null
+++ b/packages/react-ui/src/components/ToolCall/toolLabels.tsx
@@ -0,0 +1,130 @@
+import type { ToolCallStatus } from "@openuidev/react-headless";
+import { createContext, useContext, type ReactNode } from "react";
+
+/**
+ * What a tool call reads as in the UI, per stage: `running` while it streams or
+ * executes ("Searching the web"), `done` once it has a result ("Searched the
+ * web"), and `failed` when it errors ("Web search failed").
+ *
+ * @category Types
+ */
+export interface ToolLabel {
+ running: string;
+ done: string;
+ failed: string;
+}
+
+/** Tool name → its label. Keys are matched exactly, case-insensitively. @category Types */
+export type ToolLabels = Record<string, Partial<ToolLabel>>;
+
+// Built-in tool families, matched on the tool name.
+const BUILT_IN_LABELS: { match: RegExp; label: ToolLabel }[] = [
+ {
+ match: /image[_-]?search/i,
+ label: { running: "Finding images", done: "Found images", failed: "Image search failed" },
+ },
+ {
+ match: /web[_-]?search/i,
+ label: { running: "Searching the web", done: "Searched the web", failed: "Web search failed" },
+ },
+ {
+ match: /weather/i,
+ label: {
+ running: "Checking the weather",
+ done: "Checked the weather",
+ failed: "Weather check failed",
+ },
+ },
+ {
+ match: /artifact|generate[_-]?report/i,
+ label: {
+ running: "Building the artifact",
+ done: "Built the artifact",
+ failed: "Couldn't build the artifact",
+ },
+ },
+ {
+ match: /^mcp[_-]?list[_-]?tools$/i,
+ label: {
+ running: "Connecting to tools",
+ done: "Connected to tools",
+ failed: "Couldn't connect to tools",
+ },
+ },
+];
+
+// Vendor prefixes that say who provides a tool, not what it does.
+const VENDOR_PREFIX = /^(thesys|openui)[_-]/i;
+
+/**
+ * Turns a raw tool name into words: `thesys_image_search` → "image search",
+ * `getWeather` → "get weather". Exported for apps that label tools themselves.
+ *
+ * @category Functions
+ */
+export function humanizeToolName(name: string): string {
+ return name
+ .trim()
+ .replace(VENDOR_PREFIX, "")
+ .replace(/([a-z0-9])([A-Z])/g, "$1 $2")
+ .replace(/[_\-.]+/g, " ")
+ .replace(/\s+/g, " ")
+ .trim()
+ .toLowerCase();
+}
+
+const capitalize = (text: string) => text.charAt(0).toUpperCase() + text.slice(1);
+
+/** The full label for a tool, from an override, a built-in family, or its name. */
+function resolveLabel(name: string, overrides?: ToolLabels): ToolLabel {
+ const words = humanizeToolName(name);
+ const fallback: ToolLabel = words
+ ? { running: `Using ${words}`, done: `Used ${words}`, failed: `${capitalize(words)} failed` }
+ : { running: "Using a tool", done: "Used a tool", failed: "Tool failed" };
+ const builtIn = BUILT_IN_LABELS.find((entry) => entry.match.test(name))?.label ?? fallback;
+ const key = Object.keys(overrides ?? {}).find((k) => k.toLowerCase() === name.toLowerCase());
+ return { ...builtIn, ...(key ? overrides![key] : undefined) };
+}
+
+/**
+ * The label for a tool call at a given status.
+ *
+ * @category Functions
+ */
+export function toolLabel(status: ToolCallStatus, name: string, overrides?: ToolLabels): string {
+ const label = resolveLabel(name, overrides);
+ if (status === "error") return label.failed;
+ if (status === "complete") return label.done;
+ return label.running;
+}
+
+/**
+ * @deprecated Use {@link toolLabel}. Kept so existing imports don't break.
+ * @category Functions
+ */
+export const defaultLabel = toolLabel;
+
+const ToolLabelsContext = createContext<ToolLabels | undefined>(undefined);
+
+/**
+ * Gives your own tools on-brand labels everywhere tool calls render, e.g.
+ * `<ToolLabelsProvider labels={{ get_forecast: { running: "Checking the
+ * forecast", done: "Checked the forecast" } }}>`. Any stage left out falls back
+ * to the built-in copy.
+ *
+ * @category Components
+ */
+export function ToolLabelsProvider({
+ labels,
+ children,
+}: {
+ labels: ToolLabels;
+ children: ReactNode;
+}) {
+ return <ToolLabelsContext.Provider value={labels}>{children}</ToolLabelsContext.Provider>;
+}
+
+/** Label overrides from the nearest {@link ToolLabelsProvider}, if any. @category Hooks */
+export function useToolLabels(): ToolLabels | undefined {
+ return useContext(ToolLabelsContext);
+}
diff --git a/packages/react-ui/src/components/_menu.scss b/packages/react-ui/src/components/_menu.scss
new file mode 100644
index 000000000..4eda65f69
--- /dev/null
+++ b/packages/react-ui/src/components/_menu.scss
@@ -0,0 +1,65 @@
+@use "../cssUtils" as cssUtils;
+
+// Shared menu look (Select menus, dropdown menus): a single hairline ring with
+// soft layered shadows (no CSS border, so edges never double), 32px rows that
+// run edge to edge with a plain square highlight, and a 16px content inset.
+// Clipping: the menu keeps 4px top/bottom padding and clips to its radius, and
+// a row that is the menu's very first/last child takes a matching corner
+// (menu radius - 4px), so a highlight never pokes past or gets cut by the ring.
+
+$gutter: cssUtils.$space-2xs;
+$radius: cssUtils.$radius-2xl;
+$edge-row-radius: calc(#{$radius} - #{$gutter});
+$inset-x: cssUtils.$space-m-l;
+$row-height: 32px;
+
+// Rounds the first/last direct child of a menu container (the menu itself,
+// or a Select viewport) to sit concentric inside the menu's corners.
+@mixin edge-rows {
+ // Doubled pseudo-class outranks the rows' own `border-radius: 0`.
+ > :first-child:first-child {
+ border-top-left-radius: $edge-row-radius;
+ border-top-right-radius: $edge-row-radius;
+ }
+
+ > :last-child:last-child {
+ border-bottom-left-radius: $edge-row-radius;
+ border-bottom-right-radius: $edge-row-radius;
+ }
+}
+
+@mixin surface {
+ border: none;
+ border-radius: $radius;
+ overflow: hidden;
+ // Lifted a step above the card it opens over: a no-op on the white light
+ // surface, a visibly raised grey in dark mode.
+ background-color: color-mix(in oklch, cssUtils.$foreground, cssUtils.$text-white 6%);
+ // The ring is drawn in the text color so it stays visible on dark surfaces.
+ box-shadow:
+ 0 0 0 1px color-mix(in oklch, #{cssUtils.$text-neutral-primary} 6%, transparent),
+ 0 4px 12px -2px oklch(0 0 0 / 0.05),
+ 0 16px 32px -8px oklch(0 0 0 / 0.08);
+ padding: $gutter 0;
+ @include edge-rows;
+}
+
+@mixin item {
+ display: flex;
+ align-items: center;
+ height: $row-height;
+ padding: 0 $inset-x;
+ border-radius: 0;
+ outline: none;
+}
+
+@mixin label {
+ padding: cssUtils.$space-s $inset-x cssUtils.$space-2xs;
+ color: color-mix(in oklch, #{cssUtils.$text-neutral-primary} 60%, transparent);
+ font-size: 12px;
+ line-height: 12px;
+}
+
+@mixin separator {
+ margin: $gutter 0;
+}
diff --git a/packages/react-ui/src/components/_shared/tool-renderer/TimelineEntry.tsx b/packages/react-ui/src/components/_shared/tool-renderer/TimelineEntry.tsx
index 95b81a8b8..9c3e39c7a 100644
--- a/packages/react-ui/src/components/_shared/tool-renderer/TimelineEntry.tsx
+++ b/packages/react-ui/src/components/_shared/tool-renderer/TimelineEntry.tsx
@@ -7,6 +7,8 @@ export interface TimelineEntryProps {
activity: ToolActivity;
/** Whether this entry belongs to the live (last assistant) message — drives the running shimmer. */
isLast?: boolean;
+ /** Show the in-progress look (animated glyph, shimmer) whatever the status. */
+ inProgress?: boolean;
/** Optional detailed-view panel for matched renderers (defaults to the shared one). */
detailedViewPanel?: ToolDetailedViewPanel;
/** Always render the raw default card, even when a renderer matches (used for the "Behind the scenes" raw view). */
@@ -18,6 +20,9 @@ export interface TimelineEntryProps {
* to avoid rendering the raw card twice.
*/
fallbackToDefault?: boolean;
+ /** Controlled expand state for the default card (e.g. a one-open-at-a-time list). */
+ open?: boolean;
+ onOpenChange?: (open: boolean) => void;
}
const propsEqual = (a: TimelineEntryProps, b: TimelineEntryProps) =>
@@ -26,32 +31,45 @@ const propsEqual = (a: TimelineEntryProps, b: TimelineEntryProps) =>
a.activity.result === b.activity.result &&
a.activity.isError === b.activity.isError &&
a.isLast === b.isLast &&
+ a.inProgress === b.inProgress &&
a.forceDefault === b.forceDefault &&
a.fallbackToDefault === b.fallbackToDefault &&
- a.detailedViewPanel === b.detailedViewPanel;
+ a.detailedViewPanel === b.detailedViewPanel &&
+ a.open === b.open &&
+ a.onOpenChange === b.onOpenChange;
/**
* Timeline-flavoured sibling of {@link ToolCallEntry}: the same matched-renderer
* **xor** default dispatch, but the default is the timeline-shaped
- * {@link TimelineToolCard} (dot + connector + StatusStep) instead of the chevron
- * card. Used both inside `<ToolCallTimeline>` and directly by flat threads that
- * want the always-visible timeline rows.
+ * {@link TimelineToolCard} (glyph + label row) instead of the chevron card. Used
+ * both inside `<ToolCallTimeline>` and directly by flat threads that want the
+ * always-visible timeline rows.
*
* @category Components
*/
export const TimelineEntry = memo(function TimelineEntry({
activity,
isLast = false,
+ inProgress,
detailedViewPanel,
forceDefault = false,
fallbackToDefault = true,
+ open,
+ onOpenChange,
}: TimelineEntryProps) {
const renderer = useArtifactRenderer(activity.toolName); // exact → RegExp → "*"
// Run-gate the in-progress animation: a closed-args call with no result must
// not shimmer forever after the run ends (the status stays streaming/executing).
const isRunning = useThread((s) => s.isRunning);
const defaultCard = (
- <TimelineToolCard activity={activity} isLast={isLast} isRunning={isRunning} />
+ <TimelineToolCard
+ activity={activity}
+ isLast={isLast}
+ isRunning={isRunning}
+ inProgress={inProgress}
+ open={open}
+ onOpenChange={onOpenChange}
+ />
);
if (forceDefault || !renderer) return defaultCard;
// Matched renderer; if its parser returns null (skips), fall back to the raw
diff --git a/packages/react-ui/src/cssUtils.scss b/packages/react-ui/src/cssUtils.scss
index d7f0c5759..0be8b6748 100644
--- a/packages/react-ui/src/cssUtils.scss
+++ b/packages/react-ui/src/cssUtils.scss
@@ -148,6 +148,8 @@ $font-weight-regular: var(--openui-font-weight-regular);
$font-weight-medium: var(--openui-font-weight-medium);
$font-weight-bold: var(--openui-font-weight-bold);
$font-weight-heavy: var(--openui-font-weight-heavy);
+$font-variation-regular: var(--openui-font-variation-regular);
+$font-variation-medium: var(--openui-font-variation-medium);
$line-height-body: var(--openui-line-height-body);
$line-height-heading: var(--openui-line-height-heading);
$line-height-heading-large: var(--openui-line-height-heading-large);
@@ -243,34 +245,45 @@ $shadow-3xl: var(--openui-shadow-3xl);
$chat-container-bg: $background;
-@function typography($font-name) {
- @return (font: var(--#{$font-name}), letter-spacing: var(--#{$font-name}-letter-spacing));
+// $variation picks the Inter "wght" axis token: regular or medium for the
+// theme's Regular/Medium styles, null for fixed weights (600/700, code), where
+// the font shorthand's reset leaves font-weight in charge.
+@function typography($font-name, $variation: null) {
+ $axis: null;
+ @if $variation {
+ $axis: var(--openui-font-variation-#{$variation});
+ }
+ @return (
+ font: var(--#{$font-name}),
+ letter-spacing: var(--#{$font-name}-letter-spacing),
+ variation: $axis
+ );
}
$typography: (
body: (
- default: typography(openui-text-body-default),
- heavy: typography(openui-text-body-default-heavy),
- small: typography(openui-text-body-sm),
- small-heavy: typography(openui-text-body-sm-heavy),
- large: typography(openui-text-body-lg),
- large-heavy: typography(openui-text-body-lg-heavy),
- link: typography(openui-text-body-default),
- medium: typography(openui-text-body-default),
+ default: typography(openui-text-body-default, regular),
+ heavy: typography(openui-text-body-default-heavy, medium),
+ small: typography(openui-text-body-sm, regular),
+ small-heavy: typography(openui-text-body-sm-heavy, medium),
+ large: typography(openui-text-body-lg, regular),
+ large-heavy: typography(openui-text-body-lg-heavy, medium),
+ link: typography(openui-text-body-default, regular),
+ medium: typography(openui-text-body-default, regular),
),
label: (
- default: typography(openui-text-label-default),
- heavy: typography(openui-text-label-default-heavy),
- large: typography(openui-text-label-lg),
- large-heavy: typography(openui-text-label-lg-heavy),
- medium: typography(openui-text-label-default),
- medium-heavy: typography(openui-text-label-default-heavy),
- small: typography(openui-text-label-sm),
- small-heavy: typography(openui-text-label-sm-heavy),
- extra-small: typography(openui-text-label-xs),
- extra-small-heavy: typography(openui-text-label-xs-heavy),
- 2-extra-small: typography(openui-text-label-xs),
- 2-extra-small-heavy: typography(openui-text-label-xs-heavy),
+ default: typography(openui-text-label-default, regular),
+ heavy: typography(openui-text-label-default-heavy, medium),
+ large: typography(openui-text-label-lg, regular),
+ large-heavy: typography(openui-text-label-lg-heavy, medium),
+ medium: typography(openui-text-label-default, regular),
+ medium-heavy: typography(openui-text-label-default-heavy, medium),
+ small: typography(openui-text-label-sm, regular),
+ small-heavy: typography(openui-text-label-sm-heavy, medium),
+ extra-small: typography(openui-text-label-xs, regular),
+ extra-small-heavy: typography(openui-text-label-xs-heavy, medium),
+ 2-extra-small: typography(openui-text-label-xs, regular),
+ 2-extra-small-heavy: typography(openui-text-label-xs-heavy, medium),
),
heading: (
xl: typography(openui-text-heading-xl),
@@ -280,14 +293,14 @@ $typography: (
extra-small: typography(openui-text-heading-xs),
),
number: (
- large: typography(openui-text-numbers-lg),
- large-heavy: typography(openui-text-numbers-lg-heavy),
- heavy: typography(openui-text-numbers-default-heavy),
- default: typography(openui-text-numbers-default),
- small: typography(openui-text-numbers-sm),
- small-heavy: typography(openui-text-numbers-sm-heavy),
- extra-small: typography(openui-text-numbers-xs),
- extra-small-heavy: typography(openui-text-numbers-xs-heavy),
+ large: typography(openui-text-numbers-lg, regular),
+ large-heavy: typography(openui-text-numbers-lg-heavy, medium),
+ heavy: typography(openui-text-numbers-default-heavy, medium),
+ default: typography(openui-text-numbers-default, regular),
+ small: typography(openui-text-numbers-sm, regular),
+ small-heavy: typography(openui-text-numbers-sm-heavy, medium),
+ extra-small: typography(openui-text-numbers-xs, regular),
+ extra-small-heavy: typography(openui-text-numbers-xs-heavy, medium),
heading: typography(openui-text-numbers-heading-lg),
heading-small: typography(openui-text-numbers-heading-sm),
heading-medium: typography(openui-text-numbers-heading-md),
@@ -307,6 +320,8 @@ $typography: (
@mixin typography($font-name, $font-variant) {
font: map.get($typography, $font-name, $font-variant, font);
letter-spacing: map.get($typography, $font-name, $font-variant, letter-spacing);
+ // The font shorthand resets font-variation-settings, so set the axis after it.
+ font-variation-settings: map.get($typography, $font-name, $font-variant, variation);
}
@mixin button-reset {
diff --git a/packages/react-ui/src/hooks/useElementSize.ts b/packages/react-ui/src/hooks/useElementSize.ts
index c8fccc6ba..bc9506738 100644
--- a/packages/react-ui/src/hooks/useElementSize.ts
+++ b/packages/react-ui/src/hooks/useElementSize.ts
@@ -1,9 +1,12 @@
-import { useEffect, useState } from "react";
+import { useState } from "react";
+import { useIsomorphicLayoutEffect } from "../components/Charts/hooks/core/useIsomorphicLayoutEffect";
export const useElementSize = ({ ref }: { ref: React.RefObject<HTMLElement | null> }) => {
const [size, setSize] = useState<{ width: number; height: number }>({ width: 0, height: 0 });
- useEffect(() => {
+ // Before paint, so layout-dependent UI (mobile vs desktop) is right on the
+ // first visible frame.
+ useIsomorphicLayoutEffect(() => {
if (!ref.current) {
return;
}
diff --git a/packages/react-ui/src/openui-defaults.scss b/packages/react-ui/src/openui-defaults.scss
index dc315e7ce..0110eea7c 100644
--- a/packages/react-ui/src/openui-defaults.scss
+++ b/packages/react-ui/src/openui-defaults.scss
@@ -29,7 +29,7 @@
// Text Colors
--openui-text-neutral-primary: oklch(0.097 0 0 / 1);
- --openui-text-neutral-secondary: oklch(0.097 0 0 / 0.5);
+ --openui-text-neutral-secondary: oklch(0.097 0 0 / 0.6);
--openui-text-neutral-tertiary: oklch(0.097 0 0 / 0.2);
--openui-text-neutral-link: oklch(0.097 0 0 / 1);
--openui-text-brand: oklch(0.546 0.215 262.881 / 1);
@@ -144,84 +144,86 @@
--openui-font-size-3xl: 28px;
--openui-font-size-4xl: 32px;
--openui-font-size-5xl: 36px;
- --openui-font-weight-regular: 375;
- --openui-font-weight-medium: 475;
+ --openui-font-weight-regular: 400;
+ --openui-font-weight-medium: 560;
--openui-font-weight-bold: 600;
--openui-font-weight-heavy: 700;
+ --openui-font-variation-regular: "wght" 440;
+ --openui-font-variation-medium: "wght" 560;
--openui-line-height-body: 1.5;
--openui-line-height-heading: 1.25;
--openui-line-height-heading-large: 1.1;
--openui-line-height-label: 1.25;
--openui-line-height-code: 1.5;
- --openui-letter-spacing-normal: 0;
+ --openui-letter-spacing-normal: -0.01em;
--openui-letter-spacing-tight: -0.1px;
--openui-letter-spacing-tighter: -0.2px;
--openui-text-body-xs: 400 12px/1.5 "Inter", sans-serif;
- --openui-text-body-xs-letter-spacing: 0;
- --openui-text-body-xs-heavy: 500 12px/1.5 "Inter", sans-serif;
- --openui-text-body-xs-heavy-letter-spacing: 0;
+ --openui-text-body-xs-letter-spacing: -0.01em;
+ --openui-text-body-xs-heavy: 560 12px/1.5 "Inter", sans-serif;
+ --openui-text-body-xs-heavy-letter-spacing: -0.01em;
--openui-text-body-sm: 400 14px/1.5 "Inter", sans-serif;
- --openui-text-body-sm-letter-spacing: 0;
- --openui-text-body-sm-heavy: 500 14px/1.5 "Inter", sans-serif;
- --openui-text-body-sm-heavy-letter-spacing: 0;
+ --openui-text-body-sm-letter-spacing: -0.01em;
+ --openui-text-body-sm-heavy: 560 14px/1.5 "Inter", sans-serif;
+ --openui-text-body-sm-heavy-letter-spacing: -0.01em;
--openui-text-body-default: 400 16px/1.5 "Inter", sans-serif;
- --openui-text-body-default-letter-spacing: 0;
- --openui-text-body-default-heavy: 500 16px/1.5 "Inter", sans-serif;
- --openui-text-body-default-heavy-letter-spacing: 0;
+ --openui-text-body-default-letter-spacing: -0.01em;
+ --openui-text-body-default-heavy: 560 16px/1.5 "Inter", sans-serif;
+ --openui-text-body-default-heavy-letter-spacing: -0.01em;
--openui-text-body-lg: 400 18px/1.5 "Inter", sans-serif;
- --openui-text-body-lg-letter-spacing: 0;
- --openui-text-body-lg-heavy: 500 18px/1.5 "Inter", sans-serif;
- --openui-text-body-lg-heavy-letter-spacing: 0;
+ --openui-text-body-lg-letter-spacing: -0.01em;
+ --openui-text-body-lg-heavy: 560 18px/1.5 "Inter", sans-serif;
+ --openui-text-body-lg-heavy-letter-spacing: -0.01em;
--openui-text-heading-xs: 600 16px/1.25 "Inter", sans-serif;
- --openui-text-heading-xs-letter-spacing: 0;
+ --openui-text-heading-xs-letter-spacing: -0.01em;
--openui-text-heading-sm: 600 18px/1.25 "Inter", sans-serif;
- --openui-text-heading-sm-letter-spacing: 0;
+ --openui-text-heading-sm-letter-spacing: -0.01em;
--openui-text-heading-md: 600 24px/1.1 "Inter", sans-serif;
- --openui-text-heading-md-letter-spacing: 0;
+ --openui-text-heading-md-letter-spacing: -0.01em;
--openui-text-heading-lg: 600 28px/1.1 "Inter", sans-serif;
--openui-text-heading-lg-letter-spacing: -0.1px;
--openui-text-heading-xl: 700 32px/1.1 "Inter", sans-serif;
--openui-text-heading-xl-letter-spacing: -0.1px;
--openui-text-label-xs: 400 12px/1.25 "Inter", sans-serif;
- --openui-text-label-xs-letter-spacing: 0;
- --openui-text-label-xs-heavy: 500 12px/1.25 "Inter", sans-serif;
- --openui-text-label-xs-heavy-letter-spacing: 0;
+ --openui-text-label-xs-letter-spacing: -0.01em;
+ --openui-text-label-xs-heavy: 560 12px/1.25 "Inter", sans-serif;
+ --openui-text-label-xs-heavy-letter-spacing: -0.01em;
--openui-text-label-sm: 400 14px/1.25 "Inter", sans-serif;
- --openui-text-label-sm-letter-spacing: 0;
- --openui-text-label-sm-heavy: 500 14px/1.25 "Inter", sans-serif;
- --openui-text-label-sm-heavy-letter-spacing: 0;
+ --openui-text-label-sm-letter-spacing: -0.01em;
+ --openui-text-label-sm-heavy: 560 14px/1.25 "Inter", sans-serif;
+ --openui-text-label-sm-heavy-letter-spacing: -0.01em;
--openui-text-label-default: 400 16px/1.25 "Inter", sans-serif;
- --openui-text-label-default-letter-spacing: 0;
- --openui-text-label-default-heavy: 500 16px/1.25 "Inter", sans-serif;
- --openui-text-label-default-heavy-letter-spacing: 0;
+ --openui-text-label-default-letter-spacing: -0.01em;
+ --openui-text-label-default-heavy: 560 16px/1.25 "Inter", sans-serif;
+ --openui-text-label-default-heavy-letter-spacing: -0.01em;
--openui-text-label-lg: 400 18px/1.25 "Inter", sans-serif;
- --openui-text-label-lg-letter-spacing: 0;
- --openui-text-label-lg-heavy: 500 18px/1.25 "Inter", sans-serif;
- --openui-text-label-lg-heavy-letter-spacing: 0;
+ --openui-text-label-lg-letter-spacing: -0.01em;
+ --openui-text-label-lg-heavy: 560 18px/1.25 "Inter", sans-serif;
+ --openui-text-label-lg-heavy-letter-spacing: -0.01em;
--openui-text-numbers-xs: 400 12px/1.5 "Inter", sans-serif;
- --openui-text-numbers-xs-letter-spacing: 0;
- --openui-text-numbers-xs-heavy: 500 12px/1.5 "Inter", sans-serif;
- --openui-text-numbers-xs-heavy-letter-spacing: 0;
+ --openui-text-numbers-xs-letter-spacing: -0.01em;
+ --openui-text-numbers-xs-heavy: 560 12px/1.5 "Inter", sans-serif;
+ --openui-text-numbers-xs-heavy-letter-spacing: -0.01em;
--openui-text-numbers-sm: 400 14px/1.5 "Inter", sans-serif;
- --openui-text-numbers-sm-letter-spacing: 0;
- --openui-text-numbers-sm-heavy: 500 14px/1.5 "Inter", sans-serif;
- --openui-text-numbers-sm-heavy-letter-spacing: 0;
+ --openui-text-numbers-sm-letter-spacing: -0.01em;
+ --openui-text-numbers-sm-heavy: 560 14px/1.5 "Inter", sans-serif;
+ --openui-text-numbers-sm-heavy-letter-spacing: -0.01em;
--openui-text-numbers-default: 400 16px/1.5 "Inter", sans-serif;
- --openui-text-numbers-default-letter-spacing: 0;
- --openui-text-numbers-default-heavy: 500 16px/1.5 "Inter", sans-serif;
- --openui-text-numbers-default-heavy-letter-spacing: 0;
+ --openui-text-numbers-default-letter-spacing: -0.01em;
+ --openui-text-numbers-default-heavy: 560 16px/1.5 "Inter", sans-serif;
+ --openui-text-numbers-default-heavy-letter-spacing: -0.01em;
--openui-text-numbers-lg: 400 18px/1.5 "Inter", sans-serif;
- --openui-text-numbers-lg-letter-spacing: 0;
- --openui-text-numbers-lg-heavy: 500 18px/1.5 "Inter", sans-serif;
- --openui-text-numbers-lg-heavy-letter-spacing: 0;
+ --openui-text-numbers-lg-letter-spacing: -0.01em;
+ --openui-text-numbers-lg-heavy: 560 18px/1.5 "Inter", sans-serif;
+ --openui-text-numbers-lg-heavy-letter-spacing: -0.01em;
--openui-text-numbers-heading-sm: 600 18px/1.25 "Inter", sans-serif;
- --openui-text-numbers-heading-sm-letter-spacing: 0;
+ --openui-text-numbers-heading-sm-letter-spacing: -0.01em;
--openui-text-numbers-heading-md: 600 24px/1.1 "Inter", sans-serif;
- --openui-text-numbers-heading-md-letter-spacing: 0;
+ --openui-text-numbers-heading-md-letter-spacing: -0.01em;
--openui-text-numbers-heading-lg: 600 28px/1.1 "Inter", sans-serif;
- --openui-text-numbers-heading-lg-letter-spacing: 0;
+ --openui-text-numbers-heading-lg-letter-spacing: -0.01em;
--openui-text-numbers-heading-xl: 600 32px/1.1 "Inter", sans-serif;
- --openui-text-numbers-heading-xl-letter-spacing: 0;
+ --openui-text-numbers-heading-xl-letter-spacing: -0.01em;
--openui-text-code-sm: 400 12px/1.5 "SFMono-Regular", Menlo, monospace;
--openui-text-code-sm-letter-spacing: 0;
--openui-text-code-sm-heavy: 700 12px/1.5 "SFMono-Regular", Menlo, monospace;
@@ -243,7 +245,7 @@
}
@media (prefers-color-scheme: dark) {
- :root {
+ :root:not([data-openui-theme="light"]) {
// Surface / Background Colors
@@ -273,7 +275,7 @@
// Text Colors
--openui-text-neutral-primary: oklch(0.985 0 89.876 / 1);
- --openui-text-neutral-secondary: oklch(0.985 0 89.876 / 0.5);
+ --openui-text-neutral-secondary: oklch(0.985 0 89.876 / 0.6);
--openui-text-neutral-tertiary: oklch(0.985 0 89.876 / 0.2);
--openui-text-neutral-link: oklch(0.985 0 89.876 / 1);
--openui-text-brand: oklch(0.546 0.215 262.881 / 1);
@@ -388,84 +390,86 @@
--openui-font-size-3xl: 28px;
--openui-font-size-4xl: 32px;
--openui-font-size-5xl: 36px;
- --openui-font-weight-regular: 375;
- --openui-font-weight-medium: 475;
+ --openui-font-weight-regular: 400;
+ --openui-font-weight-medium: 560;
--openui-font-weight-bold: 600;
--openui-font-weight-heavy: 700;
+ --openui-font-variation-regular: "wght" 420;
+ --openui-font-variation-medium: "wght" 560;
--openui-line-height-body: 1.5;
--openui-line-height-heading: 1.25;
--openui-line-height-heading-large: 1.1;
--openui-line-height-label: 1.25;
--openui-line-height-code: 1.5;
- --openui-letter-spacing-normal: 0;
+ --openui-letter-spacing-normal: -0.01em;
--openui-letter-spacing-tight: -0.1px;
--openui-letter-spacing-tighter: -0.2px;
--openui-text-body-xs: 400 12px/1.5 "Inter", sans-serif;
- --openui-text-body-xs-letter-spacing: 0;
- --openui-text-body-xs-heavy: 500 12px/1.5 "Inter", sans-serif;
- --openui-text-body-xs-heavy-letter-spacing: 0;
+ --openui-text-body-xs-letter-spacing: -0.01em;
+ --openui-text-body-xs-heavy: 560 12px/1.5 "Inter", sans-serif;
+ --openui-text-body-xs-heavy-letter-spacing: -0.01em;
--openui-text-body-sm: 400 14px/1.5 "Inter", sans-serif;
- --openui-text-body-sm-letter-spacing: 0;
- --openui-text-body-sm-heavy: 500 14px/1.5 "Inter", sans-serif;
- --openui-text-body-sm-heavy-letter-spacing: 0;
+ --openui-text-body-sm-letter-spacing: -0.01em;
+ --openui-text-body-sm-heavy: 560 14px/1.5 "Inter", sans-serif;
+ --openui-text-body-sm-heavy-letter-spacing: -0.01em;
--openui-text-body-default: 400 16px/1.5 "Inter", sans-serif;
- --openui-text-body-default-letter-spacing: 0;
- --openui-text-body-default-heavy: 500 16px/1.5 "Inter", sans-serif;
- --openui-text-body-default-heavy-letter-spacing: 0;
+ --openui-text-body-default-letter-spacing: -0.01em;
+ --openui-text-body-default-heavy: 560 16px/1.5 "Inter", sans-serif;
+ --openui-text-body-default-heavy-letter-spacing: -0.01em;
--openui-text-body-lg: 400 18px/1.5 "Inter", sans-serif;
- --openui-text-body-lg-letter-spacing: 0;
- --openui-text-body-lg-heavy: 500 18px/1.5 "Inter", sans-serif;
- --openui-text-body-lg-heavy-letter-spacing: 0;
+ --openui-text-body-lg-letter-spacing: -0.01em;
+ --openui-text-body-lg-heavy: 560 18px/1.5 "Inter", sans-serif;
+ --openui-text-body-lg-heavy-letter-spacing: -0.01em;
--openui-text-heading-xs: 600 16px/1.25 "Inter", sans-serif;
- --openui-text-heading-xs-letter-spacing: 0;
+ --openui-text-heading-xs-letter-spacing: -0.01em;
--openui-text-heading-sm: 600 18px/1.25 "Inter", sans-serif;
- --openui-text-heading-sm-letter-spacing: 0;
+ --openui-text-heading-sm-letter-spacing: -0.01em;
--openui-text-heading-md: 600 24px/1.1 "Inter", sans-serif;
- --openui-text-heading-md-letter-spacing: 0;
+ --openui-text-heading-md-letter-spacing: -0.01em;
--openui-text-heading-lg: 600 28px/1.1 "Inter", sans-serif;
--openui-text-heading-lg-letter-spacing: -0.1px;
--openui-text-heading-xl: 700 32px/1.1 "Inter", sans-serif;
--openui-text-heading-xl-letter-spacing: -0.1px;
--openui-text-label-xs: 400 12px/1.25 "Inter", sans-serif;
- --openui-text-label-xs-letter-spacing: 0;
- --openui-text-label-xs-heavy: 500 12px/1.25 "Inter", sans-serif;
- --openui-text-label-xs-heavy-letter-spacing: 0;
+ --openui-text-label-xs-letter-spacing: -0.01em;
+ --openui-text-label-xs-heavy: 560 12px/1.25 "Inter", sans-serif;
+ --openui-text-label-xs-heavy-letter-spacing: -0.01em;
--openui-text-label-sm: 400 14px/1.25 "Inter", sans-serif;
- --openui-text-label-sm-letter-spacing: 0;
- --openui-text-label-sm-heavy: 500 14px/1.25 "Inter", sans-serif;
- --openui-text-label-sm-heavy-letter-spacing: 0;
+ --openui-text-label-sm-letter-spacing: -0.01em;
+ --openui-text-label-sm-heavy: 560 14px/1.25 "Inter", sans-serif;
+ --openui-text-label-sm-heavy-letter-spacing: -0.01em;
--openui-text-label-default: 400 16px/1.25 "Inter", sans-serif;
- --openui-text-label-default-letter-spacing: 0;
- --openui-text-label-default-heavy: 500 16px/1.25 "Inter", sans-serif;
- --openui-text-label-default-heavy-letter-spacing: 0;
+ --openui-text-label-default-letter-spacing: -0.01em;
+ --openui-text-label-default-heavy: 560 16px/1.25 "Inter", sans-serif;
+ --openui-text-label-default-heavy-letter-spacing: -0.01em;
--openui-text-label-lg: 400 18px/1.25 "Inter", sans-serif;
- --openui-text-label-lg-letter-spacing: 0;
- --openui-text-label-lg-heavy: 500 18px/1.25 "Inter", sans-serif;
- --openui-text-label-lg-heavy-letter-spacing: 0;
+ --openui-text-label-lg-letter-spacing: -0.01em;
+ --openui-text-label-lg-heavy: 560 18px/1.25 "Inter", sans-serif;
+ --openui-text-label-lg-heavy-letter-spacing: -0.01em;
--openui-text-numbers-xs: 400 12px/1.5 "Inter", sans-serif;
- --openui-text-numbers-xs-letter-spacing: 0;
- --openui-text-numbers-xs-heavy: 500 12px/1.5 "Inter", sans-serif;
- --openui-text-numbers-xs-heavy-letter-spacing: 0;
+ --openui-text-numbers-xs-letter-spacing: -0.01em;
+ --openui-text-numbers-xs-heavy: 560 12px/1.5 "Inter", sans-serif;
+ --openui-text-numbers-xs-heavy-letter-spacing: -0.01em;
--openui-text-numbers-sm: 400 14px/1.5 "Inter", sans-serif;
- --openui-text-numbers-sm-letter-spacing: 0;
- --openui-text-numbers-sm-heavy: 500 14px/1.5 "Inter", sans-serif;
- --openui-text-numbers-sm-heavy-letter-spacing: 0;
+ --openui-text-numbers-sm-letter-spacing: -0.01em;
+ --openui-text-numbers-sm-heavy: 560 14px/1.5 "Inter", sans-serif;
+ --openui-text-numbers-sm-heavy-letter-spacing: -0.01em;
--openui-text-numbers-default: 400 16px/1.5 "Inter", sans-serif;
- --openui-text-numbers-default-letter-spacing: 0;
- --openui-text-numbers-default-heavy: 500 16px/1.5 "Inter", sans-serif;
- --openui-text-numbers-default-heavy-letter-spacing: 0;
+ --openui-text-numbers-default-letter-spacing: -0.01em;
+ --openui-text-numbers-default-heavy: 560 16px/1.5 "Inter", sans-serif;
+ --openui-text-numbers-default-heavy-letter-spacing: -0.01em;
--openui-text-numbers-lg: 400 18px/1.5 "Inter", sans-serif;
- --openui-text-numbers-lg-letter-spacing: 0;
- --openui-text-numbers-lg-heavy: 500 18px/1.5 "Inter", sans-serif;
- --openui-text-numbers-lg-heavy-letter-spacing: 0;
+ --openui-text-numbers-lg-letter-spacing: -0.01em;
+ --openui-text-numbers-lg-heavy: 560 18px/1.5 "Inter", sans-serif;
+ --openui-text-numbers-lg-heavy-letter-spacing: -0.01em;
--openui-text-numbers-heading-sm: 600 18px/1.25 "Inter", sans-serif;
- --openui-text-numbers-heading-sm-letter-spacing: 0;
+ --openui-text-numbers-heading-sm-letter-spacing: -0.01em;
--openui-text-numbers-heading-md: 600 24px/1.1 "Inter", sans-serif;
- --openui-text-numbers-heading-md-letter-spacing: 0;
+ --openui-text-numbers-heading-md-letter-spacing: -0.01em;
--openui-text-numbers-heading-lg: 600 28px/1.1 "Inter", sans-serif;
- --openui-text-numbers-heading-lg-letter-spacing: 0;
+ --openui-text-numbers-heading-lg-letter-spacing: -0.01em;
--openui-text-numbers-heading-xl: 600 32px/1.1 "Inter", sans-serif;
- --openui-text-numbers-heading-xl-letter-spacing: 0;
+ --openui-text-numbers-heading-xl-letter-spacing: -0.01em;
--openui-text-code-sm: 400 12px/1.5 "SFMono-Regular", Menlo, monospace;
--openui-text-code-sm-letter-spacing: 0;
--openui-text-code-sm-heavy: 700 12px/1.5 "SFMono-Regular", Menlo, monospace;
@@ -486,3 +490,248 @@
--openui-shadow-3xl: 0 16px 32px -8px oklch(0 0 0 / 0.24), 0 32px 64px -12px oklch(0 0 0 / 0.28);
}
}
+
+:root[data-openui-theme="dark"] {
+
+ // Surface / Background Colors
+
+ --openui-background: oklch(0.145 0 0 / 1);
+ --openui-foreground: oklch(0.205 0 0 / 1);
+ --openui-popover-background: oklch(0.205 0 0 / 1);
+ --openui-sunk-light: oklch(0.994 0 89.876 / 0.02);
+ --openui-sunk: oklch(0.994 0 89.876 / 0.04);
+ --openui-sunk-deep: oklch(0.994 0 89.876 / 0.08);
+ --openui-elevated-light: oklch(0.994 0 89.876 / 0.04);
+ --openui-elevated: oklch(0.994 0 89.876 / 0.08);
+ --openui-elevated-strong: oklch(0.994 0 89.876 / 0.16);
+ --openui-elevated-intense: oklch(0.994 0 89.876 / 0.32);
+ --openui-overlay: oklch(0 0 0 / 0.6);
+ --openui-highlight-subtle: oklch(0.994 0 89.876 / 0.02);
+ --openui-highlight: oklch(0.994 0 89.876 / 0.04);
+ --openui-highlight-strong: oklch(0.994 0 89.876 / 0.08);
+ --openui-highlight-intense: oklch(0.994 0 89.876 / 0.3);
+ --openui-inverted-background: oklch(0.994 0 89.876 / 1);
+ --openui-info-background: oklch(0.623 0.188 259.815 / 0.12);
+ --openui-success-background: oklch(0.627 0.17 149.214 / 0.12);
+ --openui-alert-background: oklch(0.795 0.162 86.047 / 0.16);
+ --openui-danger-background: oklch(0.577 0.215 27.325 / 0.12);
+ --openui-purple-background: oklch(0.627 0.233 303.9 / 0.12);
+ --openui-pink-background: oklch(0.592 0.218 0.584 / 0.12);
+
+ // Text Colors
+
+ --openui-text-neutral-primary: oklch(0.985 0 89.876 / 1);
+ --openui-text-neutral-secondary: oklch(0.985 0 89.876 / 0.6);
+ --openui-text-neutral-tertiary: oklch(0.985 0 89.876 / 0.2);
+ --openui-text-neutral-link: oklch(0.985 0 89.876 / 1);
+ --openui-text-brand: oklch(0.546 0.215 262.881 / 1);
+ --openui-text-white: oklch(1 0 89.876 / 1);
+ --openui-text-black: oklch(0 0 0 / 1);
+ --openui-text-accent-primary: oklch(0.994 0 89.876 / 1);
+ --openui-text-accent-secondary: oklch(0.994 0 89.876 / 0.5);
+ --openui-text-accent-tertiary: oklch(0.994 0 89.876 / 0.2);
+ --openui-text-success-primary: oklch(0.871 0.136 154.449 / 1);
+ --openui-text-success-inverted: oklch(0.962 0.043 156.743 / 1);
+ --openui-text-alert-primary: oklch(0.905 0.166 98.111 / 1);
+ --openui-text-alert-inverted: oklch(0.973 0.069 103.193 / 1);
+ --openui-text-danger-primary: oklch(0.808 0.103 19.571 / 1);
+ --openui-text-danger-secondary: oklch(0.885 0.059 18.334 / 1);
+ --openui-text-danger-tertiary: oklch(0.936 0.031 17.717 / 1);
+ --openui-text-danger-inverted-primary: oklch(0.982 0.009 17.303 / 1);
+ --openui-text-danger-inverted-secondary: oklch(0.982 0.009 17.303 / 0.5);
+ --openui-text-danger-inverted-tertiary: oklch(0.982 0.009 17.303 / 0.3);
+ --openui-text-info-primary: oklch(0.809 0.096 251.813 / 1);
+ --openui-text-info-inverted: oklch(0.932 0.032 255.585 / 1);
+ --openui-text-pink-primary: oklch(0.823 0.11 346.018 / 1);
+ --openui-text-pink-inverted: oklch(0.948 0.028 342.258 / 1);
+ --openui-text-purple-primary: oklch(0.827 0.108 306.383 / 1);
+ --openui-text-purple-inverted: oklch(0.946 0.033 307.174 / 1);
+
+ // Interactive Colors
+
+ --openui-interactive-accent-default: oklch(0.546 0.215 262.881 / 1);
+ --openui-interactive-accent-hover: oklch(0.546 0.215 262.881 / 0.8);
+ --openui-interactive-accent-disabled: oklch(0.546 0.215 262.881 / 0.4);
+ --openui-interactive-accent-pressed: oklch(0.546 0.215 262.881 / 1);
+ --openui-interactive-destructive-default: oklch(0.577 0.215 27.325 / 0.02);
+ --openui-interactive-destructive-hover: oklch(0.577 0.215 27.325 / 0.08);
+ --openui-interactive-destructive-disabled: oklch(0.577 0.215 27.325 / 0.02);
+ --openui-interactive-destructive-pressed: oklch(0.577 0.215 27.325 / 0.1);
+ --openui-interactive-destructive-accent-default: oklch(0.577 0.215 27.325 / 1);
+ --openui-interactive-destructive-accent-hover: oklch(0.637 0.208 25.331 / 1);
+ --openui-interactive-destructive-accent-pressed: oklch(0.505 0.19 27.518 / 1);
+ --openui-interactive-destructive-accent-disabled: oklch(0.577 0.215 27.325 / 0.4);
+
+ // Chat Colors
+
+ --openui-chat-user-response-bg: oklch(0.994 0 89.876 / 0.08);
+ --openui-chat-user-response-text: oklch(0.985 0 89.876 / 1);
+
+ // Border Colors
+
+ --openui-border-default: oklch(0.994 0 89.876 / 0.06);
+ --openui-border-interactive: oklch(0.994 0 89.876 / 0.12);
+ --openui-border-interactive-emphasis: oklch(0.994 0 89.876 / 0.4);
+ --openui-border-interactive-selected: oklch(0.985 0 89.876 / 1);
+ --openui-border-accent: oklch(0.546 0.215 262.881 / 0.2);
+ --openui-border-accent-emphasis: oklch(0.546 0.215 262.881 / 0.4);
+ --openui-border-info: oklch(0.623 0.188 259.815 / 0.08);
+ --openui-border-info-emphasis: oklch(0.546 0.215 262.881 / 1);
+ --openui-border-alert: oklch(0.861 0.173 91.936 / 0.08);
+ --openui-border-alert-emphasis: oklch(0.681 0.142 75.834 / 1);
+ --openui-border-success: oklch(0.627 0.17 149.214 / 0.08);
+ --openui-border-success-emphasis: oklch(0.627 0.17 149.214 / 1);
+ --openui-border-danger: oklch(0.577 0.215 27.325 / 0.08);
+ --openui-border-danger-emphasis: oklch(0.577 0.215 27.325 / 1);
+
+ // Spacing
+
+ --openui-space-000: 0;
+ --openui-space-3xs: 2px;
+ --openui-space-2xs: 4px;
+ --openui-space-xs: 6px;
+ --openui-space-s: 8px;
+ --openui-space-s-m: 10px;
+ --openui-space-m: 12px;
+ --openui-space-m-l: 16px;
+ --openui-space-l: 18px;
+ --openui-space-xl: 24px;
+ --openui-space-2xl: 36px;
+ --openui-space-3xl: 48px;
+
+ // Border Radius
+
+ --openui-radius-none: 0;
+ --openui-radius-3xs: 1px;
+ --openui-radius-2xs: 2px;
+ --openui-radius-xs: 4px;
+ --openui-radius-s: 6px;
+ --openui-radius-m: 8px;
+ --openui-radius-l: 10px;
+ --openui-radius-xl: 12px;
+ --openui-radius-2xl: 14px;
+ --openui-radius-3xl: 16px;
+ --openui-radius-4xl: 20px;
+ --openui-radius-5xl: 24px;
+ --openui-radius-6xl: 28px;
+ --openui-radius-7xl: 32px;
+ --openui-radius-8xl: 40px;
+ --openui-radius-9xl: 48px;
+ --openui-radius-full: 9999px;
+
+ // Typography Tokens
+
+ --openui-font-body: "Inter", sans-serif;
+ --openui-font-code: "SFMono-Regular", Menlo, monospace;
+ --openui-font-heading: "Inter", sans-serif;
+ --openui-font-label: "Inter", sans-serif;
+ --openui-font-numbers: "Inter", sans-serif;
+ --openui-font-size-2xs: 10px;
+ --openui-font-size-xs: 12px;
+ --openui-font-size-sm: 14px;
+ --openui-font-size-md: 16px;
+ --openui-font-size-lg: 18px;
+ --openui-font-size-xl: 20px;
+ --openui-font-size-2xl: 24px;
+ --openui-font-size-3xl: 28px;
+ --openui-font-size-4xl: 32px;
+ --openui-font-size-5xl: 36px;
+ --openui-font-weight-regular: 400;
+ --openui-font-weight-medium: 560;
+ --openui-font-weight-bold: 600;
+ --openui-font-weight-heavy: 700;
+ --openui-font-variation-regular: "wght" 420;
+ --openui-font-variation-medium: "wght" 560;
+ --openui-line-height-body: 1.5;
+ --openui-line-height-heading: 1.25;
+ --openui-line-height-heading-large: 1.1;
+ --openui-line-height-label: 1.25;
+ --openui-line-height-code: 1.5;
+ --openui-letter-spacing-normal: -0.01em;
+ --openui-letter-spacing-tight: -0.1px;
+ --openui-letter-spacing-tighter: -0.2px;
+ --openui-text-body-xs: 400 12px/1.5 "Inter", sans-serif;
+ --openui-text-body-xs-letter-spacing: -0.01em;
+ --openui-text-body-xs-heavy: 560 12px/1.5 "Inter", sans-serif;
+ --openui-text-body-xs-heavy-letter-spacing: -0.01em;
+ --openui-text-body-sm: 400 14px/1.5 "Inter", sans-serif;
+ --openui-text-body-sm-letter-spacing: -0.01em;
+ --openui-text-body-sm-heavy: 560 14px/1.5 "Inter", sans-serif;
+ --openui-text-body-sm-heavy-letter-spacing: -0.01em;
+ --openui-text-body-default: 400 16px/1.5 "Inter", sans-serif;
+ --openui-text-body-default-letter-spacing: -0.01em;
+ --openui-text-body-default-heavy: 560 16px/1.5 "Inter", sans-serif;
+ --openui-text-body-default-heavy-letter-spacing: -0.01em;
+ --openui-text-body-lg: 400 18px/1.5 "Inter", sans-serif;
+ --openui-text-body-lg-letter-spacing: -0.01em;
+ --openui-text-body-lg-heavy: 560 18px/1.5 "Inter", sans-serif;
+ --openui-text-body-lg-heavy-letter-spacing: -0.01em;
+ --openui-text-heading-xs: 600 16px/1.25 "Inter", sans-serif;
+ --openui-text-heading-xs-letter-spacing: -0.01em;
+ --openui-text-heading-sm: 600 18px/1.25 "Inter", sans-serif;
+ --openui-text-heading-sm-letter-spacing: -0.01em;
+ --openui-text-heading-md: 600 24px/1.1 "Inter", sans-serif;
+ --openui-text-heading-md-letter-spacing: -0.01em;
+ --openui-text-heading-lg: 600 28px/1.1 "Inter", sans-serif;
+ --openui-text-heading-lg-letter-spacing: -0.1px;
+ --openui-text-heading-xl: 700 32px/1.1 "Inter", sans-serif;
+ --openui-text-heading-xl-letter-spacing: -0.1px;
+ --openui-text-label-xs: 400 12px/1.25 "Inter", sans-serif;
+ --openui-text-label-xs-letter-spacing: -0.01em;
+ --openui-text-label-xs-heavy: 560 12px/1.25 "Inter", sans-serif;
+ --openui-text-label-xs-heavy-letter-spacing: -0.01em;
+ --openui-text-label-sm: 400 14px/1.25 "Inter", sans-serif;
+ --openui-text-label-sm-letter-spacing: -0.01em;
+ --openui-text-label-sm-heavy: 560 14px/1.25 "Inter", sans-serif;
+ --openui-text-label-sm-heavy-letter-spacing: -0.01em;
+ --openui-text-label-default: 400 16px/1.25 "Inter", sans-serif;
+ --openui-text-label-default-letter-spacing: -0.01em;
+ --openui-text-label-default-heavy: 560 16px/1.25 "Inter", sans-serif;
+ --openui-text-label-default-heavy-letter-spacing: -0.01em;
+ --openui-text-label-lg: 400 18px/1.25 "Inter", sans-serif;
+ --openui-text-label-lg-letter-spacing: -0.01em;
+ --openui-text-label-lg-heavy: 560 18px/1.25 "Inter", sans-serif;
+ --openui-text-label-lg-heavy-letter-spacing: -0.01em;
+ --openui-text-numbers-xs: 400 12px/1.5 "Inter", sans-serif;
+ --openui-text-numbers-xs-letter-spacing: -0.01em;
+ --openui-text-numbers-xs-heavy: 560 12px/1.5 "Inter", sans-serif;
+ --openui-text-numbers-xs-heavy-letter-spacing: -0.01em;
+ --openui-text-numbers-sm: 400 14px/1.5 "Inter", sans-serif;
+ --openui-text-numbers-sm-letter-spacing: -0.01em;
+ --openui-text-numbers-sm-heavy: 560 14px/1.5 "Inter", sans-serif;
+ --openui-text-numbers-sm-heavy-letter-spacing: -0.01em;
+ --openui-text-numbers-default: 400 16px/1.5 "Inter", sans-serif;
+ --openui-text-numbers-default-letter-spacing: -0.01em;
+ --openui-text-numbers-default-heavy: 560 16px/1.5 "Inter", sans-serif;
+ --openui-text-numbers-default-heavy-letter-spacing: -0.01em;
+ --openui-text-numbers-lg: 400 18px/1.5 "Inter", sans-serif;
+ --openui-text-numbers-lg-letter-spacing: -0.01em;
+ --openui-text-numbers-lg-heavy: 560 18px/1.5 "Inter", sans-serif;
+ --openui-text-numbers-lg-heavy-letter-spacing: -0.01em;
+ --openui-text-numbers-heading-sm: 600 18px/1.25 "Inter", sans-serif;
+ --openui-text-numbers-heading-sm-letter-spacing: -0.01em;
+ --openui-text-numbers-heading-md: 600 24px/1.1 "Inter", sans-serif;
+ --openui-text-numbers-heading-md-letter-spacing: -0.01em;
+ --openui-text-numbers-heading-lg: 600 28px/1.1 "Inter", sans-serif;
+ --openui-text-numbers-heading-lg-letter-spacing: -0.01em;
+ --openui-text-numbers-heading-xl: 600 32px/1.1 "Inter", sans-serif;
+ --openui-text-numbers-heading-xl-letter-spacing: -0.01em;
+ --openui-text-code-sm: 400 12px/1.5 "SFMono-Regular", Menlo, monospace;
+ --openui-text-code-sm-letter-spacing: 0;
+ --openui-text-code-sm-heavy: 700 12px/1.5 "SFMono-Regular", Menlo, monospace;
+ --openui-text-code-sm-heavy-letter-spacing: 0;
+ --openui-text-code-default: 400 14px/1.5 "SFMono-Regular", Menlo, monospace;
+ --openui-text-code-default-letter-spacing: 0;
+ --openui-text-code-default-heavy: 700 14px/1.5 "SFMono-Regular", Menlo, monospace;
+ --openui-text-code-default-heavy-letter-spacing: 0;
+
+ // Shadows
+
+ --openui-shadow-0: none;
+ --openui-shadow-s: 0 1px 3px -2px oklch(0 0 0 / 0.06), 0 2px 5px -2px oklch(0 0 0 / 0.10);
+ --openui-shadow-m: 0 4px 6px -2px oklch(0 0 0 / 0.08), 0 2px 2px -2px oklch(0 0 0 / 0.12);
+ --openui-shadow-l: 0 4px 4px -2px oklch(0 0 0 / 0.12), 0 4px 8px -2px oklch(0 0 0 / 0.10);
+ --openui-shadow-xl: 0 8px 16px -4px oklch(0 0 0 / 0.16), 0 16px 32px -6px oklch(0 0 0 / 0.20);
+ --openui-shadow-2xl: 0 12px 24px -6px oklch(0 0 0 / 0.20), 0 24px 48px -8px oklch(0 0 0 / 0.24);
+ --openui-shadow-3xl: 0 16px 32px -8px oklch(0 0 0 / 0.24), 0 32px 64px -12px oklch(0 0 0 / 0.28);
+}
diff --git a/packages/react-ui/src/scripts/generate-css-utils.ts b/packages/react-ui/src/scripts/generate-css-utils.ts
index ecf144be0..3e78af51c 100644
--- a/packages/react-ui/src/scripts/generate-css-utils.ts
+++ b/packages/react-ui/src/scripts/generate-css-utils.ts
@@ -46,34 +46,45 @@ lines.push("$chat-container-bg: $background;");
// ─── Static typography system ────────────────────────────────────────────────
lines.push("");
lines.push(`\
-@function typography($font-name) {
- @return (font: var(--#{$font-name}), letter-spacing: var(--#{$font-name}-letter-spacing));
+// $variation picks the Inter "wght" axis token: regular or medium for the
+// theme's Regular/Medium styles, null for fixed weights (600/700, code), where
+// the font shorthand's reset leaves font-weight in charge.
+@function typography($font-name, $variation: null) {
+ $axis: null;
+ @if $variation {
+ $axis: var(--openui-font-variation-#{$variation});
+ }
+ @return (
+ font: var(--#{$font-name}),
+ letter-spacing: var(--#{$font-name}-letter-spacing),
+ variation: $axis
+ );
}
$typography: (
body: (
- default: typography(openui-text-body-default),
- heavy: typography(openui-text-body-default-heavy),
- small: typography(openui-text-body-sm),
- small-heavy: typography(openui-text-body-sm-heavy),
- large: typography(openui-text-body-lg),
- large-heavy: typography(openui-text-body-lg-heavy),
- link: typography(openui-text-body-default),
- medium: typography(openui-text-body-default),
+ default: typography(openui-text-body-default, regular),
+ heavy: typography(openui-text-body-default-heavy, medium),
+ small: typography(openui-text-body-sm, regular),
+ small-heavy: typography(openui-text-body-sm-heavy, medium),
+ large: typography(openui-text-body-lg, regular),
+ large-heavy: typography(openui-text-body-lg-heavy, medium),
+ link: typography(openui-text-body-default, regular),
+ medium: typography(openui-text-body-default, regular),
),
label: (
- default: typography(openui-text-label-default),
- heavy: typography(openui-text-label-default-heavy),
- large: typography(openui-text-label-lg),
- large-heavy: typography(openui-text-label-lg-heavy),
- medium: typography(openui-text-label-default),
- medium-heavy: typography(openui-text-label-default-heavy),
- small: typography(openui-text-label-sm),
- small-heavy: typography(openui-text-label-sm-heavy),
- extra-small: typography(openui-text-label-xs),
- extra-small-heavy: typography(openui-text-label-xs-heavy),
- 2-extra-small: typography(openui-text-label-xs),
- 2-extra-small-heavy: typography(openui-text-label-xs-heavy),
+ default: typography(openui-text-label-default, regular),
+ heavy: typography(openui-text-label-default-heavy, medium),
+ large: typography(openui-text-label-lg, regular),
+ large-heavy: typography(openui-text-label-lg-heavy, medium),
+ medium: typography(openui-text-label-default, regular),
+ medium-heavy: typography(openui-text-label-default-heavy, medium),
+ small: typography(openui-text-label-sm, regular),
+ small-heavy: typography(openui-text-label-sm-heavy, medium),
+ extra-small: typography(openui-text-label-xs, regular),
+ extra-small-heavy: typography(openui-text-label-xs-heavy, medium),
+ 2-extra-small: typography(openui-text-label-xs, regular),
+ 2-extra-small-heavy: typography(openui-text-label-xs-heavy, medium),
),
heading: (
xl: typography(openui-text-heading-xl),
@@ -83,14 +94,14 @@ $typography: (
extra-small: typography(openui-text-heading-xs),
),
number: (
- large: typography(openui-text-numbers-lg),
- large-heavy: typography(openui-text-numbers-lg-heavy),
- heavy: typography(openui-text-numbers-default-heavy),
- default: typography(openui-text-numbers-default),
- small: typography(openui-text-numbers-sm),
- small-heavy: typography(openui-text-numbers-sm-heavy),
- extra-small: typography(openui-text-numbers-xs),
- extra-small-heavy: typography(openui-text-numbers-xs-heavy),
+ large: typography(openui-text-numbers-lg, regular),
+ large-heavy: typography(openui-text-numbers-lg-heavy, medium),
+ heavy: typography(openui-text-numbers-default-heavy, medium),
+ default: typography(openui-text-numbers-default, regular),
+ small: typography(openui-text-numbers-sm, regular),
+ small-heavy: typography(openui-text-numbers-sm-heavy, medium),
+ extra-small: typography(openui-text-numbers-xs, regular),
+ extra-small-heavy: typography(openui-text-numbers-xs-heavy, medium),
heading: typography(openui-text-numbers-heading-lg),
heading-small: typography(openui-text-numbers-heading-sm),
heading-medium: typography(openui-text-numbers-heading-md),
@@ -110,6 +121,8 @@ $typography: (
@mixin typography($font-name, $font-variant) {
font: map.get($typography, $font-name, $font-variant, font);
letter-spacing: map.get($typography, $font-name, $font-variant, letter-spacing);
+ // The font shorthand resets font-variation-settings, so set the axis after it.
+ font-variation-settings: map.get($typography, $font-name, $font-variant, variation);
}
@mixin button-reset {
@@ -144,27 +157,34 @@ for (const [key, value] of entries) {
defaultsLines.push("}");
defaultsLines.push("");
-// ─── Dark mode defaults via prefers-color-scheme ─────────────────────────────
+// ─── Dark mode defaults ──────────────────────────────────────────────────────
+// Dark follows prefers-color-scheme unless the page pins a mode with
+// `data-openui-theme="light" | "dark"` on <html> (set before paint by apps with
+// a theme switcher, so the first frame is already in the chosen mode).
const darkEntries = Object.entries(defaultDarkTheme).filter(
([, value]) => typeof value === "string",
) as [string, string][];
-defaultsLines.push("@media (prefers-color-scheme: dark) {");
-defaultsLines.push(" :root {");
-
-for (const [key, value] of darkEntries) {
- if (sectionHeaders[key]) {
- defaultsLines.push("");
- defaultsLines.push(` ${sectionHeaders[key]}`);
- defaultsLines.push("");
+const pushDarkBlock = (selector: string, indent: string) => {
+ defaultsLines.push(`${indent}${selector} {`);
+ for (const [key, value] of darkEntries) {
+ if (sectionHeaders[key]) {
+ defaultsLines.push("");
+ defaultsLines.push(`${indent} ${sectionHeaders[key]}`);
+ defaultsLines.push("");
+ }
+ const kebab = camelToKebab(key);
+ defaultsLines.push(`${indent} --openui-${kebab}: ${value};`);
}
- const kebab = camelToKebab(key);
- defaultsLines.push(` --openui-${kebab}: ${value};`);
-}
+ defaultsLines.push(`${indent}}`);
+};
-defaultsLines.push(" }");
+defaultsLines.push("@media (prefers-color-scheme: dark) {");
+pushDarkBlock(':root:not([data-openui-theme="light"])', " ");
defaultsLines.push("}");
defaultsLines.push("");
+pushDarkBlock(':root[data-openui-theme="dark"]', "");
+defaultsLines.push("");
const defaultsOutputPath = path.resolve(__dirname, "../openui-defaults.scss");
fs.writeFileSync(defaultsOutputPath, defaultsLines.join("\n"));
diff --git a/packages/react-ui/src/utils/preferences.ts b/packages/react-ui/src/utils/preferences.ts
new file mode 100644
index 000000000..810e61c8c
--- /dev/null
+++ b/packages/react-ui/src/utils/preferences.ts
@@ -0,0 +1,23 @@
+// Saved UI preferences (sidebar state, theme mode): the one place that touches
+// localStorage. Values are JSON. Never throws: on the server, or with storage
+// blocked or full, reads return undefined and writes are dropped, so a
+// preference just isn't kept.
+
+export function readPreference<T>(key: string): T | undefined {
+ try {
+ const raw = window.localStorage.getItem(key);
+ return raw === null ? undefined : (JSON.parse(raw) as T);
+ } catch {
+ return undefined;
+ }
+}
+
+/** Saves `value`; `undefined` clears the key. */
+export function writePreference(key: string, value: unknown): void {
+ try {
+ if (value === undefined) window.localStorage.removeItem(key);
+ else window.localStorage.setItem(key, JSON.stringify(value));
+ } catch {
+ // Blocked or over quota.
+ }
+}