@vibe-forge/client 0.9.0 → 0.10.1
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/AGENTS.md +75 -0
- package/dist/assets/abap-DLDM7-KI.js +1 -0
- package/dist/assets/apex-DNDY2TF8.js +1 -0
- package/dist/assets/{arc-D9HxM0yv.js → arc-C1rWFTer.js} +1 -1
- package/dist/assets/azcli-Y6nb8tq_.js +1 -0
- package/dist/assets/bat-BwHxbl9M.js +1 -0
- package/dist/assets/bicep-CFznDFnq.js +2 -0
- package/dist/assets/{blockDiagram-c4efeb88-C_pTeiD4.js → blockDiagram-c4efeb88-DlZ9x70F.js} +1 -1
- package/dist/assets/{c4Diagram-c83219d4-_oYrCrLr.js → c4Diagram-c83219d4-BKKxi__y.js} +1 -1
- package/dist/assets/cameligo-Bf6VGUru.js +1 -0
- package/dist/assets/channel-F1aqMANO.js +1 -0
- package/dist/assets/{classDiagram-beda092f-9dnkgPhR.js → classDiagram-beda092f-CVGPySZq.js} +1 -1
- package/dist/assets/{classDiagram-v2-2358418a-BUIeZpdO.js → classDiagram-v2-2358418a-7kp8GVVj.js} +1 -1
- package/dist/assets/clojure-Dnu-v4kV.js +1 -0
- package/dist/assets/clone-B-GCuXNo.js +1 -0
- package/dist/assets/codicon-ngg6Pgfi.ttf +0 -0
- package/dist/assets/coffee-Bd8akH9Z.js +1 -0
- package/dist/assets/cpp-BbWJElDN.js +1 -0
- package/dist/assets/{createText-1719965b-DuRFplcD.js → createText-1719965b-Dykv8kT9.js} +1 -1
- package/dist/assets/csharp-Co3qMtFm.js +1 -0
- package/dist/assets/csp-D-4FJmMZ.js +1 -0
- package/dist/assets/css-DdJfP1eB.js +3 -0
- package/dist/assets/css.worker-BvV5MPou.js +93 -0
- package/dist/assets/cssMode-B59COYVW.js +1 -0
- package/dist/assets/cypher-cTPe9QuQ.js +1 -0
- package/dist/assets/dart-BOtBlQCF.js +1 -0
- package/dist/assets/dockerfile-BG73LgW2.js +1 -0
- package/dist/assets/ecl-BEgZUVRK.js +1 -0
- package/dist/assets/{edges-96097737-CTpq6Ih_.js → edges-96097737-CkZ1ZBro.js} +1 -1
- package/dist/assets/editor.worker-CKy7Pnvo.js +26 -0
- package/dist/assets/elixir-BkW5O-1t.js +1 -0
- package/dist/assets/{erDiagram-0228fc6a-CWFgdO1E.js → erDiagram-0228fc6a-281ADcRp.js} +1 -1
- package/dist/assets/flow9-BeJ5waoc.js +1 -0
- package/dist/assets/{flowDb-c6c81e3f-8Vdx29oZ.js → flowDb-c6c81e3f-BQjX_flP.js} +1 -1
- package/dist/assets/{flowDiagram-50d868cf-6S9wOVNl.js → flowDiagram-50d868cf-DMHZTjES.js} +1 -1
- package/dist/assets/flowDiagram-v2-4f6560a1-C5FzdVl1.js +1 -0
- package/dist/assets/{flowchart-elk-definition-6af322e1-DVcZ-ZBQ.js → flowchart-elk-definition-6af322e1-CI3yz4z8.js} +1 -1
- package/dist/assets/freemarker2-DWnWjibn.js +3 -0
- package/dist/assets/fsharp-PahG7c26.js +1 -0
- package/dist/assets/{ganttDiagram-a2739b55-DY1QSl-x.js → ganttDiagram-a2739b55-B3IING9L.js} +1 -1
- package/dist/assets/{gitGraphDiagram-82fe8481-BP08OBKL.js → gitGraphDiagram-82fe8481-CnArIr_T.js} +1 -1
- package/dist/assets/go-acbASCJo.js +1 -0
- package/dist/assets/{graph-D8GCszcN.js → graph-BZ1F0Yve.js} +1 -1
- package/dist/assets/graphql-BxJiqAUM.js +1 -0
- package/dist/assets/handlebars-C1QH9qTz.js +1 -0
- package/dist/assets/hcl-DtV1sZF8.js +1 -0
- package/dist/assets/html-D1NkqHjC.js +1 -0
- package/dist/assets/html.worker-BLJhxQJQ.js +470 -0
- package/dist/assets/htmlMode-DAZCE_rA.js +1 -0
- package/dist/assets/{index-5325376f-OOoAXU1u.js → index-5325376f-Da9zSHjA.js} +1 -1
- package/dist/assets/index-C0vjF3D0.js +1511 -0
- package/dist/assets/index-vzEbM21t.css +32 -0
- package/dist/assets/{infoDiagram-8eee0895-BHgkXjhJ.js → infoDiagram-8eee0895-DYbFvRM7.js} +1 -1
- package/dist/assets/ini-Kd9XrMLS.js +1 -0
- package/dist/assets/java-CXBNlu9o.js +1 -0
- package/dist/assets/javascript-CoMjGRHa.js +1 -0
- package/dist/assets/{journeyDiagram-c64418c1-BljInElp.js → journeyDiagram-c64418c1-Boebox0b.js} +1 -1
- package/dist/assets/json.worker-usMZ-FED.js +58 -0
- package/dist/assets/jsonMode-D__gAvuz.js +7 -0
- package/dist/assets/julia-cl7-CwDS.js +1 -0
- package/dist/assets/kotlin-s7OhZKlX.js +1 -0
- package/dist/assets/{layout-Cw-SwAFD.js → layout-CTcHNbHp.js} +1 -1
- package/dist/assets/less-9HpZscsL.js +2 -0
- package/dist/assets/lexon-OrD6JF1K.js +1 -0
- package/dist/assets/{line-Q-uZLuUr.js → line-4AwinCz2.js} +1 -1
- package/dist/assets/{linear-BahOnNn3.js → linear-CeSMLzJW.js} +1 -1
- package/dist/assets/liquid-DZF6egdE.js +1 -0
- package/dist/assets/lspLanguageFeatures-6K4lv5S2.js +4 -0
- package/dist/assets/lua-Cyyb5UIc.js +1 -0
- package/dist/assets/m3-B8OfTtLu.js +1 -0
- package/dist/assets/markdown-BFxVWTOG.js +1 -0
- package/dist/assets/mdx-Cnt4ka6w.js +1 -0
- package/dist/assets/{mermaid.core-BR0Qh3Rd.js → mermaid.core-B0yG5s4D.js} +6 -6
- package/dist/assets/{mindmap-definition-8da855dc-Brq2OJUZ.js → mindmap-definition-8da855dc-KJEvXMKj.js} +1 -1
- package/dist/assets/mips-CiqrrVzr.js +1 -0
- package/dist/assets/msdax-DmeGPVcC.js +1 -0
- package/dist/assets/mysql-C_tMU-Nz.js +1 -0
- package/dist/assets/objective-c-BDtDVThU.js +1 -0
- package/dist/assets/pascal-vHIfCaH5.js +1 -0
- package/dist/assets/pascaligo-DtZ0uQbO.js +1 -0
- package/dist/assets/perl-Ub6l9XKa.js +1 -0
- package/dist/assets/pgsql-BlNEE0v7.js +1 -0
- package/dist/assets/php-BBUBE1dy.js +1 -0
- package/dist/assets/{pieDiagram-a8764435-uhYdiXro.js → pieDiagram-a8764435-17nFAXPJ.js} +1 -1
- package/dist/assets/pla-DSh2-awV.js +1 -0
- package/dist/assets/postiats-CocnycG-.js +1 -0
- package/dist/assets/powerquery-tScXyioY.js +1 -0
- package/dist/assets/powershell-COWaemsV.js +1 -0
- package/dist/assets/protobuf-Brw8urJB.js +2 -0
- package/dist/assets/pug-8SOpv6rk.js +1 -0
- package/dist/assets/python-DA3TtjDv.js +1 -0
- package/dist/assets/qsharp-Bw9ernYp.js +1 -0
- package/dist/assets/{quadrantDiagram-1e28029f-TwqtEe7e.js → quadrantDiagram-1e28029f-Dt4vubi-.js} +1 -1
- package/dist/assets/r-j7ic8hl3.js +1 -0
- package/dist/assets/razor-CWDJgvX_.js +1 -0
- package/dist/assets/redis-Bu5POkcn.js +1 -0
- package/dist/assets/redshift-Bs9aos_-.js +1 -0
- package/dist/assets/{requirementDiagram-08caed73-DSXnPRDS.js → requirementDiagram-08caed73-H6aDyDK-.js} +1 -1
- package/dist/assets/restructuredtext-CqXO7rUv.js +1 -0
- package/dist/assets/ruby-zBfavPgS.js +1 -0
- package/dist/assets/rust-BzKRNQWT.js +1 -0
- package/dist/assets/{sankeyDiagram-a04cb91d-EADpJeAn.js → sankeyDiagram-a04cb91d-DxsVtbjI.js} +1 -1
- package/dist/assets/sb-BBc9UKZt.js +1 -0
- package/dist/assets/scala-D9hQfWCl.js +1 -0
- package/dist/assets/scheme-BPhDTwHR.js +1 -0
- package/dist/assets/scss-CBJaRo0y.js +3 -0
- package/dist/assets/{sequenceDiagram-c5b8d532-C8qXvt9z.js → sequenceDiagram-c5b8d532-BHa148XJ.js} +1 -1
- package/dist/assets/shell-DiJ1NA_G.js +1 -0
- package/dist/assets/solidity-Db0IVjzk.js +1 -0
- package/dist/assets/sophia-CnS9iZB_.js +1 -0
- package/dist/assets/sparql-CJmd_6j2.js +1 -0
- package/dist/assets/sql-ClhHkBeG.js +1 -0
- package/dist/assets/st-CHwy0fLd.js +1 -0
- package/dist/assets/{stateDiagram-1ecb1508-5W0ghy_S.js → stateDiagram-1ecb1508-DgwBm8LO.js} +1 -1
- package/dist/assets/{stateDiagram-v2-c2b004d7-BfwOQJw4.js → stateDiagram-v2-c2b004d7-BK7IQLVc.js} +1 -1
- package/dist/assets/{styles-b4e223ce-EkKH_ULb.js → styles-b4e223ce-DzW27Bc-.js} +1 -1
- package/dist/assets/{styles-ca3715f6-DwhrtqlU.js → styles-ca3715f6-Dex2GiLT.js} +1 -1
- package/dist/assets/{styles-d45a18b0-yqL8KH6x.js → styles-d45a18b0-B6fGtDKS.js} +1 -1
- package/dist/assets/{svgDrawCommon-b86b1483--5VjnjhC.js → svgDrawCommon-b86b1483-B4HYgfV5.js} +1 -1
- package/dist/assets/swift-Bqt4WxQ4.js +3 -0
- package/dist/assets/systemverilog-Bs9z6M-B.js +1 -0
- package/dist/assets/tcl-Dm6ycUr_.js +1 -0
- package/dist/assets/{timeline-definition-faaaa080-CWOTwik9.js → timeline-definition-faaaa080--QSbWb25.js} +1 -1
- package/dist/assets/ts.worker-DGHjMaqB.js +67731 -0
- package/dist/assets/tsMode-ZM7ocZCH.js +11 -0
- package/dist/assets/twig-Csy3S7wG.js +1 -0
- package/dist/assets/typescript-CKWDmBCc.js +1 -0
- package/dist/assets/typespec-Btyra-wh.js +1 -0
- package/dist/assets/vb-Db0cS2oM.js +1 -0
- package/dist/assets/wgsl-BTesnYfV.js +298 -0
- package/dist/assets/xml-DuEUAzPi.js +1 -0
- package/dist/assets/{xychartDiagram-f5964ef8-CZg47H1t.js → xychartDiagram-f5964ef8-D09Zkv2K.js} +1 -1
- package/dist/assets/yaml-DL7QPRYk.js +1 -0
- package/dist/favicon.svg +3 -3
- package/dist/index.html +2 -2
- package/package.json +14 -10
- package/public/favicon.svg +3 -3
- package/src/api/sessions.ts +36 -0
- package/src/api/workspace.ts +19 -0
- package/src/api.ts +4 -0
- package/src/components/NavRail.scss +9 -10
- package/src/components/ShortcutDisplay.scss +38 -0
- package/src/components/ShortcutDisplay.tsx +37 -0
- package/src/components/ShortcutTooltip.scss +36 -0
- package/src/components/ShortcutTooltip.tsx +84 -0
- package/src/components/Sidebar.scss +55 -13
- package/src/components/Sidebar.tsx +141 -52
- package/src/components/chat/AGENTS.md +163 -0
- package/src/components/chat/ChatHeader.scss +308 -49
- package/src/components/chat/ChatHeader.tsx +394 -80
- package/src/components/chat/ChatHistoryView.tsx +353 -69
- package/src/components/chat/ChatSettingsView.tsx +5 -3
- package/src/components/chat/ChatTimelineView.scss +3 -2
- package/src/components/chat/{sender/ThinkingStatus.tsx → ThinkingStatus.tsx} +1 -1
- package/src/components/chat/messages/MessageContextMenu.scss +145 -0
- package/src/components/chat/messages/MessageContextMenu.tsx +108 -0
- package/src/components/chat/messages/MessageContextMenuContent.tsx +87 -0
- package/src/components/chat/messages/MessageFooter.tsx +44 -24
- package/src/components/chat/messages/MessageItem.scss +157 -10
- package/src/components/chat/messages/MessageItem.tsx +382 -13
- package/src/components/chat/messages/build-message-context-menu-entries.ts +166 -0
- package/src/components/chat/messages/message-content-utils.ts +121 -0
- package/src/components/chat/messages/message-turns.ts +88 -0
- package/src/components/chat/messages/message-utils.ts +19 -1
- package/src/components/chat/sender/@components/adapter-select/AdapterSelectControl.scss +86 -0
- package/src/components/chat/sender/@components/adapter-select/AdapterSelectControl.tsx +54 -0
- package/src/components/chat/sender/@components/adapter-select/AdapterSelectDropdown.scss +42 -0
- package/src/components/chat/sender/@components/effort-select/EffortSelectControl.scss +68 -0
- package/src/components/chat/sender/@components/effort-select/EffortSelectControl.tsx +137 -0
- package/src/components/chat/sender/@components/effort-select/EffortSelectDropdown.scss +96 -0
- package/src/components/chat/sender/@components/model-select/ModelSelectControl.scss +82 -0
- package/src/components/chat/sender/@components/model-select/ModelSelectControl.tsx +171 -0
- package/src/components/chat/sender/@components/model-select/ModelSelectMenu.scss +95 -0
- package/src/components/chat/sender/@components/model-select/ModelSelectMenuLabels.scss +144 -0
- package/src/components/chat/sender/@components/model-select/ModelSelectOptionLabel.tsx +109 -0
- package/src/components/chat/sender/@components/reference-actions/ReferenceActionsControl.scss +106 -0
- package/src/components/chat/sender/@components/reference-actions/ReferenceActionsControl.tsx +156 -0
- package/src/components/chat/sender/@components/reference-actions/ReferenceActionsOption.scss +34 -0
- package/src/components/chat/sender/@components/reference-actions/ReferencePermissionActionsPopover.tsx +111 -0
- package/src/components/chat/sender/@components/sender-attachments/SenderAttachments.scss +103 -0
- package/src/components/chat/sender/@components/sender-attachments/SenderAttachments.tsx +47 -0
- package/src/components/chat/sender/@components/sender-body/SenderBody.tsx +137 -0
- package/src/components/chat/sender/@components/sender-interaction-panel/SenderInteractionPanel.scss +178 -0
- package/src/components/chat/sender/@components/sender-interaction-panel/SenderInteractionPanel.tsx +145 -0
- package/src/components/chat/sender/@components/sender-monaco-editor/SenderMonacoEditor.scss +47 -0
- package/src/components/chat/sender/@components/sender-monaco-editor/SenderMonacoEditor.tsx +121 -0
- package/src/components/chat/sender/@components/sender-monaco-editor/monaco-runtime.ts +99 -0
- package/src/components/chat/sender/@components/sender-monaco-editor/use-sender-editor-handle.ts +48 -0
- package/src/components/chat/sender/@components/sender-monaco-editor/use-sender-monaco-editor.ts +209 -0
- package/src/components/chat/sender/@components/sender-monaco-editor/use-sender-monaco-theme.ts +24 -0
- package/src/components/chat/sender/@components/sender-submit-action/SenderSubmitAction.scss +54 -0
- package/src/components/chat/sender/@components/sender-submit-action/SenderSubmitAction.tsx +80 -0
- package/src/components/chat/sender/@components/sender-toolbar/SenderSelectBase.scss +71 -0
- package/src/components/chat/sender/@components/sender-toolbar/SenderSelectShared.scss +118 -0
- package/src/components/chat/sender/@components/sender-toolbar/SenderToolbar.scss +99 -0
- package/src/components/chat/sender/@components/sender-toolbar/SenderToolbar.tsx +87 -0
- package/src/components/chat/sender/@core/build-sender-controller-result.ts +119 -0
- package/src/components/chat/sender/@core/build-sender-toolbar.ts +122 -0
- package/src/components/chat/sender/@core/content-attachments.ts +76 -0
- package/src/components/chat/sender/@core/create-sender-toolbar-handlers.ts +115 -0
- package/src/components/chat/sender/@core/get-sender-interaction-state.ts +18 -0
- package/src/components/chat/sender/@core/get-sender-runtime-state.ts +14 -0
- package/src/components/chat/sender/@core/sender-toolbar-bindings.ts +155 -0
- package/src/components/chat/sender/@hooks/use-model-select-browser.tsx +189 -0
- package/src/components/chat/sender/@hooks/use-sender-attachments.ts +143 -0
- package/src/components/chat/sender/@hooks/use-sender-autofocus.ts +34 -0
- package/src/components/chat/sender/@hooks/use-sender-completion.ts +62 -0
- package/src/components/chat/sender/@hooks/use-sender-composer-state.ts +34 -0
- package/src/components/chat/sender/@hooks/use-sender-controller.ts +193 -0
- package/src/components/chat/sender/@hooks/use-sender-focus-restore.ts +72 -0
- package/src/components/chat/sender/@hooks/use-sender-history.ts +79 -0
- package/src/components/chat/sender/@hooks/use-sender-keydown.ts +113 -0
- package/src/components/chat/sender/@hooks/use-sender-reference-actions.ts +191 -0
- package/src/components/chat/sender/@hooks/use-sender-reference-focus-restore.ts +21 -0
- package/src/components/chat/sender/@hooks/use-sender-refs.ts +19 -0
- package/src/components/chat/sender/@hooks/use-sender-select-overlays.ts +83 -0
- package/src/components/chat/sender/@hooks/use-sender-shortcuts.ts +78 -0
- package/src/components/chat/sender/@hooks/use-sender-submit.ts +81 -0
- package/src/components/chat/sender/@types/sender-composer.ts +19 -0
- package/src/components/chat/sender/@types/sender-editor.ts +12 -0
- package/src/components/chat/sender/@types/sender-props.ts +50 -0
- package/src/components/chat/sender/@types/sender-toolbar-types.ts +83 -0
- package/src/components/chat/sender/@types/sender-types.ts +21 -0
- package/src/components/chat/sender/@utils/sender-completion.ts +164 -0
- package/src/components/chat/sender/@utils/sender-constants.ts +18 -0
- package/src/components/chat/sender/@utils/sender-utils.ts +45 -0
- package/src/components/chat/sender/Sender.scss +6 -737
- package/src/components/chat/sender/Sender.tsx +53 -921
- package/src/components/chat/session-metadata.ts +55 -0
- package/src/components/chat/terminal/@hooks/use-terminal-instance.ts +152 -0
- package/src/components/chat/terminal/@hooks/use-terminal-session.ts +196 -0
- package/src/components/chat/terminal/ChatTerminalView.scss +62 -0
- package/src/components/chat/terminal/ChatTerminalView.tsx +114 -0
- package/src/components/chat/tools/core/ToolGroup.scss +7 -0
- package/src/components/chat/tools/core/ToolGroup.tsx +94 -44
- package/src/components/config/ConfigSectionForm.tsx +8 -1
- package/src/components/config/ConfigShortcutInput.tsx +9 -2
- package/src/components/config/configSchema.ts +12 -2
- package/src/components/config/record-editors/ModelServicesRecordEditor.tsx +0 -14
- package/src/components/dock-panel/DockPanel.scss +152 -0
- package/src/components/dock-panel/DockPanel.tsx +195 -0
- package/src/components/layout/AppShell.scss +40 -2
- package/src/components/layout/AppShell.tsx +25 -10
- package/src/components/sidebar/SessionContextMenu.scss +143 -0
- package/src/components/sidebar/SessionContextMenu.tsx +196 -0
- package/src/components/sidebar/SessionContextMenuContent.tsx +89 -0
- package/src/components/sidebar/SessionItem.scss +150 -67
- package/src/components/sidebar/SessionItem.tsx +183 -134
- package/src/components/sidebar/SessionList.scss +47 -17
- package/src/components/sidebar/SessionList.tsx +31 -16
- package/src/components/sidebar/SidebarHeader.scss +329 -49
- package/src/components/sidebar/SidebarHeader.tsx +108 -86
- package/src/components/sidebar/SidebarHeaderBatchActions.tsx +81 -0
- package/src/components/sidebar/SidebarHeaderSearchActions.tsx +176 -0
- package/src/components/sidebar/SidebarHeaderSelectField.tsx +24 -0
- package/src/components/sidebar/filter-utils.ts +23 -0
- package/src/components/workspace/ContextFilePicker.scss +64 -0
- package/src/components/workspace/ContextFilePicker.tsx +171 -0
- package/src/connectionManager.ts +4 -2
- package/src/hooks/chat/interaction-state.ts +67 -0
- package/src/hooks/chat/model-selector-data-builders.ts +146 -0
- package/src/hooks/chat/model-selector-data-option-utils.ts +62 -0
- package/src/hooks/chat/model-selector-data-types.ts +27 -0
- package/src/hooks/chat/model-selector-data.ts +109 -0
- package/src/hooks/chat/model-selector-recommendations.ts +69 -0
- package/src/hooks/chat/model-selector.ts +9 -0
- package/src/hooks/chat/use-chat-interaction.ts +13 -8
- package/src/hooks/chat/use-chat-model-adapter-selection.tsx +167 -164
- package/src/hooks/chat/use-chat-models.tsx +46 -23
- package/src/hooks/chat/use-chat-session-actions.ts +69 -23
- package/src/hooks/chat/use-chat-session-messages.ts +158 -60
- package/src/hooks/chat/use-chat-session.ts +34 -9
- package/src/hooks/chat/use-chat-view.ts +26 -6
- package/src/hooks/chat/use-composer-control-shortcuts.ts +69 -0
- package/src/hooks/chat/use-terminal-dock-visibility.ts +39 -0
- package/src/hooks/use-roving-focus-list.ts +104 -0
- package/src/hooks/use-sidebar-navigation.ts +9 -4
- package/src/hooks/use-sidebar-query-state.ts +79 -0
- package/src/main.tsx +6 -1
- package/src/resources/locales/en.json +140 -6
- package/src/resources/locales/zh.json +140 -6
- package/src/routes/ChatRoute.scss +159 -4
- package/src/routes/ChatRoute.tsx +72 -10
- package/src/runtime-config.ts +21 -0
- package/src/store/index.ts +1 -3
- package/src/styles/global.scss +12 -2
- package/src/utils/chat-links.ts +21 -0
- package/src/utils/copy.ts +18 -0
- package/src/utils/shortcutUtils.ts +111 -1
- package/src/vite-env.d.ts +1 -0
- package/src/ws.ts +6 -5
- package/vite.config.ts +71 -7
- package/dist/assets/channel-Di8KkPU4.js +0 -1
- package/dist/assets/clone-B065n6L-.js +0 -1
- package/dist/assets/flowDiagram-v2-4f6560a1-nj-oVLPK.js +0 -1
- package/dist/assets/index-BZe1Qtye.css +0 -1
- package/dist/assets/index-DV3eI2aD.js +0 -557
- package/src/components/chat/sender/CompletionMenu.scss +0 -70
- package/src/components/chat/sender/CompletionMenu.tsx +0 -58
- /package/src/components/chat/{sender/ThinkingStatus.scss → ThinkingStatus.scss} +0 -0
- /package/src/components/chat/sender/{interaction-request.ts → @core/interaction-request.ts} +0 -0
package/src/components/chat/sender/@components/sender-interaction-panel/SenderInteractionPanel.scss
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
.chat-input-wrapper--permission {
|
|
2
|
+
.interaction-panel {
|
|
3
|
+
margin-bottom: 0;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.interaction-panel {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
width: 100%;
|
|
11
|
+
gap: 6px;
|
|
12
|
+
padding: 12px;
|
|
13
|
+
border: 1px solid var(--border-color);
|
|
14
|
+
border-radius: 12px;
|
|
15
|
+
background-color: var(--input-bg, #f9fafb);
|
|
16
|
+
|
|
17
|
+
&__header {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&__options {
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
gap: 6px;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&__secondary {
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
gap: 6px;
|
|
32
|
+
overflow: hidden;
|
|
33
|
+
animation: interaction-panel-secondary-enter .2s ease;
|
|
34
|
+
transform-origin: top;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&__option.ant-btn {
|
|
38
|
+
height: auto;
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content: flex-start;
|
|
42
|
+
gap: 8px;
|
|
43
|
+
padding: 8px 10px;
|
|
44
|
+
border-radius: 10px;
|
|
45
|
+
border-color: var(--border-color);
|
|
46
|
+
background: var(--bg-color);
|
|
47
|
+
box-shadow: none;
|
|
48
|
+
text-align: left;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&__option.ant-btn:hover,
|
|
52
|
+
&__option.ant-btn:focus {
|
|
53
|
+
border-color: rgba(59, 130, 246, .3);
|
|
54
|
+
background: var(--bg-color);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&__option--allow.ant-btn {
|
|
58
|
+
.interaction-panel__option-icon {
|
|
59
|
+
color: #15803d;
|
|
60
|
+
background-color: rgba(22, 163, 74, .1);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&__option--deny.ant-btn {
|
|
65
|
+
.interaction-panel__option-icon {
|
|
66
|
+
color: #b91c1c;
|
|
67
|
+
background-color: rgba(220, 38, 38, .08);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&__option--neutral.ant-btn {
|
|
72
|
+
.interaction-panel__option-icon {
|
|
73
|
+
color: #6b7280;
|
|
74
|
+
background-color: rgba(15, 23, 42, .06);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&__option-icon {
|
|
79
|
+
display: inline-flex;
|
|
80
|
+
align-items: center;
|
|
81
|
+
justify-content: center;
|
|
82
|
+
width: 22px;
|
|
83
|
+
height: 22px;
|
|
84
|
+
border-radius: 999px;
|
|
85
|
+
flex: 0 0 auto;
|
|
86
|
+
align-self: center;
|
|
87
|
+
font-size: 13px;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
&__option-copy {
|
|
91
|
+
display: flex;
|
|
92
|
+
align-items: center;
|
|
93
|
+
min-width: 0;
|
|
94
|
+
flex: 1;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
&__option-text {
|
|
98
|
+
display: flex;
|
|
99
|
+
flex-direction: column;
|
|
100
|
+
gap: 1px;
|
|
101
|
+
min-width: 0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
&__option-label {
|
|
105
|
+
font-size: 11px;
|
|
106
|
+
font-weight: 500;
|
|
107
|
+
line-height: 1.35;
|
|
108
|
+
color: var(--text-color);
|
|
109
|
+
word-break: break-word;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
&__option-description {
|
|
113
|
+
font-size: 10px;
|
|
114
|
+
line-height: 1.25;
|
|
115
|
+
color: var(--placeholder-color, #9ca3af);
|
|
116
|
+
word-break: break-word;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
&__toggle.ant-btn {
|
|
120
|
+
height: auto;
|
|
121
|
+
display: inline-flex;
|
|
122
|
+
align-items: center;
|
|
123
|
+
justify-content: flex-start;
|
|
124
|
+
gap: 4px;
|
|
125
|
+
width: fit-content;
|
|
126
|
+
padding: 0;
|
|
127
|
+
color: var(--placeholder-color, #9ca3af);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
&__toggle.ant-btn:hover,
|
|
131
|
+
&__toggle.ant-btn:focus {
|
|
132
|
+
color: var(--sub-text-color, #6b7280);
|
|
133
|
+
background: transparent;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
&__toggle-label {
|
|
137
|
+
font-size: 10px;
|
|
138
|
+
line-height: 1.3;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
&__toggle-icon {
|
|
142
|
+
font-size: 14px;
|
|
143
|
+
line-height: 1;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
@keyframes interaction-panel-secondary-enter {
|
|
148
|
+
from {
|
|
149
|
+
max-height: 0;
|
|
150
|
+
opacity: 0;
|
|
151
|
+
transform: translateY(-4px);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
to {
|
|
155
|
+
max-height: 240px;
|
|
156
|
+
opacity: 1;
|
|
157
|
+
transform: translateY(0);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.interaction-question {
|
|
162
|
+
font-size: 12px;
|
|
163
|
+
font-weight: 600;
|
|
164
|
+
line-height: 1.4;
|
|
165
|
+
color: var(--text-color);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
@media (prefers-reduced-motion: reduce) {
|
|
169
|
+
.interaction-panel__secondary {
|
|
170
|
+
animation: none;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
html.dark {
|
|
175
|
+
.interaction-panel {
|
|
176
|
+
--input-bg: #1f1f1f;
|
|
177
|
+
}
|
|
178
|
+
}
|
package/src/components/chat/sender/@components/sender-interaction-panel/SenderInteractionPanel.tsx
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import './SenderInteractionPanel.scss'
|
|
2
|
+
|
|
3
|
+
import { Button } from 'antd'
|
|
4
|
+
import { useEffect, useState } from 'react'
|
|
5
|
+
import { useTranslation } from 'react-i18next'
|
|
6
|
+
|
|
7
|
+
import type { AskUserQuestionParams } from '@vibe-forge/core'
|
|
8
|
+
import type { PermissionInteractionContext } from '@vibe-forge/types'
|
|
9
|
+
|
|
10
|
+
const primaryOptionValues = new Set(['allow_once', 'allow_session', 'deny_once'])
|
|
11
|
+
|
|
12
|
+
const getOptionMeta = (value?: string) => {
|
|
13
|
+
switch (value) {
|
|
14
|
+
case 'allow_once':
|
|
15
|
+
return { icon: 'task_alt', tone: 'allow' as const }
|
|
16
|
+
case 'allow_session':
|
|
17
|
+
return { icon: 'history_toggle_off', tone: 'allow' as const }
|
|
18
|
+
case 'allow_project':
|
|
19
|
+
return { icon: 'folder_managed', tone: 'allow' as const }
|
|
20
|
+
case 'deny_once':
|
|
21
|
+
return { icon: 'cancel', tone: 'deny' as const }
|
|
22
|
+
case 'deny_session':
|
|
23
|
+
return { icon: 'block', tone: 'deny' as const }
|
|
24
|
+
case 'deny_project':
|
|
25
|
+
return { icon: 'folder_off', tone: 'deny' as const }
|
|
26
|
+
default:
|
|
27
|
+
return { icon: 'help', tone: 'neutral' as const }
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function SenderInteractionPanel({
|
|
32
|
+
interactionRequest,
|
|
33
|
+
permissionContext,
|
|
34
|
+
deniedTools,
|
|
35
|
+
reasons: _reasons,
|
|
36
|
+
onInteractionResponse
|
|
37
|
+
}: {
|
|
38
|
+
interactionRequest: { id: string; payload: AskUserQuestionParams }
|
|
39
|
+
permissionContext?: PermissionInteractionContext
|
|
40
|
+
deniedTools: string[]
|
|
41
|
+
reasons: string[]
|
|
42
|
+
onInteractionResponse?: (id: string, data: string | string[]) => void
|
|
43
|
+
}) {
|
|
44
|
+
const { t } = useTranslation()
|
|
45
|
+
const [showAllOptions, setShowAllOptions] = useState(false)
|
|
46
|
+
|
|
47
|
+
const toolNames = [
|
|
48
|
+
permissionContext?.subjectLabel?.trim() ?? '',
|
|
49
|
+
...deniedTools.map(tool => tool.trim())
|
|
50
|
+
].filter((value, index, values) => value !== '' && values.indexOf(value) === index)
|
|
51
|
+
const toolSummary = toolNames.join('、')
|
|
52
|
+
const title = toolSummary === ''
|
|
53
|
+
? interactionRequest.payload.question
|
|
54
|
+
: t('chat.permissionRequestTitleWithTool', { tool: toolSummary })
|
|
55
|
+
const primaryOptions =
|
|
56
|
+
interactionRequest.payload.options?.filter(option => primaryOptionValues.has(option.value ?? '')) ?? []
|
|
57
|
+
const secondaryOptions =
|
|
58
|
+
interactionRequest.payload.options?.filter(option => !primaryOptionValues.has(option.value ?? '')) ?? []
|
|
59
|
+
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
setShowAllOptions(false)
|
|
62
|
+
}, [interactionRequest.id])
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<div className='interaction-panel'>
|
|
66
|
+
<div className='interaction-panel__header'>
|
|
67
|
+
<div className='interaction-question'>
|
|
68
|
+
{title}
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
<div className='interaction-panel__options'>
|
|
72
|
+
{primaryOptions.map((option: { label: string; value?: string; description?: string }) => {
|
|
73
|
+
const meta = getOptionMeta(option.value)
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<Button
|
|
77
|
+
key={option.value ?? option.label}
|
|
78
|
+
className={[
|
|
79
|
+
'interaction-panel__option',
|
|
80
|
+
`interaction-panel__option--${meta.tone}`
|
|
81
|
+
].join(' ')}
|
|
82
|
+
onClick={() => onInteractionResponse?.(interactionRequest.id, option.value ?? option.label)}
|
|
83
|
+
>
|
|
84
|
+
<span className='interaction-panel__option-icon material-symbols-rounded'>{meta.icon}</span>
|
|
85
|
+
<div className='interaction-panel__option-copy'>
|
|
86
|
+
<div className='interaction-panel__option-text'>
|
|
87
|
+
<div className='interaction-panel__option-label'>{option.label}</div>
|
|
88
|
+
{option.description && (
|
|
89
|
+
<div className='interaction-panel__option-description'>
|
|
90
|
+
{option.description}
|
|
91
|
+
</div>
|
|
92
|
+
)}
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
</Button>
|
|
96
|
+
)
|
|
97
|
+
})}
|
|
98
|
+
{showAllOptions && secondaryOptions.length > 0 && (
|
|
99
|
+
<div className='interaction-panel__secondary'>
|
|
100
|
+
{secondaryOptions.map((option: { label: string; value?: string; description?: string }) => {
|
|
101
|
+
const meta = getOptionMeta(option.value)
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<Button
|
|
105
|
+
key={option.value ?? option.label}
|
|
106
|
+
className={[
|
|
107
|
+
'interaction-panel__option',
|
|
108
|
+
`interaction-panel__option--${meta.tone}`
|
|
109
|
+
].join(' ')}
|
|
110
|
+
onClick={() => onInteractionResponse?.(interactionRequest.id, option.value ?? option.label)}
|
|
111
|
+
>
|
|
112
|
+
<span className='interaction-panel__option-icon material-symbols-rounded'>{meta.icon}</span>
|
|
113
|
+
<div className='interaction-panel__option-copy'>
|
|
114
|
+
<div className='interaction-panel__option-text'>
|
|
115
|
+
<div className='interaction-panel__option-label'>{option.label}</div>
|
|
116
|
+
{option.description && (
|
|
117
|
+
<div className='interaction-panel__option-description'>
|
|
118
|
+
{option.description}
|
|
119
|
+
</div>
|
|
120
|
+
)}
|
|
121
|
+
</div>
|
|
122
|
+
</div>
|
|
123
|
+
</Button>
|
|
124
|
+
)
|
|
125
|
+
})}
|
|
126
|
+
</div>
|
|
127
|
+
)}
|
|
128
|
+
{secondaryOptions.length > 0 && (
|
|
129
|
+
<Button
|
|
130
|
+
type='text'
|
|
131
|
+
className='interaction-panel__toggle'
|
|
132
|
+
onClick={() => setShowAllOptions(current => !current)}
|
|
133
|
+
>
|
|
134
|
+
<span className='interaction-panel__toggle-label'>
|
|
135
|
+
{showAllOptions ? t('chat.permissionCollapseOptions') : t('chat.permissionExpandOptions')}
|
|
136
|
+
</span>
|
|
137
|
+
<span className='interaction-panel__toggle-icon material-symbols-rounded'>
|
|
138
|
+
{showAllOptions ? 'expand_less' : 'expand_more'}
|
|
139
|
+
</span>
|
|
140
|
+
</Button>
|
|
141
|
+
)}
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
)
|
|
145
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
.chat-input-monaco {
|
|
2
|
+
width: 100%;
|
|
3
|
+
|
|
4
|
+
&__editor {
|
|
5
|
+
width: 100%;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
&__token--agent {
|
|
9
|
+
color: var(--primary-text-color);
|
|
10
|
+
font-weight: 600;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&__token--tool {
|
|
14
|
+
color: var(--success-color);
|
|
15
|
+
font-weight: 600;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&__token--command {
|
|
19
|
+
color: var(--warning-color);
|
|
20
|
+
font-weight: 600;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.monaco-editor,
|
|
24
|
+
.monaco-editor-background,
|
|
25
|
+
.monaco-editor .margin,
|
|
26
|
+
.monaco-editor .inputarea.ime-input {
|
|
27
|
+
background: transparent !important;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.monaco-editor .scroll-decoration,
|
|
31
|
+
.monaco-editor .minimap-shadow-visible {
|
|
32
|
+
box-shadow: none !important;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.monaco-editor .suggest-widget {
|
|
36
|
+
border: 1px solid var(--border-color);
|
|
37
|
+
border-radius: 10px;
|
|
38
|
+
overflow: hidden;
|
|
39
|
+
box-shadow:
|
|
40
|
+
0 12px 30px rgba(15, 23, 42, .12),
|
|
41
|
+
0 3px 10px rgba(15, 23, 42, .08);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.monaco-editor .suggest-widget .codicon.codicon-symbol-interface::before {
|
|
45
|
+
content: '\eb08';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import './SenderMonacoEditor.scss'
|
|
2
|
+
|
|
3
|
+
import Editor from '@monaco-editor/react'
|
|
4
|
+
import { useId } from 'react'
|
|
5
|
+
import type { MutableRefObject } from 'react'
|
|
6
|
+
|
|
7
|
+
import type { SessionInfo } from '@vibe-forge/types'
|
|
8
|
+
|
|
9
|
+
import type { SenderEditorHandle } from '#~/components/chat/sender/@types/sender-editor'
|
|
10
|
+
import type { SenderCompletionMatch, SenderTokenDecoration } from '#~/components/chat/sender/@utils/sender-completion'
|
|
11
|
+
import { FONT_SIZE, LINE_HEIGHT } from './monaco-runtime'
|
|
12
|
+
import { useSenderMonacoEditor } from './use-sender-monaco-editor'
|
|
13
|
+
|
|
14
|
+
export function SenderMonacoEditor({
|
|
15
|
+
editorRef,
|
|
16
|
+
sessionInfo,
|
|
17
|
+
value,
|
|
18
|
+
placeholder,
|
|
19
|
+
disabled,
|
|
20
|
+
sendShortcut,
|
|
21
|
+
onSendShortcut,
|
|
22
|
+
onInputChange,
|
|
23
|
+
onCursorChange,
|
|
24
|
+
onKeyDown,
|
|
25
|
+
onPaste,
|
|
26
|
+
resolveCompletionMatch,
|
|
27
|
+
resolveTokenDecorations
|
|
28
|
+
}: {
|
|
29
|
+
editorRef: MutableRefObject<SenderEditorHandle | null>
|
|
30
|
+
sessionInfo?: SessionInfo | null
|
|
31
|
+
value: string
|
|
32
|
+
placeholder: string
|
|
33
|
+
disabled: boolean
|
|
34
|
+
sendShortcut: string
|
|
35
|
+
onSendShortcut: () => void
|
|
36
|
+
onInputChange: (value: string, cursorOffset: number | null) => void
|
|
37
|
+
onCursorChange: (cursorOffset: number | null) => void
|
|
38
|
+
onKeyDown: (event: KeyboardEvent) => void
|
|
39
|
+
onPaste: (event: ClipboardEvent) => void | Promise<void>
|
|
40
|
+
resolveCompletionMatch: (
|
|
41
|
+
value: string,
|
|
42
|
+
cursorOffset: number | null,
|
|
43
|
+
sessionInfo?: SessionInfo | null
|
|
44
|
+
) => SenderCompletionMatch | null
|
|
45
|
+
resolveTokenDecorations: (value: string) => SenderTokenDecoration[]
|
|
46
|
+
}) {
|
|
47
|
+
const editorId = useId()
|
|
48
|
+
const modelPath = `inmemory://vf-chat-sender/${editorId}.md`
|
|
49
|
+
const {
|
|
50
|
+
themeName,
|
|
51
|
+
editorHeight,
|
|
52
|
+
handleEditorMount
|
|
53
|
+
} = useSenderMonacoEditor({
|
|
54
|
+
editorRef,
|
|
55
|
+
modelPath,
|
|
56
|
+
value,
|
|
57
|
+
disabled,
|
|
58
|
+
sendShortcut,
|
|
59
|
+
onSendShortcut,
|
|
60
|
+
onInputChange,
|
|
61
|
+
onCursorChange,
|
|
62
|
+
onKeyDown,
|
|
63
|
+
onPaste,
|
|
64
|
+
sessionInfo,
|
|
65
|
+
resolveCompletionMatch,
|
|
66
|
+
resolveTokenDecorations
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<div className='chat-input-monaco'>
|
|
71
|
+
<div className='chat-input-monaco__editor' style={{ height: `${editorHeight}px` }}>
|
|
72
|
+
<Editor
|
|
73
|
+
path={modelPath}
|
|
74
|
+
language='markdown'
|
|
75
|
+
theme={themeName}
|
|
76
|
+
value={value}
|
|
77
|
+
loading={null}
|
|
78
|
+
onMount={handleEditorMount}
|
|
79
|
+
options={{
|
|
80
|
+
ariaLabel: placeholder,
|
|
81
|
+
automaticLayout: true,
|
|
82
|
+
domReadOnly: disabled,
|
|
83
|
+
folding: false,
|
|
84
|
+
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace',
|
|
85
|
+
fontSize: FONT_SIZE,
|
|
86
|
+
glyphMargin: false,
|
|
87
|
+
hideCursorInOverviewRuler: true,
|
|
88
|
+
lineDecorationsWidth: 0,
|
|
89
|
+
lineHeight: LINE_HEIGHT,
|
|
90
|
+
lineNumbers: 'off',
|
|
91
|
+
lineNumbersMinChars: 0,
|
|
92
|
+
minimap: { enabled: false },
|
|
93
|
+
overviewRulerBorder: false,
|
|
94
|
+
overviewRulerLanes: 0,
|
|
95
|
+
padding: { top: 0, bottom: 0 },
|
|
96
|
+
placeholder,
|
|
97
|
+
readOnly: disabled,
|
|
98
|
+
renderFinalNewline: 'off',
|
|
99
|
+
renderLineHighlight: 'none',
|
|
100
|
+
roundedSelection: true,
|
|
101
|
+
scrollBeyondLastLine: false,
|
|
102
|
+
scrollbar: {
|
|
103
|
+
alwaysConsumeMouseWheel: false,
|
|
104
|
+
horizontal: 'hidden',
|
|
105
|
+
useShadows: false,
|
|
106
|
+
vertical: 'hidden'
|
|
107
|
+
},
|
|
108
|
+
suggest: {
|
|
109
|
+
preview: true,
|
|
110
|
+
selectionMode: 'whenQuickSuggestion'
|
|
111
|
+
},
|
|
112
|
+
suggestOnTriggerCharacters: true,
|
|
113
|
+
wordWrap: 'on',
|
|
114
|
+
wordWrapColumn: 80,
|
|
115
|
+
wrappingIndent: 'same'
|
|
116
|
+
}}
|
|
117
|
+
/>
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
)
|
|
121
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { loader } from '@monaco-editor/react'
|
|
2
|
+
import type { IRange, editor as MonacoEditorNamespace, languages } from 'monaco-editor'
|
|
3
|
+
import * as monacoApi from 'monaco-editor'
|
|
4
|
+
import EditorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker'
|
|
5
|
+
|
|
6
|
+
import type { SessionInfo } from '@vibe-forge/types'
|
|
7
|
+
|
|
8
|
+
import type { SenderEditorSelection } from '#~/components/chat/sender/@types/sender-editor'
|
|
9
|
+
import type { SenderCompletionMatch } from '#~/components/chat/sender/@utils/sender-completion'
|
|
10
|
+
|
|
11
|
+
export const FONT_SIZE = 13
|
|
12
|
+
export const LINE_HEIGHT = 20
|
|
13
|
+
export const MIN_EDITOR_HEIGHT = LINE_HEIGHT
|
|
14
|
+
export const MAX_EDITOR_HEIGHT = LINE_HEIGHT * 10
|
|
15
|
+
|
|
16
|
+
const monacoRuntime = globalThis as typeof globalThis & {
|
|
17
|
+
MonacoEnvironment?: {
|
|
18
|
+
getWorker: () => Worker
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (monacoRuntime.MonacoEnvironment == null) {
|
|
23
|
+
monacoRuntime.MonacoEnvironment = {
|
|
24
|
+
getWorker: () => new EditorWorker()
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
loader.config({ monaco: monacoApi })
|
|
29
|
+
|
|
30
|
+
export const clampEditorHeight = (height: number) =>
|
|
31
|
+
Math.min(MAX_EDITOR_HEIGHT, Math.max(MIN_EDITOR_HEIGHT, Math.ceil(height)))
|
|
32
|
+
|
|
33
|
+
export const toMonacoRange = (
|
|
34
|
+
model: MonacoEditorNamespace.ITextModel,
|
|
35
|
+
start: number,
|
|
36
|
+
end: number
|
|
37
|
+
) => {
|
|
38
|
+
const rangeStart = model.getPositionAt(start)
|
|
39
|
+
const rangeEnd = model.getPositionAt(end)
|
|
40
|
+
|
|
41
|
+
return new monacoApi.Range(rangeStart.lineNumber, rangeStart.column, rangeEnd.lineNumber, rangeEnd.column)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const getSelectionOffsets = (
|
|
45
|
+
editor: MonacoEditorNamespace.IStandaloneCodeEditor
|
|
46
|
+
): SenderEditorSelection | null => {
|
|
47
|
+
const model = editor.getModel()
|
|
48
|
+
const selection = editor.getSelection()
|
|
49
|
+
|
|
50
|
+
if (model == null || selection == null) {
|
|
51
|
+
return null
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
start: model.getOffsetAt(selection.getStartPosition()),
|
|
56
|
+
end: model.getOffsetAt(selection.getEndPosition())
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const registerSenderCompletionProvider = ({
|
|
61
|
+
monaco,
|
|
62
|
+
resolveCompletionMatch,
|
|
63
|
+
sessionInfo
|
|
64
|
+
}: {
|
|
65
|
+
monaco: typeof monacoApi
|
|
66
|
+
resolveCompletionMatch: (
|
|
67
|
+
value: string,
|
|
68
|
+
cursorOffset: number | null,
|
|
69
|
+
sessionInfo?: SessionInfo | null
|
|
70
|
+
) => SenderCompletionMatch | null
|
|
71
|
+
sessionInfo?: SessionInfo | null
|
|
72
|
+
}) =>
|
|
73
|
+
monaco.languages.registerCompletionItemProvider('markdown', {
|
|
74
|
+
triggerCharacters: ['/', '@', '#'],
|
|
75
|
+
provideCompletionItems: (model, position) => {
|
|
76
|
+
const cursorOffset = model.getOffsetAt(position)
|
|
77
|
+
const match = resolveCompletionMatch(model.getValue(), cursorOffset, sessionInfo)
|
|
78
|
+
|
|
79
|
+
if (match == null || match.items.length === 0) {
|
|
80
|
+
return { suggestions: [] }
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const replaceRange = toMonacoRange(model, match.replaceStart, match.cursorOffset)
|
|
84
|
+
const suggestions: languages.CompletionItem[] = match.items.map((item) => ({
|
|
85
|
+
label: item.label,
|
|
86
|
+
kind: item.kind === 'command'
|
|
87
|
+
? monaco.languages.CompletionItemKind.Function
|
|
88
|
+
: item.kind === 'agent'
|
|
89
|
+
? monaco.languages.CompletionItemKind.Interface
|
|
90
|
+
: monaco.languages.CompletionItemKind.Keyword,
|
|
91
|
+
insertText: `${item.value} `,
|
|
92
|
+
range: replaceRange as IRange,
|
|
93
|
+
filterText: `${match.trigger}${item.value}`,
|
|
94
|
+
sortText: `0-${item.value.toLowerCase()}`
|
|
95
|
+
}))
|
|
96
|
+
|
|
97
|
+
return { suggestions }
|
|
98
|
+
}
|
|
99
|
+
})
|
package/src/components/chat/sender/@components/sender-monaco-editor/use-sender-editor-handle.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { editor as MonacoEditorNamespace } from 'monaco-editor'
|
|
2
|
+
import type { MutableRefObject } from 'react'
|
|
3
|
+
import { useEffect } from 'react'
|
|
4
|
+
|
|
5
|
+
import type { SenderEditorHandle, SenderEditorSelection } from '#~/components/chat/sender/@types/sender-editor'
|
|
6
|
+
|
|
7
|
+
import { getSelectionOffsets, toMonacoRange } from './monaco-runtime'
|
|
8
|
+
|
|
9
|
+
export const useSenderEditorHandle = ({
|
|
10
|
+
editorRef,
|
|
11
|
+
standaloneEditorRef,
|
|
12
|
+
value,
|
|
13
|
+
disabledRef
|
|
14
|
+
}: {
|
|
15
|
+
editorRef: MutableRefObject<SenderEditorHandle | null>
|
|
16
|
+
standaloneEditorRef: MutableRefObject<MonacoEditorNamespace.IStandaloneCodeEditor | null>
|
|
17
|
+
value: string
|
|
18
|
+
disabledRef: MutableRefObject<boolean>
|
|
19
|
+
}) => {
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
editorRef.current = {
|
|
22
|
+
focus: () => {
|
|
23
|
+
standaloneEditorRef.current?.focus()
|
|
24
|
+
},
|
|
25
|
+
setSelection: (selection: SenderEditorSelection) => {
|
|
26
|
+
const editor = standaloneEditorRef.current
|
|
27
|
+
const model = editor?.getModel()
|
|
28
|
+
|
|
29
|
+
if (editor == null || model == null) {
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
editor.setSelection(toMonacoRange(model, selection.start, selection.end))
|
|
34
|
+
},
|
|
35
|
+
getSelection: () => {
|
|
36
|
+
const editor = standaloneEditorRef.current
|
|
37
|
+
|
|
38
|
+
return editor == null ? null : getSelectionOffsets(editor)
|
|
39
|
+
},
|
|
40
|
+
getValue: () => standaloneEditorRef.current?.getValue() ?? value,
|
|
41
|
+
isDisabled: () => disabledRef.current
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return () => {
|
|
45
|
+
editorRef.current = null
|
|
46
|
+
}
|
|
47
|
+
}, [disabledRef, editorRef, standaloneEditorRef, value])
|
|
48
|
+
}
|