SNA

React Components and Store

Bundled UI components and chat store exports.

React Components and Store

Use these surfaces when you want a ready-made chat panel or when you want to compose your own panel from SNA primitives.

SurfacePurpose
SnaChatUIFull floating chat UI with agent auto-start. Props: children, defaultOpen?, dangerouslySkipPermissions?.
ChatPanelMain chat panel shell.
ChatHeaderHeader used by the panel.
MessageBubbleMessage renderer.
ChatInputInput composer.
ToolUseCardTool-use visualization.
TypingIndicatorAssistant progress indicator.
ResizeHandleSide-by-side panel resize handle.
useChatStoreZustand store for chat UI state and persisted message hydration.

SnaChatUI requires @radix-ui/react-tooltip as a peer dependency and must be rendered under SnaProvider.

Import paths

import { SnaChatUI } from "@sna-sdk/react/components/sna-chat-ui";
import { ChatPanel, ChatInput, MessageBubble } from "@sna-sdk/react/components/chat";
import { useChatStore } from "@sna-sdk/react/stores/chat-store";

SnaChatUI

SnaChatUI wraps the application content and manages the built-in panel layout.

<SnaProvider connection={sna.connection}>
  <SnaChatUI defaultOpen={false}>
    <App />
  </SnaChatUI>
</SnaProvider>
PropDefaultDescription
childrenrequiredMain application content. In desktop side-by-side mode, this content is placed next to the chat panel.
defaultOpenfalseInitial open state when localStorage["sna-chat-panel"] has not been set.
dangerouslySkipPermissionsfalseStarts the agent with permissionMode: "bypassPermissions". Use only in trusted local flows.

Runtime behavior:

ConcernDetail
Agent startupCalls POST /agent/start?session=<runtime session> on mount with runtime id claude-code.
Loading stateShows a full-screen connecting overlay until the startup request resolves or fails.
Open stateUses useChatStore.isOpen; a floating button appears when the panel is closed.
Keyboard shortcutCmd/Ctrl + . toggles the panel.
LayoutUses useResponsiveChat: side-by-side on desktop, overlay on tablet, fullscreen on mobile.
Tooltip providerWraps children in @radix-ui/react-tooltip provider.

Composable chat components

Use the lower-level components when the host wants its own shell, routing, or controls.

ComponentResponsibility
ChatPanelFull panel composition for a session.
ChatHeaderSession header and panel controls.
ChatInputText input composer for sending messages.
MessageBubbleRenders user, assistant, status, error, thinking, tool, and tool result messages.
ToolUseCardDisplays tool input/output metadata.
ThinkingCardDisplays thinking blocks.
ResizeHandleResizes the side-by-side panel.
TooltipLightweight wrapper around the tooltip primitive used by the chat UI.

useChatStore

The chat store owns UI state and a per-session message cache.

State/actionDescription
isOpen, setOpen, togglePanel open state.
width, setWidthDesktop panel width, clamped between 320 and 520.
activeSessionId, setActiveSessionCurrent chat session. Switching sessions lazy-loads messages.
sessionsPer-session messages and processed event IDs.
initSession, removeSessionCreates local store state and mirrors chat session create/delete to the server. The default session cannot be removed.
addMessage, clearMessagesUpdates local messages; clearing also requests server-side message deletion.
markEventProcessedDeduplicates streamed events by cursor and trims the set when it grows large.
hydrateFetches chat session metadata from /chat/sessions; messages are loaded lazily.
fetchSessionMessagesFetches /chat/sessions/<id>/messages once per session.

SnaProvider sets the store API URL and calls hydrate() by default. Pass hydrate={false} to SnaProvider when the app uses only hooks or custom UI and does not need the bundled chat store.

On this page