@corbits/react-ui

中文文档
0.5.1发布于 2026/11/02LGPL-2.1-onlyTypeScriptES Module近 30 天下载 4681

React components for agent and workflow surfaces.

原始使用文档
文档目录12 节
  1. Why @corbits/react-ui?
  2. Install
  3. Quickstart
  4. Where it fits
  5. Reference
  6. Theming
  7. Components
  8. For coding agents
  9. Using with Interchange
  10. Upgrading from 0.3
  11. Upgrading from 0.1
  12. License

@corbits/react-ui

React components for agent products: conversations with reasoning, tool calls and approvals, run status, artifacts and charts, styled by one Tailwind v4 token theme. The UI package of Corbits: it renders data a host web app loads from Interchange, and works in any React 18 or 19 app without Interchange.

Why @corbits/react-ui?

  1. Props in, markup out. No component fetches, subscribes or holds a client. Your data layer stays yours, and every component renders the same in stories, tests and production.
  2. Agent-shaped building blocks. Message holds a turn while Tool, Reasoning and Activity render its parts (text, reasoning, tool calls), ToolApproval asks a person before a call runs, and GateBlock and StepList cover a run that waits on a person.
  3. Pay for what you import. One root entry, the package is side-effect free apart from its CSS, and heavy peers (Radix dialog, dropdown-menu, tooltip, sonner) are optional.
  4. Server Components ready. Stateful modules ship "use client", so a React Server Components app imports them directly. Outside RSC the directive is a no-op.

Install

bun add @corbits/react-ui react react-dom lucide-react @radix-ui/react-slot

Requires Node 24 or later. Tested on React 19; the peer range also accepts React 18.2+.

Optional peers are needed only by the modules that import them. Those modules are not in the root entry, so import them by subpath:

PeerSubpaths
@radix-ui/react-dialogui/dialog, ui/command-palette, ui/sidebar-search, ui/mic-permission-dialog
@radix-ui/react-dropdown-menuui/menu
@radix-ui/react-tooltipui/tooltip
sonnerui/toast

Quickstart

Import the stylesheet once at the app root, before your own CSS, and mount ThemeProvider near the root:

import "@corbits/react-ui/styles.css";

import {
  Activity,
  Conversation,
  ConversationContent,
  ConversationItem,
  ConversationScrollButton,
  Message,
  MessageContent,
  MessageHeader,
  ThemeProvider,
  groupActivity,
  type ConversationMessage,
  type ConversationParticipant,
} from "@corbits/react-ui";

const you: ConversationParticipant = { id: "u1", kind: "person", name: "You" };
const scout: ConversationParticipant = {
  id: "a1",
  kind: "agent",
  name: "Scout",
};

const messages: ConversationMessage[] = [
  {
    id: "m1",
    author: you,
    at: "2026-01-01T09:00:00Z",
    status: "sent",
    parts: [{ kind: "text", text: "What changed in the repo today?" }],
  },
  {
    id: "m2",
    author: scout,
    at: "2026-01-01T09:00:04Z",
    status: "sent",
    parts: [
      {
        kind: "reasoning",
        text: "Check the commit log first.",
        durationMs: 1200,
      },
      {
        kind: "tool-trace",
        toolCallId: "t1",
        name: "git__log",
        status: "output-available",
        output: "3 commits",
      },
      { kind: "text", text: "Three commits landed today, all in the docs." },
    ],
  },
];

function Turn({ message }: { message: ConversationMessage }) {
  const own = message.author.id === you.id;
  return (
    <Message
      from={own ? "own" : message.author.kind}
      status={message.status}
      aria-label={own ? "You" : undefined}
    >
      {own ? null : (
        <MessageHeader name={message.author.name} at={message.at} />
      )}
      {groupActivity(message.parts).map((group) => {
        if (group.kind === "activity")
          return <Activity key={group.key} steps={group.steps} />;
        if (group.part.kind === "text")
          return <MessageContent key={group.key} text={group.part.text} />;
        return null;
      })}
    </Message>
  );
}

export function App() {
  return (
    <ThemeProvider>
      <div style={{ display: "flex", flexDirection: "column", height: 480 }}>
        <Conversation>
          <ConversationContent>
            {messages.map((message) => (
              <ConversationItem key={message.id} itemId={message.id}>
                <Turn message={message} />
              </ConversationItem>
            ))}
          </ConversationContent>
          <ConversationScrollButton />
        </Conversation>
      </div>
    </ThemeProvider>
  );
}

This renders the user message in a bubble, the agent's thinking and tool call folded into one activity line that opens onto both, and the agent's reply. Every other part kind (tool calls waiting on a person, images, sources, files) has its own component; see Chat.

styles.css includes Tailwind preflight and a base layer, so it restyles the page. If you already run Tailwind v4, import @corbits/react-ui/theme.css instead and let your build generate the utilities. Import one of the two, never both; without either, components render unstyled.

Where it fits

  • Interchange runs AI agents as principals (first-class identities with their own permissions and credentials). The hub is its multi-tenant control plane: tenants, principals, grants (permissions a principal holds) and credentials. The sidecar is the portable agent runtime.
  • Corbits is the set of published packages around Interchange that turn an agent into a product. This package is the UI bucket: it runs in the host web app and plugs into the host's data layer, not into the hub or the sidecar.
  • It pairs with the hub modules whose data it renders, such as @corbits/artifacts, @corbits/mailbox and @corbits/cron.

Reference

Import from the root; it tree-shakes to what you use. Only the optional-peer modules have their own subpath:

import { Button } from "@corbits/react-ui";
import { Toaster, toast } from "@corbits/react-ui/ui/toast";

export function SignOut() {
  return (
    <>
      <Button onClick={() => toast("Signed out.")}>Sign out</Button>
      <Toaster position="bottom-right" />
    </>
  );
}

Theming

Dark mode is a .dark class on an ancestor. With neither .dark nor .light on the root, the tokens follow prefers-color-scheme and set color-scheme for native controls; dark: utilities still need a .dark ancestor.

ThemeProvider toggles both classes and persists the choice under storageKey. Hosts that manage the class themselves add .light for an explicit light choice, since removing .dark falls back to the OS. To avoid a dark first paint for a stored light choice on a dark OS, add .light before first paint only when the stored choice is light:

<script>
  if (localStorage.getItem("corbits-theme")?.includes('"light"'))
    document.documentElement.classList.add("light");
</script>

The theme names Red Hat Display and Space Mono but does not bundle them. Load them yourself or the stack falls back to system fonts; override --font-sans and --font-mono for a face loaded under another name.

Components

Everything imports from @corbits/react-ui, except rows marked "optional peer", which import from the subpath shown; see Install.

Chat

ComponentWhat it is
ConversationScrolling conversation that settles or follows new messages; useConversation
ConversationContentThe scrolling log; a ConversationItem wraps each entry
ConversationScrollButtonJump back to the latest message
ConversationEmptyStateNo messages yet
ConversationDividerA rule with an optional label, such as a day; ConversationNotice for a system line
ConversationEarlierLoads older messages as the reader scrolls up; useHistoryWindow
ConversationMapRail of ticks, one per turn, to find your way around; useReadingPosition
ConversationThreadA reply thread headed by its parent message
MessageOne message, built from MessageAvatar, MessageHeader, MessageContent, MessageSendStatus and MessageFooter
MessageFoldFolds a very long answer to its opening
MessagePartsA message's parts as their components, any kind replaceable; keeps focus when a decided call folds
MessageActionsRow of actions under a message: MessageAction, MessageActionMenu
MessageReactionsEmoji reactions with counts
MessageRepliesReply count and time that opens the thread
ActivityA run of thinking and tool calls folded to one line; groupActivity
ReasoningAn agent's thinking, folded
ToolOne tool call that opens onto its input and output
ToolGroupTool calls that ran at the same time
ToolApprovalApprove, approve always or deny a tool call waiting on a person
GeneratedImagesImages an agent made, with placeholders while generating
SourcesNumbered citations for an answer
MediaViewerPictures, video, audio, PDFs and text full size; useMediaViewer
AttachmentsFiles as a stack, tiles or a list; useAttachments
AttachmentDropZoneArea that takes dropped files and folders; useFileDrop
PromptInputThe message box: PromptInputTextarea, PromptInputSubmit, PromptInputSuggestions; usePromptInput
PromptInputToolbarControls under the text: add menu, model and mode selects, notes
ToolPickerBrowse, search and select tools
TypingIndicatorAgent-is-typing dots
ThinkingIndicatorAnimated Corbits mark with a status label
ThinkingMarkDecorative animated Corbits mark
ThinkingLabelRotating-verb status label
ShimmerTextShimmer sweep over text
MicButtonPermission-aware microphone toggle
VoiceWaveformLive audio level bars
DictationStatusLineComposer dictation status row
MicPermissionDialogMicrophone permission prompt (optional peer, ui/mic-permission-dialog)
PanelSide panel resized from its edge; hidden panes keep their state
PanelTabsA panel's tab row: select, close, drag or keyboard to reorder; useTabs

Runs

ComponentWhat it is
LiveRunBannerStatus of a run in progress
LiveStatusLineThe single "what's happening now" line
GateBlockChrome for a run parked on a human decision
StepListVertical list of run steps and their status
HorizontalStepperHorizontal step progress
ProgressChecklistSteps of a long operation and how far along it is
TraceWaterfallRun-trace timeline, one row per span
IntakeFormInputs a workflow asks for before it runs
RunNowButtonRun something immediately
ConfirmButtonButton that asks for a second click
NowCardsAttention band of items needing action
NotificationsBellBell with count and a panel slot

Artifacts

ComponentWhat it is
ArtifactBodyOne artifact, drawn the way its kind implies
ArtifactNotice"Nothing to draw here" message for artifact viewers
BlockCardGenerative-UI block frame
ResearchBodyResearch brief and report
CompareBodySide-by-side comparison
EmbedBodySandboxed third-party embed
CsvTableCapped preview of CSV text
QuoteCardA rotating quote
ProfileCardIdentity, status, actions and channels

Charts

ComponentWhat it is
ChartFrameCaption, legend, plot, and the same data as a table
TimeSeriesChartValues over time
BarChartVertical bars
CategoryBarsDense horizontal category ranking
SparklineInline trend line
TokenMosaicShares of a whole as one stacked strip
StatGridGrid of headline numbers
AnimatedNumberNumber that counts to its new value

Layout

ComponentWhat it is
PageShellPage margins and scroll ownership
PagePanelBordered page-content frame
TopBarTitle, breadcrumbs and actions row
SidebarCollapsible navigation sidebar
SidebarSearchSearch row labelled Cmd+K (optional peer, ui/sidebar-search)
SidebarPanelSidebar with pins, body and footer
SidebarItemRowOne sidebar row
ListDetailIndex on the left, open item on the right
InspectorShellSide inspector rail
SectionTitled block of content
SettingsPanelSettings frame with optional save
LibraryPageHeaderTitle, count and controls for a library page
CardBordered content card
EmptyStateTitle, description, icon and action
RichEmptyStateEmpty state with suggested next-step actions
BootScreenScreen shown before the app loads
DitherCanvasAnimated dithered background
CorbitsMarkCorbits logo
AuthLayoutSign-in page layout
LoginFormSign-in and sign-up form, with optional SSO

Controls

ComponentWhat it is
ButtonButton with variants and sizes
InputText input
TextareaMulti-line input
SelectNative select
CheckboxCheckbox
SelectionCheckboxRow-selection checkbox
SwitchOn/off toggle
FileInputFile picker
TabsTab strip
ViewToggleGrid or rows segmented control
FilterBarRow of filters with an active-filter summary
FilterChipOne toggleable filter
KindCardGridSelectable card grid
ActionBarGrouped view controls, inline or floating
BulkActionBarActions for a multi-row selection
TableTable primitives
SortableTableTable with sortable columns
BadgeStatus label
StatusDotColored status dot
AvatarInitials or image avatar
ProviderMarkWhich service an action goes through
SkeletonLoading placeholder
DialogModal dialog (optional peer, ui/dialog)
CommandPaletteGlobal search overlay (optional peer, ui/command-palette)
MenuDropdown menu (optional peer, ui/menu)
Tooltip, InfoTooltipGeneral tooltip around any trigger, and hover info glyph (optional peer, ui/tooltip)
ToasterToast host; call toast() anywhere (optional peer, ui/toast)
ThemeProviderPersists light, dark or system mode and presets
ThemeToggleLight, dark or system switch

For coding agents

The package ships an agent skill: a short guide, usage rules and a props reference for every component. Point your agent at node_modules/@corbits/react-ui/skills/react-ui (start with SKILL.md), or copy that folder into your agent's skills directory.

Using with Interchange

The host app owns the connection to the hub; components only take props.

  1. Load run state with @intx/hub-client: createRunSession polls a workflow run's event log and exposes a seq-ordered WorkflowRunEvent timeline.
  2. Map that timeline to props: agent output to ConversationMessage parts rendered by Message inside a Conversation, a tool call waiting on a person to a PartTool carrying its ToolApprovalRecord for ToolApproval, step events to StepList items, and a run parked on a person to GateBlock.
  3. Wire callbacks back to the hub. ToolApproval's onDecide calls your hub route that resolves the awaited approval with the decision's outcome and scope; the hub checks the caller's grant, not the component. The settled record comes back on the part, and ToolApproval shows what was decided.

Upgrading from 0.3

The old chat family is removed. The conversation family replaces it: a message is a ConversationMessage whose parts are a ConversationPart[] (discriminated by kind), and the components are built from parts you compose rather than one component per screen.

  • Part, PartText, PartReasoning, PartToolTrace, PartBlock, PartFile, PartEvent and ToolTraceStatus are unchanged and still import from the root.

Removed exports and what replaces them:

RemovedUse instead
ChatThread, ChatThreadPropsConversation with ConversationContent, a ConversationItem per message and ConversationScrollButton
AgentTurn, AgentTurnPropsMessage with from="agent", MessageAvatar, MessageHeader and MessageContent, with MessageParts for the parts
MessageBubble, MessageBubblePropsMessage with MessageContent; from="own" draws the bubble
PartsRenderer, PartsRendererPropsMessageParts inside a Message; renderBlock for block parts
toolTraceToBlockStateNo replacement: Tool reads ToolTraceStatus and the approval record directly
ReasoningBlock, ReasoningBlockPropsReasoning (ReasoningTrigger, ReasoningContent) on a PartReasoning
ToolBlock, ToolBlockProps, ToolBlockStateTool (ToolHeader, ToolInput, ToolOutput) on a PartTool; the state is its ToolTraceStatus
ToolNarrative, ToolNarrativePropsTool, or ToolGroup for calls that ran together
ApprovalCard, ApprovalCardPropsToolApproval on a PartTool with a ToolApprovalRecord; onApprove, onReject and onAllowAlways become onDecide(ToolApprovalDecision), and a busy state becomes disabled
ApprovalRequest, ApprovalDetailThe PartTool itself: name and input, with the host's own account of the action as ToolApproval's children
ApprovalStateToolApprovalRecord's status for the outcome, ToolApproval's disabled while a decision is recorded
ChatInput, ChatInputPropsPromptInput with PromptInputTextarea and PromptInputSubmit; PromptInputToolbar for controls under the text
ChatAttachmentAttachmentData for Attachments, AttachmentItem from useAttachments
ChatComposer, ChatComposerPropsPromptInput, with ConversationEmptyState for an empty conversation
QuickReplyChips, QuickReplyNo replacement: suggested replies are the host's own buttons, for example inside ConversationEmptyState
ChatPanel, ChatPanelHeader, ChatPanelFooterPanel, PanelHeader and PanelContent for a side panel; put Conversation and PromptInput in your own frame
ChatMessageConversationMessage: role becomes author (ConversationParticipant), createdAt becomes at, status is required
ChatRoleConversationParticipant's kind (person or agent); a system line is a PartEvent, shown with ConversationNotice
MessageStatusConversationMessageStatus, which adds streaming
MessagePartConversationPart, discriminated by kind instead of type
TextPart, ReasoningPart, FilePartPartText, PartReasoning, PartFile
ToolPartPartTool: toolName becomes name, state becomes status, and label moves to ToolHeader's label
ToolPartStateToolTraceStatus: done becomes output-available
AgentIdentityConversationParticipant with kind: "agent"; tagline becomes role, and MessageAvatar takes initials
agentInitialsMessageAvatar, which derives initials from name
SubagentRun, SubagentStateNo replacement: the conversation model has no subagent type; show a helper's calls as PartTools or a PartToolBatch
ChatThreadSummaryNo replacement: a list of conversations is the host's own data
messageText, reasoningText, toolPartsNo replacement: filter message.parts by kind
isTurnWorkingparts.some((p) => p.kind === "tool-trace" && p.status === "running") (any tool still running; message.status === "streaming" is the whole message)
toolLabelNo replacement: ToolHeader shows the raw tool name, after the label you pass
ToolProviderMarkProviderMark with the provider read off the tool id (name.split("__")[0], for ids shaped provider__operation)
useDelayedAutofocusNo replacement: focus the element from an effect once its entrance has finished

Upgrading from 0.1

  • Install from npm. Git installs (github:corbitsdev/react-ui#<sha>) no longer build dist/.
  • Per-module subpaths are gone: import from @corbits/react-ui (import { Button } from "@corbits/react-ui").
  • ui/dialog, ui/command-palette, ui/sidebar-search, ui/mic-permission-dialog, ui/menu, ui/tooltip and ui/toast are subpath-only, and their peers are optional: import { Toaster, toast } from "@corbits/react-ui/ui/toast". Install the peer for each subpath you keep.
  • lib/csv, lib/url, lib/utils, lib/workflow-registry and ui/chat-dock-timing (removed in 0.4) are internal. Replace cn with twMerge(clsx(...)).
  • Stateful components ship "use client". Client wrappers you wrote for them still work, and can go.
  • 84 unused modules are removed, ui/command is removed, ActivityBlock is renamed ReasoningBlock (removed in 0.4; use Reasoning, see Upgrading from 0.3), and AuthLayout no longer renders DitherCanvas by default.
  • With neither .dark nor .light on the root, the theme follows the OS. Hosts that toggle .dark must add .light for an explicit light choice, or mount ThemeProvider.

License

LGPL-2.1-only. See LICENSE.

版本与发布记录

@corbits/react-ui 共发布 8 个版本,首次发布于 2026/09/25;过去 12 个月发布了 8 个版本。

版本发布日期距今
0.5.1latest2026/11/028 天前
0.5.02026/11/019 天前
0.4.02026/10/2912 天前
0.3.22026/10/2714 天前
0.3.12026/10/091 个月前
0.3.02026/10/011 个月前

关于 @corbits/react-ui 的常见问题

@corbits/react-ui 是什么?

React components for agent and workflow surfaces.

如何安装 @corbits/react-ui?

在项目目录运行 npm install @corbits/react-ui,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18.2.0 || ^19.0.0)、react-dom(^18.2.0 || ^19.0.0)、lucide-react(^0.545.0 || ^1.0.0)、@radix-ui/react-slot(^1.2.3)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@corbits/react-ui 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@corbits/react-ui 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@corbits/react-ui 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=24。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@corbits/react-ui 可以商用吗?

@corbits/react-ui 使用 LGPL-2.1-only 许可。弱 Copyleft:作为库被调用时通常不要求开源你自己的代码,但修改库本身需以 LGPL 开源;前端打包合并后的适用边界存在不同理解。以上为概括,不构成法律意见,请以许可原文为准。

@corbits/react-ui 的下载量有多少?

根据 npm 官方下载统计,@corbits/react-ui 在 2026/10/11 – 2026/11/09 这 30 天内被下载 4,681 次,日均约 156 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@corbits/react-ui 还在维护吗?

最新版本 0.5.1 发布于 2026/11/02(8 天前);至今共发布 8 个版本,其中过去 12 个月发布了 8 个;首次发布于 2026/09/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。