@robota-sdk/agent-transport 3.0.0-beta.64
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 +21 -0
- package/dist/node/headless/index.cjs +1 -0
- package/dist/node/headless/index.d.ts +2 -0
- package/dist/node/headless/index.js +1 -0
- package/dist/node/headless-CWEpJXFK.js +7 -0
- package/dist/node/headless-CWEpJXFK.js.map +1 -0
- package/dist/node/headless-CsZFelG9.cjs +6 -0
- package/dist/node/http/index.cjs +1 -0
- package/dist/node/http/index.d.ts +2 -0
- package/dist/node/http/index.js +1 -0
- package/dist/node/http-CM3TJhrF.cjs +1 -0
- package/dist/node/http-DwO1AHG-.js +2 -0
- package/dist/node/http-DwO1AHG-.js.map +1 -0
- package/dist/node/index--Ti9NzQX.d.ts +64 -0
- package/dist/node/index--Ti9NzQX.d.ts.map +1 -0
- package/dist/node/index-B_rcr14p.d.ts +47 -0
- package/dist/node/index-B_rcr14p.d.ts.map +1 -0
- package/dist/node/index-C9LWCL4l.d.ts +34 -0
- package/dist/node/index-C9LWCL4l.d.ts.map +1 -0
- package/dist/node/index-CAr3ioVh.d.ts +64 -0
- package/dist/node/index-CAr3ioVh.d.ts.map +1 -0
- package/dist/node/index-CEs25wVk.d.ts +213 -0
- package/dist/node/index-CEs25wVk.d.ts.map +1 -0
- package/dist/node/index-CvXLpjJO.d.ts +213 -0
- package/dist/node/index-CvXLpjJO.d.ts.map +1 -0
- package/dist/node/index-D34WUfFH.d.ts +26 -0
- package/dist/node/index-D34WUfFH.d.ts.map +1 -0
- package/dist/node/index-Y0zHb1Bz.d.ts +47 -0
- package/dist/node/index-Y0zHb1Bz.d.ts.map +1 -0
- package/dist/node/index-k3TUjA-T.d.ts +26 -0
- package/dist/node/index-k3TUjA-T.d.ts.map +1 -0
- package/dist/node/index-nBlMTFkZ.d.ts +34 -0
- package/dist/node/index-nBlMTFkZ.d.ts.map +1 -0
- package/dist/node/index.cjs +1 -0
- package/dist/node/index.d.ts +6 -0
- package/dist/node/index.js +1 -0
- package/dist/node/mcp/index.cjs +1 -0
- package/dist/node/mcp/index.d.ts +2 -0
- package/dist/node/mcp/index.js +1 -0
- package/dist/node/mcp-BXBwF6Wu.js +2 -0
- package/dist/node/mcp-BXBwF6Wu.js.map +1 -0
- package/dist/node/mcp-DcHuGokt.cjs +1 -0
- package/dist/node/tui/index.cjs +1 -0
- package/dist/node/tui/index.d.ts +2 -0
- package/dist/node/tui/index.js +1 -0
- package/dist/node/tui-CeD_6rSo.cjs +24 -0
- package/dist/node/tui-zmDTPk4b.js +25 -0
- package/dist/node/tui-zmDTPk4b.js.map +1 -0
- package/dist/node/ws/index.cjs +1 -0
- package/dist/node/ws/index.d.ts +2 -0
- package/dist/node/ws/index.js +1 -0
- package/dist/node/ws-B-oRccFl.js +2 -0
- package/dist/node/ws-B-oRccFl.js.map +1 -0
- package/dist/node/ws-COnIgnmn.cjs +1 -0
- package/package.json +141 -0
- package/src/headless/__tests__/headless-runner-initialization.test.ts +45 -0
- package/src/headless/__tests__/headless-runner.test.ts +484 -0
- package/src/headless/__tests__/headless-skill-activation.integration.test.ts +430 -0
- package/src/headless/__tests__/headless-transport.test.ts +268 -0
- package/src/headless/headless-runner.ts +141 -0
- package/src/headless/headless-stream-json.ts +142 -0
- package/src/headless/headless-transport.ts +43 -0
- package/src/headless/index.ts +4 -0
- package/src/http/__tests__/http-transport.test.ts +55 -0
- package/src/http/__tests__/routes.test.ts +168 -0
- package/src/http/http-transport.ts +42 -0
- package/src/http/index.ts +4 -0
- package/src/http/routes.ts +151 -0
- package/src/index.ts +5 -0
- package/src/mcp/__tests__/mcp-server.test.ts +66 -0
- package/src/mcp/__tests__/mcp-transport.test.ts +46 -0
- package/src/mcp/index.ts +4 -0
- package/src/mcp/mcp-server.ts +162 -0
- package/src/mcp/mcp-transport.ts +48 -0
- package/src/tui/App.tsx +478 -0
- package/src/tui/BackgroundTaskPanel.tsx +34 -0
- package/src/tui/CjkTextInput.tsx +204 -0
- package/src/tui/ConfirmPrompt.tsx +69 -0
- package/src/tui/ExecutionWorkspaceDetailPane.tsx +62 -0
- package/src/tui/ExecutionWorkspaceSwitcher.tsx +185 -0
- package/src/tui/InkTerminal.ts +42 -0
- package/src/tui/InputArea.tsx +298 -0
- package/src/tui/InteractivePrompt.tsx +57 -0
- package/src/tui/ListPicker.tsx +94 -0
- package/src/tui/MenuSelect.tsx +103 -0
- package/src/tui/MessageList.tsx +282 -0
- package/src/tui/PermissionPrompt.tsx +84 -0
- package/src/tui/PluginTUI.tsx +256 -0
- package/src/tui/SessionPicker.tsx +66 -0
- package/src/tui/SessionStatusBar.tsx +66 -0
- package/src/tui/SlashAutocomplete.tsx +110 -0
- package/src/tui/StatusBar.tsx +213 -0
- package/src/tui/StreamingIndicator.tsx +91 -0
- package/src/tui/TextPrompt.tsx +80 -0
- package/src/tui/ToolCommandOutput.tsx +37 -0
- package/src/tui/ToolDiffBlock.tsx +30 -0
- package/src/tui/TransportTUI.tsx +116 -0
- package/src/tui/UpdateNotice.tsx +14 -0
- package/src/tui/UsageSummaryEntry.tsx +38 -0
- package/src/tui/WaveText.tsx +44 -0
- package/src/tui/__tests__/InteractivePrompt.test.tsx +82 -0
- package/src/tui/__tests__/ListPicker.test.tsx +159 -0
- package/src/tui/__tests__/MenuSelect.test.tsx +103 -0
- package/src/tui/__tests__/PluginTUI.test.tsx +167 -0
- package/src/tui/__tests__/SlashAutocomplete.test.tsx +140 -0
- package/src/tui/__tests__/TextPrompt.test.tsx +98 -0
- package/src/tui/__tests__/UpdateNotice.test.tsx +15 -0
- package/src/tui/__tests__/abort-after-permission.test.tsx +169 -0
- package/src/tui/__tests__/abort-streaming-e2e.test.tsx +183 -0
- package/src/tui/__tests__/background-task-panel.test.tsx +53 -0
- package/src/tui/__tests__/background-task-row-format.test.ts +59 -0
- package/src/tui/__tests__/cjk-text-input-flow.test.ts +109 -0
- package/src/tui/__tests__/cjk-text-input.test.ts +191 -0
- package/src/tui/__tests__/command-effect-handler.test.ts +128 -0
- package/src/tui/__tests__/command-output-summary.test.ts +95 -0
- package/src/tui/__tests__/compact-event-bridge.test.ts +20 -0
- package/src/tui/__tests__/confirm-permission-flow.test.ts +91 -0
- package/src/tui/__tests__/confirm-prompt.test.tsx +87 -0
- package/src/tui/__tests__/execution-workspace-switcher.test.tsx +110 -0
- package/src/tui/__tests__/execution-workspace-view-model.test.ts +93 -0
- package/src/tui/__tests__/fixtures/provider-setup-prompt-driver.tsx +122 -0
- package/src/tui/__tests__/input-area-flow.test.ts +152 -0
- package/src/tui/__tests__/message-list-rendering.test.tsx +353 -0
- package/src/tui/__tests__/model-change-side-effect.test.ts +91 -0
- package/src/tui/__tests__/prompt-queue.test.tsx +255 -0
- package/src/tui/__tests__/provider-setup-pty-e2e.test.ts +233 -0
- package/src/tui/__tests__/render-markdown.test.ts +72 -0
- package/src/tui/__tests__/selection-flow.test.ts +61 -0
- package/src/tui/__tests__/slash-routing-effects.test.ts +225 -0
- package/src/tui/__tests__/status-activity.test.ts +71 -0
- package/src/tui/__tests__/status-bar.test.tsx +157 -0
- package/src/tui/__tests__/streaming-indicator.test.tsx +137 -0
- package/src/tui/__tests__/text-prompt-flow.test.ts +77 -0
- package/src/tui/__tests__/tui-state-manager.test.ts +401 -0
- package/src/tui/background-task-row-format.ts +52 -0
- package/src/tui/command-output-summary.ts +122 -0
- package/src/tui/execution-workspace-view-model.ts +123 -0
- package/src/tui/flows/cjk-text-input-flow.ts +285 -0
- package/src/tui/flows/confirm-prompt-flow.ts +45 -0
- package/src/tui/flows/input-area-flow.ts +186 -0
- package/src/tui/flows/permission-prompt-flow.ts +76 -0
- package/src/tui/flows/selection-flow.ts +126 -0
- package/src/tui/flows/text-prompt-flow.ts +98 -0
- package/src/tui/hooks/command-effect-handler.ts +98 -0
- package/src/tui/hooks/command-effect-queue.ts +39 -0
- package/src/tui/hooks/model-change-side-effect.ts +63 -0
- package/src/tui/hooks/side-effects-types.ts +38 -0
- package/src/tui/hooks/use-interactive-session-init.ts +50 -0
- package/src/tui/hooks/useAutocomplete.ts +85 -0
- package/src/tui/hooks/useInteractiveSession.ts +273 -0
- package/src/tui/hooks/usePermissionQueue.ts +51 -0
- package/src/tui/hooks/usePluginCallbacks.ts +30 -0
- package/src/tui/hooks/usePluginScreenData.ts +84 -0
- package/src/tui/hooks/useSideEffects.ts +210 -0
- package/src/tui/hooks/useSlashRouting.ts +117 -0
- package/src/tui/hooks/useStatusLineSettings.ts +35 -0
- package/src/tui/index.ts +3 -0
- package/src/tui/plugin-tui-handlers.ts +163 -0
- package/src/tui/render-markdown.ts +129 -0
- package/src/tui/render.tsx +60 -0
- package/src/tui/status-activity.ts +63 -0
- package/src/tui/tui-cli-adapter-context.tsx +12 -0
- package/src/tui/tui-cli-adapter.ts +25 -0
- package/src/tui/tui-state-manager.ts +225 -0
- package/src/tui/tui-transport.ts +32 -0
- package/src/tui/types.ts +14 -0
- package/src/tui/utils/__tests__/edit-diff.test.ts +426 -0
- package/src/tui/utils/__tests__/paste-detection.test.ts +116 -0
- package/src/tui/utils/__tests__/paste-labels.test.ts +46 -0
- package/src/tui/utils/__tests__/tool-call-extractor.test.ts +227 -0
- package/src/tui/utils/__tests__/tool-diff-summary.test.ts +104 -0
- package/src/tui/utils/edit-diff.ts +152 -0
- package/src/tui/utils/paste-labels.ts +9 -0
- package/src/tui/utils/tool-call-extractor.ts +91 -0
- package/src/tui/utils/tool-diff-summary.ts +75 -0
- package/src/ws/__tests__/ws-handler.test.ts +407 -0
- package/src/ws/__tests__/ws-transport.test.ts +53 -0
- package/src/ws/index.ts +13 -0
- package/src/ws/ws-background-messages.ts +170 -0
- package/src/ws/ws-handler.ts +279 -0
- package/src/ws/ws-protocol.ts +76 -0
- package/src/ws/ws-transport-configurable.ts +123 -0
- package/src/ws/ws-transport.ts +42 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applySelectionInput,
|
|
3
|
+
getDirectionalSelectionInputAction,
|
|
4
|
+
type ISelectionFlowState,
|
|
5
|
+
type ISelectionInputKey,
|
|
6
|
+
type TSelectionInputAction,
|
|
7
|
+
} from './selection-flow.js';
|
|
8
|
+
|
|
9
|
+
export const PERMISSION_PROMPT_OPTIONS = ['Allow', 'Allow always (this session)', 'Deny'] as const;
|
|
10
|
+
|
|
11
|
+
export type TPermissionPromptDecision = true | 'allow-session' | false;
|
|
12
|
+
export type TPermissionPromptInputAction =
|
|
13
|
+
| TSelectionInputAction
|
|
14
|
+
| { type: 'shortcut'; index: number };
|
|
15
|
+
|
|
16
|
+
export type TPermissionPromptEffect =
|
|
17
|
+
| { type: 'none' }
|
|
18
|
+
| { type: 'resolve'; decision: TPermissionPromptDecision };
|
|
19
|
+
|
|
20
|
+
export function getPermissionPromptInputAction(
|
|
21
|
+
input: string,
|
|
22
|
+
key: ISelectionInputKey,
|
|
23
|
+
): TPermissionPromptInputAction | undefined {
|
|
24
|
+
const action = getDirectionalSelectionInputAction({ ...key, escape: false });
|
|
25
|
+
if (action !== undefined) {
|
|
26
|
+
return action;
|
|
27
|
+
}
|
|
28
|
+
if (input === 'y' || input === '1') {
|
|
29
|
+
return { type: 'shortcut', index: 0 };
|
|
30
|
+
}
|
|
31
|
+
if (input === 'a' || input === '2') {
|
|
32
|
+
return { type: 'shortcut', index: 1 };
|
|
33
|
+
}
|
|
34
|
+
if (input === 'n' || input === 'd' || input === '3') {
|
|
35
|
+
return { type: 'shortcut', index: 2 };
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function applyPermissionPromptInput(
|
|
41
|
+
state: ISelectionFlowState,
|
|
42
|
+
action: TPermissionPromptInputAction,
|
|
43
|
+
): { state: ISelectionFlowState; effect: TPermissionPromptEffect } {
|
|
44
|
+
if (state.resolved) {
|
|
45
|
+
return { state, effect: { type: 'none' } };
|
|
46
|
+
}
|
|
47
|
+
if (typeof action !== 'string') {
|
|
48
|
+
return resolvePermissionIndex(state, action.index);
|
|
49
|
+
}
|
|
50
|
+
const result = applySelectionInput(state, action, {
|
|
51
|
+
itemCount: PERMISSION_PROMPT_OPTIONS.length,
|
|
52
|
+
});
|
|
53
|
+
if (result.effect.type !== 'select') {
|
|
54
|
+
return { state: result.state, effect: { type: 'none' } };
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
state: result.state,
|
|
58
|
+
effect: { type: 'resolve', decision: getPermissionDecision(result.effect.index) },
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function getPermissionDecision(index: number): TPermissionPromptDecision {
|
|
63
|
+
if (index === 0) return true;
|
|
64
|
+
if (index === 1) return 'allow-session';
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function resolvePermissionIndex(
|
|
69
|
+
state: ISelectionFlowState,
|
|
70
|
+
index: number,
|
|
71
|
+
): { state: ISelectionFlowState; effect: TPermissionPromptEffect } {
|
|
72
|
+
return {
|
|
73
|
+
state: { ...state, selectedIndex: index, resolved: true },
|
|
74
|
+
effect: { type: 'resolve', decision: getPermissionDecision(index) },
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
export interface ISelectionFlowState {
|
|
2
|
+
selectedIndex: number;
|
|
3
|
+
scrollOffset: number;
|
|
4
|
+
resolved: boolean;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface ISelectionInputKey {
|
|
8
|
+
escape?: boolean;
|
|
9
|
+
return?: boolean;
|
|
10
|
+
upArrow?: boolean;
|
|
11
|
+
downArrow?: boolean;
|
|
12
|
+
leftArrow?: boolean;
|
|
13
|
+
rightArrow?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type TSelectionInputAction = 'cancel' | 'select' | 'previous' | 'next';
|
|
17
|
+
|
|
18
|
+
export type TSelectionEffect =
|
|
19
|
+
| { type: 'none' }
|
|
20
|
+
| { type: 'cancel' }
|
|
21
|
+
| { type: 'select'; index: number };
|
|
22
|
+
|
|
23
|
+
export interface ISelectionFlowOptions {
|
|
24
|
+
itemCount: number;
|
|
25
|
+
maxVisible?: number;
|
|
26
|
+
wrap?: boolean;
|
|
27
|
+
enabled?: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function createSelectionFlowState(): ISelectionFlowState {
|
|
31
|
+
return { selectedIndex: 0, scrollOffset: 0, resolved: false };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function getVerticalSelectionInputAction(
|
|
35
|
+
key: ISelectionInputKey,
|
|
36
|
+
): TSelectionInputAction | undefined {
|
|
37
|
+
if (key.escape === true) return 'cancel';
|
|
38
|
+
if (key.upArrow === true) return 'previous';
|
|
39
|
+
if (key.downArrow === true) return 'next';
|
|
40
|
+
if (key.return === true) return 'select';
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function getDirectionalSelectionInputAction(
|
|
45
|
+
key: ISelectionInputKey,
|
|
46
|
+
): TSelectionInputAction | undefined {
|
|
47
|
+
if (key.escape === true) return 'cancel';
|
|
48
|
+
if (key.leftArrow === true || key.upArrow === true) return 'previous';
|
|
49
|
+
if (key.rightArrow === true || key.downArrow === true) return 'next';
|
|
50
|
+
if (key.return === true) return 'select';
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function applySelectionInput(
|
|
55
|
+
state: ISelectionFlowState,
|
|
56
|
+
action: TSelectionInputAction,
|
|
57
|
+
options: ISelectionFlowOptions,
|
|
58
|
+
): { state: ISelectionFlowState; effect: TSelectionEffect } {
|
|
59
|
+
if (state.resolved) {
|
|
60
|
+
return { state, effect: { type: 'none' } };
|
|
61
|
+
}
|
|
62
|
+
if (action === 'cancel') {
|
|
63
|
+
return { state: { ...state, resolved: true }, effect: { type: 'cancel' } };
|
|
64
|
+
}
|
|
65
|
+
if (options.enabled === false || options.itemCount === 0) {
|
|
66
|
+
return { state, effect: { type: 'none' } };
|
|
67
|
+
}
|
|
68
|
+
if (action === 'select') {
|
|
69
|
+
const index = clampIndex(state.selectedIndex, options.itemCount);
|
|
70
|
+
return {
|
|
71
|
+
state: { ...state, selectedIndex: index, resolved: true },
|
|
72
|
+
effect: { type: 'select', index },
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const selectedIndex = moveSelection(state.selectedIndex, action, options);
|
|
76
|
+
const scrollOffset = resolveScrollOffset(selectedIndex, state.scrollOffset, options);
|
|
77
|
+
return { state: { ...state, selectedIndex, scrollOffset }, effect: { type: 'none' } };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function normalizeSelectionState(
|
|
81
|
+
state: ISelectionFlowState,
|
|
82
|
+
options: ISelectionFlowOptions,
|
|
83
|
+
): ISelectionFlowState {
|
|
84
|
+
if (options.itemCount === 0) {
|
|
85
|
+
return { ...state, selectedIndex: 0, scrollOffset: 0 };
|
|
86
|
+
}
|
|
87
|
+
const selectedIndex = clampIndex(state.selectedIndex, options.itemCount);
|
|
88
|
+
const scrollOffset = resolveScrollOffset(selectedIndex, state.scrollOffset, options);
|
|
89
|
+
if (selectedIndex === state.selectedIndex && scrollOffset === state.scrollOffset) {
|
|
90
|
+
return state;
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
...state,
|
|
94
|
+
selectedIndex,
|
|
95
|
+
scrollOffset,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function moveSelection(
|
|
100
|
+
selectedIndex: number,
|
|
101
|
+
action: TSelectionInputAction,
|
|
102
|
+
options: ISelectionFlowOptions,
|
|
103
|
+
): number {
|
|
104
|
+
if (action === 'previous') {
|
|
105
|
+
if (options.wrap === true && selectedIndex === 0) return options.itemCount - 1;
|
|
106
|
+
return Math.max(0, selectedIndex - 1);
|
|
107
|
+
}
|
|
108
|
+
if (options.wrap === true && selectedIndex === options.itemCount - 1) return 0;
|
|
109
|
+
return Math.min(options.itemCount - 1, selectedIndex + 1);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function resolveScrollOffset(
|
|
113
|
+
selectedIndex: number,
|
|
114
|
+
scrollOffset: number,
|
|
115
|
+
options: ISelectionFlowOptions,
|
|
116
|
+
): number {
|
|
117
|
+
const maxVisible = options.maxVisible ?? options.itemCount;
|
|
118
|
+
if (maxVisible <= 0) return 0;
|
|
119
|
+
if (selectedIndex < scrollOffset) return selectedIndex;
|
|
120
|
+
if (selectedIndex >= scrollOffset + maxVisible) return selectedIndex - maxVisible + 1;
|
|
121
|
+
return Math.max(0, scrollOffset);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function clampIndex(index: number, itemCount: number): number {
|
|
125
|
+
return Math.min(Math.max(index, 0), itemCount - 1);
|
|
126
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export interface ITextPromptFlowState {
|
|
2
|
+
value: string;
|
|
3
|
+
error?: string;
|
|
4
|
+
resolved: boolean;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface ITextPromptInputKey {
|
|
8
|
+
escape?: boolean;
|
|
9
|
+
return?: boolean;
|
|
10
|
+
backspace?: boolean;
|
|
11
|
+
delete?: boolean;
|
|
12
|
+
ctrl?: boolean;
|
|
13
|
+
meta?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type TTextPromptInputAction =
|
|
17
|
+
| { type: 'cancel' }
|
|
18
|
+
| { type: 'submit' }
|
|
19
|
+
| { type: 'delete' }
|
|
20
|
+
| { type: 'insert'; value: string };
|
|
21
|
+
|
|
22
|
+
export type TTextPromptEffect =
|
|
23
|
+
| { type: 'none' }
|
|
24
|
+
| { type: 'cancel' }
|
|
25
|
+
| { type: 'submit'; value: string };
|
|
26
|
+
|
|
27
|
+
export interface ITextPromptFlowOptions {
|
|
28
|
+
allowEmpty: boolean;
|
|
29
|
+
validate?: (value: string) => string | undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function createTextPromptFlowState(): ITextPromptFlowState {
|
|
33
|
+
return { value: '', resolved: false };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function getTextPromptInputAction(
|
|
37
|
+
input: string,
|
|
38
|
+
key: ITextPromptInputKey,
|
|
39
|
+
): TTextPromptInputAction | undefined {
|
|
40
|
+
if (key.escape === true) {
|
|
41
|
+
return { type: 'cancel' };
|
|
42
|
+
}
|
|
43
|
+
if (key.return === true) {
|
|
44
|
+
return { type: 'submit' };
|
|
45
|
+
}
|
|
46
|
+
if (key.backspace === true || key.delete === true) {
|
|
47
|
+
return { type: 'delete' };
|
|
48
|
+
}
|
|
49
|
+
if (input && key.ctrl !== true && key.meta !== true) {
|
|
50
|
+
return { type: 'insert', value: input };
|
|
51
|
+
}
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function applyTextPromptInput(
|
|
56
|
+
state: ITextPromptFlowState,
|
|
57
|
+
action: TTextPromptInputAction,
|
|
58
|
+
options: ITextPromptFlowOptions,
|
|
59
|
+
): { state: ITextPromptFlowState; effect: TTextPromptEffect } {
|
|
60
|
+
if (state.resolved) {
|
|
61
|
+
return { state, effect: { type: 'none' } };
|
|
62
|
+
}
|
|
63
|
+
if (action.type === 'cancel') {
|
|
64
|
+
return { state: { ...state, resolved: true }, effect: { type: 'cancel' } };
|
|
65
|
+
}
|
|
66
|
+
if (action.type === 'delete') {
|
|
67
|
+
return {
|
|
68
|
+
state: { ...state, value: state.value.slice(0, -1), error: undefined },
|
|
69
|
+
effect: { type: 'none' },
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (action.type === 'insert') {
|
|
73
|
+
return {
|
|
74
|
+
state: { ...state, value: state.value + action.value, error: undefined },
|
|
75
|
+
effect: { type: 'none' },
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return submitTextPromptValue(state, options);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function submitTextPromptValue(
|
|
82
|
+
state: ITextPromptFlowState,
|
|
83
|
+
options: ITextPromptFlowOptions,
|
|
84
|
+
): { state: ITextPromptFlowState; effect: TTextPromptEffect } {
|
|
85
|
+
const trimmed = state.value.trim();
|
|
86
|
+
if (!trimmed && !options.allowEmpty) {
|
|
87
|
+
const emptyError = options.validate?.(trimmed);
|
|
88
|
+
return {
|
|
89
|
+
state: emptyError ? { ...state, error: emptyError } : state,
|
|
90
|
+
effect: { type: 'none' },
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
const error = options.validate?.(trimmed);
|
|
94
|
+
if (error !== undefined) {
|
|
95
|
+
return { state: { ...state, error }, effect: { type: 'none' } };
|
|
96
|
+
}
|
|
97
|
+
return { state: { ...state, resolved: true }, effect: { type: 'submit', value: trimmed } };
|
|
98
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { TCommandEffect, TStatusLineCommandSettingsPatch } from '@robota-sdk/agent-framework';
|
|
2
|
+
import { isStatusLineCommandSettingsPatch } from '@robota-sdk/agent-framework';
|
|
3
|
+
import { createSystemMessage, messageToHistoryEntry } from '@robota-sdk/agent-core';
|
|
4
|
+
import type { IHistoryEntry, TSessionEndReason } from '@robota-sdk/agent-core';
|
|
5
|
+
import type { ITuiCliAdapter } from '../tui-cli-adapter.js';
|
|
6
|
+
|
|
7
|
+
export interface ICommandEffectHandlerDeps {
|
|
8
|
+
addEntry: (entry: IHistoryEntry) => void;
|
|
9
|
+
requestShutdown: (reason: TSessionEndReason, message: string) => void;
|
|
10
|
+
requestModelChange: (modelId: string) => void;
|
|
11
|
+
openPluginTUI: () => void;
|
|
12
|
+
openSessionPicker: () => void;
|
|
13
|
+
openTransportTUI: () => void;
|
|
14
|
+
openAgentSwitcher: () => void;
|
|
15
|
+
renameSession: (name: string) => void;
|
|
16
|
+
applyStatusLinePatch: (patch: TStatusLineCommandSettingsPatch) => boolean;
|
|
17
|
+
cliAdapter: ITuiCliAdapter;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function applyCommandEffects(
|
|
21
|
+
effects: readonly TCommandEffect[],
|
|
22
|
+
deps: ICommandEffectHandlerDeps,
|
|
23
|
+
): boolean {
|
|
24
|
+
for (const effect of effects) {
|
|
25
|
+
if (effect.type === 'model-change-requested') {
|
|
26
|
+
deps.requestModelChange(effect.modelId);
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
if (effect.type === 'language-change-requested') {
|
|
30
|
+
applyLanguageEffect(effect.language, deps);
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
if (effect.type === 'settings-reset-requested') {
|
|
34
|
+
applySettingsResetEffect(deps);
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
if (effect.type === 'session-exit-requested') {
|
|
38
|
+
deps.requestShutdown(
|
|
39
|
+
effect.reason ?? 'prompt_input_exit',
|
|
40
|
+
effect.message ?? 'User requested exit',
|
|
41
|
+
);
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
if (effect.type === 'session-restart-requested') {
|
|
45
|
+
deps.requestShutdown(effect.reason, effect.message);
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
if (effect.type === 'plugin-tui-requested') {
|
|
49
|
+
deps.openPluginTUI();
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
if (effect.type === 'settings-tui-requested') {
|
|
53
|
+
deps.openTransportTUI();
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
if (effect.type === 'agent-switcher-requested') {
|
|
57
|
+
deps.openAgentSwitcher();
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
if (effect.type === 'session-picker-requested') {
|
|
61
|
+
deps.openSessionPicker();
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
if (effect.type === 'session-renamed') {
|
|
65
|
+
deps.renameSession(effect.name);
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
if (effect.type === 'statusline-settings-patch') {
|
|
69
|
+
if (isStatusLineCommandSettingsPatch(effect.patch)) {
|
|
70
|
+
return deps.applyStatusLinePatch(effect.patch);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function applyLanguageEffect(language: string, deps: ICommandEffectHandlerDeps): void {
|
|
78
|
+
const settingsPath = deps.cliAdapter.getUserSettingsPath();
|
|
79
|
+
const settings = deps.cliAdapter.readSettings(settingsPath);
|
|
80
|
+
settings.language = language;
|
|
81
|
+
deps.cliAdapter.writeSettings(settingsPath, settings);
|
|
82
|
+
deps.addEntry(
|
|
83
|
+
messageToHistoryEntry(createSystemMessage(`Language set to "${language}". Restarting...`)),
|
|
84
|
+
);
|
|
85
|
+
deps.requestShutdown('other', 'Language change restart');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function applySettingsResetEffect(deps: ICommandEffectHandlerDeps): void {
|
|
89
|
+
const settingsPath = deps.cliAdapter.getUserSettingsPath();
|
|
90
|
+
if (deps.cliAdapter.deleteSettings(settingsPath)) {
|
|
91
|
+
deps.addEntry(
|
|
92
|
+
messageToHistoryEntry(createSystemMessage(`Deleted ${settingsPath}. Exiting...`)),
|
|
93
|
+
);
|
|
94
|
+
} else {
|
|
95
|
+
deps.addEntry(messageToHistoryEntry(createSystemMessage('No user settings found.')));
|
|
96
|
+
}
|
|
97
|
+
deps.requestShutdown('other', 'Reset settings restart');
|
|
98
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ICommandInteraction, TCommandEffect } from '@robota-sdk/agent-framework';
|
|
2
|
+
|
|
3
|
+
export type TQueuedCommandState =
|
|
4
|
+
| {
|
|
5
|
+
type: 'interaction';
|
|
6
|
+
interaction: ICommandInteraction;
|
|
7
|
+
}
|
|
8
|
+
| {
|
|
9
|
+
type: 'effects';
|
|
10
|
+
effects: readonly TCommandEffect[];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export interface ICommandEffectQueue {
|
|
14
|
+
enqueueInteraction(interaction: ICommandInteraction): void;
|
|
15
|
+
enqueueEffects(effects: readonly TCommandEffect[]): void;
|
|
16
|
+
drain(): TQueuedCommandState | undefined;
|
|
17
|
+
clear(): void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class CommandEffectQueue implements ICommandEffectQueue {
|
|
21
|
+
private readonly queue: TQueuedCommandState[] = [];
|
|
22
|
+
|
|
23
|
+
enqueueInteraction(interaction: ICommandInteraction): void {
|
|
24
|
+
this.queue.push({ type: 'interaction', interaction });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
enqueueEffects(effects: readonly TCommandEffect[]): void {
|
|
28
|
+
if (effects.length === 0) return;
|
|
29
|
+
this.queue.push({ type: 'effects', effects: [...effects] });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
drain(): TQueuedCommandState | undefined {
|
|
33
|
+
return this.queue.shift();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
clear(): void {
|
|
37
|
+
this.queue.length = 0;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createSystemMessage,
|
|
3
|
+
getModelName,
|
|
4
|
+
messageToHistoryEntry,
|
|
5
|
+
type IHistoryEntry,
|
|
6
|
+
type TSessionEndReason,
|
|
7
|
+
} from '@robota-sdk/agent-core';
|
|
8
|
+
|
|
9
|
+
type TApplyModelChange = (
|
|
10
|
+
cwd: string,
|
|
11
|
+
modelId: string,
|
|
12
|
+
options?: { providerOverride?: string },
|
|
13
|
+
) => { applied: boolean };
|
|
14
|
+
|
|
15
|
+
export interface IApplyConfirmedModelChangeDeps {
|
|
16
|
+
cwd: string;
|
|
17
|
+
modelId: string;
|
|
18
|
+
providerOverride?: string | undefined;
|
|
19
|
+
addEntry: (entry: IHistoryEntry) => void;
|
|
20
|
+
requestShutdown: (reason: TSessionEndReason, message: string) => void;
|
|
21
|
+
applyModelChange?: TApplyModelChange;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function formatModelChangeConfirmationMessage(modelId: string): string {
|
|
25
|
+
return `Change model to ${getModelName(modelId)}? This will exit the current session so the next session uses it.`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function formatModelChangeExitMessage(modelId: string): string {
|
|
29
|
+
return `Model changed to ${getModelName(modelId)}. Exiting so the next session uses it.`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function applyConfirmedModelChange(deps: IApplyConfirmedModelChangeDeps): void {
|
|
33
|
+
const applyModelChange = deps.applyModelChange;
|
|
34
|
+
if (!applyModelChange) {
|
|
35
|
+
deps.addEntry(
|
|
36
|
+
messageToHistoryEntry(createSystemMessage('Model change unavailable: no adapter provided.')),
|
|
37
|
+
);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const options =
|
|
42
|
+
deps.providerOverride !== undefined ? { providerOverride: deps.providerOverride } : undefined;
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
// allow-fallback: user-facing error display for model change failure
|
|
46
|
+
applyModelChange(deps.cwd, deps.modelId, options);
|
|
47
|
+
deps.addEntry(
|
|
48
|
+
messageToHistoryEntry(createSystemMessage(formatModelChangeExitMessage(deps.modelId))),
|
|
49
|
+
);
|
|
50
|
+
deps.requestShutdown('other', 'Model change applied');
|
|
51
|
+
} catch (error) {
|
|
52
|
+
// allow-fallback: user-facing error display for model change failure
|
|
53
|
+
deps.addEntry(
|
|
54
|
+
messageToHistoryEntry(
|
|
55
|
+
createSystemMessage(`Failed: ${error instanceof Error ? error.message : String(error)}`),
|
|
56
|
+
),
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function addModelChangeCancelledMessage(addEntry: (entry: IHistoryEntry) => void): void {
|
|
62
|
+
addEntry(messageToHistoryEntry(createSystemMessage('Model change cancelled.')));
|
|
63
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { IHistoryEntry } from '@robota-sdk/agent-core';
|
|
2
|
+
import type { InteractiveSession } from '@robota-sdk/agent-framework';
|
|
3
|
+
import type {
|
|
4
|
+
TCommandInteractionPrompt as TInteractivePrompt,
|
|
5
|
+
IStatusLineCommandSettings as TStatusLineSettings,
|
|
6
|
+
} from '@robota-sdk/agent-framework';
|
|
7
|
+
import type { ICommandEffectQueue } from './command-effect-queue.js';
|
|
8
|
+
|
|
9
|
+
export type { TInteractivePrompt, TStatusLineSettings };
|
|
10
|
+
|
|
11
|
+
export interface IUseSideEffectsOptions {
|
|
12
|
+
cwd: string;
|
|
13
|
+
providerOverride?: string | undefined;
|
|
14
|
+
interactiveSession: InteractiveSession;
|
|
15
|
+
commandEffectQueue: ICommandEffectQueue;
|
|
16
|
+
addEntry: (entry: IHistoryEntry) => void;
|
|
17
|
+
baseHandleSubmit: (input: string) => Promise<void>;
|
|
18
|
+
setSessionName: (name: string) => void;
|
|
19
|
+
setStatusLineSettings: (settings: TStatusLineSettings) => void;
|
|
20
|
+
showSessionPickerOnStart?: boolean;
|
|
21
|
+
openAgentSwitcher?: () => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface IUseSideEffectsResult {
|
|
25
|
+
handleSubmit: (input: string) => Promise<void>;
|
|
26
|
+
pendingModelId: string | null;
|
|
27
|
+
pendingInteractionPrompt: TInteractivePrompt | null;
|
|
28
|
+
showPluginTUI: boolean;
|
|
29
|
+
showSessionPicker: boolean;
|
|
30
|
+
showTransportTUI: boolean;
|
|
31
|
+
setPendingModelId: (id: string | null) => void;
|
|
32
|
+
setShowPluginTUI: (show: boolean) => void;
|
|
33
|
+
setShowSessionPicker: (show: boolean) => void;
|
|
34
|
+
setShowTransportTUI: (show: boolean) => void;
|
|
35
|
+
handleModelConfirm: (index: number) => void;
|
|
36
|
+
handleInteractionSubmit: (value: string) => Promise<void>;
|
|
37
|
+
handleInteractionCancel: () => void;
|
|
38
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { InteractiveSession, CommandRegistry } from '@robota-sdk/agent-framework';
|
|
2
|
+
import type { TToolArgs } from '@robota-sdk/agent-core';
|
|
3
|
+
import type { TPermissionResultValue } from '@robota-sdk/agent-framework';
|
|
4
|
+
import { TuiStateManager } from '../tui-state-manager.js';
|
|
5
|
+
import { CommandEffectQueue, type ICommandEffectQueue } from './command-effect-queue.js';
|
|
6
|
+
import type { IInteractiveSessionProps } from './useInteractiveSession.js';
|
|
7
|
+
|
|
8
|
+
export interface IInitState {
|
|
9
|
+
interactiveSession: InteractiveSession;
|
|
10
|
+
registry: CommandRegistry;
|
|
11
|
+
commandEffectQueue: ICommandEffectQueue;
|
|
12
|
+
manager: TuiStateManager;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function initializeSession(
|
|
16
|
+
props: IInteractiveSessionProps,
|
|
17
|
+
permissionHandler: (toolName: string, toolArgs: TToolArgs) => Promise<TPermissionResultValue>,
|
|
18
|
+
): IInitState {
|
|
19
|
+
const interactiveSession = new InteractiveSession({
|
|
20
|
+
cwd: props.cwd,
|
|
21
|
+
provider: props.provider,
|
|
22
|
+
permissionMode: props.permissionMode,
|
|
23
|
+
maxTurns: props.maxTurns,
|
|
24
|
+
permissionHandler,
|
|
25
|
+
sessionStore: props.sessionStore,
|
|
26
|
+
resumeSessionId: props.resumeSessionId,
|
|
27
|
+
forkSession: props.forkSession,
|
|
28
|
+
sessionName: props.sessionName,
|
|
29
|
+
backgroundTaskRunners: props.backgroundTaskRunners,
|
|
30
|
+
subagentRunnerFactory: props.subagentRunnerFactory,
|
|
31
|
+
commandModules: props.commandModules,
|
|
32
|
+
commandHostAdapters: props.commandHostAdapters,
|
|
33
|
+
shellExec: props.shellExec,
|
|
34
|
+
language: props.language,
|
|
35
|
+
agentName: props.agentName,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const registry = new CommandRegistry();
|
|
39
|
+
for (const module of props.commandModules ?? []) {
|
|
40
|
+
registry.addModule(module);
|
|
41
|
+
}
|
|
42
|
+
props.reloadPluginCommandSource?.(registry);
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
interactiveSession,
|
|
46
|
+
registry,
|
|
47
|
+
manager: new TuiStateManager(),
|
|
48
|
+
commandEffectQueue: new CommandEffectQueue(),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slash command autocomplete hook.
|
|
3
|
+
* Extracted from InputArea.tsx for single-responsibility.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React, { useState, useMemo } from 'react';
|
|
7
|
+
import type { CommandRegistry, ICommand } from '@robota-sdk/agent-framework';
|
|
8
|
+
|
|
9
|
+
/** Parse input to determine autocomplete state */
|
|
10
|
+
export function parseSlashInput(value: string): {
|
|
11
|
+
isSlash: boolean;
|
|
12
|
+
parentCommand: string;
|
|
13
|
+
filter: string;
|
|
14
|
+
} {
|
|
15
|
+
if (!value.startsWith('/')) return { isSlash: false, parentCommand: '', filter: '' };
|
|
16
|
+
const afterSlash = value.slice(1);
|
|
17
|
+
const spaceIndex = afterSlash.indexOf(' ');
|
|
18
|
+
if (spaceIndex === -1) return { isSlash: true, parentCommand: '', filter: afterSlash };
|
|
19
|
+
const parent = afterSlash.slice(0, spaceIndex);
|
|
20
|
+
const rest = afterSlash.slice(spaceIndex + 1);
|
|
21
|
+
return { isSlash: true, parentCommand: parent, filter: rest };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Hook: manage autocomplete state */
|
|
25
|
+
export function useAutocomplete(
|
|
26
|
+
value: string,
|
|
27
|
+
registry: CommandRegistry | undefined,
|
|
28
|
+
): {
|
|
29
|
+
showPopup: boolean;
|
|
30
|
+
filteredCommands: ICommand[];
|
|
31
|
+
selectedIndex: number;
|
|
32
|
+
setSelectedIndex: React.Dispatch<React.SetStateAction<number>>;
|
|
33
|
+
isSubcommandMode: boolean;
|
|
34
|
+
setShowPopup: React.Dispatch<React.SetStateAction<boolean>>;
|
|
35
|
+
} {
|
|
36
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
37
|
+
const [dismissed, setDismissed] = useState(false);
|
|
38
|
+
|
|
39
|
+
// Reset dismissed when input changes
|
|
40
|
+
const prevValueRef = React.useRef(value);
|
|
41
|
+
if (prevValueRef.current !== value) {
|
|
42
|
+
prevValueRef.current = value;
|
|
43
|
+
if (dismissed) setDismissed(false);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const parsed = parseSlashInput(value);
|
|
47
|
+
const isSubcommandMode = parsed.isSlash && parsed.parentCommand.length > 0;
|
|
48
|
+
|
|
49
|
+
const filteredCommands = useMemo(() => {
|
|
50
|
+
if (!registry || !parsed.isSlash || dismissed) return [];
|
|
51
|
+
if (isSubcommandMode) {
|
|
52
|
+
const subs = registry.getSubcommands(parsed.parentCommand);
|
|
53
|
+
if (subs.length === 0) return [];
|
|
54
|
+
if (!parsed.filter) return subs;
|
|
55
|
+
const lower = parsed.filter.toLowerCase();
|
|
56
|
+
return subs.filter((c) => c.name.toLowerCase().startsWith(lower));
|
|
57
|
+
}
|
|
58
|
+
return registry.getCommands(parsed.filter);
|
|
59
|
+
}, [registry, parsed.isSlash, parsed.parentCommand, parsed.filter, dismissed, isSubcommandMode]);
|
|
60
|
+
|
|
61
|
+
const showPopup = parsed.isSlash && filteredCommands.length > 0 && !dismissed;
|
|
62
|
+
|
|
63
|
+
// Clamp selectedIndex
|
|
64
|
+
if (selectedIndex >= filteredCommands.length && filteredCommands.length > 0) {
|
|
65
|
+
setSelectedIndex(filteredCommands.length - 1);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
showPopup,
|
|
70
|
+
filteredCommands,
|
|
71
|
+
selectedIndex,
|
|
72
|
+
setSelectedIndex,
|
|
73
|
+
isSubcommandMode,
|
|
74
|
+
setShowPopup: (val) => {
|
|
75
|
+
if (typeof val === 'function') {
|
|
76
|
+
setDismissed((prev) => {
|
|
77
|
+
const nextVal = (val as (prev: boolean) => boolean)(!prev);
|
|
78
|
+
return !nextVal;
|
|
79
|
+
});
|
|
80
|
+
} else {
|
|
81
|
+
setDismissed(!val);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|