@principal-ai/subsystems-react 0.56.34 → 0.56.35

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.
@@ -24,6 +24,7 @@ import { type SubsystemDiagnostic } from './DiagnosticToggle';
24
24
  import { type SubsystemIssueListProps, type SubsystemIssue, type SubsystemIssueCategory } from './IssueList';
25
25
  import type { ComponentVerificationState } from './ComponentDeclaration';
26
26
  import type { DeclarationSymbolRef, SymbolInspection } from './symbolRefs';
27
+ import { type TrailsStepChange } from './TrailsPanel';
27
28
  import type { StepEmphasisMap } from './stepEmphasis';
28
29
  /** Context passed to `renderTrailViewer` when a flow/step is focused. */
29
30
  export interface TrailViewerContext {
@@ -135,6 +136,56 @@ export interface SubsystemComponentGraphProps {
135
136
  trailId: string;
136
137
  stepIndices?: number[];
137
138
  } | null) => void;
139
+ /**
140
+ * PROTOTYPE: host-controlled trail focus. Changing this expands the trail
141
+ * and drives the camera. With a `stepIndex`, it focuses that step's edge;
142
+ * without one, it frames the whole trail. `showFile` controls whether the
143
+ * step's file/trail drawer opens — omit it for whole-trail focus, or set it
144
+ * to `false` to select a step without showing its file.
145
+ *
146
+ * `undefined` leaves in-graph focus untouched; `null` clears host control.
147
+ */
148
+ focusedTrailStep?: {
149
+ trailId: string;
150
+ stepIndex?: number;
151
+ showFile?: boolean;
152
+ } | null;
153
+ /**
154
+ * PROTOTYPE: host-local ids of trails awaiting confirmation. Their Trails
155
+ * panel icon uses the proposal color instead of labelling the title.
156
+ */
157
+ proposedTrailIds?: Set<string>;
158
+ /**
159
+ * PROTOTYPE: host-local ids of steps awaiting confirmation, keyed by
160
+ * `emphasisKey(trailId, step)`. Their Trails panel text uses proposal color.
161
+ */
162
+ proposedStepKeys?: Set<string>;
163
+ /**
164
+ * PROTOTYPE: host-local before/after view for an accepted step replacement.
165
+ * The previous step stays out of the trails array; the panel renders it as a
166
+ * ghost beneath the committed step.
167
+ */
168
+ stepChange?: TrailsStepChange | null;
169
+ /** Whether the previous-state ghost is visible. @default true */
170
+ showPreviousStep?: boolean;
171
+ /** Dismiss or restore just the previous-state ghost. */
172
+ onTogglePreviousStep?: () => void;
173
+ /**
174
+ * PROTOTYPE: host-local component aliases awaiting confirmation. Their boxes
175
+ * use the proposal border, name colour and `PROPOSED` badge.
176
+ */
177
+ proposedComponentAliases?: Set<string>;
178
+ /**
179
+ * PROTOTYPE: host-local component aliases the agent is currently working on.
180
+ * Their boxes get a static ring and a sparkling WandSparkles icon.
181
+ */
182
+ workingComponentAliases?: Set<string>;
183
+ /**
184
+ * PROTOTYPE: host-local component aliases removed from the model. Their
185
+ * nodes stay in the layout, dimmed and `REMOVED`-badged, so the change is
186
+ * legible instead of silently disappearing.
187
+ */
188
+ removedComponentAliases?: Set<string>;
138
189
  /**
139
190
  * Reports which trail step is currently hovered in the Trails panel —
140
191
  * the transient preview mirror of `onTrailSelect`. `null` when nothing is
@@ -207,6 +258,11 @@ export interface SubsystemComponentGraphProps {
207
258
  * subsystem name visible as an overlay on the canvas.
208
259
  */
209
260
  hideSidebar?: boolean;
261
+ /**
262
+ * Suppress only the standard full-width header (title + sidebar-view switch)
263
+ * while keeping the sidebar and canvas. Hosts can render their own header.
264
+ */
265
+ hideHeader?: boolean;
210
266
  /**
211
267
  * How trail step highlighting behaves on the canvas.
212
268
  * - `focus` (default): zoom to the step, hide non-participants, open drawer
@@ -241,6 +297,12 @@ export interface SubsystemComponentGraphProps {
241
297
  * @default 300
242
298
  */
243
299
  trailFocusDurationMs?: number;
300
+ /**
301
+ * Downward screen-pixel offset applied when the camera frames the graph or
302
+ * a focused trail step. Useful for hosts with chrome over the canvas top.
303
+ * @default 0
304
+ */
305
+ focusVerticalBiasPx?: number;
244
306
  /**
245
307
  * Subsystem title rendered as a non-interactive overlay chip on the graph
246
308
  * canvas (top-center). Does not trigger the sidebar — for graph-only
@@ -1 +1 @@
1
- {"version":3,"file":"SubsystemComponentGraph.d.ts","sourceRoot":"","sources":["../../src/subsystem/Subs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AAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC,CAAC;IACjE;;;;;;;;OAQG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAg3GD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,4BAA4B,+BAqN1E"}
@@ -16,7 +16,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
16
16
  * injection, onNodeClick) adapted to the subsystem model — read-only.
17
17
  */
18
18
  import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
19
- import { ReactFlow, ReactFlowProvider, useReactFlow, useViewport, applyNodeChanges, } from '@xyflow/react';
19
+ import { ReactFlow, ReactFlowProvider, useReactFlow, useStore, useViewport, getViewportForBounds, applyNodeChanges, } from '@xyflow/react';
20
20
  import { useTheme } from '@principal-ade/industry-theme';
21
21
  import { SUBSYSTEM_MODEL_DESCRIPTION_MAX } from '@principal-ai/subsystems-core';
22
22
  import { ArrowDown, ArrowRight, Boxes, Files, Route, Unlink, X } from 'lucide-react';
@@ -39,7 +39,7 @@ import { GraphWithSidebar } from './GraphWithSidebar';
39
39
  import { ShareButton } from './ShareButton';
40
40
  import { DescriptionOverlay } from './DescriptionOverlay';
41
41
  import { DescriptionPreview } from './DescriptionPreview';
42
- import { TrailsPanel, TRAIL_PLAY_PAUSE_MS, TRAIL_HOVER_PREVIEW_MS } from './TrailsPanel';
42
+ import { TrailsPanel, TRAIL_PLAY_PAUSE_MS, TRAIL_HOVER_PREVIEW_MS, } from './TrailsPanel';
43
43
  import { EDGE_LABEL_WIDTH, EDGE_LABEL_HEIGHT, EDGE_LABEL_FONT_SIZE, EDGE_LABEL_CLOUD_PATH, EDGE_LABEL_CLOUD_EXTRA_TOP, } from '../utils/edgeLabel';
44
44
  import { graphGeometryBounds } from '../utils/elkLayout';
45
45
  /** Identifiers a token could match to name this component as a construct. */
@@ -179,9 +179,13 @@ const TrailDrawerContent = memo(function TrailDrawerContent({ render, trail, ste
179
179
  onVisibleStepChange,
180
180
  }) }));
181
181
  });
182
- function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirection: layoutDirectionProp, defaultLayoutDirection = 'horizontal', onLayoutDirectionChange, hideLayoutToggle = false, refocusOnLayoutFlip = true, initialTrailId, onTrailSelect, onTrailStepHover, onReorderTrails, stepEmphasis, onRemoveStepEmphasis, onSelect, onEdgeSelect, measured: _measured, maxNodeWidth, showEdgeLabels, showSingletonFrames = true, moduleNesting, edgeView, hideSidebar, trailStepMode = 'focus', autoPlayTrails = false, trailAutoPlayIntervalMs = TRAIL_PLAY_PAUSE_MS, onAutoPlayStep, zoomOnTrailFocus = true, trailFocusDurationMs = 300, graphTitle, showTrailTitle = false, description, notes, canvasOverlay, interactive = true, canvasBackground = 'theme', onLayoutReady, onNodeRects, sidebarExtra, sidebarAfterDescription, issues, showIssues, filesActive, sidebarScope, onSidebarTrailChange, focusIssueCategory, laneStatus, onSelectIssue, onApplyIssueFix, onHoverIssue, renderFileViewer, renderTrailViewer, onFileSelect, componentVerification, onInspectSymbol, boundaryColors, codeProcessKeys, regionDetails, defaultFramesCollapsed, containersActive, hideDrawer = false, persistKey, liveEvents, agentsPanel }) {
182
+ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirection: layoutDirectionProp, defaultLayoutDirection = 'horizontal', onLayoutDirectionChange, hideLayoutToggle = false, refocusOnLayoutFlip = true, initialTrailId, onTrailSelect, focusedTrailStep, proposedTrailIds, proposedStepKeys, stepChange, showPreviousStep, onTogglePreviousStep, proposedComponentAliases, workingComponentAliases, removedComponentAliases, onTrailStepHover, onReorderTrails, stepEmphasis, onRemoveStepEmphasis, onSelect, onEdgeSelect, measured: _measured, maxNodeWidth, showEdgeLabels, showSingletonFrames = true, moduleNesting, edgeView, hideSidebar, trailStepMode = 'focus', autoPlayTrails = false, trailAutoPlayIntervalMs = TRAIL_PLAY_PAUSE_MS, onAutoPlayStep, zoomOnTrailFocus = true, trailFocusDurationMs = 300, focusVerticalBiasPx = 0, graphTitle, showTrailTitle = false, description, notes, canvasOverlay, interactive = true, canvasBackground = 'theme', onLayoutReady, onNodeRects, sidebarExtra, sidebarAfterDescription, issues, showIssues, filesActive, sidebarScope, onSidebarTrailChange, focusIssueCategory, laneStatus, onSelectIssue, onApplyIssueFix, onHoverIssue, renderFileViewer, renderTrailViewer, onFileSelect, componentVerification, onInspectSymbol, boundaryColors, codeProcessKeys, regionDetails, defaultFramesCollapsed, containersActive, hideDrawer = false, persistKey, liveEvents, agentsPanel }) {
183
183
  const { theme } = useTheme();
184
- const { fitView, fitBounds } = useReactFlow();
184
+ const { fitView, fitBounds, setViewport } = useReactFlow();
185
+ const flowWidth = useStore((state) => state.width);
186
+ const flowHeight = useStore((state) => state.height);
187
+ const minZoom = useStore((state) => state.minZoom);
188
+ const maxZoom = useStore((state) => state.maxZoom);
185
189
  const [descriptionOpen, setDescriptionOpen] = useState(false);
186
190
  const rawDescription = description?.trim();
187
191
  // The host caps the authored description; trim defensively for other hosts.
@@ -203,6 +207,27 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
203
207
  edges: [],
204
208
  absoluteRects: new Map(),
205
209
  });
210
+ // React Flow's `fitBounds` always centres the bounds. A host may need the
211
+ // diagram deliberately lower (e.g. to leave room for status chrome over the
212
+ // canvas), so recompute the same viewport and shift only its screen-space y.
213
+ const fitBoundsWithBias = useCallback((bounds, options) => {
214
+ if (!focusVerticalBiasPx ||
215
+ flowWidth <= 0 ||
216
+ flowHeight <= 0) {
217
+ void fitBounds(bounds, options);
218
+ return;
219
+ }
220
+ const viewport = getViewportForBounds(bounds, flowWidth, flowHeight, minZoom, maxZoom, options.padding);
221
+ void setViewport({ ...viewport, y: viewport.y + focusVerticalBiasPx }, { duration: options.duration });
222
+ }, [
223
+ fitBounds,
224
+ setViewport,
225
+ flowWidth,
226
+ flowHeight,
227
+ minZoom,
228
+ maxZoom,
229
+ focusVerticalBiasPx,
230
+ ]);
206
231
  const fitGraphContents = useCallback((duration = 300) => {
207
232
  const edges = built.edges.map((edge) => {
208
233
  const data = edge.data;
@@ -224,8 +249,8 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
224
249
  });
225
250
  return;
226
251
  }
227
- fitBounds(bounds, { padding: 0.1, duration });
228
- }, [built.absoluteRects, built.edges, fitBounds, fitView]);
252
+ fitBoundsWithBias(bounds, { padding: 0.1, duration });
253
+ }, [built.absoluteRects, built.edges, fitBoundsWithBias, fitView]);
229
254
  const [layoutReady, setLayoutReady] = useState(false);
230
255
  const transparentCanvas = canvasBackground === 'transparent';
231
256
  // Host notifications. Refs keep the callbacks out of effect deps so an
@@ -276,6 +301,10 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
276
301
  const flipFadeTimerRef = useRef(null);
277
302
  /** Set when a layout flip starts; the camera refits once layout lands. */
278
303
  const refitAfterLayoutRef = useRef(false);
304
+ /** A host-driven step focus owns the camera across frame-layout flips. */
305
+ const stepFocusActiveRef = useRef(false);
306
+ const focusEdgeIdsRef = useRef(null);
307
+ const fitFocusBoundsRef = useRef(() => { });
279
308
  /** Solo layout: only this trail's components and edges are laid out. */
280
309
  const [layoutTrailId, setLayoutTrailId] = useState(null);
281
310
  const [committedTrailId, setCommittedTrailId] = useState(null);
@@ -443,7 +472,15 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
443
472
  return;
444
473
  refitAfterLayoutRef.current = false;
445
474
  requestAnimationFrame(() => {
446
- fitGraphContents(LAYOUT_FLIP_NODE_MS);
475
+ // Focused trail/step edges (e.g. an agent walkthrough step that just
476
+ // opened a different trail's frames) must not be replaced by a
477
+ // whole-graph fit — that would zoom back out to the entire model.
478
+ if (focusEdgeIdsRef.current) {
479
+ fitFocusBoundsRef.current(focusEdgeIdsRef.current);
480
+ }
481
+ else {
482
+ fitGraphContents(LAYOUT_FLIP_NODE_MS);
483
+ }
447
484
  });
448
485
  }, [built, layoutReady, fitGraphContents]);
449
486
  // Persist the choice so a model reopens the way it was left.
@@ -701,7 +738,10 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
701
738
  const trail = (trails ?? []).find((t) => t.id === committedTrailId);
702
739
  if (!trail)
703
740
  return { components, trails };
704
- const aliases = new Set();
741
+ // Host-local removal ghosts stay in the layout even when their steps are
742
+ // gone; otherwise accepting a removal would make the node vanish from a
743
+ // solo-focused flow instead of leaving the dim record the user asked for.
744
+ const aliases = new Set(removedComponentAliases);
705
745
  for (const step of trail.steps) {
706
746
  aliases.add(step.from);
707
747
  aliases.add(step.to);
@@ -710,7 +750,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
710
750
  components: components.filter((c) => aliases.has(c.alias)),
711
751
  trails: [trail],
712
752
  };
713
- }, [components, trails, committedTrailId]);
753
+ }, [components, trails, committedTrailId, removedComponentAliases]);
714
754
  const layoutRelations = committedTrailId ? undefined : graphifyRelations;
715
755
  const layoutKey = useMemo(() => subsystemGraphLayoutKey({
716
756
  components: layoutDoc.components,
@@ -1183,6 +1223,12 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
1183
1223
  }
1184
1224
  return new Set(tl.steps.map((s) => trailStepGraphEdgeId(s)));
1185
1225
  }, [trails, focusedTrailId, focusedStepIndex, autoPlayFocus]);
1226
+ // Keep these refs current during render, not in a later effect: the
1227
+ // post-layout refit effect is declared above and must see the focus that
1228
+ // triggered this layout swap, or it falls back to a whole-graph fit.
1229
+ stepFocusActiveRef.current =
1230
+ autoPlayFocus == null && focusedTrailId != null && focusedStepIndex != null;
1231
+ focusEdgeIdsRef.current = focusEdgeIds;
1186
1232
  // 1-based step numbers per edge of the active flow (focused or
1187
1233
  // hover/autoplay-highlighted). An edge can appear in more than one step.
1188
1234
  const selectedFlowStepNos = useMemo(() => {
@@ -1368,6 +1414,12 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
1368
1414
  };
1369
1415
  }
1370
1416
  const comp = n.data?.component;
1417
+ const proposed = comp?.alias != null &&
1418
+ proposedComponentAliases?.has(comp.alias) === true;
1419
+ const working = comp?.alias != null &&
1420
+ workingComponentAliases?.has(comp.alias) === true;
1421
+ const removed = comp?.alias != null &&
1422
+ removedComponentAliases?.has(comp.alias) === true;
1371
1423
  const fileMatch = fileMatchForNode(comp?.file, openFile, focusNodeIds?.has(n.id) === true);
1372
1424
  // Bases selection on the focused step, not the hover preview, so
1373
1425
  // hovering doesn't strip the frame's `isSelected`.
@@ -1375,7 +1427,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
1375
1427
  // `brightNodeIds` (the focused step's endpoints) is a spotlight member as
1376
1428
  // well as a bright set — see the group branch above.
1377
1429
  const dimSource = previewNodeIds ?? brightNodeIds ?? issueFocusNodeIds;
1378
- const { hidden, dimmed } = flowNodeVisibility({
1430
+ const flowVisibility = flowNodeVisibility({
1379
1431
  inOpened: openedNodeIds?.has(n.id) === true,
1380
1432
  inSelected: brightNodeIds?.has(n.id) === true,
1381
1433
  inSpotlight: dimSource?.has(n.id) === true || (hoverTrailAliases?.has(n.id) === true),
@@ -1383,12 +1435,22 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
1383
1435
  anySelected: brightNodeIds != null,
1384
1436
  anySpotlight: dimSource != null || hoverTrailAliases != null,
1385
1437
  });
1438
+ // A removed ghost is never hidden by flow focus — the whole point is to
1439
+ // keep it visible as a dim record of what the agent took out.
1440
+ const hidden = removed ? false : flowVisibility.hidden;
1441
+ const dimmed = removed ? true : flowVisibility.dimmed;
1386
1442
  // Component findings key by alias, boundary findings by region node id.
1387
1443
  // The two id spaces are disjoint (`module:` / `process:` are prefixed), so
1388
1444
  // one lookup covers both node kinds.
1389
1445
  const issueBadge = issueBadgeByAlias.get(n.id) ?? regionIssueByNodeId.get(n.id);
1390
- if (fileMatch === undefined && !isSelected && !dimmed && !issueBadge) {
1391
- const { fileMatch: _f, isSelected: _s, dimmed: _d, ...rest } = n.data;
1446
+ if (fileMatch === undefined &&
1447
+ !isSelected &&
1448
+ !dimmed &&
1449
+ !issueBadge &&
1450
+ !proposed &&
1451
+ !working &&
1452
+ !removed) {
1453
+ const { fileMatch: _f, isSelected: _s, dimmed: _d, proposed: _p, working: _w, removed: _r, ...rest } = n.data;
1392
1454
  return { ...n, hidden, data: rest };
1393
1455
  }
1394
1456
  return {
@@ -1399,11 +1461,14 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
1399
1461
  ...(fileMatch !== undefined && { fileMatch }),
1400
1462
  ...(isSelected && { isSelected }),
1401
1463
  ...(dimmed && { dimmed: true }),
1464
+ ...(proposed && { proposed: true }),
1465
+ ...(working && { working: true }),
1466
+ ...(removed && { removed: true }),
1402
1467
  ...(issueBadge && { issue: issueBadge }),
1403
1468
  },
1404
1469
  };
1405
1470
  });
1406
- }, [xyflowNodesBase, openFile, selected, focusNodeIds, openedNodeIds, brightNodeIds, previewNodeIds, hoverTrailAliases, aliasToComponent, issueFocusNodeIds, issueBadgeByAlias, regionIssueByNodeId, boundaryColors, toggleCollapsed]);
1471
+ }, [xyflowNodesBase, openFile, selected, focusNodeIds, openedNodeIds, brightNodeIds, previewNodeIds, hoverTrailAliases, aliasToComponent, issueFocusNodeIds, issueBadgeByAlias, regionIssueByNodeId, boundaryColors, proposedComponentAliases, workingComponentAliases, removedComponentAliases, toggleCollapsed]);
1407
1472
  const baseNodesKey = useMemo(() => nodes.map((n) => n.id).sort().join(','), [nodes]);
1408
1473
  const baseEdgesKey = useMemo(() => convertedEdges.map((e) => e.id).sort().join(','), [convertedEdges]);
1409
1474
  const dispEdges = useMemo(() => {
@@ -1475,8 +1540,9 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
1475
1540
  const onEdgesChange = useCallback((_changes) => dispEdges, [dispEdges]);
1476
1541
  useEffect(() => {
1477
1542
  // A layout flip runs its own camera refit when the new layout lands. This
1478
- // mount/edit fit would otherwise fire mid-flip and fight it.
1479
- if (layoutFlipping)
1543
+ // mount/edit fit would otherwise fire mid-flip and fight it. A focused
1544
+ // step also owns the camera — a frame flip must not restore whole-graph fit.
1545
+ if (layoutFlipping || stepFocusActiveRef.current)
1480
1546
  return;
1481
1547
  const t = setTimeout(() => {
1482
1548
  fitGraphContents(200);
@@ -1688,17 +1754,20 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
1688
1754
  width: Math.max(1, maxX - minX),
1689
1755
  height: Math.max(1, maxY - minY),
1690
1756
  };
1691
- fitBounds(bounds, {
1757
+ fitBoundsWithBias(bounds, {
1692
1758
  padding: 0.15,
1693
1759
  duration: trailFocusDurationMs,
1694
1760
  });
1695
1761
  }, [
1696
1762
  baseEdges,
1697
1763
  built.absoluteRects,
1698
- fitBounds,
1764
+ fitBoundsWithBias,
1699
1765
  zoomOnTrailFocus,
1700
1766
  trailFocusDurationMs,
1701
1767
  ]);
1768
+ useEffect(() => {
1769
+ fitFocusBoundsRef.current = fitFocusBounds;
1770
+ }, [fitFocusBounds]);
1702
1771
  // A node's laid-out rect in absolute flow coords. `absoluteRects` is the
1703
1772
  // authority; the fallback covers an unparented group node, whose `position` is
1704
1773
  // already absolute. Nested groups are parent-relative, so they are skipped
@@ -1738,13 +1807,13 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
1738
1807
  }
1739
1808
  if (!Number.isFinite(minX) || !Number.isFinite(minY))
1740
1809
  return;
1741
- fitBounds({
1810
+ fitBoundsWithBias({
1742
1811
  x: minX,
1743
1812
  y: minY,
1744
1813
  width: Math.max(1, maxX - minX),
1745
1814
  height: Math.max(1, maxY - minY),
1746
1815
  }, { padding, duration: trailFocusDurationMs });
1747
- }, [rectForNode, fitBounds, trailFocusDurationMs]);
1816
+ }, [rectForNode, fitBoundsWithBias, trailFocusDurationMs]);
1748
1817
  // The Containers list: every card frame in the laid-out graph, parents before
1749
1818
  // their children, with the colour the canvas draws it in. Rows keep the
1750
1819
  // grouping's declaration order — the layout moves closed cards after open
@@ -1806,10 +1875,11 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
1806
1875
  // frame the flow on the canvas. Selection state is cleared — the graph now
1807
1876
  // reads as the narrative. No drawer: the code view only opens on a step
1808
1877
  // click. A stale trail drawer (from a previously focused flow's step)
1809
- // closes; an explicitly opened file drawer stays.
1878
+ // closes; an explicitly opened file drawer stays unless a host asks for
1879
+ // file-free focus (e.g. a walkthrough step that only selects the trail).
1810
1880
  // In `dim` mode: clear step highlight and leave the full graph visible
1811
1881
  // (no zoom / hide) — matching "step away from a hovered step".
1812
- const focusTrailEdges = useCallback((tl) => {
1882
+ const focusTrailEdges = useCallback((tl, closeFile = false) => {
1813
1883
  setSelected(null);
1814
1884
  setSelectedEdgeId(null);
1815
1885
  setHoveredTrailStep(null);
@@ -1826,9 +1896,31 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
1826
1896
  setFocusedStepIndex(null);
1827
1897
  setFocusedTrailId(tl.id);
1828
1898
  onTrailSelect?.({ trailId: tl.id });
1829
- fitFocusBounds(new Set(tl.steps.map((s) => trailStepGraphEdgeId(s))));
1830
- setDrawerTarget((prev) => (prev?.kind === 'trail' ? null : prev));
1831
- }, [fitFocusBounds, trailStepMode, onTrailSelect, onSidebarTrailChange]);
1899
+ const edgeIds = new Set(tl.steps.map((s) => trailStepGraphEdgeId(s)));
1900
+ const drawerWillClose = drawerOpenRef.current && (closeFile || drawerTarget?.kind === 'trail');
1901
+ setDrawerTarget((prev) => closeFile || prev?.kind === 'trail' ? null : prev);
1902
+ if (pendingFocusFitRef.current != null) {
1903
+ window.clearTimeout(pendingFocusFitRef.current);
1904
+ pendingFocusFitRef.current = null;
1905
+ }
1906
+ if (drawerWillClose) {
1907
+ // Wait for the canvas to reclaim the drawer's height, or the fit uses
1908
+ // the temporarily shortened viewport and settles too far off-centre.
1909
+ pendingFocusFitRef.current = window.setTimeout(() => {
1910
+ pendingFocusFitRef.current = null;
1911
+ requestAnimationFrame(() => fitFocusBounds(edgeIds));
1912
+ }, FILE_DRAWER_HEIGHT_MS + 20);
1913
+ }
1914
+ else {
1915
+ fitFocusBounds(edgeIds);
1916
+ }
1917
+ }, [
1918
+ fitFocusBounds,
1919
+ trailStepMode,
1920
+ onTrailSelect,
1921
+ onSidebarTrailChange,
1922
+ drawerTarget,
1923
+ ]);
1832
1924
  const clearTrailFocus = useCallback(() => {
1833
1925
  if (pendingFocusFitRef.current != null) {
1834
1926
  window.clearTimeout(pendingFocusFitRef.current);
@@ -1880,7 +1972,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
1880
1972
  // step focus and returns to whole-flow (high-level) framing.
1881
1973
  // In `dim` mode: only dim non-participants (same as hovering a step) —
1882
1974
  // no camera move, no drawer, no hide.
1883
- const focusTrailStep = useCallback((tl, stepIndex) => {
1975
+ const focusTrailStep = useCallback((tl, stepIndex, showFile = true) => {
1884
1976
  const step = tl.steps[stepIndex];
1885
1977
  if (!step)
1886
1978
  return;
@@ -1894,6 +1986,11 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
1894
1986
  onTrailSelect?.(null);
1895
1987
  return;
1896
1988
  }
1989
+ // Opening the focused step's containing frames is what makes an
1990
+ // intra-process edge (e.g. api → store) renderable at all. Without this,
1991
+ // host-driven step focus can only frame cross-boundary hops.
1992
+ setExpandedTrails(new Set([tl.id]));
1993
+ setLayoutTrailId(tl.id);
1897
1994
  // Toggle: clicking the selected step unselects it (back to whole flow).
1898
1995
  onSidebarTrailChange(tl.id);
1899
1996
  if (focusedTrailId === tl.id && focusedStepIndex === stepIndex) {
@@ -1901,7 +1998,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
1901
1998
  // Pointer is still over the row — keep hover preview so dimming doesn't
1902
1999
  // flash off until mouseleave.
1903
2000
  setHoveredTrailStep({ trailId: tl.id, stepIndex });
1904
- setDrawerTarget((prev) => (prev?.kind === 'trail' ? null : prev));
2001
+ setDrawerTarget((prev) => !showFile ? null : prev?.kind === 'trail' ? null : prev);
1905
2002
  if (pendingFocusFitRef.current != null) {
1906
2003
  window.clearTimeout(pendingFocusFitRef.current);
1907
2004
  pendingFocusFitRef.current = null;
@@ -1913,10 +2010,13 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
1913
2010
  setFocusedTrailId(tl.id);
1914
2011
  setHoveredTrailStep(null);
1915
2012
  onTrailSelect?.({ trailId: tl.id, stepIndices: [stepIndex] });
1916
- // Open the drawer before fitting. If it was closed, wait for its height
1917
- // transition so fitView uses the reduced canvas — not full height.
2013
+ // The drawer changes the usable canvas height, so wait for its height
2014
+ // transition whenever we open or close it — not just when opening.
1918
2015
  const drawerWasOpen = drawerOpenRef.current;
1919
- if (renderTrailViewer) {
2016
+ if (!showFile) {
2017
+ setDrawerTarget(null);
2018
+ }
2019
+ else if (renderTrailViewer) {
1920
2020
  setDrawerTarget({
1921
2021
  kind: 'trail',
1922
2022
  trailId: tl.id,
@@ -1936,7 +2036,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
1936
2036
  window.clearTimeout(pendingFocusFitRef.current);
1937
2037
  pendingFocusFitRef.current = null;
1938
2038
  }
1939
- if (drawerWasOpen) {
2039
+ if (drawerWasOpen === showFile) {
1940
2040
  fitFocusBounds(edgeIds);
1941
2041
  }
1942
2042
  else {
@@ -1954,6 +2054,49 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
1954
2054
  onTrailSelect,
1955
2055
  onSidebarTrailChange,
1956
2056
  ]);
2057
+ // Host-controlled trail focus for agent-driven walkthroughs. Unlike
2058
+ // `initialTrailId`, this is repeatable. A `stepIndex` focuses one step;
2059
+ // omitting it frames the whole trail. `showFile: false` selects without
2060
+ // opening the file/trail drawer. `undefined` leaves graph-owned focus alone;
2061
+ // `null` hands control back to the graph.
2062
+ const appliedFocusedTrailStepRef = useRef(null);
2063
+ useEffect(() => {
2064
+ if (focusedTrailStep === undefined)
2065
+ return;
2066
+ if (focusedTrailStep === null) {
2067
+ if (appliedFocusedTrailStepRef.current == null)
2068
+ return;
2069
+ appliedFocusedTrailStepRef.current = null;
2070
+ clearTrailFocus();
2071
+ return;
2072
+ }
2073
+ const { trailId, stepIndex } = focusedTrailStep;
2074
+ const showFile = focusedTrailStep.showFile ?? stepIndex != null;
2075
+ const key = `${trailId}:${stepIndex ?? 'trail'}:${showFile ? 'file' : 'nofile'}`;
2076
+ if (appliedFocusedTrailStepRef.current === key)
2077
+ return;
2078
+ if (!layoutReady || !trails?.length)
2079
+ return;
2080
+ const tl = trails.find((t) => t.id === trailId);
2081
+ if (!tl)
2082
+ return;
2083
+ if (stepIndex != null && !tl.steps[stepIndex])
2084
+ return;
2085
+ appliedFocusedTrailStepRef.current = key;
2086
+ if (stepIndex == null) {
2087
+ focusTrailEdges(tl, !showFile);
2088
+ }
2089
+ else {
2090
+ focusTrailStep(tl, stepIndex, showFile);
2091
+ }
2092
+ }, [
2093
+ focusedTrailStep,
2094
+ layoutReady,
2095
+ trails,
2096
+ focusTrailEdges,
2097
+ focusTrailStep,
2098
+ clearTrailFocus,
2099
+ ]);
1957
2100
  useEffect(() => {
1958
2101
  return () => {
1959
2102
  if (pendingFocusFitRef.current != null) {
@@ -2380,7 +2523,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
2380
2523
  if (file)
2381
2524
  onOpenDeclarationFile(file);
2382
2525
  } })) : null;
2383
- const trailNavigation = trails && trails.length > 0 ? (_jsx(TrailsPanel, { drilldown: trailStepMode !== 'dim', trails: trails, expandedTrails: expandedTrails, focusedTrailId: sidebarTrail?.id ?? focusedTrailId, focusedStepIndex: !sidebarTrail || focusedTrailId === sidebarTrail.id ? focusedStepIndex : null, detailContent: sidebarPanel, hoveredTrailStep: hoveredTrailStep, onToggleCollapsed: toggleTrailCollapsed, onFocusFlow: focusTrailEdges, onClearFocus: clearTrailFocus, onFocusStep: focusTrailStep, onHoverStep: (tl, i) => {
2526
+ const trailNavigation = trails && trails.length > 0 ? (_jsx(TrailsPanel, { drilldown: trailStepMode !== 'dim', trails: trails, expandedTrails: expandedTrails, focusedTrailId: sidebarTrail?.id ?? focusedTrailId, focusedStepIndex: !sidebarTrail || focusedTrailId === sidebarTrail.id ? focusedStepIndex : null, proposedTrailIds: proposedTrailIds, proposedStepKeys: proposedStepKeys, stepChange: stepChange, showPreviousStep: showPreviousStep, onTogglePreviousStep: onTogglePreviousStep, detailContent: sidebarPanel, hoveredTrailStep: hoveredTrailStep, onToggleCollapsed: toggleTrailCollapsed, onFocusFlow: focusTrailEdges, onClearFocus: clearTrailFocus, onFocusStep: focusTrailStep, onHoverStep: (tl, i) => {
2384
2527
  cancelPendingHoverLeave();
2385
2528
  setHoveredTrailStep({ trailId: tl.id, stepIndex: i });
2386
2529
  onTrailStepHover?.({ trailId: tl.id, stepIndex: i });
@@ -2806,7 +2949,7 @@ export function SubsystemComponentGraph(props) {
2806
2949
  minHeight: 0,
2807
2950
  display: 'flex',
2808
2951
  flexDirection: 'column',
2809
- }, children: [!constructsOnly && !props.hideSidebar && (_jsxs("header", { style: {
2952
+ }, children: [!constructsOnly && !props.hideSidebar && !props.hideHeader && (_jsxs("header", { style: {
2810
2953
  flexShrink: 0,
2811
2954
  display: 'flex',
2812
2955
  alignItems: 'center',