@industry-theme/principal-view-panels 0.11.36 → 0.11.38

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.
@@ -1 +1 @@
1
- {"version":3,"file":"TraceExpansion.d.ts","sourceRoot":"","sources":["../../src/components/TraceExpansion.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,eAAe,CAAC;IACvB,KAAK,EAAE,KAAK,CAAC;IACb,eAAe,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACzG,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;CAC1B;AAsBD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAwPxD,CAAC"}
1
+ {"version":3,"file":"TraceExpansion.d.ts","sourceRoot":"","sources":["../../src/components/TraceExpansion.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,eAAe,CAAC;IACvB,KAAK,EAAE,KAAK,CAAC;IACb,eAAe,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACzG,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;CAC1B;AAsBD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAgRxD,CAAC"}
@@ -0,0 +1,56 @@
1
+ import React from 'react';
2
+ import type { ExtendedCanvas } from '@principal-ai/principal-view-core';
3
+ import type { ComposableExplanation, ExplanationStep } from './types';
4
+ import type { PanelComponentProps, PanelActions, DataSlice } from '../../types';
5
+ import type { FileTree } from '@principal-ai/repository-abstraction';
6
+ /**
7
+ * Render mode for the canvas
8
+ */
9
+ export type CanvasRenderMode = 'full' | 'story';
10
+ /**
11
+ * Typed context for ComposableExplanationPanel
12
+ */
13
+ export interface ComposableExplanationPanelContext {
14
+ fileTree: DataSlice<FileTree | null>;
15
+ }
16
+ /**
17
+ * Typed actions for ComposableExplanationPanel
18
+ */
19
+ export interface ComposableExplanationPanelActions extends PanelActions {
20
+ readFile: (path: string) => Promise<string>;
21
+ }
22
+ /**
23
+ * Props for ComposableExplanationPanel
24
+ */
25
+ export interface ComposableExplanationPanelProps extends PanelComponentProps<ComposableExplanationPanelActions, ComposableExplanationPanelContext> {
26
+ /** The explanation document to display */
27
+ explanation?: ComposableExplanation | null;
28
+ /** Pre-loaded canvases by alias (for Storybook or when canvases are already available) */
29
+ canvases?: Map<string, ExtendedCanvas>;
30
+ /** Legacy: Pre-loaded single canvas */
31
+ canvas?: ExtendedCanvas | null;
32
+ /** Initial step index */
33
+ initialStepIndex?: number;
34
+ /** Callback when step changes */
35
+ onStepChange?: (stepIndex: number, step: ExplanationStep) => void;
36
+ /** Callback when a node is clicked */
37
+ onNodeClick?: (nodeId: string, event: React.MouseEvent) => void;
38
+ /** Height of the step carousel */
39
+ carouselHeight?: number;
40
+ /** Render mode: 'full' shows entire canvas with highlights, 'story' shows only relevant fragments */
41
+ renderMode?: CanvasRenderMode;
42
+ /** Whether to animate transitions in story mode */
43
+ animateTransitions?: boolean;
44
+ }
45
+ /**
46
+ * ComposableExplanationPanel
47
+ *
48
+ * A panel for displaying agent-generated codebase explanations
49
+ * with a canvas viewer on top and step-through navigation below.
50
+ *
51
+ * Supports two render modes:
52
+ * - 'full': Shows the entire canvas with highlighted nodes (traditional)
53
+ * - 'story': Shows only the relevant canvas fragments for each step (focused)
54
+ */
55
+ export declare const ComposableExplanationPanel: React.FC<ComposableExplanationPanelProps>;
56
+ //# sourceMappingURL=ComposableExplanationPanel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComposableExplanationPanel.d.ts","sourceRoot":"","sources":["../../../src/panels/composable-explanation/ComposableExplanationPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAGjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAIxE,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EAGhB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAErE;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,OAAO,CAAC;AA0FhD;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD,QAAQ,EAAE,SAAS,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;CACtC;AAED;;GAEG;AACH,MAAM,WAAW,iCAAkC,SAAQ,YAAY;IACrE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC7C;AAED;;GAEG;AACH,MAAM,WAAW,+BACf,SAAQ,mBAAmB,CACzB,iCAAiC,EACjC,iCAAiC,CAClC;IACD,0CAA0C;IAC1C,WAAW,CAAC,EAAE,qBAAqB,GAAG,IAAI,CAAC;IAE3C,0FAA0F;IAC1F,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAEvC,uCAAuC;IACvC,MAAM,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IAE/B,yBAAyB;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,iCAAiC;IACjC,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,KAAK,IAAI,CAAC;IAElE,sCAAsC;IACtC,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IAEhE,kCAAkC;IAClC,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,qGAAqG;IACrG,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAE9B,mDAAmD;IACnD,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAWD;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,EAAE,KAAK,CAAC,EAAE,CAAC,+BAA+B,CAoehF,CAAC"}
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import type { ExplanationStep } from './types';
3
+ export interface StepCarouselProps {
4
+ /** Array of explanation steps */
5
+ steps: ExplanationStep[];
6
+ /** Currently active step index */
7
+ currentIndex: number;
8
+ /** Callback when step changes */
9
+ onStepChange: (index: number) => void;
10
+ /** Optional height override */
11
+ height?: number | string;
12
+ }
13
+ /**
14
+ * StepCarousel - Bottom navigation component for composable explanations
15
+ *
16
+ * Features:
17
+ * - Left/right arrow navigation
18
+ * - Step indicator dots
19
+ * - Current step content display
20
+ * - Smooth transitions between steps
21
+ */
22
+ export declare const StepCarousel: React.FC<StepCarouselProps>;
23
+ //# sourceMappingURL=StepCarousel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StepCarousel.d.ts","sourceRoot":"","sources":["../../../src/panels/composable-explanation/StepCarousel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAG3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,MAAM,WAAW,iBAAiB;IAChC,iCAAiC;IACjC,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,kCAAkC;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,iCAAiC;IACjC,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,+BAA+B;IAC/B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAyOpD,CAAC"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * StoryGraphRenderer
3
+ *
4
+ * A composite graph renderer that can display fragments from multiple canvases
5
+ * in a single view, with support for animated transitions between steps.
6
+ */
7
+ import React from 'react';
8
+ import type { ExtendedCanvas } from '@principal-ai/principal-view-core';
9
+ import { type BridgeEdge, type CompositionConfig } from './canvasFragments';
10
+ /**
11
+ * A single step's canvas configuration
12
+ */
13
+ export interface StoryStep {
14
+ /** Unique step ID */
15
+ id: string;
16
+ /** Nodes to show, grouped by canvas alias */
17
+ nodes: Record<string, string[]>;
18
+ /** Bridge edges for this step */
19
+ bridges?: BridgeEdge[];
20
+ /** Optional highlight node (primary focus) */
21
+ highlightNodeId?: string;
22
+ /** Optional layout override for this step */
23
+ layout?: Partial<CompositionConfig>;
24
+ }
25
+ export interface StoryGraphRendererProps {
26
+ /** Map of canvas alias to loaded canvas data */
27
+ canvases: Map<string, ExtendedCanvas>;
28
+ /** The steps defining what to show */
29
+ steps: StoryStep[];
30
+ /** Current step index */
31
+ currentStepIndex: number;
32
+ /** Callback when a node is clicked */
33
+ onNodeClick?: (nodeId: string, sourceAlias: string, originalId: string, event: React.MouseEvent) => void;
34
+ /** Whether to animate transitions */
35
+ animateTransitions?: boolean;
36
+ /** Animation duration in ms */
37
+ animationDuration?: number;
38
+ /** Whether to fit view to nodes on step change */
39
+ fitViewOnStepChange?: boolean;
40
+ /** Show minimap */
41
+ showMinimap?: boolean;
42
+ /** Show controls */
43
+ showControls?: boolean;
44
+ }
45
+ /**
46
+ * StoryGraphRenderer - Composite canvas renderer for story-driven explanations
47
+ */
48
+ export declare const StoryGraphRenderer: React.FC<StoryGraphRendererProps>;
49
+ /**
50
+ * Helper to convert explanation steps to story steps
51
+ */
52
+ export declare function explanationStepsToStorySteps(steps: Array<{
53
+ id: string;
54
+ ref?: string;
55
+ refs?: string[];
56
+ focus?: {
57
+ existing?: string[];
58
+ modified?: string[];
59
+ added?: string[];
60
+ };
61
+ }>, defaultCanvasAlias?: string): StoryStep[];
62
+ //# sourceMappingURL=StoryGraphRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StoryGraphRenderer.d.ts","sourceRoot":"","sources":["../../../src/panels/composable-explanation/StoryGraphRenderer.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAA4D,MAAM,OAAO,CAAC;AAEjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAGxE,OAAO,EAKL,KAAK,UAAU,EACf,KAAK,iBAAiB,EACvB,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,qBAAqB;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAChC,iCAAiC;IACjC,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC;IACvB,8CAA8C;IAC9C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,uBAAuB;IACtC,gDAAgD;IAChD,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACtC,sCAAsC;IACtC,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,yBAAyB;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,sCAAsC;IACtC,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IACzG,qCAAqC;IACrC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,+BAA+B;IAC/B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kDAAkD;IAClD,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,mBAAmB;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,oBAAoB;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAsNhE,CAAC;AAEF;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,KAAK,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE;QACN,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QACpB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QACpB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;KAClB,CAAC;CACH,CAAC,EACF,kBAAkB,GAAE,MAAe,GAClC,SAAS,EAAE,CAsDb"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Canvas Fragment Utilities
3
+ *
4
+ * Functions for extracting, composing, and laying out canvas fragments
5
+ * from multiple source canvases into a single composite view.
6
+ */
7
+ import type { ExtendedCanvas, ExtendedCanvasNode, ExtendedCanvasEdge } from '@principal-ai/principal-view-core';
8
+ /**
9
+ * A fragment extracted from a canvas
10
+ */
11
+ export interface CanvasFragment {
12
+ /** Source canvas alias */
13
+ sourceAlias: string;
14
+ /** Extracted nodes */
15
+ nodes: ExtendedCanvasNode[];
16
+ /** Extracted edges (only those connecting extracted nodes) */
17
+ edges: ExtendedCanvasEdge[];
18
+ /** Bounding box of the fragment */
19
+ bounds: {
20
+ minX: number;
21
+ minY: number;
22
+ maxX: number;
23
+ maxY: number;
24
+ width: number;
25
+ height: number;
26
+ };
27
+ }
28
+ /**
29
+ * A bridge edge connecting nodes from different canvases
30
+ */
31
+ export interface BridgeEdge {
32
+ id: string;
33
+ fromCanvas: string;
34
+ fromNode: string;
35
+ toCanvas: string;
36
+ toNode: string;
37
+ label?: string;
38
+ style?: 'solid' | 'dashed' | 'dotted';
39
+ }
40
+ /**
41
+ * Configuration for composing fragments
42
+ */
43
+ export interface CompositionConfig {
44
+ /** How to arrange multiple fragments */
45
+ layout: 'horizontal' | 'vertical' | 'preserve' | 'auto';
46
+ /** Gap between fragments when laid out */
47
+ fragmentGap: number;
48
+ /** Padding around the entire composition */
49
+ padding: number;
50
+ /** Whether to center the composition */
51
+ center: boolean;
52
+ }
53
+ /**
54
+ * Result of composing multiple fragments
55
+ */
56
+ export interface ComposedCanvas {
57
+ /** The composed canvas data */
58
+ canvas: ExtendedCanvas;
59
+ /** Map of original node IDs to composed node IDs */
60
+ nodeIdMap: Map<string, string>;
61
+ /** Source fragment info for each node */
62
+ nodeSourceMap: Map<string, {
63
+ alias: string;
64
+ originalId: string;
65
+ }>;
66
+ }
67
+ /**
68
+ * Default composition config
69
+ */
70
+ export declare const DEFAULT_COMPOSITION_CONFIG: CompositionConfig;
71
+ /**
72
+ * Extract a fragment from a canvas containing only specified nodes
73
+ * and edges connecting those nodes.
74
+ */
75
+ export declare function extractFragment(canvas: ExtendedCanvas, nodeIds: string[], sourceAlias: string): CanvasFragment;
76
+ /**
77
+ * Calculate the bounding box of a set of nodes
78
+ */
79
+ export declare function calculateBounds(nodes: ExtendedCanvasNode[]): CanvasFragment['bounds'];
80
+ /**
81
+ * Compose multiple canvas fragments into a single canvas
82
+ */
83
+ export declare function composeFragments(fragments: CanvasFragment[], bridgeEdges?: BridgeEdge[], config?: Partial<CompositionConfig>): ComposedCanvas;
84
+ /**
85
+ * Create a step-specific composed view from an explanation step
86
+ */
87
+ export interface StepCanvasConfig {
88
+ /** Node IDs to include, grouped by canvas alias */
89
+ nodes: Record<string, string[]>;
90
+ /** Bridge edges between canvases */
91
+ bridges?: BridgeEdge[];
92
+ /** Layout configuration */
93
+ layout?: Partial<CompositionConfig>;
94
+ }
95
+ /**
96
+ * Build a composed canvas for a specific step
97
+ */
98
+ export declare function buildStepCanvas(canvases: Map<string, ExtendedCanvas>, config: StepCanvasConfig): ComposedCanvas | null;
99
+ /**
100
+ * Calculate which nodes changed between two steps
101
+ * Useful for animating transitions
102
+ */
103
+ export interface StepTransition {
104
+ /** Nodes that are new in the next step */
105
+ entering: string[];
106
+ /** Nodes that are removed in the next step */
107
+ exiting: string[];
108
+ /** Nodes that remain (may change position) */
109
+ staying: string[];
110
+ }
111
+ export declare function calculateStepTransition(currentNodes: Set<string>, nextNodes: Set<string>): StepTransition;
112
+ //# sourceMappingURL=canvasFragments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canvasFragments.d.ts","sourceRoot":"","sources":["../../../src/panels/composable-explanation/canvasFragments.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,mCAAmC,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,0BAA0B;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,sBAAsB;IACtB,KAAK,EAAE,kBAAkB,EAAE,CAAC;IAC5B,8DAA8D;IAC9D,KAAK,EAAE,kBAAkB,EAAE,CAAC;IAC5B,mCAAmC;IACnC,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAA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QAAQ,CAAC,CA8BrF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,cAAc,EAAE,EAC3B,WAAW,GAAE,UAAU,EAAO,EAC9B,MAAM,GAAE,OAAO,CAAC,iBAAiB,CAAM,GACtC,cAAc,CA4FhB;AAmBD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAChC,oCAAoC;IACpC,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC;IACvB,2BAA2B;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACrC;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,EACrC,MAAM,EAAE,gBAAgB,GACvB,cAAc,GAAG,IAAI,CAwBvB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,8CAA8C;IAC9C,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,8CAA8C;IAC9C,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,EACzB,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,GACrB,cAAc,CAsBhB"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Composable Explanation Panel
3
+ *
4
+ * A panel for displaying agent-generated codebase explanations
5
+ * with a canvas viewer on top and step-through navigation below.
6
+ *
7
+ * Supports two render modes:
8
+ * - 'full': Shows the entire canvas with highlighted nodes
9
+ * - 'story': Shows only the relevant canvas fragments for each step (focused view)
10
+ */
11
+ export { ComposableExplanationPanel } from './ComposableExplanationPanel';
12
+ export type { ComposableExplanationPanelProps, ComposableExplanationPanelContext, ComposableExplanationPanelActions, CanvasRenderMode, } from './ComposableExplanationPanel';
13
+ export { StepCarousel } from './StepCarousel';
14
+ export type { StepCarouselProps } from './StepCarousel';
15
+ export { StoryGraphRenderer, explanationStepsToStorySteps } from './StoryGraphRenderer';
16
+ export type { StoryGraphRendererProps, StoryStep } from './StoryGraphRenderer';
17
+ export { extractFragment, composeFragments, buildStepCanvas, calculateBounds, calculateStepTransition, DEFAULT_COMPOSITION_CONFIG, } from './canvasFragments';
18
+ export type { CanvasFragment, BridgeEdge, CompositionConfig, ComposedCanvas, StepCanvasConfig, StepTransition, } from './canvasFragments';
19
+ export type { ComposableExplanation, ExplanationStep, ExplanationType, CanvasRegistry, EntityMapping, CanvasBridge, ViewFocus, FocusType, ProposedElement, LoadedCanvas, ExplanationViewerState, ElementRef, } from './types';
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/panels/composable-explanation/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,YAAY,EACV,+BAA+B,EAC/B,iCAAiC,EACjC,iCAAiC,EACjC,gBAAgB,GACjB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACxF,YAAY,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAE/E,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,cAAc,GACf,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EACV,qBAAqB,EACrB,eAAe,EACf,eAAe,EACf,cAAc,EACd,aAAa,EACb,YAAY,EACZ,SAAS,EACT,SAAS,EACT,eAAe,EACf,YAAY,EACZ,sBAAsB,EACtB,UAAU,GACX,MAAM,SAAS,CAAC"}
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Types for Composable Explanation Documents
3
+ *
4
+ * These types define the format for agent-generated codebase explanations
5
+ * that compose existing canvas visualizations with narrative content.
6
+ */
7
+ import type { ExtendedCanvas } from '@principal-ai/principal-view-core';
8
+ /**
9
+ * Reference to a canvas element using canvas-alias:element-id format
10
+ */
11
+ export type ElementRef = string;
12
+ /**
13
+ * Focus annotation types for visual treatment
14
+ */
15
+ export type FocusType = 'existing' | 'modified' | 'added' | 'removed' | 'error' | 'current';
16
+ /**
17
+ * Proposed element that doesn't exist in the canvas yet
18
+ */
19
+ export interface ProposedElement {
20
+ id: string;
21
+ after?: string;
22
+ label: string;
23
+ description?: string;
24
+ }
25
+ /**
26
+ * Focus configuration for a view
27
+ */
28
+ export interface ViewFocus {
29
+ /** Relevant existing elements - standard highlight */
30
+ existing?: string[];
31
+ /** Changed elements - yellow/amber */
32
+ modified?: string[];
33
+ /** New elements (proposed or actual) - green */
34
+ added?: string[];
35
+ /** Deleted elements - red/strikethrough */
36
+ removed?: string[];
37
+ /** Proposed elements that don't exist yet */
38
+ proposed?: ProposedElement[];
39
+ }
40
+ /**
41
+ * A single step in the explanation walkthrough
42
+ */
43
+ export interface ExplanationStep {
44
+ /** Unique ID for this step */
45
+ id: string;
46
+ /** Element reference to highlight (canvas-alias:element-id) */
47
+ ref?: ElementRef;
48
+ /** Array of element refs if highlighting multiple */
49
+ refs?: ElementRef[];
50
+ /** Narrative content for this step (markdown supported) */
51
+ content: string;
52
+ /** Optional source file reference */
53
+ source?: string;
54
+ /** Focus configuration for canvas highlighting */
55
+ focus?: ViewFocus;
56
+ /** Optional title for the step */
57
+ title?: string;
58
+ }
59
+ /**
60
+ * Canvas registry mapping aliases to file paths
61
+ */
62
+ export interface CanvasRegistry {
63
+ [alias: string]: string;
64
+ }
65
+ /**
66
+ * Entity mapping showing same logical entity across canvases
67
+ */
68
+ export interface EntityMapping {
69
+ [entityId: string]: {
70
+ description: string;
71
+ occurrences: ElementRef[];
72
+ };
73
+ }
74
+ /**
75
+ * Cross-canvas bridge connection
76
+ */
77
+ export interface CanvasBridge {
78
+ id: string;
79
+ from: ElementRef;
80
+ to: ElementRef;
81
+ label?: string;
82
+ type?: 'sync' | 'async' | 'event';
83
+ }
84
+ /**
85
+ * Explanation document types
86
+ */
87
+ export type ExplanationType = 'code-review' | 'design-spec' | 'exploration' | 'incident-analysis' | 'onboarding' | 'impact-analysis';
88
+ /**
89
+ * Main explanation document structure
90
+ */
91
+ export interface ComposableExplanation {
92
+ /** Document type */
93
+ type: ExplanationType;
94
+ /** Semantic version */
95
+ version: string;
96
+ /** Document title */
97
+ title: string;
98
+ /** Optional summary/description */
99
+ summary?: string;
100
+ /** Question being answered (for exploration type) */
101
+ question?: string;
102
+ /** Canvas registry - aliases to file paths */
103
+ canvases: CanvasRegistry;
104
+ /** Entity mappings across canvases */
105
+ entities?: EntityMapping;
106
+ /** Cross-canvas bridges */
107
+ bridges?: CanvasBridge[];
108
+ /** Scope of the explanation */
109
+ scope?: {
110
+ files?: string[];
111
+ areas?: string[];
112
+ };
113
+ /** The walkthrough steps */
114
+ steps: ExplanationStep[];
115
+ /** Related resources */
116
+ related?: {
117
+ scenarios?: string[];
118
+ sources?: string[];
119
+ workflows?: string[];
120
+ };
121
+ }
122
+ /**
123
+ * Loaded canvas data with alias
124
+ */
125
+ export interface LoadedCanvas {
126
+ alias: string;
127
+ path: string;
128
+ canvas: ExtendedCanvas;
129
+ }
130
+ /**
131
+ * Runtime state for the explanation viewer
132
+ */
133
+ export interface ExplanationViewerState {
134
+ /** Currently active step index */
135
+ currentStepIndex: number;
136
+ /** Loaded canvases by alias */
137
+ loadedCanvases: Map<string, LoadedCanvas>;
138
+ /** Currently highlighted node IDs */
139
+ highlightedNodeIds: string[];
140
+ /** Active node IDs (all nodes in current step's focus) */
141
+ activeNodeIds: string[];
142
+ /** Loading state */
143
+ loading: boolean;
144
+ /** Error message if any */
145
+ error: string | null;
146
+ }
147
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/panels/composable-explanation/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAoB,MAAM,mCAAmC,CAAC;AAE1F;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AAE5F;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,sDAAsD;IACtD,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,sCAAsC;IACtC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,2CAA2C;IAC3C,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,8BAA8B;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,+DAA+D;IAC/D,GAAG,CAAC,EAAE,UAAU,CAAC;IACjB,qDAAqD;IACrD,IAAI,CAAC,EAAE,UAAU,EAA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IAEzB,+BAA+B;IAC/B,KAAK,CAAC,EAAE;QACN,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;KAClB,CAAC;IAEF,4BAA4B;IAC5B,KAAK,EAAE,eAAe,EAAE,CAAC;IAEzB,wBAAwB;IACxB,OAAO,CAAC,EAAE;QACR,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;KACtB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,cAAc,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,kCAAkC;IAClC,gBAAgB,EAAE,MAAM,CAAC;IACzB,+BAA+B;IAC/B,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC1C,qCAAqC;IACrC,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,0DAA0D;IAC1D,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,oBAAoB;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,2BAA2B;IAC3B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB"}
@@ -100291,6 +100291,19 @@ const TraceExpansion = ({
100291
100291
  onWorkflowClick,
100292
100292
  onSpanClick
100293
100293
  }) => {
100294
+ const spanIndexMap = useMemo(() => {
100295
+ var _a;
100296
+ const map2 = /* @__PURE__ */ new Map();
100297
+ let index2 = 0;
100298
+ for (const resourceSpan of ((_a = trace.otlpData) == null ? void 0 : _a.resourceSpans) || []) {
100299
+ for (const scopeSpan of resourceSpan.scopeSpans || []) {
100300
+ for (const span of scopeSpan.spans || []) {
100301
+ map2.set(span.spanId, index2++);
100302
+ }
100303
+ }
100304
+ }
100305
+ return map2;
100306
+ }, [trace.otlpData]);
100294
100307
  const sortedSpans = useMemo(() => {
100295
100308
  var _a, _b, _c, _d;
100296
100309
  const spans = [];
@@ -100349,8 +100362,14 @@ const TraceExpansion = ({
100349
100362
  ...span,
100350
100363
  depth: getDepth(span.spanId)
100351
100364
  }));
100352
- return spansWithDepth.sort((a, b) => a.timestamp - b.timestamp);
100353
- }, [trace.scenarioMatches, trace.storyboardMatches, trace.unmatchedSpans]);
100365
+ return spansWithDepth.sort((a, b) => {
100366
+ const timeDiff = a.timestamp - b.timestamp;
100367
+ if (timeDiff !== 0) return timeDiff;
100368
+ const indexA = spanIndexMap.get(a.spanId) ?? Infinity;
100369
+ const indexB = spanIndexMap.get(b.spanId) ?? Infinity;
100370
+ return indexA - indexB;
100371
+ });
100372
+ }, [trace.scenarioMatches, trace.storyboardMatches, trace.unmatchedSpans, spanIndexMap]);
100354
100373
  const hasAnyMatches = sortedSpans.length > 0;
100355
100374
  return /* @__PURE__ */ jsxs(
100356
100375
  "div",
@@ -100425,7 +100444,7 @@ const TraceExpansion = ({
100425
100444
  {
100426
100445
  style: {
100427
100446
  fontSize: theme2.fontSizes[1],
100428
- color: span.reason.includes("No storyboards found for scope") ? theme2.colors.error || "#ef4444" : theme2.colors.textMuted,
100447
+ color: span.reason.includes("not registered in any owned-scopes") || span.reason.includes("has no storyboards") ? theme2.colors.error || "#ef4444" : theme2.colors.textMuted,
100429
100448
  marginLeft: theme2.space[2],
100430
100449
  fontStyle: "italic"
100431
100450
  },
@@ -100683,7 +100702,7 @@ const TraceList = ({
100683
100702
  display: "flex",
100684
100703
  alignItems: "center",
100685
100704
  gap: theme2.space[1],
100686
- padding: `${theme2.space[1]} ${theme2.space[2]}`,
100705
+ padding: `${theme2.space[1]}px ${theme2.space[2]}px`,
100687
100706
  fontSize: theme2.fontSizes[1],
100688
100707
  fontFamily: theme2.fonts.body,
100689
100708
  color: theme2.colors.error,