@principal-ai/subsystems-react 0.39.0 → 0.40.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/dist/components/maintain-events/MaintainEventLog.d.ts +35 -0
- package/dist/components/maintain-events/MaintainEventLog.d.ts.map +1 -0
- package/dist/components/maintain-events/MaintainEventLog.js +66 -0
- package/dist/components/maintain-events/MaintainEventLog.js.map +1 -0
- package/dist/components/maintain-events/MaintainLivePanel.d.ts +15 -0
- package/dist/components/maintain-events/MaintainLivePanel.d.ts.map +1 -0
- package/dist/components/maintain-events/MaintainLivePanel.js +49 -0
- package/dist/components/maintain-events/MaintainLivePanel.js.map +1 -0
- package/dist/components/maintain-events/index.d.ts +8 -0
- package/dist/components/maintain-events/index.d.ts.map +1 -0
- package/dist/components/maintain-events/index.js +6 -0
- package/dist/components/maintain-events/index.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.d.ts +6 -0
- package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.js +3 -2
- package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
- package/package.json +1 -1
- package/src/components/maintain-events/MaintainEventLog.tsx +152 -0
- package/src/components/maintain-events/MaintainLivePanel.tsx +99 -0
- package/src/components/maintain-events/index.ts +10 -0
- package/src/index.ts +8 -0
- package/src/stories/MaintainEvents/MaintainEventLog.stories.tsx +66 -0
- package/src/stories/MaintainEvents/MaintainLivePanel.stories.tsx +77 -0
- package/src/stories/data/maintain-live-events.json +554 -0
- package/src/subsystem/SubsystemComponentGraph.tsx +11 -1
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MaintainLivePanel — a collapsible, half-height panel that overlays the graph
|
|
3
|
+
* canvas and streams a live agent run's events. Subsystems Studio supplies the
|
|
4
|
+
* state (status/events/total/error) and renders it through
|
|
5
|
+
* `SubsystemComponentGraph`'s `liveEvents` prop; collapsing leaves just the
|
|
6
|
+
* header bar so the graph stays readable.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { useState } from 'react';
|
|
10
|
+
import { useTheme } from '@principal-ade/industry-theme';
|
|
11
|
+
import { ChevronDown, ChevronUp } from 'lucide-react';
|
|
12
|
+
import { MaintainEventLog, type MaintainEventLogProps } from './MaintainEventLog';
|
|
13
|
+
|
|
14
|
+
export interface MaintainLivePanelProps extends MaintainEventLogProps {
|
|
15
|
+
/** Start collapsed (header only). @default false */
|
|
16
|
+
defaultCollapsed?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const HEADER_HEIGHT = 36;
|
|
20
|
+
|
|
21
|
+
export function MaintainLivePanel({
|
|
22
|
+
title,
|
|
23
|
+
agent,
|
|
24
|
+
sessionId,
|
|
25
|
+
status,
|
|
26
|
+
events,
|
|
27
|
+
total,
|
|
28
|
+
error,
|
|
29
|
+
defaultCollapsed = false,
|
|
30
|
+
}: MaintainLivePanelProps) {
|
|
31
|
+
const { theme } = useTheme();
|
|
32
|
+
const muted = theme.colors.textMuted ?? theme.colors.textSecondary;
|
|
33
|
+
const border = theme.colors.border ?? 'rgba(255,255,255,0.12)';
|
|
34
|
+
const [collapsed, setCollapsed] = useState(defaultCollapsed);
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div
|
|
38
|
+
style={{
|
|
39
|
+
position: 'absolute',
|
|
40
|
+
left: 0,
|
|
41
|
+
right: 0,
|
|
42
|
+
bottom: 0,
|
|
43
|
+
height: collapsed ? HEADER_HEIGHT : '50%',
|
|
44
|
+
zIndex: 5,
|
|
45
|
+
display: 'flex',
|
|
46
|
+
flexDirection: 'column',
|
|
47
|
+
background: theme.colors.backgroundSecondary ?? theme.colors.background,
|
|
48
|
+
borderTop: `1px solid ${border}`,
|
|
49
|
+
boxShadow: '0 -8px 24px rgba(0,0,0,0.35)',
|
|
50
|
+
overflow: 'hidden',
|
|
51
|
+
}}
|
|
52
|
+
>
|
|
53
|
+
<button
|
|
54
|
+
type="button"
|
|
55
|
+
onClick={() => setCollapsed((c) => !c)}
|
|
56
|
+
style={{
|
|
57
|
+
display: 'flex',
|
|
58
|
+
alignItems: 'center',
|
|
59
|
+
gap: 8,
|
|
60
|
+
height: HEADER_HEIGHT,
|
|
61
|
+
flexShrink: 0,
|
|
62
|
+
padding: '0 12px',
|
|
63
|
+
border: 'none',
|
|
64
|
+
borderBottom: collapsed ? 'none' : `1px solid ${border}`,
|
|
65
|
+
background: 'transparent',
|
|
66
|
+
color: theme.colors.text,
|
|
67
|
+
fontFamily: theme.fonts.body,
|
|
68
|
+
fontSize: theme.fontSizes[0],
|
|
69
|
+
cursor: 'pointer',
|
|
70
|
+
textAlign: 'left',
|
|
71
|
+
}}
|
|
72
|
+
>
|
|
73
|
+
{collapsed ? <ChevronUp size={14} /> : <ChevronDown size={14} />}
|
|
74
|
+
<span style={{ fontWeight: 600 }}>Live events</span>
|
|
75
|
+
{agent ? <span style={{ color: muted }}>{agent}</span> : null}
|
|
76
|
+
{status ? <span style={{ color: muted }}>· {status}</span> : null}
|
|
77
|
+
{total > 0 ? <span style={{ color: muted }}>· {total} events</span> : null}
|
|
78
|
+
<span style={{ flex: 1 }} />
|
|
79
|
+
{sessionId ? (
|
|
80
|
+
<span style={{ color: muted, fontFamily: theme.fonts.monospace }}>{sessionId}</span>
|
|
81
|
+
) : null}
|
|
82
|
+
</button>
|
|
83
|
+
{!collapsed ? (
|
|
84
|
+
<div style={{ flex: 1, minHeight: 0 }}>
|
|
85
|
+
<MaintainEventLog
|
|
86
|
+
title={title}
|
|
87
|
+
agent={agent}
|
|
88
|
+
sessionId={sessionId}
|
|
89
|
+
status={status}
|
|
90
|
+
events={events}
|
|
91
|
+
total={total}
|
|
92
|
+
error={error}
|
|
93
|
+
showHeader={false}
|
|
94
|
+
/>
|
|
95
|
+
</div>
|
|
96
|
+
) : null}
|
|
97
|
+
</div>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maintain event log — presentational live OpenCode agent-run event feed.
|
|
3
|
+
*/
|
|
4
|
+
export { MaintainEventLog } from './MaintainEventLog';
|
|
5
|
+
export type {
|
|
6
|
+
MaintainEventLogEvent,
|
|
7
|
+
MaintainEventLogProps,
|
|
8
|
+
} from './MaintainEventLog';
|
|
9
|
+
export { MaintainLivePanel } from './MaintainLivePanel';
|
|
10
|
+
export type { MaintainLivePanelProps } from './MaintainLivePanel';
|
package/src/index.ts
CHANGED
|
@@ -16,6 +16,14 @@ export type {
|
|
|
16
16
|
SessionEventFeedRow,
|
|
17
17
|
} from './components/session-events';
|
|
18
18
|
|
|
19
|
+
// Maintain event log — presentational live OpenCode agent-run event feed
|
|
20
|
+
export { MaintainEventLog, MaintainLivePanel } from './components/maintain-events';
|
|
21
|
+
export type {
|
|
22
|
+
MaintainEventLogEvent,
|
|
23
|
+
MaintainEventLogProps,
|
|
24
|
+
MaintainLivePanelProps,
|
|
25
|
+
} from './components/maintain-events';
|
|
26
|
+
|
|
19
27
|
// Graphify integration types (graph.json data model)
|
|
20
28
|
export type {
|
|
21
29
|
JsonValue,
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maintain Event Log — presentational live agent-run event feed.
|
|
3
|
+
*
|
|
4
|
+
* The `Live` story replays a fixture derived from a real OpenCode V2 agent
|
|
5
|
+
* session (`packages/subsystems-core/src/opencode/__fixtures__/session-events.json`),
|
|
6
|
+
* mapped to the live-feed vocabulary (`session.next.*` / `session.status`) and
|
|
7
|
+
* summarized the same way the host's `/api/event` subscription is
|
|
8
|
+
* (`summarizeEvent` in `subsystems-studio/src/bun/opencode-v2-live.ts`).
|
|
9
|
+
*/
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
12
|
+
import { ThemeProvider, defaultEditorTheme } from '@principal-ade/industry-theme';
|
|
13
|
+
import {
|
|
14
|
+
MaintainEventLog,
|
|
15
|
+
type MaintainEventLogEvent,
|
|
16
|
+
} from '../../components/maintain-events';
|
|
17
|
+
import liveEvents from '../data/maintain-live-events.json';
|
|
18
|
+
|
|
19
|
+
const events = liveEvents as MaintainEventLogEvent[];
|
|
20
|
+
|
|
21
|
+
const meta = {
|
|
22
|
+
title: 'Agent Sessions/Maintain Event Log',
|
|
23
|
+
component: MaintainEventLog,
|
|
24
|
+
parameters: { layout: 'fullscreen' },
|
|
25
|
+
tags: ['autodocs'],
|
|
26
|
+
decorators: [
|
|
27
|
+
(Story) => (
|
|
28
|
+
<ThemeProvider theme={defaultEditorTheme}>
|
|
29
|
+
<div
|
|
30
|
+
style={{
|
|
31
|
+
height: '100vh',
|
|
32
|
+
background: defaultEditorTheme.colors.background,
|
|
33
|
+
color: defaultEditorTheme.colors.text,
|
|
34
|
+
}}
|
|
35
|
+
>
|
|
36
|
+
<Story />
|
|
37
|
+
</div>
|
|
38
|
+
</ThemeProvider>
|
|
39
|
+
),
|
|
40
|
+
],
|
|
41
|
+
args: {
|
|
42
|
+
title: 'Maintain events',
|
|
43
|
+
agent: 'construct-verifier',
|
|
44
|
+
sessionId: 'ses_056b1f037ffeu1d00DzvJBrHq9',
|
|
45
|
+
status: 'running',
|
|
46
|
+
events,
|
|
47
|
+
total: events.length,
|
|
48
|
+
},
|
|
49
|
+
} satisfies Meta<typeof MaintainEventLog>;
|
|
50
|
+
|
|
51
|
+
export default meta;
|
|
52
|
+
type Story = StoryObj<typeof meta>;
|
|
53
|
+
|
|
54
|
+
export const Live: Story = {};
|
|
55
|
+
|
|
56
|
+
export const WaitingForSession: Story = {
|
|
57
|
+
args: { sessionId: undefined, events: [], total: 0, status: 'starting' },
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const WaitingForEvents: Story = {
|
|
61
|
+
args: { events: [], total: 0 },
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const WithError: Story = {
|
|
65
|
+
args: { error: 'live event stream dropped — reconnecting and reconciling with server state' },
|
|
66
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maintain Live Panel — the collapsible half-height live-agent-run panel that
|
|
3
|
+
* `SubsystemComponentGraph` renders over its canvas via the `liveEvents` prop.
|
|
4
|
+
*
|
|
5
|
+
* The fixture replays a real OpenCode V2 agent session
|
|
6
|
+
* (`packages/subsystems-core/src/opencode/__fixtures__/session-events.json`),
|
|
7
|
+
* mapped to the live-feed vocabulary and summarized like the host's
|
|
8
|
+
* `/api/event` subscription.
|
|
9
|
+
*/
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
12
|
+
import { ThemeProvider, defaultEditorTheme } from '@principal-ade/industry-theme';
|
|
13
|
+
import {
|
|
14
|
+
MaintainLivePanel,
|
|
15
|
+
type MaintainEventLogEvent,
|
|
16
|
+
} from '../../components/maintain-events';
|
|
17
|
+
import liveEvents from '../data/maintain-live-events.json';
|
|
18
|
+
|
|
19
|
+
const events = liveEvents as MaintainEventLogEvent[];
|
|
20
|
+
|
|
21
|
+
const meta = {
|
|
22
|
+
title: 'Agent Sessions/Maintain Live Panel',
|
|
23
|
+
component: MaintainLivePanel,
|
|
24
|
+
parameters: { layout: 'fullscreen' },
|
|
25
|
+
tags: ['autodocs'],
|
|
26
|
+
decorators: [
|
|
27
|
+
(Story) => (
|
|
28
|
+
<ThemeProvider theme={defaultEditorTheme}>
|
|
29
|
+
<div
|
|
30
|
+
style={{
|
|
31
|
+
position: 'relative',
|
|
32
|
+
height: '100vh',
|
|
33
|
+
overflow: 'hidden',
|
|
34
|
+
background: defaultEditorTheme.colors.background,
|
|
35
|
+
color: defaultEditorTheme.colors.text,
|
|
36
|
+
}}
|
|
37
|
+
>
|
|
38
|
+
<div
|
|
39
|
+
style={{
|
|
40
|
+
position: 'absolute',
|
|
41
|
+
inset: 0,
|
|
42
|
+
display: 'grid',
|
|
43
|
+
placeItems: 'center',
|
|
44
|
+
color: defaultEditorTheme.colors.textMuted,
|
|
45
|
+
fontFamily: defaultEditorTheme.fonts.monospace,
|
|
46
|
+
fontSize: 13,
|
|
47
|
+
}}
|
|
48
|
+
>
|
|
49
|
+
graph canvas
|
|
50
|
+
</div>
|
|
51
|
+
<Story />
|
|
52
|
+
</div>
|
|
53
|
+
</ThemeProvider>
|
|
54
|
+
),
|
|
55
|
+
],
|
|
56
|
+
args: {
|
|
57
|
+
title: 'Maintain events',
|
|
58
|
+
agent: 'construct-verifier',
|
|
59
|
+
sessionId: 'ses_056b1f037ffeu1d00DzvJBrHq9',
|
|
60
|
+
status: 'running',
|
|
61
|
+
events,
|
|
62
|
+
total: events.length,
|
|
63
|
+
},
|
|
64
|
+
} satisfies Meta<typeof MaintainLivePanel>;
|
|
65
|
+
|
|
66
|
+
export default meta;
|
|
67
|
+
type Story = StoryObj<typeof meta>;
|
|
68
|
+
|
|
69
|
+
export const Expanded: Story = {};
|
|
70
|
+
|
|
71
|
+
export const Collapsed: Story = {
|
|
72
|
+
args: { defaultCollapsed: true },
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const WaitingForEvents: Story = {
|
|
76
|
+
args: { events: [], total: 0 },
|
|
77
|
+
};
|