@robosystems/core 0.13.0 → 0.13.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/components/console/ConsoleContent.d.ts +3 -1
- package/components/console/ConsoleContent.js +4 -3
- package/components/console/ConsoleDrawer.d.ts +15 -0
- package/components/console/ConsoleDrawer.js +129 -0
- package/components/console/index.d.ts +1 -0
- package/components/console/index.js +1 -0
- package/components/index.d.ts +1 -1
- package/components/index.js +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ConsoleConfig } from './types';
|
|
2
|
-
export declare function ConsoleContent({ config }: {
|
|
2
|
+
export declare function ConsoleContent({ config, variant, }: {
|
|
3
3
|
config: ConsoleConfig;
|
|
4
|
+
/** `panel` drops the page header and fills its container (the drawer). */
|
|
5
|
+
variant?: 'page' | 'panel';
|
|
4
6
|
}): import("react").JSX.Element;
|
|
@@ -75,7 +75,7 @@ function copyRowsJson(rows) {
|
|
|
75
75
|
var _a;
|
|
76
76
|
(_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.writeText(JSON.stringify(rows, null, 2));
|
|
77
77
|
}
|
|
78
|
-
export function ConsoleContent({ config }) {
|
|
78
|
+
export function ConsoleContent({ config, variant = 'page', }) {
|
|
79
79
|
const { state: graphState } = useGraphContext();
|
|
80
80
|
const graphId = graphState.currentGraphId;
|
|
81
81
|
const streamingQuery = useStreamingQuery();
|
|
@@ -738,10 +738,11 @@ export function ConsoleContent({ config }) {
|
|
|
738
738
|
};
|
|
739
739
|
// ── Render ──────────────────────────────────────────────────────────
|
|
740
740
|
const { header } = config;
|
|
741
|
-
|
|
741
|
+
const isPanel = variant === 'panel';
|
|
742
|
+
return (_jsxs("div", { className: isPanel ? 'h-full' : 'mx-auto max-w-7xl space-y-6 p-4 sm:p-6', children: [!isPanel && (_jsxs("div", { className: "flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between sm:gap-4", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-3 sm:gap-4", children: [_jsx("div", { className: `shrink-0 rounded-lg bg-gradient-to-br ${header.gradientFrom} ${header.gradientTo} p-2.5 sm:p-3`, children: _jsx(HiTerminal, { className: "h-6 w-6 text-white sm:h-8 sm:w-8" }) }), _jsxs("div", { className: "min-w-0", children: [_jsx("h1", { className: "font-heading text-2xl font-bold break-words text-gray-900 sm:text-3xl dark:text-white", children: header.title }), _jsx("p", { className: "mt-1 text-sm break-words text-gray-500 dark:text-gray-400", children: header.subtitle })] })] }), (streamingQuery.isStreaming || operatorProgress.isRunning) && (_jsxs("div", { className: "flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400", children: [_jsx("span", { className: "inline-block h-2 w-2 animate-pulse rounded-full bg-green-500" }), operatorProgress.isRunning && operatorProgress.message
|
|
742
743
|
? operatorProgress.message
|
|
743
744
|
: 'Processing...', operatorProgress.percentage !== undefined &&
|
|
744
|
-
` (${operatorProgress.percentage}%)`] }))] }), _jsx(Card, { className:
|
|
745
|
+
` (${operatorProgress.percentage}%)`] }))] })), _jsx(Card, { className: `overflow-hidden bg-gray-950 !p-0 [&>div]:!p-0 ${isPanel ? 'h-full rounded-none border-0 [&>div]:h-full' : ''}`, children: _jsxs("div", { className: "flex flex-col bg-gray-950", style: { height: isPanel ? '100%' : 'calc(100vh - 280px)' }, children: [_jsxs("div", { ref: terminalScrollRef, className: "flex-1 overflow-y-auto p-4 font-mono text-sm", children: [terminalMessages.map((message) => (_jsxs("div", { className: "mb-4", children: [_jsxs("div", { className: "mb-1 flex items-center gap-2 text-xs text-gray-700", children: [_jsx("span", { children: message.timestamp.toLocaleTimeString() }), _jsx("span", { children: "-" }), _jsx("span", { className: "tracking-wider uppercase", children: message.type })] }), _jsxs("div", { className: `leading-relaxed break-words ${message.markdown && !message.isAnimating
|
|
745
746
|
? ''
|
|
746
747
|
: 'whitespace-pre-wrap'} ${message.type === 'system'
|
|
747
748
|
? 'text-cyan-400'
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ConsoleConfig } from './types';
|
|
2
|
+
/** Height of the closed drawer's bar. */
|
|
3
|
+
export declare const CONSOLE_DRAWER_BAR_HEIGHT = 32;
|
|
4
|
+
/** Set on <html> to the space the drawer covers; pad page content by it. */
|
|
5
|
+
export declare const CONSOLE_DRAWER_HEIGHT_VAR = "--console-drawer-height";
|
|
6
|
+
/**
|
|
7
|
+
* The console as a bottom panel, like VS Code's: a thin bar when closed, a
|
|
8
|
+
* resizable panel when open, toggled with Ctrl+`. It stays mounted once
|
|
9
|
+
* opened, so the conversation survives closing it. `className` positions it,
|
|
10
|
+
* e.g. an offset for the app's sidebar.
|
|
11
|
+
*/
|
|
12
|
+
export declare function ConsoleDrawer({ config, className, }: {
|
|
13
|
+
config: ConsoleConfig;
|
|
14
|
+
className?: string;
|
|
15
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { HiChevronDown, HiChevronUp, HiOutlineArrowsExpand, HiOutlineMinus, HiTerminal, } from 'react-icons/hi';
|
|
5
|
+
import { ConsoleContent } from './ConsoleContent';
|
|
6
|
+
const STORAGE_KEY = 'robosystems:console-drawer';
|
|
7
|
+
/** Height of the closed drawer's bar. */
|
|
8
|
+
export const CONSOLE_DRAWER_BAR_HEIGHT = 32;
|
|
9
|
+
/** Set on <html> to the space the drawer covers; pad page content by it. */
|
|
10
|
+
export const CONSOLE_DRAWER_HEIGHT_VAR = '--console-drawer-height';
|
|
11
|
+
const DEFAULT_HEIGHT = 320;
|
|
12
|
+
const MIN_HEIGHT = 160;
|
|
13
|
+
// Leave the page's own header in view at full stretch.
|
|
14
|
+
const MAX_HEIGHT_RATIO = 0.8;
|
|
15
|
+
function readState() {
|
|
16
|
+
try {
|
|
17
|
+
const raw = window.localStorage.getItem(STORAGE_KEY);
|
|
18
|
+
if (raw) {
|
|
19
|
+
const parsed = JSON.parse(raw);
|
|
20
|
+
return {
|
|
21
|
+
open: parsed.open === true,
|
|
22
|
+
height: typeof parsed.height === 'number' ? parsed.height : DEFAULT_HEIGHT,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch (_a) {
|
|
27
|
+
// Storage blocked or corrupt: start closed at the default height.
|
|
28
|
+
}
|
|
29
|
+
return { open: false, height: DEFAULT_HEIGHT };
|
|
30
|
+
}
|
|
31
|
+
function writeState(state) {
|
|
32
|
+
try {
|
|
33
|
+
window.localStorage.setItem(STORAGE_KEY, JSON.stringify(state));
|
|
34
|
+
}
|
|
35
|
+
catch (_a) {
|
|
36
|
+
// Not persisting is fine; the drawer still works for this page view.
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function clampHeight(height) {
|
|
40
|
+
const max = Math.floor(window.innerHeight * MAX_HEIGHT_RATIO);
|
|
41
|
+
return Math.min(Math.max(height, MIN_HEIGHT), Math.max(max, MIN_HEIGHT));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The console as a bottom panel, like VS Code's: a thin bar when closed, a
|
|
45
|
+
* resizable panel when open, toggled with Ctrl+`. It stays mounted once
|
|
46
|
+
* opened, so the conversation survives closing it. `className` positions it,
|
|
47
|
+
* e.g. an offset for the app's sidebar.
|
|
48
|
+
*/
|
|
49
|
+
export function ConsoleDrawer({ config, className = 'left-0 right-0', }) {
|
|
50
|
+
const [state, setState] = useState({
|
|
51
|
+
open: false,
|
|
52
|
+
height: DEFAULT_HEIGHT,
|
|
53
|
+
});
|
|
54
|
+
// Mount the console on first open, then keep it.
|
|
55
|
+
const [hasOpened, setHasOpened] = useState(false);
|
|
56
|
+
const dragging = useRef(false);
|
|
57
|
+
// The height to return to when a maximized drawer is restored.
|
|
58
|
+
const restoreHeight = useRef(DEFAULT_HEIGHT);
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
const stored = readState();
|
|
61
|
+
setState(Object.assign(Object.assign({}, stored), { height: clampHeight(stored.height) }));
|
|
62
|
+
if (stored.open)
|
|
63
|
+
setHasOpened(true);
|
|
64
|
+
}, []);
|
|
65
|
+
const toggle = useCallback(() => {
|
|
66
|
+
setState((prev) => {
|
|
67
|
+
const merged = Object.assign(Object.assign({}, prev), { open: !prev.open });
|
|
68
|
+
writeState(merged);
|
|
69
|
+
return merged;
|
|
70
|
+
});
|
|
71
|
+
setHasOpened(true);
|
|
72
|
+
}, []);
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
const covered = state.open ? state.height : CONSOLE_DRAWER_BAR_HEIGHT;
|
|
75
|
+
document.documentElement.style.setProperty(CONSOLE_DRAWER_HEIGHT_VAR, `${covered}px`);
|
|
76
|
+
}, [state.open, state.height]);
|
|
77
|
+
useEffect(() => () => {
|
|
78
|
+
document.documentElement.style.removeProperty(CONSOLE_DRAWER_HEIGHT_VAR);
|
|
79
|
+
}, []);
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
const onKey = (event) => {
|
|
82
|
+
if (event.ctrlKey && event.key === '`') {
|
|
83
|
+
event.preventDefault();
|
|
84
|
+
toggle();
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
window.addEventListener('keydown', onKey);
|
|
88
|
+
return () => window.removeEventListener('keydown', onKey);
|
|
89
|
+
}, [toggle]);
|
|
90
|
+
const setHeight = (height) => {
|
|
91
|
+
setState((prev) => {
|
|
92
|
+
const merged = Object.assign(Object.assign({}, prev), { height: clampHeight(height) });
|
|
93
|
+
writeState(merged);
|
|
94
|
+
return merged;
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
const isMaximized = typeof window !== 'undefined' &&
|
|
98
|
+
state.height >= clampHeight(Number.POSITIVE_INFINITY);
|
|
99
|
+
const toggleMaximized = () => {
|
|
100
|
+
if (isMaximized) {
|
|
101
|
+
setHeight(restoreHeight.current);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
restoreHeight.current = state.height;
|
|
105
|
+
setHeight(Number.POSITIVE_INFINITY);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
const onResizeStart = (event) => {
|
|
109
|
+
event.preventDefault();
|
|
110
|
+
dragging.current = true;
|
|
111
|
+
const onMove = (move) => {
|
|
112
|
+
if (!dragging.current)
|
|
113
|
+
return;
|
|
114
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { height: clampHeight(window.innerHeight - move.clientY) })));
|
|
115
|
+
};
|
|
116
|
+
const onUp = () => {
|
|
117
|
+
dragging.current = false;
|
|
118
|
+
window.removeEventListener('pointermove', onMove);
|
|
119
|
+
window.removeEventListener('pointerup', onUp);
|
|
120
|
+
setState((prev) => {
|
|
121
|
+
writeState(prev);
|
|
122
|
+
return prev;
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
window.addEventListener('pointermove', onMove);
|
|
126
|
+
window.addEventListener('pointerup', onUp);
|
|
127
|
+
};
|
|
128
|
+
return (_jsxs("div", { className: `fixed bottom-0 z-30 flex flex-col border-t border-gray-800 bg-gray-950 shadow-2xl ${className}`, style: { height: state.open ? state.height : undefined }, "data-testid": "console-drawer", children: [state.open && (_jsx("div", { role: "separator", "aria-orientation": "horizontal", "aria-label": "Resize console", onPointerDown: onResizeStart, onDoubleClick: () => setHeight(DEFAULT_HEIGHT), title: "Drag to resize; double-click to reset", className: "h-1 shrink-0 cursor-row-resize bg-gray-800 hover:bg-cyan-700" })), _jsxs("div", { className: "flex h-8 shrink-0 items-center text-xs text-gray-400", children: [_jsxs("button", { type: "button", onClick: toggle, "aria-expanded": state.open, className: "flex h-full flex-1 items-center gap-2 px-3 hover:text-gray-200", children: [_jsx(HiTerminal, { className: "h-4 w-4" }), _jsx("span", { className: "font-medium tracking-wider uppercase", children: "Console" }), _jsx("span", { className: "text-gray-600", children: "Ctrl+`" }), _jsx("span", { className: "ml-auto", children: state.open ? (_jsx(HiChevronDown, { className: "h-4 w-4" })) : (_jsx(HiChevronUp, { className: "h-4 w-4" })) })] }), state.open && (_jsx("button", { type: "button", onClick: toggleMaximized, "aria-label": isMaximized ? 'Restore console size' : 'Maximize console', title: isMaximized ? 'Restore' : 'Maximize', className: "flex h-full items-center px-3 hover:text-gray-200", children: isMaximized ? (_jsx(HiOutlineMinus, { className: "h-4 w-4" })) : (_jsx(HiOutlineArrowsExpand, { className: "h-4 w-4" })) }))] }), hasOpened && (_jsx("div", { className: `min-h-0 flex-1 ${state.open ? '' : 'hidden'}`, children: _jsx(ConsoleContent, { config: config, variant: "panel" }) }))] }));
|
|
129
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { ConsoleContent } from './ConsoleContent';
|
|
2
|
+
export { CONSOLE_DRAWER_BAR_HEIGHT, CONSOLE_DRAWER_HEIGHT_VAR, ConsoleDrawer, } from './ConsoleDrawer';
|
|
2
3
|
export { ConsoleMarkdown } from './ConsoleMarkdown';
|
|
3
4
|
export { EXAMPLE_SETS, buildGraphAwareConsoleConfig, getGraphExampleKind, useGraphAwareConsoleConfig, } from './graphAwareConfig';
|
|
4
5
|
export type { ConsoleBranding, GraphExampleKind, GraphExampleSet, } from './graphAwareConfig';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { ConsoleContent } from './ConsoleContent';
|
|
2
|
+
export { CONSOLE_DRAWER_BAR_HEIGHT, CONSOLE_DRAWER_HEIGHT_VAR, ConsoleDrawer, } from './ConsoleDrawer';
|
|
2
3
|
export { ConsoleMarkdown } from './ConsoleMarkdown';
|
|
3
4
|
export { EXAMPLE_SETS, buildGraphAwareConsoleConfig, getGraphExampleKind, useGraphAwareConsoleConfig, } from './graphAwareConfig';
|
|
4
5
|
export { ProgressiveText } from './ProgressiveText';
|
package/components/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ConsoleContent } from './console';
|
|
1
|
+
export { CONSOLE_DRAWER_BAR_HEIGHT, CONSOLE_DRAWER_HEIGHT_VAR, ConsoleContent, ConsoleDrawer, } from './console';
|
|
2
2
|
export { EntitySelector, type EntityGroup, type SelectableEntity, } from './EntitySelector';
|
|
3
3
|
export { EntitySelectorCore, type EntityLike, type EntityRecord, type EntitySelectorProps, type GraphWithEntities, } from './EntitySelectorCore';
|
|
4
4
|
export { GraphFilters, byGraphType, composeFilters, excludeRepositories, excludeSubgraphs, hasAllSchemaExtensions, hasAnySchemaExtension, hasSchemaExtension, onlyEntityGraphs, onlyGenericGraphs, onlyRepositories, onlyUserGraphs, } from './graph-filters';
|
package/components/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ConsoleContent } from './console';
|
|
1
|
+
export { CONSOLE_DRAWER_BAR_HEIGHT, CONSOLE_DRAWER_HEIGHT_VAR, ConsoleContent, ConsoleDrawer, } from './console';
|
|
2
2
|
export { EntitySelector, } from './EntitySelector';
|
|
3
3
|
export { EntitySelectorCore, } from './EntitySelectorCore';
|
|
4
4
|
export { GraphFilters, byGraphType, composeFilters, excludeRepositories, excludeSubgraphs, hasAllSchemaExtensions, hasAnySchemaExtension, hasSchemaExtension, onlyEntityGraphs, onlyGenericGraphs, onlyRepositories, onlyUserGraphs, } from './graph-filters';
|
package/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export { clearGraphSelection, getGraphSelection, persistGraphSelection, } from '
|
|
|
11
11
|
export { clearEntitySelection, getEntitySelection, persistEntitySelection, } from './actions/entity-actions';
|
|
12
12
|
export type { Entities, Entity, User } from './types';
|
|
13
13
|
export { customTheme } from './theme';
|
|
14
|
-
export { buildGraphAwareConsoleConfig, ConsoleContent, EXAMPLE_SETS, getGraphExampleKind, useGraphAwareConsoleConfig, } from './components/console';
|
|
14
|
+
export { buildGraphAwareConsoleConfig, CONSOLE_DRAWER_BAR_HEIGHT, CONSOLE_DRAWER_HEIGHT_VAR, ConsoleContent, ConsoleDrawer, EXAMPLE_SETS, getGraphExampleKind, useGraphAwareConsoleConfig, } from './components/console';
|
|
15
15
|
export type { ConsoleBranding, ConsoleCommandContext, ConsoleConfig, ConsoleExtraCommand, ConsoleHeaderConfig, ConsoleMcpConfig, ConsoleWelcomeConfig, GraphExampleKind, GraphExampleSet, SampleQuery, } from './components/console';
|
|
16
16
|
export { anchoredMessage, errorDetail, ReportChat, type ReportChatProps, } from './components/report-chat';
|
|
17
17
|
export { ActiveSubscriptions, BrowseRepositories, EntitySelector, EntitySelectorCore, GraphSelectorCore, PageLayout, RepositoryGuard, SearchBar, SearchContent, SearchHitCard, SearchPagination, SearchResultsMeta, useIsRepository, type ActiveSubscriptionsProps, type BrowseRepositoriesProps, type EntityGroup, type EntityLike, type EntityRecord, type EntitySelectorProps, type GraphSelectorProps, type GraphWithEntities, type SearchBarProps, type SearchConfig, type SearchFilterConfig, type SearchHitCardProps, type SearchPaginationProps, type SearchResultsMetaProps, type SelectableEntity, } from './components';
|
package/index.js
CHANGED
|
@@ -32,7 +32,7 @@ export { clearEntitySelection, getEntitySelection, persistEntitySelection, } fro
|
|
|
32
32
|
export { customTheme } from './theme';
|
|
33
33
|
// Export components
|
|
34
34
|
// Export console components
|
|
35
|
-
export { buildGraphAwareConsoleConfig, ConsoleContent, EXAMPLE_SETS, getGraphExampleKind, useGraphAwareConsoleConfig, } from './components/console';
|
|
35
|
+
export { buildGraphAwareConsoleConfig, CONSOLE_DRAWER_BAR_HEIGHT, CONSOLE_DRAWER_HEIGHT_VAR, ConsoleContent, ConsoleDrawer, EXAMPLE_SETS, getGraphExampleKind, useGraphAwareConsoleConfig, } from './components/console';
|
|
36
36
|
export { anchoredMessage, errorDetail, ReportChat, } from './components/report-chat';
|
|
37
37
|
export { ActiveSubscriptions, BrowseRepositories, EntitySelector, EntitySelectorCore, GraphSelectorCore, PageLayout, RepositoryGuard, SearchBar, SearchContent, SearchHitCard, SearchPagination, SearchResultsMeta, useIsRepository, } from './components';
|
|
38
38
|
// Export graph filters
|
package/package.json
CHANGED