Skip to content
Crafts

A cursor for the agent

Craft 04 · Desktop, agents

So you see the hand, not only the result.

Cosmic Studio, my video editor, can be driven by agents. This is how you can tell where they are.

Fig. 1Claude Code driving Cosmic Studio over MCP: a seek, a split, a trim, a keyframe, then a move on the canvas.

Cosmic Studio is a video editor that agents can drive over MCP. An agent edits faster than anyone can read a timeline, and without something on screen the only account of its work is that the project looks different from a moment ago. That is the kind of thing that makes people stop trusting a tool. So the agent gets a cursor, with its name on it, and the cursor goes where a person's hand would have gone.

Every tool call the agent makes comes back to the window as an event: who called it, which tool, the arguments and the result. A single function turns that into an aim. A split points at the exact frame of the cut on that clip's lane, a trim at the clip's front edge, a new duration at its end, a keyframe at its frame, a seek or a marker at the ruler, and Save, Export, Undo or a track toggle at that control. Sixty-nine tools map this way. One that has no place a person would touch, like reading the project, moves nothing.

src/editor/agent-cursor.ts · ts
export function aimFor(work: Working, project: Project, before: Project, playhead: number): Aim | undefined {
  const a = work.arguments, r = work.result;
  const control = CONTROLS[work.tool];
  if (control) return { kind: 'control', name: control };
  const found = (clipId: string) => locate(project, clipId) ?? locate(before, clipId);
  …
  switch (work.tool) {
    case 'split_clip': return onClip(a.clipId, start => start + a.atFrameOffset);
    case 'trim_clip_start': return onClip(a.clipId, start => start);
    case 'set_clip_duration': return onClip(a.clipId, (start, duration) => start + duration);
    case 'add_keyframe': return onClip(a.clipId, () => a.frame);
    case 'roll_cut': return onClip(a.clipId, (start, duration) => start + duration);
    case 'add_marker': return { kind: 'ruler', frame: a.frame };
    case 'set_clip_properties': return { kind: 'canvas', clipId: a.clipId, frame: a.frame };
    case 'seek': return { kind: 'ruler', frame: a.frame };
    …
  }
}
Excerpt, trimmed with …. Clips are looked up in the project before the edit too, so a removed clip can still be pointed at.

Frames become screen points through the ruler, which carries its own pixels-per-frame, so the aim stays right at any zoom, and the point is clamped to the part of the timeline in view. For edits on the canvas, the window asks the Rust core for that clip's quad at that frame, after its keyframes, so the cursor lands on the clip where it actually is, tilted or scaled. Buttons only need a data-agent name; nothing threads a ref through the app for a feature that usually draws nothing.

src/editor/agent-cursor.ts · ts
const ruler = root.querySelector<HTMLElement>('[data-agent="ruler"]');
const pixelsPerFrame = Number(ruler.dataset.pixelsPerFrame);
const along = ruler.getBoundingClientRect();
const view = (ruler.closest('.filmstrip__scroll') ?? ruler).getBoundingClientRect();
const x = clamp(along.left + aim.frame * pixelsPerFrame, view.left, view.left + view.width);
if (aim.kind === 'ruler') return { x, y: centre(along).y };
const lane = root.querySelector(`[data-lane="${quoted(aim.trackId)}"]`);
return lane ? { x, y: centre(lane.getBoundingClientRect()).y } : undefined;

The cursor glides for 900 ms on a soft ease-out. The ring that marks the arrival waits 650 ms before it starts, so it opens just as the arrow lands, not while it's still travelling. Eight seconds after the last call the cursor dims to a third: an agent can stop mid-task, or lose its connection, without ever saying it's finished, and the editor must not look occupied forever. With reduced motion, it moves without the glide or the ring.

src/styles/editor.css · css
.agent-cursor {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  transform: translate(var(--agent-x), var(--agent-y));
  transition: transform 900ms cubic-bezier(0.22, 1, 0.36, 1), opacity 400ms ease;
}
.agent-cursor.is-resting { opacity: 0.35; }
.agent-cursor__ring {
  border: 2px solid var(--agent);
  opacity: 0;
  animation: agent-arrive 700ms 650ms cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes agent-arrive {
  from { transform: scale(0.4); opacity: 0.9; }
  to { transform: scale(1.3); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .agent-cursor { transition: opacity 400ms ease; }
  .agent-cursor__ring { animation: none; }
}
Excerpt.

The first version, in Cosmic Editor, announced each tool before it ran rather than after, because a long import is exactly when someone wonders what is happening. Each agent got its own colour, hashed from the name it gives when it connects, so the same agent is the same colour every session and two at once never collide, and none of them borrowed the app's lime, which already meant selected. It sat above every dialog, because an agent working while a dialog is open is when a person most needs to see it. Studio rebuilt it around where a person would act, which is what makes it read as a hand and not a highlight.