reifyui 0.17.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -227,7 +227,7 @@ the response's own `usage`. `turnFromHistory` (a session's turns feed), `turnFro
227
227
  response) and `turnFromMessage` (a `ChatMessages` blocks message, optionally timed by a clock turn)
228
228
  build the same Turn from what a host already holds. `describeTool(name, args)` reads every harness's
229
229
  tool vocabulary (Claude Code, Codex, Gemini CLI, Hermes, Goose, OpenCode, OpenHands, pi, Kimi …)
230
- into a kind, a target, lines added and removed, and the plan. The package ships the motions, never
230
+ into a kind, a target, lines added and removed, and the plan; a browser call reads as what it did ("Clicked the “About” link"). `openStep(item, d)` lets the host open a call in a place of its own (a browser step opens the live browser beside the conversation) instead of unfolding it. The package ships the motions, never
231
231
  the logos: pass your mark as a node and `motionFor(base)` names a motion, or none for three dots.
232
232
  All motion stops under `prefers-reduced-motion`.
233
233
 
@@ -53,6 +53,8 @@ __export(agent_chat_exports, {
53
53
  WorkingIndicator: () => WorkingIndicator,
54
54
  WorkingMark: () => WorkingMark,
55
55
  baseNameOf: () => baseNameOf,
56
+ browserActOf: () => browserActOf,
57
+ browserElements: () => browserElements,
56
58
  commandText: () => commandText,
57
59
  describeTool: () => describeTool,
58
60
  diffOf: () => diffOf,
@@ -229,6 +231,7 @@ var NS = /^(developer|platform|computercontroller|builtin|default|functions|tool
229
231
  function toolKind(name) {
230
232
  const raw = String(name || "").trim();
231
233
  if (!raw) return "tool";
234
+ if (browserActOf(raw) !== null) return "browser";
232
235
  if (/^mcp__/i.test(raw)) return "mcp";
233
236
  const n = raw.toLowerCase().replace(NS, "");
234
237
  if (KIND_BY_NAME[n]) return KIND_BY_NAME[n];
@@ -379,6 +382,195 @@ function shortUrl(u) {
379
382
  function humanizeName(n) {
380
383
  return str(n).replace(/^mcp__/i, "").replace(/__|\./g, " \xB7 ").replace(/[_-]+/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").trim().replace(/^\w/, (c) => c.toUpperCase());
381
384
  }
385
+ var NS_BROWSER = /^(?:mcp__.+?__|[a-z0-9_-]+?(?:__|\.))(browser[_\-.].+)$/i;
386
+ var BROWSER_SERVER = /^(?:mcp__)?(?:browser|playwright|puppeteer|browserbase|browser[_-]use|chrome[_-]?devtools)(?:__|\.)(.+)$/i;
387
+ function browserActOf(name) {
388
+ const raw = String(name || "").trim();
389
+ if (!raw) return null;
390
+ const n = raw.toLowerCase().replace(NS, "");
391
+ if (KIND_BY_NAME[n] === "browser") return n === "navigate" || n === "screenshot" ? n : "";
392
+ let m = n.match(/^(?:browser|playwright|computer)[_\-.](.+)$/);
393
+ if (m) return m[1];
394
+ m = raw.match(NS_BROWSER);
395
+ if (m) return m[1].replace(/^browser[_\-.]/i, "").toLowerCase();
396
+ m = raw.match(BROWSER_SERVER);
397
+ if (m) return m[1].replace(/^browser[_\-.]/i, "").toLowerCase();
398
+ if (/[_\-.]browser$/.test(n)) return "";
399
+ return null;
400
+ }
401
+ var ROLE_NOUN = {
402
+ link: "link",
403
+ button: "button",
404
+ submit: "button",
405
+ textbox: "field",
406
+ searchbox: "search field",
407
+ combobox: "list",
408
+ listbox: "list",
409
+ checkbox: "checkbox",
410
+ radio: "option",
411
+ option: "option",
412
+ tab: "tab",
413
+ menuitem: "menu item",
414
+ heading: "heading",
415
+ img: "image",
416
+ image: "image",
417
+ switch: "switch",
418
+ slider: "slider"
419
+ };
420
+ function cut(s, max) {
421
+ const t = str(s).replace(/\s+/g, " ").trim();
422
+ return t.length > max ? `${t.slice(0, max - 1).trimEnd()}\u2026` : t;
423
+ }
424
+ function elementWords(a, element, act) {
425
+ const desc = str(firstOf(a, ["element", "element_description", "description", "label"])).trim();
426
+ if (desc) return cut(desc, 60);
427
+ if (element && element.role) {
428
+ const noun = ROLE_NOUN[String(element.role).toLowerCase()] || "";
429
+ const name = cut(element.name, 40);
430
+ if (noun && name) return `the \u201C${name}\u201D ${noun}`;
431
+ if (noun) return `a ${noun}`;
432
+ if (name) return `\u201C${name}\u201D`;
433
+ }
434
+ const sel = str(a.selector).trim().toLowerCase();
435
+ if (sel) {
436
+ if (/^a(?=$|[\s.#[:>])|role=["']?link/.test(sel)) return "a link";
437
+ if (/^button|\[type=["']?submit|role=["']?button/.test(sel)) return "a button";
438
+ if (/^(input|textarea)|role=["']?(textbox|searchbox)|contenteditable/.test(sel)) return "a field";
439
+ if (/^select|role=["']?(combobox|listbox)/.test(sel)) return "a list";
440
+ }
441
+ if (act === "click") {
442
+ const t = str(a.text).trim();
443
+ if (t) return `\u201C${cut(t, 40)}\u201D`;
444
+ }
445
+ return "";
446
+ }
447
+ function msWords(ms) {
448
+ const s = Math.round(Number(ms) / 100) / 10;
449
+ return s >= 1 ? `${s}s` : `${Math.round(Number(ms))} ms`;
450
+ }
451
+ var BROWSER_ACTS = [
452
+ [
453
+ /^(navigate|goto|go_to|open|open_url|visit|new_tab|tab_new|browse|go)$/,
454
+ "Opening",
455
+ "Opened",
456
+ (a) => {
457
+ const u = str(firstOf(a, ["url", "href", "uri", "link", "address"]));
458
+ return u ? shortUrl(u) : "";
459
+ },
460
+ ["Opening a page", "Opened a page"]
461
+ ],
462
+ [/^(navigate_back|back|go_back|history_back)$/, "", "", null, ["Going back a page", "Went back a page"]],
463
+ [/^(navigate_forward|forward|go_forward)$/, "", "", null, ["Going forward a page", "Went forward a page"]],
464
+ [/^(reload|refresh)$/, "", "", null, ["Reloading the page", "Reloaded the page"]],
465
+ [
466
+ /^(click|left_click|double_click|right_click|triple_click|middle_click|tap|click_element)$/,
467
+ "Clicking",
468
+ "Clicked",
469
+ (a, e, act) => elementWords(a, e, act),
470
+ ["Clicking on the page", "Clicked on the page"]
471
+ ],
472
+ [/^(hover|mouse_move|move_mouse)$/, "Pointing at", "Pointed at", (a, e, act) => elementWords(a, e, act), ["Moving the pointer", "Moved the pointer"]],
473
+ [
474
+ /^(type|fill|input|input_text|type_text|insert_text|fill_form|send_keys_to)$/,
475
+ "Typing into",
476
+ "Typed into",
477
+ (a, e, act) => elementWords(a, e, act),
478
+ ["Typing into a field", "Typed into a field"]
479
+ ],
480
+ [
481
+ /^(select|select_option|choose|select_dropdown_option)$/,
482
+ "Choosing an option in",
483
+ "Chose an option in",
484
+ (a, e, act) => elementWords(a, e, act),
485
+ ["Choosing an option", "Chose an option"]
486
+ ],
487
+ [
488
+ /^(press|press_key|key|keypress|send_keys|hotkey)$/,
489
+ "Pressing",
490
+ "Pressed",
491
+ (a) => cut(firstOf(a, ["key", "keys", "text"]), 30),
492
+ ["Pressing a key", "Pressed a key"]
493
+ ],
494
+ [/^(scroll|scroll_down|scroll_up|wheel|scroll_page)$/, "Scrolling", "Scrolled", (a, e, act) => {
495
+ const d = str(firstOf(a, ["direction", "scroll_direction"])).toLowerCase();
496
+ if (/^(up|down|left|right)$/.test(d)) return d;
497
+ if (/_up$/.test(act)) return "up";
498
+ if (/_down$/.test(act)) return "down";
499
+ const dy = Number(firstOf(a, ["pixels", "delta_y", "deltaY", "amount", "scroll_amount"]));
500
+ return Number.isFinite(dy) && dy < 0 ? "up" : Number.isFinite(dy) && dy > 0 ? "down" : "";
501
+ }, ["Scrolling the page", "Scrolled the page"]],
502
+ [
503
+ /^(screenshot|take_screenshot|capture|capture_screenshot)$/,
504
+ "",
505
+ "",
506
+ null,
507
+ ["Taking a screenshot", "Took a screenshot"],
508
+ (a) => a.full_page || a.fullPage ? ["Taking a screenshot of the whole page", "Took a screenshot of the whole page"] : null
509
+ ],
510
+ [/^(snapshot|read|read_page|get_page|accessibility_snapshot|page_content|get_content|get_elements|observe)$/, "", "", null, ["Reading the page", "Read the page"]],
511
+ [/^(extract_text|get_text|extract|text|extract_content|get_page_text)$/, "", "", null, ["Reading the page\u2019s text", "Read the page\u2019s text"]],
512
+ [/^(get_url|url|current_url|location|get_title)$/, "", "", null, ["Checking the address", "Checked the address"]],
513
+ [/^(wait|wait_for|wait_for_text|wait_for_selector|sleep)$/, "Waiting", "Waited", (a) => {
514
+ const t = str(a.text).trim();
515
+ if (t) return `for \u201C${cut(t, 40)}\u201D`;
516
+ if (str(a.selector).trim()) return "for the page";
517
+ const ms = a.ms != null ? Number(a.ms) : a.time != null ? Number(a.time) * 1e3 : Number(firstOf(a, ["timeout", "duration"]));
518
+ return Number.isFinite(ms) && ms > 0 ? msWords(ms) : "";
519
+ }, ["Waiting", "Waited"]],
520
+ [/^(tabs|list_tabs|tab_list|get_tabs)$/, "", "", null, ["Listing the tabs", "Listed the tabs"]],
521
+ [/^(switch_tab|tab_select|select_tab|focus_tab|switch_to_tab)$/, "", "", null, ["Switching tabs", "Switched tabs"]],
522
+ [/^(close_tab|tab_close)$/, "", "", null, ["Closing a tab", "Closed a tab"]],
523
+ [/^(close|quit|close_browser)$/, "", "", null, ["Closing the browser", "Closed the browser"]],
524
+ [/^(drag|drag_and_drop|left_click_drag)$/, "", "", null, ["Dragging on the page", "Dragged on the page"]],
525
+ [/^(file_upload|upload|upload_file|set_input_files)$/, "", "", null, ["Uploading a file", "Uploaded a file"]],
526
+ [/^(handle_dialog|dialog|accept_dialog|dismiss_dialog)$/, "", "", null, ["Answering a dialog", "Answered a dialog"]],
527
+ [/^(resize|set_viewport|resize_window)$/, "", "", null, ["Resizing the window", "Resized the window"]],
528
+ [/^(evaluate|run_code|execute_js|eval|execute_script|run_javascript)$/, "", "", null, ["Running a script on the page", "Ran a script on the page"]],
529
+ [/^(console_messages|console|get_console)$/, "", "", null, ["Reading the console", "Read the console"]],
530
+ [/^(network_requests|network|get_network)$/, "", "", null, ["Reading the network requests", "Read the network requests"]],
531
+ [/^(pdf_save|save_pdf|pdf|print_pdf)$/, "", "", null, ["Saving the page as a PDF", "Saved the page as a PDF"]],
532
+ [/^(cursor_position)$/, "", "", null, ["Finding the pointer", "Found the pointer"]],
533
+ [/^(install)$/, "", "", null, ["Installing the browser", "Installed the browser"]]
534
+ ];
535
+ function describeBrowser(name, a, element) {
536
+ const fromName = browserActOf(name) || "";
537
+ const fromArgs = str(firstOf(a, ["action", "command", "type"])).trim();
538
+ const act = (fromName && fromName !== "use" ? fromName : fromArgs || fromName).toLowerCase().replace(/[\s-]+/g, "_");
539
+ const row = BROWSER_ACTS.find((r) => r[0].test(act));
540
+ if (row) {
541
+ const [, running, done, target, bare, special] = row;
542
+ const sp = special ? special(a) : null;
543
+ if (sp) return { running: sp[0], done: sp[1], target: "" };
544
+ const t = target ? target(a, element, act) : "";
545
+ return t ? { running, done, target: t } : { running: bare[0], done: bare[1], target: "" };
546
+ }
547
+ const u = str(firstOf(a, ["url", "href", "uri"]));
548
+ return u ? { running: "Browsing", done: "Browsed", target: shortUrl(u) } : { running: "Using the browser", done: "Used the browser", target: "" };
549
+ }
550
+ function browserElements(items) {
551
+ const out = {};
552
+ let refs = /* @__PURE__ */ new Map();
553
+ for (const it of items || []) {
554
+ if (!it || it.kind !== "tool" || toolKind(it.name) !== "browser") continue;
555
+ const a = parseToolArgs(it.args);
556
+ const ref = str(firstOf(a, ["ref", "element_ref"])).trim();
557
+ if (ref && refs.has(ref)) out[it.id] = refs.get(ref);
558
+ const text = str(it.output);
559
+ if (!text) continue;
560
+ const next = /* @__PURE__ */ new Map();
561
+ for (const ln of text.split("\n")) {
562
+ let m = ln.match(/^\s*(e\d+)\s+([a-z]+)\s+"(.*?)"/i);
563
+ if (m) {
564
+ next.set(m[1], { role: m[2], name: m[3] });
565
+ continue;
566
+ }
567
+ m = ln.match(/^\s*-\s+([a-z]+)(?:\s+"(.*?)")?[^\n]*\[ref=(e\d+)\]/i);
568
+ if (m) next.set(m[3], { role: m[1], name: m[2] || "" });
569
+ }
570
+ if (next.size) refs = next;
571
+ }
572
+ return out;
573
+ }
382
574
  var VERBS = {
383
575
  shell: ["Running", "Ran"],
384
576
  shell_output: ["Reading output of", "Read output of"],
@@ -399,7 +591,7 @@ var VERBS = {
399
591
  mcp: ["Using", "Used"],
400
592
  tool: ["Using", "Used"]
401
593
  };
402
- function describeTool(name, args) {
594
+ function describeTool(name, args, opts) {
403
595
  const a = parseToolArgs(args);
404
596
  let kind = toolKind(name);
405
597
  const nm = str(name);
@@ -409,6 +601,7 @@ function describeTool(name, args) {
409
601
  let targetFull = "";
410
602
  let mono = false;
411
603
  let note = "";
604
+ let browser = null;
412
605
  const pathOf = () => firstOf(a, [
413
606
  "file_path",
414
607
  "path",
@@ -486,11 +679,9 @@ function describeTool(name, args) {
486
679
  targetFull = target;
487
680
  break;
488
681
  case "browser": {
489
- const act = str(firstOf(a, ["action", "command", "type"]));
490
- const u = str(firstOf(a, ["url", "selector", "text"]));
491
- target = [act, u ? shortUrl(u) : ""].filter(Boolean).join(" ");
492
- targetFull = target;
493
- if (/^browser[_\-.]/i.test(nm)) note = humanizeName(nm.replace(/^browser[_\-.]/i, ""));
682
+ browser = describeBrowser(nm, a, opts && opts.element);
683
+ target = browser.target;
684
+ targetFull = str(firstOf(a, ["url", "href", "uri"])) || target;
494
685
  break;
495
686
  }
496
687
  case "mcp":
@@ -502,7 +693,7 @@ function describeTool(name, args) {
502
693
  default:
503
694
  break;
504
695
  }
505
- const v = VERBS[kind] || VERBS.tool;
696
+ const v = browser ? [browser.running, browser.done] : VERBS[kind] || VERBS.tool;
506
697
  return {
507
698
  kind,
508
699
  target: target.replace(/\s+/g, " ").trim(),
@@ -520,7 +711,9 @@ function toolLine(d, state) {
520
711
  if (d.kind === "todo" || d.kind === "toolsearch" || d.kind === "think") return verb;
521
712
  if (d.kind === "shell" && d.target && !d.mono) return d.target;
522
713
  if (d.kind === "mcp" || d.kind === "tool") return `${verb} ${d.target || "a tool"}`;
523
- return d.target ? `${verb} ${d.target}` : `${verb} ${KIND_NOUN[d.kind] || "a tool"}`;
714
+ if (d.target) return `${verb} ${d.target}`;
715
+ const noun = KIND_NOUN[d.kind];
716
+ return noun ? `${verb} ${noun}` : verb.replace(/\s+(for|of)$/, "");
524
717
  }
525
718
  var KIND_NOUN = {
526
719
  shell: "a command",
@@ -560,7 +753,7 @@ var PHRASES = {
560
753
  function summarizeCalls(calls) {
561
754
  const list = (calls || []).filter(Boolean);
562
755
  if (!list.length) return "";
563
- if (list.length === 1) return toolLine(describeTool(list[0].name, list[0].args), "done");
756
+ if (list.length === 1) return toolLine(describeTool(list[0].name, list[0].args, { element: list[0].element }), "done");
564
757
  const order = [];
565
758
  const count = {};
566
759
  for (const c of list) {
@@ -1480,8 +1673,9 @@ function StepDetail(props) {
1480
1673
  ] });
1481
1674
  }
1482
1675
  function StepRow(props) {
1483
- const { item, labels = DEFAULT_AGENT_LABELS, defaultOpen = false } = props;
1484
- const d = (0, import_react3.useMemo)(() => describeTool(item.name, item.args), [item.name, item.args]);
1676
+ const { item, labels = DEFAULT_AGENT_LABELS, defaultOpen = false, element = null, openStep, active = false } = props;
1677
+ const d = (0, import_react3.useMemo)(() => describeTool(item.name, item.args, { element }), [item.name, item.args, element]);
1678
+ const opener = openStep ? openStep(item, d) || null : null;
1485
1679
  const [open, setOpen] = (0, import_react3.useState)(defaultOpen);
1486
1680
  const uid = (0, import_react3.useRef)(`uac-s-${Math.random().toString(36).slice(2, 9)}`).current;
1487
1681
  const running = item.status === "running";
@@ -1491,8 +1685,8 @@ function StepRow(props) {
1491
1685
  const verb = running ? d.running : d.done;
1492
1686
  const hasTarget = d.target && line === `${verb} ${d.target}`;
1493
1687
  const note = !running && item.status !== "failed" ? resultNote(d.kind, item.output) : "";
1494
- const hasDetail = !!(item.args && item.args !== "{}" && item.args !== '""') || item.output !== void 0;
1495
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: cls("uac-step", `is-${item.status}`), "data-kind": d.kind, children: [
1688
+ const hasDetail = !opener && (!!(item.args && item.args !== "{}" && item.args !== '""') || item.output !== void 0);
1689
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: cls("uac-step", `is-${item.status}`, opener && "is-opens", opener && active && "is-active"), "data-kind": d.kind, children: [
1496
1690
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1497
1691
  "button",
1498
1692
  {
@@ -1500,8 +1694,9 @@ function StepRow(props) {
1500
1694
  className: "uac-step-h",
1501
1695
  "aria-expanded": hasDetail ? open : void 0,
1502
1696
  "aria-controls": hasDetail ? uid : void 0,
1503
- disabled: !hasDetail,
1504
- onClick: () => setOpen((v) => !v),
1697
+ "aria-current": opener && active ? "true" : void 0,
1698
+ disabled: !opener && !hasDetail,
1699
+ onClick: opener || (() => setOpen((v) => !v)),
1505
1700
  title: d.targetFull || void 0,
1506
1701
  children: [
1507
1702
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(StatusGlyph, { status: item.status, kind: d.kind }),
@@ -1517,7 +1712,7 @@ function StepRow(props) {
1517
1712
  note ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "uac-step-n", children: note }) : null,
1518
1713
  item.status === "stopped" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "uac-step-n", children: labels.stoppedCall }) : null,
1519
1714
  running && runMs != null ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "uac-step-time", children: formatElapsed(runMs) }) : tookMs != null && tookMs >= 1e3 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "uac-step-time", children: formatDuration(tookMs) }) : null,
1520
- hasDetail ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "uac-chev", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Chevron, { dir: open ? "down" : "right", size: 12 }) }) : null
1715
+ hasDetail || opener ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "uac-chev", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Chevron, { dir: open && !opener ? "down" : "right", size: 12 }) }) : null
1521
1716
  ]
1522
1717
  }
1523
1718
  ),
@@ -1569,14 +1764,26 @@ function sumDiff(tools) {
1569
1764
  return any ? { added, removed } : null;
1570
1765
  }
1571
1766
  function WorkGroup(props) {
1572
- const { items, live = false, liveLabel, start = null, mark, motion, labels = DEFAULT_AGENT_LABELS, defaultOpen = false } = props;
1767
+ const {
1768
+ items,
1769
+ live = false,
1770
+ liveLabel,
1771
+ start = null,
1772
+ mark,
1773
+ motion,
1774
+ labels = DEFAULT_AGENT_LABELS,
1775
+ defaultOpen = false,
1776
+ elements = null,
1777
+ openStep,
1778
+ activeStep = null
1779
+ } = props;
1573
1780
  const [open, setOpen] = (0, import_react3.useState)(defaultOpen);
1574
1781
  const uid = (0, import_react3.useRef)(`uac-g-${Math.random().toString(36).slice(2, 9)}`).current;
1575
1782
  const tools = items.filter((x) => x.kind === "tool");
1576
1783
  const thoughts = items.filter((x) => x.kind === "thinking");
1577
1784
  const failed = tools.filter((x) => x.status === "failed").length;
1578
1785
  let summary = "";
1579
- if (tools.length) summary = summarizeCalls(tools);
1786
+ if (tools.length) summary = summarizeCalls(elements ? tools.map((t) => ({ name: t.name, args: t.args, element: elements[t.id] })) : tools);
1580
1787
  else if (thoughts.length) {
1581
1788
  const t = thoughts[0];
1582
1789
  const ms = t.startedAt != null && t.endedAt != null ? t.endedAt - t.startedAt : null;
@@ -1584,7 +1791,17 @@ function WorkGroup(props) {
1584
1791
  }
1585
1792
  const diff = sumDiff(tools);
1586
1793
  if (!live && !tools.length && !thoughts.some((t) => String(t.text || "").trim())) return null;
1587
- const body = open ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "uac-calls", id: uid, children: items.map((it) => it.kind === "tool" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(StepRow, { item: it, labels }, it.id) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ThinkingRow, { item: it, labels }, it.id)) }) : null;
1794
+ const body = open ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "uac-calls", id: uid, children: items.map((it) => it.kind === "tool" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1795
+ StepRow,
1796
+ {
1797
+ item: it,
1798
+ labels,
1799
+ element: elements ? elements[it.id] || null : null,
1800
+ openStep,
1801
+ active: activeStep != null && activeStep === it.id
1802
+ },
1803
+ it.id
1804
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ThinkingRow, { item: it, labels }, it.id)) }) : null;
1588
1805
  if (live) {
1589
1806
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: cls("uac-group", "is-live", open && "is-open"), children: [
1590
1807
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
@@ -1722,9 +1939,13 @@ function AgentTurnView(props) {
1722
1939
  renderFiles,
1723
1940
  actions,
1724
1941
  describeIncomplete,
1725
- liveStart
1942
+ liveStart,
1943
+ openStep,
1944
+ activeStep = null
1726
1945
  } = props;
1727
1946
  const labels = (0, import_react3.useMemo)(() => ({ ...DEFAULT_AGENT_LABELS, ...labelsIn || {} }), [labelsIn]);
1947
+ const items = turn ? turn.items : null;
1948
+ const elements = (0, import_react3.useMemo)(() => browserElements(items), [items]);
1728
1949
  if (!turn) return null;
1729
1950
  const running = turn.status === "running";
1730
1951
  const segs = segments(turn);
@@ -1735,7 +1956,7 @@ function AgentTurnView(props) {
1735
1956
  const liveWork = running && lastSeg && lastSeg.type === "work";
1736
1957
  let liveLabel = labels.thinking;
1737
1958
  if (now) {
1738
- if (now.phase === "tool" && now.tool) liveLabel = toolLine(describeTool(now.tool.name, now.tool.args), "running");
1959
+ if (now.phase === "tool" && now.tool) liveLabel = toolLine(describeTool(now.tool.name, now.tool.args, { element: elements[now.tool.id] }), "running");
1739
1960
  else if (now.phase === "writing") liveLabel = labels.writing;
1740
1961
  else if (now.phase === "starting") liveLabel = labels.starting;
1741
1962
  }
@@ -1753,7 +1974,21 @@ function AgentTurnView(props) {
1753
1974
  if (isLive) {
1754
1975
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react3.default.Fragment, { children: [
1755
1976
  plan ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TodoCard, { todos: plan, labels, running: true }) : null,
1756
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(WorkGroup, { items: s.items, live: true, liveLabel, start, mark, motion, labels })
1977
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1978
+ WorkGroup,
1979
+ {
1980
+ items: s.items,
1981
+ live: true,
1982
+ liveLabel,
1983
+ start,
1984
+ mark,
1985
+ motion,
1986
+ labels,
1987
+ elements,
1988
+ openStep,
1989
+ activeStep
1990
+ }
1991
+ )
1757
1992
  ] }, `w${i}`);
1758
1993
  }
1759
1994
  if (s.type === "text") {
@@ -1767,7 +2002,17 @@ function AgentTurnView(props) {
1767
2002
  s.item.id || `t${i}`
1768
2003
  );
1769
2004
  }
1770
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(WorkGroup, { items: s.items, labels }, `w${i}-${s.items[0] && s.items[0].id}`);
2005
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2006
+ WorkGroup,
2007
+ {
2008
+ items: s.items,
2009
+ labels,
2010
+ elements,
2011
+ openStep,
2012
+ activeStep
2013
+ },
2014
+ `w${i}-${s.items[0] && s.items[0].id}`
2015
+ );
1771
2016
  }),
1772
2017
  !liveWork && plan ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TodoCard, { todos: plan, labels, running }) : null,
1773
2018
  running && !liveWork ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(WorkingIndicator, { mark, motion, start, label: liveLabel }) : null,
@@ -2499,10 +2744,10 @@ function middleEllipsis(name, max = 40) {
2499
2744
  function MidName(props) {
2500
2745
  const { name, className } = props;
2501
2746
  const s = String(name || "");
2502
- const cut = s.length > 16 ? s.length - Math.min(14, Math.floor(s.length / 2)) : s.length;
2747
+ const cut2 = s.length > 16 ? s.length - Math.min(14, Math.floor(s.length / 2)) : s.length;
2503
2748
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "uac-mid" + (className ? ` ${className}` : ""), children: [
2504
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "uac-mid-h", children: s.slice(0, cut) }),
2505
- cut < s.length ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "uac-mid-t", children: s.slice(cut) }) : null
2749
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "uac-mid-h", children: s.slice(0, cut2) }),
2750
+ cut2 < s.length ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "uac-mid-t", children: s.slice(cut2) }) : null
2506
2751
  ] });
2507
2752
  }
2508
2753
  function dirOf(path) {