Skip to content
Star

Reasoning trail

The agent's plan, notes, sources and edits, after it thinks. Free and MIT licensed, as HTML, a typed React component or an Astro component, in three styles with light and dark mode.

$npx designme add reasoning-trail
$npx shadcn@latest add https://designme.dev/r/shadcn/reasoning-trail.json

Need this designed into your product? Book a call

01

Install

Add it to your project with the CLI.

HTML, CSS and JS

$npx designme add reasoning-trail

React

$npx designme add reasoning-trail --react

Astro

$npx designme add reasoning-trail --astro

shadcn, React

$npx shadcn@latest add https://designme.dev/r/shadcn/reasoning-trail.json

shadcn, Astro

$npx shadcn@latest add https://designme.dev/r/shadcn/astro/reasoning-trail.json

The CLI copies the source into your project, so you own it and can change anything. Where each version lands, what it needs and the shadcn theme bridge: Installation.

02

About

What it is for and what it does.

Reasoning trail is a foldable record of how an agent worked through a task: its plan, its notes, the sources it used and the edits it made. It sits in a chat thread under a header that reads "Reasoning" with a running clock, then "Reasoned for Ns" once the agent is done.

  • When people want to check how the agent reached its answer before they trust it.
  • When the agent follows a plan and you want each step to show as done, in progress or next.
  • When the agent changed files and people should see the removed and added lines in place.
  • When the reasoning should stay out of the way until someone opens it.
03

Usage

Import it in React and drive it from your own state, or place it in an Astro page.

React

import { ReasoningTrail } from '@/components/designme/reasoning-trail/ReasoningTrail';

React example

The demo above as a React component, 77 lines you can copy.

'use client';
// The animated preview from designme.dev, rebuilt from the React component: an example of driving it from your own state.
import { useRef, useState } from 'react';
import { useIsoLayoutEffect } from '../lib/hooks';
import { ReasoningTrail, type Edit, type PlanStep, type ReasoningTrailProps, type ReasoningTrailView } from './ReasoningTrail';
import { Seg, type Source } from '../lib/motion';
import { Demo } from '../lib/Demo';
import { useScript } from '../lib/useScript';

/* ---------- Reasoning trail: each view fills in as the run makes it, then the trail settles ---------- */
const VIEWS: ReasoningTrailView[] = ['plan', 'notes', 'sources', 'edits'];
const PLAN = [['Open the onboarding file', '4 frames'], ['Compare it with the design system', '12 components'], ['Find spacing that breaks the 8px grid', '3 frames'], ['Draft fixes for review', 'Ready']];
const NOTES = ['The hero card uses 20px padding, every other card uses 24px.', 'Mobile frames already follow the grid, desktop drifted.', 'Two buttons use a hard-coded grey instead of a token.'];
// each source, with its tip while the agent reads it, once it has read it and (Card.tsx) once it has edited it
type Read = 'reading' | 'read' | 'edited';
const SOURCES: (Omit<Source, 'tip' | 'reading'> & Partial<Record<Read, string>>)[] = [
  { label: 'Onboarding.fig', kind: 'figma', reading: 'Reading the frames in Figma', read: 'Figma, 4 frames read' },
  { label: 'tokens.ts', kind: 'ts', reading: 'Reading src/styles/tokens.ts', read: 'src/styles/tokens.ts, 212 lines' },
  { label: 'Card.tsx', kind: 'tsx', reading: 'Reading src/components/Card.tsx', read: 'src/components/Card.tsx', edited: 'src/components/Card.tsx, 2 edits' },
  { label: 'Spacing guide', kind: 'web', reading: 'Reading designme.dev/guide/spacing', read: 'designme.dev/guide/spacing' }
];
const EDITS: Edit[] = [{ file: 'Card.tsx', detail: '2 lines', removed: ['padding: 20px;'], added: ['padding: var(--space-6);'] }, { file: 'Button.tsx', detail: '1 line', removed: ['color: #8a8a8a;'], added: ['color: var(--text-dim);'] }];

// where the run is: the plan steps done, the notes found (by their place in NOTES), how far each source has got and the
// edits drafted. Each view shows only what the run has made by then
interface Run { done: number; notes: number[]; src: Read[]; edits: number }
const START: Run = { done: 0, notes: [], src: ['reading'], edits: 0 };
const END: Run = { done: PLAN.length, notes: [0, 1, 2], src: ['read', 'read', 'edited', 'read'], edits: 2 };
// the run, 1.5s a step: how long after the last beat, and where it is then
const BEATS: [number, Run][] = [
  // the file is open: Onboarding.fig read and the hero card's padding noted; on to tokens.ts
  [1500, { done: 1, notes: [0], src: ['read', 'reading'], edits: 0 }],
  // then Card.tsx
  [750, { done: 1, notes: [0], src: ['read', 'read', 'reading'], edits: 0 }],
  // compared with the design system: the hard-coded grey noted; on to the spacing guide
  [750, { done: 2, notes: [0, 2], src: ['read', 'read', 'read', 'reading'], edits: 0 }],
  // the grid checked: where desktop drifted noted
  [1500, { done: 3, notes: [0, 1, 2], src: ['read', 'read', 'read', 'read'], edits: 0 }],
  // the fixes drafted: Card.tsx, then Button.tsx
  [400, { done: 3, notes: [0, 1, 2], src: ['read', 'read', 'edited', 'read'], edits: 1 }],
  [600, { done: 3, notes: [0, 1, 2], src: ['read', 'read', 'edited', 'read'], edits: 2 }],
  [500, END]
];
const content = (r: Run): Pick<ReasoningTrailProps, 'notes' | 'sources' | 'edits'> => ({
  notes: NOTES.filter((_, i) => r.notes.includes(i)),
  sources: r.src.map((s, i) => { const { reading, read, edited, ...x } = SOURCES[i]; return { ...x, tip: { reading, read, edited }[s], reading: s === 'reading' }; }),
  edits: EDITS.slice(0, r.edits)
});

export default function ReasoningTrailDemo() {
  const [run, setRun] = useState(START);
  const [view, setView] = useState<ReasoningTrailView>('plan');
  // Studio's trail is a card that grows with each view instead (owner, 18 Nov: no room kept for a later state)
  const box = useRef<HTMLDivElement>(null), [studio, setStudio] = useState(false);
  useIsoLayoutEffect(() => { setStudio((box.current?.closest('[data-style]') as HTMLElement | null)?.dataset.style === 'studio'); }, []);
  // the agent's own work: it carries on after the visitor takes over, and while the pointer rests on it
  useScript(async ({ wait }) => { for (const [ms, r] of BEATS) { await wait(ms); setRun(r); } });
  const running = run.done < PLAN.length;
  const plan: PlanStep[] = PLAN.map(([label, detail], i) => ({ label, detail, state: i < run.done ? 'done' : i === run.done ? 'now' : 'next' }));
  return (
    <Demo switcher={<Seg label="View" value={view} onChange={setView} options={[{ value: 'plan', label: 'Plan' }, { value: 'notes', label: 'Notes' }, { value: 'sources', label: 'Sources' }, { value: 'edits', label: 'Edits' }]} />}>
      {/* the preview keeps the room of its tallest view, finished, so the switcher under it stays put: a hidden copy of each
          view sits in the same grid cell, and the trail you see is centred in it */}
      <div ref={box} style={{ display: 'grid', width: '100%' }}>
        {!studio && VIEWS.map(v => (
          <div key={v} aria-hidden="true" inert style={{ gridArea: '1 / 1', visibility: 'hidden', pointerEvents: 'none' }}>
            <ReasoningTrail plan={plan} view={v} seconds={0} {...content(END)} />
          </div>
        ))}
        <div style={{ gridArea: '1 / 1', alignSelf: 'center', minWidth: 0 }}>
          <ReasoningTrail running={running} plan={plan} view={view} {...content(run)} />
        </div>
      </div>
    </Demo>
  );
}

Astro

In a page in src/pages. It plays the demo above; change its reasoning-trail.js to show your own data. Attributes like class go on its root element.

---
import ReasoningTrail from '../components/designme/reasoning-trail/ReasoningTrail.astro';
---
<ReasoningTrail />
<ReasoningTrail data-style="soft" class="my-class" />
04

Props

Everything ReasoningTrail takes.

PropTypeWhat it does
runningbooleanShimmers and counts seconds while true
secondsnumberSeconds to show. Leave it out to let the trail count while it runs
titlestringHeader text. Defaults to "Reasoning" while running and "Reasoned for Ns" after
planPlanStep[]
notesstring[]What the agent has noted so far. Pass them as it finds them
sourcesSource[]What the agent has read so far. Mark the one it is still reading with `reading`
editsEdit[]The edits the agent has drafted so far
viewReasoningTrailViewWhich part of the trail it shows: the plan, the notes, the sources or the edits. Leave it out to start on the first one there is
defaultViewReasoningTrailView
onViewChange(view: ReasoningTrailView) => void
openbooleanWhether the trail is open. Leave it out to let the header toggle it
defaultOpenboolean
onOpenChange(open: boolean) => void
barebooleanSits flat in a chat thread (the default, as on designme.dev). Set false to give it a card of its own. In the Studio style it always has its card
classNamestring
05

Code

The full source, as the CLI installs it.

ReasoningTrail.tsxReact · 198 lines
'use client';
import { useRef, useState, type KeyboardEvent } from 'react';
import { cx } from '../lib/cx';
import { useControllable, useIsoLayoutEffect, useReducedMotion, useSeconds } from '../lib/hooks';
import { Icon } from '../lib/icons';
import { Dot, enter, Fold, growFit, Pulse, reflowGlide, SourceChip, Swap, Think, type Source } from '../lib/motion';
import '../designme.css';
import './reasoning-trail.css';

export interface PlanStep {
  label: string;
  /** Shown under a finished step, like "4 frames" */
  detail?: string;
  state: 'done' | 'now' | 'next';
}
export interface Edit {
  file: string;
  /** Like "2 lines" */
  detail?: string;
  removed?: string[];
  added?: string[];
}
export type ReasoningTrailView = 'plan' | 'notes' | 'sources' | 'edits';
/** The earlier name of ReasoningTrailView */
export type ReasoningTab = ReasoningTrailView;

export interface ReasoningTrailProps {
  /** Shimmers and counts seconds while true */
  running?: boolean;
  /** Seconds to show. Leave it out to let the trail count while it runs */
  seconds?: number;
  /** Header text. Defaults to "Reasoning" while running and "Reasoned for Ns" after */
  title?: string;
  plan?: PlanStep[];
  /** What the agent has noted so far. Pass them as it finds them */
  notes?: string[];
  /** What the agent has read so far. Mark the one it is still reading with `reading` */
  sources?: Source[];
  /** The edits the agent has drafted so far */
  edits?: Edit[];
  /** Which part of the trail it shows: the plan, the notes, the sources or the edits. Leave it out to start on the first one there is */
  view?: ReasoningTrailView;
  defaultView?: ReasoningTrailView;
  onViewChange?: (view: ReasoningTrailView) => void;
  /** Whether the trail is open. Leave it out to let the header toggle it */
  open?: boolean;
  defaultOpen?: boolean;
  onOpenChange?: (open: boolean) => void;
  /** Sits flat in a chat thread (the default, as on designme.dev). Set false to give it a card of its own. In the Studio
   *  style it always has its card */
  bare?: boolean;
  className?: string;
}

const VIEWS: ReasoningTrailView[] = ['plan', 'notes', 'sources', 'edits'];

const TICK = <svg viewBox="0 0 24 24"><path pathLength={1} d="m5 12.5 4.5 4.5L19 7.5" /></svg>;
const count = (n: number, one: string) => `${n} ${one}${n === 1 ? '' : 's'}`;
/** A key for each item, the same from one render to the next as items are added: its text, and a count for a repeat */
const keysOf = (prefix: string, xs: string[] = []) => { const n = new Map<string, number>(); return xs.map(x => { const k = (n.get(x) ?? 0) + 1; n.set(x, k); return prefix + x + (k > 1 ? '#' + k : ''); }); };
/** Where `el` sits in `box` by layout, without the entrance or glide it may be in the middle of */
const place = (el: HTMLElement, box: HTMLElement) => {
  let x = 0, y = 0;
  for (let e: HTMLElement | null = el; e && e !== box; e = e.parentElement) {
    const t = getComputedStyle(e).transform;
    if (t && t !== 'none') { const m = new DOMMatrixReadOnly(t); x += m.m41; y += m.m42; }
  }
  const r = el.getBoundingClientRect(), b = box.getBoundingClientRect();
  return { x: r.left - b.left - x, y: r.top - b.top - y };
};

/** The agent's plan, notes, sources or edits, under a header it can fold away. Pick what it shows with `view`. */
export function ReasoningTrail({ running = false, seconds, title, plan, notes, sources, edits, view, defaultView, onViewChange, open, defaultOpen = true, onOpenChange, bare = true, className }: ReasoningTrailProps) {
  const counted = useSeconds(running && seconds === undefined);
  const secs = seconds ?? counted;
  const has = { plan: !!plan?.length, notes: !!notes?.length, sources: !!sources?.length, edits: !!edits?.length };
  const [picked] = useControllable(view, defaultView ?? VIEWS.find(v => has[v]) ?? 'plan', onViewChange);
  // while it runs, a view the agent hasn't added to yet says so ("No notes yet"); once it is done, a view with nothing in it
  // falls back to the first one that has something
  const tab = has[picked] || (running && picked !== 'plan') ? picked : VIEWS.find(v => has[v]) ?? picked;
  const [isOpen, setOpen] = useControllable(open, defaultOpen, onOpenChange);
  const head = title ?? (running ? 'Reasoning' : `Reasoned for ${Math.max(secs, 1)}s`);
  // Enter and Space open and fold it as a click does, and aria-expanded always says which
  const onHeadKey = (e: KeyboardEvent<HTMLButtonElement>) => {
    if ((e.key !== 'Enter' && e.key !== ' ') || e.altKey || e.ctrlKey || e.metaKey) return;
    e.preventDefault(); if (!e.repeat) setOpen(!isOpen);
  };

  // Studio: the trail is a card that grows with what it holds (as grow() on designme.dev): its height follows its content,
  // eased, as steps change, views switch and it folds. Soft and Blueprint keep their own sizing
  const rootRef = useRef<HTMLDivElement>(null), growRef = useRef<HTMLDivElement>(null), [studio, setStudio] = useState(false);
  useIsoLayoutEffect(() => {
    const el = rootRef.current, w = growRef.current;
    if (!el || !w || (el.closest('[data-style]') as HTMLElement | null)?.dataset.style !== 'studio') return;
    setStudio(true);
    el.classList.add('dm-growing'); const stop = growFit(el, w);
    return () => { stop(); el.classList.remove('dm-growing'); };
  }, []);

  // in Studio, a step that has just finished draws its tick and the rail down into the next, which starts to turn: each
  // plays once, when the plan moves on
  const states = plan?.map(p => p.state) ?? [], key = states.join(), prev = useRef<string[] | null>(null);
  const [fresh, setFresh] = useState<{ done: number[]; now: number[] }>({ done: [], now: [] });
  useIsoLayoutEffect(() => {
    const was = prev.current; prev.current = states; if (!was) return;
    setFresh({ done: states.flatMap((s, i) => s === 'done' && was[i] && was[i] !== 'done' ? [i] : []), now: states.flatMap((s, i) => s === 'now' && was[i] === 'next' ? [i] : []) });
  }, [key]);
  // the foot strip that closes a finished trail in Studio: how much of the plan is done, and what the agent read and changed
  const doneN = states.filter(s => s === 'done').length, allDone = !!plan?.length && doneN === plan.length;
  const footL = plan?.length ? (allDone ? `All ${count(plan.length, 'step')} done` : `${doneN} of ${count(plan.length, 'step')} done`) : '';
  const footR = [sources?.length ? count(sources.length, 'source') : '', edits?.length ? count(edits.length, 'edit') : ''].filter(Boolean).join(' · ');

  // what the view shows, as the items in it: switching views, or the agent adding to the one on screen, changes it
  const noteKeys = keysOf('n:', notes), sourceKeys = keysOf('s:', sources?.map(x => x.label)), editKeys = keysOf('e:', edits?.map(e => e.file));
  const keys = tab === 'notes' ? noteKeys : tab === 'sources' ? sourceKeys : tab === 'edits' ? editKeys : [];
  const sig = tab + '|' + (keys.length ? keys.join('\n') : 'none');

  // switching views, or a view taking in what the agent has just added, grows or shrinks the open trail to its new height
  // instead of jumping to it (from wherever an earlier change has it)
  const reduce = useReducedMotion();
  const bodyRef = useRef<HTMLDivElement>(null), seen = useRef({ sig: '', h: 0 }), anim = useRef<Animation | null>(null);
  useIsoLayoutEffect(() => {
    const el = bodyRef.current; if (!el) return;
    const a0 = anim.current, mine = a0?.playState === 'running' && (a0.effect as KeyframeEffect | null)?.target === el;
    if (seen.current.sig === sig) { if (!mine) seen.current.h = el.offsetHeight; return; }
    const from = mine ? el.offsetHeight : seen.current.h, was = seen.current.sig;
    a0?.cancel();
    const to = el.offsetHeight;
    seen.current = { sig, h: to };
    if (!was || !isOpen || reduce || studio || !from || Math.abs(from - to) < 1 || !el.animate) return;
    const cs = getComputedStyle(el), ms = parseFloat(cs.getPropertyValue('--dm-t')) * 1000 || 450;
    el.style.overflow = 'hidden';
    const a = el.animate([{ height: from + 'px' }, { height: to + 'px' }], { duration: ms, easing: cs.getPropertyValue('--dm-ease').trim() || 'ease' });
    a.onfinish = a.oncancel = () => { el.style.overflow = ''; if (anim.current === a) anim.current = null; };
    anim.current = a;
  });

  // a row that a new one lands above (a note found later that belongs higher up) glides down to its new place instead of
  // jumping there
  const places = useRef<{ sig: string; at: Map<string, { x: number; y: number }> }>({ sig: '', at: new Map() });
  useIsoLayoutEffect(() => {
    const box = bodyRef.current; if (!box) return;
    const rows = [...box.querySelectorAll<HTMLElement>('[data-key]')], at = new Map(rows.map(el => [el.dataset.key!, place(el, box)]));
    const was = places.current; places.current = { sig, at };
    if (reduce || was.sig === sig || was.sig.split('|')[0] !== tab || typeof box.animate !== 'function') return;
    rows.forEach(el => { const o = was.at.get(el.dataset.key!), p = at.get(el.dataset.key!)!; if (o) reflowGlide(el, o.x - p.x, o.y - p.y, box); });
  });

  // each item's entrance is set when it first shows: a view's first items follow one another 50ms apart, as a view does
  // when it opens, and one the agent adds later comes in at once
  const born = useRef({ tab, at: new Map<string, number>() });
  if (born.current.tab !== tab) born.current = { tab, at: new Map() };
  const firstPass = born.current.at.size === 0;
  const delay = (k: string, d: number) => { const m = born.current.at; if (!m.has(k)) m.set(k, firstPass ? d : 0); return m.get(k)!; };

  const body = () => {
    if (tab === 'plan') return plan?.map((p, i) => (
      <div key={'p' + i} className={cx('dm-rtr-li dm-enter', p.state === 'now' && 'dm-now', fresh.done.includes(i) && 'dm-just', fresh.now.includes(i) && 'dm-next-in')} data-s={p.state} style={enter(i * 50).style}>
        <span className="dm-g">{p.state === 'done' ? <span style={{ color: 'var(--dm-ok)', display: 'grid' }}><Icon name="check" size="xs" /></span> : p.state === 'now' ? <Pulse /> : <Dot color="var(--dm-faint)" />}<span className="dm-rtr-m" aria-hidden="true">{p.state === 'done' && TICK}</span></span>
        <span>{p.label}<span className="dm-d">{p.state === 'done' ? p.detail ?? 'Done' : p.state === 'now' ? 'Working' : 'Next'}</span></span>
      </div>));
    // a view with nothing in it yet says so, on the row the first one will take
    const none = (what: string) => (
      <div key="none" data-key="none" className="dm-rtr-li dm-enter" style={enter(delay('none', 0)).style}><span className="dm-g"><Dot color="var(--dm-faint)" /></span><span className="dm-muted">No {what} yet</span></div>);
    if (tab === 'notes') return notes?.length ? notes.map((t, i) => (
      <div key={noteKeys[i]} data-key={noteKeys[i]} className="dm-rtr-li dm-enter" style={enter(delay(noteKeys[i], i * 50)).style}><span className="dm-g"><Dot color="var(--dm-faint)" /></span><span>{t}</span></div>)) : none('notes');
    // the chips first shown come in as one row; one the agent reads later comes in by itself
    if (tab === 'sources') return sources?.length ? <div className="dm-rtr-src dm-enter">{/* the tips open below the chips, clear of the header above */}{sources.map((s, i) => {
      const own = delay(sourceKeys[i], -1) === 0;
      return <SourceChip key={sourceKeys[i]} source={s} tipSide="bottom" className={own ? 'dm-enter' : undefined} />; })}</div> : none('sources');
    return edits?.length ? edits.map((e, i) => (
      <div key={editKeys[i]} data-key={editKeys[i]} className="dm-enter" style={enter(delay(editKeys[i], i * 50)).style}>
        <div className="dm-rtr-li"><span className="dm-g"><Icon name="edit" size="xs" /></span><span>{e.file}{e.detail && <span className="dm-d">{e.detail}</span>}</span></div>
        <div className="dm-rtr-edit">{e.removed?.map((l, k) => <div key={'x' + k} className="dm-x">{l}</div>)}{e.added?.map((l, k) => <div key={'a' + k} className="dm-a">{l}</div>)}</div>
      </div>)) : none('edits');
  };

  return (
    <div data-dm="" ref={rootRef} className={cx('dm-rtr dm-mx-grow', !bare && 'dm-panel', className)} style={bare ? { paddingInline: 0 } : undefined}>
      <div ref={growRef} className="dm-grow">
      <button type="button" className="dm-rtr-h dm-mx-press" aria-expanded={isOpen} onClick={() => setOpen(!isOpen)} onKeyDown={onHeadKey}>
        <Think on={running} className="dm-rtr-mark" />
        <Swap className={cx('dm-rtr-title', running && 'dm-shim')}>{head}</Swap>
        <span className="dm-rtr-time dm-num dm-muted">{running ? secs + 's' : ''}</span>
        <Icon name="chev-d" size="xs" className="dm-rtr-chev" />
      </button>
      <Fold open={isOpen} className="dm-rtr-fold">
        {/* keyed by view, so switching views plays the entrance again */}
        <div className="dm-rtr-body" key={tab} ref={bodyRef} data-v={tab}>{body()}</div>
        <Fold open={!running && !!(footL || footR)} className="dm-rtr-ff">
          <p className="dm-rtr-f">{allDone && <span className="dm-rtr-fk" aria-hidden="true">{TICK}</span>}<span className="dm-rtr-fd">{footL}</span><span className="dm-rtr-fs">{footR}</span></p>
        </Fold>
      </Fold>
      </div>
    </div>
  );
}
reasoning-trail.cssReact · 83 lines
/* Generated from designme.dev by scripts/sync.mjs. Edit the site, then sync. */
/* ---------- Reasoning trail ---------- */
.dm-rtr{width:100%;padding:6px}
.dm-rtr-h{display:flex;align-items:center;gap:10px;width:100%;padding:10px var(--dm-s-3);border-radius:var(--dm-r-in);font-size:13.5px;transition:background .2s}
@media (hover:hover) and (pointer:fine){.dm-rtr-h:hover{background:var(--dm-row)}}
/* its motion (the core's motion pieces, owner, 26 Nov): a press on the header shows at once (.mx-press); in Studio the card grows on
   the spring (.mx-grow) */
.dm-rtr-mark{color:var(--dm-fg2)}
.dm-rtr-chev{margin-left:auto;color:var(--dm-muted);transition:transform .4s var(--dm-ease)}
.dm-rtr-h[aria-expanded="false"] .dm-rtr-chev{transform:rotate(-90deg)}
.dm-rtr-body{padding:var(--dm-s-1) var(--dm-s-3) 10px}
.dm-rtr-li{position:relative;display:flex;gap:10px;padding:6px 0 6px var(--dm-s-6);font-size:13.5px;color:var(--dm-fg2)}
.dm-rtr-li .dm-g{position:absolute;left:0;top:7px;width:16px;height:16px;display:grid;place-items:center;color:var(--dm-muted)}
.dm-rtr-li:not(:last-child)::before{content:"";position:absolute;left:7.5px;top:25px;bottom:-6px;width:1px;background:var(--dm-rail)}
.dm-rtr-li .dm-d{display:block;font-size:12px;color:var(--dm-muted);margin-top:1px}
.dm-rtr-li.dm-now{color:var(--dm-fg)}
.dm-rtr-edit{font-family:var(--dm-mono);font-size:12px;border-radius:calc(10px * var(--dm-rk-m,var(--dm-rk)));background:var(--dm-chip);padding:var(--dm-s-2) 10px;margin:var(--dm-s-1) 0 var(--dm-s-2);line-height:1.65}
.dm-rtr-edit .dm-a{color:var(--dm-add)}.dm-rtr-edit .dm-x{color:var(--dm-del);text-decoration:line-through;text-decoration-color:color-mix(in srgb,var(--dm-del) 40%,transparent)}
.dm-rtr-src{display:flex;flex-wrap:wrap;gap:6px}
/* the plan's Studio marks and the closing foot strip are Studio's alone: Soft and Blueprint never show them */
.dm-rtr-m,.dm-rtr-ff{display:none}
/* Studio (owner, 18 Nov): a card of its own, bare or not: a hairline-outlined round card with the thinking head on top and
   a hairline under it. The plan's steps sit on a hairline rail that fills down into each step as the one above finishes;
   a finished step is a green disc whose tick draws in, the step in hand a calm ink spinner ring, a queued step a hairline
   circle. Notes and edits have no rail. The finished trail closes with an off-white foot strip that sums it up. The card
   grows with what it holds (grow()) and folds into its head. Content sits 16px in from every edge; the chevron's 28px
   circle sits 16px from the head's top, bottom and right edges (owner, 23 Nov) */
:root[data-style="studio"] .dm-rtr.dm-rtr.dm-rtr,:root [data-style="studio"] .dm-rtr.dm-rtr.dm-rtr,:root [data-style="studio"].dm-rtr.dm-rtr.dm-rtr{padding:0;background:var(--dm-surface);box-shadow:var(--dm-shadow);border-radius:var(--dm-r-card);overflow:clip}
:root[data-style="studio"] .dm-rtr.dm-growing,:root [data-style="studio"] .dm-rtr.dm-growing,:root [data-style="studio"].dm-rtr.dm-growing{overflow-clip-margin:0px}
/* the chevron's 28px circle 16px from the head's top, bottom and right, as Web search's is (owner, 23 Nov) */
:root[data-style="studio"] .dm-rtr-h,:root [data-style="studio"] .dm-rtr-h,:root [data-style="studio"].dm-rtr-h{min-height:calc(28px + 2 * var(--dm-strip-y));padding:0 23px 0 16px;gap:12px;border-radius:0;font-size:13.5px}
@media (hover:hover) and (pointer:fine){:root[data-style="studio"] .dm-rtr-h:hover,:root [data-style="studio"] .dm-rtr-h:hover,:root [data-style="studio"].dm-rtr-h:hover{background:none}}
:root[data-style="studio"] .dm-rtr-h:focus-visible,:root [data-style="studio"] .dm-rtr-h:focus-visible,:root [data-style="studio"].dm-rtr-h:focus-visible{outline-offset:-2px;border-radius:var(--dm-r-card)}
/* the head's 14px mark sits centred on the steps' 16px marks, and its words start where theirs do (44px in) */
:root[data-style="studio"] .dm-rtr-mark,:root [data-style="studio"] .dm-rtr-mark,:root [data-style="studio"].dm-rtr-mark{color:var(--dm-fg);margin:0 1px}
:root[data-style="studio"] .dm-rtr-title,:root [data-style="studio"] .dm-rtr-title,:root [data-style="studio"].dm-rtr-title{font-weight:500}
:root[data-style="studio"] .dm-rtr-title:not(.dm-shim),:root [data-style="studio"] .dm-rtr-title:not(.dm-shim),:root [data-style="studio"].dm-rtr-title:not(.dm-shim){color:var(--dm-fg)}
:root[data-style="studio"] .dm-rtr-time,:root [data-style="studio"] .dm-rtr-time,:root [data-style="studio"].dm-rtr-time{font-variant-numeric:tabular-nums}
:root[data-style="studio"] .dm-rtr-chev,:root [data-style="studio"] .dm-rtr-chev,:root [data-style="studio"].dm-rtr-chev{width:14px;height:14px;border-radius:50%;box-shadow:0 0 0 7px transparent;transition:transform .4s var(--dm-ease),background-color var(--dm-t-fast) var(--dm-ease),box-shadow var(--dm-t-fast) var(--dm-ease),color var(--dm-t-fast) var(--dm-ease)}
@media (hover:hover) and (pointer:fine){:root[data-style="studio"] .dm-rtr-h:hover .dm-rtr-chev,:root [data-style="studio"] .dm-rtr-h:hover .dm-rtr-chev,:root [data-style="studio"].dm-rtr-h:hover .dm-rtr-chev{background:var(--dm-row);box-shadow:0 0 0 7px var(--dm-row);color:var(--dm-fg)}}
/* (its press, the motion pieces' .mx-press: in Studio, where the header's hover is the chevron's fill, the press deepens that fill) */
:root[data-style="studio"] .dm-rtr-h.dm-mx-press:active,:root [data-style="studio"] .dm-rtr-h.dm-mx-press:active,:root [data-style="studio"].dm-rtr-h.dm-mx-press:active{background:none}
:root[data-style="studio"] .dm-rtr-h:active .dm-rtr-chev,:root [data-style="studio"] .dm-rtr-h:active .dm-rtr-chev,:root [data-style="studio"].dm-rtr-h:active .dm-rtr-chev{background:var(--dm-row-press);box-shadow:0 0 0 7px var(--dm-row-press);transition-duration:var(--dm-t-press)}
:root[data-style="studio"] .dm-rtr-body,:root [data-style="studio"] .dm-rtr-body,:root [data-style="studio"].dm-rtr-body{padding:10px 16px;border-top:1px solid var(--dm-line)}
:root[data-style="studio"] .dm-rtr-body[data-v="sources"],:root [data-style="studio"] .dm-rtr-body[data-v="sources"],:root [data-style="studio"].dm-rtr-body[data-v="sources"]{padding:16px}
:root[data-style="studio"] .dm-rtr-li,:root [data-style="studio"] .dm-rtr-li,:root [data-style="studio"].dm-rtr-li{padding:6px 0 6px 28px;line-height:20px}
:root[data-style="studio"] .dm-rtr-li .dm-g,:root [data-style="studio"] .dm-rtr-li .dm-g,:root [data-style="studio"].dm-rtr-li .dm-g{top:8px}
:root[data-style="studio"] .dm-rtr-li .dm-d,:root [data-style="studio"] .dm-rtr-li .dm-d,:root [data-style="studio"].dm-rtr-li .dm-d{line-height:18px;margin-top:0}
/* the rail: a hairline from under each mark to just above the next, and over it the part that has filled */
:root[data-style="studio"] .dm-rtr-li:not(:last-child)::before,:root [data-style="studio"] .dm-rtr-li:not(:last-child)::before,:root [data-style="studio"].dm-rtr-li:not(:last-child)::before{top:28px;bottom:-4px;background:var(--dm-line)}
:root[data-style="studio"] .dm-rtr-body:not([data-v="plan"]) .dm-rtr-li::before,:root [data-style="studio"] .dm-rtr-body:not([data-v="plan"]) .dm-rtr-li::before,:root [data-style="studio"].dm-rtr-body:not([data-v="plan"]) .dm-rtr-li::before{display:none}
:root[data-style="studio"] .dm-rtr-body[data-v="plan"] .dm-rtr-li:not(:last-child)::before,:root [data-style="studio"] .dm-rtr-body[data-v="plan"] .dm-rtr-li:not(:last-child)::before,:root [data-style="studio"].dm-rtr-body[data-v="plan"] .dm-rtr-li:not(:last-child)::before{background:var(--dm-line) linear-gradient(var(--dm-line-strong),var(--dm-line-strong)) no-repeat 0 0/100% 0}
:root[data-style="studio"] .dm-rtr-body[data-v="plan"] .dm-rtr-li[data-s="done"]:not(:last-child)::before,:root [data-style="studio"] .dm-rtr-body[data-v="plan"] .dm-rtr-li[data-s="done"]:not(:last-child)::before,:root [data-style="studio"].dm-rtr-body[data-v="plan"] .dm-rtr-li[data-s="done"]:not(:last-child)::before{background-size:100% 100%}
/* the marks */
/* (React sets its own display on Soft's tick, so this one has to win over an inline style) */
:root[data-style="studio"] .dm-rtr-body[data-v="plan"] .dm-g>:not(.dm-rtr-m),:root [data-style="studio"] .dm-rtr-body[data-v="plan"] .dm-g>:not(.dm-rtr-m),:root [data-style="studio"].dm-rtr-body[data-v="plan"] .dm-g>:not(.dm-rtr-m){display:none!important}
:root[data-style="studio"] .dm-rtr-m,:root [data-style="studio"] .dm-rtr-m,:root [data-style="studio"].dm-rtr-m{display:grid;place-items:center;width:16px;height:16px;box-sizing:border-box;border-radius:50%}
:root[data-style="studio"] [data-s="next"]>.dm-g>.dm-rtr-m,:root [data-style="studio"] [data-s="next"]>.dm-g>.dm-rtr-m,:root [data-style="studio"][data-s="next"]>.dm-g>.dm-rtr-m{box-shadow:inset 0 0 0 1px var(--dm-line-strong)}
:root[data-style="studio"] [data-s="now"]>.dm-g>.dm-rtr-m,:root [data-style="studio"] [data-s="now"]>.dm-g>.dm-rtr-m,:root [data-style="studio"][data-s="now"]>.dm-g>.dm-rtr-m{border:1.5px solid var(--dm-line);border-top-color:var(--dm-fg);animation:dm-rot .9s linear infinite}
:root[data-style="studio"] [data-s="done"]>.dm-g>.dm-rtr-m,:root [data-style="studio"] [data-s="done"]>.dm-g>.dm-rtr-m,:root [data-style="studio"][data-s="done"]>.dm-g>.dm-rtr-m{background:var(--dm-ok-mark);color:var(--dm-surface)}
:root[data-style="studio"] .dm-rtr-m svg,:root [data-style="studio"] .dm-rtr-m svg,:root [data-style="studio"].dm-rtr-m svg,:root[data-style="studio"] .dm-rtr-fk svg,:root [data-style="studio"] .dm-rtr-fk svg,:root [data-style="studio"].dm-rtr-fk svg{width:10px;height:10px;fill:none;stroke:currentColor;stroke-width:3.2;stroke-linecap:round;stroke-linejoin:round}
/* the moment a step finishes: its disc settles in and its tick draws, the rail draws down into the next step, and that
   step's queued ring turns into the spinner as the rail reaches it */
@keyframes dm-rtrdisc{from{opacity:0;transform:scale(.5)}}
@keyframes dm-rtrdraw{to{stroke-dashoffset:0}}
@keyframes dm-rtrfill{from{background-size:100% 0}}
@keyframes dm-rtrnow{from{border-color:var(--dm-line-strong)}}
:root[data-style="studio"] .dm-rtr-li.dm-just>.dm-g>.dm-rtr-m,:root [data-style="studio"] .dm-rtr-li.dm-just>.dm-g>.dm-rtr-m,:root [data-style="studio"].dm-rtr-li.dm-just>.dm-g>.dm-rtr-m{animation:dm-rtrdisc .34s var(--dm-ease) backwards}
:root[data-style="studio"] .dm-rtr-li.dm-just>.dm-g>.dm-rtr-m path,:root [data-style="studio"] .dm-rtr-li.dm-just>.dm-g>.dm-rtr-m path,:root [data-style="studio"].dm-rtr-li.dm-just>.dm-g>.dm-rtr-m path{stroke-dasharray:1;stroke-dashoffset:1;animation:dm-rtrdraw .3s var(--dm-ease) .14s forwards}
:root[data-style="studio"] .dm-rtr-body[data-v="plan"] .dm-rtr-li.dm-just:not(:last-child)::before,:root [data-style="studio"] .dm-rtr-body[data-v="plan"] .dm-rtr-li.dm-just:not(:last-child)::before,:root [data-style="studio"].dm-rtr-body[data-v="plan"] .dm-rtr-li.dm-just:not(:last-child)::before{animation:dm-rtrfill .44s var(--dm-ease-io) .2s backwards}
:root[data-style="studio"] .dm-rtr-li.dm-next-in>.dm-g>.dm-rtr-m,:root [data-style="studio"] .dm-rtr-li.dm-next-in>.dm-g>.dm-rtr-m,:root [data-style="studio"].dm-rtr-li.dm-next-in>.dm-g>.dm-rtr-m{animation:dm-rtrnow .3s var(--dm-ease) .5s backwards,dm-rot .9s linear infinite}
:root[data-style="studio"] .dm-rtr-src,:root [data-style="studio"] .dm-rtr-src,:root [data-style="studio"].dm-rtr-src{gap:8px}
:root[data-style="studio"] .dm-rtr-body[data-v="edits"] .dm-g,:root [data-style="studio"] .dm-rtr-body[data-v="edits"] .dm-g,:root [data-style="studio"].dm-rtr-body[data-v="edits"] .dm-g{color:var(--dm-muted)}
:root[data-style="studio"] .dm-rtr-edit,:root [data-style="studio"] .dm-rtr-edit,:root [data-style="studio"].dm-rtr-edit{border-radius:var(--dm-r-box);margin:4px 0 8px;padding:8px 12px;line-height:20px}
:root[data-style="studio"] .dm-rtr-body>.dm-rtr-edit:last-child,:root [data-style="studio"] .dm-rtr-body>.dm-rtr-edit:last-child,:root [data-style="studio"].dm-rtr-body>.dm-rtr-edit:last-child,:root[data-style="studio"] .dm-rtr-body>:last-child>.dm-rtr-edit:last-child,:root [data-style="studio"] .dm-rtr-body>:last-child>.dm-rtr-edit:last-child,:root [data-style="studio"].dm-rtr-body>:last-child>.dm-rtr-edit:last-child{margin-bottom:6px}
/* the foot strip, once the trail is done: a green tick, how much of the plan is done, and what it read and changed */
:root[data-style="studio"] .dm-rtr-ff,:root [data-style="studio"] .dm-rtr-ff,:root [data-style="studio"].dm-rtr-ff{display:grid}
:root[data-style="studio"] .dm-rtr-f,:root [data-style="studio"] .dm-rtr-f,:root [data-style="studio"].dm-rtr-f{display:flex;align-items:center;gap:12px;min-height:calc(28px + 2 * var(--dm-strip-y) + 1px);margin:0;padding:0 16px;background:var(--dm-strip);border-top:1px solid var(--dm-line);font-size:12.5px;color:var(--dm-fg2);white-space:nowrap}
/* (the foot's tick is a done step's mark: the same 16px disc on the same column, its words where the steps' words start) */
:root[data-style="studio"] .dm-rtr-fk,:root [data-style="studio"] .dm-rtr-fk,:root [data-style="studio"].dm-rtr-fk{display:grid;place-items:center;width:16px;height:16px;flex:none;border-radius:50%;background:var(--dm-ok-mark);color:var(--dm-surface)}
:root[data-style="studio"] .dm-rtr-fs,:root [data-style="studio"] .dm-rtr-fs,:root [data-style="studio"].dm-rtr-fs{margin-left:auto;color:var(--dm-muted);overflow:hidden;text-overflow:ellipsis}
@media (prefers-reduced-motion:reduce){:root[data-style="studio"] .dm-rtr-li:is(.dm-just,.dm-next-in) *,:root [data-style="studio"] .dm-rtr-li:is(.dm-just,.dm-next-in) *,:root [data-style="studio"].dm-rtr-li:is(.dm-just,.dm-next-in) *,:root[data-style="studio"] .dm-rtr-li.dm-just::before,:root [data-style="studio"] .dm-rtr-li.dm-just::before,:root [data-style="studio"].dm-rtr-li.dm-just::before{animation:none!important}:root[data-style="studio"] .dm-rtr-li.dm-just>.dm-g>.dm-rtr-m path,:root [data-style="studio"] .dm-rtr-li.dm-just>.dm-g>.dm-rtr-m path,:root [data-style="studio"].dm-rtr-li.dm-just>.dm-g>.dm-rtr-m path{stroke-dashoffset:0}:root[data-style="studio"] [data-s="now"]>.dm-g>.dm-rtr-m,:root [data-style="studio"] [data-s="now"]>.dm-g>.dm-rtr-m,:root [data-style="studio"][data-s="now"]>.dm-g>.dm-rtr-m{animation:none}}
ReasoningTrail.astroAstro · 36 lines
---
// Generated from designme.dev by scripts/sync.mjs. Edit the site, then sync.
// Reasoning trail: The agent's plan, notes, sources and edits, after it thinks.
// The markup, CSS and script are designme.dev's own, run by the shared core in ../core, which mounts the component when it scrolls
// into view and plays its demo. To show your own data, change reasoning-trail.js. The markup is kept exactly as it is (is:raw).
import type { HTMLAttributes } from 'astro/types';
import '../core/designme.css';
import './reasoning-trail.css';

export interface Props extends HTMLAttributes<'div'> {
  /** "soft" or "studio" draws it in that style. Leave it out for Blueprint, or for the style set on <html> (data-style="soft" or "studio") */
  'data-style'?: 'soft' | 'studio';
}
const { class: className, ...rest } = Astro.props;
---
<div class:list={['card', 'bare', className]} data-c="reasoning-trail" {...rest}>
  <div class="stage-in"><Fragment is:raw>
<div class="rtr-dm dm"><div class="dm-main"><div class="rtr panel mx-grow">
  <button class="rtr-h mx-press" aria-expanded="true">
    <span class="think on rtr-mark"><i></i><i></i><i></i><i></i></span>
    <span class="rtr-title shim">Reasoning</span><span class="rtr-time num muted">0s</span>
    <svg class="i xs rtr-chev"><use href="#i-chev-d"/></svg>
  </button>
  <div class="fold rtr-fold"><div>
    <div class="rtr-body"></div>
    <div class="fold rtr-ff shut"><div><p class="rtr-f"><span class="rtr-fk" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="m5 12.5 4.5 4.5L19 7.5"/></svg></span><span class="rtr-fd"></span><span class="rtr-fs"></span></p></div></div>
  </div></div>
</div></div>
  <div class="demo"><div class="seg2" role="group" aria-label="View"><button aria-pressed="true" data-v="plan">Plan</button><button aria-pressed="false" data-v="notes">Notes</button><button aria-pressed="false" data-v="sources">Sources</button><button aria-pressed="false" data-v="edits">Edits</button></div></div>
</div>
  </Fragment></div>
</div>
<script>
  import './reasoning-trail.js';
</script>
reasoning-trail.htmlHTML · 18 lines
<div class="card bare" data-c="reasoning-trail">
  <div class="stage-in">
    <div class="rtr-dm dm"><div class="dm-main"><div class="rtr panel mx-grow">
      <button class="rtr-h mx-press" aria-expanded="true">
        <span class="think on rtr-mark"><i></i><i></i><i></i><i></i></span>
        <span class="rtr-title shim">Reasoning</span><span class="rtr-time num muted">0s</span>
        <svg class="i xs rtr-chev"><use href="#i-chev-d"/></svg>
      </button>
      <div class="fold rtr-fold"><div>
        <div class="rtr-body"></div>
        <div class="fold rtr-ff shut"><div><p class="rtr-f"><span class="rtr-fk" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="m5 12.5 4.5 4.5L19 7.5"/></svg></span><span class="rtr-fd"></span><span class="rtr-fs"></span></p></div></div>
      </div></div>
    </div></div>
      <div class="demo"><div class="seg2" role="group" aria-label="View"><button aria-pressed="true" data-v="plan">Plan</button><button aria-pressed="false" data-v="notes">Notes</button><button aria-pressed="false" data-v="sources">Sources</button><button aria-pressed="false" data-v="edits">Edits</button></div></div>
    </div>
  </div>
</div>
reasoning-trail.cssHTML · 82 lines
/* ---------- Reasoning trail ---------- */
.rtr{width:100%;padding:6px}
.rtr-h{display:flex;align-items:center;gap:10px;width:100%;padding:10px var(--dm-s-3);border-radius:var(--dm-r-in);font-size:13.5px;transition:background .2s}
@media (hover:hover) and (pointer:fine){.rtr-h:hover{background:var(--dm-row)}}
/* its motion (the core's motion pieces, owner, 26 Nov): a press on the header shows at once (.mx-press); in Studio the card grows on
   the spring (.mx-grow) */
.rtr-mark{color:var(--dm-fg2)}
.rtr-chev{margin-left:auto;color:var(--dm-muted);transition:transform .4s var(--dm-ease)}
.rtr-h[aria-expanded="false"] .rtr-chev{transform:rotate(-90deg)}
.rtr-body{padding:var(--dm-s-1) var(--dm-s-3) 10px}
.rtr-li{position:relative;display:flex;gap:10px;padding:6px 0 6px var(--dm-s-6);font-size:13.5px;color:var(--dm-fg2)}
.rtr-li .g{position:absolute;left:0;top:7px;width:16px;height:16px;display:grid;place-items:center;color:var(--dm-muted)}
.rtr-li:not(:last-child)::before{content:"";position:absolute;left:7.5px;top:25px;bottom:-6px;width:1px;background:var(--dm-rail)}
.rtr-li .d{display:block;font-size:12px;color:var(--dm-muted);margin-top:1px}
.rtr-li.now{color:var(--dm-fg)}
.rtr-edit{font-family:var(--dm-mono);font-size:12px;border-radius:calc(10px * var(--dm-rk-m,var(--dm-rk)));background:var(--dm-chip);padding:var(--dm-s-2) 10px;margin:var(--dm-s-1) 0 var(--dm-s-2);line-height:1.65}
.rtr-edit .a{color:var(--dm-add)}.rtr-edit .x{color:var(--dm-del);text-decoration:line-through;text-decoration-color:color-mix(in srgb,var(--dm-del) 40%,transparent)}
.rtr-src{display:flex;flex-wrap:wrap;gap:6px}
/* the plan's Studio marks and the closing foot strip are Studio's alone: Soft and Blueprint never show them */
.rtr-m,.rtr-ff{display:none}
/* Studio (owner, 18 Nov): a card of its own, bare or not: a hairline-outlined round card with the thinking head on top and
   a hairline under it. The plan's steps sit on a hairline rail that fills down into each step as the one above finishes;
   a finished step is a green disc whose tick draws in, the step in hand a calm ink spinner ring, a queued step a hairline
   circle. Notes and edits have no rail. The finished trail closes with an off-white foot strip that sums it up. The card
   grows with what it holds (grow()) and folds into its head. Content sits 16px in from every edge; the chevron's 28px
   circle sits 16px from the head's top, bottom and right edges (owner, 23 Nov) */
:root[data-style="studio"] .rtr.rtr.rtr,:root [data-style="studio"] .rtr.rtr.rtr,:root [data-style="studio"].rtr.rtr.rtr{padding:0;background:var(--dm-surface);box-shadow:var(--dm-shadow);border-radius:var(--dm-r-card);overflow:clip}
:root[data-style="studio"] .rtr.growing,:root [data-style="studio"] .rtr.growing,:root [data-style="studio"].rtr.growing{overflow-clip-margin:0px}
/* the chevron's 28px circle 16px from the head's top, bottom and right, as Web search's is (owner, 23 Nov) */
:root[data-style="studio"] .rtr-h,:root [data-style="studio"] .rtr-h,:root [data-style="studio"].rtr-h{min-height:calc(28px + 2 * var(--dm-strip-y));padding:0 23px 0 16px;gap:12px;border-radius:0;font-size:13.5px}
@media (hover:hover) and (pointer:fine){:root[data-style="studio"] .rtr-h:hover,:root [data-style="studio"] .rtr-h:hover,:root [data-style="studio"].rtr-h:hover{background:none}}
:root[data-style="studio"] .rtr-h:focus-visible,:root [data-style="studio"] .rtr-h:focus-visible,:root [data-style="studio"].rtr-h:focus-visible{outline-offset:-2px;border-radius:var(--dm-r-card)}
/* the head's 14px mark sits centred on the steps' 16px marks, and its words start where theirs do (44px in) */
:root[data-style="studio"] .rtr-mark,:root [data-style="studio"] .rtr-mark,:root [data-style="studio"].rtr-mark{color:var(--dm-fg);margin:0 1px}
:root[data-style="studio"] .rtr-title,:root [data-style="studio"] .rtr-title,:root [data-style="studio"].rtr-title{font-weight:500}
:root[data-style="studio"] .rtr-title:not(.shim),:root [data-style="studio"] .rtr-title:not(.shim),:root [data-style="studio"].rtr-title:not(.shim){color:var(--dm-fg)}
:root[data-style="studio"] .rtr-time,:root [data-style="studio"] .rtr-time,:root [data-style="studio"].rtr-time{font-variant-numeric:tabular-nums}
:root[data-style="studio"] .rtr-chev,:root [data-style="studio"] .rtr-chev,:root [data-style="studio"].rtr-chev{width:14px;height:14px;border-radius:50%;box-shadow:0 0 0 7px transparent;transition:transform .4s var(--dm-ease),background-color var(--dm-t-fast) var(--dm-ease),box-shadow var(--dm-t-fast) var(--dm-ease),color var(--dm-t-fast) var(--dm-ease)}
@media (hover:hover) and (pointer:fine){:root[data-style="studio"] .rtr-h:hover .rtr-chev,:root [data-style="studio"] .rtr-h:hover .rtr-chev,:root [data-style="studio"].rtr-h:hover .rtr-chev{background:var(--dm-row);box-shadow:0 0 0 7px var(--dm-row);color:var(--dm-fg)}}
/* (its press, the motion pieces' .mx-press: in Studio, where the header's hover is the chevron's fill, the press deepens that fill) */
:root[data-style="studio"] .rtr-h.mx-press:active,:root [data-style="studio"] .rtr-h.mx-press:active,:root [data-style="studio"].rtr-h.mx-press:active{background:none}
:root[data-style="studio"] .rtr-h:active .rtr-chev,:root [data-style="studio"] .rtr-h:active .rtr-chev,:root [data-style="studio"].rtr-h:active .rtr-chev{background:var(--dm-row-press);box-shadow:0 0 0 7px var(--dm-row-press);transition-duration:var(--dm-t-press)}
:root[data-style="studio"] .rtr-body,:root [data-style="studio"] .rtr-body,:root [data-style="studio"].rtr-body{padding:10px 16px;border-top:1px solid var(--dm-line)}
:root[data-style="studio"] .rtr-body[data-v="sources"],:root [data-style="studio"] .rtr-body[data-v="sources"],:root [data-style="studio"].rtr-body[data-v="sources"]{padding:16px}
:root[data-style="studio"] .rtr-li,:root [data-style="studio"] .rtr-li,:root [data-style="studio"].rtr-li{padding:6px 0 6px 28px;line-height:20px}
:root[data-style="studio"] .rtr-li .g,:root [data-style="studio"] .rtr-li .g,:root [data-style="studio"].rtr-li .g{top:8px}
:root[data-style="studio"] .rtr-li .d,:root [data-style="studio"] .rtr-li .d,:root [data-style="studio"].rtr-li .d{line-height:18px;margin-top:0}
/* the rail: a hairline from under each mark to just above the next, and over it the part that has filled */
:root[data-style="studio"] .rtr-li:not(:last-child)::before,:root [data-style="studio"] .rtr-li:not(:last-child)::before,:root [data-style="studio"].rtr-li:not(:last-child)::before{top:28px;bottom:-4px;background:var(--dm-line)}
:root[data-style="studio"] .rtr-body:not([data-v="plan"]) .rtr-li::before,:root [data-style="studio"] .rtr-body:not([data-v="plan"]) .rtr-li::before,:root [data-style="studio"].rtr-body:not([data-v="plan"]) .rtr-li::before{display:none}
:root[data-style="studio"] .rtr-body[data-v="plan"] .rtr-li:not(:last-child)::before,:root [data-style="studio"] .rtr-body[data-v="plan"] .rtr-li:not(:last-child)::before,:root [data-style="studio"].rtr-body[data-v="plan"] .rtr-li:not(:last-child)::before{background:var(--dm-line) linear-gradient(var(--dm-line-strong),var(--dm-line-strong)) no-repeat 0 0/100% 0}
:root[data-style="studio"] .rtr-body[data-v="plan"] .rtr-li[data-s="done"]:not(:last-child)::before,:root [data-style="studio"] .rtr-body[data-v="plan"] .rtr-li[data-s="done"]:not(:last-child)::before,:root [data-style="studio"].rtr-body[data-v="plan"] .rtr-li[data-s="done"]:not(:last-child)::before{background-size:100% 100%}
/* the marks */
/* (React sets its own display on Soft's tick, so this one has to win over an inline style) */
:root[data-style="studio"] .rtr-body[data-v="plan"] .g>:not(.rtr-m),:root [data-style="studio"] .rtr-body[data-v="plan"] .g>:not(.rtr-m),:root [data-style="studio"].rtr-body[data-v="plan"] .g>:not(.rtr-m){display:none!important}
:root[data-style="studio"] .rtr-m,:root [data-style="studio"] .rtr-m,:root [data-style="studio"].rtr-m{display:grid;place-items:center;width:16px;height:16px;box-sizing:border-box;border-radius:50%}
:root[data-style="studio"] [data-s="next"]>.g>.rtr-m,:root [data-style="studio"] [data-s="next"]>.g>.rtr-m,:root [data-style="studio"][data-s="next"]>.g>.rtr-m{box-shadow:inset 0 0 0 1px var(--dm-line-strong)}
:root[data-style="studio"] [data-s="now"]>.g>.rtr-m,:root [data-style="studio"] [data-s="now"]>.g>.rtr-m,:root [data-style="studio"][data-s="now"]>.g>.rtr-m{border:1.5px solid var(--dm-line);border-top-color:var(--dm-fg);animation:rot .9s linear infinite}
:root[data-style="studio"] [data-s="done"]>.g>.rtr-m,:root [data-style="studio"] [data-s="done"]>.g>.rtr-m,:root [data-style="studio"][data-s="done"]>.g>.rtr-m{background:var(--dm-ok-mark);color:var(--dm-surface)}
:root[data-style="studio"] .rtr-m svg,:root [data-style="studio"] .rtr-m svg,:root [data-style="studio"].rtr-m svg,:root[data-style="studio"] .rtr-fk svg,:root [data-style="studio"] .rtr-fk svg,:root [data-style="studio"].rtr-fk svg{width:10px;height:10px;fill:none;stroke:currentColor;stroke-width:3.2;stroke-linecap:round;stroke-linejoin:round}
/* the moment a step finishes: its disc settles in and its tick draws, the rail draws down into the next step, and that
   step's queued ring turns into the spinner as the rail reaches it */
@keyframes rtrdisc{from{opacity:0;transform:scale(.5)}}
@keyframes rtrdraw{to{stroke-dashoffset:0}}
@keyframes rtrfill{from{background-size:100% 0}}
@keyframes rtrnow{from{border-color:var(--dm-line-strong)}}
:root[data-style="studio"] .rtr-li.just>.g>.rtr-m,:root [data-style="studio"] .rtr-li.just>.g>.rtr-m,:root [data-style="studio"].rtr-li.just>.g>.rtr-m{animation:rtrdisc .34s var(--dm-ease) backwards}
:root[data-style="studio"] .rtr-li.just>.g>.rtr-m path,:root [data-style="studio"] .rtr-li.just>.g>.rtr-m path,:root [data-style="studio"].rtr-li.just>.g>.rtr-m path{stroke-dasharray:1;stroke-dashoffset:1;animation:rtrdraw .3s var(--dm-ease) .14s forwards}
:root[data-style="studio"] .rtr-body[data-v="plan"] .rtr-li.just:not(:last-child)::before,:root [data-style="studio"] .rtr-body[data-v="plan"] .rtr-li.just:not(:last-child)::before,:root [data-style="studio"].rtr-body[data-v="plan"] .rtr-li.just:not(:last-child)::before{animation:rtrfill .44s var(--dm-ease-io) .2s backwards}
:root[data-style="studio"] .rtr-li.next-in>.g>.rtr-m,:root [data-style="studio"] .rtr-li.next-in>.g>.rtr-m,:root [data-style="studio"].rtr-li.next-in>.g>.rtr-m{animation:rtrnow .3s var(--dm-ease) .5s backwards,rot .9s linear infinite}
:root[data-style="studio"] .rtr-src,:root [data-style="studio"] .rtr-src,:root [data-style="studio"].rtr-src{gap:8px}
:root[data-style="studio"] .rtr-body[data-v="edits"] .g,:root [data-style="studio"] .rtr-body[data-v="edits"] .g,:root [data-style="studio"].rtr-body[data-v="edits"] .g{color:var(--dm-muted)}
:root[data-style="studio"] .rtr-edit,:root [data-style="studio"] .rtr-edit,:root [data-style="studio"].rtr-edit{border-radius:var(--dm-r-box);margin:4px 0 8px;padding:8px 12px;line-height:20px}
:root[data-style="studio"] .rtr-body>.rtr-edit:last-child,:root [data-style="studio"] .rtr-body>.rtr-edit:last-child,:root [data-style="studio"].rtr-body>.rtr-edit:last-child,:root[data-style="studio"] .rtr-body>:last-child>.rtr-edit:last-child,:root [data-style="studio"] .rtr-body>:last-child>.rtr-edit:last-child,:root [data-style="studio"].rtr-body>:last-child>.rtr-edit:last-child{margin-bottom:6px}
/* the foot strip, once the trail is done: a green tick, how much of the plan is done, and what it read and changed */
:root[data-style="studio"] .rtr-ff,:root [data-style="studio"] .rtr-ff,:root [data-style="studio"].rtr-ff{display:grid}
:root[data-style="studio"] .rtr-f,:root [data-style="studio"] .rtr-f,:root [data-style="studio"].rtr-f{display:flex;align-items:center;gap:12px;min-height:calc(28px + 2 * var(--dm-strip-y) + 1px);margin:0;padding:0 16px;background:var(--dm-strip);border-top:1px solid var(--dm-line);font-size:12.5px;color:var(--dm-fg2);white-space:nowrap}
/* (the foot's tick is a done step's mark: the same 16px disc on the same column, its words where the steps' words start) */
:root[data-style="studio"] .rtr-fk,:root [data-style="studio"] .rtr-fk,:root [data-style="studio"].rtr-fk{display:grid;place-items:center;width:16px;height:16px;flex:none;border-radius:50%;background:var(--dm-ok-mark);color:var(--dm-surface)}
:root[data-style="studio"] .rtr-fs,:root [data-style="studio"] .rtr-fs,:root [data-style="studio"].rtr-fs{margin-left:auto;color:var(--dm-muted);overflow:hidden;text-overflow:ellipsis}
@media (prefers-reduced-motion:reduce){:root[data-style="studio"] .rtr-li:is(.just,.next-in) *,:root [data-style="studio"] .rtr-li:is(.just,.next-in) *,:root [data-style="studio"].rtr-li:is(.just,.next-in) *,:root[data-style="studio"] .rtr-li.just::before,:root [data-style="studio"] .rtr-li.just::before,:root [data-style="studio"].rtr-li.just::before{animation:none!important}:root[data-style="studio"] .rtr-li.just>.g>.rtr-m path,:root [data-style="studio"] .rtr-li.just>.g>.rtr-m path,:root [data-style="studio"].rtr-li.just>.g>.rtr-m path{stroke-dashoffset:0}:root[data-style="studio"] [data-s="now"]>.g>.rtr-m,:root [data-style="studio"] [data-s="now"]>.g>.rtr-m,:root [data-style="studio"][data-s="now"]>.g>.rtr-m{animation:none}}
reasoning-trail.jsHTML · 131 lines
DM.def('reasoning-trail', (r, c) => {
  const body = $('.rtr-body', r), head = $('.rtr-h', r), fold = $('.rtr-fold', r), title = $('.rtr-title', r), time = $('.rtr-time', r), mark = $('.rtr-mark', r);
  const rtr = $('.rtr', r), main = rtr.closest('.dm-main');
  let tab = 'plan', secs = 0, just = -1;
  const plan = [['Open the onboarding file','4 frames'],['Compare it with the design system','12 components'],['Find spacing that breaks the 8px grid','3 frames'],['Draft fixes for review','Ready']];
  const NOTES = ['The hero card uses 20px padding, every other card uses 24px.','Mobile frames already follow the grid, desktop drifted.','Two buttons use a hard-coded grey instead of a token.'];
  // each source's chip, and its tip while the agent reads it, once it has read it, and (Card.tsx) once it has edited it
  const SRC = [
    { k:'fig', mark:I('figma','xs'), label:'Onboarding.fig', reading:'Reading the frames in Figma', read:'Figma, 4 frames read' },
    { k:'ts', mark:'<span class="ft">TS</span>', label:'tokens.ts', reading:'Reading src/styles/tokens.ts', read:'src/styles/tokens.ts, 212 lines' },
    { k:'tsx', mark:'<span class="ft re">TSX</span>', label:'Card.tsx', reading:'Reading src/components/Card.tsx', read:'src/components/Card.tsx', edited:'src/components/Card.tsx, 2 edits' },
    { k:'web', mark:I('globe','xs'), label:'Spacing guide', reading:'Reading designme.dev/guide/spacing', read:'designme.dev/guide/spacing' }
  ];
  const EDITS = [
    `<div class="rtr-li" data-key="e0"><span class="g">${I('edit','xs')}</span><span>Card.tsx<span class="d">2 lines</span></span></div><div class="rtr-edit" data-key="e0d"><div class="x">padding: 20px;</div><div class="a">padding: var(--space-6);</div></div>`,
    `<div class="rtr-li" data-key="e1"><span class="g">${I('edit','xs')}</span><span>Button.tsx<span class="d">1 line</span></span></div><div class="rtr-edit" data-key="e1d"><div class="x">color: #8a8a8a;</div><div class="a">color: var(--text-dim);</div></div>`
  ];
  // where the run is: the plan steps done, the notes found (by their place in NOTES), each source's state (unread,
  // 'reading', 'read' or 'edited') and the edits drafted. Every view shows only what the run has made by then; END is
  // the finished trail
  const now = { done:0, end:false, notes:[], src:['reading'], edits:0 };
  const END = { done:plan.length, end:true, notes:[0, 1, 2], src:['read', 'read', 'edited', 'read'], edits:2 };
  // a view with nothing in it yet says so, on the row the first one will take
  const none = what => `<div class="rtr-li" data-key="none"><span class="g"><span class="dot" style="color:var(--dm-faint)"></span></span><span class="muted">No ${what} yet</span></div>`;
  // each step carries Studio's own mark (.rtr-m) beside Soft's glyph; the style shows one of them. The step that has just
  // finished (just) and the one it hands on to play Studio's tick and rail once
  const tick = '<svg viewBox="0 0 24 24"><path pathLength="1" d="m5 12.5 4.5 4.5L19 7.5"/></svg>';
  const views = {
    plan: S => plan.map((p, i) => { const s = i < S.done ? 'done' : i === S.done && !S.end ? 'now' : 'next';
      return `<div class="rtr-li ${s === 'now' ? 'now' : ''}${i === just ? ' just' : ''}${i === just + 1 && s === 'now' ? ' next-in' : ''}" data-s="${s}"><span class="g">${i < S.done ? `<span style="color:var(--dm-ok)">${I('check','xs')}</span>` : i === S.done && !S.end ? '<span class="pulse"></span>' : '<span class="dot" style="color:var(--dm-faint)"></span>'}<span class="rtr-m" aria-hidden="true">${s === 'done' ? tick : ''}</span></span><span>${p[0]}<span class="d">${i < S.done ? p[1] : i === S.done && !S.end ? 'Working' : 'Next'}</span></span></div>`; }).join(''),
    notes: S => S.notes.length ? NOTES.map((t, i) => S.notes.includes(i) ? `<div class="rtr-li" data-key="n${i}"><span class="g"><span class="dot" style="color:var(--dm-faint)"></span></span><span>${t}</span></div>` : '').join('') : none('notes'),
    // a source the agent is still reading shimmers, as the header does while it thinks
    sources: S => S.src.some(Boolean) ? `<div class="rtr-src" data-key="src">${SRC.map((x, i) => { const s = S.src[i]; return s ? `<button class="fchip lnk" data-key="s-${x.k}" data-tip-at="below" data-tip="${x[s]}">${x.mark}${s === 'reading' ? `<span class="shim">${x.label}</span>` : x.label}</button>` : ''; }).join('')}</div>` : none('sources'),
    edits: S => S.edits ? EDITS.slice(0, S.edits).join('') : none('edits')
  };
  const paint = anim => { body.dataset.v = tab; body.innerHTML = views[tab](now); if (anim) stagger(Array.from(body.children), 50); };
  // the view's new markup laid over what is on screen: an element that stays (known by its data-key) is kept, so a tip
  // open on a chip stays open, and only what changed in it is redrawn; new ones go in where they belong and gone ones come
  // out. Returns the new ones
  const morph = markup => {
    const t = document.createElement('template'); t.innerHTML = markup; const fresh = [];
    const same = (e, n) => e.innerHTML === n.innerHTML && [...n.attributes].every(a => a.name === 'class' || a.name === 'style' || e.getAttribute(a.name) === a.value);
    const walk = (have, want) => {
      const old = new Map([...have.children].map(e => [e.dataset.key, e]));
      [...want.children].forEach((n, i) => {
        let e = old.get(n.dataset.key);
        if (e){ old.delete(n.dataset.key);
          if (n.querySelector('[data-key]')) walk(e, n);
          else if (!same(e, n)){ for (const a of n.attributes) if (a.name !== 'class' && a.name !== 'style') e.setAttribute(a.name, a.value); e.innerHTML = n.innerHTML; if (tipFor === e) showTip(e); }
        } else { e = n; fresh.push(e); }
        if (have.children[i] !== e) have.insertBefore(e, have.children[i] || null);
      });
      old.forEach(e => e.remove());
    };
    walk(body, t.content); return fresh;
  };
  // Studio: the card grows with what it holds instead of keeping the room of its tallest view (grow()), and stays centred
  const studio = (r.closest('[data-style]') || document.documentElement).dataset.style === 'studio';
  // the header opens and folds the trail, by click, Enter or Space, and aria-expanded always says which
  let open = true;
  const setOpen = o => { open = o; fold.classList.toggle('shut', !o); fold.inert = !o; head.setAttribute('aria-expanded', o); };
  c.on(head, 'click', () => setOpen(!open));
  c.on(head, 'keydown', e => { if ((e.key === 'Enter' || e.key === ' ') && !e.altKey && !e.ctrlKey && !e.metaKey){ e.preventDefault(); if (!e.repeat) setOpen(!open); } });
  // the trail keeps the room of its tallest view, finished, so the tabs under it stay put and the trail sits centred above
  // them. A hidden copy measures each view at the trail's own width
  let fitW = 0;
  const fit = () => {
    const w = rtr.offsetWidth; if (!main || !w || w === fitW) return; fitW = w;
    const ghost = rtr.cloneNode(true), gb = $('.rtr-body', ghost);
    ghost.inert = true; ghost.setAttribute('aria-hidden', 'true'); $('.rtr-fold', ghost).classList.remove('shut');
    Object.assign(ghost.style, { position:'absolute', left:'0', top:'0', width:w + 'px', visibility:'hidden', pointerEvents:'none' });
    main.appendChild(ghost);
    let h = 0; for (const v in views){ gb.innerHTML = views[v](END); h = Math.max(h, ghost.offsetHeight); }
    ghost.remove(); main.style.minHeight = Math.ceil(h) + 'px'; main.style.justifyContent = 'center';
  };
  // switching views, or a view taking in what the run has just made, grows or shrinks the open trail to its new height
  // instead of jumping to it (from wherever an earlier change has it)
  const ease = from => {
    if (REDUCE || !open || studio) return; if (body._a) body._a.cancel();
    const to = body.offsetHeight; if (Math.abs(to - from) < 1) return;
    const cs = getComputedStyle(body), ms = parseFloat(cs.getPropertyValue('--dm-t')) * 1000 || 450;
    body.style.overflow = 'hidden';
    body._a = body.animate([{ height:from + 'px' }, { height:to + 'px' }], { duration:ms, easing:cs.getPropertyValue('--dm-ease').trim() || 'ease' });
    body._a.onfinish = body._a.oncancel = () => { body.style.overflow = ''; body._a = null; };
  };
  seg($('.seg2', r), v => { const from = body.offsetHeight; tab = v; paint(true); ease(from); });
  paint(true);
  // what the run has just made comes into the view on screen: new rows and chips come in as a view's do, and a row that a
  // new one lands above glides down to make room
  const update = () => {
    if (tab === 'plan') return;
    const from = body.offsetHeight; let fresh = [];
    reflow(() => $$('[data-key]:not(.rtr-src)', body), () => { fresh = morph(views[tab](now)); }, { root:rtr, enter:false, leave:false });
    fresh.forEach(el => enter(el));
    ease(from);
  };
  // grow() starts once the card's entrance has settled: it measures the content on screen, and the entrance's .98 scale
  // would otherwise leave the card that much short of it
  if (studio) requestAnimationFrame(() => { const run = []; for (let e = rtr; e; e = e.parentElement) run.push(...e.getAnimations().filter(a => a.effect && a.effect.getComputedTiming().endTime !== Infinity));
    Promise.all(run.map(a => a.finished.catch(() => {}))).then(() => { if (!c.dead) c.offs.push(grow(rtr)); }); });
  else {
    fit();
    const ro = new ResizeObserver(fit); ro.observe(main || rtr); c.offs.push(() => ro.disconnect());
    if (document.fonts) document.fonts.ready.then(() => { if (!c.dead){ fitW = 0; fit(); } });
  }
  c.every(1000, () => { if (!now.end){ secs++; time.textContent = secs + 's'; } });
  // a plan step finishes: in Studio its tick draws and the rail runs down into the next one
  const step = () => { now.done++; just = now.done - 1; if (tab === 'plan') paint(false); just = -1; };
  // the run, 1.5s a step: each source shows while the agent reads it, each note once the step that finds it is done, and
  // each edit as the last step drafts it
  c.run(async () => {
    // Open the onboarding file: it reads Onboarding.fig, and sees the hero card's padding is off
    await c.wait(1500); step(); now.src[0] = 'read'; now.notes.push(0);
    // Compare it with the design system: it reads tokens.ts, then Card.tsx, and finds the hard-coded grey
    now.src[1] = 'reading'; update();
    await c.wait(750); now.src[1] = 'read'; now.src[2] = 'reading'; update();
    await c.wait(750); step(); now.src[2] = 'read'; now.notes.push(2);
    // Find spacing that breaks the 8px grid: it reads the spacing guide, and finds where desktop drifted
    now.src[3] = 'reading'; update();
    await c.wait(1500); step(); now.src[3] = 'read'; now.notes.push(1); update();
    // Draft fixes for review: the edit to Card.tsx, then the one to Button.tsx
    await c.wait(400); now.edits = 1; now.src[2] = 'edited'; update();
    await c.wait(600); now.edits = 2; update();
    await c.wait(500);
    now.done = plan.length; now.end = true; title.classList.remove('shim'); mark.classList.remove('on'); swap(title, 'Reasoned for ' + Math.max(secs, 5) + 's'); time.textContent = ''; just = plan.length - 1; if (tab === 'plan') paint(false); just = -1;
    // Studio closes the trail with its foot strip: the plan done, and what the agent read and changed
    $('.rtr-fd', r).textContent = `All ${plan.length} steps done`; $('.rtr-fs', r).textContent = '4 sources · 2 edits';
    $('.rtr-ff', r).classList.remove('shut');
  });
});
06

Questions

What people ask about it.

Does the trail come with Plan, Notes, Sources and Edits tabs?
No. The component shows whichever view you pass in view, and you supply the switcher. The designme.dev demo puts a segmented control under it. In Soft and Blueprint it keeps the room of the tallest view, so the control stays put as you switch; in Studio the card grows or shrinks to each view.
How do I show progress through the plan?
Pass plan as steps with state set to 'done', 'now' or 'next', and update them from your own state as the agent moves on. Add to notes, sources and edits as the agent makes them, mark the source it is still reading with reading: true, and set running to false when it finishes.
What does an edit look like?
An edit has a file, an optional detail like "2 lines", and removed and added arrays of lines. Removed lines are shown first, then added ones, under the file name.
07

More in Agent status

Show what the agent is doing, how far along it is, and what it is working with.

ThinkingThe live trace, written as the agent works, then folded away.
Parallel agentsSeveral agents working in parallel, each with its own lane and hand-offs.
Delegation treeAn orchestrator and its sub-agents, with cost rolled up per branch.
Approval queueEvery run that needs you, is running or is done, in one list.
Trace viewOne agent run as a waterfall of spans, with latency and tokens.
Web searchThe agent's searches as a trail: what it asked, what came back, what it read or skipped, and the answer with its sources.
Agent run timelineEvery model and tool step of a run on one time axis.
Context meterHow full the context is and what fills it, with Compact to free room.
All 15 in Agent status →