Компоненты
- Accordion
- Alert
- Alert Dialog
- Autocomplete
- Avatar
- Badge
- Breadcrumb
- Button
- Calendar
- Card
- Checkbox
- Checkbox Group
- Collapsible
- Combobox
- Command
- Date Picker
- Dialog
- DrawerNew
- Empty
- Field
- Fieldset
- Form
- Frame
- Group
- Input
- Input Group
- Kbd
- Label
- Menu
- Meter
- Number Field
- OTP FieldNew
- Pagination
- Popover
- Preview Card
- Progress
- Radio Group
- Scroll Area
- Select
- Separator
- Sheet
- Skeleton
- Slider
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toast
- Toggle
- Toggle Group
- Toolbar
- Tooltip
AI Components
- AI Components
- Chat Conversation
- Chat Message
- Chat Response
- Chat Suggestion
- Chat Prompt Input
- Chat Attachments
- Chat Code Block
- Chat Image
- Chat Inline Citation
- Chat Reasoning
- Chat Sources
- Chat Actions
- Chat Context
- Chat Loader
- Chat Task
- Chat Tool
- Chat Web Preview
- Chat Snippet
- Chat Terminal
- Chat Stack Trace
- Chat Test Results
- Chat File Tree
- Chat Environment Variables
- Chat Audio Player
- Chat Transcription
- Chat Speech Input
- Chat Mic Selector
- Chat Voice Selector
- Chat Agent
- Chat Persona
- Chat Connection
- Chat Queue
- Chat Checkpoint
- Chat Confirmation
- Chat Artifact
- Chat JSX Preview
- Chat Schema Display
- Chat Package Info
- Chat Commit
- Chat Plan
- Chat Panel
- Chat Open In Chat
- Chat Sandbox
- Chat Model Selector
- Chat Canvas
- Chat Node
- Chat Edge
Resources
Chat Canvas
Flow-граф для визуализации агентских топологий — обёртка над XYFlow с Jenny токенами.
Planner
decomposes tasks
done
Used tools · 482 tokens · last call 4s ago
Researcher
calls web_search
running
Used tools · 482 tokens · last call 4s ago
Coder
writes patches
idle
Used tools · 482 tokens · last call 4s ago
Reviewer
checks output
idle
Used tools · 482 tokens · last call 4s ago
Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.
"use client";
import type { Edge, Node, NodeTypes } from "@xyflow/react";
import { Badge } from "@/components/ui/badge";
import { ChatCanvas } from "@/components/ui/chat-canvas";
import { ChatEdge } from "@/components/ui/chat-edge";
import {
ChatNode,
ChatNodeAction,
ChatNodeContent,
ChatNodeDescription,
ChatNodeHeader,
ChatNodeTitle,
} from "@/components/ui/chat-node";
type AgentNodeData = {
name: string;
role: string;
status: "idle" | "running" | "done";
};
const AgentNode = ({ data }: { data: AgentNodeData }) => (
<ChatNode handles={{ source: true, target: true }}>
<ChatNodeHeader>
<ChatNodeTitle>{data.name}</ChatNodeTitle>
<ChatNodeDescription>{data.role}</ChatNodeDescription>
<ChatNodeAction>
<Badge variant={data.status === "running" ? "default" : "secondary"}>
{data.status}
</Badge>
</ChatNodeAction>
</ChatNodeHeader>
<ChatNodeContent>
<p className="text-muted-foreground text-xs">
Used tools · 482 tokens · last call 4s ago
</p>
</ChatNodeContent>
</ChatNode>
);
const nodeTypes: NodeTypes = { agent: AgentNode };
const edgeTypes = {
animated: ChatEdge.Animated,
temporary: ChatEdge.Temporary,
};
const nodes: Node[] = [
{
id: "planner",
type: "agent",
position: { x: 0, y: 0 },
data: { name: "Planner", role: "decomposes tasks", status: "done" },
},
{
id: "researcher",
type: "agent",
position: { x: 360, y: -120 },
data: { name: "Researcher", role: "calls web_search", status: "running" },
},
{
id: "coder",
type: "agent",
position: { x: 360, y: 120 },
data: { name: "Coder", role: "writes patches", status: "idle" },
},
{
id: "reviewer",
type: "agent",
position: { x: 720, y: 0 },
data: { name: "Reviewer", role: "checks output", status: "idle" },
},
];
const edges: Edge[] = [
{ id: "p-r", source: "planner", target: "researcher", type: "animated" },
{ id: "p-c", source: "planner", target: "coder", type: "temporary" },
{ id: "r-rv", source: "researcher", target: "reviewer", type: "temporary" },
{ id: "c-rv", source: "coder", target: "reviewer", type: "temporary" },
];
export default function Particle() {
return (
<div className="h-[480px] w-full p-4">
<ChatCanvas
edgeTypes={edgeTypes}
edges={edges}
nodeTypes={nodeTypes}
nodes={nodes}
/>
</div>
);
}
Installation
pnpm dlx shadcn@latest add @jenny/chat-canvas
Зависит от @xyflow/react. Bundle добавит ~70KB — оправдано если нужен flow-визуализатор.
Usage
import { type Node, type Edge } from "@xyflow/react";
import { ChatCanvas } from "@/components/ui/chat-canvas";
import { ChatEdge } from "@/components/ui/chat-edge";
import {
ChatNode,
ChatNodeContent,
ChatNodeHeader,
ChatNodeTitle,
} from "@/components/ui/chat-node";
const nodeTypes = {
agent: ({ data }: { data: { name: string; role: string } }) => (
<ChatNode handles={{ source: true, target: true }}>
<ChatNodeHeader>
<ChatNodeTitle>{data.name}</ChatNodeTitle>
</ChatNodeHeader>
<ChatNodeContent>{data.role}</ChatNodeContent>
</ChatNode>
),
};
const edgeTypes = {
animated: ChatEdge.Animated,
temporary: ChatEdge.Temporary,
};
const nodes: Node[] = [
{ id: "1", type: "agent", position: { x: 0, y: 0 }, data: { name: "Planner", role: "decomposes tasks" } },
{ id: "2", type: "agent", position: { x: 320, y: 0 }, data: { name: "Researcher", role: "calls web_search" } },
];
const edges: Edge[] = [
{ id: "e1-2", source: "1", target: "2", type: "animated" },
];
<ChatCanvas nodes={nodes} edges={edges} nodeTypes={nodeTypes} edgeTypes={edgeTypes} />Что в комплекте
ChatCanvas—<ReactFlow>сfitView,panOnScroll, background из Jenny токеновChatNode— card-style node с опциональными source/target handlesChatEdge.Animated— линия с движущейся точкой (data flow)ChatEdge.Temporary— пунктирная линия (pending connection)
Полная XYFlow API (nodes, edges, onNodesChange, controls, minimap и т.д.) прокидывается напрямую через props ChatCanvas.
On This Page