@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,131 @@
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
+ * useFloatingElement referenceOverride 通道(DSH 对标,任务 A):
20
+ *
21
+ * - **override 非 null → setReference 收到 override**(菜单钉锚元素而非光标
22
+ * decoration 节点——suggestion-menu card-top 模式的钩子面契约);
23
+ * - **缺省 undefined / 显式 null → 原逻辑**(caret 模式零变化锁:原 reference
24
+ * 原样进入 setReference,四 dropdown 消费方 + caret suggestion 菜单不受影响)。
25
+ *
26
+ * mock 边界:@floating-ui/react 的 useFloating 是行为黑盒(refs 内部 useRef 不外露),
27
+ * 单元契约「setReference 收到什么」只能经 hook 返回的 refs 观测——这里以受控 fake
28
+ * 替换该模块(useFloatingElement 的完整 import 面:autoUpdate/useFloating/
29
+ * useDismiss/useInteractions/useTransitionStyles),其余消费面(suggestion-menu.test、
30
+ * composer 级测试)仍跑真 floating-ui 验证行为。jsdom rect 全零,几何断言无意义,
31
+ * 故不在本文件断言坐标。
32
+ */
33
+ import { afterEach, describe, expect, it, vi } from "vitest"
34
+ import { cleanup, render } from "@testing-library/react"
35
+
36
+ const h = vi.hoisted(() => ({
37
+ /** useFloating 内部 refs 的观测面(fake 暴露) */
38
+ setReference: vi.fn(),
39
+ setFloating: vi.fn(),
40
+ }))
41
+
42
+ vi.mock("@floating-ui/react", () => ({
43
+ autoUpdate: vi.fn(() => () => {}),
44
+ useFloating: () => ({
45
+ refs: {
46
+ setReference: h.setReference,
47
+ setFloating: h.setFloating,
48
+ reference: { current: null },
49
+ floating: { current: null },
50
+ setPositionReference: vi.fn(),
51
+ },
52
+ context: {},
53
+ floatingStyles: {},
54
+ isPositioned: false,
55
+ update: vi.fn(),
56
+ placement: "bottom",
57
+ middlewareData: {},
58
+ elements: { reference: null, floating: null },
59
+ x: 0,
60
+ y: 0,
61
+ strategy: "absolute",
62
+ }),
63
+ useTransitionStyles: () => ({ isMounted: true, styles: {} }),
64
+ useDismiss: () => ({}),
65
+ useInteractions: () => ({
66
+ getReferenceProps: () => ({}),
67
+ getFloatingProps: () => ({}),
68
+ }),
69
+ }))
70
+
71
+ import { useFloatingElement } from "../use-floating-element"
72
+
73
+ /** 渲染探针:show=true 恒开,只驱动 reference 通道 */
74
+ function HookProbe({
75
+ reference,
76
+ referenceOverride,
77
+ }: {
78
+ reference: HTMLElement | DOMRect | (() => DOMRect | null) | null
79
+ referenceOverride?: HTMLElement | null
80
+ }) {
81
+ const { ref } = useFloatingElement(
82
+ true,
83
+ reference,
84
+ 1000,
85
+ { placement: "bottom-start" },
86
+ undefined,
87
+ referenceOverride,
88
+ )
89
+ return <div data-testid="floating" ref={ref} />
90
+ }
91
+
92
+ afterEach(() => {
93
+ cleanup()
94
+ h.setReference.mockClear()
95
+ h.setFloating.mockClear()
96
+ })
97
+
98
+ describe("useFloatingElement referenceOverride(card-top 通道)", () => {
99
+ it("1. 缺省(不传 override):setReference 收到原 reference(caret 零变化锁)", () => {
100
+ const decorationNode = document.createElement("div")
101
+ render(<HookProbe reference={decorationNode} />)
102
+ expect(h.setReference).toHaveBeenCalledWith(decorationNode)
103
+ })
104
+
105
+ it("2. override 非 null:setReference 收到 override(caret reference 被替换)", () => {
106
+ const decorationNode = document.createElement("div")
107
+ const anchor = document.createElement("div")
108
+ render(<HookProbe reference={decorationNode} referenceOverride={anchor} />)
109
+ const calls = h.setReference.mock.calls.map((c) => c[0])
110
+ expect(calls).toContain(anchor)
111
+ // override 生效窗口内不再喂 caret reference(替换语义,非补充)
112
+ const lastCall = calls[calls.length - 1]
113
+ expect(lastCall).toBe(anchor)
114
+ })
115
+
116
+ it("3. override 显式 null:回落原逻辑(收到原 reference)", () => {
117
+ const decorationNode = document.createElement("div")
118
+ render(<HookProbe reference={decorationNode} referenceOverride={null} />)
119
+ const calls = h.setReference.mock.calls.map((c) => c[0])
120
+ expect(calls).toContain(decorationNode)
121
+ expect(calls).not.toContain(null)
122
+ })
123
+
124
+ it("4. DOMRect reference(非 HTMLElement 分支)不受 override 缺省影响", () => {
125
+ const rect = new DOMRect(0, 0, 10, 20)
126
+ render(<HookProbe reference={rect} />)
127
+ // 原逻辑:非 HTMLElement 的 reference 包装为 { getBoundingClientRect }
128
+ const lastCall = h.setReference.mock.calls[h.setReference.mock.calls.length - 1][0]
129
+ expect(typeof (lastCall as { getBoundingClientRect: () => DOMRect }).getBoundingClientRect).toBe("function")
130
+ })
131
+ })
@@ -63,6 +63,10 @@ interface FloatingElementReturn {
63
63
  * @param referencePos - DOMRect, function returning DOMRect, or null representing the position to anchor the floating element to
64
64
  * @param zIndex - Z-index value for the floating element
65
65
  * @param options - Additional options to pass to the underlying useFloating hook
66
+ * @param referenceOverride - 可选 reference 替身(card-top 通道,DSH 对标):非 null 时
67
+ * 整体接管 reference(floating-ui 的 reference 不走 options,只能从 effect 通道替换);
68
+ * null/undefined = 走原逻辑,既有消费方(floating-element 四 dropdown + caret
69
+ * suggestion 菜单)零变化
66
70
  * @returns Object containing properties and methods to control the floating element
67
71
  */
68
72
  export function useFloatingElement(
@@ -70,7 +74,8 @@ export function useFloatingElement(
70
74
  reference: HTMLElement | DOMRect | (() => DOMRect | null) | null,
71
75
  zIndex: number,
72
76
  options?: Partial<UseFloatingOptions & { dismissOptions?: UseDismissProps }>,
73
- autoUpdateOptions?: AutoUpdateOptions
77
+ autoUpdateOptions?: AutoUpdateOptions,
78
+ referenceOverride?: HTMLElement | null
74
79
  ): FloatingElementReturn {
75
80
  const { dismissOptions, ...floatingOptions } = options || {}
76
81
 
@@ -95,6 +100,14 @@ export function useFloatingElement(
95
100
  const { getReferenceProps, getFloatingProps } = useInteractions([dismiss])
96
101
 
97
102
  useEffect(() => {
103
+ // card-top 通道(DSH 对标):override 非 null 时整体接管 reference——菜单钉在
104
+ // 锚元素(如输入框卡片 InputGroup 根)而非光标 decoration 节点。null/undefined
105
+ // = 原逻辑(caret 模式零变化)。
106
+ if (referenceOverride != null) {
107
+ refs.setReference(referenceOverride)
108
+ return
109
+ }
110
+
98
111
  if (reference === null) {
99
112
  refs.setReference(null)
100
113
  return
@@ -116,7 +129,7 @@ export function useFloatingElement(
116
129
  refs.setReference({
117
130
  getBoundingClientRect,
118
131
  })
119
- }, [reference, refs])
132
+ }, [reference, referenceOverride, refs])
120
133
 
121
134
  return useMemo(
122
135
  () => ({
@@ -195,6 +195,11 @@ export function useMenuNavigation<T>({
195
195
  }
196
196
 
197
197
  if (targetElement) {
198
+ // T23 豁免(捕获相条件拦截):本监听是菜单导航键盘仲裁——挂在 editor.view.dom
199
+ // 捕获相、按菜单态(items/selectedIndex/tabSelects)条件拦截并 preventDefault
200
+ // Arrow/Tab/Home/End/Enter/Escape。官方 useHotkey/useAppHotkeys 表达不了该场景
201
+ // (需捕获相 + preventDefault + 运行时菜单态门控),故豁免「禁手写
202
+ // addEventListener('keydown')」规则;非全局热键声明,不入 appHotkeys registry。
198
203
  targetElement.addEventListener("keydown", handleKeyboardNavigation, true)
199
204
 
200
205
  return () => {
@@ -17,6 +17,7 @@
17
17
 
18
18
  import { Mention } from "@tiptap/extension-mention"
19
19
  import { docGroupIconKey } from "../lib/doc-group.ts"
20
+ import { formatThreadReference } from "@/shared/harness/thread-reference-format"
20
21
 
21
22
  const DOC_REF_SVG: Record<
22
23
  string,
@@ -91,6 +92,13 @@ export const MentionExtension = Mention.extend({
91
92
  // @知识库文档 chip 携带的知识库 id(harness 发送时收集进 knowledgeBaseIds);
92
93
  // parse/render 双向声明,保证复制粘贴 HTML 往返不丢
93
94
  kbId: { default: "", parseHTML: (el) => el.getAttribute("data-kb-id") || "" },
95
+ // @文件 chip 携带的工作区文件相对路径(@file 提及,任务 5 接入候选源);
96
+ // 同 kbId 双向声明,data-path 复制粘贴 HTML 往返不丢
97
+ path: { default: "", parseHTML: (el) => el.getAttribute("data-path") || "" },
98
+ // @会话 chip 携带的会话 id(@thread 提及,P1 任务 4 接入候选源);同 kbId/path
99
+ // 双向声明,data-thread-id 复制粘贴 HTML 往返不丢。collab-core KnowledgeMention
100
+ // renderHTML 与本分支逐字镜像(两仓镜像纪律)
101
+ threadId: { default: "", parseHTML: (el) => el.getAttribute("data-thread-id") || "" },
94
102
  color: { default: "", parseHTML: (el) => el.getAttribute("data-color") || "" },
95
103
  bgColor: { default: "", parseHTML: (el) => el.getAttribute("data-bg-color") || "" },
96
104
  }
@@ -148,6 +156,16 @@ export const MentionExtension = Mention.extend({
148
156
  "data-label": node.attrs.label,
149
157
  "data-mention-suggestion-char": char,
150
158
  "data-kb-id": node.attrs.kbId || "",
159
+ "data-path": node.attrs.path || "",
160
+ // @会话 chip:data-thread-id 双向声明配套(parse 读 data-thread-id),
161
+ // thread chip 复制粘贴/导出 HTML 往返不丢;collab-core KnowledgeMention
162
+ // renderHTML 与本分支逐字镜像(两仓镜像纪律)
163
+ "data-thread-id": node.attrs.threadId || "",
164
+ // docType 双向声明配套(parse 读 data-doc-type):@ 分支补 render 输出,
165
+ // design chip(docType="design" 非 default)复制粘贴/导出 HTML 往返不回落
166
+ // "doc";collab-core KnowledgeMention renderHTML 与本分支逐字镜像
167
+ // (两仓镜像纪律,整分支审查 finding 2)
168
+ "data-doc-type": node.attrs.docType || "doc",
151
169
  },
152
170
  `@${node.attrs.label || node.attrs.id}`,
153
171
  ]
@@ -156,6 +174,21 @@ export const MentionExtension = Mention.extend({
156
174
  renderText({ node }) {
157
175
  const char = node.attrs.mentionSuggestionChar || "@"
158
176
  if (char === "[") return `[[${node.attrs.label || node.attrs.id}]]`
177
+ // @会话 chip:序列化为 canonical 标记 `@[标题](allblue-thread:<id>)`(Phase 2),
178
+ // 供服务端 host 注入 middleware(T4)解析。格式单一来源
179
+ // shared/harness/thread-reference-format.ts(客户端 renderText 与服务端解析共用)。
180
+ // 发送后服务端就地改写为可读「参考会话《标题》」并随转录持久化——标记本身仅存于
181
+ // composer 草稿(发送前)。
182
+ const threadId = (node.attrs.threadId as string) || ""
183
+ if (threadId) {
184
+ return formatThreadReference({
185
+ id: threadId,
186
+ label: (node.attrs.label as string) || node.attrs.id || "",
187
+ })
188
+ }
189
+ // @文件 chip:按 path 序列化(含空白加引号包裹,保证 @path 边界清晰)
190
+ const path = (node.attrs.path as string) || ""
191
+ if (path) return /\s/.test(path) ? `@"${path}"` : `@${path}`
159
192
  return `@${node.attrs.label || node.attrs.id}`
160
193
  },
161
194
  })
@@ -0,0 +1,366 @@
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
+ * SuggestionMenu 机制升级(SWR / disabled / 高亮暴露 / IME / 无过度拦截)。
20
+ *
21
+ * 机制事实(已核 @tiptap/suggestion@3.31.3 dist):
22
+ * - fetch 前派发 onUpdate({loading:true, items: initialItems ?? []}),本组件不传
23
+ * initialItems → 恒 [];resolve 后派发 {loading:false, items:结果}。
24
+ *
25
+ * 审查修订(finding 1/2/3 → 移除全部 pending 拦截):
26
+ * - finding 1:曾用 view.dom 捕获阶段 preventDefault 兜底穿透,但真实浏览器 AT_TARGET
27
+ * 阶段按注册顺序触发监听器、capture 标志无效(PM 冒泡监听先注册先跑),jsdom 伪绿
28
+ * → 已移除该捕获拦截器。
29
+ * - finding 3:曾凭 pendingRef 一刀切拦截(onSelect 短路 + suggestion onKeyDown 拦
30
+ * Enter/Tab)。四消费方 items 同步但仍走 asyncRequest.fetch 进入 pending 微任务窗口 →
31
+ * 会吞掉「有候选 Enter 选中」(首次 Enter 不选中、需按第二次)。已移除 onSelect 短路,
32
+ * Enter 选中交回 useMenuNavigation(test 2 / test 6 锁定)。
33
+ * - finding 2:onKeyDown 拦截凭 pendingRef,会在退出路径搁浅 true 持续吞键。实测该
34
+ * onKeyDown 对 Enter 无效(ProseMirror someProp 链中 editorProps / StarterKit baseKeymap
35
+ * 先于 suggestion plugin,Enter 已被前置消费)、对 Tab 不可靠(空候选 pending 窗口内有
36
+ * onExit/定时器竞态复位 pendingRef)→ 连同 pendingRef 一并移除,finding 2 根源消除。
37
+ * - 残留边界:首载空候选 pending 期 Enter 仍穿透到外层提交 keymap,治本属消费方
38
+ * (composer keymap / useMenuNavigation 感知 pending)职责,不在本通用组件。
39
+ */
40
+ import { afterEach, describe, expect, it, vi } from "vitest"
41
+ import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react"
42
+ import { useEffect, useRef, useState } from "react"
43
+ import { Editor } from "@tiptap/core"
44
+ import StarterKit from "@tiptap/starter-kit"
45
+ import { SuggestionMenu } from "../suggestion-menu"
46
+ import type { SuggestionItem, SuggestionMenuRenderProps } from "../suggestion-menu-types"
47
+
48
+ type Item = SuggestionItem
49
+
50
+ /** items 回调签名(SuggestionMenu items prop 的可控子集:只消费 query) */
51
+ type ItemsFn = (props: { query: string }) => Item[] | Promise<Item[]>
52
+
53
+ /** 可控异步 items:每次 fetch 入队,测试按需 resolve */
54
+ function createAsyncItems() {
55
+ const pending: Array<{ query: string; resolve: (v: Item[]) => void }> = []
56
+ const items: ItemsFn = ({ query }) =>
57
+ new Promise((resolve) => {
58
+ pending.push({ query, resolve })
59
+ })
60
+ return { items, pending }
61
+ }
62
+
63
+ const row = (title: string): Item => ({ title, onSelect: vi.fn() })
64
+
65
+ interface ProbeHandle {
66
+ renderProps: SuggestionMenuRenderProps | null
67
+ editor: Editor | null
68
+ }
69
+
70
+ function MenuProbe({
71
+ handle,
72
+ items,
73
+ disabled,
74
+ onPendingChange,
75
+ noOpSelectWhilePending,
76
+ attachMode,
77
+ anchorElement,
78
+ }: {
79
+ handle: ProbeHandle
80
+ items: ItemsFn
81
+ disabled?: boolean
82
+ onPendingChange?: (pending: boolean) => void
83
+ noOpSelectWhilePending?: boolean
84
+ attachMode?: "caret" | "card-top"
85
+ anchorElement?: HTMLElement | null
86
+ }) {
87
+ const containerRef = useRef<HTMLDivElement>(null)
88
+ const handleRef = useRef(handle)
89
+ handleRef.current = handle
90
+ const [editor, setEditor] = useState<Editor | null>(null)
91
+
92
+ useEffect(() => {
93
+ if (!containerRef.current) return
94
+ const ed = new Editor({
95
+ element: containerRef.current,
96
+ extensions: [StarterKit],
97
+ // 镜像 composer 提交 keymap 的 IME 守卫净效果:isComposing Enter 既不提交也不换行
98
+ // (真实浏览器 PM composition 期不 splitBlock;jsdom 无 composition,否则 StarterKit
99
+ // baseKeymap 会插换行 → suggestion exit → 菜单关闭,IME 守卫断言失真)。消费之,
100
+ // 保持菜单开着。非 isComposing 键放行(返回 false),不影响其他用例。
101
+ editorProps: {
102
+ handleKeyDown: (_view, event) => {
103
+ if (event.isComposing) return true
104
+ return false
105
+ },
106
+ },
107
+ })
108
+ handleRef.current.editor = ed
109
+ setEditor(ed)
110
+ return () => ed.destroy()
111
+ }, [])
112
+
113
+ return (
114
+ <div>
115
+ <div ref={containerRef} data-testid="editor-host" />
116
+ {editor && (
117
+ <SuggestionMenu
118
+ editor={editor}
119
+ char="@"
120
+ pluginKey="probeMenu"
121
+ selector="probe-menu"
122
+ items={items}
123
+ autoSelectFirstItem={true}
124
+ disabled={disabled}
125
+ onPendingChange={onPendingChange}
126
+ noOpSelectWhilePending={noOpSelectWhilePending}
127
+ attachMode={attachMode}
128
+ anchorElement={anchorElement}
129
+ >
130
+ {(rp) => {
131
+ handle.renderProps = rp
132
+ return (
133
+ <ul>
134
+ {rp.items.map((it, i) => (
135
+ <li
136
+ key={it.title}
137
+ data-testid={`probe-item-${i}`}
138
+ data-title={it.title}
139
+ data-selected={i === rp.selectedIndex ? "true" : "false"}
140
+ onMouseMove={() => rp.setSelectedIndex?.(i)}
141
+ >
142
+ {it.title}
143
+ </li>
144
+ ))}
145
+ </ul>
146
+ )
147
+ }}
148
+ </SuggestionMenu>
149
+ )}
150
+ </div>
151
+ )
152
+ }
153
+
154
+ /** 渲染探针并返回稳定 handle + rerender(extra 透传新机制 props) */
155
+ function renderProbe(
156
+ items: ItemsFn,
157
+ disabled?: boolean,
158
+ extra?: {
159
+ onPendingChange?: (pending: boolean) => void
160
+ noOpSelectWhilePending?: boolean
161
+ attachMode?: "caret" | "card-top"
162
+ anchorElement?: HTMLElement | null
163
+ },
164
+ ) {
165
+ const handle: ProbeHandle = { renderProps: null, editor: null }
166
+ const view = render(<MenuProbe handle={handle} items={items} disabled={disabled} {...extra} />)
167
+ return { handle, rerender: (d?: boolean) => view.rerender(<MenuProbe handle={handle} items={items} disabled={d} {...extra} />) }
168
+ }
169
+
170
+ function getEditorDom(): HTMLElement {
171
+ const el = document.querySelector<HTMLElement>(".tiptap.ProseMirror")
172
+ if (!el) throw new Error("TipTap editor DOM not mounted")
173
+ return el
174
+ }
175
+
176
+ /** 等 editor 就绪 + 输入查询串(逐字 insertContent 触发 suggestion 事务) */
177
+ async function typeQuery(handle: ProbeHandle, text: string) {
178
+ await waitFor(() => expect(handle.editor).not.toBeNull())
179
+ handle.editor!.commands.focus()
180
+ handle.editor!.commands.insertContent(text)
181
+ }
182
+
183
+ afterEach(cleanup)
184
+
185
+ describe("SuggestionMenu 机制升级", () => {
186
+ it("1. SWR:pending 期保留旧行留屏(不闪空)", async () => {
187
+ const { items, pending } = createAsyncItems()
188
+ const { handle } = renderProbe(items)
189
+ await typeQuery(handle, "@a")
190
+ // 首个 fetch(query "a")resolve → 旧行上屏
191
+ await waitFor(() => expect(pending.length).toBeGreaterThanOrEqual(1))
192
+ pending[0].resolve([row("old-row")])
193
+ const listbox = await screen.findByRole("listbox", {}, { timeout: 3000 })
194
+ await waitFor(() => expect(listbox.textContent).toContain("old-row"))
195
+ // 改查询 "@ab" → 新 fetch(query "ab")入队且未 resolve(pending)
196
+ await typeQuery(handle, "b")
197
+ await waitFor(() => expect(pending.length).toBeGreaterThanOrEqual(2))
198
+ // SWR:pending 期菜单仍显示旧行(不因 loading=true 清空)
199
+ expect(screen.getByRole("listbox").textContent).toContain("old-row")
200
+ })
201
+
202
+ it("2. SWR pending 有旧行:Enter 选中当前旧行(finding 3:不再 no-op 吞掉)", async () => {
203
+ const { items, pending } = createAsyncItems()
204
+ const { handle } = renderProbe(items)
205
+ await typeQuery(handle, "@a")
206
+ await waitFor(() => expect(pending.length).toBeGreaterThanOrEqual(1))
207
+ const oldRow = row("old-row")
208
+ pending[0].resolve([oldRow])
209
+ const listbox = await screen.findByRole("listbox", {}, { timeout: 3000 })
210
+ await waitFor(() => expect(listbox.textContent).toContain("old-row"))
211
+ // 改查询 → 第二个 fetch pending(held),SWR 保留旧行、pendingRef=true
212
+ await typeQuery(handle, "b")
213
+ await waitFor(() => expect(pending.length).toBeGreaterThanOrEqual(2))
214
+ // pending + 有可选项 → Enter 照常选中当前旧行(有可选项时不拦截、onSelect 不短路)
215
+ fireEvent.keyDown(getEditorDom(), { key: "Enter" })
216
+ await waitFor(() => expect(oldRow.onSelect).toHaveBeenCalledTimes(1))
217
+ })
218
+
219
+ it("3. disabled=true → 菜单关闭", async () => {
220
+ const { items, pending } = createAsyncItems()
221
+ const { handle, rerender } = renderProbe(items)
222
+ await typeQuery(handle, "@a")
223
+ await waitFor(() => expect(pending.length).toBeGreaterThanOrEqual(1))
224
+ pending[0].resolve([row("old-row")])
225
+ await screen.findByRole("listbox", {}, { timeout: 3000 })
226
+ // disabled → 菜单立即关闭
227
+ rerender(true)
228
+ await waitFor(() => expect(screen.queryByRole("listbox")).toBeNull())
229
+ })
230
+
231
+ it("4. mousemove 驱动 setSelectedIndex(共享高亮)", async () => {
232
+ const { items, pending } = createAsyncItems()
233
+ const { handle } = renderProbe(items)
234
+ await typeQuery(handle, "@a")
235
+ await waitFor(() => expect(pending.length).toBeGreaterThanOrEqual(1))
236
+ pending[0].resolve([row("row-0"), row("row-1"), row("row-2")])
237
+ await screen.findByRole("listbox", {}, { timeout: 3000 })
238
+ // autoSelectFirstItem → 初始高亮 index 0
239
+ expect(handle.renderProps?.selectedIndex).toBe(0)
240
+ // mousemove 行 2 → setSelectedIndex(2) → 共享高亮更新
241
+ fireEvent.mouseMove(screen.getByTestId("probe-item-2"))
242
+ await waitFor(() => expect(screen.getByTestId("probe-item-2").getAttribute("data-selected")).toBe("true"))
243
+ expect(handle.renderProps?.selectedIndex).toBe(2)
244
+ })
245
+
246
+ it("5. isComposing 的 Enter 不选中(IME 守卫)", async () => {
247
+ const { items, pending } = createAsyncItems()
248
+ const { handle } = renderProbe(items)
249
+ await typeQuery(handle, "@a")
250
+ await waitFor(() => expect(pending.length).toBeGreaterThanOrEqual(1))
251
+ const r0 = row("row-0")
252
+ pending[0].resolve([r0])
253
+ await screen.findByRole("listbox", {}, { timeout: 3000 })
254
+ await waitFor(() => expect(screen.getByTestId("probe-item-0").getAttribute("data-selected")).toBe("true"))
255
+ // IME 组合期 Enter(isComposing=true):不选中(useMenuNavigation isComposing 守卫)
256
+ fireEvent.keyDown(getEditorDom(), { key: "Enter", isComposing: true })
257
+ expect(r0.onSelect).not.toHaveBeenCalled()
258
+ // 对照:非组合期 Enter → 选中首项
259
+ fireEvent.keyDown(getEditorDom(), { key: "Enter" })
260
+ await waitFor(() => expect(r0.onSelect).toHaveBeenCalled())
261
+ })
262
+
263
+ it("6. 四消费方 sync parity:pending 窗口有可选项时 Enter 照常选中(防过度拦截回归)", async () => {
264
+ // emoji/reference/mention/slash 同款同步 items:返回数组(插件仍走 asyncRequest.fetch
265
+ // → 进入 pending 微任务窗口)。若凭 pendingRef 一刀切拦截,此窗口 Enter 会被吞。
266
+ const r0 = row("row-0")
267
+ const r1 = row("row-1")
268
+ const items = vi.fn((): Item[] => [r0, r1])
269
+ const { handle } = renderProbe(items)
270
+ await typeQuery(handle, "@a")
271
+ const listbox = await screen.findByRole("listbox", {}, { timeout: 3000 })
272
+ await waitFor(() => expect(listbox.textContent).toContain("row-0"))
273
+ // 改查询 → 新 sync fetch(loading=true、pendingRef=true,SWR 保留 row-0/1)。
274
+ // Enter 应照常选中(有可选项时不拦截、onSelect 不短路),不被 pending 吞掉。
275
+ await typeQuery(handle, "b")
276
+ fireEvent.keyDown(getEditorDom(), { key: "Enter" })
277
+ await waitFor(() => expect(r0.onSelect).toHaveBeenCalled())
278
+ })
279
+
280
+ // 消费侧 pending 守卫配套机制(整分支审查 finding 1):组件只上报 pending
281
+ //(onPendingChange)+ 可选 noOpSelectWhilePending 短路;拦截本体在消费方
282
+ //(composer keymap isPending),见 harness composer-pending-guard.test.tsx。
283
+ it("7. onPendingChange 随取数窗口翻转上报(loading true→false)", async () => {
284
+ const { items, pending } = createAsyncItems()
285
+ const seen: boolean[] = []
286
+ const { handle } = renderProbe(items, undefined, {
287
+ onPendingChange: (p) => seen.push(p),
288
+ })
289
+ await typeQuery(handle, "@a")
290
+ await waitFor(() => expect(pending.length).toBeGreaterThanOrEqual(1))
291
+ // fetch 前派发 loading:true → 上报 true(去重:连发不重复)
292
+ await waitFor(() => expect(seen[0]).toBe(true))
293
+ pending[0].resolve([row("row-0")])
294
+ await screen.findByRole("listbox", {}, { timeout: 3000 })
295
+ // resolve → loading:false → 上报 false(窗口结束)
296
+ await waitFor(() => expect(seen).toContain(false))
297
+ expect(seen.filter((v) => v).length).toBe(1)
298
+ })
299
+
300
+ it("8. noOpSelectWhilePending(composer 显式启用):pending 期 Enter no-op、settle 后照常选中", async () => {
301
+ const { items, pending } = createAsyncItems()
302
+ const { handle } = renderProbe(items, undefined, { noOpSelectWhilePending: true })
303
+ await typeQuery(handle, "@a")
304
+ await waitFor(() => expect(pending.length).toBeGreaterThanOrEqual(1))
305
+ const oldRow = row("old-row")
306
+ pending[0].resolve([oldRow])
307
+ await screen.findByRole("listbox", {}, { timeout: 3000 })
308
+ await waitFor(() => expect(screen.getByRole("listbox").textContent).toContain("old-row"))
309
+ // 改查询 → 第二个 fetch pending(held),SWR 旧行留屏
310
+ await typeQuery(handle, "b")
311
+ await waitFor(() => expect(pending.length).toBeGreaterThanOrEqual(2))
312
+ // pending 期 Enter:短路(不选中旧行、菜单仍开——旧 T2 用例 2 语义)
313
+ fireEvent.keyDown(getEditorDom(), { key: "Enter" })
314
+ expect(oldRow.onSelect).not.toHaveBeenCalled()
315
+ expect(screen.queryByRole("listbox")).not.toBeNull()
316
+ // settle 后 Enter:门只在窗口内生效,选中照常(基线不被本机制改变)
317
+ pending[1].resolve([oldRow])
318
+ await waitFor(() => expect(pending.length).toBeGreaterThanOrEqual(2))
319
+ fireEvent.keyDown(getEditorDom(), { key: "Enter" })
320
+ await waitFor(() => expect(oldRow.onSelect).toHaveBeenCalledTimes(1))
321
+ })
322
+ })
323
+
324
+ /**
325
+ * attachMode card-top(DSH 对标,任务 A):菜单钉在 anchorElement(输入框卡片根,
326
+ * 如 InputGroup)上沿、与卡片同宽、不随光标移动。jsdom rect 全零 → 定位坐标不可
327
+ * 断言,行为面锁定为:
328
+ * - 菜单照常打开、条目可见(触发/渲染链路在 card-top 配置下不回归);
329
+ * - size apply 写入「同宽」style.width(值可为 "0px"——断言被写入这一行为而非数值);
330
+ * - caret 模式不写 width(零变化锁:既有消费方 floating 面原样)。
331
+ */
332
+ describe("SuggestionMenu attachMode card-top(DSH 对标)", () => {
333
+ it("9. card-top + anchorElement:菜单打开、条目可见,size apply 写入同宽 width", async () => {
334
+ const anchor = document.createElement("div")
335
+ const { items, pending } = createAsyncItems()
336
+ const { handle } = renderProbe(items, undefined, {
337
+ attachMode: "card-top",
338
+ anchorElement: anchor,
339
+ })
340
+ await typeQuery(handle, "@a")
341
+ await waitFor(() => expect(pending.length).toBeGreaterThanOrEqual(1))
342
+ pending[0].resolve([row("row-0")])
343
+ const listbox = await screen.findByRole("listbox", {}, { timeout: 3000 })
344
+ await waitFor(() => expect(listbox.textContent).toContain("row-0"))
345
+ const menu = document.querySelector<HTMLElement>('[data-selector="probe-menu"]')
346
+ expect(menu).not.toBeNull()
347
+ // 同宽行为锁:jsdom rects 全零(width 值可为 "0px"),断言「size apply 执行且
348
+ // 写入了 style.width」这一行为,而非具体数值
349
+ await waitFor(() => expect(menu!.style.width).toMatch(/px$/))
350
+ // maxHeight var 仍由 size apply 写入(消费面 MenuView 的 min(400, var) 逻辑不变)
351
+ expect(menu!.style.getPropertyValue("--suggestion-menu-max-height")).toMatch(/px$/)
352
+ })
353
+
354
+ it("10. caret 模式(缺省)不写 width(零变化锁)", async () => {
355
+ const { items, pending } = createAsyncItems()
356
+ const { handle } = renderProbe(items)
357
+ await typeQuery(handle, "@a")
358
+ await waitFor(() => expect(pending.length).toBeGreaterThanOrEqual(1))
359
+ pending[0].resolve([row("row-0")])
360
+ await screen.findByRole("listbox", {}, { timeout: 3000 })
361
+ const menu = document.querySelector<HTMLElement>('[data-selector="probe-menu"]')
362
+ expect(menu).not.toBeNull()
363
+ // caret 配置的 size apply 只写 maxHeight var,从不写 width
364
+ expect(menu!.style.width).toBe("")
365
+ })
366
+ })