wave-code 0.8.1 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ChatInterface.js +1 -1
- package/dist/components/MessageList.d.ts +2 -2
- package/dist/components/MessageList.d.ts.map +1 -1
- package/dist/components/MessageList.js +5 -6
- package/dist/contexts/useChat.d.ts.map +1 -1
- package/dist/contexts/useChat.js +2 -17
- package/dist/hooks/useInputManager.d.ts +7 -8
- package/dist/hooks/useInputManager.d.ts.map +1 -1
- package/dist/hooks/useInputManager.js +224 -232
- package/dist/managers/inputHandlers.d.ts +28 -0
- package/dist/managers/inputHandlers.d.ts.map +1 -0
- package/dist/managers/inputHandlers.js +378 -0
- package/dist/managers/inputReducer.d.ts +157 -0
- package/dist/managers/inputReducer.d.ts.map +1 -0
- package/dist/managers/inputReducer.js +242 -0
- package/package.json +2 -2
- package/src/components/ChatInterface.tsx +1 -1
- package/src/components/MessageList.tsx +5 -6
- package/src/contexts/useChat.tsx +2 -17
- package/src/hooks/useInputManager.ts +352 -299
- package/src/managers/inputHandlers.ts +560 -0
- package/src/managers/inputReducer.ts +367 -0
- package/dist/managers/InputManager.d.ts +0 -156
- package/dist/managers/InputManager.d.ts.map +0 -1
- package/dist/managers/InputManager.js +0 -749
- package/src/managers/InputManager.ts +0 -1024
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
import { PromptHistoryManager } from "wave-agent-sdk";
|
|
2
|
+
import { readClipboardImage } from "../utils/clipboard.js";
|
|
3
|
+
export const expandLongTextPlaceholders = (text, longTextMap) => {
|
|
4
|
+
let expandedText = text;
|
|
5
|
+
const longTextRegex = /\[LongText#(\d+)\]/g;
|
|
6
|
+
const matches = [...text.matchAll(longTextRegex)];
|
|
7
|
+
for (const match of matches) {
|
|
8
|
+
const placeholder = match[0];
|
|
9
|
+
const originalText = longTextMap[placeholder];
|
|
10
|
+
if (originalText) {
|
|
11
|
+
expandedText = expandedText.replace(placeholder, originalText);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return expandedText;
|
|
15
|
+
};
|
|
16
|
+
export const handleSubmit = async (state, dispatch, callbacks, isLoading = false, isCommandRunning = false, attachedImagesOverride) => {
|
|
17
|
+
if (isLoading || isCommandRunning) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (state.inputText.trim()) {
|
|
21
|
+
const imageRegex = /\[Image #(\d+)\]/g;
|
|
22
|
+
const matches = [...state.inputText.matchAll(imageRegex)];
|
|
23
|
+
const attachedImages = attachedImagesOverride || state.attachedImages;
|
|
24
|
+
const referencedImages = matches
|
|
25
|
+
.map((match) => {
|
|
26
|
+
const imageId = parseInt(match[1], 10);
|
|
27
|
+
return attachedImages.find((img) => img.id === imageId);
|
|
28
|
+
})
|
|
29
|
+
.filter((img) => img !== undefined)
|
|
30
|
+
.map((img) => ({ path: img.path, mimeType: img.mimeType }));
|
|
31
|
+
let cleanContent = state.inputText.replace(imageRegex, "").trim();
|
|
32
|
+
cleanContent = expandLongTextPlaceholders(cleanContent, state.longTextMap);
|
|
33
|
+
PromptHistoryManager.addEntry(cleanContent).catch((err) => {
|
|
34
|
+
callbacks.logger?.error("Failed to save prompt history", err);
|
|
35
|
+
});
|
|
36
|
+
callbacks.onSendMessage?.(cleanContent, referencedImages.length > 0 ? referencedImages : undefined);
|
|
37
|
+
dispatch({ type: "CLEAR_INPUT" });
|
|
38
|
+
callbacks.onResetHistoryNavigation?.();
|
|
39
|
+
dispatch({ type: "CLEAR_LONG_TEXT_MAP" });
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
export const handlePasteImage = async (dispatch) => {
|
|
43
|
+
try {
|
|
44
|
+
const result = await readClipboardImage();
|
|
45
|
+
if (result.success && result.imagePath && result.mimeType) {
|
|
46
|
+
dispatch({
|
|
47
|
+
type: "ADD_IMAGE_AND_INSERT_PLACEHOLDER",
|
|
48
|
+
payload: { path: result.imagePath, mimeType: result.mimeType },
|
|
49
|
+
});
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
console.warn("Failed to paste image from clipboard:", error);
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
export const cyclePermissionMode = (currentMode, dispatch, callbacks) => {
|
|
60
|
+
const modes = ["default", "acceptEdits", "plan"];
|
|
61
|
+
const currentIndex = modes.indexOf(currentMode);
|
|
62
|
+
const nextIndex = currentIndex === -1 ? 0 : (currentIndex + 1) % modes.length;
|
|
63
|
+
const nextMode = modes[nextIndex];
|
|
64
|
+
callbacks.logger?.debug("Cycling permission mode", {
|
|
65
|
+
from: currentMode,
|
|
66
|
+
to: nextMode,
|
|
67
|
+
});
|
|
68
|
+
dispatch({ type: "SET_PERMISSION_MODE", payload: nextMode });
|
|
69
|
+
callbacks.onPermissionModeChange?.(nextMode);
|
|
70
|
+
};
|
|
71
|
+
export const updateSearchQueriesForActiveSelectors = (state, dispatch, inputText, cursorPosition) => {
|
|
72
|
+
if (state.showFileSelector && state.atPosition >= 0) {
|
|
73
|
+
const queryStart = state.atPosition + 1;
|
|
74
|
+
const queryEnd = cursorPosition;
|
|
75
|
+
const newQuery = inputText.substring(queryStart, queryEnd);
|
|
76
|
+
dispatch({ type: "SET_FILE_SEARCH_QUERY", payload: newQuery });
|
|
77
|
+
}
|
|
78
|
+
else if (state.showCommandSelector && state.slashPosition >= 0) {
|
|
79
|
+
const queryStart = state.slashPosition + 1;
|
|
80
|
+
const queryEnd = cursorPosition;
|
|
81
|
+
const newQuery = inputText.substring(queryStart, queryEnd);
|
|
82
|
+
dispatch({ type: "SET_COMMAND_SEARCH_QUERY", payload: newQuery });
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
export const handleSpecialCharInput = (state, dispatch, char, cursorPosition, inputText) => {
|
|
86
|
+
if (char === "@") {
|
|
87
|
+
dispatch({ type: "ACTIVATE_FILE_SELECTOR", payload: cursorPosition - 1 });
|
|
88
|
+
}
|
|
89
|
+
else if (char === "/" && !state.showFileSelector && cursorPosition === 1) {
|
|
90
|
+
dispatch({
|
|
91
|
+
type: "ACTIVATE_COMMAND_SELECTOR",
|
|
92
|
+
payload: cursorPosition - 1,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
updateSearchQueriesForActiveSelectors(state, dispatch, inputText, cursorPosition);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
export const handlePasteInput = (state, dispatch, callbacks, input) => {
|
|
100
|
+
const inputString = input;
|
|
101
|
+
const isPasteOperation = inputString.length > 1 ||
|
|
102
|
+
inputString.includes("\n") ||
|
|
103
|
+
inputString.includes("\r");
|
|
104
|
+
if (isPasteOperation) {
|
|
105
|
+
if (!state.isPasting) {
|
|
106
|
+
dispatch({
|
|
107
|
+
type: "START_PASTE",
|
|
108
|
+
payload: { buffer: inputString, cursorPosition: state.cursorPosition },
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
dispatch({ type: "APPEND_PASTE_BUFFER", payload: inputString });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
let char = inputString;
|
|
117
|
+
if (char === "!" && state.cursorPosition === 0) {
|
|
118
|
+
char = "!";
|
|
119
|
+
}
|
|
120
|
+
callbacks.onResetHistoryNavigation?.();
|
|
121
|
+
dispatch({ type: "INSERT_TEXT", payload: char });
|
|
122
|
+
// Calculate new state for special char handling
|
|
123
|
+
const newCursorPosition = state.cursorPosition + char.length;
|
|
124
|
+
const beforeCursor = state.inputText.substring(0, state.cursorPosition);
|
|
125
|
+
const afterCursor = state.inputText.substring(state.cursorPosition);
|
|
126
|
+
const newInputText = beforeCursor + char + afterCursor;
|
|
127
|
+
handleSpecialCharInput(state, dispatch, char, newCursorPosition, newInputText);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
export const handleCommandSelect = (state, dispatch, callbacks, command) => {
|
|
131
|
+
if (state.slashPosition >= 0) {
|
|
132
|
+
const beforeSlash = state.inputText.substring(0, state.slashPosition);
|
|
133
|
+
const afterQuery = state.inputText.substring(state.cursorPosition);
|
|
134
|
+
const newInput = beforeSlash + afterQuery;
|
|
135
|
+
const newCursorPosition = beforeSlash.length;
|
|
136
|
+
dispatch({ type: "SET_INPUT_TEXT", payload: newInput });
|
|
137
|
+
dispatch({ type: "SET_CURSOR_POSITION", payload: newCursorPosition });
|
|
138
|
+
// Execute command asynchronously
|
|
139
|
+
(async () => {
|
|
140
|
+
let commandExecuted = false;
|
|
141
|
+
if (callbacks.onSendMessage && callbacks.onHasSlashCommand?.(command)) {
|
|
142
|
+
const fullCommand = `/${command}`;
|
|
143
|
+
try {
|
|
144
|
+
await callbacks.onSendMessage(fullCommand);
|
|
145
|
+
commandExecuted = true;
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
console.error("Failed to execute slash command:", error);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (!commandExecuted) {
|
|
152
|
+
if (command === "clear") {
|
|
153
|
+
callbacks.onClearMessages?.();
|
|
154
|
+
}
|
|
155
|
+
else if (command === "tasks") {
|
|
156
|
+
dispatch({ type: "SET_SHOW_BACKGROUND_TASK_MANAGER", payload: true });
|
|
157
|
+
}
|
|
158
|
+
else if (command === "mcp") {
|
|
159
|
+
dispatch({ type: "SET_SHOW_MCP_MANAGER", payload: true });
|
|
160
|
+
}
|
|
161
|
+
else if (command === "rewind") {
|
|
162
|
+
dispatch({ type: "SET_SHOW_REWIND_MANAGER", payload: true });
|
|
163
|
+
}
|
|
164
|
+
else if (command === "help") {
|
|
165
|
+
dispatch({ type: "SET_SHOW_HELP", payload: true });
|
|
166
|
+
}
|
|
167
|
+
else if (command === "status") {
|
|
168
|
+
dispatch({ type: "SET_SHOW_STATUS_COMMAND", payload: true });
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
})();
|
|
172
|
+
dispatch({ type: "CANCEL_COMMAND_SELECTOR" });
|
|
173
|
+
callbacks.onInputTextChange?.(newInput);
|
|
174
|
+
callbacks.onCursorPositionChange?.(newCursorPosition);
|
|
175
|
+
return { newInput, newCursorPosition };
|
|
176
|
+
}
|
|
177
|
+
return { newInput: state.inputText, newCursorPosition: state.cursorPosition };
|
|
178
|
+
};
|
|
179
|
+
export const handleFileSelect = (state, dispatch, callbacks, filePath) => {
|
|
180
|
+
if (state.atPosition >= 0) {
|
|
181
|
+
const beforeAt = state.inputText.substring(0, state.atPosition);
|
|
182
|
+
const afterQuery = state.inputText.substring(state.cursorPosition);
|
|
183
|
+
const newInput = beforeAt + `${filePath} ` + afterQuery;
|
|
184
|
+
const newCursorPosition = beforeAt.length + filePath.length + 1;
|
|
185
|
+
dispatch({ type: "SET_INPUT_TEXT", payload: newInput });
|
|
186
|
+
dispatch({ type: "SET_CURSOR_POSITION", payload: newCursorPosition });
|
|
187
|
+
dispatch({ type: "CANCEL_FILE_SELECTOR" });
|
|
188
|
+
callbacks.onInputTextChange?.(newInput);
|
|
189
|
+
callbacks.onCursorPositionChange?.(newCursorPosition);
|
|
190
|
+
return { newInput, newCursorPosition };
|
|
191
|
+
}
|
|
192
|
+
return { newInput: state.inputText, newCursorPosition: state.cursorPosition };
|
|
193
|
+
};
|
|
194
|
+
export const checkForAtDeletion = (state, dispatch, cursorPosition) => {
|
|
195
|
+
if (state.showFileSelector && cursorPosition <= state.atPosition) {
|
|
196
|
+
dispatch({ type: "CANCEL_FILE_SELECTOR" });
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
return false;
|
|
200
|
+
};
|
|
201
|
+
export const checkForSlashDeletion = (state, dispatch, cursorPosition) => {
|
|
202
|
+
if (state.showCommandSelector && cursorPosition <= state.slashPosition) {
|
|
203
|
+
dispatch({ type: "CANCEL_COMMAND_SELECTOR" });
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
return false;
|
|
207
|
+
};
|
|
208
|
+
export const handleSelectorInput = (state, dispatch, callbacks, input, key) => {
|
|
209
|
+
if (key.backspace || key.delete) {
|
|
210
|
+
if (state.cursorPosition > 0) {
|
|
211
|
+
const newCursorPosition = state.cursorPosition - 1;
|
|
212
|
+
const beforeCursor = state.inputText.substring(0, state.cursorPosition - 1);
|
|
213
|
+
const afterCursor = state.inputText.substring(state.cursorPosition);
|
|
214
|
+
const newInputText = beforeCursor + afterCursor;
|
|
215
|
+
dispatch({ type: "DELETE_CHAR" });
|
|
216
|
+
// Check for special character deletion
|
|
217
|
+
checkForAtDeletion(state, dispatch, newCursorPosition);
|
|
218
|
+
checkForSlashDeletion(state, dispatch, newCursorPosition);
|
|
219
|
+
// Update search queries
|
|
220
|
+
updateSearchQueriesForActiveSelectors(state, dispatch, newInputText, newCursorPosition);
|
|
221
|
+
}
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
if (key.upArrow || key.downArrow || key.return || key.tab) {
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
if (input &&
|
|
228
|
+
!key.ctrl &&
|
|
229
|
+
!("alt" in key && key.alt) &&
|
|
230
|
+
!key.meta &&
|
|
231
|
+
!key.return &&
|
|
232
|
+
!key.tab &&
|
|
233
|
+
!key.escape &&
|
|
234
|
+
!key.leftArrow &&
|
|
235
|
+
!key.rightArrow &&
|
|
236
|
+
!("home" in key && key.home) &&
|
|
237
|
+
!("end" in key && key.end)) {
|
|
238
|
+
dispatch({ type: "INSERT_TEXT", payload: input });
|
|
239
|
+
// Calculate new state for special char handling
|
|
240
|
+
const newCursorPosition = state.cursorPosition + input.length;
|
|
241
|
+
const beforeCursor = state.inputText.substring(0, state.cursorPosition);
|
|
242
|
+
const afterCursor = state.inputText.substring(state.cursorPosition);
|
|
243
|
+
const newInputText = beforeCursor + input + afterCursor;
|
|
244
|
+
handleSpecialCharInput(state, dispatch, input, newCursorPosition, newInputText);
|
|
245
|
+
return true;
|
|
246
|
+
}
|
|
247
|
+
return false;
|
|
248
|
+
};
|
|
249
|
+
export const handleNormalInput = async (state, dispatch, callbacks, input, key, isLoading = false, isCommandRunning = false, clearImages) => {
|
|
250
|
+
if (key.return) {
|
|
251
|
+
await handleSubmit(state, dispatch, callbacks, isLoading, isCommandRunning);
|
|
252
|
+
clearImages?.();
|
|
253
|
+
return true;
|
|
254
|
+
}
|
|
255
|
+
if (key.escape) {
|
|
256
|
+
if (state.showFileSelector) {
|
|
257
|
+
dispatch({ type: "CANCEL_FILE_SELECTOR" });
|
|
258
|
+
}
|
|
259
|
+
else if (state.showCommandSelector) {
|
|
260
|
+
dispatch({ type: "CANCEL_COMMAND_SELECTOR" });
|
|
261
|
+
}
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
if (key.backspace || key.delete) {
|
|
265
|
+
if (state.cursorPosition > 0) {
|
|
266
|
+
const newCursorPosition = state.cursorPosition - 1;
|
|
267
|
+
dispatch({ type: "DELETE_CHAR" });
|
|
268
|
+
callbacks.onResetHistoryNavigation?.();
|
|
269
|
+
checkForAtDeletion(state, dispatch, newCursorPosition);
|
|
270
|
+
checkForSlashDeletion(state, dispatch, newCursorPosition);
|
|
271
|
+
}
|
|
272
|
+
return true;
|
|
273
|
+
}
|
|
274
|
+
if (key.leftArrow) {
|
|
275
|
+
dispatch({ type: "MOVE_CURSOR", payload: -1 });
|
|
276
|
+
return true;
|
|
277
|
+
}
|
|
278
|
+
if (key.rightArrow) {
|
|
279
|
+
dispatch({ type: "MOVE_CURSOR", payload: 1 });
|
|
280
|
+
return true;
|
|
281
|
+
}
|
|
282
|
+
if (key.ctrl && input === "v") {
|
|
283
|
+
handlePasteImage(dispatch).catch((error) => {
|
|
284
|
+
console.warn("Failed to handle paste image:", error);
|
|
285
|
+
});
|
|
286
|
+
return true;
|
|
287
|
+
}
|
|
288
|
+
if (key.ctrl && input === "r") {
|
|
289
|
+
dispatch({ type: "ACTIVATE_HISTORY_SEARCH" });
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
292
|
+
if (key.ctrl && input === "b") {
|
|
293
|
+
callbacks.onBackgroundCurrentTask?.();
|
|
294
|
+
return true;
|
|
295
|
+
}
|
|
296
|
+
if (input &&
|
|
297
|
+
!key.ctrl &&
|
|
298
|
+
!("alt" in key && key.alt) &&
|
|
299
|
+
!key.meta &&
|
|
300
|
+
!key.return &&
|
|
301
|
+
!key.escape &&
|
|
302
|
+
!key.backspace &&
|
|
303
|
+
!key.delete &&
|
|
304
|
+
!key.leftArrow &&
|
|
305
|
+
!key.rightArrow &&
|
|
306
|
+
!("home" in key && key.home) &&
|
|
307
|
+
!("end" in key && key.end)) {
|
|
308
|
+
handlePasteInput(state, dispatch, callbacks, input);
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
return false;
|
|
312
|
+
};
|
|
313
|
+
export const handleInput = async (state, dispatch, callbacks, input, key, isLoading = false, isCommandRunning = false, clearImages) => {
|
|
314
|
+
if (state.selectorJustUsed) {
|
|
315
|
+
return true;
|
|
316
|
+
}
|
|
317
|
+
if (key.escape) {
|
|
318
|
+
if ((isLoading || isCommandRunning) &&
|
|
319
|
+
!(state.showFileSelector ||
|
|
320
|
+
state.showCommandSelector ||
|
|
321
|
+
state.showHistorySearch ||
|
|
322
|
+
state.showBackgroundTaskManager ||
|
|
323
|
+
state.showMcpManager ||
|
|
324
|
+
state.showRewindManager ||
|
|
325
|
+
state.showHelp ||
|
|
326
|
+
state.showStatusCommand)) {
|
|
327
|
+
callbacks.onAbortMessage?.();
|
|
328
|
+
return true;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
if (key.tab && key.shift) {
|
|
332
|
+
cyclePermissionMode(state.permissionMode, dispatch, callbacks);
|
|
333
|
+
return true;
|
|
334
|
+
}
|
|
335
|
+
if (state.showFileSelector ||
|
|
336
|
+
state.showCommandSelector ||
|
|
337
|
+
state.showHistorySearch ||
|
|
338
|
+
state.showBackgroundTaskManager ||
|
|
339
|
+
state.showMcpManager ||
|
|
340
|
+
state.showRewindManager ||
|
|
341
|
+
state.showHelp ||
|
|
342
|
+
state.showStatusCommand) {
|
|
343
|
+
if (state.showBackgroundTaskManager ||
|
|
344
|
+
state.showMcpManager ||
|
|
345
|
+
state.showRewindManager ||
|
|
346
|
+
state.showHelp ||
|
|
347
|
+
state.showStatusCommand) {
|
|
348
|
+
return true;
|
|
349
|
+
}
|
|
350
|
+
if (state.showHistorySearch) {
|
|
351
|
+
if (key.escape) {
|
|
352
|
+
dispatch({ type: "CANCEL_HISTORY_SEARCH" });
|
|
353
|
+
return true;
|
|
354
|
+
}
|
|
355
|
+
if (key.backspace || key.delete) {
|
|
356
|
+
if (state.historySearchQuery.length > 0) {
|
|
357
|
+
dispatch({
|
|
358
|
+
type: "SET_HISTORY_SEARCH_QUERY",
|
|
359
|
+
payload: state.historySearchQuery.slice(0, -1),
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
return true;
|
|
363
|
+
}
|
|
364
|
+
if (input && !key.ctrl && !key.meta && !key.return && !key.tab) {
|
|
365
|
+
dispatch({
|
|
366
|
+
type: "SET_HISTORY_SEARCH_QUERY",
|
|
367
|
+
payload: state.historySearchQuery + input,
|
|
368
|
+
});
|
|
369
|
+
return true;
|
|
370
|
+
}
|
|
371
|
+
return true;
|
|
372
|
+
}
|
|
373
|
+
return handleSelectorInput(state, dispatch, callbacks, input, key);
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
return await handleNormalInput(state, dispatch, callbacks, input, key, isLoading, isCommandRunning, clearImages);
|
|
377
|
+
}
|
|
378
|
+
};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { FileItem, PermissionMode, Logger } from "wave-agent-sdk";
|
|
2
|
+
export interface AttachedImage {
|
|
3
|
+
id: number;
|
|
4
|
+
path: string;
|
|
5
|
+
mimeType: string;
|
|
6
|
+
}
|
|
7
|
+
export interface InputManagerCallbacks {
|
|
8
|
+
onInputTextChange?: (text: string) => void;
|
|
9
|
+
onCursorPositionChange?: (position: number) => void;
|
|
10
|
+
onFileSelectorStateChange?: (show: boolean, files: FileItem[], query: string, position: number) => void;
|
|
11
|
+
onCommandSelectorStateChange?: (show: boolean, query: string, position: number) => void;
|
|
12
|
+
onHistorySearchStateChange?: (show: boolean, query: string) => void;
|
|
13
|
+
onBackgroundTaskManagerStateChange?: (show: boolean) => void;
|
|
14
|
+
onMcpManagerStateChange?: (show: boolean) => void;
|
|
15
|
+
onRewindManagerStateChange?: (show: boolean) => void;
|
|
16
|
+
onHelpStateChange?: (show: boolean) => void;
|
|
17
|
+
onStatusCommandStateChange?: (show: boolean) => void;
|
|
18
|
+
onImagesStateChange?: (images: AttachedImage[]) => void;
|
|
19
|
+
onSendMessage?: (content: string, images?: Array<{
|
|
20
|
+
path: string;
|
|
21
|
+
mimeType: string;
|
|
22
|
+
}>) => void | Promise<void>;
|
|
23
|
+
onHasSlashCommand?: (commandId: string) => boolean;
|
|
24
|
+
onAbortMessage?: () => void;
|
|
25
|
+
onClearMessages?: () => void;
|
|
26
|
+
onBackgroundCurrentTask?: () => void;
|
|
27
|
+
onResetHistoryNavigation?: () => void;
|
|
28
|
+
onPermissionModeChange?: (mode: PermissionMode) => void;
|
|
29
|
+
logger?: Logger;
|
|
30
|
+
}
|
|
31
|
+
export interface InputState {
|
|
32
|
+
inputText: string;
|
|
33
|
+
cursorPosition: number;
|
|
34
|
+
showFileSelector: boolean;
|
|
35
|
+
atPosition: number;
|
|
36
|
+
fileSearchQuery: string;
|
|
37
|
+
filteredFiles: FileItem[];
|
|
38
|
+
showCommandSelector: boolean;
|
|
39
|
+
slashPosition: number;
|
|
40
|
+
commandSearchQuery: string;
|
|
41
|
+
showHistorySearch: boolean;
|
|
42
|
+
historySearchQuery: string;
|
|
43
|
+
longTextCounter: number;
|
|
44
|
+
longTextMap: Record<string, string>;
|
|
45
|
+
attachedImages: AttachedImage[];
|
|
46
|
+
imageIdCounter: number;
|
|
47
|
+
showBackgroundTaskManager: boolean;
|
|
48
|
+
showMcpManager: boolean;
|
|
49
|
+
showRewindManager: boolean;
|
|
50
|
+
showHelp: boolean;
|
|
51
|
+
showStatusCommand: boolean;
|
|
52
|
+
permissionMode: PermissionMode;
|
|
53
|
+
selectorJustUsed: boolean;
|
|
54
|
+
isPasting: boolean;
|
|
55
|
+
pasteBuffer: string;
|
|
56
|
+
initialPasteCursorPosition: number;
|
|
57
|
+
}
|
|
58
|
+
export declare const initialState: InputState;
|
|
59
|
+
export type InputAction = {
|
|
60
|
+
type: "SET_INPUT_TEXT";
|
|
61
|
+
payload: string;
|
|
62
|
+
} | {
|
|
63
|
+
type: "SET_CURSOR_POSITION";
|
|
64
|
+
payload: number;
|
|
65
|
+
} | {
|
|
66
|
+
type: "INSERT_TEXT";
|
|
67
|
+
payload: string;
|
|
68
|
+
} | {
|
|
69
|
+
type: "DELETE_CHAR";
|
|
70
|
+
} | {
|
|
71
|
+
type: "MOVE_CURSOR";
|
|
72
|
+
payload: number;
|
|
73
|
+
} | {
|
|
74
|
+
type: "ACTIVATE_FILE_SELECTOR";
|
|
75
|
+
payload: number;
|
|
76
|
+
} | {
|
|
77
|
+
type: "SET_FILE_SEARCH_QUERY";
|
|
78
|
+
payload: string;
|
|
79
|
+
} | {
|
|
80
|
+
type: "SET_FILTERED_FILES";
|
|
81
|
+
payload: FileItem[];
|
|
82
|
+
} | {
|
|
83
|
+
type: "CANCEL_FILE_SELECTOR";
|
|
84
|
+
} | {
|
|
85
|
+
type: "ACTIVATE_COMMAND_SELECTOR";
|
|
86
|
+
payload: number;
|
|
87
|
+
} | {
|
|
88
|
+
type: "SET_COMMAND_SEARCH_QUERY";
|
|
89
|
+
payload: string;
|
|
90
|
+
} | {
|
|
91
|
+
type: "CANCEL_COMMAND_SELECTOR";
|
|
92
|
+
} | {
|
|
93
|
+
type: "ACTIVATE_HISTORY_SEARCH";
|
|
94
|
+
} | {
|
|
95
|
+
type: "SET_HISTORY_SEARCH_QUERY";
|
|
96
|
+
payload: string;
|
|
97
|
+
} | {
|
|
98
|
+
type: "CANCEL_HISTORY_SEARCH";
|
|
99
|
+
} | {
|
|
100
|
+
type: "ADD_IMAGE";
|
|
101
|
+
payload: {
|
|
102
|
+
path: string;
|
|
103
|
+
mimeType: string;
|
|
104
|
+
};
|
|
105
|
+
} | {
|
|
106
|
+
type: "REMOVE_IMAGE";
|
|
107
|
+
payload: number;
|
|
108
|
+
} | {
|
|
109
|
+
type: "CLEAR_IMAGES";
|
|
110
|
+
} | {
|
|
111
|
+
type: "SET_SHOW_BACKGROUND_TASK_MANAGER";
|
|
112
|
+
payload: boolean;
|
|
113
|
+
} | {
|
|
114
|
+
type: "SET_SHOW_MCP_MANAGER";
|
|
115
|
+
payload: boolean;
|
|
116
|
+
} | {
|
|
117
|
+
type: "SET_SHOW_REWIND_MANAGER";
|
|
118
|
+
payload: boolean;
|
|
119
|
+
} | {
|
|
120
|
+
type: "SET_SHOW_HELP";
|
|
121
|
+
payload: boolean;
|
|
122
|
+
} | {
|
|
123
|
+
type: "SET_SHOW_STATUS_COMMAND";
|
|
124
|
+
payload: boolean;
|
|
125
|
+
} | {
|
|
126
|
+
type: "SET_PERMISSION_MODE";
|
|
127
|
+
payload: PermissionMode;
|
|
128
|
+
} | {
|
|
129
|
+
type: "SET_SELECTOR_JUST_USED";
|
|
130
|
+
payload: boolean;
|
|
131
|
+
} | {
|
|
132
|
+
type: "COMPRESS_AND_INSERT_TEXT";
|
|
133
|
+
payload: string;
|
|
134
|
+
} | {
|
|
135
|
+
type: "CLEAR_LONG_TEXT_MAP";
|
|
136
|
+
} | {
|
|
137
|
+
type: "CLEAR_INPUT";
|
|
138
|
+
} | {
|
|
139
|
+
type: "START_PASTE";
|
|
140
|
+
payload: {
|
|
141
|
+
buffer: string;
|
|
142
|
+
cursorPosition: number;
|
|
143
|
+
};
|
|
144
|
+
} | {
|
|
145
|
+
type: "APPEND_PASTE_BUFFER";
|
|
146
|
+
payload: string;
|
|
147
|
+
} | {
|
|
148
|
+
type: "END_PASTE";
|
|
149
|
+
} | {
|
|
150
|
+
type: "ADD_IMAGE_AND_INSERT_PLACEHOLDER";
|
|
151
|
+
payload: {
|
|
152
|
+
path: string;
|
|
153
|
+
mimeType: string;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
export declare function inputReducer(state: InputState, action: InputAction): InputState;
|
|
157
|
+
//# sourceMappingURL=inputReducer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputReducer.d.ts","sourceRoot":"","sources":["../../src/managers/inputReducer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAElE,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,qBAAqB;IACpC,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,sBAAsB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACpD,yBAAyB,CAAC,EAAE,CAC1B,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,QAAQ,EAAE,EACjB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,KACb,IAAI,CAAC;IACV,4BAA4B,CAAC,EAAE,CAC7B,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,KACb,IAAI,CAAC;IACV,0BAA0B,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACpE,kCAAkC,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7D,uBAAuB,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAClD,0BAA0B,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,C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