@allbluecn/web-app 0.27.41 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (297) hide show
  1. package/package.json +1 -1
  2. package/public/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
  3. package/public/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
  4. package/public/pdfjs/cmaps/78-H.bcmap +0 -0
  5. package/public/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
  6. package/public/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
  7. package/public/pdfjs/cmaps/78-V.bcmap +0 -0
  8. package/public/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
  9. package/public/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
  10. package/public/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
  11. package/public/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
  12. package/public/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
  13. package/public/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
  14. package/public/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
  15. package/public/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
  16. package/public/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
  17. package/public/pdfjs/cmaps/Add-H.bcmap +0 -0
  18. package/public/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
  19. package/public/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
  20. package/public/pdfjs/cmaps/Add-V.bcmap +0 -0
  21. package/public/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
  22. package/public/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
  23. package/public/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
  24. package/public/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
  25. package/public/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
  26. package/public/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
  27. package/public/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
  28. package/public/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
  29. package/public/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
  30. package/public/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
  31. package/public/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
  32. package/public/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
  33. package/public/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
  34. package/public/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
  35. package/public/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
  36. package/public/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
  37. package/public/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
  38. package/public/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
  39. package/public/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
  40. package/public/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
  41. package/public/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
  42. package/public/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
  43. package/public/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
  44. package/public/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
  45. package/public/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
  46. package/public/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
  47. package/public/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
  48. package/public/pdfjs/cmaps/B5-H.bcmap +0 -0
  49. package/public/pdfjs/cmaps/B5-V.bcmap +0 -0
  50. package/public/pdfjs/cmaps/B5pc-H.bcmap +0 -0
  51. package/public/pdfjs/cmaps/B5pc-V.bcmap +0 -0
  52. package/public/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
  53. package/public/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
  54. package/public/pdfjs/cmaps/CNS1-H.bcmap +0 -0
  55. package/public/pdfjs/cmaps/CNS1-V.bcmap +0 -0
  56. package/public/pdfjs/cmaps/CNS2-H.bcmap +0 -0
  57. package/public/pdfjs/cmaps/CNS2-V.bcmap +3 -0
  58. package/public/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
  59. package/public/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
  60. package/public/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
  61. package/public/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
  62. package/public/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
  63. package/public/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
  64. package/public/pdfjs/cmaps/EUC-H.bcmap +0 -0
  65. package/public/pdfjs/cmaps/EUC-V.bcmap +0 -0
  66. package/public/pdfjs/cmaps/Ext-H.bcmap +0 -0
  67. package/public/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
  68. package/public/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
  69. package/public/pdfjs/cmaps/Ext-V.bcmap +0 -0
  70. package/public/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
  71. package/public/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
  72. package/public/pdfjs/cmaps/GB-H.bcmap +4 -0
  73. package/public/pdfjs/cmaps/GB-V.bcmap +0 -0
  74. package/public/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
  75. package/public/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
  76. package/public/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
  77. package/public/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
  78. package/public/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
  79. package/public/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
  80. package/public/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
  81. package/public/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
  82. package/public/pdfjs/cmaps/GBT-H.bcmap +0 -0
  83. package/public/pdfjs/cmaps/GBT-V.bcmap +0 -0
  84. package/public/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
  85. package/public/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
  86. package/public/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
  87. package/public/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
  88. package/public/pdfjs/cmaps/H.bcmap +0 -0
  89. package/public/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
  90. package/public/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
  91. package/public/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
  92. package/public/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
  93. package/public/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
  94. package/public/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
  95. package/public/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
  96. package/public/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
  97. package/public/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
  98. package/public/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
  99. package/public/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
  100. package/public/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
  101. package/public/pdfjs/cmaps/Hankaku.bcmap +0 -0
  102. package/public/pdfjs/cmaps/Hiragana.bcmap +0 -0
  103. package/public/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
  104. package/public/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
  105. package/public/pdfjs/cmaps/KSC-H.bcmap +0 -0
  106. package/public/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
  107. package/public/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
  108. package/public/pdfjs/cmaps/KSC-V.bcmap +0 -0
  109. package/public/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
  110. package/public/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
  111. package/public/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
  112. package/public/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
  113. package/public/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
  114. package/public/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
  115. package/public/pdfjs/cmaps/Katakana.bcmap +0 -0
  116. package/public/pdfjs/cmaps/LICENSE +36 -0
  117. package/public/pdfjs/cmaps/NWP-H.bcmap +0 -0
  118. package/public/pdfjs/cmaps/NWP-V.bcmap +0 -0
  119. package/public/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
  120. package/public/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
  121. package/public/pdfjs/cmaps/Roman.bcmap +0 -0
  122. package/public/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
  123. package/public/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
  124. package/public/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
  125. package/public/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
  126. package/public/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
  127. package/public/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
  128. package/public/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
  129. package/public/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
  130. package/public/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
  131. package/public/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
  132. package/public/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
  133. package/public/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
  134. package/public/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
  135. package/public/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
  136. package/public/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
  137. package/public/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
  138. package/public/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
  139. package/public/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
  140. package/public/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
  141. package/public/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
  142. package/public/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
  143. package/public/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
  144. package/public/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
  145. package/public/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
  146. package/public/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
  147. package/public/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
  148. package/public/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
  149. package/public/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
  150. package/public/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
  151. package/public/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
  152. package/public/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
  153. package/public/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
  154. package/public/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
  155. package/public/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
  156. package/public/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
  157. package/public/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
  158. package/public/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
  159. package/public/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
  160. package/public/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
  161. package/public/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
  162. package/public/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
  163. package/public/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
  164. package/public/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
  165. package/public/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
  166. package/public/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
  167. package/public/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
  168. package/public/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
  169. package/public/pdfjs/cmaps/V.bcmap +0 -0
  170. package/public/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
  171. package/src/components/ai/ai-prompt-input/index.tsx +3 -87
  172. package/src/components/ai-elements/__tests__/context.test.tsx +167 -0
  173. package/src/components/ai-elements/context.tsx +182 -94
  174. package/src/components/ai-elements/prompt-input.tsx +6 -104
  175. package/src/components/harness/__tests__/composer-attachments.test.tsx +17 -9
  176. package/src/components/harness/__tests__/composer-click-focus.test.tsx +175 -0
  177. package/src/components/harness/__tests__/composer-focus.test.tsx +7 -0
  178. package/src/components/harness/__tests__/composer-keymap.test.ts +57 -0
  179. package/src/components/harness/__tests__/composer-paste.test.tsx +7 -0
  180. package/src/components/harness/__tests__/composer-pending-guard.test.tsx +207 -0
  181. package/src/components/harness/__tests__/composer-placeholder.test.ts +7 -6
  182. package/src/components/harness/__tests__/composer-plus-menu.test.tsx +202 -0
  183. package/src/components/harness/__tests__/composer-primary-button.test.tsx +7 -0
  184. package/src/components/harness/__tests__/composer-send.test.tsx +12 -4
  185. package/src/components/harness/__tests__/composer-undo.test.tsx +7 -0
  186. package/src/components/harness/__tests__/dock-registry.test.ts +3 -0
  187. package/src/components/harness/__tests__/harness-workbench-auth-error.test.tsx +42 -4
  188. package/src/components/harness/__tests__/mention-kbid.test.ts +69 -0
  189. package/src/components/harness/__tests__/undo-last-turn.test.ts +134 -0
  190. package/src/components/harness/__tests__/voice-activity.test.tsx +2 -2
  191. package/src/components/harness/conversation-panel/composer/__tests__/file-chip-open.test.tsx +195 -0
  192. package/src/components/harness/conversation-panel/composer/__tests__/menu-view.test.tsx +107 -0
  193. package/src/components/harness/conversation-panel/composer/command/__tests__/claim-attachments.test.tsx +271 -0
  194. package/src/components/harness/conversation-panel/composer/command/__tests__/claim-client-submit.test.tsx +291 -0
  195. package/src/components/harness/conversation-panel/composer/command/__tests__/claim-guard.test.tsx +275 -0
  196. package/src/components/harness/conversation-panel/composer/command/__tests__/command-permission.test.tsx +286 -0
  197. package/src/components/harness/conversation-panel/composer/command/__tests__/command-plan.test.tsx +344 -0
  198. package/src/components/harness/conversation-panel/composer/command/__tests__/command-popup.test.tsx +193 -0
  199. package/src/components/harness/conversation-panel/composer/command/__tests__/command-server-source.test.tsx +235 -0
  200. package/src/components/harness/conversation-panel/composer/command/__tests__/command-suggestion-menu.test.tsx +151 -1
  201. package/src/components/harness/conversation-panel/composer/command/__tests__/command-undo.test.tsx +168 -0
  202. package/src/components/harness/conversation-panel/composer/command/__tests__/exclude-composer-seat.test.ts +106 -0
  203. package/src/components/harness/conversation-panel/composer/command/__tests__/menu-view.test.tsx +55 -2
  204. package/src/components/harness/conversation-panel/composer/command/__tests__/skill-source.test.tsx +336 -0
  205. package/src/components/harness/conversation-panel/composer/command/claim.ts +7 -1
  206. package/src/components/harness/conversation-panel/composer/command/command-popup.tsx +140 -0
  207. package/src/components/harness/conversation-panel/composer/command/command-suggestion-menu.tsx +261 -75
  208. package/src/components/harness/conversation-panel/composer/command/menu-view.tsx +188 -50
  209. package/src/components/harness/conversation-panel/composer/command/popup-panel.tsx +106 -0
  210. package/src/components/harness/conversation-panel/composer/command/skill-source.ts +231 -0
  211. package/src/components/harness/conversation-panel/composer/composer-editor.tsx +216 -14
  212. package/src/components/harness/conversation-panel/composer/composer-keymap.ts +26 -0
  213. package/src/components/harness/conversation-panel/composer/extension/__tests__/command-menu.test.ts +128 -12
  214. package/src/components/harness/conversation-panel/composer/extension/command-menu.ts +303 -44
  215. package/src/components/harness/conversation-panel/composer/extension/index.ts +8 -0
  216. package/src/components/harness/conversation-panel/composer/harness-composer.tsx +551 -83
  217. package/src/components/harness/conversation-panel/composer/mention/__tests__/file-mention.test.tsx +517 -0
  218. package/src/components/harness/conversation-panel/composer/mention/__tests__/mention-source-registration.test.tsx +5 -2
  219. package/src/components/harness/conversation-panel/composer/mention/__tests__/mention-suggestion-menu.test.tsx +120 -0
  220. package/src/components/harness/conversation-panel/composer/mention/__tests__/mention-trigger-source.test.ts +52 -9
  221. package/src/components/harness/conversation-panel/composer/mention/__tests__/story-mention.test.tsx +356 -0
  222. package/src/components/harness/conversation-panel/composer/mention/__tests__/thread-mention.test.tsx +377 -0
  223. package/src/components/harness/conversation-panel/composer/mention/file-mention.ts +162 -0
  224. package/src/components/harness/conversation-panel/composer/mention/mention-resolvers.ts +6 -0
  225. package/src/components/harness/conversation-panel/composer/mention/mention-suggestion-menu.tsx +212 -107
  226. package/src/components/harness/conversation-panel/composer/mention/mention-trigger-source.ts +71 -8
  227. package/src/components/harness/conversation-panel/composer/mention/story-mention.ts +131 -0
  228. package/src/components/harness/conversation-panel/composer/mention/thread-mention.ts +159 -0
  229. package/src/components/harness/conversation-panel/composer/mention/use-mention-sources.ts +9 -1
  230. package/src/components/harness/conversation-panel/composer/model-selector/__tests__/model-selector.test.tsx +401 -0
  231. package/src/components/harness/conversation-panel/composer/model-selector/__tests__/wiring.test.ts +117 -0
  232. package/src/components/harness/conversation-panel/composer/model-selector/model-selector-panel.tsx +411 -0
  233. package/src/components/harness/conversation-panel/composer/model-selector/model-selector-trigger.tsx +254 -0
  234. package/src/components/harness/conversation-panel/composer/model-selector/wiring.ts +112 -0
  235. package/src/components/harness/conversation-panel/composer/permission/__tests__/permission-select.test.tsx +264 -0
  236. package/src/components/harness/conversation-panel/composer/permission/permission-policy.ts +76 -0
  237. package/src/components/harness/conversation-panel/composer/permission/permission-popup.tsx +302 -0
  238. package/src/components/harness/conversation-panel/composer/permission/permission-select-button.tsx +140 -0
  239. package/src/components/harness/conversation-panel/composer/workspace/__tests__/workspace-select.test.tsx +390 -0
  240. package/src/components/harness/conversation-panel/composer/workspace/workspace-select-button.tsx +367 -0
  241. package/src/components/harness/conversation-panel/messages/harness-chain/__tests__/use-harness-session-putmedia.test.tsx +17 -0
  242. package/src/components/harness/conversation-panel/messages/harness-chain/use-harness-chat-adapter.ts +26 -6
  243. package/src/components/harness/conversation-panel/messages/harness-chain/use-harness-session.ts +21 -3
  244. package/src/components/harness/extension-panel/dock/__tests__/dock-persist.test.ts +2 -1
  245. package/src/components/harness/extension-panel/dock/__tests__/guide-page.test.tsx +44 -3
  246. package/src/components/harness/extension-panel/dock/dock-persist.ts +6 -4
  247. package/src/components/harness/extension-panel/dock/dock-registry.ts +35 -14
  248. package/src/components/harness/extension-panel/dock/dock-surface.tsx +2 -0
  249. package/src/components/harness/extension-panel/dock/guide-page.tsx +75 -45
  250. package/src/components/harness/extension-panel/panels/plugin/__tests__/install-dialog.test.tsx +260 -0
  251. package/src/components/harness/extension-panel/panels/plugin/__tests__/plugin-page.test.tsx +912 -0
  252. package/src/components/harness/extension-panel/panels/plugin/__tests__/plugin-row.test.tsx +215 -0
  253. package/src/components/harness/extension-panel/panels/plugin/builtin-section.tsx +204 -0
  254. package/src/components/harness/extension-panel/panels/plugin/install-dialog.tsx +195 -0
  255. package/src/components/harness/extension-panel/panels/plugin/installed-section.tsx +378 -0
  256. package/src/components/harness/extension-panel/panels/plugin/kind.tsx +17 -4
  257. package/src/components/harness/extension-panel/panels/plugin/pending-builds-block.tsx +49 -0
  258. package/src/components/harness/extension-panel/panels/plugin/plugin-page.tsx +257 -0
  259. package/src/components/harness/extension-panel/panels/plugin/plugin-row.tsx +206 -0
  260. package/src/components/harness/extension-panel/panels/plugin/plugin-types.ts +13 -0
  261. package/src/components/harness/extension-panel/panels/plugin/worker-section.tsx +322 -0
  262. package/src/components/harness/workbench/__tests__/provider-model-groups.test.ts +301 -0
  263. package/src/components/harness/workbench/harness-workbench-page.tsx +164 -2
  264. package/src/components/harness/workbench/provider-model-groups.ts +140 -0
  265. package/src/components/harness/workbench/undo-last-turn.ts +79 -0
  266. package/src/components/harness/workbench/workbench-context.tsx +53 -3
  267. package/src/components/tiptap/hooks/__tests__/use-floating-element.test.tsx +131 -0
  268. package/src/components/tiptap/hooks/use-floating-element.ts +15 -2
  269. package/src/components/tiptap/hooks/use-menu-navigation.ts +5 -0
  270. package/src/components/tiptap/node/mention-extension.ts +33 -0
  271. package/src/components/tiptap/ui/suggestion-menu/__tests__/suggestion-menu.test.tsx +366 -0
  272. package/src/components/tiptap/ui/suggestion-menu/suggestion-menu-types.ts +54 -0
  273. package/src/components/tiptap/ui/suggestion-menu/suggestion-menu.tsx +176 -45
  274. package/src/lib/changelog/sdk-versions.ts +2 -2
  275. package/src/lib/queries/__tests__/harness-plugin-queries.test.ts +49 -0
  276. package/src/lib/queries/harness.ts +50 -0
  277. package/src/paraglide/messages/_index.js +1574 -311
  278. package/src/paraglide/messages/en.js +513 -103
  279. package/src/paraglide/messages/zh.js +514 -104
  280. package/src/routes/_nav/harness/route.lazy.tsx +13 -0
  281. package/src/server/ai-gateway/sandbox/policy.ts +6 -6
  282. package/src/server/harness/__tests__/compact-plugin.server.test.ts +46 -0
  283. package/src/server/harness/__tests__/define-expose.test.ts +17 -0
  284. package/src/server/harness/__tests__/thread-reference.server.test.ts +258 -0
  285. package/src/server/harness/define.server.ts +21 -3
  286. package/src/server/harness/thread-reference.server.ts +446 -0
  287. package/src/server/serverFns/chat/__tests__/conversations-sandbox-default.test.ts +23 -0
  288. package/src/server/serverFns/chat/conversations.ts +18 -3
  289. package/src/server/serverFns/harness/search-mention-candidates.ts +14 -1
  290. package/src/shared/harness/__tests__/thread-reference-format.test.ts +128 -0
  291. package/src/shared/harness/thread-reference-format.ts +98 -0
  292. package/LICENSE +0 -661
  293. package/src/components/agents/slash-skill-menu.tsx +0 -75
  294. package/src/components/harness/conversation-panel/composer/extension/__tests__/demo-story-reference.test.tsx +0 -177
  295. package/src/components/harness/conversation-panel/composer/extension/demo-story-reference.tsx +0 -227
  296. package/src/components/harness/conversation-panel/composer/plugin-mention-menu.tsx +0 -109
  297. package/src/components/harness/extension-panel/panels/plugin-panel.tsx +0 -1021
@@ -0,0 +1,401 @@
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
+ * ModelSelector 合并面板行为回归(任务 2,设计 §3.1):
20
+ * 分组渲染(组头 tag + 能力 tag + threadModel 别名形当前高亮)/ 选中双通道(裸 id +
21
+ * writeKey 别名)/ 搜索过滤与阈值 / 思考区(reasoningSupported 白名单 + 7 档滑条
22
+ * commit 通道)/ 旧链降级 / ⌥T 循环切档 / 浮层开合上报。
23
+ *
24
+ * 渲染 trigger + panel(Base UI Popover 真实开合/Esc/外点通道);2026-11-21 二段式
25
+ * 改版:root=服务商入口行+当前域模型列表+思考强度,providers=三形式分组+管理模型
26
+ * (钻入/返回交互是断言对象)。;fixture 经任务 1
27
+ * buildProviderModelGroups 派生(writeKey 语义真实:preset 内别名形 / 自定义裸形)。
28
+ * paraglide(新 key stub 返回 key 名)/ 品牌图标(lobehub 动态 import jsdom 拖不起)/
29
+ * RouterLink(jsdom 无 router context)mock。
30
+ */
31
+ import { afterEach, expect, it, vi } from "vitest"
32
+ import { act, cleanup, fireEvent, render, screen } from "@testing-library/react"
33
+ import type { ReactNode } from "react"
34
+
35
+ import {
36
+ buildProviderModelGroups,
37
+ type ProviderModelGroup,
38
+ } from "../../../../workbench/provider-model-groups"
39
+ import { ModelSelector } from "../model-selector-trigger"
40
+
41
+ // 新 i18n key stub:任意 key 调用返回 key 名(带参数附 JSON)——文案断言 = key 存在性。
42
+ // 新 key 本任务才补进 messages(zh/en),真实 paraglide 产物不含 harness_model_* 新键。
43
+ vi.mock("@/paraglide/messages.js", () => ({
44
+ m: new Proxy(
45
+ {},
46
+ {
47
+ get: (_t, key: string) =>
48
+ (args?: Record<string, unknown>) =>
49
+ args === undefined ? String(key) : `${String(key)}:${JSON.stringify(args)}`,
50
+ },
51
+ ),
52
+ }))
53
+
54
+ // 品牌图标走 @lobehub/icons 动态 import,jsdom 拖不起——stub 渲染模型 id
55
+ vi.mock("@/components/ai/model-brand-icon", () => ({
56
+ ModelBrandIcon: ({ model }: { model: { id: string; name?: string } }) => (
57
+ <span data-testid={`brand-${model.id}`}>{model.id}</span>
58
+ ),
59
+ }))
60
+
61
+ // 面板底部「管理模型」RouterLink:jsdom 无 router context,stub 成锚
62
+ vi.mock("@tanstack/react-router", () => ({
63
+ Link: (props: { to: string; children?: ReactNode }) => (
64
+ <a href={props.to}>{props.children}</a>
65
+ ),
66
+ }))
67
+
68
+ afterEach(() => {
69
+ cleanup()
70
+ })
71
+
72
+ /**
73
+ * 基础 fixture:openai(kind=openai,两 preset 模型,gpt-x 与 acme 自定义 id 同名撞)+
74
+ * acme(本地,openai-compatible——reasoningSupported=false 白名单外)。
75
+ * writeKey:openai preset 内 → `${providerId}/${id}` 别名形;acme 自定义 id → 裸形。
76
+ */
77
+ function makeGroups(acmeModels: ReadonlyArray<string> = ["gpt-x"]): ProviderModelGroup[] {
78
+ return buildProviderModelGroups([
79
+ {
80
+ meta: {
81
+ providerId: "openai",
82
+ displayName: "OpenAI",
83
+ iconSlug: "",
84
+ brandColor: "",
85
+ adapterKind: "openai",
86
+ models: [
87
+ { id: "gpt-x", displayName: "GPT X", capabilities: ["vision", "reasoning"] },
88
+ { id: "gpt-y", displayName: "GPT Y" },
89
+ ],
90
+ },
91
+ config: { enabled: true, hasKey: true },
92
+ },
93
+ {
94
+ meta: {
95
+ providerId: "acme",
96
+ displayName: "Acme",
97
+ iconSlug: "",
98
+ brandColor: "",
99
+ isLocal: true,
100
+ adapterKind: "openai-compatible",
101
+ models: [{ id: "acme-pro", displayName: "Acme Pro" }],
102
+ },
103
+ config: { enabled: true, models: [...acmeModels] },
104
+ },
105
+ ])
106
+ }
107
+
108
+ interface SetupOptions {
109
+ groups?: ProviderModelGroup[]
110
+ model?: string
111
+ threadModel?: string
112
+ threadReasoning?: string
113
+ onModelChange?: (bareId: string) => void
114
+ onThreadModelChange?: (writeKey: string) => Promise<unknown> | void
115
+ onThreadReasoningChange?: (level: string) => Promise<unknown> | void
116
+ harnessEnabled?: boolean
117
+ onMenuOpenChange?: (open: boolean) => void
118
+ }
119
+
120
+ /** 渲染进真实容器(容器即 hotkeyTarget——⌥T 监听真实注册在含面板的元素上) */
121
+ function setup(opts: SetupOptions = {}) {
122
+ const container = document.createElement("div")
123
+ document.body.appendChild(container)
124
+ const hotkeyTarget = { current: container as HTMLElement | null }
125
+ render(
126
+ <div className="relative">
127
+ <ModelSelector
128
+ groups={opts.groups ?? makeGroups()}
129
+ model={opts.model}
130
+ threadModel={opts.threadModel}
131
+ threadReasoning={opts.threadReasoning as never}
132
+ onModelChange={opts.onModelChange ?? (() => {})}
133
+ onThreadModelChange={opts.onThreadModelChange}
134
+ onThreadReasoningChange={opts.onThreadReasoningChange as never}
135
+ harnessEnabled={opts.harnessEnabled ?? true}
136
+ onMenuOpenChange={opts.onMenuOpenChange ?? (() => {})}
137
+ hotkeyTarget={hotkeyTarget}
138
+ />
139
+ </div>,
140
+ { container },
141
+ )
142
+ return { container }
143
+ }
144
+
145
+ /** 点触发钮开面板(trigger 是树内唯一 button) */
146
+ function openPanel() {
147
+ fireEvent.click(screen.getByRole("button"))
148
+ return screen.findByRole("listbox")
149
+ }
150
+
151
+ /** 点服务商入口行(LOGO+名称,aria=providersAria)钻入 providers 段 */
152
+ async function openProviders() {
153
+ fireEvent.click(screen.getByRole("button", { name: /harness_model_providersAria/ }))
154
+ return await screen.findByText("harness_model_groupApiKey")
155
+ }
156
+
157
+ /**
158
+ * 按 textContent 找行,点行内最深文本元素(事件冒泡到 MenuView 行 Item onClick)。
159
+ * excludeText:同名撞行时排除另一组(openai GPT X 行 textContent 含品牌图标 'gpt-x')。
160
+ */
161
+ function clickRow(text: string, excludeText?: string) {
162
+ const row = screen.getAllByRole("option").find(
163
+ (r) => r.textContent?.includes(text) && !(excludeText && r.textContent?.includes(excludeText)),
164
+ )
165
+ if (!row) throw new Error(`row not found: ${text}`)
166
+ const inner = [...row.querySelectorAll<HTMLElement>("*")]
167
+ .reverse()
168
+ .find((el) => el.textContent === text)
169
+ fireEvent.click(inner ?? row)
170
+ }
171
+
172
+ it("root 段:服务商入口行(当前域 OpenAI)+ 当前域模型列表(别域名外组不列),当前行右侧 Check + 能力 tag", async () => {
173
+ setup({ threadModel: "openai/gpt-x" })
174
+ await openPanel()
175
+ // 服务商入口行 = **服务商 LOGO + 名称**(打磨二轮裁决:不写「模型服务商」文字)
176
+ const entryRow = screen.getByRole("button", { name: /harness_model_providersAria/ })
177
+ expect(entryRow.textContent).toContain("OpenAI")
178
+ expect(entryRow.querySelector("svg")).not.toBeNull()
179
+ expect(screen.queryByText("harness_model_providersEntry")).toBeNull()
180
+ expect(screen.getAllByText("OpenAI").length).toBeGreaterThan(0)
181
+ // root 模型列表 = 当前域(openai)的模型;他组(acme)模型不列(二段式裁决)
182
+ const rows = screen.getAllByRole("option").map((r) => r.textContent ?? "").join("\n")
183
+ expect(rows).toContain("GPT X")
184
+ expect(rows).toContain("GPT Y")
185
+ expect(rows).not.toContain("acme-pro")
186
+ // 当前档判定:threadModel 别名形 → 命中 openai GPT X 行,aria-selected + 右侧 Check
187
+ const current = screen
188
+ .getAllByRole("option")
189
+ .filter((el) => el.getAttribute("aria-selected") === "true")
190
+ expect(current).toHaveLength(1)
191
+ expect(current[0].textContent).toContain("GPT X")
192
+ expect(current[0].querySelector("svg.lucide-check")).not.toBeNull()
193
+ // 能力 tag:capabilities vision/reasoning → settings_ai_capabilitiesMap_*
194
+ expect(current[0].textContent).toContain("settings_ai_capabilitiesMap_vision")
195
+ expect(current[0].textContent).toContain("settings_ai_capabilitiesMap_reasoning")
196
+ })
197
+
198
+ it("未配置(groups 空):触发钮不禁用、面板正常打开,入口位变管理模型 + 暂无可用模型(三轮打磨裁决)", async () => {
199
+ const onModelChange = vi.fn()
200
+ setup({ groups: [], onModelChange })
201
+ // 触发钮不禁用(Sparkles 占位 + 选择模型文案)
202
+ const trigger = screen.getByRole("button")
203
+ expect(trigger).toHaveProperty("disabled", false)
204
+ fireEvent.click(trigger)
205
+ // 入口位 = 管理模型(Link + chevron),非服务商入口 Button
206
+ expect(await screen.findByText("harness_model_manage")).toBeTruthy()
207
+ expect(screen.queryByRole("button", { name: /harness_model_providersAria/ })).toBeNull()
208
+ // 模型列表空态(MenuView 空分支无 listbox)
209
+ expect(screen.getByText("harness_model_noModels")).toBeTruthy()
210
+ // 思考区不渲染(current null)
211
+ expect(screen.queryByText("harness_model_reasoningLabel")).toBeNull()
212
+ expect(onModelChange).not.toHaveBeenCalled()
213
+ })
214
+
215
+ it("providers 段:三形式分组(平台模型/ACP 暂无 + Api Key 行)+ 管理模型;选 Api Key 行切 root 域", async () => {
216
+ setup({ threadModel: "openai/gpt-x" })
217
+ await openPanel()
218
+ await openProviders()
219
+ // 空分组整组隐藏(二轮裁决):平台模型/ACP 无数据不渲染,仅 Api Key 组
220
+ expect(screen.queryByText("harness_model_groupPlatform")).toBeNull()
221
+ expect(screen.queryByText("harness_model_groupAcp")).toBeNull()
222
+ expect(screen.queryByText("harness_model_groupEmpty")).toBeNull()
223
+ expect(screen.getByText("harness_model_groupApiKey")).toBeTruthy()
224
+ expect(screen.getByText("OpenAI")).toBeTruthy()
225
+ expect(screen.getByText("Acme")).toBeTruthy()
226
+ // 管理模型行右侧箭头(打磨二轮裁决)
227
+ expect(screen.getByText("harness_model_manage").closest("a")?.querySelector("svg.lucide-chevron-right")).not.toBeNull()
228
+ // 返回行在(Back aria)
229
+ expect(screen.getByRole("button", { name: "harness_model_back" })).toBeTruthy()
230
+ // 选 Api Key 组 Acme 行 → 回 root,域切到 acme(acme 自定义 id gpt-x 在列,openai 域不列)
231
+ fireEvent.click(screen.getByText("Acme"))
232
+ await screen.findByRole("listbox")
233
+ const rows = screen.getAllByRole("option").map((r) => r.textContent ?? "").join("\n")
234
+ expect(rows).toContain("gpt-x")
235
+ expect(rows).not.toContain("GPT X")
236
+ expect(rows).not.toContain("GPT Y")
237
+ })
238
+
239
+ it("选中调用:onModelChange 收裸 id 且 onThreadModelChange 收 writeKey(preset 别名形 / 自定义裸形)", async () => {
240
+ const onModelChange = vi.fn()
241
+ const onThreadModelChange = vi.fn(() => Promise.resolve())
242
+ setup({ threadModel: "openai/gpt-x", onModelChange, onThreadModelChange })
243
+ await openPanel()
244
+ // preset 模型:裸 id + 别名 writeKey
245
+ clickRow("GPT Y")
246
+ expect(onModelChange).toHaveBeenCalledExactlyOnceWith("gpt-y")
247
+ expect(onThreadModelChange).toHaveBeenCalledExactlyOnceWith("openai/gpt-y")
248
+ // 跨 provider:先钻 providers 段选 Acme(切 root 域),再点其自定义 id 行 → 裸形 writeKey
249
+ await openProviders()
250
+ fireEvent.click(screen.getByText("Acme"))
251
+ await screen.findByRole("listbox")
252
+ clickRow("gpt-x")
253
+ expect(onModelChange).toHaveBeenCalledWith("gpt-x")
254
+ expect(onThreadModelChange).toHaveBeenLastCalledWith("gpt-x")
255
+ // 写通道 Promise 已在 runWrite await(spinner 挂起→复位)——flush 微任务消 act 噪音
256
+ await act(async () => {})
257
+ })
258
+
259
+ it("搜索过滤:当前域 >4 项 → 搜索框 + 域内子串过滤;≤4 项不渲染搜索框", async () => {
260
+ // 当前域(openai)5 模型(> 4)→ 搜索框显示,域内过滤(二段式:root 只列当前域)
261
+ const wide: ProviderModelGroup[] = [
262
+ {
263
+ providerId: "openai",
264
+ displayName: "OpenAI",
265
+ models: [
266
+ { id: "gpt-x", displayName: "GPT X", capabilities: ["vision", "reasoning"], reasoningSupported: true, writeKey: "openai/gpt-x" },
267
+ ...Array.from({ length: 4 }, (_, i) => ({
268
+ id: `gpt-w${i}`, displayName: `GPT W${i}`, reasoningSupported: true, writeKey: `openai/gpt-w${i}`,
269
+ })),
270
+ ],
271
+ },
272
+ ]
273
+ setup({ groups: wide, threadModel: "openai/gpt-x" })
274
+ await openPanel()
275
+ const search = screen.getByPlaceholderText("harness_command_modelSearch")
276
+ fireEvent.change(search, { target: { value: "W1" } })
277
+ const rows = screen.getAllByRole("option").map((r) => r.textContent ?? "").join("\n")
278
+ expect(rows).toContain("GPT W1")
279
+ expect(rows).not.toContain("GPT W2")
280
+ expect(rows).not.toContain("GPT X")
281
+ // 当前域 2 模型(≤ 4)→ 无搜索框
282
+ cleanup()
283
+ setup({ groups: makeGroups(["gpt-x", "acme-b"]) })
284
+ await openPanel()
285
+ expect(screen.queryByPlaceholderText("harness_command_modelSearch")).toBeNull()
286
+ // 3 项(基础 fixture)→ 无搜索框
287
+ cleanup()
288
+ setup({})
289
+ await openPanel()
290
+ expect(screen.queryByPlaceholderText("harness_command_modelSearch")).toBeNull()
291
+ })
292
+
293
+ it("思考区:reasoningSupported=true 渲 7 档滑条(数组形受控单 thumb),commit 调 onThreadReasoningChange;=false 显示 unsupported 灰字无滑条", async () => {
294
+ const onThreadReasoningChange = vi.fn(() => Promise.resolve())
295
+ setup({ threadModel: "openai/gpt-x", threadReasoning: "low", onThreadReasoningChange })
296
+ await openPanel()
297
+ // 思考区 label(灰字 unsupported 不出现)
298
+ expect(screen.getByText("harness_model_reasoningLabel")).toBeTruthy()
299
+ expect(screen.queryByText("harness_model_reasoningUnsupported")).toBeNull()
300
+ // 数组形受控:单 thumb(传单 number 会渲染双 thumb——复审 P2-1 回归哨兵)。
301
+ // hidden:true——Base UI thumb 内 input[type=range] 为 sr-only(clip-path: inset(50%)),
302
+ // 默认角色查询按不可见排除。
303
+ const thumbs = screen.getAllByRole("slider", { hidden: true })
304
+ expect(thumbs).toHaveLength(1)
305
+ // commit 语义(键盘 → onValueCommitted):low 的 next = medium
306
+ fireEvent.keyDown(thumbs[0], { key: "ArrowRight" })
307
+ expect(onThreadReasoningChange).toHaveBeenCalledExactlyOnceWith("medium")
308
+ // 写通道 Promise 已在 runWrite await——flush 微任务消 act 噪音
309
+ await act(async () => {})
310
+ // 刻度只标首尾与当前档:off / max 两处唯一;low(当前档)在刻度与思考区头部各一处
311
+ expect(screen.getByText("harness_composer_effort_off")).toBeTruthy()
312
+ expect(screen.getAllByText("harness_composer_effort_low").length).toBeGreaterThan(0)
313
+ expect(screen.getByText("harness_composer_effort_max")).toBeTruthy()
314
+ expect(screen.queryByText("harness_composer_effort_minimal")).toBeNull()
315
+ expect(screen.queryByText("harness_composer_effort_high")).toBeNull()
316
+ // reasoningSupported=false(acme 自定义 id,openai-compatible 白名单外):灰字 + 无滑条
317
+ cleanup()
318
+ setup({ groups: makeGroups(["gpt-x", "acme-custom"]), threadModel: "acme-custom", onThreadReasoningChange })
319
+ await openPanel()
320
+ expect(screen.getByText("harness_model_reasoningUnsupported")).toBeTruthy()
321
+ expect(screen.queryByRole("slider", { hidden: true })).toBeNull()
322
+ })
323
+
324
+ it("旧链:harnessEnabled=false 不渲染思考区(模型列表照常)", async () => {
325
+ setup({ threadModel: "openai/gpt-x", threadReasoning: "high", harnessEnabled: false })
326
+ await openPanel()
327
+ expect(screen.queryByText("harness_model_reasoningLabel")).toBeNull()
328
+ expect(screen.queryByText("harness_model_reasoningUnsupported")).toBeNull()
329
+ expect(screen.queryByRole("slider", { hidden: true })).toBeNull()
330
+ // 模型列表照常(当前域 openai 的模型在列)
331
+ const rows = screen.getAllByRole("option").map((r) => r.textContent ?? "").join("\n")
332
+ expect(rows).toContain("GPT X")
333
+ })
334
+
335
+ it("⌥T 循环:keydown Alt+T 档位 next(off→minimal / max→off),harnessEnabled=false 不绑", async () => {
336
+ const onThreadReasoningChange = vi.fn()
337
+ const { container } = setup({ threadReasoning: "off", onThreadReasoningChange })
338
+ fireEvent.keyDown(container, { key: "t", altKey: true })
339
+ expect(onThreadReasoningChange).toHaveBeenCalledExactlyOnceWith("minimal")
340
+ // 尾回 off:max 的 next = off
341
+ cleanup()
342
+ const onThreadReasoningChange2 = vi.fn()
343
+ const { container: container2 } = setup({ threadReasoning: "max", onThreadReasoningChange: onThreadReasoningChange2 })
344
+ fireEvent.keyDown(container2, { key: "t", altKey: true })
345
+ expect(onThreadReasoningChange2).toHaveBeenCalledExactlyOnceWith("off")
346
+ // 旧链不绑:harnessEnabled=false 时 Alt+T 无效
347
+ cleanup()
348
+ const onThreadReasoningChange3 = vi.fn()
349
+ const { container: container3 } = setup({
350
+ threadReasoning: "off",
351
+ onThreadReasoningChange: onThreadReasoningChange3,
352
+ harnessEnabled: false,
353
+ })
354
+ fireEvent.keyDown(container3, { key: "t", altKey: true })
355
+ expect(onThreadReasoningChange3).not.toHaveBeenCalled()
356
+ })
357
+
358
+ it("打开态再点触发钮:净关闭不重开(触发钮在外点通道豁免域内,onMenuOpenChange(false) 不重复)", async () => {
359
+ // 任务 2 审查挂账 Minor(关后重开竞态):面板 open 时再点触发钮,pointerdown
360
+ // (外点通道,目标在面板外)先于 click 到达——若触发钮不在豁免域内,外点通道先
361
+ // 关面板、随后的 click toggle 又重开(无法用触发钮关闭 + onMenuOpenChange(false)
362
+ // 后紧跟 (true))。修复后触发钮纳入 contains 豁免域:pointerdown 不关、click
363
+ // toggle 净关闭,false 恰上报一次。
364
+ const onMenuOpenChange = vi.fn()
365
+ setup({ onMenuOpenChange })
366
+ // 先捕获触发钮(面板 open 后树内可能不止一个 button 角色,避免误查)
367
+ const trigger = screen.getByRole("button")
368
+ fireEvent.click(trigger)
369
+ await screen.findByRole("listbox")
370
+ expect(onMenuOpenChange).toHaveBeenCalledExactlyOnceWith(true)
371
+ // 打开态再点触发钮:完整 pointerdown + click 序列(模拟真实点击的两段派发)
372
+ fireEvent.pointerDown(trigger, { bubbles: true })
373
+ fireEvent.click(trigger)
374
+ // 恰一次 false(外点通道被豁免、click toggle 关闭),面板不重开
375
+ expect(onMenuOpenChange).toHaveBeenCalledTimes(2)
376
+ expect(onMenuOpenChange).toHaveBeenLastCalledWith(false)
377
+ expect(screen.queryByRole("listbox")).toBeNull()
378
+ })
379
+
380
+ it("浮层开合:open 变化调 onMenuOpenChange(true/false)(点钮开 / Esc 关 / 外点关)", async () => {
381
+ const onMenuOpenChange = vi.fn()
382
+ setup({ onMenuOpenChange, threadModel: "openai/gpt-x" })
383
+ expect(onMenuOpenChange).not.toHaveBeenCalled()
384
+ // 点触发钮 → true
385
+ fireEvent.click(screen.getByRole("button"))
386
+ expect(onMenuOpenChange).toHaveBeenCalledExactlyOnceWith(true)
387
+ // Esc(PopupPanel document capture)→ false
388
+ fireEvent.keyDown(document, { key: "Escape" })
389
+ expect(onMenuOpenChange).toHaveBeenCalledTimes(2)
390
+ expect(onMenuOpenChange).toHaveBeenLastCalledWith(false)
391
+ // 再开 → true;外点(pointerdown 落 body,不在面板/触发钮内)→ false
392
+ fireEvent.click(screen.getByRole("button"))
393
+ expect(onMenuOpenChange).toHaveBeenCalledTimes(3)
394
+ expect(onMenuOpenChange).toHaveBeenLastCalledWith(true)
395
+ // Base UI Popover mouse 用 intentional 口径——完整 pointerdown+click 模拟真实外点
396
+ // (workspace 测试同款)
397
+ fireEvent.pointerDown(document.body, { bubbles: true })
398
+ fireEvent.click(document.body, { bubbles: true })
399
+ expect(onMenuOpenChange).toHaveBeenCalledTimes(4)
400
+ expect(onMenuOpenChange).toHaveBeenLastCalledWith(false)
401
+ })
@@ -0,0 +1,117 @@
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
+ * resolveModelSelectorWiring 纯函数回归(P2 任务 3,设计 §3.1 接线 + 复审 P1-3):
20
+ * harness-composer 零既有渲染测试,接线组装逻辑落在纯函数上——
21
+ * reasoning 回显归一(对象形 .level / string 直通 / undefined 透传)/
22
+ * 写通道组装(updateThreadSettings({ model: writeKey }) 与 { reasoning: level })/
23
+ * 旧链降级(写通道缺 → 回调 undefined)/ Promise 拒绝 catch + toast。
24
+ * 渲染面 mock 留给任务 2 组件测试(model-selector.test.tsx)。
25
+ */
26
+ import { afterEach, expect, it, vi } from "vitest"
27
+
28
+ import { resolveModelSelectorWiring } from "../wiring"
29
+ import { m } from "@/paraglide/messages.js"
30
+ import { toast } from "@/components/ui/toast"
31
+
32
+ // i18n stub:任意 key 调用返回 key 名——toast 断言 = key 存在性(与组件测试同构)
33
+ vi.mock("@/paraglide/messages.js", () => ({
34
+ m: new Proxy(
35
+ {},
36
+ {
37
+ get: (_t, key: string) =>
38
+ (args?: Record<string, unknown>) =>
39
+ args === undefined ? String(key) : `${String(key)}:${JSON.stringify(args)}`,
40
+ },
41
+ ),
42
+ }))
43
+
44
+ vi.mock("@/components/ui/toast", () => ({
45
+ toast: { error: vi.fn() },
46
+ }))
47
+
48
+ afterEach(() => {
49
+ vi.mocked(toast.error).mockClear()
50
+ })
51
+
52
+ it("reasoning 回显归一:threadSettings.reasoning 对象形取 .level、string 直通、undefined→undefined", () => {
53
+ // 对象形(ReasoningOption 完整形):取 level
54
+ expect(
55
+ resolveModelSelectorWiring({ threadSettings: { reasoning: { level: "high" } } })
56
+ .threadReasoning,
57
+ ).toBe("high")
58
+ // string 形:直通
59
+ expect(
60
+ resolveModelSelectorWiring({ threadSettings: { reasoning: "low" } }).threadReasoning,
61
+ ).toBe("low")
62
+ // undefined(旧链 / 未设置):透传 undefined(ModelSelector 回落 off)
63
+ expect(resolveModelSelectorWiring({}).threadReasoning).toBeUndefined()
64
+ expect(resolveModelSelectorWiring({ threadSettings: {} }).threadReasoning).toBeUndefined()
65
+ })
66
+
67
+ it("currentModel 回显:threadSettings.model 优先(服务端是真相),缺省回落单例 model", () => {
68
+ expect(
69
+ resolveModelSelectorWiring({ threadSettings: { model: "openai/gpt-x" }, model: "gpt-y" })
70
+ .currentModel,
71
+ ).toBe("openai/gpt-x")
72
+ expect(resolveModelSelectorWiring({ model: "gpt-y" }).currentModel).toBe("gpt-y")
73
+ expect(resolveModelSelectorWiring({}).currentModel).toBeUndefined()
74
+ })
75
+
76
+ it("harness 链在:onThreadModelChange 组装为 updateThreadSettings({ model: writeKey });链缺失(旧链)为 undefined", () => {
77
+ const updateThreadSettings = vi.fn(() => Promise.resolve())
78
+ const wiring = resolveModelSelectorWiring({ onThreadSettingsChange: updateThreadSettings })
79
+ expect(wiring.onThreadModelChange).toBeTypeOf("function")
80
+ wiring.onThreadModelChange?.("openai/gpt-x")
81
+ expect(updateThreadSettings).toHaveBeenCalledExactlyOnceWith({ model: "openai/gpt-x" })
82
+ // 通道同步返回 undefined(非 Promise)→ 回调透传 undefined,零 toast
83
+ const syncChannel = resolveModelSelectorWiring({
84
+ onThreadSettingsChange: () => undefined,
85
+ })
86
+ expect(syncChannel.onThreadModelChange?.("gpt-x")).toBeUndefined()
87
+ expect(toast.error).not.toHaveBeenCalled()
88
+ // 旧链(无写通道):回调 undefined(ModelSelector runWrite no-op)
89
+ const legacy = resolveModelSelectorWiring({ model: "gpt-y" })
90
+ expect(legacy.onThreadModelChange).toBeUndefined()
91
+ })
92
+
93
+ it("思考档组装为 updateThreadSettings({ reasoning: level });旧链 undefined", () => {
94
+ const updateThreadSettings = vi.fn(() => Promise.resolve())
95
+ const wiring = resolveModelSelectorWiring({ onThreadSettingsChange: updateThreadSettings })
96
+ expect(wiring.onThreadReasoningChange).toBeTypeOf("function")
97
+ wiring.onThreadReasoningChange?.("max")
98
+ expect(updateThreadSettings).toHaveBeenCalledExactlyOnceWith({ reasoning: "max" })
99
+ const legacy = resolveModelSelectorWiring({})
100
+ expect(legacy.onThreadReasoningChange).toBeUndefined()
101
+ })
102
+
103
+ it("写通道 Promise 拒绝 → catch 消化 + toast.error(runFailed),回调 Promise 归为 resolved(不外抛)", async () => {
104
+ const updateThreadSettings = vi.fn(() => Promise.reject(new Error("boom")))
105
+ const wiring = resolveModelSelectorWiring({ onThreadSettingsChange: updateThreadSettings })
106
+ // model 通道:拒绝被 catch + toast(m stub → key 名)
107
+ await expect(wiring.onThreadModelChange?.("openai/gpt-x")).resolves.toBeUndefined()
108
+ expect(toast.error).toHaveBeenCalledExactlyOnceWith(m.harness_command_runFailed())
109
+ // reasoning 通道同构
110
+ await expect(wiring.onThreadReasoningChange?.("high")).resolves.toBeUndefined()
111
+ expect(toast.error).toHaveBeenCalledTimes(2)
112
+ // 成功路径零 toast
113
+ vi.mocked(toast.error).mockClear()
114
+ const ok = resolveModelSelectorWiring({ onThreadSettingsChange: () => Promise.resolve() })
115
+ await expect(ok.onThreadModelChange?.("gpt-x")).resolves.toBeUndefined()
116
+ expect(toast.error).not.toHaveBeenCalled()
117
+ })