@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
|
@@ -1,20 +1,136 @@
|
|
|
1
1
|
import './MessageItem.scss'
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import { App } from 'antd'
|
|
4
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react'
|
|
5
|
+
import { useTranslation } from 'react-i18next'
|
|
6
|
+
import { useSearchParams } from 'react-router-dom'
|
|
7
|
+
|
|
3
8
|
import type { ChatMessage, ChatMessageContent } from '@vibe-forge/core'
|
|
4
|
-
import
|
|
9
|
+
import type { SessionInfo } from '@vibe-forge/types'
|
|
10
|
+
|
|
11
|
+
import { MarkdownContent } from '#~/components/MarkdownContent'
|
|
12
|
+
import { Sender } from '../sender/Sender'
|
|
5
13
|
import { ToolRenderer } from '../tools/core/ToolRenderer'
|
|
14
|
+
import { MessageContextMenu } from './MessageContextMenu'
|
|
6
15
|
import { MessageFooter } from './MessageFooter'
|
|
16
|
+
import {
|
|
17
|
+
getCopyableMessageText,
|
|
18
|
+
getEditableMessageContent,
|
|
19
|
+
isSameEditableMessageContent,
|
|
20
|
+
normalizeEditableMessageContent
|
|
21
|
+
} from './message-content-utils'
|
|
7
22
|
|
|
8
23
|
interface MessageItemProps {
|
|
24
|
+
anchorId: string
|
|
9
25
|
msg: ChatMessage
|
|
10
26
|
isFirstInGroup: boolean
|
|
27
|
+
originalMessage: ChatMessage
|
|
28
|
+
isTargeted: boolean
|
|
29
|
+
sessionId?: string
|
|
30
|
+
sessionInfo?: SessionInfo | null
|
|
31
|
+
isSessionBusy: boolean
|
|
32
|
+
isEditing: boolean
|
|
33
|
+
showAssistantActions: boolean
|
|
34
|
+
onEditMessage: (messageId: string, content: string | ChatMessageContent[]) => Promise<boolean>
|
|
35
|
+
onRecallMessage: (messageId: string) => Promise<boolean>
|
|
36
|
+
onForkMessage: (messageId: string) => Promise<boolean>
|
|
37
|
+
onStartEditing: (messageId: string) => void
|
|
38
|
+
onCancelEditing: (messageId: string) => void
|
|
11
39
|
}
|
|
12
40
|
|
|
41
|
+
type PendingConfirmAction = 'fork' | 'recall' | null
|
|
42
|
+
|
|
43
|
+
const ACTION_SHOW_DELAY_MS = 90
|
|
44
|
+
const ACTION_HIDE_DELAY_MS = 140
|
|
45
|
+
|
|
13
46
|
function MessageItemComponent({
|
|
47
|
+
anchorId,
|
|
14
48
|
msg,
|
|
15
|
-
isFirstInGroup
|
|
49
|
+
isFirstInGroup,
|
|
50
|
+
originalMessage,
|
|
51
|
+
isTargeted,
|
|
52
|
+
sessionId,
|
|
53
|
+
sessionInfo,
|
|
54
|
+
isSessionBusy,
|
|
55
|
+
isEditing,
|
|
56
|
+
showAssistantActions,
|
|
57
|
+
onEditMessage,
|
|
58
|
+
onRecallMessage,
|
|
59
|
+
onForkMessage,
|
|
60
|
+
onStartEditing,
|
|
61
|
+
onCancelEditing
|
|
16
62
|
}: MessageItemProps) {
|
|
63
|
+
const { t } = useTranslation()
|
|
64
|
+
const { message } = App.useApp()
|
|
65
|
+
const [searchParams] = useSearchParams()
|
|
66
|
+
const isDebugMode = searchParams.get('debug') === 'true'
|
|
17
67
|
const isUser = msg.role === 'user'
|
|
68
|
+
const [isSubmitting, setIsSubmitting] = useState(false)
|
|
69
|
+
const [isActionsVisible, setIsActionsVisible] = useState(false)
|
|
70
|
+
const [pendingConfirmAction, setPendingConfirmAction] = useState<PendingConfirmAction>(null)
|
|
71
|
+
const wrapperRef = useRef<HTMLDivElement | null>(null)
|
|
72
|
+
const showActionsTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
|
73
|
+
const hideActionsTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
|
74
|
+
const editableContent = useMemo(() => getEditableMessageContent(msg), [msg])
|
|
75
|
+
const copyableText = useMemo(() => getCopyableMessageText(msg), [msg])
|
|
76
|
+
const actionMessageId = originalMessage.id
|
|
77
|
+
const isPersistedMessage = sessionId != null && sessionId !== '' && !actionMessageId.startsWith('local-')
|
|
78
|
+
const canEdit = isPersistedMessage && !isSessionBusy && isUser && editableContent != null
|
|
79
|
+
const canRecall = isPersistedMessage && !isSessionBusy && isUser
|
|
80
|
+
const canFork = isPersistedMessage && !isSessionBusy && isUser
|
|
81
|
+
const canCopy = copyableText != null
|
|
82
|
+
const shouldShowAssistantActions = !isUser && showAssistantActions
|
|
83
|
+
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
setIsSubmitting(false)
|
|
86
|
+
}, [isEditing, msg.id])
|
|
87
|
+
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
if (isEditing) {
|
|
90
|
+
setIsActionsVisible(false)
|
|
91
|
+
setPendingConfirmAction(null)
|
|
92
|
+
}
|
|
93
|
+
}, [isEditing])
|
|
94
|
+
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
return () => {
|
|
97
|
+
if (showActionsTimerRef.current != null) {
|
|
98
|
+
clearTimeout(showActionsTimerRef.current)
|
|
99
|
+
}
|
|
100
|
+
if (hideActionsTimerRef.current != null) {
|
|
101
|
+
clearTimeout(hideActionsTimerRef.current)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}, [])
|
|
105
|
+
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
if (!isActionsVisible) {
|
|
108
|
+
setPendingConfirmAction(null)
|
|
109
|
+
}
|
|
110
|
+
}, [isActionsVisible])
|
|
111
|
+
|
|
112
|
+
useEffect(() => {
|
|
113
|
+
if (pendingConfirmAction == null) {
|
|
114
|
+
return
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const handlePointerDown = (event: PointerEvent) => {
|
|
118
|
+
const nextTarget = event.target
|
|
119
|
+
if (!(nextTarget instanceof Node)) {
|
|
120
|
+
setPendingConfirmAction(null)
|
|
121
|
+
return
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (!wrapperRef.current?.contains(nextTarget)) {
|
|
125
|
+
setPendingConfirmAction(null)
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
document.addEventListener('pointerdown', handlePointerDown, true)
|
|
130
|
+
return () => {
|
|
131
|
+
document.removeEventListener('pointerdown', handlePointerDown, true)
|
|
132
|
+
}
|
|
133
|
+
}, [pendingConfirmAction])
|
|
18
134
|
|
|
19
135
|
const renderContent = () => {
|
|
20
136
|
if (msg.content == null) return null
|
|
@@ -27,7 +143,9 @@ function MessageItemComponent({
|
|
|
27
143
|
|
|
28
144
|
if (!Array.isArray(msg.content)) return null
|
|
29
145
|
|
|
30
|
-
const hasContent = msg.content.some((c: ChatMessageContent) =>
|
|
146
|
+
const hasContent = msg.content.some((c: ChatMessageContent) => (
|
|
147
|
+
c.type === 'text' || c.type === 'image' || c.type === 'file'
|
|
148
|
+
)) ||
|
|
31
149
|
msg.toolCall != null
|
|
32
150
|
if (!hasContent) return null
|
|
33
151
|
|
|
@@ -46,6 +164,14 @@ function MessageItemComponent({
|
|
|
46
164
|
</a>
|
|
47
165
|
)
|
|
48
166
|
}
|
|
167
|
+
if (item.type === 'file') {
|
|
168
|
+
return (
|
|
169
|
+
<div key={i} className='message-context-file'>
|
|
170
|
+
<span className='material-symbols-rounded message-context-file__icon'>description</span>
|
|
171
|
+
<code className='message-context-file__path'>{item.path}</code>
|
|
172
|
+
</div>
|
|
173
|
+
)
|
|
174
|
+
}
|
|
49
175
|
return null
|
|
50
176
|
})}
|
|
51
177
|
{msg.toolCall != null && (
|
|
@@ -73,29 +199,272 @@ function MessageItemComponent({
|
|
|
73
199
|
const content = renderContent()
|
|
74
200
|
if (content == null) return null
|
|
75
201
|
|
|
202
|
+
const handleStartEdit = () => {
|
|
203
|
+
if (editableContent == null) return
|
|
204
|
+
setPendingConfirmAction(null)
|
|
205
|
+
onStartEditing(actionMessageId)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const submitEditedContent = async (nextContent: string | ChatMessageContent[]) => {
|
|
209
|
+
const normalizedNextContent = normalizeEditableMessageContent(nextContent)
|
|
210
|
+
if (normalizedNextContent == null || isSameEditableMessageContent(normalizedNextContent, editableContent)) {
|
|
211
|
+
onCancelEditing(actionMessageId)
|
|
212
|
+
return true
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
setIsSubmitting(true)
|
|
216
|
+
try {
|
|
217
|
+
const didCreateBranch = await onEditMessage(actionMessageId, normalizedNextContent)
|
|
218
|
+
if (didCreateBranch) {
|
|
219
|
+
onCancelEditing(actionMessageId)
|
|
220
|
+
}
|
|
221
|
+
return didCreateBranch
|
|
222
|
+
} finally {
|
|
223
|
+
setIsSubmitting(false)
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const handleSubmitEditText = async (nextText: string) => {
|
|
228
|
+
return submitEditedContent(nextText)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const handleSubmitEditContent = async (nextContent: ChatMessageContent[]) => {
|
|
232
|
+
return submitEditedContent(nextContent)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const handleCopyRawText = async () => {
|
|
236
|
+
if (copyableText == null) {
|
|
237
|
+
return
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
setPendingConfirmAction(null)
|
|
241
|
+
try {
|
|
242
|
+
await navigator.clipboard.writeText(copyableText)
|
|
243
|
+
void message.success(t('chat.messageActions.copySuccess'))
|
|
244
|
+
} catch {
|
|
245
|
+
void message.error(t('chat.messageActions.copyFailed'))
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const handleRecall = async () => {
|
|
250
|
+
setPendingConfirmAction(null)
|
|
251
|
+
await onRecallMessage(actionMessageId)
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const handleFork = async () => {
|
|
255
|
+
setPendingConfirmAction(null)
|
|
256
|
+
await onForkMessage(actionMessageId)
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const handleConfirmableActionClick = (action: Exclude<PendingConfirmAction, null>) => {
|
|
260
|
+
if (pendingConfirmAction === action) {
|
|
261
|
+
if (action === 'recall') {
|
|
262
|
+
void handleRecall()
|
|
263
|
+
return
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
void handleFork()
|
|
267
|
+
return
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
setPendingConfirmAction(action)
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const handleActionsPointerEnter = () => {
|
|
274
|
+
if (!isUser || isEditing) {
|
|
275
|
+
return
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (hideActionsTimerRef.current != null) {
|
|
279
|
+
clearTimeout(hideActionsTimerRef.current)
|
|
280
|
+
hideActionsTimerRef.current = null
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (isActionsVisible || showActionsTimerRef.current != null) {
|
|
284
|
+
return
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
showActionsTimerRef.current = setTimeout(() => {
|
|
288
|
+
setIsActionsVisible(true)
|
|
289
|
+
showActionsTimerRef.current = null
|
|
290
|
+
}, ACTION_SHOW_DELAY_MS)
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const handleActionsPointerLeave = () => {
|
|
294
|
+
if (!isUser) {
|
|
295
|
+
return
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (showActionsTimerRef.current != null) {
|
|
299
|
+
clearTimeout(showActionsTimerRef.current)
|
|
300
|
+
showActionsTimerRef.current = null
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if (!isActionsVisible || hideActionsTimerRef.current != null) {
|
|
304
|
+
return
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
hideActionsTimerRef.current = setTimeout(() => {
|
|
308
|
+
setIsActionsVisible(false)
|
|
309
|
+
setPendingConfirmAction(null)
|
|
310
|
+
hideActionsTimerRef.current = null
|
|
311
|
+
}, ACTION_HIDE_DELAY_MS)
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
const actionButtons = (
|
|
315
|
+
<>
|
|
316
|
+
{canCopy && (
|
|
317
|
+
<button
|
|
318
|
+
type='button'
|
|
319
|
+
className='msg-action-button msg-action-button--copy'
|
|
320
|
+
title={t('chat.messageActions.copy')}
|
|
321
|
+
aria-label={t('chat.messageActions.copy')}
|
|
322
|
+
onClick={() => {
|
|
323
|
+
void handleCopyRawText()
|
|
324
|
+
}}
|
|
325
|
+
>
|
|
326
|
+
<span className='material-symbols-rounded'>content_copy</span>
|
|
327
|
+
</button>
|
|
328
|
+
)}
|
|
329
|
+
{canEdit && (
|
|
330
|
+
<button
|
|
331
|
+
type='button'
|
|
332
|
+
className='msg-action-button msg-action-button--edit'
|
|
333
|
+
title={t('chat.messageActions.edit')}
|
|
334
|
+
aria-label={t('chat.messageActions.edit')}
|
|
335
|
+
onClick={handleStartEdit}
|
|
336
|
+
>
|
|
337
|
+
<span className='material-symbols-rounded'>edit</span>
|
|
338
|
+
</button>
|
|
339
|
+
)}
|
|
340
|
+
{canRecall && (
|
|
341
|
+
<button
|
|
342
|
+
type='button'
|
|
343
|
+
className={`msg-action-button msg-action-button--recall ${
|
|
344
|
+
pendingConfirmAction === 'recall' ? 'is-confirming' : ''
|
|
345
|
+
}`}
|
|
346
|
+
title={pendingConfirmAction === 'recall'
|
|
347
|
+
? t('chat.messageActions.confirmInline')
|
|
348
|
+
: t('chat.messageActions.recall')}
|
|
349
|
+
aria-label={pendingConfirmAction === 'recall'
|
|
350
|
+
? t('chat.messageActions.confirmInline')
|
|
351
|
+
: t('chat.messageActions.recall')}
|
|
352
|
+
onClick={() => {
|
|
353
|
+
handleConfirmableActionClick('recall')
|
|
354
|
+
}}
|
|
355
|
+
>
|
|
356
|
+
<span className='material-symbols-rounded'>undo</span>
|
|
357
|
+
{pendingConfirmAction === 'recall' && (
|
|
358
|
+
<span className='msg-action-button__label'>{t('chat.messageActions.confirmInline')}</span>
|
|
359
|
+
)}
|
|
360
|
+
</button>
|
|
361
|
+
)}
|
|
362
|
+
{canFork && (
|
|
363
|
+
<button
|
|
364
|
+
type='button'
|
|
365
|
+
className={`msg-action-button msg-action-button--fork ${
|
|
366
|
+
pendingConfirmAction === 'fork' ? 'is-confirming' : ''
|
|
367
|
+
}`}
|
|
368
|
+
title={pendingConfirmAction === 'fork'
|
|
369
|
+
? t('chat.messageActions.confirmInline')
|
|
370
|
+
: t('chat.messageActions.fork')}
|
|
371
|
+
aria-label={pendingConfirmAction === 'fork'
|
|
372
|
+
? t('chat.messageActions.confirmInline')
|
|
373
|
+
: t('chat.messageActions.fork')}
|
|
374
|
+
onClick={() => {
|
|
375
|
+
handleConfirmableActionClick('fork')
|
|
376
|
+
}}
|
|
377
|
+
>
|
|
378
|
+
<span className='material-symbols-rounded'>fork_right</span>
|
|
379
|
+
{pendingConfirmAction === 'fork' && (
|
|
380
|
+
<span className='msg-action-button__label'>{t('chat.messageActions.confirmInline')}</span>
|
|
381
|
+
)}
|
|
382
|
+
</button>
|
|
383
|
+
)}
|
|
384
|
+
</>
|
|
385
|
+
)
|
|
386
|
+
|
|
76
387
|
return (
|
|
77
|
-
<
|
|
78
|
-
|
|
388
|
+
<MessageContextMenu
|
|
389
|
+
anchorId={anchorId}
|
|
390
|
+
canEdit={canEdit}
|
|
391
|
+
canFork={canFork}
|
|
392
|
+
canRecall={canRecall}
|
|
393
|
+
copyableText={copyableText}
|
|
394
|
+
isDebugMode={isDebugMode}
|
|
395
|
+
isEditing={isEditing}
|
|
396
|
+
message={originalMessage}
|
|
397
|
+
sessionId={sessionId}
|
|
398
|
+
onFork={handleFork}
|
|
399
|
+
onRecall={handleRecall}
|
|
400
|
+
onStartEditing={handleStartEdit}
|
|
79
401
|
>
|
|
80
|
-
<div
|
|
81
|
-
|
|
82
|
-
|
|
402
|
+
<div
|
|
403
|
+
ref={wrapperRef}
|
|
404
|
+
id={anchorId}
|
|
405
|
+
className={`${isUser ? 'chat-message-user' : 'chat-message-assistant'} ${isEditing ? 'is-editing' : ''} ${
|
|
406
|
+
!isFirstInGroup ? 'consecutive' : ''
|
|
407
|
+
} ${isActionsVisible ? 'is-actions-visible' : ''} ${isTargeted ? 'is-targeted' : ''}`}
|
|
408
|
+
data-message-id={originalMessage.id}
|
|
409
|
+
onPointerEnter={handleActionsPointerEnter}
|
|
410
|
+
onPointerLeave={handleActionsPointerLeave}
|
|
411
|
+
>
|
|
412
|
+
<div className={`message-body-container ${isEditing ? 'is-editing' : ''}`}>
|
|
413
|
+
{isUser && !isEditing && (
|
|
414
|
+
<div className='message-side-actions'>
|
|
415
|
+
{actionButtons}
|
|
416
|
+
</div>
|
|
417
|
+
)}
|
|
418
|
+
<div className={`bubble ${isEditing ? 'is-editing' : ''}`}>
|
|
419
|
+
{isEditing
|
|
420
|
+
? (
|
|
421
|
+
<div className='message-inline-editor'>
|
|
422
|
+
<Sender
|
|
423
|
+
variant='inline-edit'
|
|
424
|
+
sessionInfo={sessionInfo}
|
|
425
|
+
initialContent={editableContent}
|
|
426
|
+
submitLabel={t('chat.send')}
|
|
427
|
+
submitLoading={isSubmitting}
|
|
428
|
+
autoFocus
|
|
429
|
+
onCancel={() => {
|
|
430
|
+
onCancelEditing(actionMessageId)
|
|
431
|
+
}}
|
|
432
|
+
onSend={handleSubmitEditText}
|
|
433
|
+
onSendContent={handleSubmitEditContent}
|
|
434
|
+
onInterrupt={() => {}}
|
|
435
|
+
/>
|
|
436
|
+
</div>
|
|
437
|
+
)
|
|
438
|
+
: content}
|
|
439
|
+
</div>
|
|
440
|
+
{!isEditing && (
|
|
441
|
+
<MessageFooter msg={originalMessage} isUser={isUser}>
|
|
442
|
+
{shouldShowAssistantActions ? actionButtons : undefined}
|
|
443
|
+
</MessageFooter>
|
|
444
|
+
)}
|
|
83
445
|
</div>
|
|
84
|
-
<MessageFooter msg={msg} isUser={isUser} />
|
|
85
446
|
</div>
|
|
86
|
-
</
|
|
447
|
+
</MessageContextMenu>
|
|
87
448
|
)
|
|
88
449
|
}
|
|
89
450
|
|
|
90
451
|
const areMessageItemPropsEqual = (prev: MessageItemProps, next: MessageItemProps) => {
|
|
91
|
-
return prev.
|
|
452
|
+
return prev.anchorId === next.anchorId &&
|
|
453
|
+
prev.isFirstInGroup === next.isFirstInGroup &&
|
|
454
|
+
prev.isTargeted === next.isTargeted &&
|
|
455
|
+
prev.isSessionBusy === next.isSessionBusy &&
|
|
456
|
+
prev.isEditing === next.isEditing &&
|
|
457
|
+
prev.sessionId === next.sessionId &&
|
|
458
|
+
prev.sessionInfo === next.sessionInfo &&
|
|
459
|
+
prev.showAssistantActions === next.showAssistantActions &&
|
|
92
460
|
prev.msg.id === next.msg.id &&
|
|
93
461
|
prev.msg.role === next.msg.role &&
|
|
94
462
|
prev.msg.createdAt === next.msg.createdAt &&
|
|
95
463
|
prev.msg.model === next.msg.model &&
|
|
96
464
|
prev.msg.content === next.msg.content &&
|
|
97
465
|
prev.msg.toolCall === next.msg.toolCall &&
|
|
98
|
-
prev.msg.usage === next.msg.usage
|
|
466
|
+
prev.msg.usage === next.msg.usage &&
|
|
467
|
+
prev.originalMessage === next.originalMessage
|
|
99
468
|
}
|
|
100
469
|
|
|
101
470
|
export const MessageItem = React.memo(MessageItemComponent, areMessageItemPropsEqual)
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import type { ChatMessage } from '@vibe-forge/core'
|
|
2
|
+
|
|
3
|
+
import { buildSessionUrl } from '#~/utils/chat-links.js'
|
|
4
|
+
import { copyTextWithFeedback } from '#~/utils/copy.js'
|
|
5
|
+
import type { MessageContextMenuEntry } from './MessageContextMenuContent'
|
|
6
|
+
|
|
7
|
+
type PendingMessageMenuAction = 'fork' | 'recall' | null
|
|
8
|
+
|
|
9
|
+
export function buildMessageContextMenuEntries({
|
|
10
|
+
anchorId,
|
|
11
|
+
canEdit,
|
|
12
|
+
canFork,
|
|
13
|
+
canRecall,
|
|
14
|
+
copyableText,
|
|
15
|
+
isDebugMode,
|
|
16
|
+
isEditing,
|
|
17
|
+
messageApi,
|
|
18
|
+
onCloseMenu,
|
|
19
|
+
onConfirmableActionClick,
|
|
20
|
+
onStartEditing,
|
|
21
|
+
sessionId,
|
|
22
|
+
sourceMessage,
|
|
23
|
+
t
|
|
24
|
+
}: {
|
|
25
|
+
anchorId: string
|
|
26
|
+
canEdit: boolean
|
|
27
|
+
canFork: boolean
|
|
28
|
+
canRecall: boolean
|
|
29
|
+
copyableText?: string
|
|
30
|
+
isDebugMode: boolean
|
|
31
|
+
isEditing: boolean
|
|
32
|
+
messageApi: {
|
|
33
|
+
error: (content: string) => void
|
|
34
|
+
success: (content: string) => void
|
|
35
|
+
}
|
|
36
|
+
onCloseMenu: () => void
|
|
37
|
+
onConfirmableActionClick: (action: Exclude<PendingMessageMenuAction, null>) => void
|
|
38
|
+
onStartEditing: () => void
|
|
39
|
+
sessionId?: string
|
|
40
|
+
sourceMessage: ChatMessage
|
|
41
|
+
t: (key: string, options?: Record<string, unknown>) => string
|
|
42
|
+
}): MessageContextMenuEntry[] {
|
|
43
|
+
const entries: MessageContextMenuEntry[] = []
|
|
44
|
+
|
|
45
|
+
const closeWithCopy = (text: string, successMessage: string) => {
|
|
46
|
+
onCloseMenu()
|
|
47
|
+
void copyTextWithFeedback({
|
|
48
|
+
text,
|
|
49
|
+
messageApi,
|
|
50
|
+
successMessage,
|
|
51
|
+
failureMessage: t('chat.messageActions.copyFailed')
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (copyableText != null) {
|
|
56
|
+
entries.push({
|
|
57
|
+
key: 'copy',
|
|
58
|
+
label: t('chat.messageActions.copy'),
|
|
59
|
+
icon: 'content_copy',
|
|
60
|
+
onClick: () => {
|
|
61
|
+
closeWithCopy(copyableText, t('chat.messageActions.copySuccess'))
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (canEdit && !isEditing) {
|
|
67
|
+
entries.push({
|
|
68
|
+
key: 'edit',
|
|
69
|
+
label: t('chat.messageActions.edit'),
|
|
70
|
+
icon: 'edit',
|
|
71
|
+
onClick: () => {
|
|
72
|
+
onCloseMenu()
|
|
73
|
+
onStartEditing()
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (canRecall) {
|
|
79
|
+
entries.push({
|
|
80
|
+
key: 'recall',
|
|
81
|
+
label: t('chat.messageActions.recall'),
|
|
82
|
+
confirmLabel: t('common.confirmAction', {
|
|
83
|
+
action: t('chat.messageActions.recall')
|
|
84
|
+
}),
|
|
85
|
+
icon: 'undo',
|
|
86
|
+
danger: true,
|
|
87
|
+
onClick: () => {
|
|
88
|
+
onConfirmableActionClick('recall')
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (canFork) {
|
|
94
|
+
entries.push({
|
|
95
|
+
key: 'fork',
|
|
96
|
+
label: t('chat.messageActions.fork'),
|
|
97
|
+
confirmLabel: t('common.confirmAction', {
|
|
98
|
+
action: t('chat.messageActions.fork')
|
|
99
|
+
}),
|
|
100
|
+
icon: 'fork_right',
|
|
101
|
+
onClick: () => {
|
|
102
|
+
onConfirmableActionClick('fork')
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (entries.length > 0) {
|
|
108
|
+
entries.push({
|
|
109
|
+
key: 'divider-primary',
|
|
110
|
+
type: 'divider',
|
|
111
|
+
label: '',
|
|
112
|
+
icon: '',
|
|
113
|
+
onClick: () => undefined
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (sessionId != null && sessionId !== '') {
|
|
118
|
+
entries.push({
|
|
119
|
+
key: 'copy-link',
|
|
120
|
+
label: t('chat.messageActions.copyLink'),
|
|
121
|
+
icon: 'link',
|
|
122
|
+
onClick: () => {
|
|
123
|
+
closeWithCopy(buildSessionUrl(sessionId, { anchorId }), t('chat.messageActions.copyLinkSuccess'))
|
|
124
|
+
}
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
entries.push({
|
|
129
|
+
key: 'copy-id',
|
|
130
|
+
label: t('chat.messageActions.copyId'),
|
|
131
|
+
icon: 'fingerprint',
|
|
132
|
+
onClick: () => {
|
|
133
|
+
closeWithCopy(sourceMessage.id, t('chat.messageActions.copyIdSuccess'))
|
|
134
|
+
}
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
if (isDebugMode) {
|
|
138
|
+
entries.push(
|
|
139
|
+
{
|
|
140
|
+
key: 'divider-debug',
|
|
141
|
+
type: 'divider',
|
|
142
|
+
label: '',
|
|
143
|
+
icon: '',
|
|
144
|
+
onClick: () => undefined
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
key: 'copy-json',
|
|
148
|
+
label: t('chat.messageActions.copyJson'),
|
|
149
|
+
icon: 'data_object',
|
|
150
|
+
onClick: () => {
|
|
151
|
+
closeWithCopy(JSON.stringify(sourceMessage, null, 2), t('chat.messageActions.copyJsonSuccess'))
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
key: 'copy-timestamp',
|
|
156
|
+
label: t('chat.messageActions.copyTimestamp'),
|
|
157
|
+
icon: 'schedule',
|
|
158
|
+
onClick: () => {
|
|
159
|
+
closeWithCopy(String(sourceMessage.createdAt), t('chat.messageActions.copyTimestampSuccess'))
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return entries
|
|
166
|
+
}
|