@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,411 @@
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 面板内容(P2 任务 2;2026-11-21 打磨二段式改版,用户裁决):
20
+ *
21
+ * **root 段**:「模型服务商」入口行(icon + 当前服务商名 + chevron,钻 providers 段)+
22
+ * border-t 模型列表(**当前服务商域**的模型行 = 品牌图标 + 显示名 + 能力 tag + 当档
23
+ * Check 右侧槽)+ border-t 思考强度区(白名单内滑条 / 外灰字)。
24
+ *
25
+ * **providers 段**(服务商二级菜单):返回行 + 三形式分组(**平台模型**——平台托管
26
+ * 服务,一期暂无;**ACP**——本地引擎 agent,云端会话暂无;**Api Key**——用户 BYOK
27
+ * providers,真实行)+ border-t「管理模型」整行。选 Api Key 行 = 切 root 段展示域
28
+ * (不写线程设置——写线程设置只在点模型行时发生)。
29
+ *
30
+ * 容器:根元素自承载描边/底色/**上圆下方**(下缘贴触发钮)+ shadow-lg(Popover 外壳
31
+ * chrome 已剥:rounded-none ring-0)。思考区按 `entry.reasoningSupported` 诚实白名单
32
+ * (R5-A)。
33
+ */
34
+ import { useMemo, useState } from "react"
35
+ import { Search, Check, ArrowLeft, ChevronRight, Loader2, Bot, Settings2 } from "lucide-react"
36
+ import { Link } from "@tanstack/react-router"
37
+ import { REASONING_LEVELS, type ReasoningLevel } from "@tanstack/ai"
38
+ import { cn } from "cn"
39
+ import { MenuView, type MenuViewEntry } from "../command/menu-view"
40
+ import { Button } from "@/components/ui/button"
41
+ import { Input } from "@/components/ui/input"
42
+ import { Slider } from "@/components/ui/slider"
43
+ import { Kbd } from "@/components/ui/kbd"
44
+ import { Badge } from "@/components/ui/badge"
45
+ import { ModelBrandIcon } from "@/components/ai/model-brand-icon"
46
+ import { ProviderLogo } from "@/components/settings/ai/provider-logo"
47
+ import { m } from "@/paraglide/messages.js"
48
+ import type {
49
+ ProviderModelEntry,
50
+ ProviderModelGroup,
51
+ } from "@/components/harness/workbench/provider-model-groups"
52
+
53
+ /** 「非默认思考档」触发钮徽标判定基准(沿 composer effort pill 既有默认档 medium)。 */
54
+ export const DEFAULT_REASONING_LEVEL: ReasoningLevel = "medium"
55
+
56
+ /** 能力 tag 文案(thunk 渲染期求值——沿用既有 settings_ai_capabilitiesMap_* key)。 */
57
+ const CAPABILITY_LABELS: Partial<Record<string, () => string>> = {
58
+ vision: m.settings_ai_capabilitiesMap_vision,
59
+ reasoning: m.settings_ai_capabilitiesMap_reasoning,
60
+ }
61
+
62
+ /** 7 档展示文案(thunk 渲染期求值——paraglide 不冻结 locale,POLICY_LABELS 同款)。 */
63
+ const EFFORT_LABELS: Record<ReasoningLevel, () => string> = {
64
+ off: m.harness_composer_effort_off,
65
+ minimal: m.harness_composer_effort_minimal,
66
+ low: m.harness_composer_effort_low,
67
+ medium: m.harness_composer_effort_medium,
68
+ high: m.harness_composer_effort_high,
69
+ xhigh: m.harness_composer_effort_xhigh,
70
+ max: m.harness_composer_effort_max,
71
+ }
72
+
73
+ /** 思考档展示文案(触发钮徽标 / aria / 思考区当前档共用)。 */
74
+ export function reasoningLevelLabel(level: ReasoningLevel): string {
75
+ return EFFORT_LABELS[level]()
76
+ }
77
+
78
+ /** MenuView 行负载(条目 generic):分组元数据 + 模型条目。 */
79
+ export interface ModelRowPayload {
80
+ group: ProviderModelGroup
81
+ entry: ProviderModelEntry
82
+ }
83
+
84
+ export interface ModelSelectorPanelProps {
85
+ groups: ReadonlyArray<ProviderModelGroup>
86
+ /** 当前模型条目(trigger 经 findModelRow(groups, threadModel ?? model) 归一) */
87
+ current: ProviderModelEntry | undefined
88
+ /** 当前条目所属 providerId(触发钮从 findModelRow 的分组域带出) */
89
+ currentProviderId?: string
90
+ /** 当前思考档(threadReasoning ?? off;level 形已由调用方归一) */
91
+ currentLevel: ReasoningLevel
92
+ /** 点选模型行(trigger 落双通道写) */
93
+ onSelectModel: (payload: ModelRowPayload) => void
94
+ /** 思考档写通道(滑条 commit 语义直通) */
95
+ onThreadReasoningChange?: (level: ReasoningLevel) => Promise<unknown> | void
96
+ /** 写通道挂起(trigger await Promise 期间):当前行 spinner */
97
+ busy: boolean
98
+ /** harness 链总门:false → 思考区不渲染(旧链降级,模型列表照常) */
99
+ harnessEnabled: boolean
100
+ /** 本地 ACP agent 清单(body.localAgents 透传;ACP 组展示行——真实模型选择走本地通路) */
101
+ acpAgents?: ReadonlyArray<{ id: string; available: boolean }>
102
+ }
103
+
104
+ /** 分组行共用(providers 段三形式组):组头 = muted 小字。 */
105
+ function GroupHeader({ label }: { label: string }) {
106
+ return (
107
+ <div className="px-2.5 py-0.5 text-xs font-medium text-muted-foreground">{label}</div>
108
+ )
109
+ }
110
+
111
+ export function ModelSelectorPanel({
112
+ groups,
113
+ current,
114
+ currentProviderId,
115
+ currentLevel,
116
+ onSelectModel,
117
+ onThreadReasoningChange,
118
+ busy,
119
+ harnessEnabled,
120
+ acpAgents = [],
121
+ }: ModelSelectorPanelProps) {
122
+ // 两段式:root(服务商入口 + 当前域模型列表 + 思考强度)/ providers(三形式分组 +
123
+ // 管理模型)。面板随 open 条件渲染挂载——useState 每次开面板重置回 root。
124
+ const [pane, setPane] = useState<"root" | "providers">("root")
125
+ // root 模型列表展示域:二级所选 Api Key provider 优先,回落当前模型所在组,再回落首组
126
+ const [pickedProviderId, setPickedProviderId] = useState<string | null>(null)
127
+ const effectiveProviderId =
128
+ pickedProviderId ?? currentProviderId ?? groups[0]?.providerId ?? null
129
+ const effectiveGroup =
130
+ groups.find((g) => g.providerId === effectiveProviderId) ?? groups[0]
131
+
132
+ // 当前档判定(同分组同 id 同 writeKey——别名形回显的行才命中 ✓)
133
+ const isCurrent = (payload: ModelRowPayload): boolean =>
134
+ current != null &&
135
+ payload.entry.id === current.id &&
136
+ payload.entry.writeKey === current.writeKey
137
+
138
+ // 模型搜索:域内过滤(大小写不敏感 includes,匹配 id + displayName)
139
+ const [query, setQuery] = useState("")
140
+ const entries = useMemo(() => {
141
+ if (!effectiveGroup) return []
142
+ const q = query.trim().toLowerCase()
143
+ const out: Array<MenuViewEntry<ModelRowPayload>> = []
144
+ for (const entry of effectiveGroup.models) {
145
+ if (q) {
146
+ const haystack = `${entry.id} ${entry.displayName ?? ""}`.toLowerCase()
147
+ if (!haystack.includes(q)) continue
148
+ }
149
+ out.push({
150
+ key: `${effectiveGroup.providerId}/${entry.id}`,
151
+ groupLabel: effectiveGroup.displayName,
152
+ item: { group: effectiveGroup, entry },
153
+ })
154
+ }
155
+ return out
156
+ }, [effectiveGroup, query])
157
+
158
+ // >4 项才显示搜索框(沿既有 SEARCH_THRESHOLD 口径:按当前域模型总数判定)
159
+ const showSearch = (effectiveGroup?.models.length ?? 0) > 4
160
+
161
+ const currentProviderName =
162
+ effectiveGroup?.displayName ?? m.harness_workspace_selectPlaceholder()
163
+
164
+ return (
165
+ // **裸内容**(无自承载卡):chrome 由 PopoverContent 默认承载(工作区 POP 同款
166
+ // ring-1 细边 + rounded-md 四角圆——三轮裁决恢复下圆角)。MenuView unstyled
167
+ // 防内层第二层 border。
168
+ <>
169
+ {pane === "root" ? (
170
+ <>
171
+ {/* 入口行(钻 providers 段):已配置 = 服务商 LOGO + 名称 + 切换服务商文案 +
172
+ chevron;**未配置(groups 空)= 入口位直接变管理模型**(三轮打磨裁决:
173
+ 面板照常打开,选模型走 /settings/ai) */}
174
+ <div className="p-1">
175
+ {groups.length > 0 ? (
176
+ <Button
177
+ type="button"
178
+ variant="ghost"
179
+ size="sm"
180
+ className="w-full justify-start gap-2 px-2 text-left font-normal"
181
+ aria-label={m.harness_model_providersAria({ name: currentProviderName })}
182
+ onClick={() => setPane("providers")}
183
+ >
184
+ <ProviderLogo
185
+ provider={{ providerId: effectiveProviderId ?? "", brandName: currentProviderName }}
186
+ size={14}
187
+ />
188
+ <span className="min-w-0 flex-1 truncate text-xs">
189
+ {currentProviderName}
190
+ </span>
191
+ <span className="shrink-0 text-xs text-muted-foreground">
192
+ {m.harness_model_switchProvider()}
193
+ </span>
194
+ <ChevronRight aria-hidden className="size-3.5 shrink-0 text-muted-foreground" />
195
+ </Button>
196
+ ) : (
197
+ <Link
198
+ to="/settings/ai"
199
+ className="flex items-center gap-2 rounded-md px-2 py-2 text-sm text-foreground hover:bg-accent"
200
+ >
201
+ <Settings2 aria-hidden className="size-3.5 shrink-0 text-muted-foreground" />
202
+ <span className="min-w-0 flex-1 truncate">{m.harness_model_manage()}</span>
203
+ <ChevronRight aria-hidden className="size-3.5 shrink-0 text-muted-foreground" />
204
+ </Link>
205
+ )}
206
+ </div>
207
+ <div className="border-t" />
208
+ {/* 模型列表(当前服务商域) */}
209
+ {showSearch && (
210
+ <div className="relative p-2">
211
+ <Search className="absolute left-4 top-1/2 size-4 -translate-y-1/2 text-muted-foreground" />
212
+ <Input
213
+ value={query}
214
+ onChange={(e) => setQuery(e.target.value)}
215
+ placeholder={m.harness_command_modelSearch()}
216
+ aria-label={m.harness_command_modelSearch()}
217
+ className="h-8 pl-8 text-sm"
218
+ />
219
+ </div>
220
+ )}
221
+ <MenuView
222
+ unstyled
223
+ entries={entries}
224
+ selectedIndex={-1}
225
+ onSelect={onSelectModel}
226
+ selector="model-selector"
227
+ loading={false}
228
+ emptyMessage={
229
+ effectiveGroup && effectiveGroup.models.length > 0
230
+ ? m.harness_model_search_noMatches()
231
+ : m.harness_model_noModels()
232
+ }
233
+ isCurrent={isCurrent}
234
+ renderMedia={(payload) => (
235
+ <ModelBrandIcon
236
+ model={{
237
+ id: payload.entry.id,
238
+ name: payload.entry.displayName ?? payload.entry.id,
239
+ iconSlug: payload.entry.iconSlug,
240
+ }}
241
+ providerId={payload.group.providerId}
242
+ size={14}
243
+ />
244
+ )}
245
+ renderTitle={(payload) => (
246
+ <span className="flex min-w-0 items-center gap-1.5">
247
+ <span className={cn("truncate", isCurrent(payload) && "font-semibold")}>
248
+ {payload.entry.displayName ?? payload.entry.id}
249
+ </span>
250
+ {(payload.entry.capabilities ?? []).map((cap) => {
251
+ const label = CAPABILITY_LABELS[cap]
252
+ if (!label) return null
253
+ return (
254
+ // text-[10px]:能力徽标微型字号(设计稿视觉密度取值——标准刻度最小
255
+ // text-xs=12px 对 h-5 徽标过大;settings/ai/model-card.tsx 同款口径)
256
+ <Badge
257
+ key={cap}
258
+ variant="secondary"
259
+ className="h-5 shrink-0 px-1.5 text-[10px]"
260
+ >
261
+ {label()}
262
+ </Badge>
263
+ )
264
+ })}
265
+ </span>
266
+ )}
267
+ // 当档 Check 右侧槽(打磨裁决:lucide 图标非 emoji);写通道挂起时当档行
268
+ // spinner 暂替
269
+ renderTrailing={(payload) =>
270
+ busy && isCurrent(payload) ? (
271
+ <Loader2 aria-hidden className="size-3.5 animate-spin text-muted-foreground" />
272
+ ) : isCurrent(payload) ? (
273
+ <Check aria-hidden className="size-4 text-primary" />
274
+ ) : null
275
+ }
276
+ />
277
+ {/* 底部固定区:思考强度(harness 链才有 settings 写通道,旧链不渲染) */}
278
+ {harnessEnabled && current != null ? (
279
+ current.reasoningSupported ? (
280
+ <div className="border-t p-3" data-slot="model-selector-reasoning">
281
+ <div className="flex items-center justify-between text-xs text-muted-foreground">
282
+ <span className="font-medium">{m.harness_model_reasoningLabel()}</span>
283
+ <span className="flex items-center gap-1.5">
284
+ {reasoningLevelLabel(currentLevel)}
285
+ <Kbd>⌥T</Kbd>
286
+ </span>
287
+ </div>
288
+ {/* 离散 7 档滑条(REASONING_LEVELS 单一来源;数组形受控——Base UI wrapper
289
+ 传单 number 会渲染双 thumb,复审 P2-1);写通道挂 onValueCommitted
290
+ (commit 语义:拖动过程不连发 configure op)。 */}
291
+ <Slider
292
+ value={[REASONING_LEVELS.indexOf(currentLevel)]}
293
+ min={0}
294
+ max={6}
295
+ step={1}
296
+ onValueCommitted={(v) =>
297
+ onThreadReasoningChange?.(
298
+ REASONING_LEVELS[Array.isArray(v) ? v[0] : v],
299
+ )
300
+ }
301
+ aria-label={m.harness_model_reasoningLabel()}
302
+ className={
303
+ // ui/slider 是 shadcn 禁改目录(track 无 className 出参),渐变轨道只能
304
+ // 从消费方经 data-slot 任意变体注入(图1 对标绿→蓝)
305
+ "[&_[data-slot=slider-track]]:bg-linear-to-r [&_[data-slot=slider-track]]:from-emerald-500 [&_[data-slot=slider-track]]:to-blue-500"
306
+ }
307
+ />
308
+ {/* 刻度只标首尾与当前档(7 个全标过密);text-[10px] 为刻度小字视觉密度
309
+ 取值(标准刻度最小 text-xs=12px 偏大,需精确像素) */}
310
+ <div className="mt-1 flex justify-between text-[10px] text-muted-foreground">
311
+ {REASONING_LEVELS.map((level, index) =>
312
+ index === 0 ||
313
+ index === REASONING_LEVELS.length - 1 ||
314
+ level === currentLevel ? (
315
+ <span key={level}>{reasoningLevelLabel(level)}</span>
316
+ ) : (
317
+ <span key={level} />
318
+ ),
319
+ )}
320
+ </div>
321
+ </div>
322
+ ) : (
323
+ // R5-A 诚实白名单外(reasoningSupported=false):灰字提示,无滑条
324
+ <div className="border-t px-3 py-2 text-xs text-muted-foreground">
325
+ {m.harness_model_reasoningUnsupported()}
326
+ </div>
327
+ )
328
+ ) : null}
329
+ </>
330
+ ) : (
331
+ <>
332
+ {/* 返回行 + 段标题 */}
333
+ <div className="flex items-center gap-1 p-1">
334
+ <Button
335
+ type="button"
336
+ variant="ghost"
337
+ size="icon-sm"
338
+ aria-label={m.harness_model_back()}
339
+ onClick={() => setPane("root")}
340
+ >
341
+ <ArrowLeft aria-hidden className="size-3.5" />
342
+ </Button>
343
+ <span className="text-xs font-medium text-muted-foreground">
344
+ {m.harness_model_providersEntry()}
345
+ </span>
346
+ </div>
347
+ <div className="border-t" />
348
+ {/* 三形式分组(打磨裁决:平台模型 / ACP / Api Key);**空分组不显示**
349
+ (二轮裁决 2026-11-21:平台模型一期暂无、ACP 云端会话无数据 → 整组隐藏) */}
350
+ <div className="py-1">
351
+ {acpAgents.length > 0 ? (
352
+ <>
353
+ <GroupHeader label={m.harness_model_groupAcp()} />
354
+ {acpAgents.map((agent) => (
355
+ // ACP agent 展示行:真实模型选择走本地引擎通路(桌面),本面板不改会话模型
356
+ <div
357
+ key={agent.id}
358
+ className="flex cursor-default items-center gap-2 px-2.5 py-1.5 text-sm"
359
+ >
360
+ <Bot aria-hidden className="size-3.5 shrink-0 text-muted-foreground" />
361
+ <span className="min-w-0 flex-1 truncate">{agent.id}</span>
362
+ </div>
363
+ ))}
364
+ </>
365
+ ) : null}
366
+ {groups.length > 0 ? (
367
+ <>
368
+ <GroupHeader label={m.harness_model_groupApiKey()} />
369
+ {groups.map((group) => {
370
+ const active = group.providerId === effectiveProviderId
371
+ return (
372
+ <Button
373
+ key={group.providerId}
374
+ type="button"
375
+ variant="ghost"
376
+ size="sm"
377
+ className="w-full justify-start gap-2 px-2 text-left font-normal"
378
+ onClick={() => {
379
+ setPickedProviderId(group.providerId)
380
+ setPane("root")
381
+ }}
382
+ >
383
+ {/* 服务商 logo 与 settings/ai 同源(LOBE_ICON_MAP[providerId]) */}
384
+ <ProviderLogo
385
+ provider={{ providerId: group.providerId, brandName: group.displayName }}
386
+ size={16}
387
+ />
388
+ <span className="min-w-0 flex-1 truncate">{group.displayName}</span>
389
+ {active && <Check aria-hidden className="size-4 shrink-0 text-primary" />}
390
+ </Button>
391
+ )
392
+ })}
393
+ </>
394
+ ) : null}
395
+ </div>
396
+ <div className="border-t" />
397
+ {/* 管理模型整行入口(图1 对标:全宽 hover 行 + 右侧箭头) */}
398
+ <div className="p-1">
399
+ <Link
400
+ to="/settings/ai"
401
+ className="flex items-center rounded-md px-2.5 py-2 text-sm text-foreground hover:bg-accent"
402
+ >
403
+ <span className="min-w-0 flex-1 truncate">{m.harness_model_manage()}</span>
404
+ <ChevronRight aria-hidden className="size-3.5 shrink-0 text-muted-foreground" />
405
+ </Link>
406
+ </div>
407
+ </>
408
+ )}
409
+ </>
410
+ )
411
+ }
@@ -0,0 +1,254 @@
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 触发钮 + 浮层(P2 任务 2,设计 §3.1;2026-11-21 打磨改版):模型选择
20
+ * + 思考强度合并面板(替代 PromptInputModelSelect + PromptInputEffortSelect 两 pill;
21
+ * composer 接线在任务 3,本组件纯 UI + 写通道直通)。
22
+ *
23
+ * 触发钮 = PromptInputButton sm outline rounded-full(与现模型 pill 同形):品牌图标
24
+ * (ModelBrandIcon,**providerId + 条目 iconSlug 双注入**——与列表行图标逐像素同源,
25
+ * 打磨裁决「列表有图标的按钮也要回显」)+ 显示名(displayName 优先回落 id)+ 非默认
26
+ * 思考档短徽标(`· 档名`)+ chevron。空占位复用 harness_composer_modelEmpty。
27
+ *
28
+ * 面板 = Base UI Popover(**锚触发钮上方弹出**,2026-11-21 打磨裁决与工作区选择同构,
29
+ * 弃 PopupPanel 钉卡上沿——/model 斜杠 popup 仍走 PopupPanel 不受影响);open 态经
30
+ * onOpenChange=changeOpen 并入上层 menuOpen 通道(屏蔽 Esc-Esc 停止序列双保险);
31
+ * PopoverTrigger 自带 toggle(open 态再点触发钮 = 净关闭,Base UI 原生语义,任务 3
32
+ * 的 extraInsideSelector 豁免域随 PopupPanel 一并退役)。
33
+ *
34
+ * 选中即写:单例恒写裸 id(旧链写域 + workbench「不在目录即清空」校验口径),harness
35
+ * 链另写 settings writeKey(preset 别名形防跨 provider 裸 id 撞名)。
36
+ *
37
+ * 写通道返回 Promise 时 await + 行内 spinner(触发钮与当前行);失败不 toast(任务 3
38
+ * wiring 统一包装),此处 catch 只防 unhandled rejection。
39
+ *
40
+ * ⌥T 循环切档:REASONING_LEVELS 序 next(尾回 off),组件级 useHotkey 锚会话区域
41
+ * (会话级键位,与 Esc-Esc 同类豁免,不进 defineAppHotkeys)。enabled = 面板数据就绪
42
+ * (groups 非空)+ harnessEnabled。
43
+ */
44
+ import { useCallback, useMemo, useState, type RefObject } from "react"
45
+ import { ChevronDown, Loader2, Sparkles } from "lucide-react"
46
+ import { REASONING_LEVELS, type ReasoningLevel } from "@tanstack/ai"
47
+ import { useHotkey } from "@tanstack/react-hotkeys"
48
+ import { cn } from "cn"
49
+ import { PromptInputButton } from "@/components/ai-elements/prompt-input"
50
+ import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"
51
+ import { ModelBrandIcon } from "@/components/ai/model-brand-icon"
52
+ import {
53
+ findModelRow,
54
+ type ProviderModelGroup,
55
+ } from "@/components/harness/workbench/provider-model-groups"
56
+ import {
57
+ ModelSelectorPanel,
58
+ DEFAULT_REASONING_LEVEL,
59
+ reasoningLevelLabel,
60
+ type ModelRowPayload,
61
+ } from "./model-selector-panel"
62
+ import { m } from "@/paraglide/messages.js"
63
+
64
+ export interface ModelSelectorProps {
65
+ /** 模型分组目录(任务 1 providerModelGroups;空 = 触发钮禁用 + ⌥T 不绑) */
66
+ groups: ReadonlyArray<ProviderModelGroup>
67
+ /** 单例裸 id(显示回落 + 旧链写域) */
68
+ model?: string
69
+ /** settings.model 回显(可能别名形,优先显示——服务端是真相) */
70
+ threadModel?: string
71
+ /** settings.reasoning 回显(level 形已由调用方归一) */
72
+ threadReasoning?: ReasoningLevel
73
+ onModelChange: (bareId: string) => void
74
+ /** harness 写通道(writeKey 别名形);返回 Promise 时行内 spinner */
75
+ onThreadModelChange?: (writeKey: string) => Promise<unknown> | void
76
+ /** harness 思考档写通道(level 形);返回 Promise 时行内 spinner */
77
+ onThreadReasoningChange?: (level: ReasoningLevel) => Promise<unknown> | void
78
+ /** 思考区总门,调用方双条件收口(任务 3 接线):isHarnessClientEnabled() && 线程设置写通道在(旧链 false:思考区不渲染、⌥T 不绑,通道缺省时不展示静默 no-op 滑条) */
79
+ harnessEnabled: boolean
80
+ onMenuOpenChange: (open: boolean) => void
81
+ /** 触发钮禁用;缺省按目录空判定 */
82
+ disabled?: boolean
83
+ /** ⌥T 监听锚(composer 会话区域根 ref,任务 3 接线传入) */
84
+ hotkeyTarget?: RefObject<HTMLElement | null>
85
+ /** 本地 ACP agent 清单(providers 段 ACP 组展示行;body.localAgents 透传) */
86
+ acpAgents?: ReadonlyArray<{ id: string; available: boolean }>
87
+ }
88
+
89
+ /** Promise 判定(写通道可 void 可 Promise) */
90
+ function isPromiseLike(value: Promise<unknown> | void): value is Promise<unknown> {
91
+ return (
92
+ typeof value === "object" &&
93
+ value !== null &&
94
+ typeof (value as Promise<unknown>).then === "function"
95
+ )
96
+ }
97
+
98
+ export function ModelSelector({
99
+ groups,
100
+ model,
101
+ threadModel,
102
+ threadReasoning,
103
+ onModelChange,
104
+ onThreadModelChange,
105
+ onThreadReasoningChange,
106
+ harnessEnabled,
107
+ onMenuOpenChange,
108
+ disabled,
109
+ hotkeyTarget,
110
+ acpAgents = [],
111
+ }: ModelSelectorProps) {
112
+ const [open, setOpen] = useState(false)
113
+ const [busy, setBusy] = useState(false)
114
+
115
+ // 当前模型条目 + 所属分组:settings 优先(服务端是真相),裸 id/别名形统一归一;
116
+ // 分组 providerId/iconSlug 供触发钮图标与列表行同源回显
117
+ const currentRow = useMemo(
118
+ () => findModelRow(groups, threadModel ?? model),
119
+ [groups, threadModel, model],
120
+ )
121
+ const current = currentRow?.entry
122
+ const currentLevel: ReasoningLevel = threadReasoning ?? "off"
123
+
124
+ // open 变化统一经此(点钮开 / Esc 外点关)——同步上报 onMenuOpenChange
125
+ const changeOpen = useCallback(
126
+ (next: boolean) => {
127
+ setOpen(next)
128
+ onMenuOpenChange(next)
129
+ },
130
+ [onMenuOpenChange],
131
+ )
132
+
133
+ // 写通道统一 await + 行内 spinner(触发钮与当前行);catch 只防 unhandled
134
+ // rejection——失败 toast 由任务 3 wiring 包装,此处不重复报错面
135
+ const runWrite = useCallback((write: Promise<unknown> | void) => {
136
+ if (!isPromiseLike(write)) return
137
+ setBusy(true)
138
+ write
139
+ .catch((error: unknown) => {
140
+ console.error("[model-selector] 线程设置写入失败", error)
141
+ })
142
+ .finally(() => setBusy(false))
143
+ }, [])
144
+
145
+ const handleSelectModel = useCallback(
146
+ (payload: ModelRowPayload) => {
147
+ // 单例恒写裸 id(旧链写域);harness 链另写 settings writeKey(别名形)
148
+ onModelChange(payload.entry.id)
149
+ runWrite(onThreadModelChange?.(payload.entry.writeKey))
150
+ },
151
+ [onModelChange, onThreadModelChange, runWrite],
152
+ )
153
+
154
+ // ⌥T 循环切档:REASONING_LEVELS 序 next,尾回 off(裁决:会话级键位,不进
155
+ // defineAppHotkeys)。ignoreInputs 显式 false——Alt 组合默认跳过输入框/编辑器,
156
+ // 而本快捷键要在 TipTap 聚焦时可用(绑定点消费声明,无 registry 冲突见单测)。
157
+ const hotkeyEnabled = harnessEnabled && groups.length > 0
158
+ useHotkey(
159
+ "Alt+T",
160
+ () => {
161
+ const nextIndex =
162
+ (REASONING_LEVELS.indexOf(currentLevel) + 1) % REASONING_LEVELS.length
163
+ runWrite(onThreadReasoningChange?.(REASONING_LEVELS[nextIndex]))
164
+ },
165
+ {
166
+ target: hotkeyTarget ?? null,
167
+ enabled: hotkeyEnabled,
168
+ preventDefault: true,
169
+ ignoreInputs: false,
170
+ },
171
+ )
172
+
173
+ const currentName = current ? (current.displayName ?? current.id) : ""
174
+ const showEffortBadge =
175
+ harnessEnabled &&
176
+ threadReasoning != null &&
177
+ threadReasoning !== DEFAULT_REASONING_LEVEL
178
+
179
+ return (
180
+ <Popover open={open} onOpenChange={changeOpen}>
181
+ <PopoverTrigger
182
+ render={
183
+ <PromptInputButton
184
+ size="sm"
185
+ variant="outline"
186
+ className="rounded-full"
187
+ // 测试钩子(marker):模型面板定位/防误查(Popover 迁移后豁免域语义退役)
188
+ data-model-selector-trigger=""
189
+ aria-label={m.harness_model_selectorAria({
190
+ name: currentName || m.harness_composer_modelEmpty(),
191
+ effort: reasoningLevelLabel(currentLevel),
192
+ })}
193
+ // 未配置(groups 空)不再禁用(三轮打磨裁决:面板正常打开,入口位变管理模型)
194
+ disabled={disabled}
195
+ >
196
+ {currentRow ? (
197
+ <ModelBrandIcon
198
+ model={{
199
+ id: currentRow.entry.id,
200
+ name: currentRow.entry.displayName ?? currentRow.entry.id,
201
+ iconSlug: currentRow.entry.iconSlug,
202
+ }}
203
+ providerId={currentRow.group.providerId}
204
+ size={14}
205
+ />
206
+ ) : (
207
+ <Sparkles aria-hidden className="size-3.5" />
208
+ )}
209
+ <span className="max-w-32 truncate text-xs">
210
+ {current ? (current.displayName ?? current.id) : m.harness_composer_modelEmpty()}
211
+ </span>
212
+ {showEffortBadge && (
213
+ <span className="shrink-0 text-xs text-muted-foreground">
214
+ · {reasoningLevelLabel(currentLevel)}
215
+ </span>
216
+ )}
217
+ {busy && (
218
+ <Loader2 aria-hidden className="size-3 shrink-0 animate-spin text-muted-foreground" />
219
+ )}
220
+ <ChevronDown
221
+ aria-hidden
222
+ className={cn(
223
+ "size-3.5 shrink-0 text-muted-foreground transition-transform",
224
+ open && "rotate-180",
225
+ )}
226
+ />
227
+ </PromptInputButton>
228
+ }
229
+ />
230
+ {open && (
231
+ // 锚触发钮上方弹出(与工作区选择同构);面板自承载描边/底色/圆角,Popover
232
+ // 外壳只做定位(chrome 全剥,避免双层卡)
233
+ <PopoverContent
234
+ side="top"
235
+ align="end"
236
+ sideOffset={8}
237
+ className="w-72 gap-0 overflow-hidden p-0"
238
+ >
239
+ <ModelSelectorPanel
240
+ groups={groups}
241
+ current={current}
242
+ currentProviderId={currentRow?.group.providerId}
243
+ currentLevel={currentLevel}
244
+ onSelectModel={handleSelectModel}
245
+ onThreadReasoningChange={onThreadReasoningChange}
246
+ busy={busy}
247
+ harnessEnabled={harnessEnabled}
248
+ acpAgents={acpAgents}
249
+ />
250
+ </PopoverContent>
251
+ )}
252
+ </Popover>
253
+ )
254
+ }