@didim365/agent-cli 0.1.1 → 0.1.3

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 (1091) hide show
  1. package/dist/package.json +5 -2
  2. package/dist/src/config/settingsSchema.d.ts +85 -0
  3. package/dist/src/config/settingsSchema.js +85 -0
  4. package/dist/src/config/settingsSchema.js.map +1 -1
  5. package/dist/src/core/initializer.js +42 -3
  6. package/dist/src/core/initializer.js.map +1 -1
  7. package/dist/src/gemini.d.ts +6 -0
  8. package/dist/src/gemini.js +79 -5
  9. package/dist/src/gemini.js.map +1 -1
  10. package/dist/src/generated/git-commit.d.ts +1 -1
  11. package/dist/src/generated/git-commit.js +1 -1
  12. package/dist/src/test-utils/render.js +9 -0
  13. package/dist/src/test-utils/render.js.map +1 -1
  14. package/dist/src/ui/AppContainer.js +182 -9
  15. package/dist/src/ui/AppContainer.js.map +1 -1
  16. package/dist/src/ui/auth/ApiAuthDialog.d.ts +3 -1
  17. package/dist/src/ui/auth/ApiAuthDialog.js +7 -5
  18. package/dist/src/ui/auth/ApiAuthDialog.js.map +1 -1
  19. package/dist/src/ui/auth/AuthDialog.d.ts +3 -1
  20. package/dist/src/ui/auth/AuthDialog.js +6 -6
  21. package/dist/src/ui/auth/AuthDialog.js.map +1 -1
  22. package/dist/src/ui/auth/ProviderSelectDialog.d.ts +15 -0
  23. package/dist/src/ui/auth/ProviderSelectDialog.js +39 -0
  24. package/dist/src/ui/auth/ProviderSelectDialog.js.map +1 -0
  25. package/dist/src/ui/auth/SlmConfigDialog.d.ts +21 -0
  26. package/dist/src/ui/auth/SlmConfigDialog.js +170 -0
  27. package/dist/src/ui/auth/SlmConfigDialog.js.map +1 -0
  28. package/dist/src/ui/auth/VertexConfigDialog.d.ts +18 -0
  29. package/dist/src/ui/auth/VertexConfigDialog.js +97 -0
  30. package/dist/src/ui/auth/VertexConfigDialog.js.map +1 -0
  31. package/dist/src/ui/auth/providerMetadata.d.ts +38 -0
  32. package/dist/src/ui/auth/providerMetadata.js +71 -0
  33. package/dist/src/ui/auth/providerMetadata.js.map +1 -0
  34. package/dist/src/ui/auth/useAuth.d.ts +3 -0
  35. package/dist/src/ui/auth/useAuth.js +243 -39
  36. package/dist/src/ui/auth/useAuth.js.map +1 -1
  37. package/dist/src/ui/commands/authCommand.js +18 -1
  38. package/dist/src/ui/commands/authCommand.js.map +1 -1
  39. package/dist/src/ui/commands/initCommand.js +1 -1
  40. package/dist/src/ui/commands/initCommand.js.map +1 -1
  41. package/dist/src/ui/commands/rewindCommand.js.map +1 -1
  42. package/dist/src/ui/components/ContextSummaryDisplay.js.map +1 -1
  43. package/dist/src/ui/components/DialogManager.js +27 -2
  44. package/dist/src/ui/components/DialogManager.js.map +1 -1
  45. package/dist/src/ui/components/InputPrompt.js +1 -1
  46. package/dist/src/ui/components/InputPrompt.js.map +1 -1
  47. package/dist/src/ui/contexts/UIActionsContext.d.ts +14 -0
  48. package/dist/src/ui/contexts/UIActionsContext.js.map +1 -1
  49. package/dist/src/ui/contexts/UIStateContext.d.ts +4 -0
  50. package/dist/src/ui/contexts/UIStateContext.js.map +1 -1
  51. package/dist/src/ui/hooks/useRewind.js.map +1 -1
  52. package/dist/src/ui/types.d.ts +4 -1
  53. package/dist/src/ui/types.js +6 -0
  54. package/dist/src/ui/types.js.map +1 -1
  55. package/dist/src/ui/utils/mouse.js +1 -1
  56. package/dist/src/ui/utils/mouse.js.map +1 -1
  57. package/dist/src/ui/utils/rewindFileOps.js.map +1 -1
  58. package/package.json +6 -3
  59. package/dist/src/commands/extensions/configure.test.d.ts +0 -1
  60. package/dist/src/commands/extensions/configure.test.js +0 -197
  61. package/dist/src/commands/extensions/configure.test.js.map +0 -1
  62. package/dist/src/commands/extensions/disable.test.d.ts +0 -6
  63. package/dist/src/commands/extensions/disable.test.js +0 -169
  64. package/dist/src/commands/extensions/disable.test.js.map +0 -1
  65. package/dist/src/commands/extensions/enable.test.d.ts +0 -6
  66. package/dist/src/commands/extensions/enable.test.js +0 -199
  67. package/dist/src/commands/extensions/enable.test.js.map +0 -1
  68. package/dist/src/commands/extensions/install.test.d.ts +0 -6
  69. package/dist/src/commands/extensions/install.test.js +0 -140
  70. package/dist/src/commands/extensions/install.test.js.map +0 -1
  71. package/dist/src/commands/extensions/link.test.d.ts +0 -6
  72. package/dist/src/commands/extensions/link.test.js +0 -137
  73. package/dist/src/commands/extensions/link.test.js.map +0 -1
  74. package/dist/src/commands/extensions/list.test.d.ts +0 -6
  75. package/dist/src/commands/extensions/list.test.js +0 -148
  76. package/dist/src/commands/extensions/list.test.js.map +0 -1
  77. package/dist/src/commands/extensions/new.test.d.ts +0 -6
  78. package/dist/src/commands/extensions/new.test.js +0 -62
  79. package/dist/src/commands/extensions/new.test.js.map +0 -1
  80. package/dist/src/commands/extensions/uninstall.test.d.ts +0 -6
  81. package/dist/src/commands/extensions/uninstall.test.js +0 -199
  82. package/dist/src/commands/extensions/uninstall.test.js.map +0 -1
  83. package/dist/src/commands/extensions/update.test.d.ts +0 -6
  84. package/dist/src/commands/extensions/update.test.js +0 -170
  85. package/dist/src/commands/extensions/update.test.js.map +0 -1
  86. package/dist/src/commands/extensions/validate.test.d.ts +0 -6
  87. package/dist/src/commands/extensions/validate.test.js +0 -96
  88. package/dist/src/commands/extensions/validate.test.js.map +0 -1
  89. package/dist/src/commands/extensions.test.d.ts +0 -6
  90. package/dist/src/commands/extensions.test.js +0 -67
  91. package/dist/src/commands/extensions.test.js.map +0 -1
  92. package/dist/src/commands/hooks/migrate.test.d.ts +0 -6
  93. package/dist/src/commands/hooks/migrate.test.js +0 -388
  94. package/dist/src/commands/hooks/migrate.test.js.map +0 -1
  95. package/dist/src/commands/mcp/add.test.d.ts +0 -6
  96. package/dist/src/commands/mcp/add.test.js +0 -274
  97. package/dist/src/commands/mcp/add.test.js.map +0 -1
  98. package/dist/src/commands/mcp/list.test.d.ts +0 -6
  99. package/dist/src/commands/mcp/list.test.js +0 -150
  100. package/dist/src/commands/mcp/list.test.js.map +0 -1
  101. package/dist/src/commands/mcp/remove.test.d.ts +0 -6
  102. package/dist/src/commands/mcp/remove.test.js +0 -189
  103. package/dist/src/commands/mcp/remove.test.js.map +0 -1
  104. package/dist/src/commands/mcp.test.d.ts +0 -6
  105. package/dist/src/commands/mcp.test.js +0 -65
  106. package/dist/src/commands/mcp.test.js.map +0 -1
  107. package/dist/src/commands/skills/disable.test.d.ts +0 -6
  108. package/dist/src/commands/skills/disable.test.js +0 -96
  109. package/dist/src/commands/skills/disable.test.js.map +0 -1
  110. package/dist/src/commands/skills/enable.test.d.ts +0 -6
  111. package/dist/src/commands/skills/enable.test.js +0 -107
  112. package/dist/src/commands/skills/enable.test.js.map +0 -1
  113. package/dist/src/commands/skills/install.test.d.ts +0 -6
  114. package/dist/src/commands/skills/install.test.js +0 -95
  115. package/dist/src/commands/skills/install.test.js.map +0 -1
  116. package/dist/src/commands/skills/list.test.d.ts +0 -6
  117. package/dist/src/commands/skills/list.test.js +0 -136
  118. package/dist/src/commands/skills/list.test.js.map +0 -1
  119. package/dist/src/commands/skills/uninstall.test.d.ts +0 -6
  120. package/dist/src/commands/skills/uninstall.test.js +0 -61
  121. package/dist/src/commands/skills/uninstall.test.js.map +0 -1
  122. package/dist/src/commands/skills.test.d.ts +0 -6
  123. package/dist/src/commands/skills.test.js +0 -49
  124. package/dist/src/commands/skills.test.js.map +0 -1
  125. package/dist/src/commands/utils.test.d.ts +0 -6
  126. package/dist/src/commands/utils.test.js +0 -35
  127. package/dist/src/commands/utils.test.js.map +0 -1
  128. package/dist/src/config/auth.test.d.ts +0 -6
  129. package/dist/src/config/auth.test.js +0 -89
  130. package/dist/src/config/auth.test.js.map +0 -1
  131. package/dist/src/config/config.integration.test.d.ts +0 -6
  132. package/dist/src/config/config.integration.test.js +0 -205
  133. package/dist/src/config/config.integration.test.js.map +0 -1
  134. package/dist/src/config/config.test.d.ts +0 -6
  135. package/dist/src/config/config.test.js +0 -2413
  136. package/dist/src/config/config.test.js.map +0 -1
  137. package/dist/src/config/extension-manager-agents.test.d.ts +0 -6
  138. package/dist/src/config/extension-manager-agents.test.js +0 -114
  139. package/dist/src/config/extension-manager-agents.test.js.map +0 -1
  140. package/dist/src/config/extension-manager-scope.test.d.ts +0 -6
  141. package/dist/src/config/extension-manager-scope.test.js +0 -153
  142. package/dist/src/config/extension-manager-scope.test.js.map +0 -1
  143. package/dist/src/config/extension-manager-skills.test.d.ts +0 -6
  144. package/dist/src/config/extension-manager-skills.test.js +0 -148
  145. package/dist/src/config/extension-manager-skills.test.js.map +0 -1
  146. package/dist/src/config/extension.test.d.ts +0 -6
  147. package/dist/src/config/extension.test.js +0 -1671
  148. package/dist/src/config/extension.test.js.map +0 -1
  149. package/dist/src/config/extensions/consent.test.d.ts +0 -6
  150. package/dist/src/config/extensions/consent.test.js +0 -280
  151. package/dist/src/config/extensions/consent.test.js.map +0 -1
  152. package/dist/src/config/extensions/extensionEnablement.test.d.ts +0 -6
  153. package/dist/src/config/extensions/extensionEnablement.test.js +0 -404
  154. package/dist/src/config/extensions/extensionEnablement.test.js.map +0 -1
  155. package/dist/src/config/extensions/extensionSettings.test.d.ts +0 -6
  156. package/dist/src/config/extensions/extensionSettings.test.js +0 -493
  157. package/dist/src/config/extensions/extensionSettings.test.js.map +0 -1
  158. package/dist/src/config/extensions/extensionUpdates.test.d.ts +0 -6
  159. package/dist/src/config/extensions/extensionUpdates.test.js +0 -230
  160. package/dist/src/config/extensions/extensionUpdates.test.js.map +0 -1
  161. package/dist/src/config/extensions/github.test.d.ts +0 -6
  162. package/dist/src/config/extensions/github.test.js +0 -441
  163. package/dist/src/config/extensions/github.test.js.map +0 -1
  164. package/dist/src/config/extensions/github_fetch.test.d.ts +0 -6
  165. package/dist/src/config/extensions/github_fetch.test.js +0 -169
  166. package/dist/src/config/extensions/github_fetch.test.js.map +0 -1
  167. package/dist/src/config/extensions/storage.test.d.ts +0 -6
  168. package/dist/src/config/extensions/storage.test.js +0 -64
  169. package/dist/src/config/extensions/storage.test.js.map +0 -1
  170. package/dist/src/config/extensions/update.test.d.ts +0 -6
  171. package/dist/src/config/extensions/update.test.js +0 -231
  172. package/dist/src/config/extensions/update.test.js.map +0 -1
  173. package/dist/src/config/extensions/variables.test.d.ts +0 -6
  174. package/dist/src/config/extensions/variables.test.js +0 -103
  175. package/dist/src/config/extensions/variables.test.js.map +0 -1
  176. package/dist/src/config/keyBindings.test.d.ts +0 -6
  177. package/dist/src/config/keyBindings.test.js +0 -108
  178. package/dist/src/config/keyBindings.test.js.map +0 -1
  179. package/dist/src/config/mcp/mcpServerEnablement.test.d.ts +0 -6
  180. package/dist/src/config/mcp/mcpServerEnablement.test.js +0 -147
  181. package/dist/src/config/mcp/mcpServerEnablement.test.js.map +0 -1
  182. package/dist/src/config/policy-engine.integration.test.d.ts +0 -6
  183. package/dist/src/config/policy-engine.integration.test.js +0 -353
  184. package/dist/src/config/policy-engine.integration.test.js.map +0 -1
  185. package/dist/src/config/sandboxConfig.test.d.ts +0 -6
  186. package/dist/src/config/sandboxConfig.test.js +0 -184
  187. package/dist/src/config/sandboxConfig.test.js.map +0 -1
  188. package/dist/src/config/settingPaths.test.d.ts +0 -6
  189. package/dist/src/config/settingPaths.test.js +0 -22
  190. package/dist/src/config/settingPaths.test.js.map +0 -1
  191. package/dist/src/config/settings-validation.test.d.ts +0 -6
  192. package/dist/src/config/settings-validation.test.js +0 -370
  193. package/dist/src/config/settings-validation.test.js.map +0 -1
  194. package/dist/src/config/settings.test.d.ts +0 -6
  195. package/dist/src/config/settings.test.js +0 -1822
  196. package/dist/src/config/settings.test.js.map +0 -1
  197. package/dist/src/config/settingsSchema.test.d.ts +0 -6
  198. package/dist/src/config/settingsSchema.test.js +0 -309
  199. package/dist/src/config/settingsSchema.test.js.map +0 -1
  200. package/dist/src/config/settings_repro.test.d.ts +0 -6
  201. package/dist/src/config/settings_repro.test.js +0 -166
  202. package/dist/src/config/settings_repro.test.js.map +0 -1
  203. package/dist/src/config/settings_validation_warning.test.d.ts +0 -6
  204. package/dist/src/config/settings_validation_warning.test.js +0 -123
  205. package/dist/src/config/settings_validation_warning.test.js.map +0 -1
  206. package/dist/src/config/skills-backward-compatibility.test.d.ts +0 -6
  207. package/dist/src/config/skills-backward-compatibility.test.js +0 -99
  208. package/dist/src/config/skills-backward-compatibility.test.js.map +0 -1
  209. package/dist/src/config/trustedFolders.test.d.ts +0 -6
  210. package/dist/src/config/trustedFolders.test.js +0 -385
  211. package/dist/src/config/trustedFolders.test.js.map +0 -1
  212. package/dist/src/core/auth.test.d.ts +0 -6
  213. package/dist/src/core/auth.test.js +0 -47
  214. package/dist/src/core/auth.test.js.map +0 -1
  215. package/dist/src/core/initializer.test.d.ts +0 -6
  216. package/dist/src/core/initializer.test.js +0 -101
  217. package/dist/src/core/initializer.test.js.map +0 -1
  218. package/dist/src/core/theme.test.d.ts +0 -6
  219. package/dist/src/core/theme.test.js +0 -46
  220. package/dist/src/core/theme.test.js.map +0 -1
  221. package/dist/src/deferred.test.d.ts +0 -6
  222. package/dist/src/deferred.test.js +0 -164
  223. package/dist/src/deferred.test.js.map +0 -1
  224. package/dist/src/gemini.test.d.ts +0 -6
  225. package/dist/src/gemini.test.js +0 -1334
  226. package/dist/src/gemini.test.js.map +0 -1
  227. package/dist/src/gemini_cleanup.test.d.ts +0 -6
  228. package/dist/src/gemini_cleanup.test.js +0 -208
  229. package/dist/src/gemini_cleanup.test.js.map +0 -1
  230. package/dist/src/nonInteractiveCli.test.d.ts +0 -6
  231. package/dist/src/nonInteractiveCli.test.js +0 -1687
  232. package/dist/src/nonInteractiveCli.test.js.map +0 -1
  233. package/dist/src/services/BuiltinCommandLoader.test.d.ts +0 -6
  234. package/dist/src/services/BuiltinCommandLoader.test.js +0 -254
  235. package/dist/src/services/BuiltinCommandLoader.test.js.map +0 -1
  236. package/dist/src/services/CommandService.test.d.ts +0 -6
  237. package/dist/src/services/CommandService.test.js +0 -234
  238. package/dist/src/services/CommandService.test.js.map +0 -1
  239. package/dist/src/services/FileCommandLoader.test.d.ts +0 -6
  240. package/dist/src/services/FileCommandLoader.test.js +0 -1102
  241. package/dist/src/services/FileCommandLoader.test.js.map +0 -1
  242. package/dist/src/services/McpPromptLoader.test.d.ts +0 -6
  243. package/dist/src/services/McpPromptLoader.test.js +0 -411
  244. package/dist/src/services/McpPromptLoader.test.js.map +0 -1
  245. package/dist/src/services/prompt-processors/argumentProcessor.test.d.ts +0 -6
  246. package/dist/src/services/prompt-processors/argumentProcessor.test.js +0 -40
  247. package/dist/src/services/prompt-processors/argumentProcessor.test.js.map +0 -1
  248. package/dist/src/services/prompt-processors/atFileProcessor.test.d.ts +0 -6
  249. package/dist/src/services/prompt-processors/atFileProcessor.test.js +0 -174
  250. package/dist/src/services/prompt-processors/atFileProcessor.test.js.map +0 -1
  251. package/dist/src/services/prompt-processors/injectionParser.test.d.ts +0 -6
  252. package/dist/src/services/prompt-processors/injectionParser.test.js +0 -189
  253. package/dist/src/services/prompt-processors/injectionParser.test.js.map +0 -1
  254. package/dist/src/services/prompt-processors/shellProcessor.test.d.ts +0 -6
  255. package/dist/src/services/prompt-processors/shellProcessor.test.js +0 -514
  256. package/dist/src/services/prompt-processors/shellProcessor.test.js.map +0 -1
  257. package/dist/src/test-utils/mockCommandContext.test.d.ts +0 -6
  258. package/dist/src/test-utils/mockCommandContext.test.js +0 -51
  259. package/dist/src/test-utils/mockCommandContext.test.js.map +0 -1
  260. package/dist/src/test-utils/render.test.d.ts +0 -6
  261. package/dist/src/test-utils/render.test.js +0 -79
  262. package/dist/src/test-utils/render.test.js.map +0 -1
  263. package/dist/src/ui/App.test.d.ts +0 -6
  264. package/dist/src/ui/App.test.js +0 -218
  265. package/dist/src/ui/App.test.js.map +0 -1
  266. package/dist/src/ui/AppContainer.test.d.ts +0 -6
  267. package/dist/src/ui/AppContainer.test.js +0 -2072
  268. package/dist/src/ui/AppContainer.test.js.map +0 -1
  269. package/dist/src/ui/IdeIntegrationNudge.test.d.ts +0 -6
  270. package/dist/src/ui/IdeIntegrationNudge.test.js +0 -158
  271. package/dist/src/ui/IdeIntegrationNudge.test.js.map +0 -1
  272. package/dist/src/ui/auth/ApiAuthDialog.test.d.ts +0 -6
  273. package/dist/src/ui/auth/ApiAuthDialog.test.js +0 -109
  274. package/dist/src/ui/auth/ApiAuthDialog.test.js.map +0 -1
  275. package/dist/src/ui/auth/AuthDialog.test.d.ts +0 -6
  276. package/dist/src/ui/auth/AuthDialog.test.js +0 -309
  277. package/dist/src/ui/auth/AuthDialog.test.js.map +0 -1
  278. package/dist/src/ui/auth/AuthInProgress.test.d.ts +0 -6
  279. package/dist/src/ui/auth/AuthInProgress.test.js +0 -81
  280. package/dist/src/ui/auth/AuthInProgress.test.js.map +0 -1
  281. package/dist/src/ui/auth/LoginWithGoogleRestartDialog.test.d.ts +0 -6
  282. package/dist/src/ui/auth/LoginWithGoogleRestartDialog.test.js +0 -66
  283. package/dist/src/ui/auth/LoginWithGoogleRestartDialog.test.js.map +0 -1
  284. package/dist/src/ui/auth/useAuth.test.d.ts +0 -6
  285. package/dist/src/ui/auth/useAuth.test.js +0 -189
  286. package/dist/src/ui/auth/useAuth.test.js.map +0 -1
  287. package/dist/src/ui/commands/aboutCommand.test.d.ts +0 -6
  288. package/dist/src/ui/commands/aboutCommand.test.js +0 -143
  289. package/dist/src/ui/commands/aboutCommand.test.js.map +0 -1
  290. package/dist/src/ui/commands/agentsCommand.test.d.ts +0 -6
  291. package/dist/src/ui/commands/agentsCommand.test.js +0 -344
  292. package/dist/src/ui/commands/agentsCommand.test.js.map +0 -1
  293. package/dist/src/ui/commands/authCommand.test.d.ts +0 -6
  294. package/dist/src/ui/commands/authCommand.test.js +0 -98
  295. package/dist/src/ui/commands/authCommand.test.js.map +0 -1
  296. package/dist/src/ui/commands/bugCommand.test.d.ts +0 -6
  297. package/dist/src/ui/commands/bugCommand.test.js +0 -186
  298. package/dist/src/ui/commands/bugCommand.test.js.map +0 -1
  299. package/dist/src/ui/commands/chatCommand.test.d.ts +0 -6
  300. package/dist/src/ui/commands/chatCommand.test.js +0 -620
  301. package/dist/src/ui/commands/chatCommand.test.js.map +0 -1
  302. package/dist/src/ui/commands/clearCommand.test.d.ts +0 -6
  303. package/dist/src/ui/commands/clearCommand.test.js +0 -87
  304. package/dist/src/ui/commands/clearCommand.test.js.map +0 -1
  305. package/dist/src/ui/commands/compressCommand.test.d.ts +0 -6
  306. package/dist/src/ui/commands/compressCommand.test.js +0 -98
  307. package/dist/src/ui/commands/compressCommand.test.js.map +0 -1
  308. package/dist/src/ui/commands/copyCommand.test.d.ts +0 -6
  309. package/dist/src/ui/commands/copyCommand.test.js +0 -242
  310. package/dist/src/ui/commands/copyCommand.test.js.map +0 -1
  311. package/dist/src/ui/commands/corgiCommand.test.d.ts +0 -6
  312. package/dist/src/ui/commands/corgiCommand.test.js +0 -28
  313. package/dist/src/ui/commands/corgiCommand.test.js.map +0 -1
  314. package/dist/src/ui/commands/directoryCommand.test.d.ts +0 -6
  315. package/dist/src/ui/commands/directoryCommand.test.js +0 -353
  316. package/dist/src/ui/commands/directoryCommand.test.js.map +0 -1
  317. package/dist/src/ui/commands/docsCommand.test.d.ts +0 -6
  318. package/dist/src/ui/commands/docsCommand.test.js +0 -72
  319. package/dist/src/ui/commands/docsCommand.test.js.map +0 -1
  320. package/dist/src/ui/commands/editorCommand.test.d.ts +0 -6
  321. package/dist/src/ui/commands/editorCommand.test.js +0 -27
  322. package/dist/src/ui/commands/editorCommand.test.js.map +0 -1
  323. package/dist/src/ui/commands/extensionsCommand.test.d.ts +0 -6
  324. package/dist/src/ui/commands/extensionsCommand.test.js +0 -778
  325. package/dist/src/ui/commands/extensionsCommand.test.js.map +0 -1
  326. package/dist/src/ui/commands/helpCommand.test.d.ts +0 -6
  327. package/dist/src/ui/commands/helpCommand.test.js +0 -42
  328. package/dist/src/ui/commands/helpCommand.test.js.map +0 -1
  329. package/dist/src/ui/commands/hooksCommand.test.d.ts +0 -6
  330. package/dist/src/ui/commands/hooksCommand.test.js +0 -572
  331. package/dist/src/ui/commands/hooksCommand.test.js.map +0 -1
  332. package/dist/src/ui/commands/ideCommand.test.d.ts +0 -6
  333. package/dist/src/ui/commands/ideCommand.test.js +0 -203
  334. package/dist/src/ui/commands/ideCommand.test.js.map +0 -1
  335. package/dist/src/ui/commands/initCommand.test.d.ts +0 -6
  336. package/dist/src/ui/commands/initCommand.test.js +0 -84
  337. package/dist/src/ui/commands/initCommand.test.js.map +0 -1
  338. package/dist/src/ui/commands/mcpCommand.test.d.ts +0 -6
  339. package/dist/src/ui/commands/mcpCommand.test.js +0 -189
  340. package/dist/src/ui/commands/mcpCommand.test.js.map +0 -1
  341. package/dist/src/ui/commands/memoryCommand.test.d.ts +0 -6
  342. package/dist/src/ui/commands/memoryCommand.test.js +0 -350
  343. package/dist/src/ui/commands/memoryCommand.test.js.map +0 -1
  344. package/dist/src/ui/commands/modelCommand.test.d.ts +0 -6
  345. package/dist/src/ui/commands/modelCommand.test.js +0 -41
  346. package/dist/src/ui/commands/modelCommand.test.js.map +0 -1
  347. package/dist/src/ui/commands/permissionsCommand.test.d.ts +0 -6
  348. package/dist/src/ui/commands/permissionsCommand.test.js +0 -86
  349. package/dist/src/ui/commands/permissionsCommand.test.js.map +0 -1
  350. package/dist/src/ui/commands/policiesCommand.test.d.ts +0 -6
  351. package/dist/src/ui/commands/policiesCommand.test.js +0 -87
  352. package/dist/src/ui/commands/policiesCommand.test.js.map +0 -1
  353. package/dist/src/ui/commands/privacyCommand.test.d.ts +0 -6
  354. package/dist/src/ui/commands/privacyCommand.test.js +0 -32
  355. package/dist/src/ui/commands/privacyCommand.test.js.map +0 -1
  356. package/dist/src/ui/commands/quitCommand.test.d.ts +0 -6
  357. package/dist/src/ui/commands/quitCommand.test.js +0 -50
  358. package/dist/src/ui/commands/quitCommand.test.js.map +0 -1
  359. package/dist/src/ui/commands/restoreCommand.test.d.ts +0 -6
  360. package/dist/src/ui/commands/restoreCommand.test.js +0 -190
  361. package/dist/src/ui/commands/restoreCommand.test.js.map +0 -1
  362. package/dist/src/ui/commands/rewindCommand.test.d.ts +0 -6
  363. package/dist/src/ui/commands/rewindCommand.test.js +0 -242
  364. package/dist/src/ui/commands/rewindCommand.test.js.map +0 -1
  365. package/dist/src/ui/commands/settingsCommand.test.d.ts +0 -6
  366. package/dist/src/ui/commands/settingsCommand.test.js +0 -30
  367. package/dist/src/ui/commands/settingsCommand.test.js.map +0 -1
  368. package/dist/src/ui/commands/setupGithubCommand.test.d.ts +0 -6
  369. package/dist/src/ui/commands/setupGithubCommand.test.js +0 -238
  370. package/dist/src/ui/commands/setupGithubCommand.test.js.map +0 -1
  371. package/dist/src/ui/commands/skillsCommand.test.d.ts +0 -6
  372. package/dist/src/ui/commands/skillsCommand.test.js +0 -426
  373. package/dist/src/ui/commands/skillsCommand.test.js.map +0 -1
  374. package/dist/src/ui/commands/statsCommand.test.d.ts +0 -6
  375. package/dist/src/ui/commands/statsCommand.test.js +0 -70
  376. package/dist/src/ui/commands/statsCommand.test.js.map +0 -1
  377. package/dist/src/ui/commands/terminalSetupCommand.test.d.ts +0 -6
  378. package/dist/src/ui/commands/terminalSetupCommand.test.js +0 -66
  379. package/dist/src/ui/commands/terminalSetupCommand.test.js.map +0 -1
  380. package/dist/src/ui/commands/themeCommand.test.d.ts +0 -6
  381. package/dist/src/ui/commands/themeCommand.test.js +0 -32
  382. package/dist/src/ui/commands/themeCommand.test.js.map +0 -1
  383. package/dist/src/ui/commands/toolsCommand.test.d.ts +0 -6
  384. package/dist/src/ui/commands/toolsCommand.test.js +0 -100
  385. package/dist/src/ui/commands/toolsCommand.test.js.map +0 -1
  386. package/dist/src/ui/components/AboutBox.test.d.ts +0 -6
  387. package/dist/src/ui/components/AboutBox.test.js +0 -59
  388. package/dist/src/ui/components/AboutBox.test.js.map +0 -1
  389. package/dist/src/ui/components/AdminSettingsChangedDialog.test.d.ts +0 -6
  390. package/dist/src/ui/components/AdminSettingsChangedDialog.test.js +0 -43
  391. package/dist/src/ui/components/AdminSettingsChangedDialog.test.js.map +0 -1
  392. package/dist/src/ui/components/AgentConfigDialog.test.d.ts +0 -6
  393. package/dist/src/ui/components/AgentConfigDialog.test.js +0 -241
  394. package/dist/src/ui/components/AgentConfigDialog.test.js.map +0 -1
  395. package/dist/src/ui/components/AlternateBufferQuittingDisplay.test.d.ts +0 -6
  396. package/dist/src/ui/components/AlternateBufferQuittingDisplay.test.js +0 -190
  397. package/dist/src/ui/components/AlternateBufferQuittingDisplay.test.js.map +0 -1
  398. package/dist/src/ui/components/AnsiOutput.test.d.ts +0 -6
  399. package/dist/src/ui/components/AnsiOutput.test.js +0 -92
  400. package/dist/src/ui/components/AnsiOutput.test.js.map +0 -1
  401. package/dist/src/ui/components/AppHeader.test.d.ts +0 -6
  402. package/dist/src/ui/components/AppHeader.test.js +0 -225
  403. package/dist/src/ui/components/AppHeader.test.js.map +0 -1
  404. package/dist/src/ui/components/ApprovalModeIndicator.test.d.ts +0 -6
  405. package/dist/src/ui/components/ApprovalModeIndicator.test.js +0 -37
  406. package/dist/src/ui/components/ApprovalModeIndicator.test.js.map +0 -1
  407. package/dist/src/ui/components/AskUserDialog.test.d.ts +0 -6
  408. package/dist/src/ui/components/AskUserDialog.test.js +0 -598
  409. package/dist/src/ui/components/AskUserDialog.test.js.map +0 -1
  410. package/dist/src/ui/components/Banner.test.d.ts +0 -6
  411. package/dist/src/ui/components/Banner.test.js +0 -24
  412. package/dist/src/ui/components/Banner.test.js.map +0 -1
  413. package/dist/src/ui/components/CliSpinner.test.d.ts +0 -6
  414. package/dist/src/ui/components/CliSpinner.test.js +0 -28
  415. package/dist/src/ui/components/CliSpinner.test.js.map +0 -1
  416. package/dist/src/ui/components/Composer.test.d.ts +0 -6
  417. package/dist/src/ui/components/Composer.test.js +0 -383
  418. package/dist/src/ui/components/Composer.test.js.map +0 -1
  419. package/dist/src/ui/components/ConfigInitDisplay.test.d.ts +0 -6
  420. package/dist/src/ui/components/ConfigInitDisplay.test.js +0 -117
  421. package/dist/src/ui/components/ConfigInitDisplay.test.js.map +0 -1
  422. package/dist/src/ui/components/ConsentPrompt.test.d.ts +0 -6
  423. package/dist/src/ui/components/ConsentPrompt.test.js +0 -77
  424. package/dist/src/ui/components/ConsentPrompt.test.js.map +0 -1
  425. package/dist/src/ui/components/ConsoleSummaryDisplay.test.d.ts +0 -6
  426. package/dist/src/ui/components/ConsoleSummaryDisplay.test.js +0 -26
  427. package/dist/src/ui/components/ConsoleSummaryDisplay.test.js.map +0 -1
  428. package/dist/src/ui/components/ContextSummaryDisplay.test.d.ts +0 -6
  429. package/dist/src/ui/components/ContextSummaryDisplay.test.js +0 -102
  430. package/dist/src/ui/components/ContextSummaryDisplay.test.js.map +0 -1
  431. package/dist/src/ui/components/ContextUsageDisplay.test.d.ts +0 -6
  432. package/dist/src/ui/components/ContextUsageDisplay.test.js +0 -43
  433. package/dist/src/ui/components/ContextUsageDisplay.test.js.map +0 -1
  434. package/dist/src/ui/components/CopyModeWarning.test.d.ts +0 -6
  435. package/dist/src/ui/components/CopyModeWarning.test.js +0 -33
  436. package/dist/src/ui/components/CopyModeWarning.test.js.map +0 -1
  437. package/dist/src/ui/components/DebugProfiler.test.d.ts +0 -6
  438. package/dist/src/ui/components/DebugProfiler.test.js +0 -229
  439. package/dist/src/ui/components/DebugProfiler.test.js.map +0 -1
  440. package/dist/src/ui/components/DetailedMessagesDisplay.test.d.ts +0 -6
  441. package/dist/src/ui/components/DetailedMessagesDisplay.test.js +0 -39
  442. package/dist/src/ui/components/DetailedMessagesDisplay.test.js.map +0 -1
  443. package/dist/src/ui/components/DialogManager.test.d.ts +0 -6
  444. package/dist/src/ui/components/DialogManager.test.js +0 -177
  445. package/dist/src/ui/components/DialogManager.test.js.map +0 -1
  446. package/dist/src/ui/components/EditorSettingsDialog.test.d.ts +0 -6
  447. package/dist/src/ui/components/EditorSettingsDialog.test.js +0 -119
  448. package/dist/src/ui/components/EditorSettingsDialog.test.js.map +0 -1
  449. package/dist/src/ui/components/ExitWarning.test.d.ts +0 -6
  450. package/dist/src/ui/components/ExitWarning.test.js +0 -54
  451. package/dist/src/ui/components/ExitWarning.test.js.map +0 -1
  452. package/dist/src/ui/components/FolderTrustDialog.test.d.ts +0 -6
  453. package/dist/src/ui/components/FolderTrustDialog.test.js +0 -102
  454. package/dist/src/ui/components/FolderTrustDialog.test.js.map +0 -1
  455. package/dist/src/ui/components/Footer.test.d.ts +0 -6
  456. package/dist/src/ui/components/Footer.test.js +0 -321
  457. package/dist/src/ui/components/Footer.test.js.map +0 -1
  458. package/dist/src/ui/components/GeminiRespondingSpinner.test.d.ts +0 -6
  459. package/dist/src/ui/components/GeminiRespondingSpinner.test.js +0 -61
  460. package/dist/src/ui/components/GeminiRespondingSpinner.test.js.map +0 -1
  461. package/dist/src/ui/components/GradientRegression.test.d.ts +0 -6
  462. package/dist/src/ui/components/GradientRegression.test.js +0 -105
  463. package/dist/src/ui/components/GradientRegression.test.js.map +0 -1
  464. package/dist/src/ui/components/Header.test.d.ts +0 -6
  465. package/dist/src/ui/components/Header.test.js +0 -147
  466. package/dist/src/ui/components/Header.test.js.map +0 -1
  467. package/dist/src/ui/components/Help.test.d.ts +0 -6
  468. package/dist/src/ui/components/Help.test.js +0 -67
  469. package/dist/src/ui/components/Help.test.js.map +0 -1
  470. package/dist/src/ui/components/HistoryItemDisplay.test.d.ts +0 -6
  471. package/dist/src/ui/components/HistoryItemDisplay.test.js +0 -207
  472. package/dist/src/ui/components/HistoryItemDisplay.test.js.map +0 -1
  473. package/dist/src/ui/components/HookStatusDisplay.test.d.ts +0 -6
  474. package/dist/src/ui/components/HookStatusDisplay.test.js +0 -51
  475. package/dist/src/ui/components/HookStatusDisplay.test.js.map +0 -1
  476. package/dist/src/ui/components/IdeTrustChangeDialog.test.d.ts +0 -6
  477. package/dist/src/ui/components/IdeTrustChangeDialog.test.js +0 -58
  478. package/dist/src/ui/components/IdeTrustChangeDialog.test.js.map +0 -1
  479. package/dist/src/ui/components/InputPrompt.test.d.ts +0 -6
  480. package/dist/src/ui/components/InputPrompt.test.js +0 -2596
  481. package/dist/src/ui/components/InputPrompt.test.js.map +0 -1
  482. package/dist/src/ui/components/LoadingIndicator.test.d.ts +0 -6
  483. package/dist/src/ui/components/LoadingIndicator.test.js +0 -207
  484. package/dist/src/ui/components/LoadingIndicator.test.js.map +0 -1
  485. package/dist/src/ui/components/LogoutConfirmationDialog.test.d.ts +0 -6
  486. package/dist/src/ui/components/LogoutConfirmationDialog.test.js +0 -59
  487. package/dist/src/ui/components/LogoutConfirmationDialog.test.js.map +0 -1
  488. package/dist/src/ui/components/LoopDetectionConfirmation.test.d.ts +0 -6
  489. package/dist/src/ui/components/LoopDetectionConfirmation.test.js +0 -25
  490. package/dist/src/ui/components/LoopDetectionConfirmation.test.js.map +0 -1
  491. package/dist/src/ui/components/MainContent.test.d.ts +0 -6
  492. package/dist/src/ui/components/MainContent.test.js +0 -83
  493. package/dist/src/ui/components/MainContent.test.js.map +0 -1
  494. package/dist/src/ui/components/MemoryUsageDisplay.test.d.ts +0 -6
  495. package/dist/src/ui/components/MemoryUsageDisplay.test.js +0 -49
  496. package/dist/src/ui/components/MemoryUsageDisplay.test.js.map +0 -1
  497. package/dist/src/ui/components/ModelDialog.test.d.ts +0 -6
  498. package/dist/src/ui/components/ModelDialog.test.js +0 -197
  499. package/dist/src/ui/components/ModelDialog.test.js.map +0 -1
  500. package/dist/src/ui/components/ModelStatsDisplay.test.d.ts +0 -6
  501. package/dist/src/ui/components/ModelStatsDisplay.test.js +0 -343
  502. package/dist/src/ui/components/ModelStatsDisplay.test.js.map +0 -1
  503. package/dist/src/ui/components/MultiFolderTrustDialog.test.d.ts +0 -6
  504. package/dist/src/ui/components/MultiFolderTrustDialog.test.js +0 -162
  505. package/dist/src/ui/components/MultiFolderTrustDialog.test.js.map +0 -1
  506. package/dist/src/ui/components/NewAgentsNotification.test.d.ts +0 -6
  507. package/dist/src/ui/components/NewAgentsNotification.test.js +0 -48
  508. package/dist/src/ui/components/NewAgentsNotification.test.js.map +0 -1
  509. package/dist/src/ui/components/Notifications.test.d.ts +0 -6
  510. package/dist/src/ui/components/Notifications.test.js +0 -164
  511. package/dist/src/ui/components/Notifications.test.js.map +0 -1
  512. package/dist/src/ui/components/PermissionsModifyTrustDialog.test.d.ts +0 -6
  513. package/dist/src/ui/components/PermissionsModifyTrustDialog.test.js +0 -162
  514. package/dist/src/ui/components/PermissionsModifyTrustDialog.test.js.map +0 -1
  515. package/dist/src/ui/components/ProQuotaDialog.test.d.ts +0 -6
  516. package/dist/src/ui/components/ProQuotaDialog.test.js +0 -191
  517. package/dist/src/ui/components/ProQuotaDialog.test.js.map +0 -1
  518. package/dist/src/ui/components/QueuedMessageDisplay.test.d.ts +0 -6
  519. package/dist/src/ui/components/QueuedMessageDisplay.test.js +0 -65
  520. package/dist/src/ui/components/QueuedMessageDisplay.test.js.map +0 -1
  521. package/dist/src/ui/components/QuittingDisplay.test.d.ts +0 -6
  522. package/dist/src/ui/components/QuittingDisplay.test.js +0 -49
  523. package/dist/src/ui/components/QuittingDisplay.test.js.map +0 -1
  524. package/dist/src/ui/components/RawMarkdownIndicator.test.d.ts +0 -6
  525. package/dist/src/ui/components/RawMarkdownIndicator.test.js +0 -34
  526. package/dist/src/ui/components/RawMarkdownIndicator.test.js.map +0 -1
  527. package/dist/src/ui/components/RewindConfirmation.test.d.ts +0 -6
  528. package/dist/src/ui/components/RewindConfirmation.test.js +0 -53
  529. package/dist/src/ui/components/RewindConfirmation.test.js.map +0 -1
  530. package/dist/src/ui/components/RewindViewer.test.d.ts +0 -6
  531. package/dist/src/ui/components/RewindViewer.test.js +0 -241
  532. package/dist/src/ui/components/RewindViewer.test.js.map +0 -1
  533. package/dist/src/ui/components/SessionBrowser.test.d.ts +0 -6
  534. package/dist/src/ui/components/SessionBrowser.test.js +0 -256
  535. package/dist/src/ui/components/SessionBrowser.test.js.map +0 -1
  536. package/dist/src/ui/components/SessionSummaryDisplay.test.d.ts +0 -6
  537. package/dist/src/ui/components/SessionSummaryDisplay.test.js +0 -75
  538. package/dist/src/ui/components/SessionSummaryDisplay.test.js.map +0 -1
  539. package/dist/src/ui/components/SettingsDialog.test.d.ts +0 -6
  540. package/dist/src/ui/components/SettingsDialog.test.js +0 -1150
  541. package/dist/src/ui/components/SettingsDialog.test.js.map +0 -1
  542. package/dist/src/ui/components/ShellInputPrompt.test.d.ts +0 -6
  543. package/dist/src/ui/components/ShellInputPrompt.test.js +0 -91
  544. package/dist/src/ui/components/ShellInputPrompt.test.js.map +0 -1
  545. package/dist/src/ui/components/ShellModeIndicator.test.d.ts +0 -6
  546. package/dist/src/ui/components/ShellModeIndicator.test.js +0 -17
  547. package/dist/src/ui/components/ShellModeIndicator.test.js.map +0 -1
  548. package/dist/src/ui/components/ShowMoreLines.test.d.ts +0 -6
  549. package/dist/src/ui/components/ShowMoreLines.test.js +0 -40
  550. package/dist/src/ui/components/ShowMoreLines.test.js.map +0 -1
  551. package/dist/src/ui/components/StatsDisplay.test.d.ts +0 -6
  552. package/dist/src/ui/components/StatsDisplay.test.js +0 -438
  553. package/dist/src/ui/components/StatsDisplay.test.js.map +0 -1
  554. package/dist/src/ui/components/StatusDisplay.test.d.ts +0 -6
  555. package/dist/src/ui/components/StatusDisplay.test.js +0 -155
  556. package/dist/src/ui/components/StatusDisplay.test.js.map +0 -1
  557. package/dist/src/ui/components/StickyHeader.test.d.ts +0 -6
  558. package/dist/src/ui/components/StickyHeader.test.js +0 -17
  559. package/dist/src/ui/components/StickyHeader.test.js.map +0 -1
  560. package/dist/src/ui/components/SuggestionsDisplay.test.d.ts +0 -6
  561. package/dist/src/ui/components/SuggestionsDisplay.test.js +0 -56
  562. package/dist/src/ui/components/SuggestionsDisplay.test.js.map +0 -1
  563. package/dist/src/ui/components/Table.test.d.ts +0 -6
  564. package/dist/src/ui/components/Table.test.js +0 -53
  565. package/dist/src/ui/components/Table.test.js.map +0 -1
  566. package/dist/src/ui/components/ThemeDialog.test.d.ts +0 -6
  567. package/dist/src/ui/components/ThemeDialog.test.js +0 -167
  568. package/dist/src/ui/components/ThemeDialog.test.js.map +0 -1
  569. package/dist/src/ui/components/ThemedGradient.test.d.ts +0 -6
  570. package/dist/src/ui/components/ThemedGradient.test.js +0 -30
  571. package/dist/src/ui/components/ThemedGradient.test.js.map +0 -1
  572. package/dist/src/ui/components/Tips.test.d.ts +0 -6
  573. package/dist/src/ui/components/Tips.test.js +0 -23
  574. package/dist/src/ui/components/Tips.test.js.map +0 -1
  575. package/dist/src/ui/components/ToolConfirmationQueue.test.d.ts +0 -6
  576. package/dist/src/ui/components/ToolConfirmationQueue.test.js +0 -71
  577. package/dist/src/ui/components/ToolConfirmationQueue.test.js.map +0 -1
  578. package/dist/src/ui/components/ToolStatsDisplay.test.d.ts +0 -6
  579. package/dist/src/ui/components/ToolStatsDisplay.test.js +0 -227
  580. package/dist/src/ui/components/ToolStatsDisplay.test.js.map +0 -1
  581. package/dist/src/ui/components/UpdateNotification.test.d.ts +0 -6
  582. package/dist/src/ui/components/UpdateNotification.test.js +0 -16
  583. package/dist/src/ui/components/UpdateNotification.test.js.map +0 -1
  584. package/dist/src/ui/components/ValidationDialog.test.d.ts +0 -6
  585. package/dist/src/ui/components/ValidationDialog.test.js +0 -153
  586. package/dist/src/ui/components/ValidationDialog.test.js.map +0 -1
  587. package/dist/src/ui/components/messages/CompressionMessage.test.d.ts +0 -6
  588. package/dist/src/ui/components/messages/CompressionMessage.test.js +0 -191
  589. package/dist/src/ui/components/messages/CompressionMessage.test.js.map +0 -1
  590. package/dist/src/ui/components/messages/DiffRenderer.test.d.ts +0 -6
  591. package/dist/src/ui/components/messages/DiffRenderer.test.js +0 -240
  592. package/dist/src/ui/components/messages/DiffRenderer.test.js.map +0 -1
  593. package/dist/src/ui/components/messages/ErrorMessage.test.d.ts +0 -6
  594. package/dist/src/ui/components/messages/ErrorMessage.test.js +0 -23
  595. package/dist/src/ui/components/messages/ErrorMessage.test.js.map +0 -1
  596. package/dist/src/ui/components/messages/GeminiMessage.test.d.ts +0 -6
  597. package/dist/src/ui/components/messages/GeminiMessage.test.js +0 -35
  598. package/dist/src/ui/components/messages/GeminiMessage.test.js.map +0 -1
  599. package/dist/src/ui/components/messages/InfoMessage.test.d.ts +0 -6
  600. package/dist/src/ui/components/messages/InfoMessage.test.js +0 -28
  601. package/dist/src/ui/components/messages/InfoMessage.test.js.map +0 -1
  602. package/dist/src/ui/components/messages/RedirectionConfirmation.test.d.ts +0 -6
  603. package/dist/src/ui/components/messages/RedirectionConfirmation.test.js +0 -33
  604. package/dist/src/ui/components/messages/RedirectionConfirmation.test.js.map +0 -1
  605. package/dist/src/ui/components/messages/ShellToolMessage.test.d.ts +0 -6
  606. package/dist/src/ui/components/messages/ShellToolMessage.test.js +0 -123
  607. package/dist/src/ui/components/messages/ShellToolMessage.test.js.map +0 -1
  608. package/dist/src/ui/components/messages/Todo.test.d.ts +0 -6
  609. package/dist/src/ui/components/messages/Todo.test.js +0 -114
  610. package/dist/src/ui/components/messages/Todo.test.js.map +0 -1
  611. package/dist/src/ui/components/messages/ToolConfirmationMessage.test.d.ts +0 -6
  612. package/dist/src/ui/components/messages/ToolConfirmationMessage.test.js +0 -232
  613. package/dist/src/ui/components/messages/ToolConfirmationMessage.test.js.map +0 -1
  614. package/dist/src/ui/components/messages/ToolGroupMessage.test.d.ts +0 -6
  615. package/dist/src/ui/components/messages/ToolGroupMessage.test.js +0 -529
  616. package/dist/src/ui/components/messages/ToolGroupMessage.test.js.map +0 -1
  617. package/dist/src/ui/components/messages/ToolMessage.test.d.ts +0 -6
  618. package/dist/src/ui/components/messages/ToolMessage.test.js +0 -217
  619. package/dist/src/ui/components/messages/ToolMessage.test.js.map +0 -1
  620. package/dist/src/ui/components/messages/ToolMessageFocusHint.test.d.ts +0 -6
  621. package/dist/src/ui/components/messages/ToolMessageFocusHint.test.js +0 -89
  622. package/dist/src/ui/components/messages/ToolMessageFocusHint.test.js.map +0 -1
  623. package/dist/src/ui/components/messages/ToolMessageRawMarkdown.test.d.ts +0 -6
  624. package/dist/src/ui/components/messages/ToolMessageRawMarkdown.test.js +0 -62
  625. package/dist/src/ui/components/messages/ToolMessageRawMarkdown.test.js.map +0 -1
  626. package/dist/src/ui/components/messages/ToolResultDisplay.test.d.ts +0 -6
  627. package/dist/src/ui/components/messages/ToolResultDisplay.test.js +0 -114
  628. package/dist/src/ui/components/messages/ToolResultDisplay.test.js.map +0 -1
  629. package/dist/src/ui/components/messages/ToolStickyHeaderRegression.test.d.ts +0 -6
  630. package/dist/src/ui/components/messages/ToolStickyHeaderRegression.test.js +0 -134
  631. package/dist/src/ui/components/messages/ToolStickyHeaderRegression.test.js.map +0 -1
  632. package/dist/src/ui/components/messages/UserMessage.test.d.ts +0 -6
  633. package/dist/src/ui/components/messages/UserMessage.test.js +0 -32
  634. package/dist/src/ui/components/messages/UserMessage.test.js.map +0 -1
  635. package/dist/src/ui/components/messages/WarningMessage.test.d.ts +0 -6
  636. package/dist/src/ui/components/messages/WarningMessage.test.js +0 -23
  637. package/dist/src/ui/components/messages/WarningMessage.test.js.map +0 -1
  638. package/dist/src/ui/components/shared/BaseSelectionList.test.d.ts +0 -6
  639. package/dist/src/ui/components/shared/BaseSelectionList.test.js +0 -386
  640. package/dist/src/ui/components/shared/BaseSelectionList.test.js.map +0 -1
  641. package/dist/src/ui/components/shared/BaseSettingsDialog.test.d.ts +0 -6
  642. package/dist/src/ui/components/shared/BaseSettingsDialog.test.js +0 -434
  643. package/dist/src/ui/components/shared/BaseSettingsDialog.test.js.map +0 -1
  644. package/dist/src/ui/components/shared/DescriptiveRadioButtonSelect.test.d.ts +0 -6
  645. package/dist/src/ui/components/shared/DescriptiveRadioButtonSelect.test.js +0 -79
  646. package/dist/src/ui/components/shared/DescriptiveRadioButtonSelect.test.js.map +0 -1
  647. package/dist/src/ui/components/shared/EnumSelector.test.d.ts +0 -6
  648. package/dist/src/ui/components/shared/EnumSelector.test.js +0 -70
  649. package/dist/src/ui/components/shared/EnumSelector.test.js.map +0 -1
  650. package/dist/src/ui/components/shared/ExpandableText.test.d.ts +0 -6
  651. package/dist/src/ui/components/shared/ExpandableText.test.js +0 -88
  652. package/dist/src/ui/components/shared/ExpandableText.test.js.map +0 -1
  653. package/dist/src/ui/components/shared/HalfLinePaddedBox.test.d.ts +0 -6
  654. package/dist/src/ui/components/shared/HalfLinePaddedBox.test.js +0 -34
  655. package/dist/src/ui/components/shared/HalfLinePaddedBox.test.js.map +0 -1
  656. package/dist/src/ui/components/shared/MaxSizedBox.test.d.ts +0 -6
  657. package/dist/src/ui/components/shared/MaxSizedBox.test.js +0 -90
  658. package/dist/src/ui/components/shared/MaxSizedBox.test.js.map +0 -1
  659. package/dist/src/ui/components/shared/RadioButtonSelect.test.d.ts +0 -6
  660. package/dist/src/ui/components/shared/RadioButtonSelect.test.js +0 -134
  661. package/dist/src/ui/components/shared/RadioButtonSelect.test.js.map +0 -1
  662. package/dist/src/ui/components/shared/Scrollable.test.d.ts +0 -6
  663. package/dist/src/ui/components/shared/Scrollable.test.js +0 -74
  664. package/dist/src/ui/components/shared/Scrollable.test.js.map +0 -1
  665. package/dist/src/ui/components/shared/ScrollableList.test.d.ts +0 -6
  666. package/dist/src/ui/components/shared/ScrollableList.test.js +0 -241
  667. package/dist/src/ui/components/shared/ScrollableList.test.js.map +0 -1
  668. package/dist/src/ui/components/shared/TabHeader.test.d.ts +0 -6
  669. package/dist/src/ui/components/shared/TabHeader.test.js +0 -106
  670. package/dist/src/ui/components/shared/TabHeader.test.js.map +0 -1
  671. package/dist/src/ui/components/shared/TextInput.test.d.ts +0 -6
  672. package/dist/src/ui/components/shared/TextInput.test.js +0 -242
  673. package/dist/src/ui/components/shared/TextInput.test.js.map +0 -1
  674. package/dist/src/ui/components/shared/VirtualizedList.test.d.ts +0 -6
  675. package/dist/src/ui/components/shared/VirtualizedList.test.js +0 -171
  676. package/dist/src/ui/components/shared/VirtualizedList.test.js.map +0 -1
  677. package/dist/src/ui/components/shared/performance.test.d.ts +0 -1
  678. package/dist/src/ui/components/shared/performance.test.js +0 -67
  679. package/dist/src/ui/components/shared/performance.test.js.map +0 -1
  680. package/dist/src/ui/components/shared/text-buffer.test.d.ts +0 -6
  681. package/dist/src/ui/components/shared/text-buffer.test.js +0 -2490
  682. package/dist/src/ui/components/shared/text-buffer.test.js.map +0 -1
  683. package/dist/src/ui/components/shared/vim-buffer-actions.test.d.ts +0 -6
  684. package/dist/src/ui/components/shared/vim-buffer-actions.test.js +0 -964
  685. package/dist/src/ui/components/shared/vim-buffer-actions.test.js.map +0 -1
  686. package/dist/src/ui/components/views/ChatList.test.d.ts +0 -6
  687. package/dist/src/ui/components/views/ChatList.test.js +0 -45
  688. package/dist/src/ui/components/views/ChatList.test.js.map +0 -1
  689. package/dist/src/ui/components/views/ExtensionsList.test.d.ts +0 -6
  690. package/dist/src/ui/components/views/ExtensionsList.test.js +0 -148
  691. package/dist/src/ui/components/views/ExtensionsList.test.js.map +0 -1
  692. package/dist/src/ui/components/views/McpStatus.test.d.ts +0 -6
  693. package/dist/src/ui/components/views/McpStatus.test.js +0 -153
  694. package/dist/src/ui/components/views/McpStatus.test.js.map +0 -1
  695. package/dist/src/ui/components/views/SkillsList.test.d.ts +0 -6
  696. package/dist/src/ui/components/views/SkillsList.test.js +0 -97
  697. package/dist/src/ui/components/views/SkillsList.test.js.map +0 -1
  698. package/dist/src/ui/components/views/ToolsList.test.d.ts +0 -6
  699. package/dist/src/ui/components/views/ToolsList.test.js +0 -45
  700. package/dist/src/ui/components/views/ToolsList.test.js.map +0 -1
  701. package/dist/src/ui/contexts/KeypressContext.test.d.ts +0 -6
  702. package/dist/src/ui/contexts/KeypressContext.test.js +0 -957
  703. package/dist/src/ui/contexts/KeypressContext.test.js.map +0 -1
  704. package/dist/src/ui/contexts/MouseContext.test.d.ts +0 -6
  705. package/dist/src/ui/contexts/MouseContext.test.js +0 -198
  706. package/dist/src/ui/contexts/MouseContext.test.js.map +0 -1
  707. package/dist/src/ui/contexts/ScrollProvider.drag.test.d.ts +0 -6
  708. package/dist/src/ui/contexts/ScrollProvider.drag.test.js +0 -319
  709. package/dist/src/ui/contexts/ScrollProvider.drag.test.js.map +0 -1
  710. package/dist/src/ui/contexts/ScrollProvider.test.d.ts +0 -6
  711. package/dist/src/ui/contexts/ScrollProvider.test.js +0 -377
  712. package/dist/src/ui/contexts/ScrollProvider.test.js.map +0 -1
  713. package/dist/src/ui/contexts/SessionContext.test.d.ts +0 -6
  714. package/dist/src/ui/contexts/SessionContext.test.js +0 -198
  715. package/dist/src/ui/contexts/SessionContext.test.js.map +0 -1
  716. package/dist/src/ui/contexts/ToolActionsContext.test.d.ts +0 -6
  717. package/dist/src/ui/contexts/ToolActionsContext.test.js +0 -166
  718. package/dist/src/ui/contexts/ToolActionsContext.test.js.map +0 -1
  719. package/dist/src/ui/hooks/atCommandProcessor.test.d.ts +0 -6
  720. package/dist/src/ui/hooks/atCommandProcessor.test.js +0 -1032
  721. package/dist/src/ui/hooks/atCommandProcessor.test.js.map +0 -1
  722. package/dist/src/ui/hooks/atCommandProcessor_agents.test.d.ts +0 -6
  723. package/dist/src/ui/hooks/atCommandProcessor_agents.test.js +0 -183
  724. package/dist/src/ui/hooks/atCommandProcessor_agents.test.js.map +0 -1
  725. package/dist/src/ui/hooks/shellCommandProcessor.test.d.ts +0 -6
  726. package/dist/src/ui/hooks/shellCommandProcessor.test.js +0 -521
  727. package/dist/src/ui/hooks/shellCommandProcessor.test.js.map +0 -1
  728. package/dist/src/ui/hooks/slashCommandProcessor.test.d.ts +0 -6
  729. package/dist/src/ui/hooks/slashCommandProcessor.test.js +0 -796
  730. package/dist/src/ui/hooks/slashCommandProcessor.test.js.map +0 -1
  731. package/dist/src/ui/hooks/toolMapping.test.d.ts +0 -6
  732. package/dist/src/ui/hooks/toolMapping.test.js +0 -209
  733. package/dist/src/ui/hooks/toolMapping.test.js.map +0 -1
  734. package/dist/src/ui/hooks/useAnimatedScrollbar.test.d.ts +0 -6
  735. package/dist/src/ui/hooks/useAnimatedScrollbar.test.js +0 -85
  736. package/dist/src/ui/hooks/useAnimatedScrollbar.test.js.map +0 -1
  737. package/dist/src/ui/hooks/useApprovalModeIndicator.test.d.ts +0 -6
  738. package/dist/src/ui/hooks/useApprovalModeIndicator.test.js +0 -435
  739. package/dist/src/ui/hooks/useApprovalModeIndicator.test.js.map +0 -1
  740. package/dist/src/ui/hooks/useAtCompletion.test.d.ts +0 -6
  741. package/dist/src/ui/hooks/useAtCompletion.test.js +0 -417
  742. package/dist/src/ui/hooks/useAtCompletion.test.js.map +0 -1
  743. package/dist/src/ui/hooks/useAtCompletion_agents.test.d.ts +0 -6
  744. package/dist/src/ui/hooks/useAtCompletion_agents.test.js +0 -87
  745. package/dist/src/ui/hooks/useAtCompletion_agents.test.js.map +0 -1
  746. package/dist/src/ui/hooks/useBanner.test.d.ts +0 -6
  747. package/dist/src/ui/hooks/useBanner.test.js +0 -92
  748. package/dist/src/ui/hooks/useBanner.test.js.map +0 -1
  749. package/dist/src/ui/hooks/useBatchedScroll.test.d.ts +0 -6
  750. package/dist/src/ui/hooks/useBatchedScroll.test.js +0 -62
  751. package/dist/src/ui/hooks/useBatchedScroll.test.js.map +0 -1
  752. package/dist/src/ui/hooks/useCommandCompletion.test.d.ts +0 -6
  753. package/dist/src/ui/hooks/useCommandCompletion.test.js +0 -462
  754. package/dist/src/ui/hooks/useCommandCompletion.test.js.map +0 -1
  755. package/dist/src/ui/hooks/useConsoleMessages.test.d.ts +0 -6
  756. package/dist/src/ui/hooks/useConsoleMessages.test.js +0 -159
  757. package/dist/src/ui/hooks/useConsoleMessages.test.js.map +0 -1
  758. package/dist/src/ui/hooks/useEditorSettings.test.d.ts +0 -6
  759. package/dist/src/ui/hooks/useEditorSettings.test.js +0 -179
  760. package/dist/src/ui/hooks/useEditorSettings.test.js.map +0 -1
  761. package/dist/src/ui/hooks/useExtensionUpdates.test.d.ts +0 -6
  762. package/dist/src/ui/hooks/useExtensionUpdates.test.js +0 -279
  763. package/dist/src/ui/hooks/useExtensionUpdates.test.js.map +0 -1
  764. package/dist/src/ui/hooks/useFlickerDetector.test.d.ts +0 -6
  765. package/dist/src/ui/hooks/useFlickerDetector.test.js +0 -106
  766. package/dist/src/ui/hooks/useFlickerDetector.test.js.map +0 -1
  767. package/dist/src/ui/hooks/useFocus.test.d.ts +0 -6
  768. package/dist/src/ui/hooks/useFocus.test.js +0 -131
  769. package/dist/src/ui/hooks/useFocus.test.js.map +0 -1
  770. package/dist/src/ui/hooks/useFolderTrust.test.d.ts +0 -6
  771. package/dist/src/ui/hooks/useFolderTrust.test.js +0 -218
  772. package/dist/src/ui/hooks/useFolderTrust.test.js.map +0 -1
  773. package/dist/src/ui/hooks/useGeminiStream.test.d.ts +0 -6
  774. package/dist/src/ui/hooks/useGeminiStream.test.js +0 -2149
  775. package/dist/src/ui/hooks/useGeminiStream.test.js.map +0 -1
  776. package/dist/src/ui/hooks/useGitBranchName.test.d.ts +0 -6
  777. package/dist/src/ui/hooks/useGitBranchName.test.js +0 -183
  778. package/dist/src/ui/hooks/useGitBranchName.test.js.map +0 -1
  779. package/dist/src/ui/hooks/useHistoryManager.test.d.ts +0 -6
  780. package/dist/src/ui/hooks/useHistoryManager.test.js +0 -188
  781. package/dist/src/ui/hooks/useHistoryManager.test.js.map +0 -1
  782. package/dist/src/ui/hooks/useHookDisplayState.test.d.ts +0 -6
  783. package/dist/src/ui/hooks/useHookDisplayState.test.js +0 -180
  784. package/dist/src/ui/hooks/useHookDisplayState.test.js.map +0 -1
  785. package/dist/src/ui/hooks/useIdeTrustListener.test.d.ts +0 -6
  786. package/dist/src/ui/hooks/useIdeTrustListener.test.js +0 -214
  787. package/dist/src/ui/hooks/useIdeTrustListener.test.js.map +0 -1
  788. package/dist/src/ui/hooks/useIncludeDirsTrust.test.d.ts +0 -6
  789. package/dist/src/ui/hooks/useIncludeDirsTrust.test.js +0 -172
  790. package/dist/src/ui/hooks/useIncludeDirsTrust.test.js.map +0 -1
  791. package/dist/src/ui/hooks/useInputHistory.test.d.ts +0 -6
  792. package/dist/src/ui/hooks/useInputHistory.test.js +0 -208
  793. package/dist/src/ui/hooks/useInputHistory.test.js.map +0 -1
  794. package/dist/src/ui/hooks/useInputHistoryStore.test.d.ts +0 -6
  795. package/dist/src/ui/hooks/useInputHistoryStore.test.js +0 -238
  796. package/dist/src/ui/hooks/useInputHistoryStore.test.js.map +0 -1
  797. package/dist/src/ui/hooks/useKeypress.test.d.ts +0 -6
  798. package/dist/src/ui/hooks/useKeypress.test.js +0 -205
  799. package/dist/src/ui/hooks/useKeypress.test.js.map +0 -1
  800. package/dist/src/ui/hooks/useLoadingIndicator.test.d.ts +0 -6
  801. package/dist/src/ui/hooks/useLoadingIndicator.test.js +0 -145
  802. package/dist/src/ui/hooks/useLoadingIndicator.test.js.map +0 -1
  803. package/dist/src/ui/hooks/useMcpStatus.test.d.ts +0 -6
  804. package/dist/src/ui/hooks/useMcpStatus.test.js +0 -69
  805. package/dist/src/ui/hooks/useMcpStatus.test.js.map +0 -1
  806. package/dist/src/ui/hooks/useMemoryMonitor.test.d.ts +0 -6
  807. package/dist/src/ui/hooks/useMemoryMonitor.test.js +0 -62
  808. package/dist/src/ui/hooks/useMemoryMonitor.test.js.map +0 -1
  809. package/dist/src/ui/hooks/useMessageQueue.test.d.ts +0 -6
  810. package/dist/src/ui/hooks/useMessageQueue.test.js +0 -327
  811. package/dist/src/ui/hooks/useMessageQueue.test.js.map +0 -1
  812. package/dist/src/ui/hooks/useModelCommand.test.d.ts +0 -6
  813. package/dist/src/ui/hooks/useModelCommand.test.js +0 -45
  814. package/dist/src/ui/hooks/useModelCommand.test.js.map +0 -1
  815. package/dist/src/ui/hooks/useMouse.test.d.ts +0 -6
  816. package/dist/src/ui/hooks/useMouse.test.js +0 -57
  817. package/dist/src/ui/hooks/useMouse.test.js.map +0 -1
  818. package/dist/src/ui/hooks/useMouseClick.test.d.ts +0 -6
  819. package/dist/src/ui/hooks/useMouseClick.test.js +0 -59
  820. package/dist/src/ui/hooks/useMouseClick.test.js.map +0 -1
  821. package/dist/src/ui/hooks/useMouseDoubleClick.test.d.ts +0 -6
  822. package/dist/src/ui/hooks/useMouseDoubleClick.test.js +0 -125
  823. package/dist/src/ui/hooks/useMouseDoubleClick.test.js.map +0 -1
  824. package/dist/src/ui/hooks/usePermissionsModifyTrust.test.d.ts +0 -6
  825. package/dist/src/ui/hooks/usePermissionsModifyTrust.test.js +0 -291
  826. package/dist/src/ui/hooks/usePermissionsModifyTrust.test.js.map +0 -1
  827. package/dist/src/ui/hooks/usePhraseCycler.test.d.ts +0 -6
  828. package/dist/src/ui/hooks/usePhraseCycler.test.js +0 -208
  829. package/dist/src/ui/hooks/usePhraseCycler.test.js.map +0 -1
  830. package/dist/src/ui/hooks/usePrivacySettings.test.d.ts +0 -6
  831. package/dist/src/ui/hooks/usePrivacySettings.test.js +0 -104
  832. package/dist/src/ui/hooks/usePrivacySettings.test.js.map +0 -1
  833. package/dist/src/ui/hooks/useQuotaAndFallback.test.d.ts +0 -6
  834. package/dist/src/ui/hooks/useQuotaAndFallback.test.js +0 -477
  835. package/dist/src/ui/hooks/useQuotaAndFallback.test.js.map +0 -1
  836. package/dist/src/ui/hooks/useReactToolScheduler.test.d.ts +0 -6
  837. package/dist/src/ui/hooks/useReactToolScheduler.test.js +0 -58
  838. package/dist/src/ui/hooks/useReactToolScheduler.test.js.map +0 -1
  839. package/dist/src/ui/hooks/useReverseSearchCompletion.test.d.ts +0 -6
  840. package/dist/src/ui/hooks/useReverseSearchCompletion.test.js +0 -169
  841. package/dist/src/ui/hooks/useReverseSearchCompletion.test.js.map +0 -1
  842. package/dist/src/ui/hooks/useRewind.test.d.ts +0 -6
  843. package/dist/src/ui/hooks/useRewind.test.js +0 -100
  844. package/dist/src/ui/hooks/useRewind.test.js.map +0 -1
  845. package/dist/src/ui/hooks/useSelectionList.test.d.ts +0 -6
  846. package/dist/src/ui/hooks/useSelectionList.test.js +0 -848
  847. package/dist/src/ui/hooks/useSelectionList.test.js.map +0 -1
  848. package/dist/src/ui/hooks/useSessionBrowser.test.d.ts +0 -6
  849. package/dist/src/ui/hooks/useSessionBrowser.test.js +0 -203
  850. package/dist/src/ui/hooks/useSessionBrowser.test.js.map +0 -1
  851. package/dist/src/ui/hooks/useSessionResume.test.d.ts +0 -6
  852. package/dist/src/ui/hooks/useSessionResume.test.js +0 -336
  853. package/dist/src/ui/hooks/useSessionResume.test.js.map +0 -1
  854. package/dist/src/ui/hooks/useShellHistory.test.d.ts +0 -6
  855. package/dist/src/ui/hooks/useShellHistory.test.js +0 -223
  856. package/dist/src/ui/hooks/useShellHistory.test.js.map +0 -1
  857. package/dist/src/ui/hooks/useShellInactivityStatus.test.d.ts +0 -6
  858. package/dist/src/ui/hooks/useShellInactivityStatus.test.js +0 -84
  859. package/dist/src/ui/hooks/useShellInactivityStatus.test.js.map +0 -1
  860. package/dist/src/ui/hooks/useSlashCompletion.test.d.ts +0 -9
  861. package/dist/src/ui/hooks/useSlashCompletion.test.js +0 -845
  862. package/dist/src/ui/hooks/useSlashCompletion.test.js.map +0 -1
  863. package/dist/src/ui/hooks/useSnowfall.test.d.ts +0 -6
  864. package/dist/src/ui/hooks/useSnowfall.test.js +0 -88
  865. package/dist/src/ui/hooks/useSnowfall.test.js.map +0 -1
  866. package/dist/src/ui/hooks/useTabbedNavigation.test.d.ts +0 -6
  867. package/dist/src/ui/hooks/useTabbedNavigation.test.js +0 -187
  868. package/dist/src/ui/hooks/useTabbedNavigation.test.js.map +0 -1
  869. package/dist/src/ui/hooks/useTimer.test.d.ts +0 -6
  870. package/dist/src/ui/hooks/useTimer.test.js +0 -119
  871. package/dist/src/ui/hooks/useTimer.test.js.map +0 -1
  872. package/dist/src/ui/hooks/useTips.test.d.ts +0 -6
  873. package/dist/src/ui/hooks/useTips.test.js +0 -33
  874. package/dist/src/ui/hooks/useTips.test.js.map +0 -1
  875. package/dist/src/ui/hooks/useToolExecutionScheduler.test.d.ts +0 -6
  876. package/dist/src/ui/hooks/useToolExecutionScheduler.test.js +0 -376
  877. package/dist/src/ui/hooks/useToolExecutionScheduler.test.js.map +0 -1
  878. package/dist/src/ui/hooks/useToolScheduler.test.d.ts +0 -6
  879. package/dist/src/ui/hooks/useToolScheduler.test.js +0 -881
  880. package/dist/src/ui/hooks/useToolScheduler.test.js.map +0 -1
  881. package/dist/src/ui/hooks/useToolSchedulerFacade.test.d.ts +0 -6
  882. package/dist/src/ui/hooks/useToolSchedulerFacade.test.js +0 -45
  883. package/dist/src/ui/hooks/useToolSchedulerFacade.test.js.map +0 -1
  884. package/dist/src/ui/hooks/useTurnActivityMonitor.test.d.ts +0 -6
  885. package/dist/src/ui/hooks/useTurnActivityMonitor.test.js +0 -97
  886. package/dist/src/ui/hooks/useTurnActivityMonitor.test.js.map +0 -1
  887. package/dist/src/ui/hooks/vim.test.d.ts +0 -6
  888. package/dist/src/ui/hooks/vim.test.js +0 -1384
  889. package/dist/src/ui/hooks/vim.test.js.map +0 -1
  890. package/dist/src/ui/keyMatchers.test.d.ts +0 -6
  891. package/dist/src/ui/keyMatchers.test.js +0 -386
  892. package/dist/src/ui/keyMatchers.test.js.map +0 -1
  893. package/dist/src/ui/privacy/CloudFreePrivacyNotice.test.d.ts +0 -6
  894. package/dist/src/ui/privacy/CloudFreePrivacyNotice.test.js +0 -121
  895. package/dist/src/ui/privacy/CloudFreePrivacyNotice.test.js.map +0 -1
  896. package/dist/src/ui/privacy/CloudPaidPrivacyNotice.test.d.ts +0 -6
  897. package/dist/src/ui/privacy/CloudPaidPrivacyNotice.test.js +0 -34
  898. package/dist/src/ui/privacy/CloudPaidPrivacyNotice.test.js.map +0 -1
  899. package/dist/src/ui/privacy/GeminiPrivacyNotice.test.d.ts +0 -6
  900. package/dist/src/ui/privacy/GeminiPrivacyNotice.test.js +0 -34
  901. package/dist/src/ui/privacy/GeminiPrivacyNotice.test.js.map +0 -1
  902. package/dist/src/ui/privacy/PrivacyNotice.test.d.ts +0 -6
  903. package/dist/src/ui/privacy/PrivacyNotice.test.js +0 -62
  904. package/dist/src/ui/privacy/PrivacyNotice.test.js.map +0 -1
  905. package/dist/src/ui/state/extensions.test.d.ts +0 -6
  906. package/dist/src/ui/state/extensions.test.js +0 -219
  907. package/dist/src/ui/state/extensions.test.js.map +0 -1
  908. package/dist/src/ui/themes/color-utils.test.d.ts +0 -6
  909. package/dist/src/ui/themes/color-utils.test.js +0 -245
  910. package/dist/src/ui/themes/color-utils.test.js.map +0 -1
  911. package/dist/src/ui/themes/theme-manager.test.d.ts +0 -6
  912. package/dist/src/ui/themes/theme-manager.test.js +0 -150
  913. package/dist/src/ui/themes/theme-manager.test.js.map +0 -1
  914. package/dist/src/ui/themes/theme.test.d.ts +0 -6
  915. package/dist/src/ui/themes/theme.test.js +0 -174
  916. package/dist/src/ui/themes/theme.test.js.map +0 -1
  917. package/dist/src/ui/utils/CodeColorizer.test.d.ts +0 -6
  918. package/dist/src/ui/utils/CodeColorizer.test.js +0 -38
  919. package/dist/src/ui/utils/CodeColorizer.test.js.map +0 -1
  920. package/dist/src/ui/utils/InlineMarkdownRenderer.test.d.ts +0 -6
  921. package/dist/src/ui/utils/InlineMarkdownRenderer.test.js +0 -21
  922. package/dist/src/ui/utils/InlineMarkdownRenderer.test.js.map +0 -1
  923. package/dist/src/ui/utils/MarkdownDisplay.test.d.ts +0 -6
  924. package/dist/src/ui/utils/MarkdownDisplay.test.js +0 -159
  925. package/dist/src/ui/utils/MarkdownDisplay.test.js.map +0 -1
  926. package/dist/src/ui/utils/clipboardUtils.test.d.ts +0 -6
  927. package/dist/src/ui/utils/clipboardUtils.test.js +0 -359
  928. package/dist/src/ui/utils/clipboardUtils.test.js.map +0 -1
  929. package/dist/src/ui/utils/clipboardUtils.windows.test.d.ts +0 -6
  930. package/dist/src/ui/utils/clipboardUtils.windows.test.js +0 -55
  931. package/dist/src/ui/utils/clipboardUtils.windows.test.js.map +0 -1
  932. package/dist/src/ui/utils/commandUtils.test.d.ts +0 -6
  933. package/dist/src/ui/utils/commandUtils.test.js +0 -479
  934. package/dist/src/ui/utils/commandUtils.test.js.map +0 -1
  935. package/dist/src/ui/utils/computeStats.test.d.ts +0 -6
  936. package/dist/src/ui/utils/computeStats.test.js +0 -271
  937. package/dist/src/ui/utils/computeStats.test.js.map +0 -1
  938. package/dist/src/ui/utils/directoryUtils.test.d.ts +0 -6
  939. package/dist/src/ui/utils/directoryUtils.test.js +0 -244
  940. package/dist/src/ui/utils/directoryUtils.test.js.map +0 -1
  941. package/dist/src/ui/utils/displayUtils.test.d.ts +0 -6
  942. package/dist/src/ui/utils/displayUtils.test.js +0 -61
  943. package/dist/src/ui/utils/displayUtils.test.js.map +0 -1
  944. package/dist/src/ui/utils/formatters.test.d.ts +0 -6
  945. package/dist/src/ui/utils/formatters.test.js +0 -124
  946. package/dist/src/ui/utils/formatters.test.js.map +0 -1
  947. package/dist/src/ui/utils/highlight.test.d.ts +0 -6
  948. package/dist/src/ui/utils/highlight.test.js +0 -198
  949. package/dist/src/ui/utils/highlight.test.js.map +0 -1
  950. package/dist/src/ui/utils/input.test.d.ts +0 -6
  951. package/dist/src/ui/utils/input.test.js +0 -44
  952. package/dist/src/ui/utils/input.test.js.map +0 -1
  953. package/dist/src/ui/utils/markdownUtilities.test.d.ts +0 -6
  954. package/dist/src/ui/utils/markdownUtilities.test.js +0 -42
  955. package/dist/src/ui/utils/markdownUtilities.test.js.map +0 -1
  956. package/dist/src/ui/utils/mouse.test.d.ts +0 -6
  957. package/dist/src/ui/utils/mouse.test.js +0 -136
  958. package/dist/src/ui/utils/mouse.test.js.map +0 -1
  959. package/dist/src/ui/utils/rewindFileOps.test.d.ts +0 -6
  960. package/dist/src/ui/utils/rewindFileOps.test.js +0 -375
  961. package/dist/src/ui/utils/rewindFileOps.test.js.map +0 -1
  962. package/dist/src/ui/utils/terminalCapabilityManager.test.d.ts +0 -6
  963. package/dist/src/ui/utils/terminalCapabilityManager.test.js +0 -220
  964. package/dist/src/ui/utils/terminalCapabilityManager.test.js.map +0 -1
  965. package/dist/src/ui/utils/terminalSetup.test.d.ts +0 -6
  966. package/dist/src/ui/utils/terminalSetup.test.js +0 -147
  967. package/dist/src/ui/utils/terminalSetup.test.js.map +0 -1
  968. package/dist/src/ui/utils/terminalUtils.test.d.ts +0 -6
  969. package/dist/src/ui/utils/terminalUtils.test.js +0 -40
  970. package/dist/src/ui/utils/terminalUtils.test.js.map +0 -1
  971. package/dist/src/ui/utils/textOutput.test.d.ts +0 -6
  972. package/dist/src/ui/utils/textOutput.test.js +0 -79
  973. package/dist/src/ui/utils/textOutput.test.js.map +0 -1
  974. package/dist/src/ui/utils/textUtils.test.d.ts +0 -6
  975. package/dist/src/ui/utils/textUtils.test.js +0 -168
  976. package/dist/src/ui/utils/textUtils.test.js.map +0 -1
  977. package/dist/src/ui/utils/ui-sizing.test.d.ts +0 -6
  978. package/dist/src/ui/utils/ui-sizing.test.js +0 -38
  979. package/dist/src/ui/utils/ui-sizing.test.js.map +0 -1
  980. package/dist/src/ui/utils/updateCheck.test.d.ts +0 -6
  981. package/dist/src/ui/utils/updateCheck.test.js +0 -134
  982. package/dist/src/ui/utils/updateCheck.test.js.map +0 -1
  983. package/dist/src/utils/agentUtils.test.d.ts +0 -6
  984. package/dist/src/utils/agentUtils.test.js +0 -121
  985. package/dist/src/utils/agentUtils.test.js.map +0 -1
  986. package/dist/src/utils/checks.test.d.ts +0 -6
  987. package/dist/src/utils/checks.test.js +0 -29
  988. package/dist/src/utils/checks.test.js.map +0 -1
  989. package/dist/src/utils/cleanup.test.d.ts +0 -6
  990. package/dist/src/utils/cleanup.test.js +0 -92
  991. package/dist/src/utils/cleanup.test.js.map +0 -1
  992. package/dist/src/utils/commands.test.d.ts +0 -6
  993. package/dist/src/utils/commands.test.js +0 -115
  994. package/dist/src/utils/commands.test.js.map +0 -1
  995. package/dist/src/utils/commentJson.test.d.ts +0 -6
  996. package/dist/src/utils/commentJson.test.js +0 -308
  997. package/dist/src/utils/commentJson.test.js.map +0 -1
  998. package/dist/src/utils/deepMerge.test.d.ts +0 -6
  999. package/dist/src/utils/deepMerge.test.js +0 -201
  1000. package/dist/src/utils/deepMerge.test.js.map +0 -1
  1001. package/dist/src/utils/dialogScopeUtils.test.d.ts +0 -6
  1002. package/dist/src/utils/dialogScopeUtils.test.js +0 -81
  1003. package/dist/src/utils/dialogScopeUtils.test.js.map +0 -1
  1004. package/dist/src/utils/envVarResolver.test.d.ts +0 -6
  1005. package/dist/src/utils/envVarResolver.test.js +0 -221
  1006. package/dist/src/utils/envVarResolver.test.js.map +0 -1
  1007. package/dist/src/utils/errors.test.d.ts +0 -6
  1008. package/dist/src/utils/errors.test.js +0 -435
  1009. package/dist/src/utils/errors.test.js.map +0 -1
  1010. package/dist/src/utils/events.test.d.ts +0 -6
  1011. package/dist/src/utils/events.test.js +0 -24
  1012. package/dist/src/utils/events.test.js.map +0 -1
  1013. package/dist/src/utils/gitUtils.test.d.ts +0 -6
  1014. package/dist/src/utils/gitUtils.test.js +0 -113
  1015. package/dist/src/utils/gitUtils.test.js.map +0 -1
  1016. package/dist/src/utils/handleAutoUpdate.test.d.ts +0 -6
  1017. package/dist/src/utils/handleAutoUpdate.test.js +0 -310
  1018. package/dist/src/utils/handleAutoUpdate.test.js.map +0 -1
  1019. package/dist/src/utils/installationInfo.test.d.ts +0 -6
  1020. package/dist/src/utils/installationInfo.test.js +0 -296
  1021. package/dist/src/utils/installationInfo.test.js.map +0 -1
  1022. package/dist/src/utils/jsonoutput.test.d.ts +0 -6
  1023. package/dist/src/utils/jsonoutput.test.js +0 -74
  1024. package/dist/src/utils/jsonoutput.test.js.map +0 -1
  1025. package/dist/src/utils/math.test.d.ts +0 -6
  1026. package/dist/src/utils/math.test.js +0 -23
  1027. package/dist/src/utils/math.test.js.map +0 -1
  1028. package/dist/src/utils/persistentState.test.d.ts +0 -6
  1029. package/dist/src/utils/persistentState.test.js +0 -68
  1030. package/dist/src/utils/persistentState.test.js.map +0 -1
  1031. package/dist/src/utils/processUtils.test.d.ts +0 -6
  1032. package/dist/src/utils/processUtils.test.js +0 -20
  1033. package/dist/src/utils/processUtils.test.js.map +0 -1
  1034. package/dist/src/utils/readStdin.test.d.ts +0 -6
  1035. package/dist/src/utils/readStdin.test.js +0 -117
  1036. package/dist/src/utils/readStdin.test.js.map +0 -1
  1037. package/dist/src/utils/readStdin_safety.test.d.ts +0 -6
  1038. package/dist/src/utils/readStdin_safety.test.js +0 -68
  1039. package/dist/src/utils/readStdin_safety.test.js.map +0 -1
  1040. package/dist/src/utils/relaunch.test.d.ts +0 -6
  1041. package/dist/src/utils/relaunch.test.js +0 -279
  1042. package/dist/src/utils/relaunch.test.js.map +0 -1
  1043. package/dist/src/utils/resolvePath.test.d.ts +0 -6
  1044. package/dist/src/utils/resolvePath.test.js +0 -34
  1045. package/dist/src/utils/resolvePath.test.js.map +0 -1
  1046. package/dist/src/utils/sandbox.test.d.ts +0 -6
  1047. package/dist/src/utils/sandbox.test.js +0 -314
  1048. package/dist/src/utils/sandbox.test.js.map +0 -1
  1049. package/dist/src/utils/sandboxUtils.test.d.ts +0 -6
  1050. package/dist/src/utils/sandboxUtils.test.js +0 -122
  1051. package/dist/src/utils/sandboxUtils.test.js.map +0 -1
  1052. package/dist/src/utils/sessionCleanup.integration.test.d.ts +0 -6
  1053. package/dist/src/utils/sessionCleanup.integration.test.js +0 -182
  1054. package/dist/src/utils/sessionCleanup.integration.test.js.map +0 -1
  1055. package/dist/src/utils/sessionCleanup.test.d.ts +0 -6
  1056. package/dist/src/utils/sessionCleanup.test.js +0 -1298
  1057. package/dist/src/utils/sessionCleanup.test.js.map +0 -1
  1058. package/dist/src/utils/sessionUtils.test.d.ts +0 -6
  1059. package/dist/src/utils/sessionUtils.test.js +0 -503
  1060. package/dist/src/utils/sessionUtils.test.js.map +0 -1
  1061. package/dist/src/utils/sessions.test.d.ts +0 -6
  1062. package/dist/src/utils/sessions.test.js +0 -581
  1063. package/dist/src/utils/sessions.test.js.map +0 -1
  1064. package/dist/src/utils/settingsUtils.test.d.ts +0 -6
  1065. package/dist/src/utils/settingsUtils.test.js +0 -808
  1066. package/dist/src/utils/settingsUtils.test.js.map +0 -1
  1067. package/dist/src/utils/skillUtils.test.d.ts +0 -6
  1068. package/dist/src/utils/skillUtils.test.js +0 -70
  1069. package/dist/src/utils/skillUtils.test.js.map +0 -1
  1070. package/dist/src/utils/startupWarnings.test.d.ts +0 -6
  1071. package/dist/src/utils/startupWarnings.test.js +0 -61
  1072. package/dist/src/utils/startupWarnings.test.js.map +0 -1
  1073. package/dist/src/utils/updateEventEmitter.test.d.ts +0 -6
  1074. package/dist/src/utils/updateEventEmitter.test.js +0 -18
  1075. package/dist/src/utils/updateEventEmitter.test.js.map +0 -1
  1076. package/dist/src/utils/userStartupWarnings.test.d.ts +0 -6
  1077. package/dist/src/utils/userStartupWarnings.test.js +0 -98
  1078. package/dist/src/utils/userStartupWarnings.test.js.map +0 -1
  1079. package/dist/src/utils/windowTitle.test.d.ts +0 -6
  1080. package/dist/src/utils/windowTitle.test.js +0 -216
  1081. package/dist/src/utils/windowTitle.test.js.map +0 -1
  1082. package/dist/src/validateNonInterActiveAuth.test.d.ts +0 -6
  1083. package/dist/src/validateNonInterActiveAuth.test.js +0 -319
  1084. package/dist/src/validateNonInterActiveAuth.test.js.map +0 -1
  1085. package/dist/src/zed-integration/fileSystemService.test.d.ts +0 -6
  1086. package/dist/src/zed-integration/fileSystemService.test.js +0 -88
  1087. package/dist/src/zed-integration/fileSystemService.test.js.map +0 -1
  1088. package/dist/src/zed-integration/zedIntegration.test.d.ts +0 -6
  1089. package/dist/src/zed-integration/zedIntegration.test.js +0 -625
  1090. package/dist/src/zed-integration/zedIntegration.test.js.map +0 -1
  1091. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1,2490 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2025 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
7
- import stripAnsi from 'strip-ansi';
8
- import { act } from 'react';
9
- import { renderHook, renderHookWithProviders, } from '../../../test-utils/render.js';
10
- import { useTextBuffer, offsetToLogicalPos, logicalPosToOffset, textBufferReducer, findWordEndInLine, findNextWordStartInLine, isWordCharStrict, calculateTransformationsForLine, calculateTransformedLine, getTransformUnderCursor, getTransformedImagePath, } from './text-buffer.js';
11
- import { cpLen } from '../../utils/textUtils.js';
12
- const defaultVisualLayout = {
13
- visualLines: [''],
14
- logicalToVisualMap: [[[0, 0]]],
15
- visualToLogicalMap: [[0, 0]],
16
- transformedToLogicalMaps: [[]],
17
- visualToTransformedMap: [],
18
- };
19
- const initialState = {
20
- lines: [''],
21
- cursorRow: 0,
22
- cursorCol: 0,
23
- preferredCol: null,
24
- undoStack: [],
25
- redoStack: [],
26
- clipboard: null,
27
- selectionAnchor: null,
28
- viewportWidth: 80,
29
- viewportHeight: 24,
30
- transformationsByLine: [[]],
31
- visualLayout: defaultVisualLayout,
32
- pastedContent: {},
33
- expandedPasteInfo: new Map(),
34
- };
35
- /**
36
- * Helper to create a TextBufferState with properly calculated transformations.
37
- */
38
- function createStateWithTransformations(partial) {
39
- const state = { ...initialState, ...partial };
40
- return {
41
- ...state,
42
- transformationsByLine: state.lines.map((l) => calculateTransformationsForLine(l)),
43
- };
44
- }
45
- describe('textBufferReducer', () => {
46
- afterEach(() => {
47
- vi.restoreAllMocks();
48
- });
49
- it('should return the initial state if state is undefined', () => {
50
- const action = { type: 'unknown_action' };
51
- const state = textBufferReducer(initialState, action);
52
- expect(state).toHaveOnlyValidCharacters();
53
- expect(state).toEqual(initialState);
54
- });
55
- describe('set_text action', () => {
56
- it('should set new text and move cursor to the end', () => {
57
- const action = {
58
- type: 'set_text',
59
- payload: 'hello\nworld',
60
- };
61
- const state = textBufferReducer(initialState, action);
62
- expect(state).toHaveOnlyValidCharacters();
63
- expect(state.lines).toEqual(['hello', 'world']);
64
- expect(state.cursorRow).toBe(1);
65
- expect(state.cursorCol).toBe(5);
66
- expect(state.undoStack.length).toBe(1);
67
- });
68
- it('should not create an undo snapshot if pushToUndo is false', () => {
69
- const action = {
70
- type: 'set_text',
71
- payload: 'no undo',
72
- pushToUndo: false,
73
- };
74
- const state = textBufferReducer(initialState, action);
75
- expect(state).toHaveOnlyValidCharacters();
76
- expect(state.lines).toEqual(['no undo']);
77
- expect(state.undoStack.length).toBe(0);
78
- });
79
- });
80
- describe('insert action', () => {
81
- it('should insert a character', () => {
82
- const action = { type: 'insert', payload: 'a' };
83
- const state = textBufferReducer(initialState, action);
84
- expect(state).toHaveOnlyValidCharacters();
85
- expect(state.lines).toEqual(['a']);
86
- expect(state.cursorCol).toBe(1);
87
- });
88
- it('should insert a newline', () => {
89
- const stateWithText = { ...initialState, lines: ['hello'] };
90
- const action = { type: 'insert', payload: '\n' };
91
- const state = textBufferReducer(stateWithText, action);
92
- expect(state).toHaveOnlyValidCharacters();
93
- expect(state.lines).toEqual(['', 'hello']);
94
- expect(state.cursorRow).toBe(1);
95
- expect(state.cursorCol).toBe(0);
96
- });
97
- });
98
- describe('insert action with options', () => {
99
- it('should filter input using inputFilter option', () => {
100
- const action = { type: 'insert', payload: 'a1b2c3' };
101
- const options = {
102
- inputFilter: (text) => text.replace(/[0-9]/g, ''),
103
- };
104
- const state = textBufferReducer(initialState, action, options);
105
- expect(state.lines).toEqual(['abc']);
106
- expect(state.cursorCol).toBe(3);
107
- });
108
- it('should strip newlines when singleLine option is true', () => {
109
- const action = {
110
- type: 'insert',
111
- payload: 'hello\nworld',
112
- };
113
- const options = { singleLine: true };
114
- const state = textBufferReducer(initialState, action, options);
115
- expect(state.lines).toEqual(['helloworld']);
116
- expect(state.cursorCol).toBe(10);
117
- });
118
- it('should apply both inputFilter and singleLine options', () => {
119
- const action = {
120
- type: 'insert',
121
- payload: 'h\ne\nl\nl\no\n1\n2\n3',
122
- };
123
- const options = {
124
- singleLine: true,
125
- inputFilter: (text) => text.replace(/[0-9]/g, ''),
126
- };
127
- const state = textBufferReducer(initialState, action, options);
128
- expect(state.lines).toEqual(['hello']);
129
- expect(state.cursorCol).toBe(5);
130
- });
131
- });
132
- describe('add_pasted_content action', () => {
133
- it('should add content to pastedContent Record', () => {
134
- const action = {
135
- type: 'add_pasted_content',
136
- payload: { id: '[Pasted Text: 6 lines]', text: 'large content' },
137
- };
138
- const state = textBufferReducer(initialState, action);
139
- expect(state.pastedContent).toEqual({
140
- '[Pasted Text: 6 lines]': 'large content',
141
- });
142
- });
143
- });
144
- describe('backspace action', () => {
145
- it('should remove a character', () => {
146
- const stateWithText = {
147
- ...initialState,
148
- lines: ['a'],
149
- cursorRow: 0,
150
- cursorCol: 1,
151
- };
152
- const action = { type: 'backspace' };
153
- const state = textBufferReducer(stateWithText, action);
154
- expect(state).toHaveOnlyValidCharacters();
155
- expect(state.lines).toEqual(['']);
156
- expect(state.cursorCol).toBe(0);
157
- });
158
- it('should join lines if at the beginning of a line', () => {
159
- const stateWithText = {
160
- ...initialState,
161
- lines: ['hello', 'world'],
162
- cursorRow: 1,
163
- cursorCol: 0,
164
- };
165
- const action = { type: 'backspace' };
166
- const state = textBufferReducer(stateWithText, action);
167
- expect(state).toHaveOnlyValidCharacters();
168
- expect(state.lines).toEqual(['helloworld']);
169
- expect(state.cursorRow).toBe(0);
170
- expect(state.cursorCol).toBe(5);
171
- });
172
- });
173
- describe('atomic placeholder deletion', () => {
174
- describe('paste placeholders', () => {
175
- it('backspace at end of paste placeholder removes entire placeholder', () => {
176
- const placeholder = '[Pasted Text: 6 lines]';
177
- const stateWithPlaceholder = createStateWithTransformations({
178
- lines: [placeholder],
179
- cursorRow: 0,
180
- cursorCol: placeholder.length, // cursor at end
181
- pastedContent: {
182
- [placeholder]: 'line1\nline2\nline3\nline4\nline5\nline6',
183
- },
184
- });
185
- const action = { type: 'backspace' };
186
- const state = textBufferReducer(stateWithPlaceholder, action);
187
- expect(state).toHaveOnlyValidCharacters();
188
- expect(state.lines).toEqual(['']);
189
- expect(state.cursorCol).toBe(0);
190
- // pastedContent should be cleaned up
191
- expect(state.pastedContent[placeholder]).toBeUndefined();
192
- });
193
- it('delete at start of paste placeholder removes entire placeholder', () => {
194
- const placeholder = '[Pasted Text: 6 lines]';
195
- const stateWithPlaceholder = createStateWithTransformations({
196
- lines: [placeholder],
197
- cursorRow: 0,
198
- cursorCol: 0, // cursor at start
199
- pastedContent: {
200
- [placeholder]: 'line1\nline2\nline3\nline4\nline5\nline6',
201
- },
202
- });
203
- const action = { type: 'delete' };
204
- const state = textBufferReducer(stateWithPlaceholder, action);
205
- expect(state).toHaveOnlyValidCharacters();
206
- expect(state.lines).toEqual(['']);
207
- expect(state.cursorCol).toBe(0);
208
- // pastedContent should be cleaned up
209
- expect(state.pastedContent[placeholder]).toBeUndefined();
210
- });
211
- it('backspace inside paste placeholder does normal deletion', () => {
212
- const placeholder = '[Pasted Text: 6 lines]';
213
- const stateWithPlaceholder = createStateWithTransformations({
214
- lines: [placeholder],
215
- cursorRow: 0,
216
- cursorCol: 10, // cursor in middle
217
- pastedContent: {
218
- [placeholder]: 'line1\nline2\nline3\nline4\nline5\nline6',
219
- },
220
- });
221
- const action = { type: 'backspace' };
222
- const state = textBufferReducer(stateWithPlaceholder, action);
223
- expect(state).toHaveOnlyValidCharacters();
224
- // Should only delete one character
225
- expect(state.lines[0].length).toBe(placeholder.length - 1);
226
- expect(state.cursorCol).toBe(9);
227
- // pastedContent should NOT be cleaned up (placeholder is broken)
228
- expect(state.pastedContent[placeholder]).toBeDefined();
229
- });
230
- });
231
- describe('image placeholders', () => {
232
- it('backspace at end of image path removes entire path', () => {
233
- const imagePath = '@test.png';
234
- const stateWithImage = createStateWithTransformations({
235
- lines: [imagePath],
236
- cursorRow: 0,
237
- cursorCol: imagePath.length, // cursor at end
238
- });
239
- const action = { type: 'backspace' };
240
- const state = textBufferReducer(stateWithImage, action);
241
- expect(state).toHaveOnlyValidCharacters();
242
- expect(state.lines).toEqual(['']);
243
- expect(state.cursorCol).toBe(0);
244
- });
245
- it('delete at start of image path removes entire path', () => {
246
- const imagePath = '@test.png';
247
- const stateWithImage = createStateWithTransformations({
248
- lines: [imagePath],
249
- cursorRow: 0,
250
- cursorCol: 0, // cursor at start
251
- });
252
- const action = { type: 'delete' };
253
- const state = textBufferReducer(stateWithImage, action);
254
- expect(state).toHaveOnlyValidCharacters();
255
- expect(state.lines).toEqual(['']);
256
- expect(state.cursorCol).toBe(0);
257
- });
258
- it('backspace inside image path does normal deletion', () => {
259
- const imagePath = '@test.png';
260
- const stateWithImage = createStateWithTransformations({
261
- lines: [imagePath],
262
- cursorRow: 0,
263
- cursorCol: 5, // cursor in middle
264
- });
265
- const action = { type: 'backspace' };
266
- const state = textBufferReducer(stateWithImage, action);
267
- expect(state).toHaveOnlyValidCharacters();
268
- // Should only delete one character
269
- expect(state.lines[0].length).toBe(imagePath.length - 1);
270
- expect(state.cursorCol).toBe(4);
271
- });
272
- });
273
- describe('undo behavior', () => {
274
- it('undo after placeholder deletion restores everything', () => {
275
- const placeholder = '[Pasted Text: 6 lines]';
276
- const pasteContent = 'line1\nline2\nline3\nline4\nline5\nline6';
277
- const stateWithPlaceholder = createStateWithTransformations({
278
- lines: [placeholder],
279
- cursorRow: 0,
280
- cursorCol: placeholder.length,
281
- pastedContent: { [placeholder]: pasteContent },
282
- });
283
- // Delete the placeholder
284
- const deleteAction = { type: 'backspace' };
285
- const stateAfterDelete = textBufferReducer(stateWithPlaceholder, deleteAction);
286
- expect(stateAfterDelete.lines).toEqual(['']);
287
- expect(stateAfterDelete.pastedContent[placeholder]).toBeUndefined();
288
- // Undo should restore
289
- const undoAction = { type: 'undo' };
290
- const stateAfterUndo = textBufferReducer(stateAfterDelete, undoAction);
291
- expect(stateAfterUndo).toHaveOnlyValidCharacters();
292
- expect(stateAfterUndo.lines).toEqual([placeholder]);
293
- expect(stateAfterUndo.pastedContent[placeholder]).toBe(pasteContent);
294
- });
295
- });
296
- });
297
- describe('undo/redo actions', () => {
298
- it('should undo and redo a change', () => {
299
- // 1. Insert text
300
- const insertAction = {
301
- type: 'insert',
302
- payload: 'test',
303
- };
304
- const stateAfterInsert = textBufferReducer(initialState, insertAction);
305
- expect(stateAfterInsert).toHaveOnlyValidCharacters();
306
- expect(stateAfterInsert.lines).toEqual(['test']);
307
- expect(stateAfterInsert.undoStack.length).toBe(1);
308
- // 2. Undo
309
- const undoAction = { type: 'undo' };
310
- const stateAfterUndo = textBufferReducer(stateAfterInsert, undoAction);
311
- expect(stateAfterUndo).toHaveOnlyValidCharacters();
312
- expect(stateAfterUndo.lines).toEqual(['']);
313
- expect(stateAfterUndo.undoStack.length).toBe(0);
314
- expect(stateAfterUndo.redoStack.length).toBe(1);
315
- // 3. Redo
316
- const redoAction = { type: 'redo' };
317
- const stateAfterRedo = textBufferReducer(stateAfterUndo, redoAction);
318
- expect(stateAfterRedo).toHaveOnlyValidCharacters();
319
- expect(stateAfterRedo.lines).toEqual(['test']);
320
- expect(stateAfterRedo.undoStack.length).toBe(1);
321
- expect(stateAfterRedo.redoStack.length).toBe(0);
322
- });
323
- });
324
- describe('create_undo_snapshot action', () => {
325
- it('should create a snapshot without changing state', () => {
326
- const stateWithText = {
327
- ...initialState,
328
- lines: ['hello'],
329
- cursorRow: 0,
330
- cursorCol: 5,
331
- };
332
- const action = { type: 'create_undo_snapshot' };
333
- const state = textBufferReducer(stateWithText, action);
334
- expect(state).toHaveOnlyValidCharacters();
335
- expect(state.lines).toEqual(['hello']);
336
- expect(state.cursorRow).toBe(0);
337
- expect(state.cursorCol).toBe(5);
338
- expect(state.undoStack.length).toBe(1);
339
- expect(state.undoStack[0].lines).toEqual(['hello']);
340
- expect(state.undoStack[0].cursorRow).toBe(0);
341
- expect(state.undoStack[0].cursorCol).toBe(5);
342
- });
343
- });
344
- describe('delete_word_left action', () => {
345
- const createSingleLineState = (text, col) => ({
346
- ...initialState,
347
- lines: [text],
348
- cursorRow: 0,
349
- cursorCol: col,
350
- });
351
- it.each([
352
- {
353
- input: 'hello world',
354
- cursorCol: 11,
355
- expectedLines: ['hello '],
356
- expectedCol: 6,
357
- desc: 'simple word',
358
- },
359
- {
360
- input: 'path/to/file',
361
- cursorCol: 12,
362
- expectedLines: ['path/to/'],
363
- expectedCol: 8,
364
- desc: 'path segment',
365
- },
366
- {
367
- input: 'variable_name',
368
- cursorCol: 13,
369
- expectedLines: ['variable_'],
370
- expectedCol: 9,
371
- desc: 'variable_name parts',
372
- },
373
- ])('should delete $desc', ({ input, cursorCol, expectedLines, expectedCol }) => {
374
- const state = textBufferReducer(createSingleLineState(input, cursorCol), { type: 'delete_word_left' });
375
- expect(state.lines).toEqual(expectedLines);
376
- expect(state.cursorCol).toBe(expectedCol);
377
- });
378
- it('should act like backspace at the beginning of a line', () => {
379
- const stateWithText = {
380
- ...initialState,
381
- lines: ['hello', 'world'],
382
- cursorRow: 1,
383
- cursorCol: 0,
384
- };
385
- const state = textBufferReducer(stateWithText, {
386
- type: 'delete_word_left',
387
- });
388
- expect(state.lines).toEqual(['helloworld']);
389
- expect(state.cursorRow).toBe(0);
390
- expect(state.cursorCol).toBe(5);
391
- });
392
- });
393
- describe('delete_word_right action', () => {
394
- const createSingleLineState = (text, col) => ({
395
- ...initialState,
396
- lines: [text],
397
- cursorRow: 0,
398
- cursorCol: col,
399
- });
400
- it.each([
401
- {
402
- input: 'hello world',
403
- cursorCol: 0,
404
- expectedLines: ['world'],
405
- expectedCol: 0,
406
- desc: 'simple word',
407
- },
408
- {
409
- input: 'variable_name',
410
- cursorCol: 0,
411
- expectedLines: ['_name'],
412
- expectedCol: 0,
413
- desc: 'variable_name parts',
414
- },
415
- ])('should delete $desc', ({ input, cursorCol, expectedLines, expectedCol }) => {
416
- const state = textBufferReducer(createSingleLineState(input, cursorCol), { type: 'delete_word_right' });
417
- expect(state.lines).toEqual(expectedLines);
418
- expect(state.cursorCol).toBe(expectedCol);
419
- });
420
- it('should delete path segments progressively', () => {
421
- const stateWithText = {
422
- ...initialState,
423
- lines: ['path/to/file'],
424
- cursorRow: 0,
425
- cursorCol: 0,
426
- };
427
- let state = textBufferReducer(stateWithText, {
428
- type: 'delete_word_right',
429
- });
430
- expect(state.lines).toEqual(['/to/file']);
431
- state = textBufferReducer(state, { type: 'delete_word_right' });
432
- expect(state.lines).toEqual(['to/file']);
433
- });
434
- it('should act like delete at the end of a line', () => {
435
- const stateWithText = {
436
- ...initialState,
437
- lines: ['hello', 'world'],
438
- cursorRow: 0,
439
- cursorCol: 5,
440
- };
441
- const state = textBufferReducer(stateWithText, {
442
- type: 'delete_word_right',
443
- });
444
- expect(state.lines).toEqual(['helloworld']);
445
- expect(state.cursorRow).toBe(0);
446
- expect(state.cursorCol).toBe(5);
447
- });
448
- });
449
- describe('toggle_paste_expansion action', () => {
450
- const placeholder = '[Pasted Text: 6 lines]';
451
- const content = 'line1\nline2\nline3\nline4\nline5\nline6';
452
- it('should expand a placeholder correctly', () => {
453
- const stateWithPlaceholder = createStateWithTransformations({
454
- lines: ['prefix ' + placeholder + ' suffix'],
455
- cursorRow: 0,
456
- cursorCol: 0,
457
- pastedContent: { [placeholder]: content },
458
- });
459
- const action = {
460
- type: 'toggle_paste_expansion',
461
- payload: { id: placeholder },
462
- };
463
- const state = textBufferReducer(stateWithPlaceholder, action);
464
- expect(state.lines).toEqual([
465
- 'prefix line1',
466
- 'line2',
467
- 'line3',
468
- 'line4',
469
- 'line5',
470
- 'line6 suffix',
471
- ]);
472
- expect(state.expandedPasteInfo.has(placeholder)).toBe(true);
473
- const info = state.expandedPasteInfo.get(placeholder);
474
- expect(info).toEqual({
475
- startLine: 0,
476
- lineCount: 6,
477
- prefix: 'prefix ',
478
- suffix: ' suffix',
479
- });
480
- // Cursor should be at the end of expanded content (before suffix)
481
- expect(state.cursorRow).toBe(5);
482
- expect(state.cursorCol).toBe(5); // length of 'line6'
483
- });
484
- it('should collapse an expanded placeholder correctly', () => {
485
- const expandedState = createStateWithTransformations({
486
- lines: [
487
- 'prefix line1',
488
- 'line2',
489
- 'line3',
490
- 'line4',
491
- 'line5',
492
- 'line6 suffix',
493
- ],
494
- cursorRow: 5,
495
- cursorCol: 5,
496
- pastedContent: { [placeholder]: content },
497
- expandedPasteInfo: new Map([
498
- [
499
- placeholder,
500
- {
501
- startLine: 0,
502
- lineCount: 6,
503
- prefix: 'prefix ',
504
- suffix: ' suffix',
505
- },
506
- ],
507
- ]),
508
- });
509
- const action = {
510
- type: 'toggle_paste_expansion',
511
- payload: { id: placeholder },
512
- };
513
- const state = textBufferReducer(expandedState, action);
514
- expect(state.lines).toEqual(['prefix ' + placeholder + ' suffix']);
515
- expect(state.expandedPasteInfo.has(placeholder)).toBe(false);
516
- // Cursor should be at the end of the collapsed placeholder
517
- expect(state.cursorRow).toBe(0);
518
- expect(state.cursorCol).toBe(('prefix ' + placeholder).length);
519
- });
520
- it('should expand single-line content correctly', () => {
521
- const singleLinePlaceholder = '[Pasted Text: 10 chars]';
522
- const singleLineContent = 'some text';
523
- const stateWithPlaceholder = createStateWithTransformations({
524
- lines: [singleLinePlaceholder],
525
- cursorRow: 0,
526
- cursorCol: 0,
527
- pastedContent: { [singleLinePlaceholder]: singleLineContent },
528
- });
529
- const state = textBufferReducer(stateWithPlaceholder, {
530
- type: 'toggle_paste_expansion',
531
- payload: { id: singleLinePlaceholder },
532
- });
533
- expect(state.lines).toEqual(['some text']);
534
- expect(state.cursorRow).toBe(0);
535
- expect(state.cursorCol).toBe(9);
536
- });
537
- it('should return current state if placeholder ID not found in pastedContent', () => {
538
- const action = {
539
- type: 'toggle_paste_expansion',
540
- payload: { id: 'unknown' },
541
- };
542
- const state = textBufferReducer(initialState, action);
543
- expect(state).toBe(initialState);
544
- });
545
- it('should preserve expandedPasteInfo when lines change from edits outside the region', () => {
546
- // Start with an expanded paste at line 0 (3 lines long)
547
- const placeholder = '[Pasted Text: 3 lines]';
548
- const expandedState = createStateWithTransformations({
549
- lines: ['line1', 'line2', 'line3', 'suffix'],
550
- cursorRow: 3,
551
- cursorCol: 0,
552
- pastedContent: { [placeholder]: 'line1\nline2\nline3' },
553
- expandedPasteInfo: new Map([
554
- [
555
- placeholder,
556
- {
557
- startLine: 0,
558
- lineCount: 3,
559
- prefix: '',
560
- suffix: '',
561
- },
562
- ],
563
- ]),
564
- });
565
- expect(expandedState.expandedPasteInfo.size).toBe(1);
566
- // Insert a newline at the end - this changes lines but is OUTSIDE the expanded region
567
- const stateAfterInsert = textBufferReducer(expandedState, {
568
- type: 'insert',
569
- payload: '\n',
570
- });
571
- // Lines changed, but expandedPasteInfo should be PRESERVED and optionally shifted (no shift here since edit is after)
572
- expect(stateAfterInsert.expandedPasteInfo.size).toBe(1);
573
- expect(stateAfterInsert.expandedPasteInfo.has(placeholder)).toBe(true);
574
- });
575
- });
576
- });
577
- const getBufferState = (result) => {
578
- expect(result.current).toHaveOnlyValidCharacters();
579
- return {
580
- text: result.current.text,
581
- lines: [...result.current.lines], // Clone for safety
582
- cursor: [...result.current.cursor],
583
- allVisualLines: [...result.current.allVisualLines],
584
- viewportVisualLines: [...result.current.viewportVisualLines],
585
- visualCursor: [...result.current.visualCursor],
586
- visualScrollRow: result.current.visualScrollRow,
587
- preferredCol: result.current.preferredCol,
588
- };
589
- };
590
- describe('useTextBuffer', () => {
591
- let viewport;
592
- beforeEach(() => {
593
- viewport = { width: 10, height: 3 }; // Default viewport for tests
594
- });
595
- afterEach(() => {
596
- vi.restoreAllMocks();
597
- });
598
- describe('Initialization', () => {
599
- it('should initialize with empty text and cursor at (0,0) by default', () => {
600
- const { result } = renderHook(() => useTextBuffer({ viewport, isValidPath: () => false }));
601
- const state = getBufferState(result);
602
- expect(state.text).toBe('');
603
- expect(state.lines).toEqual(['']);
604
- expect(state.cursor).toEqual([0, 0]);
605
- expect(state.allVisualLines).toEqual(['']);
606
- expect(state.viewportVisualLines).toEqual(['']);
607
- expect(state.visualCursor).toEqual([0, 0]);
608
- expect(state.visualScrollRow).toBe(0);
609
- });
610
- it('should initialize with provided initialText', () => {
611
- const { result } = renderHook(() => useTextBuffer({
612
- initialText: 'hello',
613
- viewport,
614
- isValidPath: () => false,
615
- }));
616
- const state = getBufferState(result);
617
- expect(state.text).toBe('hello');
618
- expect(state.lines).toEqual(['hello']);
619
- expect(state.cursor).toEqual([0, 0]); // Default cursor if offset not given
620
- expect(state.allVisualLines).toEqual(['hello']);
621
- expect(state.viewportVisualLines).toEqual(['hello']);
622
- expect(state.visualCursor).toEqual([0, 0]);
623
- });
624
- it('should initialize with initialText and initialCursorOffset', () => {
625
- const { result } = renderHook(() => useTextBuffer({
626
- initialText: 'hello\nworld',
627
- initialCursorOffset: 7, // Should be at 'o' in 'world'
628
- viewport,
629
- isValidPath: () => false,
630
- }));
631
- const state = getBufferState(result);
632
- expect(state.text).toBe('hello\nworld');
633
- expect(state.lines).toEqual(['hello', 'world']);
634
- expect(state.cursor).toEqual([1, 1]); // Logical cursor at 'o' in "world"
635
- expect(state.allVisualLines).toEqual(['hello', 'world']);
636
- expect(state.viewportVisualLines).toEqual(['hello', 'world']);
637
- expect(state.visualCursor[0]).toBe(1); // On the second visual line
638
- expect(state.visualCursor[1]).toBe(1); // At 'o' in "world"
639
- });
640
- it('should wrap visual lines', () => {
641
- const { result } = renderHook(() => useTextBuffer({
642
- initialText: 'The quick brown fox jumps over the lazy dog.',
643
- initialCursorOffset: 2, // After '好'
644
- viewport: { width: 15, height: 4 },
645
- isValidPath: () => false,
646
- }));
647
- const state = getBufferState(result);
648
- expect(state.allVisualLines).toEqual([
649
- 'The quick',
650
- 'brown fox',
651
- 'jumps over the',
652
- 'lazy dog.',
653
- ]);
654
- });
655
- it('should wrap visual lines with multiple spaces', () => {
656
- const { result } = renderHook(() => useTextBuffer({
657
- initialText: 'The quick brown fox jumps over the lazy dog.',
658
- viewport: { width: 15, height: 4 },
659
- isValidPath: () => false,
660
- }));
661
- const state = getBufferState(result);
662
- // Including multiple spaces at the end of the lines like this is
663
- // consistent with Google docs behavior and makes it intuitive to edit
664
- // the spaces as needed.
665
- expect(state.allVisualLines).toEqual([
666
- 'The quick ',
667
- 'brown fox ',
668
- 'jumps over the',
669
- 'lazy dog.',
670
- ]);
671
- });
672
- it('should wrap visual lines even without spaces', () => {
673
- const { result } = renderHook(() => useTextBuffer({
674
- initialText: '123456789012345ABCDEFG', // 4 chars, 12 bytes
675
- viewport: { width: 15, height: 2 },
676
- isValidPath: () => false,
677
- }));
678
- const state = getBufferState(result);
679
- // Including multiple spaces at the end of the lines like this is
680
- // consistent with Google docs behavior and makes it intuitive to edit
681
- // the spaces as needed.
682
- expect(state.allVisualLines).toEqual(['123456789012345', 'ABCDEFG']);
683
- });
684
- it('should initialize with multi-byte unicode characters and correct cursor offset', () => {
685
- const { result } = renderHook(() => useTextBuffer({
686
- initialText: '你好世界', // 4 chars, 12 bytes
687
- initialCursorOffset: 2, // After '好'
688
- viewport: { width: 5, height: 2 },
689
- isValidPath: () => false,
690
- }));
691
- const state = getBufferState(result);
692
- expect(state.text).toBe('你好世界');
693
- expect(state.lines).toEqual(['你好世界']);
694
- expect(state.cursor).toEqual([0, 2]);
695
- // Visual: "你好" (width 4), "世"界" (width 4) with viewport width 5
696
- expect(state.allVisualLines).toEqual(['你好', '世界']);
697
- expect(state.visualCursor).toEqual([1, 0]);
698
- });
699
- });
700
- describe('Basic Editing', () => {
701
- it('insert: should insert a character and update cursor', () => {
702
- const { result } = renderHook(() => useTextBuffer({ viewport, isValidPath: () => false }));
703
- act(() => result.current.insert('a'));
704
- let state = getBufferState(result);
705
- expect(state.text).toBe('a');
706
- expect(state.cursor).toEqual([0, 1]);
707
- expect(state.visualCursor).toEqual([0, 1]);
708
- act(() => result.current.insert('b'));
709
- state = getBufferState(result);
710
- expect(state.text).toBe('ab');
711
- expect(state.cursor).toEqual([0, 2]);
712
- expect(state.visualCursor).toEqual([0, 2]);
713
- });
714
- it('insert: should insert text in the middle of a line', () => {
715
- const { result } = renderHook(() => useTextBuffer({
716
- initialText: 'abc',
717
- viewport,
718
- isValidPath: () => false,
719
- }));
720
- act(() => result.current.move('right'));
721
- act(() => result.current.insert('-NEW-'));
722
- const state = getBufferState(result);
723
- expect(state.text).toBe('a-NEW-bc');
724
- expect(state.cursor).toEqual([0, 6]);
725
- });
726
- it('insert: should use placeholder for large text paste', () => {
727
- const { result } = renderHook(() => useTextBuffer({ viewport, isValidPath: () => false }));
728
- const largeText = '1\n2\n3\n4\n5\n6';
729
- act(() => result.current.insert(largeText, { paste: true }));
730
- const state = getBufferState(result);
731
- expect(state.text).toBe('[Pasted Text: 6 lines]');
732
- expect(result.current.pastedContent['[Pasted Text: 6 lines]']).toBe(largeText);
733
- });
734
- it('insert: should NOT use placeholder for large text if NOT a paste', () => {
735
- const { result } = renderHook(() => useTextBuffer({ viewport, isValidPath: () => false }));
736
- const largeText = '1\n2\n3\n4\n5\n6';
737
- act(() => result.current.insert(largeText, { paste: false }));
738
- const state = getBufferState(result);
739
- expect(state.text).toBe(largeText);
740
- });
741
- it('insert: should clean up pastedContent when placeholder is deleted', () => {
742
- const { result } = renderHook(() => useTextBuffer({ viewport, isValidPath: () => false }));
743
- const largeText = '1\n2\n3\n4\n5\n6';
744
- act(() => result.current.insert(largeText, { paste: true }));
745
- expect(result.current.pastedContent['[Pasted Text: 6 lines]']).toBe(largeText);
746
- // Delete the placeholder using setText
747
- act(() => result.current.setText(''));
748
- expect(Object.keys(result.current.pastedContent)).toHaveLength(0);
749
- });
750
- it('insert: should clean up pastedContent when placeholder is removed via atomic backspace', () => {
751
- const { result } = renderHook(() => useTextBuffer({ viewport, isValidPath: () => false }));
752
- const largeText = '1\n2\n3\n4\n5\n6';
753
- act(() => result.current.insert(largeText, { paste: true }));
754
- expect(result.current.pastedContent['[Pasted Text: 6 lines]']).toBe(largeText);
755
- // Single backspace at end of placeholder removes entire placeholder
756
- act(() => {
757
- result.current.backspace();
758
- });
759
- expect(getBufferState(result).text).toBe('');
760
- // pastedContent is cleaned up when placeholder is deleted atomically
761
- expect(Object.keys(result.current.pastedContent)).toHaveLength(0);
762
- });
763
- it('newline: should create a new line and move cursor', () => {
764
- const { result } = renderHook(() => useTextBuffer({
765
- initialText: 'ab',
766
- viewport,
767
- isValidPath: () => false,
768
- }));
769
- act(() => result.current.move('end')); // cursor at [0,2]
770
- act(() => result.current.newline());
771
- const state = getBufferState(result);
772
- expect(state.text).toBe('ab\n');
773
- expect(state.lines).toEqual(['ab', '']);
774
- expect(state.cursor).toEqual([1, 0]);
775
- expect(state.allVisualLines).toEqual(['ab', '']);
776
- expect(state.viewportVisualLines).toEqual(['ab', '']); // viewport height 3
777
- expect(state.visualCursor).toEqual([1, 0]); // On the new visual line
778
- });
779
- it('backspace: should delete char to the left or merge lines', () => {
780
- const { result } = renderHook(() => useTextBuffer({
781
- initialText: 'a\nb',
782
- viewport,
783
- isValidPath: () => false,
784
- }));
785
- act(() => {
786
- result.current.move('down');
787
- });
788
- act(() => {
789
- result.current.move('end'); // cursor to [1,1] (end of 'b')
790
- });
791
- act(() => result.current.backspace()); // delete 'b'
792
- let state = getBufferState(result);
793
- expect(state.text).toBe('a\n');
794
- expect(state.cursor).toEqual([1, 0]);
795
- act(() => result.current.backspace()); // merge lines
796
- state = getBufferState(result);
797
- expect(state.text).toBe('a');
798
- expect(state.cursor).toEqual([0, 1]); // cursor after 'a'
799
- expect(state.allVisualLines).toEqual(['a']);
800
- expect(state.viewportVisualLines).toEqual(['a']);
801
- expect(state.visualCursor).toEqual([0, 1]);
802
- });
803
- it('del: should delete char to the right or merge lines', () => {
804
- const { result } = renderHook(() => useTextBuffer({
805
- initialText: 'a\nb',
806
- viewport,
807
- isValidPath: () => false,
808
- }));
809
- // cursor at [0,0]
810
- act(() => result.current.del()); // delete 'a'
811
- let state = getBufferState(result);
812
- expect(state.text).toBe('\nb');
813
- expect(state.cursor).toEqual([0, 0]);
814
- act(() => result.current.del()); // merge lines (deletes newline)
815
- state = getBufferState(result);
816
- expect(state.text).toBe('b');
817
- expect(state.cursor).toEqual([0, 0]);
818
- expect(state.allVisualLines).toEqual(['b']);
819
- expect(state.viewportVisualLines).toEqual(['b']);
820
- expect(state.visualCursor).toEqual([0, 0]);
821
- });
822
- });
823
- describe('Drag and Drop File Paths', () => {
824
- it('should prepend @ to a valid file path on insert', () => {
825
- const { result } = renderHook(() => useTextBuffer({ viewport, isValidPath: () => true }));
826
- const filePath = '/path/to/a/valid/file.txt';
827
- act(() => result.current.insert(filePath, { paste: true }));
828
- expect(getBufferState(result).text).toBe(`@${filePath} `);
829
- });
830
- it('should not prepend @ to an invalid file path on insert', () => {
831
- const { result } = renderHook(() => useTextBuffer({ viewport, isValidPath: () => false }));
832
- const notAPath = 'this is just some long text';
833
- act(() => result.current.insert(notAPath, { paste: true }));
834
- expect(getBufferState(result).text).toBe(notAPath);
835
- });
836
- it('should handle quoted paths', () => {
837
- const { result } = renderHook(() => useTextBuffer({ viewport, isValidPath: () => true }));
838
- const filePath = "'/path/to/a/valid/file.txt'";
839
- act(() => result.current.insert(filePath, { paste: true }));
840
- expect(getBufferState(result).text).toBe(`@/path/to/a/valid/file.txt `);
841
- });
842
- it('should not prepend @ to short text that is not a path', () => {
843
- const { result } = renderHook(() => useTextBuffer({ viewport, isValidPath: () => true }));
844
- const shortText = 'ab';
845
- act(() => result.current.insert(shortText, { paste: true }));
846
- expect(getBufferState(result).text).toBe(shortText);
847
- });
848
- it('should prepend @ to multiple valid file paths on insert', () => {
849
- // Use Set to model reality: individual paths exist, combined string doesn't
850
- const validPaths = new Set(['/path/to/file1.txt', '/path/to/file2.txt']);
851
- const { result } = renderHook(() => useTextBuffer({ viewport, isValidPath: (p) => validPaths.has(p) }));
852
- const filePaths = '/path/to/file1.txt /path/to/file2.txt';
853
- act(() => result.current.insert(filePaths, { paste: true }));
854
- expect(getBufferState(result).text).toBe('@/path/to/file1.txt @/path/to/file2.txt ');
855
- });
856
- it('should handle multiple paths with escaped spaces', () => {
857
- // Use Set to model reality: individual paths exist, combined string doesn't
858
- const validPaths = new Set(['/path/to/my file.txt', '/other/path.txt']);
859
- const { result } = renderHook(() => useTextBuffer({ viewport, isValidPath: (p) => validPaths.has(p) }));
860
- const filePaths = '/path/to/my\\ file.txt /other/path.txt';
861
- act(() => result.current.insert(filePaths, { paste: true }));
862
- expect(getBufferState(result).text).toBe('@/path/to/my\\ file.txt @/other/path.txt ');
863
- });
864
- it('should only prepend @ to valid paths in multi-path paste', () => {
865
- const { result } = renderHook(() => useTextBuffer({
866
- viewport,
867
- isValidPath: (p) => p.endsWith('.txt'),
868
- }));
869
- const filePaths = '/valid/file.txt /invalid/file.jpg';
870
- act(() => result.current.insert(filePaths, { paste: true }));
871
- expect(getBufferState(result).text).toBe('@/valid/file.txt /invalid/file.jpg ');
872
- });
873
- });
874
- describe('Shell Mode Behavior', () => {
875
- it('should not prepend @ to valid file paths when shellModeActive is true', () => {
876
- const { result } = renderHook(() => useTextBuffer({
877
- viewport,
878
- isValidPath: () => true,
879
- shellModeActive: true,
880
- }));
881
- const filePath = '/path/to/a/valid/file.txt';
882
- act(() => result.current.insert(filePath, { paste: true }));
883
- expect(getBufferState(result).text).toBe(filePath); // No @ prefix
884
- });
885
- it('should not prepend @ to quoted paths when shellModeActive is true', () => {
886
- const { result } = renderHook(() => useTextBuffer({
887
- viewport,
888
- isValidPath: () => true,
889
- shellModeActive: true,
890
- }));
891
- const quotedFilePath = "'/path/to/a/valid/file.txt'";
892
- act(() => result.current.insert(quotedFilePath, { paste: true }));
893
- expect(getBufferState(result).text).toBe(quotedFilePath); // No @ prefix, keeps quotes
894
- });
895
- it('should behave normally with invalid paths when shellModeActive is true', () => {
896
- const { result } = renderHook(() => useTextBuffer({
897
- viewport,
898
- isValidPath: () => false,
899
- shellModeActive: true,
900
- }));
901
- const notAPath = 'this is just some text';
902
- act(() => result.current.insert(notAPath, { paste: true }));
903
- expect(getBufferState(result).text).toBe(notAPath);
904
- });
905
- it('should behave normally with short text when shellModeActive is true', () => {
906
- const { result } = renderHook(() => useTextBuffer({
907
- viewport,
908
- isValidPath: () => true,
909
- shellModeActive: true,
910
- }));
911
- const shortText = 'ls';
912
- act(() => result.current.insert(shortText, { paste: true }));
913
- expect(getBufferState(result).text).toBe(shortText); // No @ prefix for short text
914
- });
915
- });
916
- describe('Cursor Movement', () => {
917
- it('move: left/right should work within and across visual lines (due to wrapping)', () => {
918
- // Text: "long line1next line2" (20 chars)
919
- // Viewport width 5. Word wrapping should produce:
920
- // "long " (5)
921
- // "line1" (5)
922
- // "next " (5)
923
- // "line2" (5)
924
- const { result } = renderHook(() => useTextBuffer({
925
- initialText: 'long line1next line2', // Corrected: was 'long line1next line2'
926
- viewport: { width: 5, height: 4 },
927
- isValidPath: () => false,
928
- }));
929
- // Initial cursor [0,0] logical, visual [0,0] ("l" of "long ")
930
- act(() => result.current.move('right')); // visual [0,1] ("o")
931
- expect(getBufferState(result).visualCursor).toEqual([0, 1]);
932
- act(() => result.current.move('right')); // visual [0,2] ("n")
933
- act(() => result.current.move('right')); // visual [0,3] ("g")
934
- act(() => result.current.move('right')); // visual [0,4] (" ")
935
- expect(getBufferState(result).visualCursor).toEqual([0, 4]);
936
- act(() => result.current.move('right')); // visual [1,0] ("l" of "line1")
937
- expect(getBufferState(result).visualCursor).toEqual([1, 0]);
938
- expect(getBufferState(result).cursor).toEqual([0, 5]); // logical cursor
939
- act(() => result.current.move('left')); // visual [0,4] (" " of "long ")
940
- expect(getBufferState(result).visualCursor).toEqual([0, 4]);
941
- expect(getBufferState(result).cursor).toEqual([0, 4]); // logical cursor
942
- });
943
- it('move: up/down should preserve preferred visual column', () => {
944
- const text = 'abcde\nxy\n12345';
945
- const { result } = renderHook(() => useTextBuffer({
946
- initialText: text,
947
- viewport,
948
- isValidPath: () => false,
949
- }));
950
- expect(result.current.allVisualLines).toEqual(['abcde', 'xy', '12345']);
951
- // Place cursor at the end of "abcde" -> logical [0,5]
952
- act(() => {
953
- result.current.move('home'); // to [0,0]
954
- });
955
- for (let i = 0; i < 5; i++) {
956
- act(() => {
957
- result.current.move('right'); // to [0,5]
958
- });
959
- }
960
- expect(getBufferState(result).cursor).toEqual([0, 5]);
961
- expect(getBufferState(result).visualCursor).toEqual([0, 5]);
962
- // Set preferredCol by moving up then down to the same spot, then test.
963
- act(() => {
964
- result.current.move('down'); // to xy, logical [1,2], visual [1,2], preferredCol should be 5
965
- });
966
- let state = getBufferState(result);
967
- expect(state.cursor).toEqual([1, 2]); // Logical cursor at end of 'xy'
968
- expect(state.visualCursor).toEqual([1, 2]); // Visual cursor at end of 'xy'
969
- expect(state.preferredCol).toBe(5);
970
- act(() => result.current.move('down')); // to '12345', preferredCol=5.
971
- state = getBufferState(result);
972
- expect(state.cursor).toEqual([2, 5]); // Logical cursor at end of '12345'
973
- expect(state.visualCursor).toEqual([2, 5]); // Visual cursor at end of '12345'
974
- expect(state.preferredCol).toBe(5); // Preferred col is maintained
975
- act(() => result.current.move('left')); // preferredCol should reset
976
- state = getBufferState(result);
977
- expect(state.preferredCol).toBe(null);
978
- });
979
- it('move: home/end should go to visual line start/end', () => {
980
- const initialText = 'line one\nsecond line';
981
- const { result } = renderHook(() => useTextBuffer({
982
- initialText,
983
- viewport: { width: 5, height: 5 },
984
- isValidPath: () => false,
985
- }));
986
- expect(result.current.allVisualLines).toEqual([
987
- 'line',
988
- 'one',
989
- 'secon',
990
- 'd',
991
- 'line',
992
- ]);
993
- // Initial cursor [0,0] (start of "line")
994
- act(() => result.current.move('down')); // visual cursor from [0,0] to [1,0] ("o" of "one")
995
- act(() => result.current.move('right')); // visual cursor to [1,1] ("n" of "one")
996
- expect(getBufferState(result).visualCursor).toEqual([1, 1]);
997
- act(() => result.current.move('home')); // visual cursor to [1,0] (start of "one")
998
- expect(getBufferState(result).visualCursor).toEqual([1, 0]);
999
- act(() => result.current.move('end')); // visual cursor to [1,3] (end of "one")
1000
- expect(getBufferState(result).visualCursor).toEqual([1, 3]); // "one" is 3 chars
1001
- });
1002
- });
1003
- describe('Visual Layout & Viewport', () => {
1004
- it('should wrap long lines correctly into visualLines', () => {
1005
- const { result } = renderHook(() => useTextBuffer({
1006
- initialText: 'This is a very long line of text.', // 33 chars
1007
- viewport: { width: 10, height: 5 },
1008
- isValidPath: () => false,
1009
- }));
1010
- const state = getBufferState(result);
1011
- // Expected visual lines with word wrapping (viewport width 10):
1012
- // "This is a"
1013
- // "very long"
1014
- // "line of"
1015
- // "text."
1016
- expect(state.allVisualLines.length).toBe(4);
1017
- expect(state.allVisualLines[0]).toBe('This is a');
1018
- expect(state.allVisualLines[1]).toBe('very long');
1019
- expect(state.allVisualLines[2]).toBe('line of');
1020
- expect(state.allVisualLines[3]).toBe('text.');
1021
- });
1022
- it('should update visualScrollRow when visualCursor moves out of viewport', () => {
1023
- const { result } = renderHook(() => useTextBuffer({
1024
- initialText: 'l1\nl2\nl3\nl4\nl5',
1025
- viewport: { width: 5, height: 3 }, // Can show 3 visual lines
1026
- isValidPath: () => false,
1027
- }));
1028
- // Initial: l1, l2, l3 visible. visualScrollRow = 0. visualCursor = [0,0]
1029
- expect(getBufferState(result).visualScrollRow).toBe(0);
1030
- expect(getBufferState(result).allVisualLines).toEqual([
1031
- 'l1',
1032
- 'l2',
1033
- 'l3',
1034
- 'l4',
1035
- 'l5',
1036
- ]);
1037
- expect(getBufferState(result).viewportVisualLines).toEqual([
1038
- 'l1',
1039
- 'l2',
1040
- 'l3',
1041
- ]);
1042
- act(() => result.current.move('down')); // vc=[1,0]
1043
- act(() => result.current.move('down')); // vc=[2,0] (l3)
1044
- expect(getBufferState(result).visualScrollRow).toBe(0);
1045
- act(() => result.current.move('down')); // vc=[3,0] (l4) - scroll should happen
1046
- // Now: l2, l3, l4 visible. visualScrollRow = 1.
1047
- let state = getBufferState(result);
1048
- expect(state.visualScrollRow).toBe(1);
1049
- expect(state.allVisualLines).toEqual(['l1', 'l2', 'l3', 'l4', 'l5']);
1050
- expect(state.viewportVisualLines).toEqual(['l2', 'l3', 'l4']);
1051
- expect(state.visualCursor).toEqual([3, 0]);
1052
- act(() => result.current.move('up')); // vc=[2,0] (l3)
1053
- act(() => result.current.move('up')); // vc=[1,0] (l2)
1054
- expect(getBufferState(result).visualScrollRow).toBe(1);
1055
- act(() => result.current.move('up')); // vc=[0,0] (l1) - scroll up
1056
- // Now: l1, l2, l3 visible. visualScrollRow = 0
1057
- state = getBufferState(result); // Assign to the existing `state` variable
1058
- expect(state.visualScrollRow).toBe(0);
1059
- expect(state.allVisualLines).toEqual(['l1', 'l2', 'l3', 'l4', 'l5']);
1060
- expect(state.viewportVisualLines).toEqual(['l1', 'l2', 'l3']);
1061
- expect(state.visualCursor).toEqual([0, 0]);
1062
- });
1063
- });
1064
- describe('Undo/Redo', () => {
1065
- it('should undo and redo an insert operation', () => {
1066
- const { result } = renderHook(() => useTextBuffer({ viewport, isValidPath: () => false }));
1067
- act(() => result.current.insert('a'));
1068
- expect(getBufferState(result).text).toBe('a');
1069
- act(() => result.current.undo());
1070
- expect(getBufferState(result).text).toBe('');
1071
- expect(getBufferState(result).cursor).toEqual([0, 0]);
1072
- act(() => result.current.redo());
1073
- expect(getBufferState(result).text).toBe('a');
1074
- expect(getBufferState(result).cursor).toEqual([0, 1]);
1075
- });
1076
- it('should undo and redo a newline operation', () => {
1077
- const { result } = renderHook(() => useTextBuffer({
1078
- initialText: 'test',
1079
- viewport,
1080
- isValidPath: () => false,
1081
- }));
1082
- act(() => result.current.move('end'));
1083
- act(() => result.current.newline());
1084
- expect(getBufferState(result).text).toBe('test\n');
1085
- act(() => result.current.undo());
1086
- expect(getBufferState(result).text).toBe('test');
1087
- expect(getBufferState(result).cursor).toEqual([0, 4]);
1088
- act(() => result.current.redo());
1089
- expect(getBufferState(result).text).toBe('test\n');
1090
- expect(getBufferState(result).cursor).toEqual([1, 0]);
1091
- });
1092
- });
1093
- describe('Unicode Handling', () => {
1094
- it('insert: should correctly handle multi-byte unicode characters', () => {
1095
- const { result } = renderHook(() => useTextBuffer({ viewport, isValidPath: () => false }));
1096
- act(() => result.current.insert('你好'));
1097
- const state = getBufferState(result);
1098
- expect(state.text).toBe('你好');
1099
- expect(state.cursor).toEqual([0, 2]); // Cursor is 2 (char count)
1100
- expect(state.visualCursor).toEqual([0, 2]);
1101
- });
1102
- it('backspace: should correctly delete multi-byte unicode characters', () => {
1103
- const { result } = renderHook(() => useTextBuffer({
1104
- initialText: '你好',
1105
- viewport,
1106
- isValidPath: () => false,
1107
- }));
1108
- act(() => result.current.move('end')); // cursor at [0,2]
1109
- act(() => result.current.backspace()); // delete '好'
1110
- let state = getBufferState(result);
1111
- expect(state.text).toBe('你');
1112
- expect(state.cursor).toEqual([0, 1]);
1113
- act(() => result.current.backspace()); // delete '你'
1114
- state = getBufferState(result);
1115
- expect(state.text).toBe('');
1116
- expect(state.cursor).toEqual([0, 0]);
1117
- });
1118
- it('move: left/right should treat multi-byte chars as single units for visual cursor', () => {
1119
- const { result } = renderHook(() => useTextBuffer({
1120
- initialText: '🐶🐱',
1121
- viewport: { width: 5, height: 1 },
1122
- isValidPath: () => false,
1123
- }));
1124
- // Initial: visualCursor [0,0]
1125
- act(() => result.current.move('right')); // visualCursor [0,1] (after 🐶)
1126
- let state = getBufferState(result);
1127
- expect(state.cursor).toEqual([0, 1]);
1128
- expect(state.visualCursor).toEqual([0, 1]);
1129
- act(() => result.current.move('right')); // visualCursor [0,2] (after 🐱)
1130
- state = getBufferState(result);
1131
- expect(state.cursor).toEqual([0, 2]);
1132
- expect(state.visualCursor).toEqual([0, 2]);
1133
- act(() => result.current.move('left')); // visualCursor [0,1] (before 🐱 / after 🐶)
1134
- state = getBufferState(result);
1135
- expect(state.cursor).toEqual([0, 1]);
1136
- expect(state.visualCursor).toEqual([0, 1]);
1137
- });
1138
- it('moveToVisualPosition: should correctly handle wide characters (Chinese)', () => {
1139
- const { result } = renderHook(() => useTextBuffer({
1140
- initialText: '你好', // 2 chars, width 4
1141
- viewport: { width: 10, height: 1 },
1142
- isValidPath: () => false,
1143
- }));
1144
- // '你' (width 2): visual 0-1. '好' (width 2): visual 2-3.
1145
- // Click on '你' (first half, x=0) -> index 0
1146
- act(() => result.current.moveToVisualPosition(0, 0));
1147
- expect(getBufferState(result).cursor).toEqual([0, 0]);
1148
- // Click on '你' (second half, x=1) -> index 1 (after first char)
1149
- act(() => result.current.moveToVisualPosition(0, 1));
1150
- expect(getBufferState(result).cursor).toEqual([0, 1]);
1151
- // Click on '好' (first half, x=2) -> index 1 (before second char)
1152
- act(() => result.current.moveToVisualPosition(0, 2));
1153
- expect(getBufferState(result).cursor).toEqual([0, 1]);
1154
- // Click on '好' (second half, x=3) -> index 2 (after second char)
1155
- act(() => result.current.moveToVisualPosition(0, 3));
1156
- expect(getBufferState(result).cursor).toEqual([0, 2]);
1157
- });
1158
- });
1159
- describe('handleInput', () => {
1160
- it('should insert printable characters', () => {
1161
- const { result } = renderHook(() => useTextBuffer({ viewport, isValidPath: () => false }));
1162
- act(() => result.current.handleInput({
1163
- name: 'h',
1164
- shift: false,
1165
- alt: false,
1166
- ctrl: false,
1167
- cmd: false,
1168
- insertable: true,
1169
- sequence: 'h',
1170
- }));
1171
- act(() => result.current.handleInput({
1172
- name: 'i',
1173
- shift: false,
1174
- alt: false,
1175
- ctrl: false,
1176
- cmd: false,
1177
- insertable: true,
1178
- sequence: 'i',
1179
- }));
1180
- expect(getBufferState(result).text).toBe('hi');
1181
- });
1182
- it('should handle "Enter" key as newline', () => {
1183
- const { result } = renderHook(() => useTextBuffer({ viewport, isValidPath: () => false }));
1184
- act(() => result.current.handleInput({
1185
- name: 'return',
1186
- shift: false,
1187
- alt: false,
1188
- ctrl: false,
1189
- cmd: false,
1190
- insertable: true,
1191
- sequence: '\r',
1192
- }));
1193
- expect(getBufferState(result).lines).toEqual(['', '']);
1194
- });
1195
- it('should handle Ctrl+J as newline', () => {
1196
- const { result } = renderHook(() => useTextBuffer({ viewport, isValidPath: () => false }));
1197
- act(() => result.current.handleInput({
1198
- name: 'j',
1199
- shift: false,
1200
- alt: false,
1201
- ctrl: true,
1202
- cmd: false,
1203
- insertable: false,
1204
- sequence: '\n',
1205
- }));
1206
- expect(getBufferState(result).lines).toEqual(['', '']);
1207
- });
1208
- it('should do nothing for a tab key press', () => {
1209
- const { result } = renderHook(() => useTextBuffer({ viewport, isValidPath: () => false }));
1210
- act(() => result.current.handleInput({
1211
- name: 'tab',
1212
- shift: false,
1213
- alt: false,
1214
- ctrl: false,
1215
- cmd: false,
1216
- insertable: false,
1217
- sequence: '\t',
1218
- }));
1219
- expect(getBufferState(result).text).toBe('');
1220
- });
1221
- it('should do nothing for a shift tab key press', () => {
1222
- const { result } = renderHook(() => useTextBuffer({ viewport, isValidPath: () => false }));
1223
- act(() => result.current.handleInput({
1224
- name: 'tab',
1225
- shift: true,
1226
- alt: false,
1227
- ctrl: false,
1228
- cmd: false,
1229
- insertable: false,
1230
- sequence: '\u001b[9;2u',
1231
- }));
1232
- expect(getBufferState(result).text).toBe('');
1233
- });
1234
- it('should handle "Backspace" key', () => {
1235
- const { result } = renderHook(() => useTextBuffer({
1236
- initialText: 'a',
1237
- viewport,
1238
- isValidPath: () => false,
1239
- }));
1240
- act(() => result.current.move('end'));
1241
- act(() => result.current.handleInput({
1242
- name: 'backspace',
1243
- shift: false,
1244
- alt: false,
1245
- ctrl: false,
1246
- cmd: false,
1247
- insertable: false,
1248
- sequence: '\x7f',
1249
- }));
1250
- expect(getBufferState(result).text).toBe('');
1251
- });
1252
- it('should handle multiple delete characters in one input', () => {
1253
- const { result } = renderHook(() => useTextBuffer({
1254
- initialText: 'abcde',
1255
- viewport,
1256
- isValidPath: () => false,
1257
- }));
1258
- act(() => result.current.move('end')); // cursor at the end
1259
- expect(getBufferState(result).cursor).toEqual([0, 5]);
1260
- act(() => {
1261
- result.current.handleInput({
1262
- name: 'backspace',
1263
- shift: false,
1264
- alt: false,
1265
- ctrl: false,
1266
- cmd: false,
1267
- insertable: false,
1268
- sequence: '\x7f',
1269
- });
1270
- result.current.handleInput({
1271
- name: 'backspace',
1272
- shift: false,
1273
- alt: false,
1274
- ctrl: false,
1275
- cmd: false,
1276
- insertable: false,
1277
- sequence: '\x7f',
1278
- });
1279
- result.current.handleInput({
1280
- name: 'backspace',
1281
- shift: false,
1282
- alt: false,
1283
- ctrl: false,
1284
- cmd: false,
1285
- insertable: false,
1286
- sequence: '\x7f',
1287
- });
1288
- });
1289
- expect(getBufferState(result).text).toBe('ab');
1290
- expect(getBufferState(result).cursor).toEqual([0, 2]);
1291
- });
1292
- it('should handle inserts that contain delete characters', () => {
1293
- const { result } = renderHook(() => useTextBuffer({
1294
- initialText: 'abcde',
1295
- viewport,
1296
- isValidPath: () => false,
1297
- }));
1298
- act(() => result.current.move('end')); // cursor at the end
1299
- expect(getBufferState(result).cursor).toEqual([0, 5]);
1300
- act(() => {
1301
- result.current.insert('\x7f\x7f\x7f');
1302
- });
1303
- expect(getBufferState(result).text).toBe('ab');
1304
- expect(getBufferState(result).cursor).toEqual([0, 2]);
1305
- });
1306
- it('should handle inserts with a mix of regular and delete characters', () => {
1307
- const { result } = renderHook(() => useTextBuffer({
1308
- initialText: 'abcde',
1309
- viewport,
1310
- isValidPath: () => false,
1311
- }));
1312
- act(() => result.current.move('end')); // cursor at the end
1313
- expect(getBufferState(result).cursor).toEqual([0, 5]);
1314
- act(() => {
1315
- result.current.insert('\x7fI\x7f\x7fNEW');
1316
- });
1317
- expect(getBufferState(result).text).toBe('abcNEW');
1318
- expect(getBufferState(result).cursor).toEqual([0, 6]);
1319
- });
1320
- it('should handle arrow keys for movement', () => {
1321
- const { result } = renderHook(() => useTextBuffer({
1322
- initialText: 'ab',
1323
- viewport,
1324
- isValidPath: () => false,
1325
- }));
1326
- act(() => result.current.move('end')); // cursor [0,2]
1327
- act(() => result.current.handleInput({
1328
- name: 'left',
1329
- shift: false,
1330
- alt: false,
1331
- ctrl: false,
1332
- cmd: false,
1333
- insertable: false,
1334
- sequence: '\x1b[D',
1335
- }));
1336
- expect(getBufferState(result).cursor).toEqual([0, 1]);
1337
- act(() => result.current.handleInput({
1338
- name: 'right',
1339
- shift: false,
1340
- alt: false,
1341
- ctrl: false,
1342
- cmd: false,
1343
- insertable: false,
1344
- sequence: '\x1b[C',
1345
- }));
1346
- expect(getBufferState(result).cursor).toEqual([0, 2]);
1347
- });
1348
- it('should strip ANSI escape codes when pasting text', () => {
1349
- const { result } = renderHook(() => useTextBuffer({ viewport, isValidPath: () => false }));
1350
- const textWithAnsi = '\x1B[31mHello\x1B[0m \x1B[32mWorld\x1B[0m';
1351
- // Simulate pasting by calling handleInput with a string longer than 1 char
1352
- act(() => result.current.handleInput({
1353
- name: '',
1354
- shift: false,
1355
- alt: false,
1356
- ctrl: false,
1357
- cmd: false,
1358
- insertable: true,
1359
- sequence: textWithAnsi,
1360
- }));
1361
- expect(getBufferState(result).text).toBe('Hello World');
1362
- });
1363
- it('should handle VSCode terminal Shift+Enter as newline', () => {
1364
- const { result } = renderHook(() => useTextBuffer({ viewport, isValidPath: () => false }));
1365
- act(() => result.current.handleInput({
1366
- name: 'return',
1367
- shift: true,
1368
- alt: false,
1369
- ctrl: false,
1370
- cmd: false,
1371
- insertable: true,
1372
- sequence: '\r',
1373
- })); // Simulates Shift+Enter in VSCode terminal
1374
- expect(getBufferState(result).lines).toEqual(['', '']);
1375
- });
1376
- it('should correctly handle repeated pasting of long text', () => {
1377
- const longText = `not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
1378
-
1379
- Why do we use it?
1380
- It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
1381
-
1382
- Where does it come from?
1383
- Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lore
1384
- `;
1385
- const { result } = renderHook(() => useTextBuffer({ viewport, isValidPath: () => false }));
1386
- // Simulate pasting the long text multiple times
1387
- act(() => {
1388
- result.current.insert(longText, { paste: true });
1389
- result.current.insert(longText, { paste: true });
1390
- result.current.insert(longText, { paste: true });
1391
- });
1392
- const state = getBufferState(result);
1393
- // Check that the text is the result of three concatenations of unique placeholders.
1394
- // Now that ID generation is in the reducer, they are correctly unique even when batched.
1395
- expect(state.lines).toStrictEqual([
1396
- '[Pasted Text: 8 lines][Pasted Text: 8 lines #2][Pasted Text: 8 lines #3]',
1397
- ]);
1398
- expect(result.current.pastedContent['[Pasted Text: 8 lines]']).toBe(longText);
1399
- expect(result.current.pastedContent['[Pasted Text: 8 lines #2]']).toBe(longText);
1400
- expect(result.current.pastedContent['[Pasted Text: 8 lines #3]']).toBe(longText);
1401
- const expectedCursorPos = offsetToLogicalPos(state.text, state.text.length);
1402
- expect(state.cursor).toEqual(expectedCursorPos);
1403
- });
1404
- });
1405
- // More tests would be needed for:
1406
- // - setText, replaceRange
1407
- // - deleteWordLeft, deleteWordRight
1408
- // - More complex undo/redo scenarios
1409
- // - Selection and clipboard (copy/paste) - might need clipboard API mocks or internal state check
1410
- // - openInExternalEditor (heavy mocking of fs, child_process, os)
1411
- // - All edge cases for visual scrolling and wrapping with different viewport sizes and text content.
1412
- describe('replaceRange', () => {
1413
- it('should replace a single-line range with single-line text', () => {
1414
- const { result } = renderHook(() => useTextBuffer({
1415
- initialText: '@pac',
1416
- viewport,
1417
- isValidPath: () => false,
1418
- }));
1419
- act(() => result.current.replaceRange(0, 1, 0, 4, 'packages'));
1420
- const state = getBufferState(result);
1421
- expect(state.text).toBe('@packages');
1422
- expect(state.cursor).toEqual([0, 9]); // cursor after 'typescript'
1423
- });
1424
- it('should replace a multi-line range with single-line text', () => {
1425
- const { result } = renderHook(() => useTextBuffer({
1426
- initialText: 'hello\nworld\nagain',
1427
- viewport,
1428
- isValidPath: () => false,
1429
- }));
1430
- act(() => result.current.replaceRange(0, 2, 1, 3, ' new ')); // replace 'llo\nwor' with ' new '
1431
- const state = getBufferState(result);
1432
- expect(state.text).toBe('he new ld\nagain');
1433
- expect(state.cursor).toEqual([0, 7]); // cursor after ' new '
1434
- });
1435
- it('should delete a range when replacing with an empty string', () => {
1436
- const { result } = renderHook(() => useTextBuffer({
1437
- initialText: 'hello world',
1438
- viewport,
1439
- isValidPath: () => false,
1440
- }));
1441
- act(() => result.current.replaceRange(0, 5, 0, 11, '')); // delete ' world'
1442
- const state = getBufferState(result);
1443
- expect(state.text).toBe('hello');
1444
- expect(state.cursor).toEqual([0, 5]);
1445
- });
1446
- it('should handle replacing at the beginning of the text', () => {
1447
- const { result } = renderHook(() => useTextBuffer({
1448
- initialText: 'world',
1449
- viewport,
1450
- isValidPath: () => false,
1451
- }));
1452
- act(() => result.current.replaceRange(0, 0, 0, 0, 'hello '));
1453
- const state = getBufferState(result);
1454
- expect(state.text).toBe('hello world');
1455
- expect(state.cursor).toEqual([0, 6]);
1456
- });
1457
- it('should handle replacing at the end of the text', () => {
1458
- const { result } = renderHook(() => useTextBuffer({
1459
- initialText: 'hello',
1460
- viewport,
1461
- isValidPath: () => false,
1462
- }));
1463
- act(() => result.current.replaceRange(0, 5, 0, 5, ' world'));
1464
- const state = getBufferState(result);
1465
- expect(state.text).toBe('hello world');
1466
- expect(state.cursor).toEqual([0, 11]);
1467
- });
1468
- it('should handle replacing the entire buffer content', () => {
1469
- const { result } = renderHook(() => useTextBuffer({
1470
- initialText: 'old text',
1471
- viewport,
1472
- isValidPath: () => false,
1473
- }));
1474
- act(() => result.current.replaceRange(0, 0, 0, 8, 'new text'));
1475
- const state = getBufferState(result);
1476
- expect(state.text).toBe('new text');
1477
- expect(state.cursor).toEqual([0, 8]);
1478
- });
1479
- it('should correctly replace with unicode characters', () => {
1480
- const { result } = renderHook(() => useTextBuffer({
1481
- initialText: 'hello *** world',
1482
- viewport,
1483
- isValidPath: () => false,
1484
- }));
1485
- act(() => result.current.replaceRange(0, 6, 0, 9, '你好'));
1486
- const state = getBufferState(result);
1487
- expect(state.text).toBe('hello 你好 world');
1488
- expect(state.cursor).toEqual([0, 8]); // after '你好'
1489
- });
1490
- it('should handle invalid range by returning false and not changing text', () => {
1491
- const { result } = renderHook(() => useTextBuffer({
1492
- initialText: 'test',
1493
- viewport,
1494
- isValidPath: () => false,
1495
- }));
1496
- act(() => {
1497
- result.current.replaceRange(0, 5, 0, 3, 'fail'); // startCol > endCol in same line
1498
- });
1499
- expect(getBufferState(result).text).toBe('test');
1500
- act(() => {
1501
- result.current.replaceRange(1, 0, 0, 0, 'fail'); // startRow > endRow
1502
- });
1503
- expect(getBufferState(result).text).toBe('test');
1504
- });
1505
- it('replaceRange: multiple lines with a single character', () => {
1506
- const { result } = renderHook(() => useTextBuffer({
1507
- initialText: 'first\nsecond\nthird',
1508
- viewport,
1509
- isValidPath: () => false,
1510
- }));
1511
- act(() => result.current.replaceRange(0, 2, 2, 3, 'X')); // Replace 'rst\nsecond\nthi'
1512
- const state = getBufferState(result);
1513
- expect(state.text).toBe('fiXrd');
1514
- expect(state.cursor).toEqual([0, 3]); // After 'X'
1515
- });
1516
- it('should replace a single-line range with multi-line text', () => {
1517
- const { result } = renderHook(() => useTextBuffer({
1518
- initialText: 'one two three',
1519
- viewport,
1520
- isValidPath: () => false,
1521
- }));
1522
- // Replace "two" with "new\nline"
1523
- act(() => result.current.replaceRange(0, 4, 0, 7, 'new\nline'));
1524
- const state = getBufferState(result);
1525
- expect(state.lines).toEqual(['one new', 'line three']);
1526
- expect(state.text).toBe('one new\nline three');
1527
- expect(state.cursor).toEqual([1, 4]); // cursor after 'line'
1528
- });
1529
- });
1530
- describe('Input Sanitization', () => {
1531
- const createInput = (sequence) => ({
1532
- name: '',
1533
- shift: false,
1534
- alt: false,
1535
- ctrl: false,
1536
- cmd: false,
1537
- insertable: true,
1538
- sequence,
1539
- });
1540
- it.each([
1541
- {
1542
- input: '\x1B[31mHello\x1B[0m \x1B[32mWorld\x1B[0m',
1543
- expected: 'Hello World',
1544
- desc: 'ANSI escape codes',
1545
- },
1546
- {
1547
- input: 'H\x07e\x08l\x0Bl\x0Co',
1548
- expected: 'Hello',
1549
- desc: 'control characters',
1550
- },
1551
- {
1552
- input: '\u001B[4mH\u001B[0mello',
1553
- expected: 'Hello',
1554
- desc: 'mixed ANSI and control characters',
1555
- },
1556
- {
1557
- input: '\u001B[4mPasted\u001B[4m Text',
1558
- expected: 'Pasted Text',
1559
- desc: 'pasted text with ANSI',
1560
- },
1561
- ])('should strip $desc from input', ({ input, expected }) => {
1562
- const { result } = renderHook(() => useTextBuffer({ viewport, isValidPath: () => false }));
1563
- act(() => result.current.handleInput(createInput(input)));
1564
- expect(getBufferState(result).text).toBe(expected);
1565
- });
1566
- it('should not strip standard characters or newlines', () => {
1567
- const { result } = renderHook(() => useTextBuffer({ viewport, isValidPath: () => false }));
1568
- const validText = 'Hello World\nThis is a test.';
1569
- act(() => result.current.handleInput(createInput(validText)));
1570
- expect(getBufferState(result).text).toBe(validText);
1571
- });
1572
- it('should sanitize large text (>5000 chars) and strip unsafe characters', () => {
1573
- const { result } = renderHook(() => useTextBuffer({ viewport, isValidPath: () => false }));
1574
- const unsafeChars = '\x07\x08\x0B\x0C';
1575
- const largeTextWithUnsafe = 'safe text'.repeat(600) + unsafeChars + 'more safe text';
1576
- expect(largeTextWithUnsafe.length).toBeGreaterThan(5000);
1577
- act(() => result.current.handleInput({
1578
- name: '',
1579
- shift: false,
1580
- alt: false,
1581
- ctrl: false,
1582
- cmd: false,
1583
- insertable: true,
1584
- sequence: largeTextWithUnsafe,
1585
- }));
1586
- const resultText = getBufferState(result).text;
1587
- expect(resultText).not.toContain('\x07');
1588
- expect(resultText).not.toContain('\x08');
1589
- expect(resultText).not.toContain('\x0B');
1590
- expect(resultText).not.toContain('\x0C');
1591
- expect(resultText).toContain('safe text');
1592
- expect(resultText).toContain('more safe text');
1593
- });
1594
- it('should sanitize large ANSI text (>5000 chars) and strip escape codes', () => {
1595
- const { result } = renderHook(() => useTextBuffer({ viewport, isValidPath: () => false }));
1596
- const largeTextWithAnsi = '\x1B[31m' +
1597
- 'red text'.repeat(800) +
1598
- '\x1B[0m' +
1599
- '\x1B[32m' +
1600
- 'green text'.repeat(200) +
1601
- '\x1B[0m';
1602
- expect(largeTextWithAnsi.length).toBeGreaterThan(5000);
1603
- act(() => result.current.handleInput({
1604
- name: '',
1605
- shift: false,
1606
- alt: false,
1607
- ctrl: false,
1608
- cmd: false,
1609
- insertable: true,
1610
- sequence: largeTextWithAnsi,
1611
- }));
1612
- const resultText = getBufferState(result).text;
1613
- expect(resultText).not.toContain('\x1B[31m');
1614
- expect(resultText).not.toContain('\x1B[32m');
1615
- expect(resultText).not.toContain('\x1B[0m');
1616
- expect(resultText).toContain('red text');
1617
- expect(resultText).toContain('green text');
1618
- });
1619
- it('should not strip popular emojis', () => {
1620
- const { result } = renderHook(() => useTextBuffer({ viewport, isValidPath: () => false }));
1621
- const emojis = '🐍🐳🦀🦄';
1622
- act(() => result.current.handleInput({
1623
- name: '',
1624
- shift: false,
1625
- alt: false,
1626
- ctrl: false,
1627
- cmd: false,
1628
- insertable: true,
1629
- sequence: emojis,
1630
- }));
1631
- expect(getBufferState(result).text).toBe(emojis);
1632
- });
1633
- });
1634
- describe('inputFilter', () => {
1635
- it('should filter input based on the provided filter function', () => {
1636
- const { result } = renderHook(() => useTextBuffer({
1637
- viewport,
1638
- isValidPath: () => false,
1639
- inputFilter: (text) => text.replace(/[^0-9]/g, ''),
1640
- }));
1641
- act(() => result.current.insert('a1b2c3'));
1642
- expect(getBufferState(result).text).toBe('123');
1643
- });
1644
- it('should handle empty result from filter', () => {
1645
- const { result } = renderHook(() => useTextBuffer({
1646
- viewport,
1647
- isValidPath: () => false,
1648
- inputFilter: (text) => text.replace(/[^0-9]/g, ''),
1649
- }));
1650
- act(() => result.current.insert('abc'));
1651
- expect(getBufferState(result).text).toBe('');
1652
- });
1653
- it('should filter pasted text', () => {
1654
- const { result } = renderHook(() => useTextBuffer({
1655
- viewport,
1656
- isValidPath: () => false,
1657
- inputFilter: (text) => text.toUpperCase(),
1658
- }));
1659
- act(() => result.current.insert('hello', { paste: true }));
1660
- expect(getBufferState(result).text).toBe('HELLO');
1661
- });
1662
- it('should not filter newlines if they are allowed by the filter', () => {
1663
- const { result } = renderHook(() => useTextBuffer({
1664
- viewport,
1665
- isValidPath: () => false,
1666
- inputFilter: (text) => text, // Allow everything including newlines
1667
- }));
1668
- act(() => result.current.insert('a\nb'));
1669
- // The insert function splits by newline and inserts separately if it detects them.
1670
- // If the filter allows them, they should be handled correctly by the subsequent logic in insert.
1671
- expect(getBufferState(result).text).toBe('a\nb');
1672
- });
1673
- it('should filter before newline check in insert', () => {
1674
- const { result } = renderHook(() => useTextBuffer({
1675
- viewport,
1676
- isValidPath: () => false,
1677
- inputFilter: (text) => text.replace(/\n/g, ''), // Filter out newlines
1678
- }));
1679
- act(() => result.current.insert('a\nb'));
1680
- expect(getBufferState(result).text).toBe('ab');
1681
- });
1682
- });
1683
- describe('stripAnsi', () => {
1684
- it('should correctly strip ANSI escape codes', () => {
1685
- const textWithAnsi = '\x1B[31mHello\x1B[0m World';
1686
- expect(stripAnsi(textWithAnsi)).toBe('Hello World');
1687
- });
1688
- it('should handle multiple ANSI codes', () => {
1689
- const textWithMultipleAnsi = '\x1B[1m\x1B[34mBold Blue\x1B[0m Text';
1690
- expect(stripAnsi(textWithMultipleAnsi)).toBe('Bold Blue Text');
1691
- });
1692
- it('should not modify text without ANSI codes', () => {
1693
- const plainText = 'Plain text';
1694
- expect(stripAnsi(plainText)).toBe('Plain text');
1695
- });
1696
- it('should handle empty string', () => {
1697
- expect(stripAnsi('')).toBe('');
1698
- });
1699
- });
1700
- describe('Memoization', () => {
1701
- it('should keep action references stable across re-renders', () => {
1702
- // We pass a stable `isValidPath` so that callbacks that depend on it
1703
- // are not recreated on every render.
1704
- const isValidPath = () => false;
1705
- const { result, rerender } = renderHook(() => useTextBuffer({ viewport, isValidPath }));
1706
- const initialInsert = result.current.insert;
1707
- const initialBackspace = result.current.backspace;
1708
- const initialMove = result.current.move;
1709
- const initialHandleInput = result.current.handleInput;
1710
- rerender();
1711
- expect(result.current.insert).toBe(initialInsert);
1712
- expect(result.current.backspace).toBe(initialBackspace);
1713
- expect(result.current.move).toBe(initialMove);
1714
- expect(result.current.handleInput).toBe(initialHandleInput);
1715
- });
1716
- it('should have memoized actions that operate on the latest state', () => {
1717
- const isValidPath = () => false;
1718
- const { result } = renderHook(() => useTextBuffer({ viewport, isValidPath }));
1719
- // Store a reference to the memoized insert function.
1720
- const memoizedInsert = result.current.insert;
1721
- // Update the buffer state.
1722
- act(() => {
1723
- result.current.insert('hello');
1724
- });
1725
- expect(getBufferState(result).text).toBe('hello');
1726
- // Now, call the original memoized function reference.
1727
- act(() => {
1728
- memoizedInsert(' world');
1729
- });
1730
- // It should have operated on the updated state.
1731
- expect(getBufferState(result).text).toBe('hello world');
1732
- });
1733
- });
1734
- describe('singleLine mode', () => {
1735
- it('should not insert a newline character when singleLine is true', () => {
1736
- const { result } = renderHook(() => useTextBuffer({
1737
- viewport,
1738
- isValidPath: () => false,
1739
- singleLine: true,
1740
- }));
1741
- act(() => result.current.insert('\n'));
1742
- const state = getBufferState(result);
1743
- expect(state.text).toBe('');
1744
- expect(state.lines).toEqual(['']);
1745
- });
1746
- it('should not create a new line when newline() is called and singleLine is true', () => {
1747
- const { result } = renderHook(() => useTextBuffer({
1748
- initialText: 'ab',
1749
- viewport,
1750
- isValidPath: () => false,
1751
- singleLine: true,
1752
- }));
1753
- act(() => result.current.move('end')); // cursor at [0,2]
1754
- act(() => result.current.newline());
1755
- const state = getBufferState(result);
1756
- expect(state.text).toBe('ab');
1757
- expect(state.lines).toEqual(['ab']);
1758
- expect(state.cursor).toEqual([0, 2]);
1759
- });
1760
- it('should not handle "Enter" key as newline when singleLine is true', () => {
1761
- const { result } = renderHook(() => useTextBuffer({
1762
- viewport,
1763
- isValidPath: () => false,
1764
- singleLine: true,
1765
- }));
1766
- act(() => result.current.handleInput({
1767
- name: 'return',
1768
- shift: false,
1769
- alt: false,
1770
- ctrl: false,
1771
- cmd: false,
1772
- insertable: true,
1773
- sequence: '\r',
1774
- }));
1775
- expect(getBufferState(result).lines).toEqual(['']);
1776
- });
1777
- it('should not print anything for function keys when singleLine is true', () => {
1778
- const { result } = renderHook(() => useTextBuffer({
1779
- viewport,
1780
- isValidPath: () => false,
1781
- singleLine: true,
1782
- }));
1783
- act(() => result.current.handleInput({
1784
- name: 'f1',
1785
- shift: false,
1786
- alt: false,
1787
- ctrl: false,
1788
- cmd: false,
1789
- insertable: false,
1790
- sequence: '\u001bOP',
1791
- }));
1792
- expect(getBufferState(result).lines).toEqual(['']);
1793
- });
1794
- it('should strip newlines from pasted text when singleLine is true', () => {
1795
- const { result } = renderHook(() => useTextBuffer({
1796
- viewport,
1797
- isValidPath: () => false,
1798
- singleLine: true,
1799
- }));
1800
- act(() => result.current.insert('hello\nworld', { paste: true }));
1801
- const state = getBufferState(result);
1802
- expect(state.text).toBe('helloworld');
1803
- expect(state.lines).toEqual(['helloworld']);
1804
- });
1805
- });
1806
- });
1807
- describe('offsetToLogicalPos', () => {
1808
- it.each([
1809
- { text: 'any text', offset: 0, expected: [0, 0], desc: 'offset 0' },
1810
- { text: 'hello', offset: 0, expected: [0, 0], desc: 'single line start' },
1811
- { text: 'hello', offset: 2, expected: [0, 2], desc: 'single line middle' },
1812
- { text: 'hello', offset: 5, expected: [0, 5], desc: 'single line end' },
1813
- { text: 'hello', offset: 10, expected: [0, 5], desc: 'beyond end clamps' },
1814
- {
1815
- text: 'a\n\nc',
1816
- offset: 0,
1817
- expected: [0, 0],
1818
- desc: 'empty lines - first char',
1819
- },
1820
- {
1821
- text: 'a\n\nc',
1822
- offset: 1,
1823
- expected: [0, 1],
1824
- desc: 'empty lines - end of first',
1825
- },
1826
- {
1827
- text: 'a\n\nc',
1828
- offset: 2,
1829
- expected: [1, 0],
1830
- desc: 'empty lines - empty line',
1831
- },
1832
- {
1833
- text: 'a\n\nc',
1834
- offset: 3,
1835
- expected: [2, 0],
1836
- desc: 'empty lines - last line start',
1837
- },
1838
- {
1839
- text: 'a\n\nc',
1840
- offset: 4,
1841
- expected: [2, 1],
1842
- desc: 'empty lines - last line end',
1843
- },
1844
- {
1845
- text: 'hello\n',
1846
- offset: 5,
1847
- expected: [0, 5],
1848
- desc: 'newline end - before newline',
1849
- },
1850
- {
1851
- text: 'hello\n',
1852
- offset: 6,
1853
- expected: [1, 0],
1854
- desc: 'newline end - after newline',
1855
- },
1856
- {
1857
- text: 'hello\n',
1858
- offset: 7,
1859
- expected: [1, 0],
1860
- desc: 'newline end - beyond',
1861
- },
1862
- {
1863
- text: '\nhello',
1864
- offset: 0,
1865
- expected: [0, 0],
1866
- desc: 'newline start - first line',
1867
- },
1868
- {
1869
- text: '\nhello',
1870
- offset: 1,
1871
- expected: [1, 0],
1872
- desc: 'newline start - second line',
1873
- },
1874
- {
1875
- text: '\nhello',
1876
- offset: 3,
1877
- expected: [1, 2],
1878
- desc: 'newline start - middle of second',
1879
- },
1880
- { text: '', offset: 0, expected: [0, 0], desc: 'empty string at 0' },
1881
- { text: '', offset: 5, expected: [0, 0], desc: 'empty string beyond' },
1882
- {
1883
- text: '你好\n世界',
1884
- offset: 0,
1885
- expected: [0, 0],
1886
- desc: 'unicode - start',
1887
- },
1888
- {
1889
- text: '你好\n世界',
1890
- offset: 1,
1891
- expected: [0, 1],
1892
- desc: 'unicode - after first char',
1893
- },
1894
- {
1895
- text: '你好\n世界',
1896
- offset: 2,
1897
- expected: [0, 2],
1898
- desc: 'unicode - end first line',
1899
- },
1900
- {
1901
- text: '你好\n世界',
1902
- offset: 3,
1903
- expected: [1, 0],
1904
- desc: 'unicode - second line start',
1905
- },
1906
- {
1907
- text: '你好\n世界',
1908
- offset: 4,
1909
- expected: [1, 1],
1910
- desc: 'unicode - second line middle',
1911
- },
1912
- {
1913
- text: '你好\n世界',
1914
- offset: 5,
1915
- expected: [1, 2],
1916
- desc: 'unicode - second line end',
1917
- },
1918
- {
1919
- text: '你好\n世界',
1920
- offset: 6,
1921
- expected: [1, 2],
1922
- desc: 'unicode - beyond',
1923
- },
1924
- {
1925
- text: 'abc\ndef',
1926
- offset: 3,
1927
- expected: [0, 3],
1928
- desc: 'at newline - end of line',
1929
- },
1930
- {
1931
- text: 'abc\ndef',
1932
- offset: 4,
1933
- expected: [1, 0],
1934
- desc: 'at newline - after newline',
1935
- },
1936
- { text: '🐶🐱', offset: 0, expected: [0, 0], desc: 'emoji - start' },
1937
- { text: '🐶🐱', offset: 1, expected: [0, 1], desc: 'emoji - middle' },
1938
- { text: '🐶🐱', offset: 2, expected: [0, 2], desc: 'emoji - end' },
1939
- ])('should handle $desc', ({ text, offset, expected }) => {
1940
- expect(offsetToLogicalPos(text, offset)).toEqual(expected);
1941
- });
1942
- describe('multi-line text', () => {
1943
- const text = 'hello\nworld\n123';
1944
- it.each([
1945
- { offset: 0, expected: [0, 0], desc: 'start of first line' },
1946
- { offset: 3, expected: [0, 3], desc: 'middle of first line' },
1947
- { offset: 5, expected: [0, 5], desc: 'end of first line' },
1948
- { offset: 6, expected: [1, 0], desc: 'start of second line' },
1949
- { offset: 8, expected: [1, 2], desc: 'middle of second line' },
1950
- { offset: 11, expected: [1, 5], desc: 'end of second line' },
1951
- { offset: 12, expected: [2, 0], desc: 'start of third line' },
1952
- { offset: 13, expected: [2, 1], desc: 'middle of third line' },
1953
- { offset: 15, expected: [2, 3], desc: 'end of third line' },
1954
- { offset: 20, expected: [2, 3], desc: 'beyond end' },
1955
- ])('should return $expected for $desc (offset $offset)', ({ offset, expected }) => {
1956
- expect(offsetToLogicalPos(text, offset)).toEqual(expected);
1957
- });
1958
- });
1959
- });
1960
- describe('logicalPosToOffset', () => {
1961
- it('should convert row/col position to offset correctly', () => {
1962
- const lines = ['hello', 'world', '123'];
1963
- // Line 0: "hello" (5 chars)
1964
- expect(logicalPosToOffset(lines, 0, 0)).toBe(0); // Start of 'hello'
1965
- expect(logicalPosToOffset(lines, 0, 3)).toBe(3); // 'l' in 'hello'
1966
- expect(logicalPosToOffset(lines, 0, 5)).toBe(5); // End of 'hello'
1967
- // Line 1: "world" (5 chars), offset starts at 6 (5 + 1 for newline)
1968
- expect(logicalPosToOffset(lines, 1, 0)).toBe(6); // Start of 'world'
1969
- expect(logicalPosToOffset(lines, 1, 2)).toBe(8); // 'r' in 'world'
1970
- expect(logicalPosToOffset(lines, 1, 5)).toBe(11); // End of 'world'
1971
- // Line 2: "123" (3 chars), offset starts at 12 (5 + 1 + 5 + 1)
1972
- expect(logicalPosToOffset(lines, 2, 0)).toBe(12); // Start of '123'
1973
- expect(logicalPosToOffset(lines, 2, 1)).toBe(13); // '2' in '123'
1974
- expect(logicalPosToOffset(lines, 2, 3)).toBe(15); // End of '123'
1975
- });
1976
- it('should handle empty lines', () => {
1977
- const lines = ['a', '', 'c'];
1978
- expect(logicalPosToOffset(lines, 0, 0)).toBe(0); // 'a'
1979
- expect(logicalPosToOffset(lines, 0, 1)).toBe(1); // End of 'a'
1980
- expect(logicalPosToOffset(lines, 1, 0)).toBe(2); // Empty line
1981
- expect(logicalPosToOffset(lines, 2, 0)).toBe(3); // 'c'
1982
- expect(logicalPosToOffset(lines, 2, 1)).toBe(4); // End of 'c'
1983
- });
1984
- it('should handle single empty line', () => {
1985
- const lines = [''];
1986
- expect(logicalPosToOffset(lines, 0, 0)).toBe(0);
1987
- });
1988
- it('should be inverse of offsetToLogicalPos', () => {
1989
- const lines = ['hello', 'world', '123'];
1990
- const text = lines.join('\n');
1991
- // Test round-trip conversion
1992
- for (let offset = 0; offset <= text.length; offset++) {
1993
- const [row, col] = offsetToLogicalPos(text, offset);
1994
- const convertedOffset = logicalPosToOffset(lines, row, col);
1995
- expect(convertedOffset).toBe(offset);
1996
- }
1997
- });
1998
- it('should handle out-of-bounds positions', () => {
1999
- const lines = ['hello'];
2000
- // Beyond end of line
2001
- expect(logicalPosToOffset(lines, 0, 10)).toBe(5); // Clamps to end of line
2002
- // Beyond array bounds - should clamp to the last line
2003
- expect(logicalPosToOffset(lines, 5, 0)).toBe(0); // Clamps to start of last line (row 0)
2004
- expect(logicalPosToOffset(lines, 5, 10)).toBe(5); // Clamps to end of last line
2005
- });
2006
- });
2007
- const createTestState = (lines, cursorRow, cursorCol, viewportWidth = 80) => {
2008
- const text = lines.join('\n');
2009
- let state = textBufferReducer(initialState, {
2010
- type: 'set_text',
2011
- payload: text,
2012
- });
2013
- state = textBufferReducer(state, {
2014
- type: 'set_cursor',
2015
- payload: { cursorRow, cursorCol, preferredCol: null },
2016
- });
2017
- state = textBufferReducer(state, {
2018
- type: 'set_viewport',
2019
- payload: { width: viewportWidth, height: 24 },
2020
- });
2021
- return state;
2022
- };
2023
- describe('textBufferReducer vim operations', () => {
2024
- describe('vim_delete_line', () => {
2025
- it('should delete a single line including newline in multi-line text', () => {
2026
- const state = createTestState(['line1', 'line2', 'line3'], 1, 2);
2027
- const action = {
2028
- type: 'vim_delete_line',
2029
- payload: { count: 1 },
2030
- };
2031
- const result = textBufferReducer(state, action);
2032
- expect(result).toHaveOnlyValidCharacters();
2033
- // After deleting line2, we should have line1 and line3, with cursor on line3 (now at index 1)
2034
- expect(result.lines).toEqual(['line1', 'line3']);
2035
- expect(result.cursorRow).toBe(1);
2036
- expect(result.cursorCol).toBe(0);
2037
- });
2038
- it('should delete multiple lines when count > 1', () => {
2039
- const state = createTestState(['line1', 'line2', 'line3', 'line4'], 1, 0);
2040
- const action = {
2041
- type: 'vim_delete_line',
2042
- payload: { count: 2 },
2043
- };
2044
- const result = textBufferReducer(state, action);
2045
- expect(result).toHaveOnlyValidCharacters();
2046
- // Should delete line2 and line3, leaving line1 and line4
2047
- expect(result.lines).toEqual(['line1', 'line4']);
2048
- expect(result.cursorRow).toBe(1);
2049
- expect(result.cursorCol).toBe(0);
2050
- });
2051
- it('should clear single line content when only one line exists', () => {
2052
- const state = createTestState(['only line'], 0, 5);
2053
- const action = {
2054
- type: 'vim_delete_line',
2055
- payload: { count: 1 },
2056
- };
2057
- const result = textBufferReducer(state, action);
2058
- expect(result).toHaveOnlyValidCharacters();
2059
- // Should clear the line content but keep the line
2060
- expect(result.lines).toEqual(['']);
2061
- expect(result.cursorRow).toBe(0);
2062
- expect(result.cursorCol).toBe(0);
2063
- });
2064
- it('should handle deleting the last line properly', () => {
2065
- const state = createTestState(['line1', 'line2'], 1, 0);
2066
- const action = {
2067
- type: 'vim_delete_line',
2068
- payload: { count: 1 },
2069
- };
2070
- const result = textBufferReducer(state, action);
2071
- expect(result).toHaveOnlyValidCharacters();
2072
- // Should delete the last line completely, not leave empty line
2073
- expect(result.lines).toEqual(['line1']);
2074
- expect(result.cursorRow).toBe(0);
2075
- expect(result.cursorCol).toBe(0);
2076
- });
2077
- it('should handle deleting all lines and maintain valid state for subsequent paste', () => {
2078
- const state = createTestState(['line1', 'line2', 'line3', 'line4'], 0, 0);
2079
- // Delete all 4 lines with 4dd
2080
- const deleteAction = {
2081
- type: 'vim_delete_line',
2082
- payload: { count: 4 },
2083
- };
2084
- const afterDelete = textBufferReducer(state, deleteAction);
2085
- expect(afterDelete).toHaveOnlyValidCharacters();
2086
- // After deleting all lines, should have one empty line
2087
- expect(afterDelete.lines).toEqual(['']);
2088
- expect(afterDelete.cursorRow).toBe(0);
2089
- expect(afterDelete.cursorCol).toBe(0);
2090
- // Now paste multiline content - this should work correctly
2091
- const pasteAction = {
2092
- type: 'insert',
2093
- payload: 'new1\nnew2\nnew3\nnew4',
2094
- };
2095
- const afterPaste = textBufferReducer(afterDelete, pasteAction);
2096
- expect(afterPaste).toHaveOnlyValidCharacters();
2097
- // All lines including the first one should be present
2098
- expect(afterPaste.lines).toEqual(['new1', 'new2', 'new3', 'new4']);
2099
- expect(afterPaste.cursorRow).toBe(3);
2100
- expect(afterPaste.cursorCol).toBe(4);
2101
- });
2102
- });
2103
- });
2104
- describe('Unicode helper functions', () => {
2105
- describe('findWordEndInLine with Unicode', () => {
2106
- it('should handle combining characters', () => {
2107
- // café with combining accent
2108
- const cafeWithCombining = 'cafe\u0301';
2109
- const result = findWordEndInLine(cafeWithCombining + ' test', 0);
2110
- expect(result).toBe(3); // End of 'café' at base character 'e', not combining accent
2111
- });
2112
- it('should handle precomposed characters with diacritics', () => {
2113
- // café with precomposed é (U+00E9)
2114
- const cafePrecomposed = 'café';
2115
- const result = findWordEndInLine(cafePrecomposed + ' test', 0);
2116
- expect(result).toBe(3); // End of 'café' at precomposed character 'é'
2117
- });
2118
- it('should return null when no word end found', () => {
2119
- const result = findWordEndInLine(' ', 0);
2120
- expect(result).toBeNull(); // No word end found in whitespace-only string string
2121
- });
2122
- });
2123
- describe('findNextWordStartInLine with Unicode', () => {
2124
- it('should handle right-to-left text', () => {
2125
- const result = findNextWordStartInLine('hello مرحبا world', 0);
2126
- expect(result).toBe(6); // Start of Arabic word
2127
- });
2128
- it('should handle Chinese characters', () => {
2129
- const result = findNextWordStartInLine('hello 你好 world', 0);
2130
- expect(result).toBe(6); // Start of Chinese word
2131
- });
2132
- it('should return null at end of line', () => {
2133
- const result = findNextWordStartInLine('hello', 10);
2134
- expect(result).toBeNull();
2135
- });
2136
- it('should handle combining characters', () => {
2137
- // café with combining accent + next word
2138
- const textWithCombining = 'cafe\u0301 test';
2139
- const result = findNextWordStartInLine(textWithCombining, 0);
2140
- expect(result).toBe(6); // Start of 'test' after 'café ' (combining char makes string longer)
2141
- });
2142
- it('should handle precomposed characters with diacritics', () => {
2143
- // café with precomposed é + next word
2144
- const textPrecomposed = 'café test';
2145
- const result = findNextWordStartInLine(textPrecomposed, 0);
2146
- expect(result).toBe(5); // Start of 'test' after 'café '
2147
- });
2148
- });
2149
- describe('isWordCharStrict with Unicode', () => {
2150
- it('should return true for ASCII word characters', () => {
2151
- expect(isWordCharStrict('a')).toBe(true);
2152
- expect(isWordCharStrict('Z')).toBe(true);
2153
- expect(isWordCharStrict('0')).toBe(true);
2154
- expect(isWordCharStrict('_')).toBe(true);
2155
- });
2156
- it('should return false for punctuation', () => {
2157
- expect(isWordCharStrict('.')).toBe(false);
2158
- expect(isWordCharStrict(',')).toBe(false);
2159
- expect(isWordCharStrict('!')).toBe(false);
2160
- });
2161
- it('should return true for non-Latin scripts', () => {
2162
- expect(isWordCharStrict('你')).toBe(true); // Chinese character
2163
- expect(isWordCharStrict('م')).toBe(true); // Arabic character
2164
- });
2165
- it('should return false for whitespace', () => {
2166
- expect(isWordCharStrict(' ')).toBe(false);
2167
- expect(isWordCharStrict('\t')).toBe(false);
2168
- });
2169
- });
2170
- describe('cpLen with Unicode', () => {
2171
- it('should handle combining characters', () => {
2172
- expect(cpLen('é')).toBe(1); // Precomposed
2173
- expect(cpLen('e\u0301')).toBe(2); // e + combining acute
2174
- });
2175
- it('should handle Chinese and Arabic text', () => {
2176
- expect(cpLen('hello 你好 world')).toBe(14); // 5 + 1 + 2 + 1 + 5 = 14
2177
- expect(cpLen('hello مرحبا world')).toBe(17);
2178
- });
2179
- });
2180
- describe('useTextBuffer CJK Navigation', () => {
2181
- const viewport = { width: 80, height: 24 };
2182
- it('should navigate by word in Chinese', () => {
2183
- const { result } = renderHook(() => useTextBuffer({
2184
- initialText: '你好世界',
2185
- initialCursorOffset: 4, // End of string
2186
- viewport,
2187
- isValidPath: () => false,
2188
- }));
2189
- // Initial state: cursor at end (index 2 in code points if 4 is length? wait. length is 2 code points? No. '你好世界' length is 4.)
2190
- // '你好世界' length is 4. Code points length is 4.
2191
- // Move word left
2192
- act(() => {
2193
- result.current.move('wordLeft');
2194
- });
2195
- // Should be at start of "世界" (index 2)
2196
- // "你好世界" -> "你好" | "世界"
2197
- expect(result.current.cursor[1]).toBe(2);
2198
- // Move word left again
2199
- act(() => {
2200
- result.current.move('wordLeft');
2201
- });
2202
- // Should be at start of "你好" (index 0)
2203
- expect(result.current.cursor[1]).toBe(0);
2204
- // Move word left again (should stay at 0)
2205
- act(() => {
2206
- result.current.move('wordLeft');
2207
- });
2208
- expect(result.current.cursor[1]).toBe(0);
2209
- // Move word right
2210
- act(() => {
2211
- result.current.move('wordRight');
2212
- });
2213
- // Should be at end of "你好" (index 2)
2214
- expect(result.current.cursor[1]).toBe(2);
2215
- // Move word right again
2216
- act(() => {
2217
- result.current.move('wordRight');
2218
- });
2219
- // Should be at end of "世界" (index 4)
2220
- expect(result.current.cursor[1]).toBe(4);
2221
- // Move word right again (should stay at end)
2222
- act(() => {
2223
- result.current.move('wordRight');
2224
- });
2225
- expect(result.current.cursor[1]).toBe(4);
2226
- });
2227
- it('should navigate mixed English and Chinese', () => {
2228
- const { result } = renderHook(() => useTextBuffer({
2229
- initialText: 'Hello你好World',
2230
- initialCursorOffset: 10, // End
2231
- viewport,
2232
- isValidPath: () => false,
2233
- }));
2234
- // Hello (5) + 你好 (2) + World (5) = 12 chars.
2235
- // initialCursorOffset 10? 'Hello你好World'.length is 12.
2236
- // Let's set it to end.
2237
- act(() => {
2238
- result.current.move('end');
2239
- });
2240
- expect(result.current.cursor[1]).toBe(12);
2241
- // wordLeft -> start of "World" (index 7)
2242
- act(() => result.current.move('wordLeft'));
2243
- expect(result.current.cursor[1]).toBe(7);
2244
- // wordLeft -> start of "你好" (index 5)
2245
- act(() => result.current.move('wordLeft'));
2246
- expect(result.current.cursor[1]).toBe(5);
2247
- // wordLeft -> start of "Hello" (index 0)
2248
- act(() => result.current.move('wordLeft'));
2249
- expect(result.current.cursor[1]).toBe(0);
2250
- // wordLeft -> start of line (should stay at 0)
2251
- act(() => result.current.move('wordLeft'));
2252
- expect(result.current.cursor[1]).toBe(0);
2253
- });
2254
- });
2255
- });
2256
- describe('Transformation Utilities', () => {
2257
- afterEach(() => {
2258
- vi.restoreAllMocks();
2259
- });
2260
- describe('getTransformedImagePath', () => {
2261
- it('should transform a simple image path', () => {
2262
- expect(getTransformedImagePath('@test.png')).toBe('[Image test.png]');
2263
- });
2264
- it('should handle paths with directories', () => {
2265
- expect(getTransformedImagePath('@path/to/image.jpg')).toBe('[Image image.jpg]');
2266
- });
2267
- it('should truncate long filenames', () => {
2268
- expect(getTransformedImagePath('@verylongfilename1234567890.png')).toBe('[Image ...1234567890.png]');
2269
- });
2270
- it('should handle different image extensions', () => {
2271
- expect(getTransformedImagePath('@test.jpg')).toBe('[Image test.jpg]');
2272
- expect(getTransformedImagePath('@test.jpeg')).toBe('[Image test.jpeg]');
2273
- expect(getTransformedImagePath('@test.gif')).toBe('[Image test.gif]');
2274
- expect(getTransformedImagePath('@test.webp')).toBe('[Image test.webp]');
2275
- expect(getTransformedImagePath('@test.svg')).toBe('[Image test.svg]');
2276
- expect(getTransformedImagePath('@test.bmp')).toBe('[Image test.bmp]');
2277
- });
2278
- it('should handle POSIX-style forward-slash paths on any platform', () => {
2279
- const input = '@C:/Users/foo/screenshots/image2x.png';
2280
- expect(getTransformedImagePath(input)).toBe('[Image image2x.png]');
2281
- });
2282
- it('should handle Windows-style backslash paths on any platform', () => {
2283
- const input = '@C:\\Users\\foo\\screenshots\\image2x.png';
2284
- expect(getTransformedImagePath(input)).toBe('[Image image2x.png]');
2285
- });
2286
- it('should handle escaped spaces in paths', () => {
2287
- const input = '@path/to/my\\ file.png';
2288
- expect(getTransformedImagePath(input)).toBe('[Image my file.png]');
2289
- });
2290
- });
2291
- describe('getTransformationsForLine', () => {
2292
- it('should find transformations in a line', () => {
2293
- const line = 'Check out @test.png and @another.jpg';
2294
- const result = calculateTransformationsForLine(line);
2295
- expect(result).toHaveLength(2);
2296
- expect(result[0]).toMatchObject({
2297
- logicalText: '@test.png',
2298
- collapsedText: '[Image test.png]',
2299
- });
2300
- expect(result[1]).toMatchObject({
2301
- logicalText: '@another.jpg',
2302
- collapsedText: '[Image another.jpg]',
2303
- });
2304
- });
2305
- it('should handle no transformations', () => {
2306
- const line = 'Just some regular text';
2307
- const result = calculateTransformationsForLine(line);
2308
- expect(result).toEqual([]);
2309
- });
2310
- it('should handle empty line', () => {
2311
- const result = calculateTransformationsForLine('');
2312
- expect(result).toEqual([]);
2313
- });
2314
- it('should keep adjacent image paths as separate transformations', () => {
2315
- const line = '@a.png@b.png@c.png';
2316
- const result = calculateTransformationsForLine(line);
2317
- expect(result).toHaveLength(3);
2318
- expect(result[0].logicalText).toBe('@a.png');
2319
- expect(result[1].logicalText).toBe('@b.png');
2320
- expect(result[2].logicalText).toBe('@c.png');
2321
- });
2322
- it('should handle multiple transformations in a row', () => {
2323
- const line = '@a.png @b.png @c.png';
2324
- const result = calculateTransformationsForLine(line);
2325
- expect(result).toHaveLength(3);
2326
- });
2327
- });
2328
- describe('getTransformUnderCursor', () => {
2329
- const transformations = [
2330
- {
2331
- logStart: 5,
2332
- logEnd: 14,
2333
- logicalText: '@test.png',
2334
- collapsedText: '[Image @test.png]',
2335
- type: 'image',
2336
- },
2337
- {
2338
- logStart: 20,
2339
- logEnd: 31,
2340
- logicalText: '@another.jpg',
2341
- collapsedText: '[Image @another.jpg]',
2342
- type: 'image',
2343
- },
2344
- ];
2345
- it('should find transformation when cursor is inside it', () => {
2346
- const result = getTransformUnderCursor(0, 7, [transformations]);
2347
- expect(result).toEqual(transformations[0]);
2348
- });
2349
- it('should find transformation when cursor is at start', () => {
2350
- const result = getTransformUnderCursor(0, 5, [transformations]);
2351
- expect(result).toEqual(transformations[0]);
2352
- });
2353
- it('should find transformation when cursor is at end', () => {
2354
- const result = getTransformUnderCursor(0, 14, [transformations]);
2355
- expect(result).toEqual(transformations[0]);
2356
- });
2357
- it('should return null when cursor is not on a transformation', () => {
2358
- const result = getTransformUnderCursor(0, 2, [transformations]);
2359
- expect(result).toBeNull();
2360
- });
2361
- it('should handle empty transformations array', () => {
2362
- const result = getTransformUnderCursor(0, 5, []);
2363
- expect(result).toBeNull();
2364
- });
2365
- });
2366
- describe('calculateTransformedLine', () => {
2367
- it('should transform a line with one transformation', () => {
2368
- const line = 'Check out @test.png';
2369
- const transformations = calculateTransformationsForLine(line);
2370
- const result = calculateTransformedLine(line, 0, [0, 0], transformations);
2371
- expect(result.transformedLine).toBe('Check out [Image test.png]');
2372
- expect(result.transformedToLogMap).toHaveLength(27); // Length includes all characters in the transformed line
2373
- // Test that we have proper mappings
2374
- expect(result.transformedToLogMap[0]).toBe(0); // 'C'
2375
- expect(result.transformedToLogMap[9]).toBe(9); // ' ' before transformation
2376
- });
2377
- it('should handle cursor inside transformation', () => {
2378
- const line = 'Check out @test.png';
2379
- const transformations = calculateTransformationsForLine(line);
2380
- // Cursor at '@' (position 10 in the line)
2381
- const result = calculateTransformedLine(line, 0, [0, 10], transformations);
2382
- // Should show full path when cursor is on it
2383
- expect(result.transformedLine).toBe('Check out @test.png');
2384
- // When expanded, each character maps to itself
2385
- expect(result.transformedToLogMap[10]).toBe(10); // '@'
2386
- });
2387
- it('should handle line with no transformations', () => {
2388
- const line = 'Just some text';
2389
- const result = calculateTransformedLine(line, 0, [0, 0], []);
2390
- expect(result.transformedLine).toBe(line);
2391
- // Each visual position should map directly to logical position + trailing
2392
- expect(result.transformedToLogMap).toHaveLength(15); // 14 chars + 1 trailing
2393
- expect(result.transformedToLogMap[0]).toBe(0);
2394
- expect(result.transformedToLogMap[13]).toBe(13);
2395
- expect(result.transformedToLogMap[14]).toBe(14); // Trailing position
2396
- });
2397
- it('should handle empty line', () => {
2398
- const result = calculateTransformedLine('', 0, [0, 0], []);
2399
- expect(result.transformedLine).toBe('');
2400
- expect(result.transformedToLogMap).toEqual([0]); // Just the trailing position
2401
- });
2402
- });
2403
- describe('Layout Caching and Invalidation', () => {
2404
- it.each([
2405
- {
2406
- desc: 'via setText',
2407
- actFn: (result) => result.current.setText('changed line'),
2408
- expected: 'changed line',
2409
- },
2410
- {
2411
- desc: 'via replaceRange',
2412
- actFn: (result) => result.current.replaceRange(0, 0, 0, 13, 'changed line'),
2413
- expected: 'changed line',
2414
- },
2415
- ])('should invalidate cache when line content changes $desc', ({ actFn, expected }) => {
2416
- const viewport = { width: 80, height: 24 };
2417
- const { result } = renderHookWithProviders(() => useTextBuffer({
2418
- initialText: 'original line',
2419
- viewport,
2420
- isValidPath: () => true,
2421
- }));
2422
- const originalLayout = result.current.visualLayout;
2423
- act(() => {
2424
- actFn(result);
2425
- });
2426
- expect(result.current.visualLayout).not.toBe(originalLayout);
2427
- expect(result.current.allVisualLines[0]).toBe(expected);
2428
- });
2429
- it('should invalidate cache when viewport width changes', () => {
2430
- const viewport = { width: 80, height: 24 };
2431
- const { result, rerender } = renderHookWithProviders(({ vp }) => useTextBuffer({
2432
- initialText: 'a very long line that will wrap when the viewport is small',
2433
- viewport: vp,
2434
- isValidPath: () => true,
2435
- }), { initialProps: { vp: viewport } });
2436
- const originalLayout = result.current.visualLayout;
2437
- // Shrink viewport to force wrapping change
2438
- rerender({ vp: { width: 10, height: 24 } });
2439
- expect(result.current.visualLayout).not.toBe(originalLayout);
2440
- expect(result.current.allVisualLines.length).toBeGreaterThan(1);
2441
- });
2442
- it('should correctly handle cursor expansion/collapse in cached layout', () => {
2443
- const viewport = { width: 80, height: 24 };
2444
- const text = 'Check @image.png here';
2445
- const { result } = renderHookWithProviders(() => useTextBuffer({
2446
- initialText: text,
2447
- viewport,
2448
- isValidPath: () => true,
2449
- }));
2450
- // Cursor at start (collapsed)
2451
- act(() => {
2452
- result.current.moveToOffset(0);
2453
- });
2454
- expect(result.current.allVisualLines[0]).toContain('[Image image.png]');
2455
- // Move cursor onto the @path (expanded)
2456
- act(() => {
2457
- result.current.moveToOffset(7); // onto @
2458
- });
2459
- expect(result.current.allVisualLines[0]).toContain('@image.png');
2460
- expect(result.current.allVisualLines[0]).not.toContain('[Image image.png]');
2461
- // Move cursor away (collapsed again)
2462
- act(() => {
2463
- result.current.moveToOffset(0);
2464
- });
2465
- expect(result.current.allVisualLines[0]).toContain('[Image image.png]');
2466
- });
2467
- it('should reuse cache for unchanged lines during editing', () => {
2468
- const viewport = { width: 80, height: 24 };
2469
- const initialText = 'line 1\nline 2\nline 3';
2470
- const { result } = renderHookWithProviders(() => useTextBuffer({
2471
- initialText,
2472
- viewport,
2473
- isValidPath: () => true,
2474
- }));
2475
- const layout1 = result.current.visualLayout;
2476
- // Edit line 1
2477
- act(() => {
2478
- result.current.moveToOffset(0);
2479
- result.current.insert('X');
2480
- });
2481
- const layout2 = result.current.visualLayout;
2482
- expect(layout2).not.toBe(layout1);
2483
- // Verify that visual lines for line 2 and 3 (indices 1 and 2 in visualLines)
2484
- // are identical in content if not in object reference (the arrays are rebuilt, but contents are cached)
2485
- expect(result.current.allVisualLines[1]).toBe('line 2');
2486
- expect(result.current.allVisualLines[2]).toBe('line 3');
2487
- });
2488
- });
2489
- });
2490
- //# sourceMappingURL=text-buffer.test.js.map