snow-ai 0.4.16 → 0.4.17
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/bundle/cli.mjs +477445 -0
- package/bundle/sql-wasm.wasm +0 -0
- package/package.json +31 -26
- package/dist/agents/codebaseIndexAgent.d.ts +0 -102
- package/dist/agents/codebaseIndexAgent.js +0 -641
- package/dist/agents/codebaseReviewAgent.d.ts +0 -61
- package/dist/agents/codebaseReviewAgent.js +0 -301
- package/dist/agents/compactAgent.d.ts +0 -55
- package/dist/agents/compactAgent.js +0 -306
- package/dist/agents/promptOptimizeAgent.d.ts +0 -54
- package/dist/agents/promptOptimizeAgent.js +0 -268
- package/dist/agents/reviewAgent.d.ts +0 -50
- package/dist/agents/reviewAgent.js +0 -265
- package/dist/agents/summaryAgent.d.ts +0 -57
- package/dist/agents/summaryAgent.js +0 -260
- package/dist/api/anthropic.d.ts +0 -44
- package/dist/api/anthropic.js +0 -598
- package/dist/api/chat.d.ts +0 -73
- package/dist/api/chat.js +0 -386
- package/dist/api/embedding.d.ts +0 -34
- package/dist/api/embedding.js +0 -80
- package/dist/api/gemini.d.ts +0 -31
- package/dist/api/gemini.js +0 -445
- package/dist/api/models.d.ts +0 -15
- package/dist/api/models.js +0 -139
- package/dist/api/responses.d.ts +0 -38
- package/dist/api/responses.js +0 -515
- package/dist/api/systemPrompt.d.ts +0 -4
- package/dist/api/systemPrompt.js +0 -408
- package/dist/api/types.d.ts +0 -53
- package/dist/api/types.js +0 -4
- package/dist/app.d.ts +0 -8
- package/dist/app.js +0 -112
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -199
- package/dist/hooks/useAgentPicker.d.ts +0 -14
- package/dist/hooks/useAgentPicker.js +0 -119
- package/dist/hooks/useClipboard.d.ts +0 -4
- package/dist/hooks/useClipboard.js +0 -175
- package/dist/hooks/useCommandHandler.d.ts +0 -35
- package/dist/hooks/useCommandHandler.js +0 -346
- package/dist/hooks/useCommandPanel.d.ts +0 -17
- package/dist/hooks/useCommandPanel.js +0 -114
- package/dist/hooks/useConversation.d.ts +0 -49
- package/dist/hooks/useConversation.js +0 -1052
- package/dist/hooks/useFilePicker.d.ts +0 -18
- package/dist/hooks/useFilePicker.js +0 -224
- package/dist/hooks/useGlobalExit.d.ts +0 -5
- package/dist/hooks/useGlobalExit.js +0 -34
- package/dist/hooks/useGlobalNavigation.d.ts +0 -6
- package/dist/hooks/useGlobalNavigation.js +0 -17
- package/dist/hooks/useHistoryNavigation.d.ts +0 -35
- package/dist/hooks/useHistoryNavigation.js +0 -133
- package/dist/hooks/useInputBuffer.d.ts +0 -6
- package/dist/hooks/useInputBuffer.js +0 -45
- package/dist/hooks/useKeyboardInput.d.ts +0 -80
- package/dist/hooks/useKeyboardInput.js +0 -608
- package/dist/hooks/useSessionManagement.d.ts +0 -10
- package/dist/hooks/useSessionManagement.js +0 -43
- package/dist/hooks/useSessionSave.d.ts +0 -8
- package/dist/hooks/useSessionSave.js +0 -63
- package/dist/hooks/useSnapshotState.d.ts +0 -26
- package/dist/hooks/useSnapshotState.js +0 -28
- package/dist/hooks/useStreamingState.d.ts +0 -33
- package/dist/hooks/useStreamingState.js +0 -105
- package/dist/hooks/useTerminalFocus.d.ts +0 -28
- package/dist/hooks/useTerminalFocus.js +0 -87
- package/dist/hooks/useTerminalSize.d.ts +0 -4
- package/dist/hooks/useTerminalSize.js +0 -20
- package/dist/hooks/useTodoPicker.d.ts +0 -16
- package/dist/hooks/useTodoPicker.js +0 -94
- package/dist/hooks/useToolConfirmation.d.ts +0 -19
- package/dist/hooks/useToolConfirmation.js +0 -61
- package/dist/hooks/useVSCodeState.d.ts +0 -8
- package/dist/hooks/useVSCodeState.js +0 -81
- package/dist/i18n/I18nContext.d.ts +0 -14
- package/dist/i18n/I18nContext.js +0 -24
- package/dist/i18n/index.d.ts +0 -3
- package/dist/i18n/index.js +0 -2
- package/dist/i18n/lang/en.d.ts +0 -2
- package/dist/i18n/lang/en.js +0 -502
- package/dist/i18n/lang/es.d.ts +0 -2
- package/dist/i18n/lang/es.js +0 -502
- package/dist/i18n/lang/ja.d.ts +0 -2
- package/dist/i18n/lang/ja.js +0 -502
- package/dist/i18n/lang/ko.d.ts +0 -2
- package/dist/i18n/lang/ko.js +0 -502
- package/dist/i18n/lang/zh-TW.d.ts +0 -2
- package/dist/i18n/lang/zh-TW.js +0 -502
- package/dist/i18n/lang/zh.d.ts +0 -2
- package/dist/i18n/lang/zh.js +0 -502
- package/dist/i18n/translations.d.ts +0 -2
- package/dist/i18n/translations.js +0 -14
- package/dist/i18n/types.d.ts +0 -478
- package/dist/i18n/types.js +0 -1
- package/dist/mcp/aceCodeSearch.d.ts +0 -247
- package/dist/mcp/aceCodeSearch.js +0 -1058
- package/dist/mcp/bash.d.ts +0 -50
- package/dist/mcp/bash.js +0 -153
- package/dist/mcp/codebaseSearch.d.ts +0 -44
- package/dist/mcp/codebaseSearch.js +0 -275
- package/dist/mcp/filesystem.d.ts +0 -392
- package/dist/mcp/filesystem.js +0 -1445
- package/dist/mcp/ideDiagnostics.d.ts +0 -36
- package/dist/mcp/ideDiagnostics.js +0 -90
- package/dist/mcp/notebook.d.ts +0 -10
- package/dist/mcp/notebook.js +0 -367
- package/dist/mcp/subagent.d.ts +0 -37
- package/dist/mcp/subagent.js +0 -113
- package/dist/mcp/todo.d.ts +0 -46
- package/dist/mcp/todo.js +0 -511
- package/dist/mcp/types/aceCodeSearch.types.d.ts +0 -92
- package/dist/mcp/types/aceCodeSearch.types.js +0 -4
- package/dist/mcp/types/bash.types.d.ts +0 -13
- package/dist/mcp/types/bash.types.js +0 -4
- package/dist/mcp/types/filesystem.types.d.ts +0 -210
- package/dist/mcp/types/filesystem.types.js +0 -27
- package/dist/mcp/types/todo.types.d.ts +0 -27
- package/dist/mcp/types/todo.types.js +0 -4
- package/dist/mcp/types/websearch.types.d.ts +0 -30
- package/dist/mcp/types/websearch.types.js +0 -4
- package/dist/mcp/utils/aceCodeSearch/filesystem.utils.d.ts +0 -34
- package/dist/mcp/utils/aceCodeSearch/filesystem.utils.js +0 -146
- package/dist/mcp/utils/aceCodeSearch/language.utils.d.ts +0 -14
- package/dist/mcp/utils/aceCodeSearch/language.utils.js +0 -418
- package/dist/mcp/utils/aceCodeSearch/search.utils.d.ts +0 -31
- package/dist/mcp/utils/aceCodeSearch/search.utils.js +0 -136
- package/dist/mcp/utils/aceCodeSearch/symbol.utils.d.ts +0 -20
- package/dist/mcp/utils/aceCodeSearch/symbol.utils.js +0 -141
- package/dist/mcp/utils/bash/security.utils.d.ts +0 -20
- package/dist/mcp/utils/bash/security.utils.js +0 -34
- package/dist/mcp/utils/filesystem/batch-operations.utils.d.ts +0 -39
- package/dist/mcp/utils/filesystem/batch-operations.utils.js +0 -182
- package/dist/mcp/utils/filesystem/code-analysis.utils.d.ts +0 -18
- package/dist/mcp/utils/filesystem/code-analysis.utils.js +0 -165
- package/dist/mcp/utils/filesystem/match-finder.utils.d.ts +0 -16
- package/dist/mcp/utils/filesystem/match-finder.utils.js +0 -85
- package/dist/mcp/utils/filesystem/office-parser.utils.d.ts +0 -43
- package/dist/mcp/utils/filesystem/office-parser.utils.js +0 -163
- package/dist/mcp/utils/filesystem/path-fixer.utils.d.ts +0 -7
- package/dist/mcp/utils/filesystem/path-fixer.utils.js +0 -60
- package/dist/mcp/utils/filesystem/similarity.utils.d.ts +0 -22
- package/dist/mcp/utils/filesystem/similarity.utils.js +0 -75
- package/dist/mcp/utils/todo/date.utils.d.ts +0 -9
- package/dist/mcp/utils/todo/date.utils.js +0 -14
- package/dist/mcp/utils/websearch/browser.utils.d.ts +0 -8
- package/dist/mcp/utils/websearch/browser.utils.js +0 -58
- package/dist/mcp/utils/websearch/text.utils.d.ts +0 -16
- package/dist/mcp/utils/websearch/text.utils.js +0 -39
- package/dist/mcp/websearch.d.ts +0 -88
- package/dist/mcp/websearch.js +0 -375
- package/dist/test/logger-test.d.ts +0 -1
- package/dist/test/logger-test.js +0 -7
- package/dist/types/index.d.ts +0 -15
- package/dist/types/index.js +0 -1
- package/dist/ui/components/AgentPickerPanel.d.ts +0 -10
- package/dist/ui/components/AgentPickerPanel.js +0 -74
- package/dist/ui/components/ChatInput.d.ts +0 -46
- package/dist/ui/components/ChatInput.js +0 -384
- package/dist/ui/components/CommandPanel.d.ts +0 -15
- package/dist/ui/components/CommandPanel.js +0 -80
- package/dist/ui/components/DiffViewer.d.ts +0 -11
- package/dist/ui/components/DiffViewer.js +0 -178
- package/dist/ui/components/FileList.d.ts +0 -15
- package/dist/ui/components/FileList.js +0 -360
- package/dist/ui/components/FileRollbackConfirmation.d.ts +0 -8
- package/dist/ui/components/FileRollbackConfirmation.js +0 -108
- package/dist/ui/components/HelpPanel.d.ts +0 -2
- package/dist/ui/components/HelpPanel.js +0 -67
- package/dist/ui/components/MCPInfoPanel.d.ts +0 -2
- package/dist/ui/components/MCPInfoPanel.js +0 -108
- package/dist/ui/components/MCPInfoScreen.d.ts +0 -7
- package/dist/ui/components/MCPInfoScreen.js +0 -115
- package/dist/ui/components/MarkdownRenderer.d.ts +0 -6
- package/dist/ui/components/MarkdownRenderer.js +0 -70
- package/dist/ui/components/Menu.d.ts +0 -17
- package/dist/ui/components/Menu.js +0 -88
- package/dist/ui/components/MessageList.d.ts +0 -56
- package/dist/ui/components/MessageList.js +0 -97
- package/dist/ui/components/PendingMessages.d.ts +0 -13
- package/dist/ui/components/PendingMessages.js +0 -29
- package/dist/ui/components/PendingToolCalls.d.ts +0 -11
- package/dist/ui/components/PendingToolCalls.js +0 -35
- package/dist/ui/components/ScrollableSelectInput.d.ts +0 -29
- package/dist/ui/components/ScrollableSelectInput.js +0 -157
- package/dist/ui/components/SessionListPanel.d.ts +0 -7
- package/dist/ui/components/SessionListPanel.js +0 -175
- package/dist/ui/components/SessionListScreen.d.ts +0 -7
- package/dist/ui/components/SessionListScreen.js +0 -217
- package/dist/ui/components/SessionListScreenWrapper.d.ts +0 -7
- package/dist/ui/components/SessionListScreenWrapper.js +0 -14
- package/dist/ui/components/ShimmerText.d.ts +0 -9
- package/dist/ui/components/ShimmerText.js +0 -30
- package/dist/ui/components/TodoPickerPanel.d.ts +0 -14
- package/dist/ui/components/TodoPickerPanel.js +0 -119
- package/dist/ui/components/TodoTree.d.ts +0 -15
- package/dist/ui/components/TodoTree.js +0 -60
- package/dist/ui/components/ToolConfirmation.d.ts +0 -21
- package/dist/ui/components/ToolConfirmation.js +0 -204
- package/dist/ui/components/ToolResultPreview.d.ts +0 -13
- package/dist/ui/components/ToolResultPreview.js +0 -337
- package/dist/ui/components/UsagePanel.d.ts +0 -2
- package/dist/ui/components/UsagePanel.js +0 -394
- package/dist/ui/contexts/ThemeContext.d.ts +0 -13
- package/dist/ui/contexts/ThemeContext.js +0 -28
- package/dist/ui/pages/ChatScreen.d.ts +0 -6
- package/dist/ui/pages/ChatScreen.js +0 -1519
- package/dist/ui/pages/CodeBaseConfigScreen.d.ts +0 -8
- package/dist/ui/pages/CodeBaseConfigScreen.js +0 -350
- package/dist/ui/pages/ConfigScreen.d.ts +0 -8
- package/dist/ui/pages/ConfigScreen.js +0 -1101
- package/dist/ui/pages/CustomHeadersScreen.d.ts +0 -6
- package/dist/ui/pages/CustomHeadersScreen.js +0 -502
- package/dist/ui/pages/HeadlessModeScreen.d.ts +0 -7
- package/dist/ui/pages/HeadlessModeScreen.js +0 -381
- package/dist/ui/pages/LanguageSettingsScreen.d.ts +0 -7
- package/dist/ui/pages/LanguageSettingsScreen.js +0 -91
- package/dist/ui/pages/MCPConfigScreen.d.ts +0 -6
- package/dist/ui/pages/MCPConfigScreen.js +0 -55
- package/dist/ui/pages/ProxyConfigScreen.d.ts +0 -8
- package/dist/ui/pages/ProxyConfigScreen.js +0 -149
- package/dist/ui/pages/SensitiveCommandConfigScreen.d.ts +0 -7
- package/dist/ui/pages/SensitiveCommandConfigScreen.js +0 -271
- package/dist/ui/pages/SubAgentConfigScreen.d.ts +0 -9
- package/dist/ui/pages/SubAgentConfigScreen.js +0 -435
- package/dist/ui/pages/SubAgentListScreen.d.ts +0 -9
- package/dist/ui/pages/SubAgentListScreen.js +0 -131
- package/dist/ui/pages/SystemPromptConfigScreen.d.ts +0 -6
- package/dist/ui/pages/SystemPromptConfigScreen.js +0 -326
- package/dist/ui/pages/ThemeSettingsScreen.d.ts +0 -7
- package/dist/ui/pages/ThemeSettingsScreen.js +0 -106
- package/dist/ui/pages/WelcomeScreen.d.ts +0 -7
- package/dist/ui/pages/WelcomeScreen.js +0 -217
- package/dist/ui/themes/index.d.ts +0 -23
- package/dist/ui/themes/index.js +0 -140
- package/dist/utils/apiConfig.d.ts +0 -126
- package/dist/utils/apiConfig.js +0 -423
- package/dist/utils/autoCompress.d.ts +0 -15
- package/dist/utils/autoCompress.js +0 -24
- package/dist/utils/chatExporter.d.ts +0 -9
- package/dist/utils/chatExporter.js +0 -118
- package/dist/utils/checkpointManager.d.ts +0 -74
- package/dist/utils/checkpointManager.js +0 -181
- package/dist/utils/codebaseConfig.d.ts +0 -16
- package/dist/utils/codebaseConfig.js +0 -67
- package/dist/utils/codebaseDatabase.d.ts +0 -102
- package/dist/utils/codebaseDatabase.js +0 -333
- package/dist/utils/codebaseSearchEvents.d.ts +0 -16
- package/dist/utils/codebaseSearchEvents.js +0 -13
- package/dist/utils/commandExecutor.d.ts +0 -13
- package/dist/utils/commandExecutor.js +0 -26
- package/dist/utils/commands/agent.d.ts +0 -2
- package/dist/utils/commands/agent.js +0 -12
- package/dist/utils/commands/clear.d.ts +0 -2
- package/dist/utils/commands/clear.js +0 -12
- package/dist/utils/commands/compact.d.ts +0 -2
- package/dist/utils/commands/compact.js +0 -12
- package/dist/utils/commands/export.d.ts +0 -2
- package/dist/utils/commands/export.js +0 -12
- package/dist/utils/commands/help.d.ts +0 -2
- package/dist/utils/commands/help.js +0 -11
- package/dist/utils/commands/home.d.ts +0 -2
- package/dist/utils/commands/home.js +0 -34
- package/dist/utils/commands/ide.d.ts +0 -2
- package/dist/utils/commands/ide.js +0 -32
- package/dist/utils/commands/init.d.ts +0 -2
- package/dist/utils/commands/init.js +0 -93
- package/dist/utils/commands/mcp.d.ts +0 -2
- package/dist/utils/commands/mcp.js +0 -12
- package/dist/utils/commands/resume.d.ts +0 -2
- package/dist/utils/commands/resume.js +0 -12
- package/dist/utils/commands/review.d.ts +0 -2
- package/dist/utils/commands/review.js +0 -81
- package/dist/utils/commands/role.d.ts +0 -2
- package/dist/utils/commands/role.js +0 -37
- package/dist/utils/commands/todoPicker.d.ts +0 -2
- package/dist/utils/commands/todoPicker.js +0 -12
- package/dist/utils/commands/usage.d.ts +0 -2
- package/dist/utils/commands/usage.js +0 -12
- package/dist/utils/commands/yolo.d.ts +0 -2
- package/dist/utils/commands/yolo.js +0 -12
- package/dist/utils/configManager.d.ts +0 -45
- package/dist/utils/configManager.js +0 -303
- package/dist/utils/contextCompressor.d.ts +0 -16
- package/dist/utils/contextCompressor.js +0 -334
- package/dist/utils/devMode.d.ts +0 -13
- package/dist/utils/devMode.js +0 -54
- package/dist/utils/escapeHandler.d.ts +0 -79
- package/dist/utils/escapeHandler.js +0 -153
- package/dist/utils/fileDialog.d.ts +0 -9
- package/dist/utils/fileDialog.js +0 -74
- package/dist/utils/fileUtils.d.ts +0 -40
- package/dist/utils/fileUtils.js +0 -185
- package/dist/utils/historyManager.d.ts +0 -45
- package/dist/utils/historyManager.js +0 -159
- package/dist/utils/incrementalSnapshot.d.ts +0 -109
- package/dist/utils/incrementalSnapshot.js +0 -383
- package/dist/utils/index.d.ts +0 -11
- package/dist/utils/index.js +0 -18
- package/dist/utils/languageConfig.d.ts +0 -21
- package/dist/utils/languageConfig.js +0 -61
- package/dist/utils/logger.d.ts +0 -37
- package/dist/utils/logger.js +0 -122
- package/dist/utils/mcpToolsManager.d.ts +0 -52
- package/dist/utils/mcpToolsManager.js +0 -878
- package/dist/utils/messageFormatter.d.ts +0 -12
- package/dist/utils/messageFormatter.js +0 -115
- package/dist/utils/notebookManager.d.ts +0 -59
- package/dist/utils/notebookManager.js +0 -213
- package/dist/utils/patch-highlight.d.ts +0 -5
- package/dist/utils/patch-highlight.js +0 -23
- package/dist/utils/processManager.d.ts +0 -27
- package/dist/utils/processManager.js +0 -75
- package/dist/utils/proxyUtils.d.ts +0 -15
- package/dist/utils/proxyUtils.js +0 -50
- package/dist/utils/resourceMonitor.d.ts +0 -65
- package/dist/utils/resourceMonitor.js +0 -175
- package/dist/utils/retryUtils.d.ts +0 -49
- package/dist/utils/retryUtils.js +0 -303
- package/dist/utils/sensitiveCommandManager.d.ts +0 -53
- package/dist/utils/sensitiveCommandManager.js +0 -308
- package/dist/utils/sessionConverter.d.ts +0 -7
- package/dist/utils/sessionConverter.js +0 -306
- package/dist/utils/sessionManager.d.ts +0 -53
- package/dist/utils/sessionManager.js +0 -371
- package/dist/utils/subAgentConfig.d.ts +0 -50
- package/dist/utils/subAgentConfig.js +0 -221
- package/dist/utils/subAgentExecutor.d.ts +0 -40
- package/dist/utils/subAgentExecutor.js +0 -434
- package/dist/utils/terminal.d.ts +0 -5
- package/dist/utils/terminal.js +0 -13
- package/dist/utils/textBuffer.d.ts +0 -99
- package/dist/utils/textBuffer.js +0 -547
- package/dist/utils/textUtils.d.ts +0 -37
- package/dist/utils/textUtils.js +0 -102
- package/dist/utils/themeConfig.d.ts +0 -21
- package/dist/utils/themeConfig.js +0 -61
- package/dist/utils/todoPreprocessor.d.ts +0 -5
- package/dist/utils/todoPreprocessor.js +0 -18
- package/dist/utils/todoScanner.d.ts +0 -8
- package/dist/utils/todoScanner.js +0 -148
- package/dist/utils/toolDisplayConfig.d.ts +0 -16
- package/dist/utils/toolDisplayConfig.js +0 -47
- package/dist/utils/toolExecutor.d.ts +0 -37
- package/dist/utils/toolExecutor.js +0 -224
- package/dist/utils/usageLogger.d.ts +0 -11
- package/dist/utils/usageLogger.js +0 -114
- package/dist/utils/vscodeConnection.d.ts +0 -76
- package/dist/utils/vscodeConnection.js +0 -430
- package/dist/utils/workspaceSnapshot.d.ts +0 -63
- package/dist/utils/workspaceSnapshot.js +0 -300
|
@@ -1,384 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useRef, useMemo, lazy, Suspense } from 'react';
|
|
2
|
-
import { Box, Text } from 'ink';
|
|
3
|
-
import { cpSlice } from '../../utils/textUtils.js';
|
|
4
|
-
// Lazy load panel components to reduce initial bundle size
|
|
5
|
-
const CommandPanel = lazy(() => import('./CommandPanel.js'));
|
|
6
|
-
const FileList = lazy(() => import('./FileList.js'));
|
|
7
|
-
const AgentPickerPanel = lazy(() => import('./AgentPickerPanel.js'));
|
|
8
|
-
const TodoPickerPanel = lazy(() => import('./TodoPickerPanel.js'));
|
|
9
|
-
import { useInputBuffer } from '../../hooks/useInputBuffer.js';
|
|
10
|
-
import { useCommandPanel } from '../../hooks/useCommandPanel.js';
|
|
11
|
-
import { useFilePicker } from '../../hooks/useFilePicker.js';
|
|
12
|
-
import { useHistoryNavigation } from '../../hooks/useHistoryNavigation.js';
|
|
13
|
-
import { useClipboard } from '../../hooks/useClipboard.js';
|
|
14
|
-
import { useKeyboardInput } from '../../hooks/useKeyboardInput.js';
|
|
15
|
-
import { useTerminalSize } from '../../hooks/useTerminalSize.js';
|
|
16
|
-
import { useTerminalFocus } from '../../hooks/useTerminalFocus.js';
|
|
17
|
-
import { useAgentPicker } from '../../hooks/useAgentPicker.js';
|
|
18
|
-
import { useTodoPicker } from '../../hooks/useTodoPicker.js';
|
|
19
|
-
import { useI18n } from '../../i18n/index.js';
|
|
20
|
-
import { useTheme } from '../contexts/ThemeContext.js';
|
|
21
|
-
/**
|
|
22
|
-
* Calculate context usage percentage
|
|
23
|
-
* This is the same logic used in ChatInput to display usage
|
|
24
|
-
*/
|
|
25
|
-
export function calculateContextPercentage(contextUsage) {
|
|
26
|
-
// Determine which caching system is being used
|
|
27
|
-
const isAnthropic = (contextUsage.cacheCreationTokens || 0) > 0 ||
|
|
28
|
-
(contextUsage.cacheReadTokens || 0) > 0;
|
|
29
|
-
// For Anthropic: Total = inputTokens + cacheCreationTokens + cacheReadTokens
|
|
30
|
-
// For OpenAI: Total = inputTokens (cachedTokens are already included in inputTokens)
|
|
31
|
-
const totalInputTokens = isAnthropic
|
|
32
|
-
? contextUsage.inputTokens +
|
|
33
|
-
(contextUsage.cacheCreationTokens || 0) +
|
|
34
|
-
(contextUsage.cacheReadTokens || 0)
|
|
35
|
-
: contextUsage.inputTokens;
|
|
36
|
-
return Math.min(100, (totalInputTokens / contextUsage.maxContextTokens) * 100);
|
|
37
|
-
}
|
|
38
|
-
export default function ChatInput({ onSubmit, onCommand, placeholder = 'Type your message...', disabled = false, isProcessing = false, chatHistory = [], onHistorySelect, yoloMode = false, contextUsage, initialContent = null, onContextPercentageChange, }) {
|
|
39
|
-
// Use i18n hook for translations
|
|
40
|
-
const { t } = useI18n();
|
|
41
|
-
const { theme } = useTheme();
|
|
42
|
-
// Use terminal size hook to listen for resize events
|
|
43
|
-
const { columns: terminalWidth } = useTerminalSize();
|
|
44
|
-
const prevTerminalWidthRef = useRef(terminalWidth);
|
|
45
|
-
// Use terminal focus hook to detect focus state
|
|
46
|
-
const { hasFocus, ensureFocus } = useTerminalFocus();
|
|
47
|
-
// Recalculate viewport dimensions to ensure proper resizing
|
|
48
|
-
const uiOverhead = 8;
|
|
49
|
-
const viewportWidth = Math.max(40, terminalWidth - uiOverhead);
|
|
50
|
-
const viewport = useMemo(() => ({
|
|
51
|
-
width: viewportWidth,
|
|
52
|
-
height: 1,
|
|
53
|
-
}), [viewportWidth]); // Memoize viewport to prevent unnecessary re-renders
|
|
54
|
-
// Use input buffer hook
|
|
55
|
-
const { buffer, triggerUpdate, forceUpdate } = useInputBuffer(viewport);
|
|
56
|
-
// Use command panel hook
|
|
57
|
-
const { showCommands, setShowCommands, commandSelectedIndex, setCommandSelectedIndex, getFilteredCommands, updateCommandPanelState, isProcessing: commandPanelIsProcessing, } = useCommandPanel(buffer, isProcessing);
|
|
58
|
-
// Use file picker hook
|
|
59
|
-
const { showFilePicker, setShowFilePicker, fileSelectedIndex, setFileSelectedIndex, fileQuery, setFileQuery, atSymbolPosition, setAtSymbolPosition, filteredFileCount, searchMode, updateFilePickerState, handleFileSelect, handleFilteredCountChange, fileListRef, } = useFilePicker(buffer, triggerUpdate);
|
|
60
|
-
// Use history navigation hook
|
|
61
|
-
const { showHistoryMenu, setShowHistoryMenu, historySelectedIndex, setHistorySelectedIndex, escapeKeyCount, setEscapeKeyCount, escapeKeyTimer, getUserMessages, handleHistorySelect, currentHistoryIndex, navigateHistoryUp, navigateHistoryDown, resetHistoryNavigation, saveToHistory, } = useHistoryNavigation(buffer, triggerUpdate, chatHistory, onHistorySelect);
|
|
62
|
-
// Use agent picker hook
|
|
63
|
-
const { showAgentPicker, setShowAgentPicker, agentSelectedIndex, setAgentSelectedIndex, updateAgentPickerState, getFilteredAgents, handleAgentSelect, } = useAgentPicker(buffer, triggerUpdate);
|
|
64
|
-
// Use todo picker hook
|
|
65
|
-
const { showTodoPicker, setShowTodoPicker, todoSelectedIndex, setTodoSelectedIndex, todos, selectedTodos, toggleTodoSelection, confirmTodoSelection, isLoading: todoIsLoading, searchQuery: todoSearchQuery, setSearchQuery: setTodoSearchQuery, totalTodoCount, } = useTodoPicker(buffer, triggerUpdate, process.cwd());
|
|
66
|
-
// Use clipboard hook
|
|
67
|
-
const { pasteFromClipboard } = useClipboard(buffer, updateCommandPanelState, updateFilePickerState, triggerUpdate);
|
|
68
|
-
// Use keyboard input hook
|
|
69
|
-
useKeyboardInput({
|
|
70
|
-
buffer,
|
|
71
|
-
disabled,
|
|
72
|
-
triggerUpdate,
|
|
73
|
-
forceUpdate,
|
|
74
|
-
showCommands,
|
|
75
|
-
setShowCommands,
|
|
76
|
-
commandSelectedIndex,
|
|
77
|
-
setCommandSelectedIndex,
|
|
78
|
-
getFilteredCommands,
|
|
79
|
-
updateCommandPanelState,
|
|
80
|
-
onCommand,
|
|
81
|
-
showFilePicker,
|
|
82
|
-
setShowFilePicker,
|
|
83
|
-
fileSelectedIndex,
|
|
84
|
-
setFileSelectedIndex,
|
|
85
|
-
fileQuery,
|
|
86
|
-
setFileQuery,
|
|
87
|
-
atSymbolPosition,
|
|
88
|
-
setAtSymbolPosition,
|
|
89
|
-
filteredFileCount,
|
|
90
|
-
updateFilePickerState,
|
|
91
|
-
handleFileSelect,
|
|
92
|
-
fileListRef,
|
|
93
|
-
showHistoryMenu,
|
|
94
|
-
setShowHistoryMenu,
|
|
95
|
-
historySelectedIndex,
|
|
96
|
-
setHistorySelectedIndex,
|
|
97
|
-
escapeKeyCount,
|
|
98
|
-
setEscapeKeyCount,
|
|
99
|
-
escapeKeyTimer,
|
|
100
|
-
getUserMessages,
|
|
101
|
-
handleHistorySelect,
|
|
102
|
-
currentHistoryIndex,
|
|
103
|
-
navigateHistoryUp,
|
|
104
|
-
navigateHistoryDown,
|
|
105
|
-
resetHistoryNavigation,
|
|
106
|
-
saveToHistory,
|
|
107
|
-
pasteFromClipboard,
|
|
108
|
-
onSubmit,
|
|
109
|
-
ensureFocus,
|
|
110
|
-
showAgentPicker,
|
|
111
|
-
setShowAgentPicker,
|
|
112
|
-
agentSelectedIndex,
|
|
113
|
-
setAgentSelectedIndex,
|
|
114
|
-
updateAgentPickerState,
|
|
115
|
-
getFilteredAgents,
|
|
116
|
-
handleAgentSelect,
|
|
117
|
-
showTodoPicker,
|
|
118
|
-
setShowTodoPicker,
|
|
119
|
-
todoSelectedIndex,
|
|
120
|
-
setTodoSelectedIndex,
|
|
121
|
-
todos,
|
|
122
|
-
selectedTodos,
|
|
123
|
-
toggleTodoSelection,
|
|
124
|
-
confirmTodoSelection,
|
|
125
|
-
todoSearchQuery,
|
|
126
|
-
setTodoSearchQuery,
|
|
127
|
-
});
|
|
128
|
-
// Set initial content when provided (e.g., when rolling back to first message)
|
|
129
|
-
useEffect(() => {
|
|
130
|
-
if (initialContent) {
|
|
131
|
-
// Always do full restore to avoid duplicate placeholders
|
|
132
|
-
buffer.setText('');
|
|
133
|
-
const text = initialContent.text;
|
|
134
|
-
const images = initialContent.images || [];
|
|
135
|
-
if (images.length === 0) {
|
|
136
|
-
// No images, just set the text
|
|
137
|
-
if (text) {
|
|
138
|
-
buffer.insert(text);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
// Split text by image placeholders and reconstruct with actual images
|
|
143
|
-
// Placeholder format: [image #N]
|
|
144
|
-
const imagePlaceholderPattern = /\[image #\d+\]/g;
|
|
145
|
-
const parts = text.split(imagePlaceholderPattern);
|
|
146
|
-
// Interleave text parts with images
|
|
147
|
-
for (let i = 0; i < parts.length; i++) {
|
|
148
|
-
// Insert text part
|
|
149
|
-
const part = parts[i];
|
|
150
|
-
if (part) {
|
|
151
|
-
buffer.insert(part);
|
|
152
|
-
}
|
|
153
|
-
// Insert image after this text part (if exists)
|
|
154
|
-
if (i < images.length) {
|
|
155
|
-
const img = images[i];
|
|
156
|
-
if (img) {
|
|
157
|
-
// Extract base64 data from data URL if present
|
|
158
|
-
let base64Data = img.data;
|
|
159
|
-
if (base64Data.startsWith('data:')) {
|
|
160
|
-
const base64Index = base64Data.indexOf('base64,');
|
|
161
|
-
if (base64Index !== -1) {
|
|
162
|
-
base64Data = base64Data.substring(base64Index + 7);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
buffer.insertImage(base64Data, img.mimeType);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
triggerUpdate();
|
|
171
|
-
}
|
|
172
|
-
// Only run when initialContent changes
|
|
173
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
174
|
-
}, [initialContent]);
|
|
175
|
-
// Force full re-render when file picker visibility changes to prevent artifacts
|
|
176
|
-
useEffect(() => {
|
|
177
|
-
// Use a small delay to ensure the component tree has updated
|
|
178
|
-
const timer = setTimeout(() => {
|
|
179
|
-
forceUpdate();
|
|
180
|
-
}, 10);
|
|
181
|
-
return () => clearTimeout(timer);
|
|
182
|
-
}, [showFilePicker, forceUpdate]);
|
|
183
|
-
// Handle terminal width changes with debounce (like gemini-cli)
|
|
184
|
-
useEffect(() => {
|
|
185
|
-
// Skip on initial mount
|
|
186
|
-
if (prevTerminalWidthRef.current === terminalWidth) {
|
|
187
|
-
prevTerminalWidthRef.current = terminalWidth;
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
prevTerminalWidthRef.current = terminalWidth;
|
|
191
|
-
// Debounce the re-render to avoid flickering during resize
|
|
192
|
-
const timer = setTimeout(() => {
|
|
193
|
-
forceUpdate();
|
|
194
|
-
}, 100);
|
|
195
|
-
return () => clearTimeout(timer);
|
|
196
|
-
}, [terminalWidth, forceUpdate]);
|
|
197
|
-
// Notify parent of context percentage changes
|
|
198
|
-
const lastPercentageRef = useRef(0);
|
|
199
|
-
useEffect(() => {
|
|
200
|
-
if (contextUsage && onContextPercentageChange) {
|
|
201
|
-
const percentage = calculateContextPercentage(contextUsage);
|
|
202
|
-
// Only call callback if percentage has actually changed
|
|
203
|
-
if (percentage !== lastPercentageRef.current) {
|
|
204
|
-
lastPercentageRef.current = percentage;
|
|
205
|
-
onContextPercentageChange(percentage);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}, [contextUsage, onContextPercentageChange]);
|
|
209
|
-
// Render cursor based on focus state
|
|
210
|
-
const renderCursor = useCallback((char) => {
|
|
211
|
-
if (hasFocus) {
|
|
212
|
-
// Focused: solid block cursor (use inverted colors)
|
|
213
|
-
return (React.createElement(Text, { backgroundColor: theme.colors.menuNormal, color: theme.colors.background }, char));
|
|
214
|
-
}
|
|
215
|
-
else {
|
|
216
|
-
// Unfocused: no cursor, just render the character normally
|
|
217
|
-
return React.createElement(Text, null, char);
|
|
218
|
-
}
|
|
219
|
-
}, [hasFocus, theme]);
|
|
220
|
-
// Render content with cursor (treat all text including placeholders as plain text)
|
|
221
|
-
const renderContent = () => {
|
|
222
|
-
if (buffer.text.length > 0) {
|
|
223
|
-
// Use visual lines for proper wrapping and multi-line support
|
|
224
|
-
const visualLines = buffer.viewportVisualLines;
|
|
225
|
-
const [cursorRow, cursorCol] = buffer.visualCursor;
|
|
226
|
-
const renderedLines = [];
|
|
227
|
-
for (let i = 0; i < visualLines.length; i++) {
|
|
228
|
-
const line = visualLines[i] || '';
|
|
229
|
-
if (i === cursorRow) {
|
|
230
|
-
// This line contains the cursor
|
|
231
|
-
const beforeCursor = cpSlice(line, 0, cursorCol);
|
|
232
|
-
const atCursor = cpSlice(line, cursorCol, cursorCol + 1) || ' ';
|
|
233
|
-
const afterCursor = cpSlice(line, cursorCol + 1);
|
|
234
|
-
renderedLines.push(React.createElement(Box, { key: i, flexDirection: "row" },
|
|
235
|
-
React.createElement(Text, null, beforeCursor),
|
|
236
|
-
renderCursor(atCursor),
|
|
237
|
-
React.createElement(Text, null, afterCursor)));
|
|
238
|
-
}
|
|
239
|
-
else {
|
|
240
|
-
// No cursor in this line
|
|
241
|
-
renderedLines.push(React.createElement(Text, { key: i }, line || ' '));
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
return React.createElement(Box, { flexDirection: "column" }, renderedLines);
|
|
245
|
-
}
|
|
246
|
-
else {
|
|
247
|
-
return (React.createElement(React.Fragment, null,
|
|
248
|
-
renderCursor(' '),
|
|
249
|
-
React.createElement(Text, { color: theme.colors.menuSecondary, dimColor: true }, disabled ? t.chatScreen.waitingForResponse : placeholder)));
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
return (React.createElement(Box, { flexDirection: "column", paddingX: 1, width: terminalWidth },
|
|
253
|
-
showHistoryMenu && (React.createElement(Box, { flexDirection: "column", marginBottom: 1, width: terminalWidth - 2 },
|
|
254
|
-
React.createElement(Box, { flexDirection: "column" }, (() => {
|
|
255
|
-
const userMessages = getUserMessages();
|
|
256
|
-
const maxVisibleItems = 5; // Number of message items to show (reduced for small terminals)
|
|
257
|
-
// Calculate scroll window to keep selected index visible
|
|
258
|
-
let startIndex = 0;
|
|
259
|
-
if (userMessages.length > maxVisibleItems) {
|
|
260
|
-
// Keep selected item in the middle of the view when possible
|
|
261
|
-
startIndex = Math.max(0, historySelectedIndex - Math.floor(maxVisibleItems / 2));
|
|
262
|
-
// Adjust if we're near the end
|
|
263
|
-
startIndex = Math.min(startIndex, userMessages.length - maxVisibleItems);
|
|
264
|
-
}
|
|
265
|
-
const endIndex = Math.min(userMessages.length, startIndex + maxVisibleItems);
|
|
266
|
-
const visibleMessages = userMessages.slice(startIndex, endIndex);
|
|
267
|
-
const hasMoreAbove = startIndex > 0;
|
|
268
|
-
const hasMoreBelow = endIndex < userMessages.length;
|
|
269
|
-
return (React.createElement(React.Fragment, null,
|
|
270
|
-
React.createElement(Box, { height: 1 }, hasMoreAbove ? (React.createElement(Text, { color: theme.colors.menuSecondary, dimColor: true }, t.chatScreen.moreAbove.replace('{count}', startIndex.toString()))) : (React.createElement(Text, null, " "))),
|
|
271
|
-
visibleMessages.map((message, displayIndex) => {
|
|
272
|
-
const actualIndex = startIndex + displayIndex;
|
|
273
|
-
// Ensure single line by removing all newlines and control characters
|
|
274
|
-
const singleLineLabel = message.label
|
|
275
|
-
.replace(/[\r\n\t\v\f\u0000-\u001F\u007F-\u009F]+/g, ' ')
|
|
276
|
-
.replace(/\s+/g, ' ')
|
|
277
|
-
.trim();
|
|
278
|
-
// Calculate available width for the message
|
|
279
|
-
const prefixWidth = 3; // "❯ " or " "
|
|
280
|
-
const maxLabelWidth = terminalWidth - 4 - prefixWidth;
|
|
281
|
-
const truncatedLabel = singleLineLabel.length > maxLabelWidth
|
|
282
|
-
? singleLineLabel.slice(0, maxLabelWidth - 3) + '...'
|
|
283
|
-
: singleLineLabel;
|
|
284
|
-
return (React.createElement(Box, { key: message.value, height: 1 },
|
|
285
|
-
React.createElement(Text, { color: actualIndex === historySelectedIndex
|
|
286
|
-
? theme.colors.menuSelected
|
|
287
|
-
: theme.colors.menuNormal, bold: true, wrap: "truncate" },
|
|
288
|
-
actualIndex === historySelectedIndex ? '❯ ' : ' ',
|
|
289
|
-
truncatedLabel)));
|
|
290
|
-
}),
|
|
291
|
-
React.createElement(Box, { height: 1 }, hasMoreBelow ? (React.createElement(Text, { color: theme.colors.menuSecondary, dimColor: true }, t.chatScreen.moreBelow.replace('{count}', (userMessages.length - endIndex).toString()))) : (React.createElement(Text, null, " ")))));
|
|
292
|
-
})()),
|
|
293
|
-
React.createElement(Box, { marginBottom: 1 },
|
|
294
|
-
React.createElement(Text, { color: theme.colors.menuInfo, dimColor: true }, t.chatScreen.historyNavigateHint)))),
|
|
295
|
-
!showHistoryMenu && (React.createElement(React.Fragment, null,
|
|
296
|
-
React.createElement(Box, { flexDirection: "column", width: terminalWidth - 2 },
|
|
297
|
-
React.createElement(Text, { color: theme.colors.menuSecondary }, '─'.repeat(terminalWidth - 2)),
|
|
298
|
-
React.createElement(Box, { flexDirection: "row" },
|
|
299
|
-
React.createElement(Text, { color: theme.colors.menuInfo, bold: true },
|
|
300
|
-
"\u276F",
|
|
301
|
-
' '),
|
|
302
|
-
React.createElement(Box, { flexGrow: 1 }, renderContent())),
|
|
303
|
-
React.createElement(Text, { color: theme.colors.menuSecondary }, '─'.repeat(terminalWidth - 2))),
|
|
304
|
-
(showCommands && getFilteredCommands().length > 0) ||
|
|
305
|
-
showFilePicker ? (React.createElement(Box, { marginTop: 1 },
|
|
306
|
-
React.createElement(Text, null, showCommands && getFilteredCommands().length > 0
|
|
307
|
-
? t.chatScreen.typeToFilterCommands
|
|
308
|
-
: showFilePicker
|
|
309
|
-
? searchMode === 'content'
|
|
310
|
-
? t.chatScreen.contentSearchHint
|
|
311
|
-
: t.chatScreen.fileSearchHint
|
|
312
|
-
: ''))) : null,
|
|
313
|
-
React.createElement(Suspense, { fallback: null },
|
|
314
|
-
React.createElement(CommandPanel, { commands: getFilteredCommands(), selectedIndex: commandSelectedIndex, query: buffer.getFullText().slice(1), visible: showCommands, isProcessing: commandPanelIsProcessing })),
|
|
315
|
-
React.createElement(Box, null,
|
|
316
|
-
React.createElement(Suspense, { fallback: null },
|
|
317
|
-
React.createElement(FileList, { ref: fileListRef, query: fileQuery, selectedIndex: fileSelectedIndex, visible: showFilePicker, maxItems: 10, rootPath: process.cwd(), onFilteredCountChange: handleFilteredCountChange, searchMode: searchMode }))),
|
|
318
|
-
React.createElement(Suspense, { fallback: null },
|
|
319
|
-
React.createElement(AgentPickerPanel, { agents: getFilteredAgents(), selectedIndex: agentSelectedIndex, visible: showAgentPicker, maxHeight: 5 })),
|
|
320
|
-
React.createElement(Suspense, { fallback: null },
|
|
321
|
-
React.createElement(TodoPickerPanel, { todos: todos, selectedIndex: todoSelectedIndex, selectedTodos: selectedTodos, visible: showTodoPicker, maxHeight: 5, isLoading: todoIsLoading, searchQuery: todoSearchQuery, totalCount: totalTodoCount })),
|
|
322
|
-
yoloMode && (React.createElement(Box, { marginTop: 1 },
|
|
323
|
-
React.createElement(Text, { color: theme.colors.warning, dimColor: true }, t.chatScreen.yoloModeActive))),
|
|
324
|
-
contextUsage && (React.createElement(Box, { marginTop: 1 },
|
|
325
|
-
React.createElement(Text, { color: theme.colors.menuSecondary, dimColor: true }, (() => {
|
|
326
|
-
// Determine which caching system is being used
|
|
327
|
-
const isAnthropic = (contextUsage.cacheCreationTokens || 0) > 0 ||
|
|
328
|
-
(contextUsage.cacheReadTokens || 0) > 0;
|
|
329
|
-
const isOpenAI = (contextUsage.cachedTokens || 0) > 0;
|
|
330
|
-
// Use the exported function for consistent calculation
|
|
331
|
-
const percentage = calculateContextPercentage(contextUsage);
|
|
332
|
-
// Calculate total tokens for display
|
|
333
|
-
const totalInputTokens = isAnthropic
|
|
334
|
-
? contextUsage.inputTokens +
|
|
335
|
-
(contextUsage.cacheCreationTokens || 0) +
|
|
336
|
-
(contextUsage.cacheReadTokens || 0)
|
|
337
|
-
: contextUsage.inputTokens;
|
|
338
|
-
let color;
|
|
339
|
-
if (percentage < 50)
|
|
340
|
-
color = theme.colors.success;
|
|
341
|
-
else if (percentage < 75)
|
|
342
|
-
color = theme.colors.warning;
|
|
343
|
-
else if (percentage < 90)
|
|
344
|
-
color = theme.colors.warning;
|
|
345
|
-
else
|
|
346
|
-
color = theme.colors.error;
|
|
347
|
-
const formatNumber = (num) => {
|
|
348
|
-
if (num >= 1000)
|
|
349
|
-
return `${(num / 1000).toFixed(1)}k`;
|
|
350
|
-
return num.toString();
|
|
351
|
-
};
|
|
352
|
-
const hasCacheMetrics = isAnthropic || isOpenAI;
|
|
353
|
-
return (React.createElement(React.Fragment, null,
|
|
354
|
-
React.createElement(Text, { color: color },
|
|
355
|
-
percentage.toFixed(1),
|
|
356
|
-
"%"),
|
|
357
|
-
React.createElement(Text, null, " \u00B7 "),
|
|
358
|
-
React.createElement(Text, { color: color }, formatNumber(totalInputTokens)),
|
|
359
|
-
React.createElement(Text, null, t.chatScreen.tokens),
|
|
360
|
-
hasCacheMetrics && (React.createElement(React.Fragment, null,
|
|
361
|
-
React.createElement(Text, null, " \u00B7 "),
|
|
362
|
-
isAnthropic && (React.createElement(React.Fragment, null,
|
|
363
|
-
(contextUsage.cacheReadTokens || 0) > 0 && (React.createElement(React.Fragment, null,
|
|
364
|
-
React.createElement(Text, { color: theme.colors.menuInfo },
|
|
365
|
-
"\u21AF",
|
|
366
|
-
' ',
|
|
367
|
-
formatNumber(contextUsage.cacheReadTokens || 0),
|
|
368
|
-
' ',
|
|
369
|
-
t.chatScreen.cached))),
|
|
370
|
-
(contextUsage.cacheCreationTokens || 0) > 0 && (React.createElement(React.Fragment, null,
|
|
371
|
-
(contextUsage.cacheReadTokens || 0) > 0 && (React.createElement(Text, null, " \u00B7 ")),
|
|
372
|
-
React.createElement(Text, { color: theme.colors.warning },
|
|
373
|
-
"\u25C6",
|
|
374
|
-
' ',
|
|
375
|
-
formatNumber(contextUsage.cacheCreationTokens || 0),
|
|
376
|
-
' ',
|
|
377
|
-
t.chatScreen.newCache))))),
|
|
378
|
-
isOpenAI && (React.createElement(Text, { color: theme.colors.menuInfo },
|
|
379
|
-
"\u21AF ",
|
|
380
|
-
formatNumber(contextUsage.cachedTokens || 0),
|
|
381
|
-
' ',
|
|
382
|
-
t.chatScreen.cached))))));
|
|
383
|
-
})())))))));
|
|
384
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
interface Command {
|
|
3
|
-
name: string;
|
|
4
|
-
description: string;
|
|
5
|
-
}
|
|
6
|
-
interface Props {
|
|
7
|
-
commands: Command[];
|
|
8
|
-
selectedIndex: number;
|
|
9
|
-
query: string;
|
|
10
|
-
visible: boolean;
|
|
11
|
-
maxHeight?: number;
|
|
12
|
-
isProcessing?: boolean;
|
|
13
|
-
}
|
|
14
|
-
declare const CommandPanel: React.MemoExoticComponent<({ commands, selectedIndex, visible, maxHeight, isProcessing, }: Props) => React.JSX.Element | null>;
|
|
15
|
-
export default CommandPanel;
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import React, { memo, useMemo } from 'react';
|
|
2
|
-
import { Box, Text } from 'ink';
|
|
3
|
-
import { Alert } from '@inkjs/ui';
|
|
4
|
-
import { useI18n } from '../../i18n/index.js';
|
|
5
|
-
import { useTheme } from '../contexts/ThemeContext.js';
|
|
6
|
-
const CommandPanel = memo(({ commands, selectedIndex, visible, maxHeight, isProcessing = false, }) => {
|
|
7
|
-
const { t } = useI18n();
|
|
8
|
-
const { theme } = useTheme();
|
|
9
|
-
// Fixed maximum display items to prevent rendering issues
|
|
10
|
-
const MAX_DISPLAY_ITEMS = 5;
|
|
11
|
-
const effectiveMaxItems = maxHeight
|
|
12
|
-
? Math.min(maxHeight, MAX_DISPLAY_ITEMS)
|
|
13
|
-
: MAX_DISPLAY_ITEMS;
|
|
14
|
-
// Limit displayed commands
|
|
15
|
-
const displayedCommands = useMemo(() => {
|
|
16
|
-
if (commands.length <= effectiveMaxItems) {
|
|
17
|
-
return commands;
|
|
18
|
-
}
|
|
19
|
-
// Show commands around the selected index
|
|
20
|
-
const halfWindow = Math.floor(effectiveMaxItems / 2);
|
|
21
|
-
let startIndex = Math.max(0, selectedIndex - halfWindow);
|
|
22
|
-
let endIndex = Math.min(commands.length, startIndex + effectiveMaxItems);
|
|
23
|
-
// Adjust if we're near the end
|
|
24
|
-
if (endIndex - startIndex < effectiveMaxItems) {
|
|
25
|
-
startIndex = Math.max(0, endIndex - effectiveMaxItems);
|
|
26
|
-
}
|
|
27
|
-
return commands.slice(startIndex, endIndex);
|
|
28
|
-
}, [commands, selectedIndex, effectiveMaxItems]);
|
|
29
|
-
// Calculate actual selected index in the displayed subset
|
|
30
|
-
const displayedSelectedIndex = useMemo(() => {
|
|
31
|
-
return displayedCommands.findIndex(cmd => {
|
|
32
|
-
const originalIndex = commands.indexOf(cmd);
|
|
33
|
-
return originalIndex === selectedIndex;
|
|
34
|
-
});
|
|
35
|
-
}, [displayedCommands, commands, selectedIndex]);
|
|
36
|
-
// Don't show panel if not visible
|
|
37
|
-
if (!visible) {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
// Show processing message if conversation is in progress
|
|
41
|
-
if (isProcessing) {
|
|
42
|
-
return (React.createElement(Box, { flexDirection: "column" },
|
|
43
|
-
React.createElement(Box, { width: "100%" },
|
|
44
|
-
React.createElement(Box, { flexDirection: "column", width: "100%" },
|
|
45
|
-
React.createElement(Box, null,
|
|
46
|
-
React.createElement(Text, { color: theme.colors.warning, bold: true }, t.commandPanel.title)),
|
|
47
|
-
React.createElement(Box, { marginTop: 1 },
|
|
48
|
-
React.createElement(Alert, { variant: "info" }, t.commandPanel.processingMessage))))));
|
|
49
|
-
}
|
|
50
|
-
// Don't show panel if no commands found
|
|
51
|
-
if (commands.length === 0) {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
return (React.createElement(Box, { flexDirection: "column" },
|
|
55
|
-
React.createElement(Box, { width: "100%" },
|
|
56
|
-
React.createElement(Box, { flexDirection: "column", width: "100%" },
|
|
57
|
-
React.createElement(Box, null,
|
|
58
|
-
React.createElement(Text, { color: theme.colors.warning, bold: true },
|
|
59
|
-
t.commandPanel.availableCommands,
|
|
60
|
-
' ',
|
|
61
|
-
commands.length > effectiveMaxItems &&
|
|
62
|
-
`(${selectedIndex + 1}/${commands.length})`)),
|
|
63
|
-
displayedCommands.map((command, index) => (React.createElement(Box, { key: command.name, flexDirection: "column", width: "100%" },
|
|
64
|
-
React.createElement(Text, { color: index === displayedSelectedIndex ? theme.colors.success : theme.colors.menuSecondary, bold: true },
|
|
65
|
-
index === displayedSelectedIndex ? '❯ ' : ' ',
|
|
66
|
-
"/",
|
|
67
|
-
command.name),
|
|
68
|
-
React.createElement(Box, { marginLeft: 3 },
|
|
69
|
-
React.createElement(Text, { color: index === displayedSelectedIndex ? theme.colors.success : theme.colors.menuSecondary, dimColor: true },
|
|
70
|
-
"\u2514\u2500 ",
|
|
71
|
-
command.description))))),
|
|
72
|
-
commands.length > effectiveMaxItems && (React.createElement(Box, { marginTop: 1 },
|
|
73
|
-
React.createElement(Text, { color: theme.colors.menuSecondary, dimColor: true },
|
|
74
|
-
t.commandPanel.scrollHint,
|
|
75
|
-
" \u00B7",
|
|
76
|
-
' ',
|
|
77
|
-
t.commandPanel.moreHidden.replace('{count}', (commands.length - effectiveMaxItems).toString()))))))));
|
|
78
|
-
});
|
|
79
|
-
CommandPanel.displayName = 'CommandPanel';
|
|
80
|
-
export default CommandPanel;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
interface Props {
|
|
3
|
-
oldContent?: string;
|
|
4
|
-
newContent: string;
|
|
5
|
-
filename?: string;
|
|
6
|
-
completeOldContent?: string;
|
|
7
|
-
completeNewContent?: string;
|
|
8
|
-
startLineNumber?: number;
|
|
9
|
-
}
|
|
10
|
-
export default function DiffViewer({ oldContent, newContent, filename, completeOldContent, completeNewContent, startLineNumber, }: Props): React.JSX.Element | null;
|
|
11
|
-
export {};
|