@kitlangton/motel 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +142 -0
- package/LICENSE +21 -0
- package/README.md +199 -0
- package/package.json +92 -0
- package/src/App.tsx +217 -0
- package/src/cli.ts +258 -0
- package/src/config.ts +39 -0
- package/src/daemon.test.ts +59 -0
- package/src/daemon.ts +398 -0
- package/src/domain.ts +233 -0
- package/src/httpApi.ts +384 -0
- package/src/index.tsx +18 -0
- package/src/instructions.ts +72 -0
- package/src/localServer.ts +699 -0
- package/src/locator.ts +138 -0
- package/src/mcp.ts +260 -0
- package/src/motel.ts +86 -0
- package/src/motelClient.ts +201 -0
- package/src/otlp.ts +142 -0
- package/src/queryFilters.ts +39 -0
- package/src/registry.ts +86 -0
- package/src/runtime.ts +38 -0
- package/src/server.ts +10 -0
- package/src/services/LogQueryService.ts +43 -0
- package/src/services/TelemetryStore.ts +1821 -0
- package/src/services/TraceQueryService.ts +71 -0
- package/src/telemetry.test.ts +726 -0
- package/src/ui/ServiceLogs.tsx +112 -0
- package/src/ui/SpanDetail.tsx +134 -0
- package/src/ui/SpanDetailFull.tsx +224 -0
- package/src/ui/SpanDetailPane.tsx +91 -0
- package/src/ui/TraceDetailsPane.tsx +169 -0
- package/src/ui/TraceList.tsx +128 -0
- package/src/ui/Waterfall.tsx +412 -0
- package/src/ui/app/TraceListPane.tsx +34 -0
- package/src/ui/app/TraceWorkspace.tsx +254 -0
- package/src/ui/app/useAppLayout.ts +79 -0
- package/src/ui/app/useTraceScreenData.ts +411 -0
- package/src/ui/format.ts +119 -0
- package/src/ui/primitives.tsx +170 -0
- package/src/ui/state.ts +137 -0
- package/src/ui/theme.ts +153 -0
- package/src/ui/traceDetailsWidth.repro.test.ts +115 -0
- package/src/ui/traceSortNav.repro.seed.ts +62 -0
- package/src/ui/traceSortNav.repro.test.ts +220 -0
- package/src/ui/useKeyboardNav.ts +532 -0
- package/src/ui/waterfallNav.repro.seed.ts +86 -0
- package/src/ui/waterfallNav.repro.test.ts +263 -0
- package/src/ui/waterfallNav.test.ts +422 -0
- package/src/ui/waterfallNav.ts +75 -0
- package/web/dist/assets/index-BEKIiisE.js +27 -0
- package/web/dist/assets/index-DzuHNBGV.css +2 -0
- package/web/dist/index.html +13 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { TraceSpanItem } from "../domain.ts"
|
|
2
|
+
import { findFirstChildIndex, findParentIndex, getVisibleSpans } from "./Waterfall.tsx"
|
|
3
|
+
|
|
4
|
+
export type CollapseStep = {
|
|
5
|
+
readonly collapsed: ReadonlySet<string>
|
|
6
|
+
readonly selectedIndex: number | null
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type ResolveCollapseParams = {
|
|
10
|
+
readonly spans: readonly TraceSpanItem[]
|
|
11
|
+
readonly collapsed: ReadonlySet<string>
|
|
12
|
+
readonly selectedIndex: number | null
|
|
13
|
+
readonly direction: "left" | "right"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Pure resolver for the `h` (left) / `l` (right) keys in the waterfall.
|
|
18
|
+
*
|
|
19
|
+
* Semantics:
|
|
20
|
+
* - `right`: if the selected span has children and is currently collapsed,
|
|
21
|
+
* expand it; selection stays on the same span. Otherwise, if it has visible
|
|
22
|
+
* children, move selection to its first child. Otherwise no-op.
|
|
23
|
+
* - `left`: if the selected span has children and is currently expanded,
|
|
24
|
+
* collapse it; selection stays on the same span. Otherwise, if it has a
|
|
25
|
+
* parent in the visible list, move selection to that parent. Otherwise no-op.
|
|
26
|
+
*
|
|
27
|
+
* Stale or out-of-range selection indices are treated as no-ops rather than
|
|
28
|
+
* crashing — defensive against the one-frame window between a state change
|
|
29
|
+
* and the next render.
|
|
30
|
+
*/
|
|
31
|
+
export const resolveCollapseStep = ({
|
|
32
|
+
spans,
|
|
33
|
+
collapsed,
|
|
34
|
+
selectedIndex,
|
|
35
|
+
direction,
|
|
36
|
+
}: ResolveCollapseParams): CollapseStep => {
|
|
37
|
+
const noChange: CollapseStep = { collapsed, selectedIndex }
|
|
38
|
+
|
|
39
|
+
if (selectedIndex === null) return noChange
|
|
40
|
+
|
|
41
|
+
const visible = getVisibleSpans(spans, collapsed)
|
|
42
|
+
if (selectedIndex < 0 || selectedIndex >= visible.length) return noChange
|
|
43
|
+
|
|
44
|
+
const span = visible[selectedIndex]!
|
|
45
|
+
const fullIndex = spans.indexOf(span)
|
|
46
|
+
const hasChildren = fullIndex >= 0 && findFirstChildIndex(spans, fullIndex) !== null
|
|
47
|
+
const isCollapsed = collapsed.has(span.spanId)
|
|
48
|
+
|
|
49
|
+
if (direction === "right") {
|
|
50
|
+
// Expand a collapsed parent (selection stays).
|
|
51
|
+
if (hasChildren && isCollapsed) {
|
|
52
|
+
const next = new Set(collapsed)
|
|
53
|
+
next.delete(span.spanId)
|
|
54
|
+
return { collapsed: next, selectedIndex }
|
|
55
|
+
}
|
|
56
|
+
// Walk into first visible child.
|
|
57
|
+
if (hasChildren) {
|
|
58
|
+
const childIdx = findFirstChildIndex(visible, selectedIndex)
|
|
59
|
+
if (childIdx !== null) return { collapsed, selectedIndex: childIdx }
|
|
60
|
+
}
|
|
61
|
+
return noChange
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// direction === "left"
|
|
65
|
+
// Collapse an expanded parent (selection stays).
|
|
66
|
+
if (hasChildren && !isCollapsed) {
|
|
67
|
+
const next = new Set(collapsed)
|
|
68
|
+
next.add(span.spanId)
|
|
69
|
+
return { collapsed: next, selectedIndex }
|
|
70
|
+
}
|
|
71
|
+
// Walk to parent in the visible list.
|
|
72
|
+
const parentIdx = findParentIndex(visible, selectedIndex)
|
|
73
|
+
if (parentIdx !== null) return { collapsed, selectedIndex: parentIdx }
|
|
74
|
+
return noChange
|
|
75
|
+
}
|