@volter-ai-dev/supercode-ui 0.1.55 → 0.1.56

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/subagents.mjs CHANGED
@@ -1,3 +1,6 @@
1
+ // src/subagents.jsx
2
+ import { useEffect as useEffect5, useRef as useRef4, useState as useState3 } from "preact/hooks";
3
+
1
4
  // core.mjs
2
5
  var HARNESS_NAMES = Object.freeze({
3
6
  "claude-code": "Claude Code",
@@ -1402,10 +1405,51 @@ function HarnessLogo({ id, activity, size = 28, onMissingLogo }) {
1402
1405
 
1403
1406
  // src/subagents.jsx
1404
1407
  import { jsx as jsx6, jsxs as jsxs5 } from "preact/jsx-runtime";
1405
- function SubagentInspector({ state, adapter, onClose }) {
1406
- const inspector = state.subagentInspector;
1407
- if (!inspector) return null;
1408
+ var ATTENTION_ACTIVITY = /* @__PURE__ */ new Set(["needs-input", "failed", "unseen"]);
1409
+ var ACTIVE_ACTIVITY = /* @__PURE__ */ new Set(["working", "running", "recent"]);
1410
+ function activityLabel(activity, age) {
1411
+ if (activity === "needs-input") return "Needs input";
1412
+ if (activity === "failed") return "Failed";
1413
+ if (activity === "unseen") return "New update";
1414
+ if (activity === "working") return "Working";
1415
+ if (activity === "running") return "Running";
1416
+ if (activity === "recent") return "Recent";
1417
+ if (activity === "finished") return "Finished";
1418
+ return age;
1419
+ }
1420
+ function SubagentRow({ row, inspector, adapter }) {
1421
+ return /* @__PURE__ */ jsxs5("button", { className: "scui-subagent-row", type: "button", "data-activity": row.activity ?? "idle", onClick: () => adapter.onIntent({ action: "openSubagent", parentKey: inspector.parentKey, key: row.key }), children: [
1422
+ /* @__PURE__ */ jsx6(HarnessLogo, { id: row.harness, activity: row.activity, size: 30 }),
1423
+ /* @__PURE__ */ jsxs5("span", { children: [
1424
+ /* @__PURE__ */ jsx6("strong", { children: sessionDisplayName(row) }),
1425
+ /* @__PURE__ */ jsx6("small", { children: row.preview || (row.activity === "working" ? "Working\u2026" : row.cwd) })
1426
+ ] }),
1427
+ /* @__PURE__ */ jsxs5("span", { children: [
1428
+ /* @__PURE__ */ jsx6("small", { children: activityLabel(row.activity, row.age) }),
1429
+ /* @__PURE__ */ jsx6(UiIcon, { name: "chevron", size: 14 })
1430
+ ] })
1431
+ ] });
1432
+ }
1433
+ function SubagentSection({ label, rows, inspector, adapter }) {
1434
+ if (!rows.length) return null;
1435
+ return /* @__PURE__ */ jsxs5("section", { className: "scui-subagent-section", "aria-labelledby": `scui-subagents-${label.toLowerCase().replaceAll(" ", "-")}`, children: [
1436
+ /* @__PURE__ */ jsx6("h2", { id: `scui-subagents-${label.toLowerCase().replaceAll(" ", "-")}`, children: label }),
1437
+ rows.map((row) => /* @__PURE__ */ jsx6(SubagentRow, { row, inspector, adapter }, row.key))
1438
+ ] });
1439
+ }
1440
+ function SubagentInspectorContent({ state, adapter, onClose, inspector }) {
1408
1441
  const selected = inspector.items.find((row) => row.key === inspector.selectedKey) ?? null;
1442
+ const attention = inspector.items.filter((row) => ATTENTION_ACTIVITY.has(row.activity));
1443
+ const active = inspector.items.filter((row) => ACTIVE_ACTIVITY.has(row.activity));
1444
+ const finished = inspector.items.filter((row) => !ATTENTION_ACTIVITY.has(row.activity) && !ACTIVE_ACTIVITY.has(row.activity));
1445
+ const [finishedOpen, setFinishedOpen] = useState3(false);
1446
+ const backButton = useRef4(null);
1447
+ useEffect5(() => {
1448
+ if (inspector.status === "ready" && !attention.length && !active.length) setFinishedOpen(true);
1449
+ }, [inspector.parentKey, inspector.status]);
1450
+ useEffect5(() => {
1451
+ backButton.current?.focus({ preventScroll: true });
1452
+ }, [selected?.key]);
1409
1453
  const detailState = selected ? {
1410
1454
  ...state,
1411
1455
  transcript: inspector.transcript,
@@ -1426,15 +1470,14 @@ function SubagentInspector({ state, adapter, onClose }) {
1426
1470
  onClose();
1427
1471
  };
1428
1472
  const back = () => selected ? adapter.onIntent({ action: "openSubagents", key: inspector.parentKey }) : leave();
1429
- return /* @__PURE__ */ jsxs5("section", { className: "scui-subagents", "aria-label": `Subagents for ${inspector.parentTitle}`, children: [
1473
+ return /* @__PURE__ */ jsxs5("section", { className: "scui-subagents", "aria-label": `Agents for ${inspector.parentTitle}`, children: [
1430
1474
  /* @__PURE__ */ jsxs5("header", { className: "scui-head", children: [
1431
- /* @__PURE__ */ jsx6("button", { type: "button", "aria-label": selected ? "Back to subagents" : "Back to chats", onClick: back, children: /* @__PURE__ */ jsx6(UiIcon, { name: "back", size: 17 }) }),
1432
- /* @__PURE__ */ jsx6(UiIcon, { name: "agents", size: 20 }),
1475
+ /* @__PURE__ */ jsx6("button", { ref: backButton, type: "button", "aria-label": selected ? "Back to agents" : "Back to chats", onClick: back, children: /* @__PURE__ */ jsx6(UiIcon, { name: "back", size: 17 }) }),
1476
+ selected ? /* @__PURE__ */ jsx6(HarnessLogo, { id: selected.harness, activity: selected.activity, size: 24 }) : /* @__PURE__ */ jsx6(UiIcon, { name: "agents", size: 20 }),
1433
1477
  /* @__PURE__ */ jsxs5("span", { className: "scui-head-copy", children: [
1434
1478
  /* @__PURE__ */ jsx6("strong", { children: selected ? sessionDisplayName(selected) : `${inspector.items.length || ""} ${inspector.items.length === 1 ? "agent" : "agents"}`.trim() }),
1435
1479
  /* @__PURE__ */ jsx6("small", { children: selected ? `${harnessDisplayName(selected.harness)} \xB7 Read-only` : inspector.parentTitle })
1436
- ] }),
1437
- /* @__PURE__ */ jsx6("button", { type: "button", "aria-label": "Close subagent inspector", onClick: leave, children: /* @__PURE__ */ jsx6(UiIcon, { name: "close", size: 18 }) })
1480
+ ] })
1438
1481
  ] }),
1439
1482
  inspector.status === "loading" ? /* @__PURE__ */ jsxs5("div", { className: "scui-subagents-loading", role: "status", children: [
1440
1483
  /* @__PURE__ */ jsx6("i", {}),
@@ -1444,21 +1487,26 @@ function SubagentInspector({ state, adapter, onClose }) {
1444
1487
  ] })
1445
1488
  ] }) : null,
1446
1489
  inspector.error ? /* @__PURE__ */ jsx6("div", { className: "scui-error", role: "alert", children: inspector.error }) : null,
1447
- !selected && inspector.status === "ready" ? /* @__PURE__ */ jsx6("div", { className: "scui-subagent-rows", children: inspector.items.map((row) => /* @__PURE__ */ jsxs5("button", { type: "button", "data-activity": row.activity ?? "idle", onClick: () => adapter.onIntent({ action: "openSubagent", parentKey: inspector.parentKey, key: row.key }), children: [
1448
- /* @__PURE__ */ jsx6(HarnessLogo, { id: row.harness, activity: row.activity, size: 30 }),
1449
- /* @__PURE__ */ jsxs5("span", { children: [
1450
- /* @__PURE__ */ jsx6("strong", { children: sessionDisplayName(row) }),
1451
- /* @__PURE__ */ jsx6("small", { children: row.preview || (row.activity === "working" ? "Working\u2026" : row.cwd) })
1452
- ] }),
1453
- /* @__PURE__ */ jsxs5("span", { children: [
1454
- /* @__PURE__ */ jsx6("small", { children: row.activity === "needs-input" ? "Needs input" : row.activity === "working" ? "Working" : row.age }),
1455
- /* @__PURE__ */ jsx6(UiIcon, { name: "chevron", size: 14 })
1456
- ] })
1457
- ] }, row.key)) }) : null,
1490
+ !selected && inspector.status === "ready" && inspector.items.length ? /* @__PURE__ */ jsxs5("div", { className: "scui-subagent-rows", children: [
1491
+ /* @__PURE__ */ jsx6(SubagentSection, { label: "Needs attention", rows: attention, inspector, adapter }),
1492
+ /* @__PURE__ */ jsx6(SubagentSection, { label: "Active", rows: active, inspector, adapter }),
1493
+ finished.length ? /* @__PURE__ */ jsxs5("details", { className: "scui-subagent-history", open: finishedOpen, onToggle: (event) => setFinishedOpen(event.currentTarget.open), children: [
1494
+ /* @__PURE__ */ jsxs5("summary", { children: [
1495
+ /* @__PURE__ */ jsx6("span", { children: "Finished" }),
1496
+ /* @__PURE__ */ jsx6("small", { children: finished.length }),
1497
+ /* @__PURE__ */ jsx6(UiIcon, { name: "chevron", size: 14 })
1498
+ ] }),
1499
+ /* @__PURE__ */ jsx6("div", { children: finished.map((row) => /* @__PURE__ */ jsx6(SubagentRow, { row, inspector, adapter }, row.key)) })
1500
+ ] }) : null
1501
+ ] }) : null,
1458
1502
  !selected && inspector.status === "ready" && !inspector.items.length ? /* @__PURE__ */ jsx6("div", { className: "scui-empty", children: "No native child sessions were found." }) : null,
1459
1503
  selected && inspector.status === "ready" && detailState ? /* @__PURE__ */ jsx6(Conversation, { state: detailState, adapter, memoryKey: `subagent:${selected.key}` }) : null
1460
1504
  ] });
1461
1505
  }
1506
+ function SubagentInspector({ state, adapter, onClose }) {
1507
+ if (!state.subagentInspector) return null;
1508
+ return /* @__PURE__ */ jsx6(SubagentInspectorContent, { state, adapter, onClose, inspector: state.subagentInspector });
1509
+ }
1462
1510
  export {
1463
1511
  SubagentInspector
1464
1512
  };