@workbench-kit/shell-react 0.0.2-prototype.0.2.6 → 0.0.2-prototype.0.2.8
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/README.md +41 -0
- package/package.json +9 -9
- package/src/{chat-ai-mock-proposals.ts → chat/ai-mock-proposals.ts} +39 -39
- package/src/{chat-command-input.ts → chat/command-input.ts} +52 -52
- package/src/{chat-command-policy.ts → chat/command-policy.ts} +54 -54
- package/src/{chat-command-surface.tsx → chat/command-surface.tsx} +155 -155
- package/src/{use-workbench-chat-command-proposals.ts → chat/use-chat-command-proposals.ts} +194 -194
- package/src/{chat-view-data.ts → chat/view-data.ts} +20 -20
- package/src/{chat-view.tsx → chat/view.tsx} +220 -220
- package/src/{command-inspector-surface.tsx → commands/inspector-surface.tsx} +46 -46
- package/src/{use-workbench-command-descriptors.ts → commands/use-command-descriptors.ts} +41 -41
- package/src/{use-context-key-revision.ts → commands/use-context-key-revision.ts} +18 -18
- package/src/{commands-view-data.ts → commands/view-data.ts} +17 -17
- package/src/{commands-view.tsx → commands/view.tsx} +43 -43
- package/src/devtools/WorkbenchDevtoolsPanel.tsx +124 -124
- package/src/devtools/WorkbenchDevtoolsShell.tsx +17 -17
- package/src/devtools/index.ts +11 -11
- package/src/devtools/use-workbench-devtools-snapshot.ts +84 -84
- package/src/devtools/workbench-devtools-snapshot.ts +140 -140
- package/src/devtools/workbench-devtools.css +82 -82
- package/src/{editor-area-dnd.ts → editor/area-dnd.ts} +69 -69
- package/src/{editor-area-model.ts → editor/area-model.ts} +71 -71
- package/src/{editor-area.css → editor/area.css} +454 -454
- package/src/{editor-area.tsx → editor/area.tsx} +676 -676
- package/src/{editor-host-surface.tsx → editor/host-surface.tsx} +631 -634
- package/src/{editor-pane-visibility.ts → editor/pane-visibility.ts} +130 -130
- package/src/{editor-resource.ts → editor/resource.ts} +36 -36
- package/src/{editor-state-storage.ts → editor/state-storage.ts} +182 -193
- package/src/{editor-tab-context-menu.ts → editor/tab-context-menu.ts} +118 -118
- package/src/{use-editor.ts → editor/use-editor.ts} +114 -107
- package/src/{editor-view-providers.tsx → editor/view-providers.tsx} +552 -552
- package/src/{editor-workspace-file-availability.ts → editor/workspace-file-availability.ts} +15 -15
- package/src/{editor-workspace-reconcile.tsx → editor/workspace-reconcile.tsx} +31 -28
- package/src/{explorer-context-menu.ts → explorer/context-menu.ts} +114 -114
- package/src/{createCommandWorkspaceExplorerPort.ts → explorer/create-command-workspace-explorer-port.ts} +86 -86
- package/src/{explorer-reveal.ts → explorer/reveal.ts} +112 -112
- package/src/{search-view-data.ts → explorer/search-view-data.ts} +15 -15
- package/src/{search-view.tsx → explorer/search-view.tsx} +65 -62
- package/src/{use-active-workspace-path.ts → explorer/use-active-workspace-path.ts} +15 -15
- package/src/{explorer-view-data.ts → explorer/view-data.ts} +58 -58
- package/src/{explorer-view.tsx → explorer/view.tsx} +227 -224
- package/src/{extension-context-menu.ts → extensions/context-menu.ts} +52 -52
- package/src/{extension-management-model.ts → extensions/management-model.ts} +313 -313
- package/src/{use-extension-management.ts → extensions/use-extension-management.ts} +241 -193
- package/src/{extensions-view-data.ts → extensions/view-data.ts} +19 -19
- package/src/{extensions-view.tsx → extensions/view.tsx} +63 -38
- package/src/{field-remap-demo.tsx → field-remap/demo.tsx} +18 -18
- package/src/{field-remap-editor-surface.tsx → field-remap/editor-surface.tsx} +36 -36
- package/src/{field-remap-flow-adapter.ts → field-remap/flow-adapter.ts} +240 -240
- package/src/{field-remap-flow.tsx → field-remap/flow.tsx} +369 -369
- package/src/{field-remap-graph.tsx → field-remap/graph.tsx} +559 -559
- package/src/field-remap/jsonata-transform.ts +166 -0
- package/src/{field-remap-panel.tsx → field-remap/panel.tsx} +193 -175
- package/src/{field-remap-samples.ts → field-remap/samples.ts} +352 -352
- package/src/{table-mapping-adapter.ts → field-remap/table-mapping-adapter.ts} +59 -59
- package/src/{field-remap-tree.tsx → field-remap/tree.tsx} +404 -404
- package/src/{field-remap-view-data.ts → field-remap/view-data.ts} +16 -16
- package/src/{field-remap-view.css → field-remap/view.css} +676 -676
- package/src/{field-remap-view.tsx → field-remap/view.tsx} +86 -86
- package/src/index.ts +212 -199
- package/src/{json-form-source-patch.ts → jdw/json-form-source-patch.ts} +323 -323
- package/src/{jdw-lab-view-data.ts → jdw/lab-view-data.ts} +25 -25
- package/src/{jdw-lab-view.css → jdw/lab-view.css} +21 -21
- package/src/{jdw-lab-view.tsx → jdw/lab-view.tsx} +79 -79
- package/src/{jdw-widget-form-view.tsx → jdw/widget-form-view.tsx} +68 -65
- package/src/{jdw-widget-preview-view.tsx → jdw/widget-preview-view.tsx} +54 -51
- package/src/{keybinding-overrides-storage.ts → management/keybinding-overrides-storage.ts} +49 -57
- package/src/{keybinding-management-settings.tsx → management/keybinding-settings.tsx} +16 -16
- package/src/{management-palette-commands.ts → management/palette-commands.ts} +38 -38
- package/src/{preference-settings-storage.ts → management/preference-settings-storage.ts} +50 -58
- package/src/{management-settings-ids.ts → management/settings-ids.ts} +12 -12
- package/src/{management-settings.tsx → management/settings.tsx} +96 -75
- package/src/{use-command-management.ts → management/use-command-management.ts} +191 -191
- package/src/{use-keybinding-management.ts → management/use-keybinding-management.ts} +130 -130
- package/src/{shell-model.tsx → shell/model.tsx} +149 -149
- package/src/{provider.tsx → shell/provider.tsx} +603 -573
- package/src/{shell-secondary-actions.tsx → shell/secondary-actions.tsx} +59 -59
- package/src/{shell-settings-constants.ts → shell/settings-constants.ts} +9 -9
- package/src/{shell-settings.tsx → shell/settings.tsx} +599 -599
- package/src/{shell.tsx → shell/shell.tsx} +680 -649
- package/src/{shell-titlebar-layout-controls.tsx → shell/titlebar-layout-controls.tsx} +4 -4
- package/src/{shell-view-host.tsx → shell/view-host.tsx} +212 -199
- package/src/{workbench-appearance-storage.ts → workbench/appearance-storage.ts} +107 -115
- package/src/{workbench-command-host.tsx → workbench/command-host.tsx} +243 -243
- package/src/{workbench-command-palette.ts → workbench/command-palette.ts} +208 -208
- package/src/{workbench-keybinding-bridge.ts → workbench/keybinding-bridge.ts} +54 -54
- package/src/{workbench-layout-storage.ts → workbench/layout-storage.ts} +134 -145
- package/src/{workbench-profile-modal.tsx → workbench/profile-modal.tsx} +118 -118
- package/src/{workbench-shell-command-registration.ts → workbench/shell-command-registration.ts} +58 -58
- package/src/{workbench-startup-gate.tsx → workbench/startup-gate.tsx} +136 -136
- package/src/{workbench-status-sections.ts → workbench/status-sections.ts} +43 -43
- package/src/{use-persisted-workbench-appearance.ts → workbench/use-persisted-appearance.ts} +33 -33
- package/src/{workbench-user-commands.ts → workbench/user-commands.ts} +46 -46
- package/src/{workspace-view-state.ts → workbench/workspace-view-state.ts} +35 -35
- package/src/jsonata-transform.ts +0 -36
|
@@ -1,155 +1,155 @@
|
|
|
1
|
-
import { useCallback, useMemo, useRef, type KeyboardEvent } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
WorkbenchCommandSuggest,
|
|
4
|
-
isWorkbenchCommandRunnable,
|
|
5
|
-
useSlashCommandSuggest,
|
|
6
|
-
type WorkbenchCommandDescriptor,
|
|
7
|
-
} from '@workbench-kit/react/workbench';
|
|
8
|
-
|
|
9
|
-
import { parseWorkbenchChatCommandInput } from './
|
|
10
|
-
import { useWorkbench } from '
|
|
11
|
-
import { useWorkbenchCommandDescriptors } from '
|
|
12
|
-
|
|
13
|
-
export interface WorkbenchChatCommandRunResult {
|
|
14
|
-
commandId: string;
|
|
15
|
-
label?: string | undefined;
|
|
16
|
-
message?: string | undefined;
|
|
17
|
-
status: 'error' | 'success';
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface WorkbenchChatCommandSurfaceOptions {
|
|
21
|
-
additionalCommands?: readonly WorkbenchCommandDescriptor[] | undefined;
|
|
22
|
-
onCommandResult?: ((result: WorkbenchChatCommandRunResult) => void) | undefined;
|
|
23
|
-
onValueChange: (value: string) => void;
|
|
24
|
-
value: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function useWorkbenchChatCommandSurface({
|
|
28
|
-
additionalCommands,
|
|
29
|
-
onCommandResult,
|
|
30
|
-
onValueChange,
|
|
31
|
-
value,
|
|
32
|
-
}: WorkbenchChatCommandSurfaceOptions) {
|
|
33
|
-
const { executeCommand } = useWorkbench();
|
|
34
|
-
const composerRef = useRef<HTMLTextAreaElement>(null);
|
|
35
|
-
const commands = useWorkbenchCommandDescriptors(additionalCommands);
|
|
36
|
-
const commandIds = useMemo(() => new Set(commands.map((command) => command.id)), [commands]);
|
|
37
|
-
const suggest = useSlashCommandSuggest({ commands, value });
|
|
38
|
-
|
|
39
|
-
const runCommand = useCallback(
|
|
40
|
-
async (commandId: string, args: readonly unknown[] = []) => {
|
|
41
|
-
const command = commands.find((candidate) => candidate.id === commandId);
|
|
42
|
-
if (command && !isWorkbenchCommandRunnable(command)) {
|
|
43
|
-
onCommandResult?.({
|
|
44
|
-
commandId,
|
|
45
|
-
label: command.label,
|
|
46
|
-
message: command.disabledReason ?? 'Command is currently unavailable.',
|
|
47
|
-
status: 'error',
|
|
48
|
-
});
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
onValueChange('');
|
|
53
|
-
|
|
54
|
-
try {
|
|
55
|
-
await executeCommand(commandId, ...args);
|
|
56
|
-
onCommandResult?.({
|
|
57
|
-
commandId,
|
|
58
|
-
label: command?.label,
|
|
59
|
-
status: 'success',
|
|
60
|
-
});
|
|
61
|
-
} catch (error) {
|
|
62
|
-
onCommandResult?.({
|
|
63
|
-
commandId,
|
|
64
|
-
label: command?.label,
|
|
65
|
-
message: getCommandErrorMessage(error),
|
|
66
|
-
status: 'error',
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
[commands, executeCommand, onCommandResult, onValueChange],
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
const runInputAsCommand = useCallback(
|
|
74
|
-
(message: string) => {
|
|
75
|
-
const parsed = parseWorkbenchChatCommandInput(message, (commandId) =>
|
|
76
|
-
commandIds.has(commandId),
|
|
77
|
-
);
|
|
78
|
-
if (parsed.type === 'none') {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (parsed.type === 'unknown') {
|
|
83
|
-
onValueChange('');
|
|
84
|
-
onCommandResult?.({
|
|
85
|
-
commandId: parsed.token || '/',
|
|
86
|
-
message: parsed.token ? `Unknown command: ${parsed.token}` : 'Type a command after /.',
|
|
87
|
-
status: 'error',
|
|
88
|
-
});
|
|
89
|
-
return true;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (parsed.type === 'invalid-arguments') {
|
|
93
|
-
onValueChange('');
|
|
94
|
-
onCommandResult?.({
|
|
95
|
-
commandId: parsed.commandId,
|
|
96
|
-
message: parsed.message,
|
|
97
|
-
status: 'error',
|
|
98
|
-
});
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
void runCommand(parsed.commandId, parsed.args);
|
|
103
|
-
return true;
|
|
104
|
-
},
|
|
105
|
-
[commandIds, onCommandResult, onValueChange, runCommand],
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
const handleKeyDown = useCallback(
|
|
109
|
-
(event: KeyboardEvent<HTMLTextAreaElement>) => {
|
|
110
|
-
suggest.handleKeyDown(event, (commandId) => {
|
|
111
|
-
void runCommand(commandId);
|
|
112
|
-
});
|
|
113
|
-
},
|
|
114
|
-
[runCommand, suggest],
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
const openCommandSuggest = useCallback(() => {
|
|
118
|
-
if (!value.trimStart().startsWith('/')) {
|
|
119
|
-
onValueChange('/');
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
window.requestAnimationFrame(() => {
|
|
123
|
-
composerRef.current?.focus();
|
|
124
|
-
});
|
|
125
|
-
}, [onValueChange, value]);
|
|
126
|
-
|
|
127
|
-
const commandSuggestPopover = (
|
|
128
|
-
<WorkbenchCommandSuggest
|
|
129
|
-
activeCommandId={suggest.activeCommandId}
|
|
130
|
-
commands={suggest.suggestedCommands}
|
|
131
|
-
query={suggest.commandQuery}
|
|
132
|
-
visible={suggest.isOpen}
|
|
133
|
-
onActiveCommandChange={suggest.setActiveCommandByKey}
|
|
134
|
-
onRunCommand={(command) => {
|
|
135
|
-
void runCommand(command.id);
|
|
136
|
-
}}
|
|
137
|
-
/>
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
return {
|
|
141
|
-
commandSuggestPopover,
|
|
142
|
-
composerRef,
|
|
143
|
-
onCommandClick: openCommandSuggest,
|
|
144
|
-
onKeyDown: handleKeyDown,
|
|
145
|
-
runInputAsCommand,
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
function getCommandErrorMessage(error: unknown) {
|
|
150
|
-
if (error instanceof Error) {
|
|
151
|
-
return error.message;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return String(error);
|
|
155
|
-
}
|
|
1
|
+
import { useCallback, useMemo, useRef, type KeyboardEvent } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
WorkbenchCommandSuggest,
|
|
4
|
+
isWorkbenchCommandRunnable,
|
|
5
|
+
useSlashCommandSuggest,
|
|
6
|
+
type WorkbenchCommandDescriptor,
|
|
7
|
+
} from '@workbench-kit/react/workbench';
|
|
8
|
+
|
|
9
|
+
import { parseWorkbenchChatCommandInput } from './command-input.js';
|
|
10
|
+
import { useWorkbench } from '../shell/provider.js';
|
|
11
|
+
import { useWorkbenchCommandDescriptors } from '../commands/use-command-descriptors.js';
|
|
12
|
+
|
|
13
|
+
export interface WorkbenchChatCommandRunResult {
|
|
14
|
+
commandId: string;
|
|
15
|
+
label?: string | undefined;
|
|
16
|
+
message?: string | undefined;
|
|
17
|
+
status: 'error' | 'success';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface WorkbenchChatCommandSurfaceOptions {
|
|
21
|
+
additionalCommands?: readonly WorkbenchCommandDescriptor[] | undefined;
|
|
22
|
+
onCommandResult?: ((result: WorkbenchChatCommandRunResult) => void) | undefined;
|
|
23
|
+
onValueChange: (value: string) => void;
|
|
24
|
+
value: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function useWorkbenchChatCommandSurface({
|
|
28
|
+
additionalCommands,
|
|
29
|
+
onCommandResult,
|
|
30
|
+
onValueChange,
|
|
31
|
+
value,
|
|
32
|
+
}: WorkbenchChatCommandSurfaceOptions) {
|
|
33
|
+
const { executeCommand } = useWorkbench();
|
|
34
|
+
const composerRef = useRef<HTMLTextAreaElement>(null);
|
|
35
|
+
const commands = useWorkbenchCommandDescriptors(additionalCommands);
|
|
36
|
+
const commandIds = useMemo(() => new Set(commands.map((command) => command.id)), [commands]);
|
|
37
|
+
const suggest = useSlashCommandSuggest({ commands, value });
|
|
38
|
+
|
|
39
|
+
const runCommand = useCallback(
|
|
40
|
+
async (commandId: string, args: readonly unknown[] = []) => {
|
|
41
|
+
const command = commands.find((candidate) => candidate.id === commandId);
|
|
42
|
+
if (command && !isWorkbenchCommandRunnable(command)) {
|
|
43
|
+
onCommandResult?.({
|
|
44
|
+
commandId,
|
|
45
|
+
label: command.label,
|
|
46
|
+
message: command.disabledReason ?? 'Command is currently unavailable.',
|
|
47
|
+
status: 'error',
|
|
48
|
+
});
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
onValueChange('');
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
await executeCommand(commandId, ...args);
|
|
56
|
+
onCommandResult?.({
|
|
57
|
+
commandId,
|
|
58
|
+
label: command?.label,
|
|
59
|
+
status: 'success',
|
|
60
|
+
});
|
|
61
|
+
} catch (error) {
|
|
62
|
+
onCommandResult?.({
|
|
63
|
+
commandId,
|
|
64
|
+
label: command?.label,
|
|
65
|
+
message: getCommandErrorMessage(error),
|
|
66
|
+
status: 'error',
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
[commands, executeCommand, onCommandResult, onValueChange],
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const runInputAsCommand = useCallback(
|
|
74
|
+
(message: string) => {
|
|
75
|
+
const parsed = parseWorkbenchChatCommandInput(message, (commandId) =>
|
|
76
|
+
commandIds.has(commandId),
|
|
77
|
+
);
|
|
78
|
+
if (parsed.type === 'none') {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (parsed.type === 'unknown') {
|
|
83
|
+
onValueChange('');
|
|
84
|
+
onCommandResult?.({
|
|
85
|
+
commandId: parsed.token || '/',
|
|
86
|
+
message: parsed.token ? `Unknown command: ${parsed.token}` : 'Type a command after /.',
|
|
87
|
+
status: 'error',
|
|
88
|
+
});
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (parsed.type === 'invalid-arguments') {
|
|
93
|
+
onValueChange('');
|
|
94
|
+
onCommandResult?.({
|
|
95
|
+
commandId: parsed.commandId,
|
|
96
|
+
message: parsed.message,
|
|
97
|
+
status: 'error',
|
|
98
|
+
});
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
void runCommand(parsed.commandId, parsed.args);
|
|
103
|
+
return true;
|
|
104
|
+
},
|
|
105
|
+
[commandIds, onCommandResult, onValueChange, runCommand],
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
const handleKeyDown = useCallback(
|
|
109
|
+
(event: KeyboardEvent<HTMLTextAreaElement>) => {
|
|
110
|
+
suggest.handleKeyDown(event, (commandId) => {
|
|
111
|
+
void runCommand(commandId);
|
|
112
|
+
});
|
|
113
|
+
},
|
|
114
|
+
[runCommand, suggest],
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
const openCommandSuggest = useCallback(() => {
|
|
118
|
+
if (!value.trimStart().startsWith('/')) {
|
|
119
|
+
onValueChange('/');
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
window.requestAnimationFrame(() => {
|
|
123
|
+
composerRef.current?.focus();
|
|
124
|
+
});
|
|
125
|
+
}, [onValueChange, value]);
|
|
126
|
+
|
|
127
|
+
const commandSuggestPopover = (
|
|
128
|
+
<WorkbenchCommandSuggest
|
|
129
|
+
activeCommandId={suggest.activeCommandId}
|
|
130
|
+
commands={suggest.suggestedCommands}
|
|
131
|
+
query={suggest.commandQuery}
|
|
132
|
+
visible={suggest.isOpen}
|
|
133
|
+
onActiveCommandChange={suggest.setActiveCommandByKey}
|
|
134
|
+
onRunCommand={(command) => {
|
|
135
|
+
void runCommand(command.id);
|
|
136
|
+
}}
|
|
137
|
+
/>
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
commandSuggestPopover,
|
|
142
|
+
composerRef,
|
|
143
|
+
onCommandClick: openCommandSuggest,
|
|
144
|
+
onKeyDown: handleKeyDown,
|
|
145
|
+
runInputAsCommand,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function getCommandErrorMessage(error: unknown) {
|
|
150
|
+
if (error instanceof Error) {
|
|
151
|
+
return error.message;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return String(error);
|
|
155
|
+
}
|