causal-inspector 0.1.2 → 0.1.5
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/engines/query.js +21 -9
- package/dist/engines/url.js +8 -1
- package/dist/events.d.ts +7 -2
- package/dist/panes/CausalFlowPane.js +22 -18
- package/dist/panes/LogsPane.js +1 -1
- package/dist/panes/TimelinePane.js +18 -72
- package/dist/queries.d.ts +1 -1
- package/dist/queries.js +11 -8
- package/dist/reducer.js +14 -4
- package/dist/state.d.ts +1 -0
- package/dist/state.js +1 -0
- package/dist/types.d.ts +4 -0
- package/package.json +1 -1
package/dist/engines/query.js
CHANGED
|
@@ -119,12 +119,24 @@ export const createQueryEngine = (transport) => {
|
|
|
119
119
|
console.error("[causal-inspector] fetch logs failed:", e);
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
|
-
|
|
122
|
+
let correlationCursor = null;
|
|
123
|
+
const fetchCorrelations = async (opts) => {
|
|
124
|
+
const append = opts?.append ?? false;
|
|
125
|
+
const cursor = append ? correlationCursor : undefined;
|
|
123
126
|
try {
|
|
124
|
-
const data = await transport.query(INSPECTOR_CORRELATIONS, {
|
|
127
|
+
const data = await transport.query(INSPECTOR_CORRELATIONS, {
|
|
128
|
+
search: opts?.search || undefined,
|
|
129
|
+
limit: 50,
|
|
130
|
+
cursor: cursor || undefined,
|
|
131
|
+
});
|
|
132
|
+
correlationCursor = data.inspectorCorrelations.nextCursor;
|
|
125
133
|
dispatch({
|
|
126
134
|
type: "events/correlations_loaded",
|
|
127
|
-
payload:
|
|
135
|
+
payload: {
|
|
136
|
+
correlations: data.inspectorCorrelations.correlations,
|
|
137
|
+
hasMore: data.inspectorCorrelations.nextCursor != null,
|
|
138
|
+
append,
|
|
139
|
+
},
|
|
128
140
|
});
|
|
129
141
|
}
|
|
130
142
|
catch (e) {
|
|
@@ -214,16 +226,16 @@ export const createQueryEngine = (transport) => {
|
|
|
214
226
|
fetchCausalTree(event.payload.seq);
|
|
215
227
|
break;
|
|
216
228
|
case "ui/filter_changed":
|
|
217
|
-
dispatch({
|
|
218
|
-
type: "events/page_loaded",
|
|
219
|
-
payload: { events: [], hasMore: true },
|
|
220
|
-
});
|
|
221
229
|
fetchEvents();
|
|
222
230
|
break;
|
|
231
|
+
case "ui/load_more_correlations_requested":
|
|
232
|
+
fetchCorrelations({ append: true });
|
|
233
|
+
break;
|
|
223
234
|
case "ui/correlations_requested":
|
|
224
|
-
|
|
235
|
+
correlationCursor = null;
|
|
236
|
+
fetchCorrelations({ search: event.payload.search });
|
|
225
237
|
stopCorrelationPolling();
|
|
226
|
-
correlationPollTimer = setInterval(() => fetchCorrelations(event.payload.search), 5000);
|
|
238
|
+
correlationPollTimer = setInterval(() => fetchCorrelations({ search: event.payload.search }), 5000);
|
|
227
239
|
break;
|
|
228
240
|
case "ui/aggregate_lifecycle_requested":
|
|
229
241
|
fetchAggregateLifecycle(event.payload.aggregateKey);
|
package/dist/engines/url.js
CHANGED
|
@@ -18,7 +18,7 @@ function buildSearch(correlationId, handler) {
|
|
|
18
18
|
else
|
|
19
19
|
params.delete("handler");
|
|
20
20
|
const search = params.toString();
|
|
21
|
-
return search ?
|
|
21
|
+
return search ? `${window.location.pathname}?${search}` : window.location.pathname;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* URL engine — keeps the browser URL in sync with navigation state.
|
|
@@ -51,6 +51,13 @@ export const createUrlEngine = (dispatch, _getState) => {
|
|
|
51
51
|
case "ui/flow_closed":
|
|
52
52
|
window.history.pushState(null, "", buildSearch(null, null));
|
|
53
53
|
break;
|
|
54
|
+
case "ui/filter_changed": {
|
|
55
|
+
const payload = event.payload;
|
|
56
|
+
if (payload.correlationId !== undefined) {
|
|
57
|
+
window.history.pushState(null, "", buildSearch(payload.correlationId, null));
|
|
58
|
+
}
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
54
61
|
case "ui/handler_selected":
|
|
55
62
|
// Replace rather than push — handler changes within a flow are fine as one history entry
|
|
56
63
|
window.history.replaceState(null, "", buildSearch(new URLSearchParams(window.location.search).get("correlation"), event.payload.reactorId));
|
package/dist/events.d.ts
CHANGED
|
@@ -31,7 +31,11 @@ type OutcomesLoaded = BaseEvent<"events/outcomes_loaded", {
|
|
|
31
31
|
correlationId: string;
|
|
32
32
|
outcomes: ReactorOutcome[];
|
|
33
33
|
}>;
|
|
34
|
-
type CorrelationsLoaded = BaseEvent<"events/correlations_loaded",
|
|
34
|
+
type CorrelationsLoaded = BaseEvent<"events/correlations_loaded", {
|
|
35
|
+
correlations: CorrelationSummary[];
|
|
36
|
+
hasMore: boolean;
|
|
37
|
+
append: boolean;
|
|
38
|
+
}>;
|
|
35
39
|
type ReactorDependenciesLoaded = BaseEvent<"events/reactor_dependencies_loaded", ReactorDependency[]>;
|
|
36
40
|
type AggregateKeysLoaded = BaseEvent<"events/aggregate_keys_loaded", string[]>;
|
|
37
41
|
type AggregateLifecycleLoaded = BaseEvent<"events/aggregate_lifecycle_loaded", {
|
|
@@ -69,9 +73,10 @@ type HandlerSelected = BaseEvent<"ui/handler_selected", {
|
|
|
69
73
|
type AggregateLifecycleRequested = BaseEvent<"ui/aggregate_lifecycle_requested", {
|
|
70
74
|
aggregateKey: string;
|
|
71
75
|
}>;
|
|
76
|
+
type LoadMoreCorrelationsRequested = BaseEvent<"ui/load_more_correlations_requested">;
|
|
72
77
|
type LocationChanged = BaseEvent<"location/changed", {
|
|
73
78
|
correlationId: string | null;
|
|
74
79
|
handler: string | null;
|
|
75
80
|
}>;
|
|
76
|
-
export type InspectorMachineEvent = EventsReceived | SubscriptionConnected | SubscriptionError | PageLoaded | CausalTreeLoaded | FlowLoaded | LogsLoaded | DescriptionsLoaded | DescriptionSnapshotsLoaded | AggregateTimelineLoaded | OutcomesLoaded | CorrelationsLoaded | EventSelected | EventDeselected | FlowOpened | FlowClosed | FlowNodeSelected | FilterChanged | LoadMoreRequested | LayoutChanged | ScrubberStartChanged | ScrubberEndChanged | ScrubberPlayToggled | ScrubberSpeedChanged | CorrelationsRequested | ReactorDependenciesLoaded | AggregateKeysLoaded | HandlerSelected | LocationChanged | AggregateLifecycleLoaded | AggregateLifecycleRequested;
|
|
81
|
+
export type InspectorMachineEvent = EventsReceived | SubscriptionConnected | SubscriptionError | PageLoaded | CausalTreeLoaded | FlowLoaded | LogsLoaded | DescriptionsLoaded | DescriptionSnapshotsLoaded | AggregateTimelineLoaded | OutcomesLoaded | CorrelationsLoaded | EventSelected | EventDeselected | FlowOpened | FlowClosed | FlowNodeSelected | FilterChanged | LoadMoreRequested | LayoutChanged | ScrubberStartChanged | ScrubberEndChanged | ScrubberPlayToggled | ScrubberSpeedChanged | CorrelationsRequested | ReactorDependenciesLoaded | AggregateKeysLoaded | HandlerSelected | LocationChanged | AggregateLifecycleLoaded | AggregateLifecycleRequested | LoadMoreCorrelationsRequested;
|
|
77
82
|
export {};
|
|
@@ -4,7 +4,7 @@ import { ReactFlow, Background, Controls, useReactFlow, Handle, MarkerType, Posi
|
|
|
4
4
|
import dagre from "@dagrejs/dagre";
|
|
5
5
|
import { useSelector, useDispatch } from "../machine";
|
|
6
6
|
import { eventBg, eventBorder, eventTextColor } from "../theme";
|
|
7
|
-
import { Filter } from "lucide-react";
|
|
7
|
+
import { Filter, ArrowRight, ArrowDown } from "lucide-react";
|
|
8
8
|
import { inScrubberRange } from "../utils";
|
|
9
9
|
/* eslint-disable-next-line @typescript-eslint/no-redeclare -- shadowing the tree-pane ReactorNode on purpose */
|
|
10
10
|
const NODE_WIDTH = 180;
|
|
@@ -60,6 +60,7 @@ const ReactorNode = memo(({ data }) => {
|
|
|
60
60
|
const d = data;
|
|
61
61
|
const blocks = d.blocks;
|
|
62
62
|
const outcome = d.outcome;
|
|
63
|
+
const dir = d.direction ?? "LR";
|
|
63
64
|
const hasBlocks = blocks && blocks.length > 0;
|
|
64
65
|
const borderColor = STATUS_BORDER[outcome?.status ?? "pending"] ?? "#2a2a35";
|
|
65
66
|
const isRunning = outcome?.status === "running";
|
|
@@ -79,10 +80,11 @@ const ReactorNode = memo(({ data }) => {
|
|
|
79
80
|
boxShadow: isRunning
|
|
80
81
|
? `0 0 12px ${borderColor}40`
|
|
81
82
|
: "0 2px 8px rgba(0, 0, 0, 0.3)",
|
|
82
|
-
}, children: [_jsx(Handle, { type: "target", position: Position.Left, style: { visibility: "hidden" } }), _jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", gap: 8 }, children: [_jsx("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", direction: "rtl", textAlign: "left" }, children: d.label }), duration && _jsx("span", { style: { fontSize: 9, color: "#60608a", fontStyle: "normal", whiteSpace: "nowrap", flexShrink: 0 }, children: duration })] }), hasBlocks && blocks.map((block, i) => _jsx(BlockRenderer, { block: block }, i)), outcome?.status === "error" && outcome.error && (_jsx("div", { style: { fontSize: 9, color: "#ef4444", marginTop: 4 }, children: outcome.error })), _jsx(Handle, { type: "source", position: Position.Right, style: { visibility: "hidden" } })] }));
|
|
83
|
+
}, children: [_jsx(Handle, { type: "target", position: dir === "LR" ? Position.Left : Position.Top, style: { visibility: "hidden" } }), _jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", gap: 8 }, children: [_jsx("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", direction: "rtl", textAlign: "left" }, children: d.label }), duration && _jsx("span", { style: { fontSize: 9, color: "#60608a", fontStyle: "normal", whiteSpace: "nowrap", flexShrink: 0 }, children: duration })] }), hasBlocks && blocks.map((block, i) => _jsx(BlockRenderer, { block: block }, i)), outcome?.status === "error" && outcome.error && (_jsx("div", { style: { fontSize: 9, color: "#ef4444", marginTop: 4 }, children: outcome.error })), _jsx(Handle, { type: "source", position: dir === "LR" ? Position.Right : Position.Bottom, style: { visibility: "hidden" } })] }));
|
|
83
84
|
});
|
|
84
85
|
const EventNode = memo(({ data }) => {
|
|
85
86
|
const d = data;
|
|
87
|
+
const dir = d.direction ?? "LR";
|
|
86
88
|
return (_jsxs("div", { style: {
|
|
87
89
|
background: eventBg(d.eventName),
|
|
88
90
|
border: `1px solid ${eventBorder(d.eventName)}`,
|
|
@@ -99,10 +101,10 @@ const EventNode = memo(({ data }) => {
|
|
|
99
101
|
boxShadow: `0 2px 8px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.04)`,
|
|
100
102
|
fontWeight: 500,
|
|
101
103
|
letterSpacing: "0.01em",
|
|
102
|
-
}, children: [_jsx(Handle, { type: "target", position: Position.Left, style: { visibility: "hidden" } }), d.label, _jsx(Handle, { type: "source", position: Position.Right, style: { visibility: "hidden" } })] }));
|
|
104
|
+
}, children: [_jsx(Handle, { type: "target", position: dir === "LR" ? Position.Left : Position.Top, style: { visibility: "hidden" } }), d.label, _jsx(Handle, { type: "source", position: dir === "LR" ? Position.Right : Position.Bottom, style: { visibility: "hidden" } })] }));
|
|
103
105
|
});
|
|
104
106
|
const nodeTypes = { reactor: ReactorNode, event: EventNode };
|
|
105
|
-
function buildFlowGraph(events, descriptions, outcomes, hiddenReactors) {
|
|
107
|
+
function buildFlowGraph(events, descriptions, outcomes, hiddenReactors, direction = "LR") {
|
|
106
108
|
// Group events by type name only (merge across reactors)
|
|
107
109
|
const eventGroups = new Map();
|
|
108
110
|
const reactorIds = new Set();
|
|
@@ -154,9 +156,10 @@ function buildFlowGraph(events, descriptions, outcomes, hiddenReactors) {
|
|
|
154
156
|
label: group.count > 1 ? `${group.name} (${group.count})` : group.name,
|
|
155
157
|
nodeKind: "event-type",
|
|
156
158
|
eventName: group.name,
|
|
159
|
+
direction,
|
|
157
160
|
},
|
|
158
|
-
sourcePosition: Position.Right,
|
|
159
|
-
targetPosition: Position.Left,
|
|
161
|
+
sourcePosition: direction === "LR" ? Position.Right : Position.Bottom,
|
|
162
|
+
targetPosition: direction === "LR" ? Position.Left : Position.Top,
|
|
160
163
|
});
|
|
161
164
|
}
|
|
162
165
|
// Reactor nodes
|
|
@@ -169,9 +172,9 @@ function buildFlowGraph(events, descriptions, outcomes, hiddenReactors) {
|
|
|
169
172
|
id: `hdl:${reactorId}`,
|
|
170
173
|
type: "reactor",
|
|
171
174
|
position: { x: 0, y: 0 },
|
|
172
|
-
data: { label: reactorId, nodeKind: "reactor", reactorId, blocks, outcome },
|
|
173
|
-
sourcePosition: Position.Right,
|
|
174
|
-
targetPosition: Position.Left,
|
|
175
|
+
data: { label: reactorId, nodeKind: "reactor", reactorId, blocks, outcome, direction },
|
|
176
|
+
sourcePosition: direction === "LR" ? Position.Right : Position.Bottom,
|
|
177
|
+
targetPosition: direction === "LR" ? Position.Left : Position.Top,
|
|
175
178
|
});
|
|
176
179
|
}
|
|
177
180
|
const arrowMarker = { type: MarkerType.ArrowClosed, color: "#3a3a4a", width: 14, height: 14 };
|
|
@@ -226,9 +229,9 @@ function buildFlowGraph(events, descriptions, outcomes, hiddenReactors) {
|
|
|
226
229
|
id: `hdl:${reactorId}`,
|
|
227
230
|
type: "reactor",
|
|
228
231
|
position: { x: 0, y: 0 },
|
|
229
|
-
data: { label: reactorId, nodeKind: "reactor", reactorId, blocks, outcome },
|
|
230
|
-
sourcePosition: Position.Bottom,
|
|
231
|
-
targetPosition: Position.Top,
|
|
232
|
+
data: { label: reactorId, nodeKind: "reactor", reactorId, blocks, outcome, direction },
|
|
233
|
+
sourcePosition: direction === "LR" ? Position.Right : Position.Bottom,
|
|
234
|
+
targetPosition: direction === "LR" ? Position.Left : Position.Top,
|
|
232
235
|
});
|
|
233
236
|
const isPending = outcome.status === "pending" || outcome.status === "running";
|
|
234
237
|
for (const eventId of outcome.triggeringEventIds ?? []) {
|
|
@@ -250,7 +253,7 @@ function buildFlowGraph(events, descriptions, outcomes, hiddenReactors) {
|
|
|
250
253
|
}
|
|
251
254
|
}
|
|
252
255
|
}
|
|
253
|
-
return layoutGraph(nodes, edges);
|
|
256
|
+
return layoutGraph(nodes, edges, direction);
|
|
254
257
|
}
|
|
255
258
|
function estimateReactorHeight(data) {
|
|
256
259
|
if (data.nodeKind !== "reactor")
|
|
@@ -274,10 +277,10 @@ function estimateReactorHeight(data) {
|
|
|
274
277
|
h += 14;
|
|
275
278
|
return h;
|
|
276
279
|
}
|
|
277
|
-
function layoutGraph(nodes, edges) {
|
|
280
|
+
function layoutGraph(nodes, edges, direction = "LR") {
|
|
278
281
|
const g = new dagre.graphlib.Graph();
|
|
279
282
|
g.setDefaultEdgeLabel(() => ({}));
|
|
280
|
-
g.setGraph({ rankdir:
|
|
283
|
+
g.setGraph({ rankdir: direction, nodesep: 40, ranksep: 80 });
|
|
281
284
|
const heights = new Map();
|
|
282
285
|
for (const node of nodes) {
|
|
283
286
|
const isReactor = node.id.startsWith("hdl:");
|
|
@@ -460,6 +463,7 @@ export function CausalFlowPane({ defaultHiddenReactors, headerExtra } = {}) {
|
|
|
460
463
|
return map;
|
|
461
464
|
}, [outcomesMap, flowCorrelationId]);
|
|
462
465
|
const [hiddenReactors, setHiddenReactors] = useState(() => defaultHiddenReactors ?? new Set());
|
|
466
|
+
const [direction, setDirection] = useState("LR");
|
|
463
467
|
const allReactorIds = useMemo(() => {
|
|
464
468
|
const ids = new Set();
|
|
465
469
|
for (const evt of flowData) {
|
|
@@ -475,8 +479,8 @@ export function CausalFlowPane({ defaultHiddenReactors, headerExtra } = {}) {
|
|
|
475
479
|
const { nodes: fullNodes, edges: fullEdges } = useMemo(() => {
|
|
476
480
|
if (!flowData || flowData.length === 0)
|
|
477
481
|
return { nodes: [], edges: [] };
|
|
478
|
-
return buildFlowGraph(flowData, descriptions, outcomes, hiddenReactors);
|
|
479
|
-
}, [flowData, descriptions, outcomes, hiddenReactors]);
|
|
482
|
+
return buildFlowGraph(flowData, descriptions, outcomes, hiddenReactors, direction);
|
|
483
|
+
}, [flowData, descriptions, outcomes, hiddenReactors, direction]);
|
|
480
484
|
// Compute visible IDs when scrubber range is active
|
|
481
485
|
const visibleIds = useMemo(() => {
|
|
482
486
|
if (scrubberStart == null && scrubberEnd == null)
|
|
@@ -592,5 +596,5 @@ export function CausalFlowPane({ defaultHiddenReactors, headerExtra } = {}) {
|
|
|
592
596
|
if (flowLoading) {
|
|
593
597
|
return (_jsxs("div", { className: "h-full flex flex-col", children: [_jsxs("div", { className: "flex items-center gap-2 px-3 py-1.5 border-b border-border shrink-0", children: [_jsx("div", { className: "h-3 w-10 bg-muted rounded animate-pulse" }), _jsx("div", { className: "h-3 w-48 bg-muted rounded animate-pulse" })] }), _jsx("div", { className: "flex-1 flex items-center justify-center", children: _jsxs("div", { className: "animate-pulse flex flex-col items-center gap-3", children: [_jsx("div", { className: "h-8 w-40 bg-muted rounded-md" }), _jsx("div", { className: "h-6 w-px bg-muted" }), _jsx("div", { className: "h-6 w-28 bg-muted rounded-full" }), _jsxs("div", { className: "flex items-start gap-8", children: [_jsxs("div", { className: "flex flex-col items-center gap-3", children: [_jsx("div", { className: "h-6 w-px bg-muted" }), _jsx("div", { className: "h-8 w-36 bg-muted rounded-md" })] }), _jsxs("div", { className: "flex flex-col items-center gap-3", children: [_jsx("div", { className: "h-6 w-px bg-muted" }), _jsx("div", { className: "h-8 w-36 bg-muted rounded-md" })] })] })] }) })] }));
|
|
594
598
|
}
|
|
595
|
-
return (_jsxs("div", { className: "h-full flex flex-col", children: [_jsxs("div", { className: "flex items-center gap-2.5 px-3 py-2 border-b border-border shrink-0", style: { background: "rgba(15, 15, 20, 0.6)", backdropFilter: "blur(8px)" }, children: [_jsx("h3", { className: "text-[10px] font-semibold text-muted-foreground/60 uppercase tracking-widest", children: "Flow" }), _jsx("span", { className: "text-[10px] font-mono text-foreground/80 truncate px-1.5 py-0.5 rounded bg-white/[0.03] border border-border", children: flowCorrelationId }), _jsxs("span", { className: "text-[10px] text-muted-foreground/50 tabular-nums", children: [flowData.length, " events \u00B7 ", nodes.length, " nodes"] }), headerExtra,
|
|
599
|
+
return (_jsxs("div", { className: "h-full flex flex-col", children: [_jsxs("div", { className: "flex items-center gap-2.5 px-3 py-2 border-b border-border shrink-0", style: { background: "rgba(15, 15, 20, 0.6)", backdropFilter: "blur(8px)" }, children: [_jsx("h3", { className: "text-[10px] font-semibold text-muted-foreground/60 uppercase tracking-widest", children: "Flow" }), _jsx("span", { className: "text-[10px] font-mono text-foreground/80 truncate px-1.5 py-0.5 rounded bg-white/[0.03] border border-border", children: flowCorrelationId }), _jsxs("span", { className: "text-[10px] text-muted-foreground/50 tabular-nums", children: [flowData.length, " events \u00B7 ", nodes.length, " nodes"] }), headerExtra, _jsxs("div", { className: "ml-auto flex items-center gap-1.5", children: [_jsx("button", { onClick: () => setDirection(d => d === "LR" ? "TB" : "LR"), className: "text-[10px] text-muted-foreground/60 hover:text-foreground px-2 py-1 rounded-md border border-border hover:border-indigo-500/30 transition-all duration-150", title: direction === "LR" ? "Switch to vertical layout" : "Switch to horizontal layout", children: direction === "LR" ? _jsx(ArrowDown, { size: 11, className: "inline" }) : _jsx(ArrowRight, { size: 11, className: "inline" }) }), _jsx(ReactorFilter, { allReactorIds: allReactorIds, hiddenReactors: hiddenReactors, setHiddenReactors: setHiddenReactors })] })] }), _jsx("div", { className: "flex-1 relative", children: _jsxs(ReactFlow, { nodes: nodes, edges: edges, nodeTypes: nodeTypes, defaultEdgeOptions: { type: "smoothstep" }, onNodesChange: onNodesChange, onNodeClick: onNodeClick, onPaneClick: onPaneClick, minZoom: 0.25, proOptions: { hideAttribution: true }, nodesDraggable: false, nodesConnectable: false, elevateNodesOnSelect: false, colorMode: "dark", children: [_jsx(FitOnLoad, {}), _jsx(FocusOnSelection, { nodes: nodes, flowData: flowData }), _jsx(Background, { color: "rgba(255,255,255,0.03)", gap: 24, size: 1 }), _jsx(Controls, { showInteractive: false })] }) })] }));
|
|
596
600
|
}
|
package/dist/panes/LogsPane.js
CHANGED
|
@@ -61,5 +61,5 @@ export function LogsPane({ onInvestigate } = {}) {
|
|
|
61
61
|
};
|
|
62
62
|
return (_jsxs("div", { className: "h-full flex flex-col", children: [_jsxs("div", { className: "px-3 py-2 border-b border-border flex items-center gap-3 flex-wrap", style: { background: "rgba(15, 15, 20, 0.6)", backdropFilter: "blur(8px)" }, children: [_jsx("div", { className: "flex items-center gap-1 text-[10px]", children: ["debug", "info", "warn"].map((level) => (_jsx("button", { onClick: () => toggleLevel(level), className: `px-2 py-0.5 rounded-md uppercase font-semibold transition-all duration-150 ${levelFilter.has(level)
|
|
63
63
|
? LOG_LEVEL_COLORS[level]
|
|
64
|
-
: "text-muted-foreground/30 line-through"}`, children: level }, level))) }), _jsxs("div", { className: "relative flex items-center
|
|
64
|
+
: "text-muted-foreground/30 line-through"}`, children: level }, level))) }), _jsxs("div", { className: "relative flex items-center", children: [_jsx(Search, { size: 10, className: "absolute left-2.5 text-muted-foreground/40 pointer-events-none" }), _jsx("input", { type: "text", placeholder: "Search logs...", value: searchText, onChange: (e) => setSearchText(e.target.value), className: "pl-7 pr-2 text-[11px] bg-background/50 border border-border rounded-md py-1 w-44 focus:outline-none focus:ring-1 focus:ring-indigo-500/40 focus:border-indigo-500/30 text-foreground placeholder:text-muted-foreground/40 transition-all" })] }), onInvestigate && (_jsx("button", { onClick: () => onInvestigate(logsFilter), className: "flex items-center gap-1 px-2 py-1 rounded-md text-[11px] text-muted-foreground/50 hover:text-foreground hover:bg-white/[0.04] transition-all duration-150", title: "Investigate logs", children: _jsx(Search, { size: 12 }) }))] }), _jsxs("div", { className: "px-3 py-1.5 text-[10px] text-muted-foreground/50", children: [logsFilter.reactorId ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "font-mono text-foreground/60", children: logsFilter.reactorId }), isCorrelationScope && _jsx("span", { className: "ml-1", children: "(all reactors in correlation)" })] })) : (_jsx("span", { children: "All reactors in correlation" })), _jsxs("span", { className: "ml-2 tabular-nums", children: [filteredLogs.length, " logs"] })] }), _jsxs("div", { className: "flex-1 overflow-y-auto px-1", children: [filteredLogs.length === 0 && (_jsx("div", { className: "p-3 text-[11px] text-muted-foreground/40", children: "No logs match filters" })), filteredLogs.map((log, i) => (_jsx(LogRow, { log: log, showReactor: isCorrelationScope }, i)))] })] }));
|
|
65
65
|
}
|
|
@@ -4,62 +4,21 @@ import { useSelector, useDispatch } from "../machine";
|
|
|
4
4
|
import { FilterBar } from "../components/FilterBar";
|
|
5
5
|
import { CopyablePayload } from "../components/CopyablePayload";
|
|
6
6
|
import { eventTextColor, eventBg } from "../theme";
|
|
7
|
-
import { formatTs, compactPayload,
|
|
8
|
-
import { Search, ChevronRight
|
|
9
|
-
function EventRow({ event, isSelected, onClick, onFilterCorrelation,
|
|
7
|
+
import { formatTs, compactPayload, inScrubberRange } from "../utils";
|
|
8
|
+
import { Search, ChevronRight } from "lucide-react";
|
|
9
|
+
function EventRow({ event, isSelected, onClick, onFilterCorrelation, onInvestigate, }) {
|
|
10
10
|
const [payloadOpen, setPayloadOpen] = useState(false);
|
|
11
11
|
return (_jsxs("div", { className: `group w-full text-left px-3 py-2 border-b border-border transition-all duration-150 ${isSelected
|
|
12
12
|
? "bg-indigo-500/15"
|
|
13
|
-
: "hover:bg-white/[0.02]"}`,
|
|
13
|
+
: "hover:bg-white/[0.02]"}`, children: [_jsx("div", { onClick: onClick, role: "button", tabIndex: 0, className: "w-full text-left cursor-pointer", children: _jsxs("div", { className: "flex items-center gap-2.5 min-w-0", children: [_jsx("span", { className: "text-[10px] font-mono text-muted-foreground/60 w-10 shrink-0 text-right tabular-nums", children: event.seq }), _jsx("span", { className: "text-[10px] text-muted-foreground/70 shrink-0 w-32 tabular-nums", children: formatTs(event.ts) }), event.correlationId && (_jsx("button", { onClick: (e) => { e.stopPropagation(); onFilterCorrelation(event.correlationId); }, className: "px-1.5 py-0.5 rounded-full text-[9px] font-mono bg-purple-500/8 text-purple-400/80 hover:bg-purple-500/15 hover:text-purple-400 shrink-0 transition-all border border-purple-500/10", title: `Filter by correlation ${event.correlationId}`, children: event.correlationId.slice(0, 8) })), _jsx("span", { className: "text-xs font-mono shrink-0 px-1.5 py-0.5 rounded", style: {
|
|
14
14
|
color: eventTextColor(event.name),
|
|
15
15
|
background: eventBg(event.name),
|
|
16
16
|
}, children: event.name }), _jsxs("button", { onClick: (e) => { e.stopPropagation(); setPayloadOpen((v) => !v); }, className: "flex items-center gap-1 text-[10px] font-mono text-muted-foreground/60 hover:text-muted-foreground truncate text-left min-w-0 transition-colors", title: "Click to expand payload", children: [_jsx(ChevronRight, { size: 10, className: `shrink-0 transition-transform duration-150 ${payloadOpen ? "rotate-90" : ""}` }), _jsx("span", { className: "truncate", children: event.summary ?? compactPayload(event.payload) })] }), onInvestigate && (_jsx("button", { onClick: (e) => { e.stopPropagation(); onInvestigate(); }, className: "opacity-0 group-hover:opacity-100 transition-opacity duration-150 ml-auto p-1 rounded-md hover:bg-white/[0.05] shrink-0 text-muted-foreground", title: "Investigate", children: _jsx(Search, { size: 12 }) }))] }) }), payloadOpen && (_jsx(CopyablePayload, { payload: event.payload, className: "mt-2 ml-12 max-h-64" }))] }));
|
|
17
17
|
}
|
|
18
|
-
function groupEventsByCorrelation(events) {
|
|
19
|
-
const result = [];
|
|
20
|
-
let i = 0;
|
|
21
|
-
while (i < events.length) {
|
|
22
|
-
const event = events[i];
|
|
23
|
-
if (!event.correlationId) {
|
|
24
|
-
result.push(event);
|
|
25
|
-
i++;
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
// Collect consecutive events with the same correlationId
|
|
29
|
-
const cid = event.correlationId;
|
|
30
|
-
const groupEvents = [event];
|
|
31
|
-
let j = i + 1;
|
|
32
|
-
while (j < events.length && events[j].correlationId === cid) {
|
|
33
|
-
groupEvents.push(events[j]);
|
|
34
|
-
j++;
|
|
35
|
-
}
|
|
36
|
-
if (groupEvents.length === 1) {
|
|
37
|
-
// Single event — render flat
|
|
38
|
-
result.push(event);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
// Find the root event (no reactorId) or fall back to first
|
|
42
|
-
const rootIdx = groupEvents.findIndex((e) => !e.reactorId);
|
|
43
|
-
const root = rootIdx >= 0 ? groupEvents[rootIdx] : groupEvents[0];
|
|
44
|
-
const children = groupEvents.filter((e) => e !== root);
|
|
45
|
-
result.push({ correlationId: cid, root, children });
|
|
46
|
-
}
|
|
47
|
-
i = j;
|
|
48
|
-
}
|
|
49
|
-
return result;
|
|
50
|
-
}
|
|
51
|
-
function EventGroupRow({ group, selectedSeq, collapsed, onToggle, onSelect, onFilterCorrelation, onFilterStream, onInvestigate, }) {
|
|
52
|
-
return (_jsxs("div", { children: [_jsxs("div", { className: "relative", children: [_jsx("button", { onClick: onToggle, className: "absolute left-1 top-2.5 z-10 p-0.5 rounded hover:bg-white/[0.05] text-muted-foreground/60 hover:text-muted-foreground transition-colors", title: collapsed ? "Expand group" : "Collapse group", children: collapsed ? _jsx(ChevronRight, { size: 12 }) : _jsx(ChevronDown, { size: 12 }) }), _jsxs("div", { className: "relative", children: [_jsx(EventRow, { event: group.root, isSelected: group.root.seq === selectedSeq, onClick: () => onSelect(group.root), onFilterCorrelation: onFilterCorrelation, onFilterStream: onFilterStream, onInvestigate: onInvestigate ? () => onInvestigate(group.root) : undefined }), collapsed && (_jsxs("span", { className: "absolute right-3 top-2.5 text-[9px] font-mono px-1.5 py-0.5 rounded-full bg-white/[0.04] text-muted-foreground/60 border border-border", children: ["+", group.children.length] }))] })] }), !collapsed &&
|
|
53
|
-
group.children.map((child) => (_jsx(EventRow, { event: child, isSelected: child.seq === selectedSeq, onClick: () => onSelect(child), onFilterCorrelation: onFilterCorrelation, onFilterStream: onFilterStream, onInvestigate: onInvestigate ? () => onInvestigate(child) : undefined, indent: true }, child.seq)))] }));
|
|
54
|
-
}
|
|
55
18
|
function InfiniteScrollSentinel({ onVisible, loading }) {
|
|
56
19
|
const ref = useRef(null);
|
|
57
20
|
const onVisibleRef = useRef(onVisible);
|
|
58
21
|
onVisibleRef.current = onVisible;
|
|
59
|
-
// Re-create observer when loading finishes so it re-checks visibility.
|
|
60
|
-
// Without this, if loaded events collapse into one group row the sentinel
|
|
61
|
-
// stays visible but the observer never fires again (it only fires on
|
|
62
|
-
// enter/leave transitions).
|
|
63
22
|
useEffect(() => {
|
|
64
23
|
if (loading)
|
|
65
24
|
return;
|
|
@@ -74,31 +33,30 @@ function InfiniteScrollSentinel({ onVisible, loading }) {
|
|
|
74
33
|
return (_jsx("div", { ref: ref, className: "flex items-center justify-center py-4", children: loading && (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("div", { className: "w-1.5 h-1.5 rounded-full bg-indigo-500/50 animate-pulse" }), _jsx("span", { className: "text-[10px] text-muted-foreground/60", children: "Loading" })] })) }));
|
|
75
34
|
}
|
|
76
35
|
export function TimelinePane({ onInvestigate } = {}) {
|
|
77
|
-
const events = useSelector((s) =>
|
|
36
|
+
const events = useSelector((s) => {
|
|
37
|
+
let result = s.events;
|
|
38
|
+
const cid = s.filters.correlationId;
|
|
39
|
+
if (cid)
|
|
40
|
+
result = result.filter((e) => e.correlationId === cid);
|
|
41
|
+
const search = s.filters.search?.toLowerCase();
|
|
42
|
+
if (search) {
|
|
43
|
+
result = result.filter((e) => e.name.toLowerCase().includes(search) ||
|
|
44
|
+
e.payload.toLowerCase().includes(search) ||
|
|
45
|
+
(e.correlationId ?? "").toLowerCase().includes(search));
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
});
|
|
78
49
|
const loading = useSelector((s) => s.loading);
|
|
79
50
|
const hasMore = useSelector((s) => s.hasMore);
|
|
80
51
|
const selectedSeq = useSelector((s) => s.selectedSeq);
|
|
81
52
|
const scrubberStart = useSelector((s) => s.scrubberStart);
|
|
82
53
|
const scrubberEnd = useSelector((s) => s.scrubberEnd);
|
|
83
54
|
const dispatch = useDispatch();
|
|
84
|
-
// Default collapsed — this set tracks which groups are *expanded*
|
|
85
|
-
const [expandedGroups, setExpandedGroups] = useState(() => new Set());
|
|
86
55
|
const displayedEvents = useMemo(() => {
|
|
87
56
|
if (scrubberStart == null && scrubberEnd == null)
|
|
88
57
|
return events;
|
|
89
58
|
return events.filter(e => inScrubberRange(e.seq, scrubberStart, scrubberEnd));
|
|
90
59
|
}, [events, scrubberStart, scrubberEnd]);
|
|
91
|
-
const grouped = useMemo(() => groupEventsByCorrelation(displayedEvents), [displayedEvents]);
|
|
92
|
-
const toggleGroup = useCallback((correlationId) => {
|
|
93
|
-
setExpandedGroups((prev) => {
|
|
94
|
-
const next = new Set(prev);
|
|
95
|
-
if (next.has(correlationId))
|
|
96
|
-
next.delete(correlationId);
|
|
97
|
-
else
|
|
98
|
-
next.add(correlationId);
|
|
99
|
-
return next;
|
|
100
|
-
});
|
|
101
|
-
}, []);
|
|
102
60
|
const handleSelect = useCallback((event) => {
|
|
103
61
|
dispatch({ type: "ui/event_selected", payload: { seq: event.seq } });
|
|
104
62
|
if (event.correlationId) {
|
|
@@ -108,20 +66,8 @@ export function TimelinePane({ onInvestigate } = {}) {
|
|
|
108
66
|
const handleFilterCorrelation = useCallback((correlationId) => {
|
|
109
67
|
dispatch({ type: "ui/filter_changed", payload: { correlationId } });
|
|
110
68
|
}, [dispatch]);
|
|
111
|
-
const handleFilterStream = useCallback((aggregateKey) => {
|
|
112
|
-
dispatch({ type: "ui/filter_changed", payload: { aggregateKey } });
|
|
113
|
-
}, [dispatch]);
|
|
114
69
|
const handleLoadMore = useCallback(() => {
|
|
115
70
|
dispatch({ type: "ui/load_more_requested" });
|
|
116
71
|
}, [dispatch]);
|
|
117
|
-
return (_jsxs("div", { className: "flex flex-col h-full", children: [_jsx(FilterBar, {}), loading && events.length === 0 ? (_jsx("div", { className: "animate-pulse p-1", children: Array.from({ length: 12 }).map((_, i) => (_jsxs("div", { className: "flex items-center gap-2 px-3 py-2.5 border-b border-border", children: [_jsx("div", { className: "h-3 w-10 bg-white/[0.03] rounded shrink-0" }), _jsx("div", { className: "h-3 w-32 bg-white/[0.03] rounded shrink-0" }), _jsx("div", { className: "h-3 bg-white/[0.03] rounded flex-1", style: { maxWidth: `${150 + (i * 37) % 200}px` } })] }, i))) })) : events.length === 0 ? (_jsx("div", { className: "flex items-center justify-center h-32 text-sm text-muted-foreground/60", children: "No events found" })) : (_jsxs("div", { className: "flex-1 overflow-y-auto", children: [
|
|
118
|
-
if ("correlationId" in item && "root" in item) {
|
|
119
|
-
// EventGroup
|
|
120
|
-
const group = item;
|
|
121
|
-
return (_jsx(EventGroupRow, { group: group, selectedSeq: selectedSeq, collapsed: !expandedGroups.has(group.correlationId), onToggle: () => toggleGroup(group.correlationId), onSelect: handleSelect, onFilterCorrelation: handleFilterCorrelation, onFilterStream: handleFilterStream, onInvestigate: onInvestigate }, `group-${group.correlationId}-${group.root.seq}`));
|
|
122
|
-
}
|
|
123
|
-
// Single event
|
|
124
|
-
const event = item;
|
|
125
|
-
return (_jsx(EventRow, { event: event, isSelected: event.seq === selectedSeq, onClick: () => handleSelect(event), onFilterCorrelation: handleFilterCorrelation, onFilterStream: handleFilterStream, onInvestigate: onInvestigate ? () => onInvestigate(event) : undefined }, event.seq));
|
|
126
|
-
}), hasMore && (_jsx(InfiniteScrollSentinel, { onVisible: handleLoadMore, loading: loading }))] }))] }));
|
|
72
|
+
return (_jsxs("div", { className: "flex flex-col h-full", children: [_jsx(FilterBar, {}), loading && events.length === 0 ? (_jsx("div", { className: "animate-pulse p-1", children: Array.from({ length: 12 }).map((_, i) => (_jsxs("div", { className: "flex items-center gap-2 px-3 py-2.5 border-b border-border", children: [_jsx("div", { className: "h-3 w-10 bg-white/[0.03] rounded shrink-0" }), _jsx("div", { className: "h-3 w-32 bg-white/[0.03] rounded shrink-0" }), _jsx("div", { className: "h-3 bg-white/[0.03] rounded flex-1", style: { maxWidth: `${150 + (i * 37) % 200}px` } })] }, i))) })) : events.length === 0 ? (_jsx("div", { className: "flex items-center justify-center h-32 text-sm text-muted-foreground/60", children: "No events found" })) : (_jsxs("div", { className: "flex-1 overflow-y-auto", children: [displayedEvents.map((event) => (_jsx(EventRow, { event: event, isSelected: event.seq === selectedSeq, onClick: () => handleSelect(event), onFilterCorrelation: handleFilterCorrelation, onInvestigate: onInvestigate ? () => onInvestigate(event) : undefined }, event.seq))), hasMore && (_jsx(InfiniteScrollSentinel, { onVisible: handleLoadMore, loading: loading }))] }))] }));
|
|
127
73
|
}
|
package/dist/queries.d.ts
CHANGED
|
@@ -11,5 +11,5 @@ export declare const INSPECTOR_AGGREGATE_TIMELINE = "\n query InspectorAggregat
|
|
|
11
11
|
export declare const INSPECTOR_REACTOR_DEPENDENCIES = "\n query InspectorReactorDependencies {\n inspectorReactorDependencies {\n reactorId\n inputEventTypes\n outputEventTypes\n }\n }\n";
|
|
12
12
|
export declare const INSPECTOR_AGGREGATE_KEYS = "\n query InspectorAggregateKeys {\n inspectorAggregateKeys\n }\n";
|
|
13
13
|
export declare const INSPECTOR_AGGREGATE_LIFECYCLE = "\n query InspectorAggregateLifecycle($aggregateKey: String!, $limit: Int) {\n inspectorAggregateLifecycle(aggregateKey: $aggregateKey, limit: $limit) {\n seq\n eventId\n eventType\n ts\n correlationId\n aggregateKey\n state\n }\n }\n";
|
|
14
|
-
export declare const INSPECTOR_CORRELATIONS = "\n query InspectorCorrelations($search: String, $limit: Int) {\n inspectorCorrelations(search: $search, limit: $limit) {\n correlationId\n
|
|
14
|
+
export declare const INSPECTOR_CORRELATIONS = "\n query InspectorCorrelations($search: String, $limit: Int, $cursor: String) {\n inspectorCorrelations(search: $search, limit: $limit, cursor: $cursor) {\n correlations {\n correlationId\n eventCount\n firstTs\n lastTs\n rootEventType\n hasErrors\n }\n nextCursor\n }\n }\n";
|
|
15
15
|
export declare const INSPECTOR_REACTOR_OUTCOMES = "\n query InspectorReactorOutcomes($correlationId: String!) {\n inspectorReactorOutcomes(correlationId: $correlationId) {\n reactorId\n status\n error\n attempts\n startedAt\n completedAt\n triggeringEventIds\n }\n }\n";
|
package/dist/queries.js
CHANGED
|
@@ -145,14 +145,17 @@ export const INSPECTOR_AGGREGATE_LIFECYCLE = `
|
|
|
145
145
|
}
|
|
146
146
|
`;
|
|
147
147
|
export const INSPECTOR_CORRELATIONS = `
|
|
148
|
-
query InspectorCorrelations($search: String, $limit: Int) {
|
|
149
|
-
inspectorCorrelations(search: $search, limit: $limit) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
148
|
+
query InspectorCorrelations($search: String, $limit: Int, $cursor: String) {
|
|
149
|
+
inspectorCorrelations(search: $search, limit: $limit, cursor: $cursor) {
|
|
150
|
+
correlations {
|
|
151
|
+
correlationId
|
|
152
|
+
eventCount
|
|
153
|
+
firstTs
|
|
154
|
+
lastTs
|
|
155
|
+
rootEventType
|
|
156
|
+
hasErrors
|
|
157
|
+
}
|
|
158
|
+
nextCursor
|
|
156
159
|
}
|
|
157
160
|
}
|
|
158
161
|
`;
|
package/dist/reducer.js
CHANGED
|
@@ -47,8 +47,6 @@ export const reducer = (draft, event) => {
|
|
|
47
47
|
// ── Subscription ──
|
|
48
48
|
case "events/received": {
|
|
49
49
|
const newEvents = event.payload;
|
|
50
|
-
// Filter subscription events against active filters so they don't
|
|
51
|
-
// pollute the view when the user has a search or correlation filter.
|
|
52
50
|
const filtered = newEvents.filter((e) => {
|
|
53
51
|
if (draft.filters.correlationId && e.correlationId !== draft.filters.correlationId) {
|
|
54
52
|
return false;
|
|
@@ -111,10 +109,18 @@ export const reducer = (draft, event) => {
|
|
|
111
109
|
draft.outcomes[correlationId] = outcomes;
|
|
112
110
|
break;
|
|
113
111
|
}
|
|
114
|
-
case "events/correlations_loaded":
|
|
115
|
-
|
|
112
|
+
case "events/correlations_loaded": {
|
|
113
|
+
const { correlations, hasMore, append } = event.payload;
|
|
114
|
+
if (append) {
|
|
115
|
+
draft.correlations.push(...correlations);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
draft.correlations = correlations;
|
|
119
|
+
}
|
|
120
|
+
draft.correlationsHasMore = hasMore;
|
|
116
121
|
draft.correlationsLoading = false;
|
|
117
122
|
break;
|
|
123
|
+
}
|
|
118
124
|
case "events/reactor_dependencies_loaded":
|
|
119
125
|
draft.reactorDependencies = event.payload;
|
|
120
126
|
break;
|
|
@@ -137,6 +143,7 @@ export const reducer = (draft, event) => {
|
|
|
137
143
|
break;
|
|
138
144
|
case "location/changed":
|
|
139
145
|
applyNavigation(draft, event.payload.correlationId, event.payload.handler);
|
|
146
|
+
draft.filters.correlationId = event.payload.correlationId;
|
|
140
147
|
break;
|
|
141
148
|
// ── UI ──
|
|
142
149
|
case "ui/event_selected":
|
|
@@ -181,5 +188,8 @@ export const reducer = (draft, event) => {
|
|
|
181
188
|
case "ui/correlations_requested":
|
|
182
189
|
draft.correlationsLoading = true;
|
|
183
190
|
break;
|
|
191
|
+
case "ui/load_more_correlations_requested":
|
|
192
|
+
draft.correlationsLoading = true;
|
|
193
|
+
break;
|
|
184
194
|
}
|
|
185
195
|
};
|
package/dist/state.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export type InspectorState = {
|
|
|
24
24
|
outcomes: Record<string, ReactorOutcome[]>;
|
|
25
25
|
correlations: CorrelationSummary[];
|
|
26
26
|
correlationsLoading: boolean;
|
|
27
|
+
correlationsHasMore: boolean;
|
|
27
28
|
reactorDependencies: ReactorDependency[];
|
|
28
29
|
aggregateKeys: string[];
|
|
29
30
|
aggregateLifecycle: AggregateLifecycleEntry[];
|
package/dist/state.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -113,6 +113,10 @@ export type CorrelationSummary = {
|
|
|
113
113
|
rootEventType: string;
|
|
114
114
|
hasErrors: boolean;
|
|
115
115
|
};
|
|
116
|
+
export type CorrelationSummaryPage = {
|
|
117
|
+
correlations: CorrelationSummary[];
|
|
118
|
+
nextCursor: string | null;
|
|
119
|
+
};
|
|
116
120
|
export type FilterState = {
|
|
117
121
|
search: string;
|
|
118
122
|
correlationId: string | null;
|