@allbluecn/web-app 0.27.41 → 0.28.1

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 (342) hide show
  1. package/package.json +4 -3
  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 +46 -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-chat-adapter.test.ts +20 -0
  242. package/src/components/harness/conversation-panel/messages/harness-chain/__tests__/use-harness-session-putmedia.test.tsx +17 -0
  243. package/src/components/harness/conversation-panel/messages/harness-chain/use-agent-terminals.ts +116 -0
  244. package/src/components/harness/conversation-panel/messages/harness-chain/use-harness-chat-adapter.ts +43 -11
  245. package/src/components/harness/conversation-panel/messages/harness-chain/use-harness-session.ts +25 -4
  246. package/src/components/harness/conversation-panel/messages/tools/__tests__/tool-run.test.ts +26 -1
  247. package/src/components/harness/conversation-panel/messages/tools/tool-run.ts +11 -0
  248. package/src/components/harness/extension-panel/dock/__tests__/dock-persist.test.ts +2 -1
  249. package/src/components/harness/extension-panel/dock/__tests__/guide-page.test.tsx +44 -3
  250. package/src/components/harness/extension-panel/dock/__tests__/tab-strip.test.tsx +45 -0
  251. package/src/components/harness/extension-panel/dock/dock-persist.ts +6 -4
  252. package/src/components/harness/extension-panel/dock/dock-registry.ts +69 -14
  253. package/src/components/harness/extension-panel/dock/dock-surface.tsx +35 -0
  254. package/src/components/harness/extension-panel/dock/guide-page.tsx +78 -45
  255. package/src/components/harness/extension-panel/dock/tab-strip.tsx +9 -1
  256. package/src/components/harness/extension-panel/panels/plugin/__tests__/install-dialog.test.tsx +260 -0
  257. package/src/components/harness/extension-panel/panels/plugin/__tests__/plugin-page.test.tsx +912 -0
  258. package/src/components/harness/extension-panel/panels/plugin/__tests__/plugin-row.test.tsx +215 -0
  259. package/src/components/harness/extension-panel/panels/plugin/builtin-section.tsx +204 -0
  260. package/src/components/harness/extension-panel/panels/plugin/install-dialog.tsx +195 -0
  261. package/src/components/harness/extension-panel/panels/plugin/installed-section.tsx +378 -0
  262. package/src/components/harness/extension-panel/panels/plugin/kind.tsx +17 -4
  263. package/src/components/harness/extension-panel/panels/plugin/pending-builds-block.tsx +49 -0
  264. package/src/components/harness/extension-panel/panels/plugin/plugin-page.tsx +257 -0
  265. package/src/components/harness/extension-panel/panels/plugin/plugin-row.tsx +206 -0
  266. package/src/components/harness/extension-panel/panels/plugin/plugin-types.ts +13 -0
  267. package/src/components/harness/extension-panel/panels/plugin/worker-section.tsx +322 -0
  268. package/src/components/harness/extension-panel/panels/terminal/__tests__/kind.test.tsx +219 -2
  269. package/src/components/harness/extension-panel/panels/terminal/__tests__/terminal-instance.test.tsx +322 -19
  270. package/src/components/harness/extension-panel/panels/terminal/__tests__/use-agent-terminal-roster.test.tsx +393 -0
  271. package/src/components/harness/extension-panel/panels/terminal/__tests__/ws-transport.test.ts +25 -0
  272. package/src/components/harness/extension-panel/panels/terminal/kind.tsx +55 -1
  273. package/src/components/harness/extension-panel/panels/terminal/shell-pref.ts +7 -4
  274. package/src/components/harness/extension-panel/panels/terminal/sse-transport.ts +26 -6
  275. package/src/components/harness/extension-panel/panels/terminal/tab-control-state.tsx +114 -0
  276. package/src/components/harness/extension-panel/panels/terminal/terminal-instance.tsx +190 -96
  277. package/src/components/harness/extension-panel/panels/terminal/terminal-theme.ts +113 -0
  278. package/src/components/harness/extension-panel/panels/terminal/transport.ts +28 -6
  279. package/src/components/harness/extension-panel/panels/terminal/use-agent-terminal-roster.ts +107 -0
  280. package/src/components/harness/extension-panel/panels/terminal/ws-transport.ts +7 -5
  281. package/src/components/harness/extension-panel/panels/terminal/xterm-terminal.tsx +5 -67
  282. package/src/components/harness/workbench/__tests__/provider-model-groups.test.ts +301 -0
  283. package/src/components/harness/workbench/harness-workbench-page.tsx +164 -2
  284. package/src/components/harness/workbench/provider-model-groups.ts +140 -0
  285. package/src/components/harness/workbench/undo-last-turn.ts +79 -0
  286. package/src/components/harness/workbench/workbench-context.tsx +53 -3
  287. package/src/components/tiptap/hooks/__tests__/use-floating-element.test.tsx +131 -0
  288. package/src/components/tiptap/hooks/use-floating-element.ts +15 -2
  289. package/src/components/tiptap/hooks/use-menu-navigation.ts +5 -0
  290. package/src/components/tiptap/node/mention-extension.ts +33 -0
  291. package/src/components/tiptap/ui/suggestion-menu/__tests__/suggestion-menu.test.tsx +366 -0
  292. package/src/components/tiptap/ui/suggestion-menu/suggestion-menu-types.ts +54 -0
  293. package/src/components/tiptap/ui/suggestion-menu/suggestion-menu.tsx +176 -45
  294. package/src/lib/changelog/sdk-versions.ts +2 -2
  295. package/src/lib/queries/__tests__/harness-plugin-queries.test.ts +49 -0
  296. package/src/lib/queries/harness-terminal.ts +77 -0
  297. package/src/lib/queries/harness.ts +50 -0
  298. package/src/paraglide/messages/_index.js +1622 -311
  299. package/src/paraglide/messages/en.js +528 -103
  300. package/src/paraglide/messages/zh.js +529 -104
  301. package/src/routes/_nav/harness/route.lazy.tsx +13 -0
  302. package/src/routes/api/harness/$.ts +19 -2
  303. package/src/routes/api/harness/terminal/$.ts +37 -6
  304. package/src/routes/api/harness/terminal/__tests__/route.test.ts +120 -0
  305. package/src/server/ai-gateway/sandbox/policy.ts +6 -6
  306. package/src/server/harness/__tests__/agent-terminal.server.test.ts +448 -0
  307. package/src/server/harness/__tests__/builtin-tools-invariant.test.ts +22 -12
  308. package/src/server/harness/__tests__/compact-plugin.server.test.ts +46 -0
  309. package/src/server/harness/__tests__/define-expose.test.ts +17 -0
  310. package/src/server/harness/__tests__/first-contact-fakes.test.ts +103 -3
  311. package/src/server/harness/__tests__/terminal-manager.server.test.ts +761 -2
  312. package/src/server/harness/__tests__/thread-reference.server.test.ts +258 -0
  313. package/src/server/harness/agent-terminal.server.ts +631 -0
  314. package/src/server/harness/define.server.ts +21 -3
  315. package/src/server/harness/first-contact-fakes.ts +115 -4
  316. package/src/server/harness/host.server.ts +28 -1
  317. package/src/server/harness/persistence/__tests__/session-index-store.server.test.ts +83 -0
  318. package/src/server/harness/persistence/prisma-persistence.server.ts +12 -3
  319. package/src/server/harness/persistence/session-index-store.server.ts +26 -0
  320. package/src/server/harness/plugins/__tests__/assemble-disable.test.ts +25 -17
  321. package/src/server/harness/plugins/__tests__/tool-risk-audit.test.ts +16 -6
  322. package/src/server/harness/plugins/assemble-app.ts +12 -0
  323. package/src/server/harness/plugins/base-patch.ts +9 -2
  324. package/src/server/harness/plugins/builtin/__tests__/agent-terminal.plugin.test.ts +702 -0
  325. package/src/server/harness/plugins/builtin/agent-terminal.plugin.ts +518 -0
  326. package/src/server/harness/terminal-frame-builder.server.ts +5 -3
  327. package/src/server/harness/terminal-manager.server.ts +772 -35
  328. package/src/server/harness/terminal-ws-handler.server.ts +8 -2
  329. package/src/server/harness/thread-reference.server.ts +446 -0
  330. package/src/server/harness/tool-risk.ts +20 -4
  331. package/src/server/serverFns/chat/__tests__/conversations-sandbox-default.test.ts +23 -0
  332. package/src/server/serverFns/chat/conversations.ts +18 -3
  333. package/src/server/serverFns/harness/search-mention-candidates.ts +14 -1
  334. package/src/shared/harness/__tests__/thread-reference-format.test.ts +128 -0
  335. package/src/shared/harness/thread-reference-format.ts +98 -0
  336. package/LICENSE +0 -661
  337. package/src/components/agents/slash-skill-menu.tsx +0 -75
  338. package/src/components/harness/conversation-panel/composer/extension/__tests__/demo-story-reference.test.tsx +0 -177
  339. package/src/components/harness/conversation-panel/composer/extension/demo-story-reference.tsx +0 -227
  340. package/src/components/harness/conversation-panel/composer/plugin-mention-menu.tsx +0 -109
  341. package/src/components/harness/extension-panel/panels/plugin-panel.tsx +0 -1021
  342. package/src/components/harness/extension-panel/panels/terminal/__tests__/xterm-webgl.test.ts +0 -68
@@ -25,6 +25,7 @@ import { describe, expect, it, vi } from "vitest"
25
25
  import { createBuiltinMentionSource, insertMentionCandidateChip } from "../mention-trigger-source"
26
26
  import type { MentionCandidate } from "../mention-resolvers"
27
27
  import type { InputTriggerSource, TriggerCandidate } from "../../extension"
28
+ import { m } from "@/paraglide/messages.js"
28
29
 
29
30
  /** 内置源 candidates 实际同步返回(接口面为 union),测试内收窄 */
30
31
  function syncCandidates(source: InputTriggerSource, query: string): TriggerCandidate[] {
@@ -70,27 +71,40 @@ describe("createBuiltinMentionSource(@ 内置源)", () => {
70
71
  expect(syncCandidates(source, "")).toEqual([])
71
72
  })
72
73
 
73
- it("候选映射:kb-doc 携带 kbName 分组与 kbId 负载,design 用语义标签", () => {
74
+ it("候选映射:kb 分组=知识库文档、副文本=库名+工作空间;design 分组=设计、无工作空间副文本缺省", () => {
74
75
  const source = createBuiltinMentionSource(() => [kbDoc(), design()])
75
76
  expect(syncCandidates(source, "")).toEqual([
76
77
  {
77
78
  id: "doc-1",
78
79
  label: "KB doc alpha",
79
80
  kind: "kb-doc",
80
- group: "测试知识库",
81
- subtext: expect.any(String),
81
+ // 用户裁决 2026-11-21:kb 分组固定「知识库文档」(不再按库名分组),副文本=
82
+ // 知识库名+加入的工作空间(未加入仅库名)
83
+ group: m.harness_mention_kb_doc(),
84
+ subtext: "测试知识库",
82
85
  data: { kbId: "kb-1", kbName: "测试知识库" },
83
86
  },
84
87
  {
85
88
  id: "d-1",
86
89
  label: "Design alpha",
87
90
  kind: "design",
88
- group: expect.any(String),
89
- subtext: expect.any(String),
91
+ group: m.harness_mention_prd(),
92
+ // design 数据模型暂无工作空间关联 → 副文本缺省(显示通路先立)
93
+ subtext: undefined,
90
94
  },
91
95
  ])
92
96
  })
93
97
 
98
+ it("kb 副文本拼接:知识库名 · 加入的工作空间(多空间序;未加入仅库名)", () => {
99
+ const source = createBuiltinMentionSource(() => [
100
+ kbDoc({ id: "doc-ws", kbName: "团队库", workspaceNames: ["工作空间 A", "工作空间 B"] }),
101
+ kbDoc({ id: "doc-nows", kbName: "个人库", workspaceNames: [] }),
102
+ ])
103
+ const items = syncCandidates(source, "")
104
+ expect(items[0].subtext).toBe("团队库 · 工作空间 A · 工作空间 B")
105
+ expect(items[1].subtext).toBe("个人库")
106
+ })
107
+
94
108
  it("查询过滤:label 包含匹配(trim + 大小写不敏感),kb-doc 在前 design 在后", () => {
95
109
  const source = createBuiltinMentionSource(() => [
96
110
  kbDoc({ id: "doc-2", label: "Beta doc", kbId: "kb-2", kbName: undefined }),
@@ -106,13 +120,26 @@ describe("createBuiltinMentionSource(@ 内置源)", () => {
106
120
  expect(beta[0].group).not.toBe("测试知识库")
107
121
  })
108
122
 
109
- it("只放行 kb-doc / design(file/story 等分组类型不出候选,防御口径保留)", () => {
123
+ it("放行 kb-doc / design / thread / story(file/plugin-tool 分组不出候选,防御口径保留;story 放行 = P1 任务 5 转正)", () => {
110
124
  const source = createBuiltinMentionSource(() => [
111
- { kind: "story", id: "s-1", label: "Story alpha" } as MentionCandidate,
125
+ { kind: "story", id: "s-1", label: "Story alpha" },
126
+ { kind: "file", id: "f-1", label: "src/app.ts" },
112
127
  kbDoc(),
113
128
  ])
114
- expect(syncCandidates(source, "")).toHaveLength(1)
115
- expect(syncCandidates(source, "")[0].kind).toBe("kb-doc")
129
+ const items = syncCandidates(source, "")
130
+ // file 不放行(生产 file 候选来自 file-mention.ts 菜单层聚合,非数据面)
131
+ expect(items.map((c) => c.kind)).toEqual(["kb-doc", "story"])
132
+ // story 放行(P1 任务 5):group 需求组 + data.id 承载 story 主键(onPick →
133
+ // insertMentionCandidateChip 的 story 分支写 attrs.id);mention 数据面无 story
134
+ // 生产者,此为防御面透传
135
+ expect(items[1]).toMatchObject({
136
+ id: "s-1",
137
+ label: "Story alpha",
138
+ kind: "story",
139
+ group: m.harness_mention_storyGroup(),
140
+ subtext: m.harness_mention_storyGroup(),
141
+ data: { id: "s-1" },
142
+ })
116
143
  })
117
144
 
118
145
  it("live getter:candidates 每次调用读最新数据(源对象稳定,数据更新不重注册)", () => {
@@ -125,6 +152,22 @@ describe("createBuiltinMentionSource(@ 内置源)", () => {
125
152
  })
126
153
  })
127
154
 
155
+ describe("createBuiltinMentionSource fuzzy 过滤(子序列打分)", () => {
156
+ it("子序列命中:query '需评' 命中 label '需求评审'(需→评按序)", () => {
157
+ const source = createBuiltinMentionSource(() => [
158
+ kbDoc({ id: "doc-fz", label: "需求评审", kbId: "kb-fz", kbName: "测试库" }),
159
+ ])
160
+ expect(syncCandidates(source, "需评").map((c) => c.id)).toEqual(["doc-fz"])
161
+ })
162
+
163
+ it("顺序敏感:query '评需' 不命中 label '需求评审'(评在需后,顺序逆)", () => {
164
+ const source = createBuiltinMentionSource(() => [
165
+ kbDoc({ id: "doc-fz", label: "需求评审", kbId: "kb-fz", kbName: "测试库" }),
166
+ ])
167
+ expect(syncCandidates(source, "评需")).toEqual([])
168
+ })
169
+ })
170
+
128
171
  describe("insertMentionCandidateChip(onPick 通道)", () => {
129
172
  it("attrs 与迁移前 handleSelect 逐字段一致:docType kb-doc→doc、kbId 走 schema 级键", () => {
130
173
  const { editor, insertContentAt } = makeEditorSpy()
@@ -0,0 +1,356 @@
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
+ * @story 需求提及源测试(P1 任务 5,demo 需求引用扩展转正):
20
+ * - 纯逻辑 describe:storyMentionCandidates 候选形状(id 'story:'+id / kind 'story' /
21
+ * label `${identifier} ${title}` / group 需求组 / subtext identifier / data{id})、
22
+ * fuzzy 过滤(identifier 段命中 + 子序列命中 + 无命中空 + 空 query 全量)、
23
+ * 抛错 fail-closed(不 rethrow)、signal 透传、**无 gating**(gate 关仍出候选——
24
+ * 用户级 serverFn 双链可用,区别于 file/thread 的 gate 守卫);
25
+ * - 集成 describe:真实 TipTap 渲染 composer,断言「需求」组出现(组序
26
+ * file→thread→story→kb/design)、空 query 服务端返回即首屏(serverFn query:""
27
+ * 直调,不建 queryOptions)、fuzzy 菜单层过滤(键入查询只留命中)、选中插 chip
28
+ * (attrs id=story id 本身——'story:' 前缀不进 attrs.id / docType 'story' /
29
+ * 尾随空格 + renderText 字面 `@ALL-123 登录页支持验证码`——story chip 无
30
+ * path/threadId 落 mention-extension 兜底序列化 `@${label}`)。
31
+ *
32
+ * mock 组合照 thread-mention.test.tsx(hoisted gateState + serverFn 整模块 mock +
33
+ * 全新 QueryClient);story serverFn mock 照 thread/file 手法(subpath 整模块 mock,
34
+ * 仅 story-mention.ts 消费该 subpath);i18n 断言一律对 m.* 解析值(locale 无关)。
35
+ */
36
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"
37
+ import { cleanup, fireEvent, render, waitFor } from "@testing-library/react"
38
+ import type { Editor } from "@tiptap/core"
39
+ import type { JSONContent } from "@tiptap/core"
40
+
41
+ import { HarnessComposer } from "../../harness-composer"
42
+ import { ComposerEditor } from "../../composer-editor"
43
+ import { clearComposerExtensions } from "../../extension"
44
+ import { storyMentionCandidates } from "../story-mention"
45
+ import { getQueryClient, setQueryClient } from "@/lib/query-client-seam"
46
+ import { QueryClient } from "@tanstack/react-query"
47
+ import { m } from "@/paraglide/messages.js"
48
+
49
+ // ── hoisted 可变 mock 状态(gate 开关)──
50
+ const gateState = vi.hoisted(() => ({ enabled: true }))
51
+
52
+ vi.mock("@/lib/harness-gate", () => ({
53
+ isHarnessClientEnabled: () => gateState.enabled,
54
+ }))
55
+ vi.mock("@/server/serverFns/story/story-search", () => ({
56
+ searchStoriesFn: vi.fn(),
57
+ reorderStoriesFn: vi.fn(),
58
+ }))
59
+ vi.mock("@/server/serverFns/harness/workspace-threads", () => ({
60
+ listHarnessWorkspacesWithThreadsFn: vi.fn(),
61
+ setThreadPinnedFn: vi.fn(),
62
+ getWorkspaceRootStatusFn: vi.fn(),
63
+ }))
64
+ vi.mock("@/server/serverFns/harness/thread-workspace-search", () => ({
65
+ searchThreadWorkspaceFilesFn: vi.fn(),
66
+ }))
67
+ vi.mock("@/server/serverFns/harness/thread-workspace-files", () => ({
68
+ listThreadWorkspaceDirFn: vi.fn(),
69
+ }))
70
+ vi.mock("@/server/serverFns/harness/media", () => ({ generatePrototypeFn: vi.fn(() => Promise.resolve({})) }))
71
+ vi.mock("../../voice-input-button", () => ({ VoiceInputButton: () => null }))
72
+ vi.mock("@/components/billing/use-feature", () => ({ useFeature: () => ({ enabled: true, loading: false }) }))
73
+ vi.mock("../use-mention-sources", () => ({
74
+ useMentionSources: () => ({
75
+ all: [
76
+ { kind: "kb-doc", id: "doc-1", label: "KB doc alpha", kbId: "kb-1", kbName: "测试知识库" },
77
+ ],
78
+ isLoading: false,
79
+ }),
80
+ }))
81
+
82
+ import { searchStoriesFn } from "@/server/serverFns/story/story-search"
83
+ import { listHarnessWorkspacesWithThreadsFn as listWsFn } from "@/server/serverFns/harness/workspace-threads"
84
+ import { listThreadWorkspaceDirFn as listDirFn } from "@/server/serverFns/harness/thread-workspace-files"
85
+
86
+ const searchMock = vi.mocked(searchStoriesFn)
87
+ const listWsMock = vi.mocked(listWsFn)
88
+ const listDirMock = vi.mocked(listDirFn)
89
+
90
+ /** story serverFn 命中夹具(服务端 take 10 已限,客户端不再截断)。 */
91
+ const STORIES = [
92
+ { id: "st-1", title: "登录页支持验证码", identifier: "ALL-123" },
93
+ { id: "st-2", title: "重构 prompt 输入", identifier: "ALL-456" },
94
+ { id: "st-3", title: "导出 PDF", identifier: "ALL-789" },
95
+ ]
96
+
97
+ /** 会话投影夹具(thread 源组序断言用;服务端 updatedAt desc 序)。 */
98
+ const SESSIONS = [
99
+ { id: "t-1", title: "调试登录态", workspaceId: null, engine: "local" as const, isArchived: false, pinned: false, lastMessageAt: "2026-11-20T00:00:00.000Z", messageCount: 1, statusPoint: "completed" as const },
100
+ { id: "t-2", title: "联调协作服务", workspaceId: null, engine: "cloud" as const, isArchived: false, pinned: false, lastMessageAt: "2026-11-20T01:00:00.000Z", messageCount: 2, statusPoint: "completed" as const },
101
+ ]
102
+
103
+ const EMPTY_DIR = { entries: [], truncated: false }
104
+
105
+ beforeEach(() => {
106
+ sessionStorage.clear()
107
+ gateState.enabled = true
108
+ searchMock.mockReset()
109
+ searchMock.mockResolvedValue(STORIES)
110
+ listWsMock.mockReset()
111
+ listWsMock.mockResolvedValue({ workspaces: [], sessions: SESSIONS })
112
+ listDirMock.mockReset()
113
+ listDirMock.mockResolvedValue(EMPTY_DIR)
114
+ // 全新 QueryClient:避免跨测试 thread-workspaces / 目录 listing 缓存串染
115
+ setQueryClient(new QueryClient())
116
+ })
117
+ afterEach(() => {
118
+ cleanup()
119
+ clearComposerExtensions()
120
+ getQueryClient().clear()
121
+ })
122
+
123
+ function getEditorDom(): HTMLElement {
124
+ const el = document.querySelector<HTMLElement>(".tiptap.ProseMirror")
125
+ if (!el) throw new Error("TipTap 编辑器 DOM 未挂载")
126
+ return el
127
+ }
128
+
129
+ function getMenuView(): HTMLElement {
130
+ const el = document.querySelector<HTMLElement>(
131
+ '[data-selector="tiptap-mention-suggestion-menu"] [data-menu-view]',
132
+ )
133
+ if (!el) throw new Error("@ 菜单 MenuView 未挂载")
134
+ return el
135
+ }
136
+
137
+ function getOptions(menu: HTMLElement): HTMLElement[] {
138
+ return Array.from(menu.querySelectorAll<HTMLElement>('[role="option"]'))
139
+ }
140
+
141
+ function findMentionNodes(doc: JSONContent): JSONContent[] {
142
+ const found: JSONContent[] = []
143
+ const walk = (nodes: JSONContent[] | undefined) => {
144
+ for (const node of nodes ?? []) {
145
+ if (node.type === "mention") found.push(node)
146
+ if (Array.isArray(node.content)) walk(node.content)
147
+ }
148
+ }
149
+ walk(doc.content)
150
+ return found
151
+ }
152
+
153
+ // ═══════════════════════════════════════════════════════════════════
154
+ // 纯逻辑:storyMentionCandidates(候选映射 + 过滤 + fail-closed)
155
+ // ═══════════════════════════════════════════════════════════════════
156
+ describe("storyMentionCandidates(纯查询→候选映射)", () => {
157
+ it("候选形状:kind 'story'、id 'story:'+id、label `${identifier} ${title}`、group 需求组、subtext identifier、data{id}", async () => {
158
+ const res = await storyMentionCandidates({ query: "", getStories: () => STORIES })
159
+ expect(res.map((c) => c.id)).toEqual(["story:st-1", "story:st-2", "story:st-3"])
160
+ expect(res[0]).toMatchObject({
161
+ id: "story:st-1",
162
+ label: "ALL-123 登录页支持验证码",
163
+ kind: "story",
164
+ group: m.harness_mention_storyGroup(),
165
+ subtext: "ALL-123",
166
+ data: { id: "st-1" },
167
+ })
168
+ })
169
+
170
+ it("fuzzy 过滤:identifier 段命中 + title includes 命中 + 子序列命中 + 无命中恒空", async () => {
171
+ // identifier 段命中(label 前缀 "ALL-789 导出 PDF" includes "789")
172
+ const byId = await storyMentionCandidates({ query: "789", getStories: () => STORIES })
173
+ expect(byId.map((c) => c.data?.id)).toEqual(["st-3"])
174
+ // title includes 命中
175
+ const byIncludes = await storyMentionCandidates({ query: "登录", getStories: () => STORIES })
176
+ expect(byIncludes.map((c) => c.data?.id)).toEqual(["st-1"])
177
+ // 子序列命中:'构pr' 命中 "ALL-456 重构 prompt 输入"(构→p→r 按序)
178
+ const byFuzzy = await storyMentionCandidates({ query: "构pr", getStories: () => STORIES })
179
+ expect(byFuzzy.map((c) => c.data?.id)).toEqual(["st-2"])
180
+ const none = await storyMentionCandidates({ query: "zzz", getStories: () => STORIES })
181
+ expect(none).toEqual([])
182
+ })
183
+
184
+ it("空 query 全量首屏(服务端 take 10 已限,客户端不再截断)", async () => {
185
+ const res = await storyMentionCandidates({ query: "", getStories: () => STORIES })
186
+ expect(res).toHaveLength(3)
187
+ })
188
+
189
+ it("getStories 抛错 → fail-closed 空数组(不 rethrow,插件对 items 抛错会清旧行)", async () => {
190
+ const res = await storyMentionCandidates({
191
+ query: "",
192
+ getStories: () => Promise.reject(new Error("boom")),
193
+ })
194
+ expect(res).toEqual([])
195
+ })
196
+
197
+ it("signal 透传 getStories(逐调用取消,省流量;正确性不依赖——插件对晚归 resolve 一律丢弃)", async () => {
198
+ const controller = new AbortController()
199
+ const getStories = vi.fn(async () => STORIES)
200
+ await storyMentionCandidates({ query: "登录", signal: controller.signal, getStories })
201
+ expect(getStories).toHaveBeenCalledWith("登录", controller.signal)
202
+ })
203
+
204
+ it("无 gating:gate false 仍出候选且 getter 照常调用(用户级 serverFn 双链可用,区别于 file/thread)", async () => {
205
+ gateState.enabled = false
206
+ const getStories = vi.fn(() => STORIES)
207
+ const res = await storyMentionCandidates({ query: "", getStories })
208
+ expect(res).toHaveLength(3)
209
+ expect(getStories).toHaveBeenCalledTimes(1)
210
+ })
211
+ })
212
+
213
+ // ═══════════════════════════════════════════════════════════════════
214
+ // 集成:真实 TipTap 渲染 composer
215
+ // ═══════════════════════════════════════════════════════════════════
216
+ describe("@story 需求提及源(集成)", () => {
217
+ it("story 组出现:组序 file→thread→story→kb/design;空 query 服务端返回即首屏", async () => {
218
+ listDirMock.mockResolvedValue({
219
+ entries: [
220
+ { name: "src", kind: "dir" as const },
221
+ { name: "README.md", kind: "file" as const },
222
+ ],
223
+ truncated: false,
224
+ })
225
+ const holder: { current: Editor | null } = { current: null }
226
+ render(
227
+ <ComposerEditor
228
+ threadId="t-1"
229
+ rawThreadId="t-1"
230
+ editable
231
+ onTextChange={() => {}}
232
+ editorRef={(e) => {
233
+ holder.current = e
234
+ }}
235
+ />,
236
+ )
237
+ await waitFor(() => expect(holder.current).not.toBeNull(), { timeout: 3000 })
238
+ holder.current!.commands.insertContent("@")
239
+ const menu = await waitFor(() => getMenuView(), { timeout: 3000 })
240
+ // story 候选出现(空 query → 服务端返回即首屏,全量 3 条)
241
+ await waitFor(() => expect(menu.textContent).toContain("ALL-123 登录页支持验证码"), { timeout: 3000 })
242
+ expect(menu.textContent).toContain("ALL-456 重构 prompt 输入")
243
+ expect(menu.textContent).toContain("ALL-789 导出 PDF")
244
+ expect(menu.textContent).toContain(m.harness_mention_storyGroup())
245
+ // 空 query 直调 serverFn(query:"" 首屏,不建 queryOptions)
246
+ expect(searchMock).toHaveBeenCalledWith(expect.objectContaining({ data: { query: "" } }))
247
+ // 组序:file → thread → story → kb
248
+ const text = menu.textContent ?? ""
249
+ expect(text.indexOf(m.harness_mention_fileGroup())).toBeLessThan(text.indexOf(m.harness_mention_threadGroup()))
250
+ expect(text.indexOf(m.harness_mention_threadGroup())).toBeLessThan(text.indexOf(m.harness_mention_storyGroup()))
251
+ expect(text.indexOf(m.harness_mention_storyGroup())).toBeLessThan(text.indexOf("测试知识库"))
252
+ })
253
+
254
+ it("fuzzy 菜单层过滤:键入查询只留命中需求(file/thread/kb 均无命中)", async () => {
255
+ const holder: { current: Editor | null } = { current: null }
256
+ render(
257
+ <ComposerEditor
258
+ threadId="t-1"
259
+ rawThreadId="t-1"
260
+ editable
261
+ onTextChange={() => {}}
262
+ editorRef={(e) => {
263
+ holder.current = e
264
+ }}
265
+ />,
266
+ )
267
+ await waitFor(() => expect(holder.current).not.toBeNull(), { timeout: 3000 })
268
+ const editor = holder.current!
269
+ editor.commands.insertContent("@")
270
+ const menu = await waitFor(() => getMenuView(), { timeout: 3000 })
271
+ // 键入查询(事务触发 suggestion 重算 query="验证码";jsdom 无真实键盘输入)。
272
+ // debounce=200:过滤态落定须等待——用「未命中项消失」做 waitFor 条件(contains
273
+ // 首屏即真,不能作过滤完成信号)。注意 thread t-1「调试登录态」因 rawThreadId
274
+ // 排除首屏即不在列,不能作标记;用 kb doc(空 query 在列、过滤后消失)。
275
+ editor.commands.insertContent("验证码")
276
+ await waitFor(
277
+ () => expect(menu.textContent).not.toContain("KB doc alpha"),
278
+ { timeout: 3000 },
279
+ )
280
+ // 命中需求在列;其他源无命中:thread 会话与 kb doc 均被过滤
281
+ expect(menu.textContent).toContain("ALL-123 登录页支持验证码")
282
+ expect(menu.textContent).not.toContain("联调协作服务")
283
+ expect(menu.textContent).not.toContain("ALL-456")
284
+ })
285
+
286
+ it("选中插 chip:attrs id=story id 本身('story:' 前缀不进 attrs.id)/ docType 'story' + 尾随空格 + renderText 字面", async () => {
287
+ const holder: { current: Editor | null } = { current: null }
288
+ render(
289
+ <ComposerEditor
290
+ threadId="t-1"
291
+ rawThreadId="t-1"
292
+ editable
293
+ onTextChange={() => {}}
294
+ editorRef={(e) => {
295
+ holder.current = e
296
+ }}
297
+ />,
298
+ )
299
+ await waitFor(() => expect(holder.current).not.toBeNull(), { timeout: 3000 })
300
+ const editor = holder.current!
301
+ editor.commands.insertContent("@")
302
+ const textbox = getEditorDom()
303
+ const menu = await waitFor(() => getMenuView(), { timeout: 3000 })
304
+ // 键入查询过滤到唯一 story 候选 → autoSelectFirstItem 使 Enter 必选中它。
305
+ // 等待过滤落定(唯一 option 且为命中需求)再 Enter——debounce 未落定 Enter 会
306
+ // 选中首屏首项(非 story 行)。
307
+ editor.commands.insertContent("验证码")
308
+ await waitFor(
309
+ () => {
310
+ const options = getOptions(menu)
311
+ expect(options).toHaveLength(1)
312
+ expect(options[0].textContent).toContain("ALL-123 登录页支持验证码")
313
+ },
314
+ { timeout: 3000 },
315
+ )
316
+ fireEvent.keyDown(textbox, { key: "Enter" })
317
+ // chip 插入 + 尾随空格(DOM 可见 @label 字面)
318
+ await waitFor(() => expect(textbox.textContent).toContain("@ALL-123 登录页支持验证码"), { timeout: 3000 })
319
+ const mentions = findMentionNodes(editor.getJSON())
320
+ expect(mentions).toHaveLength(1)
321
+ expect(mentions[0].attrs).toMatchObject({
322
+ id: "st-1",
323
+ label: "ALL-123 登录页支持验证码",
324
+ docType: "story",
325
+ })
326
+ // 'story:' 前缀不进 attrs.id(与 thread/file 候选键隔离同款)
327
+ expect(String(mentions[0].attrs?.id)).not.toContain("story:")
328
+ // renderText 字面(getText 经 renderText 序列化——无 path/threadId 落兜底 `@${label}`)+ 尾随空格
329
+ expect(editor.getText()).toBe("@ALL-123 登录页支持验证码 ")
330
+ })
331
+
332
+ it("双链可用:gate false(legacy 链)+ 空态 threadId=null → 需求组仍出现(无 threadId / gate 依赖)", async () => {
333
+ gateState.enabled = false
334
+ render(
335
+ <HarnessComposer
336
+ threadId={null}
337
+ isRunning={false}
338
+ hasAiKey
339
+ busyPreference="queue"
340
+ onSend={vi.fn()}
341
+ onStop={vi.fn()}
342
+ conversationRegionRef={{ current: null }}
343
+ messages={[]}
344
+ handoffPrefillText="@"
345
+ />,
346
+ )
347
+ const menu = await waitFor(() => getMenuView(), { timeout: 3000 })
348
+ await waitFor(() => expect(menu.textContent).toContain("ALL-123 登录页支持验证码"), { timeout: 3000 })
349
+ expect(menu.textContent).toContain(m.harness_mention_storyGroup())
350
+ // 用户级 serverFn 照常直调(无 gate 守卫——区别于 file/thread 的恒空 gating)
351
+ expect(searchMock).toHaveBeenCalledWith(expect.objectContaining({ data: { query: "" } }))
352
+ // gate 关 → file/thread 组恒空(对照:story 不受 gate 影响)
353
+ expect(menu.textContent).not.toContain(m.harness_mention_fileGroup())
354
+ expect(menu.textContent).not.toContain(m.harness_mention_threadGroup())
355
+ })
356
+ })