@robota-sdk/agent-transport 3.0.0-beta.75 → 3.0.0-beta.76

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.
Files changed (187) hide show
  1. package/README.md +10 -10
  2. package/dist/node/headless/index.cjs +1 -1
  3. package/dist/node/{headless-CT2ibQnr.cjs → headless-OnpVk4-k.cjs} +7 -7
  4. package/dist/node/index.cjs +1 -1
  5. package/dist/node/index.d.ts +1 -6
  6. package/dist/node/index.d.ts.map +1 -1
  7. package/dist/node/index.js +1 -1
  8. package/dist/node/index.js.map +1 -1
  9. package/package.json +7 -75
  10. package/src/index.ts +1 -5
  11. package/src/transport-registry.ts +0 -9
  12. package/dist/node/http/index.cjs +0 -1
  13. package/dist/node/http/index.d.ts +0 -2
  14. package/dist/node/http/index.js +0 -1
  15. package/dist/node/http-2Jiuflc1.js +0 -2
  16. package/dist/node/http-2Jiuflc1.js.map +0 -1
  17. package/dist/node/http-CBAvefLw.cjs +0 -1
  18. package/dist/node/index-BNccqSpv.d.ts +0 -86
  19. package/dist/node/index-BNccqSpv.d.ts.map +0 -1
  20. package/dist/node/index-BUhHIf7X.d.ts +0 -86
  21. package/dist/node/index-BUhHIf7X.d.ts.map +0 -1
  22. package/dist/node/index-BnAGE-u9.d.ts +0 -33
  23. package/dist/node/index-BnAGE-u9.d.ts.map +0 -1
  24. package/dist/node/index-BrQ4gGw0.d.ts +0 -213
  25. package/dist/node/index-BrQ4gGw0.d.ts.map +0 -1
  26. package/dist/node/index-CoeBF21y.d.ts +0 -213
  27. package/dist/node/index-CoeBF21y.d.ts.map +0 -1
  28. package/dist/node/index-DHt-2VQ-.d.ts +0 -46
  29. package/dist/node/index-DHt-2VQ-.d.ts.map +0 -1
  30. package/dist/node/index-DMwKN5Le.d.ts +0 -33
  31. package/dist/node/index-DMwKN5Le.d.ts.map +0 -1
  32. package/dist/node/index-c0M42fsA.d.ts +0 -46
  33. package/dist/node/index-c0M42fsA.d.ts.map +0 -1
  34. package/dist/node/mcp/index.cjs +0 -1
  35. package/dist/node/mcp/index.d.ts +0 -2
  36. package/dist/node/mcp/index.js +0 -1
  37. package/dist/node/mcp-BOglBJNy.cjs +0 -1
  38. package/dist/node/mcp-D3BBVK7C.js +0 -2
  39. package/dist/node/mcp-D3BBVK7C.js.map +0 -1
  40. package/dist/node/rolldown-runtime-CMqjfN_6.cjs +0 -1
  41. package/dist/node/tui/index.cjs +0 -1
  42. package/dist/node/tui/index.d.ts +0 -2
  43. package/dist/node/tui/index.js +0 -1
  44. package/dist/node/tui-CcH5EsQh.js +0 -25
  45. package/dist/node/tui-CcH5EsQh.js.map +0 -1
  46. package/dist/node/tui-DznRbcku.cjs +0 -24
  47. package/dist/node/ws/index.cjs +0 -1
  48. package/dist/node/ws/index.d.ts +0 -2
  49. package/dist/node/ws/index.js +0 -1
  50. package/dist/node/ws-Dc2RUwVs.js +0 -2
  51. package/dist/node/ws-Dc2RUwVs.js.map +0 -1
  52. package/dist/node/ws-QNMQn5kg.cjs +0 -1
  53. package/src/http/__tests__/http-transport.test.ts +0 -55
  54. package/src/http/__tests__/routes.test.ts +0 -168
  55. package/src/http/http-transport.ts +0 -41
  56. package/src/http/index.ts +0 -4
  57. package/src/http/routes.ts +0 -152
  58. package/src/mcp/__tests__/mcp-server.test.ts +0 -66
  59. package/src/mcp/__tests__/mcp-transport.test.ts +0 -46
  60. package/src/mcp/index.ts +0 -4
  61. package/src/mcp/mcp-server.ts +0 -163
  62. package/src/mcp/mcp-transport.ts +0 -48
  63. package/src/tui/App.tsx +0 -491
  64. package/src/tui/BackgroundTaskPanel.tsx +0 -36
  65. package/src/tui/CjkTextInput.tsx +0 -199
  66. package/src/tui/ConfirmPrompt.tsx +0 -70
  67. package/src/tui/ContextWarningBanner.tsx +0 -34
  68. package/src/tui/ExecutionWorkspaceDetailPane.tsx +0 -64
  69. package/src/tui/ExecutionWorkspaceSwitcher.tsx +0 -187
  70. package/src/tui/InputArea.tsx +0 -310
  71. package/src/tui/InteractivePrompt.tsx +0 -59
  72. package/src/tui/ListPicker.tsx +0 -95
  73. package/src/tui/MenuSelect.tsx +0 -104
  74. package/src/tui/MessageList.tsx +0 -284
  75. package/src/tui/PermissionPrompt.tsx +0 -86
  76. package/src/tui/PluginTUI.tsx +0 -258
  77. package/src/tui/SessionPicker.tsx +0 -68
  78. package/src/tui/SessionStatusBar.tsx +0 -73
  79. package/src/tui/SlashAutocomplete.tsx +0 -110
  80. package/src/tui/StatusBar.tsx +0 -236
  81. package/src/tui/StreamingIndicator.tsx +0 -93
  82. package/src/tui/TextPrompt.tsx +0 -81
  83. package/src/tui/ToolCommandOutput.tsx +0 -39
  84. package/src/tui/ToolDiffBlock.tsx +0 -32
  85. package/src/tui/TransportTUI.tsx +0 -117
  86. package/src/tui/TuiInteractionChannel.ts +0 -495
  87. package/src/tui/UpdateNotice.tsx +0 -14
  88. package/src/tui/UsageSummaryEntry.tsx +0 -39
  89. package/src/tui/WaveText.tsx +0 -44
  90. package/src/tui/__tests__/InteractivePrompt.test.tsx +0 -82
  91. package/src/tui/__tests__/ListPicker.test.tsx +0 -159
  92. package/src/tui/__tests__/MenuSelect.test.tsx +0 -103
  93. package/src/tui/__tests__/PluginTUI.test.tsx +0 -167
  94. package/src/tui/__tests__/SlashAutocomplete.test.tsx +0 -140
  95. package/src/tui/__tests__/TextPrompt.test.tsx +0 -98
  96. package/src/tui/__tests__/TuiInteractionChannel.display-contract.test.ts +0 -239
  97. package/src/tui/__tests__/TuiInteractionChannel.lifecycle.test.ts +0 -297
  98. package/src/tui/__tests__/TuiInteractionChannel.requestAction.test.ts +0 -124
  99. package/src/tui/__tests__/UpdateNotice.test.tsx +0 -15
  100. package/src/tui/__tests__/abort-after-permission.test.tsx +0 -169
  101. package/src/tui/__tests__/abort-streaming-e2e.test.tsx +0 -183
  102. package/src/tui/__tests__/background-task-panel.test.tsx +0 -53
  103. package/src/tui/__tests__/background-task-row-format.test.ts +0 -59
  104. package/src/tui/__tests__/channel-factory-integration.test.ts +0 -138
  105. package/src/tui/__tests__/cjk-text-input-flow.test.ts +0 -109
  106. package/src/tui/__tests__/cjk-text-input.test.ts +0 -191
  107. package/src/tui/__tests__/command-effect-handler.test.ts +0 -127
  108. package/src/tui/__tests__/command-output-summary.test.ts +0 -95
  109. package/src/tui/__tests__/compact-event-bridge.test.ts +0 -20
  110. package/src/tui/__tests__/confirm-permission-flow.test.ts +0 -130
  111. package/src/tui/__tests__/confirm-prompt.test.tsx +0 -87
  112. package/src/tui/__tests__/execution-workspace-switcher.test.tsx +0 -110
  113. package/src/tui/__tests__/execution-workspace-view-model.test.ts +0 -93
  114. package/src/tui/__tests__/fixtures/provider-setup-prompt-driver.tsx +0 -125
  115. package/src/tui/__tests__/input-area-flow.test.ts +0 -164
  116. package/src/tui/__tests__/message-list-rendering.test.tsx +0 -353
  117. package/src/tui/__tests__/prompt-queue.test.tsx +0 -255
  118. package/src/tui/__tests__/provider-setup-pty-e2e.test.ts +0 -233
  119. package/src/tui/__tests__/pty/pty-driver.ts +0 -135
  120. package/src/tui/__tests__/pty/tui-pty.ptytest.ts +0 -61
  121. package/src/tui/__tests__/render-channel-options.test.ts +0 -32
  122. package/src/tui/__tests__/render-markdown.test.ts +0 -72
  123. package/src/tui/__tests__/selection-flow.test.ts +0 -61
  124. package/src/tui/__tests__/session-init-poller.test.ts +0 -102
  125. package/src/tui/__tests__/session-naming.test.ts +0 -64
  126. package/src/tui/__tests__/session-switch-channel.test.tsx +0 -307
  127. package/src/tui/__tests__/slash-routing-effects.test.ts +0 -228
  128. package/src/tui/__tests__/status-activity.test.ts +0 -71
  129. package/src/tui/__tests__/status-bar.test.tsx +0 -177
  130. package/src/tui/__tests__/streaming-indicator.test.tsx +0 -137
  131. package/src/tui/__tests__/text-prompt-flow.test.ts +0 -77
  132. package/src/tui/__tests__/tui-channel-init-failure.test.ts +0 -57
  133. package/src/tui/__tests__/tui-state-manager.test.ts +0 -401
  134. package/src/tui/background-task-row-format.ts +0 -53
  135. package/src/tui/command-interaction.ts +0 -9
  136. package/src/tui/command-output-summary.ts +0 -122
  137. package/src/tui/create-default-tui-cli-adapter.ts +0 -41
  138. package/src/tui/execution-workspace-view-model.ts +0 -123
  139. package/src/tui/flows/cjk-text-input-flow.ts +0 -285
  140. package/src/tui/flows/confirm-prompt-flow.ts +0 -45
  141. package/src/tui/flows/input-area-flow.ts +0 -189
  142. package/src/tui/flows/permission-prompt-flow.ts +0 -85
  143. package/src/tui/flows/selection-flow.ts +0 -126
  144. package/src/tui/flows/session-init-poller.ts +0 -77
  145. package/src/tui/flows/text-prompt-flow.ts +0 -98
  146. package/src/tui/hooks/command-effect-handler.ts +0 -97
  147. package/src/tui/hooks/command-effect-queue.ts +0 -39
  148. package/src/tui/hooks/side-effects-types.ts +0 -35
  149. package/src/tui/hooks/useAutocomplete.ts +0 -87
  150. package/src/tui/hooks/usePluginCallbacks.ts +0 -31
  151. package/src/tui/hooks/usePluginScreenData.ts +0 -85
  152. package/src/tui/hooks/useSideEffects.ts +0 -175
  153. package/src/tui/hooks/useSlashRouting.ts +0 -118
  154. package/src/tui/hooks/useStatusLineSettings.ts +0 -37
  155. package/src/tui/hooks/useTuiChannel.ts +0 -95
  156. package/src/tui/index.ts +0 -14
  157. package/src/tui/interactions/CommandConfirm.tsx +0 -36
  158. package/src/tui/interactions/CommandPicker.tsx +0 -77
  159. package/src/tui/interactions/__tests__/CommandConfirm.test.tsx +0 -124
  160. package/src/tui/interactions/__tests__/CommandPicker.test.tsx +0 -138
  161. package/src/tui/plugin-tui-handlers.ts +0 -163
  162. package/src/tui/render-markdown.ts +0 -130
  163. package/src/tui/render.tsx +0 -129
  164. package/src/tui/session-naming.ts +0 -33
  165. package/src/tui/status-activity.ts +0 -63
  166. package/src/tui/tui-cli-adapter-context.tsx +0 -13
  167. package/src/tui/tui-cli-adapter.ts +0 -25
  168. package/src/tui/tui-state-manager.ts +0 -226
  169. package/src/tui/tui-transport.ts +0 -35
  170. package/src/tui/types.ts +0 -15
  171. package/src/tui/utils/__tests__/edit-diff.test.ts +0 -426
  172. package/src/tui/utils/__tests__/paste-detection.test.ts +0 -116
  173. package/src/tui/utils/__tests__/paste-labels.test.ts +0 -46
  174. package/src/tui/utils/__tests__/tool-call-extractor.test.ts +0 -227
  175. package/src/tui/utils/__tests__/tool-diff-summary.test.ts +0 -104
  176. package/src/tui/utils/edit-diff.ts +0 -153
  177. package/src/tui/utils/paste-labels.ts +0 -9
  178. package/src/tui/utils/tool-call-extractor.ts +0 -92
  179. package/src/tui/utils/tool-diff-summary.ts +0 -75
  180. package/src/ws/__tests__/ws-handler.test.ts +0 -409
  181. package/src/ws/__tests__/ws-transport.test.ts +0 -53
  182. package/src/ws/index.ts +0 -13
  183. package/src/ws/ws-background-messages.ts +0 -170
  184. package/src/ws/ws-handler.ts +0 -280
  185. package/src/ws/ws-protocol.ts +0 -78
  186. package/src/ws/ws-transport-configurable.ts +0 -128
  187. package/src/ws/ws-transport.ts +0 -42
@@ -1,199 +0,0 @@
1
- /**
2
- * CJK-aware TextInput component for Ink.
3
- *
4
- * Replaces ink-text-input with proper wide character support:
5
- * - Uses string-width for display width calculation
6
- * - Cursor position based on character index (not display columns)
7
- * - Renders CJK characters correctly (2 columns each)
8
- * - Uses refs for value/cursor to avoid React state batching issues
9
- * (IME sends multiple keystrokes synchronously, state updates are async)
10
- *
11
- * Drop-in replacement: same props as ink-text-input.
12
- */
13
-
14
- import chalk from 'chalk';
15
- import { Text, useInput, usePaste } from 'ink';
16
- import React, { useRef, useState } from 'react';
17
-
18
- import {
19
- applyCjkTextInput,
20
- applyCjkTextPaste,
21
- createCjkTextInputFlowState,
22
- syncCjkTextInputFlowState,
23
- type ICjkTextInputFlowState,
24
- } from './flows/cjk-text-input-flow.js';
25
-
26
- interface IProps {
27
- value: string;
28
- onChange: (value: string) => void;
29
- onSubmit?: (value: string) => void;
30
- onPaste?: (text: string, cursorPosition: number) => void;
31
- placeholder?: string;
32
- focus?: boolean;
33
- showCursor?: boolean;
34
- /** Available width in columns for visual line wrapping navigation */
35
- availableWidth?: number;
36
- /** Cursor position hint for external value changes. null = end (default). */
37
- cursorHint?: number | null;
38
- /** When false, parent flows own up/down arrow behavior. */
39
- enableVerticalNavigation?: boolean;
40
- }
41
-
42
- interface IInputHandlerOptions {
43
- stateRef: React.MutableRefObject<ICjkTextInputFlowState>;
44
- onChange: (value: string) => void;
45
- onSubmit?: (value: string) => void;
46
- onPaste?: (text: string, cursorPosition: number) => void;
47
- availableWidth?: number;
48
- focus: boolean;
49
- enableVerticalNavigation: boolean;
50
- forceRender: React.Dispatch<React.SetStateAction<number>>;
51
- }
52
-
53
- export default function CjkTextInput({
54
- value,
55
- onChange,
56
- onSubmit,
57
- onPaste,
58
- placeholder = '',
59
- focus = true,
60
- showCursor = true,
61
- availableWidth,
62
- cursorHint = null,
63
- enableVerticalNavigation = true,
64
- }: IProps): React.ReactElement {
65
- const stateRef = useRef<ICjkTextInputFlowState>(createCjkTextInputFlowState(value));
66
- const [, forceRender] = useState(0);
67
-
68
- // Sync ref when value changes from parent (e.g., setValue(''), tab completion, paste)
69
- stateRef.current = syncCjkTextInputFlowState(stateRef.current, value, cursorHint);
70
-
71
- useCjkTextInputHandlers({
72
- stateRef,
73
- onChange,
74
- onSubmit,
75
- onPaste,
76
- availableWidth,
77
- focus,
78
- enableVerticalNavigation,
79
- forceRender,
80
- });
81
-
82
- // Real terminal cursor positioning is intentionally omitted.
83
- // setCursorPosition(x, 0) crashes Terminal.app via Korean IME SIGSEGV.
84
- // Correct fix requires the input row's y offset from the bottom of the render,
85
- // which Ink does not expose. Tracked as a known limitation.
86
-
87
- return (
88
- <Text>
89
- {renderWithCursor(
90
- stateRef.current.value,
91
- stateRef.current.cursor,
92
- placeholder,
93
- showCursor && focus,
94
- )}
95
- </Text>
96
- );
97
- }
98
-
99
- function useCjkTextInputHandlers(options: IInputHandlerOptions): void {
100
- usePaste(
101
- (text) => {
102
- applyCjkFlowSafely(options, () =>
103
- applyCjkTextPaste(options.stateRef.current, text, createFlowOptions(options)),
104
- );
105
- },
106
- { isActive: options.focus },
107
- );
108
-
109
- useInput(
110
- (input, key) => {
111
- applyCjkFlowSafely(options, () =>
112
- applyCjkTextInput(options.stateRef.current, input, key, createFlowOptions(options)),
113
- );
114
- },
115
- { isActive: options.focus },
116
- );
117
- }
118
-
119
- function createFlowOptions(options: IInputHandlerOptions): {
120
- availableWidth?: number;
121
- canPaste: boolean;
122
- enableVerticalNavigation: boolean;
123
- } {
124
- return {
125
- availableWidth: options.availableWidth,
126
- canPaste: options.onPaste !== undefined,
127
- enableVerticalNavigation: options.enableVerticalNavigation,
128
- };
129
- }
130
-
131
- function applyCjkFlowSafely(
132
- options: IInputHandlerOptions,
133
- run: () => ReturnType<typeof applyCjkTextInput>,
134
- ): void {
135
- try {
136
- const result = run();
137
- options.stateRef.current = result.state;
138
- applyCjkTextInputEffect(
139
- result.effect,
140
- options.onChange,
141
- options.onSubmit,
142
- options.onPaste,
143
- options.forceRender,
144
- );
145
- } catch {
146
- // allow-fallback: Korean IME in raw mode can produce unexpected byte sequences
147
- }
148
- }
149
-
150
- function applyCjkTextInputEffect(
151
- effect: ReturnType<typeof applyCjkTextInput>['effect'],
152
- onChange: (value: string) => void,
153
- onSubmit: ((value: string) => void) | undefined,
154
- onPaste: ((text: string, cursorPosition: number) => void) | undefined,
155
- forceRender: React.Dispatch<React.SetStateAction<number>>,
156
- ): void {
157
- if (effect.type === 'change') {
158
- onChange(effect.value);
159
- } else if (effect.type === 'submit') {
160
- onSubmit?.(effect.value);
161
- } else if (effect.type === 'paste') {
162
- onPaste?.(effect.text, effect.cursor);
163
- } else if (effect.type === 'render') {
164
- forceRender((n) => n + 1);
165
- }
166
- }
167
-
168
- /** Render text with an inverse-style cursor at the correct position */
169
- function renderWithCursor(
170
- value: string,
171
- cursorOffset: number,
172
- placeholder: string,
173
- showCursor: boolean,
174
- ): string {
175
- if (!showCursor) {
176
- return value.length > 0 ? value : placeholder ? chalk.gray(placeholder) : '';
177
- }
178
-
179
- if (value.length === 0) {
180
- if (placeholder.length > 0) {
181
- return chalk.inverse(placeholder[0]) + chalk.gray(placeholder.slice(1));
182
- }
183
- return chalk.inverse(' ');
184
- }
185
-
186
- const chars = [...value];
187
- let rendered = '';
188
-
189
- for (let i = 0; i < chars.length; i++) {
190
- const char = chars[i] ?? '';
191
- rendered += i === cursorOffset ? chalk.inverse(char) : char;
192
- }
193
-
194
- if (cursorOffset >= chars.length) {
195
- rendered += chalk.inverse(' ');
196
- }
197
-
198
- return rendered;
199
- }
@@ -1,70 +0,0 @@
1
- /**
2
- * Reusable confirmation prompt with arrow-key selection.
3
- * Used by model change, permission prompts, and other yes/no confirmations.
4
- */
5
-
6
- import { Box, Text, useInput } from 'ink';
7
- import React, { useState, useRef, useCallback } from 'react';
8
-
9
- import {
10
- applyConfirmPromptInput,
11
- getConfirmPromptInputAction,
12
- type TConfirmPromptInputAction,
13
- } from './flows/confirm-prompt-flow.js';
14
- import { createSelectionFlowState, type ISelectionFlowState } from './flows/selection-flow.js';
15
-
16
- interface IProps {
17
- /** Message to display above the options */
18
- message: string;
19
- /** Options to select from (default: ['Yes', 'No']) */
20
- options?: string[];
21
- /** Callback with the selected index */
22
- onSelect: (index: number) => void;
23
- }
24
-
25
- export default function ConfirmPrompt({
26
- message,
27
- options = ['Yes', 'No'],
28
- onSelect,
29
- }: IProps): React.ReactElement {
30
- const [state, setState] = useState<ISelectionFlowState>(() => createSelectionFlowState());
31
- const stateRef = useRef(state);
32
- const applyAction = useCallback(
33
- (action: TConfirmPromptInputAction): void => {
34
- const result = applyConfirmPromptInput(stateRef.current, action, options.length);
35
- stateRef.current = result.state;
36
- setState(result.state);
37
- if (result.effect.type === 'select') {
38
- onSelect(result.effect.index);
39
- }
40
- },
41
- [onSelect, options.length],
42
- );
43
-
44
- useInput((input, key) => {
45
- const action = getConfirmPromptInputAction(input, key, options.length);
46
- if (action !== undefined) {
47
- applyAction(action);
48
- }
49
- });
50
-
51
- return (
52
- <Box flexDirection="column" borderStyle="round" borderColor="yellow" paddingX={1}>
53
- <Text color="yellow">{message}</Text>
54
- <Box marginTop={1}>
55
- {options.map((opt, i) => (
56
- <Box key={opt} marginRight={2}>
57
- <Text
58
- color={i === state.selectedIndex ? 'cyan' : undefined}
59
- bold={i === state.selectedIndex}
60
- >
61
- {i === state.selectedIndex ? '> ' : ' '}
62
- {opt}
63
- </Text>
64
- </Box>
65
- ))}
66
- </Box>
67
- <Text dimColor> arrow keys to select, Enter to confirm</Text>
68
- </Box>
69
- );
70
- }
@@ -1,34 +0,0 @@
1
- import { Box, Text } from 'ink';
2
- import React from 'react';
3
-
4
- interface IProps {
5
- percentage: number;
6
- }
7
-
8
- const COMPACT_SUGGESTION_THRESHOLD = 70;
9
- const CRITICAL_THRESHOLD = 90;
10
-
11
- export function ContextWarningBanner({ percentage }: IProps): React.ReactElement | null {
12
- if (percentage >= CRITICAL_THRESHOLD) {
13
- return (
14
- <Box borderStyle="single" borderColor="red" paddingX={1}>
15
- <Text color="red" bold>
16
- ⚠ Context at {Math.round(percentage)}% — window nearly full. Run /compact to summarize
17
- the conversation.
18
- </Text>
19
- </Box>
20
- );
21
- }
22
-
23
- if (percentage >= COMPACT_SUGGESTION_THRESHOLD) {
24
- return (
25
- <Box paddingX={1}>
26
- <Text color="yellow">
27
- Context at {Math.round(percentage)}% — consider running /compact to free up space.
28
- </Text>
29
- </Box>
30
- );
31
- }
32
-
33
- return null;
34
- }
@@ -1,64 +0,0 @@
1
- import { Box, Text } from 'ink';
2
- import React from 'react';
3
-
4
- import {
5
- formatExecutionDetailRecord,
6
- formatExecutionWorkspaceEntryRow,
7
- } from './execution-workspace-view-model.js';
8
-
9
- import type {
10
- IExecutionDetailPage,
11
- IExecutionWorkspaceEntry,
12
- TExecutionDetailRecordKind,
13
- } from '@robota-sdk/agent-interface-transport';
14
-
15
- const MAX_VISIBLE_DETAIL_RECORDS = 12;
16
-
17
- interface IProps {
18
- entry: IExecutionWorkspaceEntry;
19
- page: IExecutionDetailPage | null;
20
- loading?: boolean;
21
- error?: string;
22
- }
23
-
24
- export default function ExecutionWorkspaceDetailPane({
25
- entry,
26
- page,
27
- loading,
28
- error,
29
- }: IProps): React.ReactElement {
30
- const row = formatExecutionWorkspaceEntryRow(entry, { selectedEntryId: entry.id });
31
- const records = page?.records.slice(-MAX_VISIBLE_DETAIL_RECORDS) ?? [];
32
-
33
- return (
34
- <Box flexDirection="column" marginBottom={1}>
35
- <Text color="cyan" bold>
36
- {`Viewing ${row.title}`}
37
- </Text>
38
- <Text dimColor>
39
- {row.statusLabel}
40
- {row.subtitle ? ` · ${row.subtitle}` : ''}
41
- {row.preview ? ` · ${row.preview}` : ''}
42
- </Text>
43
- {loading ? <Text dimColor>Loading workspace detail...</Text> : null}
44
- {error ? <Text color="red">{error}</Text> : null}
45
- {!loading && !error && records.length === 0 ? <Text dimColor>No detail yet</Text> : null}
46
- {!loading &&
47
- !error &&
48
- records.map((record) => (
49
- <Text key={record.id} color={getDetailRecordColor(record.kind)}>
50
- {formatExecutionDetailRecord(record)}
51
- </Text>
52
- ))}
53
- {page?.nextCursor ? <Text dimColor>... more detail available</Text> : null}
54
- </Box>
55
- );
56
- }
57
-
58
- function getDetailRecordColor(kind: TExecutionDetailRecordKind): string | undefined {
59
- if (kind === 'error') return 'red';
60
- if (kind === 'result') return 'green';
61
- if (kind === 'process_output') return 'white';
62
- if (kind === 'group_summary') return 'cyan';
63
- return undefined;
64
- }
@@ -1,187 +0,0 @@
1
- import { Box, Text, useInput } from 'ink';
2
- import React, { useEffect, useRef, useState } from 'react';
3
-
4
- import { formatExecutionWorkspaceEntryRow } from './execution-workspace-view-model.js';
5
- import {
6
- applySelectionInput,
7
- createSelectionFlowState,
8
- getVerticalSelectionInputAction,
9
- normalizeSelectionState,
10
- type ISelectionFlowState,
11
- type TSelectionInputAction,
12
- } from './flows/selection-flow.js';
13
-
14
- import type {
15
- IExecutionWorkspaceEntry,
16
- IExecutionWorkspaceSnapshot,
17
- } from '@robota-sdk/agent-interface-transport';
18
-
19
- const MAX_VISIBLE_WORKSPACE_ENTRIES = 8;
20
-
21
- interface IProps {
22
- snapshot: IExecutionWorkspaceSnapshot | null;
23
- selectedEntryId?: string;
24
- onSelect: (entryId: string) => void;
25
- onClose: () => void;
26
- }
27
-
28
- export default function ExecutionWorkspaceSwitcher({
29
- snapshot,
30
- selectedEntryId,
31
- onSelect,
32
- onClose,
33
- }: IProps): React.ReactElement {
34
- const entries = [...(snapshot?.entries ?? [])];
35
- const { normalized, visibleEntries, applyAction } = useWorkspaceSwitcherSelection({
36
- entries,
37
- selectedEntryId,
38
- onSelect,
39
- onClose,
40
- });
41
-
42
- useInput((_input, key) => {
43
- const action = getVerticalSelectionInputAction(key);
44
- if (action !== undefined) applyAction(action);
45
- });
46
-
47
- return (
48
- <Box flexDirection="column" borderStyle="round" borderColor="cyan" paddingX={1}>
49
- <Text color="cyan" bold>
50
- Execution workspace
51
- </Text>
52
- <Box flexDirection="column" marginTop={1}>
53
- {visibleEntries.length === 0 ? (
54
- <Text dimColor>No workspace entries</Text>
55
- ) : (
56
- visibleEntries.map((entry, index) => (
57
- <ExecutionWorkspaceSwitcherRow
58
- key={entry.id}
59
- entry={entry}
60
- isFocused={normalized.scrollOffset + index === normalized.selectedIndex}
61
- selectedEntryId={selectedEntryId}
62
- />
63
- ))
64
- )}
65
- </Box>
66
- <Text dimColor>Ctrl+B Close ↑↓ Navigate Enter Switch Esc Close</Text>
67
- </Box>
68
- );
69
- }
70
-
71
- interface IUseWorkspaceSwitcherSelectionInput {
72
- entries: IExecutionWorkspaceEntry[];
73
- selectedEntryId?: string;
74
- onSelect: (entryId: string) => void;
75
- onClose: () => void;
76
- }
77
-
78
- function useWorkspaceSwitcherSelection({
79
- entries,
80
- selectedEntryId,
81
- onSelect,
82
- onClose,
83
- }: IUseWorkspaceSwitcherSelectionInput): {
84
- normalized: ISelectionFlowState;
85
- visibleEntries: IExecutionWorkspaceEntry[];
86
- applyAction: (action: TSelectionInputAction) => void;
87
- } {
88
- const [state, setState] = useState<ISelectionFlowState>(() => createSelectionFlowState());
89
- const stateRef = useRef(state);
90
-
91
- useEffect(() => {
92
- const selectedIndex = Math.max(
93
- 0,
94
- entries.findIndex((entry) => entry.id === selectedEntryId),
95
- );
96
- const nextState = createNormalizedSelection({ selectedIndex, itemCount: entries.length });
97
- stateRef.current = nextState;
98
- setState(nextState);
99
- }, [entries.length, selectedEntryId]);
100
-
101
- const normalized = createNormalizedSelection({
102
- selectedIndex: state.selectedIndex,
103
- scrollOffset: state.scrollOffset,
104
- itemCount: entries.length,
105
- });
106
- if (normalized !== state) stateRef.current = normalized;
107
- return {
108
- normalized,
109
- visibleEntries: entries.slice(
110
- normalized.scrollOffset,
111
- normalized.scrollOffset + MAX_VISIBLE_WORKSPACE_ENTRIES,
112
- ),
113
- applyAction: createApplyAction({ entries, stateRef, setState, onSelect, onClose }),
114
- };
115
- }
116
-
117
- function createApplyAction({
118
- entries,
119
- stateRef,
120
- setState,
121
- onSelect,
122
- onClose,
123
- }: {
124
- entries: IExecutionWorkspaceEntry[];
125
- stateRef: React.MutableRefObject<ISelectionFlowState>;
126
- setState: React.Dispatch<React.SetStateAction<ISelectionFlowState>>;
127
- onSelect: (entryId: string) => void;
128
- onClose: () => void;
129
- }): (action: TSelectionInputAction) => void {
130
- return (action): void => {
131
- const result = applySelectionInput(stateRef.current, action, {
132
- itemCount: entries.length,
133
- maxVisible: MAX_VISIBLE_WORKSPACE_ENTRIES,
134
- });
135
- const nextState =
136
- result.effect.type === 'select' || result.effect.type === 'cancel'
137
- ? { ...result.state, resolved: false }
138
- : result.state;
139
- stateRef.current = nextState;
140
- setState(nextState);
141
- if (result.effect.type === 'cancel') {
142
- onClose();
143
- } else if (result.effect.type === 'select') {
144
- const entry = entries[result.effect.index];
145
- if (entry) onSelect(entry.id);
146
- }
147
- };
148
- }
149
-
150
- function createNormalizedSelection(input: {
151
- selectedIndex: number;
152
- scrollOffset?: number;
153
- itemCount: number;
154
- }): ISelectionFlowState {
155
- return normalizeSelectionState(
156
- {
157
- selectedIndex: input.selectedIndex,
158
- scrollOffset: input.scrollOffset ?? 0,
159
- resolved: false,
160
- },
161
- { itemCount: input.itemCount, maxVisible: MAX_VISIBLE_WORKSPACE_ENTRIES },
162
- );
163
- }
164
-
165
- function ExecutionWorkspaceSwitcherRow({
166
- entry,
167
- isFocused,
168
- selectedEntryId,
169
- }: {
170
- entry: IExecutionWorkspaceEntry;
171
- isFocused: boolean;
172
- selectedEntryId?: string;
173
- }): React.ReactElement {
174
- const row = formatExecutionWorkspaceEntryRow(entry, { selectedEntryId });
175
- return (
176
- <Text>
177
- <Text color={isFocused ? 'cyan' : undefined} bold={isFocused}>
178
- {isFocused ? '> ' : ' '}
179
- </Text>
180
- <Text color={row.color}>{row.radio}</Text>
181
- <Text color={isFocused ? 'cyan' : undefined} bold={isFocused}>{` ${row.title}`}</Text>
182
- <Text dimColor>{` · ${row.statusLabel}`}</Text>
183
- {row.subtitle ? <Text dimColor>{` · ${row.subtitle}`}</Text> : null}
184
- {row.preview ? <Text dimColor>{` · ${row.preview}`}</Text> : null}
185
- </Text>
186
- );
187
- }