@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
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { SessionInfo } from '@vibe-forge/types'
|
|
2
|
+
|
|
3
|
+
export type SessionAssetDiagnostic = NonNullable<Extract<SessionInfo, { type: 'init' }>['assetDiagnostics']>[number]
|
|
4
|
+
export type SessionSelectionWarning = NonNullable<Extract<SessionInfo, { type: 'init' }>['selectionWarnings']>[number]
|
|
5
|
+
|
|
6
|
+
export interface SessionToolGroup {
|
|
7
|
+
key: 'chrome-devtools' | 'system'
|
|
8
|
+
labelKey: 'chat.toolGroupChromeDevtools' | 'chat.toolGroupSystem'
|
|
9
|
+
icon: string
|
|
10
|
+
tools: string[]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const formatToolLabel = (tool: string) => {
|
|
14
|
+
const parts = tool.split('__')
|
|
15
|
+
return parts[parts.length - 1] || tool
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const getSessionToolGroups = (sessionInfo: SessionInfo | null): SessionToolGroup[] => {
|
|
19
|
+
if (sessionInfo == null || sessionInfo.type !== 'init') {
|
|
20
|
+
return []
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return [
|
|
24
|
+
{
|
|
25
|
+
key: 'chrome-devtools',
|
|
26
|
+
labelKey: 'chat.toolGroupChromeDevtools',
|
|
27
|
+
icon: 'web_traffic',
|
|
28
|
+
tools: sessionInfo.tools.filter((tool: string) => tool.startsWith('mcp__ChromeDevtools__'))
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
key: 'system',
|
|
32
|
+
labelKey: 'chat.toolGroupSystem',
|
|
33
|
+
icon: 'memory',
|
|
34
|
+
tools: sessionInfo.tools.filter((tool: string) => !tool.startsWith('mcp__ChromeDevtools__'))
|
|
35
|
+
}
|
|
36
|
+
].filter((group): group is SessionToolGroup => group.tools.length > 0)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const getSessionAssetWarnings = (sessionInfo: SessionInfo | null): SessionAssetDiagnostic[] => {
|
|
40
|
+
if (sessionInfo == null || sessionInfo.type !== 'init') {
|
|
41
|
+
return []
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return (sessionInfo.assetDiagnostics ?? []).filter((diagnostic: SessionAssetDiagnostic) =>
|
|
45
|
+
diagnostic.status === 'skipped'
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const getSessionSelectionWarnings = (sessionInfo: SessionInfo | null): SessionSelectionWarning[] => {
|
|
50
|
+
if (sessionInfo == null || sessionInfo.type !== 'init') {
|
|
51
|
+
return []
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return sessionInfo.selectionWarnings ?? []
|
|
55
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
import { FitAddon } from '@xterm/addon-fit'
|
|
4
|
+
import { Terminal } from '@xterm/xterm'
|
|
5
|
+
|
|
6
|
+
const DEFAULT_COLS = 120
|
|
7
|
+
const DEFAULT_ROWS = 32
|
|
8
|
+
|
|
9
|
+
const readCssVar = (styles: CSSStyleDeclaration, name: string, fallback: string) => {
|
|
10
|
+
const value = styles.getPropertyValue(name).trim()
|
|
11
|
+
return value === '' ? fallback : value
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const buildTerminalTheme = () => {
|
|
15
|
+
const styles = window.getComputedStyle(document.documentElement)
|
|
16
|
+
const isDark = document.documentElement.classList.contains('dark')
|
|
17
|
+
const background = readCssVar(styles, '--bg-color', isDark ? '#141414' : '#ffffff')
|
|
18
|
+
const foreground = readCssVar(styles, '--text-color', isDark ? '#ffffff' : '#000000')
|
|
19
|
+
const subForeground = readCssVar(styles, '--sub-text-color', isDark ? '#8c8c8c' : '#1b1b1b')
|
|
20
|
+
const primaryColor = readCssVar(styles, '--primary-color', isDark ? '#3b82f6' : '#2563eb')
|
|
21
|
+
const primarySoftBg = readCssVar(styles, '--primary-soft-bg', isDark ? '#111b26' : '#eff6ff')
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
background,
|
|
25
|
+
foreground,
|
|
26
|
+
cursor: primaryColor,
|
|
27
|
+
cursorAccent: background,
|
|
28
|
+
selectionBackground: primarySoftBg,
|
|
29
|
+
black: isDark ? '#0f172a' : '#111827',
|
|
30
|
+
red: isDark ? '#ef4444' : '#dc2626',
|
|
31
|
+
green: isDark ? '#10b981' : '#047857',
|
|
32
|
+
yellow: isDark ? '#f59e0b' : '#b45309',
|
|
33
|
+
blue: isDark ? '#60a5fa' : '#2563eb',
|
|
34
|
+
magenta: isDark ? '#f472b6' : '#c026d3',
|
|
35
|
+
cyan: isDark ? '#22d3ee' : '#0f766e',
|
|
36
|
+
white: isDark ? '#e2e8f0' : subForeground,
|
|
37
|
+
brightBlack: isDark ? '#475569' : '#4b5563',
|
|
38
|
+
brightRed: isDark ? '#f87171' : '#ef4444',
|
|
39
|
+
brightGreen: isDark ? '#34d399' : '#10b981',
|
|
40
|
+
brightYellow: isDark ? '#fbbf24' : '#f59e0b',
|
|
41
|
+
brightBlue: isDark ? '#93c5fd' : '#3b82f6',
|
|
42
|
+
brightMagenta: isDark ? '#f9a8d4' : '#d946ef',
|
|
43
|
+
brightCyan: isDark ? '#67e8f9' : '#14b8a6',
|
|
44
|
+
brightWhite: foreground
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function useTerminalInstance({
|
|
49
|
+
onInput,
|
|
50
|
+
onResize
|
|
51
|
+
}: {
|
|
52
|
+
onInput: (data: string) => void
|
|
53
|
+
onResize: (cols: number, rows: number) => void
|
|
54
|
+
}) {
|
|
55
|
+
const containerRef = useRef<HTMLDivElement | null>(null)
|
|
56
|
+
const terminalRef = useRef<Terminal | null>(null)
|
|
57
|
+
const fitAddonRef = useRef<FitAddon | null>(null)
|
|
58
|
+
const onInputRef = useRef(onInput)
|
|
59
|
+
const onResizeRef = useRef(onResize)
|
|
60
|
+
const [terminalMounted, setTerminalMounted] = useState(false)
|
|
61
|
+
const [lastMeasuredSize, setLastMeasuredSize] = useState({
|
|
62
|
+
cols: DEFAULT_COLS,
|
|
63
|
+
rows: DEFAULT_ROWS
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
onInputRef.current = onInput
|
|
67
|
+
onResizeRef.current = onResize
|
|
68
|
+
|
|
69
|
+
const fitTerminal = useCallback(() => {
|
|
70
|
+
const terminal = terminalRef.current
|
|
71
|
+
const fitAddon = fitAddonRef.current
|
|
72
|
+
if (terminal == null || fitAddon == null) {
|
|
73
|
+
return
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
fitAddon.fit()
|
|
77
|
+
if (terminal.cols <= 0 || terminal.rows <= 0) {
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
setLastMeasuredSize({
|
|
82
|
+
cols: terminal.cols,
|
|
83
|
+
rows: terminal.rows
|
|
84
|
+
})
|
|
85
|
+
onResizeRef.current(terminal.cols, terminal.rows)
|
|
86
|
+
}, [])
|
|
87
|
+
|
|
88
|
+
const focusTerminal = useCallback(() => {
|
|
89
|
+
terminalRef.current?.focus()
|
|
90
|
+
}, [])
|
|
91
|
+
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
const container = containerRef.current
|
|
94
|
+
if (container == null) {
|
|
95
|
+
return
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const terminal = new Terminal({
|
|
99
|
+
cursorBlink: true,
|
|
100
|
+
fontSize: 13,
|
|
101
|
+
fontFamily: '"SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace',
|
|
102
|
+
scrollback: 5000,
|
|
103
|
+
theme: buildTerminalTheme()
|
|
104
|
+
})
|
|
105
|
+
const fitAddon = new FitAddon()
|
|
106
|
+
|
|
107
|
+
terminal.loadAddon(fitAddon)
|
|
108
|
+
terminal.open(container)
|
|
109
|
+
terminal.focus()
|
|
110
|
+
|
|
111
|
+
terminalRef.current = terminal
|
|
112
|
+
fitAddonRef.current = fitAddon
|
|
113
|
+
setTerminalMounted(true)
|
|
114
|
+
fitTerminal()
|
|
115
|
+
|
|
116
|
+
const dataDisposable = terminal.onData((data) => {
|
|
117
|
+
onInputRef.current(data)
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
121
|
+
fitTerminal()
|
|
122
|
+
})
|
|
123
|
+
resizeObserver.observe(container)
|
|
124
|
+
|
|
125
|
+
const themeObserver = new MutationObserver(() => {
|
|
126
|
+
terminal.options.theme = buildTerminalTheme()
|
|
127
|
+
})
|
|
128
|
+
themeObserver.observe(document.documentElement, {
|
|
129
|
+
attributes: true,
|
|
130
|
+
attributeFilter: ['class', 'style']
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
return () => {
|
|
134
|
+
themeObserver.disconnect()
|
|
135
|
+
resizeObserver.disconnect()
|
|
136
|
+
dataDisposable.dispose()
|
|
137
|
+
fitAddon.dispose()
|
|
138
|
+
terminal.dispose()
|
|
139
|
+
fitAddonRef.current = null
|
|
140
|
+
terminalRef.current = null
|
|
141
|
+
}
|
|
142
|
+
}, [fitTerminal])
|
|
143
|
+
|
|
144
|
+
return {
|
|
145
|
+
containerRef,
|
|
146
|
+
fitTerminal,
|
|
147
|
+
focusTerminal,
|
|
148
|
+
lastMeasuredSize,
|
|
149
|
+
terminalMounted,
|
|
150
|
+
terminalRef
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react'
|
|
2
|
+
import { useTranslation } from 'react-i18next'
|
|
3
|
+
|
|
4
|
+
import type { TerminalSessionCommand, TerminalSessionEvent } from '@vibe-forge/types'
|
|
5
|
+
|
|
6
|
+
import { createSocket } from '#~/ws.js'
|
|
7
|
+
|
|
8
|
+
const isSocketOpen = (socket: WebSocket | null): socket is WebSocket => {
|
|
9
|
+
return socket != null && socket.readyState === WebSocket.OPEN
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function useTerminalSession({
|
|
13
|
+
sessionId,
|
|
14
|
+
active,
|
|
15
|
+
initialCols,
|
|
16
|
+
initialRows,
|
|
17
|
+
onReady,
|
|
18
|
+
onOutput,
|
|
19
|
+
onExit
|
|
20
|
+
}: {
|
|
21
|
+
sessionId: string
|
|
22
|
+
active: boolean
|
|
23
|
+
initialCols: number
|
|
24
|
+
initialRows: number
|
|
25
|
+
onReady: (event: Extract<TerminalSessionEvent, { type: 'terminal_ready' }>) => void
|
|
26
|
+
onOutput: (data: string) => void
|
|
27
|
+
onExit?: (event: Extract<TerminalSessionEvent, { type: 'terminal_exit' }>) => void
|
|
28
|
+
}) {
|
|
29
|
+
const { t } = useTranslation()
|
|
30
|
+
const socketRef = useRef<WebSocket | null>(null)
|
|
31
|
+
const expectedCloseRef = useRef(false)
|
|
32
|
+
const fatalErrorRef = useRef(false)
|
|
33
|
+
const reconnectTimerRef = useRef<number | null>(null)
|
|
34
|
+
const restartRequestedRef = useRef(false)
|
|
35
|
+
const latestSizeRef = useRef({ cols: initialCols, rows: initialRows })
|
|
36
|
+
const pendingResizeRef = useRef<{ cols: number; rows: number } | null>(null)
|
|
37
|
+
const onReadyRef = useRef(onReady)
|
|
38
|
+
const onOutputRef = useRef(onOutput)
|
|
39
|
+
const onExitRef = useRef(onExit)
|
|
40
|
+
const [connectVersion, setConnectVersion] = useState(0)
|
|
41
|
+
const [errorMessage, setErrorMessage] = useState<string | null>(null)
|
|
42
|
+
const [lastExit, setLastExit] = useState<{ exitCode: number | null; signal: number | null } | null>(null)
|
|
43
|
+
|
|
44
|
+
onReadyRef.current = onReady
|
|
45
|
+
onOutputRef.current = onOutput
|
|
46
|
+
onExitRef.current = onExit
|
|
47
|
+
latestSizeRef.current = { cols: initialCols, rows: initialRows }
|
|
48
|
+
|
|
49
|
+
const sendCommand = useCallback((command: TerminalSessionCommand) => {
|
|
50
|
+
const socket = socketRef.current
|
|
51
|
+
if (!isSocketOpen(socket)) {
|
|
52
|
+
return false
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
socket.send(JSON.stringify(command))
|
|
56
|
+
return true
|
|
57
|
+
}, [])
|
|
58
|
+
|
|
59
|
+
const scheduleReconnect = useCallback(() => {
|
|
60
|
+
if (reconnectTimerRef.current != null) {
|
|
61
|
+
window.clearTimeout(reconnectTimerRef.current)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
reconnectTimerRef.current = window.setTimeout(() => {
|
|
65
|
+
reconnectTimerRef.current = null
|
|
66
|
+
setConnectVersion(current => current + 1)
|
|
67
|
+
}, 800)
|
|
68
|
+
}, [])
|
|
69
|
+
|
|
70
|
+
const sendInput = useCallback((data: string) => {
|
|
71
|
+
return sendCommand({
|
|
72
|
+
type: 'terminal_input',
|
|
73
|
+
data
|
|
74
|
+
})
|
|
75
|
+
}, [sendCommand])
|
|
76
|
+
|
|
77
|
+
const sendResizeCommand = useCallback((cols: number, rows: number) => {
|
|
78
|
+
return sendCommand({
|
|
79
|
+
type: 'terminal_resize',
|
|
80
|
+
cols,
|
|
81
|
+
rows
|
|
82
|
+
})
|
|
83
|
+
}, [sendCommand])
|
|
84
|
+
|
|
85
|
+
const flushPendingResize = useCallback(() => {
|
|
86
|
+
const pendingResize = pendingResizeRef.current
|
|
87
|
+
if (pendingResize == null) {
|
|
88
|
+
return false
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const sent = sendResizeCommand(pendingResize.cols, pendingResize.rows)
|
|
92
|
+
if (sent) {
|
|
93
|
+
pendingResizeRef.current = null
|
|
94
|
+
}
|
|
95
|
+
return sent
|
|
96
|
+
}, [sendResizeCommand])
|
|
97
|
+
|
|
98
|
+
const resizeTerminal = useCallback((cols: number, rows: number) => {
|
|
99
|
+
latestSizeRef.current = { cols, rows }
|
|
100
|
+
pendingResizeRef.current = { cols, rows }
|
|
101
|
+
return flushPendingResize()
|
|
102
|
+
}, [flushPendingResize])
|
|
103
|
+
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
if (!active) {
|
|
106
|
+
return
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
expectedCloseRef.current = false
|
|
110
|
+
fatalErrorRef.current = false
|
|
111
|
+
restartRequestedRef.current = false
|
|
112
|
+
setErrorMessage(null)
|
|
113
|
+
pendingResizeRef.current = latestSizeRef.current
|
|
114
|
+
|
|
115
|
+
const connectSize = latestSizeRef.current
|
|
116
|
+
|
|
117
|
+
const socket = createSocket<TerminalSessionEvent>({
|
|
118
|
+
onOpen: () => {
|
|
119
|
+
flushPendingResize()
|
|
120
|
+
},
|
|
121
|
+
onMessage: (event) => {
|
|
122
|
+
switch (event.type) {
|
|
123
|
+
case 'terminal_ready':
|
|
124
|
+
setErrorMessage(null)
|
|
125
|
+
if (event.info.status === 'exited') {
|
|
126
|
+
if (!restartRequestedRef.current) {
|
|
127
|
+
restartRequestedRef.current = true
|
|
128
|
+
const restartSize = latestSizeRef.current
|
|
129
|
+
socket.send(JSON.stringify(
|
|
130
|
+
{
|
|
131
|
+
type: 'terminal_restart',
|
|
132
|
+
cols: restartSize.cols,
|
|
133
|
+
rows: restartSize.rows
|
|
134
|
+
} satisfies TerminalSessionCommand
|
|
135
|
+
))
|
|
136
|
+
}
|
|
137
|
+
return
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
restartRequestedRef.current = false
|
|
141
|
+
setLastExit(null)
|
|
142
|
+
onReadyRef.current(event)
|
|
143
|
+
return
|
|
144
|
+
case 'terminal_output':
|
|
145
|
+
onOutputRef.current(event.data)
|
|
146
|
+
return
|
|
147
|
+
case 'terminal_exit':
|
|
148
|
+
setLastExit({
|
|
149
|
+
exitCode: event.exitCode,
|
|
150
|
+
signal: event.signal
|
|
151
|
+
})
|
|
152
|
+
onExitRef.current?.(event)
|
|
153
|
+
return
|
|
154
|
+
case 'terminal_error':
|
|
155
|
+
fatalErrorRef.current = event.fatal === true
|
|
156
|
+
setErrorMessage(event.message)
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
onError: () => {
|
|
160
|
+
setErrorMessage(t('chat.terminal.connectionError'))
|
|
161
|
+
},
|
|
162
|
+
onClose: () => {
|
|
163
|
+
socketRef.current = null
|
|
164
|
+
if (expectedCloseRef.current || fatalErrorRef.current) {
|
|
165
|
+
return
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
scheduleReconnect()
|
|
169
|
+
}
|
|
170
|
+
}, {
|
|
171
|
+
channel: 'terminal',
|
|
172
|
+
sessionId,
|
|
173
|
+
cols: String(connectSize.cols),
|
|
174
|
+
rows: String(connectSize.rows)
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
socketRef.current = socket
|
|
178
|
+
|
|
179
|
+
return () => {
|
|
180
|
+
expectedCloseRef.current = true
|
|
181
|
+
if (reconnectTimerRef.current != null) {
|
|
182
|
+
window.clearTimeout(reconnectTimerRef.current)
|
|
183
|
+
reconnectTimerRef.current = null
|
|
184
|
+
}
|
|
185
|
+
socket.close()
|
|
186
|
+
socketRef.current = null
|
|
187
|
+
}
|
|
188
|
+
}, [active, connectVersion, flushPendingResize, scheduleReconnect, sessionId, t])
|
|
189
|
+
|
|
190
|
+
return {
|
|
191
|
+
errorMessage,
|
|
192
|
+
lastExit,
|
|
193
|
+
resizeTerminal,
|
|
194
|
+
sendInput
|
|
195
|
+
}
|
|
196
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
.chat-terminal-view {
|
|
2
|
+
position: relative;
|
|
3
|
+
|
|
4
|
+
&__error {
|
|
5
|
+
position: absolute;
|
|
6
|
+
top: 36px;
|
|
7
|
+
right: 16px;
|
|
8
|
+
z-index: 3;
|
|
9
|
+
padding: 8px 10px;
|
|
10
|
+
border-radius: 10px;
|
|
11
|
+
border: 1px solid
|
|
12
|
+
color-mix(in srgb, var(--danger-color) 24%, var(--border-color));
|
|
13
|
+
background-color: color-mix(
|
|
14
|
+
in srgb,
|
|
15
|
+
var(--bg-color) 86%,
|
|
16
|
+
var(--danger-color) 14%
|
|
17
|
+
);
|
|
18
|
+
color: var(--danger-color);
|
|
19
|
+
font-size: 12px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&__surface {
|
|
23
|
+
display: flex;
|
|
24
|
+
position: relative;
|
|
25
|
+
flex: 1;
|
|
26
|
+
min-height: 0;
|
|
27
|
+
overflow: hidden;
|
|
28
|
+
background:
|
|
29
|
+
radial-gradient(
|
|
30
|
+
circle at top,
|
|
31
|
+
color-mix(in srgb, var(--primary-color) 12%, transparent),
|
|
32
|
+
transparent 52%
|
|
33
|
+
),
|
|
34
|
+
linear-gradient(
|
|
35
|
+
180deg,
|
|
36
|
+
color-mix(in srgb, var(--sub-bg-color) 78%, var(--bg-color)),
|
|
37
|
+
var(--bg-color)
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&__terminal {
|
|
42
|
+
flex: 1;
|
|
43
|
+
min-width: 0;
|
|
44
|
+
min-height: 0;
|
|
45
|
+
overflow: hidden;
|
|
46
|
+
cursor: text;
|
|
47
|
+
|
|
48
|
+
.xterm {
|
|
49
|
+
height: 100%;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.xterm-viewport {
|
|
53
|
+
background-color: var(--bg-color);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&__footer {
|
|
58
|
+
padding: 0;
|
|
59
|
+
font-size: 12px;
|
|
60
|
+
color: var(--sub-text-color);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import '@xterm/xterm/css/xterm.css'
|
|
2
|
+
import './ChatTerminalView.scss'
|
|
3
|
+
|
|
4
|
+
import React, { useCallback, useState } from 'react'
|
|
5
|
+
import { useTranslation } from 'react-i18next'
|
|
6
|
+
|
|
7
|
+
import { DockPanel } from '#~/components/dock-panel/DockPanel'
|
|
8
|
+
import { useTerminalInstance } from './@hooks/use-terminal-instance'
|
|
9
|
+
import { useTerminalSession } from './@hooks/use-terminal-session'
|
|
10
|
+
|
|
11
|
+
const TERMINAL_HEIGHT_STORAGE_KEY = 'chatTerminalHeight'
|
|
12
|
+
const formatShellLabel = (shell: string | undefined) => shell?.split('/').filter(Boolean).at(-1) ?? 'shell'
|
|
13
|
+
|
|
14
|
+
export function ChatTerminalView({
|
|
15
|
+
isOpen,
|
|
16
|
+
onClose,
|
|
17
|
+
sessionId
|
|
18
|
+
}: {
|
|
19
|
+
isOpen: boolean
|
|
20
|
+
onClose: () => void
|
|
21
|
+
sessionId: string
|
|
22
|
+
}) {
|
|
23
|
+
const { t } = useTranslation()
|
|
24
|
+
const inputHandlerRef = React.useRef<(data: string) => void>(() => undefined)
|
|
25
|
+
const resizeHandlerRef = React.useRef<(cols: number, rows: number) => void>(() => undefined)
|
|
26
|
+
const [shellLabel, setShellLabel] = useState('zsh')
|
|
27
|
+
const {
|
|
28
|
+
containerRef,
|
|
29
|
+
fitTerminal,
|
|
30
|
+
focusTerminal,
|
|
31
|
+
lastMeasuredSize,
|
|
32
|
+
terminalMounted,
|
|
33
|
+
terminalRef
|
|
34
|
+
} = useTerminalInstance({
|
|
35
|
+
onInput: (data: string) => inputHandlerRef.current(data),
|
|
36
|
+
onResize: (cols: number, rows: number) => resizeHandlerRef.current(cols, rows)
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
const {
|
|
40
|
+
errorMessage,
|
|
41
|
+
lastExit,
|
|
42
|
+
resizeTerminal,
|
|
43
|
+
sendInput
|
|
44
|
+
} = useTerminalSession({
|
|
45
|
+
sessionId,
|
|
46
|
+
active: terminalMounted,
|
|
47
|
+
initialCols: lastMeasuredSize.cols,
|
|
48
|
+
initialRows: lastMeasuredSize.rows,
|
|
49
|
+
onReady: useCallback((event) => {
|
|
50
|
+
const terminal = terminalRef.current
|
|
51
|
+
if (terminal == null) {
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
terminal.reset()
|
|
56
|
+
setShellLabel(formatShellLabel(event.info.shell))
|
|
57
|
+
if (event.scrollback != null && event.scrollback !== '') {
|
|
58
|
+
terminal.write(event.scrollback)
|
|
59
|
+
}
|
|
60
|
+
fitTerminal()
|
|
61
|
+
}, [fitTerminal, terminalRef]),
|
|
62
|
+
onOutput: useCallback((data) => {
|
|
63
|
+
terminalRef.current?.write(data)
|
|
64
|
+
}, [terminalRef])
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
inputHandlerRef.current = (data: string) => {
|
|
68
|
+
void sendInput(data)
|
|
69
|
+
}
|
|
70
|
+
resizeHandlerRef.current = (cols: number, rows: number) => {
|
|
71
|
+
void resizeTerminal(cols, rows)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const exitSummary = lastExit == null
|
|
75
|
+
? null
|
|
76
|
+
: t('chat.terminal.exitSummary', {
|
|
77
|
+
code: lastExit.exitCode ?? 'null',
|
|
78
|
+
signal: lastExit.signal ?? 'null'
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<DockPanel
|
|
83
|
+
className='chat-terminal-view'
|
|
84
|
+
isOpen={isOpen}
|
|
85
|
+
title={t('chat.viewTerminal')}
|
|
86
|
+
meta={shellLabel}
|
|
87
|
+
closeLabel={t('common.close')}
|
|
88
|
+
resizeLabel={t('chat.terminal.resizePanel')}
|
|
89
|
+
storageKey={TERMINAL_HEIGHT_STORAGE_KEY}
|
|
90
|
+
onClose={onClose}
|
|
91
|
+
footer={exitSummary != null
|
|
92
|
+
? (
|
|
93
|
+
<div className='chat-terminal-view__footer'>
|
|
94
|
+
{exitSummary}
|
|
95
|
+
</div>
|
|
96
|
+
)
|
|
97
|
+
: undefined}
|
|
98
|
+
>
|
|
99
|
+
{errorMessage != null && errorMessage !== '' && (
|
|
100
|
+
<div className='chat-terminal-view__error'>
|
|
101
|
+
{errorMessage}
|
|
102
|
+
</div>
|
|
103
|
+
)}
|
|
104
|
+
|
|
105
|
+
<div className='chat-terminal-view__surface'>
|
|
106
|
+
<div
|
|
107
|
+
ref={containerRef}
|
|
108
|
+
className='chat-terminal-view__terminal'
|
|
109
|
+
onClick={focusTerminal}
|
|
110
|
+
/>
|
|
111
|
+
</div>
|
|
112
|
+
</DockPanel>
|
|
113
|
+
)
|
|
114
|
+
}
|