@dxos/react-ui-trace 0.11.1
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/LICENSE +105 -0
- package/README.md +3 -0
- package/dist/lib/index.mjs +2868 -0
- package/dist/lib/index.mjs.map +1 -0
- package/dist/lib/testing.mjs +338 -0
- package/dist/lib/testing.mjs.map +1 -0
- package/dist/lib/translations.mjs +19 -0
- package/dist/lib/translations.mjs.map +1 -0
- package/dist/types/src/components/Gantt/Gantt.d.ts +68 -0
- package/dist/types/src/components/Gantt/Gantt.d.ts.map +1 -0
- package/dist/types/src/components/Gantt/Gantt.stories.d.ts +30 -0
- package/dist/types/src/components/Gantt/Gantt.stories.d.ts.map +1 -0
- package/dist/types/src/components/Gantt/index.d.ts +2 -0
- package/dist/types/src/components/Gantt/index.d.ts.map +1 -0
- package/dist/types/src/components/ProcessTree/ProcessTree.d.ts +32 -0
- package/dist/types/src/components/ProcessTree/ProcessTree.d.ts.map +1 -0
- package/dist/types/src/components/ProcessTree/ProcessTree.stories.d.ts +8 -0
- package/dist/types/src/components/ProcessTree/ProcessTree.stories.d.ts.map +1 -0
- package/dist/types/src/components/ProcessTree/index.d.ts +2 -0
- package/dist/types/src/components/ProcessTree/index.d.ts.map +1 -0
- package/dist/types/src/components/Timeline/Timeline.d.ts +50 -0
- package/dist/types/src/components/Timeline/Timeline.d.ts.map +1 -0
- package/dist/types/src/components/Timeline/Timeline.stories.d.ts +24 -0
- package/dist/types/src/components/Timeline/Timeline.stories.d.ts.map +1 -0
- package/dist/types/src/components/Timeline/index.d.ts +4 -0
- package/dist/types/src/components/Timeline/index.d.ts.map +1 -0
- package/dist/types/src/components/Timeline/timeline-options.d.ts +9 -0
- package/dist/types/src/components/Timeline/timeline-options.d.ts.map +1 -0
- package/dist/types/src/components/Timeline/timeline-printer.d.ts +7 -0
- package/dist/types/src/components/Timeline/timeline-printer.d.ts.map +1 -0
- package/dist/types/src/components/Timeline/timeline-printer.test.d.ts +2 -0
- package/dist/types/src/components/Timeline/timeline-printer.test.d.ts.map +1 -0
- package/dist/types/src/components/TracePanel/TracePanel.d.ts +28 -0
- package/dist/types/src/components/TracePanel/TracePanel.d.ts.map +1 -0
- package/dist/types/src/components/TracePanel/dxn-extractor.d.ts +19 -0
- package/dist/types/src/components/TracePanel/dxn-extractor.d.ts.map +1 -0
- package/dist/types/src/components/TracePanel/dxn-extractor.test.d.ts +2 -0
- package/dist/types/src/components/TracePanel/dxn-extractor.test.d.ts.map +1 -0
- package/dist/types/src/components/TracePanel/index.d.ts +4 -0
- package/dist/types/src/components/TracePanel/index.d.ts.map +1 -0
- package/dist/types/src/components/TracePanel/trace-filter.d.ts +39 -0
- package/dist/types/src/components/TracePanel/trace-filter.d.ts.map +1 -0
- package/dist/types/src/components/TracePanel/trace-filter.test.d.ts +2 -0
- package/dist/types/src/components/TracePanel/trace-filter.test.d.ts.map +1 -0
- package/dist/types/src/components/TracePanel/useTraceMenu.d.ts +15 -0
- package/dist/types/src/components/TracePanel/useTraceMenu.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +5 -0
- package/dist/types/src/components/index.d.ts.map +1 -0
- package/dist/types/src/execution-graph/execution-graph.d.ts +139 -0
- package/dist/types/src/execution-graph/execution-graph.d.ts.map +1 -0
- package/dist/types/src/execution-graph/execution-graph.test.d.ts +2 -0
- package/dist/types/src/execution-graph/execution-graph.test.d.ts.map +1 -0
- package/dist/types/src/execution-graph/index.d.ts +4 -0
- package/dist/types/src/execution-graph/index.d.ts.map +1 -0
- package/dist/types/src/execution-graph/pending-block-status.d.ts +26 -0
- package/dist/types/src/execution-graph/pending-block-status.d.ts.map +1 -0
- package/dist/types/src/execution-graph/pending-block-status.test.d.ts +2 -0
- package/dist/types/src/execution-graph/pending-block-status.test.d.ts.map +1 -0
- package/dist/types/src/execution-graph/remote-snapshot.test.d.ts +2 -0
- package/dist/types/src/execution-graph/remote-snapshot.test.d.ts.map +1 -0
- package/dist/types/src/execution-graph/span-tree.d.ts +106 -0
- package/dist/types/src/execution-graph/span-tree.d.ts.map +1 -0
- package/dist/types/src/execution-graph/span-tree.test.d.ts +2 -0
- package/dist/types/src/execution-graph/span-tree.test.d.ts.map +1 -0
- package/dist/types/src/execution-graph/sub-agent-delegation.test.d.ts +2 -0
- package/dist/types/src/execution-graph/sub-agent-delegation.test.d.ts.map +1 -0
- package/dist/types/src/execution-graph/testing/collect-trace-events.d.ts +40 -0
- package/dist/types/src/execution-graph/testing/collect-trace-events.d.ts.map +1 -0
- package/dist/types/src/execution-graph/testing/index.d.ts +2 -0
- package/dist/types/src/execution-graph/testing/index.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +4 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useExecutionGraph.d.ts +17 -0
- package/dist/types/src/hooks/useExecutionGraph.d.ts.map +1 -0
- package/dist/types/src/hooks/useSessionTimeline.d.ts +17 -0
- package/dist/types/src/hooks/useSessionTimeline.d.ts.map +1 -0
- package/dist/types/src/hooks/useTraceMessages.d.ts +17 -0
- package/dist/types/src/hooks/useTraceMessages.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +5 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/session-timeline/index.d.ts +3 -0
- package/dist/types/src/session-timeline/index.d.ts.map +1 -0
- package/dist/types/src/session-timeline/session-timeline.d.ts +19 -0
- package/dist/types/src/session-timeline/session-timeline.d.ts.map +1 -0
- package/dist/types/src/session-timeline/session-timeline.test.d.ts +2 -0
- package/dist/types/src/session-timeline/session-timeline.test.d.ts.map +1 -0
- package/dist/types/src/session-timeline/types.d.ts +129 -0
- package/dist/types/src/session-timeline/types.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +5 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/simulated-agent.d.ts +63 -0
- package/dist/types/src/testing/simulated-agent.d.ts.map +1 -0
- package/dist/types/src/testing/snapshot-playback.d.ts +12 -0
- package/dist/types/src/testing/snapshot-playback.d.ts.map +1 -0
- package/dist/types/src/testing/test-trace.d.ts +5 -0
- package/dist/types/src/testing/test-trace.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +19 -0
- package/dist/types/src/translations.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +77 -0
- package/src/components/Gantt/Gantt.stories.tsx +241 -0
- package/src/components/Gantt/Gantt.tsx +589 -0
- package/src/components/Gantt/index.ts +5 -0
- package/src/components/ProcessTree/ProcessTree.stories.tsx +95 -0
- package/src/components/ProcessTree/ProcessTree.tsx +265 -0
- package/src/components/ProcessTree/index.ts +5 -0
- package/src/components/Timeline/Timeline.stories.tsx +326 -0
- package/src/components/Timeline/Timeline.tsx +534 -0
- package/src/components/Timeline/git.drawio.svg +821 -0
- package/src/components/Timeline/index.ts +7 -0
- package/src/components/Timeline/timeline-options.ts +27 -0
- package/src/components/Timeline/timeline-printer.test.ts +76 -0
- package/src/components/Timeline/timeline-printer.ts +223 -0
- package/src/components/TracePanel/TracePanel.tsx +248 -0
- package/src/components/TracePanel/dxn-extractor.test.ts +153 -0
- package/src/components/TracePanel/dxn-extractor.ts +166 -0
- package/src/components/TracePanel/index.ts +7 -0
- package/src/components/TracePanel/trace-filter.test.ts +137 -0
- package/src/components/TracePanel/trace-filter.ts +120 -0
- package/src/components/TracePanel/useTraceMenu.ts +95 -0
- package/src/components/index.ts +8 -0
- package/src/execution-graph/SPEC.md +749 -0
- package/src/execution-graph/execution-graph.test.ts +1205 -0
- package/src/execution-graph/execution-graph.ts +1076 -0
- package/src/execution-graph/index.ts +35 -0
- package/src/execution-graph/pending-block-status.test.ts +118 -0
- package/src/execution-graph/pending-block-status.ts +88 -0
- package/src/execution-graph/remote-snapshot.test.ts +116 -0
- package/src/execution-graph/span-tree.test.ts +370 -0
- package/src/execution-graph/span-tree.ts +404 -0
- package/src/execution-graph/sub-agent-delegation.test.ts +65 -0
- package/src/execution-graph/testing/collect-trace-events.ts +76 -0
- package/src/execution-graph/testing/index.ts +5 -0
- package/src/execution-graph/testing/sub-agent-delegation.json +1285 -0
- package/src/hooks/index.ts +7 -0
- package/src/hooks/useExecutionGraph.ts +107 -0
- package/src/hooks/useSessionTimeline.ts +53 -0
- package/src/hooks/useTraceMessages.ts +58 -0
- package/src/index.ts +8 -0
- package/src/session-timeline/index.ts +6 -0
- package/src/session-timeline/session-timeline.test.ts +662 -0
- package/src/session-timeline/session-timeline.ts +605 -0
- package/src/session-timeline/types.ts +100 -0
- package/src/testing/index.ts +8 -0
- package/src/testing/simulated-agent.ts +293 -0
- package/src/testing/snapshot-playback.ts +45 -0
- package/src/testing/test-trace.ts +22 -0
- package/src/translations.ts +29 -0
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dxos/react-ui-trace",
|
|
3
|
+
"version": "0.11.1",
|
|
4
|
+
"description": "Runtime observability: process tree, trace timeline, session gantt.",
|
|
5
|
+
"homepage": "https://dxos.org",
|
|
6
|
+
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dxos/dxos"
|
|
10
|
+
},
|
|
11
|
+
"license": "FSL-1.1-Apache-2.0",
|
|
12
|
+
"author": "DXOS.org",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"source": "./src/index.ts",
|
|
17
|
+
"types": "./dist/types/src/index.d.ts",
|
|
18
|
+
"import": "./dist/lib/index.mjs"
|
|
19
|
+
},
|
|
20
|
+
"./testing": {
|
|
21
|
+
"source": "./src/testing/index.ts",
|
|
22
|
+
"types": "./dist/types/src/testing/index.d.ts",
|
|
23
|
+
"import": "./dist/lib/testing.mjs"
|
|
24
|
+
},
|
|
25
|
+
"./translations": {
|
|
26
|
+
"source": "./src/translations.ts",
|
|
27
|
+
"types": "./dist/types/src/translations.d.ts",
|
|
28
|
+
"import": "./dist/lib/translations.mjs"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"types": "dist/types/src/index.d.ts",
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"src"
|
|
35
|
+
],
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@effect/atom-react": "4.0.0-rc.115",
|
|
38
|
+
"date-fns": "^3.6.0",
|
|
39
|
+
"effect": "4.0.0-rc.115",
|
|
40
|
+
"@dxos/async": "0.11.1",
|
|
41
|
+
"@dxos/compute": "0.11.1",
|
|
42
|
+
"@dxos/compute-runtime": "0.11.1",
|
|
43
|
+
"@dxos/echo": "0.11.1",
|
|
44
|
+
"@dxos/keys": "0.11.1",
|
|
45
|
+
"@dxos/log": "0.11.1",
|
|
46
|
+
"@dxos/react-hooks": "0.11.1",
|
|
47
|
+
"@dxos/react-ui-components": "0.11.1",
|
|
48
|
+
"@dxos/react-client": "0.11.1",
|
|
49
|
+
"@dxos/react-ui-list": "0.11.1",
|
|
50
|
+
"@dxos/react-ui-menu": "0.11.1",
|
|
51
|
+
"@dxos/types": "0.11.1",
|
|
52
|
+
"@dxos/react-ui-syntax-highlighter": "0.11.1",
|
|
53
|
+
"@dxos/util": "0.11.1"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@storybook/react-vite": "^10.5.8",
|
|
57
|
+
"@types/react": "~19.2.17",
|
|
58
|
+
"@types/react-dom": "~19.2.3",
|
|
59
|
+
"react": "~19.2.7",
|
|
60
|
+
"react-dom": "~19.2.7",
|
|
61
|
+
"vite": "^8.2.1",
|
|
62
|
+
"@dxos/random": "0.11.1",
|
|
63
|
+
"@dxos/react-ui": "0.11.1",
|
|
64
|
+
"@dxos/storybook-utils": "0.11.1",
|
|
65
|
+
"@dxos/ui-theme": "0.11.1"
|
|
66
|
+
},
|
|
67
|
+
"peerDependencies": {
|
|
68
|
+
"effect": "4.0.0-rc.115",
|
|
69
|
+
"react": "~19.2.7",
|
|
70
|
+
"react-dom": "~19.2.7",
|
|
71
|
+
"@dxos/react-ui": "^0.11.1",
|
|
72
|
+
"@dxos/ui-theme": "^0.11.1"
|
|
73
|
+
},
|
|
74
|
+
"publishConfig": {
|
|
75
|
+
"access": "public"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React, { type ReactNode, useEffect, useState } from 'react';
|
|
7
|
+
|
|
8
|
+
import { random } from '@dxos/random';
|
|
9
|
+
import { JsonHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
10
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
11
|
+
|
|
12
|
+
import { Gantt, type GanttData, type GanttLane, type GanttMarker } from './Gantt.tsx';
|
|
13
|
+
|
|
14
|
+
random.seed(1);
|
|
15
|
+
|
|
16
|
+
const T0 = Date.UTC(2026, 8, 11, 10, 0, 0);
|
|
17
|
+
const MINUTE = 60_000;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Process A works two tasks itself and spawns process B for a third, which in turn works two subtasks
|
|
21
|
+
* in-session; process C is a second spawn from A. Two runs have terminated (one failed), the rest are
|
|
22
|
+
* still going, and the last task waits on C.
|
|
23
|
+
*/
|
|
24
|
+
const lanes: GanttLane[] = [
|
|
25
|
+
{
|
|
26
|
+
id: 'a',
|
|
27
|
+
kind: 'session',
|
|
28
|
+
label: 'Process A — Plan the release',
|
|
29
|
+
status: 'running',
|
|
30
|
+
start: T0,
|
|
31
|
+
tokens: { input: 12_400, output: 3_100, total: 15_500 },
|
|
32
|
+
toolCalls: 6,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: 'a:triage',
|
|
36
|
+
kind: 'task',
|
|
37
|
+
taskId: 'task:triage',
|
|
38
|
+
label: 'Triage open issues',
|
|
39
|
+
status: 'done',
|
|
40
|
+
parentId: 'a',
|
|
41
|
+
start: T0 + 0.5 * MINUTE,
|
|
42
|
+
end: T0 + 1.8 * MINUTE,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 'a:docs',
|
|
46
|
+
kind: 'task',
|
|
47
|
+
taskId: 'task:docs',
|
|
48
|
+
label: 'Update docs',
|
|
49
|
+
status: 'failed',
|
|
50
|
+
parentId: 'a',
|
|
51
|
+
start: T0 + 2.4 * MINUTE,
|
|
52
|
+
end: T0 + 3.6 * MINUTE,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: 'b',
|
|
56
|
+
kind: 'session',
|
|
57
|
+
taskId: 'task:changelog',
|
|
58
|
+
label: 'Process B — Draft changelog',
|
|
59
|
+
status: 'done',
|
|
60
|
+
parentId: 'a',
|
|
61
|
+
start: T0 + 4.1 * MINUTE,
|
|
62
|
+
end: T0 + 7.2 * MINUTE,
|
|
63
|
+
delegatedFrom: { laneId: 'a', markerId: 'm:a-spawn-b' },
|
|
64
|
+
tokens: { input: 40_200, output: 8_900, total: 49_100 },
|
|
65
|
+
toolCalls: 4,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: 'b:titles',
|
|
69
|
+
kind: 'task',
|
|
70
|
+
taskId: 'task:titles',
|
|
71
|
+
label: 'Collect PR titles',
|
|
72
|
+
status: 'done',
|
|
73
|
+
parentId: 'b',
|
|
74
|
+
start: T0 + 4.6 * MINUTE,
|
|
75
|
+
end: T0 + 5.7 * MINUTE,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: 'b:highlights',
|
|
79
|
+
kind: 'task',
|
|
80
|
+
taskId: 'task:highlights',
|
|
81
|
+
label: 'Write highlights',
|
|
82
|
+
status: 'done',
|
|
83
|
+
parentId: 'b',
|
|
84
|
+
start: T0 + 6 * MINUTE,
|
|
85
|
+
end: T0 + 6.9 * MINUTE,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
id: 'c',
|
|
89
|
+
kind: 'session',
|
|
90
|
+
taskId: 'task:notes',
|
|
91
|
+
label: 'Process C — Write release notes',
|
|
92
|
+
status: 'running',
|
|
93
|
+
parentId: 'a',
|
|
94
|
+
start: T0 + 5.1 * MINUTE,
|
|
95
|
+
delegatedFrom: { laneId: 'a', markerId: 'm:a-spawn-c' },
|
|
96
|
+
tokens: { input: 8_000, output: 900, total: 8_900 },
|
|
97
|
+
toolCalls: 2,
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
id: 'a:announce',
|
|
101
|
+
kind: 'task',
|
|
102
|
+
taskId: 'task:announce',
|
|
103
|
+
label: 'Publish announcement',
|
|
104
|
+
status: 'blocked',
|
|
105
|
+
parentId: 'a',
|
|
106
|
+
blockedOn: ['c'],
|
|
107
|
+
},
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
const markers: GanttMarker[] = [
|
|
111
|
+
{ id: 'm:a-begin', laneId: 'a', kind: 'request', timestamp: T0, label: 'Request started' },
|
|
112
|
+
{ id: 'm:a-user', laneId: 'a', kind: 'message', timestamp: T0 + 0.2 * MINUTE, label: 'Plan the release' },
|
|
113
|
+
{ id: 'm:a-spawn-b', laneId: 'a', kind: 'delegation', timestamp: T0 + 4 * MINUTE, label: 'Spawned process B' },
|
|
114
|
+
{ id: 'm:a-spawn-c', laneId: 'a', kind: 'delegation', timestamp: T0 + 5 * MINUTE, label: 'Spawned process C' },
|
|
115
|
+
{ id: 'm:a-end', laneId: 'a', kind: 'request', timestamp: T0 + 5.4 * MINUTE, label: 'Request success' },
|
|
116
|
+
|
|
117
|
+
{ id: 'm:triage-start', laneId: 'a:triage', kind: 'operation', timestamp: T0 + 0.5 * MINUTE, label: 'Started' },
|
|
118
|
+
{ id: 'm:triage-tool', laneId: 'a:triage', kind: 'tool', timestamp: T0 + 1.1 * MINUTE, label: 'list-issues' },
|
|
119
|
+
{ id: 'm:triage-end', laneId: 'a:triage', kind: 'operation', timestamp: T0 + 1.8 * MINUTE, label: 'Done' },
|
|
120
|
+
|
|
121
|
+
{ id: 'm:docs-start', laneId: 'a:docs', kind: 'operation', timestamp: T0 + 2.4 * MINUTE, label: 'Started' },
|
|
122
|
+
{ id: 'm:docs-tool', laneId: 'a:docs', kind: 'tool', timestamp: T0 + 3 * MINUTE, label: 'search' },
|
|
123
|
+
{
|
|
124
|
+
id: 'm:docs-fail',
|
|
125
|
+
laneId: 'a:docs',
|
|
126
|
+
kind: 'error',
|
|
127
|
+
timestamp: T0 + 3.6 * MINUTE,
|
|
128
|
+
label: 'Add artifact',
|
|
129
|
+
level: 'error',
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
{ id: 'm:b-start', laneId: 'b', kind: 'operation', timestamp: T0 + 4.1 * MINUTE, label: 'Run Instructions' },
|
|
133
|
+
{ id: 'm:b-tool', laneId: 'b', kind: 'tool', timestamp: T0 + 4.3 * MINUTE, label: 'read-project' },
|
|
134
|
+
{ id: 'm:b-end', laneId: 'b', kind: 'operation', timestamp: T0 + 7.2 * MINUTE, label: 'Run Instructions' },
|
|
135
|
+
|
|
136
|
+
{ id: 'm:titles-start', laneId: 'b:titles', kind: 'operation', timestamp: T0 + 4.6 * MINUTE, label: 'Started' },
|
|
137
|
+
{ id: 'm:titles-tool', laneId: 'b:titles', kind: 'tool', timestamp: T0 + 5.2 * MINUTE, label: 'list-pull-requests' },
|
|
138
|
+
{ id: 'm:titles-end', laneId: 'b:titles', kind: 'operation', timestamp: T0 + 5.7 * MINUTE, label: 'Done' },
|
|
139
|
+
|
|
140
|
+
{ id: 'm:highlights-start', laneId: 'b:highlights', kind: 'operation', timestamp: T0 + 6 * MINUTE, label: 'Started' },
|
|
141
|
+
{
|
|
142
|
+
id: 'm:highlights-tool',
|
|
143
|
+
laneId: 'b:highlights',
|
|
144
|
+
kind: 'tool',
|
|
145
|
+
timestamp: T0 + 6.4 * MINUTE,
|
|
146
|
+
label: 'create-document',
|
|
147
|
+
},
|
|
148
|
+
{ id: 'm:highlights-end', laneId: 'b:highlights', kind: 'operation', timestamp: T0 + 6.9 * MINUTE, label: 'Done' },
|
|
149
|
+
|
|
150
|
+
{ id: 'm:c-start', laneId: 'c', kind: 'operation', timestamp: T0 + 5.1 * MINUTE, label: 'Run Instructions' },
|
|
151
|
+
{ id: 'm:c-tool-1', laneId: 'c', kind: 'tool', timestamp: T0 + 6.6 * MINUTE, label: 'search' },
|
|
152
|
+
{ id: 'm:c-tool-2', laneId: 'c', kind: 'tool', timestamp: T0 + 8.3 * MINUTE, label: 'create-document' },
|
|
153
|
+
];
|
|
154
|
+
|
|
155
|
+
/** The chart over the data it was drawn from, so a reader can match a bar to its lane. */
|
|
156
|
+
const Layout = ({ chart, data }: { chart: ReactNode; data: unknown }) => (
|
|
157
|
+
<div className='flex flex-col dx-fill overflow-hidden'>
|
|
158
|
+
{chart}
|
|
159
|
+
<JsonHighlighter data={data} classNames='dx-grow border-t border-separator text-xs' />
|
|
160
|
+
</div>
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
type StoryArgs = GanttData & {
|
|
164
|
+
/** Render the drawing alone, as a host that already lists the lanes does. */
|
|
165
|
+
chartOnly?: boolean;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const Chart = ({ chartOnly, ...data }: StoryArgs) => (
|
|
169
|
+
<Gantt.Root {...data} classNames='p-4'>
|
|
170
|
+
{!chartOnly && <Gantt.Legend />}
|
|
171
|
+
<Gantt.Chart />
|
|
172
|
+
{!chartOnly && <Gantt.Meta />}
|
|
173
|
+
</Gantt.Root>
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
const DefaultStory = (props: StoryArgs) => (
|
|
177
|
+
<Layout
|
|
178
|
+
chart={<Chart {...props} />}
|
|
179
|
+
data={{ lanes: props.lanes, markers: props.markers, range: props.range, now: props.now }}
|
|
180
|
+
/>
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
/** Appends a tool marker to the running sub-agent every tick, so its box grows with `now`. */
|
|
184
|
+
const LiveStory = (props: StoryArgs) => {
|
|
185
|
+
const [now, setNow] = useState(T0 + 10 * MINUTE);
|
|
186
|
+
const [live, setLive] = useState<GanttMarker[]>([...(props.markers ?? [])]);
|
|
187
|
+
useEffect(() => {
|
|
188
|
+
const interval = setInterval(() => {
|
|
189
|
+
setNow((now) => {
|
|
190
|
+
const next = now + 0.5 * MINUTE;
|
|
191
|
+
setLive((markers) => [
|
|
192
|
+
...markers,
|
|
193
|
+
{
|
|
194
|
+
id: `m:live-${markers.length}`,
|
|
195
|
+
laneId: 'c',
|
|
196
|
+
kind: 'tool',
|
|
197
|
+
timestamp: next,
|
|
198
|
+
label: random.lorem.word(),
|
|
199
|
+
},
|
|
200
|
+
]);
|
|
201
|
+
return next;
|
|
202
|
+
});
|
|
203
|
+
}, 1_000);
|
|
204
|
+
return () => clearInterval(interval);
|
|
205
|
+
}, []);
|
|
206
|
+
const range = { start: T0, end: now + MINUTE };
|
|
207
|
+
return (
|
|
208
|
+
<Layout
|
|
209
|
+
chart={<Chart {...props} markers={live} now={now} range={range} />}
|
|
210
|
+
data={{ lanes: props.lanes, markers: live, range, now }}
|
|
211
|
+
/>
|
|
212
|
+
);
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const meta = {
|
|
216
|
+
title: 'ui/react-ui-components/Gantt',
|
|
217
|
+
render: DefaultStory,
|
|
218
|
+
decorators: [withTheme(), withLayout({ layout: 'fullscreen' })],
|
|
219
|
+
args: {
|
|
220
|
+
lanes,
|
|
221
|
+
markers,
|
|
222
|
+
now: T0 + 10 * MINUTE,
|
|
223
|
+
range: { start: T0, end: T0 + 11 * MINUTE },
|
|
224
|
+
onLaneSelect: (lane: GanttLane) => console.log('lane', lane),
|
|
225
|
+
onMarkerSelect: (marker: GanttMarker) => console.log('marker', marker),
|
|
226
|
+
},
|
|
227
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
228
|
+
|
|
229
|
+
export default meta;
|
|
230
|
+
|
|
231
|
+
type Story = StoryObj<typeof meta>;
|
|
232
|
+
|
|
233
|
+
export const Default: Story = {};
|
|
234
|
+
|
|
235
|
+
export const ChartOnly: Story = {
|
|
236
|
+
args: { chartOnly: true },
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
export const Live: Story = {
|
|
240
|
+
render: LiveStory,
|
|
241
|
+
};
|