@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.
- package/package.json +1 -1
- package/public/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
- package/public/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
- package/public/pdfjs/cmaps/78-H.bcmap +0 -0
- package/public/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
- package/public/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
- package/public/pdfjs/cmaps/78-V.bcmap +0 -0
- package/public/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
- package/public/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
- package/public/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
- package/public/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
- package/public/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
- package/public/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
- package/public/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
- package/public/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
- package/public/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
- package/public/pdfjs/cmaps/Add-H.bcmap +0 -0
- package/public/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
- package/public/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
- package/public/pdfjs/cmaps/Add-V.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
- package/public/pdfjs/cmaps/B5-H.bcmap +0 -0
- package/public/pdfjs/cmaps/B5-V.bcmap +0 -0
- package/public/pdfjs/cmaps/B5pc-H.bcmap +0 -0
- package/public/pdfjs/cmaps/B5pc-V.bcmap +0 -0
- package/public/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
- package/public/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
- package/public/pdfjs/cmaps/CNS1-H.bcmap +0 -0
- package/public/pdfjs/cmaps/CNS1-V.bcmap +0 -0
- package/public/pdfjs/cmaps/CNS2-H.bcmap +0 -0
- package/public/pdfjs/cmaps/CNS2-V.bcmap +3 -0
- package/public/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
- package/public/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
- package/public/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
- package/public/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
- package/public/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
- package/public/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
- package/public/pdfjs/cmaps/EUC-H.bcmap +0 -0
- package/public/pdfjs/cmaps/EUC-V.bcmap +0 -0
- package/public/pdfjs/cmaps/Ext-H.bcmap +0 -0
- package/public/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
- package/public/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
- package/public/pdfjs/cmaps/Ext-V.bcmap +0 -0
- package/public/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
- package/public/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
- package/public/pdfjs/cmaps/GB-H.bcmap +4 -0
- package/public/pdfjs/cmaps/GB-V.bcmap +0 -0
- package/public/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
- package/public/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
- package/public/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
- package/public/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
- package/public/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
- package/public/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
- package/public/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
- package/public/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
- package/public/pdfjs/cmaps/GBT-H.bcmap +0 -0
- package/public/pdfjs/cmaps/GBT-V.bcmap +0 -0
- package/public/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
- package/public/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
- package/public/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
- package/public/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
- package/public/pdfjs/cmaps/H.bcmap +0 -0
- package/public/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
- package/public/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
- package/public/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
- package/public/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
- package/public/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
- package/public/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
- package/public/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
- package/public/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
- package/public/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
- package/public/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
- package/public/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
- package/public/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
- package/public/pdfjs/cmaps/Hankaku.bcmap +0 -0
- package/public/pdfjs/cmaps/Hiragana.bcmap +0 -0
- package/public/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
- package/public/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
- package/public/pdfjs/cmaps/KSC-H.bcmap +0 -0
- package/public/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
- package/public/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
- package/public/pdfjs/cmaps/KSC-V.bcmap +0 -0
- package/public/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
- package/public/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
- package/public/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
- package/public/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
- package/public/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
- package/public/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
- package/public/pdfjs/cmaps/Katakana.bcmap +0 -0
- package/public/pdfjs/cmaps/LICENSE +36 -0
- package/public/pdfjs/cmaps/NWP-H.bcmap +0 -0
- package/public/pdfjs/cmaps/NWP-V.bcmap +0 -0
- package/public/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
- package/public/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
- package/public/pdfjs/cmaps/Roman.bcmap +0 -0
- package/public/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
- package/public/pdfjs/cmaps/V.bcmap +0 -0
- package/public/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
- package/src/components/ai/ai-prompt-input/index.tsx +3 -87
- package/src/components/ai-elements/__tests__/context.test.tsx +167 -0
- package/src/components/ai-elements/context.tsx +182 -94
- package/src/components/ai-elements/prompt-input.tsx +6 -104
- package/src/components/harness/__tests__/composer-attachments.test.tsx +17 -9
- package/src/components/harness/__tests__/composer-click-focus.test.tsx +175 -0
- package/src/components/harness/__tests__/composer-focus.test.tsx +7 -0
- package/src/components/harness/__tests__/composer-keymap.test.ts +57 -0
- package/src/components/harness/__tests__/composer-paste.test.tsx +7 -0
- package/src/components/harness/__tests__/composer-pending-guard.test.tsx +207 -0
- package/src/components/harness/__tests__/composer-placeholder.test.ts +7 -6
- package/src/components/harness/__tests__/composer-plus-menu.test.tsx +202 -0
- package/src/components/harness/__tests__/composer-primary-button.test.tsx +7 -0
- package/src/components/harness/__tests__/composer-send.test.tsx +12 -4
- package/src/components/harness/__tests__/composer-undo.test.tsx +7 -0
- package/src/components/harness/__tests__/dock-registry.test.ts +3 -0
- package/src/components/harness/__tests__/harness-workbench-auth-error.test.tsx +42 -4
- package/src/components/harness/__tests__/mention-kbid.test.ts +69 -0
- package/src/components/harness/__tests__/undo-last-turn.test.ts +134 -0
- package/src/components/harness/__tests__/voice-activity.test.tsx +2 -2
- package/src/components/harness/conversation-panel/composer/__tests__/file-chip-open.test.tsx +195 -0
- package/src/components/harness/conversation-panel/composer/__tests__/menu-view.test.tsx +107 -0
- package/src/components/harness/conversation-panel/composer/command/__tests__/claim-attachments.test.tsx +271 -0
- package/src/components/harness/conversation-panel/composer/command/__tests__/claim-client-submit.test.tsx +291 -0
- package/src/components/harness/conversation-panel/composer/command/__tests__/claim-guard.test.tsx +275 -0
- package/src/components/harness/conversation-panel/composer/command/__tests__/command-permission.test.tsx +286 -0
- package/src/components/harness/conversation-panel/composer/command/__tests__/command-plan.test.tsx +344 -0
- package/src/components/harness/conversation-panel/composer/command/__tests__/command-popup.test.tsx +193 -0
- package/src/components/harness/conversation-panel/composer/command/__tests__/command-server-source.test.tsx +235 -0
- package/src/components/harness/conversation-panel/composer/command/__tests__/command-suggestion-menu.test.tsx +151 -1
- package/src/components/harness/conversation-panel/composer/command/__tests__/command-undo.test.tsx +168 -0
- package/src/components/harness/conversation-panel/composer/command/__tests__/exclude-composer-seat.test.ts +106 -0
- package/src/components/harness/conversation-panel/composer/command/__tests__/menu-view.test.tsx +55 -2
- package/src/components/harness/conversation-panel/composer/command/__tests__/skill-source.test.tsx +336 -0
- package/src/components/harness/conversation-panel/composer/command/claim.ts +7 -1
- package/src/components/harness/conversation-panel/composer/command/command-popup.tsx +140 -0
- package/src/components/harness/conversation-panel/composer/command/command-suggestion-menu.tsx +261 -75
- package/src/components/harness/conversation-panel/composer/command/menu-view.tsx +188 -50
- package/src/components/harness/conversation-panel/composer/command/popup-panel.tsx +106 -0
- package/src/components/harness/conversation-panel/composer/command/skill-source.ts +231 -0
- package/src/components/harness/conversation-panel/composer/composer-editor.tsx +216 -14
- package/src/components/harness/conversation-panel/composer/composer-keymap.ts +26 -0
- package/src/components/harness/conversation-panel/composer/extension/__tests__/command-menu.test.ts +128 -12
- package/src/components/harness/conversation-panel/composer/extension/command-menu.ts +303 -44
- package/src/components/harness/conversation-panel/composer/extension/index.ts +8 -0
- package/src/components/harness/conversation-panel/composer/harness-composer.tsx +551 -83
- package/src/components/harness/conversation-panel/composer/mention/__tests__/file-mention.test.tsx +517 -0
- package/src/components/harness/conversation-panel/composer/mention/__tests__/mention-source-registration.test.tsx +5 -2
- package/src/components/harness/conversation-panel/composer/mention/__tests__/mention-suggestion-menu.test.tsx +120 -0
- package/src/components/harness/conversation-panel/composer/mention/__tests__/mention-trigger-source.test.ts +52 -9
- package/src/components/harness/conversation-panel/composer/mention/__tests__/story-mention.test.tsx +356 -0
- package/src/components/harness/conversation-panel/composer/mention/__tests__/thread-mention.test.tsx +377 -0
- package/src/components/harness/conversation-panel/composer/mention/file-mention.ts +162 -0
- package/src/components/harness/conversation-panel/composer/mention/mention-resolvers.ts +6 -0
- package/src/components/harness/conversation-panel/composer/mention/mention-suggestion-menu.tsx +212 -107
- package/src/components/harness/conversation-panel/composer/mention/mention-trigger-source.ts +71 -8
- package/src/components/harness/conversation-panel/composer/mention/story-mention.ts +131 -0
- package/src/components/harness/conversation-panel/composer/mention/thread-mention.ts +159 -0
- package/src/components/harness/conversation-panel/composer/mention/use-mention-sources.ts +9 -1
- package/src/components/harness/conversation-panel/composer/model-selector/__tests__/model-selector.test.tsx +401 -0
- package/src/components/harness/conversation-panel/composer/model-selector/__tests__/wiring.test.ts +117 -0
- package/src/components/harness/conversation-panel/composer/model-selector/model-selector-panel.tsx +411 -0
- package/src/components/harness/conversation-panel/composer/model-selector/model-selector-trigger.tsx +254 -0
- package/src/components/harness/conversation-panel/composer/model-selector/wiring.ts +112 -0
- package/src/components/harness/conversation-panel/composer/permission/__tests__/permission-select.test.tsx +264 -0
- package/src/components/harness/conversation-panel/composer/permission/permission-policy.ts +76 -0
- package/src/components/harness/conversation-panel/composer/permission/permission-popup.tsx +302 -0
- package/src/components/harness/conversation-panel/composer/permission/permission-select-button.tsx +140 -0
- package/src/components/harness/conversation-panel/composer/workspace/__tests__/workspace-select.test.tsx +390 -0
- package/src/components/harness/conversation-panel/composer/workspace/workspace-select-button.tsx +367 -0
- package/src/components/harness/conversation-panel/messages/harness-chain/__tests__/use-harness-session-putmedia.test.tsx +17 -0
- package/src/components/harness/conversation-panel/messages/harness-chain/use-harness-chat-adapter.ts +26 -6
- package/src/components/harness/conversation-panel/messages/harness-chain/use-harness-session.ts +21 -3
- package/src/components/harness/extension-panel/dock/__tests__/dock-persist.test.ts +2 -1
- package/src/components/harness/extension-panel/dock/__tests__/guide-page.test.tsx +44 -3
- package/src/components/harness/extension-panel/dock/dock-persist.ts +6 -4
- package/src/components/harness/extension-panel/dock/dock-registry.ts +35 -14
- package/src/components/harness/extension-panel/dock/dock-surface.tsx +2 -0
- package/src/components/harness/extension-panel/dock/guide-page.tsx +75 -45
- package/src/components/harness/extension-panel/panels/plugin/__tests__/install-dialog.test.tsx +260 -0
- package/src/components/harness/extension-panel/panels/plugin/__tests__/plugin-page.test.tsx +912 -0
- package/src/components/harness/extension-panel/panels/plugin/__tests__/plugin-row.test.tsx +215 -0
- package/src/components/harness/extension-panel/panels/plugin/builtin-section.tsx +204 -0
- package/src/components/harness/extension-panel/panels/plugin/install-dialog.tsx +195 -0
- package/src/components/harness/extension-panel/panels/plugin/installed-section.tsx +378 -0
- package/src/components/harness/extension-panel/panels/plugin/kind.tsx +17 -4
- package/src/components/harness/extension-panel/panels/plugin/pending-builds-block.tsx +49 -0
- package/src/components/harness/extension-panel/panels/plugin/plugin-page.tsx +257 -0
- package/src/components/harness/extension-panel/panels/plugin/plugin-row.tsx +206 -0
- package/src/components/harness/extension-panel/panels/plugin/plugin-types.ts +13 -0
- package/src/components/harness/extension-panel/panels/plugin/worker-section.tsx +322 -0
- package/src/components/harness/workbench/__tests__/provider-model-groups.test.ts +301 -0
- package/src/components/harness/workbench/harness-workbench-page.tsx +164 -2
- package/src/components/harness/workbench/provider-model-groups.ts +140 -0
- package/src/components/harness/workbench/undo-last-turn.ts +79 -0
- package/src/components/harness/workbench/workbench-context.tsx +53 -3
- package/src/components/tiptap/hooks/__tests__/use-floating-element.test.tsx +131 -0
- package/src/components/tiptap/hooks/use-floating-element.ts +15 -2
- package/src/components/tiptap/hooks/use-menu-navigation.ts +5 -0
- package/src/components/tiptap/node/mention-extension.ts +33 -0
- package/src/components/tiptap/ui/suggestion-menu/__tests__/suggestion-menu.test.tsx +366 -0
- package/src/components/tiptap/ui/suggestion-menu/suggestion-menu-types.ts +54 -0
- package/src/components/tiptap/ui/suggestion-menu/suggestion-menu.tsx +176 -45
- package/src/lib/changelog/sdk-versions.ts +2 -2
- package/src/lib/queries/__tests__/harness-plugin-queries.test.ts +49 -0
- package/src/lib/queries/harness.ts +50 -0
- package/src/paraglide/messages/_index.js +1574 -311
- package/src/paraglide/messages/en.js +513 -103
- package/src/paraglide/messages/zh.js +514 -104
- package/src/routes/_nav/harness/route.lazy.tsx +13 -0
- package/src/server/ai-gateway/sandbox/policy.ts +6 -6
- package/src/server/harness/__tests__/compact-plugin.server.test.ts +46 -0
- package/src/server/harness/__tests__/define-expose.test.ts +17 -0
- package/src/server/harness/__tests__/thread-reference.server.test.ts +258 -0
- package/src/server/harness/define.server.ts +21 -3
- package/src/server/harness/thread-reference.server.ts +446 -0
- package/src/server/serverFns/chat/__tests__/conversations-sandbox-default.test.ts +23 -0
- package/src/server/serverFns/chat/conversations.ts +18 -3
- package/src/server/serverFns/harness/search-mention-candidates.ts +14 -1
- package/src/shared/harness/__tests__/thread-reference-format.test.ts +128 -0
- package/src/shared/harness/thread-reference-format.ts +98 -0
- package/LICENSE +0 -661
- package/src/components/agents/slash-skill-menu.tsx +0 -75
- package/src/components/harness/conversation-panel/composer/extension/__tests__/demo-story-reference.test.tsx +0 -177
- package/src/components/harness/conversation-panel/composer/extension/demo-story-reference.tsx +0 -227
- package/src/components/harness/conversation-panel/composer/plugin-mention-menu.tsx +0 -109
- package/src/components/harness/extension-panel/panels/plugin-panel.tsx +0 -1021
|
@@ -0,0 +1,286 @@
|
|
|
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
|
+
* /permission popup(任务 9):沙箱三档切换 + full 档 AlertDialog 二次确认 + 门控。
|
|
20
|
+
*
|
|
21
|
+
* 五用例:
|
|
22
|
+
* 1. 三档列表 + 当前档高亮:getSandboxPolicy 返回 workspace-write → popup 三行、
|
|
23
|
+
* 当前行 ✓ 勾选(popup 打开时直读当前档);
|
|
24
|
+
* 2. 切档成功:点只读 → setSandboxPolicy 收到 {threadId, level:"readonly",
|
|
25
|
+
* confirmFull:false} + 本地高亮切换 + 成功 toast(popup 保持);
|
|
26
|
+
* 3. full 档确认弹窗:点完全访问 → AlertDialog 叠加在 popup 之上(portal body +
|
|
27
|
+
* modal;取消回 popup 且 popup 状态保留、不调用)→ 确认 → confirmFull:true;
|
|
28
|
+
* 4. serverFn 报错 → 错误 toast + popup 保持 + 高亮不变;
|
|
29
|
+
* 5. 门控:legacy 链(isHarnessClientEnabled=false)/ sandboxExecution entitlement
|
|
30
|
+
* disabled → /permission 不在 '/' 菜单;空态(threadId=null)**可用**(用户裁决
|
|
31
|
+
* 2026-11-20 对齐 DSH blank 会话)——popup 初始高亮默认档、选档走 onPendingLevel
|
|
32
|
+
* pending 分流(getSandboxPolicy/setSandboxPolicy 均不调)。
|
|
33
|
+
*
|
|
34
|
+
* 渲染 HarnessComposer(真实 TipTap),handoffPrefillText 预填触发串
|
|
35
|
+
* (command-popup.test 同款手法)。permission-policy 整模块 mock(mock 链切断——
|
|
36
|
+
* 真模块顶层 import sandbox-policy serverFn → policy index,后者在本文件 throw 守卫)。
|
|
37
|
+
*/
|
|
38
|
+
import { afterEach, beforeEach, expect, it, vi } from "vitest"
|
|
39
|
+
import { cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react"
|
|
40
|
+
import { HarnessComposer } from "../../harness-composer"
|
|
41
|
+
import { PermissionPopup } from "../../permission/permission-popup"
|
|
42
|
+
import * as permissionPolicy from "../../permission/permission-policy"
|
|
43
|
+
import { useFeature } from "@/components/billing/use-feature"
|
|
44
|
+
import { toast } from "@/components/ui/toast"
|
|
45
|
+
import { m } from "@/paraglide/messages.js"
|
|
46
|
+
|
|
47
|
+
vi.mock("@/server/serverFns/harness/media", () => ({ generatePrototypeFn: vi.fn(() => Promise.resolve({})) }))
|
|
48
|
+
vi.mock("../../mention/use-mention-sources", () => ({
|
|
49
|
+
useMentionSources: () => ({ all: [], isLoading: false }),
|
|
50
|
+
}))
|
|
51
|
+
vi.mock("@/components/billing/use-feature", () => ({
|
|
52
|
+
useFeature: vi.fn(() => ({ enabled: true, loading: false })),
|
|
53
|
+
}))
|
|
54
|
+
// bundle 守卫(T8 立规,本任务沿用):composer 链路不得加载服务端沙箱 policy index
|
|
55
|
+
// ——permission-policy 是唯一合法通道(本文件顶部已整模块 mock 切断其 import 链)。
|
|
56
|
+
vi.mock("@/server/ai-gateway/sandbox/policy", () => { throw new Error("Server sandbox policy must not be loaded by the composer") })
|
|
57
|
+
vi.mock("../../permission/permission-policy", () => ({
|
|
58
|
+
SANDBOX_POLICY_LEVELS: ["readonly", "workspace-write", "full"],
|
|
59
|
+
// 客户端默认档常量(空态 popup 初始高亮;真值 "workspace-write" 与 server 同值)
|
|
60
|
+
SANDBOX_CLIENT_DEFAULT_LEVEL: "readonly",
|
|
61
|
+
getSandboxPolicy: vi.fn(() => Promise.resolve("workspace-write")),
|
|
62
|
+
setSandboxPolicy: vi.fn(() => Promise.resolve("workspace-write")),
|
|
63
|
+
}))
|
|
64
|
+
vi.mock("../../voice-input-button", () => ({ VoiceInputButton: () => null }))
|
|
65
|
+
vi.mock("@/components/harness/conversation-panel/messages/approvals/interrupt-approval", () => ({ InterruptApproval: () => null }))
|
|
66
|
+
vi.mock("@/components/ui/toast", () => ({
|
|
67
|
+
toast: {
|
|
68
|
+
success: vi.fn(),
|
|
69
|
+
error: vi.fn(),
|
|
70
|
+
warning: vi.fn(),
|
|
71
|
+
info: vi.fn(),
|
|
72
|
+
loading: vi.fn(),
|
|
73
|
+
message: vi.fn(),
|
|
74
|
+
dismiss: vi.fn(),
|
|
75
|
+
promise: vi.fn(),
|
|
76
|
+
},
|
|
77
|
+
}))
|
|
78
|
+
|
|
79
|
+
beforeEach(() => {
|
|
80
|
+
sessionStorage.clear()
|
|
81
|
+
// harness 客户端门控开(vitest 默认 '0',config 注释钦定用例级 stubEnv 显式开)
|
|
82
|
+
vi.stubEnv("VITE_HARNESS_DEV", "1")
|
|
83
|
+
// 基线复位(clearAllMocks 不清 return 值,逐项重设防跨用例泄漏)
|
|
84
|
+
vi.mocked(useFeature).mockReturnValue({ enabled: true, loading: false })
|
|
85
|
+
vi.mocked(permissionPolicy.getSandboxPolicy).mockResolvedValue("workspace-write")
|
|
86
|
+
vi.mocked(permissionPolicy.setSandboxPolicy).mockResolvedValue("workspace-write")
|
|
87
|
+
})
|
|
88
|
+
afterEach(() => {
|
|
89
|
+
cleanup()
|
|
90
|
+
vi.unstubAllEnvs()
|
|
91
|
+
vi.clearAllMocks()
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
/** 取 ProseMirror 编辑面(composer-send.test 同款定位) */
|
|
95
|
+
function getEditorDom(): HTMLElement {
|
|
96
|
+
const el = document.querySelector<HTMLElement>(".tiptap.ProseMirror")
|
|
97
|
+
if (!el) throw new Error("TipTap 编辑器 DOM 未挂载")
|
|
98
|
+
return el
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
interface SetupOptions {
|
|
102
|
+
prefill: string
|
|
103
|
+
threadId?: string | null
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function setup({ prefill, threadId = "t1" }: SetupOptions) {
|
|
107
|
+
render(
|
|
108
|
+
<HarnessComposer
|
|
109
|
+
threadId={threadId}
|
|
110
|
+
isRunning={false}
|
|
111
|
+
hasAiKey
|
|
112
|
+
busyPreference="queue"
|
|
113
|
+
onSend={vi.fn()}
|
|
114
|
+
onStop={vi.fn()}
|
|
115
|
+
conversationRegionRef={{ current: null }}
|
|
116
|
+
messages={[]}
|
|
117
|
+
handoffPrefillText={prefill}
|
|
118
|
+
models={[]}
|
|
119
|
+
/>,
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* '/' 菜单开(handoffPrefillText 预填即开)→ Enter 选中 /permission → popup 开
|
|
125
|
+
* (三档列表)。每轮 poll 重查询 listbox,规避 '/' 菜单未卸载瞬间的 stale 捕获。
|
|
126
|
+
*/
|
|
127
|
+
async function openPermissionPopup(): Promise<HTMLElement> {
|
|
128
|
+
const textbox = getEditorDom()
|
|
129
|
+
const menu = await screen.findByRole("listbox", {}, { timeout: 3000 })
|
|
130
|
+
await waitFor(() => expect(menu.textContent).toContain("权限"))
|
|
131
|
+
fireEvent.keyDown(textbox, { key: "Enter" })
|
|
132
|
+
await waitFor(
|
|
133
|
+
() => {
|
|
134
|
+
const popup = screen.getByRole("listbox")
|
|
135
|
+
expect(popup.textContent).toContain("只读")
|
|
136
|
+
},
|
|
137
|
+
{ timeout: 3000 },
|
|
138
|
+
)
|
|
139
|
+
return screen.getByRole("listbox")
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** 取含指定文案的三档行(popup 内 option 行) */
|
|
143
|
+
function findLevelRow(scope: HTMLElement, label: string): HTMLElement {
|
|
144
|
+
const row = within(scope)
|
|
145
|
+
.getAllByRole("option")
|
|
146
|
+
.find((r) => r.textContent?.includes(label))
|
|
147
|
+
if (!row) throw new Error(`三档行未渲染: ${label}`)
|
|
148
|
+
return row
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
it("三档列表 + 当前档高亮:popup 打开直读当前档 workspace-write", async () => {
|
|
152
|
+
setup({ prefill: "/permission" })
|
|
153
|
+
const popup = await openPermissionPopup()
|
|
154
|
+
// 三行齐备(只读 / 工作区可写 / 完全访问)
|
|
155
|
+
expect(popup.textContent).toContain("只读")
|
|
156
|
+
expect(popup.textContent).toContain("工作区可写")
|
|
157
|
+
expect(popup.textContent).toContain("完全访问")
|
|
158
|
+
// 直读当前档(P0 直调):**两路合法读**——控制行按钮挂载直读(自动回显,用户裁决
|
|
159
|
+
// 2026-11-21)+ 斜杠 popup 挂载直读;同参幂等 GET
|
|
160
|
+
expect(permissionPolicy.getSandboxPolicy).toHaveBeenCalledTimes(2)
|
|
161
|
+
expect(permissionPolicy.getSandboxPolicy).toHaveBeenCalledWith({ threadId: "t1" })
|
|
162
|
+
// 当前行勾选且唯一(Check 图标落 workspace-write 行右侧,其余行无;打磨后行=图标+档名)
|
|
163
|
+
const rows = within(popup).getAllByRole("option")
|
|
164
|
+
expect(rows.filter((r) => r.querySelector("svg.lucide-check"))).toHaveLength(1)
|
|
165
|
+
expect(findLevelRow(popup, "工作区可写").querySelector("svg.lucide-check")).not.toBeNull()
|
|
166
|
+
expect(findLevelRow(popup, "只读").querySelector("svg.lucide-check")).toBeNull()
|
|
167
|
+
expect(findLevelRow(popup, "完全访问").querySelector("svg.lucide-check")).toBeNull()
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
it("切档成功:点只读 → setSandboxPolicy({threadId, level:'readonly', confirmFull:false}) + 高亮切换 + 成功 toast", async () => {
|
|
171
|
+
vi.mocked(permissionPolicy.setSandboxPolicy).mockResolvedValue("readonly")
|
|
172
|
+
setup({ prefill: "/permission" })
|
|
173
|
+
const popup = await openPermissionPopup()
|
|
174
|
+
fireEvent.click(within(popup).getByText("只读"))
|
|
175
|
+
await waitFor(() =>
|
|
176
|
+
expect(permissionPolicy.setSandboxPolicy).toHaveBeenCalledExactlyOnceWith({
|
|
177
|
+
threadId: "t1",
|
|
178
|
+
level: "readonly",
|
|
179
|
+
confirmFull: false,
|
|
180
|
+
}),
|
|
181
|
+
)
|
|
182
|
+
// 成功 toast
|
|
183
|
+
await waitFor(() => expect(toast.success).toHaveBeenCalledWith(m.harness_command_permissionChanged()))
|
|
184
|
+
// 本地高亮切换(popup 保持打开):Check 移到只读行
|
|
185
|
+
await waitFor(() =>
|
|
186
|
+
expect(findLevelRow(popup, "只读").querySelector("svg.lucide-check")).not.toBeNull(),
|
|
187
|
+
)
|
|
188
|
+
expect(findLevelRow(popup, "工作区可写").querySelector("svg.lucide-check")).toBeNull()
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
it("full 档确认弹窗:AlertDialog 叠加 popup 之上;取消回 popup 不调用;确认才 confirmFull:true", async () => {
|
|
192
|
+
vi.mocked(permissionPolicy.setSandboxPolicy).mockResolvedValue("full")
|
|
193
|
+
setup({ prefill: "/permission" })
|
|
194
|
+
await openPermissionPopup()
|
|
195
|
+
// 点完全访问 → AlertDialog 弹出(portal 到 body),未确认前不调用
|
|
196
|
+
fireEvent.click(screen.getByText("完全访问"))
|
|
197
|
+
const dialog = await screen.findByRole("alertdialog")
|
|
198
|
+
expect(within(dialog).getByText("启用完全访问?")).toBeTruthy()
|
|
199
|
+
expect(permissionPolicy.setSandboxPolicy).not.toHaveBeenCalled()
|
|
200
|
+
// 叠加而非替换:popup 面板仍在文档中(三档行保留)
|
|
201
|
+
const panelDuringDialog = document.querySelector("[data-command-popup]")
|
|
202
|
+
expect(panelDuringDialog?.textContent).toContain("工作区可写")
|
|
203
|
+
// 取消 → 弹窗关、回 popup、不调用(popup 状态保留——高亮仍是 workspace-write)
|
|
204
|
+
fireEvent.click(within(dialog).getByText("取消"))
|
|
205
|
+
await waitFor(() => expect(screen.queryByRole("alertdialog")).toBeNull())
|
|
206
|
+
expect(permissionPolicy.setSandboxPolicy).not.toHaveBeenCalled()
|
|
207
|
+
expect(document.querySelector("[data-command-popup]")).toBeTruthy()
|
|
208
|
+
expect(
|
|
209
|
+
findLevelRow(screen.getByRole("listbox"), "工作区可写").querySelector("svg.lucide-check"),
|
|
210
|
+
).not.toBeNull()
|
|
211
|
+
// 重开确认 → setSandboxPolicy 收到 confirmFull:true
|
|
212
|
+
fireEvent.click(screen.getByText("完全访问"))
|
|
213
|
+
const dialog2 = await screen.findByRole("alertdialog")
|
|
214
|
+
fireEvent.click(within(dialog2).getByText("确认启用"))
|
|
215
|
+
await waitFor(() =>
|
|
216
|
+
expect(permissionPolicy.setSandboxPolicy).toHaveBeenCalledExactlyOnceWith({
|
|
217
|
+
threadId: "t1",
|
|
218
|
+
level: "full",
|
|
219
|
+
confirmFull: true,
|
|
220
|
+
}),
|
|
221
|
+
)
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
it("serverFn 报错 → 错误 toast + popup 保持 + 高亮不变", async () => {
|
|
225
|
+
vi.mocked(permissionPolicy.setSandboxPolicy).mockRejectedValue(new Error("boom"))
|
|
226
|
+
setup({ prefill: "/permission" })
|
|
227
|
+
const popup = await openPermissionPopup()
|
|
228
|
+
fireEvent.click(within(popup).getByText("只读"))
|
|
229
|
+
// 失败 toast(复用 runFailed 错误面)、无成功 toast
|
|
230
|
+
await waitFor(() => expect(toast.error).toHaveBeenCalledWith(m.harness_command_runFailed()))
|
|
231
|
+
expect(toast.success).not.toHaveBeenCalled()
|
|
232
|
+
// popup 保持:三档行仍在、Check 仍在 workspace-write 行(高亮未切换,可重试)
|
|
233
|
+
expect(document.querySelector("[data-command-popup]")).toBeTruthy()
|
|
234
|
+
expect(findLevelRow(popup, "工作区可写").querySelector("svg.lucide-check")).not.toBeNull()
|
|
235
|
+
expect(findLevelRow(popup, "只读").querySelector("svg.lucide-check")).toBeNull()
|
|
236
|
+
})
|
|
237
|
+
|
|
238
|
+
async function expectPermissionGated(): Promise<void> {
|
|
239
|
+
const menu = await screen.findByRole("listbox", {}, { timeout: 3000 })
|
|
240
|
+
await waitFor(() => expect(menu.textContent).toContain("清空输入"))
|
|
241
|
+
// 门控关闭:/permission 被组装侧过滤(其余命令照常——控制组)
|
|
242
|
+
expect(menu.textContent).not.toContain("权限")
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
it("空态(threadId=null):PermissionPopup 初始高亮默认档,选档走 pending 分流(不调 serverFn)", async () => {
|
|
246
|
+
// 用户裁决 2026-11-20 对齐 DSH blank 会话:空态可用。直渲 PermissionPopup(组件级,
|
|
247
|
+
// 确定性——菜单→popup 集成面由真机验收覆盖;jsdom 下 composer 内行点击存在
|
|
248
|
+
// suggestion 重建的双菜单干扰,不宜在此纠缠)。断言 pending 分流本体:onPendingLevel
|
|
249
|
+
// 上报 + 本地高亮 + pending toast,getSandboxPolicy/setSandboxPolicy 均不调。
|
|
250
|
+
const onPendingLevel = vi.fn()
|
|
251
|
+
const onClose = vi.fn()
|
|
252
|
+
render(<PermissionPopup threadId={null} onClose={onClose} onPendingLevel={onPendingLevel} />)
|
|
253
|
+
|
|
254
|
+
const popup = await waitFor(() => {
|
|
255
|
+
const el = document.querySelector<HTMLElement>('[data-command-popup] [role="listbox"]')
|
|
256
|
+
expect(el).not.toBeNull()
|
|
257
|
+
return el as HTMLElement
|
|
258
|
+
})
|
|
259
|
+
// 初始高亮默认档(无服务端真值可读)——Check 在只读行(默认档=readonly,用户裁决 2026-11-21)
|
|
260
|
+
expect(permissionPolicy.getSandboxPolicy).not.toHaveBeenCalled()
|
|
261
|
+
expect(findLevelRow(popup, "只读").querySelector("svg.lucide-check")).not.toBeNull()
|
|
262
|
+
|
|
263
|
+
// 点「只读」→ onPendingLevel 收到档位 + pending toast,setSandboxPolicy 不调。
|
|
264
|
+
// 点击目标须为 Item 根(data-slot=item,onClick 挂载点)——role=option wrapper 是
|
|
265
|
+
// 其父级,click 不冒泡向下。
|
|
266
|
+
const readonlyRow = findLevelRow(popup, "只读")
|
|
267
|
+
const itemEl = readonlyRow.querySelector<HTMLElement>('[data-slot="item"]') ?? readonlyRow
|
|
268
|
+
fireEvent.click(itemEl)
|
|
269
|
+
await waitFor(() => expect(onPendingLevel).toHaveBeenCalledExactlyOnceWith("readonly"))
|
|
270
|
+
expect(permissionPolicy.setSandboxPolicy).not.toHaveBeenCalled()
|
|
271
|
+
expect(vi.mocked(toast.success).mock.calls.some((c) =>
|
|
272
|
+
String(c[0]).includes("新会话") || String(c[0]).includes("生效"),
|
|
273
|
+
)).toBe(true)
|
|
274
|
+
})
|
|
275
|
+
|
|
276
|
+
it("门控:legacy 链(VITE_HARNESS_DEV=0 → isHarnessClientEnabled=false)→ /permission 不在菜单", async () => {
|
|
277
|
+
vi.stubEnv("VITE_HARNESS_DEV", "0")
|
|
278
|
+
setup({ prefill: "/" })
|
|
279
|
+
await expectPermissionGated()
|
|
280
|
+
})
|
|
281
|
+
|
|
282
|
+
it("门控:sandboxExecution entitlement disabled(useFeature.enabled=false)→ /permission 不在菜单", async () => {
|
|
283
|
+
vi.mocked(useFeature).mockReturnValue({ enabled: false, loading: false })
|
|
284
|
+
setup({ prefill: "/" })
|
|
285
|
+
await expectPermissionGated()
|
|
286
|
+
})
|
package/src/components/harness/conversation-panel/composer/command/__tests__/command-plan.test.tsx
ADDED
|
@@ -0,0 +1,344 @@
|
|
|
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
|
+
* /plan 计划模式命令(P2 任务 2,claim 型切档全链)。
|
|
20
|
+
*
|
|
21
|
+
* /plan 是 client input 型命令(command-menu 内置,workbench-page 注入执行通路
|
|
22
|
+
* onPlanSubmit):选中落 chip(claim,T1 修复后的 client 结算通路)→ Enter 结算 =
|
|
23
|
+
* 切 readonly/plan 档 + 发送任务文本。plan 档 = readonly 映射(sandboxPolicyToPermissionMode
|
|
24
|
+
* readonly→'plan'),切档复用 setSandboxPolicy(composer/permission/permission-policy
|
|
25
|
+
* 封装,readonly 档无需 confirmFull)。
|
|
26
|
+
*
|
|
27
|
+
* 本文件锁定 composer 层 prop→命令 wiring 与切档→发送时序(审查重点 3):workbench-page
|
|
28
|
+
* 把 setSandboxPolicy + 发送组装成 onPlanSubmit 闭包注入;本文件用同款组合在测试侧复刻,
|
|
29
|
+
* 保证「先切档、切档成功才发送」的次序可断言:
|
|
30
|
+
* ① 门控:harness 链 + thread 存在 + 非运行中 → '/' 菜单含「计划模式」;
|
|
31
|
+
* legacy 链(不传 onPlanSubmit)/ isRunning → 不出现(清空输入照常——控制组);空态
|
|
32
|
+
* threadId **可用**(用户裁决 2026-11-20 对齐 DSH blank 会话,pending 档随建线落库);
|
|
33
|
+
* ② 全链:chip + 任务文本 → Enter → setSandboxPolicy(level:'readonly') 先于发送被调
|
|
34
|
+
* (调用序断言)→ 发送内容 = 任务文本;
|
|
35
|
+
* ③ 切档失败 fail-closed:setSandboxPolicy reject → 不发送、草稿保留 chip、toast 错误;
|
|
36
|
+
* ④ 附件信封:草稿带附件 → Enter → 拦截 toast、不切档不发送(plan 无 acceptsAttachments);
|
|
37
|
+
* ⑤ Space 裁定:手敲 /plan + Space → 落 chip。
|
|
38
|
+
*
|
|
39
|
+
* 渲染 HarnessComposer(真实 TipTap)+ composer 级 mock 组合(claim-client-submit /
|
|
40
|
+
* command-undo 同款);每例 clearComposerExtensions()。i18n 断言走 zh locale。
|
|
41
|
+
*/
|
|
42
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"
|
|
43
|
+
import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react"
|
|
44
|
+
import { HarnessComposer } from "../../harness-composer"
|
|
45
|
+
import { clearComposerExtensions } from "../../extension"
|
|
46
|
+
import { setSandboxPolicy } from "../../permission/permission-policy"
|
|
47
|
+
import { toast } from "@/components/ui/toast"
|
|
48
|
+
import { m } from "@/paraglide/messages.js"
|
|
49
|
+
import type { HarnessComposerProps } from "../../harness-composer"
|
|
50
|
+
import type { JSONContent } from "@tiptap/react"
|
|
51
|
+
|
|
52
|
+
vi.mock("@/server/serverFns/harness/media", () => ({ generatePrototypeFn: vi.fn(() => Promise.resolve({})) }))
|
|
53
|
+
vi.mock("../../mention/use-mention-sources", () => ({
|
|
54
|
+
useMentionSources: () => ({ all: [], isLoading: false }),
|
|
55
|
+
}))
|
|
56
|
+
vi.mock("@/components/billing/use-feature", () => ({ useFeature: () => ({ enabled: true, loading: false }) }))
|
|
57
|
+
vi.mock("@/server/ai-gateway/sandbox/policy", () => { throw new Error("Server sandbox policy must not be loaded by the composer") })
|
|
58
|
+
// 切档通路 mock:workbench-page 的 onPlanSubmit 闭包经 permission-policy.setSandboxPolicy
|
|
59
|
+
// 切 readonly 档——本文件 mock 之并断言 level:'readonly' 与「先于发送」的调用序。
|
|
60
|
+
vi.mock("../../permission/permission-policy", () => ({
|
|
61
|
+
SANDBOX_POLICY_LEVELS: ["readonly", "workspace-write", "full"],
|
|
62
|
+
getSandboxPolicy: vi.fn(() => Promise.resolve("workspace-write")),
|
|
63
|
+
setSandboxPolicy: vi.fn(() => Promise.resolve("workspace-write")),
|
|
64
|
+
}))
|
|
65
|
+
vi.mock("../../voice-input-button", () => ({ VoiceInputButton: () => null }))
|
|
66
|
+
vi.mock("@/components/harness/conversation-panel/messages/approvals/interrupt-approval", () => ({ InterruptApproval: () => null }))
|
|
67
|
+
vi.mock("@/components/ui/toast", () => ({
|
|
68
|
+
toast: {
|
|
69
|
+
error: vi.fn(),
|
|
70
|
+
success: vi.fn(),
|
|
71
|
+
info: vi.fn(),
|
|
72
|
+
warning: vi.fn(),
|
|
73
|
+
loading: vi.fn(),
|
|
74
|
+
message: vi.fn(),
|
|
75
|
+
dismiss: vi.fn(),
|
|
76
|
+
promise: vi.fn(),
|
|
77
|
+
},
|
|
78
|
+
}))
|
|
79
|
+
|
|
80
|
+
// 附件轨道 mock(附件信封用例):holder 挂 vi.hoisted 保工厂闭包可用。
|
|
81
|
+
type FakeAttachment = { id: string; file: File; previewUrl: string; status: string }
|
|
82
|
+
const attachmentsMock = vi.hoisted(() => {
|
|
83
|
+
const list: FakeAttachment[] = []
|
|
84
|
+
return { list, clear: vi.fn() }
|
|
85
|
+
})
|
|
86
|
+
vi.mock("../../attachments/use-attachments", () => ({
|
|
87
|
+
useAttachments: () => ({
|
|
88
|
+
attachments: attachmentsMock.list,
|
|
89
|
+
addFiles: vi.fn(),
|
|
90
|
+
removeAttachment: vi.fn(),
|
|
91
|
+
clearAttachments: attachmentsMock.clear,
|
|
92
|
+
retryAttachment: vi.fn(),
|
|
93
|
+
hasPending: false,
|
|
94
|
+
}),
|
|
95
|
+
}))
|
|
96
|
+
|
|
97
|
+
const DRAFTS_KEY = "allblue.harness.drafts"
|
|
98
|
+
|
|
99
|
+
beforeEach(() => {
|
|
100
|
+
sessionStorage.clear()
|
|
101
|
+
attachmentsMock.list = []
|
|
102
|
+
attachmentsMock.clear.mockClear()
|
|
103
|
+
vi.mocked(setSandboxPolicy).mockClear()
|
|
104
|
+
vi.mocked(setSandboxPolicy).mockResolvedValue("workspace-write")
|
|
105
|
+
vi.mocked(toast.error).mockClear()
|
|
106
|
+
vi.mocked(toast.info).mockClear()
|
|
107
|
+
vi.spyOn(console, "error").mockImplementation(() => {})
|
|
108
|
+
})
|
|
109
|
+
afterEach(() => {
|
|
110
|
+
cleanup()
|
|
111
|
+
clearComposerExtensions()
|
|
112
|
+
vi.mocked(console.error).mockRestore()
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
/** 取 ProseMirror 编辑面 */
|
|
116
|
+
function getEditorDom(): HTMLElement {
|
|
117
|
+
const el = document.querySelector<HTMLElement>(".tiptap.ProseMirror")
|
|
118
|
+
if (!el) throw new Error("TipTap 编辑器 DOM 未挂载")
|
|
119
|
+
return el
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** chip 节点 DOM(commandChip renderHTML;null = doc 已无 chip——idle) */
|
|
123
|
+
function getChipDom(name: string): HTMLElement | null {
|
|
124
|
+
return document.querySelector<HTMLElement>(`[data-command-chip][data-chip-name="${name}"]`)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** 行首 commandChip 的 claimed doc(claim-guard/claim-attachments 同款形状) */
|
|
128
|
+
function claimedDoc(name: string, args: string, label?: string): JSONContent {
|
|
129
|
+
return {
|
|
130
|
+
type: "doc",
|
|
131
|
+
content: [
|
|
132
|
+
{
|
|
133
|
+
type: "paragraph",
|
|
134
|
+
content: [
|
|
135
|
+
{ type: "commandChip", attrs: { name, label: label ?? name, hint: "描述你的任务…" } },
|
|
136
|
+
...(args ? [{ type: "text", text: ` ${args}` }] : []),
|
|
137
|
+
],
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** 预置 claimed 草稿(ComposerEditor 挂载经 draftsStore.load 回放) */
|
|
144
|
+
function seedClaimedDraft(threadId: string, doc: JSONContent): void {
|
|
145
|
+
sessionStorage.setItem(DRAFTS_KEY, JSON.stringify({ [`draft:${threadId}`]: JSON.stringify(doc) }))
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** 附件轨道条目(mock 注入;file/previewUrl 为托盘渲染所需最小形状) */
|
|
149
|
+
function fakeAttachment(status: string): FakeAttachment {
|
|
150
|
+
return {
|
|
151
|
+
id: `att-${status}`,
|
|
152
|
+
file: new File(["x"], "a.png", { type: "image/png" }),
|
|
153
|
+
previewUrl: `blob:mock-${status}`,
|
|
154
|
+
status,
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* 复刻 workbench-page 的 onPlanSubmit 组合(切档 → 发送,审查重点 3):先 await
|
|
160
|
+
* setSandboxPolicy(level:'readonly'),成功才经 onSend 发送任务文本;切档失败原样
|
|
161
|
+
* rethrow(由 composer claim 结算层 toast + 保草稿)。返回各 spy 供调用序断言。
|
|
162
|
+
*/
|
|
163
|
+
function makeOnPlanSubmit(onSend: ReturnType<typeof vi.fn> & ((args: string) => void)): HarnessComposerProps["onPlanSubmit"] {
|
|
164
|
+
return async (args: string) => {
|
|
165
|
+
await setSandboxPolicy({ threadId: "t1", level: "readonly" })
|
|
166
|
+
onSend(args)
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
interface SetupResult {
|
|
171
|
+
onSend: ReturnType<typeof vi.fn>
|
|
172
|
+
onPlanSubmit: HarnessComposerProps["onPlanSubmit"]
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** 挂载 HarnessComposer(无 prefill——预置草稿接管;真实内置命令集含 /plan) */
|
|
176
|
+
function renderComposer(options?: {
|
|
177
|
+
withPlan?: boolean
|
|
178
|
+
attachments?: FakeAttachment[]
|
|
179
|
+
}): SetupResult {
|
|
180
|
+
seedClaimedDraft("t1", claimedDoc("plan", "为登录流程补齐测试"))
|
|
181
|
+
if (options?.attachments) attachmentsMock.list = options.attachments
|
|
182
|
+
const onSend = vi.fn()
|
|
183
|
+
const onPlanSubmit = makeOnPlanSubmit(onSend)
|
|
184
|
+
render(
|
|
185
|
+
<HarnessComposer
|
|
186
|
+
threadId="t1"
|
|
187
|
+
isRunning={false}
|
|
188
|
+
hasAiKey
|
|
189
|
+
busyPreference="queue"
|
|
190
|
+
onSend={onSend}
|
|
191
|
+
onStop={vi.fn()}
|
|
192
|
+
conversationRegionRef={{ current: null }}
|
|
193
|
+
messages={[]}
|
|
194
|
+
models={[]}
|
|
195
|
+
{...(options?.withPlan === false ? {} : { onPlanSubmit })}
|
|
196
|
+
/>,
|
|
197
|
+
)
|
|
198
|
+
return { onSend, onPlanSubmit }
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** 打开 '/' 菜单(handoffPrefillText 触发,command-undo 同款手法) */
|
|
202
|
+
async function openSlashMenu(extraProps?: Partial<HarnessComposerProps>) {
|
|
203
|
+
render(
|
|
204
|
+
<HarnessComposer
|
|
205
|
+
threadId="t1"
|
|
206
|
+
isRunning={false}
|
|
207
|
+
hasAiKey
|
|
208
|
+
busyPreference="queue"
|
|
209
|
+
onSend={vi.fn()}
|
|
210
|
+
onStop={vi.fn()}
|
|
211
|
+
conversationRegionRef={{ current: null }}
|
|
212
|
+
messages={[]}
|
|
213
|
+
models={[]}
|
|
214
|
+
handoffPrefillText="/"
|
|
215
|
+
{...extraProps}
|
|
216
|
+
/>,
|
|
217
|
+
)
|
|
218
|
+
const menu = await screen.findByRole("listbox", {}, { timeout: 3000 })
|
|
219
|
+
await waitFor(() => expect(menu.textContent).toContain("清空输入"), { timeout: 3000 })
|
|
220
|
+
return menu
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
describe("① 门控", () => {
|
|
224
|
+
it("harness 链 + thread 存在 + 非运行中 → '/' 菜单含「计划模式」(指令组)", async () => {
|
|
225
|
+
const menu = await openSlashMenu({ onPlanSubmit: vi.fn(), canPlan: true })
|
|
226
|
+
expect(menu.textContent).toContain("计划模式")
|
|
227
|
+
// client 组(组头「指令」)
|
|
228
|
+
expect(menu.textContent).toContain("指令")
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
it("legacy 链(不传 onPlanSubmit)→ 不出现(清空输入照常——控制组)", async () => {
|
|
232
|
+
const menu = await openSlashMenu()
|
|
233
|
+
expect(menu.textContent).toContain("清空输入")
|
|
234
|
+
expect(menu.textContent).not.toContain("计划模式")
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
it("空 threadId → 仍出现(用户裁决 2026-11-20 对齐 DSH blank 会话:空态走 pending 档随建线落库)", async () => {
|
|
238
|
+
const menu = await openSlashMenu({ threadId: null, onPlanSubmit: vi.fn(), canPlan: true })
|
|
239
|
+
expect(menu.textContent).toContain("清空输入")
|
|
240
|
+
expect(menu.textContent).toContain("计划模式")
|
|
241
|
+
})
|
|
242
|
+
|
|
243
|
+
it("isRunning → 不出现", async () => {
|
|
244
|
+
const menu = await openSlashMenu({ isRunning: true, onPlanSubmit: vi.fn() })
|
|
245
|
+
expect(menu.textContent).toContain("清空输入")
|
|
246
|
+
expect(menu.textContent).not.toContain("计划模式")
|
|
247
|
+
})
|
|
248
|
+
})
|
|
249
|
+
|
|
250
|
+
describe("② 全链", () => {
|
|
251
|
+
it("chip + 任务文本 → Enter → setSandboxPolicy(level:'readonly') 先于发送被调 → 发送内容 = 任务文本", async () => {
|
|
252
|
+
const { onSend } = renderComposer()
|
|
253
|
+
await waitFor(() => expect(getChipDom("plan")).not.toBeNull(), { timeout: 3000 })
|
|
254
|
+
|
|
255
|
+
// 调用序:onSend 内部记录 setSandboxPolicy 已被调——若 setSandboxPolicy 晚于发送
|
|
256
|
+
// 则 onSend 触发时 order 仍为 0,断言即失败(审查重点 3:切档必须先于发送)。
|
|
257
|
+
let setPolicyOrder = -1
|
|
258
|
+
let sendOrder = -1
|
|
259
|
+
let step = 0
|
|
260
|
+
vi.mocked(setSandboxPolicy).mockImplementation(() => {
|
|
261
|
+
setPolicyOrder = step++
|
|
262
|
+
return Promise.resolve("workspace-write")
|
|
263
|
+
})
|
|
264
|
+
onSend.mockImplementation(() => {
|
|
265
|
+
sendOrder = step++
|
|
266
|
+
})
|
|
267
|
+
|
|
268
|
+
fireEvent.keyDown(getEditorDom(), { key: "Enter" })
|
|
269
|
+
|
|
270
|
+
await waitFor(() => expect(getChipDom("plan")).toBeNull(), { timeout: 3000 })
|
|
271
|
+
// 切档:readonly 档(plan 映射)
|
|
272
|
+
expect(setSandboxPolicy).toHaveBeenCalledTimes(1)
|
|
273
|
+
expect(setSandboxPolicy).toHaveBeenCalledWith({ threadId: "t1", level: "readonly" })
|
|
274
|
+
// 发送内容 = 任务文本(chip 后参数)
|
|
275
|
+
expect(onSend).toHaveBeenCalledTimes(1)
|
|
276
|
+
expect(onSend).toHaveBeenCalledWith("为登录流程补齐测试")
|
|
277
|
+
// 调用序:切档先于发送
|
|
278
|
+
expect(setPolicyOrder).toBe(0)
|
|
279
|
+
expect(sendOrder).toBe(1)
|
|
280
|
+
})
|
|
281
|
+
})
|
|
282
|
+
|
|
283
|
+
describe("③ 切档失败 fail-closed", () => {
|
|
284
|
+
it("setSandboxPolicy reject → 不发送、草稿保留 chip、toast 错误", async () => {
|
|
285
|
+
vi.mocked(setSandboxPolicy).mockRejectedValue(new Error("policy denied"))
|
|
286
|
+
const { onSend } = renderComposer()
|
|
287
|
+
await waitFor(() => expect(getChipDom("plan")).not.toBeNull(), { timeout: 3000 })
|
|
288
|
+
|
|
289
|
+
fireEvent.keyDown(getEditorDom(), { key: "Enter" })
|
|
290
|
+
|
|
291
|
+
// 切档尝试过(失败)
|
|
292
|
+
expect(setSandboxPolicy).toHaveBeenCalledTimes(1)
|
|
293
|
+
// fail-closed:不发送
|
|
294
|
+
expect(onSend).not.toHaveBeenCalled()
|
|
295
|
+
// 草稿保留:chip 仍在(仍 claimed,可改参数重试)
|
|
296
|
+
await waitFor(() => expect(toast.error).toHaveBeenCalledTimes(1), { timeout: 3000 })
|
|
297
|
+
expect(getChipDom("plan")).not.toBeNull()
|
|
298
|
+
})
|
|
299
|
+
})
|
|
300
|
+
|
|
301
|
+
describe("④ 附件信封", () => {
|
|
302
|
+
it("草稿带附件 → Enter → 拦截 toast、不切档不发送(plan 无 acceptsAttachments)", async () => {
|
|
303
|
+
const { onSend } = renderComposer({ attachments: [fakeAttachment("ready")] })
|
|
304
|
+
await waitFor(() => expect(getChipDom("plan")).not.toBeNull(), { timeout: 3000 })
|
|
305
|
+
expect(document.querySelector<HTMLElement>('img[alt="a.png"]')).not.toBeNull()
|
|
306
|
+
|
|
307
|
+
fireEvent.keyDown(getEditorDom(), { key: "Enter" })
|
|
308
|
+
|
|
309
|
+
expect(toast.info).toHaveBeenCalledTimes(1)
|
|
310
|
+
expect(toast.info).toHaveBeenCalledWith(m.harness_command_claimAttachmentsUnsupported({ command: "plan" }))
|
|
311
|
+
// 信封守卫先于切档:不切档、不发送
|
|
312
|
+
expect(setSandboxPolicy).not.toHaveBeenCalled()
|
|
313
|
+
expect(onSend).not.toHaveBeenCalled()
|
|
314
|
+
// 草稿保留(仍 claimed)
|
|
315
|
+
expect(getChipDom("plan")).not.toBeNull()
|
|
316
|
+
})
|
|
317
|
+
})
|
|
318
|
+
|
|
319
|
+
describe("⑤ Space 裁定", () => {
|
|
320
|
+
it("手敲 /plan + Space → 落 chip(client input 命令 Space 裁定,T1 断点②回归)", async () => {
|
|
321
|
+
// 预填触发串 "/plan"(无 Space)——不落 chip(尚未裁定);补 Space → 落 chip。
|
|
322
|
+
render(
|
|
323
|
+
<HarnessComposer
|
|
324
|
+
threadId="t1"
|
|
325
|
+
isRunning={false}
|
|
326
|
+
hasAiKey
|
|
327
|
+
busyPreference="queue"
|
|
328
|
+
onSend={vi.fn()}
|
|
329
|
+
onStop={vi.fn()}
|
|
330
|
+
conversationRegionRef={{ current: null }}
|
|
331
|
+
messages={[]}
|
|
332
|
+
models={[]}
|
|
333
|
+
onPlanSubmit={vi.fn()}
|
|
334
|
+
handoffPrefillText="/plan"
|
|
335
|
+
/>,
|
|
336
|
+
)
|
|
337
|
+
await waitFor(() => expect(getEditorDom()).not.toBeNull(), { timeout: 3000 })
|
|
338
|
+
expect(getChipDom("plan")).toBeNull()
|
|
339
|
+
|
|
340
|
+
fireEvent.keyDown(getEditorDom(), { key: " " })
|
|
341
|
+
|
|
342
|
+
await waitFor(() => expect(getChipDom("plan")).not.toBeNull(), { timeout: 3000 })
|
|
343
|
+
})
|
|
344
|
+
})
|