@allbluecn/web-app 0.27.41 → 0.28.0

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 (297) hide show
  1. package/package.json +1 -1
  2. package/public/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
  3. package/public/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
  4. package/public/pdfjs/cmaps/78-H.bcmap +0 -0
  5. package/public/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
  6. package/public/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
  7. package/public/pdfjs/cmaps/78-V.bcmap +0 -0
  8. package/public/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
  9. package/public/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
  10. package/public/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
  11. package/public/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
  12. package/public/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
  13. package/public/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
  14. package/public/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
  15. package/public/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
  16. package/public/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
  17. package/public/pdfjs/cmaps/Add-H.bcmap +0 -0
  18. package/public/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
  19. package/public/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
  20. package/public/pdfjs/cmaps/Add-V.bcmap +0 -0
  21. package/public/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
  22. package/public/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
  23. package/public/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
  24. package/public/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
  25. package/public/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
  26. package/public/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
  27. package/public/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
  28. package/public/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
  29. package/public/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
  30. package/public/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
  31. package/public/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
  32. package/public/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
  33. package/public/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
  34. package/public/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
  35. package/public/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
  36. package/public/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
  37. package/public/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
  38. package/public/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
  39. package/public/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
  40. package/public/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
  41. package/public/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
  42. package/public/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
  43. package/public/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
  44. package/public/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
  45. package/public/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
  46. package/public/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
  47. package/public/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
  48. package/public/pdfjs/cmaps/B5-H.bcmap +0 -0
  49. package/public/pdfjs/cmaps/B5-V.bcmap +0 -0
  50. package/public/pdfjs/cmaps/B5pc-H.bcmap +0 -0
  51. package/public/pdfjs/cmaps/B5pc-V.bcmap +0 -0
  52. package/public/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
  53. package/public/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
  54. package/public/pdfjs/cmaps/CNS1-H.bcmap +0 -0
  55. package/public/pdfjs/cmaps/CNS1-V.bcmap +0 -0
  56. package/public/pdfjs/cmaps/CNS2-H.bcmap +0 -0
  57. package/public/pdfjs/cmaps/CNS2-V.bcmap +3 -0
  58. package/public/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
  59. package/public/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
  60. package/public/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
  61. package/public/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
  62. package/public/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
  63. package/public/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
  64. package/public/pdfjs/cmaps/EUC-H.bcmap +0 -0
  65. package/public/pdfjs/cmaps/EUC-V.bcmap +0 -0
  66. package/public/pdfjs/cmaps/Ext-H.bcmap +0 -0
  67. package/public/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
  68. package/public/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
  69. package/public/pdfjs/cmaps/Ext-V.bcmap +0 -0
  70. package/public/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
  71. package/public/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
  72. package/public/pdfjs/cmaps/GB-H.bcmap +4 -0
  73. package/public/pdfjs/cmaps/GB-V.bcmap +0 -0
  74. package/public/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
  75. package/public/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
  76. package/public/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
  77. package/public/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
  78. package/public/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
  79. package/public/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
  80. package/public/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
  81. package/public/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
  82. package/public/pdfjs/cmaps/GBT-H.bcmap +0 -0
  83. package/public/pdfjs/cmaps/GBT-V.bcmap +0 -0
  84. package/public/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
  85. package/public/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
  86. package/public/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
  87. package/public/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
  88. package/public/pdfjs/cmaps/H.bcmap +0 -0
  89. package/public/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
  90. package/public/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
  91. package/public/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
  92. package/public/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
  93. package/public/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
  94. package/public/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
  95. package/public/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
  96. package/public/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
  97. package/public/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
  98. package/public/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
  99. package/public/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
  100. package/public/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
  101. package/public/pdfjs/cmaps/Hankaku.bcmap +0 -0
  102. package/public/pdfjs/cmaps/Hiragana.bcmap +0 -0
  103. package/public/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
  104. package/public/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
  105. package/public/pdfjs/cmaps/KSC-H.bcmap +0 -0
  106. package/public/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
  107. package/public/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
  108. package/public/pdfjs/cmaps/KSC-V.bcmap +0 -0
  109. package/public/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
  110. package/public/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
  111. package/public/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
  112. package/public/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
  113. package/public/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
  114. package/public/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
  115. package/public/pdfjs/cmaps/Katakana.bcmap +0 -0
  116. package/public/pdfjs/cmaps/LICENSE +36 -0
  117. package/public/pdfjs/cmaps/NWP-H.bcmap +0 -0
  118. package/public/pdfjs/cmaps/NWP-V.bcmap +0 -0
  119. package/public/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
  120. package/public/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
  121. package/public/pdfjs/cmaps/Roman.bcmap +0 -0
  122. package/public/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
  123. package/public/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
  124. package/public/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
  125. package/public/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
  126. package/public/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
  127. package/public/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
  128. package/public/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
  129. package/public/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
  130. package/public/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
  131. package/public/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
  132. package/public/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
  133. package/public/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
  134. package/public/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
  135. package/public/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
  136. package/public/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
  137. package/public/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
  138. package/public/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
  139. package/public/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
  140. package/public/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
  141. package/public/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
  142. package/public/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
  143. package/public/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
  144. package/public/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
  145. package/public/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
  146. package/public/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
  147. package/public/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
  148. package/public/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
  149. package/public/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
  150. package/public/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
  151. package/public/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
  152. package/public/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
  153. package/public/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
  154. package/public/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
  155. package/public/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
  156. package/public/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
  157. package/public/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
  158. package/public/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
  159. package/public/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
  160. package/public/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
  161. package/public/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
  162. package/public/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
  163. package/public/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
  164. package/public/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
  165. package/public/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
  166. package/public/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
  167. package/public/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
  168. package/public/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
  169. package/public/pdfjs/cmaps/V.bcmap +0 -0
  170. package/public/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
  171. package/src/components/ai/ai-prompt-input/index.tsx +3 -87
  172. package/src/components/ai-elements/__tests__/context.test.tsx +167 -0
  173. package/src/components/ai-elements/context.tsx +182 -94
  174. package/src/components/ai-elements/prompt-input.tsx +6 -104
  175. package/src/components/harness/__tests__/composer-attachments.test.tsx +17 -9
  176. package/src/components/harness/__tests__/composer-click-focus.test.tsx +175 -0
  177. package/src/components/harness/__tests__/composer-focus.test.tsx +7 -0
  178. package/src/components/harness/__tests__/composer-keymap.test.ts +57 -0
  179. package/src/components/harness/__tests__/composer-paste.test.tsx +7 -0
  180. package/src/components/harness/__tests__/composer-pending-guard.test.tsx +207 -0
  181. package/src/components/harness/__tests__/composer-placeholder.test.ts +7 -6
  182. package/src/components/harness/__tests__/composer-plus-menu.test.tsx +202 -0
  183. package/src/components/harness/__tests__/composer-primary-button.test.tsx +7 -0
  184. package/src/components/harness/__tests__/composer-send.test.tsx +12 -4
  185. package/src/components/harness/__tests__/composer-undo.test.tsx +7 -0
  186. package/src/components/harness/__tests__/dock-registry.test.ts +3 -0
  187. package/src/components/harness/__tests__/harness-workbench-auth-error.test.tsx +42 -4
  188. package/src/components/harness/__tests__/mention-kbid.test.ts +69 -0
  189. package/src/components/harness/__tests__/undo-last-turn.test.ts +134 -0
  190. package/src/components/harness/__tests__/voice-activity.test.tsx +2 -2
  191. package/src/components/harness/conversation-panel/composer/__tests__/file-chip-open.test.tsx +195 -0
  192. package/src/components/harness/conversation-panel/composer/__tests__/menu-view.test.tsx +107 -0
  193. package/src/components/harness/conversation-panel/composer/command/__tests__/claim-attachments.test.tsx +271 -0
  194. package/src/components/harness/conversation-panel/composer/command/__tests__/claim-client-submit.test.tsx +291 -0
  195. package/src/components/harness/conversation-panel/composer/command/__tests__/claim-guard.test.tsx +275 -0
  196. package/src/components/harness/conversation-panel/composer/command/__tests__/command-permission.test.tsx +286 -0
  197. package/src/components/harness/conversation-panel/composer/command/__tests__/command-plan.test.tsx +344 -0
  198. package/src/components/harness/conversation-panel/composer/command/__tests__/command-popup.test.tsx +193 -0
  199. package/src/components/harness/conversation-panel/composer/command/__tests__/command-server-source.test.tsx +235 -0
  200. package/src/components/harness/conversation-panel/composer/command/__tests__/command-suggestion-menu.test.tsx +151 -1
  201. package/src/components/harness/conversation-panel/composer/command/__tests__/command-undo.test.tsx +168 -0
  202. package/src/components/harness/conversation-panel/composer/command/__tests__/exclude-composer-seat.test.ts +106 -0
  203. package/src/components/harness/conversation-panel/composer/command/__tests__/menu-view.test.tsx +55 -2
  204. package/src/components/harness/conversation-panel/composer/command/__tests__/skill-source.test.tsx +336 -0
  205. package/src/components/harness/conversation-panel/composer/command/claim.ts +7 -1
  206. package/src/components/harness/conversation-panel/composer/command/command-popup.tsx +140 -0
  207. package/src/components/harness/conversation-panel/composer/command/command-suggestion-menu.tsx +261 -75
  208. package/src/components/harness/conversation-panel/composer/command/menu-view.tsx +188 -50
  209. package/src/components/harness/conversation-panel/composer/command/popup-panel.tsx +106 -0
  210. package/src/components/harness/conversation-panel/composer/command/skill-source.ts +231 -0
  211. package/src/components/harness/conversation-panel/composer/composer-editor.tsx +216 -14
  212. package/src/components/harness/conversation-panel/composer/composer-keymap.ts +26 -0
  213. package/src/components/harness/conversation-panel/composer/extension/__tests__/command-menu.test.ts +128 -12
  214. package/src/components/harness/conversation-panel/composer/extension/command-menu.ts +303 -44
  215. package/src/components/harness/conversation-panel/composer/extension/index.ts +8 -0
  216. package/src/components/harness/conversation-panel/composer/harness-composer.tsx +551 -83
  217. package/src/components/harness/conversation-panel/composer/mention/__tests__/file-mention.test.tsx +517 -0
  218. package/src/components/harness/conversation-panel/composer/mention/__tests__/mention-source-registration.test.tsx +5 -2
  219. package/src/components/harness/conversation-panel/composer/mention/__tests__/mention-suggestion-menu.test.tsx +120 -0
  220. package/src/components/harness/conversation-panel/composer/mention/__tests__/mention-trigger-source.test.ts +52 -9
  221. package/src/components/harness/conversation-panel/composer/mention/__tests__/story-mention.test.tsx +356 -0
  222. package/src/components/harness/conversation-panel/composer/mention/__tests__/thread-mention.test.tsx +377 -0
  223. package/src/components/harness/conversation-panel/composer/mention/file-mention.ts +162 -0
  224. package/src/components/harness/conversation-panel/composer/mention/mention-resolvers.ts +6 -0
  225. package/src/components/harness/conversation-panel/composer/mention/mention-suggestion-menu.tsx +212 -107
  226. package/src/components/harness/conversation-panel/composer/mention/mention-trigger-source.ts +71 -8
  227. package/src/components/harness/conversation-panel/composer/mention/story-mention.ts +131 -0
  228. package/src/components/harness/conversation-panel/composer/mention/thread-mention.ts +159 -0
  229. package/src/components/harness/conversation-panel/composer/mention/use-mention-sources.ts +9 -1
  230. package/src/components/harness/conversation-panel/composer/model-selector/__tests__/model-selector.test.tsx +401 -0
  231. package/src/components/harness/conversation-panel/composer/model-selector/__tests__/wiring.test.ts +117 -0
  232. package/src/components/harness/conversation-panel/composer/model-selector/model-selector-panel.tsx +411 -0
  233. package/src/components/harness/conversation-panel/composer/model-selector/model-selector-trigger.tsx +254 -0
  234. package/src/components/harness/conversation-panel/composer/model-selector/wiring.ts +112 -0
  235. package/src/components/harness/conversation-panel/composer/permission/__tests__/permission-select.test.tsx +264 -0
  236. package/src/components/harness/conversation-panel/composer/permission/permission-policy.ts +76 -0
  237. package/src/components/harness/conversation-panel/composer/permission/permission-popup.tsx +302 -0
  238. package/src/components/harness/conversation-panel/composer/permission/permission-select-button.tsx +140 -0
  239. package/src/components/harness/conversation-panel/composer/workspace/__tests__/workspace-select.test.tsx +390 -0
  240. package/src/components/harness/conversation-panel/composer/workspace/workspace-select-button.tsx +367 -0
  241. package/src/components/harness/conversation-panel/messages/harness-chain/__tests__/use-harness-session-putmedia.test.tsx +17 -0
  242. package/src/components/harness/conversation-panel/messages/harness-chain/use-harness-chat-adapter.ts +26 -6
  243. package/src/components/harness/conversation-panel/messages/harness-chain/use-harness-session.ts +21 -3
  244. package/src/components/harness/extension-panel/dock/__tests__/dock-persist.test.ts +2 -1
  245. package/src/components/harness/extension-panel/dock/__tests__/guide-page.test.tsx +44 -3
  246. package/src/components/harness/extension-panel/dock/dock-persist.ts +6 -4
  247. package/src/components/harness/extension-panel/dock/dock-registry.ts +35 -14
  248. package/src/components/harness/extension-panel/dock/dock-surface.tsx +2 -0
  249. package/src/components/harness/extension-panel/dock/guide-page.tsx +75 -45
  250. package/src/components/harness/extension-panel/panels/plugin/__tests__/install-dialog.test.tsx +260 -0
  251. package/src/components/harness/extension-panel/panels/plugin/__tests__/plugin-page.test.tsx +912 -0
  252. package/src/components/harness/extension-panel/panels/plugin/__tests__/plugin-row.test.tsx +215 -0
  253. package/src/components/harness/extension-panel/panels/plugin/builtin-section.tsx +204 -0
  254. package/src/components/harness/extension-panel/panels/plugin/install-dialog.tsx +195 -0
  255. package/src/components/harness/extension-panel/panels/plugin/installed-section.tsx +378 -0
  256. package/src/components/harness/extension-panel/panels/plugin/kind.tsx +17 -4
  257. package/src/components/harness/extension-panel/panels/plugin/pending-builds-block.tsx +49 -0
  258. package/src/components/harness/extension-panel/panels/plugin/plugin-page.tsx +257 -0
  259. package/src/components/harness/extension-panel/panels/plugin/plugin-row.tsx +206 -0
  260. package/src/components/harness/extension-panel/panels/plugin/plugin-types.ts +13 -0
  261. package/src/components/harness/extension-panel/panels/plugin/worker-section.tsx +322 -0
  262. package/src/components/harness/workbench/__tests__/provider-model-groups.test.ts +301 -0
  263. package/src/components/harness/workbench/harness-workbench-page.tsx +164 -2
  264. package/src/components/harness/workbench/provider-model-groups.ts +140 -0
  265. package/src/components/harness/workbench/undo-last-turn.ts +79 -0
  266. package/src/components/harness/workbench/workbench-context.tsx +53 -3
  267. package/src/components/tiptap/hooks/__tests__/use-floating-element.test.tsx +131 -0
  268. package/src/components/tiptap/hooks/use-floating-element.ts +15 -2
  269. package/src/components/tiptap/hooks/use-menu-navigation.ts +5 -0
  270. package/src/components/tiptap/node/mention-extension.ts +33 -0
  271. package/src/components/tiptap/ui/suggestion-menu/__tests__/suggestion-menu.test.tsx +366 -0
  272. package/src/components/tiptap/ui/suggestion-menu/suggestion-menu-types.ts +54 -0
  273. package/src/components/tiptap/ui/suggestion-menu/suggestion-menu.tsx +176 -45
  274. package/src/lib/changelog/sdk-versions.ts +2 -2
  275. package/src/lib/queries/__tests__/harness-plugin-queries.test.ts +49 -0
  276. package/src/lib/queries/harness.ts +50 -0
  277. package/src/paraglide/messages/_index.js +1574 -311
  278. package/src/paraglide/messages/en.js +513 -103
  279. package/src/paraglide/messages/zh.js +514 -104
  280. package/src/routes/_nav/harness/route.lazy.tsx +13 -0
  281. package/src/server/ai-gateway/sandbox/policy.ts +6 -6
  282. package/src/server/harness/__tests__/compact-plugin.server.test.ts +46 -0
  283. package/src/server/harness/__tests__/define-expose.test.ts +17 -0
  284. package/src/server/harness/__tests__/thread-reference.server.test.ts +258 -0
  285. package/src/server/harness/define.server.ts +21 -3
  286. package/src/server/harness/thread-reference.server.ts +446 -0
  287. package/src/server/serverFns/chat/__tests__/conversations-sandbox-default.test.ts +23 -0
  288. package/src/server/serverFns/chat/conversations.ts +18 -3
  289. package/src/server/serverFns/harness/search-mention-candidates.ts +14 -1
  290. package/src/shared/harness/__tests__/thread-reference-format.test.ts +128 -0
  291. package/src/shared/harness/thread-reference-format.ts +98 -0
  292. package/LICENSE +0 -661
  293. package/src/components/agents/slash-skill-menu.tsx +0 -75
  294. package/src/components/harness/conversation-panel/composer/extension/__tests__/demo-story-reference.test.tsx +0 -177
  295. package/src/components/harness/conversation-panel/composer/extension/demo-story-reference.tsx +0 -227
  296. package/src/components/harness/conversation-panel/composer/plugin-mention-menu.tsx +0 -109
  297. package/src/components/harness/extension-panel/panels/plugin-panel.tsx +0 -1021
@@ -0,0 +1,336 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ /**
19
+ * skills 第二源(P1 任务 3):'/' 菜单技能候选(纯文本插入,官方 skillPrompt 形态)。
20
+ *
21
+ * 触发源 = InputTriggerSource(trigger '/',name 'skills'),CommandSuggestionMenu
22
+ * 内 mount 注册(builtin/skills,照 MentionSuggestionMenu 范式),数据经 props 注入
23
+ * (workbench-page useQuery → HarnessComposer → ComposerEditor → 菜单;composer 不
24
+ * 自拉 query)。空 skills(undefined/[])→ 候选恒空 → 菜单无「技能」组 = 自然 gating。
25
+ *
26
+ * 选中形态(官方 ai-skills skillPrompt,harness.js:21-24 同款):插入
27
+ * `Use the <name> skill: `(task 由用户选中后续敲);参数已紧跟插入点时省略尾随
28
+ * 空格——最终文本收敛到 `Use the <name> skill: <task>`(冒号后单空格)。
29
+ *
30
+ * 四用例 + 工厂契约(简报步骤 1 三例 + 完整形态合并断言):
31
+ * 1. `/test` → 「技能」组含「测试技能」→ Enter → 编辑器文本 `Use the test-skill skill: `
32
+ * (触发词被替换、冒号尾随空格);
33
+ * 2. 完整形态:`/test-skill 写总结` + 光标回移到触发词(菜单重开,空格截断语义下
34
+ * 唯一可选中路径)→ Enter → `Use the test-skill skill: 写总结`(参数保留冒号后);
35
+ * 3. 空 skills(seam 取数返回 [],legacy 无数据同态)→ 无「技能」组、无技能条目
36
+ * (菜单其余命令照常——控制组);
37
+ * 4. fuzzy 部分匹配:`/tst` 命中 test-skill → 选中替换同形态。
38
+ * 5. seam 取数失败(401/网络)→ fail-closed 空目录 → 无「技能」组(不阻塞菜单)。
39
+ *
40
+ * **数据面**:源内经 getQueryClient seam 自拉(fetchSkillsViaQueryClient 缺省
41
+ * getter)——整页直渲测试无 QueryClientProvider 也安全(P0 file-mention
42
+ * fetchDirFromQueryClient 同范式;曾以 workbench-page useQuery 注入引入过
43
+ * Provider 陷阱回归,修复后 props 链已拆)。本文件整模块 mock query-client-seam。
44
+ * 渲染 HarnessComposer(真实 TipTap)/ ComposerEditor 直渲(onReady 捕获编辑器,
45
+ * claim-guard 同款)。mock 组合照 claim-guard.test.tsx:44-71;bundle 守卫:composer
46
+ * 链禁 sandbox/policy index(T8 立规沿用)。i18n 断言走 zh locale(setup.ts
47
+ * overwriteGetLocale('zh'))。
48
+ */
49
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"
50
+ import { act, cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react"
51
+ import { HarnessComposer } from "../../harness-composer"
52
+ import { ComposerEditor, type ComposerEditorHandle } from "../../composer-editor"
53
+ import { draftsStore } from "../../use-drafts"
54
+ import type { ComposerDraftApi } from "../../extension"
55
+ import type { ComposerSkillRef } from "../skill-source"
56
+ import {
57
+ createBuiltinSkillSource,
58
+ skillPromptText,
59
+ withTimeout,
60
+ fetchSkillsViaQueryClient,
61
+ SKILLS_FETCH_TIMEOUT_MS,
62
+ } from "../skill-source"
63
+
64
+ const { fetchQueryMock } = vi.hoisted(() => ({ fetchQueryMock: vi.fn() }))
65
+ // seam 整模块 mock:技能源默认 getter 经 getQueryClient().fetchQuery 拉目录——
66
+ // 桩掉即零网络、按用例注入数据/错误(工厂契约例注入同步 getter,不经此 mock)。
67
+ // 注:client 须是**真 QueryClient**(fetchQuery 桩掉、其余方法原生)——任务 5 起
68
+ // WorkspaceSelectButton 经同一 seam 直连 react-query(useQuery/useMutation 的
69
+ // 可选 client 形参消费 defaultQueryOptions 等方法),窄桩对象会渲染即炸。
70
+ vi.mock("@/lib/query-client-seam", async () => {
71
+ const { QueryClient } = await import("@tanstack/react-query")
72
+ const client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
73
+ client.fetchQuery = fetchQueryMock as never
74
+ return { getQueryClient: () => client }
75
+ })
76
+
77
+ vi.mock("@/server/serverFns/harness/media", () => ({ generatePrototypeFn: vi.fn(() => Promise.resolve({})) }))
78
+ vi.mock("../../mention/use-mention-sources", () => ({
79
+ useMentionSources: () => ({ all: [], isLoading: false }),
80
+ }))
81
+ vi.mock("@/components/billing/use-feature", () => ({ useFeature: () => ({ enabled: true, loading: false }) }))
82
+ // bundle 守卫(T8 立规,本任务沿用):composer 链路不得加载服务端沙箱 policy index
83
+ // ——permission-policy 是唯一合法通道(本文件顶部已整模块 mock 切断其 import 链)。
84
+ vi.mock("@/server/ai-gateway/sandbox/policy", () => { throw new Error("Server sandbox policy must not be loaded by the composer") })
85
+ vi.mock("../../permission/permission-policy", () => ({
86
+ SANDBOX_POLICY_LEVELS: ["readonly", "workspace-write", "full"],
87
+ getSandboxPolicy: vi.fn(),
88
+ setSandboxPolicy: vi.fn(),
89
+ }))
90
+ vi.mock("../../voice-input-button", () => ({ VoiceInputButton: () => null }))
91
+ vi.mock("@/components/harness/conversation-panel/messages/approvals/interrupt-approval", () => ({ InterruptApproval: () => null }))
92
+
93
+ beforeEach(() => {
94
+ sessionStorage.clear()
95
+ // 缺省:seam 返回双技能目录(空/失败用例各自覆写)
96
+ fetchQueryMock.mockReset()
97
+ fetchQueryMock.mockResolvedValue(SKILLS)
98
+ })
99
+ afterEach(() => {
100
+ cleanup()
101
+ })
102
+
103
+ /** 取 ProseMirror 编辑面(composer-send.test 同款定位) */
104
+ function getEditorDom(): HTMLElement {
105
+ const el = document.querySelector<HTMLElement>(".tiptap.ProseMirror")
106
+ if (!el) throw new Error("TipTap 编辑器 DOM 未挂载")
107
+ return el
108
+ }
109
+
110
+ const SKILLS: ReadonlyArray<ComposerSkillRef> = [
111
+ { name: "test-skill", title: "测试技能" },
112
+ { name: "code-review", title: "代码审查" },
113
+ ]
114
+
115
+ const baseProps = {
116
+ threadId: "t1",
117
+ isRunning: false,
118
+ hasAiKey: true,
119
+ busyPreference: "queue" as const,
120
+ onSend: vi.fn(),
121
+ onStop: vi.fn(),
122
+ conversationRegionRef: { current: null },
123
+ messages: [],
124
+ models: [],
125
+ } satisfies Parameters<typeof HarnessComposer>[0]
126
+
127
+ interface EditorHarness {
128
+ handleHolder: { current: ComposerEditorHandle | null }
129
+ unmount: () => void
130
+ }
131
+
132
+ /** 直渲 ComposerEditor(draft 域挂 '/' 菜单)+ onReady 捕获真实 Editor 实例 */
133
+ function renderEditor(): EditorHarness {
134
+ const handleHolder: { current: ComposerEditorHandle | null } = { current: null }
135
+ const draft: ComposerDraftApi = {
136
+ threadId: "t1",
137
+ store: draftsStore,
138
+ get editorHandle() {
139
+ return handleHolder.current
140
+ },
141
+ get text() {
142
+ return handleHolder.current?.editor.getText() ?? ""
143
+ },
144
+ clear: () => {},
145
+ }
146
+ const view = render(
147
+ <ComposerEditor
148
+ threadId="t1"
149
+ rawThreadId="t1"
150
+ editable
151
+ onTextChange={() => {}}
152
+ onReady={(handle) => {
153
+ handleHolder.current = handle
154
+ }}
155
+ draft={draft}
156
+ />,
157
+ )
158
+ return { handleHolder, unmount: view.unmount }
159
+ }
160
+
161
+ async function waitEditorReady(harness: EditorHarness): Promise<ComposerEditorHandle> {
162
+ await waitFor(() => expect(harness.handleHolder.current).not.toBeNull())
163
+ return harness.handleHolder.current as ComposerEditorHandle
164
+ }
165
+
166
+ it("技能源端到端:/test → 「技能」组含「测试技能」(subtext 小写名)→ Enter → 触发词替换为 `Use the test-skill skill: `", async () => {
167
+ render(<HarnessComposer {...baseProps} handoffPrefillText="/test" />)
168
+ const textbox = getEditorDom()
169
+ const menu = await screen.findByRole("listbox", {}, { timeout: 3000 })
170
+ // 技能组条目(title 主文本 + name 副文本)——数据经 seam 自拉(fetchQueryMock)
171
+ await waitFor(() => expect(menu.textContent).toContain("测试技能"))
172
+ expect(menu.textContent).toContain("test-skill")
173
+ expect(fetchQueryMock).toHaveBeenCalled()
174
+ // 组头「技能」:getAllByText 精确全等匹配——条目 title「测试技能」不含歧义
175
+ // (exact=true 要求整串相等,只有组头元素文本恰为「技能」)
176
+ await waitFor(() => expect(screen.getAllByText("技能").length).toBeGreaterThan(0))
177
+ // Enter 选中(autoSelectFirstItem,技能为唯一命中条目)→ 官方 skillPrompt 形态
178
+ //(冒号尾随空格,邀请续敲任务参数)
179
+ fireEvent.keyDown(textbox, { key: "Enter" })
180
+ await waitFor(() => expect(getEditorDom().textContent).toBe("Use the test-skill skill: "))
181
+ })
182
+
183
+ it("完整形态:/test-skill 写总结 + 光标回移触发词(菜单重开)→ Enter → `Use the test-skill skill: 写总结`(参数保留冒号后)", async () => {
184
+ const harness = renderEditor()
185
+ const handle = await waitEditorReady(harness)
186
+ act(() => {
187
+ // jsdom 无真实键盘输入:setContent 预置 `/test-skill 写总结`(空格截断语义下
188
+ // 光标在参数尾时菜单已关——回移光标到触发词段尾重开,唯一可选中路径)
189
+ handle.editor.commands.setContent({
190
+ type: "doc",
191
+ content: [{ type: "paragraph", content: [{ type: "text", text: "/test-skill 写总结" }] }],
192
+ })
193
+ // "/test-skill" 段尾 = 段内偏移 12(doc 位置:内容起点 1 + 11 字符)
194
+ handle.editor.commands.setTextSelection(12)
195
+ })
196
+ const menu = await screen.findByRole("listbox", {}, { timeout: 3000 })
197
+ await waitFor(() => expect(menu.textContent).toContain("测试技能"))
198
+ fireEvent.keyDown(getEditorDom(), { key: "Enter" })
199
+ // '/' 菜单 command() 已 deleteRange 删除 `/test-skill`(参数「 写总结」前移),
200
+ // onPick 光标锚定插入 prompt;插入点紧跟空白 → 尾随空格省略,最终文本与官方
201
+ // skillPrompt(`Use the ${name} skill: ${task}`) 逐字一致
202
+ await waitFor(() => expect(getEditorDom().textContent).toBe("Use the test-skill skill: 写总结"))
203
+ harness.unmount()
204
+ })
205
+
206
+ it("空 skills(seam 返回 [],legacy 无数据同态):无「技能」组、无技能条目(自然 gating,菜单其余命令照常)", async () => {
207
+ fetchQueryMock.mockResolvedValue([])
208
+ render(<HarnessComposer {...baseProps} handoffPrefillText="/" />)
209
+ const menu = await screen.findByRole("listbox", {}, { timeout: 3000 })
210
+ // 控制组:菜单本体活着(内置 client 命令在列)
211
+ await waitFor(() => expect(menu.textContent).toContain("清空输入"))
212
+ // 技能源候选恒空 → 组头与条目均不出现
213
+ expect(screen.queryAllByText("技能")).toHaveLength(0)
214
+ expect(menu.textContent).not.toContain("测试技能")
215
+ })
216
+
217
+ it("seam 取数失败(401/网络):fail-closed 空目录 → 无「技能」组,不阻塞菜单其余命令", async () => {
218
+ fetchQueryMock.mockRejectedValue(new Error("boom"))
219
+ render(<HarnessComposer {...baseProps} handoffPrefillText="/" />)
220
+ const menu = await screen.findByRole("listbox", {}, { timeout: 3000 })
221
+ await waitFor(() => expect(menu.textContent).toContain("清空输入"))
222
+ expect(screen.queryAllByText("技能")).toHaveLength(0)
223
+ expect(menu.textContent).not.toContain("测试技能")
224
+ })
225
+
226
+ it("fuzzy 部分匹配:/tst 命中 test-skill → Enter → 同形态替换", async () => {
227
+ render(<HarnessComposer {...baseProps} handoffPrefillText="/tst" />)
228
+ const menu = await screen.findByRole("listbox", {}, { timeout: 3000 })
229
+ await waitFor(() => expect(menu.textContent).toContain("测试技能"))
230
+ fireEvent.keyDown(getEditorDom(), { key: "Enter" })
231
+ await waitFor(() => expect(getEditorDom().textContent).toBe("Use the test-skill skill: "))
232
+ })
233
+
234
+ describe("createBuiltinSkillSource 工厂契约", () => {
235
+ const source = createBuiltinSkillSource(() => SKILLS)
236
+
237
+ /** InputTriggerSource.candidates 接口面为 union(sync | async)——工厂实际同步返回,收窄 */
238
+ function syncCandidates(s: ReturnType<typeof createBuiltinSkillSource>, query: string) {
239
+ const result = s.candidates(query)
240
+ if (result instanceof Promise) throw new Error("技能源 candidates 应同步返回")
241
+ return result
242
+ }
243
+
244
+ it("形状:trigger '/' + name 'skills'(组 id 稳定,菜单侧 localizeGroup 出本地化文案)", () => {
245
+ expect(source.trigger).toBe("/")
246
+ expect(source.name).toBe("skills")
247
+ })
248
+
249
+ it("空 query 全量首屏;候选形状(id/kind/group/label=title/subtext=name/data.name)", () => {
250
+ const all = syncCandidates(source, "")
251
+ expect(all).toHaveLength(2)
252
+ expect(all[0]).toMatchObject({
253
+ id: "skill:test-skill",
254
+ kind: "skill",
255
+ group: "skills",
256
+ label: "测试技能",
257
+ subtext: "test-skill",
258
+ data: { name: "test-skill", title: "测试技能" },
259
+ })
260
+ })
261
+
262
+ it("query 过滤:fuzzy 子序列(tst → test-skill)∪ name/title includes(审查 → 代码审查);无命中返回空", () => {
263
+ expect(syncCandidates(source, "tst").map((c) => c.data?.name)).toEqual(["test-skill"])
264
+ expect(syncCandidates(source, "审查").map((c) => c.data?.name)).toEqual(["code-review"])
265
+ expect(syncCandidates(source, "code").map((c) => c.data?.name)).toEqual(["code-review"])
266
+ expect(syncCandidates(source, "zzz")).toEqual([])
267
+ })
268
+
269
+ it("空 skills → 候选恒空(legacy 链无数据 = 自然 gating)", () => {
270
+ const emptySource = createBuiltinSkillSource(() => [])
271
+ expect(syncCandidates(emptySource, "")).toEqual([])
272
+ expect(syncCandidates(emptySource, "test")).toEqual([])
273
+ })
274
+ })
275
+
276
+ describe("skillPromptText 文本形态(官方 ai-skills skillPrompt 同款)", () => {
277
+ it("缺省(参数未敲):冒号尾随空格——邀请续敲任务", () => {
278
+ expect(skillPromptText("test-skill")).toBe("Use the test-skill skill: ")
279
+ })
280
+
281
+ it("插入点紧跟空白参数:省略尾随空格——最终文本收敛 `Use the <name> skill: <task>`(单空格)", () => {
282
+ expect(skillPromptText("test-skill", { followingWhitespace: true })).toBe("Use the test-skill skill:")
283
+ })
284
+ })
285
+
286
+ describe("skills 取数 settle 超时守卫(真机 `/` 菜单骨架永挂修复)", () => {
287
+ describe("withTimeout 工具", () => {
288
+ it("promise 先 settle → 透传其值(clearTimeout 防泄漏)", async () => {
289
+ await expect(withTimeout(Promise.resolve("ok"), 100, "fb")).resolves.toBe("ok")
290
+ })
291
+
292
+ it("promise reject → resolve 为 fallback(不向外抛,fail-closed)", async () => {
293
+ await expect(
294
+ withTimeout(Promise.reject(new Error("boom")), 100, "fb"),
295
+ ).resolves.toBe("fb")
296
+ })
297
+
298
+ it("promise 永不 settle → 超时后 resolve 为 fallback(真机 hang 根因兜底)", async () => {
299
+ vi.useFakeTimers()
300
+ try {
301
+ const p = withTimeout(new Promise<string>(() => {}), 100, "fb")
302
+ await vi.advanceTimersByTimeAsync(150)
303
+ await expect(p).resolves.toBe("fb")
304
+ } finally {
305
+ vi.useRealTimers()
306
+ }
307
+ })
308
+ })
309
+
310
+ it("fetchSkillsViaQueryClient:fetchQuery 永不 settle → 超时回落 [](真机 `/` 菜单骨架永挂根因兜底)", async () => {
311
+ vi.useFakeTimers()
312
+ try {
313
+ fetchQueryMock.mockReturnValue(new Promise<readonly ComposerSkillRef[]>(() => {}))
314
+ const p = fetchSkillsViaQueryClient()
315
+ await vi.advanceTimersByTimeAsync(SKILLS_FETCH_TIMEOUT_MS + 200)
316
+ await expect(p).resolves.toEqual([])
317
+ } finally {
318
+ vi.useRealTimers()
319
+ }
320
+ })
321
+
322
+ it(
323
+ "菜单级:skills fetch 挂起(真机骨架永挂场景)→ 超时兜底后 `/` 菜单仍渲染其余命令(骨架退出,非永挂)",
324
+ async () => {
325
+ fetchQueryMock.mockReturnValue(new Promise<readonly ComposerSkillRef[]>(() => {}))
326
+ render(<HarnessComposer {...baseProps} handoffPrefillText="/" />)
327
+ const menu = await screen.findByRole("listbox", {}, { timeout: 3000 })
328
+ // 超时(2.5s)后 skills 回落 [],mergeLists 仍产出 client+server 命令 → 骨架退出
329
+ //(真机修复前:items Promise 永不 settle → 骨架永挂、连命令都不渲染)
330
+ await waitFor(() => expect(menu.textContent).toContain("清空输入"), { timeout: 5000 })
331
+ // skills 超时回落空 → 无「技能」组(优雅降级,其余命令不受阻)
332
+ expect(screen.queryAllByText("技能")).toHaveLength(0)
333
+ expect(menu.textContent).not.toContain("测试技能")
334
+ },
335
+ )
336
+ })
@@ -44,7 +44,13 @@ export interface ComposerCommandClaim {
44
44
  hint?: string
45
45
  /** claim 是否接受附件(缺省 false:草稿有附件时结算被拒 attachmentsUnsupported) */
46
46
  acceptsAttachments?: boolean
47
- /** 结算执行(server → onRunCommand(name, args);client → cmd.run(ctx, args)) */
47
+ /**
48
+ * 结算执行(server → onRunCommand(name, args);client → cmd.run({ ...ctx, args }))。
49
+ * resolveClaimCommand 本身形状无关:只按 {name, input, hint, acceptsAttachments,
50
+ * description|label} 匹配并回调 run(name, args);client 分支由结算方(harness-composer
51
+ * submitClaim)把 ComposerClientCommand 投影成 claim 形状(label→description)、并在
52
+ * run 闭包内直调 cmd.run(P2 任务 1 兑现——此前 client 命令从未进回查清单)。
53
+ */
48
54
  submit: (args: string) => void | Promise<unknown>
49
55
  }
50
56
 
@@ -0,0 +1,140 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ /**
19
+ * popup 型命令浮层(/model):MenuView(selector `command-popup`)+ /model >4 项时
20
+ * 顶部搜索框(本仓自定阈值,非 DSH popup 行为;本地过滤)。
21
+ *
22
+ * **定位方案(已裁)**:本地 state + InputGroup 内 `absolute inset-x-0 bottom-full mb-1`
23
+ * 面板——InputGroup 根类含 `relative`,面板钉卡上沿(DSH 视觉)。**不用 Base UI
24
+ * PopoverContent**(Portal+floating 定位给不出钉卡布局;shadcn 禁改不能加导出)。
25
+ *
26
+ * **Esc/外点关闭自接**(PopupPanel 外壳,两 popup 复用):keydown Escape + document
27
+ * pointerdown capture,监听挂本面板生命周期内(useEffect mount/unmount)。Escape
28
+ * `stopPropagation`——流式期(isRunning)吃掉 Esc,屏蔽 Esc-Esc 停止序列第一击
29
+ * (审查重点#6,popup open 态经上层并入 onMenuOpenChange 通道双保险)。
30
+ * confirmOpen=true(AlertDialog 开启中)时抑制两监听——Esc 归 AlertDialog(取消回
31
+ * popup,popup 状态保留),外点不落 cancel 通路。
32
+ *
33
+ * **取消恢复**:Esc/外点(非 settle)→ onClose("cancel"),上层按 restoreToken 决定是否
34
+ * `insertContent`;点选 settle → onClose("settle"),不恢复。恢复触发词的编辑器事务在
35
+ * composer-editor(持 editor 实例),本组件只上报关闭原因。
36
+ *
37
+ * /permission popup 已迁出(任务 4):`../permission/permission-popup`(独立文件 +
38
+ * 受控 props,控制行工作区权限按钮共用);本文件只剩 /model 面板。CommandPopupCloseReason
39
+ * 仍是两 popup 共用的关闭原因单一来源(permission-popup type-only 回引)。
40
+ */
41
+ import { useMemo, useState } from "react"
42
+ import { Search } from "lucide-react"
43
+ import { cn } from "cn"
44
+ import { MenuView, type MenuViewEntry } from "./menu-view"
45
+ // popup 外壳(P2 任务 2 迁出共享):/model、/permission 与 model-selector 三处复用
46
+ import { PopupPanel } from "./popup-panel"
47
+ import { Input } from "@/components/ui/input"
48
+ import { m } from "@/paraglide/messages.js"
49
+
50
+ /** popup 关闭原因:settle(点选项,不恢复触发词)/ cancel(Esc/外点,恢复触发词)。 */
51
+ export type CommandPopupCloseReason = "settle" | "cancel"
52
+
53
+ export interface CommandPopupProps {
54
+ /** 模型目录(body.availableModels;空 = 上层不弹 popup) */
55
+ models: ReadonlyArray<string>
56
+ /** 当前会话模型 */
57
+ model?: string
58
+ /** 切换当前会话模型(点选 settle 路径) */
59
+ onModelChange: (model: string) => void
60
+ /**
61
+ * 关闭回调:settle = 点选(不恢复触发词);cancel = Esc/外点(上层按 restoreToken
62
+ * 决定是否 insertContent 恢复)。恢复触发词 + 焦点回编辑器的编辑器事务在
63
+ * composer-editor(持 editor 实例),本组件只上报关闭原因。
64
+ */
65
+ onClose: (reason: CommandPopupCloseReason) => void
66
+ }
67
+
68
+ /** 搜索框显示阈值(>4 项时显示——本仓自定阈值,非 DSH popup 无条件搜索)。 */
69
+ const SEARCH_THRESHOLD = 4
70
+
71
+ /**
72
+ * 模型目录 popup 面板。selector `command-popup`(MenuView option id 派生前缀,同页
73
+ * 与 '/' 菜单 / @ 菜单 listbox 区分;两 popup 状态互斥不共存,共用同一 selector)。
74
+ */
75
+ export function CommandPopup({
76
+ models,
77
+ model,
78
+ onModelChange,
79
+ onClose,
80
+ }: CommandPopupProps) {
81
+ const [query, setQuery] = useState("")
82
+
83
+ // 本地过滤(大小写不敏感 includes;模型名即展示文案,无需 fuzzy)
84
+ const filtered = useMemo(() => {
85
+ const q = query.trim().toLowerCase()
86
+ if (!q) return [...models]
87
+ return models.filter((name) => name.toLowerCase().includes(q))
88
+ }, [models, query])
89
+
90
+ // >4 项才显示搜索框(本仓自定阈值);按原始目录数判定,非过滤后数
91
+ const showSearch = models.length > SEARCH_THRESHOLD
92
+
93
+ const entries: ReadonlyArray<MenuViewEntry<string>> = filtered.map((name) => ({
94
+ key: name,
95
+ groupLabel: m.harness_command_model(),
96
+ item: name,
97
+ }))
98
+
99
+ const handleSelect = (name: string) => {
100
+ if (name !== model) onModelChange(name)
101
+ onClose("settle")
102
+ }
103
+
104
+ return (
105
+ <PopupPanel onClose={onClose}>
106
+ <div className="rounded-xl border bg-background text-card-foreground">
107
+ {showSearch && (
108
+ <div className="relative p-2">
109
+ <Search className="absolute left-4 top-1/2 size-4 -translate-y-1/2 text-muted-foreground" />
110
+ <Input
111
+ value={query}
112
+ onChange={(e) => setQuery(e.target.value)}
113
+ placeholder={m.harness_command_modelSearch()}
114
+ aria-label={m.harness_command_modelSearch()}
115
+ className="h-8 pl-8 text-sm"
116
+ />
117
+ </div>
118
+ )}
119
+ <MenuView
120
+ entries={entries}
121
+ selectedIndex={-1}
122
+ onSelect={handleSelect}
123
+ selector="command-popup"
124
+ loading={false}
125
+ emptyMessage={m.harness_command_modelEmpty()}
126
+ isCurrent={(name) => name === model}
127
+ renderTitle={(name) => (
128
+ <span className={cn(name === model && "font-semibold")}>{name}</span>
129
+ )}
130
+ renderMedia={(name) =>
131
+ name === model ? (
132
+ <span aria-hidden className="text-primary">✓</span>
133
+ ) : null
134
+ }
135
+ />
136
+ </div>
137
+ </PopupPanel>
138
+ )
139
+ }
140
+