Skip to Content

Diagrams, kanban, AI chat

Screens beyond tables and forms, built with libraries already in your app: edit a process as a diagram, view an org chart, drag cards on a kanban board, chat with AI.

Four libraries ship with the app (@xyflow/react, @ant-design/graphs, @dnd-kit/*, @ant-design/x). Import them directly, no install. Each example is a complete app/page.tsx to copy as a starting point: an approval flow editor, an org chart, an order kanban, an AI assistant.

Shortcut: an AI assistant with its server side (a *.agent.ts file, stored conversations, tools on your app’s real data, every step shown as it happens, changes to data waiting for the user’s approval) comes ready with block_add("ai-assistant"), so ask your agent to add it instead of writing it.

Edit a process as a diagram

When users need to draw or change a process (approval steps, a handling flow), use @xyflow/react: ReactFlow, useNodesState, useEdgesState, addEdge, and custom nodes with Handle.

Workflow designer (React Flow)Approval workflow designer: @xyflow/react drag-and-drop nodes, connect edges, add steps, save as JSON (CSS is in the vendor bundle — do not import .css).
example.manh.run · sample dataOpen in editor ↗
The example runs when you scroll to it

Save the whole diagram as JSON { nodes, edges } through the app’s API.

app/workflows/[id:int]/page.tsx
const [nodes, setNodes, onNodesChange] = useNodesState<Node<StepData>>(initialNodes); const [edges, setEdges, onEdgesChange] = useEdgesState<Edge>(initialEdges); const onConnect = useCallback((c: Connection) => setEdges((eds) => addEdge(c, eds)), [setEdges]); const save = () => api.workflows.update(id, { graph: JSON.stringify({ nodes, edges }) }); <Flex style={{ height: 520 }}> {/* the container needs a fixed height */} <ReactFlow nodes={nodes} edges={edges} onNodesChange={onNodesChange} onEdgesChange={onEdgesChange} onConnect={onConnect} nodeTypes={nodeTypes} fitView> <Background /><MiniMap pannable zoomable /><Controls /> </ReactFlow> </Flex>

Color nodes with theme.useToken() so the diagram follows the app’s light and dark themes.

View an org chart

For view-only diagrams built from data (org charts, flows, mind maps), use @ant-design/graphs: OrganizationChart, FlowGraph, MindMap, FlowDirectionGraph.

Org chart (graphs)Read-only org chart: @ant-design/graphs OrganizationChart from department data (G6: { nodes: [{ id, data }], edges }).
example.manh.run · sample dataOpen in editor ↗
The example runs when you scroll to it
app/org/page.tsx
const data = { nodes: people.map((p) => ({ id: p.id, data: { name: p.name } })), edges: people.filter((p) => p.manager).map((p) => ({ source: p.manager, target: p.id })), }; <div style={{ height: 520 }}> <OrganizationChart data={data} labelField={(d) => d.data.name} autoFit="view" /> </div>

Drag-and-drop kanban

A kanban board lets users change a stage by dragging a card to another column. Use @dnd-kit/core: DndContext, useDraggable, useDroppable, DragOverlay. Show a column’s status colour as a Badge dot or a Tag next to its name, not as a thick coloured border on top of the column or card.

Drag-and-drop kanban (dnd-kit)Customer pipeline kanban: @dnd-kit drags cards between columns, count and total value per column, ProCard cards on antd tokens.
example.manh.run · sample dataOpen in editor ↗
The example runs when you scroll to it

Save the new stage in onDragEnd, then reload the list.

app/deals/page.tsx
// A drag starts only after 5px, so clicking a card still opens it const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 5 } })); const onDragEnd = async (e: DragEndEvent) => { setActive(null); const to = e.over?.id as Stage | undefined; if (!to) return; await api.deals.update(Number(e.active.id), { stage: to }); refresh(); }; <DndContext sensors={sensors} onDragStart={(e) => setActive(String(e.active.id))} onDragEnd={onDragEnd}> <Flex gap={12} wrap align="flex-start"> {STAGES.map((s) => <Column key={s.key} stage={s} deals={byStage[s.key]} />)} </Flex> <DragOverlay>{active ? <DealCard deal={find(active)} /> : null}</DragOverlay> </DndContext>

To reorder rows in a table, use DragSortTable from pro-components.

AI chat

A chat panel uses @ant-design/x: Welcome and Prompts before the first message, Bubble.List for the conversation, and Sender for the input. Render AI answers with <XMarkdown content> from @ant-design/x-markdown.

AI assistant (antd X)In-app AI assistant: antd X (Welcome, Prompts, Bubble.List, Sender) + XMarkdown; the answer is a simulated stream (real apps: the "ai-assistant" lego block).
example.manh.run · sample dataOpen in editor ↗
The example runs when you scroll to it

The server side (storing conversations, letting the AI call tools on your app’s data with the user’s own permissions, approval before any change to data, a stop button) comes ready in the ai-assistant block; the example below only simulates the answer. Ask your agent to add the block instead of writing it. The server runs the agent with manh/agent.

Live updates

When someone else changes data (drags a card, approves an order), your screen reloads right away. The handler sends a signal after a successful write; the page listens on that channel.

app/deals/[id:int]/patch.ts
import { broadcast } from "manh/realtime"; // … after the update succeeds broadcast("deals", { id: deal.id });
app/deals/page.tsx
import { useLive } from "app/hooks"; useLive("deals", () => refresh());

Good to know

  • Don’t import the CSS file of @xyflow/react. The CSS is already included, and check reports code.no-css-import.
  • The container of ReactFlow or an @ant-design/graphs chart needs a fixed height; otherwise the diagram is 0px tall.
  • Anyone who opens the app can listen on a realtime channel (except user:<id>). Send only ids or a “changed” signal, and let the page reload through the API, which checks permissions.

Next steps

Last updated