footprint-explainable-ui 0.8.1 → 0.9.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/dist/index.cjs CHANGED
@@ -3796,28 +3796,39 @@ var VLinePill = (0, import_react19.memo)(function VLinePill2({
3796
3796
  /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: { flex: 1, width: 1, background: theme.border } })
3797
3797
  ] });
3798
3798
  });
3799
- var RIGHT_PANEL_LABELS = {
3800
- memory: "Memory",
3801
- narrative: "Narrative"
3802
- };
3803
3799
  var DetailsContent = (0, import_react19.memo)(function DetailsContent2({
3804
3800
  snapshots,
3805
3801
  selectedIndex,
3806
3802
  narrativeEntries,
3807
3803
  narrative,
3808
3804
  size,
3809
- fillHeight
3805
+ fillHeight,
3806
+ extraViews
3810
3807
  }) {
3811
- const [rightPanel, setRightPanel] = (0, import_react19.useState)("memory");
3808
+ const builtInViews = [
3809
+ {
3810
+ id: "memory",
3811
+ name: "Memory",
3812
+ render: ({ snapshots: snaps, selectedIndex: idx }) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(MemoryPanel, { snapshots: snaps, selectedIndex: idx, size, style: fillHeight ? { height: "100%" } : void 0 })
3813
+ },
3814
+ {
3815
+ id: "narrative",
3816
+ name: "Narrative",
3817
+ render: ({ snapshots: snaps, selectedIndex: idx }) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(NarrativePanel, { snapshots: snaps, selectedIndex: idx, narrativeEntries, narrative, size, style: fillHeight ? { height: "100%" } : void 0 })
3818
+ }
3819
+ ];
3820
+ const allViews = [...builtInViews, ...extraViews ?? []];
3821
+ const [activeViewId, setActiveViewId] = (0, import_react19.useState)(allViews[0]?.id ?? "memory");
3822
+ const activeView = allViews.find((v2) => v2.id === activeViewId) ?? allViews[0];
3812
3823
  return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { flex: 1, display: "flex", flexDirection: "column", overflow: "hidden" }, children: [
3813
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: { display: "flex", borderBottom: `1px solid ${theme.border}`, flexShrink: 0 }, children: ["memory", "narrative"].map((panel) => {
3814
- const active = rightPanel === panel;
3824
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: { display: "flex", borderBottom: `1px solid ${theme.border}`, flexShrink: 0, overflowX: "auto" }, children: allViews.map((view) => {
3825
+ const active = view.id === activeViewId;
3815
3826
  return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3816
3827
  "button",
3817
3828
  {
3818
- onClick: () => setRightPanel(panel),
3829
+ onClick: () => setActiveViewId(view.id),
3819
3830
  style: {
3820
- flex: 1,
3831
+ flex: allViews.length <= 3 ? 1 : void 0,
3821
3832
  padding: "6px 8px",
3822
3833
  fontSize: 11,
3823
3834
  fontWeight: active ? 600 : 400,
@@ -3828,17 +3839,15 @@ var DetailsContent = (0, import_react19.memo)(function DetailsContent2({
3828
3839
  cursor: "pointer",
3829
3840
  textTransform: "uppercase",
3830
3841
  letterSpacing: "0.06em",
3831
- fontFamily: "inherit"
3842
+ fontFamily: "inherit",
3843
+ whiteSpace: "nowrap"
3832
3844
  },
3833
- children: RIGHT_PANEL_LABELS[panel]
3845
+ children: view.name
3834
3846
  },
3835
- panel
3847
+ view.id
3836
3848
  );
3837
3849
  }) }),
3838
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { style: { flex: 1, overflow: "auto" }, children: [
3839
- rightPanel === "memory" && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(MemoryPanel, { snapshots, selectedIndex, size, style: fillHeight ? { height: "100%" } : void 0 }),
3840
- rightPanel === "narrative" && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(NarrativePanel, { snapshots, selectedIndex, narrativeEntries, narrative, size, style: fillHeight ? { height: "100%" } : void 0 })
3841
- ] })
3850
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: { flex: 1, overflow: "auto" }, children: activeView?.render({ snapshots, selectedIndex }) })
3842
3851
  ] });
3843
3852
  });
3844
3853
  function resolveSubflowLevel(parentSpec, parentSnapshots, subflowNodeName, narrativeEntries) {
@@ -3848,8 +3857,9 @@ function resolveSubflowLevel(parentSpec, parentSnapshots, subflowNodeName, narra
3848
3857
  (s) => s.stageName === subflowNodeName || s.stageLabel === subflowNodeName
3849
3858
  );
3850
3859
  if (!parentSnap?.subflowResult) return null;
3851
- const sfNarrativeName = specNode.subflowName ?? specNode.name ?? subflowNodeName;
3852
- const sfNarrative = narrativeEntries ? extractSubflowNarrative(narrativeEntries, sfNarrativeName) : void 0;
3860
+ const sfId = specNode.subflowId ?? subflowNodeName;
3861
+ const sfDisplayName = specNode.subflowName ?? specNode.name;
3862
+ const sfNarrative = narrativeEntries ? extractSubflowNarrative(narrativeEntries, sfId, sfDisplayName) : void 0;
3853
3863
  const sfSnapshots = subflowResultToSnapshots(parentSnap.subflowResult, sfNarrative);
3854
3864
  if (sfSnapshots.length === 0) return null;
3855
3865
  return {
@@ -3859,15 +3869,21 @@ function resolveSubflowLevel(parentSpec, parentSnapshots, subflowNodeName, narra
3859
3869
  snapshots: sfSnapshots
3860
3870
  };
3861
3871
  }
3862
- function extractSubflowNarrative(entries, subflowName) {
3872
+ function extractSubflowNarrative(entries, subflowId, subflowName) {
3873
+ const prefix = subflowId + "/";
3874
+ const byPrefix = entries.filter((e) => e.stageName?.startsWith(prefix));
3875
+ if (byPrefix.length > 0) return byPrefix;
3876
+ const byId = entries.filter((e) => e.subflowId === subflowId);
3877
+ if (byId.length > 0) return byId;
3863
3878
  const result = [];
3879
+ const searchName = subflowName ?? subflowId;
3864
3880
  let inside = false;
3865
3881
  for (const entry of entries) {
3866
- if (entry.type === "subflow" && entry.text.includes(subflowName) && entry.text.startsWith("Entering")) {
3882
+ if (entry.type === "subflow" && entry.text.includes(searchName) && entry.text.startsWith("Entering")) {
3867
3883
  inside = true;
3868
3884
  continue;
3869
3885
  }
3870
- if (inside && entry.type === "subflow" && entry.text.includes(subflowName) && entry.text.startsWith("Exiting")) break;
3886
+ if (inside && entry.type === "subflow" && entry.text.includes(searchName) && entry.text.startsWith("Exiting")) break;
3871
3887
  if (inside) result.push(entry);
3872
3888
  }
3873
3889
  return result;
@@ -3915,6 +3931,7 @@ function ExplainableShell({
3915
3931
  hideConsole = false,
3916
3932
  panelLabels,
3917
3933
  defaultExpanded,
3934
+ recorderViews,
3918
3935
  renderFlowchart,
3919
3936
  size = "default",
3920
3937
  unstyled = false,
@@ -4185,7 +4202,8 @@ function ExplainableShell({
4185
4202
  selectedIndex: safeIdx,
4186
4203
  narrativeEntries: activeNarrativeEntries,
4187
4204
  narrative: activeNarrative,
4188
- size
4205
+ size,
4206
+ extraViews: recorderViews
4189
4207
  }
4190
4208
  ) }),
4191
4209
  /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(HLinePill, { label: bottomLabel, detail: `${activeSnapshots.length} stages`, expanded: timelineExpanded, onClick: toggleTimeline }),
@@ -4223,7 +4241,8 @@ function ExplainableShell({
4223
4241
  narrativeEntries: activeNarrativeEntries,
4224
4242
  narrative: activeNarrative,
4225
4243
  size,
4226
- fillHeight: true
4244
+ fillHeight: true,
4245
+ extraViews: recorderViews
4227
4246
  }
4228
4247
  )
4229
4248
  ] }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(VLinePill, { label: rightLabel, expanded: false, onClick: () => toggleRight(true) })