@dyyz1993/create-agent 2.1.1 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (346) hide show
  1. package/package.json +5 -4
  2. package/src/__tests__/cli.test.ts +2 -0
  3. package/src/__tests__/copy.test.ts +110 -122
  4. package/src/__tests__/create-args.test.ts +113 -0
  5. package/src/__tests__/templates.test.ts +29 -3
  6. package/src/__tests__/update.test.ts +129 -0
  7. package/src/cli.ts +30 -32
  8. package/src/commands/create.ts +83 -24
  9. package/src/commands/update.ts +174 -0
  10. package/src/commands/workspace.ts +26 -6
  11. package/src/lib/copy.ts +127 -91
  12. package/src/lib/templates.ts +12 -0
  13. package/templates/agent/.husky/commit-msg +4 -0
  14. package/templates/agent/.husky/pre-commit +11 -0
  15. package/templates/agent/.husky/pre-push +6 -0
  16. package/templates/agent/CHANGELOG.md +15 -0
  17. package/templates/agent/package.json +3 -3
  18. package/templates/agent/src/gateway/__tests__/ws-handler-token.test.ts +53 -39
  19. package/templates/agent/src/mainview/App.tsx +14 -12
  20. package/templates/agent/src/mainview/__tests__/hooks/use-rpc-init.test.ts +194 -190
  21. package/templates/agent/src/mainview/components/bash/BashPanel.tsx +210 -189
  22. package/templates/agent/src/mainview/components/chat/ChatPanel.tsx +45 -20
  23. package/templates/agent/src/mainview/components/common/ThemeToggle.tsx +41 -21
  24. package/templates/agent/src/mainview/components/debug/DebugPanel.tsx +181 -114
  25. package/templates/agent/src/mainview/components/debug/__tests__/DebugPanel.test.tsx +80 -80
  26. package/templates/agent/src/mainview/components/diff/__tests__/DiffViewerPanel.test.tsx +61 -58
  27. package/templates/agent/src/mainview/components/feed/FeedPanel.tsx +43 -41
  28. package/templates/agent/src/mainview/components/file-preview/FilePreviewOverlay.tsx +69 -50
  29. package/templates/agent/src/mainview/components/file-preview/VirtualizedCodeView.tsx +31 -18
  30. package/templates/agent/src/mainview/components/git/GitPanel.tsx +731 -490
  31. package/templates/agent/src/mainview/components/git/__tests__/GitPanel.test.tsx +157 -139
  32. package/templates/agent/src/mainview/components/layout/AppLayout.tsx +210 -161
  33. package/templates/agent/src/mainview/components/layout/__tests__/AppLayout.test.tsx +130 -122
  34. package/templates/agent/src/mainview/components/rules/RulesPanel.tsx +119 -109
  35. package/templates/agent/src/mainview/components/search/SearchPanel.tsx +123 -117
  36. package/templates/agent/src/mainview/components/search/__tests__/SearchPanel.test.tsx +64 -44
  37. package/templates/agent/src/mainview/components/sidebar/__tests__/PinButton.test.tsx +38 -38
  38. package/templates/agent/src/mainview/components/todo/TodoPanel.tsx +40 -38
  39. package/templates/agent/src/mainview/components/todo/__tests__/TodoPanel.test.tsx +72 -72
  40. package/templates/agent/src/mainview/lib/i18n/locales/en.json +175 -155
  41. package/templates/agent/src/mainview/lib/i18n/locales/zh.json +173 -155
  42. package/templates/agent/src/mainview/stores/use-app-store.ts +96 -86
  43. package/templates/agent/src/mainview/stores/use-explorer-store.ts +292 -275
  44. package/templates/agent/src/mainview/types/index.ts +23 -22
  45. package/templates/agent/src/mainview/utils/file-icon.tsx +17 -21
  46. package/templates/agent/src/shared/handlers/chat.ts +53 -53
  47. package/templates/agent/src/shared/handlers/debug.ts +13 -3
  48. package/templates/browser-agent/.env.example +19 -0
  49. package/templates/browser-agent/.husky/commit-msg +4 -0
  50. package/templates/browser-agent/.husky/pre-commit +11 -0
  51. package/templates/browser-agent/.husky/pre-push +6 -0
  52. package/templates/browser-agent/.prettierignore +6 -0
  53. package/templates/browser-agent/.prettierrc +9 -0
  54. package/templates/browser-agent/AGENTS.md +396 -0
  55. package/templates/browser-agent/CHANGELOG.md +15 -0
  56. package/templates/browser-agent/LICENSE +21 -0
  57. package/templates/browser-agent/README.md +103 -0
  58. package/templates/browser-agent/commitlint.config.js +8 -0
  59. package/templates/browser-agent/electrobun.config.ts +27 -0
  60. package/templates/browser-agent/electron/main.js +46 -0
  61. package/templates/browser-agent/electron/preload.js +5 -0
  62. package/templates/browser-agent/electron-builder.json +40 -0
  63. package/templates/browser-agent/eslint.config.mjs +79 -0
  64. package/templates/browser-agent/llms.txt +24 -0
  65. package/templates/browser-agent/package.json +140 -0
  66. package/templates/browser-agent/postcss.config.js +6 -0
  67. package/templates/browser-agent/scripts/dev.ts +138 -0
  68. package/templates/browser-agent/src/__tests__/hybrid-mode.test.ts +126 -0
  69. package/templates/browser-agent/src/__tests__/server-config-security.test.ts +55 -0
  70. package/templates/browser-agent/src/__tests__/server-config.test.ts +59 -0
  71. package/templates/browser-agent/src/bun/index.ts +130 -0
  72. package/templates/browser-agent/src/bun/three.d.ts +1 -0
  73. package/templates/browser-agent/src/gateway/http-routes.ts +1 -0
  74. package/templates/browser-agent/src/gateway/ipc-transport.ts +68 -0
  75. package/templates/browser-agent/src/gateway/sse-transport.ts +221 -0
  76. package/templates/browser-agent/src/mainview/App.tsx +45 -0
  77. package/templates/browser-agent/src/mainview/__tests__/hooks/use-rpc-init.test.ts +202 -0
  78. package/templates/browser-agent/src/mainview/__tests__/hooks/use-sidebar-resize.test.ts +127 -0
  79. package/templates/browser-agent/src/mainview/__tests__/i18n/i18n.test.ts +49 -0
  80. package/templates/browser-agent/src/mainview/__tests__/setup.ts +40 -0
  81. package/templates/browser-agent/src/mainview/__tests__/stores/use-chat-store.test.ts +73 -0
  82. package/templates/browser-agent/src/mainview/__tests__/stores/use-sidebar-store.test.ts +61 -0
  83. package/templates/browser-agent/src/mainview/__tests__/theme-variables.test.ts +36 -0
  84. package/templates/browser-agent/src/mainview/components/assets/AssetsPanel.tsx +139 -0
  85. package/templates/browser-agent/src/mainview/components/chat/ChatPanel.tsx +219 -0
  86. package/templates/browser-agent/src/mainview/components/chat/CommandBar.tsx +184 -0
  87. package/templates/browser-agent/src/mainview/components/chat/MessageBubble.tsx +249 -0
  88. package/templates/browser-agent/src/mainview/components/chat/ToolPicker.tsx +115 -0
  89. package/templates/browser-agent/src/mainview/components/common/ErrorBoundary.tsx +1 -0
  90. package/templates/browser-agent/src/mainview/components/common/LanguageSwitcher.tsx +15 -0
  91. package/templates/browser-agent/src/mainview/components/common/ThemeToggle.tsx +45 -0
  92. package/templates/browser-agent/src/mainview/components/common/__tests__/ErrorBoundary.test.tsx +74 -0
  93. package/templates/browser-agent/src/mainview/components/common/__tests__/LanguageSwitcher.test.tsx +44 -0
  94. package/templates/browser-agent/src/mainview/components/common/__tests__/ThemeToggle.test.tsx +41 -0
  95. package/templates/browser-agent/src/mainview/components/dev/NetworkPanel.tsx +155 -0
  96. package/templates/browser-agent/src/mainview/components/layout/AppLayout.tsx +311 -0
  97. package/templates/browser-agent/src/mainview/components/onboarding/SetupWizard.tsx +310 -0
  98. package/templates/browser-agent/src/mainview/components/process/ProcessPanel.tsx +329 -0
  99. package/templates/browser-agent/src/mainview/components/sidebar/SessionSidebar.tsx +122 -0
  100. package/templates/browser-agent/src/mainview/components/sidebar/SkillSidebar.tsx +115 -0
  101. package/templates/browser-agent/src/mainview/components/topbar/TopBar.tsx +350 -0
  102. package/templates/browser-agent/src/mainview/global.d.ts +13 -0
  103. package/templates/browser-agent/src/mainview/hooks/__tests__/use-breakpoint.test.ts +151 -0
  104. package/templates/browser-agent/src/mainview/hooks/use-agent-chat.ts +157 -0
  105. package/templates/browser-agent/src/mainview/hooks/use-breakpoint.ts +68 -0
  106. package/templates/browser-agent/src/mainview/hooks/use-rpc-init.ts +71 -0
  107. package/templates/browser-agent/src/mainview/hooks/use-sidebar-resize.ts +40 -0
  108. package/templates/browser-agent/src/mainview/index.css +71 -0
  109. package/templates/browser-agent/src/mainview/index.html +12 -0
  110. package/templates/browser-agent/src/mainview/lib/api-client.ts +397 -0
  111. package/templates/browser-agent/src/mainview/lib/i18n/index.ts +30 -0
  112. package/templates/browser-agent/src/mainview/lib/i18n/locales/en.json +130 -0
  113. package/templates/browser-agent/src/mainview/lib/i18n/locales/zh.json +128 -0
  114. package/templates/browser-agent/src/mainview/lib/network-bus.ts +92 -0
  115. package/templates/browser-agent/src/mainview/lib/rpc-cache.ts +94 -0
  116. package/templates/browser-agent/src/mainview/main.tsx +18 -0
  117. package/templates/browser-agent/src/mainview/stores/__tests__/use-connection-store.test.ts +26 -0
  118. package/templates/browser-agent/src/mainview/stores/__tests__/use-locale-store.test.ts +32 -0
  119. package/templates/browser-agent/src/mainview/stores/__tests__/use-log-store.test.ts +28 -0
  120. package/templates/browser-agent/src/mainview/stores/__tests__/use-theme-store.test.ts +59 -0
  121. package/templates/browser-agent/src/mainview/stores/message-batcher.ts +25 -0
  122. package/templates/browser-agent/src/mainview/stores/use-asset-store.ts +65 -0
  123. package/templates/browser-agent/src/mainview/stores/use-chat-store.ts +200 -0
  124. package/templates/browser-agent/src/mainview/stores/use-connection-store.ts +173 -0
  125. package/templates/browser-agent/src/mainview/stores/use-locale-store.ts +27 -0
  126. package/templates/browser-agent/src/mainview/stores/use-log-store.ts +16 -0
  127. package/templates/browser-agent/src/mainview/stores/use-network-panel-store.ts +18 -0
  128. package/templates/browser-agent/src/mainview/stores/use-record-store.ts +147 -0
  129. package/templates/browser-agent/src/mainview/stores/use-session-store.ts +151 -0
  130. package/templates/browser-agent/src/mainview/stores/use-sidebar-store.ts +161 -0
  131. package/templates/browser-agent/src/mainview/stores/use-theme-store.ts +46 -0
  132. package/templates/browser-agent/src/mainview/stores/use-view-store.ts +20 -0
  133. package/templates/browser-agent/src/mainview/types/index.ts +6 -0
  134. package/templates/browser-agent/src/server-config.ts +45 -0
  135. package/templates/browser-agent/src/server.ts +78 -0
  136. package/templates/browser-agent/src/shared/handlers/__tests__/chat-concurrency.test.ts +127 -0
  137. package/templates/browser-agent/src/shared/handlers/__tests__/chat-handler.test.ts +77 -0
  138. package/templates/browser-agent/src/shared/handlers/__tests__/file-handler.test.ts +100 -0
  139. package/templates/browser-agent/src/shared/handlers/__tests__/system-handler.test.ts +55 -0
  140. package/templates/browser-agent/src/shared/handlers/__tests__/timer-handler.test.ts +77 -0
  141. package/templates/browser-agent/src/shared/handlers/browser.ts +596 -0
  142. package/templates/browser-agent/src/shared/handlers/chat.ts +213 -0
  143. package/templates/browser-agent/src/shared/handlers/file.ts +99 -0
  144. package/templates/browser-agent/src/shared/handlers/index.ts +7 -0
  145. package/templates/browser-agent/src/shared/handlers/session.ts +167 -0
  146. package/templates/browser-agent/src/shared/handlers/system.ts +27 -0
  147. package/templates/browser-agent/src/shared/handlers/timer.ts +34 -0
  148. package/templates/browser-agent/src/shared/http-routes.ts +437 -0
  149. package/templates/browser-agent/src/shared/lib/__tests__/logger.test.ts +92 -0
  150. package/templates/browser-agent/src/shared/lib/__tests__/path-security.test.ts +77 -0
  151. package/templates/browser-agent/src/shared/lib/__tests__/web-server.test.ts +203 -0
  152. package/templates/browser-agent/src/shared/lib/agent.ts +384 -0
  153. package/templates/browser-agent/src/shared/lib/cdp.ts +448 -0
  154. package/templates/browser-agent/src/shared/lib/generate.ts +111 -0
  155. package/templates/browser-agent/src/shared/lib/logger.ts +152 -0
  156. package/templates/browser-agent/src/shared/lib/mock-stream.ts +147 -0
  157. package/templates/browser-agent/src/shared/lib/path-security.ts +38 -0
  158. package/templates/browser-agent/src/shared/lib/port-registry.ts +103 -0
  159. package/templates/browser-agent/src/shared/lib/web-server.ts +127 -0
  160. package/templates/browser-agent/src/shared/lib/xhs-extract.ts +71 -0
  161. package/templates/browser-agent/src/shared/modules/browser.ts +86 -0
  162. package/templates/browser-agent/src/shared/modules/chat.ts +20 -0
  163. package/templates/browser-agent/src/shared/modules/file.ts +40 -0
  164. package/templates/browser-agent/src/shared/modules/session.ts +55 -0
  165. package/templates/browser-agent/src/shared/modules/system.ts +8 -0
  166. package/templates/browser-agent/src/shared/modules/timer.ts +11 -0
  167. package/templates/browser-agent/src/shared/register-all-handlers.ts +36 -0
  168. package/templates/browser-agent/src/shared/rpc-schema.ts +34 -0
  169. package/templates/browser-agent/tailwind.config.js +15 -0
  170. package/templates/browser-agent/tsconfig.ipc.json +14 -0
  171. package/templates/browser-agent/tsconfig.json +36 -0
  172. package/templates/browser-agent/vite.config.ts +3 -0
  173. package/templates/browser-agent/vitest.config.ts +3 -0
  174. package/templates/chat/.husky/commit-msg +4 -0
  175. package/templates/chat/.husky/pre-commit +11 -0
  176. package/templates/chat/.husky/pre-push +6 -0
  177. package/templates/chat/CHANGELOG.md +15 -0
  178. package/templates/chat/commitlint.config.js +8 -0
  179. package/templates/chat/package.json +19 -4
  180. package/templates/chat/src/mainview/__tests__/hooks/use-input-history.test.ts +125 -0
  181. package/templates/chat/src/mainview/__tests__/setup.ts +32 -29
  182. package/templates/chat/src/mainview/components/chat/ChatPanel.tsx +80 -55
  183. package/templates/chat/src/mainview/components/common/ThemeToggle.tsx +40 -20
  184. package/templates/chat/src/mainview/lib/i18n/locales/en.json +175 -155
  185. package/templates/chat/src/mainview/lib/i18n/locales/zh.json +173 -155
  186. package/templates/chat/src/shared/handlers/chat.ts +17 -19
  187. package/templates/chat/src/shared/handlers/debug.ts +12 -2
  188. package/templates/cowork/.env.example +8 -0
  189. package/templates/cowork/.prettierignore +6 -0
  190. package/templates/cowork/.prettierrc +9 -0
  191. package/templates/cowork/AGENTS.md +236 -0
  192. package/templates/cowork/CHANGELOG.md +15 -0
  193. package/templates/cowork/LICENSE +21 -0
  194. package/templates/cowork/README.md +103 -0
  195. package/templates/cowork/commitlint.config.js +8 -0
  196. package/templates/cowork/docs/CODE-VIEW-PLAN.md +637 -0
  197. package/templates/cowork/docs/CODE-VIEW-V2.md +196 -0
  198. package/templates/cowork/docs/CODE-VIEW-V4.md +150 -0
  199. package/templates/cowork/electrobun.config.ts +27 -0
  200. package/templates/cowork/eslint.config.mjs +79 -0
  201. package/templates/cowork/llms.txt +24 -0
  202. package/templates/cowork/package.json +87 -0
  203. package/templates/cowork/postcss.config.js +6 -0
  204. package/templates/cowork/scripts/dev.ts +138 -0
  205. package/templates/cowork/src/__tests__/hybrid-mode.test.ts +126 -0
  206. package/templates/cowork/src/__tests__/server-config-security.test.ts +55 -0
  207. package/templates/cowork/src/__tests__/server-config.test.ts +59 -0
  208. package/templates/cowork/src/bun/index.ts +130 -0
  209. package/templates/cowork/src/bun/three.d.ts +1 -0
  210. package/templates/cowork/src/gateway/http-routes.ts +1 -0
  211. package/templates/cowork/src/gateway/ipc-transport.ts +68 -0
  212. package/templates/cowork/src/gateway/sse-transport.ts +231 -0
  213. package/templates/cowork/src/mainview/App.tsx +45 -0
  214. package/templates/cowork/src/mainview/__tests__/hooks/use-rpc-init.test.ts +202 -0
  215. package/templates/cowork/src/mainview/__tests__/hooks/use-sidebar-resize.test.ts +127 -0
  216. package/templates/cowork/src/mainview/__tests__/i18n/i18n.test.ts +49 -0
  217. package/templates/cowork/src/mainview/__tests__/setup.ts +40 -0
  218. package/templates/cowork/src/mainview/__tests__/stores/use-chat-store.test.ts +73 -0
  219. package/templates/cowork/src/mainview/__tests__/stores/use-sidebar-store.test.ts +61 -0
  220. package/templates/cowork/src/mainview/__tests__/theme-variables.test.ts +36 -0
  221. package/templates/cowork/src/mainview/components/chat/TaskChat.tsx +311 -0
  222. package/templates/cowork/src/mainview/components/chat/__tests__/localhost-links.test.ts +76 -0
  223. package/templates/cowork/src/mainview/components/common/ErrorBoundary.tsx +1 -0
  224. package/templates/cowork/src/mainview/components/common/LanguageSwitcher.tsx +15 -0
  225. package/templates/cowork/src/mainview/components/common/ThemeToggle.tsx +45 -0
  226. package/templates/cowork/src/mainview/components/common/__tests__/ErrorBoundary.test.tsx +74 -0
  227. package/templates/cowork/src/mainview/components/common/__tests__/LanguageSwitcher.test.tsx +44 -0
  228. package/templates/cowork/src/mainview/components/common/__tests__/ThemeToggle.test.tsx +41 -0
  229. package/templates/cowork/src/mainview/components/dev/NetworkPanel.tsx +155 -0
  230. package/templates/cowork/src/mainview/components/layout/AppLayout.tsx +216 -0
  231. package/templates/cowork/src/mainview/components/right/ArtifactsPanel.tsx +54 -0
  232. package/templates/cowork/src/mainview/components/right/ContextPanel.tsx +133 -0
  233. package/templates/cowork/src/mainview/components/right/ElementPicker.tsx +206 -0
  234. package/templates/cowork/src/mainview/components/right/PreviewBlock.tsx +155 -0
  235. package/templates/cowork/src/mainview/components/right/ProgressPanel.tsx +85 -0
  236. package/templates/cowork/src/mainview/components/sidebar/TaskSidebar.tsx +211 -0
  237. package/templates/cowork/src/mainview/components/topbar/TopBar.tsx +86 -0
  238. package/templates/cowork/src/mainview/global.d.ts +13 -0
  239. package/templates/cowork/src/mainview/hooks/__tests__/use-breakpoint.test.ts +123 -0
  240. package/templates/cowork/src/mainview/hooks/use-breakpoint.ts +53 -0
  241. package/templates/cowork/src/mainview/hooks/use-rpc-init.ts +26 -0
  242. package/templates/cowork/src/mainview/hooks/use-sidebar-resize.ts +40 -0
  243. package/templates/cowork/src/mainview/index.css +89 -0
  244. package/templates/cowork/src/mainview/index.html +12 -0
  245. package/templates/cowork/src/mainview/lib/api-client.ts +404 -0
  246. package/templates/cowork/src/mainview/lib/i18n/index.ts +30 -0
  247. package/templates/cowork/src/mainview/lib/i18n/locales/en.json +130 -0
  248. package/templates/cowork/src/mainview/lib/i18n/locales/zh.json +128 -0
  249. package/templates/cowork/src/mainview/lib/network-bus.ts +92 -0
  250. package/templates/cowork/src/mainview/lib/rpc-cache.ts +94 -0
  251. package/templates/cowork/src/mainview/main.tsx +18 -0
  252. package/templates/cowork/src/mainview/stores/__tests__/use-connection-store.test.ts +26 -0
  253. package/templates/cowork/src/mainview/stores/__tests__/use-locale-store.test.ts +32 -0
  254. package/templates/cowork/src/mainview/stores/__tests__/use-log-store.test.ts +28 -0
  255. package/templates/cowork/src/mainview/stores/__tests__/use-preview-store.test.ts +193 -0
  256. package/templates/cowork/src/mainview/stores/__tests__/use-sidebar-store.test.ts +81 -0
  257. package/templates/cowork/src/mainview/stores/__tests__/use-theme-store.test.ts +59 -0
  258. package/templates/cowork/src/mainview/stores/message-batcher.ts +25 -0
  259. package/templates/cowork/src/mainview/stores/use-chat-store.ts +198 -0
  260. package/templates/cowork/src/mainview/stores/use-connection-store.ts +168 -0
  261. package/templates/cowork/src/mainview/stores/use-context-store.ts +68 -0
  262. package/templates/cowork/src/mainview/stores/use-locale-store.ts +27 -0
  263. package/templates/cowork/src/mainview/stores/use-log-store.ts +16 -0
  264. package/templates/cowork/src/mainview/stores/use-network-panel-store.ts +18 -0
  265. package/templates/cowork/src/mainview/stores/use-output-store.ts +47 -0
  266. package/templates/cowork/src/mainview/stores/use-preview-store.ts +97 -0
  267. package/templates/cowork/src/mainview/stores/use-sidebar-store.ts +272 -0
  268. package/templates/cowork/src/mainview/stores/use-task-store.ts +86 -0
  269. package/templates/cowork/src/mainview/stores/use-theme-store.ts +46 -0
  270. package/templates/cowork/src/mainview/stores/use-view-store.ts +29 -0
  271. package/templates/cowork/src/mainview/types/index.ts +6 -0
  272. package/templates/cowork/src/server-config.ts +44 -0
  273. package/templates/cowork/src/server.ts +78 -0
  274. package/templates/cowork/src/shared/handlers/__tests__/chat-concurrency.test.ts +127 -0
  275. package/templates/cowork/src/shared/handlers/__tests__/chat-handler.test.ts +77 -0
  276. package/templates/cowork/src/shared/handlers/__tests__/file-handler.test.ts +100 -0
  277. package/templates/cowork/src/shared/handlers/__tests__/preview-handler.test.ts +172 -0
  278. package/templates/cowork/src/shared/handlers/__tests__/system-handler.test.ts +55 -0
  279. package/templates/cowork/src/shared/handlers/__tests__/timer-handler.test.ts +77 -0
  280. package/templates/cowork/src/shared/handlers/chat.ts +213 -0
  281. package/templates/cowork/src/shared/handlers/context.ts +72 -0
  282. package/templates/cowork/src/shared/handlers/file.ts +99 -0
  283. package/templates/cowork/src/shared/handlers/index.ts +9 -0
  284. package/templates/cowork/src/shared/handlers/output.ts +59 -0
  285. package/templates/cowork/src/shared/handlers/preview.ts +81 -0
  286. package/templates/cowork/src/shared/handlers/system.ts +27 -0
  287. package/templates/cowork/src/shared/handlers/task.ts +101 -0
  288. package/templates/cowork/src/shared/handlers/timer.ts +34 -0
  289. package/templates/cowork/src/shared/http-routes.ts +444 -0
  290. package/templates/cowork/src/shared/lib/__tests__/logger.test.ts +92 -0
  291. package/templates/cowork/src/shared/lib/__tests__/path-security.test.ts +77 -0
  292. package/templates/cowork/src/shared/lib/__tests__/web-server.test.ts +203 -0
  293. package/templates/cowork/src/shared/lib/logger.ts +152 -0
  294. package/templates/cowork/src/shared/lib/path-security.ts +38 -0
  295. package/templates/cowork/src/shared/lib/port-registry.ts +103 -0
  296. package/templates/cowork/src/shared/lib/web-server.ts +127 -0
  297. package/templates/cowork/src/shared/modules/chat.ts +20 -0
  298. package/templates/cowork/src/shared/modules/context.ts +32 -0
  299. package/templates/cowork/src/shared/modules/file.ts +40 -0
  300. package/templates/cowork/src/shared/modules/output.ts +20 -0
  301. package/templates/cowork/src/shared/modules/preview.ts +44 -0
  302. package/templates/cowork/src/shared/modules/system.ts +8 -0
  303. package/templates/cowork/src/shared/modules/task.ts +31 -0
  304. package/templates/cowork/src/shared/modules/timer.ts +11 -0
  305. package/templates/cowork/src/shared/register-all-handlers.ts +36 -0
  306. package/templates/cowork/src/shared/rpc-schema.ts +38 -0
  307. package/templates/cowork/tailwind.config.js +15 -0
  308. package/templates/cowork/test-upload.txt +0 -0
  309. package/templates/cowork/tsconfig.ipc.json +14 -0
  310. package/templates/cowork/tsconfig.json +36 -0
  311. package/templates/cowork/vite.config.ts +3 -0
  312. package/templates/cowork/vitest.config.ts +3 -0
  313. package/templates/general/.husky/commit-msg +4 -0
  314. package/templates/general/.husky/pre-commit +11 -0
  315. package/templates/general/.husky/pre-push +6 -0
  316. package/templates/general/CHANGELOG.md +15 -0
  317. package/templates/general/commitlint.config.js +8 -0
  318. package/templates/general/package.json +19 -4
  319. package/templates/general/src/mainview/__tests__/hooks/use-input-history.test.ts +125 -0
  320. package/templates/general/src/mainview/__tests__/setup.ts +32 -29
  321. package/templates/general/src/mainview/components/chat/ChatPanel.tsx +80 -55
  322. package/templates/general/src/mainview/components/common/ThemeToggle.tsx +40 -20
  323. package/templates/general/src/mainview/components/debug/DebugPanel.tsx +170 -156
  324. package/templates/general/src/mainview/components/debug/__tests__/DebugPanel.test.tsx +169 -0
  325. package/templates/general/src/mainview/components/explorer/ConfirmDialog.tsx +42 -42
  326. package/templates/general/src/mainview/components/explorer/ContextMenu.tsx +72 -67
  327. package/templates/general/src/mainview/components/feed/FeedPanel.tsx +7 -5
  328. package/templates/general/src/mainview/components/file-preview/FilePreviewOverlay.tsx +64 -45
  329. package/templates/general/src/mainview/components/file-preview/VirtualizedCodeView.tsx +24 -7
  330. package/templates/general/src/mainview/components/git/GitPanel.tsx +700 -473
  331. package/templates/general/src/mainview/components/layout/AppLayout.tsx +123 -114
  332. package/templates/general/src/mainview/components/search/SearchPanel.tsx +15 -19
  333. package/templates/general/src/mainview/lib/i18n/locales/en.json +175 -155
  334. package/templates/general/src/mainview/lib/i18n/locales/zh.json +173 -155
  335. package/templates/general/src/mainview/stores/__tests__/use-explorer-store.test.ts +259 -0
  336. package/templates/general/src/mainview/stores/__tests__/use-feed-store.test.ts +160 -0
  337. package/templates/general/src/mainview/stores/__tests__/use-git-store.test.ts +313 -0
  338. package/templates/general/src/mainview/stores/__tests__/use-notification-store.test.ts +115 -0
  339. package/templates/general/src/mainview/stores/__tests__/use-sidebar-store.test.ts +120 -0
  340. package/templates/general/src/mainview/stores/use-explorer-store.ts +277 -260
  341. package/templates/general/src/mainview/types/index.ts +21 -20
  342. package/templates/general/src/shared/handlers/chat.ts +1 -1
  343. package/templates/general/src/shared/handlers/debug.ts +12 -2
  344. package/templates/shared/components/ErrorBoundary.tsx +0 -1
  345. package/templates/shared/vite-base.config.ts +8 -7
  346. /package/templates/{shared → browser-agent}/test-upload.txt +0 -0
@@ -1,206 +1,227 @@
1
- import { useState, useRef, useEffect, useCallback } from "react";
2
- import { useTranslation } from "react-i18next";
3
- import { Play, Square, X } from "lucide-react";
4
- import { useVirtualizer } from "@tanstack/react-virtual";
5
- import { useBashStore } from "../../stores/use-bash-store";
1
+ import { useState, useRef, useEffect, useCallback } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { Play, Square, X } from 'lucide-react';
4
+ import { useVirtualizer } from '@tanstack/react-virtual';
5
+ import { useBashStore } from '../../stores/use-bash-store';
6
6
 
7
7
  export function BashPanel() {
8
- const { t } = useTranslation();
9
- const [command, setCommand] = useState("");
10
- const processes = useBashStore((s) => s.processes);
11
- const activePid = useBashStore((s) => s.activePid);
12
- const executeCommand = useBashStore((s) => s.executeCommand);
13
- const killProcess = useBashStore((s) => s.killProcess);
14
- const setActive = useBashStore((s) => s.setActive);
15
- const parentRef = useRef<HTMLDivElement>(null);
16
- const isUserScrollingRef = useRef(false);
8
+ const { t } = useTranslation();
9
+ const [command, setCommand] = useState('');
10
+ const processes = useBashStore((s) => s.processes);
11
+ const activePid = useBashStore((s) => s.activePid);
12
+ const executeCommand = useBashStore((s) => s.executeCommand);
13
+ const killProcess = useBashStore((s) => s.killProcess);
14
+ const setActive = useBashStore((s) => s.setActive);
15
+ const parentRef = useRef<HTMLDivElement>(null);
16
+ const isUserScrollingRef = useRef(false);
17
17
 
18
- const activeProcess = activePid != null ? processes.get(activePid) : null;
19
- const lines = activeProcess?.output ? activeProcess.output.split("\n") : [];
18
+ const activeProcess = activePid != null ? processes.get(activePid) : null;
19
+ const lines = activeProcess?.output ? activeProcess.output.split('\n') : [];
20
20
 
21
- const virtualizer = useVirtualizer({
22
- count: lines.length,
23
- getScrollElement: () => parentRef.current,
24
- estimateSize: () => 20,
25
- overscan: 20,
26
- });
21
+ const virtualizer = useVirtualizer({
22
+ count: lines.length,
23
+ getScrollElement: () => parentRef.current,
24
+ estimateSize: () => 20,
25
+ overscan: 20,
26
+ });
27
27
 
28
- const handleScroll = useCallback(() => {
29
- const el = parentRef.current;
30
- if (!el) return;
31
- const atBottom = el.scrollHeight - el.scrollTop - el.clientHeight < 40;
32
- isUserScrollingRef.current = !atBottom;
33
- }, []);
28
+ const handleScroll = useCallback(() => {
29
+ const el = parentRef.current;
30
+ if (!el) return;
31
+ const atBottom = el.scrollHeight - el.scrollTop - el.clientHeight < 40;
32
+ isUserScrollingRef.current = !atBottom;
33
+ }, []);
34
34
 
35
- useEffect(() => {
36
- if (!isUserScrollingRef.current && lines.length > 0) {
37
- virtualizer.scrollToIndex(lines.length - 1, { align: "end" });
38
- }
39
- }, [lines.length, virtualizer]);
35
+ useEffect(() => {
36
+ if (!isUserScrollingRef.current && lines.length > 0) {
37
+ virtualizer.scrollToIndex(lines.length - 1, { align: 'end' });
38
+ }
39
+ }, [lines.length, virtualizer]);
40
40
 
41
- const handleRun = () => {
42
- if (!command.trim()) return;
43
- executeCommand(command.trim());
44
- setCommand("");
45
- };
41
+ const handleRun = () => {
42
+ if (!command.trim()) return;
43
+ executeCommand(command.trim());
44
+ setCommand('');
45
+ };
46
46
 
47
- const handleKeyDown = (e: React.KeyboardEvent) => {
48
- if (e.key === "Enter" && !e.shiftKey) {
49
- e.preventDefault();
50
- handleRun();
51
- }
52
- };
47
+ const handleKeyDown = (e: React.KeyboardEvent) => {
48
+ if (e.key === 'Enter' && !e.shiftKey) {
49
+ e.preventDefault();
50
+ handleRun();
51
+ }
52
+ };
53
53
 
54
- const processList = Array.from(processes.entries());
54
+ const processList = Array.from(processes.entries());
55
55
 
56
- return (
57
- <div className="flex flex-col h-full">
58
- <div className="p-3 border-b border-[var(--color-border-primary)] flex items-center gap-2">
59
- <input
60
- type="text"
61
- value={command}
62
- onChange={(e) => setCommand(e.target.value)}
63
- onKeyDown={handleKeyDown}
64
- placeholder={t("bash.enterCommand")}
65
- className="flex-1 bg-[var(--color-bg-secondary)] text-[var(--color-text-secondary)] px-3 py-1.5 rounded text-sm font-mono border border-[var(--color-border-secondary)] focus:border-[var(--color-accent)] focus:outline-none"
66
- />
67
- <button
68
- onClick={handleRun}
69
- disabled={!command.trim()}
70
- className="flex items-center gap-1 px-3 py-1.5 bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-40 disabled:cursor-not-allowed rounded text-sm text-[var(--color-text-primary)]"
71
- >
72
- <Play className="w-3.5 h-3.5" />
73
- {t("bash.run")}
74
- </button>
75
- </div>
56
+ return (
57
+ <div className="flex flex-col h-full">
58
+ <div className="p-3 border-b border-[var(--color-border-primary)] flex items-center gap-2">
59
+ <input
60
+ type="text"
61
+ value={command}
62
+ onChange={(e) => setCommand(e.target.value)}
63
+ onKeyDown={handleKeyDown}
64
+ placeholder={t('bash.enterCommand')}
65
+ className="flex-1 bg-[var(--color-bg-secondary)] text-[var(--color-text-secondary)] px-3 py-1.5 rounded text-sm font-mono border border-[var(--color-border-secondary)] focus:border-[var(--color-accent)] focus:outline-none"
66
+ />
67
+ <button
68
+ onClick={handleRun}
69
+ disabled={!command.trim()}
70
+ className="flex items-center gap-1 px-3 py-1.5 bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] disabled:opacity-40 disabled:cursor-not-allowed rounded text-sm text-[var(--color-text-primary)]"
71
+ >
72
+ <Play className="w-3.5 h-3.5" />
73
+ {t('bash.run')}
74
+ </button>
75
+ </div>
76
76
 
77
- {processList.length > 0 && (
78
- <div className="flex gap-1 px-3 py-2 border-b border-[var(--color-border-primary)] overflow-x-auto">
79
- {processList.map(([pid, proc]) => (
80
- <button
81
- key={pid}
82
- onClick={() => setActive(pid)}
83
- className={`group relative flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs whitespace-nowrap transition-colors ${
84
- activePid === pid
85
- ? proc.running
86
- ? "bg-green-900/50 text-green-300 border border-green-700"
87
- : "bg-[var(--color-bg-tertiary)] text-[var(--color-text-secondary)] border border-[var(--color-border-secondary)]"
88
- : "text-[var(--color-text-placeholder)] bg-[var(--color-bg-secondary)]/50 border border-transparent hover:text-[var(--color-text-secondary)]"
89
- }`}
90
- >
91
- {proc.running && (
92
- <span className="relative flex h-2 w-2">
93
- <span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75" />
94
- <span className="relative inline-flex rounded-full h-2 w-2 bg-green-500" />
95
- </span>
96
- )}
97
- {!proc.running && (
98
- <span className={`w-2 h-2 rounded-full ${proc.exitCode === 0 ? "bg-green-500" : "bg-red-500"}`} />
99
- )}
100
- PID {pid}
101
- {proc.running && activePid === pid && (
102
- <button
103
- onClick={(e) => { e.stopPropagation(); killProcess(pid); }}
104
- className="ml-0.5 text-[var(--color-text-error)] hover:text-red-300"
105
- >
106
- <X className="w-3 h-3" />
107
- </button>
108
- )}
109
- {!proc.running && (
110
- <span className={`text-[10px] ${proc.exitCode === 0 ? "text-green-500/70" : "text-red-500/70"}`}>
111
- {t("bash.exited", { code: proc.exitCode ?? "?" })}
112
- </span>
113
- )}
114
- </button>
115
- ))}
116
- </div>
117
- )}
77
+ {processList.length > 0 && (
78
+ <div className="flex gap-1 px-3 py-2 border-b border-[var(--color-border-primary)] overflow-x-auto">
79
+ {processList.map(([pid, proc]) => (
80
+ <button
81
+ key={pid}
82
+ onClick={() => setActive(pid)}
83
+ className={`group relative flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs whitespace-nowrap transition-colors ${
84
+ activePid === pid
85
+ ? proc.running
86
+ ? 'bg-[var(--color-text-success)]/50 text-[var(--color-text-success)] border border-[var(--color-text-success)]'
87
+ : 'bg-[var(--color-bg-tertiary)] text-[var(--color-text-secondary)] border border-[var(--color-border-secondary)]'
88
+ : 'text-[var(--color-text-placeholder)] bg-[var(--color-bg-secondary)]/50 border border-transparent hover:text-[var(--color-text-secondary)]'
89
+ }`}
90
+ >
91
+ {proc.running && (
92
+ <span className="relative flex h-2 w-2">
93
+ <span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-[var(--color-text-success)] opacity-75" />
94
+ <span className="relative inline-flex rounded-full h-2 w-2 bg-[var(--color-text-success)]" />
95
+ </span>
96
+ )}
97
+ {!proc.running && (
98
+ <span
99
+ className={`w-2 h-2 rounded-full ${proc.exitCode === 0 ? 'bg-[var(--color-text-success)]' : 'bg-[var(--color-text-error)]'}`}
100
+ />
101
+ )}
102
+ PID {pid}
103
+ {proc.running && activePid === pid && (
104
+ <button
105
+ onClick={(e) => {
106
+ e.stopPropagation();
107
+ killProcess(pid);
108
+ }}
109
+ className="ml-0.5 text-[var(--color-text-error)] hover:text-[var(--color-text-error)]"
110
+ >
111
+ <X className="w-3 h-3" />
112
+ </button>
113
+ )}
114
+ {!proc.running && (
115
+ <span
116
+ className={`text-[10px] ${proc.exitCode === 0 ? 'text-[var(--color-text-success)]/70' : 'text-[var(--color-text-error)]/70'}`}
117
+ >
118
+ {t('bash.exited', { code: proc.exitCode ?? '?' })}
119
+ </span>
120
+ )}
121
+ </button>
122
+ ))}
123
+ </div>
124
+ )}
118
125
 
119
- <div
120
- ref={parentRef}
121
- onScroll={handleScroll}
122
- className="flex-1 overflow-auto p-3 font-mono text-xs text-[var(--color-text-secondary)] bg-gray-950 whitespace-pre-wrap leading-relaxed"
123
- >
124
- {activeProcess ? (
125
- <>
126
- {activeProcess.running && (
127
- <div className="flex items-center gap-2 text-yellow-400 mb-2 pb-2 border-b border-[var(--color-bg-secondary)]">
128
- <span className="relative flex h-2 w-2">
129
- <span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-yellow-400 opacity-75" />
130
- <span className="relative inline-flex rounded-full h-2 w-2 bg-yellow-500" />
131
- </span>
132
- {t("bash.processRunning", { pid: activePid })}
133
- </div>
134
- )}
135
- {lines.length > 0 ? (
136
- <div
137
- style={{
138
- height: virtualizer.getTotalSize(),
139
- width: "100%",
140
- position: "relative",
141
- }}
142
- >
143
- {virtualizer.getVirtualItems().map((virtualRow) => {
144
- const line = lines[virtualRow.index];
145
- return (
146
- <div
147
- key={virtualRow.index}
148
- style={{
149
- position: "absolute",
150
- top: 0,
151
- left: 0,
152
- width: "100%",
153
- height: `${virtualRow.size}px`,
154
- transform: `translateY(${virtualRow.start}px)`,
155
- }}
156
- className="hover:bg-[var(--color-bg-secondary)]/30 px-1 -mx-1 rounded"
157
- >
158
- <span className="text-[var(--color-text-placeholder)] select-none mr-2">&gt;</span>
159
- <span>{line || "\u00A0"}</span>
160
- </div>
161
- );
162
- })}
163
- </div>
164
- ) : activeProcess.running ? (
165
- <span className="text-gray-600">{t("bash.waitingOutput")}</span>
166
- ) : null}
167
- {!activeProcess.running && activeProcess.exitCode != null && (
168
- <div className={`mt-2 pt-2 border-t border-[var(--color-bg-secondary)] text-xs font-semibold ${
169
- activeProcess.exitCode === 0 ? "text-[var(--color-text-success)]" : "text-[var(--color-text-error)]"
170
- }`}>
171
- {t("bash.exit", { code: activeProcess.exitCode })}
172
- </div>
173
- )}
174
- </>
175
- ) : (
176
- <div className="flex flex-col items-center justify-center h-full text-gray-600">
177
- <TerminalIcon className="w-12 h-12 mb-3 opacity-30" />
178
- <span className="text-sm">{t("bash.noActiveProcess")}</span>
179
- <span className="text-xs mt-1">{t("bash.getStarted")}</span>
180
- </div>
181
- )}
182
- </div>
126
+ <div
127
+ ref={parentRef}
128
+ onScroll={handleScroll}
129
+ className="flex-1 overflow-auto p-3 font-mono text-xs text-[var(--color-text-secondary)] bg-[var(--color-bg-primary)] whitespace-pre-wrap leading-relaxed"
130
+ >
131
+ {activeProcess ? (
132
+ <>
133
+ {activeProcess.running && (
134
+ <div className="flex items-center gap-2 text-yellow-400 mb-2 pb-2 border-b border-[var(--color-bg-secondary)]">
135
+ <span className="relative flex h-2 w-2">
136
+ <span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-yellow-400 opacity-75" />
137
+ <span className="relative inline-flex rounded-full h-2 w-2 bg-yellow-500" />
138
+ </span>
139
+ {t('bash.processRunning', { pid: activePid })}
140
+ </div>
141
+ )}
142
+ {lines.length > 0 ? (
143
+ <div
144
+ style={{
145
+ height: virtualizer.getTotalSize(),
146
+ width: '100%',
147
+ position: 'relative',
148
+ }}
149
+ >
150
+ {virtualizer.getVirtualItems().map((virtualRow) => {
151
+ const line = lines[virtualRow.index];
152
+ return (
153
+ <div
154
+ key={virtualRow.index}
155
+ style={{
156
+ position: 'absolute',
157
+ top: 0,
158
+ left: 0,
159
+ width: '100%',
160
+ height: `${virtualRow.size}px`,
161
+ transform: `translateY(${virtualRow.start}px)`,
162
+ }}
163
+ className="hover:bg-[var(--color-bg-secondary)]/30 px-1 -mx-1 rounded"
164
+ >
165
+ <span className="text-[var(--color-text-placeholder)] select-none mr-2">
166
+ &gt;
167
+ </span>
168
+ <span>{line || '\u00A0'}</span>
169
+ </div>
170
+ );
171
+ })}
172
+ </div>
173
+ ) : activeProcess.running ? (
174
+ <span className="text-[var(--color-text-tertiary)]">{t('bash.waitingOutput')}</span>
175
+ ) : null}
176
+ {!activeProcess.running && activeProcess.exitCode != null && (
177
+ <div
178
+ className={`mt-2 pt-2 border-t border-[var(--color-bg-secondary)] text-xs font-semibold ${
179
+ activeProcess.exitCode === 0
180
+ ? 'text-[var(--color-text-success)]'
181
+ : 'text-[var(--color-text-error)]'
182
+ }`}
183
+ >
184
+ {t('bash.exit', { code: activeProcess.exitCode })}
185
+ </div>
186
+ )}
187
+ </>
188
+ ) : (
189
+ <div className="flex flex-col items-center justify-center h-full text-[var(--color-text-tertiary)]">
190
+ <TerminalIcon className="w-12 h-12 mb-3 opacity-30" />
191
+ <span className="text-sm">{t('bash.noActiveProcess')}</span>
192
+ <span className="text-xs mt-1">{t('bash.getStarted')}</span>
193
+ </div>
194
+ )}
195
+ </div>
183
196
 
184
- {activeProcess?.running && (
185
- <div className="p-2 border-t border-[var(--color-border-primary)] flex justify-end">
186
- <button
187
- onClick={() => activePid != null && killProcess(activePid)}
188
- className="flex items-center gap-1 px-3 py-1 bg-red-600 hover:bg-red-500 rounded text-xs text-[var(--color-text-primary)]"
189
- >
190
- <Square className="w-3 h-3" />
191
- {t("bash.kill")}
192
- </button>
193
- </div>
194
- )}
195
- </div>
196
- );
197
+ {activeProcess?.running && (
198
+ <div className="p-2 border-t border-[var(--color-border-primary)] flex justify-end">
199
+ <button
200
+ onClick={() => activePid != null && killProcess(activePid)}
201
+ className="flex items-center gap-1 px-3 py-1 bg-[var(--color-text-error)] hover:opacity-80 rounded text-xs text-[var(--color-text-primary)]"
202
+ >
203
+ <Square className="w-3 h-3" />
204
+ {t('bash.kill')}
205
+ </button>
206
+ </div>
207
+ )}
208
+ </div>
209
+ );
197
210
  }
198
211
 
199
212
  function TerminalIcon({ className }: { className?: string }) {
200
- return (
201
- <svg className={className} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
202
- <polyline points="4 17 10 11 4 5" />
203
- <line x1="12" y1="19" x2="20" y2="19" />
204
- </svg>
205
- );
213
+ return (
214
+ <svg
215
+ className={className}
216
+ viewBox="0 0 24 24"
217
+ fill="none"
218
+ stroke="currentColor"
219
+ strokeWidth="1.5"
220
+ strokeLinecap="round"
221
+ strokeLinejoin="round"
222
+ >
223
+ <polyline points="4 17 10 11 4 5" />
224
+ <line x1="12" y1="19" x2="20" y2="19" />
225
+ </svg>
226
+ );
206
227
  }
@@ -1,9 +1,10 @@
1
- import { useEffect, useRef } from "react";
2
- import { useTranslation } from "react-i18next";
3
- import { useVirtualizer } from "@tanstack/react-virtual";
4
- import { MessageSquare, Send } from "lucide-react";
5
- import { useChatStore } from "../../stores/use-chat-store";
6
- import { MessageBubble } from "./MessageBubble";
1
+ import { useCallback, useEffect, useRef } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { useVirtualizer } from '@tanstack/react-virtual';
4
+ import { MessageSquare, Send } from 'lucide-react';
5
+ import { useChatStore } from '../../stores/use-chat-store';
6
+ import { useInputHistory } from '../../hooks/use-input-history';
7
+ import { MessageBubble } from './MessageBubble';
7
8
 
8
9
  export function ChatPanel() {
9
10
  const { t } = useTranslation();
@@ -13,6 +14,14 @@ export function ChatPanel() {
13
14
  const sendMessage = useChatStore((s) => s.sendMessage);
14
15
  const parentRef = useRef<HTMLDivElement>(null);
15
16
  const prevMessageCountRef = useRef(0);
17
+ const { saveToHistory, navigatePrev, navigateNext } = useInputHistory('default');
18
+
19
+ const handleSend = useCallback(() => {
20
+ const text = inputText.trim();
21
+ if (!text) return;
22
+ saveToHistory(text);
23
+ sendMessage();
24
+ }, [inputText, saveToHistory, sendMessage]);
16
25
 
17
26
  const virtualizer = useVirtualizer({
18
27
  count: messages.length,
@@ -24,7 +33,7 @@ export function ChatPanel() {
24
33
 
25
34
  useEffect(() => {
26
35
  if (messages.length > prevMessageCountRef.current) {
27
- virtualizer.scrollToIndex(messages.length - 1, { align: "end" });
36
+ virtualizer.scrollToIndex(messages.length - 1, { align: 'end' });
28
37
  }
29
38
  prevMessageCountRef.current = messages.length;
30
39
  }, [messages.length, virtualizer]);
@@ -34,7 +43,7 @@ export function ChatPanel() {
34
43
  <div className="px-4 py-2 bg-[var(--color-bg-secondary)] border-b border-[var(--color-border-primary)] flex items-center justify-between flex-shrink-0">
35
44
  <h2 className="text-sm font-semibold flex items-center gap-1.5">
36
45
  <MessageSquare className="w-4 h-4 text-[var(--color-text-accent)]" />
37
- {t("chat.title")}
46
+ {t('chat.title')}
38
47
  {messages.length > 0 && (
39
48
  <span className="ml-1 px-2 py-0.5 bg-[var(--color-accent)]/30 text-[var(--color-text-accent)] rounded text-[10px]">
40
49
  {messages.length}
@@ -46,14 +55,14 @@ export function ChatPanel() {
46
55
  <div ref={parentRef} className="flex-1 overflow-y-auto">
47
56
  {messages.length === 0 ? (
48
57
  <div className="flex items-center justify-center h-full text-[var(--color-text-placeholder)] text-sm">
49
- {t("chat.empty")}
58
+ {t('chat.empty')}
50
59
  </div>
51
60
  ) : (
52
61
  <div
53
62
  style={{
54
63
  height: virtualizer.getTotalSize(),
55
- width: "100%",
56
- position: "relative",
64
+ width: '100%',
65
+ position: 'relative',
57
66
  }}
58
67
  >
59
68
  {virtualizer.getVirtualItems().map((virtualItem) => {
@@ -64,12 +73,12 @@ export function ChatPanel() {
64
73
  data-index={virtualItem.index}
65
74
  ref={virtualizer.measureElement}
66
75
  style={{
67
- position: "absolute",
76
+ position: 'absolute',
68
77
  top: 0,
69
78
  left: 0,
70
- width: "100%",
79
+ width: '100%',
71
80
  transform: `translateY(${virtualItem.start}px)`,
72
- padding: "6px 16px",
81
+ padding: '6px 16px',
73
82
  }}
74
83
  >
75
84
  <MessageBubble message={msg} />
@@ -80,23 +89,39 @@ export function ChatPanel() {
80
89
  )}
81
90
  </div>
82
91
 
83
- <div className="px-4 py-3 bg-[var(--color-bg-secondary)] border-t border-[var(--color-border-primary)] flex gap-2 flex-shrink-0">
92
+ <form
93
+ onSubmit={(e) => e.preventDefault()}
94
+ className="px-4 py-3 bg-[var(--color-bg-secondary)] border-t border-[var(--color-border-primary)] flex gap-2 flex-shrink-0"
95
+ >
84
96
  <input
85
97
  type="text"
86
98
  value={inputText}
87
99
  onChange={(e) => setInputText(e.target.value)}
88
- onKeyDown={(e) => e.key === "Enter" && !e.shiftKey && sendMessage()}
89
- placeholder={t("chat.placeholder")}
100
+ onKeyDown={(e) => {
101
+ if (e.key === 'Enter' && !e.shiftKey) {
102
+ e.preventDefault();
103
+ handleSend();
104
+ } else if (e.key === 'ArrowUp' && !inputText) {
105
+ e.preventDefault();
106
+ const prev = navigatePrev();
107
+ if (prev !== null) setInputText(prev);
108
+ } else if (e.key === 'ArrowDown') {
109
+ e.preventDefault();
110
+ const next = navigateNext();
111
+ if (next !== null) setInputText(next);
112
+ }
113
+ }}
114
+ placeholder={t('chat.placeholder')}
90
115
  className="flex-1 px-3 py-2 text-sm bg-[var(--color-bg-tertiary)] rounded-lg text-[var(--color-text-primary)] border border-[var(--color-border-secondary)] focus:border-[var(--color-accent)] focus:outline-none"
91
116
  />
92
117
  <button
93
- onClick={sendMessage}
118
+ onClick={handleSend}
94
119
  className="px-4 py-2 text-sm bg-[var(--color-accent)] hover:bg-[var(--color-accent-hover)] rounded-lg transition-colors flex items-center gap-1.5"
95
120
  >
96
121
  <Send className="w-4 h-4" />
97
- {t("chat.send")}
122
+ {t('chat.send')}
98
123
  </button>
99
- </div>
124
+ </form>
100
125
  </div>
101
126
  );
102
127
  }
@@ -1,25 +1,45 @@
1
- import { useThemeStore } from "../../stores/use-theme-store";
1
+ import { useThemeStore } from '../../stores/use-theme-store';
2
2
 
3
3
  export function ThemeToggle() {
4
- const theme = useThemeStore((s) => s.theme);
5
- const toggleTheme = useThemeStore((s) => s.toggleTheme);
4
+ const theme = useThemeStore((s) => s.theme);
5
+ const toggleTheme = useThemeStore((s) => s.toggleTheme);
6
6
 
7
- return (
8
- <button
9
- data-testid="theme-toggle"
10
- onClick={toggleTheme}
11
- className="p-1.5 rounded-md hover:bg-[var(--color-bg-hover)] transition-colors"
12
- title={theme === "dark" ? "Switch to light mode" : "Switch to dark mode"}
13
- >
14
- {theme === "dark" ? (
15
- <svg className="w-4 h-4 text-yellow-400" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
16
- <path strokeLinecap="round" strokeLinejoin="round" d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z" />
17
- </svg>
18
- ) : (
19
- <svg className="w-4 h-4 text-gray-600" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
20
- <path strokeLinecap="round" strokeLinejoin="round" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" />
21
- </svg>
22
- )}
23
- </button>
24
- );
7
+ return (
8
+ <button
9
+ data-testid="theme-toggle"
10
+ onClick={toggleTheme}
11
+ className="p-1.5 rounded-md hover:bg-[var(--color-bg-hover)] transition-colors"
12
+ title={theme === 'dark' ? 'Switch to light mode' : 'Switch to dark mode'}
13
+ >
14
+ {theme === 'dark' ? (
15
+ <svg
16
+ className="w-4 h-4 text-yellow-400"
17
+ fill="none"
18
+ viewBox="0 0 24 24"
19
+ stroke="currentColor"
20
+ strokeWidth={2}
21
+ >
22
+ <path
23
+ strokeLinecap="round"
24
+ strokeLinejoin="round"
25
+ d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"
26
+ />
27
+ </svg>
28
+ ) : (
29
+ <svg
30
+ className="w-4 h-4 text-[var(--color-text-tertiary)]"
31
+ fill="none"
32
+ viewBox="0 0 24 24"
33
+ stroke="currentColor"
34
+ strokeWidth={2}
35
+ >
36
+ <path
37
+ strokeLinecap="round"
38
+ strokeLinejoin="round"
39
+ d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"
40
+ />
41
+ </svg>
42
+ )}
43
+ </button>
44
+ );
25
45
  }