@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,215 @@
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
+ // PluginRow 统一行组件 + PluginStatusDot 五态状态点(设计 §3.1)单测:
19
+ // 槽位渲染、switch 接线(Base UI 切换语义)、menu 不冒泡、受控展开、
20
+ // 五态类映射、unknown 态补充说明 Tooltip、description 溢出全文 Tooltip。
21
+ // Tooltip 悬浮配方沿用 guide-page.test.tsx:185-196(closest tooltip-trigger +
22
+ // mouseEnter/mouseMove + waitFor)。
23
+
24
+ import { describe, expect, it, vi } from "vitest"
25
+ import { fireEvent, render, screen, waitFor } from "@testing-library/react"
26
+ import { Puzzle } from "lucide-react"
27
+ import { Badge } from "@/components/ui/badge"
28
+ import { Button } from "@/components/ui/button"
29
+ import { PluginRow, PluginStatusDot, type PluginStatus } from "../plugin-row"
30
+
31
+ describe("PluginRow", () => {
32
+ it("渲染 icon/title/description/badges/meta 各槽位", () => {
33
+ render(
34
+ <PluginRow
35
+ icon={<Puzzle data-testid="row-icon" />}
36
+ title="测试插件"
37
+ badges={<Badge data-testid="row-badge">v1.2.3</Badge>}
38
+ description="一行描述文本"
39
+ meta={<span data-testid="row-meta">来源:内置</span>}
40
+ />,
41
+ )
42
+ expect(screen.getByText("测试插件")).toBeInTheDocument()
43
+ expect(screen.getByText("一行描述文本")).toBeInTheDocument()
44
+ expect(screen.getByTestId("row-badge")).toBeInTheDocument()
45
+ expect(screen.getByTestId("row-meta")).toBeInTheDocument()
46
+ const iconContainer = screen.getByTestId("row-icon").parentElement as HTMLElement
47
+ expect(iconContainer).toHaveClass("size-12", "rounded-xl", "bg-muted")
48
+ })
49
+
50
+ it("switch 槽位接线", () => {
51
+ const onCheckedChange = vi.fn()
52
+ const { rerender } = render(
53
+ <PluginRow
54
+ icon={<Puzzle />}
55
+ title="开关行"
56
+ switch={{ checked: true, disabled: false, onCheckedChange }}
57
+ />,
58
+ )
59
+ expect(screen.getByRole("switch")).toHaveAttribute("aria-checked", "true")
60
+ // Base UI Switch 点击是切换语义:checked=true 点击 → onCheckedChange(false)
61
+ //(仓内先例 design/canvas/panels/__tests__/rows.test.tsx「visible 翻转」)
62
+ fireEvent.click(screen.getByRole("switch"))
63
+ expect(onCheckedChange).toHaveBeenCalledWith(false)
64
+ onCheckedChange.mockClear()
65
+ rerender(
66
+ <PluginRow
67
+ icon={<Puzzle />}
68
+ title="开关行"
69
+ switch={{ checked: false, disabled: false, onCheckedChange }}
70
+ />,
71
+ )
72
+ expect(screen.getByRole("switch")).toHaveAttribute("aria-checked", "false")
73
+ fireEvent.click(screen.getByRole("switch"))
74
+ expect(onCheckedChange).toHaveBeenCalledWith(true)
75
+ })
76
+
77
+ it("menu 槽位渲染且点击不冒泡触发行点击", () => {
78
+ const onExpandedChange = vi.fn()
79
+ render(
80
+ <PluginRow
81
+ icon={<Puzzle />}
82
+ title="菜单行"
83
+ detail={<div>详情内容</div>}
84
+ expanded={false}
85
+ onExpandedChange={onExpandedChange}
86
+ menu={
87
+ <Button data-testid="row-menu" onClick={(e) => e.stopPropagation()}>
88
+ 菜单
89
+ </Button>
90
+ }
91
+ />,
92
+ )
93
+ expect(screen.getByTestId("row-menu")).toBeInTheDocument()
94
+ fireEvent.click(screen.getByTestId("row-menu"))
95
+ expect(onExpandedChange).not.toHaveBeenCalled()
96
+ })
97
+
98
+ it("detail 存在时行点击切换展开(受控)", () => {
99
+ const onExpandedChange = vi.fn()
100
+ const base = {
101
+ testId: "plugin-row",
102
+ icon: <Puzzle />,
103
+ title: "展开行",
104
+ detail: <div>详情</div>,
105
+ onExpandedChange,
106
+ }
107
+ const { rerender, container } = render(<PluginRow {...base} expanded={false} />)
108
+ fireEvent.click(screen.getByTestId("plugin-row"))
109
+ expect(onExpandedChange).toHaveBeenCalledWith(true)
110
+ const chevron = container.querySelector(".lucide-chevron-down")
111
+ expect(chevron).toBeTruthy()
112
+ expect(chevron!.getAttribute("class")).toContain("-rotate-90")
113
+ rerender(<PluginRow {...base} expanded={true} />)
114
+ expect(container.querySelector(".lucide-chevron-down")!.getAttribute("class")).toContain(
115
+ "rotate-0",
116
+ )
117
+ })
118
+
119
+ it("detail 行键盘可达:role=button + tabIndex + Enter/Space 切换展开", () => {
120
+ const onExpandedChange = vi.fn()
121
+ render(
122
+ <PluginRow
123
+ testId="plugin-row"
124
+ icon={<Puzzle />}
125
+ title="键盘行"
126
+ detail={<div>详情</div>}
127
+ expanded={false}
128
+ onExpandedChange={onExpandedChange}
129
+ />,
130
+ )
131
+ const row = screen.getByTestId("plugin-row")
132
+ // role=button + tabIndex=0 参与 Tab 序
133
+ expect(row.getAttribute("role")).toBe("button")
134
+ expect(row.getAttribute("tabindex")).toBe("0")
135
+ // Enter 切换展开
136
+ fireEvent.keyDown(row, { key: "Enter" })
137
+ expect(onExpandedChange).toHaveBeenCalledWith(true)
138
+ // Space 切换展开
139
+ fireEvent.keyDown(row, { key: " " })
140
+ expect(onExpandedChange).toHaveBeenCalledTimes(2)
141
+ })
142
+
143
+ it("无 detail 的行不参与键盘序(无 role/tabIndex)", () => {
144
+ render(<PluginRow testId="plugin-row" icon={<Puzzle />} title="普通行" />)
145
+ const row = screen.getByTestId("plugin-row")
146
+ expect(row.getAttribute("role")).toBeNull()
147
+ expect(row.getAttribute("tabindex")).toBeNull()
148
+ })
149
+ })
150
+
151
+ describe("PluginStatusDot", () => {
152
+ it("五态类映射", () => {
153
+ const cases: Array<{ status: PluginStatus; assert: (dot: HTMLElement) => void }> = [
154
+ { status: "activated", assert: (dot) => expect(dot).toHaveClass("bg-green-500") },
155
+ { status: "failed", assert: (dot) => expect(dot).toHaveClass("bg-red-500") },
156
+ { status: "deactivated", assert: (dot) => expect(dot).toHaveClass("bg-muted-foreground") },
157
+ {
158
+ status: "disabled",
159
+ assert: (dot) => {
160
+ expect(dot).toHaveClass("border-border", "bg-transparent")
161
+ // 空心:除 bg-transparent 外不含任何 bg- 实色
162
+ expect(dot.className).not.toMatch(/bg-(green|red|muted-foreground)/)
163
+ },
164
+ },
165
+ { status: "unknown", assert: (dot) => expect(dot).toHaveClass("bg-muted-foreground") },
166
+ ]
167
+ for (const c of cases) {
168
+ const { unmount } = render(<PluginStatusDot status={c.status} />)
169
+ c.assert(screen.getByTestId("plugin-status-dot"))
170
+ unmount()
171
+ }
172
+ })
173
+
174
+ it("unknown 态 Tooltip 含补充说明", async () => {
175
+ render(<PluginStatusDot status="unknown" />)
176
+ const dot = screen.getByTestId("plugin-status-dot")
177
+ const trigger = dot.closest('[data-slot="tooltip-trigger"]') as HTMLElement
178
+ expect(trigger).toBeTruthy()
179
+ fireEvent.mouseEnter(trigger)
180
+ fireEvent.mouseMove(trigger)
181
+ await waitFor(() => {
182
+ expect(screen.getAllByText(/组装期未见该 bundle/).length).toBeGreaterThan(0)
183
+ })
184
+ })
185
+
186
+ it("状态点 aria-label 可被屏幕阅读器读到(不依赖 hover Tooltip)", () => {
187
+ // 激活态:aria-label 含状态文案
188
+ const { unmount } = render(<PluginStatusDot status="activated" />)
189
+ const dot = screen.getByTestId("plugin-status-dot")
190
+ expect(dot.getAttribute("aria-label")).toBeTruthy()
191
+ expect(dot.getAttribute("aria-label")).toContain("已激活")
192
+ unmount()
193
+ // unknown 态:aria-label 含状态文案 + 组装期补充说明
194
+ render(<PluginStatusDot status="unknown" />)
195
+ const unknownDot = screen.getByTestId("plugin-status-dot")
196
+ expect(unknownDot.getAttribute("aria-label")).toContain("组装期未见该 bundle")
197
+ })
198
+ })
199
+
200
+ describe("PluginRow description Tooltip", () => {
201
+ it("description 溢出 Tooltip 显示全文", async () => {
202
+ const longDesc = "这是一个很长的插件描述文本".repeat(12)
203
+ render(<PluginRow icon={<Puzzle />} title="长描述行" description={longDesc} />)
204
+ const trigger = screen.getByText(longDesc).closest(
205
+ '[data-slot="tooltip-trigger"]',
206
+ ) as HTMLElement
207
+ expect(trigger).toBeTruthy()
208
+ fireEvent.mouseEnter(trigger)
209
+ fireEvent.mouseMove(trigger)
210
+ await waitFor(() => {
211
+ // 触发前仅描述 span 一处命中;hover 后 Tooltip 悬浮层再添一份 → ≥2
212
+ expect(screen.getAllByText(longDesc).length).toBeGreaterThan(1)
213
+ })
214
+ })
215
+ })
@@ -0,0 +1,204 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+
5
+ // BuiltinSection(Section B:内置七域启停 + 组装诊断,任务 4 交付,设计 §3.4)。含七域
6
+ // patch id 清单 / 静态图标映射 / 惰性名称描述映射(均仅本 Section 消费,随之迁出)。
7
+ // 由 PluginPage 装配,report 未下发时整组不渲染(页级容错)。
8
+
9
+ import { useState } from "react"
10
+ import type { ReactElement, ReactNode } from "react"
11
+ import {
12
+ BookOpen,
13
+ Bug,
14
+ FolderKanban,
15
+ Layers,
16
+ ListChecks,
17
+ PenTool,
18
+ SquareCheck,
19
+ } from "lucide-react"
20
+ import type { LucideIcon } from "lucide-react"
21
+ import { useMutation, useQueryClient } from "@tanstack/react-query"
22
+ import {
23
+ AlertDialog,
24
+ AlertDialogAction,
25
+ AlertDialogCancel,
26
+ AlertDialogContent,
27
+ AlertDialogDescription,
28
+ AlertDialogFooter,
29
+ AlertDialogHeader,
30
+ AlertDialogTitle,
31
+ } from "@/components/ui/alert-dialog"
32
+ import { HARNESS_PLUGIN_REPORT_QUERY_KEY } from "@/lib/queries/harness"
33
+ import { setBuiltinPluginEnabledFn } from "@/server/serverFns/harness/plugins"
34
+ import { PluginRow } from "./plugin-row"
35
+ import { m } from "@/paraglide/messages.js"
36
+ import type { HarnessReport } from "./plugin-types"
37
+
38
+ /** 内置域 patch id(base-patch 七域),本页 toggle 的域清单单一来源(迁旧面板原样)。 */
39
+ const BUILTIN_DOMAIN_IDS = [
40
+ "allblue/knowledge",
41
+ "allblue/project",
42
+ "allblue/story",
43
+ "allblue/bug",
44
+ "allblue/testcase",
45
+ "allblue/design",
46
+ "allblue/task",
47
+ ] as const
48
+
49
+ type BuiltinDomainId = (typeof BUILTIN_DOMAIN_IDS)[number]
50
+
51
+ /** 七域静态图标映射(i18n 实现约束:禁运行时字符串拼键,静态 Record 消费)。 */
52
+ const DOMAIN_ICONS: Record<BuiltinDomainId, LucideIcon> = {
53
+ "allblue/knowledge": BookOpen,
54
+ "allblue/project": FolderKanban,
55
+ "allblue/story": Layers,
56
+ "allblue/bug": Bug,
57
+ "allblue/testcase": ListChecks,
58
+ "allblue/design": PenTool,
59
+ "allblue/task": SquareCheck,
60
+ }
61
+
62
+ /**
63
+ * 七域名称/描述惰性映射:value 是 () => string,渲染期才调 m.*()——防模块求值时固化
64
+ * 语言(运行时切语言后仍能更新,同旧面板 STATUS_CONFIG 惰性函数先例)。
65
+ */
66
+ const DOMAIN_META: Record<BuiltinDomainId, { name: () => string; desc: () => string }> = {
67
+ "allblue/knowledge": {
68
+ name: () => m.harness_panel_plugin_domain_knowledge(),
69
+ desc: () => m.harness_panel_plugin_domain_knowledge_desc(),
70
+ },
71
+ "allblue/project": {
72
+ name: () => m.harness_panel_plugin_domain_project(),
73
+ desc: () => m.harness_panel_plugin_domain_project_desc(),
74
+ },
75
+ "allblue/story": {
76
+ name: () => m.harness_panel_plugin_domain_story(),
77
+ desc: () => m.harness_panel_plugin_domain_story_desc(),
78
+ },
79
+ "allblue/bug": {
80
+ name: () => m.harness_panel_plugin_domain_bug(),
81
+ desc: () => m.harness_panel_plugin_domain_bug_desc(),
82
+ },
83
+ "allblue/testcase": {
84
+ name: () => m.harness_panel_plugin_domain_testcase(),
85
+ desc: () => m.harness_panel_plugin_domain_testcase_desc(),
86
+ },
87
+ "allblue/design": {
88
+ name: () => m.harness_panel_plugin_domain_design(),
89
+ desc: () => m.harness_panel_plugin_domain_design_desc(),
90
+ },
91
+ "allblue/task": {
92
+ name: () => m.harness_panel_plugin_domain_task(),
93
+ desc: () => m.harness_panel_plugin_domain_task_desc(),
94
+ },
95
+ }
96
+
97
+ /**
98
+ * Section B:内置插件(七域启停 + 组装诊断,设计 §3.4)。自包含确认链:Switch 点击
99
+ * 先弹「重建会中断进行中回合」确认 AlertDialog(禁原生 confirm),Action 才调
100
+ * setBuiltinPluginEnabledFn;onSuccess invalidate report 键(重建后诊断刷新)。
101
+ * 行描述:域在 failed 桶 → errorLabel 摘要;deactivated 桶 → missingServices 摘要;
102
+ * 其余 → 功能一句话。错误/缺失明细入 detail(行点击展开诊断)。
103
+ */
104
+ export function BuiltinSection({
105
+ report,
106
+ canManage,
107
+ }: {
108
+ report: HarnessReport
109
+ canManage: boolean
110
+ }): ReactElement {
111
+ const queryClient = useQueryClient()
112
+ // 待确认的启停操作(AlertDialog):域 id + 目标态(迁旧面板 BuiltinTab state 原样)
113
+ const [pendingToggle, setPendingToggle] = useState<{ domain: string; enabled: boolean } | null>(
114
+ null,
115
+ )
116
+ const [expandedId, setExpandedId] = useState<string | null>(null)
117
+
118
+ const toggleMutation = useMutation({
119
+ mutationFn: (input: { domain: string; enabled: boolean }) =>
120
+ setBuiltinPluginEnabledFn({ data: input }),
121
+ onSuccess: () => {
122
+ queryClient.invalidateQueries({ queryKey: HARNESS_PLUGIN_REPORT_QUERY_KEY })
123
+ setPendingToggle(null)
124
+ },
125
+ })
126
+
127
+ const disabledIds = new Set(report.disabled.map((p) => p.id))
128
+
129
+ return (
130
+ <section className="space-y-1">
131
+ <h3 className="text-sm font-semibold">{m.harness_plugin_builtinTitle()}</h3>
132
+ <div className="space-y-1">
133
+ {BUILTIN_DOMAIN_IDS.map((id) => {
134
+ const Icon = DOMAIN_ICONS[id]
135
+ const failedEntry = report.failed.find((p) => p.id === id)
136
+ const deactivatedEntry = report.deactivated.find((p) => p.id === id)
137
+ let description = DOMAIN_META[id].desc()
138
+ let detail: ReactNode
139
+ if (failedEntry) {
140
+ description = m.harness_plugin_errorLabel({ error: failedEntry.error })
141
+ detail = (
142
+ <p className="break-all font-mono text-xs text-red-500">{failedEntry.error}</p>
143
+ )
144
+ } else if (deactivatedEntry && deactivatedEntry.missing.length > 0) {
145
+ description = m.harness_plugin_missingServices({
146
+ services: deactivatedEntry.missing.join(", "),
147
+ })
148
+ detail = (
149
+ <p className="break-all font-mono text-xs text-orange-500">
150
+ {deactivatedEntry.missing.join(", ")}
151
+ </p>
152
+ )
153
+ }
154
+ return (
155
+ <PluginRow
156
+ key={id}
157
+ testId={`builtin-row-${id}`}
158
+ icon={<Icon className="size-6 text-muted-foreground" />}
159
+ title={DOMAIN_META[id].name()}
160
+ description={description}
161
+ detail={detail}
162
+ expanded={expandedId === id}
163
+ onExpandedChange={(v) => setExpandedId(v ? id : null)}
164
+ switch={{
165
+ checked: !disabledIds.has(id),
166
+ disabled: !canManage || toggleMutation.isPending,
167
+ onCheckedChange: (enabled) => setPendingToggle({ domain: id, enabled }),
168
+ }}
169
+ />
170
+ )
171
+ })}
172
+ </div>
173
+
174
+ {/* 启停确认(迁旧面板 L329-355):提示重建会中断进行中回合(规格 §4.2.2) */}
175
+ <AlertDialog
176
+ open={pendingToggle !== null}
177
+ onOpenChange={(open) => {
178
+ if (!open) setPendingToggle(null)
179
+ }}
180
+ >
181
+ <AlertDialogContent>
182
+ <AlertDialogHeader>
183
+ <AlertDialogTitle>{m.harness_plugin_builtinToggleTitle()}</AlertDialogTitle>
184
+ <AlertDialogDescription>
185
+ {m.harness_plugin_restartConfirmDescription()}
186
+ </AlertDialogDescription>
187
+ </AlertDialogHeader>
188
+ <AlertDialogFooter>
189
+ <AlertDialogCancel onClick={() => setPendingToggle(null)}>
190
+ {m.harness_plugin_restartConfirmCancel()}
191
+ </AlertDialogCancel>
192
+ <AlertDialogAction
193
+ onClick={() => {
194
+ if (pendingToggle) toggleMutation.mutate(pendingToggle)
195
+ }}
196
+ >
197
+ {m.harness_plugin_restartConfirmAction()}
198
+ </AlertDialogAction>
199
+ </AlertDialogFooter>
200
+ </AlertDialogContent>
201
+ </AlertDialog>
202
+ </section>
203
+ )
204
+ }
@@ -0,0 +1,195 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+
5
+ // InstallDialog 添加插件对话框(任务 3,设计 §3.6):Dialog 基座(表单交互,非
6
+ // AlertDialog)+ label/Input + Collapsible 指引(默认收起,四形态示例 + 一键填入)+
7
+ // PRE-5 安全句常驻非折叠。点安装先开 PRE-5 确认 AlertDialog 叠层(Base UI 弹窗栈
8
+ // isTopmost:Cancel/Esc 只关叠层,外层 Dialog 保持 open),AlertDialog Action 才真正
9
+ // 调 installDshPluginFn。成功关双层 + invalidate 两键(任务 1 工厂常量)+ toast;
10
+ // blockedBuilds 非空 → onBlockedBuilds 上抛由页面 PRE-3 批准链接管(任务 4 消费);
11
+ // 失败 reason 原文内联展示于叠层内(不归类、不翻译,复审 R3-M7);异常 toast.error。
12
+ // 不做前端形态硬校验(inspect 先看再装在后端,硬校验会与后端六类 problem 漂移)。
13
+
14
+ import { useState } from "react"
15
+ import type { ReactElement } from "react"
16
+ import { ChevronDown, TriangleAlert } from "lucide-react"
17
+ import { useMutation, useQueryClient } from "@tanstack/react-query"
18
+ import { cn } from "cn"
19
+ import {
20
+ AlertDialog,
21
+ AlertDialogAction,
22
+ AlertDialogCancel,
23
+ AlertDialogContent,
24
+ AlertDialogDescription,
25
+ AlertDialogFooter,
26
+ AlertDialogHeader,
27
+ AlertDialogTitle,
28
+ } from "@/components/ui/alert-dialog"
29
+ import { Button } from "@/components/ui/button"
30
+ import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible"
31
+ import {
32
+ Dialog,
33
+ DialogContent,
34
+ DialogDescription,
35
+ DialogFooter,
36
+ DialogHeader,
37
+ DialogTitle,
38
+ } from "@/components/ui/dialog"
39
+ import { Input } from "@/components/ui/input"
40
+ import { toast } from "@/components/ui/toast"
41
+ import { DSH_INSTALLED_QUERY_KEY, HARNESS_PLUGIN_REPORT_QUERY_KEY } from "@/lib/queries/harness"
42
+ import { installDshPluginFn } from "@/server/serverFns/harness/dsh-plugins"
43
+ import { m } from "@/paraglide/messages.js"
44
+
45
+ export interface InstallDialogProps {
46
+ open: boolean
47
+ onOpenChange: (open: boolean) => void
48
+ canManage: boolean
49
+ /** 安装/更新返回 blockedBuilds 时上抛,由页面 PRE-3 批准链接管 */
50
+ onBlockedBuilds: (names: string[]) => void
51
+ }
52
+
53
+ /** 指引四形态示例(npm / git / tarball / 本地目录;技术串保留原文,同 placeholder 规则)。 */
54
+ const GUIDE_EXAMPLES = [
55
+ "@scope/dsh-plugin",
56
+ "git+https://github.com/owner/repo",
57
+ "./plugin-1.0.0.tgz",
58
+ "/path/to/plugin",
59
+ ] as const
60
+
61
+ /** 「填入示例」填充值(npm 形态,与 placeholder 示例同源)。 */
62
+ const EXAMPLE_SPEC = GUIDE_EXAMPLES[0]
63
+
64
+ export function InstallDialog(props: InstallDialogProps): ReactElement {
65
+ const { open, onOpenChange, canManage, onBlockedBuilds } = props
66
+ const [installSpec, setInstallSpec] = useState("")
67
+ const [consentOpen, setConsentOpen] = useState(false)
68
+ const [guideOpen, setGuideOpen] = useState(false)
69
+ const queryClient = useQueryClient()
70
+
71
+ const installMutation = useMutation({
72
+ mutationFn: (spec: string) => installDshPluginFn({ data: { spec } }),
73
+ onSuccess: (result) => {
74
+ if (!result.ok) {
75
+ // !ok:双层保持 open,reason 原文在 AlertDialog 内联展示(见下方渲染)
76
+ return
77
+ }
78
+ if (result.blockedBuilds.length > 0) {
79
+ // blockedBuilds 非空 → 上抛,由页面 PRE-3 批准链接管(任务 4 消费)
80
+ onBlockedBuilds(result.blockedBuilds)
81
+ }
82
+ // ok:关双层 + invalidate 两键 + 成功 toast
83
+ setConsentOpen(false)
84
+ onOpenChange(false)
85
+ queryClient.invalidateQueries({ queryKey: DSH_INSTALLED_QUERY_KEY })
86
+ queryClient.invalidateQueries({ queryKey: HARNESS_PLUGIN_REPORT_QUERY_KEY })
87
+ toast.success(m.harness_plugin_dshInstallSucceeded())
88
+ },
89
+ onError: (err) => {
90
+ toast.error(String(err))
91
+ },
92
+ })
93
+
94
+ const pending = installMutation.isPending
95
+ // !result.ok 的 reason 原文(=== false 判别收窄,避免 !ok 联合收窄的 TS 兼容歧义)
96
+ const failedReason =
97
+ installMutation.isSuccess && installMutation.data && installMutation.data.ok === false
98
+ ? installMutation.data.reason
99
+ : null
100
+
101
+ return (
102
+ <Dialog open={open} onOpenChange={onOpenChange}>
103
+ <DialogContent className="gap-4">
104
+ <DialogHeader>
105
+ <DialogTitle>{m.harness_plugin_dshInstallTitle()}</DialogTitle>
106
+ <DialogDescription>{m.harness_panel_plugin_install_label()}</DialogDescription>
107
+ </DialogHeader>
108
+ <Input
109
+ value={installSpec}
110
+ onChange={(e) => setInstallSpec(e.target.value)}
111
+ placeholder={m.harness_plugin_dshInstallPlaceholder()}
112
+ disabled={pending}
113
+ />
114
+ <Collapsible open={guideOpen} onOpenChange={setGuideOpen}>
115
+ <CollapsibleTrigger className="flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground">
116
+ <ChevronDown
117
+ className={cn(
118
+ "size-3.5 shrink-0 transition-transform",
119
+ guideOpen ? "rotate-0" : "-rotate-90",
120
+ )}
121
+ />
122
+ {m.harness_panel_plugin_install_guide()}
123
+ </CollapsibleTrigger>
124
+ <CollapsibleContent className="mt-2 space-y-2">
125
+ <div className="space-y-0.5 font-mono text-xs text-muted-foreground">
126
+ {GUIDE_EXAMPLES.map((example) => (
127
+ <div key={example}>{example}</div>
128
+ ))}
129
+ </div>
130
+ <Button
131
+ variant="outline"
132
+ size="sm"
133
+ className="h-7 text-xs"
134
+ disabled={pending}
135
+ onClick={() => setInstallSpec(EXAMPLE_SPEC)}
136
+ >
137
+ {m.harness_panel_plugin_install_guide_example()}
138
+ </Button>
139
+ </CollapsibleContent>
140
+ </Collapsible>
141
+ {/* PRE-5 安全句:常驻非折叠(与叠层 body 同一条 dshInstallConsentBody) */}
142
+ <p className="flex items-start gap-1.5 text-xs text-muted-foreground">
143
+ <TriangleAlert className="mt-0.5 size-3.5 shrink-0 text-amber-500" />
144
+ {m.harness_plugin_dshInstallConsentBody()}
145
+ </p>
146
+ <DialogFooter>
147
+ <Button variant="outline" disabled={pending} onClick={() => onOpenChange(false)}>
148
+ {m.harness_plugin_dshInstallCancel()}
149
+ </Button>
150
+ <Button
151
+ disabled={installSpec.trim() === "" || pending || !canManage}
152
+ onClick={() => {
153
+ // 重开 PRE-5 叠层前清上一次尝试的失败残留(isError / !ok reason),
154
+ // 否则 Cancel 后再点安装会立即重现旧错误直到下次 mutate 覆盖。
155
+ installMutation.reset()
156
+ setConsentOpen(true)
157
+ }}
158
+ >
159
+ {pending ? m.harness_plugin_dshInstalling() : m.harness_plugin_dshInstallAction()}
160
+ </Button>
161
+ </DialogFooter>
162
+ </DialogContent>
163
+
164
+ {/* PRE-5 确认叠层(open 态叠加于 Dialog 之上;Action 才调 installMutation) */}
165
+ <AlertDialog open={consentOpen} onOpenChange={setConsentOpen}>
166
+ <AlertDialogContent>
167
+ <AlertDialogHeader>
168
+ <AlertDialogTitle>{m.harness_plugin_dshInstallConsentTitle()}</AlertDialogTitle>
169
+ <AlertDialogDescription>
170
+ {m.harness_plugin_dshInstallConsentBody()}
171
+ </AlertDialogDescription>
172
+ </AlertDialogHeader>
173
+ {/* 就地反馈沿用(isError / !result.ok 内联于叠层内;ok 关双层走 toast) */}
174
+ {installMutation.isError && (
175
+ <p className="break-all text-sm text-red-500">
176
+ {m.harness_plugin_dshInstallFailed({ reason: String(installMutation.error) })}
177
+ </p>
178
+ )}
179
+ {failedReason && <p className="break-all text-sm text-red-500">{failedReason}</p>}
180
+ <AlertDialogFooter>
181
+ <AlertDialogCancel disabled={pending}>
182
+ {m.harness_plugin_dshInstallCancel()}
183
+ </AlertDialogCancel>
184
+ <AlertDialogAction
185
+ disabled={pending}
186
+ onClick={() => installMutation.mutate(installSpec.trim())}
187
+ >
188
+ {pending ? m.harness_plugin_dshInstalling() : m.harness_plugin_dshInstallConfirm()}
189
+ </AlertDialogAction>
190
+ </AlertDialogFooter>
191
+ </AlertDialogContent>
192
+ </AlertDialog>
193
+ </Dialog>
194
+ )
195
+ }