fss-link 1.0.49 → 1.0.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (419) hide show
  1. package/dist/index.js +0 -0
  2. package/dist/package.json +2 -2
  3. package/dist/src/config/auth.js +8 -5
  4. package/dist/src/config/auth.js.map +1 -1
  5. package/dist/src/config/database.d.ts +103 -11
  6. package/dist/src/config/database.js +301 -59
  7. package/dist/src/config/database.js.map +1 -1
  8. package/dist/src/config/databaseBackup.d.ts +114 -0
  9. package/dist/src/config/databaseBackup.js +334 -0
  10. package/dist/src/config/databaseBackup.js.map +1 -0
  11. package/dist/src/config/databaseMigrations.d.ts +63 -0
  12. package/dist/src/config/databaseMigrations.js +379 -0
  13. package/dist/src/config/databaseMigrations.js.map +1 -0
  14. package/dist/src/config/databasePool.d.ts +70 -0
  15. package/dist/src/config/databasePool.js +193 -0
  16. package/dist/src/config/databasePool.js.map +1 -0
  17. package/dist/src/config/queryOptimizer.d.ts +127 -0
  18. package/dist/src/config/queryOptimizer.js +309 -0
  19. package/dist/src/config/queryOptimizer.js.map +1 -0
  20. package/dist/src/utils/sandbox.js +2 -8
  21. package/dist/src/utils/sandbox.js.map +1 -1
  22. package/dist/src/validateNonInterActiveAuth.js +3 -7
  23. package/dist/src/validateNonInterActiveAuth.js.map +1 -1
  24. package/dist/tsconfig.tsbuildinfo +1 -1
  25. package/package.json +2 -2
  26. package/dist/commands/mcp/add.test.ts +0 -122
  27. package/dist/commands/mcp/add.ts +0 -222
  28. package/dist/commands/mcp/list.test.ts +0 -154
  29. package/dist/commands/mcp/list.ts +0 -139
  30. package/dist/commands/mcp/remove.test.ts +0 -69
  31. package/dist/commands/mcp/remove.ts +0 -60
  32. package/dist/commands/mcp.test.ts +0 -55
  33. package/dist/commands/mcp.ts +0 -27
  34. package/dist/config/apiValidation.test.ts +0 -118
  35. package/dist/config/auth.test.ts +0 -79
  36. package/dist/config/auth.ts +0 -100
  37. package/dist/config/config.integration.test.ts +0 -407
  38. package/dist/config/config.test.ts +0 -1952
  39. package/dist/config/config.ts +0 -690
  40. package/dist/config/database.test.ts +0 -96
  41. package/dist/config/database.ts +0 -824
  42. package/dist/config/extension.test.ts +0 -236
  43. package/dist/config/extension.ts +0 -180
  44. package/dist/config/keyBindings.test.ts +0 -62
  45. package/dist/config/keyBindings.ts +0 -184
  46. package/dist/config/modelManager.ts +0 -326
  47. package/dist/config/providerManager.ts +0 -244
  48. package/dist/config/providerPersistence.test.ts +0 -377
  49. package/dist/config/providerPersistence.ts +0 -105
  50. package/dist/config/sandboxConfig.ts +0 -107
  51. package/dist/config/settings.test.ts +0 -1424
  52. package/dist/config/settings.ts +0 -517
  53. package/dist/config/settingsSchema.test.ts +0 -252
  54. package/dist/config/settingsSchema.ts +0 -728
  55. package/dist/config/trustedFolders.test.ts +0 -208
  56. package/dist/config/trustedFolders.ts +0 -167
  57. package/dist/gemini.test.tsx +0 -252
  58. package/dist/gemini.tsx +0 -357
  59. package/dist/generated/git-commit.ts +0 -10
  60. package/dist/index.ts +0 -21
  61. package/dist/nonInteractiveCli.test.ts +0 -276
  62. package/dist/nonInteractiveCli.ts +0 -143
  63. package/dist/patches/is-in-ci.ts +0 -17
  64. package/dist/services/BuiltinCommandLoader.test.ts +0 -127
  65. package/dist/services/BuiltinCommandLoader.ts +0 -95
  66. package/dist/services/CommandService.test.ts +0 -352
  67. package/dist/services/CommandService.ts +0 -103
  68. package/dist/services/FileCommandLoader.test.ts +0 -1002
  69. package/dist/services/FileCommandLoader.ts +0 -289
  70. package/dist/services/McpPromptLoader.ts +0 -231
  71. package/dist/services/SearchEngineConfigProvider.ts +0 -100
  72. package/dist/services/prompt-processors/argumentProcessor.test.ts +0 -41
  73. package/dist/services/prompt-processors/argumentProcessor.ts +0 -23
  74. package/dist/services/prompt-processors/shellProcessor.test.ts +0 -709
  75. package/dist/services/prompt-processors/shellProcessor.ts +0 -248
  76. package/dist/services/prompt-processors/types.ts +0 -44
  77. package/dist/services/types.ts +0 -24
  78. package/dist/src/config/apiValidation.test.d.ts +0 -6
  79. package/dist/src/config/apiValidation.test.js +0 -99
  80. package/dist/src/config/apiValidation.test.js.map +0 -1
  81. package/dist/src/config/database.test.d.ts +0 -6
  82. package/dist/src/config/database.test.js +0 -80
  83. package/dist/src/config/database.test.js.map +0 -1
  84. package/dist/src/config/providerManager.d.ts +0 -74
  85. package/dist/src/config/providerManager.js +0 -203
  86. package/dist/src/config/providerManager.js.map +0 -1
  87. package/dist/src/config/providerPersistence.test.d.ts +0 -6
  88. package/dist/src/config/providerPersistence.test.js +0 -283
  89. package/dist/src/config/providerPersistence.test.js.map +0 -1
  90. package/dist/src/ui/components/GeminiKeyDialog.d.ts +0 -11
  91. package/dist/src/ui/components/GeminiKeyDialog.js +0 -156
  92. package/dist/src/ui/components/GeminiKeyDialog.js.map +0 -1
  93. package/dist/src/ui/components/OpenAIEndpointDialog.d.ts +0 -19
  94. package/dist/src/ui/components/OpenAIEndpointDialog.js +0 -163
  95. package/dist/src/ui/components/OpenAIEndpointDialog.js.map +0 -1
  96. package/dist/test-setup.ts +0 -12
  97. package/dist/test-utils/customMatchers.ts +0 -65
  98. package/dist/test-utils/mockCommandContext.test.ts +0 -62
  99. package/dist/test-utils/mockCommandContext.ts +0 -105
  100. package/dist/test-utils/render.tsx +0 -18
  101. package/dist/ui/App.test.tsx +0 -2181
  102. package/dist/ui/App.tsx +0 -1344
  103. package/dist/ui/IdeIntegrationNudge.tsx +0 -98
  104. package/dist/ui/__snapshots__/App.test.tsx.snap +0 -124
  105. package/dist/ui/colors.ts +0 -56
  106. package/dist/ui/commands/aboutCommand.test.ts +0 -153
  107. package/dist/ui/commands/aboutCommand.ts +0 -49
  108. package/dist/ui/commands/authCommand.test.ts +0 -36
  109. package/dist/ui/commands/authCommand.ts +0 -17
  110. package/dist/ui/commands/bugCommand.test.ts +0 -114
  111. package/dist/ui/commands/bugCommand.ts +0 -92
  112. package/dist/ui/commands/chatCommand.test.ts +0 -414
  113. package/dist/ui/commands/chatCommand.ts +0 -280
  114. package/dist/ui/commands/clearCommand.test.ts +0 -100
  115. package/dist/ui/commands/clearCommand.ts +0 -29
  116. package/dist/ui/commands/compressCommand.test.ts +0 -129
  117. package/dist/ui/commands/compressCommand.ts +0 -78
  118. package/dist/ui/commands/contextCommand.ts +0 -132
  119. package/dist/ui/commands/copyCommand.test.ts +0 -296
  120. package/dist/ui/commands/copyCommand.ts +0 -67
  121. package/dist/ui/commands/corgiCommand.test.ts +0 -34
  122. package/dist/ui/commands/corgiCommand.ts +0 -16
  123. package/dist/ui/commands/directoryCommand.test.tsx +0 -185
  124. package/dist/ui/commands/directoryCommand.tsx +0 -179
  125. package/dist/ui/commands/docsCommand.test.ts +0 -99
  126. package/dist/ui/commands/docsCommand.ts +0 -42
  127. package/dist/ui/commands/editorCommand.test.ts +0 -30
  128. package/dist/ui/commands/editorCommand.ts +0 -21
  129. package/dist/ui/commands/extensionsCommand.test.ts +0 -67
  130. package/dist/ui/commands/extensionsCommand.ts +0 -46
  131. package/dist/ui/commands/helpCommand.test.ts +0 -52
  132. package/dist/ui/commands/helpCommand.ts +0 -23
  133. package/dist/ui/commands/ideCommand.test.ts +0 -255
  134. package/dist/ui/commands/ideCommand.ts +0 -283
  135. package/dist/ui/commands/initCommand.test.ts +0 -127
  136. package/dist/ui/commands/initCommand.ts +0 -117
  137. package/dist/ui/commands/mcpCommand.test.ts +0 -1057
  138. package/dist/ui/commands/mcpCommand.ts +0 -531
  139. package/dist/ui/commands/memoryCommand.test.ts +0 -344
  140. package/dist/ui/commands/memoryCommand.ts +0 -305
  141. package/dist/ui/commands/privacyCommand.test.ts +0 -38
  142. package/dist/ui/commands/privacyCommand.ts +0 -17
  143. package/dist/ui/commands/quitCommand.test.ts +0 -55
  144. package/dist/ui/commands/quitCommand.ts +0 -36
  145. package/dist/ui/commands/restoreCommand.test.ts +0 -250
  146. package/dist/ui/commands/restoreCommand.ts +0 -157
  147. package/dist/ui/commands/searchEngineSetupCommand.ts +0 -18
  148. package/dist/ui/commands/settingsCommand.test.ts +0 -36
  149. package/dist/ui/commands/settingsCommand.ts +0 -17
  150. package/dist/ui/commands/setupGithubCommand.test.ts +0 -238
  151. package/dist/ui/commands/setupGithubCommand.ts +0 -212
  152. package/dist/ui/commands/speakCommand.ts +0 -175
  153. package/dist/ui/commands/statsCommand.test.ts +0 -78
  154. package/dist/ui/commands/statsCommand.ts +0 -70
  155. package/dist/ui/commands/terminalSetupCommand.test.ts +0 -85
  156. package/dist/ui/commands/terminalSetupCommand.ts +0 -45
  157. package/dist/ui/commands/themeCommand.test.ts +0 -38
  158. package/dist/ui/commands/themeCommand.ts +0 -17
  159. package/dist/ui/commands/toolsCommand.test.ts +0 -105
  160. package/dist/ui/commands/toolsCommand.ts +0 -71
  161. package/dist/ui/commands/ttsCommand.ts +0 -143
  162. package/dist/ui/commands/types.ts +0 -204
  163. package/dist/ui/commands/vimCommand.ts +0 -25
  164. package/dist/ui/commands/voiceCommand.ts +0 -125
  165. package/dist/ui/components/AboutBox.tsx +0 -133
  166. package/dist/ui/components/AsciiArt.ts +0 -54
  167. package/dist/ui/components/AuthDialog.test.tsx +0 -334
  168. package/dist/ui/components/AuthDialog.tsx +0 -289
  169. package/dist/ui/components/AuthInProgress.tsx +0 -62
  170. package/dist/ui/components/AutoAcceptIndicator.tsx +0 -47
  171. package/dist/ui/components/ConsoleSummaryDisplay.tsx +0 -35
  172. package/dist/ui/components/ContextSummaryDisplay.test.tsx +0 -85
  173. package/dist/ui/components/ContextSummaryDisplay.tsx +0 -120
  174. package/dist/ui/components/ContextUsageDisplay.tsx +0 -77
  175. package/dist/ui/components/DebugProfiler.tsx +0 -36
  176. package/dist/ui/components/DetailedMessagesDisplay.tsx +0 -82
  177. package/dist/ui/components/EditorSettingsDialog.tsx +0 -172
  178. package/dist/ui/components/FolderTrustDialog.test.tsx +0 -36
  179. package/dist/ui/components/FolderTrustDialog.tsx +0 -74
  180. package/dist/ui/components/Footer.test.tsx +0 -159
  181. package/dist/ui/components/Footer.tsx +0 -158
  182. package/dist/ui/components/GeminiKeyDialog.tsx +0 -252
  183. package/dist/ui/components/GeminiRespondingSpinner.tsx +0 -34
  184. package/dist/ui/components/Header.test.tsx +0 -44
  185. package/dist/ui/components/Header.tsx +0 -70
  186. package/dist/ui/components/Help.tsx +0 -174
  187. package/dist/ui/components/HistoryItemDisplay.test.tsx +0 -125
  188. package/dist/ui/components/HistoryItemDisplay.tsx +0 -98
  189. package/dist/ui/components/InputPrompt.test.tsx +0 -1467
  190. package/dist/ui/components/InputPrompt.tsx +0 -641
  191. package/dist/ui/components/LMStudioModelPrompt.tsx +0 -215
  192. package/dist/ui/components/LoadingIndicator.test.tsx +0 -296
  193. package/dist/ui/components/LoadingIndicator.tsx +0 -82
  194. package/dist/ui/components/MemoryUsageDisplay.tsx +0 -36
  195. package/dist/ui/components/ModelStatsDisplay.test.tsx +0 -252
  196. package/dist/ui/components/ModelStatsDisplay.tsx +0 -197
  197. package/dist/ui/components/OllamaModelPrompt.tsx +0 -206
  198. package/dist/ui/components/OpenAIEndpointDialog.tsx +0 -261
  199. package/dist/ui/components/OpenAIKeyPrompt.test.tsx +0 -64
  200. package/dist/ui/components/OpenAIKeyPrompt.tsx +0 -197
  201. package/dist/ui/components/PrepareLabel.tsx +0 -48
  202. package/dist/ui/components/SearchEngineConfigDialog.tsx +0 -280
  203. package/dist/ui/components/SessionSummaryDisplay.test.tsx +0 -75
  204. package/dist/ui/components/SessionSummaryDisplay.tsx +0 -18
  205. package/dist/ui/components/SettingsDialog.test.tsx +0 -865
  206. package/dist/ui/components/SettingsDialog.tsx +0 -753
  207. package/dist/ui/components/ShellConfirmationDialog.test.tsx +0 -53
  208. package/dist/ui/components/ShellConfirmationDialog.tsx +0 -103
  209. package/dist/ui/components/ShellModeIndicator.tsx +0 -18
  210. package/dist/ui/components/ShowMoreLines.tsx +0 -40
  211. package/dist/ui/components/StatsDisplay.test.tsx +0 -401
  212. package/dist/ui/components/StatsDisplay.tsx +0 -273
  213. package/dist/ui/components/SuggestionsDisplay.tsx +0 -102
  214. package/dist/ui/components/ThemeDialog.tsx +0 -310
  215. package/dist/ui/components/Tips.tsx +0 -45
  216. package/dist/ui/components/TodoDisplay.test.tsx +0 -97
  217. package/dist/ui/components/TodoDisplay.tsx +0 -72
  218. package/dist/ui/components/ToolStatsDisplay.test.tsx +0 -180
  219. package/dist/ui/components/ToolStatsDisplay.tsx +0 -208
  220. package/dist/ui/components/UpdateNotification.tsx +0 -23
  221. package/dist/ui/components/WelcomeBackDialog.tsx +0 -290
  222. package/dist/ui/components/__snapshots__/IDEContextDetailDisplay.test.tsx.snap +0 -24
  223. package/dist/ui/components/__snapshots__/ModelStatsDisplay.test.tsx.snap +0 -121
  224. package/dist/ui/components/__snapshots__/SessionSummaryDisplay.test.tsx.snap +0 -30
  225. package/dist/ui/components/__snapshots__/ShellConfirmationDialog.test.tsx.snap +0 -21
  226. package/dist/ui/components/__snapshots__/StatsDisplay.test.tsx.snap +0 -264
  227. package/dist/ui/components/__snapshots__/ToolStatsDisplay.test.tsx.snap +0 -91
  228. package/dist/ui/components/messages/CompressionMessage.tsx +0 -49
  229. package/dist/ui/components/messages/DiffRenderer.test.tsx +0 -365
  230. package/dist/ui/components/messages/DiffRenderer.tsx +0 -358
  231. package/dist/ui/components/messages/ErrorMessage.tsx +0 -31
  232. package/dist/ui/components/messages/GeminiMessage.tsx +0 -43
  233. package/dist/ui/components/messages/GeminiMessageContent.tsx +0 -43
  234. package/dist/ui/components/messages/InfoMessage.tsx +0 -32
  235. package/dist/ui/components/messages/ToolConfirmationMessage.test.tsx +0 -58
  236. package/dist/ui/components/messages/ToolConfirmationMessage.tsx +0 -297
  237. package/dist/ui/components/messages/ToolGroupMessage.tsx +0 -126
  238. package/dist/ui/components/messages/ToolMessage.test.tsx +0 -183
  239. package/dist/ui/components/messages/ToolMessage.tsx +0 -296
  240. package/dist/ui/components/messages/UserMessage.tsx +0 -43
  241. package/dist/ui/components/messages/UserShellMessage.tsx +0 -25
  242. package/dist/ui/components/shared/MaxSizedBox.test.tsx +0 -425
  243. package/dist/ui/components/shared/MaxSizedBox.tsx +0 -624
  244. package/dist/ui/components/shared/RadioButtonSelect.test.tsx +0 -181
  245. package/dist/ui/components/shared/RadioButtonSelect.tsx +0 -234
  246. package/dist/ui/components/shared/__snapshots__/RadioButtonSelect.test.tsx.snap +0 -47
  247. package/dist/ui/components/shared/text-buffer.test.ts +0 -1728
  248. package/dist/ui/components/shared/text-buffer.ts +0 -2227
  249. package/dist/ui/components/shared/vim-buffer-actions.test.ts +0 -1119
  250. package/dist/ui/components/shared/vim-buffer-actions.ts +0 -814
  251. package/dist/ui/constants.ts +0 -17
  252. package/dist/ui/contexts/KeypressContext.test.tsx +0 -391
  253. package/dist/ui/contexts/KeypressContext.tsx +0 -440
  254. package/dist/ui/contexts/OverflowContext.tsx +0 -87
  255. package/dist/ui/contexts/SessionContext.test.tsx +0 -132
  256. package/dist/ui/contexts/SessionContext.tsx +0 -143
  257. package/dist/ui/contexts/SettingsContext.tsx +0 -20
  258. package/dist/ui/contexts/StreamingContext.tsx +0 -22
  259. package/dist/ui/contexts/VimModeContext.tsx +0 -79
  260. package/dist/ui/editors/editorSettingsManager.ts +0 -66
  261. package/dist/ui/hooks/atCommandProcessor.test.ts +0 -1102
  262. package/dist/ui/hooks/atCommandProcessor.ts +0 -485
  263. package/dist/ui/hooks/shellCommandProcessor.test.ts +0 -481
  264. package/dist/ui/hooks/shellCommandProcessor.ts +0 -314
  265. package/dist/ui/hooks/slashCommandProcessor.test.ts +0 -1044
  266. package/dist/ui/hooks/slashCommandProcessor.ts +0 -595
  267. package/dist/ui/hooks/useAtCompletion.test.ts +0 -497
  268. package/dist/ui/hooks/useAtCompletion.ts +0 -244
  269. package/dist/ui/hooks/useAuthCommand.ts +0 -129
  270. package/dist/ui/hooks/useAutoAcceptIndicator.test.ts +0 -300
  271. package/dist/ui/hooks/useAutoAcceptIndicator.ts +0 -52
  272. package/dist/ui/hooks/useBracketedPaste.ts +0 -37
  273. package/dist/ui/hooks/useCommandCompletion.test.ts +0 -518
  274. package/dist/ui/hooks/useCommandCompletion.tsx +0 -238
  275. package/dist/ui/hooks/useCompletion.ts +0 -128
  276. package/dist/ui/hooks/useConsoleMessages.test.ts +0 -147
  277. package/dist/ui/hooks/useConsoleMessages.ts +0 -110
  278. package/dist/ui/hooks/useEditorSettings.test.ts +0 -283
  279. package/dist/ui/hooks/useEditorSettings.ts +0 -75
  280. package/dist/ui/hooks/useFocus.test.ts +0 -119
  281. package/dist/ui/hooks/useFocus.ts +0 -48
  282. package/dist/ui/hooks/useFolderTrust.test.ts +0 -159
  283. package/dist/ui/hooks/useFolderTrust.ts +0 -72
  284. package/dist/ui/hooks/useGeminiStream.test.tsx +0 -1998
  285. package/dist/ui/hooks/useGeminiStream.ts +0 -1017
  286. package/dist/ui/hooks/useGitBranchName.test.ts +0 -280
  287. package/dist/ui/hooks/useGitBranchName.ts +0 -79
  288. package/dist/ui/hooks/useHistoryManager.test.ts +0 -202
  289. package/dist/ui/hooks/useHistoryManager.ts +0 -111
  290. package/dist/ui/hooks/useInputHistory.test.ts +0 -261
  291. package/dist/ui/hooks/useInputHistory.ts +0 -111
  292. package/dist/ui/hooks/useKeypress.test.ts +0 -280
  293. package/dist/ui/hooks/useKeypress.ts +0 -39
  294. package/dist/ui/hooks/useKittyKeyboardProtocol.ts +0 -31
  295. package/dist/ui/hooks/useLoadingIndicator.test.ts +0 -139
  296. package/dist/ui/hooks/useLoadingIndicator.ts +0 -57
  297. package/dist/ui/hooks/useLogger.ts +0 -32
  298. package/dist/ui/hooks/useMessageQueue.test.ts +0 -226
  299. package/dist/ui/hooks/useMessageQueue.ts +0 -69
  300. package/dist/ui/hooks/usePhraseCycler.test.ts +0 -145
  301. package/dist/ui/hooks/usePhraseCycler.ts +0 -198
  302. package/dist/ui/hooks/usePrivacySettings.test.ts +0 -242
  303. package/dist/ui/hooks/usePrivacySettings.ts +0 -150
  304. package/dist/ui/hooks/useReactToolScheduler.ts +0 -309
  305. package/dist/ui/hooks/useRefreshMemoryCommand.ts +0 -7
  306. package/dist/ui/hooks/useReverseSearchCompletion.test.tsx +0 -260
  307. package/dist/ui/hooks/useReverseSearchCompletion.tsx +0 -95
  308. package/dist/ui/hooks/useSettingsCommand.ts +0 -25
  309. package/dist/ui/hooks/useShellHistory.test.ts +0 -219
  310. package/dist/ui/hooks/useShellHistory.ts +0 -133
  311. package/dist/ui/hooks/useShowMemoryCommand.ts +0 -75
  312. package/dist/ui/hooks/useSlashCompletion.test.ts +0 -434
  313. package/dist/ui/hooks/useSlashCompletion.ts +0 -187
  314. package/dist/ui/hooks/useStateAndRef.ts +0 -36
  315. package/dist/ui/hooks/useTerminalSize.ts +0 -32
  316. package/dist/ui/hooks/useThemeCommand.ts +0 -110
  317. package/dist/ui/hooks/useTimer.test.ts +0 -120
  318. package/dist/ui/hooks/useTimer.ts +0 -65
  319. package/dist/ui/hooks/useToolScheduler.test.ts +0 -1123
  320. package/dist/ui/hooks/useWelcomeBack.ts +0 -253
  321. package/dist/ui/hooks/vim.test.ts +0 -1691
  322. package/dist/ui/hooks/vim.ts +0 -784
  323. package/dist/ui/keyMatchers.test.ts +0 -337
  324. package/dist/ui/keyMatchers.ts +0 -105
  325. package/dist/ui/privacy/CloudFreePrivacyNotice.tsx +0 -117
  326. package/dist/ui/privacy/CloudPaidPrivacyNotice.tsx +0 -59
  327. package/dist/ui/privacy/GeminiPrivacyNotice.tsx +0 -62
  328. package/dist/ui/privacy/PrivacyNotice.tsx +0 -42
  329. package/dist/ui/semantic-colors.ts +0 -26
  330. package/dist/ui/themes/ansi-light.ts +0 -150
  331. package/dist/ui/themes/ansi.ts +0 -159
  332. package/dist/ui/themes/atom-one-dark.ts +0 -147
  333. package/dist/ui/themes/ayu-light.ts +0 -139
  334. package/dist/ui/themes/ayu.ts +0 -113
  335. package/dist/ui/themes/color-utils.test.ts +0 -221
  336. package/dist/ui/themes/color-utils.ts +0 -231
  337. package/dist/ui/themes/default-light.ts +0 -108
  338. package/dist/ui/themes/default.ts +0 -151
  339. package/dist/ui/themes/dracula.ts +0 -124
  340. package/dist/ui/themes/fss-code-dark.ts +0 -156
  341. package/dist/ui/themes/fss-dark.ts +0 -113
  342. package/dist/ui/themes/fss-light.ts +0 -139
  343. package/dist/ui/themes/github-dark.ts +0 -147
  344. package/dist/ui/themes/github-light.ts +0 -149
  345. package/dist/ui/themes/googlecode.ts +0 -146
  346. package/dist/ui/themes/no-color.ts +0 -125
  347. package/dist/ui/themes/qwen-dark.ts +0 -118
  348. package/dist/ui/themes/qwen-light.ts +0 -144
  349. package/dist/ui/themes/semantic-tokens.ts +0 -127
  350. package/dist/ui/themes/shades-of-purple.ts +0 -352
  351. package/dist/ui/themes/theme-manager.test.ts +0 -99
  352. package/dist/ui/themes/theme-manager.ts +0 -257
  353. package/dist/ui/themes/theme.test.ts +0 -97
  354. package/dist/ui/themes/theme.ts +0 -451
  355. package/dist/ui/themes/xcode.ts +0 -154
  356. package/dist/ui/types.ts +0 -255
  357. package/dist/ui/utils/CodeColorizer.tsx +0 -217
  358. package/dist/ui/utils/ConsolePatcher.ts +0 -71
  359. package/dist/ui/utils/InlineMarkdownRenderer.tsx +0 -173
  360. package/dist/ui/utils/MarkdownDisplay.test.tsx +0 -244
  361. package/dist/ui/utils/MarkdownDisplay.tsx +0 -415
  362. package/dist/ui/utils/TableRenderer.tsx +0 -159
  363. package/dist/ui/utils/__snapshots__/MarkdownDisplay.test.tsx.snap +0 -93
  364. package/dist/ui/utils/clipboardUtils.test.ts +0 -76
  365. package/dist/ui/utils/clipboardUtils.ts +0 -149
  366. package/dist/ui/utils/commandUtils.test.ts +0 -384
  367. package/dist/ui/utils/commandUtils.ts +0 -106
  368. package/dist/ui/utils/computeStats.test.ts +0 -292
  369. package/dist/ui/utils/computeStats.ts +0 -86
  370. package/dist/ui/utils/displayUtils.test.ts +0 -58
  371. package/dist/ui/utils/displayUtils.ts +0 -32
  372. package/dist/ui/utils/formatters.test.ts +0 -72
  373. package/dist/ui/utils/formatters.ts +0 -63
  374. package/dist/ui/utils/isNarrowWidth.ts +0 -9
  375. package/dist/ui/utils/kittyProtocolDetector.ts +0 -105
  376. package/dist/ui/utils/markdownUtilities.test.ts +0 -50
  377. package/dist/ui/utils/markdownUtilities.ts +0 -125
  378. package/dist/ui/utils/platformConstants.ts +0 -52
  379. package/dist/ui/utils/terminalSetup.ts +0 -342
  380. package/dist/ui/utils/textUtils.ts +0 -40
  381. package/dist/ui/utils/updateCheck.test.ts +0 -163
  382. package/dist/ui/utils/updateCheck.ts +0 -100
  383. package/dist/utils/checks.ts +0 -28
  384. package/dist/utils/cleanup.test.ts +0 -68
  385. package/dist/utils/cleanup.ts +0 -36
  386. package/dist/utils/dialogScopeUtils.ts +0 -64
  387. package/dist/utils/events.ts +0 -14
  388. package/dist/utils/gitUtils.test.ts +0 -149
  389. package/dist/utils/gitUtils.ts +0 -116
  390. package/dist/utils/handleAutoUpdate.test.ts +0 -272
  391. package/dist/utils/handleAutoUpdate.ts +0 -145
  392. package/dist/utils/installationInfo.test.ts +0 -315
  393. package/dist/utils/installationInfo.ts +0 -176
  394. package/dist/utils/package.ts +0 -38
  395. package/dist/utils/readStdin.ts +0 -51
  396. package/dist/utils/resolvePath.ts +0 -21
  397. package/dist/utils/sandbox-macos-permissive-closed.sb +0 -32
  398. package/dist/utils/sandbox-macos-permissive-open.sb +0 -25
  399. package/dist/utils/sandbox-macos-permissive-proxied.sb +0 -37
  400. package/dist/utils/sandbox-macos-restrictive-closed.sb +0 -93
  401. package/dist/utils/sandbox-macos-restrictive-open.sb +0 -96
  402. package/dist/utils/sandbox-macos-restrictive-proxied.sb +0 -98
  403. package/dist/utils/sandbox.ts +0 -962
  404. package/dist/utils/settingsUtils.test.ts +0 -797
  405. package/dist/utils/settingsUtils.ts +0 -489
  406. package/dist/utils/spawnWrapper.ts +0 -9
  407. package/dist/utils/startupWarnings.test.ts +0 -83
  408. package/dist/utils/startupWarnings.ts +0 -40
  409. package/dist/utils/updateEventEmitter.ts +0 -13
  410. package/dist/utils/userStartupWarnings.test.ts +0 -87
  411. package/dist/utils/userStartupWarnings.ts +0 -69
  412. package/dist/utils/version.ts +0 -12
  413. package/dist/validateNonInterActiveAuth.test.ts +0 -260
  414. package/dist/validateNonInterActiveAuth.ts +0 -51
  415. package/dist/vitest.config.ts +0 -37
  416. package/dist/zed-integration/acp.ts +0 -366
  417. package/dist/zed-integration/fileSystemService.ts +0 -47
  418. package/dist/zed-integration/schema.ts +0 -466
  419. package/dist/zed-integration/zedIntegration.ts +0 -944
@@ -1,1467 +0,0 @@
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
- });