{
  "antiPatterns": [
    "Using array positions as sequence numbers.",
    "Reversing the events within a delta group."
  ],
  "api": {
    "importPath": "@ancrel/workspace/transcript",
    "props": [
      {
        "name": "className",
        "required": false,
        "type": "string"
      },
      {
        "name": "events",
        "required": true,
        "type": "readonly EventRecord[]"
      },
      {
        "name": "initialExpandedCount",
        "required": false,
        "type": "number"
      },
      {
        "name": "key",
        "required": false,
        "type": "React.Key | null | undefined"
      },
      {
        "name": "label",
        "required": false,
        "type": "string"
      },
      {
        "name": "ref",
        "required": false,
        "type": "React.Ref<HTMLDivElement> | undefined"
      },
      {
        "name": "renderGroup",
        "required": false,
        "type": "((group: EventGroup) => React.ReactNode) | undefined"
      }
    ],
    "symbol": "EventList",
    "typeRef": "api/workspace/transcript/index.d.ts"
  },
  "constraints": [
    "Assign sequence numbers unique across the displayed stream. The last record received for a sequence wins.",
    "Use delta, reasoning, tool or tool:<name> for coalescing and dispose the buffer on unsubscribe."
  ],
  "docs": "raw/frontend/event-list.md",
  "examples": [
    {
      "code": "'use client'\n\nimport { useEffect, useRef, useState } from 'react'\nimport { Button, Disclosure } from '@ancrel/ui'\nimport { createRafEventBuffer, EventList, groupEvents } from '@ancrel/workspace/transcript'\nimport type { EventGroup, EventRecord, RafEventBuffer } from '@ancrel/workspace/transcript'\nimport '@ancrel/tokens/css'\nimport '@ancrel/ui/styles.css'\nimport '@ancrel/workspace/styles.css'\nimport './example.css'\n\nconst initial: EventRecord[] = [\n  { seq: 1, kind: 'delta', runId: 'a', text: 'Read' },\n  { seq: 2, kind: 'delta', runId: 'a', text: 'y' },\n]\n\nconst times = new Map([[1, '10:04:05'], [3, '10:04:08'], [4, '10:04:11']])\n\nfunction renderGroup(group: EventGroup) {\n  const events = group.events\n  const time = times.get(group.firstSeq)\n  return <Disclosure defaultOpen summary={<>\n    {events[0].kind} <span className=\"ac-EventExample-meta\">#{group.firstSeq}</span>\n    {time && <time className=\"ac-EventExample-meta\" dateTime={time}>{time}</time>}\n  </>}>\n    {events.map(event => event.text).join('')}\n  </Disclosure>\n}\n\nexport default function App() {\n  const [events, setEvents] = useState<readonly EventRecord[]>(initial)\n  const [newest, setNewest] = useState(false)\n  const buffer = useRef<RafEventBuffer | null>(null)\n  useEffect(() => {\n    const stream = createRafEventBuffer(setEvents)\n    initial.forEach(stream.push)\n    buffer.current = stream\n    return () => { stream.dispose(); buffer.current = null }\n  }, [])\n  function addBatch() {\n    buffer.current?.push({ seq: 4, kind: 'tool:read', text: 'Not yet available' })\n    buffer.current?.push({ seq: 3, kind: 'notice', text: 'Opened' })\n    buffer.current?.push({ seq: 4, kind: 'tool:read', text: 'Complete' })\n  }\n  return <>\n    <Button onClick={addBatch}>Receive batch</Button>\n    <Button aria-pressed={newest} onClick={() => setNewest(!newest)}>Newest first</Button>\n    {newest ? <ol aria-label=\"Updates\">{groupEvents(events).reverse().map(group =>\n      <li key={group.firstSeq}>{renderGroup(group)}</li>)}</ol>\n      : <EventList events={events} label=\"Updates\" renderGroup={renderGroup} />}\n  </>\n}\n",
      "command": "pnpm test",
      "entry": "examples/fe.event-list/App.tsx",
      "fixture": "examples/fe.event-list/",
      "id": "minimal"
    }
  ],
  "id": "fe.event-list",
  "kind": "react-component",
  "language": "typescript",
  "layer": "frontend",
  "owner": "frontend-infra",
  "package": {
    "ecosystem": "npm",
    "name": "@ancrel/workspace",
    "version": "0.2.0"
  },
  "provenance": {
    "changes": "Adapted groupTaskEvents at lines 445–630 to domain-free event records, preserving contiguous runs, sandwiched reasoning, tool identity and first-sequence keys. The initial limit and sequence-based frame batching follow frontend/src/components/tasks/TaskDetailDrawer.tsx (initial limit at lines 70–130).",
    "commit": "4cc384c3bdbd09a3a50268adf81ba23f53aac93e",
    "mode": "extracted",
    "origin": "rule-studio",
    "path": "frontend/src/components/tasks/taskFormatters.ts",
    "rights": "org-internal; approved-by=owner; ref=item-19"
  },
  "schemaVersion": 1,
  "stability": "experimental",
  "summary": "Chronological event groups with stable keys, collapsible details and frame-batched snapshots.",
  "tokenDependencies": [
    "ref.color.x16161a",
    "ref.color.x202025",
    "ref.color.x292930",
    "ref.color.x393941",
    "ref.color.x684a84",
    "ref.color.xc0c0c9",
    "ref.color.xcdb2ea",
    "ref.color.xe6e6ea",
    "ref.color.xededef",
    "ref.color.xffffff",
    "ref.family.mono",
    "ref.fontFeature.tnum",
    "ref.space.px12",
    "ref.space.px2",
    "ref.space.px4",
    "ref.space.px6",
    "ref.space.px8",
    "sys.action.focus",
    "sys.border.subtle",
    "sys.ink.primary",
    "sys.ink.secondary",
    "sys.space.hair",
    "sys.space.inset",
    "sys.space.snug",
    "sys.space.tight",
    "sys.surface.panel",
    "sys.type.family.mono",
    "sys.type.numeric"
  ]
}
