@allbluecn/web-app 0.27.40 → 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 (299) 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/browser/__tests__/webview-frame.test.tsx +5 -2
  251. package/src/components/harness/extension-panel/panels/plugin/__tests__/install-dialog.test.tsx +260 -0
  252. package/src/components/harness/extension-panel/panels/plugin/__tests__/plugin-page.test.tsx +912 -0
  253. package/src/components/harness/extension-panel/panels/plugin/__tests__/plugin-row.test.tsx +215 -0
  254. package/src/components/harness/extension-panel/panels/plugin/builtin-section.tsx +204 -0
  255. package/src/components/harness/extension-panel/panels/plugin/install-dialog.tsx +195 -0
  256. package/src/components/harness/extension-panel/panels/plugin/installed-section.tsx +378 -0
  257. package/src/components/harness/extension-panel/panels/plugin/kind.tsx +17 -4
  258. package/src/components/harness/extension-panel/panels/plugin/pending-builds-block.tsx +49 -0
  259. package/src/components/harness/extension-panel/panels/plugin/plugin-page.tsx +257 -0
  260. package/src/components/harness/extension-panel/panels/plugin/plugin-row.tsx +206 -0
  261. package/src/components/harness/extension-panel/panels/plugin/plugin-types.ts +13 -0
  262. package/src/components/harness/extension-panel/panels/plugin/worker-section.tsx +322 -0
  263. package/src/components/harness/workbench/__tests__/provider-model-groups.test.ts +301 -0
  264. package/src/components/harness/workbench/harness-workbench-page.tsx +164 -2
  265. package/src/components/harness/workbench/provider-model-groups.ts +140 -0
  266. package/src/components/harness/workbench/undo-last-turn.ts +79 -0
  267. package/src/components/harness/workbench/workbench-context.tsx +53 -3
  268. package/src/components/tiptap/hooks/__tests__/use-floating-element.test.tsx +131 -0
  269. package/src/components/tiptap/hooks/use-floating-element.ts +15 -2
  270. package/src/components/tiptap/hooks/use-menu-navigation.ts +5 -0
  271. package/src/components/tiptap/node/mention-extension.ts +33 -0
  272. package/src/components/tiptap/ui/suggestion-menu/__tests__/suggestion-menu.test.tsx +366 -0
  273. package/src/components/tiptap/ui/suggestion-menu/suggestion-menu-types.ts +54 -0
  274. package/src/components/tiptap/ui/suggestion-menu/suggestion-menu.tsx +176 -45
  275. package/src/lib/changelog/sdk-versions.ts +2 -2
  276. package/src/lib/queries/__tests__/harness-plugin-queries.test.ts +49 -0
  277. package/src/lib/queries/harness.ts +50 -0
  278. package/src/paraglide/messages/_index.js +1574 -311
  279. package/src/paraglide/messages/en.js +513 -103
  280. package/src/paraglide/messages/zh.js +514 -104
  281. package/src/routeTree.gen.ts +31 -0
  282. package/src/routes/_nav/harness/route.lazy.tsx +13 -0
  283. package/src/server/ai-gateway/sandbox/policy.ts +6 -6
  284. package/src/server/harness/__tests__/compact-plugin.server.test.ts +46 -0
  285. package/src/server/harness/__tests__/define-expose.test.ts +17 -0
  286. package/src/server/harness/__tests__/thread-reference.server.test.ts +258 -0
  287. package/src/server/harness/define.server.ts +21 -3
  288. package/src/server/harness/thread-reference.server.ts +446 -0
  289. package/src/server/serverFns/chat/__tests__/conversations-sandbox-default.test.ts +23 -0
  290. package/src/server/serverFns/chat/conversations.ts +18 -3
  291. package/src/server/serverFns/harness/search-mention-candidates.ts +14 -1
  292. package/src/shared/harness/__tests__/thread-reference-format.test.ts +128 -0
  293. package/src/shared/harness/thread-reference-format.ts +98 -0
  294. package/LICENSE +0 -661
  295. package/src/components/agents/slash-skill-menu.tsx +0 -75
  296. package/src/components/harness/conversation-panel/composer/extension/__tests__/demo-story-reference.test.tsx +0 -177
  297. package/src/components/harness/conversation-panel/composer/extension/demo-story-reference.tsx +0 -227
  298. package/src/components/harness/conversation-panel/composer/plugin-mention-menu.tsx +0 -109
  299. package/src/components/harness/extension-panel/panels/plugin-panel.tsx +0 -1021
@@ -0,0 +1,193 @@
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
+ * /model popup(模型目录 popup + 取消恢复触发词 + menuOpen 上报)挂真实 composer。
20
+ *
21
+ * 五用例:
22
+ * 1. /model 选中 → popup 开(模型列表)→ 点选 → onModelChange + popup 关 + 焦点回编辑器;
23
+ * 2. 取消恢复:popup 开 → Escape → popup 关 + 编辑器文本恢复 `/model `(规范命令名,
24
+ * 非用户敲的 `/mo`)+ 无 onModelChange;
25
+ * 3. 流式期 Esc 不误停:isRunning=true + popup 开 → Esc-Esc 序列不武装、onStop 未调
26
+ * (popup open 态并入 onMenuOpenChange 通道 + popup 面板 document capture
27
+ * stopPropagation,第一击 Esc 不抵达停止热键监听)。派发到**真实容器**(ref 指向
28
+ * 含 composer 的元素,Esc-Esc 热键真实注册——传 {current:null} 会跳过注册致平凡通过);
29
+ * 4. 门控:models=[] → /model 不在 `/` 菜单;
30
+ * 5. 控制组:popup 关 + isRunning=true → Esc-Esc 序列武装并触发 onStop(证明热键真实
31
+ * 注册、用例 3 的 onStop 未调非平凡成立)。
32
+ *
33
+ * 渲染 HarnessComposer(真实 TipTap),handoffPrefillText 预填触发串
34
+ * (command-suggestion-menu.test 同款手法)。
35
+ */
36
+ import { afterEach, beforeEach, expect, it, vi } from "vitest"
37
+ import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react"
38
+ import { HarnessComposer } from "../../harness-composer"
39
+ import { draftsStore } from "../../use-drafts"
40
+
41
+ vi.mock("@/server/serverFns/harness/media", () => ({ generatePrototypeFn: vi.fn(() => Promise.resolve({})) }))
42
+ vi.mock("../../mention/use-mention-sources", () => ({
43
+ useMentionSources: () => ({ all: [], isLoading: false }),
44
+ }))
45
+ vi.mock("@/components/billing/use-feature", () => ({ useFeature: () => ({ enabled: true, loading: false }) }))
46
+ // bundle 守卫(T9 将共用本组件):composer 链路不得加载服务端沙箱策略
47
+ vi.mock("@/server/ai-gateway/sandbox/policy", () => { throw new Error("Server sandbox policy must not be loaded by the composer") })
48
+ // mock 链切断(T9):command-popup 经 permission-policy 访问沙箱策略——真模块顶层
49
+ // import sandbox-policy serverFn → policy index(上方 throw 守卫),桩掉即断链
50
+ vi.mock("../../permission/permission-policy", () => ({
51
+ SANDBOX_POLICY_LEVELS: ["readonly", "workspace-write", "full"],
52
+ getSandboxPolicy: vi.fn(),
53
+ setSandboxPolicy: vi.fn(),
54
+ }))
55
+ vi.mock("../../voice-input-button", () => ({ VoiceInputButton: () => null }))
56
+ vi.mock("@/components/harness/conversation-panel/messages/approvals/interrupt-approval", () => ({ InterruptApproval: () => null }))
57
+
58
+ beforeEach(() => {
59
+ sessionStorage.clear()
60
+ })
61
+ afterEach(() => {
62
+ cleanup()
63
+ })
64
+
65
+ /** 取 ProseMirror 编辑面(composer-send.test 同款定位) */
66
+ function getEditorDom(): HTMLElement {
67
+ const el = document.querySelector<HTMLElement>(".tiptap.ProseMirror")
68
+ if (!el) throw new Error("TipTap 编辑器 DOM 未挂载")
69
+ return el
70
+ }
71
+
72
+ const MODELS = ["gpt-4o", "gpt-4o-mini", "claude-sonnet-4-5", "gemini-2-0-flash", "o3-mini"]
73
+
74
+ interface SetupOptions {
75
+ prefill: string
76
+ models?: string[]
77
+ model?: string
78
+ onModelChange?: (model: string) => void
79
+ onStop?: () => void
80
+ isRunning?: boolean
81
+ }
82
+
83
+ /**
84
+ * 渲染进真实容器元素,`conversationRegionRef` 指向该容器——Esc-Esc 停止序列热键
85
+ * **真正注册**到容器上(传 `{current:null}` 会因 resolveTarget→null 被适配器跳过注册,
86
+ * 用例 3 会平凡通过)。返回容器元素供用例 3 在其上派发 Esc(编辑器在容器内,keydown
87
+ * 冒泡到容器被热键监听捕获)。
88
+ */
89
+ function setup({ prefill, models = MODELS, model, onModelChange, onStop, isRunning = false }: SetupOptions) {
90
+ const container = document.createElement("div")
91
+ document.body.appendChild(container)
92
+ const regionRef = { current: container as HTMLDivElement | null }
93
+ render(
94
+ <HarnessComposer
95
+ threadId="t1"
96
+ isRunning={isRunning}
97
+ hasAiKey
98
+ busyPreference="queue"
99
+ onSend={vi.fn()}
100
+ onStop={onStop ?? vi.fn()}
101
+ conversationRegionRef={regionRef}
102
+ messages={[]}
103
+ handoffPrefillText={prefill}
104
+ models={models}
105
+ model={model}
106
+ onModelChange={onModelChange}
107
+ />,
108
+ { container },
109
+ )
110
+ return { container }
111
+ }
112
+
113
+ /** `/` 菜单开(handoffPrefillText 预填即开)→ Enter 选中 /model → popup 开(模型列表) */
114
+ async function openModelPopup() {
115
+ // '/' 菜单随预填自动打开(真实 SuggestionMenu)
116
+ const textbox = getEditorDom()
117
+ const menu = await screen.findByRole("listbox", {}, { timeout: 3000 })
118
+ await waitFor(() => expect(menu.textContent).toContain("模型"))
119
+ // Enter 选中 /model(client 源排最前 + autoSelectFirstItem)→ '/' 菜单关、popup 开
120
+ fireEvent.keyDown(textbox, { key: "Enter" })
121
+ const popup = await screen.findByRole("listbox", {}, { timeout: 3000 })
122
+ await waitFor(() => expect(popup.textContent).toContain("gpt-4o"))
123
+ return { textbox, popup }
124
+ }
125
+
126
+ it("/model 选中 → popup 开 → 点选 → onModelChange 调用 + popup 关 + 焦点回编辑器", async () => {
127
+ const onModelChange = vi.fn()
128
+ setup({ prefill: "/model", onModelChange })
129
+ const { textbox, popup } = await openModelPopup()
130
+ // >4 项 → 顶部搜索框(本仓自定阈值)
131
+ expect(screen.getByPlaceholderText("搜索模型…")).toBeTruthy()
132
+ // 点选 gpt-4o(精确匹配取首个,规避 gpt-4o-mini 子串与标题/行双层匹配)
133
+ const gptOptions = screen.getAllByText("gpt-4o", { exact: true })
134
+ fireEvent.click(gptOptions[0])
135
+ expect(onModelChange).toHaveBeenCalledExactlyOnceWith("gpt-4o")
136
+ // popup 关(模型列表消失)
137
+ await waitFor(() => expect(screen.queryByPlaceholderText("搜索模型…")).toBeNull())
138
+ // settle 不恢复触发词 + 焦点回编辑器
139
+ await waitFor(() => expect(textbox.textContent).toBe(""))
140
+ await waitFor(() => expect(getEditorDom()).toHaveFocus())
141
+ void popup
142
+ })
143
+
144
+ it("取消恢复:popup 开 → Escape → popup 关 + 文本恢复 `/model ` + 无 onModelChange", async () => {
145
+ const onModelChange = vi.fn()
146
+ setup({ prefill: "/mo", onModelChange })
147
+ const { textbox } = await openModelPopup()
148
+ // popup open 期间 Esc 只关 popup
149
+ fireEvent.keyDown(document, { key: "Escape" })
150
+ await waitFor(() => expect(screen.queryByPlaceholderText("搜索模型…")).toBeNull())
151
+ // 取消路径恢复规范触发词(非用户敲的 /mo)
152
+ await waitFor(() => expect(textbox.textContent).toBe("/model "))
153
+ expect(onModelChange).not.toHaveBeenCalled()
154
+ })
155
+
156
+ it("流式期 Esc 不误停:isRunning=true + popup 开 → Esc-Esc 序列不武装、onStop 未调", async () => {
157
+ const onModelChange = vi.fn()
158
+ const onStop = vi.fn()
159
+ const { container } = setup({ prefill: "/model", onModelChange, onStop, isRunning: true })
160
+ const { textbox } = await openModelPopup()
161
+ // 两击 Esc 都派发到会话区域容器(Esc-Esc 停止热键的注册目标)——popup 开启期第一击
162
+ // 被 popup 面板 document capture stopPropagation 吃掉,序列不武装。
163
+ fireEvent.keyDown(container, { key: "Escape" })
164
+ await waitFor(() => expect(screen.queryByPlaceholderText("搜索模型…")).toBeNull())
165
+ fireEvent.keyDown(container, { key: "Escape" })
166
+ // onStop 未被调用:第一击 Esc 未抵达停止热键监听(popup capture stopPropagation),
167
+ // 序列停留在 progress 0 → 第二击只是重新武装、不完成序列(审查重点#6 真实覆盖)。
168
+ expect(onStop).not.toHaveBeenCalled()
169
+ // 第一击 popup 关 + 取消路径恢复触发词
170
+ await waitFor(() => expect(textbox.textContent).toBe("/model "))
171
+ })
172
+
173
+ it("控制组:popup 关 + isRunning=true → Esc-Esc 序列武装并触发 onStop(热键真实注册)", async () => {
174
+ const onStop = vi.fn()
175
+ const { container } = setup({ prefill: "hi", onStop, isRunning: true })
176
+ // 等 prefill 落到编辑器(非空草稿 → 主按钮切停止形态,isRunning 门控开启)
177
+ const textbox = getEditorDom()
178
+ await waitFor(() => expect(textbox.textContent).toBe("hi"))
179
+ // popup 未开启:两击 Esc 都抵达容器上的停止热键监听 → 序列完成 → onStop
180
+ fireEvent.keyDown(container, { key: "Escape" })
181
+ fireEvent.keyDown(container, { key: "Escape" })
182
+ expect(onStop).toHaveBeenCalledTimes(1)
183
+ })
184
+
185
+ it("门控:models=[] → /model 不在 `/` 菜单(其余命令照常)", async () => {
186
+ setup({ prefill: "/", models: [] })
187
+ const listbox = await screen.findByRole("listbox", {}, { timeout: 3000 })
188
+ await waitFor(() => expect(listbox.textContent).toContain("清空输入"))
189
+ // 门控关闭:/model 被组装侧过滤
190
+ expect(listbox.textContent).not.toContain("模型")
191
+ // 草稿仓未被触碰(未选中任何命令)
192
+ expect(draftsStore.load("draft:t1")).toBeNull()
193
+ })
@@ -0,0 +1,235 @@
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
+ * '/' 菜单 server 源首条真实命令(任务 1:/compact):
20
+ * view store commands 切片投影 [{ name: 'compact', description: 英文原文 }]
21
+ * 进 '/' 菜单(HarnessComposer props 注入,workbench-page 接线同口径)——
22
+ * ① 已知 server 命令 label 走本地化映射(「压缩上下文」),英文 description 原文不上屏;
23
+ * ② server 组头「服务端命令」与 client 组头「指令」区分(不再同名合并);
24
+ * ③ Enter 选中 → onRunCommand('compact')(client.runCommand 通路)。
25
+ * 渲染 HarnessComposer(真实 TipTap),handoffPrefillText 预填触发串
26
+ * (command-suggestion-menu.test 同款手法;mock 组合同 claim-guard.test 基线)。
27
+ */
28
+ import { afterEach, beforeEach, expect, it, vi } from "vitest"
29
+ import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react"
30
+ import { HarnessComposer } from "../../harness-composer"
31
+ import { clearComposerExtensions } from "../../extension"
32
+
33
+ vi.mock("@/server/serverFns/harness/media", () => ({ generatePrototypeFn: vi.fn(() => Promise.resolve({})) }))
34
+ vi.mock("../../mention/use-mention-sources", () => ({
35
+ useMentionSources: () => ({ all: [], isLoading: false }),
36
+ }))
37
+ vi.mock("@/components/billing/use-feature", () => ({ useFeature: () => ({ enabled: true, loading: false }) }))
38
+ vi.mock("@/server/ai-gateway/sandbox/policy", () => { throw new Error("Server sandbox policy must not be loaded by the composer") })
39
+ // mock 链切断(T9):command-popup 经 permission-policy 访问沙箱策略——真模块顶层
40
+ // import sandbox-policy serverFn → policy index(上方 throw 守卫),桩掉即断链
41
+ vi.mock("../../permission/permission-policy", () => ({
42
+ SANDBOX_POLICY_LEVELS: ["readonly", "workspace-write", "full"],
43
+ getSandboxPolicy: vi.fn(),
44
+ setSandboxPolicy: vi.fn(),
45
+ }))
46
+ vi.mock("../../voice-input-button", () => ({ VoiceInputButton: () => null }))
47
+ vi.mock("../../../../../interrupt-approval", () => ({ InterruptApproval: () => null }))
48
+
49
+ beforeEach(() => {
50
+ sessionStorage.clear()
51
+ })
52
+ afterEach(() => {
53
+ cleanup()
54
+ clearComposerExtensions()
55
+ })
56
+
57
+ function getEditorDom(): HTMLElement {
58
+ const el = document.querySelector<HTMLElement>(".tiptap.ProseMirror")
59
+ if (!el) throw new Error("TipTap 编辑器 DOM 未挂载")
60
+ return el
61
+ }
62
+
63
+ /** 取 '/' 菜单浮层(listbox role;MenuView 承接 combobox 语义) */
64
+ async function openCommandMenu(): Promise<HTMLElement> {
65
+ return await screen.findByRole("listbox", {}, { timeout: 3000 })
66
+ }
67
+
68
+ /** 官方 compact 插件 setup 贡献的命令(session/commands 切片投影形状) */
69
+ const COMPACT_SERVER_COMMAND = {
70
+ name: "compact",
71
+ description: "Summarize the conversation to save tokens",
72
+ }
73
+
74
+ function setup(options: {
75
+ prefill: string
76
+ commands?: ReadonlyArray<{ name: string; description: string }>
77
+ onRunCommand?: (name: string) => void | Promise<unknown>
78
+ models?: string[]
79
+ canPlan?: boolean
80
+ onPlanSubmit?: (args: string) => Promise<void>
81
+ }) {
82
+ const onSend = vi.fn()
83
+ const baseProps = {
84
+ threadId: "t1",
85
+ isRunning: false,
86
+ hasAiKey: true,
87
+ busyPreference: "queue" as const,
88
+ onSend,
89
+ onStop: vi.fn(),
90
+ conversationRegionRef: { current: null },
91
+ messages: [],
92
+ onRunCommand: options.onRunCommand,
93
+ }
94
+ const view = render(
95
+ <HarnessComposer
96
+ {...baseProps}
97
+ handoffPrefillText={options.prefill}
98
+ commands={options.commands}
99
+ models={options.models}
100
+ canPlan={options.canPlan}
101
+ onPlanSubmit={options.onPlanSubmit}
102
+ />,
103
+ )
104
+ return {
105
+ onSend,
106
+ /** 供「commands 异步后到」回归用:保持其余 props 不变,仅改 commands / prefill 重渲染 */
107
+ rerender: (next: {
108
+ commands?: ReadonlyArray<{ name: string; description: string }>
109
+ prefill?: string
110
+ models?: string[]
111
+ canPlan?: boolean
112
+ onPlanSubmit?: (args: string) => Promise<void>
113
+ }) => {
114
+ view.rerender(
115
+ <HarnessComposer
116
+ {...baseProps}
117
+ handoffPrefillText={next.prefill ?? options.prefill}
118
+ commands={next.commands ?? options.commands}
119
+ models={next.models ?? options.models}
120
+ canPlan={next.canPlan ?? options.canPlan}
121
+ onPlanSubmit={next.onPlanSubmit ?? options.onPlanSubmit}
122
+ />,
123
+ )
124
+ },
125
+ }
126
+ }
127
+
128
+ it("server 命令 compact:「服务端命令」组出现「压缩上下文」(label 本地化映射,英文 description 原文不上屏)", async () => {
129
+ setup({ prefill: "/", commands: [COMPACT_SERVER_COMMAND], onRunCommand: vi.fn() })
130
+ const listbox = await openCommandMenu()
131
+ await waitFor(() => expect(listbox.textContent).toContain("压缩上下文"))
132
+ // 已知 server 命令 label 走 KNOWN_SERVER_COMMAND_LABELS 映射,英文原文不上屏
133
+ expect(listbox.textContent).not.toContain("Summarize the conversation to save tokens")
134
+ // server 组头与 client 组头区分(P0 两相邻组同名「指令」被 MenuView 聚合合并)
135
+ await waitFor(() => expect(listbox.textContent).toContain("服务端命令"))
136
+ })
137
+
138
+ it("组头区分:「指令」组含清空输入(client),「服务端命令」组含 compact(server),两段并存", async () => {
139
+ setup({ prefill: "/", commands: [COMPACT_SERVER_COMMAND], onRunCommand: vi.fn() })
140
+ const listbox = await openCommandMenu()
141
+ await waitFor(() => expect(listbox.textContent).toContain("压缩上下文"))
142
+ const clientHeaders = await screen.findAllByText("指令")
143
+ const serverHeaders = await screen.findAllByText("服务端命令")
144
+ expect(clientHeaders.length).toBeGreaterThan(0)
145
+ expect(serverHeaders.length).toBeGreaterThan(0)
146
+ // 顺序:client 组在前(unifyCommandItems client → server),server 组头在后
147
+ const first = clientHeaders[0].compareDocumentPosition(serverHeaders[0])
148
+ expect(first & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy()
149
+ })
150
+
151
+ it("Enter 选中 compact → onRunCommand('compact') 被调(client.runCommand 通路)", async () => {
152
+ const onRunCommand = vi.fn<(name: string) => Promise<unknown>>((name) => Promise.resolve(name))
153
+ setup({ prefill: "/comp", commands: [COMPACT_SERVER_COMMAND], onRunCommand })
154
+ const textbox = getEditorDom()
155
+ const listbox = await openCommandMenu()
156
+ // 查询 "comp" 命中 name=compact(唯一候选 → autoSelectFirstItem 高亮它)
157
+ await waitFor(() => expect(listbox.textContent).toContain("压缩上下文"))
158
+ fireEvent.keyDown(textbox, { key: "Enter" })
159
+ expect(onRunCommand).toHaveBeenCalledExactlyOnceWith("compact")
160
+ // 触发词已删除(非 mention 触发的 SuggestionMenu deleteRange)
161
+ await waitFor(() => expect(textbox.textContent).toBe(""))
162
+ })
163
+
164
+ /**
165
+ * 回归锁定(P2 任务 0,/compact 菜单渲染缺口):
166
+ * SuggestionMenu 插件注册 effect(suggestion-menu.tsx:220-445,deps 仅
167
+ * [editor, pluginKey, closePopup, disabled, setPending],**不含 items/commands**)在
168
+ * 注册时把**当时的 items: getItems 函数引用**一次性固化进插件配置。server commands
169
+ * 来自 view store、**挂载后异步后到** → 注册期捕获的是「空 commands 闭包的 getItems」,
170
+ * 后到 commands 重渲染重建的新 getItems 不会被插件看到 → server 项永不现形。
171
+ *
172
+ * 本例复刻该时序:先以**无 commands**挂载(插件此刻用「空 commands 闭包的 getItems」
173
+ * 注册完毕),随后 commands prop 后到(view store session open 投影),再开菜单——
174
+ * server 组「压缩上下文」必须现形。
175
+ *
176
+ * **修复前本例失败**(插件持注册期空闭包,后到 commands 不进菜单);
177
+ * **修复后转绿**(getItems 经 commandsRef/onRunCommandRef live ref 取最新值)。
178
+ */
179
+ it("commands 异步后到:挂载时无 server 命令,commands prop 后到再开菜单,server 项现形", async () => {
180
+ // ① 无 commands 挂载:插件以「空 commands 闭包的 getItems」注册(editor key=aiReady
181
+ // 稳定,commands 变化不重挂、不重注册——与真机后到时序一致)
182
+ const { rerender } = setup({
183
+ prefill: "",
184
+ commands: undefined,
185
+ onRunCommand: vi.fn(),
186
+ })
187
+ expect(screen.queryByRole("listbox")).toBeNull()
188
+
189
+ // ② commands 后到(同一次 rerender 触发 handoffPrefillText 变更 → insertContent('/')
190
+ // → 插件 onStart → 调用注册期那份 getItems)
191
+ rerender({ commands: [COMPACT_SERVER_COMMAND], prefill: "/" })
192
+
193
+ // ③ 修复后 getItems 经 live ref 取到后到 commands,server 组「压缩上下文」现形
194
+ const listbox = await openCommandMenu()
195
+ await waitFor(() => expect(listbox.textContent).toContain("压缩上下文"))
196
+ })
197
+
198
+ /**
199
+ * 回归锁定(/model /plan 菜单项缺失,T0 live-ref 通道的遗漏面):
200
+ * T0 只把 commands/onRunCommand/resolvedClientCommands 改经 ref,getItems 闭包读的
201
+ * `models`/`canPlan` 等门控输入仍被注册期闭包固化——模型目录 query / workbench-page
202
+ * canPlan 都是挂载后异步就绪,固化的「models=[] / canPlan=undefined」使 /model /plan
203
+ * 恒隐藏(真机实证:models prop 已到 2 项而菜单无「模型」)。
204
+ *
205
+ * 本例复刻该时序:先以**无 models / 无 canPlan** 挂载(注册期固化),随后两 prop 后到,
206
+ * 再开菜单——「模型」与「计划模式」必须现形。**修复前失败,修复后(门控输入并入
207
+ * live-ref 通道)转绿**。
208
+ */
209
+ it("models/canPlan 异步后到:挂载时为空,props 后到再开菜单,「模型」与「计划模式」现形", async () => {
210
+ // ① 无 models / canPlan 挂载:注册期固化「空 models 闭包的 getItems」
211
+ const { rerender } = setup({
212
+ prefill: "",
213
+ commands: undefined,
214
+ onRunCommand: vi.fn(),
215
+ models: undefined,
216
+ canPlan: undefined,
217
+ })
218
+ expect(screen.queryByRole("listbox")).toBeNull()
219
+
220
+ // ② models/canPlan/onPlanSubmit 后到(同一次 rerender 触发 prefill 变更 → 菜单重开
221
+ // → 调注册期那份 getItems)。plan 命令双条件:clientCommands memo 按 onPlanSubmit
222
+ // 条件产出 + filterGatedClientCommands 按 canPlan 门控,缺一即隐藏(真机接线两者
223
+ // 由 workbench-page 同传)。
224
+ rerender({
225
+ models: ["gpt-4o-mini", "sensenova-6.8-flash"],
226
+ canPlan: true,
227
+ onPlanSubmit: () => Promise.resolve(),
228
+ prefill: "/",
229
+ })
230
+
231
+ // ③ 修复后门控输入经 ref 取最新值:「模型」与「计划模式」均现形
232
+ const listbox = await openCommandMenu()
233
+ await waitFor(() => expect(listbox.textContent).toContain("模型"))
234
+ await waitFor(() => expect(listbox.textContent).toContain("计划模式"))
235
+ })
@@ -38,6 +38,13 @@ vi.mock("../../mention/use-mention-sources", () => ({
38
38
  }))
39
39
  vi.mock("@/components/billing/use-feature", () => ({ useFeature: () => ({ enabled: true, loading: false }) }))
40
40
  vi.mock("@/server/ai-gateway/sandbox/policy", () => { throw new Error("Server sandbox policy must not be loaded by the composer") })
41
+ // mock 链切断(T9):command-popup 经 permission-policy 访问沙箱策略——真模块顶层
42
+ // import sandbox-policy serverFn → policy index(上方 throw 守卫),桩掉即断链
43
+ vi.mock("../../permission/permission-policy", () => ({
44
+ SANDBOX_POLICY_LEVELS: ["readonly", "workspace-write", "full"],
45
+ getSandboxPolicy: vi.fn(),
46
+ setSandboxPolicy: vi.fn(),
47
+ }))
41
48
  vi.mock("../../voice-input-button", () => ({ VoiceInputButton: () => null }))
42
49
  vi.mock("../../../../../interrupt-approval", () => ({ InterruptApproval: () => null }))
43
50
 
@@ -47,6 +54,7 @@ beforeEach(() => {
47
54
  afterEach(() => {
48
55
  cleanup()
49
56
  clearComposerExtensions()
57
+ vi.unstubAllEnvs()
50
58
  })
51
59
 
52
60
  /** 取 ProseMirror 编辑面(composer-send.test 同款定位,afterEach 保证单实例) */
@@ -60,9 +68,16 @@ interface SetupOptions {
60
68
  prefill: string
61
69
  commands?: ReadonlyArray<{ name: string; description: string }>
62
70
  onRunCommand?: (name: string) => void | Promise<unknown>
71
+ /** 执行引擎(门控断言用:'local' → attachmentsEnabled=false → /file 不进菜单;
72
+ * 缺省 cloud → 附件开、/file 在列) */
73
+ engine?: "cloud" | "local"
74
+ /** 系统文件选择器回调(/file 执行断言用) */
75
+ openFilePicker?: () => void
76
+ /** 模型目录(/model 门控断言用:非空 → /model 进 '/' 菜单) */
77
+ models?: string[]
63
78
  }
64
79
 
65
- function setup({ prefill, commands, onRunCommand }: SetupOptions) {
80
+ function setup({ prefill, commands, onRunCommand, engine, openFilePicker, models }: SetupOptions) {
66
81
  const onSend = vi.fn()
67
82
  render(
68
83
  <HarnessComposer
@@ -77,6 +92,9 @@ function setup({ prefill, commands, onRunCommand }: SetupOptions) {
77
92
  handoffPrefillText={prefill}
78
93
  commands={commands}
79
94
  onRunCommand={onRunCommand}
95
+ engine={engine}
96
+ openFilePicker={openFilePicker}
97
+ models={models}
80
98
  />,
81
99
  )
82
100
  return onSend
@@ -137,6 +155,17 @@ it("trigger 源:registry 注册 '/' 源 → 菜单展示候选 → Enter 选
137
155
  expect(ctx.range).toBeTruthy()
138
156
  })
139
157
 
158
+ it("Tab 确认高亮候选(tabSelects):清空输入被执行 → 编辑器清空", async () => {
159
+ setup({ prefill: "/" })
160
+ const textbox = getEditorDom()
161
+ const listbox = await screen.findByRole("listbox", {}, { timeout: 3000 })
162
+ await waitFor(() => expect(listbox.textContent).toContain("清空输入"))
163
+ // Tab = 确认高亮候选(批 18 与 @ 菜单统一),不再移动高亮 → 清空输入执行
164
+ fireEvent.keyDown(textbox, { key: "Tab" })
165
+ await waitFor(() => expect(textbox.textContent).toBe(""))
166
+ expect(draftsStore.load("draft:t1")).toBeNull()
167
+ })
168
+
140
169
  it("查询无候选 → Enter 透传提交('/' 原文发送,@ 菜单仲裁基线)", async () => {
141
170
  const onSend = setup({ prefill: "/xyz", commands: [{ name: "mode", description: "切换模式" }] })
142
171
  const textbox = getEditorDom()
@@ -149,3 +178,124 @@ it("查询无候选 → Enter 透传提交('/' 原文发送,@ 菜单仲裁
149
178
  // useMenuNavigation 对空 items 放行 → 提交 keymap 消费 → onSend
150
179
  expect(onSend).toHaveBeenCalledWith("/xyz", expect.objectContaining({ whenBusy: "queue" }))
151
180
  })
181
+
182
+ it("/file 命令:'/' 菜单含「文件」(添加组置顶)→ Enter 选中 → openFilePicker 调用 + 触发词被消费", async () => {
183
+ const openFilePicker = vi.fn()
184
+ setup({ prefill: "/", openFilePicker })
185
+ const textbox = getEditorDom()
186
+ const listbox = await screen.findByRole("listbox", {}, { timeout: 3000 })
187
+ // '/' 触发后 query 为空 → matchesQuery 全放行,/file(label「文件」)与 /clear 均在列
188
+ await waitFor(() => expect(listbox.textContent).toContain("文件"))
189
+ await waitFor(() => expect(listbox.textContent).toContain("清空输入"))
190
+ // autoSelectFirstItem → Enter 选中首项(client 源排最前 + file 在数组首位 → /file)
191
+ fireEvent.keyDown(textbox, { key: "Enter" })
192
+ // /file 执行体:打开系统文件选择器
193
+ expect(openFilePicker).toHaveBeenCalledTimes(1)
194
+ // 非输入型命令选中即执行:'/' 触发词被 SuggestionMenu deleteRange 清除
195
+ await waitFor(() => expect(textbox.textContent).toBe(""))
196
+ })
197
+
198
+ it("门控:engine=local(attachmentsEnabled=false)→ /file 不在菜单(其余命令照常)", async () => {
199
+ setup({ prefill: "/", engine: "local", openFilePicker: vi.fn() })
200
+ const textbox = getEditorDom()
201
+ const listbox = await screen.findByRole("listbox", {}, { timeout: 3000 })
202
+ await waitFor(() => expect(listbox.textContent).toContain("清空输入"))
203
+ // 门控关闭:/file 被组装侧过滤(清空输入不受影响)
204
+ expect(listbox.textContent).not.toContain("文件")
205
+ })
206
+
207
+ // 零回归断言(2026-11-20 任务 7 `+` 菜单收敛):excludeComposerSeatCommands 只包在
208
+ // harness-composer 的 plusMenuCommands(`+` Popover)外侧,'/' 菜单链路(clientCommands
209
+ // prop → getItems → filterGatedClientCommands)必须原样保留模型/权限两项。
210
+ it("/ 菜单零回归:+ 菜单收敛后仍含 模型 与 权限(门控照旧)", async () => {
211
+ // harness 客户端门控开(permissionEnabled = isHarnessClientEnabled() && entitlement)
212
+ vi.stubEnv("VITE_HARNESS_DEV", "1")
213
+ setup({ prefill: "/", models: ["gpt-4o"], openFilePicker: vi.fn() })
214
+ const listbox = await screen.findByRole("listbox", {}, { timeout: 3000 })
215
+ await waitFor(() => expect(listbox.textContent).toContain("清空输入"))
216
+ expect(listbox.textContent).toContain("模型")
217
+ expect(listbox.textContent).toContain("权限")
218
+ })
219
+
220
+ it("全角触发回归:prefill / → 命令菜单开(清空输入在列)", async () => {
221
+ setup({ prefill: "/" })
222
+ const textbox = getEditorDom()
223
+ expect(textbox.textContent).toBe("/")
224
+ // createFullWidthFindSuggestionMatch("/") 变体 ["/", "/"] → 全角命中同一命令菜单
225
+ const listbox = await screen.findByRole("listbox", {}, { timeout: 3000 })
226
+ await waitFor(() => expect(listbox.textContent).toContain("清空输入"))
227
+ })
228
+
229
+ it("全角触发回归:prefill @ → @ 菜单开(mention 浮层挂载)", async () => {
230
+ setup({ prefill: "@" })
231
+ const textbox = getEditorDom()
232
+ expect(textbox.textContent).toBe("@")
233
+ // 本文件 mention 源 mock 为空 + 测试 env harness 门控关(file 源恒空)→ 无候选行,
234
+ // 但 SuggestionMenu 浮层容器(char='@' 插件)已挂载 = 菜单开(createFullWidthFindSuggestionMatch
235
+ // ("@") 变体 ["@", "@"] → 全角命中同一 mention 插件实例)
236
+ const container = await waitFor(
237
+ () => {
238
+ const el = document.querySelector<HTMLElement>(
239
+ '[data-selector="tiptap-mention-suggestion-menu"]',
240
+ )
241
+ if (!el) throw new Error("@ 菜单浮层未挂载")
242
+ return el
243
+ },
244
+ { timeout: 3000 },
245
+ )
246
+ expect(container.getAttribute("role")).toBe("listbox")
247
+ })
248
+
249
+ it("空查询分节:组头「添加」在前,「指令」组含清空输入(组头恒显)", async () => {
250
+ setup({ prefill: "/", openFilePicker: vi.fn() })
251
+ const listbox = await screen.findByRole("listbox", {}, { timeout: 3000 })
252
+ await waitFor(() => expect(listbox.textContent).toContain("清空输入"))
253
+ // 组头恒显:添加(/file)+ 指令(清空输入)两段;client 组排最前 → 添加组置顶
254
+ const addHeaders = await screen.findAllByText("添加")
255
+ const cmdHeaders = await screen.findAllByText("指令")
256
+ expect(addHeaders.length).toBeGreaterThan(0)
257
+ expect(cmdHeaders.length).toBeGreaterThan(0)
258
+ const first = addHeaders[0].compareDocumentPosition(cmdHeaders[0])
259
+ // Node.DOCUMENT_POSITION_FOLLOWING (4):指令组头在添加组头之后
260
+ expect(first & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy()
261
+ })
262
+
263
+ /**
264
+ * card-top 卡片锚定端到端(DSH 对标,任务 A):ComposerEditor 经 editor.view.dom
265
+ * closest 求锚(InputGroup 根)→ 两菜单 attachMode="card-top" → floating size apply
266
+ * 写入同宽 width。jsdom rect 全零(width 值可为 "0px")——断言「style.width 被写入 +
267
+ * 浮层在卡片子树内」这一行为,定位数值属浏览器视觉验证范畴。
268
+ */
269
+ it("card-top(@ 菜单):浮层挂在输入框卡片子树内且 style.width 被写入", async () => {
270
+ setup({ prefill: "@" })
271
+ const menu = await waitFor(
272
+ () => {
273
+ const el = document.querySelector<HTMLElement>(
274
+ '[data-selector="tiptap-mention-suggestion-menu"]',
275
+ )
276
+ if (!el) throw new Error("@ 菜单浮层未挂载")
277
+ return el
278
+ },
279
+ { timeout: 3000 },
280
+ )
281
+ // 浮层渲染在组件树原位(非 portal):必在卡片(InputGroup)子树内
282
+ expect(menu.closest('[data-slot="input-group"]')).not.toBeNull()
283
+ // card-top 的 size apply 已执行:同宽 width 被写入(rects 全零 → "0px" 合法)
284
+ await waitFor(() => expect(menu.style.width).toMatch(/px$/), { timeout: 3000 })
285
+ })
286
+
287
+ it("card-top('/' 菜单):浮层挂在输入框卡片子树内且 style.width 被写入", async () => {
288
+ setup({ prefill: "/" })
289
+ const menu = await waitFor(
290
+ () => {
291
+ const el = document.querySelector<HTMLElement>(
292
+ '[data-selector="tiptap-command-suggestion-menu"]',
293
+ )
294
+ if (!el) throw new Error("'/' 菜单浮层未挂载")
295
+ return el
296
+ },
297
+ { timeout: 3000 },
298
+ )
299
+ expect(menu.closest('[data-slot="input-group"]')).not.toBeNull()
300
+ await waitFor(() => expect(menu.style.width).toMatch(/px$/), { timeout: 3000 })
301
+ })