@invergent/agent-chat-react 2.8.0 → 2.8.1

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/dist/index.cjs CHANGED
@@ -16405,10 +16405,20 @@ function fallbackSessionTitle(entry) {
16405
16405
  if (entry.runKind === "scheduled") return "Scheduled run";
16406
16406
  return "New session";
16407
16407
  }
16408
+ function rowStateClass(isActive, isInActiveGroup) {
16409
+ if (isActive) {
16410
+ return "bg-faint/30 dark:bg-[#1e2840] text-foreground border-l-primary";
16411
+ }
16412
+ if (isInActiveGroup) {
16413
+ return "bg-line/70 dark:bg-line/60 text-foreground/80 hover:bg-input hover:text-foreground border-l-transparent";
16414
+ }
16415
+ return "bg-transparent text-foreground/80 hover:bg-input hover:text-foreground border-l-transparent";
16416
+ }
16408
16417
  function TreeNodeRow({
16409
16418
  entry,
16410
16419
  depth,
16411
16420
  activeSessionId,
16421
+ activeGroupRootId,
16412
16422
  canStop,
16413
16423
  canDelete,
16414
16424
  onSelect,
@@ -16420,11 +16430,15 @@ function TreeNodeRow({
16420
16430
  const isActive = entry.id === activeSessionId;
16421
16431
  const isRunning = entry.status === "active";
16422
16432
  const isChildSession = entry.parentId != null;
16433
+ const isInActiveGroup = activeGroupRootId !== null && (entry.id === activeGroupRootId || entry.parentId === activeGroupRootId);
16423
16434
  const title = entry.title ?? fallbackSessionTitle(entry);
16424
16435
  const subtitle = [
16425
16436
  formatRunKind(entry.runKind),
16426
16437
  formatSessionTime(entry.updatedAt)
16427
16438
  ].filter(Boolean).join(" \xB7 ");
16439
+ react.useEffect(() => {
16440
+ if (hasChildren) setExpanded(isInActiveGroup);
16441
+ }, [isInActiveGroup, hasChildren]);
16428
16442
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
16429
16443
  /* @__PURE__ */ jsxRuntime.jsxs(
16430
16444
  "div",
@@ -16438,7 +16452,7 @@ function TreeNodeRow({
16438
16452
  className: cn(
16439
16453
  "group flex items-center gap-2 w-full py-2 pr-2 text-left cursor-pointer transition-colors border-l-2",
16440
16454
  "min-h-11 md:min-h-0",
16441
- isActive ? "bg-line text-foreground border-l-primary" : "bg-transparent text-foreground/80 hover:bg-input hover:text-foreground border-l-transparent"
16455
+ rowStateClass(isActive, isInActiveGroup)
16442
16456
  ),
16443
16457
  style: { paddingLeft: `${depth * 12 + 12}px` },
16444
16458
  children: [
@@ -16497,6 +16511,7 @@ function TreeNodeRow({
16497
16511
  entry: child,
16498
16512
  depth: depth + 1,
16499
16513
  activeSessionId,
16514
+ activeGroupRootId,
16500
16515
  canStop,
16501
16516
  canDelete,
16502
16517
  onSelect,
@@ -16613,6 +16628,21 @@ function SessionTreePanel({
16613
16628
  return () => clearInterval(id);
16614
16629
  }, [refetch, runningCount]);
16615
16630
  const roots = react.useMemo(() => buildTree(nodes), [nodes]);
16631
+ const activeGroupRootId = react.useMemo(() => {
16632
+ if (!activeSessionId) return null;
16633
+ const parentOf = /* @__PURE__ */ new Map();
16634
+ for (const n of nodes) parentOf.set(n.id, n.parentId ?? null);
16635
+ const visited = /* @__PURE__ */ new Set();
16636
+ let current = activeSessionId;
16637
+ let parent = parentOf.get(current);
16638
+ while (parent != null) {
16639
+ if (visited.has(parent)) break;
16640
+ visited.add(current);
16641
+ current = parent;
16642
+ parent = parentOf.get(current);
16643
+ }
16644
+ return parentOf.has(current) ? current : null;
16645
+ }, [activeSessionId, nodes]);
16616
16646
  const handleSelect = react.useCallback(
16617
16647
  (id) => {
16618
16648
  onSessionSelect?.(id);
@@ -16676,6 +16706,7 @@ function SessionTreePanel({
16676
16706
  entry,
16677
16707
  depth: 0,
16678
16708
  activeSessionId: activeSessionId ?? "",
16709
+ activeGroupRootId,
16679
16710
  canStop: Boolean(adapter.stopSession),
16680
16711
  canDelete: Boolean(adapter.deleteSession),
16681
16712
  onSelect: handleSelect,