@principal-ai/principal-view-react 0.7.40 → 0.8.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.
Files changed (44) hide show
  1. package/dist/components/EdgeInfoPanel.d.ts.map +1 -1
  2. package/dist/components/EdgeInfoPanel.js +18 -12
  3. package/dist/components/EdgeInfoPanel.js.map +1 -1
  4. package/dist/components/NodeInfoPanel.d.ts.map +1 -1
  5. package/dist/components/NodeInfoPanel.js +46 -30
  6. package/dist/components/NodeInfoPanel.js.map +1 -1
  7. package/dist/components/NodeTooltip.d.ts.map +1 -1
  8. package/dist/components/NodeTooltip.js +11 -6
  9. package/dist/components/NodeTooltip.js.map +1 -1
  10. package/dist/components/SelectionSidebar.d.ts.map +1 -1
  11. package/dist/components/SelectionSidebar.js +24 -13
  12. package/dist/components/SelectionSidebar.js.map +1 -1
  13. package/dist/edges/CustomEdge.d.ts.map +1 -1
  14. package/dist/edges/CustomEdge.js +8 -4
  15. package/dist/edges/CustomEdge.js.map +1 -1
  16. package/dist/nodes/CustomNode.d.ts.map +1 -1
  17. package/dist/nodes/CustomNode.js +32 -19
  18. package/dist/nodes/CustomNode.js.map +1 -1
  19. package/dist/utils/orientationUtils.d.ts +1 -1
  20. package/dist/utils/orientationUtils.d.ts.map +1 -1
  21. package/package.json +2 -2
  22. package/src/components/EdgeInfoPanel.tsx +20 -14
  23. package/src/components/NodeInfoPanel.tsx +48 -32
  24. package/src/components/NodeTooltip.tsx +11 -6
  25. package/src/components/SelectionSidebar.tsx +24 -13
  26. package/src/edges/CustomEdge.tsx +8 -4
  27. package/src/nodes/CustomNode.tsx +32 -19
  28. package/src/utils/orientationUtils.ts +1 -1
  29. package/dist/components/NarrativeRenderer.d.ts +0 -19
  30. package/dist/components/NarrativeRenderer.d.ts.map +0 -1
  31. package/dist/components/NarrativeRenderer.js +0 -103
  32. package/dist/components/NarrativeRenderer.js.map +0 -1
  33. package/dist/components/TestEventPanel.d.ts +0 -44
  34. package/dist/components/TestEventPanel.d.ts.map +0 -1
  35. package/dist/components/TestEventPanel.js +0 -277
  36. package/dist/components/TestEventPanel.js.map +0 -1
  37. package/dist/utils/narrative-converter.d.ts +0 -45
  38. package/dist/utils/narrative-converter.d.ts.map +0 -1
  39. package/dist/utils/narrative-converter.js +0 -121
  40. package/dist/utils/narrative-converter.js.map +0 -1
  41. package/dist/utils/narrative-loader.d.ts +0 -53
  42. package/dist/utils/narrative-loader.d.ts.map +0 -1
  43. package/dist/utils/narrative-loader.js +0 -163
  44. package/dist/utils/narrative-loader.js.map +0 -1
@@ -1,103 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useMemo } from 'react';
3
- import { renderNarrative } from '@principal-ai/principal-view-core/browser';
4
- import { useTheme } from '@principal-ade/industry-theme';
5
- /**
6
- * Renders OTEL events as a human-readable narrative using a template
7
- */
8
- export const NarrativeRenderer = ({ template, events, className, style, showMetadata = false, }) => {
9
- const { theme } = useTheme();
10
- // Render the narrative
11
- const result = useMemo(() => {
12
- try {
13
- return renderNarrative(template, events);
14
- }
15
- catch (error) {
16
- return {
17
- text: `Error rendering narrative: ${error instanceof Error ? error.message : 'Unknown error'}`,
18
- scenarioId: 'error',
19
- metadata: {
20
- eventCount: events.length,
21
- spanCount: 0,
22
- logCount: 0,
23
- },
24
- };
25
- }
26
- }, [template, events]);
27
- // Parse narrative text to add syntax highlighting
28
- const renderHighlightedText = (text) => {
29
- const lines = text.split('\n');
30
- return lines.map((line, idx) => {
31
- // Determine line style based on content
32
- let lineStyle = {};
33
- let content = line;
34
- // Status indicators (✅ ❌ ⚠️ 📋)
35
- if (/^[✅❌⚠️📋]/.test(line)) {
36
- lineStyle = {
37
- fontWeight: 'bold',
38
- fontSize: '16px',
39
- marginTop: idx > 0 ? '8px' : '0',
40
- marginBottom: '4px',
41
- };
42
- }
43
- // Separators (━━━━)
44
- else if (/^━+/.test(line)) {
45
- lineStyle = {
46
- color: theme.colors.border,
47
- opacity: 0.6,
48
- };
49
- }
50
- // Arrow items (→)
51
- else if (/^(\s*)→/.test(line)) {
52
- const indent = line.match(/^(\s*)/)?.[1] || '';
53
- lineStyle = {
54
- color: theme.colors.text,
55
- fontWeight: indent.length === 0 ? 'bold' : 'normal',
56
- marginTop: indent.length === 0 ? '12px' : '4px',
57
- };
58
- }
59
- // Bullet items (•)
60
- else if (/^\s+•/.test(line)) {
61
- lineStyle = {
62
- color: theme.colors.textMuted,
63
- paddingLeft: '8px',
64
- };
65
- }
66
- // Section headers (UPPERCASE at start)
67
- else if (/^[A-Z\s]+:/.test(line)) {
68
- lineStyle = {
69
- fontWeight: 'bold',
70
- marginTop: '8px',
71
- color: theme.colors.text,
72
- };
73
- }
74
- return (_jsx("div", { style: lineStyle, children: content }, idx));
75
- });
76
- };
77
- return (_jsxs("div", { className: className, style: {
78
- width: '100%',
79
- height: '100%',
80
- display: 'flex',
81
- flexDirection: 'column',
82
- ...style,
83
- }, children: [_jsx("div", { style: {
84
- flex: 1,
85
- overflow: 'auto',
86
- padding: '20px',
87
- fontFamily: theme.fonts.monospace,
88
- fontSize: '14px',
89
- lineHeight: '1.6',
90
- color: theme.colors.text,
91
- backgroundColor: theme.colors.background,
92
- whiteSpace: 'pre-wrap',
93
- wordWrap: 'break-word',
94
- }, children: renderHighlightedText(result.text) }), showMetadata && (_jsxs("div", { style: {
95
- borderTop: `1px solid ${theme.colors.border}`,
96
- padding: '12px 20px',
97
- backgroundColor: theme.colors.surface,
98
- fontSize: '12px',
99
- color: theme.colors.textMuted,
100
- fontFamily: theme.fonts.monospace,
101
- }, children: [_jsxs("div", { style: { marginBottom: '4px' }, children: [_jsx("strong", { style: { color: theme.colors.text }, children: "Template:" }), " ", template.name] }), _jsxs("div", { style: { marginBottom: '4px' }, children: [_jsx("strong", { style: { color: theme.colors.text }, children: "Scenario:" }), " ", result.scenarioId] }), _jsxs("div", { children: [_jsx("strong", { style: { color: theme.colors.text }, children: "Events:" }), " ", result.metadata.eventCount, " total (", result.metadata.spanCount, " spans, ", result.metadata.logCount, " logs)"] }), result.metadata.timeRange && (_jsxs("div", { style: { marginTop: '4px' }, children: [_jsx("strong", { style: { color: theme.colors.text }, children: "Duration:" }), ' ', Number(result.metadata.timeRange.end) - Number(result.metadata.timeRange.start), "ms"] }))] }))] }));
102
- };
103
- //# sourceMappingURL=NarrativeRenderer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NarrativeRenderer.js","sourceRoot":"","sources":["../../src/components/NarrativeRenderer.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAE5E,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAmBzD;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAqC,CAAC,EAClE,QAAQ,EACR,MAAM,EACN,SAAS,EACT,KAAK,EACL,YAAY,GAAG,KAAK,GACrB,EAAE,EAAE;IACH,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ,EAAE,CAAC;IAE7B,uBAAuB;IACvB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE;QAC1B,IAAI;YACF,OAAO,eAAe,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;SAC1C;QAAC,OAAO,KAAK,EAAE;YACd,OAAO;gBACL,IAAI,EAAE,8BAA8B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE;gBAC9F,UAAU,EAAE,OAAO;gBACnB,QAAQ,EAAE;oBACR,UAAU,EAAE,MAAM,CAAC,MAAM;oBACzB,SAAS,EAAE,CAAC;oBACZ,QAAQ,EAAE,CAAC;iBACZ;aACF,CAAC;SACH;IACH,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IAEvB,kDAAkD;IAClD,MAAM,qBAAqB,GA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AAE,KAAK,CAAC,MAAM,CAAC,SAAS;oBAC7B,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS;iBAClC,aAED,eAAK,KAAK,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,aACjC,iBAAQ,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,0BAAoB,OAAE,QAAQ,CAAC,IAAI,IAC1E,EACN,eAAK,KAAK,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,aACjC,iBAAQ,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,0BAAoB,OAAE,MAAM,CAAC,UAAU,IAC9E,EACN,0BACE,iBAAQ,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,wBAAkB,OAAE,MAAM,CAAC,QAAQ,CAAC,UAAU,cACvF,MAAM,CAAC,QAAQ,CAAC,SAAS,cAAU,MAAM,CAAC,QAAQ,CAAC,QAAQ,cACzD,EACL,MAAM,CAAC,QAAQ,CAAC,SAAS,IAAI,CAC5B,eAAK,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,aAC9B,iBAAQ,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,0BAAoB,EAAC,GAAG,EAClE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,UAC5E,CACP,IACG,CACP,IACG,CACP,CAAC;AACJ,CAAC,CAAC"}
@@ -1,44 +0,0 @@
1
- import React from 'react';
2
- import type { NarrativeTemplate, JsonValue } from '@principal-ai/principal-view-core/browser';
3
- interface SpanEvent {
4
- time: number;
5
- name: string;
6
- attributes: Record<string, string | number | boolean>;
7
- }
8
- interface TestSpan {
9
- id: string;
10
- name: string;
11
- startTime: number;
12
- endTime?: number;
13
- duration?: number;
14
- attributes: Record<string, string | number | boolean>;
15
- events: SpanEvent[];
16
- status: 'OK' | 'ERROR';
17
- errorMessage?: string;
18
- }
19
- export type OtelSeverity = 'TRACE' | 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' | 'FATAL';
20
- export interface OtelLog {
21
- timestamp: number;
22
- severity: OtelSeverity;
23
- body: string | Record<string, unknown>;
24
- resource: Record<string, string | number>;
25
- attributes?: Record<string, JsonValue>;
26
- traceId?: string;
27
- spanId?: string;
28
- }
29
- export type ViewMode = 'raw' | 'narrative';
30
- export interface TestEventPanelProps {
31
- spans: TestSpan[];
32
- logs?: OtelLog[];
33
- currentSpanIndex: number;
34
- currentEventIndex: number;
35
- highlightedPhase?: string;
36
- onSpanIndexChange?: (index: number) => void;
37
- viewMode?: ViewMode;
38
- narrativeTemplate?: NarrativeTemplate;
39
- onViewModeChange?: (mode: ViewMode) => void;
40
- showNarrativeMetadata?: boolean;
41
- }
42
- export declare const TestEventPanel: React.FC<TestEventPanelProps>;
43
- export {};
44
- //# sourceMappingURL=TestEventPanel.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TestEventPanel.d.ts","sourceRoot":"","sources":["../../src/components/TestEventPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAIjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,2CAA2C,CAAC;AAI9F,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;CACvD;AAED,UAAU,QAAQ;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CA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C;CACjC;AA2BD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA4exD,CAAC"}
@@ -1,277 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState, useMemo } from 'react';
3
- import { useTheme } from '@principal-ade/industry-theme';
4
- import { HelpCircle } from 'lucide-react';
5
- import yaml from 'js-yaml';
6
- import { NarrativeRenderer } from './NarrativeRenderer';
7
- import { convertToOtelEvents } from '../utils/narrative-converter';
8
- // Helper functions for log severity
9
- function getSeverityColor(severity) {
10
- const colors = {
11
- TRACE: '#6b7280',
12
- DEBUG: '#60a5fa',
13
- INFO: '#4ade80',
14
- WARN: '#fbbf24',
15
- ERROR: '#f87171',
16
- FATAL: '#dc2626',
17
- };
18
- return colors[severity] || '#9ca3af';
19
- }
20
- function getSeverityIcon(severity) {
21
- const icons = {
22
- TRACE: '○',
23
- DEBUG: '◐',
24
- INFO: '●',
25
- WARN: '⚠',
26
- ERROR: '✕',
27
- FATAL: '☠',
28
- };
29
- return icons[severity] || '•';
30
- }
31
- export const TestEventPanel = ({ spans, logs = [], currentSpanIndex, currentEventIndex, highlightedPhase, onSpanIndexChange, viewMode = 'raw', narrativeTemplate, onViewModeChange, showNarrativeMetadata = false, }) => {
32
- const { theme } = useTheme();
33
- const [showHelp, setShowHelp] = useState(false);
34
- const currentSpan = spans[currentSpanIndex];
35
- // Convert current span to OtelEvents for narrative rendering
36
- const otelEvents = useMemo(() => {
37
- if (!currentSpan || viewMode !== 'narrative')
38
- return [];
39
- return convertToOtelEvents(currentSpan, logs);
40
- }, [currentSpan, logs, viewMode]);
41
- const handlePrevTest = () => {
42
- if (currentSpanIndex > 0 && onSpanIndexChange) {
43
- onSpanIndexChange(currentSpanIndex - 1);
44
- }
45
- };
46
- const handleNextTest = () => {
47
- if (currentSpanIndex < spans.length - 1 && onSpanIndexChange) {
48
- onSpanIndexChange(currentSpanIndex + 1);
49
- }
50
- };
51
- // Build interleaved timeline
52
- const timeline = useMemo(() => {
53
- if (!currentSpan)
54
- return [];
55
- const items = [
56
- // Span events
57
- ...currentSpan.events.slice(0, currentEventIndex + 1).map((event) => ({
58
- type: 'event',
59
- time: event.time,
60
- name: event.name,
61
- attributes: event.attributes,
62
- })),
63
- // Correlated logs (matching current span's traceId)
64
- ...logs
65
- .filter((log) => log.traceId === currentSpan.id)
66
- .map((log) => ({
67
- type: 'log',
68
- time: typeof log.timestamp === 'number' ? log.timestamp : new Date(log.timestamp).getTime(),
69
- severity: log.severity,
70
- body: log.body,
71
- resource: log.resource,
72
- attributes: log.attributes,
73
- })),
74
- ].sort((a, b) => a.time - b.time);
75
- return items;
76
- }, [currentSpan, currentEventIndex, logs]);
77
- return (_jsxs("div", { style: {
78
- width: '100%',
79
- height: '100%',
80
- backgroundColor: theme.colors.background,
81
- color: theme.colors.text,
82
- fontFamily: theme.fonts.monospace,
83
- fontSize: '14px',
84
- boxSizing: 'border-box',
85
- display: 'flex',
86
- flexDirection: 'column',
87
- }, children: [_jsxs("div", { style: {
88
- padding: '20px 20px 0 20px',
89
- backgroundColor: theme.colors.background,
90
- borderBottom: `1px solid ${theme.colors.border}`,
91
- flexShrink: 0,
92
- }, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: '12px' }, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: '12px' }, children: [_jsx("button", { onClick: handlePrevTest, disabled: currentSpanIndex === 0, style: {
93
- padding: '4px 12px',
94
- background: theme.colors.surface,
95
- border: `1px solid ${theme.colors.border}`,
96
- borderRadius: '4px',
97
- color: currentSpanIndex === 0 ? theme.colors.textMuted : theme.colors.text,
98
- cursor: currentSpanIndex === 0 ? 'not-allowed' : 'pointer',
99
- fontSize: '14px',
100
- opacity: currentSpanIndex === 0 ? 0.5 : 1,
101
- }, children: "\u2190 Prev" }), _jsxs("div", { style: { fontSize: '14px', fontWeight: 'bold' }, children: ["Test ", currentSpanIndex + 1, " of ", spans.length] }), _jsx("button", { onClick: handleNextTest, disabled: currentSpanIndex === spans.length - 1, style: {
102
- padding: '4px 12px',
103
- background: theme.colors.surface,
104
- border: `1px solid ${theme.colors.border}`,
105
- borderRadius: '4px',
106
- color: currentSpanIndex === spans.length - 1 ? theme.colors.textMuted : theme.colors.text,
107
- cursor: currentSpanIndex === spans.length - 1 ? 'not-allowed' : 'pointer',
108
- fontSize: '14px',
109
- opacity: currentSpanIndex === spans.length - 1 ? 0.5 : 1,
110
- }, children: "Next \u2192" })] }), _jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: '12px' }, children: [_jsx("div", { style: { fontSize: '13px', color: theme.colors.textMuted }, children: _jsx("span", { style: { color: '#4ade80' }, children: "All Passed \u2713" }) }), _jsx("button", { onClick: () => setShowHelp(true), style: {
111
- background: 'transparent',
112
- border: 'none',
113
- cursor: 'pointer',
114
- padding: '4px',
115
- display: 'flex',
116
- alignItems: 'center',
117
- color: theme.colors.textMuted,
118
- }, onMouseEnter: (e) => {
119
- e.currentTarget.style.color = theme.colors.text;
120
- }, onMouseLeave: (e) => {
121
- e.currentTarget.style.color = theme.colors.textMuted;
122
- }, children: _jsx(HelpCircle, { size: 20 }) })] })] }), narrativeTemplate && onViewModeChange && (_jsxs("div", { style: { display: 'flex', gap: '8px', marginBottom: '12px' }, children: [_jsx("button", { onClick: () => onViewModeChange('raw'), style: {
123
- padding: '6px 12px',
124
- background: viewMode === 'raw' ? theme.colors.primary : theme.colors.surface,
125
- border: `1px solid ${theme.colors.border}`,
126
- borderRadius: '4px',
127
- color: viewMode === 'raw' ? '#ffffff' : theme.colors.text,
128
- cursor: 'pointer',
129
- fontSize: '13px',
130
- fontWeight: viewMode === 'raw' ? 'bold' : 'normal',
131
- }, children: "Raw Events" }), _jsx("button", { onClick: () => onViewModeChange('narrative'), style: {
132
- padding: '6px 12px',
133
- background: viewMode === 'narrative' ? theme.colors.primary : theme.colors.surface,
134
- border: `1px solid ${theme.colors.border}`,
135
- borderRadius: '4px',
136
- color: viewMode === 'narrative' ? '#ffffff' : theme.colors.text,
137
- cursor: 'pointer',
138
- fontSize: '13px',
139
- fontWeight: viewMode === 'narrative' ? 'bold' : 'normal',
140
- }, children: "Narrative" })] })), _jsxs("div", { style: { fontSize: '13px', color: theme.colors.textMuted, marginBottom: '15px' }, children: ["Test: ", currentSpan?.name || 'Loading...'] })] }), showHelp && (_jsx("div", { style: {
141
- position: 'fixed',
142
- top: 0,
143
- left: 0,
144
- right: 0,
145
- bottom: 0,
146
- backgroundColor: 'rgba(0, 0, 0, 0.7)',
147
- display: 'flex',
148
- alignItems: 'center',
149
- justifyContent: 'center',
150
- zIndex: 9999,
151
- }, onClick: () => setShowHelp(false), children: _jsxs("div", { style: {
152
- backgroundColor: theme.colors.background,
153
- color: theme.colors.text,
154
- padding: '24px',
155
- borderRadius: '8px',
156
- maxWidth: '600px',
157
- border: `1px solid ${theme.colors.border}`,
158
- }, onClick: (e) => e.stopPropagation(), children: [_jsx("div", { style: { fontWeight: 'bold', fontSize: '18px', marginBottom: '16px' }, children: "How to Read This Panel" }), _jsxs("div", { style: { fontSize: '14px', marginBottom: '16px', lineHeight: '1.6' }, children: [_jsx("p", { style: { marginBottom: '12px' }, children: _jsx("strong", { children: "Timeline shows both events and logs:" }) }), _jsxs("ul", { style: { marginLeft: '20px', marginBottom: '16px' }, children: [_jsxs("li", { style: { marginBottom: '8px' }, children: [_jsx("span", { style: { color: '#f59e0b' }, children: "\uD83D\uDFE7 Events" }), " - Structured lifecycle points"] }), _jsxs("li", { style: { marginBottom: '8px' }, children: [_jsx("span", { style: { color: '#4ade80' }, children: "\u25CF Logs" }), " - Standalone log records (color = severity)"] }), _jsx("li", { style: { marginBottom: '8px' }, children: _jsx("span", { style: { color: '#60a5fa' }, children: "Blue = Test file" }) }), _jsx("li", { children: _jsx("span", { style: { color: '#4ade80' }, children: "Green \u2192 Code under test" }) })] })] }), _jsx("button", { onClick: () => setShowHelp(false), style: {
159
- padding: '8px 16px',
160
- backgroundColor: theme.colors.primary,
161
- color: '#ffffff',
162
- border: 'none',
163
- borderRadius: '4px',
164
- cursor: 'pointer',
165
- fontSize: '14px',
166
- fontWeight: 500,
167
- }, children: "Got it" })] }) })), _jsxs("div", { style: {
168
- flex: 1,
169
- overflow: 'auto',
170
- padding: viewMode === 'narrative' ? '0' : '20px',
171
- }, children: [viewMode === 'narrative' && narrativeTemplate && currentSpan ? (_jsx(NarrativeRenderer, { template: narrativeTemplate, events: otelEvents, showMetadata: showNarrativeMetadata })) : viewMode === 'narrative' && !narrativeTemplate ? (_jsxs("div", { style: {
172
- padding: '40px 20px',
173
- textAlign: 'center',
174
- color: theme.colors.textMuted,
175
- }, children: [_jsx("div", { style: { fontSize: '16px', marginBottom: '12px' }, children: "\u24D8 No narrative template available" }), _jsxs("div", { style: { fontSize: '14px', lineHeight: '1.6' }, children: ["Create a narrative template to see a human-readable", _jsx("br", {}), "summary of this test execution."] }), _jsx("button", { onClick: () => onViewModeChange?.('raw'), style: {
176
- marginTop: '20px',
177
- padding: '8px 16px',
178
- background: theme.colors.primary,
179
- color: '#ffffff',
180
- border: 'none',
181
- borderRadius: '4px',
182
- cursor: 'pointer',
183
- fontSize: '14px',
184
- }, children: "View Raw Events" })] })) : null, viewMode === 'raw' && currentSpan && (_jsx("div", { children: timeline.map((item, idx) => {
185
- if (item.type === 'event') {
186
- // SPAN EVENT RENDERING
187
- const filepath = item.attributes?.['code.filepath'];
188
- const lineno = item.attributes?.['code.lineno'];
189
- const isCodeUnderTest = filepath && filepath !== 'GraphConverter.test.ts';
190
- // Determine which phase this event belongs to
191
- const eventPhase = item.name?.split('.')[0]; // 'setup', 'execution', 'assertion'
192
- const isHighlighted = highlightedPhase === eventPhase;
193
- return (_jsxs("div", { style: {
194
- marginBottom: '12px',
195
- paddingBottom: '12px',
196
- paddingLeft: '12px',
197
- borderBottom: idx < timeline.length - 1 ? `1px solid ${theme.colors.border}` : 'none',
198
- borderLeft: '3px solid #f59e0b',
199
- opacity: highlightedPhase && !isHighlighted ? 0.4 : 1,
200
- transition: 'opacity 0.2s ease',
201
- transform: isHighlighted ? 'scale(1.02)' : 'scale(1)',
202
- backgroundColor: isHighlighted ? theme.colors.surface : 'transparent',
203
- padding: isHighlighted ? '8px 8px 8px 12px' : '0 0 12px 12px',
204
- borderRadius: '4px',
205
- }, children: [_jsxs("div", { style: {
206
- display: 'flex',
207
- justifyContent: 'space-between',
208
- alignItems: 'center',
209
- marginBottom: '4px',
210
- gap: '8px',
211
- }, children: [_jsxs("div", { style: { color: '#f59e0b', fontSize: '13px', fontWeight: 'bold', flexShrink: 0 }, children: ["EVENT: ", item.name] }), filepath && (_jsxs("div", { style: {
212
- fontSize: '12px',
213
- color: isCodeUnderTest ? '#4ade80' : '#60a5fa',
214
- fontFamily: 'monospace',
215
- background: isCodeUnderTest ? '#064e3b' : '#1e3a8a',
216
- padding: '2px 6px',
217
- borderRadius: '3px',
218
- flexShrink: 1,
219
- minWidth: 0,
220
- overflow: 'hidden',
221
- textOverflow: 'ellipsis',
222
- whiteSpace: 'nowrap',
223
- }, children: [isCodeUnderTest && '→ ', filepath, ":", lineno] }))] }), _jsx("pre", { style: {
224
- background: theme.colors.surface,
225
- padding: '8px',
226
- borderRadius: '4px',
227
- margin: 0,
228
- fontSize: '13px',
229
- lineHeight: '1.5',
230
- overflow: 'auto',
231
- maxWidth: '100%',
232
- }, children: yaml.dump(Object.fromEntries(Object.entries(item.attributes || {}).filter(([key]) => key !== 'code.filepath' && key !== 'code.lineno')), { indent: 2, lineWidth: -1 }) })] }, idx));
233
- }
234
- else {
235
- // OTEL LOG RENDERING
236
- const serviceName = item.resource?.['service.name'];
237
- const severityColor = getSeverityColor(item.severity);
238
- return (_jsxs("div", { style: {
239
- marginBottom: '12px',
240
- paddingBottom: '12px',
241
- paddingLeft: '12px',
242
- borderBottom: idx < timeline.length - 1 ? `1px solid ${theme.colors.border}` : 'none',
243
- borderLeft: `3px solid ${severityColor}`,
244
- }, children: [_jsxs("div", { style: {
245
- display: 'flex',
246
- justifyContent: 'space-between',
247
- alignItems: 'center',
248
- marginBottom: '4px',
249
- }, children: [_jsxs("div", { style: { display: 'flex', gap: '8px', alignItems: 'center' }, children: [_jsx("span", { style: { fontSize: '16px' }, children: getSeverityIcon(item.severity) }), _jsxs("span", { style: {
250
- color: severityColor,
251
- fontSize: '13px',
252
- fontWeight: 'bold',
253
- }, children: ["LOG: ", item.severity] })] }), serviceName && (_jsx("div", { style: {
254
- fontSize: '12px',
255
- color: '#9ca3af',
256
- background: '#1e293b',
257
- padding: '2px 6px',
258
- borderRadius: '3px',
259
- }, children: serviceName }))] }), _jsx("div", { style: {
260
- background: theme.colors.surface,
261
- padding: '8px',
262
- borderRadius: '4px',
263
- marginBottom: item.attributes && Object.keys(item.attributes).length > 0 ? '8px' : '0',
264
- fontSize: '13px',
265
- }, children: typeof item.body === 'string' ? (item.body) : (_jsx("pre", { style: { margin: 0, fontSize: '13px', lineHeight: '1.5' }, children: yaml.dump(item.body, { indent: 2, lineWidth: -1 }) })) }), item.attributes && Object.keys(item.attributes).length > 0 && (_jsx("pre", { style: {
266
- background: theme.colors.surface,
267
- padding: '8px',
268
- borderRadius: '4px',
269
- margin: 0,
270
- fontSize: '12px',
271
- lineHeight: '1.5',
272
- opacity: 0.8,
273
- }, children: yaml.dump(item.attributes, { indent: 2, lineWidth: -1 }) }))] }, idx));
274
- }
275
- }) }))] })] }));
276
- };
277
- //# sourceMappingURL=TestEventPanel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TestEventPanel.js","sourceRoot":"","sources":["../../src/components/TestEventPanel.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,IAAI,MAAM,SAAS,CAAC;AAE3B,OAAO,EAAE,iBAAi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K,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,YAC3D,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,GAC/C,CACP,GACG,EAGL,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,CAC7D,cACE,KAAK,EAAE;gDACL,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO;gDAChC,OAAO,EAAE,KAAK;gDACd,YAAY,EAAE,KAAK;gDACnB,MAAM,EAAE,CAAC;gDACT,QAAQ,EAAE,MAAM;gDAChB,UAAU,EAAE,KAAK;gDACjB,OAAO,EAAE,GAAG;6CACb,YAEA,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,GACrD,CACP,KA9EI,GAAG,CA+EJ,CACP,CAAC;6BACH;wBACH,CAAC,CAAC,GACI,CACP,IACG,IACF,CACP,CAAC;AACJ,CAAC,CAAC"}
@@ -1,45 +0,0 @@
1
- /**
2
- * Utilities for converting TestEventPanel data to OtelEvent format
3
- * for use with the narrative renderer
4
- */
5
- import type { OtelEvent } from '@principal-ai/principal-view-core/browser';
6
- import type { OtelLog } from '../components/TestEventPanel';
7
- interface SpanEvent {
8
- time: number;
9
- name: string;
10
- attributes: Record<string, string | number | boolean>;
11
- }
12
- interface TestSpan {
13
- id: string;
14
- name: string;
15
- startTime: number;
16
- endTime?: number;
17
- duration?: number;
18
- attributes: Record<string, string | number | boolean>;
19
- events: SpanEvent[];
20
- status: 'OK' | 'ERROR';
21
- errorMessage?: string;
22
- }
23
- /**
24
- * Convert TestSpan and OtelLogs to OtelEvent array
25
- *
26
- * @param span - The test span to convert
27
- * @param logs - Optional OTEL logs to include
28
- * @returns Array of OtelEvents in chronological order
29
- */
30
- export declare function convertToOtelEvents(span: TestSpan, logs?: OtelLog[]): OtelEvent[];
31
- /**
32
- * Convert all TestSpans to OtelEvents
33
- *
34
- * @param spans - Array of test spans
35
- * @param logs - Optional OTEL logs to include
36
- * @returns Array of OtelEvents for all spans
37
- */
38
- export declare function convertAllSpansToOtelEvents(spans: TestSpan[], logs?: OtelLog[]): OtelEvent[];
39
- /**
40
- * Extract test result attributes from TestSpan
41
- * Useful for narrative templates that check assertions
42
- */
43
- export declare function extractTestAttributes(span: TestSpan): Record<string, unknown>;
44
- export {};
45
- //# sourceMappingURL=narrative-converter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"narrative-converter.d.ts","sourceRoot":"","sources":["../../src/utils/narrative-converter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,KAAK,EAAE,OAAO,EAAgB,MAAM,8BAA8B,CAAC;AAG1E,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;CACvD;AAED,UAAU,QAAQ;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;IACtD,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,MAAM,EAAE,IAAI,GAAG,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AA6DD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,GAAE,OAAO,EAAO,GAAG,SAAS,EAAE,CAerF;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,IAAI,GAAE,OAAO,EAAO,GAAG,SAAS,EAAE,CAchG;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAmB7E"}
@@ -1,121 +0,0 @@
1
- /**
2
- * Utilities for converting TestEventPanel data to OtelEvent format
3
- * for use with the narrative renderer
4
- */
5
- /**
6
- * Convert OtelSeverity to severity number (OpenTelemetry spec)
7
- */
8
- function severityToNumber(severity) {
9
- const severityMap = {
10
- TRACE: 1,
11
- DEBUG: 5,
12
- INFO: 9,
13
- WARN: 13,
14
- ERROR: 17,
15
- FATAL: 21,
16
- };
17
- return severityMap[severity] || 9;
18
- }
19
- /**
20
- * Convert TestSpan events to OtelEvent spans
21
- */
22
- function convertSpanEvents(span) {
23
- return span.events.map((event) => ({
24
- name: event.name,
25
- timestamp: event.time,
26
- type: 'span',
27
- spanId: span.id,
28
- traceId: span.id,
29
- attributes: event.attributes,
30
- }));
31
- }
32
- /**
33
- * Convert OtelLogs to OtelEvent logs
34
- */
35
- function convertLogs(logs) {
36
- return logs.map((log) => {
37
- // Filter out null values from attributes (OtelAttributeValue doesn't include null)
38
- const filterNullValues = (obj) => {
39
- if (!obj)
40
- return {};
41
- return Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== null));
42
- };
43
- return {
44
- name: 'log',
45
- timestamp: typeof log.timestamp === 'number' ? log.timestamp : new Date(log.timestamp).getTime(),
46
- type: 'log',
47
- spanId: log.spanId,
48
- traceId: log.traceId,
49
- severityText: log.severity,
50
- severityNumber: severityToNumber(log.severity),
51
- body: typeof log.body === 'string' ? log.body : JSON.stringify(log.body),
52
- attributes: {
53
- ...filterNullValues(log.attributes),
54
- ...filterNullValues(log.resource),
55
- },
56
- };
57
- });
58
- }
59
- /**
60
- * Convert TestSpan and OtelLogs to OtelEvent array
61
- *
62
- * @param span - The test span to convert
63
- * @param logs - Optional OTEL logs to include
64
- * @returns Array of OtelEvents in chronological order
65
- */
66
- export function convertToOtelEvents(span, logs = []) {
67
- const spanEvents = convertSpanEvents(span);
68
- // Filter logs for this specific span
69
- const spanLogs = logs.filter((log) => log.spanId === span.id || log.traceId === span.id);
70
- const logEvents = convertLogs(spanLogs);
71
- // Combine and sort by timestamp
72
- const allEvents = [...spanEvents, ...logEvents].sort((a, b) => {
73
- const aTime = typeof a.timestamp === 'number' ? a.timestamp : new Date(a.timestamp).getTime();
74
- const bTime = typeof b.timestamp === 'number' ? b.timestamp : new Date(b.timestamp).getTime();
75
- return aTime - bTime;
76
- });
77
- return allEvents;
78
- }
79
- /**
80
- * Convert all TestSpans to OtelEvents
81
- *
82
- * @param spans - Array of test spans
83
- * @param logs - Optional OTEL logs to include
84
- * @returns Array of OtelEvents for all spans
85
- */
86
- export function convertAllSpansToOtelEvents(spans, logs = []) {
87
- const allEvents = [];
88
- for (const span of spans) {
89
- const spanEvents = convertToOtelEvents(span, logs);
90
- allEvents.push(...spanEvents);
91
- }
92
- // Sort all events chronologically
93
- return allEvents.sort((a, b) => {
94
- const aTime = typeof a.timestamp === 'number' ? a.timestamp : new Date(a.timestamp).getTime();
95
- const bTime = typeof b.timestamp === 'number' ? b.timestamp : new Date(b.timestamp).getTime();
96
- return aTime - bTime;
97
- });
98
- }
99
- /**
100
- * Extract test result attributes from TestSpan
101
- * Useful for narrative templates that check assertions
102
- */
103
- export function extractTestAttributes(span) {
104
- // Find assertion.complete event
105
- const assertionComplete = span.events.find((e) => e.name === 'assertion.complete');
106
- if (assertionComplete) {
107
- return {
108
- 'assertions.passed': assertionComplete.attributes['assertions.passed'] || 0,
109
- 'assertions.failed': assertionComplete.attributes['assertions.failed'] || 0,
110
- 'test.status': span.status,
111
- 'test.name': span.name,
112
- ...span.attributes,
113
- };
114
- }
115
- return {
116
- 'test.status': span.status,
117
- 'test.name': span.name,
118
- ...span.attributes,
119
- };
120
- }
121
- //# sourceMappingURL=narrative-converter.js.map