Компоненты
- 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 Edge
Edge-стили для ChatCanvas — Animated (data flow) и Temporary (pending).
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-edge
Usage
Зарегистрируй edge types в <ChatCanvas>:
import { ChatCanvas } from "@/components/ui/chat-canvas";
import { ChatEdge } from "@/components/ui/chat-edge";
const edgeTypes = {
animated: ChatEdge.Animated,
temporary: ChatEdge.Temporary,
};
<ChatCanvas
edgeTypes={edgeTypes}
edges={[
{ id: "e1-2", source: "1", target: "2", type: "animated" },
{ id: "e2-3", source: "2", target: "3", type: "temporary" },
]}
nodes={nodes}
/>Варианты
ChatEdge.Animated— solid bezier с движущейся точкой (<animateMotion>). Используй для активного data flow между нодами.ChatEdge.Temporary— пунктирная линия (stroke-dasharray: 5,5). Используй для pending соединений — например, пока агент решает к кому подключиться.
Оба используют CSS-токены --color-ring / --color-primary, поэтому темы работают из коробки.
On This Page