fss-link 1.0.40 → 1.0.45
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/commands/mcp/add.test.ts +122 -0
- package/dist/commands/mcp/add.ts +222 -0
- package/dist/commands/mcp/list.test.ts +154 -0
- package/dist/commands/mcp/list.ts +139 -0
- package/dist/commands/mcp/remove.test.ts +69 -0
- package/dist/commands/mcp/remove.ts +60 -0
- package/dist/commands/mcp.test.ts +55 -0
- package/dist/commands/mcp.ts +27 -0
- package/dist/config/apiValidation.test.ts +118 -0
- package/dist/config/auth.test.ts +79 -0
- package/dist/config/auth.ts +100 -0
- package/dist/config/config.integration.test.ts +407 -0
- package/dist/config/config.test.ts +1952 -0
- package/dist/config/config.ts +690 -0
- package/dist/config/database.test.ts +96 -0
- package/dist/config/database.ts +752 -0
- package/dist/config/extension.test.ts +236 -0
- package/dist/config/extension.ts +180 -0
- package/dist/config/keyBindings.test.ts +62 -0
- package/dist/config/keyBindings.ts +184 -0
- package/dist/config/modelManager.ts +275 -0
- package/dist/config/providerManager.ts +244 -0
- package/dist/config/providerPersistence.test.ts +377 -0
- package/dist/config/providerPersistence.ts +105 -0
- package/dist/config/sandboxConfig.ts +107 -0
- package/dist/config/settings.test.ts +1424 -0
- package/dist/config/settings.ts +517 -0
- package/dist/config/settingsSchema.test.ts +252 -0
- package/dist/config/settingsSchema.ts +728 -0
- package/dist/config/trustedFolders.test.ts +208 -0
- package/dist/config/trustedFolders.ts +167 -0
- package/dist/gemini.test.tsx +252 -0
- package/dist/gemini.tsx +357 -0
- package/dist/generated/git-commit.ts +10 -0
- package/dist/index.ts +21 -0
- package/dist/nonInteractiveCli.test.ts +276 -0
- package/dist/nonInteractiveCli.ts +143 -0
- package/dist/package.json +87 -87
- package/dist/patches/is-in-ci.ts +17 -0
- package/dist/services/BuiltinCommandLoader.test.ts +127 -0
- package/dist/services/BuiltinCommandLoader.ts +95 -0
- package/dist/services/CommandService.test.ts +352 -0
- package/dist/services/CommandService.ts +103 -0
- package/dist/services/FileCommandLoader.test.ts +1002 -0
- package/dist/services/FileCommandLoader.ts +289 -0
- package/dist/services/McpPromptLoader.ts +231 -0
- package/dist/services/SearchEngineConfigProvider.ts +100 -0
- package/dist/services/prompt-processors/argumentProcessor.test.ts +41 -0
- package/dist/services/prompt-processors/argumentProcessor.ts +23 -0
- package/dist/services/prompt-processors/shellProcessor.test.ts +709 -0
- package/dist/services/prompt-processors/shellProcessor.ts +248 -0
- package/dist/services/prompt-processors/types.ts +44 -0
- package/dist/services/types.ts +24 -0
- package/dist/src/config/apiValidation.test.d.ts +6 -0
- package/dist/src/config/apiValidation.test.js +99 -0
- package/dist/src/config/apiValidation.test.js.map +1 -0
- package/dist/src/config/database.d.ts +32 -0
- package/dist/src/config/database.js +281 -2
- package/dist/src/config/database.js.map +1 -1
- package/dist/src/config/database.test.d.ts +6 -0
- package/dist/src/config/database.test.js +80 -0
- package/dist/src/config/database.test.js.map +1 -0
- package/dist/src/config/providerManager.d.ts +74 -0
- package/dist/src/config/providerManager.js +203 -0
- package/dist/src/config/providerManager.js.map +1 -0
- package/dist/src/config/providerPersistence.d.ts +75 -0
- package/dist/src/config/providerPersistence.js +55 -0
- package/dist/src/config/providerPersistence.js.map +1 -0
- package/dist/src/config/providerPersistence.test.d.ts +6 -0
- package/dist/src/config/providerPersistence.test.js +283 -0
- package/dist/src/config/providerPersistence.test.js.map +1 -0
- package/dist/src/config/settingsSchema.d.ts +9 -0
- package/dist/src/config/settingsSchema.js +9 -0
- package/dist/src/config/settingsSchema.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +1 -1
- package/dist/src/generated/git-commit.js +1 -1
- package/dist/src/services/BuiltinCommandLoader.js +2 -0
- package/dist/src/services/BuiltinCommandLoader.js.map +1 -1
- package/dist/src/ui/App.js +14 -2
- package/dist/src/ui/App.js.map +1 -1
- package/dist/src/ui/commands/contextCommand.d.ts +7 -0
- package/dist/src/ui/commands/contextCommand.js +115 -0
- package/dist/src/ui/commands/contextCommand.js.map +1 -0
- package/dist/src/ui/components/ContextUsageDisplay.d.ts +3 -1
- package/dist/src/ui/components/ContextUsageDisplay.js +43 -3
- package/dist/src/ui/components/ContextUsageDisplay.js.map +1 -1
- package/dist/src/ui/components/Footer.d.ts +1 -0
- package/dist/src/ui/components/Footer.js +2 -2
- package/dist/src/ui/components/Footer.js.map +1 -1
- package/dist/src/ui/components/GeminiKeyDialog.d.ts +11 -0
- package/dist/src/ui/components/GeminiKeyDialog.js +156 -0
- package/dist/src/ui/components/GeminiKeyDialog.js.map +1 -0
- package/dist/src/ui/components/OpenAIEndpointDialog.d.ts +19 -0
- package/dist/src/ui/components/OpenAIEndpointDialog.js +163 -0
- package/dist/src/ui/components/OpenAIEndpointDialog.js.map +1 -0
- package/dist/src/ui/components/WelcomeBackDialog.d.ts +36 -0
- package/dist/src/ui/components/WelcomeBackDialog.js +109 -0
- package/dist/src/ui/components/WelcomeBackDialog.js.map +1 -0
- package/dist/src/ui/hooks/useWelcomeBack.d.ts +52 -0
- package/dist/src/ui/hooks/useWelcomeBack.js +214 -0
- package/dist/src/ui/hooks/useWelcomeBack.js.map +1 -0
- package/dist/src/zed-integration/schema.d.ts +1516 -1516
- package/dist/test-setup.ts +12 -0
- package/dist/test-utils/customMatchers.ts +65 -0
- package/dist/test-utils/mockCommandContext.test.ts +62 -0
- package/dist/test-utils/mockCommandContext.ts +105 -0
- package/dist/test-utils/render.tsx +18 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/ui/App.test.tsx +2181 -0
- package/dist/ui/App.tsx +1344 -0
- package/dist/ui/IdeIntegrationNudge.tsx +98 -0
- package/dist/ui/__snapshots__/App.test.tsx.snap +124 -0
- package/dist/ui/colors.ts +56 -0
- package/dist/ui/commands/aboutCommand.test.ts +153 -0
- package/dist/ui/commands/aboutCommand.ts +49 -0
- package/dist/ui/commands/authCommand.test.ts +36 -0
- package/dist/ui/commands/authCommand.ts +17 -0
- package/dist/ui/commands/bugCommand.test.ts +114 -0
- package/dist/ui/commands/bugCommand.ts +92 -0
- package/dist/ui/commands/chatCommand.test.ts +414 -0
- package/dist/ui/commands/chatCommand.ts +280 -0
- package/dist/ui/commands/clearCommand.test.ts +100 -0
- package/dist/ui/commands/clearCommand.ts +29 -0
- package/dist/ui/commands/compressCommand.test.ts +129 -0
- package/dist/ui/commands/compressCommand.ts +78 -0
- package/dist/ui/commands/contextCommand.ts +132 -0
- package/dist/ui/commands/copyCommand.test.ts +296 -0
- package/dist/ui/commands/copyCommand.ts +67 -0
- package/dist/ui/commands/corgiCommand.test.ts +34 -0
- package/dist/ui/commands/corgiCommand.ts +16 -0
- package/dist/ui/commands/directoryCommand.test.tsx +185 -0
- package/dist/ui/commands/directoryCommand.tsx +179 -0
- package/dist/ui/commands/docsCommand.test.ts +99 -0
- package/dist/ui/commands/docsCommand.ts +42 -0
- package/dist/ui/commands/editorCommand.test.ts +30 -0
- package/dist/ui/commands/editorCommand.ts +21 -0
- package/dist/ui/commands/extensionsCommand.test.ts +67 -0
- package/dist/ui/commands/extensionsCommand.ts +46 -0
- package/dist/ui/commands/helpCommand.test.ts +52 -0
- package/dist/ui/commands/helpCommand.ts +23 -0
- package/dist/ui/commands/ideCommand.test.ts +255 -0
- package/dist/ui/commands/ideCommand.ts +283 -0
- package/dist/ui/commands/initCommand.test.ts +127 -0
- package/dist/ui/commands/initCommand.ts +117 -0
- package/dist/ui/commands/mcpCommand.test.ts +1057 -0
- package/dist/ui/commands/mcpCommand.ts +531 -0
- package/dist/ui/commands/memoryCommand.test.ts +344 -0
- package/dist/ui/commands/memoryCommand.ts +305 -0
- package/dist/ui/commands/privacyCommand.test.ts +38 -0
- package/dist/ui/commands/privacyCommand.ts +17 -0
- package/dist/ui/commands/quitCommand.test.ts +55 -0
- package/dist/ui/commands/quitCommand.ts +36 -0
- package/dist/ui/commands/restoreCommand.test.ts +250 -0
- package/dist/ui/commands/restoreCommand.ts +157 -0
- package/dist/ui/commands/searchEngineSetupCommand.ts +18 -0
- package/dist/ui/commands/settingsCommand.test.ts +36 -0
- package/dist/ui/commands/settingsCommand.ts +17 -0
- package/dist/ui/commands/setupGithubCommand.test.ts +238 -0
- package/dist/ui/commands/setupGithubCommand.ts +212 -0
- package/dist/ui/commands/speakCommand.ts +175 -0
- package/dist/ui/commands/statsCommand.test.ts +78 -0
- package/dist/ui/commands/statsCommand.ts +70 -0
- package/dist/ui/commands/terminalSetupCommand.test.ts +85 -0
- package/dist/ui/commands/terminalSetupCommand.ts +45 -0
- package/dist/ui/commands/themeCommand.test.ts +38 -0
- package/dist/ui/commands/themeCommand.ts +17 -0
- package/dist/ui/commands/toolsCommand.test.ts +105 -0
- package/dist/ui/commands/toolsCommand.ts +71 -0
- package/dist/ui/commands/ttsCommand.ts +143 -0
- package/dist/ui/commands/types.ts +204 -0
- package/dist/ui/commands/vimCommand.ts +25 -0
- package/dist/ui/commands/voiceCommand.ts +125 -0
- package/dist/ui/components/AboutBox.tsx +133 -0
- package/dist/ui/components/AsciiArt.ts +54 -0
- package/dist/ui/components/AuthDialog.test.tsx +334 -0
- package/dist/ui/components/AuthDialog.tsx +289 -0
- package/dist/ui/components/AuthInProgress.tsx +62 -0
- package/dist/ui/components/AutoAcceptIndicator.tsx +47 -0
- package/dist/ui/components/ConsoleSummaryDisplay.tsx +35 -0
- package/dist/ui/components/ContextSummaryDisplay.test.tsx +85 -0
- package/dist/ui/components/ContextSummaryDisplay.tsx +120 -0
- package/dist/ui/components/ContextUsageDisplay.tsx +77 -0
- package/dist/ui/components/DebugProfiler.tsx +36 -0
- package/dist/ui/components/DetailedMessagesDisplay.tsx +82 -0
- package/dist/ui/components/EditorSettingsDialog.tsx +172 -0
- package/dist/ui/components/FolderTrustDialog.test.tsx +36 -0
- package/dist/ui/components/FolderTrustDialog.tsx +74 -0
- package/dist/ui/components/Footer.test.tsx +159 -0
- package/dist/ui/components/Footer.tsx +158 -0
- package/dist/ui/components/GeminiKeyDialog.tsx +252 -0
- package/dist/ui/components/GeminiRespondingSpinner.tsx +34 -0
- package/dist/ui/components/Header.test.tsx +44 -0
- package/dist/ui/components/Header.tsx +70 -0
- package/dist/ui/components/Help.tsx +174 -0
- package/dist/ui/components/HistoryItemDisplay.test.tsx +125 -0
- package/dist/ui/components/HistoryItemDisplay.tsx +98 -0
- package/dist/ui/components/InputPrompt.test.tsx +1467 -0
- package/dist/ui/components/InputPrompt.tsx +641 -0
- package/dist/ui/components/LMStudioModelPrompt.tsx +215 -0
- package/dist/ui/components/LoadingIndicator.test.tsx +296 -0
- package/dist/ui/components/LoadingIndicator.tsx +82 -0
- package/dist/ui/components/MemoryUsageDisplay.tsx +36 -0
- package/dist/ui/components/ModelStatsDisplay.test.tsx +252 -0
- package/dist/ui/components/ModelStatsDisplay.tsx +197 -0
- package/dist/ui/components/OllamaModelPrompt.tsx +206 -0
- package/dist/ui/components/OpenAIEndpointDialog.tsx +261 -0
- package/dist/ui/components/OpenAIKeyPrompt.test.tsx +64 -0
- package/dist/ui/components/OpenAIKeyPrompt.tsx +197 -0
- package/dist/ui/components/PrepareLabel.tsx +48 -0
- package/dist/ui/components/SearchEngineConfigDialog.tsx +280 -0
- package/dist/ui/components/SessionSummaryDisplay.test.tsx +75 -0
- package/dist/ui/components/SessionSummaryDisplay.tsx +18 -0
- package/dist/ui/components/SettingsDialog.test.tsx +865 -0
- package/dist/ui/components/SettingsDialog.tsx +753 -0
- package/dist/ui/components/ShellConfirmationDialog.test.tsx +53 -0
- package/dist/ui/components/ShellConfirmationDialog.tsx +103 -0
- package/dist/ui/components/ShellModeIndicator.tsx +18 -0
- package/dist/ui/components/ShowMoreLines.tsx +40 -0
- package/dist/ui/components/StatsDisplay.test.tsx +401 -0
- package/dist/ui/components/StatsDisplay.tsx +273 -0
- package/dist/ui/components/SuggestionsDisplay.tsx +102 -0
- package/dist/ui/components/ThemeDialog.tsx +310 -0
- package/dist/ui/components/Tips.tsx +45 -0
- package/dist/ui/components/TodoDisplay.test.tsx +97 -0
- package/dist/ui/components/TodoDisplay.tsx +72 -0
- package/dist/ui/components/ToolStatsDisplay.test.tsx +180 -0
- package/dist/ui/components/ToolStatsDisplay.tsx +208 -0
- package/dist/ui/components/UpdateNotification.tsx +23 -0
- package/dist/ui/components/WelcomeBackDialog.tsx +290 -0
- package/dist/ui/components/__snapshots__/IDEContextDetailDisplay.test.tsx.snap +24 -0
- package/dist/ui/components/__snapshots__/ModelStatsDisplay.test.tsx.snap +121 -0
- package/dist/ui/components/__snapshots__/SessionSummaryDisplay.test.tsx.snap +30 -0
- package/dist/ui/components/__snapshots__/ShellConfirmationDialog.test.tsx.snap +21 -0
- package/dist/ui/components/__snapshots__/StatsDisplay.test.tsx.snap +264 -0
- package/dist/ui/components/__snapshots__/ToolStatsDisplay.test.tsx.snap +91 -0
- package/dist/ui/components/messages/CompressionMessage.tsx +49 -0
- package/dist/ui/components/messages/DiffRenderer.test.tsx +365 -0
- package/dist/ui/components/messages/DiffRenderer.tsx +358 -0
- package/dist/ui/components/messages/ErrorMessage.tsx +31 -0
- package/dist/ui/components/messages/GeminiMessage.tsx +43 -0
- package/dist/ui/components/messages/GeminiMessageContent.tsx +43 -0
- package/dist/ui/components/messages/InfoMessage.tsx +32 -0
- package/dist/ui/components/messages/ToolConfirmationMessage.test.tsx +58 -0
- package/dist/ui/components/messages/ToolConfirmationMessage.tsx +297 -0
- package/dist/ui/components/messages/ToolGroupMessage.tsx +126 -0
- package/dist/ui/components/messages/ToolMessage.test.tsx +183 -0
- package/dist/ui/components/messages/ToolMessage.tsx +296 -0
- package/dist/ui/components/messages/UserMessage.tsx +43 -0
- package/dist/ui/components/messages/UserShellMessage.tsx +25 -0
- package/dist/ui/components/shared/MaxSizedBox.test.tsx +425 -0
- package/dist/ui/components/shared/MaxSizedBox.tsx +624 -0
- package/dist/ui/components/shared/RadioButtonSelect.test.tsx +181 -0
- package/dist/ui/components/shared/RadioButtonSelect.tsx +234 -0
- package/dist/ui/components/shared/__snapshots__/RadioButtonSelect.test.tsx.snap +47 -0
- package/dist/ui/components/shared/text-buffer.test.ts +1728 -0
- package/dist/ui/components/shared/text-buffer.ts +2227 -0
- package/dist/ui/components/shared/vim-buffer-actions.test.ts +1119 -0
- package/dist/ui/components/shared/vim-buffer-actions.ts +814 -0
- package/dist/ui/constants.ts +17 -0
- package/dist/ui/contexts/KeypressContext.test.tsx +391 -0
- package/dist/ui/contexts/KeypressContext.tsx +440 -0
- package/dist/ui/contexts/OverflowContext.tsx +87 -0
- package/dist/ui/contexts/SessionContext.test.tsx +132 -0
- package/dist/ui/contexts/SessionContext.tsx +143 -0
- package/dist/ui/contexts/SettingsContext.tsx +20 -0
- package/dist/ui/contexts/StreamingContext.tsx +22 -0
- package/dist/ui/contexts/VimModeContext.tsx +79 -0
- package/dist/ui/editors/editorSettingsManager.ts +66 -0
- package/dist/ui/hooks/atCommandProcessor.test.ts +1102 -0
- package/dist/ui/hooks/atCommandProcessor.ts +485 -0
- package/dist/ui/hooks/shellCommandProcessor.test.ts +481 -0
- package/dist/ui/hooks/shellCommandProcessor.ts +314 -0
- package/dist/ui/hooks/slashCommandProcessor.test.ts +1044 -0
- package/dist/ui/hooks/slashCommandProcessor.ts +595 -0
- package/dist/ui/hooks/useAtCompletion.test.ts +497 -0
- package/dist/ui/hooks/useAtCompletion.ts +244 -0
- package/dist/ui/hooks/useAuthCommand.ts +129 -0
- package/dist/ui/hooks/useAutoAcceptIndicator.test.ts +300 -0
- package/dist/ui/hooks/useAutoAcceptIndicator.ts +52 -0
- package/dist/ui/hooks/useBracketedPaste.ts +37 -0
- package/dist/ui/hooks/useCommandCompletion.test.ts +518 -0
- package/dist/ui/hooks/useCommandCompletion.tsx +238 -0
- package/dist/ui/hooks/useCompletion.ts +128 -0
- package/dist/ui/hooks/useConsoleMessages.test.ts +147 -0
- package/dist/ui/hooks/useConsoleMessages.ts +110 -0
- package/dist/ui/hooks/useEditorSettings.test.ts +283 -0
- package/dist/ui/hooks/useEditorSettings.ts +75 -0
- package/dist/ui/hooks/useFocus.test.ts +119 -0
- package/dist/ui/hooks/useFocus.ts +48 -0
- package/dist/ui/hooks/useFolderTrust.test.ts +159 -0
- package/dist/ui/hooks/useFolderTrust.ts +72 -0
- package/dist/ui/hooks/useGeminiStream.test.tsx +1998 -0
- package/dist/ui/hooks/useGeminiStream.ts +1017 -0
- package/dist/ui/hooks/useGitBranchName.test.ts +280 -0
- package/dist/ui/hooks/useGitBranchName.ts +79 -0
- package/dist/ui/hooks/useHistoryManager.test.ts +202 -0
- package/dist/ui/hooks/useHistoryManager.ts +111 -0
- package/dist/ui/hooks/useInputHistory.test.ts +261 -0
- package/dist/ui/hooks/useInputHistory.ts +111 -0
- package/dist/ui/hooks/useKeypress.test.ts +280 -0
- package/dist/ui/hooks/useKeypress.ts +39 -0
- package/dist/ui/hooks/useKittyKeyboardProtocol.ts +31 -0
- package/dist/ui/hooks/useLoadingIndicator.test.ts +139 -0
- package/dist/ui/hooks/useLoadingIndicator.ts +57 -0
- package/dist/ui/hooks/useLogger.ts +32 -0
- package/dist/ui/hooks/useMessageQueue.test.ts +226 -0
- package/dist/ui/hooks/useMessageQueue.ts +69 -0
- package/dist/ui/hooks/usePhraseCycler.test.ts +145 -0
- package/dist/ui/hooks/usePhraseCycler.ts +198 -0
- package/dist/ui/hooks/usePrivacySettings.test.ts +242 -0
- package/dist/ui/hooks/usePrivacySettings.ts +150 -0
- package/dist/ui/hooks/useReactToolScheduler.ts +309 -0
- package/dist/ui/hooks/useRefreshMemoryCommand.ts +7 -0
- package/dist/ui/hooks/useReverseSearchCompletion.test.tsx +260 -0
- package/dist/ui/hooks/useReverseSearchCompletion.tsx +95 -0
- package/dist/ui/hooks/useSettingsCommand.ts +25 -0
- package/dist/ui/hooks/useShellHistory.test.ts +219 -0
- package/dist/ui/hooks/useShellHistory.ts +133 -0
- package/dist/ui/hooks/useShowMemoryCommand.ts +75 -0
- package/dist/ui/hooks/useSlashCompletion.test.ts +434 -0
- package/dist/ui/hooks/useSlashCompletion.ts +187 -0
- package/dist/ui/hooks/useStateAndRef.ts +36 -0
- package/dist/ui/hooks/useTerminalSize.ts +32 -0
- package/dist/ui/hooks/useThemeCommand.ts +110 -0
- package/dist/ui/hooks/useTimer.test.ts +120 -0
- package/dist/ui/hooks/useTimer.ts +65 -0
- package/dist/ui/hooks/useToolScheduler.test.ts +1123 -0
- package/dist/ui/hooks/useWelcomeBack.ts +253 -0
- package/dist/ui/hooks/vim.test.ts +1691 -0
- package/dist/ui/hooks/vim.ts +784 -0
- package/dist/ui/keyMatchers.test.ts +337 -0
- package/dist/ui/keyMatchers.ts +105 -0
- package/dist/ui/privacy/CloudFreePrivacyNotice.tsx +117 -0
- package/dist/ui/privacy/CloudPaidPrivacyNotice.tsx +59 -0
- package/dist/ui/privacy/GeminiPrivacyNotice.tsx +62 -0
- package/dist/ui/privacy/PrivacyNotice.tsx +42 -0
- package/dist/ui/semantic-colors.ts +26 -0
- package/dist/ui/themes/ansi-light.ts +150 -0
- package/dist/ui/themes/ansi.ts +159 -0
- package/dist/ui/themes/atom-one-dark.ts +147 -0
- package/dist/ui/themes/ayu-light.ts +139 -0
- package/dist/ui/themes/ayu.ts +113 -0
- package/dist/ui/themes/color-utils.test.ts +221 -0
- package/dist/ui/themes/color-utils.ts +231 -0
- package/dist/ui/themes/default-light.ts +108 -0
- package/dist/ui/themes/default.ts +151 -0
- package/dist/ui/themes/dracula.ts +124 -0
- package/dist/ui/themes/fss-code-dark.ts +156 -0
- package/dist/ui/themes/fss-dark.ts +113 -0
- package/dist/ui/themes/fss-light.ts +139 -0
- package/dist/ui/themes/github-dark.ts +147 -0
- package/dist/ui/themes/github-light.ts +149 -0
- package/dist/ui/themes/googlecode.ts +146 -0
- package/dist/ui/themes/no-color.ts +125 -0
- package/dist/ui/themes/qwen-dark.ts +118 -0
- package/dist/ui/themes/qwen-light.ts +144 -0
- package/dist/ui/themes/semantic-tokens.ts +127 -0
- package/dist/ui/themes/shades-of-purple.ts +352 -0
- package/dist/ui/themes/theme-manager.test.ts +99 -0
- package/dist/ui/themes/theme-manager.ts +257 -0
- package/dist/ui/themes/theme.test.ts +97 -0
- package/dist/ui/themes/theme.ts +451 -0
- package/dist/ui/themes/xcode.ts +154 -0
- package/dist/ui/types.ts +255 -0
- package/dist/ui/utils/CodeColorizer.tsx +217 -0
- package/dist/ui/utils/ConsolePatcher.ts +71 -0
- package/dist/ui/utils/InlineMarkdownRenderer.tsx +173 -0
- package/dist/ui/utils/MarkdownDisplay.test.tsx +244 -0
- package/dist/ui/utils/MarkdownDisplay.tsx +415 -0
- package/dist/ui/utils/TableRenderer.tsx +159 -0
- package/dist/ui/utils/__snapshots__/MarkdownDisplay.test.tsx.snap +93 -0
- package/dist/ui/utils/clipboardUtils.test.ts +76 -0
- package/dist/ui/utils/clipboardUtils.ts +149 -0
- package/dist/ui/utils/commandUtils.test.ts +384 -0
- package/dist/ui/utils/commandUtils.ts +106 -0
- package/dist/ui/utils/computeStats.test.ts +292 -0
- package/dist/ui/utils/computeStats.ts +86 -0
- package/dist/ui/utils/displayUtils.test.ts +58 -0
- package/dist/ui/utils/displayUtils.ts +32 -0
- package/dist/ui/utils/formatters.test.ts +72 -0
- package/dist/ui/utils/formatters.ts +63 -0
- package/dist/ui/utils/isNarrowWidth.ts +9 -0
- package/dist/ui/utils/kittyProtocolDetector.ts +105 -0
- package/dist/ui/utils/markdownUtilities.test.ts +50 -0
- package/dist/ui/utils/markdownUtilities.ts +125 -0
- package/dist/ui/utils/platformConstants.ts +52 -0
- package/dist/ui/utils/terminalSetup.ts +342 -0
- package/dist/ui/utils/textUtils.ts +40 -0
- package/dist/ui/utils/updateCheck.test.ts +163 -0
- package/dist/ui/utils/updateCheck.ts +100 -0
- package/dist/utils/checks.ts +28 -0
- package/dist/utils/cleanup.test.ts +68 -0
- package/dist/utils/cleanup.ts +36 -0
- package/dist/utils/dialogScopeUtils.ts +64 -0
- package/dist/utils/events.ts +14 -0
- package/dist/utils/gitUtils.test.ts +149 -0
- package/dist/utils/gitUtils.ts +116 -0
- package/dist/utils/handleAutoUpdate.test.ts +272 -0
- package/dist/utils/handleAutoUpdate.ts +145 -0
- package/dist/utils/installationInfo.test.ts +315 -0
- package/dist/utils/installationInfo.ts +176 -0
- package/dist/utils/package.ts +38 -0
- package/dist/utils/readStdin.ts +51 -0
- package/dist/utils/resolvePath.ts +21 -0
- package/dist/utils/sandbox-macos-permissive-closed.sb +32 -0
- package/dist/utils/sandbox-macos-permissive-open.sb +25 -0
- package/dist/utils/sandbox-macos-permissive-proxied.sb +37 -0
- package/dist/utils/sandbox-macos-restrictive-closed.sb +93 -0
- package/dist/utils/sandbox-macos-restrictive-open.sb +96 -0
- package/dist/utils/sandbox-macos-restrictive-proxied.sb +98 -0
- package/dist/utils/sandbox.ts +962 -0
- package/dist/utils/settingsUtils.test.ts +797 -0
- package/dist/utils/settingsUtils.ts +489 -0
- package/dist/utils/spawnWrapper.ts +9 -0
- package/dist/utils/startupWarnings.test.ts +83 -0
- package/dist/utils/startupWarnings.ts +40 -0
- package/dist/utils/updateEventEmitter.ts +13 -0
- package/dist/utils/userStartupWarnings.test.ts +87 -0
- package/dist/utils/userStartupWarnings.ts +69 -0
- package/dist/utils/version.ts +12 -0
- package/dist/validateNonInterActiveAuth.test.ts +260 -0
- package/dist/validateNonInterActiveAuth.ts +51 -0
- package/dist/vitest.config.ts +37 -0
- package/dist/zed-integration/acp.ts +366 -0
- package/dist/zed-integration/fileSystemService.ts +47 -0
- package/dist/zed-integration/schema.ts +466 -0
- package/dist/zed-integration/zedIntegration.ts +944 -0
- package/package.json +2 -2
|
@@ -0,0 +1,1467 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { renderWithProviders } from '../../test-utils/render.js';
|
|
8
|
+
import { waitFor } from '@testing-library/react';
|
|
9
|
+
import { InputPrompt, InputPromptProps } from './InputPrompt.js';
|
|
10
|
+
import type { TextBuffer } from './shared/text-buffer.js';
|
|
11
|
+
import { Config } from 'fss-link-core';
|
|
12
|
+
import * as path from 'path';
|
|
13
|
+
import {
|
|
14
|
+
CommandContext,
|
|
15
|
+
SlashCommand,
|
|
16
|
+
CommandKind,
|
|
17
|
+
} from '../commands/types.js';
|
|
18
|
+
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
|
19
|
+
import {
|
|
20
|
+
useShellHistory,
|
|
21
|
+
UseShellHistoryReturn,
|
|
22
|
+
} from '../hooks/useShellHistory.js';
|
|
23
|
+
import {
|
|
24
|
+
useCommandCompletion,
|
|
25
|
+
UseCommandCompletionReturn,
|
|
26
|
+
} from '../hooks/useCommandCompletion.js';
|
|
27
|
+
import {
|
|
28
|
+
useInputHistory,
|
|
29
|
+
UseInputHistoryReturn,
|
|
30
|
+
} from '../hooks/useInputHistory.js';
|
|
31
|
+
import * as clipboardUtils from '../utils/clipboardUtils.js';
|
|
32
|
+
import { createMockCommandContext } from '../../test-utils/mockCommandContext.js';
|
|
33
|
+
|
|
34
|
+
vi.mock('../hooks/useShellHistory.js');
|
|
35
|
+
vi.mock('../hooks/useCommandCompletion.js');
|
|
36
|
+
vi.mock('../hooks/useInputHistory.js');
|
|
37
|
+
vi.mock('../utils/clipboardUtils.js');
|
|
38
|
+
|
|
39
|
+
const mockSlashCommands: SlashCommand[] = [
|
|
40
|
+
{
|
|
41
|
+
name: 'clear',
|
|
42
|
+
kind: CommandKind.BUILT_IN,
|
|
43
|
+
description: 'Clear screen',
|
|
44
|
+
action: vi.fn(),
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'memory',
|
|
48
|
+
kind: CommandKind.BUILT_IN,
|
|
49
|
+
description: 'Manage memory',
|
|
50
|
+
subCommands: [
|
|
51
|
+
{
|
|
52
|
+
name: 'show',
|
|
53
|
+
kind: CommandKind.BUILT_IN,
|
|
54
|
+
description: 'Show memory',
|
|
55
|
+
action: vi.fn(),
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'add',
|
|
59
|
+
kind: CommandKind.BUILT_IN,
|
|
60
|
+
description: 'Add to memory',
|
|
61
|
+
action: vi.fn(),
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'refresh',
|
|
65
|
+
kind: CommandKind.BUILT_IN,
|
|
66
|
+
description: 'Refresh memory',
|
|
67
|
+
action: vi.fn(),
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'chat',
|
|
73
|
+
description: 'Manage chats',
|
|
74
|
+
kind: CommandKind.BUILT_IN,
|
|
75
|
+
subCommands: [
|
|
76
|
+
{
|
|
77
|
+
name: 'resume',
|
|
78
|
+
description: 'Resume a chat',
|
|
79
|
+
kind: CommandKind.BUILT_IN,
|
|
80
|
+
action: vi.fn(),
|
|
81
|
+
completion: async () => ['fix-foo', 'fix-bar'],
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
describe('InputPrompt', () => {
|
|
88
|
+
let props: InputPromptProps;
|
|
89
|
+
let mockShellHistory: UseShellHistoryReturn;
|
|
90
|
+
let mockCommandCompletion: UseCommandCompletionReturn;
|
|
91
|
+
let mockInputHistory: UseInputHistoryReturn;
|
|
92
|
+
let mockBuffer: TextBuffer;
|
|
93
|
+
let mockCommandContext: CommandContext;
|
|
94
|
+
|
|
95
|
+
const mockedUseShellHistory = vi.mocked(useShellHistory);
|
|
96
|
+
const mockedUseCommandCompletion = vi.mocked(useCommandCompletion);
|
|
97
|
+
const mockedUseInputHistory = vi.mocked(useInputHistory);
|
|
98
|
+
|
|
99
|
+
beforeEach(() => {
|
|
100
|
+
vi.resetAllMocks();
|
|
101
|
+
|
|
102
|
+
mockCommandContext = createMockCommandContext();
|
|
103
|
+
|
|
104
|
+
mockBuffer = {
|
|
105
|
+
text: '',
|
|
106
|
+
cursor: [0, 0],
|
|
107
|
+
lines: [''],
|
|
108
|
+
setText: vi.fn((newText: string) => {
|
|
109
|
+
mockBuffer.text = newText;
|
|
110
|
+
mockBuffer.lines = [newText];
|
|
111
|
+
mockBuffer.cursor = [0, newText.length];
|
|
112
|
+
mockBuffer.viewportVisualLines = [newText];
|
|
113
|
+
mockBuffer.allVisualLines = [newText];
|
|
114
|
+
}),
|
|
115
|
+
replaceRangeByOffset: vi.fn(),
|
|
116
|
+
viewportVisualLines: [''],
|
|
117
|
+
allVisualLines: [''],
|
|
118
|
+
visualCursor: [0, 0],
|
|
119
|
+
visualScrollRow: 0,
|
|
120
|
+
handleInput: vi.fn(),
|
|
121
|
+
move: vi.fn(),
|
|
122
|
+
moveToOffset: (offset: number) => {
|
|
123
|
+
mockBuffer.cursor = [0, offset];
|
|
124
|
+
},
|
|
125
|
+
killLineRight: vi.fn(),
|
|
126
|
+
killLineLeft: vi.fn(),
|
|
127
|
+
openInExternalEditor: vi.fn(),
|
|
128
|
+
newline: vi.fn(),
|
|
129
|
+
backspace: vi.fn(),
|
|
130
|
+
preferredCol: null,
|
|
131
|
+
selectionAnchor: null,
|
|
132
|
+
insert: vi.fn(),
|
|
133
|
+
del: vi.fn(),
|
|
134
|
+
undo: vi.fn(),
|
|
135
|
+
redo: vi.fn(),
|
|
136
|
+
replaceRange: vi.fn(),
|
|
137
|
+
deleteWordLeft: vi.fn(),
|
|
138
|
+
deleteWordRight: vi.fn(),
|
|
139
|
+
} as unknown as TextBuffer;
|
|
140
|
+
|
|
141
|
+
mockShellHistory = {
|
|
142
|
+
history: [],
|
|
143
|
+
addCommandToHistory: vi.fn(),
|
|
144
|
+
getPreviousCommand: vi.fn().mockReturnValue(null),
|
|
145
|
+
getNextCommand: vi.fn().mockReturnValue(null),
|
|
146
|
+
resetHistoryPosition: vi.fn(),
|
|
147
|
+
};
|
|
148
|
+
mockedUseShellHistory.mockReturnValue(mockShellHistory);
|
|
149
|
+
|
|
150
|
+
mockCommandCompletion = {
|
|
151
|
+
suggestions: [],
|
|
152
|
+
activeSuggestionIndex: -1,
|
|
153
|
+
isLoadingSuggestions: false,
|
|
154
|
+
showSuggestions: false,
|
|
155
|
+
visibleStartIndex: 0,
|
|
156
|
+
isPerfectMatch: false,
|
|
157
|
+
navigateUp: vi.fn(),
|
|
158
|
+
navigateDown: vi.fn(),
|
|
159
|
+
resetCompletionState: vi.fn(),
|
|
160
|
+
setActiveSuggestionIndex: vi.fn(),
|
|
161
|
+
setShowSuggestions: vi.fn(),
|
|
162
|
+
handleAutocomplete: vi.fn(),
|
|
163
|
+
};
|
|
164
|
+
mockedUseCommandCompletion.mockReturnValue(mockCommandCompletion);
|
|
165
|
+
|
|
166
|
+
mockInputHistory = {
|
|
167
|
+
navigateUp: vi.fn(),
|
|
168
|
+
navigateDown: vi.fn(),
|
|
169
|
+
handleSubmit: vi.fn(),
|
|
170
|
+
};
|
|
171
|
+
mockedUseInputHistory.mockReturnValue(mockInputHistory);
|
|
172
|
+
|
|
173
|
+
props = {
|
|
174
|
+
buffer: mockBuffer,
|
|
175
|
+
onSubmit: vi.fn(),
|
|
176
|
+
userMessages: [],
|
|
177
|
+
onClearScreen: vi.fn(),
|
|
178
|
+
config: {
|
|
179
|
+
getProjectRoot: () => path.join('test', 'project'),
|
|
180
|
+
getTargetDir: () => path.join('test', 'project', 'src'),
|
|
181
|
+
getVimMode: () => false,
|
|
182
|
+
getWorkspaceContext: () => ({
|
|
183
|
+
getDirectories: () => ['/test/project/src'],
|
|
184
|
+
}),
|
|
185
|
+
} as unknown as Config,
|
|
186
|
+
slashCommands: mockSlashCommands,
|
|
187
|
+
commandContext: mockCommandContext,
|
|
188
|
+
shellModeActive: false,
|
|
189
|
+
setShellModeActive: vi.fn(),
|
|
190
|
+
inputWidth: 80,
|
|
191
|
+
suggestionsWidth: 80,
|
|
192
|
+
focus: true,
|
|
193
|
+
};
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
const wait = (ms = 50) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
197
|
+
|
|
198
|
+
it('should call shellHistory.getPreviousCommand on up arrow in shell mode', async () => {
|
|
199
|
+
props.shellModeActive = true;
|
|
200
|
+
const { stdin, unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
201
|
+
await wait();
|
|
202
|
+
|
|
203
|
+
stdin.write('\u001B[A');
|
|
204
|
+
await wait();
|
|
205
|
+
|
|
206
|
+
expect(mockShellHistory.getPreviousCommand).toHaveBeenCalled();
|
|
207
|
+
unmount();
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it('should call shellHistory.getNextCommand on down arrow in shell mode', async () => {
|
|
211
|
+
props.shellModeActive = true;
|
|
212
|
+
const { stdin, unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
213
|
+
await wait();
|
|
214
|
+
|
|
215
|
+
stdin.write('\u001B[B');
|
|
216
|
+
await wait();
|
|
217
|
+
|
|
218
|
+
expect(mockShellHistory.getNextCommand).toHaveBeenCalled();
|
|
219
|
+
unmount();
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
it('should set the buffer text when a shell history command is retrieved', async () => {
|
|
223
|
+
props.shellModeActive = true;
|
|
224
|
+
vi.mocked(mockShellHistory.getPreviousCommand).mockReturnValue(
|
|
225
|
+
'previous command',
|
|
226
|
+
);
|
|
227
|
+
const { stdin, unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
228
|
+
await wait();
|
|
229
|
+
|
|
230
|
+
stdin.write('\u001B[A');
|
|
231
|
+
await wait();
|
|
232
|
+
|
|
233
|
+
expect(mockShellHistory.getPreviousCommand).toHaveBeenCalled();
|
|
234
|
+
expect(props.buffer.setText).toHaveBeenCalledWith('previous command');
|
|
235
|
+
unmount();
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it('should call shellHistory.addCommandToHistory on submit in shell mode', async () => {
|
|
239
|
+
props.shellModeActive = true;
|
|
240
|
+
props.buffer.setText('ls -l');
|
|
241
|
+
const { stdin, unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
242
|
+
await wait();
|
|
243
|
+
|
|
244
|
+
stdin.write('\r');
|
|
245
|
+
await wait();
|
|
246
|
+
|
|
247
|
+
expect(mockShellHistory.addCommandToHistory).toHaveBeenCalledWith('ls -l');
|
|
248
|
+
expect(props.onSubmit).toHaveBeenCalledWith('ls -l');
|
|
249
|
+
unmount();
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
it('should NOT call shell history methods when not in shell mode', async () => {
|
|
253
|
+
props.buffer.setText('some text');
|
|
254
|
+
const { stdin, unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
255
|
+
await wait();
|
|
256
|
+
|
|
257
|
+
stdin.write('\u001B[A'); // Up arrow
|
|
258
|
+
await wait();
|
|
259
|
+
stdin.write('\u001B[B'); // Down arrow
|
|
260
|
+
await wait();
|
|
261
|
+
stdin.write('\r'); // Enter
|
|
262
|
+
await wait();
|
|
263
|
+
|
|
264
|
+
expect(mockShellHistory.getPreviousCommand).not.toHaveBeenCalled();
|
|
265
|
+
expect(mockShellHistory.getNextCommand).not.toHaveBeenCalled();
|
|
266
|
+
expect(mockShellHistory.addCommandToHistory).not.toHaveBeenCalled();
|
|
267
|
+
|
|
268
|
+
expect(mockInputHistory.navigateUp).toHaveBeenCalled();
|
|
269
|
+
expect(mockInputHistory.navigateDown).toHaveBeenCalled();
|
|
270
|
+
expect(props.onSubmit).toHaveBeenCalledWith('some text');
|
|
271
|
+
unmount();
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
it('should call completion.navigateUp for both up arrow and Ctrl+P when suggestions are showing', async () => {
|
|
275
|
+
mockedUseCommandCompletion.mockReturnValue({
|
|
276
|
+
...mockCommandCompletion,
|
|
277
|
+
showSuggestions: true,
|
|
278
|
+
suggestions: [
|
|
279
|
+
{ label: 'memory', value: 'memory' },
|
|
280
|
+
{ label: 'memcache', value: 'memcache' },
|
|
281
|
+
],
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
props.buffer.setText('/mem');
|
|
285
|
+
|
|
286
|
+
const { stdin, unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
287
|
+
await wait();
|
|
288
|
+
|
|
289
|
+
// Test up arrow
|
|
290
|
+
stdin.write('\u001B[A'); // Up arrow
|
|
291
|
+
await wait();
|
|
292
|
+
|
|
293
|
+
stdin.write('\u0010'); // Ctrl+P
|
|
294
|
+
await wait();
|
|
295
|
+
expect(mockCommandCompletion.navigateUp).toHaveBeenCalledTimes(2);
|
|
296
|
+
expect(mockCommandCompletion.navigateDown).not.toHaveBeenCalled();
|
|
297
|
+
|
|
298
|
+
unmount();
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
it('should call completion.navigateDown for both down arrow and Ctrl+N when suggestions are showing', async () => {
|
|
302
|
+
mockedUseCommandCompletion.mockReturnValue({
|
|
303
|
+
...mockCommandCompletion,
|
|
304
|
+
showSuggestions: true,
|
|
305
|
+
suggestions: [
|
|
306
|
+
{ label: 'memory', value: 'memory' },
|
|
307
|
+
{ label: 'memcache', value: 'memcache' },
|
|
308
|
+
],
|
|
309
|
+
});
|
|
310
|
+
props.buffer.setText('/mem');
|
|
311
|
+
|
|
312
|
+
const { stdin, unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
313
|
+
await wait();
|
|
314
|
+
|
|
315
|
+
// Test down arrow
|
|
316
|
+
stdin.write('\u001B[B'); // Down arrow
|
|
317
|
+
await wait();
|
|
318
|
+
|
|
319
|
+
stdin.write('\u000E'); // Ctrl+N
|
|
320
|
+
await wait();
|
|
321
|
+
expect(mockCommandCompletion.navigateDown).toHaveBeenCalledTimes(2);
|
|
322
|
+
expect(mockCommandCompletion.navigateUp).not.toHaveBeenCalled();
|
|
323
|
+
|
|
324
|
+
unmount();
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
it('should NOT call completion navigation when suggestions are not showing', async () => {
|
|
328
|
+
mockedUseCommandCompletion.mockReturnValue({
|
|
329
|
+
...mockCommandCompletion,
|
|
330
|
+
showSuggestions: false,
|
|
331
|
+
});
|
|
332
|
+
props.buffer.setText('some text');
|
|
333
|
+
|
|
334
|
+
const { stdin, unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
335
|
+
await wait();
|
|
336
|
+
|
|
337
|
+
stdin.write('\u001B[A'); // Up arrow
|
|
338
|
+
await wait();
|
|
339
|
+
stdin.write('\u001B[B'); // Down arrow
|
|
340
|
+
await wait();
|
|
341
|
+
stdin.write('\u0010'); // Ctrl+P
|
|
342
|
+
await wait();
|
|
343
|
+
stdin.write('\u000E'); // Ctrl+N
|
|
344
|
+
await wait();
|
|
345
|
+
|
|
346
|
+
expect(mockCommandCompletion.navigateUp).not.toHaveBeenCalled();
|
|
347
|
+
expect(mockCommandCompletion.navigateDown).not.toHaveBeenCalled();
|
|
348
|
+
unmount();
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
describe('clipboard image paste', () => {
|
|
352
|
+
beforeEach(() => {
|
|
353
|
+
vi.mocked(clipboardUtils.clipboardHasImage).mockResolvedValue(false);
|
|
354
|
+
vi.mocked(clipboardUtils.saveClipboardImage).mockResolvedValue(null);
|
|
355
|
+
vi.mocked(clipboardUtils.cleanupOldClipboardImages).mockResolvedValue(
|
|
356
|
+
undefined,
|
|
357
|
+
);
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
it('should handle Ctrl+V when clipboard has an image', async () => {
|
|
361
|
+
vi.mocked(clipboardUtils.clipboardHasImage).mockResolvedValue(true);
|
|
362
|
+
vi.mocked(clipboardUtils.saveClipboardImage).mockResolvedValue(
|
|
363
|
+
'/test/.gemini-clipboard/clipboard-123.png',
|
|
364
|
+
);
|
|
365
|
+
|
|
366
|
+
const { stdin, unmount } = renderWithProviders(
|
|
367
|
+
<InputPrompt {...props} />,
|
|
368
|
+
);
|
|
369
|
+
await wait();
|
|
370
|
+
|
|
371
|
+
// Send Ctrl+V
|
|
372
|
+
stdin.write('\x16'); // Ctrl+V
|
|
373
|
+
await wait();
|
|
374
|
+
|
|
375
|
+
expect(clipboardUtils.clipboardHasImage).toHaveBeenCalled();
|
|
376
|
+
expect(clipboardUtils.saveClipboardImage).toHaveBeenCalledWith(
|
|
377
|
+
props.config.getTargetDir(),
|
|
378
|
+
);
|
|
379
|
+
expect(clipboardUtils.cleanupOldClipboardImages).toHaveBeenCalledWith(
|
|
380
|
+
props.config.getTargetDir(),
|
|
381
|
+
);
|
|
382
|
+
expect(mockBuffer.replaceRangeByOffset).toHaveBeenCalled();
|
|
383
|
+
unmount();
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
it('should not insert anything when clipboard has no image', async () => {
|
|
387
|
+
vi.mocked(clipboardUtils.clipboardHasImage).mockResolvedValue(false);
|
|
388
|
+
|
|
389
|
+
const { stdin, unmount } = renderWithProviders(
|
|
390
|
+
<InputPrompt {...props} />,
|
|
391
|
+
);
|
|
392
|
+
await wait();
|
|
393
|
+
|
|
394
|
+
stdin.write('\x16'); // Ctrl+V
|
|
395
|
+
await wait();
|
|
396
|
+
|
|
397
|
+
expect(clipboardUtils.clipboardHasImage).toHaveBeenCalled();
|
|
398
|
+
expect(clipboardUtils.saveClipboardImage).not.toHaveBeenCalled();
|
|
399
|
+
expect(mockBuffer.setText).not.toHaveBeenCalled();
|
|
400
|
+
unmount();
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
it('should handle image save failure gracefully', async () => {
|
|
404
|
+
vi.mocked(clipboardUtils.clipboardHasImage).mockResolvedValue(true);
|
|
405
|
+
vi.mocked(clipboardUtils.saveClipboardImage).mockResolvedValue(null);
|
|
406
|
+
|
|
407
|
+
const { stdin, unmount } = renderWithProviders(
|
|
408
|
+
<InputPrompt {...props} />,
|
|
409
|
+
);
|
|
410
|
+
await wait();
|
|
411
|
+
|
|
412
|
+
stdin.write('\x16'); // Ctrl+V
|
|
413
|
+
await wait();
|
|
414
|
+
|
|
415
|
+
expect(clipboardUtils.saveClipboardImage).toHaveBeenCalled();
|
|
416
|
+
expect(mockBuffer.setText).not.toHaveBeenCalled();
|
|
417
|
+
unmount();
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
it('should insert image path at cursor position with proper spacing', async () => {
|
|
421
|
+
const imagePath = path.join(
|
|
422
|
+
'test',
|
|
423
|
+
'.gemini-clipboard',
|
|
424
|
+
'clipboard-456.png',
|
|
425
|
+
);
|
|
426
|
+
vi.mocked(clipboardUtils.clipboardHasImage).mockResolvedValue(true);
|
|
427
|
+
vi.mocked(clipboardUtils.saveClipboardImage).mockResolvedValue(imagePath);
|
|
428
|
+
|
|
429
|
+
// Set initial text and cursor position
|
|
430
|
+
mockBuffer.text = 'Hello world';
|
|
431
|
+
mockBuffer.cursor = [0, 5]; // Cursor after "Hello"
|
|
432
|
+
mockBuffer.lines = ['Hello world'];
|
|
433
|
+
mockBuffer.replaceRangeByOffset = vi.fn();
|
|
434
|
+
|
|
435
|
+
const { stdin, unmount } = renderWithProviders(
|
|
436
|
+
<InputPrompt {...props} />,
|
|
437
|
+
);
|
|
438
|
+
await wait();
|
|
439
|
+
|
|
440
|
+
stdin.write('\x16'); // Ctrl+V
|
|
441
|
+
await wait();
|
|
442
|
+
|
|
443
|
+
// Should insert at cursor position with spaces
|
|
444
|
+
expect(mockBuffer.replaceRangeByOffset).toHaveBeenCalled();
|
|
445
|
+
|
|
446
|
+
// Get the actual call to see what path was used
|
|
447
|
+
const actualCall = vi.mocked(mockBuffer.replaceRangeByOffset).mock
|
|
448
|
+
.calls[0];
|
|
449
|
+
expect(actualCall[0]).toBe(5); // start offset
|
|
450
|
+
expect(actualCall[1]).toBe(5); // end offset
|
|
451
|
+
expect(actualCall[2]).toBe(
|
|
452
|
+
' @' + path.relative(path.join('test', 'project', 'src'), imagePath),
|
|
453
|
+
);
|
|
454
|
+
unmount();
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
it('should handle errors during clipboard operations', async () => {
|
|
458
|
+
const consoleErrorSpy = vi
|
|
459
|
+
.spyOn(console, 'error')
|
|
460
|
+
.mockImplementation(() => {});
|
|
461
|
+
vi.mocked(clipboardUtils.clipboardHasImage).mockRejectedValue(
|
|
462
|
+
new Error('Clipboard error'),
|
|
463
|
+
);
|
|
464
|
+
|
|
465
|
+
const { stdin, unmount } = renderWithProviders(
|
|
466
|
+
<InputPrompt {...props} />,
|
|
467
|
+
);
|
|
468
|
+
await wait();
|
|
469
|
+
|
|
470
|
+
stdin.write('\x16'); // Ctrl+V
|
|
471
|
+
await wait();
|
|
472
|
+
|
|
473
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith(
|
|
474
|
+
'Error handling clipboard image:',
|
|
475
|
+
expect.any(Error),
|
|
476
|
+
);
|
|
477
|
+
expect(mockBuffer.setText).not.toHaveBeenCalled();
|
|
478
|
+
|
|
479
|
+
consoleErrorSpy.mockRestore();
|
|
480
|
+
unmount();
|
|
481
|
+
});
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
it('should complete a partial parent command', async () => {
|
|
485
|
+
// SCENARIO: /mem -> Tab
|
|
486
|
+
mockedUseCommandCompletion.mockReturnValue({
|
|
487
|
+
...mockCommandCompletion,
|
|
488
|
+
showSuggestions: true,
|
|
489
|
+
suggestions: [{ label: 'memory', value: 'memory', description: '...' }],
|
|
490
|
+
activeSuggestionIndex: 0,
|
|
491
|
+
});
|
|
492
|
+
props.buffer.setText('/mem');
|
|
493
|
+
|
|
494
|
+
const { stdin, unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
495
|
+
await wait();
|
|
496
|
+
|
|
497
|
+
stdin.write('\t'); // Press Tab
|
|
498
|
+
await wait();
|
|
499
|
+
|
|
500
|
+
expect(mockCommandCompletion.handleAutocomplete).toHaveBeenCalledWith(0);
|
|
501
|
+
unmount();
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
it('should append a sub-command when the parent command is already complete', async () => {
|
|
505
|
+
// SCENARIO: /memory -> Tab (to accept 'add')
|
|
506
|
+
mockedUseCommandCompletion.mockReturnValue({
|
|
507
|
+
...mockCommandCompletion,
|
|
508
|
+
showSuggestions: true,
|
|
509
|
+
suggestions: [
|
|
510
|
+
{ label: 'show', value: 'show' },
|
|
511
|
+
{ label: 'add', value: 'add' },
|
|
512
|
+
],
|
|
513
|
+
activeSuggestionIndex: 1, // 'add' is highlighted
|
|
514
|
+
});
|
|
515
|
+
props.buffer.setText('/memory ');
|
|
516
|
+
|
|
517
|
+
const { stdin, unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
518
|
+
await wait();
|
|
519
|
+
|
|
520
|
+
stdin.write('\t'); // Press Tab
|
|
521
|
+
await wait();
|
|
522
|
+
|
|
523
|
+
expect(mockCommandCompletion.handleAutocomplete).toHaveBeenCalledWith(1);
|
|
524
|
+
unmount();
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
it('should handle the "backspace" edge case correctly', async () => {
|
|
528
|
+
// SCENARIO: /memory -> Backspace -> /memory -> Tab (to accept 'show')
|
|
529
|
+
mockedUseCommandCompletion.mockReturnValue({
|
|
530
|
+
...mockCommandCompletion,
|
|
531
|
+
showSuggestions: true,
|
|
532
|
+
suggestions: [
|
|
533
|
+
{ label: 'show', value: 'show' },
|
|
534
|
+
{ label: 'add', value: 'add' },
|
|
535
|
+
],
|
|
536
|
+
activeSuggestionIndex: 0, // 'show' is highlighted
|
|
537
|
+
});
|
|
538
|
+
// The user has backspaced, so the query is now just '/memory'
|
|
539
|
+
props.buffer.setText('/memory');
|
|
540
|
+
|
|
541
|
+
const { stdin, unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
542
|
+
await wait();
|
|
543
|
+
|
|
544
|
+
stdin.write('\t'); // Press Tab
|
|
545
|
+
await wait();
|
|
546
|
+
|
|
547
|
+
// It should NOT become '/show'. It should correctly become '/memory show'.
|
|
548
|
+
expect(mockCommandCompletion.handleAutocomplete).toHaveBeenCalledWith(0);
|
|
549
|
+
unmount();
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
it('should complete a partial argument for a command', async () => {
|
|
553
|
+
// SCENARIO: /chat resume fi- -> Tab
|
|
554
|
+
mockedUseCommandCompletion.mockReturnValue({
|
|
555
|
+
...mockCommandCompletion,
|
|
556
|
+
showSuggestions: true,
|
|
557
|
+
suggestions: [{ label: 'fix-foo', value: 'fix-foo' }],
|
|
558
|
+
activeSuggestionIndex: 0,
|
|
559
|
+
});
|
|
560
|
+
props.buffer.setText('/chat resume fi-');
|
|
561
|
+
|
|
562
|
+
const { stdin, unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
563
|
+
await wait();
|
|
564
|
+
|
|
565
|
+
stdin.write('\t'); // Press Tab
|
|
566
|
+
await wait();
|
|
567
|
+
|
|
568
|
+
expect(mockCommandCompletion.handleAutocomplete).toHaveBeenCalledWith(0);
|
|
569
|
+
unmount();
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
it('should autocomplete on Enter when suggestions are active, without submitting', async () => {
|
|
573
|
+
mockedUseCommandCompletion.mockReturnValue({
|
|
574
|
+
...mockCommandCompletion,
|
|
575
|
+
showSuggestions: true,
|
|
576
|
+
suggestions: [{ label: 'memory', value: 'memory' }],
|
|
577
|
+
activeSuggestionIndex: 0,
|
|
578
|
+
});
|
|
579
|
+
props.buffer.setText('/mem');
|
|
580
|
+
|
|
581
|
+
const { stdin, unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
582
|
+
await wait();
|
|
583
|
+
|
|
584
|
+
stdin.write('\r');
|
|
585
|
+
await wait();
|
|
586
|
+
|
|
587
|
+
// The app should autocomplete the text, NOT submit.
|
|
588
|
+
expect(mockCommandCompletion.handleAutocomplete).toHaveBeenCalledWith(0);
|
|
589
|
+
|
|
590
|
+
expect(props.onSubmit).not.toHaveBeenCalled();
|
|
591
|
+
unmount();
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
it('should complete a command based on its altNames', async () => {
|
|
595
|
+
props.slashCommands = [
|
|
596
|
+
{
|
|
597
|
+
name: 'help',
|
|
598
|
+
altNames: ['?'],
|
|
599
|
+
kind: CommandKind.BUILT_IN,
|
|
600
|
+
description: '...',
|
|
601
|
+
},
|
|
602
|
+
];
|
|
603
|
+
|
|
604
|
+
mockedUseCommandCompletion.mockReturnValue({
|
|
605
|
+
...mockCommandCompletion,
|
|
606
|
+
showSuggestions: true,
|
|
607
|
+
suggestions: [{ label: 'help', value: 'help' }],
|
|
608
|
+
activeSuggestionIndex: 0,
|
|
609
|
+
});
|
|
610
|
+
props.buffer.setText('/?');
|
|
611
|
+
|
|
612
|
+
const { stdin, unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
613
|
+
await wait();
|
|
614
|
+
|
|
615
|
+
stdin.write('\t'); // Press Tab for autocomplete
|
|
616
|
+
await wait();
|
|
617
|
+
|
|
618
|
+
expect(mockCommandCompletion.handleAutocomplete).toHaveBeenCalledWith(0);
|
|
619
|
+
unmount();
|
|
620
|
+
});
|
|
621
|
+
|
|
622
|
+
it('should not submit on Enter when the buffer is empty or only contains whitespace', async () => {
|
|
623
|
+
props.buffer.setText(' '); // Set buffer to whitespace
|
|
624
|
+
|
|
625
|
+
const { stdin, unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
626
|
+
await wait();
|
|
627
|
+
|
|
628
|
+
stdin.write('\r'); // Press Enter
|
|
629
|
+
await wait();
|
|
630
|
+
|
|
631
|
+
expect(props.onSubmit).not.toHaveBeenCalled();
|
|
632
|
+
unmount();
|
|
633
|
+
});
|
|
634
|
+
|
|
635
|
+
it('should submit directly on Enter when isPerfectMatch is true', async () => {
|
|
636
|
+
mockedUseCommandCompletion.mockReturnValue({
|
|
637
|
+
...mockCommandCompletion,
|
|
638
|
+
showSuggestions: false,
|
|
639
|
+
isPerfectMatch: true,
|
|
640
|
+
});
|
|
641
|
+
props.buffer.setText('/clear');
|
|
642
|
+
|
|
643
|
+
const { stdin, unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
644
|
+
await wait();
|
|
645
|
+
|
|
646
|
+
stdin.write('\r');
|
|
647
|
+
await wait();
|
|
648
|
+
|
|
649
|
+
expect(props.onSubmit).toHaveBeenCalledWith('/clear');
|
|
650
|
+
unmount();
|
|
651
|
+
});
|
|
652
|
+
|
|
653
|
+
it('should submit directly on Enter when a complete leaf command is typed', async () => {
|
|
654
|
+
mockedUseCommandCompletion.mockReturnValue({
|
|
655
|
+
...mockCommandCompletion,
|
|
656
|
+
showSuggestions: false,
|
|
657
|
+
isPerfectMatch: false, // Added explicit isPerfectMatch false
|
|
658
|
+
});
|
|
659
|
+
props.buffer.setText('/clear');
|
|
660
|
+
|
|
661
|
+
const { stdin, unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
662
|
+
await wait();
|
|
663
|
+
|
|
664
|
+
stdin.write('\r');
|
|
665
|
+
await wait();
|
|
666
|
+
|
|
667
|
+
expect(props.onSubmit).toHaveBeenCalledWith('/clear');
|
|
668
|
+
unmount();
|
|
669
|
+
});
|
|
670
|
+
|
|
671
|
+
it('should autocomplete an @-path on Enter without submitting', async () => {
|
|
672
|
+
mockedUseCommandCompletion.mockReturnValue({
|
|
673
|
+
...mockCommandCompletion,
|
|
674
|
+
showSuggestions: true,
|
|
675
|
+
suggestions: [{ label: 'index.ts', value: 'index.ts' }],
|
|
676
|
+
activeSuggestionIndex: 0,
|
|
677
|
+
});
|
|
678
|
+
props.buffer.setText('@src/components/');
|
|
679
|
+
|
|
680
|
+
const { stdin, unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
681
|
+
await wait();
|
|
682
|
+
|
|
683
|
+
stdin.write('\r');
|
|
684
|
+
await wait();
|
|
685
|
+
|
|
686
|
+
expect(mockCommandCompletion.handleAutocomplete).toHaveBeenCalledWith(0);
|
|
687
|
+
expect(props.onSubmit).not.toHaveBeenCalled();
|
|
688
|
+
unmount();
|
|
689
|
+
});
|
|
690
|
+
|
|
691
|
+
it('should add a newline on enter when the line ends with a backslash', async () => {
|
|
692
|
+
// This test simulates multi-line input, not submission
|
|
693
|
+
mockBuffer.text = 'first line\\';
|
|
694
|
+
mockBuffer.cursor = [0, 11];
|
|
695
|
+
mockBuffer.lines = ['first line\\'];
|
|
696
|
+
|
|
697
|
+
const { stdin, unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
698
|
+
await wait();
|
|
699
|
+
|
|
700
|
+
stdin.write('\r');
|
|
701
|
+
await wait();
|
|
702
|
+
|
|
703
|
+
expect(props.onSubmit).not.toHaveBeenCalled();
|
|
704
|
+
expect(props.buffer.backspace).toHaveBeenCalled();
|
|
705
|
+
expect(props.buffer.newline).toHaveBeenCalled();
|
|
706
|
+
unmount();
|
|
707
|
+
});
|
|
708
|
+
|
|
709
|
+
it('should clear the buffer on Ctrl+C if it has text', async () => {
|
|
710
|
+
props.buffer.setText('some text to clear');
|
|
711
|
+
const { stdin, unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
712
|
+
await wait();
|
|
713
|
+
|
|
714
|
+
stdin.write('\x03'); // Ctrl+C character
|
|
715
|
+
await wait();
|
|
716
|
+
|
|
717
|
+
expect(props.buffer.setText).toHaveBeenCalledWith('');
|
|
718
|
+
expect(mockCommandCompletion.resetCompletionState).toHaveBeenCalled();
|
|
719
|
+
expect(props.onSubmit).not.toHaveBeenCalled();
|
|
720
|
+
unmount();
|
|
721
|
+
});
|
|
722
|
+
|
|
723
|
+
it('should NOT clear the buffer on Ctrl+C if it is empty', async () => {
|
|
724
|
+
props.buffer.text = '';
|
|
725
|
+
const { stdin, unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
726
|
+
await wait();
|
|
727
|
+
|
|
728
|
+
stdin.write('\x03'); // Ctrl+C character
|
|
729
|
+
await wait();
|
|
730
|
+
|
|
731
|
+
expect(props.buffer.setText).not.toHaveBeenCalled();
|
|
732
|
+
unmount();
|
|
733
|
+
});
|
|
734
|
+
|
|
735
|
+
describe('cursor-based completion trigger', () => {
|
|
736
|
+
it('should trigger completion when cursor is after @ without spaces', async () => {
|
|
737
|
+
// Set up buffer state
|
|
738
|
+
mockBuffer.text = '@src/components';
|
|
739
|
+
mockBuffer.lines = ['@src/components'];
|
|
740
|
+
mockBuffer.cursor = [0, 15];
|
|
741
|
+
|
|
742
|
+
mockedUseCommandCompletion.mockReturnValue({
|
|
743
|
+
...mockCommandCompletion,
|
|
744
|
+
showSuggestions: true,
|
|
745
|
+
suggestions: [{ label: 'Button.tsx', value: 'Button.tsx' }],
|
|
746
|
+
});
|
|
747
|
+
|
|
748
|
+
const { unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
749
|
+
await wait();
|
|
750
|
+
|
|
751
|
+
// Verify useCompletion was called with correct signature
|
|
752
|
+
expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
|
|
753
|
+
mockBuffer,
|
|
754
|
+
['/test/project/src'],
|
|
755
|
+
path.join('test', 'project', 'src'),
|
|
756
|
+
mockSlashCommands,
|
|
757
|
+
mockCommandContext,
|
|
758
|
+
false,
|
|
759
|
+
expect.any(Object),
|
|
760
|
+
);
|
|
761
|
+
|
|
762
|
+
unmount();
|
|
763
|
+
});
|
|
764
|
+
|
|
765
|
+
it('should trigger completion when cursor is after / without spaces', async () => {
|
|
766
|
+
mockBuffer.text = '/memory';
|
|
767
|
+
mockBuffer.lines = ['/memory'];
|
|
768
|
+
mockBuffer.cursor = [0, 7];
|
|
769
|
+
|
|
770
|
+
mockedUseCommandCompletion.mockReturnValue({
|
|
771
|
+
...mockCommandCompletion,
|
|
772
|
+
showSuggestions: true,
|
|
773
|
+
suggestions: [{ label: 'show', value: 'show' }],
|
|
774
|
+
});
|
|
775
|
+
|
|
776
|
+
const { unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
777
|
+
await wait();
|
|
778
|
+
|
|
779
|
+
expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
|
|
780
|
+
mockBuffer,
|
|
781
|
+
['/test/project/src'],
|
|
782
|
+
path.join('test', 'project', 'src'),
|
|
783
|
+
mockSlashCommands,
|
|
784
|
+
mockCommandContext,
|
|
785
|
+
false,
|
|
786
|
+
expect.any(Object),
|
|
787
|
+
);
|
|
788
|
+
|
|
789
|
+
unmount();
|
|
790
|
+
});
|
|
791
|
+
|
|
792
|
+
it('should NOT trigger completion when cursor is after space following @', async () => {
|
|
793
|
+
mockBuffer.text = '@src/file.ts hello';
|
|
794
|
+
mockBuffer.lines = ['@src/file.ts hello'];
|
|
795
|
+
mockBuffer.cursor = [0, 18];
|
|
796
|
+
|
|
797
|
+
mockedUseCommandCompletion.mockReturnValue({
|
|
798
|
+
...mockCommandCompletion,
|
|
799
|
+
showSuggestions: false,
|
|
800
|
+
suggestions: [],
|
|
801
|
+
});
|
|
802
|
+
|
|
803
|
+
const { unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
804
|
+
await wait();
|
|
805
|
+
|
|
806
|
+
expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
|
|
807
|
+
mockBuffer,
|
|
808
|
+
['/test/project/src'],
|
|
809
|
+
path.join('test', 'project', 'src'),
|
|
810
|
+
mockSlashCommands,
|
|
811
|
+
mockCommandContext,
|
|
812
|
+
false,
|
|
813
|
+
expect.any(Object),
|
|
814
|
+
);
|
|
815
|
+
|
|
816
|
+
unmount();
|
|
817
|
+
});
|
|
818
|
+
|
|
819
|
+
it('should NOT trigger completion when cursor is after space following /', async () => {
|
|
820
|
+
mockBuffer.text = '/memory add';
|
|
821
|
+
mockBuffer.lines = ['/memory add'];
|
|
822
|
+
mockBuffer.cursor = [0, 11];
|
|
823
|
+
|
|
824
|
+
mockedUseCommandCompletion.mockReturnValue({
|
|
825
|
+
...mockCommandCompletion,
|
|
826
|
+
showSuggestions: false,
|
|
827
|
+
suggestions: [],
|
|
828
|
+
});
|
|
829
|
+
|
|
830
|
+
const { unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
831
|
+
await wait();
|
|
832
|
+
|
|
833
|
+
expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
|
|
834
|
+
mockBuffer,
|
|
835
|
+
['/test/project/src'],
|
|
836
|
+
path.join('test', 'project', 'src'),
|
|
837
|
+
mockSlashCommands,
|
|
838
|
+
mockCommandContext,
|
|
839
|
+
false,
|
|
840
|
+
expect.any(Object),
|
|
841
|
+
);
|
|
842
|
+
|
|
843
|
+
unmount();
|
|
844
|
+
});
|
|
845
|
+
|
|
846
|
+
it('should NOT trigger completion when cursor is not after @ or /', async () => {
|
|
847
|
+
mockBuffer.text = 'hello world';
|
|
848
|
+
mockBuffer.lines = ['hello world'];
|
|
849
|
+
mockBuffer.cursor = [0, 5];
|
|
850
|
+
|
|
851
|
+
mockedUseCommandCompletion.mockReturnValue({
|
|
852
|
+
...mockCommandCompletion,
|
|
853
|
+
showSuggestions: false,
|
|
854
|
+
suggestions: [],
|
|
855
|
+
});
|
|
856
|
+
|
|
857
|
+
const { unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
858
|
+
await wait();
|
|
859
|
+
|
|
860
|
+
expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
|
|
861
|
+
mockBuffer,
|
|
862
|
+
['/test/project/src'],
|
|
863
|
+
path.join('test', 'project', 'src'),
|
|
864
|
+
mockSlashCommands,
|
|
865
|
+
mockCommandContext,
|
|
866
|
+
false,
|
|
867
|
+
expect.any(Object),
|
|
868
|
+
);
|
|
869
|
+
|
|
870
|
+
unmount();
|
|
871
|
+
});
|
|
872
|
+
|
|
873
|
+
it('should handle multiline text correctly', async () => {
|
|
874
|
+
mockBuffer.text = 'first line\n/memory';
|
|
875
|
+
mockBuffer.lines = ['first line', '/memory'];
|
|
876
|
+
mockBuffer.cursor = [1, 7];
|
|
877
|
+
|
|
878
|
+
mockedUseCommandCompletion.mockReturnValue({
|
|
879
|
+
...mockCommandCompletion,
|
|
880
|
+
showSuggestions: false,
|
|
881
|
+
suggestions: [],
|
|
882
|
+
});
|
|
883
|
+
|
|
884
|
+
const { unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
885
|
+
await wait();
|
|
886
|
+
|
|
887
|
+
// Verify useCompletion was called with the buffer
|
|
888
|
+
expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
|
|
889
|
+
mockBuffer,
|
|
890
|
+
['/test/project/src'],
|
|
891
|
+
path.join('test', 'project', 'src'),
|
|
892
|
+
mockSlashCommands,
|
|
893
|
+
mockCommandContext,
|
|
894
|
+
false,
|
|
895
|
+
expect.any(Object),
|
|
896
|
+
);
|
|
897
|
+
|
|
898
|
+
unmount();
|
|
899
|
+
});
|
|
900
|
+
|
|
901
|
+
it('should handle single line slash command correctly', async () => {
|
|
902
|
+
mockBuffer.text = '/memory';
|
|
903
|
+
mockBuffer.lines = ['/memory'];
|
|
904
|
+
mockBuffer.cursor = [0, 7];
|
|
905
|
+
|
|
906
|
+
mockedUseCommandCompletion.mockReturnValue({
|
|
907
|
+
...mockCommandCompletion,
|
|
908
|
+
showSuggestions: true,
|
|
909
|
+
suggestions: [{ label: 'show', value: 'show' }],
|
|
910
|
+
});
|
|
911
|
+
|
|
912
|
+
const { unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
913
|
+
await wait();
|
|
914
|
+
|
|
915
|
+
expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
|
|
916
|
+
mockBuffer,
|
|
917
|
+
['/test/project/src'],
|
|
918
|
+
path.join('test', 'project', 'src'),
|
|
919
|
+
mockSlashCommands,
|
|
920
|
+
mockCommandContext,
|
|
921
|
+
false,
|
|
922
|
+
expect.any(Object),
|
|
923
|
+
);
|
|
924
|
+
|
|
925
|
+
unmount();
|
|
926
|
+
});
|
|
927
|
+
|
|
928
|
+
it('should handle Unicode characters (emojis) correctly in paths', async () => {
|
|
929
|
+
// Test with emoji in path after @
|
|
930
|
+
mockBuffer.text = '@src/file👍.txt';
|
|
931
|
+
mockBuffer.lines = ['@src/file👍.txt'];
|
|
932
|
+
mockBuffer.cursor = [0, 14]; // After the emoji character
|
|
933
|
+
|
|
934
|
+
mockedUseCommandCompletion.mockReturnValue({
|
|
935
|
+
...mockCommandCompletion,
|
|
936
|
+
showSuggestions: true,
|
|
937
|
+
suggestions: [{ label: 'file👍.txt', value: 'file👍.txt' }],
|
|
938
|
+
});
|
|
939
|
+
|
|
940
|
+
const { unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
941
|
+
await wait();
|
|
942
|
+
|
|
943
|
+
expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
|
|
944
|
+
mockBuffer,
|
|
945
|
+
['/test/project/src'],
|
|
946
|
+
path.join('test', 'project', 'src'),
|
|
947
|
+
mockSlashCommands,
|
|
948
|
+
mockCommandContext,
|
|
949
|
+
false,
|
|
950
|
+
expect.any(Object),
|
|
951
|
+
);
|
|
952
|
+
|
|
953
|
+
unmount();
|
|
954
|
+
});
|
|
955
|
+
|
|
956
|
+
it('should handle Unicode characters with spaces after them', async () => {
|
|
957
|
+
// Test with emoji followed by space - should NOT trigger completion
|
|
958
|
+
mockBuffer.text = '@src/file👍.txt hello';
|
|
959
|
+
mockBuffer.lines = ['@src/file👍.txt hello'];
|
|
960
|
+
mockBuffer.cursor = [0, 20]; // After the space
|
|
961
|
+
|
|
962
|
+
mockedUseCommandCompletion.mockReturnValue({
|
|
963
|
+
...mockCommandCompletion,
|
|
964
|
+
showSuggestions: false,
|
|
965
|
+
suggestions: [],
|
|
966
|
+
});
|
|
967
|
+
|
|
968
|
+
const { unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
969
|
+
await wait();
|
|
970
|
+
|
|
971
|
+
expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
|
|
972
|
+
mockBuffer,
|
|
973
|
+
['/test/project/src'],
|
|
974
|
+
path.join('test', 'project', 'src'),
|
|
975
|
+
mockSlashCommands,
|
|
976
|
+
mockCommandContext,
|
|
977
|
+
false,
|
|
978
|
+
expect.any(Object),
|
|
979
|
+
);
|
|
980
|
+
|
|
981
|
+
unmount();
|
|
982
|
+
});
|
|
983
|
+
|
|
984
|
+
it('should handle escaped spaces in paths correctly', async () => {
|
|
985
|
+
// Test with escaped space in path - should trigger completion
|
|
986
|
+
mockBuffer.text = '@src/my\\ file.txt';
|
|
987
|
+
mockBuffer.lines = ['@src/my\\ file.txt'];
|
|
988
|
+
mockBuffer.cursor = [0, 16]; // After the escaped space and filename
|
|
989
|
+
|
|
990
|
+
mockedUseCommandCompletion.mockReturnValue({
|
|
991
|
+
...mockCommandCompletion,
|
|
992
|
+
showSuggestions: true,
|
|
993
|
+
suggestions: [{ label: 'my file.txt', value: 'my file.txt' }],
|
|
994
|
+
});
|
|
995
|
+
|
|
996
|
+
const { unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
997
|
+
await wait();
|
|
998
|
+
|
|
999
|
+
expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
|
|
1000
|
+
mockBuffer,
|
|
1001
|
+
['/test/project/src'],
|
|
1002
|
+
path.join('test', 'project', 'src'),
|
|
1003
|
+
mockSlashCommands,
|
|
1004
|
+
mockCommandContext,
|
|
1005
|
+
false,
|
|
1006
|
+
expect.any(Object),
|
|
1007
|
+
);
|
|
1008
|
+
|
|
1009
|
+
unmount();
|
|
1010
|
+
});
|
|
1011
|
+
|
|
1012
|
+
it('should NOT trigger completion after unescaped space following escaped space', async () => {
|
|
1013
|
+
// Test: @path/my\ file.txt hello (unescaped space after escaped space)
|
|
1014
|
+
mockBuffer.text = '@path/my\\ file.txt hello';
|
|
1015
|
+
mockBuffer.lines = ['@path/my\\ file.txt hello'];
|
|
1016
|
+
mockBuffer.cursor = [0, 24]; // After "hello"
|
|
1017
|
+
|
|
1018
|
+
mockedUseCommandCompletion.mockReturnValue({
|
|
1019
|
+
...mockCommandCompletion,
|
|
1020
|
+
showSuggestions: false,
|
|
1021
|
+
suggestions: [],
|
|
1022
|
+
});
|
|
1023
|
+
|
|
1024
|
+
const { unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
1025
|
+
await wait();
|
|
1026
|
+
|
|
1027
|
+
expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
|
|
1028
|
+
mockBuffer,
|
|
1029
|
+
['/test/project/src'],
|
|
1030
|
+
path.join('test', 'project', 'src'),
|
|
1031
|
+
mockSlashCommands,
|
|
1032
|
+
mockCommandContext,
|
|
1033
|
+
false,
|
|
1034
|
+
expect.any(Object),
|
|
1035
|
+
);
|
|
1036
|
+
|
|
1037
|
+
unmount();
|
|
1038
|
+
});
|
|
1039
|
+
|
|
1040
|
+
it('should handle multiple escaped spaces in paths', async () => {
|
|
1041
|
+
// Test with multiple escaped spaces
|
|
1042
|
+
mockBuffer.text = '@docs/my\\ long\\ file\\ name.md';
|
|
1043
|
+
mockBuffer.lines = ['@docs/my\\ long\\ file\\ name.md'];
|
|
1044
|
+
mockBuffer.cursor = [0, 29]; // At the end
|
|
1045
|
+
|
|
1046
|
+
mockedUseCommandCompletion.mockReturnValue({
|
|
1047
|
+
...mockCommandCompletion,
|
|
1048
|
+
showSuggestions: true,
|
|
1049
|
+
suggestions: [
|
|
1050
|
+
{ label: 'my long file name.md', value: 'my long file name.md' },
|
|
1051
|
+
],
|
|
1052
|
+
});
|
|
1053
|
+
|
|
1054
|
+
const { unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
1055
|
+
await wait();
|
|
1056
|
+
|
|
1057
|
+
expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
|
|
1058
|
+
mockBuffer,
|
|
1059
|
+
['/test/project/src'],
|
|
1060
|
+
path.join('test', 'project', 'src'),
|
|
1061
|
+
mockSlashCommands,
|
|
1062
|
+
mockCommandContext,
|
|
1063
|
+
false,
|
|
1064
|
+
expect.any(Object),
|
|
1065
|
+
);
|
|
1066
|
+
|
|
1067
|
+
unmount();
|
|
1068
|
+
});
|
|
1069
|
+
|
|
1070
|
+
it('should handle escaped spaces in slash commands', async () => {
|
|
1071
|
+
// Test escaped spaces with slash commands (though less common)
|
|
1072
|
+
mockBuffer.text = '/memory\\ test';
|
|
1073
|
+
mockBuffer.lines = ['/memory\\ test'];
|
|
1074
|
+
mockBuffer.cursor = [0, 13]; // At the end
|
|
1075
|
+
|
|
1076
|
+
mockedUseCommandCompletion.mockReturnValue({
|
|
1077
|
+
...mockCommandCompletion,
|
|
1078
|
+
showSuggestions: true,
|
|
1079
|
+
suggestions: [{ label: 'test-command', value: 'test-command' }],
|
|
1080
|
+
});
|
|
1081
|
+
|
|
1082
|
+
const { unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
1083
|
+
await wait();
|
|
1084
|
+
|
|
1085
|
+
expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
|
|
1086
|
+
mockBuffer,
|
|
1087
|
+
['/test/project/src'],
|
|
1088
|
+
path.join('test', 'project', 'src'),
|
|
1089
|
+
mockSlashCommands,
|
|
1090
|
+
mockCommandContext,
|
|
1091
|
+
false,
|
|
1092
|
+
expect.any(Object),
|
|
1093
|
+
);
|
|
1094
|
+
|
|
1095
|
+
unmount();
|
|
1096
|
+
});
|
|
1097
|
+
|
|
1098
|
+
it('should handle Unicode characters with escaped spaces', async () => {
|
|
1099
|
+
// Test combining Unicode and escaped spaces
|
|
1100
|
+
mockBuffer.text = '@' + path.join('files', 'emoji\\ 👍\\ test.txt');
|
|
1101
|
+
mockBuffer.lines = ['@' + path.join('files', 'emoji\\ 👍\\ test.txt')];
|
|
1102
|
+
mockBuffer.cursor = [0, 25]; // After the escaped space and emoji
|
|
1103
|
+
|
|
1104
|
+
mockedUseCommandCompletion.mockReturnValue({
|
|
1105
|
+
...mockCommandCompletion,
|
|
1106
|
+
showSuggestions: true,
|
|
1107
|
+
suggestions: [
|
|
1108
|
+
{ label: 'emoji 👍 test.txt', value: 'emoji 👍 test.txt' },
|
|
1109
|
+
],
|
|
1110
|
+
});
|
|
1111
|
+
|
|
1112
|
+
const { unmount } = renderWithProviders(<InputPrompt {...props} />);
|
|
1113
|
+
await wait();
|
|
1114
|
+
|
|
1115
|
+
expect(mockedUseCommandCompletion).toHaveBeenCalledWith(
|
|
1116
|
+
mockBuffer,
|
|
1117
|
+
['/test/project/src'],
|
|
1118
|
+
path.join('test', 'project', 'src'),
|
|
1119
|
+
mockSlashCommands,
|
|
1120
|
+
mockCommandContext,
|
|
1121
|
+
false,
|
|
1122
|
+
expect.any(Object),
|
|
1123
|
+
);
|
|
1124
|
+
|
|
1125
|
+
unmount();
|
|
1126
|
+
});
|
|
1127
|
+
});
|
|
1128
|
+
|
|
1129
|
+
describe('vim mode', () => {
|
|
1130
|
+
it('should not call buffer.handleInput when vim mode is enabled and vim handles the input', async () => {
|
|
1131
|
+
props.vimModeEnabled = true;
|
|
1132
|
+
props.vimHandleInput = vi.fn().mockReturnValue(true); // Mock that vim handled it.
|
|
1133
|
+
const { stdin, unmount } = renderWithProviders(
|
|
1134
|
+
<InputPrompt {...props} />,
|
|
1135
|
+
);
|
|
1136
|
+
await wait();
|
|
1137
|
+
|
|
1138
|
+
stdin.write('i');
|
|
1139
|
+
await wait();
|
|
1140
|
+
|
|
1141
|
+
expect(props.vimHandleInput).toHaveBeenCalled();
|
|
1142
|
+
expect(mockBuffer.handleInput).not.toHaveBeenCalled();
|
|
1143
|
+
unmount();
|
|
1144
|
+
});
|
|
1145
|
+
|
|
1146
|
+
it('should call buffer.handleInput when vim mode is enabled but vim does not handle the input', async () => {
|
|
1147
|
+
props.vimModeEnabled = true;
|
|
1148
|
+
props.vimHandleInput = vi.fn().mockReturnValue(false); // Mock that vim did NOT handle it.
|
|
1149
|
+
const { stdin, unmount } = renderWithProviders(
|
|
1150
|
+
<InputPrompt {...props} />,
|
|
1151
|
+
);
|
|
1152
|
+
await wait();
|
|
1153
|
+
|
|
1154
|
+
stdin.write('i');
|
|
1155
|
+
await wait();
|
|
1156
|
+
|
|
1157
|
+
expect(props.vimHandleInput).toHaveBeenCalled();
|
|
1158
|
+
expect(mockBuffer.handleInput).toHaveBeenCalled();
|
|
1159
|
+
unmount();
|
|
1160
|
+
});
|
|
1161
|
+
|
|
1162
|
+
it('should call handleInput when vim mode is disabled', async () => {
|
|
1163
|
+
// Mock vimHandleInput to return false (vim didn't handle the input)
|
|
1164
|
+
props.vimHandleInput = vi.fn().mockReturnValue(false);
|
|
1165
|
+
const { stdin, unmount } = renderWithProviders(
|
|
1166
|
+
<InputPrompt {...props} />,
|
|
1167
|
+
);
|
|
1168
|
+
await wait();
|
|
1169
|
+
|
|
1170
|
+
stdin.write('i');
|
|
1171
|
+
await wait();
|
|
1172
|
+
|
|
1173
|
+
expect(props.vimHandleInput).toHaveBeenCalled();
|
|
1174
|
+
expect(mockBuffer.handleInput).toHaveBeenCalled();
|
|
1175
|
+
unmount();
|
|
1176
|
+
});
|
|
1177
|
+
});
|
|
1178
|
+
|
|
1179
|
+
describe('unfocused paste', () => {
|
|
1180
|
+
it('should handle bracketed paste when not focused', async () => {
|
|
1181
|
+
props.focus = false;
|
|
1182
|
+
const { stdin, unmount } = renderWithProviders(
|
|
1183
|
+
<InputPrompt {...props} />,
|
|
1184
|
+
);
|
|
1185
|
+
await wait();
|
|
1186
|
+
|
|
1187
|
+
stdin.write('\x1B[200~pasted text\x1B[201~');
|
|
1188
|
+
await wait();
|
|
1189
|
+
|
|
1190
|
+
expect(mockBuffer.handleInput).toHaveBeenCalledWith(
|
|
1191
|
+
expect.objectContaining({
|
|
1192
|
+
paste: true,
|
|
1193
|
+
sequence: 'pasted text',
|
|
1194
|
+
}),
|
|
1195
|
+
);
|
|
1196
|
+
unmount();
|
|
1197
|
+
});
|
|
1198
|
+
|
|
1199
|
+
it('should ignore regular keypresses when not focused', async () => {
|
|
1200
|
+
props.focus = false;
|
|
1201
|
+
const { stdin, unmount } = renderWithProviders(
|
|
1202
|
+
<InputPrompt {...props} />,
|
|
1203
|
+
);
|
|
1204
|
+
await wait();
|
|
1205
|
+
|
|
1206
|
+
stdin.write('a');
|
|
1207
|
+
await wait();
|
|
1208
|
+
|
|
1209
|
+
expect(mockBuffer.handleInput).not.toHaveBeenCalled();
|
|
1210
|
+
unmount();
|
|
1211
|
+
});
|
|
1212
|
+
});
|
|
1213
|
+
|
|
1214
|
+
describe('multiline paste', () => {
|
|
1215
|
+
it.each([
|
|
1216
|
+
{
|
|
1217
|
+
description: 'with \n newlines',
|
|
1218
|
+
pastedText: 'This \n is \n a \n multiline \n paste.',
|
|
1219
|
+
},
|
|
1220
|
+
{
|
|
1221
|
+
description: 'with extra slashes before \n newlines',
|
|
1222
|
+
pastedText: 'This \\\n is \\\n a \\\n multiline \\\n paste.',
|
|
1223
|
+
},
|
|
1224
|
+
{
|
|
1225
|
+
description: 'with \r\n newlines',
|
|
1226
|
+
pastedText: 'This\r\nis\r\na\r\nmultiline\r\npaste.',
|
|
1227
|
+
},
|
|
1228
|
+
])('should handle multiline paste $description', async ({ pastedText }) => {
|
|
1229
|
+
const { stdin, unmount } = renderWithProviders(
|
|
1230
|
+
<InputPrompt {...props} />,
|
|
1231
|
+
);
|
|
1232
|
+
await wait();
|
|
1233
|
+
|
|
1234
|
+
// Simulate a bracketed paste event from the terminal
|
|
1235
|
+
stdin.write(`\x1b[200~${pastedText}\x1b[201~`);
|
|
1236
|
+
await wait();
|
|
1237
|
+
|
|
1238
|
+
// Verify that the buffer's handleInput was called once with the full text
|
|
1239
|
+
expect(props.buffer.handleInput).toHaveBeenCalledTimes(1);
|
|
1240
|
+
expect(props.buffer.handleInput).toHaveBeenCalledWith(
|
|
1241
|
+
expect.objectContaining({
|
|
1242
|
+
paste: true,
|
|
1243
|
+
sequence: pastedText,
|
|
1244
|
+
}),
|
|
1245
|
+
);
|
|
1246
|
+
|
|
1247
|
+
unmount();
|
|
1248
|
+
});
|
|
1249
|
+
});
|
|
1250
|
+
|
|
1251
|
+
describe('enhanced input UX - double ESC clear functionality', () => {
|
|
1252
|
+
it('should clear buffer on second ESC press', async () => {
|
|
1253
|
+
const onEscapePromptChange = vi.fn();
|
|
1254
|
+
props.onEscapePromptChange = onEscapePromptChange;
|
|
1255
|
+
props.buffer.setText('text to clear');
|
|
1256
|
+
|
|
1257
|
+
const { stdin, unmount } = renderWithProviders(
|
|
1258
|
+
<InputPrompt {...props} />,
|
|
1259
|
+
);
|
|
1260
|
+
await wait();
|
|
1261
|
+
|
|
1262
|
+
stdin.write('\x1B');
|
|
1263
|
+
await wait();
|
|
1264
|
+
|
|
1265
|
+
stdin.write('\x1B');
|
|
1266
|
+
await wait();
|
|
1267
|
+
|
|
1268
|
+
expect(props.buffer.setText).toHaveBeenCalledWith('');
|
|
1269
|
+
expect(mockCommandCompletion.resetCompletionState).toHaveBeenCalled();
|
|
1270
|
+
unmount();
|
|
1271
|
+
});
|
|
1272
|
+
|
|
1273
|
+
it('should reset escape state on any non-ESC key', async () => {
|
|
1274
|
+
const onEscapePromptChange = vi.fn();
|
|
1275
|
+
props.onEscapePromptChange = onEscapePromptChange;
|
|
1276
|
+
props.buffer.setText('some text');
|
|
1277
|
+
|
|
1278
|
+
const { stdin, unmount } = renderWithProviders(
|
|
1279
|
+
<InputPrompt {...props} />,
|
|
1280
|
+
);
|
|
1281
|
+
|
|
1282
|
+
stdin.write('\x1B');
|
|
1283
|
+
|
|
1284
|
+
await waitFor(() => {
|
|
1285
|
+
expect(onEscapePromptChange).toHaveBeenCalledWith(true);
|
|
1286
|
+
});
|
|
1287
|
+
|
|
1288
|
+
stdin.write('a');
|
|
1289
|
+
|
|
1290
|
+
await waitFor(() => {
|
|
1291
|
+
expect(onEscapePromptChange).toHaveBeenCalledWith(false);
|
|
1292
|
+
});
|
|
1293
|
+
unmount();
|
|
1294
|
+
});
|
|
1295
|
+
|
|
1296
|
+
it('should handle ESC in shell mode by disabling shell mode', async () => {
|
|
1297
|
+
props.shellModeActive = true;
|
|
1298
|
+
|
|
1299
|
+
const { stdin, unmount } = renderWithProviders(
|
|
1300
|
+
<InputPrompt {...props} />,
|
|
1301
|
+
);
|
|
1302
|
+
await wait();
|
|
1303
|
+
|
|
1304
|
+
stdin.write('\x1B');
|
|
1305
|
+
await wait();
|
|
1306
|
+
|
|
1307
|
+
expect(props.setShellModeActive).toHaveBeenCalledWith(false);
|
|
1308
|
+
unmount();
|
|
1309
|
+
});
|
|
1310
|
+
|
|
1311
|
+
it('should handle ESC when completion suggestions are showing', async () => {
|
|
1312
|
+
mockedUseCommandCompletion.mockReturnValue({
|
|
1313
|
+
...mockCommandCompletion,
|
|
1314
|
+
showSuggestions: true,
|
|
1315
|
+
suggestions: [{ label: 'suggestion', value: 'suggestion' }],
|
|
1316
|
+
});
|
|
1317
|
+
|
|
1318
|
+
const { stdin, unmount } = renderWithProviders(
|
|
1319
|
+
<InputPrompt {...props} />,
|
|
1320
|
+
);
|
|
1321
|
+
await wait();
|
|
1322
|
+
|
|
1323
|
+
stdin.write('\x1B');
|
|
1324
|
+
await wait();
|
|
1325
|
+
|
|
1326
|
+
expect(mockCommandCompletion.resetCompletionState).toHaveBeenCalled();
|
|
1327
|
+
unmount();
|
|
1328
|
+
});
|
|
1329
|
+
|
|
1330
|
+
it('should not call onEscapePromptChange when not provided', async () => {
|
|
1331
|
+
props.onEscapePromptChange = undefined;
|
|
1332
|
+
props.buffer.setText('some text');
|
|
1333
|
+
|
|
1334
|
+
const { stdin, unmount } = renderWithProviders(
|
|
1335
|
+
<InputPrompt {...props} />,
|
|
1336
|
+
);
|
|
1337
|
+
await wait();
|
|
1338
|
+
|
|
1339
|
+
stdin.write('\x1B');
|
|
1340
|
+
await wait();
|
|
1341
|
+
|
|
1342
|
+
unmount();
|
|
1343
|
+
});
|
|
1344
|
+
|
|
1345
|
+
it('should not interfere with existing keyboard shortcuts', async () => {
|
|
1346
|
+
const { stdin, unmount } = renderWithProviders(
|
|
1347
|
+
<InputPrompt {...props} />,
|
|
1348
|
+
);
|
|
1349
|
+
await wait();
|
|
1350
|
+
|
|
1351
|
+
stdin.write('\x0C');
|
|
1352
|
+
await wait();
|
|
1353
|
+
|
|
1354
|
+
expect(props.onClearScreen).toHaveBeenCalled();
|
|
1355
|
+
|
|
1356
|
+
stdin.write('\x01');
|
|
1357
|
+
await wait();
|
|
1358
|
+
|
|
1359
|
+
expect(props.buffer.move).toHaveBeenCalledWith('home');
|
|
1360
|
+
unmount();
|
|
1361
|
+
});
|
|
1362
|
+
});
|
|
1363
|
+
|
|
1364
|
+
describe('reverse search', () => {
|
|
1365
|
+
beforeEach(async () => {
|
|
1366
|
+
props.shellModeActive = true;
|
|
1367
|
+
|
|
1368
|
+
vi.mocked(useShellHistory).mockReturnValue({
|
|
1369
|
+
history: ['echo hello', 'echo world', 'ls'],
|
|
1370
|
+
getPreviousCommand: vi.fn(),
|
|
1371
|
+
getNextCommand: vi.fn(),
|
|
1372
|
+
addCommandToHistory: vi.fn(),
|
|
1373
|
+
resetHistoryPosition: vi.fn(),
|
|
1374
|
+
});
|
|
1375
|
+
});
|
|
1376
|
+
|
|
1377
|
+
it('invokes reverse search on Ctrl+R', async () => {
|
|
1378
|
+
const { stdin, stdout, unmount } = renderWithProviders(
|
|
1379
|
+
<InputPrompt {...props} />,
|
|
1380
|
+
);
|
|
1381
|
+
await wait();
|
|
1382
|
+
|
|
1383
|
+
stdin.write('\x12');
|
|
1384
|
+
await wait();
|
|
1385
|
+
|
|
1386
|
+
const frame = stdout.lastFrame();
|
|
1387
|
+
expect(frame).toContain('(r:)');
|
|
1388
|
+
expect(frame).toContain('echo hello');
|
|
1389
|
+
expect(frame).toContain('echo world');
|
|
1390
|
+
expect(frame).toContain('ls');
|
|
1391
|
+
|
|
1392
|
+
unmount();
|
|
1393
|
+
});
|
|
1394
|
+
|
|
1395
|
+
it('resets reverse search state on Escape', async () => {
|
|
1396
|
+
const { stdin, stdout, unmount } = renderWithProviders(
|
|
1397
|
+
<InputPrompt {...props} />,
|
|
1398
|
+
);
|
|
1399
|
+
await wait();
|
|
1400
|
+
|
|
1401
|
+
stdin.write('\x12');
|
|
1402
|
+
await wait();
|
|
1403
|
+
stdin.write('\x1B');
|
|
1404
|
+
|
|
1405
|
+
await waitFor(() => {
|
|
1406
|
+
expect(stdout.lastFrame()).not.toContain('(r:)');
|
|
1407
|
+
});
|
|
1408
|
+
|
|
1409
|
+
expect(stdout.lastFrame()).not.toContain('echo hello');
|
|
1410
|
+
|
|
1411
|
+
unmount();
|
|
1412
|
+
});
|
|
1413
|
+
|
|
1414
|
+
it('completes the highlighted entry on Tab and exits reverse-search', async () => {
|
|
1415
|
+
const { stdin, stdout, unmount } = renderWithProviders(
|
|
1416
|
+
<InputPrompt {...props} />,
|
|
1417
|
+
);
|
|
1418
|
+
stdin.write('\x12');
|
|
1419
|
+
await wait();
|
|
1420
|
+
stdin.write('\t');
|
|
1421
|
+
|
|
1422
|
+
await waitFor(() => {
|
|
1423
|
+
expect(stdout.lastFrame()).not.toContain('(r:)');
|
|
1424
|
+
});
|
|
1425
|
+
|
|
1426
|
+
expect(props.buffer.setText).toHaveBeenCalledWith('echo hello');
|
|
1427
|
+
unmount();
|
|
1428
|
+
});
|
|
1429
|
+
|
|
1430
|
+
it('submits the highlighted entry on Enter and exits reverse-search', async () => {
|
|
1431
|
+
const { stdin, stdout, unmount } = renderWithProviders(
|
|
1432
|
+
<InputPrompt {...props} />,
|
|
1433
|
+
);
|
|
1434
|
+
stdin.write('\x12');
|
|
1435
|
+
await wait();
|
|
1436
|
+
expect(stdout.lastFrame()).toContain('(r:)');
|
|
1437
|
+
stdin.write('\r');
|
|
1438
|
+
|
|
1439
|
+
await waitFor(() => {
|
|
1440
|
+
expect(stdout.lastFrame()).not.toContain('(r:)');
|
|
1441
|
+
});
|
|
1442
|
+
|
|
1443
|
+
expect(props.onSubmit).toHaveBeenCalledWith('echo hello');
|
|
1444
|
+
unmount();
|
|
1445
|
+
});
|
|
1446
|
+
|
|
1447
|
+
it('text and cursor position should be restored after reverse search', async () => {
|
|
1448
|
+
props.buffer.setText('initial text');
|
|
1449
|
+
props.buffer.cursor = [0, 3];
|
|
1450
|
+
const { stdin, stdout, unmount } = renderWithProviders(
|
|
1451
|
+
<InputPrompt {...props} />,
|
|
1452
|
+
);
|
|
1453
|
+
stdin.write('\x12');
|
|
1454
|
+
await wait();
|
|
1455
|
+
expect(stdout.lastFrame()).toContain('(r:)');
|
|
1456
|
+
stdin.write('\x1B');
|
|
1457
|
+
|
|
1458
|
+
await waitFor(() => {
|
|
1459
|
+
expect(stdout.lastFrame()).not.toContain('(r:)');
|
|
1460
|
+
});
|
|
1461
|
+
expect(props.buffer.text).toBe('initial text');
|
|
1462
|
+
expect(props.buffer.cursor).toEqual([0, 3]);
|
|
1463
|
+
|
|
1464
|
+
unmount();
|
|
1465
|
+
});
|
|
1466
|
+
});
|
|
1467
|
+
});
|