Thinking
The live trace, written as the agent works, then folded away. Free and MIT licensed, as HTML, a typed React component or an Astro component, in three styles with light and dark mode.
Need this designed into your product? Book a call
Install
Add it to your project with the CLI.
HTML, CSS and JS
npx designme add thinkingReact
npx designme add thinking --reactAstro
npx designme add thinking --astroshadcn, React
npx shadcn@latest add https://designme.dev/r/shadcn/thinking.json shadcn, Astro
npx shadcn@latest add https://designme.dev/r/shadcn/astro/thinking.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.
About
What it is for and what it does.
Thinking is the live trace an agent writes while it works: the steps it takes, one under another on a line that turns green as each finishes, each with what it found. A step that runs into a problem shows it in amber while it waits and tries again. When the work is done, the header says what it came to and the trace folds away, one click from opening again.
- When an agent works for more than a few seconds and people want to see what it is doing rather than a spinner.
- When each step has a result worth reading, like how many frames it opened or which cards failed a check.
- When a step can hit a timeout or a rate limit and the agent waits it out instead of failing.
- When the trace should step aside once the answer is ready but stay one click away.
- Each step has a
label, astate, an optionalresultand an optionaltime. A running step turns in the accent with a soft halo and its label shimmers,retryshows a clock in amber while the step waits on a problem, anddoneturns into a check. In Studio a running step is a turning ring in the accent (white in dark mode), a done one a green disc whose tick draws in, andretryan amber clock. - The line from each step down to the next turns green, top to bottom, once the step above it is done, so the trace fills in as the work gets through it. In Studio the line is a grey hairline that darkens instead.
- While a step waits or retries its
resultcrossfades in place, so a countdown like "Trying again in 2s" updates where it is. Once the step is done, what it found writes itself in a word at a time, and itstime, like "1.3s", shows at its right.resultTipadds more detail on hover. A step's spinner, clock and check crossfade into one another on its tile (in Studio the check draws itself on a green disc). - The header shows
titlewhile it runs, like "Checking the pricing page", beside four dots turning in the accent (white in Studio's dark mode), and a clock that counts by itself unless you passseconds. - When
runningturns false, the header becomessummary, like "3 cards to fix, 2 changes planned", with a check that crossfades in for the thinking dots. The clock goes then, and withcollapseWhenDoneon, the default, the trace folds away a moment later. The trace grows with its steps instead of keeping room for them. In Studio it has a card of its own and the check draws itself on a green disc. - The header toggles the trace open and shut, and
open,defaultOpenandonOpenChangelet you control it.
- The header is a button with
aria-expanded, so screen readers hear whether the trace is open. - The list of steps is an
aria-live="polite"region, so new steps and their results are announced as they arrive. - The line between the steps is decoration: each step's state is in its mark and its words.
- With
prefers-reduced-motion: reduce, the spinner, halo, shimmer, the line's growth and the words' entrance stop and changes appear at once.
Usage
Import it in React and drive it from your own state, or place it in an Astro page.
React
import { Thinking } from '@/components/designme/thinking/Thinking';React example
The demo above as a React component, 46 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 { Thinking, type ThinkingStep } from './Thinking';
import { useScript, useStory } from '../lib/useScript';
/* ---------- Thinking: each step and what it found; measuring the cards times out once and tries again; then it folds away ---------- */
export const PRICING_STEPS: { label: string; result: string; ms: number; retry?: string; tip?: string }[] = [
{ label: 'Open Pricing v4 in Figma', result: '6 frames', ms: 1300 },
{ label: 'Read the spacing tokens', result: 'tokens.css, 9 spacing values', ms: 1200 },
{ label: 'Measure the plan cards', result: 'Off the 8px grid', ms: 1400, retry: "Figma didn't answer", tip: 'Pro has an 18px gap, Team 22px and Enterprise 13px' },
{ label: 'Check text contrast', result: 'All 14 text pairs pass AA', ms: 1100 },
{ label: 'Plan the fix', result: 'About 3 minutes of work', ms: 1200 }
];
export default function ThinkingDemo() {
const ref = useRef<HTMLDivElement>(null);
const [steps, setSteps] = useState<ThinkingStep[]>([]);
const [running, setRunning] = useState(true);
const [open, setOpen] = useState(true);
useScript(async ({ wait }) => {
await wait(600);
const out: ThinkingStep[] = [];
const show = () => setSteps(out.slice());
for (const s of PRICING_STEPS) {
out.push({ label: s.label, state: 'running' }); show();
const at = out.length - 1;
let took = s.ms;
await wait(s.ms);
if (s.retry) {
took += 2900;
for (let k = 2; k > 0; k--) { out[at] = { ...out[at], state: 'retry', result: `${s.retry}. Trying again in ${k}s` }; show(); await wait(1000); }
out[at] = { ...out[at], state: 'running', result: 'Trying again' }; show(); await wait(900);
}
out[at] = { ...out[at], state: 'done', result: s.result, resultTip: s.tip, time: (took / 1000).toFixed(1) + 's' }; show();
}
// the header says what the work came to as the last step finishes, never after it
setRunning(false);
});
// the preview's story: once it has folded, the person opens it again to read what the cards measured
useStory(ref, async ({ wait }) => {
await wait(16000); setOpen(true);
}, { hold: false });
return <div ref={ref} style={{ width: '100%' }}><Thinking steps={steps} running={running} title="Checking the pricing page" summary="3 cards to fix, 2 changes planned" open={open} onOpenChange={setOpen} /></div>;
}
Astro
In a page in src/pages. It plays the demo above; change its thinking.js to show your own data. Attributes like class go on its root element.
---
import Thinking from '../components/designme/thinking/Thinking.astro';
---
<Thinking />
<Thinking data-style="soft" class="my-class" />Props
Everything Thinking takes.
| Prop | Type | What it does |
|---|---|---|
stepsrequired | ThinkingStep[] | |
runningrequired | boolean | Spins, counts seconds and keeps the trace open while true |
seconds | number | Seconds to show. Leave it out to let it count while running |
title | string | The header while it runs, like "Checking the pricing page" |
summary | string | The header once it is done: what the work came to, like "3 cards to fix, 2 changes planned". Defaults to the number of steps |
collapseWhenDone | boolean | Folds the trace away a moment after it finishes |
open | boolean | Whether the trace is open. Leave it out to let the header toggle it |
defaultOpen | boolean | |
onOpenChange | (open: boolean) => void | |
className | string |
Code
The full source, as the CLI installs it.
Thinking.tsxReact · 144 lines
'use client';
import { useEffect, useRef, useState } from 'react';
import { cx } from '../lib/cx';
import { useControllable, useIsoLayoutEffect, useReducedMotion, useSeconds } from '../lib/hooks';
import { Icon } from '../lib/icons';
import { enter, Fold, growFit, Spin, Swap, SwapIcon, Think, Tip } from '../lib/motion';
import '../designme.css';
import './thinking.css';
export interface ThinkingStep {
/** What the agent does, like "Measure the plan cards" */
label: string;
/** running spins and shimmers, retry waits out a problem in amber, done turns into a check */
state: 'running' | 'retry' | 'done';
/** What the step found, or what it waits on, under it: "Off the 8px grid". Opens and crossfades when it changes */
result?: string;
/** More detail shown when you hover the result, like the measured values */
resultTip?: string;
/** How long the step took, like "1.3s", shown at its right once it is done */
time?: string;
}
export interface ThinkingProps {
steps: ThinkingStep[];
/** Spins, counts seconds and keeps the trace open while true */
running: boolean;
/** Seconds to show. Leave it out to let it count while running */
seconds?: number;
/** The header while it runs, like "Checking the pricing page" */
title?: string;
/** The header once it is done: what the work came to, like "3 cards to fix, 2 changes planned". Defaults to the number of steps */
summary?: string;
/** Folds the trace away a moment after it finishes */
collapseWhenDone?: boolean;
/** Whether the trace is open. Leave it out to let the header toggle it */
open?: boolean;
defaultOpen?: boolean;
onOpenChange?: (open: boolean) => void;
className?: string;
}
/** A line that settles in place when its words change, sharpening out of a soft blur. While it shimmers it just takes the new words */
function Settle({ children, shimmer, className }: { children: string; shimmer: boolean; className?: string }) {
const ref = useRef<HTMLSpanElement>(null);
const prev = useRef({ text: children, shimmer });
const reduce = useReducedMotion();
useIsoLayoutEffect(() => {
const el = ref.current, was = prev.current; prev.current = { text: children, shimmer };
if (!el) return;
// the shimmer draws the words in a clear colour; going straight to the solid colour stops it fading in from nothing
if (was.shimmer && !shimmer){ el.style.transition = 'none'; void el.offsetWidth; requestAnimationFrame(() => { el.style.transition = ''; }); }
if (shimmer || reduce || was.text === children) return;
const bp = getComputedStyle(el).getPropertyValue('--dm-motion').trim() === 'bp';
el.animate(bp ? [{ opacity: .6 }, { opacity: 1 }] : [{ opacity: .6, filter: 'blur(1.5px)' }, { opacity: 1, filter: 'blur(0)' }],
{ duration: bp ? 220 : 460, easing: bp ? 'steps(3, end)' : 'cubic-bezier(.22,1,.36,1)' });
}, [children, shimmer]);
return <span ref={ref} className={cx(shimmer && 'dm-shim', className)}>{children}</span>;
}
/** What a finished step found, written in a word at a time */
function Words({ text }: { text: string }) {
const w = text.split(' ');
return <>{w.map((x, i) => <span key={i} className="dm-w" style={{ animationDelay: `${i * 45}ms` }}>{x}{i < w.length - 1 ? ' ' : ''}</span>)}</>;
}
/** A step's result line while it runs, in amber while the step waits out a problem. The colour changes with the words
(Swap writes them 170ms on), so the words fading out keep theirs */
function Result({ text, warn }: { text: string; warn: boolean }) {
const reduce = useReducedMotion();
const [tone, setTone] = useState(warn);
const said = useRef(text);
useEffect(() => {
const was = said.current; said.current = text;
if (reduce || !was.trim() || was === text) { setTone(warn); return; }
const t = setTimeout(() => setTone(warn), 170);
return () => clearTimeout(t);
}, [text, warn, reduce]);
return <Swap className={tone ? 'dm-warn' : undefined}>{text}</Swap>;
}
function Mark({ state, studio }: { state: ThinkingStep['state']; studio: boolean }) {
const glyph = state === 'running' ? <Spin /> : <Icon name={state === 'retry' ? 'clock' : 'check'} size="xs" />;
// the mark crossfades on its tile, which keeps its fill (SwapIcon, a motion piece); Studio draws its disc and tick, keyed so
// each new mark plays its entrance once
if (!studio) return <SwapIcon id={state} style={{ display: 'grid' }}>{glyph}</SwapIcon>;
if (state === 'running') return glyph;
return <span key={state} className="dm-enter" style={{ display: 'grid' }}>{glyph}</span>;
}
/** The live trace: each step the agent takes on a line that turns green as they finish, and what each found, then a header
that says what the work came to, folded away. */
export function Thinking({ steps, running, seconds, title = 'Working on it', summary, collapseWhenDone = true, open, defaultOpen = true, onOpenChange, className }: ThinkingProps) {
// the trace grows with its steps, eased (grow() on the site), in every style (owner, 18 Nov). In Studio the finished header's
// mark is a green disc with a tick
const root = useRef<HTMLDivElement>(null), inner = useRef<HTMLDivElement>(null);
const [studio, setStudio] = useState(false);
useIsoLayoutEffect(() => { setStudio(root.current?.closest('[data-style]')?.getAttribute('data-style') === 'studio'); }, []);
useIsoLayoutEffect(() => { const el = root.current, w = inner.current; if (el && w) return growFit(el, w); }, []);
const counted = useSeconds(running && seconds === undefined);
const secs = seconds ?? counted;
const [isOpen, setOpen] = useControllable(open, defaultOpen, onOpenChange);
// once it finishes, the trace waits a beat and folds itself away
useEffect(() => {
if (running || !collapseWhenDone || !steps.length) return;
const t = setTimeout(() => setOpen(false), 2500);
return () => clearTimeout(t);
}, [running, collapseWhenDone, steps.length]); // eslint-disable-line react-hooks/exhaustive-deps
const done = !running && steps.length > 0;
return (
<div data-dm="" ref={root} className={cx('dm-tk', 'dm-growing dm-mx-grow dm-mx-ic', className)} data-open={isOpen ? '1' : '0'}>
<div ref={inner} className="dm-grow">
<button type="button" className={cx('dm-tk-h', done && 'dm-tk-fin')} aria-expanded={isOpen} onClick={() => setOpen(!isOpen)}>
<span className="dm-tk-mark">{studio ? (done ? <span key="ok" {...enter()} style={{ display: 'grid' }}><Icon name="check" size="xs" /></span> : <Think on={running} />)
: <SwapIcon id={done ? 'ok' : 'think'} style={{ display: 'grid' }}>{done ? <Icon name="ok" size="s" /> : <Think on={running} />}</SwapIcon>}</span>
<Settle className="dm-tk-title" shimmer={running}>{done ? summary ?? `${steps.length} ${steps.length === 1 ? 'step' : 'steps'}` : title}</Settle>
<span className="dm-tk-time dm-num">{secs + 's'}</span>
<Icon name="chev-d" size="xs" className="dm-tk-chev" />
</button>
<Fold open={isOpen} className="dm-tk-fold">
<ol className="dm-tk-list" aria-live="polite">
{steps.map((s, i) => (
<li key={i} className={cx('dm-tk-st dm-enter', s.state === 'running' ? 'dm-run' : 'dm-' + s.state)}>
<span className="dm-mk"><Mark state={s.state} studio={studio} /></span>
<div className="dm-tx">
<span className="dm-tk-ln">
<Settle className="dm-lab" shimmer={s.state === 'running'}>{s.label}</Settle>
{s.state === 'done' && s.time && <span key="t" className="dm-tk-dur dm-num dm-enter">{s.time}</span>}
</span>
<span className={cx('dm-res', s.result && 'dm-on')}>
{s.state === 'done' && s.result
? <span key={'w' + s.result}>{s.resultTip ? <Tip label={s.resultTip}><span tabIndex={0} data-tip=""><Words text={s.result} /></span></Tip> : <Words text={s.result} />}</span>
: <Result text={s.result ?? ''} warn={s.state === 'retry'} />}
</span>
</div>
</li>
))}
</ol>
</Fold>
</div>
</div>
);
}
thinking.cssReact · 117 lines
/* Generated from designme.dev by scripts/sync.mjs. Edit the site, then sync. */
/* ---------- Thinking ---------- */
/* the steps the agent takes, on a line that turns green as each one finishes; the step in hand turns in the accent with a
soft halo, and what each step found writes itself in under it. The header ends as a summary of the work */
/* neither the trace nor the box it sits in anchors the page's scroll: a centred demo that grows would otherwise pull
the page along with it */
.dm-stage-in:has(>.dm-tk){overflow-anchor:none}
.dm-tk{font-size:14px;width:100%;max-width:420px;margin-inline:auto;overflow-anchor:none}
/* on a card the trace keeps the room it will fill, so the header stays put as steps arrive */
/* the trace grows with its steps in every style (grow(), owner's notes 18 Nov): no room kept for the steps to come. The
header's hover fill reaches 8px past its sides, so the growing box lets that much show */
.dm-tk.dm-growing{overflow-clip-margin:12px}
.dm-tk-h{display:flex;align-items:center;gap:10px;width:calc(100% + 16px);margin:0 -8px;padding:6px var(--dm-s-2);border-radius:calc(10px * var(--dm-rk-m,var(--dm-rk)));text-align:left;transition:background var(--dm-t-fast)}
/* the header's hover is a quiet fill round the chevron, never a band wider than the trace (owner, 18 Nov) */
@media (hover:hover) and (pointer:fine){.dm-tk-h:hover .dm-tk-chev{background:color-mix(in srgb,var(--dm-fg) 5%,transparent);box-shadow:0 0 0 6px color-mix(in srgb,var(--dm-fg) 5%,transparent);color:var(--dm-fg)}}
.dm-tk-mark{width:18px;height:18px;flex:none;display:grid;place-items:center;color:var(--dm-accent-mark,var(--dm-accent));transition:color .3s}
.dm-tk-h.dm-tk-fin .dm-tk-mark{color:var(--dm-ok)}
/* a finished state has no elapsed clock (owner, 18 Nov): the clock goes once the header says what the work came to */
.dm-tk-h.dm-tk-fin .dm-tk-time{visibility:hidden}
.dm-tk-h.dm-tk-fin .dm-tk-mark .dm-i{animation:dm-tkpop .5s var(--dm-ease) backwards}
.dm-tk-title{flex:1;min-width:0;color:var(--dm-fg)}
.dm-tk-time{color:var(--dm-muted);font-size:13px}
.dm-tk-chev{color:var(--dm-muted);border-radius:50%;transition:transform .32s var(--dm-ease),background-color var(--dm-t-fast),box-shadow var(--dm-t-fast),color var(--dm-t-fast)}
:root:not([data-style="soft"],[data-style="studio"]) .dm-tk-chev:not(:where([data-style="soft"],[data-style="soft"] *,[data-style="studio"],[data-style="studio"] *)){border-radius:0}
.dm-tk[data-open="0"] .dm-tk-chev{transform:rotate(-90deg)}
.dm-tk-list{list-style:none;margin:0;padding:6px 0 0;display:flex;flex-direction:column}
.dm-tk-st{position:relative;display:flex;gap:10px;padding:6px 0}
/* the line from each step down to the next: grey, and green once the step above it is done */
.dm-tk-st:not(:last-child)::before,.dm-tk-st.dm-done:not(:last-child)::after{content:"";position:absolute;left:8.25px;top:29px;bottom:-5px;width:1.5px;border-radius:1px;background:var(--dm-line)}
.dm-tk-st.dm-done:not(:last-child)::after{background:color-mix(in srgb,var(--dm-ok) 55%,var(--dm-line));transform-origin:top;animation:dm-tkgrow .6s var(--dm-ease) backwards}
@keyframes dm-tkgrow{from{transform:scaleY(0)}}
.dm-tk-st .dm-mk{position:relative;width:18px;height:18px;flex:none;margin-top:1px;display:grid;place-items:center;border-radius:50%;color:var(--dm-muted);transition:background .32s,color .32s}
.dm-tk-st .dm-mk .dm-spin{width:10px;height:10px}
.dm-tk-st.dm-run .dm-mk{color:var(--dm-accent-mark,var(--dm-accent));background:var(--dm-accent-bg);animation:dm-tkhalo 1.8s var(--dm-ease-io) infinite}
.dm-tk-st.dm-done .dm-mk{background:var(--dm-ok-bg);color:var(--dm-ok)}
.dm-tk-st.dm-done .dm-mk .dm-i{animation:dm-tkpop .45s var(--dm-ease) backwards}
/* its motion (the core's motion pieces, owner, 26 Nov): a press on the header shows at once as a deeper fill round the chevron,
the hover's own shape; a mark that changes (a step's ring, clock and tick, the header's dots and finished mark) crossfades in
place (.mx-ic, iconSwap(), in place of the tick's own pop); the trace grows on the spring (.mx-grow) */
.dm-tk-h:active .dm-tk-chev{background:var(--dm-row-press);box-shadow:0 0 0 6px var(--dm-row-press);transition-duration:var(--dm-t-press)}
.dm-tk.dm-mx-ic .dm-tk-st.dm-done .dm-mk .dm-i,.dm-tk.dm-mx-ic .dm-tk-h.dm-tk-fin .dm-tk-mark .dm-i{animation:none}
.dm-tk-st.dm-retry .dm-mk{background:var(--dm-warn-bg);color:var(--dm-warn);animation:dm-tkhalow 1.8s var(--dm-ease-io) infinite}
@keyframes dm-tkhalo{0%,100%{box-shadow:0 0 0 0 color-mix(in srgb,var(--dm-fg) 0%,transparent)}50%{box-shadow:0 0 0 4px color-mix(in srgb,var(--dm-fg) 6%,transparent)}}
@keyframes dm-tkhalow{0%,100%{box-shadow:0 0 0 0 color-mix(in srgb,var(--dm-fg) 0%,transparent)}50%{box-shadow:0 0 0 4px color-mix(in srgb,var(--dm-fg) 6%,transparent)}}
@keyframes dm-tkpop{0%{transform:scale(.4);opacity:0}60%{transform:scale(1.15);opacity:1}100%{transform:none}}
.dm-tk-st .dm-tx{flex:1;min-width:0;display:flex;flex-direction:column}
.dm-tk-st .dm-tk-ln{display:flex;align-items:baseline;gap:var(--dm-s-2)}
.dm-tk-st .dm-lab{flex:1;min-width:0;color:var(--dm-fg);transition:color .32s}
.dm-tk-st.dm-done .dm-lab{color:var(--dm-fg2)}
/* how long the step took, once it is done */
.dm-tk-st .dm-tk-dur{flex:none;font-size:12px;color:var(--dm-muted)}
/* what a step found opens under it, a word at a time */
.dm-tk-st .dm-res{display:grid;grid-template-rows:0fr;font-size:13px;color:var(--dm-muted);transition:grid-template-rows .32s var(--dm-ease),color .32s}
.dm-tk-st .dm-res.dm-on{grid-template-rows:1fr}
.dm-tk-st .dm-res>span{overflow:hidden;min-height:0}
.dm-tk-st .dm-res .dm-w{display:inline-block;white-space:pre;animation:dm-tkword .42s var(--dm-ease) backwards}
@keyframes dm-tkword{from{opacity:0;transform:translateY(3px);filter:blur(2px)}}
/* a retry's words are amber; the colour changes with the words, so the ones fading out keep theirs */
.dm-tk-st .dm-res .dm-warn{color:var(--dm-warn)}
.dm-tk-st .dm-res [data-tip]{text-decoration:underline dotted var(--dm-faint);text-underline-offset:3px;cursor:default}
:root:not([data-style="soft"],[data-style="studio"]) .dm-tk-st.dm-run .dm-mk:not(:where([data-style="soft"],[data-style="soft"] *,[data-style="studio"],[data-style="studio"] *)),:root:not([data-style="soft"],[data-style="studio"]) .dm-tk-st.dm-retry .dm-mk:not(:where([data-style="soft"],[data-style="soft"] *,[data-style="studio"],[data-style="studio"] *)){animation:none}
:root:not([data-style="soft"],[data-style="studio"]) .dm-tk-st.dm-run .dm-mk:not(:where([data-style="soft"],[data-style="soft"] *,[data-style="studio"],[data-style="studio"] *)){box-shadow:inset 0 0 0 1px var(--dm-accent-mark)}
:root:not([data-style="soft"],[data-style="studio"]) .dm-tk-st.dm-done:not(:last-child):not(:where([data-style="soft"],[data-style="soft"] *,[data-style="studio"],[data-style="studio"] *))::after{background:var(--dm-ok);width:1px;left:8.5px}
:root:not([data-style="soft"],[data-style="studio"]) .dm-tk-st:not(:last-child):not(:where([data-style="soft"],[data-style="soft"] *,[data-style="studio"],[data-style="studio"] *))::before{width:1px;left:8.5px;background:repeating-linear-gradient(var(--dm-rail) 0 3px,transparent 3px 6px)}
:root:not([data-style="soft"],[data-style="studio"]) .dm-tk-st.dm-done .dm-mk .dm-i:not(:where([data-style="soft"],[data-style="soft"] *,[data-style="studio"],[data-style="studio"] *)),:root:not([data-style="soft"],[data-style="studio"]) .dm-tk-h.dm-tk-fin .dm-tk-mark .dm-i:not(:where([data-style="soft"],[data-style="soft"] *,[data-style="studio"],[data-style="studio"] *)){animation:none}
:root:not([data-style="soft"],[data-style="studio"]) .dm-tk-st .dm-res .dm-w:not(:where([data-style="soft"],[data-style="soft"] *,[data-style="studio"],[data-style="studio"] *)){animation:dm-bpin .3s var(--dm-ease) backwards}
/* Studio (owner, 18 Nov): a card of its own, like Reasoning trail's: a hairline-outlined round card with the header on top
and a hairline under it. The card grows with its steps (grow(), never the room it will fill) and folds into its header.
Content sits 16px in from every edge, and each step's words start where the header's do. The steps sit on a hairline
that darkens down into each step as the one above finishes (grey, never a hue); the step in hand is a turning ring in the accent (white in dark mode),
a finished step a green disc whose tick draws in, and a step waiting out a problem an amber clock. The header's dots
turn in the accent, and as the last step finishes it becomes what the work came to, with a green disc */
:root[data-style="studio"] .dm-tk,:root [data-style="studio"] .dm-tk,:root [data-style="studio"].dm-tk{background:var(--dm-surface);box-shadow:var(--dm-shadow);border-radius:var(--dm-r-card);overflow:clip}
:root[data-style="studio"] .dm-tk.dm-growing,:root [data-style="studio"] .dm-tk.dm-growing,:root [data-style="studio"].dm-tk.dm-growing{overflow-clip-margin:0px}
:root[data-style="studio"] .dm-tk-h,:root [data-style="studio"] .dm-tk-h,:root [data-style="studio"].dm-tk-h{width:100%;min-height:48px;margin:0;padding:16px;gap:10px;align-items:flex-start;border-radius:0;line-height:20px}
/* a header that wraps on a phone keeps its mark, time and chevron on the centre line of its first line */
:root[data-style="studio"] .dm-tk-h>.dm-tk-mark,:root [data-style="studio"] .dm-tk-h>.dm-tk-mark,:root [data-style="studio"].dm-tk-h>.dm-tk-mark{margin-top:2px}
:root[data-style="studio"] .dm-tk-h>.dm-tk-chev,:root [data-style="studio"] .dm-tk-h>.dm-tk-chev,:root [data-style="studio"].dm-tk-h>.dm-tk-chev{margin-top:3px}
@media (hover:hover) and (pointer:fine){:root[data-style="studio"] .dm-tk-h:hover,:root [data-style="studio"] .dm-tk-h:hover,:root [data-style="studio"].dm-tk-h:hover{background:none}}
:root[data-style="studio"] .dm-tk-h:focus-visible,:root [data-style="studio"] .dm-tk-h:focus-visible,:root [data-style="studio"].dm-tk-h:focus-visible{outline-offset:-2px;border-radius:var(--dm-r-card)}
/* the clock follows the title while it works, as in "Checking the pricing page 7s", and goes once the header says what the
work came to (a finished state has no elapsed clock); the chevron keeps the right edge, where the steps' times end too */
:root[data-style="studio"] .dm-tk-title,:root [data-style="studio"] .dm-tk-title,:root [data-style="studio"].dm-tk-title{flex:0 1 auto;font-weight:500}
:root[data-style="studio"] .dm-tk-time,:root [data-style="studio"] .dm-tk-time,:root [data-style="studio"].dm-tk-time{margin-right:auto;font-variant-numeric:tabular-nums}
:root[data-style="studio"] .dm-tk-chev,:root [data-style="studio"] .dm-tk-chev,:root [data-style="studio"].dm-tk-chev{width:14px;height:14px;border-radius:50%;box-shadow:0 0 0 7px transparent;transition:transform var(--dm-t) 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-tk-h:hover .dm-tk-chev,:root [data-style="studio"] .dm-tk-h:hover .dm-tk-chev,:root [data-style="studio"].dm-tk-h:hover .dm-tk-chev{background:var(--dm-row);box-shadow:0 0 0 7px var(--dm-row);color:var(--dm-fg)}}
:root[data-style="studio"] .dm-tk-h:active .dm-tk-chev,:root [data-style="studio"] .dm-tk-h:active .dm-tk-chev,:root [data-style="studio"].dm-tk-h:active .dm-tk-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-tk-mark,:root [data-style="studio"] .dm-tk-mark,:root [data-style="studio"].dm-tk-mark{width:16px;height:16px;margin-right:2px;color:var(--dm-accent-mark)}
:root[data-style="studio"] .dm-tk-h.dm-tk-fin .dm-tk-mark,:root [data-style="studio"] .dm-tk-h.dm-tk-fin .dm-tk-mark,:root [data-style="studio"].dm-tk-h.dm-tk-fin .dm-tk-mark{width:16px;height:16px;border-radius:50%;background:var(--dm-ok-mark);color:var(--dm-surface);animation:dm-tkdisc var(--dm-t) var(--dm-ease) backwards}
:root[data-style="studio"] .dm-tk-h.dm-tk-fin .dm-tk-mark .dm-i,:root [data-style="studio"] .dm-tk-h.dm-tk-fin .dm-tk-mark .dm-i,:root [data-style="studio"].dm-tk-h.dm-tk-fin .dm-tk-mark .dm-i{width:10px;height:10px;stroke-width:3.2;stroke-dasharray:21;animation:dm-tkdraw var(--dm-t) var(--dm-ease) .14s backwards}
/* the first step's words 16px under the header's hairline and the last ones 16px from the card's foot, 5px above and below
each step; the card is no taller than Soft's trace, so its stage keeps its height in every style */
:root[data-style="studio"] .dm-tk-list,:root [data-style="studio"] .dm-tk-list,:root [data-style="studio"].dm-tk-list{padding:10px 16px;border-top:1px solid var(--dm-line)}
:root[data-style="studio"] .dm-tk-st,:root [data-style="studio"] .dm-tk-st,:root [data-style="studio"].dm-tk-st{padding:5px 0}
/* a step's time sits on its first line's baseline (owner, 23 Nov: words side by side share one baseline), and ends where the
chevron does */
:root[data-style="studio"] .dm-tk-st .dm-tk-ln,:root [data-style="studio"] .dm-tk-st .dm-tk-ln,:root [data-style="studio"].dm-tk-st .dm-tk-ln{align-items:baseline}
:root[data-style="studio"] .dm-tk-st .dm-lab,:root [data-style="studio"] .dm-tk-st .dm-lab,:root [data-style="studio"].dm-tk-st .dm-lab,:root[data-style="studio"] .dm-tk-st .dm-tk-dur,:root [data-style="studio"] .dm-tk-st .dm-tk-dur,:root [data-style="studio"].dm-tk-st .dm-tk-dur{line-height:19px}
:root[data-style="studio"] .dm-tk-st .dm-res,:root [data-style="studio"] .dm-tk-st .dm-res,:root [data-style="studio"].dm-tk-st .dm-res{line-height:17px}
:root[data-style="studio"] .dm-tk-st .dm-tk-dur,:root [data-style="studio"] .dm-tk-st .dm-tk-dur,:root [data-style="studio"].dm-tk-st .dm-tk-dur{font-variant-numeric:tabular-nums}
/* the marks: 16px discs 16px in from the card's edge, centred on the step's first line, under the header's mark */
:root[data-style="studio"] .dm-tk-st .dm-mk,:root [data-style="studio"] .dm-tk-st .dm-mk,:root [data-style="studio"].dm-tk-st .dm-mk{width:16px;height:16px;margin:1.5px 2px 0 0;color:var(--dm-fg);background:none;transition:none}
:root[data-style="studio"] .dm-tk-st.dm-run .dm-mk,:root [data-style="studio"] .dm-tk-st.dm-run .dm-mk,:root [data-style="studio"].dm-tk-st.dm-run .dm-mk{background:none;animation:none}
:root[data-style="studio"] .dm-tk-st.dm-run .dm-mk .dm-spin,:root [data-style="studio"] .dm-tk-st.dm-run .dm-mk .dm-spin,:root [data-style="studio"].dm-tk-st.dm-run .dm-mk .dm-spin{box-sizing:border-box;width:16px;height:16px;border:1.5px solid var(--dm-line);border-top-color:var(--dm-accent-mark);animation:dm-rot .9s linear infinite}
:root[data-style="studio"] .dm-tk-st.dm-done .dm-mk,:root [data-style="studio"] .dm-tk-st.dm-done .dm-mk,:root [data-style="studio"].dm-tk-st.dm-done .dm-mk{background:var(--dm-ok-mark);color:var(--dm-surface);animation:dm-tkdisc var(--dm-t) var(--dm-ease) backwards}
:root[data-style="studio"] .dm-tk-st.dm-done .dm-mk .dm-i,:root [data-style="studio"] .dm-tk-st.dm-done .dm-mk .dm-i,:root [data-style="studio"].dm-tk-st.dm-done .dm-mk .dm-i{width:10px;height:10px;stroke-width:3.2;stroke-dasharray:21;animation:dm-tkdraw var(--dm-t) var(--dm-ease) .14s backwards}
:root[data-style="studio"] .dm-tk-st.dm-retry .dm-mk,:root [data-style="studio"] .dm-tk-st.dm-retry .dm-mk,:root [data-style="studio"].dm-tk-st.dm-retry .dm-mk{background:none;color:var(--dm-warn-mark);animation:none}
:root[data-style="studio"] .dm-tk-st.dm-retry .dm-mk .dm-i,:root [data-style="studio"] .dm-tk-st.dm-retry .dm-mk .dm-i,:root [data-style="studio"].dm-tk-st.dm-retry .dm-mk .dm-i{width:16px;height:16px;stroke-width:1.8}
@keyframes dm-tkdisc{from{opacity:0;transform:scale(.5)}}
@keyframes dm-tkdraw{from{stroke-dashoffset:21}}
/* the hairline from under each mark to just above the next, darkening down into the next step once this one is done */
:root[data-style="studio"] .dm-tk-st:not(:last-child)::before,:root [data-style="studio"] .dm-tk-st:not(:last-child)::before,:root [data-style="studio"].dm-tk-st:not(:last-child)::before,:root[data-style="studio"] .dm-tk-st.dm-done:not(:last-child)::after,:root [data-style="studio"] .dm-tk-st.dm-done:not(:last-child)::after,:root [data-style="studio"].dm-tk-st.dm-done:not(:last-child)::after{left:7.5px;top:26.5px;bottom:-2.5px;width:1px;border-radius:0;background:var(--dm-line)}
:root[data-style="studio"] .dm-tk-st.dm-done:not(:last-child)::after,:root [data-style="studio"] .dm-tk-st.dm-done:not(:last-child)::after,:root [data-style="studio"].dm-tk-st.dm-done:not(:last-child)::after{background:var(--dm-line-strong);animation:dm-tkgrow var(--dm-t-slow) var(--dm-ease-io) .2s backwards}
/* what a step found writes itself in a word at a time: a fade and a 3px rise, no blur */
@keyframes dm-tkwordc{from{opacity:0;transform:translateY(3px)}}
:root[data-style="studio"] .dm-tk-st .dm-res .dm-w,:root [data-style="studio"] .dm-tk-st .dm-res .dm-w,:root [data-style="studio"].dm-tk-st .dm-res .dm-w{animation:dm-tkwordc var(--dm-t-slow) var(--dm-ease) backwards}
Thinking.astroAstro · 31 lines
---
// Generated from designme.dev by scripts/sync.mjs. Edit the site, then sync.
// Thinking: The live trace, written as the agent works, then folded away.
// 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 thinking.js. The markup is kept exactly as it is (is:raw).
import type { HTMLAttributes } from 'astro/types';
import '../core/designme.css';
import './thinking.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="thinking" {...rest}>
<div class="stage-in"><Fragment is:raw>
<div class="tk mx-grow mx-ic" data-open="1">
<button class="tk-h" aria-expanded="true">
<span class="tk-mark"><span class="think on"><i></i><i></i><i></i><i></i></span></span>
<span class="tk-title shim">Checking the pricing page</span><span class="tk-time num">0s</span>
<svg class="i xs tk-chev"><use href="#i-chev-d"/></svg>
</button>
<div class="fold tk-fold"><div><ol class="tk-list" aria-live="polite"></ol></div></div>
</div>
</Fragment></div>
</div>
<script>
import './thinking.js';
</script>
thinking.htmlHTML · 13 lines
<div class="card bare" data-c="thinking">
<div class="stage-in">
<div class="tk mx-grow mx-ic" data-open="1">
<button class="tk-h" aria-expanded="true">
<span class="tk-mark"><span class="think on"><i></i><i></i><i></i><i></i></span></span>
<span class="tk-title shim">Checking the pricing page</span><span class="tk-time num">0s</span>
<svg class="i xs tk-chev"><use href="#i-chev-d"/></svg>
</button>
<div class="fold tk-fold"><div><ol class="tk-list" aria-live="polite"></ol></div></div>
</div>
</div>
</div>
thinking.cssHTML · 116 lines
/* ---------- Thinking ---------- */
/* the steps the agent takes, on a line that turns green as each one finishes; the step in hand turns in the accent with a
soft halo, and what each step found writes itself in under it. The header ends as a summary of the work */
/* neither the trace nor the box it sits in anchors the page's scroll: a centred demo that grows would otherwise pull
the page along with it */
.stage-in:has(>.tk){overflow-anchor:none}
.tk{font-size:14px;width:100%;max-width:420px;margin-inline:auto;overflow-anchor:none}
/* on a card the trace keeps the room it will fill, so the header stays put as steps arrive */
/* the trace grows with its steps in every style (grow(), owner's notes 18 Nov): no room kept for the steps to come. The
header's hover fill reaches 8px past its sides, so the growing box lets that much show */
.tk.growing{overflow-clip-margin:12px}
.tk-h{display:flex;align-items:center;gap:10px;width:calc(100% + 16px);margin:0 -8px;padding:6px var(--dm-s-2);border-radius:calc(10px * var(--dm-rk-m,var(--dm-rk)));text-align:left;transition:background var(--dm-t-fast)}
/* the header's hover is a quiet fill round the chevron, never a band wider than the trace (owner, 18 Nov) */
@media (hover:hover) and (pointer:fine){.tk-h:hover .tk-chev{background:color-mix(in srgb,var(--dm-fg) 5%,transparent);box-shadow:0 0 0 6px color-mix(in srgb,var(--dm-fg) 5%,transparent);color:var(--dm-fg)}}
.tk-mark{width:18px;height:18px;flex:none;display:grid;place-items:center;color:var(--dm-accent-mark,var(--dm-accent));transition:color .3s}
.tk-h.tk-fin .tk-mark{color:var(--dm-ok)}
/* a finished state has no elapsed clock (owner, 18 Nov): the clock goes once the header says what the work came to */
.tk-h.tk-fin .tk-time{visibility:hidden}
.tk-h.tk-fin .tk-mark .i{animation:tkpop .5s var(--dm-ease) backwards}
.tk-title{flex:1;min-width:0;color:var(--dm-fg)}
.tk-time{color:var(--dm-muted);font-size:13px}
.tk-chev{color:var(--dm-muted);border-radius:50%;transition:transform .32s var(--dm-ease),background-color var(--dm-t-fast),box-shadow var(--dm-t-fast),color var(--dm-t-fast)}
:root:not([data-style="soft"],[data-style="studio"]) .tk-chev:not(:where([data-style="soft"],[data-style="soft"] *,[data-style="studio"],[data-style="studio"] *)){border-radius:0}
.tk[data-open="0"] .tk-chev{transform:rotate(-90deg)}
.tk-list{list-style:none;margin:0;padding:6px 0 0;display:flex;flex-direction:column}
.tk-st{position:relative;display:flex;gap:10px;padding:6px 0}
/* the line from each step down to the next: grey, and green once the step above it is done */
.tk-st:not(:last-child)::before,.tk-st.done:not(:last-child)::after{content:"";position:absolute;left:8.25px;top:29px;bottom:-5px;width:1.5px;border-radius:1px;background:var(--dm-line)}
.tk-st.done:not(:last-child)::after{background:color-mix(in srgb,var(--dm-ok) 55%,var(--dm-line));transform-origin:top;animation:tkgrow .6s var(--dm-ease) backwards}
@keyframes tkgrow{from{transform:scaleY(0)}}
.tk-st .mk{position:relative;width:18px;height:18px;flex:none;margin-top:1px;display:grid;place-items:center;border-radius:50%;color:var(--dm-muted);transition:background .32s,color .32s}
.tk-st .mk .spin{width:10px;height:10px}
.tk-st.run .mk{color:var(--dm-accent-mark,var(--dm-accent));background:var(--dm-accent-bg);animation:tkhalo 1.8s var(--dm-ease-io) infinite}
.tk-st.done .mk{background:var(--dm-ok-bg);color:var(--dm-ok)}
.tk-st.done .mk .i{animation:tkpop .45s var(--dm-ease) backwards}
/* its motion (the core's motion pieces, owner, 26 Nov): a press on the header shows at once as a deeper fill round the chevron,
the hover's own shape; a mark that changes (a step's ring, clock and tick, the header's dots and finished mark) crossfades in
place (.mx-ic, iconSwap(), in place of the tick's own pop); the trace grows on the spring (.mx-grow) */
.tk-h:active .tk-chev{background:var(--dm-row-press);box-shadow:0 0 0 6px var(--dm-row-press);transition-duration:var(--dm-t-press)}
.tk.mx-ic .tk-st.done .mk .i,.tk.mx-ic .tk-h.tk-fin .tk-mark .i{animation:none}
.tk-st.retry .mk{background:var(--dm-warn-bg);color:var(--dm-warn);animation:tkhalow 1.8s var(--dm-ease-io) infinite}
@keyframes tkhalo{0%,100%{box-shadow:0 0 0 0 color-mix(in srgb,var(--dm-fg) 0%,transparent)}50%{box-shadow:0 0 0 4px color-mix(in srgb,var(--dm-fg) 6%,transparent)}}
@keyframes tkhalow{0%,100%{box-shadow:0 0 0 0 color-mix(in srgb,var(--dm-fg) 0%,transparent)}50%{box-shadow:0 0 0 4px color-mix(in srgb,var(--dm-fg) 6%,transparent)}}
@keyframes tkpop{0%{transform:scale(.4);opacity:0}60%{transform:scale(1.15);opacity:1}100%{transform:none}}
.tk-st .tx{flex:1;min-width:0;display:flex;flex-direction:column}
.tk-st .tk-ln{display:flex;align-items:baseline;gap:var(--dm-s-2)}
.tk-st .lab{flex:1;min-width:0;color:var(--dm-fg);transition:color .32s}
.tk-st.done .lab{color:var(--dm-fg2)}
/* how long the step took, once it is done */
.tk-st .tk-dur{flex:none;font-size:12px;color:var(--dm-muted)}
/* what a step found opens under it, a word at a time */
.tk-st .res{display:grid;grid-template-rows:0fr;font-size:13px;color:var(--dm-muted);transition:grid-template-rows .32s var(--dm-ease),color .32s}
.tk-st .res.on{grid-template-rows:1fr}
.tk-st .res>span{overflow:hidden;min-height:0}
.tk-st .res .w{display:inline-block;white-space:pre;animation:tkword .42s var(--dm-ease) backwards}
@keyframes tkword{from{opacity:0;transform:translateY(3px);filter:blur(2px)}}
/* a retry's words are amber; the colour changes with the words, so the ones fading out keep theirs */
.tk-st .res .warn{color:var(--dm-warn)}
.tk-st .res [data-tip]{text-decoration:underline dotted var(--dm-faint);text-underline-offset:3px;cursor:default}
:root:not([data-style="soft"],[data-style="studio"]) .tk-st.run .mk:not(:where([data-style="soft"],[data-style="soft"] *,[data-style="studio"],[data-style="studio"] *)),:root:not([data-style="soft"],[data-style="studio"]) .tk-st.retry .mk:not(:where([data-style="soft"],[data-style="soft"] *,[data-style="studio"],[data-style="studio"] *)){animation:none}
:root:not([data-style="soft"],[data-style="studio"]) .tk-st.run .mk:not(:where([data-style="soft"],[data-style="soft"] *,[data-style="studio"],[data-style="studio"] *)){box-shadow:inset 0 0 0 1px var(--dm-accent-mark)}
:root:not([data-style="soft"],[data-style="studio"]) .tk-st.done:not(:last-child):not(:where([data-style="soft"],[data-style="soft"] *,[data-style="studio"],[data-style="studio"] *))::after{background:var(--dm-ok);width:1px;left:8.5px}
:root:not([data-style="soft"],[data-style="studio"]) .tk-st:not(:last-child):not(:where([data-style="soft"],[data-style="soft"] *,[data-style="studio"],[data-style="studio"] *))::before{width:1px;left:8.5px;background:repeating-linear-gradient(var(--dm-rail) 0 3px,transparent 3px 6px)}
:root:not([data-style="soft"],[data-style="studio"]) .tk-st.done .mk .i:not(:where([data-style="soft"],[data-style="soft"] *,[data-style="studio"],[data-style="studio"] *)),:root:not([data-style="soft"],[data-style="studio"]) .tk-h.tk-fin .tk-mark .i:not(:where([data-style="soft"],[data-style="soft"] *,[data-style="studio"],[data-style="studio"] *)){animation:none}
:root:not([data-style="soft"],[data-style="studio"]) .tk-st .res .w:not(:where([data-style="soft"],[data-style="soft"] *,[data-style="studio"],[data-style="studio"] *)){animation:bpin .3s var(--dm-ease) backwards}
/* Studio (owner, 18 Nov): a card of its own, like Reasoning trail's: a hairline-outlined round card with the header on top
and a hairline under it. The card grows with its steps (grow(), never the room it will fill) and folds into its header.
Content sits 16px in from every edge, and each step's words start where the header's do. The steps sit on a hairline
that darkens down into each step as the one above finishes (grey, never a hue); the step in hand is a turning ring in the accent (white in dark mode),
a finished step a green disc whose tick draws in, and a step waiting out a problem an amber clock. The header's dots
turn in the accent, and as the last step finishes it becomes what the work came to, with a green disc */
:root[data-style="studio"] .tk,:root [data-style="studio"] .tk,:root [data-style="studio"].tk{background:var(--dm-surface);box-shadow:var(--dm-shadow);border-radius:var(--dm-r-card);overflow:clip}
:root[data-style="studio"] .tk.growing,:root [data-style="studio"] .tk.growing,:root [data-style="studio"].tk.growing{overflow-clip-margin:0px}
:root[data-style="studio"] .tk-h,:root [data-style="studio"] .tk-h,:root [data-style="studio"].tk-h{width:100%;min-height:48px;margin:0;padding:16px;gap:10px;align-items:flex-start;border-radius:0;line-height:20px}
/* a header that wraps on a phone keeps its mark, time and chevron on the centre line of its first line */
:root[data-style="studio"] .tk-h>.tk-mark,:root [data-style="studio"] .tk-h>.tk-mark,:root [data-style="studio"].tk-h>.tk-mark{margin-top:2px}
:root[data-style="studio"] .tk-h>.tk-chev,:root [data-style="studio"] .tk-h>.tk-chev,:root [data-style="studio"].tk-h>.tk-chev{margin-top:3px}
@media (hover:hover) and (pointer:fine){:root[data-style="studio"] .tk-h:hover,:root [data-style="studio"] .tk-h:hover,:root [data-style="studio"].tk-h:hover{background:none}}
:root[data-style="studio"] .tk-h:focus-visible,:root [data-style="studio"] .tk-h:focus-visible,:root [data-style="studio"].tk-h:focus-visible{outline-offset:-2px;border-radius:var(--dm-r-card)}
/* the clock follows the title while it works, as in "Checking the pricing page 7s", and goes once the header says what the
work came to (a finished state has no elapsed clock); the chevron keeps the right edge, where the steps' times end too */
:root[data-style="studio"] .tk-title,:root [data-style="studio"] .tk-title,:root [data-style="studio"].tk-title{flex:0 1 auto;font-weight:500}
:root[data-style="studio"] .tk-time,:root [data-style="studio"] .tk-time,:root [data-style="studio"].tk-time{margin-right:auto;font-variant-numeric:tabular-nums}
:root[data-style="studio"] .tk-chev,:root [data-style="studio"] .tk-chev,:root [data-style="studio"].tk-chev{width:14px;height:14px;border-radius:50%;box-shadow:0 0 0 7px transparent;transition:transform var(--dm-t) 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"] .tk-h:hover .tk-chev,:root [data-style="studio"] .tk-h:hover .tk-chev,:root [data-style="studio"].tk-h:hover .tk-chev{background:var(--dm-row);box-shadow:0 0 0 7px var(--dm-row);color:var(--dm-fg)}}
:root[data-style="studio"] .tk-h:active .tk-chev,:root [data-style="studio"] .tk-h:active .tk-chev,:root [data-style="studio"].tk-h:active .tk-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"] .tk-mark,:root [data-style="studio"] .tk-mark,:root [data-style="studio"].tk-mark{width:16px;height:16px;margin-right:2px;color:var(--dm-accent-mark)}
:root[data-style="studio"] .tk-h.tk-fin .tk-mark,:root [data-style="studio"] .tk-h.tk-fin .tk-mark,:root [data-style="studio"].tk-h.tk-fin .tk-mark{width:16px;height:16px;border-radius:50%;background:var(--dm-ok-mark);color:var(--dm-surface);animation:tkdisc var(--dm-t) var(--dm-ease) backwards}
:root[data-style="studio"] .tk-h.tk-fin .tk-mark .i,:root [data-style="studio"] .tk-h.tk-fin .tk-mark .i,:root [data-style="studio"].tk-h.tk-fin .tk-mark .i{width:10px;height:10px;stroke-width:3.2;stroke-dasharray:21;animation:tkdraw var(--dm-t) var(--dm-ease) .14s backwards}
/* the first step's words 16px under the header's hairline and the last ones 16px from the card's foot, 5px above and below
each step; the card is no taller than Soft's trace, so its stage keeps its height in every style */
:root[data-style="studio"] .tk-list,:root [data-style="studio"] .tk-list,:root [data-style="studio"].tk-list{padding:10px 16px;border-top:1px solid var(--dm-line)}
:root[data-style="studio"] .tk-st,:root [data-style="studio"] .tk-st,:root [data-style="studio"].tk-st{padding:5px 0}
/* a step's time sits on its first line's baseline (owner, 23 Nov: words side by side share one baseline), and ends where the
chevron does */
:root[data-style="studio"] .tk-st .tk-ln,:root [data-style="studio"] .tk-st .tk-ln,:root [data-style="studio"].tk-st .tk-ln{align-items:baseline}
:root[data-style="studio"] .tk-st .lab,:root [data-style="studio"] .tk-st .lab,:root [data-style="studio"].tk-st .lab,:root[data-style="studio"] .tk-st .tk-dur,:root [data-style="studio"] .tk-st .tk-dur,:root [data-style="studio"].tk-st .tk-dur{line-height:19px}
:root[data-style="studio"] .tk-st .res,:root [data-style="studio"] .tk-st .res,:root [data-style="studio"].tk-st .res{line-height:17px}
:root[data-style="studio"] .tk-st .tk-dur,:root [data-style="studio"] .tk-st .tk-dur,:root [data-style="studio"].tk-st .tk-dur{font-variant-numeric:tabular-nums}
/* the marks: 16px discs 16px in from the card's edge, centred on the step's first line, under the header's mark */
:root[data-style="studio"] .tk-st .mk,:root [data-style="studio"] .tk-st .mk,:root [data-style="studio"].tk-st .mk{width:16px;height:16px;margin:1.5px 2px 0 0;color:var(--dm-fg);background:none;transition:none}
:root[data-style="studio"] .tk-st.run .mk,:root [data-style="studio"] .tk-st.run .mk,:root [data-style="studio"].tk-st.run .mk{background:none;animation:none}
:root[data-style="studio"] .tk-st.run .mk .spin,:root [data-style="studio"] .tk-st.run .mk .spin,:root [data-style="studio"].tk-st.run .mk .spin{box-sizing:border-box;width:16px;height:16px;border:1.5px solid var(--dm-line);border-top-color:var(--dm-accent-mark);animation:rot .9s linear infinite}
:root[data-style="studio"] .tk-st.done .mk,:root [data-style="studio"] .tk-st.done .mk,:root [data-style="studio"].tk-st.done .mk{background:var(--dm-ok-mark);color:var(--dm-surface);animation:tkdisc var(--dm-t) var(--dm-ease) backwards}
:root[data-style="studio"] .tk-st.done .mk .i,:root [data-style="studio"] .tk-st.done .mk .i,:root [data-style="studio"].tk-st.done .mk .i{width:10px;height:10px;stroke-width:3.2;stroke-dasharray:21;animation:tkdraw var(--dm-t) var(--dm-ease) .14s backwards}
:root[data-style="studio"] .tk-st.retry .mk,:root [data-style="studio"] .tk-st.retry .mk,:root [data-style="studio"].tk-st.retry .mk{background:none;color:var(--dm-warn-mark);animation:none}
:root[data-style="studio"] .tk-st.retry .mk .i,:root [data-style="studio"] .tk-st.retry .mk .i,:root [data-style="studio"].tk-st.retry .mk .i{width:16px;height:16px;stroke-width:1.8}
@keyframes tkdisc{from{opacity:0;transform:scale(.5)}}
@keyframes tkdraw{from{stroke-dashoffset:21}}
/* the hairline from under each mark to just above the next, darkening down into the next step once this one is done */
:root[data-style="studio"] .tk-st:not(:last-child)::before,:root [data-style="studio"] .tk-st:not(:last-child)::before,:root [data-style="studio"].tk-st:not(:last-child)::before,:root[data-style="studio"] .tk-st.done:not(:last-child)::after,:root [data-style="studio"] .tk-st.done:not(:last-child)::after,:root [data-style="studio"].tk-st.done:not(:last-child)::after{left:7.5px;top:26.5px;bottom:-2.5px;width:1px;border-radius:0;background:var(--dm-line)}
:root[data-style="studio"] .tk-st.done:not(:last-child)::after,:root [data-style="studio"] .tk-st.done:not(:last-child)::after,:root [data-style="studio"].tk-st.done:not(:last-child)::after{background:var(--dm-line-strong);animation:tkgrow var(--dm-t-slow) var(--dm-ease-io) .2s backwards}
/* what a step found writes itself in a word at a time: a fade and a 3px rise, no blur */
@keyframes tkwordc{from{opacity:0;transform:translateY(3px)}}
:root[data-style="studio"] .tk-st .res .w,:root [data-style="studio"] .tk-st .res .w,:root [data-style="studio"].tk-st .res .w{animation:tkwordc var(--dm-t-slow) var(--dm-ease) backwards}
thinking.jsHTML · 61 lines
DM.def('thinking', (r, c) => {
const tk = $('.tk', r), list = $('.tk-list', r), title = $('.tk-title', r), time = $('.tk-time', r), head = $('.tk-h', r), fold = $('.tk-fold', r), mark = $('.tk-mark', r);
// each step: what the agent does and what it found. Measuring the cards times out once, counts down and tries again
const S = [
['Open Pricing v4 in Figma', '6 frames', 1300],
['Read the spacing tokens', 'tokens.css, 9 spacing values', 1200],
['Measure the plan cards', 'Off the 8px grid', 1400, { retry:"Figma didn't answer", tip:'Pro has an 18px gap, Team 22px and Enterprise 13px' }],
['Check text contrast', 'All 14 text pairs pass AA', 1100],
['Plan the fix', 'About 3 minutes of work', 1200]
];
const setOpen = o => { tk.dataset.open = o ? '1' : '0'; fold.classList.toggle('shut', !o); head.setAttribute('aria-expanded', o); };
head.onclick = () => setOpen(tk.dataset.open !== '1');
// the trace grows with its steps in every style (grow(), started once its entrance has settled, so it measures the card
// at its real size), and its header says what the work came to as the last step finishes, never after it (owner, 18 Nov).
// Studio draws its finished mark as a tick on a green disc
const ds = r.closest('[data-style]'), studio = !!ds && ds.dataset.style === 'studio';
Promise.resolve().then(() => Promise.all(tk.getAnimations().map(a => a.finished.catch(() => {})))).then(() => { if (!c.dead && tk.isConnected) c.offs.push(grow(tk)); });
// (the template's chevron names the sprite's icon directly, which the homepage renames, so it is drawn through I())
$('.tk-chev', r).outerHTML = I('chev-d', 'xs tk-chev');
// the header becomes what the work came to
// (the dots and the finished mark crossfade, iconSwap(); Studio draws its tick on its disc as before)
const finish = () => { live = false; head.classList.add('tk-fin'); if (studio){ mark.innerHTML = I('check','xs'); enter(mark.firstElementChild); } else iconSwap(mark, () => { mark.innerHTML = I('ok'); }); title.classList.remove('shim'); swap(title, '3 cards to fix, 2 changes planned'); };
// the line under a step opens and then crossfades; what the step found writes itself in a word at a time, and a tip on it
// holds the detail
const words = t => t.split(' ').map((w, i, a) => `<span class="w" style="animation-delay:${i * 45}ms">${w}${i < a.length - 1 ? ' ' : ''}</span>`).join('');
// (warn: the step is waiting out a problem; its amber lands with its words, 170ms on as swap() writes them)
const note = (li, text, tip, found, warn = false) => { const res = $('.res', li), sp = res.firstElementChild; res.classList.add('on');
clearTimeout(sp._tone); const set = () => sp.classList.toggle('warn', warn);
if (found){ set(); sp._sw = null; sp.classList.remove('out'); sp.innerHTML = tip ? `<span data-tip="${tip}">${words(text)}</span>` : words(text); }
else { const lag = !REDUCE && !!sp.textContent.trim() && sp.textContent !== text; swap(sp, text); if (lag) sp._tone = setTimeout(set, 170); else set(); } };
// (a step's mark crossfades on its tile, which keeps its fill: iconSwap(); Studio draws its disc and tick as before)
const glyph = (li, g) => { const mk = $('.mk', li), put = () => { mk.innerHTML = g; }; if (studio){ put(); enter(mk.firstElementChild); } else iconSwap(mk, put, { inner:true }); };
let secs = 0, live = true; c.every(1000, () => { if (live){ secs++; time.textContent = secs + 's'; } });
c.run(async () => {
await c.wait(600);
for (const [lab, res, ms, x] of S){
const li = html(`<li class="tk-st run"><span class="mk"><span class="spin"></span></span><div class="tx"><span class="tk-ln"><span class="lab shim">${lab}</span><span class="tk-dur num"></span></span><span class="res"><span></span></span></div></li>`);
list.appendChild(li); enter(li);
const l = $('.lab', li); let took = ms;
await c.wait(ms);
if (x && x.retry){
li.classList.replace('run', 'retry'); l.classList.remove('shim'); glyph(li, I('clock','xs'));
for (let k = 2; k > 0; k--){ note(li, `${x.retry}. Trying again in ${k}s`, null, false, true); await c.wait(1000); }
li.classList.replace('retry', 'run'); l.classList.add('shim'); glyph(li, '<span class="spin"></span>'); note(li, 'Trying again'); await c.wait(900); took += 2900;
}
li.classList.replace('run', 'done'); l.classList.remove('shim'); glyph(li, I('check','xs')); note(li, res, x && x.tip, true);
const t = $('.tk-dur', li); t.textContent = (took / 1000).toFixed(1) + 's'; enter(t);
}
// the header becomes what the work came to as the last step finishes, and folds the trace away
finish();
await c.wait(2500); setOpen(false);
});
// the preview's story: once it has folded, the person opens it again and reads what the cards measured
if (r === c.st) c.story(async s => {
await s.until(() => fold.classList.contains('shut')); await s.beat(2);
await s.tap(head); await s.beat(2);
await s.point($('.res [data-tip]', list)); await s.beat(3);
s.away(); await s.beat(1);
});
});
Questions
What people ask about it.
- How do I show a step that is waiting out a problem?
- Set its
stateto'retry'and put what it waits on inresult, like "Figma didn't answer. Trying again in 2s". Update the result each second for a countdown, then set the state back to'running'and finally'done'with what it found. - What does the header say when the work is done?
- Whatever you pass as
summary, which should say what the work came to. Without it, the header says how many steps there were. - Can I keep the trace open after it finishes?
- Yes. Set
collapseWhenDoneto false, or control it withopenandonOpenChange.
More in Agent status
Show what the agent is doing, how far along it is, and what it is working with.