Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(block-agent): show a working row while a turn has nothing to read (#6305)
Wolf Mermelstein0a262c673712
diff --git a/apps/web/src/features/block-agent/component/AgentMessage.tsx b/apps/web/src/features/block-agent/component/AgentMessage.tsxindex d95a9c2449..f82e3361b1 100644--- a/apps/web/src/features/block-agent/component/AgentMessage.tsx+++ b/apps/web/src/features/block-agent/component/AgentMessage.tsx@@ -12,7 +12,7 @@ import type {import { For, type JSX, Show } from 'solid-js';import { match } from 'ts-pattern';import { isControlMessage } from '../state/control-message';-import { ActionLine, Thought } from '../ui';+import { ActionLine, Thought, WorkingLine } from '../ui';import { ControlPart } from './parts/ControlPart';import { ElicitationPart } from './parts/ElicitationPart';import { PermissionPart } from './parts/PermissionPart';@@ -55,6 +55,27 @@ function AgentMessagePart(props: {.exhaustive();}+/**+ * Whether an open turn should show the working row at its tail.+ *+ * Skipped wherever the transcript already shows the turn is alive — prose+ * streaming in, a thought shimmering — and wherever it is not: a permission+ * or elicitation prompt is waiting on the reader, not working.+ */+function showsWorkingLine(message: FoldedMessage): boolean {+ const last = message.parts[message.parts.length - 1];+ if (last === undefined) return true;+ return match(last)+ .with(+ { kind: 'text' },+ { kind: 'thought' },+ { kind: 'permission' },+ { kind: 'elicitation' },+ () => false+ )+ .otherwise(() => true);+}+/*** A prompt, in the chat block's user-bubble treatment* (`@core/component/AI/component/message/UserMessage.tsx`): right-aligned,@@ -105,6 +126,11 @@ export function Message(props: { message: FoldedMessage }) {/>)}</For>+ {/* The turn is open with nothing to read yet — a dot and a rotating+ verb, so the wait reads as work rather than as a stall. */}+ <Show when={inFlight() && showsWorkingLine(props.message)}>+ <WorkingLine />+ </Show>{/* A turn the runtime errored is something that happened to thesession, like a model change or a stop — so it reads as one,at the foot of whatever the agent managed to say first. */}diff --git a/apps/web/src/features/block-agent/ui/TextShimmer.tsx b/apps/web/src/features/block-agent/ui/TextShimmer.tsxindex 0af920a6d5..29ca7aff4a 100644--- a/apps/web/src/features/block-agent/ui/TextShimmer.tsx+++ b/apps/web/src/features/block-agent/ui/TextShimmer.tsx@@ -17,6 +17,11 @@ const SWAP_MS = 200;export interface TextShimmerProps {text: string;active: boolean;+ /**+ * What assistive technology hears, when that should stay put while the+ * visible text changes. Defaults to the visible text.+ */+ label?: string;class?: string;}@@ -49,7 +54,7 @@ export function TextShimmer(props: TextShimmerProps) {return (<spanclass={`inline-grid whitespace-pre align-baseline ${props.class ?? ''}`}- aria-label={props.text}+ aria-label={props.label ?? props.text}><spanaria-hidden="true"diff --git a/apps/web/src/features/block-agent/ui/WorkingLine.test.tsx b/apps/web/src/features/block-agent/ui/WorkingLine.test.tsxnew file mode 100644index 0000000000..0655d94654--- /dev/null+++ b/apps/web/src/features/block-agent/ui/WorkingLine.test.tsx@@ -0,0 +1,28 @@+/** @vitest-environment jsdom */++import { cleanup, render } from '@solidjs/testing-library';+import { afterEach, describe, expect, it } from 'vitest';+import { WorkingLine } from './WorkingLine';+import { WORKING_LABEL } from './working-verbs';++afterEach(cleanup);++describe('WorkingLine', () => {+ it('opens on the base word, so short turns never show a verb', () => {+ const { container } = render(() => <WorkingLine />);++ expect(container.textContent).toContain(WORKING_LABEL);+ });++ it('offers one stable label rather than a rotating one', () => {+ const { getAllByLabelText } = render(() => <WorkingLine />);++ expect(getAllByLabelText(WORKING_LABEL)).toHaveLength(1);+ });++ it('has nothing to expand, so it is not a control', () => {+ const { queryByRole } = render(() => <WorkingLine />);++ expect(queryByRole('button')).toBeNull();+ });+});diff --git a/apps/web/src/features/block-agent/ui/WorkingLine.tsx b/apps/web/src/features/block-agent/ui/WorkingLine.tsxnew file mode 100644index 0000000000..03a6544946--- /dev/null+++ b/apps/web/src/features/block-agent/ui/WorkingLine.tsx@@ -0,0 +1,67 @@+/**+ * The tail of an open turn that has produced nothing to read yet.+ *+ * A sibling of `Thought`, deliberately shaped differently. A thought row leads+ * with a caret because there is text behind it; this row has nothing to+ * expand, so the caret gives way to a dot that breathes on the shimmer's own+ * period, and the row is not a control at all. The leading slot keeps the+ * caret's width so the label does not shift sideways once reasoning arrives+ * and the row becomes a `Thought`.+ */++import { createSignal, onCleanup } from 'solid-js';+import { TextShimmer } from './TextShimmer';+import { createVerbDraw, WORKING_LABEL } from './working-verbs';++/**+ * How long a word holds. Faster reads as thrashing rather than work. The first+ * word holds for a full interval too, so the short turns that make up most of+ * a session never show a verb at all.+ */+const HOLD_MS = 4000;++/** How long the crossfade between words runs. */+const SWAP_MS = 180;++export function WorkingLine() {+ const [verb, setVerb] = createSignal(WORKING_LABEL);+ const [swapping, setSwapping] = createSignal(false);++ const drawVerb = createVerbDraw();+ let swapTimer: ReturnType<typeof setTimeout> | undefined;++ const rotation = setInterval(() => {+ setSwapping(true);+ swapTimer = setTimeout(() => {+ setVerb(drawVerb());+ setSwapping(false);+ }, SWAP_MS);+ }, HOLD_MS);++ onCleanup(() => {+ clearInterval(rotation);+ if (swapTimer !== undefined) clearTimeout(swapTimer);+ });++ return (+ <div class="flex min-h-7 items-center gap-1 py-1 text-xs leading-5 text-ink-extra-muted">+ <span+ aria-hidden="true"+ class="flex size-4 shrink-0 items-center justify-center"+ >+ <span class="agent-working-dot size-[5px] rounded-full bg-current" />+ </span>+ {/* The visible word rotates; the label a screen reader hears does not.+ Narrating a synonym every few seconds is noise, and the one fact+ worth announcing is that the turn is still open. */}+ <TextShimmer+ text={verb()}+ label={WORKING_LABEL}+ active+ class={`transition-opacity duration-200 motion-reduce:transition-none ${+ swapping() ? 'opacity-0' : ''+ }`}+ />+ </div>+ );+}diff --git a/apps/web/src/features/block-agent/ui/index.ts b/apps/web/src/features/block-agent/ui/index.tsindex 1285d6ad05..d1d4eef7cf 100644--- a/apps/web/src/features/block-agent/ui/index.ts+++ b/apps/web/src/features/block-agent/ui/index.ts@@ -56,3 +56,5 @@ export {type TodoItem,type ToolStatus,} from './types';+export { WorkingLine } from './WorkingLine';+export { createVerbDraw, WORKING_LABEL } from './working-verbs';diff --git a/apps/web/src/features/block-agent/ui/working-verbs.test.ts b/apps/web/src/features/block-agent/ui/working-verbs.test.tsnew file mode 100644index 0000000000..0ed1167712--- /dev/null+++ b/apps/web/src/features/block-agent/ui/working-verbs.test.ts@@ -0,0 +1,22 @@+import { describe, expect, it } from 'vitest';+import { createVerbDraw, VERBS } from './working-verbs';++describe('createVerbDraw', () => {+ it('spends the whole list before repeating a verb', () => {+ const draw = createVerbDraw();+ const drawn = Array.from({ length: VERBS.length }, draw);++ expect(new Set(drawn).size).toBe(VERBS.length);+ });++ it('reshuffles rather than running dry', () => {+ const draw = createVerbDraw();+ const drawn = Array.from({ length: VERBS.length * 3 }, draw);++ expect(drawn.every((verb) => VERBS.includes(verb))).toBe(true);+ });++ it('offers gerunds only, so any two read as the same kind of word', () => {+ expect(VERBS.every((verb) => verb.endsWith('ing'))).toBe(true);+ });+});diff --git a/apps/web/src/features/block-agent/ui/working-verbs.ts b/apps/web/src/features/block-agent/ui/working-verbs.tsnew file mode 100644index 0000000000..0642017d9c--- /dev/null+++ b/apps/web/src/features/block-agent/ui/working-verbs.ts@@ -0,0 +1,64 @@+/**+ * The words an open turn shows while the agent has produced nothing to read.+ *+ * Modelled on Claude Code's spinner corpus, but off paper rather than out of a+ * kitchen, because that is the work this agent does.+ */++export const VERBS: readonly string[] = [+ 'Skimming',+ 'Poring',+ 'Leafing',+ 'Combing',+ 'Sifting',+ 'Thumbing',+ 'Excerpting',+ 'Pondering',+ 'Puzzling',+ 'Mulling',+ 'Percolating',+ 'Weighing',+ 'Reconsidering',+ 'Drafting',+ 'Wordsmithing',+ 'Redlining',+ 'Tightening',+ 'Annotating',+ 'Collating',+ 'Threading',+ 'Indexing',+ 'Cross-referencing',+];++/**+ * The word an open turn shows before its first rotation, and the label a+ * screen reader hears for the whole turn. Deliberately not "Thinking": a bare+ * row has no reasoning behind it and the turn may well be running a tool.+ */+export const WORKING_LABEL = 'Working';++/**+ * A draw that does not repeat until every verb has been used.+ *+ * Repetition is the one thing that makes a rotation look cheap, so the list is+ * drawn down and reshuffled rather than sampled.+ */+export function createVerbDraw(+ random: () => number = Math.random+): () => string {+ let remaining: string[] = [];++ return () => {+ if (remaining.length === 0) remaining = shuffled(VERBS, random);+ return remaining.pop() ?? WORKING_LABEL;+ };+}++function shuffled(pool: readonly string[], random: () => number): string[] {+ const out = [...pool];+ for (let index = out.length - 1; index > 0; index--) {+ const swap = Math.floor(random() * (index + 1));+ [out[index], out[swap]] = [out[swap] as string, out[index] as string];+ }+ return out;+}diff --git a/apps/web/src/index.css b/apps/web/src/index.cssindex bc9f437df8..0b92dfb13d 100644--- a/apps/web/src/index.css+++ b/apps/web/src/index.css@@ -586,6 +586,31 @@ html[data-theme-light='false'] {}}+/* The dot leading an open agent turn that has nothing to expand yet. Shares+ the shimmer's period so the row reads as one motion, not two. */+@keyframes agent-working-dot {+ 0%,+ 100% {+ opacity: 0.3;+ transform: scale(0.65);+ }+ 50% {+ opacity: 1;+ transform: scale(1);+ }+}++.agent-working-dot {+ animation: agent-working-dot 1.8s ease-in-out infinite;+}++@media (prefers-reduced-motion: reduce) {+ .agent-working-dot {+ animation: none;+ opacity: 0.55;+ }+}+@keyframes skeleton-shimmer {100% {transform: translateX(100%);