Loading component…
Loading component…
Agents working in a document like teammates in a multiplayer editor – live pointers with names, suggestions typed letter by letter and comments beside the page.
To reuse this local React demo, copy all files from the Code tab into the same folder, then import AgentCursors from ./agent-cursors.
import { AgentCursors, acceptSuggestion } from "@/components/ui/agent-cursors";
// One shared ink for all of them – their logos tell them apart (pass color to give one its own)
const agents = [
{ id: "research", name: "Researcher", avatar: <ClaudeLogo /> },
{ id: "writer", name: "Writer", avatar: <OpenAILogo /> },
];
export function Brief() {
const [doc, setDoc] = useState({ blocks, suggestions: [] });
// From your agents' stream: where each one is and what it does
const cursors = {
research: { block: "why", at: 24, select: 9, doing: "Checking the numbers" },
writer: { block: "list", at: 31, doing: "Adding detail", typing: true },
};
return (
<AgentCursors
title="Launch brief"
agents={agents}
blocks={doc.blocks}
suggestions={doc.suggestions}
cursors={cursors}
onAccept={(s) => setDoc((d) => acceptSuggestion(d.blocks, d.suggestions, s.id))}
onReject={(s) => setDoc((d) => ({ ...d, suggestions: d.suggestions.filter((x) => x.id !== s.id) }))}
/>
);
}| Name | Type | Default | Description |
|---|---|---|---|
| agents | CursorAgent[] | { id, name, color?, avatar?, tint?, cost? } – everyone who can be in the document; without a color every agent shares one ink (near-black, light in dark mode) and the logos tell them apart | |
| cursors | Record<string, AgentCursor \| null> | Per agent: { block, at?, in?, select?, point?, doing?, typing? } – where it is (a block or a comment), a selected passage or a held image, the corner or middle of an image, what it's doing (on its flag) and whether it types; null or missing means it left | |
| comments | DocComment[] | { id, agent, block, at?, x?, y?, text, open? } – comment pins on the page: on a character of the block (at), or at its top edge x along the page (0–1); y moves it down; open keeps the window open (e.g. while the agent writes), otherwise a dark round pin with the agent's mark that grows into the window on hover | |
| onResolveComment | (comment: DocComment) => void | The black check in a comment's window – remove it from your list | |
| onReply | (comment: DocComment, text: string) => void | Shows a reply field in the window; Enter sends | |
| height | number | A fixed page height in px – the rest of the document fades out towards the bottom | |
| tabs / tab / onTabChange | { id, label }[] / string / (id) => void | Tabs above the page – the open one white with a stroke; you switch the blocks and agents | |
| agents[].cost | number | Per agent: what it has cost so far – a small tag on its flag, the total in the header | |
| agents[].tint | string | Per agent: the fill of its face while you follow it – defaults to a light wash of its color | |
| formatCost | (amount: number) => string | dollars, e.g. "$0.42" | Formats every cost |
| suggestions | DocSuggestion[] | [] | { id, agent, block, at, remove?, insert?, note? } – changes waiting for you: removed text is struck through, new text underlined, both in the agent's color |
| onAccept / onReject | (suggestion: DocSuggestion) => void | From the window that opens on a suggestion – acceptSuggestion() writes one into your blocks | |
| onAcceptAll | () => void | Shows "Accept all" in the header when there is more than one suggestion | |
| following / onFollowingChange | string \| null | The agent you follow, controlled or uncontrolled – the other pointers and selections fade back | |
| title | string | "Untitled" | The document's name in the header |
| className | string | Extra class on the root | |
| acceptSuggestion | (blocks, suggestions, id) => { blocks, suggestions } | Helper: writes a suggestion into the text and moves the other suggestions in that block along |
Every position is measured from the page itself, so any width, font size or zoom works – the pointers stay on their letters while the text wraps
Comment windows open towards the bottom right – towards the left near the right edge, upwards near the bottom
Flags always sit to the bottom right of their pointer; near the right edge they are cut off rather than moved
Below 520px the page gets tighter margins and the suggestion count in the header gives way to the faces
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"