@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
@@ -31,7 +31,7 @@
31
31
 
32
32
  import { z } from "zod"
33
33
  import type { DockTab, PaneNode, FloatPane, Rect } from "./dock-layout"
34
- import { GUIDE_KIND, createGuideTab } from "./dock-layout"
34
+ import { createGuideTab } from "./dock-layout"
35
35
  import { MIN_PANE_FRACTION } from "./dock-spec"
36
36
 
37
37
  // ---------------------------------------------------------------------------
@@ -209,7 +209,8 @@ function asPane(n: PaneNode): Extract<PaneNode, { kind: "pane" }> | null {
209
209
  // 默认布局 / 导出函数
210
210
  // ---------------------------------------------------------------------------
211
211
 
212
- /** 默认 guide 单页布局(无存档 / 校验失败的回落;自身过 v2 校验)。 */
212
+ /** 默认 guide 单页布局(无存档 / 校验失败的回落;自身过 v2 校验)。
213
+ * expanded=false:进入 Harness 右侧面板默认收起(2026-11-19 用户裁决)。 */
213
214
  export function defaultDockLayout(): PersistedDockStateV2 {
214
215
  const guide = createGuideTab()
215
216
  return {
@@ -219,7 +220,7 @@ export function defaultDockLayout(): PersistedDockStateV2 {
219
220
  rootId: "root",
220
221
  floats: [],
221
222
  activePaneId: "root",
222
- expanded: true,
223
+ expanded: false,
223
224
  }
224
225
  }
225
226
 
@@ -270,7 +271,8 @@ export function migrateV1ToV2(v1: z.infer<typeof persistedDockSchemaV1>): Persis
270
271
  rootId: "root",
271
272
  floats: [],
272
273
  activePaneId: "root",
273
- expanded: true,
274
+ // v1 无展开态语义(旧扁平 dock 恒展开);迁移产物对齐新默认收起(2026-11-19 用户裁决)
275
+ expanded: false,
274
276
  }
275
277
  // 迁移后过一遍 v2 校验(结构 + 引用完整性);不过则回落默认布局。
276
278
  const parsed = persistedDockSchemaV2.safeParse(state)
@@ -137,6 +137,8 @@ export function createDockRegistry() {
137
137
 
138
138
  // ⚠ panelVersion 并入 state(文件头注释):注册/注销/切线程/expanded 变更手动 +1,
139
139
  // 布局纯函数自带 +1。expanded 随 persist v2 载荷持久化(设计 §3.7),故并入 runtime 态。
140
+ // 初始 expanded=false:进入 Harness 右侧面板默认收起(2026-11-19 用户裁决),首帧
141
+ // (switchThread effect 未跑)也不闪现空面板。
140
142
  let state: DockStateV2 = {
141
143
  tabs: {},
142
144
  nodes: { root: { id: "root", kind: "pane", tabIds: [], activeTabId: null } },
@@ -145,7 +147,7 @@ export function createDockRegistry() {
145
147
  activePaneId: "root",
146
148
  panelVersion: 0,
147
149
  }
148
- let expanded = true
150
+ let expanded = false
149
151
 
150
152
  const listeners = new Set<() => void>()
151
153
  const emit = () => listeners.forEach((l) => l())
@@ -155,7 +157,10 @@ export function createDockRegistry() {
155
157
  let instanceSeq = 0
156
158
 
157
159
  // per-thread 持久化(设计 §3.7):write-through,每次变更即存;switchThread 存旧恢复新。
158
- let currentThreadId: string | null = null
160
+ // undefined = 尚未切换过(sentinel,非合法线程 id):首个 switchThread(含 null)必须
161
+ // 真正执行一次(种默认 guide 布局)——初始 null === null no-op 会把上面的空 root pane
162
+ // 留在屏上,「打开面板是空页」(2026-11-19 用户反馈)根因之一。
163
+ let currentThreadId: string | null | undefined = undefined
159
164
 
160
165
  const toPersisted = (): PersistedDockStateV2 => ({
161
166
  version: 2,
@@ -529,23 +534,39 @@ export function createDockRegistry() {
529
534
  /**
530
535
  * 切线程:存旧线程 v2 布局(write-through 期间已最新,此处兜底)→ 恢复新线程存档
531
536
  * (无存档 / 校验失败 → defaultDockLayout)。panelVersion 继续单调递增(#730 语义),
532
- * 恢复的布局覆盖内存态,expanded 一并恢复。同一线程重复切换 no-op(防 effect 重跑闪烁)。
537
+ * 恢复的布局覆盖内存态。同一线程重复切换 no-op(防 effect 重跑闪烁)。
538
+ * expanded:有存档按存档恢复(模块内切线程的 per-thread 记忆);无存档保持当前态
539
+ * ——切到无存档线程不弹开也不强制收起;进入模块的默认收起由 route.lazy 入口
540
+ * effect 强制(2026-11-19 用户裁决),不在此处掺和。
533
541
  */
534
542
  switchThread(threadId: string | null) {
535
543
  if (threadId === currentThreadId) return
536
544
  if (currentThreadId) saveDockState(currentThreadId, toPersisted())
537
545
  currentThreadId = threadId
538
- // 无存档 / 校验失败 → defaultDockLayout(设计 §3.7:回落默认 guide 单页布局)
539
- const restored = loadDockState(threadId) ?? defaultDockLayout()
540
- expanded = restored.expanded
541
- state = {
542
- tabs: restored.tabs,
543
- nodes: restored.nodes,
544
- rootId: restored.rootId,
545
- floats: restored.floats,
546
- activePaneId: restored.activePaneId,
547
- // panelVersion 不持久化(dock-persist 载荷无此字段),恢复时自行递增
548
- panelVersion: state.panelVersion + 1,
546
+ const restored = loadDockState(threadId)
547
+ if (restored) {
548
+ expanded = restored.expanded
549
+ state = {
550
+ tabs: restored.tabs,
551
+ nodes: restored.nodes,
552
+ rootId: restored.rootId,
553
+ floats: restored.floats,
554
+ activePaneId: restored.activePaneId,
555
+ // panelVersion 不持久化(dock-persist 载荷无此字段),恢复时自行递增
556
+ panelVersion: state.panelVersion + 1,
557
+ }
558
+ } else {
559
+ // 无存档(无会话 / 新线程 / 校验失败)→ 默认 guide 单页布局(设计 §3.7);
560
+ // 首次切换(sentinel)也走此支,把初始空 root pane 换成 guide 开始页。
561
+ const d = defaultDockLayout()
562
+ state = {
563
+ tabs: d.tabs,
564
+ nodes: d.nodes,
565
+ rootId: d.rootId,
566
+ floats: d.floats,
567
+ activePaneId: d.activePaneId,
568
+ panelVersion: state.panelVersion + 1,
569
+ }
549
570
  }
550
571
  emit()
551
572
  },
@@ -169,6 +169,8 @@ export function DockSurface({
169
169
  createTodoKind({ chatMessagesRef, title: m.harness_panel_todo() }),
170
170
  createPluginKind({
171
171
  title: m.harness_panel_guide_plugin(),
172
+ guideTitle: m.harness_panel_guide_plugin(),
173
+ guideDescription: m.harness_panel_plugin_subtitle(),
172
174
  onClose: () => dockRegistry.closeTab("plugin"),
173
175
  }),
174
176
  createFilesKind({
@@ -40,7 +40,6 @@ import { formatForDisplay } from "@tanstack/hotkeys"
40
40
  import { dockRegistry, type DockPanelKind } from "./dock-registry"
41
41
  import { appHotkeys, formatAppHotkeyForBadge, type AppHotkeyId } from "@/lib/hotkeys/registry"
42
42
  import {
43
- readTerminalShellPref,
44
43
  writeTerminalShellPref,
45
44
  } from "@/components/harness/extension-panel/panels/terminal/shell-pref"
46
45
  import { Kbd } from "@/components/ui/kbd"
@@ -53,8 +52,8 @@ import {
53
52
  import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"
54
53
  import { m } from "@/paraglide/messages.js"
55
54
 
56
- /** 描述显隐上限(DSH MAX_DESCRIBED_ENTRIES):≤4 卡显描述,更多则全隐保持轻量。 */
57
- const MAX_DESCRIBED_ENTRIES = 4
55
+ /** 描述显隐上限(DSH MAX_DESCRIBED_ENTRIES):≤5 卡显描述(DSH 上限对齐 5 卡),更多则全隐保持轻量。 */
56
+ const MAX_DESCRIBED_ENTRIES = 5
58
57
 
59
58
  /**
60
59
  * kind.shortcutId(AppHotkeyId 字符串)→ 符号形 chord(⇧⌘B 等,与 DSH 菜单一致;
@@ -177,6 +176,8 @@ function TerminalShellMenu({
177
176
  <DropdownMenuTrigger
178
177
  data-testid="dock-guide-shell-trigger"
179
178
  aria-label={m.harness_panel_shellLabel()}
179
+ // 卡主体是可点容器(开默认 shell),chevron 点击须截停冒泡,防误开卡
180
+ onClick={(e) => e.stopPropagation()}
180
181
  className="flex size-6 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
181
182
  >
182
183
  <svg width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true">
@@ -258,6 +259,54 @@ function GuideEntryCard({
258
259
  void dockRegistry.openKind(entry.kind, { replaceGuide: true })
259
260
  }
260
261
 
262
+ // 终端卡:主体开默认 shell(记偏好),标题行尾 chevron 下拉选具体 shell(2026-11-19
263
+ // 用户裁决:chevron 紧跟标题后,不再绝对定位于卡右缘——与快捷键徽标位置重合)。
264
+ // 卡主体是容器 div(承接整卡点击:图标/描述/留白),标题是独立 button(键盘可达),
265
+ // chevron 是兄弟节点——HTML 禁止交互元素嵌套(button 内不得再有 button),不能落进
266
+ // 标题按钮子树。disabled 终端卡不渲染 chevron(走下方 button 卡版式)。
267
+ const withShellChevron = entry.dropdown === "shell" && !disabled
268
+
269
+ if (withShellChevron) {
270
+ return (
271
+ <div
272
+ data-testid={`dock-guide-entry-${entry.kind}`}
273
+ onClick={onOpen}
274
+ className="flex min-h-14 w-full max-w-95 items-center gap-3.5 rounded-xl border-[0.5px] border-border/60 bg-card px-5 py-3.5 text-left transition-colors hover:bg-muted"
275
+ >
276
+ <span
277
+ className={`flex flex-none items-center justify-center text-muted-foreground [&_svg]:size-full ${hasDescription ? "size-6.5" : "size-5.5"}`}
278
+ >
279
+ {entry.icon}
280
+ </span>
281
+ <span className="flex min-w-0 flex-1 flex-col gap-[3px]">
282
+ <span className="flex min-w-0 items-center gap-1.5">
283
+ <button type="button" className="min-w-0 truncate text-sm leading-[1.4]">
284
+ {entry.title}
285
+ </button>
286
+ <TerminalShellMenu
287
+ threadId={threadId}
288
+ onPick={(shell) => {
289
+ writeTerminalShellPref(shell)
290
+ // tab 标题 = shell 名(设计 §4.2);服务端 create 实际解析的 shell 与偏好一致。
291
+ void dockRegistry.openKind(entry.kind, {
292
+ replaceGuide: true,
293
+ title: shell,
294
+ })
295
+ }}
296
+ />
297
+ </span>
298
+ {hasDescription && (
299
+ <span className="truncate text-[11px] leading-[1.4] text-muted-foreground">
300
+ {entry.description}
301
+ </span>
302
+ )}
303
+ </span>
304
+ {/* 快捷键徽标(P1d 接真 chord:shortcutId → 符号形;非法/缺省不渲染空壳,DSH 同款) */}
305
+ {shortcut ? <Kbd>{shortcut}</Kbd> : null}
306
+ </div>
307
+ )
308
+ }
309
+
261
310
  const card = (
262
311
  <button
263
312
  type="button"
@@ -285,32 +334,6 @@ function GuideEntryCard({
285
334
  </button>
286
335
  )
287
336
 
288
- // 终端卡:主体开默认 shell(记偏好),标题行右 chevron 下拉选具体 shell。
289
- // 卡为 button,chevron 不能嵌套 button(HTML 禁止交互元素嵌套)→ 包一层 relative div,
290
- // chevron 绝对定位于右缘(不落进 button 子树)。disabled 终端卡不渲染 chevron。
291
- const withShellChevron = entry.dropdown === "shell" && !disabled
292
-
293
- const wrapped = withShellChevron ? (
294
- <div className="relative w-full max-w-95">
295
- {card}
296
- <div className="absolute right-3 top-1/2 -translate-y-1/2">
297
- <TerminalShellMenu
298
- threadId={threadId}
299
- onPick={(shell) => {
300
- writeTerminalShellPref(shell)
301
- // tab 标题 = shell 名(设计 §4.2);服务端 create 实际解析的 shell 与偏好一致。
302
- void dockRegistry.openKind(entry.kind, {
303
- replaceGuide: true,
304
- title: shell,
305
- })
306
- }}
307
- />
308
- </div>
309
- </div>
310
- ) : (
311
- card
312
- )
313
-
314
337
  if (disabled) {
315
338
  return (
316
339
  <Tooltip>
@@ -320,19 +343,21 @@ function GuideEntryCard({
320
343
  <span className="flex w-full max-w-95 cursor-not-allowed" />
321
344
  }
322
345
  >
323
- {wrapped}
346
+ {card}
324
347
  </TooltipTrigger>
325
348
  <TooltipContent>{m.harness_panel_unsupported()}</TooltipContent>
326
349
  </Tooltip>
327
350
  )
328
351
  }
329
352
 
330
- return wrapped
353
+ return card
331
354
  }
332
355
 
333
356
  /** More 卡(固定入口,非 listKinds 派生):changes/todo/plugin 行 + 浏览更多插件。 */
334
357
  function GuideMoreCard() {
335
358
  // More 菜单行 = 无 guide 字段的固定集合(设计 §3.3:changes/todo/plugin 属 More)。
359
+ // 注:plugin 现已升为 Guide 第五卡(带 guide 字段),但 More 行按 2026-11-19 用户裁决 ① 原样保留
360
+ // ——Guide 卡 + More 行 + 「浏览更多插件」三入口并存,不删 More 行。
336
361
  // 各行 availability 恒 on(changes/todo/plugin 无 availability 门控),但仍经
337
362
  // resolveAvailability 求值以对齐未来门控;未注册 kind → 行置灰不可点。
338
363
  const moreKinds: { kind: string; title: string }[] = [
@@ -395,26 +420,31 @@ function GuideMoreCard() {
395
420
  */
396
421
  export function GuidePage({ threadId }: { threadId?: string | null }) {
397
422
  const entries = collectGuideEntries(dockRegistry.listKinds())
398
- // ≤4 卡显描述(当前恰 4 张入口卡 → 描述全显)
423
+ // ≤5 卡显描述(当前恰 5 张入口卡:files/terminal/browser/media/plugin → 描述全显)
399
424
  const described = entries.length <= MAX_DESCRIBED_ENTRIES
400
425
 
426
+ // 两层滚动结构(计划复审 P2-7 技术修正):现状单层 `min-h-full + justify-center` 下根随内容
427
+ // 增长、自身永不滚动,单纯加 overflow-y-auto 不生效。改外层滚动根 `h-full overflow-y-auto`
428
+ // + 内层承接原 flex 居中类——内容矮时内层居中、高时外层滚动(溢出的 unsafe centering 一并消除)。
401
429
  return (
402
430
  <div
403
431
  data-testid="dock-guide-page"
404
- className="flex min-h-full flex-col items-center justify-center gap-3.5 px-6"
432
+ className="h-full overflow-y-auto"
405
433
  >
406
- <GuideHero />
407
- {entries.map((entry) => (
408
- <GuideEntryCard
409
- key={entry.kind}
410
- entry={entry}
411
- described={described}
412
- threadId={threadId}
413
- />
414
- ))}
415
- <GuideMoreCard />
416
- {/* 尾部 10% 抬升 spacer(DSH .guide::after flex:0 1 10% 的 padding 等价实现) */}
417
- <span aria-hidden="true" className="flex-[0_1_10%]" />
434
+ <div className="flex min-h-full flex-col items-center justify-center gap-3.5 px-6">
435
+ <GuideHero />
436
+ {entries.map((entry) => (
437
+ <GuideEntryCard
438
+ key={entry.kind}
439
+ entry={entry}
440
+ described={described}
441
+ threadId={threadId}
442
+ />
443
+ ))}
444
+ <GuideMoreCard />
445
+ {/* 尾部 10% 抬升 spacer(DSH .guide::after flex:0 1 10% 的 padding 等价实现) */}
446
+ <span aria-hidden="true" className="flex-[0_1_10%]" />
447
+ </div>
418
448
  </div>
419
449
  )
420
450
  }
@@ -151,10 +151,13 @@ beforeEach(() => {
151
151
  bridge.release.mockResolvedValue(undefined)
152
152
  // jsdom 无 webview 元素:拦截 createElement("webview")
153
153
  origCreate = document.createElement.bind(document)
154
- vi.spyOn(document, "createElement").mockImplementation((tag: string) => {
154
+ // mockImplementation 的参数签名须匹配 createElement 重载表("webview" 专属
155
+ // WebviewTag 返回,@types/react 19.3+)——整体函数 cast 放宽,双端(@types/react
156
+ // lock 版本差异)typecheck 稳健。
157
+ vi.spyOn(document, "createElement").mockImplementation(((tag: string) => {
155
158
  if (tag === "webview") return makeMockWebview() as unknown as HTMLElement
156
159
  return origCreate(tag)
157
- })
160
+ }) as unknown as typeof document.createElement)
158
161
  })
159
162
 
160
163
  afterEach(() => {
@@ -0,0 +1,260 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+
5
+ // InstallDialog 添加插件对话框(任务 3,设计 §3.6)单测 7 用例:
6
+ // 1 空 spec/只读禁用 2 安全句常驻 + 指引一键填入 3 PRE-5 叠层安装链(Esc 只关
7
+ // AlertDialog) 4 成功关双层 + invalidate 两键 5 blockedBuilds 上抛 6 失败 reason
8
+ // 原文内联 7 进行态禁用。
9
+ //
10
+ // ⚠ 双渲染碰撞(复审 P3 预判):Dialog 常驻安全句与 AlertDialog body 是同一条
11
+ // dshInstallConsentBody,叠层期两处同时渲染属预期——文案断言一律 getAllByText(…).length ≥ 1,
12
+ // 禁单匹配 getByByText。
13
+ // serverFn mock 沿用任务 1 先例(harness-plugin-queries.test.ts):mock 具名导出 +
14
+ // 先 mock 后 import;QueryClient 配置沿用 workspace-browser-sync.test.ts:136。
15
+ // locale 由 setup.ts 强制 zh,文案断言直接用 zh 字面量(同 plugin-row.test.tsx)。
16
+
17
+ import { useState } from "react"
18
+ import { beforeEach, describe, expect, it, vi } from "vitest"
19
+ import { fireEvent, render, screen, waitFor } from "@testing-library/react"
20
+ import { QueryClient, QueryClientProvider } from "@tanstack/react-query"
21
+
22
+ const h = vi.hoisted(() => ({
23
+ installFn: vi.fn(),
24
+ toast: {
25
+ success: vi.fn(),
26
+ error: vi.fn(),
27
+ warning: vi.fn(),
28
+ info: vi.fn(),
29
+ loading: vi.fn(),
30
+ message: vi.fn(),
31
+ dismiss: vi.fn(),
32
+ promise: vi.fn(),
33
+ },
34
+ }))
35
+
36
+ vi.mock("@/server/serverFns/harness/dsh-plugins", () => ({
37
+ installDshPluginFn: h.installFn,
38
+ }))
39
+ // 只 mock 组件消费的两个键常量(避免拉起 lib/queries/harness 的整条 serverFn 依赖链);
40
+ // 键值与真实导出逐字一致,真实键对账由 harness-plugin-queries.test.ts 钉住。
41
+ vi.mock("@/lib/queries/harness", () => ({
42
+ DSH_INSTALLED_QUERY_KEY: ["harness-dsh-installed"],
43
+ HARNESS_PLUGIN_REPORT_QUERY_KEY: ["harness-plugin-report"],
44
+ }))
45
+ vi.mock("@/components/ui/toast", () => ({ toast: h.toast }))
46
+
47
+ import { InstallDialog } from "../install-dialog"
48
+
49
+ // zh 文案字面量(setup.ts overwriteGetLocale(() => 'zh'),与 messages/zh.json 同源)
50
+ const TITLE = "安装 DSH 插件"
51
+ const CONSENT_BODY =
52
+ "插件在本机以你的权限运行,来源不明可能损坏系统或泄露数据。请仅安装信任来源。"
53
+ const GUIDE = "安装指引"
54
+ const FILL_EXAMPLE = "填入示例"
55
+ const CONFIRM = "确认安装"
56
+ const CANCEL = "取消"
57
+ const INSTALL_ACTION = "安装"
58
+ const INSTALLING = "正在检查并安装…"
59
+ const SUCCEEDED = "安装完成"
60
+ const PLACEHOLDER = "输入安装来源,如 @scope/dsh-plugin 或 git+https://…"
61
+ // 指引四形态示例的代表行(git 形态;初始收起态断言用)
62
+ const GUIDE_EXAMPLE_LINE = "git+https://github.com/owner/repo"
63
+ const REASON = "pnpm-add-failed (status 1)…"
64
+
65
+ function makeClient() {
66
+ return new QueryClient({
67
+ defaultOptions: { queries: { retry: false }, mutations: { retry: false } },
68
+ })
69
+ }
70
+
71
+ /** 受控 open 的宿主:onOpenChange(false) 真实关 Dialog(关双层断言的前提) */
72
+ function TestHost(props: {
73
+ client: QueryClient
74
+ canManage: boolean
75
+ onBlockedBuilds: (names: string[]) => void
76
+ }) {
77
+ const [open, setOpen] = useState(true)
78
+ return (
79
+ <QueryClientProvider client={props.client}>
80
+ <InstallDialog
81
+ open={open}
82
+ onOpenChange={setOpen}
83
+ canManage={props.canManage}
84
+ onBlockedBuilds={props.onBlockedBuilds}
85
+ />
86
+ </QueryClientProvider>
87
+ )
88
+ }
89
+
90
+ function renderDialog(opts?: {
91
+ canManage?: boolean
92
+ onBlockedBuilds?: (names: string[]) => void
93
+ }) {
94
+ const client = makeClient()
95
+ const canManage = opts?.canManage ?? true
96
+ const onBlockedBuilds = opts?.onBlockedBuilds ?? (() => {})
97
+ const view = render(
98
+ <TestHost client={client} canManage={canManage} onBlockedBuilds={onBlockedBuilds} />,
99
+ )
100
+ return { ...view, client }
101
+ }
102
+
103
+ function typeSpec(spec: string) {
104
+ fireEvent.change(screen.getByPlaceholderText(PLACEHOLDER), { target: { value: spec } })
105
+ }
106
+
107
+ function clickInstall() {
108
+ fireEvent.click(screen.getByRole("button", { name: INSTALL_ACTION }))
109
+ }
110
+
111
+ beforeEach(() => {
112
+ vi.resetAllMocks()
113
+ })
114
+
115
+ describe("InstallDialog", () => {
116
+ it("空 spec 或只读时安装钮 disabled", () => {
117
+ const view = renderDialog()
118
+ // 空输入 → disabled
119
+ expect(screen.getByRole("button", { name: INSTALL_ACTION })).toBeDisabled()
120
+ // 填入 spec(含首尾空白,trim 后非空)→ 可点
121
+ typeSpec(" @scope/dsh-plugin ")
122
+ expect(screen.getByRole("button", { name: INSTALL_ACTION })).toBeEnabled()
123
+ // canManage=false → disabled
124
+ view.rerender(
125
+ <TestHost client={view.client} canManage={false} onBlockedBuilds={() => {}} />,
126
+ )
127
+ expect(screen.getByRole("button", { name: INSTALL_ACTION })).toBeDisabled()
128
+ })
129
+
130
+ it("安全句常驻 + 指引默认收起,展开可一键填入示例", () => {
131
+ renderDialog()
132
+ // 安全句常驻(getAllByText:叠层期可能与 AlertDialog body 双渲染)
133
+ expect(screen.getAllByText(CONSENT_BODY).length).toBeGreaterThanOrEqual(1)
134
+ // 指引默认收起:示例内容不在文档
135
+ expect(screen.queryByText(GUIDE_EXAMPLE_LINE)).not.toBeInTheDocument()
136
+ // 展开后指引内容出现
137
+ fireEvent.click(screen.getByRole("button", { name: GUIDE }))
138
+ expect(screen.getByText(GUIDE_EXAMPLE_LINE)).toBeInTheDocument()
139
+ // 一键填入示例 → Input 值非空
140
+ fireEvent.click(screen.getByRole("button", { name: FILL_EXAMPLE }))
141
+ const input = screen.getByPlaceholderText(PLACEHOLDER) as HTMLInputElement
142
+ expect(input.value.length).toBeGreaterThan(0)
143
+ })
144
+
145
+ it("安装链:点安装只开 PRE-5,Action 才调 installDshPluginFn;Esc 只关 AlertDialog 不关 Dialog", async () => {
146
+ h.installFn.mockResolvedValue({ ok: true, bundle: { name: "x" }, blockedBuilds: [] })
147
+ renderDialog()
148
+ typeSpec(" @scope/dsh-plugin ")
149
+ clickInstall()
150
+ // 只开 PRE-5:AlertDialog 出现,installDshPluginFn 未被调
151
+ expect(screen.getByRole("alertdialog")).toBeInTheDocument()
152
+ expect(h.installFn).not.toHaveBeenCalled()
153
+ // Esc 只关 AlertDialog,外层 Dialog 保持 open
154
+ fireEvent.keyDown(document, { key: "Escape" })
155
+ await waitFor(() => {
156
+ expect(screen.queryByRole("alertdialog")).not.toBeInTheDocument()
157
+ })
158
+ expect(screen.getByText(TITLE)).toBeInTheDocument()
159
+ // 再点安装 → AlertDialog 复开;Action 才调 installDshPluginFn(trim 后 spec,一次)
160
+ clickInstall()
161
+ expect(screen.getByRole("alertdialog")).toBeInTheDocument()
162
+ fireEvent.click(screen.getByRole("button", { name: CONFIRM }))
163
+ await waitFor(() => {
164
+ expect(h.installFn).toHaveBeenCalledTimes(1)
165
+ })
166
+ expect(h.installFn).toHaveBeenCalledWith({ data: { spec: "@scope/dsh-plugin" } })
167
+ })
168
+
169
+ it("成功(无 blockedBuilds)关双层并 invalidate 两键", async () => {
170
+ h.installFn.mockResolvedValue({ ok: true, bundle: { name: "x" }, blockedBuilds: [] })
171
+ const { client } = renderDialog()
172
+ const invalidateSpy = vi.spyOn(client, "invalidateQueries")
173
+ typeSpec("@scope/dsh-plugin")
174
+ clickInstall()
175
+ fireEvent.click(screen.getByRole("button", { name: CONFIRM }))
176
+ await waitFor(() => {
177
+ expect(invalidateSpy).toHaveBeenCalledWith({ queryKey: ["harness-dsh-installed"] })
178
+ })
179
+ expect(invalidateSpy).toHaveBeenCalledWith({ queryKey: ["harness-plugin-report"] })
180
+ expect(h.toast.success).toHaveBeenCalledWith(SUCCEEDED)
181
+ // 关双层:AlertDialog 与 Dialog 都消失
182
+ await waitFor(() => {
183
+ expect(screen.queryByRole("alertdialog")).not.toBeInTheDocument()
184
+ expect(screen.queryByText(TITLE)).not.toBeInTheDocument()
185
+ })
186
+ })
187
+
188
+ it("blockedBuilds 上抛", async () => {
189
+ h.installFn.mockResolvedValue({ ok: true, bundle: { name: "x" }, blockedBuilds: ["pkg-a"] })
190
+ const onBlockedBuilds = vi.fn()
191
+ renderDialog({ onBlockedBuilds })
192
+ typeSpec("@scope/dsh-plugin")
193
+ clickInstall()
194
+ fireEvent.click(screen.getByRole("button", { name: CONFIRM }))
195
+ await waitFor(() => {
196
+ expect(onBlockedBuilds).toHaveBeenCalledWith(["pkg-a"])
197
+ })
198
+ // 关双层
199
+ await waitFor(() => {
200
+ expect(screen.queryByRole("alertdialog")).not.toBeInTheDocument()
201
+ expect(screen.queryByText(TITLE)).not.toBeInTheDocument()
202
+ })
203
+ })
204
+
205
+ it("失败 reason 原文内联,Dialog 不自动关闭", async () => {
206
+ h.installFn.mockResolvedValue({ ok: false, reason: REASON })
207
+ renderDialog()
208
+ typeSpec("@scope/dsh-plugin")
209
+ clickInstall()
210
+ fireEvent.click(screen.getByRole("button", { name: CONFIRM }))
211
+ // reason 原文内联(不归类、不翻译;getAllByText 防碰撞)
212
+ await waitFor(() => {
213
+ expect(screen.getAllByText(REASON).length).toBeGreaterThanOrEqual(1)
214
+ })
215
+ // Dialog 不自动关闭(叠层也不关)
216
+ expect(screen.getByText(TITLE)).toBeInTheDocument()
217
+ expect(screen.getByRole("alertdialog")).toBeInTheDocument()
218
+ expect(h.toast.success).not.toHaveBeenCalled()
219
+ })
220
+
221
+ it("失败后 Cancel 再重开叠层,旧 reason 不再显示(reset 清残留)", async () => {
222
+ h.installFn.mockResolvedValue({ ok: false, reason: REASON })
223
+ renderDialog()
224
+ typeSpec("@scope/dsh-plugin")
225
+ clickInstall()
226
+ fireEvent.click(screen.getByRole("button", { name: CONFIRM }))
227
+ // 首次失败:reason 内联
228
+ await waitFor(() => {
229
+ expect(screen.getAllByText(REASON).length).toBeGreaterThanOrEqual(1)
230
+ })
231
+ // Cancel 关叠层(Dialog 保持 open)
232
+ fireEvent.click(screen.getByRole("button", { name: CANCEL }))
233
+ await waitFor(() => {
234
+ expect(screen.queryByRole("alertdialog")).not.toBeInTheDocument()
235
+ })
236
+ // 重开叠层(再点安装):旧 reason 应已被 reset 清除,不立即重现
237
+ clickInstall()
238
+ await waitFor(() => {
239
+ expect(screen.getByRole("alertdialog")).toBeInTheDocument()
240
+ })
241
+ expect(screen.queryByText(REASON)).not.toBeInTheDocument()
242
+ })
243
+
244
+ it("进行态:isPending 时输入与两按钮禁用", async () => {
245
+ h.installFn.mockReturnValue(new Promise(() => {}))
246
+ renderDialog()
247
+ typeSpec("@scope/dsh-plugin")
248
+ clickInstall()
249
+ fireEvent.click(screen.getByRole("button", { name: CONFIRM }))
250
+ // 安装钮文案换 dshInstalling 且禁用(Dialog 安装钮 + 叠层确认钮)
251
+ await waitFor(() => {
252
+ const pendingButtons = screen.getAllByRole("button", { name: INSTALLING })
253
+ expect(pendingButtons.length).toBeGreaterThanOrEqual(1)
254
+ for (const btn of pendingButtons) {
255
+ expect(btn).toBeDisabled()
256
+ }
257
+ })
258
+ expect(screen.getByPlaceholderText(PLACEHOLDER)).toBeDisabled()
259
+ })
260
+ })