@openhands/agent-canvas 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/README.windows.md +2 -2
- package/build/assets/{Trans-B7lYw4uD.js → Trans-Bwpzk1wT.js} +1 -1
- package/build/assets/{acp-providers-WUD4tfSq.js → acp-providers-C921BlYB.js} +1 -1
- package/build/assets/active-backend-context-BiwzkzDy.js +2 -0
- package/build/assets/agent-context-settings-DXNT_dcw.js +1 -0
- package/build/assets/agent-profiles-settings-BymJf3EP.js +1 -0
- package/build/assets/agent-server-conversation-service.api-CYSWw-2g.js +41 -0
- package/build/assets/agent-settings-BjgQQe-_.js +1 -0
- package/build/assets/{agent-settings-BGTyoT6X.js → agent-settings-WzqXk6B4.js} +2 -2
- package/build/assets/{alert-banner-eRyIwDyU.js → alert-banner-DR8EVyZM.js} +1 -1
- package/build/assets/api-error-message-e16L1kwH.js +1 -0
- package/build/assets/{api-key-entry-screen-JOx3SH1-.js → api-key-entry-screen-DI0I04O3.js} +1 -1
- package/build/assets/{app-settings-D53QZy5p.js → app-settings-DGistSFV.js} +1 -1
- package/build/assets/automation-C_eCrGyP.js +1 -0
- package/build/assets/automation-detail-DY6x2FW1.js +2 -0
- package/build/assets/automation-export-C09f-Lua.js +2 -0
- package/build/assets/automation-setup-route-CqKp0717.js +1 -0
- package/build/assets/automations-list-CqWJ7qXW.js +1 -0
- package/build/assets/{back-nav-button-C02hGa8t.js → back-nav-button-D4ngzpSh.js} +1 -1
- package/build/assets/backend-form-modal-B8D5hBzK.js +1 -0
- package/build/assets/{backend-synced-settings-badge-CQ9xtNWm.js → backend-synced-settings-badge-BnzI8Ysj.js} +1 -1
- package/build/assets/{badge-CzXbf7tR.js → badge-1Mf1iPcX.js} +1 -1
- package/build/assets/{base-modal-DkVyzFMt.js → base-modal-BBuy0WQQ.js} +1 -1
- package/build/assets/{brand-button-BUlDL-mz.js → brand-button-DGN6Y9o6.js} +1 -1
- package/build/assets/browser-D_ekTlTS.js +6 -0
- package/build/assets/{browser-tab-BijpUbdt.js → browser-tab-D4a4Ou_w.js} +1 -1
- package/build/assets/{chat-send-button-BKsVjhtA.js → chat-send-button-CgbcjD97.js} +1 -1
- package/build/assets/check-CPLXgluF.js +1 -0
- package/build/assets/chevron-down-CP4QHvyc.js +1 -0
- package/build/assets/circle-check-Dpy2_xSI.js +1 -0
- package/build/assets/{circle-plus-check-toggle-DdjUiOo1.js → circle-plus-check-toggle-yTAS-nX3.js} +1 -1
- package/build/assets/cloud-funnel-analytics-CEOl5Gxr.js +1 -0
- package/build/assets/{combobox-caret-Dl9UtvD6.js → combobox-caret-Bd2yySnF.js} +1 -1
- package/build/assets/command-menu-Bj6X4ckE.js +1 -0
- package/build/assets/condenser-settings-EAXQNR2E.js +1 -0
- package/build/assets/{confirmation-modal-CRBJSllP.js → confirmation-modal-NCUPr2-O.js} +1 -1
- package/build/assets/{context-menu-list-item-FGaafXGh.js → context-menu-list-item-CrCrYuPF.js} +1 -1
- package/build/assets/conversation-BzyIcSwr.js +1 -0
- package/build/assets/conversation-CUJ0Vo8g.js +90 -0
- package/build/assets/conversation-panel-BzyIcSwr.js +1 -0
- package/build/assets/conversation-state-store-F62HvuI1.js +1 -0
- package/build/assets/{conversation-tab-empty-state-CDjvNgpG.js → conversation-tab-empty-state-BCZ7rUMH.js} +1 -1
- package/build/assets/{copy-Drwu97Gx.js → copy-DCmZtz6n.js} +1 -1
- package/build/assets/{copy-to-clipboard-button-NbN1clVr.js → copy-to-clipboard-button-D_Lp6-Fl.js} +1 -1
- package/build/assets/{device-verify-CDm_WrVu.js → device-verify-DLmolX8Q.js} +1 -1
- package/build/assets/{dropdown-classes-CqA2BTCL.js → dropdown-classes-BB8rzqXL.js} +1 -1
- package/build/assets/{entry.client-BO2KQj0y.js → entry.client-BbIYOsIg.js} +2 -2
- package/build/assets/{enum-filter-dropdown-DSqPZnsD.js → enum-filter-dropdown-C08-srev.js} +1 -1
- package/build/assets/{environment-switch-overlay-mGl2pqqx.js → environment-switch-overlay-BepBBX66.js} +1 -1
- package/build/assets/{extensions-hub-Br3Lgynp.js → extensions-hub-R3KNv-5V.js} +1 -1
- package/build/assets/{extensions-navigation-BQmstKDZ.js → extensions-navigation-CfWFmI1I.js} +1 -1
- package/build/assets/{external-link-D9B2QMPf.js → external-link-BdBSg8rk.js} +1 -1
- package/build/assets/files-tab-DEq8MbHu.js +1 -0
- package/build/assets/{form-control-classes-CtVAktAy.js → form-control-classes-DAfsCJTe.js} +1 -1
- package/build/assets/{format-time-delta-DICE64sz.js → format-time-delta-CxfPJpzC.js} +1 -1
- package/build/assets/git-provider-icon-BZqqUPlm.js +1 -0
- package/build/assets/git-repo-dropdown-9WKINV6J.js +1 -0
- package/build/assets/git-repo-dropdown-DEpOwUez.js +1 -0
- package/build/assets/{highlighted-source-view-KMsA9c4a.js → highlighted-source-view-CX9oIoVT.js} +1 -1
- package/build/assets/home-CY0JaxiY.js +1 -0
- package/build/assets/home-CaNWlVvB.js +1 -0
- package/build/assets/home-store-Ch1ErdBc.js +1 -0
- package/build/assets/index-home-CaNWlVvB.js +1 -0
- package/build/assets/info-CmWQXtRQ.js +1 -0
- package/build/assets/install-server-modal-BWrudmZU.js +1 -0
- package/build/assets/{launch-DjkKw55l.js → launch-B1POpHuP.js} +1 -1
- package/build/assets/{list-todo-BpAf7aOT.js → list-todo-DtiL3lTp.js} +1 -1
- package/build/assets/llm-not-configured-banner-3tMsM4K6.js +27 -0
- package/build/assets/{llm-settings-D8zNkIlP.js → llm-settings-CXo8iPNW.js} +1 -1
- package/build/assets/llm-settings-D0W8mJDk.js +1 -0
- package/build/assets/{llm-subscription-service-COTgZc1C.js → llm-subscription-service-DBJbfd8Z.js} +1 -1
- package/build/assets/loader-circle-B4QDBARx.js +1 -0
- package/build/assets/{loading-spinner-DRFyh6Iy.js → loading-spinner-DfZ_bhV7.js} +1 -1
- package/build/assets/{manage-backends-modal-DiRWE3tJ.js → manage-backends-modal-CwyWsiag.js} +1 -1
- package/build/assets/manifest-39f4789d.js +1 -0
- package/build/assets/markdown-renderer-DgiLLhW6.js +8 -0
- package/build/assets/mcp-DXG9LWrI.js +9 -0
- package/build/assets/mcp-marketplace-utils-DFmhKc5s.js +1 -0
- package/build/assets/messages-kBjKaAeA.js +40 -0
- package/build/assets/{modal-body-C3bGicn4.js → modal-body-CMsDpalT.js} +1 -1
- package/build/assets/{modal-classes-DFFO6BMU.js → modal-classes-B6PDrxXo.js} +1 -1
- package/build/assets/{modal-close-button-vxkAIRyZ.js → modal-close-button-DyxBZaAb.js} +1 -1
- package/build/assets/{onboarding-DWuFieEA.js → onboarding-47hh2IHA.js} +1 -1
- package/build/assets/{onboarding-modal-C8m72Dpb.js → onboarding-modal-9BuvvROo.js} +1 -1
- package/build/assets/{organization-service.api-CQ73CB-S.js → organization-service.api-UDy63-oC.js} +1 -1
- package/build/assets/{pencil-DzW2GB2M.js → pencil-BjgtZmWp.js} +1 -1
- package/build/assets/{planner-tab-YG0bGxDY.js → planner-tab-BWk8885v.js} +1 -1
- package/build/assets/{plugins-management-service-ijhH8OSh.js → plugins-management-service-CjkgF2dd.js} +1 -1
- package/build/assets/plus-DrKuuvMe.js +1 -0
- package/build/assets/{profiles-service.api-C32pPm70.js → profiles-service.api-CukSFLzz.js} +1 -1
- package/build/assets/{providers-DuSn9s2i.js → providers-CqUWC85T.js} +1 -1
- package/build/assets/{proxy-BiyDhMBd.js → proxy-BBUG3sd2.js} +1 -1
- package/build/assets/{puzzle-DlqT0yvr.js → puzzle-BoNc6zZ8.js} +1 -1
- package/build/assets/recommended-automations-launcher-ejxy1P27.js +1 -0
- package/build/assets/{refresh-cw-Br5254f4.js → refresh-cw-BrM5ZAZD.js} +1 -1
- package/build/assets/root-5S-M8SYa.js +2 -0
- package/build/assets/root-DZ39lS5f.css +1 -0
- package/build/assets/root-layout-BPqoa0gv.js +3 -0
- package/build/assets/{schema-field-htfNouTG.js → schema-field-nImDoY6-.js} +1 -1
- package/build/assets/{sdk-section-page-D0K1dBQY.js → sdk-section-page-BxMrtUNV.js} +1 -1
- package/build/assets/search-Dc2qR4O2.js +1 -0
- package/build/assets/{secrets-service-Dbv5Zb8G.js → secrets-service-Dhjh3HhH.js} +1 -1
- package/build/assets/{secrets-settings-Da4SSaX9.js → secrets-settings-CPdxceT_.js} +1 -1
- package/build/assets/segmented-toggle-Do6oyepX.js +1 -0
- package/build/assets/{settings-F4a09IxY.js → settings-BRbnfKEm.js} +1 -1
- package/build/assets/{settings-dropdown-input-jOiv5Yrk.js → settings-dropdown-input-DYCULKpp.js} +1 -1
- package/build/assets/{settings-index-CyJBf5NA.js → settings-index-C9o2NBO0.js} +1 -1
- package/build/assets/settings-input-B-q2gkVy.js +1 -0
- package/build/assets/{settings-list-classes-VqMzkYYt.js → settings-list-classes-WpQi0q1L.js} +1 -1
- package/build/assets/{settings-modal-C-S1NpbC.js → settings-modal-CEK0AIx6.js} +1 -1
- package/build/assets/{settings-service.api-CTJRrvMu.js → settings-service.api-CZiPD8__.js} +1 -1
- package/build/assets/{settings-switch-B405oU_v.js → settings-switch-LqKdGxHL.js} +1 -1
- package/build/assets/shared-conversation-Bu-dQlgp.js +1 -0
- package/build/assets/{sidebar-layout-BGMuyC86.js → sidebar-layout-oHBGQmLh.js} +1 -1
- package/build/assets/{sidebar-mobile-menu-toggle-xiKoUfGa.js → sidebar-mobile-menu-toggle-ND-hgygu.js} +1 -1
- package/build/assets/{sidebar-nav-link-DA4_ct9G.js → sidebar-nav-link-CrujNA09.js} +1 -1
- package/build/assets/{sidebar-store-FRJ3rADB.js → sidebar-store-Bui-WNEr.js} +1 -1
- package/build/assets/{skill-card-pill-row-BMdhr_sd.js → skill-card-pill-row-CZBI7OqH.js} +1 -1
- package/build/assets/{skill-icon-badge-CGUkgcVH.js → skill-icon-badge-BOov_phZ.js} +1 -1
- package/build/assets/{skills-plugins-C5eJnyft.js → skills-plugins-D0PiHWAD.js} +1 -1
- package/build/assets/{skills-settings-pUxMr6WZ.js → skills-settings-B43KArIz.js} +2 -2
- package/build/assets/{styled-tooltip-B3kIdVyH.js → styled-tooltip-C7grwnOX.js} +1 -1
- package/build/assets/{task-list-tab-B3k4W1cK.js → task-list-tab-R3ac6m7O.js} +1 -1
- package/build/assets/{terminal-CBI_41Zc.js → terminal-yqkNdEAx.js} +1 -1
- package/build/assets/{toggle-switch-DYRr9CAR.js → toggle-switch-BeSrbgCg.js} +1 -1
- package/build/assets/{trash-2-gZPlx23R.js → trash-2-wW5TWcdN.js} +1 -1
- package/build/assets/{typography-B1UxuuEC.js → typography-iYhzLlHO.js} +1 -1
- package/build/assets/{use-acp-credential-form-CjSvKWFH.js → use-acp-credential-form-DUxbxmbq.js} +1 -1
- package/build/assets/{use-activate-agent-profile-DCRf47e-.js → use-activate-agent-profile-CDHA52tC.js} +1 -1
- package/build/assets/use-agent-profiles-TsOdIyw5.js +1 -0
- package/build/assets/{use-can-manage-org-profiles-vBiP7rHF.js → use-can-manage-org-profiles-Bt1M71u5.js} +1 -1
- package/build/assets/{use-cloud-current-user-id-BMq9gw93.js → use-cloud-current-user-id-DWt7HCgf.js} +1 -1
- package/build/assets/use-config-CxlEdf_v.js +1 -0
- package/build/assets/{use-create-conversation-CakhLF0X.js → use-create-conversation-nOJ6Um5h.js} +1 -1
- package/build/assets/{use-create-secret-RT4QtSS9.js → use-create-secret-Dj5ang9x.js} +1 -1
- package/build/assets/use-is-authed-BT7Iud4U.js +1 -0
- package/build/assets/{use-is-creating-conversation-CIAcnd8M.js → use-is-creating-conversation-CAggrM75.js} +1 -1
- package/build/assets/use-llm-profiles-2Wc2db8u.js +1 -0
- package/build/assets/{use-onboarding-completion-CJU4MNAY.js → use-onboarding-completion-gxQlcEy2.js} +1 -1
- package/build/assets/{use-plugins-marketplace-D-93nqtJ.js → use-plugins-marketplace-CVO7sXYR.js} +1 -1
- package/build/assets/use-save-agent-profile-D0wC5ExW.js +1 -0
- package/build/assets/{use-save-settings--C6LZXfI.js → use-save-settings-L3aMaDeS.js} +1 -1
- package/build/assets/{use-settings-DIAo5KFk.js → use-settings-8nt3DGxW.js} +1 -1
- package/build/assets/use-settings-nav-items-DHAAD-zk.js +16 -0
- package/build/assets/{use-skills-D_mLhYNa.js → use-skills-CE6miQ3r.js} +1 -1
- package/build/assets/use-tracking-BGboadaZ.js +68 -0
- package/build/assets/{use-user-conversation-DhcAEyJX.js → use-user-conversation-BIIpGUgM.js} +1 -1
- package/build/assets/useInfiniteQuery-BLRVmVPU.js +1 -0
- package/build/assets/{useMutation-DHLpZ6J0.js → useMutation-CaSHLnX0.js} +1 -1
- package/build/assets/{useQueries-B3T1a7qt.js → useQueries--d_WWAzc.js} +1 -1
- package/build/assets/{useQuery-B38jBavx.js → useQuery-DiPh8LRJ.js} +1 -1
- package/build/assets/utils-BgGG1znF.js +1 -0
- package/build/assets/{vendor~browser-CIoZCqGs.js → vendor~browser-IVYgIgG1.js} +1 -1
- package/build/assets/{vendor~entry.client-Di4qO77Y.js → vendor~entry.client-BcYIVQvB.js} +1 -1
- package/build/assets/{vendor~entry.client-BfviqoVc.js → vendor~entry.client-CXM9oiAk.js} +1 -1
- package/build/assets/{vendor~entry.client~root~root-layout~index-home~home~conversation-panel~conversation~launch~g4xrpilz-CYPMCkX1.js → vendor~entry.client~root~root-layout~index-home~home~conversation-panel~conversation~launch~b0bpqexo-CbTboogo.js} +1 -1
- package/build/assets/{vendor~entry.client~root~root-layout~index-home~home~conversation-panel~conversation~launch~f9xdmd0z-DLMP7bZx.js → vendor~entry.client~root~root-layout~index-home~home~conversation-panel~conversation~launch~d4by102p-C2f0ZhS-.js} +1 -1
- package/build/assets/{vendor~files-tab-atebg0iG.js → vendor~files-tab-C7RmQJwN.js} +1 -1
- package/build/assets/{vendor~index-home~home~conversation-panel~conversation-G9DMrR7m.js → vendor~index-home~home~conversation-panel~conversation-Bqp1ZqJM.js} +1 -1
- package/build/assets/{vendor~root-layout~conversation-panel~conversation-DEhW1h3I.js → vendor~root-layout~conversation-panel~conversation-BCn8lzeG.js} +1 -1
- package/build/assets/vendor~root-layout~index-home~home~conversation-panel~conversation~automation-setup-route-B_L-gcOG.js +1 -0
- package/build/assets/vendor~root-layout~index-home~home~conversation-panel~conversation~shared-conversation-sjx0x5ac.js +1 -0
- package/build/assets/vendor~root-layout~index-home~home~mcp~automations-list~automation-setup-route~onboarding-modal-D7IDevqN.js +1 -0
- package/build/assets/{vendor~root~root-layout~index-home~home~conversation-panel~conversation~launch~extensions-h~bi2r7bko-VFnwct3q.js → vendor~root~root-layout~index-home~home~conversation-panel~conversation~launch~extensions-h~dfc8ddxy-tTyxnjXT.js} +1 -1
- package/build/assets/{vendor~root~root-layout~index-home~home~conversation-panel~conversation~launch~extensions-h~hakxo2tj-ClV0p9g3.js → vendor~root~root-layout~index-home~home~conversation-panel~conversation~launch~extensions-h~gy8zbn65-CGt6bWRT.js} +1 -1
- package/build/assets/{vendor~root-layout~index-home~home~conversation-panel~conversation~launch~skills-settings~a~eywn6ulz-BKxxr74w.js → vendor~root~root-layout~index-home~home~conversation-panel~conversation~launch~skills-setti~dufan6ng-Dtdw8H0q.js} +17 -4
- package/build/assets/{verification-settings-Vr5cN4md.js → verification-settings-DBsnSXC3.js} +1 -1
- package/build/assets/x-omAzpXkl.js +1 -0
- package/build/index.html +4 -4
- package/build/locales/ar/openhands.json +37 -2
- package/build/locales/ca/openhands.json +37 -2
- package/build/locales/de/openhands.json +37 -2
- package/build/locales/en/openhands.json +38 -3
- package/build/locales/es/openhands.json +37 -2
- package/build/locales/fr/openhands.json +37 -2
- package/build/locales/it/openhands.json +37 -2
- package/build/locales/ja/openhands.json +37 -2
- package/build/locales/ko-KR/openhands.json +37 -2
- package/build/locales/no/openhands.json +37 -2
- package/build/locales/pt/openhands.json +37 -2
- package/build/locales/tr/openhands.json +37 -2
- package/build/locales/uk/openhands.json +37 -2
- package/build/locales/zh-CN/openhands.json +37 -2
- package/build/locales/zh-TW/openhands.json +37 -2
- package/config/defaults.json +1 -1
- package/dist/api/agent-server-adapter.cjs +3 -3
- package/dist/api/agent-server-adapter.cjs.map +1 -1
- package/dist/api/agent-server-adapter.d.ts +46 -6
- package/dist/api/agent-server-adapter.js +187 -168
- package/dist/api/agent-server-adapter.js.map +1 -1
- package/dist/api/agent-server-compatibility.cjs +1 -1
- package/dist/api/agent-server-compatibility.cjs.map +1 -1
- package/dist/api/agent-server-compatibility.d.ts +4 -0
- package/dist/api/agent-server-compatibility.js +41 -38
- package/dist/api/agent-server-compatibility.js.map +1 -1
- package/dist/api/automation-service/automation-service.api.cjs +1 -1
- package/dist/api/automation-service/automation-service.api.cjs.map +1 -1
- package/dist/api/automation-service/automation-service.api.d.ts +20 -0
- package/dist/api/automation-service/automation-service.api.js +99 -62
- package/dist/api/automation-service/automation-service.api.js.map +1 -1
- package/dist/components/conversation-events/chat/event-content-helpers/get-action-event-title.cjs +2 -0
- package/dist/components/conversation-events/chat/event-content-helpers/get-action-event-title.cjs.map +1 -0
- package/dist/components/conversation-events/chat/event-content-helpers/get-action-event-title.d.ts +12 -0
- package/dist/components/conversation-events/chat/event-content-helpers/get-action-event-title.js +94 -0
- package/dist/components/conversation-events/chat/event-content-helpers/get-action-event-title.js.map +1 -0
- package/dist/components/conversation-events/chat/event-content-helpers/get-event-content.cjs +1 -1
- package/dist/components/conversation-events/chat/event-content-helpers/get-event-content.cjs.map +1 -1
- package/dist/components/conversation-events/chat/event-content-helpers/get-event-content.js +31 -90
- package/dist/components/conversation-events/chat/event-content-helpers/get-event-content.js.map +1 -1
- package/dist/components/features/automations/recommended-automations-launcher.d.ts +0 -7
- package/dist/components/features/automations/recommended-automations-section.d.ts +0 -6
- package/dist/components/features/backends/backend-form-modal.cjs +1 -1
- package/dist/components/features/backends/backend-form-modal.cjs.map +1 -1
- package/dist/components/features/backends/backend-form-modal.js +568 -358
- package/dist/components/features/backends/backend-form-modal.js.map +1 -1
- package/dist/components/features/backends/device-flow-auth.cjs +1 -1
- package/dist/components/features/backends/device-flow-auth.cjs.map +1 -1
- package/dist/components/features/backends/device-flow-auth.d.ts +9 -1
- package/dist/components/features/backends/device-flow-auth.js +56 -55
- package/dist/components/features/backends/device-flow-auth.js.map +1 -1
- package/dist/components/features/backends/manage-backends-modal.cjs +1 -1
- package/dist/components/features/backends/manage-backends-modal.cjs.map +1 -1
- package/dist/components/features/backends/manage-backends-modal.js +1 -1
- package/dist/components/features/backends/manage-backends-modal.js.map +1 -1
- package/dist/components/features/chat/chat-interface.cjs +1 -1
- package/dist/components/features/chat/chat-interface.cjs.map +1 -1
- package/dist/components/features/chat/chat-interface.js +105 -105
- package/dist/components/features/chat/chat-interface.js.map +1 -1
- package/dist/components/features/chat/chat-message.cjs +1 -1
- package/dist/components/features/chat/chat-message.cjs.map +1 -1
- package/dist/components/features/chat/chat-message.d.ts +2 -1
- package/dist/components/features/chat/chat-message.js +59 -49
- package/dist/components/features/chat/chat-message.js.map +1 -1
- package/dist/components/features/chat/pending-user-messages.cjs +1 -1
- package/dist/components/features/chat/pending-user-messages.cjs.map +1 -1
- package/dist/components/features/chat/pending-user-messages.js +4 -1
- package/dist/components/features/chat/pending-user-messages.js.map +1 -1
- package/dist/components/features/chat/typing-indicator.cjs +1 -1
- package/dist/components/features/chat/typing-indicator.cjs.map +1 -1
- package/dist/components/features/chat/typing-indicator.d.ts +8 -1
- package/dist/components/features/chat/typing-indicator.js +94 -10
- package/dist/components/features/chat/typing-indicator.js.map +1 -1
- package/dist/components/features/command-menu/command-menu-items.d.ts +5 -1
- package/dist/components/features/files-tab/segmented-toggle.cjs +1 -1
- package/dist/components/features/files-tab/segmented-toggle.cjs.map +1 -1
- package/dist/components/features/files-tab/segmented-toggle.d.ts +2 -0
- package/dist/components/features/files-tab/segmented-toggle.js +17 -14
- package/dist/components/features/files-tab/segmented-toggle.js.map +1 -1
- package/dist/components/features/manifest/manifest-form-field.d.ts +27 -0
- package/dist/components/features/manifest/manifest-prerequisites-step.d.ts +11 -0
- package/dist/components/features/manifest/manifest-review-step.d.ts +14 -0
- package/dist/components/features/manifest/manifest-setup-dialog.d.ts +14 -0
- package/dist/components/features/settings/settings-input.cjs +1 -1
- package/dist/components/features/settings/settings-input.cjs.map +1 -1
- package/dist/components/features/settings/settings-input.d.ts +6 -0
- package/dist/components/features/settings/settings-input.js +13 -8
- package/dist/components/features/settings/settings-input.js.map +1 -1
- package/dist/components/features/sidebar/sidebar-rail-body.cjs +1 -1
- package/dist/components/features/sidebar/sidebar-rail-body.cjs.map +1 -1
- package/dist/components/features/sidebar/sidebar-rail-body.js +124 -123
- package/dist/components/features/sidebar/sidebar-rail-body.js.map +1 -1
- package/dist/config/defaults.cjs +1 -1
- package/dist/config/defaults.cjs.map +1 -1
- package/dist/config/defaults.js +1 -1
- package/dist/config/defaults.js.map +1 -1
- package/dist/hooks/query/query-keys.cjs.map +1 -1
- package/dist/hooks/query/query-keys.d.ts +4 -0
- package/dist/hooks/query/query-keys.js.map +1 -1
- package/dist/hooks/query/use-manifest-capabilities.d.ts +21 -0
- package/dist/hooks/query/use-manifest-prerequisites.d.ts +24 -0
- package/dist/hooks/use-llm-configured.cjs +1 -1
- package/dist/hooks/use-llm-configured.cjs.map +1 -1
- package/dist/hooks/use-llm-configured.js +2 -1
- package/dist/hooks/use-llm-configured.js.map +1 -1
- package/dist/hooks/use-manifest-preflight.d.ts +18 -0
- package/dist/hooks/use-tracking.cjs +1 -1
- package/dist/hooks/use-tracking.cjs.map +1 -1
- package/dist/hooks/use-tracking.d.ts +14 -0
- package/dist/hooks/use-tracking.js +19 -1
- package/dist/hooks/use-tracking.js.map +1 -1
- package/dist/i18n/declaration.cjs +1 -1
- package/dist/i18n/declaration.cjs.map +1 -1
- package/dist/i18n/declaration.d.ts +36 -1
- package/dist/i18n/declaration.js +1 -1
- package/dist/i18n/declaration.js.map +1 -1
- package/dist/i18n/translation.cjs +2 -2
- package/dist/i18n/translation.cjs.map +1 -1
- package/dist/i18n/translation.js +611 -16
- package/dist/i18n/translation.js.map +1 -1
- package/dist/icons/external-link.cjs +2 -0
- package/dist/icons/external-link.cjs.map +1 -0
- package/dist/icons/external-link.js +22 -0
- package/dist/icons/external-link.js.map +1 -0
- package/dist/icons/server.cjs +2 -0
- package/dist/icons/server.cjs.map +1 -0
- package/dist/icons/server.js +17 -0
- package/dist/icons/server.js.map +1 -0
- package/dist/locales/ar/openhands.json +37 -2
- package/dist/locales/ca/openhands.json +37 -2
- package/dist/locales/de/openhands.json +37 -2
- package/dist/locales/en/openhands.json +38 -3
- package/dist/locales/es/openhands.json +37 -2
- package/dist/locales/fr/openhands.json +37 -2
- package/dist/locales/it/openhands.json +37 -2
- package/dist/locales/ja/openhands.json +37 -2
- package/dist/locales/ko-KR/openhands.json +37 -2
- package/dist/locales/no/openhands.json +37 -2
- package/dist/locales/pt/openhands.json +37 -2
- package/dist/locales/tr/openhands.json +37 -2
- package/dist/locales/uk/openhands.json +37 -2
- package/dist/locales/zh-CN/openhands.json +37 -2
- package/dist/locales/zh-TW/openhands.json +37 -2
- package/dist/manifests/automation-interface.cjs +2 -0
- package/dist/manifests/automation-interface.cjs.map +1 -0
- package/dist/manifests/automation-interface.d.ts +44 -0
- package/dist/manifests/automation-interface.js +81 -0
- package/dist/manifests/automation-interface.js.map +1 -0
- package/dist/manifests/automation-setup.cjs +2 -0
- package/dist/manifests/automation-setup.cjs.map +1 -0
- package/dist/manifests/automation-setup.d.ts +52 -0
- package/dist/manifests/automation-setup.js +8 -0
- package/dist/manifests/automation-setup.js.map +1 -0
- package/dist/manifests/interface-validation.cjs +2 -0
- package/dist/manifests/interface-validation.cjs.map +1 -0
- package/dist/manifests/interface-validation.d.ts +27 -0
- package/dist/manifests/interface-validation.js +182 -0
- package/dist/manifests/interface-validation.js.map +1 -0
- package/dist/manifests/manifest-actions.d.ts +15 -0
- package/dist/manifests/manifest-capabilities.d.ts +25 -0
- package/dist/manifests/manifest-error-map.d.ts +40 -0
- package/dist/manifests/manifest-local-validation.d.ts +56 -0
- package/dist/manifests/manifest-registry.cjs +2 -0
- package/dist/manifests/manifest-registry.cjs.map +1 -0
- package/dist/manifests/manifest-registry.d.ts +15 -0
- package/dist/manifests/manifest-registry.js +26 -0
- package/dist/manifests/manifest-registry.js.map +1 -0
- package/dist/manifests/manifest-sources.cjs +2 -0
- package/dist/manifests/manifest-sources.cjs.map +1 -0
- package/dist/manifests/manifest-sources.d.ts +15 -0
- package/dist/manifests/manifest-sources.js +8 -0
- package/dist/manifests/manifest-sources.js.map +1 -0
- package/dist/manifests/manifest-template.d.ts +18 -0
- package/dist/manifests/manifest-validation.cjs +2 -0
- package/dist/manifests/manifest-validation.cjs.map +1 -0
- package/dist/manifests/manifest-validation.d.ts +30 -0
- package/dist/manifests/manifest-validation.js +145 -0
- package/dist/manifests/manifest-validation.js.map +1 -0
- package/dist/manifests/types.cjs +2 -0
- package/dist/manifests/types.cjs.map +1 -0
- package/dist/manifests/types.d.ts +227 -0
- package/dist/manifests/types.js +6 -0
- package/dist/manifests/types.js.map +1 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/github-pr-reviewer/manifest.cjs +9 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/github-pr-reviewer/manifest.cjs.map +1 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/github-pr-reviewer/manifest.js +75 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/github-pr-reviewer/manifest.js.map +1 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/github-repo-monitor/manifest.cjs +9 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/github-repo-monitor/manifest.cjs.map +1 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/github-repo-monitor/manifest.js +78 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/github-repo-monitor/manifest.js.map +1 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/incident-retrospective-drafter/manifest.cjs +17 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/incident-retrospective-drafter/manifest.cjs.map +1 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/incident-retrospective-drafter/manifest.js +89 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/incident-retrospective-drafter/manifest.js.map +1 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/jira-issue-to-pr/manifest.cjs +10 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/jira-issue-to-pr/manifest.cjs.map +1 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/jira-issue-to-pr/manifest.js +17 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/jira-issue-to-pr/manifest.js.map +1 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/linear-triage-assistant/manifest.cjs +9 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/linear-triage-assistant/manifest.cjs.map +1 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/linear-triage-assistant/manifest.js +15 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/linear-triage-assistant/manifest.js.map +1 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/research-brief-writer/manifest.cjs +9 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/research-brief-writer/manifest.cjs.map +1 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/research-brief-writer/manifest.js +18 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/research-brief-writer/manifest.js.map +1 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/slack-channel-monitor/manifest.cjs +9 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/slack-channel-monitor/manifest.cjs.map +1 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/slack-channel-monitor/manifest.js +14 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/slack-channel-monitor/manifest.js.map +1 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/slack-standup-digest/manifest.cjs +9 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/slack-standup-digest/manifest.cjs.map +1 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/slack-standup-digest/manifest.js +14 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog/slack-standup-digest/manifest.js.map +1 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog-index.cjs +2 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog-index.cjs.map +1 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog-index.js +23 -0
- package/dist/node_modules/@openhands/extensions/automations/catalog-index.js.map +1 -0
- package/dist/node_modules/@openhands/extensions/automations/index.cjs +2 -0
- package/dist/node_modules/@openhands/extensions/automations/index.cjs.map +1 -0
- package/dist/node_modules/@openhands/extensions/automations/index.js +18 -0
- package/dist/node_modules/@openhands/extensions/automations/index.js.map +1 -0
- package/dist/node_modules/@openhands/extensions/automations/interface.cjs +2 -0
- package/dist/node_modules/@openhands/extensions/automations/interface.cjs.map +1 -0
- package/dist/node_modules/@openhands/extensions/automations/interface.js +89 -0
- package/dist/node_modules/@openhands/extensions/automations/interface.js.map +1 -0
- package/dist/node_modules/@openhands/extensions/integrations/catalog/datadog.cjs +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/datadog.cjs.map +1 -1
- package/dist/node_modules/@openhands/extensions/integrations/catalog/datadog.js +3 -3
- package/dist/node_modules/@openhands/extensions/integrations/catalog/datadog.js.map +1 -1
- package/dist/node_modules/@openhands/extensions/skills/index.cjs +17 -4
- package/dist/node_modules/@openhands/extensions/skills/index.cjs.map +1 -1
- package/dist/node_modules/@openhands/extensions/skills/index.js +5 -5
- package/dist/node_modules/@openhands/extensions/skills/index.js.map +1 -1
- package/dist/node_modules/lucide-react/dist/esm/icons/monitor.cjs +2 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/monitor.cjs.map +1 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/monitor.js +29 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/monitor.js.map +1 -0
- package/dist/package.cjs +1 -1
- package/dist/package.cjs.map +1 -1
- package/dist/package.js +2 -2
- package/dist/package.js.map +1 -1
- package/dist/types/agent-server/core/events/conversation-state-event.d.ts +2 -19
- package/dist/types/agent-server/core/events/observation-event.d.ts +2 -18
- package/dist/types/automation.d.ts +7 -3
- package/dist/utils/api-error-message.d.ts +6 -2
- package/dist/utils/automation-catalog.cjs +2 -0
- package/dist/utils/automation-catalog.cjs.map +1 -0
- package/dist/utils/automation-catalog.d.ts +28 -0
- package/dist/utils/automation-catalog.js +5 -0
- package/dist/utils/automation-catalog.js.map +1 -0
- package/dist/utils/automation-timeout.d.ts +3 -2
- package/dist/utils/responder-deployment.d.ts +5 -1
- package/dist/utils/transcript-export/index.cjs +5 -5
- package/dist/utils/transcript-export/index.js +12 -12
- package/package.json +2 -2
- package/scripts/check-translation-completeness.cjs +1 -0
- package/scripts/dev-safe.mjs +15 -10
- package/scripts/dev-static.mjs +17 -0
- package/scripts/dev-with-automation.mjs +12 -14
- package/scripts/ingress.mjs +22 -0
- package/scripts/proxy-utils.mjs +157 -2
- package/scripts/runtime-services-info.mjs +6 -6
- package/scripts/static-build.mjs +0 -7
- package/scripts/static-server.mjs +10 -0
- package/build/assets/active-backend-context-mY7Gff5c.js +0 -2
- package/build/assets/agent-context-settings-BTUmWEzL.js +0 -1
- package/build/assets/agent-profiles-settings-Ilqid_R5.js +0 -1
- package/build/assets/agent-server-conversation-service.api-C_7YnjzP.js +0 -41
- package/build/assets/agent-settings-CxfT4ksO.js +0 -1
- package/build/assets/automation-BGP_I1RR.js +0 -1
- package/build/assets/automation-detail-nEflClmc.js +0 -2
- package/build/assets/automation-export-BO_kfqC8.js +0 -2
- package/build/assets/automations-list-BYncC7gv.js +0 -1
- package/build/assets/backend-form-modal-CKrBF80P.js +0 -1
- package/build/assets/browser-3QjrEr1D.js +0 -6
- package/build/assets/check-CrxQfJZ2.js +0 -1
- package/build/assets/chevron-down-D_LsyTA7.js +0 -1
- package/build/assets/circle-check-DZn9HkLE.js +0 -1
- package/build/assets/cloud-funnel-analytics-NlmDoeo2.js +0 -1
- package/build/assets/command-menu-CvLPs7dg.js +0 -1
- package/build/assets/condenser-settings-C4Y9CzQV.js +0 -1
- package/build/assets/conversation-D_ORtpKC.js +0 -1
- package/build/assets/conversation-Dpc5nmGi.js +0 -90
- package/build/assets/conversation-panel-D_ORtpKC.js +0 -1
- package/build/assets/conversation-state-store-CGRQemtx.js +0 -1
- package/build/assets/files-tab-4c9HFSLo.js +0 -1
- package/build/assets/git-provider-icon-0PqmIS_S.js +0 -1
- package/build/assets/home-D9JsyEmE.js +0 -1
- package/build/assets/home-TFhnmZLx.js +0 -1
- package/build/assets/index-home-D9JsyEmE.js +0 -1
- package/build/assets/install-server-modal-BgGRnqA0.js +0 -1
- package/build/assets/llm-not-configured-banner-Y4W9-sar.js +0 -27
- package/build/assets/llm-settings-nPwv7hKu.js +0 -1
- package/build/assets/loader-circle-CGD6-Vak.js +0 -1
- package/build/assets/manifest-1cf33a7b.js +0 -1
- package/build/assets/markdown-renderer-U40HF0Ak.js +0 -8
- package/build/assets/mcp-xDMaHzOw.js +0 -9
- package/build/assets/messages-CdNfZPgd.js +0 -40
- package/build/assets/plus-CTGLo3aa.js +0 -1
- package/build/assets/recommended-automations-launcher-Dru1yN46.js +0 -58
- package/build/assets/root-B5JXKp1P.css +0 -1
- package/build/assets/root-DOLLQteU.js +0 -2
- package/build/assets/root-layout-xmylWoew.js +0 -3
- package/build/assets/search-BrpWXWUi.js +0 -1
- package/build/assets/segmented-toggle-CZKOdIly.js +0 -1
- package/build/assets/settings-input-BEaTCem1.js +0 -1
- package/build/assets/shared-conversation-BvWtTwES.js +0 -1
- package/build/assets/use-agent-profiles-DmT9zxAN.js +0 -1
- package/build/assets/use-config-C959QcRC.js +0 -1
- package/build/assets/use-is-authed-BsS4XwSL.js +0 -1
- package/build/assets/use-llm-profiles-CdaxVpyY.js +0 -1
- package/build/assets/use-save-agent-profile-DGJ3-u0M.js +0 -1
- package/build/assets/use-settings-nav-items-DPK5sxvR.js +0 -16
- package/build/assets/use-tracking-COqZLobY.js +0 -1
- package/build/assets/utils-DsWhWn2F.js +0 -1
- package/build/assets/vendor~root-layout~index-home~home~conversation-panel~conversation-Acmf1sKj.js +0 -1
- package/build/assets/vendor~root-layout~index-home~home~conversation-panel~conversation~shared-conversation-CmzCY1BT.js +0 -1
- package/build/assets/vendor~root-layout~index-home~home~mcp~automations-list~onboarding-modal-C7Yh77RT.js +0 -1
- package/build/assets/x-Dx_JbpHA.js +0 -1
- /package/build/assets/{vendor~entry.client~root~root-layout~index-home~home~conversation-panel~conversation~launch~f1hl7voa-BrmgjeOw.js → vendor~entry.client~root~root-layout~index-home~home~conversation-panel~conversation~launch~emdr2jt4-BrmgjeOw.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-interface.js","names":[],"sources":["../../../../src/components/features/chat/chat-interface.tsx"],"sourcesContent":["import React from \"react\";\nimport { useNavigate } from \"react-router\";\nimport { useTracking } from \"#/hooks/use-tracking\";\nimport { useTranslation } from \"react-i18next\";\nimport { isAcpAuthErrorCode } from \"#/utils/acp-error-codes\";\nimport { convertImageToBase64 } from \"#/utils/convert-image-to-base-64\";\nimport { createChatMessage } from \"#/services/chat-service\";\nimport { BtwMessages } from \"./btw-messages\";\nimport { GoalStatusBanner } from \"./goal-status-banner\";\nimport { ModelMessages } from \"./model-messages\";\nimport { useModelStore } from \"#/stores/model-store\";\nimport { useGoalStore } from \"#/stores/goal-store\";\nimport { InteractiveChatBox } from \"./interactive-chat-box\";\nimport { AgentState } from \"#/types/agent-state\";\nimport { useFilteredEvents } from \"#/hooks/use-filtered-events\";\nimport { useScrollToBottom } from \"#/hooks/use-scroll-to-bottom\";\nimport { useLoadOlderEvents } from \"#/hooks/use-load-older-events\";\nimport { TypingIndicator } from \"./typing-indicator\";\nimport { ChatSuggestions } from \"./chat-suggestions\";\nimport { ScrollProvider } from \"#/context/scroll-context\";\nimport { useInitialQueryStore } from \"#/stores/initial-query-store\";\nimport { useSendMessage } from \"#/hooks/use-send-message\";\nimport { useAgentState } from \"#/hooks/use-agent-state\";\nimport { useIsArchivedConversation } from \"#/hooks/use-is-archived-conversation\";\nimport { useHandleBuildPlanClick } from \"#/hooks/use-handle-build-plan-click\";\n\nimport { ScrollToBottomButton } from \"#/components/shared/buttons/scroll-to-bottom-button\";\nimport { LoadingSpinner } from \"#/components/shared/loading-spinner\";\nimport { ChatMessagesSkeleton } from \"./chat-messages-skeleton\";\nimport { displayErrorToast } from \"#/utils/custom-toast-handlers\";\nimport { useErrorMessageStore } from \"#/stores/error-message-store\";\nimport { useOptimisticUserMessageStore } from \"#/stores/optimistic-user-message-store\";\nimport { SERVER_CONNECTION_ERROR_MESSAGE } from \"#/constants/server-connection-error\";\nimport { ErrorMessageBanner } from \"./error-message-banner\";\nimport { SkillInstallRestartBanner } from \"./skill-install-restart-banner\";\nimport { LlmNotConfiguredBanner } from \"#/components/features/home/llm-not-configured-banner\";\nimport { useLlmConfigured } from \"#/hooks/use-llm-configured\";\nimport { Messages } from \"#/components/conversation-events/chat/messages\";\nimport { PendingUserMessages } from \"./pending-user-messages\";\nimport { useUnifiedUploadFiles } from \"#/hooks/mutation/use-unified-upload-files\";\nimport { validateFiles } from \"#/utils/file-validation\";\nimport { useConversationStore } from \"#/stores/conversation-store\";\nimport ConfirmationModeEnabled from \"./confirmation-mode-enabled\";\nimport { useTaskPolling } from \"#/hooks/query/use-task-polling\";\nimport { matchesPendingConversationId } from \"#/utils/pending-task-message-link\";\nimport { useConversationWebSocket } from \"#/contexts/conversation-websocket-context\";\nimport ChatStatusIndicator from \"./chat-status-indicator\";\nimport { getStatusColor, getStatusText } from \"#/utils/utils\";\nimport { useNewConversationCommand } from \"#/hooks/mutation/use-new-conversation-command\";\nimport { useOptionalConversationId } from \"#/hooks/use-conversation-id\";\nimport { useActiveConversation } from \"#/hooks/query/use-active-conversation\";\nimport { I18nKey } from \"#/i18n/declaration\";\nimport { hasConversationStarted } from \"./components/resolve-picker-kind\";\n\nfunction getEntryPoint(\n hasRepository: boolean | null,\n hasReplayJson: boolean | null,\n): string {\n if (hasRepository) return \"github\";\n if (hasReplayJson) return \"replay\";\n return \"direct\";\n}\n\nexport function ChatInterface() {\n const { trackInitialQuerySubmitted, trackUserMessageSent } = useTracking();\n const { setMessageToSend } = useConversationStore();\n const { errorMessage, errorCode, removeErrorMessage, setErrorMessage } =\n useErrorMessageStore();\n const navigate = useNavigate();\n const { isTask, taskStatus, taskDetail } = useTaskPolling();\n // Hide empty-state chrome for the entire `/conversations/task-{uuid}` route,\n // including the brief READY window before redirect completes.\n const isProvisioningTask = isTask;\n const conversationWebSocket = useConversationWebSocket();\n const { send } = useSendMessage();\n const {\n renderableEvents,\n allConversationEvents,\n totalEvents,\n hasSubstantiveAgentActions,\n userEventsExist,\n } = useFilteredEvents();\n const enqueuePendingMessage = useOptimisticUserMessageStore(\n (state) => state.enqueuePendingMessage,\n );\n const markPendingMessageError = useOptimisticUserMessageStore(\n (state) => state.markPendingMessageError,\n );\n const pendingMessages = useOptimisticUserMessageStore(\n (state) => state.pendingMessages,\n );\n const { t } = useTranslation(\"openhands\");\n const scrollRef = React.useRef<HTMLDivElement>(null);\n const {\n scrollDomToBottom,\n onChatBodyScroll,\n hitBottom,\n autoScroll,\n setAutoScroll,\n setHitBottom,\n } = useScrollToBottom(scrollRef);\n const {\n mutate: newConversationCommand,\n isPending: isNewConversationPending,\n } = useNewConversationCommand();\n\n const { curAgentState } = useAgentState();\n const { handleBuildPlanClick } = useHandleBuildPlanClick();\n\n // Cloud conversations whose sandbox is MISSING or ERROR are read-only:\n // the sandbox is gone and cannot be resumed, so we hide the chat input\n // and show an explanatory banner. For local backends sandbox_status is\n // always null, so this is effectively a no-op for non-cloud use.\n const { data: activeConversation } = useActiveConversation();\n const sandboxStatus = activeConversation?.sandbox_status ?? null;\n const isArchivedConversation = useIsArchivedConversation();\n\n // Block sending in a resumed conversation that has no usable LLM, and show\n // the same setup banner as the home screen so the dead end is explained.\n const { isConfigured: isLlmConfigured, isLoading: isLlmConfigLoading } =\n useLlmConfigured();\n const llmBlocked = !isLlmConfigLoading && !isLlmConfigured;\n\n // Disable Build button while agent is running (streaming)\n const isAgentRunning =\n curAgentState === AgentState.RUNNING ||\n curAgentState === AgentState.LOADING;\n\n // Global keyboard shortcut for Build button (Cmd+Enter / Ctrl+Enter)\n // This is placed here instead of PlanPreview to avoid duplicate listeners\n // when multiple PlanPreview components exist in the chat\n React.useEffect(() => {\n if (isAgentRunning) {\n return undefined;\n }\n\n const handleKeyDown = (event: KeyboardEvent) => {\n // Check for Cmd+Enter (Mac) or Ctrl+Enter (Windows/Linux)\n if ((event.metaKey || event.ctrlKey) && event.key === \"Enter\") {\n event.preventDefault();\n event.stopPropagation();\n handleBuildPlanClick(event);\n scrollDomToBottom();\n }\n };\n\n document.addEventListener(\"keydown\", handleKeyDown);\n\n return () => {\n document.removeEventListener(\"keydown\", handleKeyDown);\n };\n }, [isAgentRunning, handleBuildPlanClick, scrollDomToBottom]);\n\n const { selectedRepository, replayJson } = useInitialQueryStore();\n const { conversationId } = useOptionalConversationId();\n\n // The live goal banner renders in the scroll stream but advances via store\n // updates (in-progress goal events are filtered out of `renderableEvents`),\n // so the bottom-following effect would not react to it. This key changes as\n // an active loop appears and advances each round; feeding it into that effect\n // keeps the banner in view when the user is pinned to the bottom.\n const activeGoalScrollKey = useGoalStore((s) => {\n const goal = conversationId\n ? s.statusByConversation[conversationId]\n : undefined;\n return goal?.active ? `${goal.iteration}:${goal.status}` : null;\n });\n const { mutateAsync: uploadFiles } = useUnifiedUploadFiles();\n\n // Lazy \"scroll up to load older events\" backfill. Initial REST fetch only\n // returns the most recent page; this hook paginates older events into the\n // store on demand so the chat doesn't load (potentially) thousands of\n // events on first render.\n const {\n isLoading: isLoadingOlderEvents,\n hasMore: hasMoreOlderEvents,\n loadOlder,\n } = useLoadOlderEvents(conversationId);\n\n // Trigger `loadOlder` and preserve the visual scroll position once the\n // older page is merged in (otherwise prepending events would jump the\n // chat far down). We fire from three places to cover the cases the\n // browser's scroll event misses:\n //\n // - `onScroll`: normal \"user scrolled near the top\" path.\n // - `onWheel`: user is already pinned at scrollTop=0 and tries to\n // wheel further up — no scroll event fires past 0.\n // - effect: content is shorter than the viewport (no scrollbar\n // at all), so the user has nothing to scroll. Re-runs\n // as more pages arrive until there's overflow or the\n // server runs out of older events.\n const SCROLL_TOP_THRESHOLD_PX = 80;\n const preserveScrollPosition = React.useRef<{\n scrollHeight: number;\n scrollTop: number;\n } | null>(null);\n const maybeLoadOlder = React.useCallback(\n (target: HTMLElement) => {\n if (isProvisioningTask || isLoadingOlderEvents || !hasMoreOlderEvents) {\n return;\n }\n\n const atTop = target.scrollTop <= SCROLL_TOP_THRESHOLD_PX;\n const noOverflow =\n target.scrollHeight <= target.clientHeight + SCROLL_TOP_THRESHOLD_PX;\n if (!atTop && !noOverflow) return;\n\n preserveScrollPosition.current = {\n scrollHeight: target.scrollHeight,\n scrollTop: target.scrollTop,\n };\n loadOlder().catch((error) => {\n preserveScrollPosition.current = null;\n const message =\n error instanceof Error && error.message\n ? error.message\n : t(I18nKey.ERROR$GENERIC);\n setErrorMessage(message);\n });\n },\n [\n hasMoreOlderEvents,\n isLoadingOlderEvents,\n isProvisioningTask,\n loadOlder,\n setErrorMessage,\n t,\n ],\n );\n\n const handleWheelForPagination = React.useCallback(\n (e: React.WheelEvent<HTMLDivElement>) => {\n // Browsers don't dispatch a scroll event when scrollTop is already\n // 0 and the user wheels upward, so onScroll alone misses this case.\n if (e.deltaY < 0 && e.currentTarget.scrollTop <= 0) {\n maybeLoadOlder(e.currentTarget);\n }\n },\n [maybeLoadOlder],\n );\n\n const hasPendingUserMessages = React.useMemo(\n () =>\n conversationId\n ? pendingMessages.some((message) =>\n matchesPendingConversationId(\n conversationId,\n message.conversationId,\n ),\n )\n : false,\n [pendingMessages, conversationId],\n );\n\n const hasModelEntries = useModelStore((s) =>\n conversationId\n ? (s.entriesByConversation[conversationId]?.length ?? 0) > 0\n : false,\n );\n const hasStartedConversation = hasConversationStarted({\n isLoadingHistory: conversationWebSocket?.isLoadingHistory === true,\n hasUserEvents: userEventsExist,\n hasPendingUserMessages,\n hasSubstantiveAgentActions,\n hasModelEntries,\n });\n\n // Show V1 messages immediately if events exist in store (e.g., remount),\n // if the user already has a locally-tracked pending bubble (home-page cloud\n // submit while history/WS catch up), or once loading completes. This\n // replaces the old transition-observation pattern (useState + useEffect\n // watching loading→loaded) which always showed skeleton on remount because\n // local state initialized to false.\n const showConversationMessages =\n allConversationEvents.length > 0 ||\n hasPendingUserMessages ||\n !conversationWebSocket?.isLoadingHistory;\n\n const isReturningToConversation = !!conversationId;\n // Only show loading skeleton when genuinely loading AND no events in store yet.\n // If events exist (e.g., remount after data was already fetched), skip skeleton.\n const isHistoryLoading = !showConversationMessages;\n const isChatLoading = isHistoryLoading && !isTask;\n\n const handleSendMessage = async (\n content: string,\n originalImages: File[],\n originalFiles: File[],\n ) => {\n // Handle /new command for V1 conversations\n if (content.trim() === \"/new\") {\n if (!conversationId) {\n displayErrorToast(t(I18nKey.CONVERSATION$CLEAR_NO_ID));\n return;\n }\n if (totalEvents === 0) {\n displayErrorToast(t(I18nKey.CONVERSATION$CLEAR_EMPTY));\n return;\n }\n if (isNewConversationPending) {\n return;\n }\n newConversationCommand();\n return;\n }\n\n // Create mutable copies of the arrays\n const images = [...originalImages];\n const files = [...originalFiles];\n if (totalEvents === 0) {\n trackInitialQuerySubmitted({\n entryPoint: getEntryPoint(\n selectedRepository !== null,\n replayJson !== null,\n ),\n queryCharacterLength: content.length,\n replayJsonSize: replayJson?.length,\n });\n } else {\n trackUserMessageSent({\n sessionMessageCount: totalEvents,\n currentMessageLength: content.length,\n });\n }\n\n // Validate file sizes before any processing\n const allFiles = [...images, ...files];\n const validation = validateFiles(allFiles);\n\n if (!validation.isValid) {\n displayErrorToast(`Error: ${validation.errorMessage}`);\n return; // Stop processing if validation fails\n }\n\n const promises = images.map((image) => convertImageToBase64(image));\n const imageUrls = await Promise.all(promises);\n\n const timestamp = new Date().toISOString();\n\n const { skipped_files: skippedFiles, uploaded_files: uploadedFiles } =\n files.length > 0\n ? await uploadFiles({ conversationId: conversationId!, files })\n : { skipped_files: [], uploaded_files: [] };\n\n skippedFiles.forEach((f) => displayErrorToast(f.reason));\n\n const filePrompt = `${t(I18nKey.CHAT_INTERFACE$AUGMENTED_PROMPT_FILES_TITLE)}: ${uploadedFiles.join(\"\\n\\n\")}`;\n const prompt =\n uploadedFiles.length > 0 ? `${content}\\n\\n${filePrompt}` : content;\n\n // Enqueue the message into the local pending queue with status \"sending\"\n // so the user immediately sees it in the chat with a faded treatment. The\n // entry is removed when the WebSocket echoes back the corresponding\n // `UserMessageEvent`. If the API call to send the message fails, the entry\n // is flipped to \"error\" with a retry link.\n const pendingId = enqueuePendingMessage({\n conversationId: conversationId!,\n // `text` is what the user sees in the bubble; `content` is what we\n // actually hand to the server (the prompt may include an appended\n // \"Files uploaded: …\" block) and is what the echo will be matched\n // against. They're different when there are file attachments.\n text: content,\n content: prompt,\n imageUrls,\n fileUrls: uploadedFiles,\n timestamp,\n });\n // Submitting a new prompt should always pull the chat back to the\n // latest message even if the user had scrolled up. This also re-arms\n // autoScroll so the streamed agent reply auto-follows.\n scrollDomToBottom();\n setMessageToSend(\"\");\n\n try {\n await send(\n createChatMessage(prompt, imageUrls, uploadedFiles, timestamp),\n );\n } catch (sendError) {\n const sendErrorMessage =\n sendError instanceof Error\n ? sendError.message\n : t(I18nKey.CHAT_INTERFACE$FAILED_TO_SEND_MESSAGE);\n markPendingMessageError(pendingId, sendErrorMessage);\n }\n };\n\n // Auto-scroll to bottom when new messages arrive — but only if the user is\n // already pinned to the bottom. Scrolling up to load older events also\n // grows `renderableEvents`, and we don't want to yank the user back to the\n // bottom in that case.\n React.useEffect(() => {\n // If a \"load older\" was just triggered, restore the scroll position so\n // the conversation appears to extend upward instead of jumping.\n if (preserveScrollPosition.current && scrollRef.current) {\n const { scrollHeight: prevHeight, scrollTop: prevTop } =\n preserveScrollPosition.current;\n const dom = scrollRef.current;\n const delta = dom.scrollHeight - prevHeight;\n if (delta > 0) {\n dom.scrollTop = prevTop + delta;\n }\n preserveScrollPosition.current = null;\n return;\n }\n\n if (autoScroll) {\n scrollDomToBottom();\n }\n // Note: We intentionally exclude autoScroll from deps because we only want\n // to scroll when message content changes, not when autoScroll state changes.\n }, [\n renderableEvents.length,\n hasPendingUserMessages,\n activeGoalScrollKey,\n scrollDomToBottom,\n ]);\n\n // Auto-load older events when the chat content doesn't overflow the\n // scroll area (no scrollbar to drag, no wheel events past 0). We\n // re-run only when the rendered list grows or `hasMore` flips, NOT\n // when `maybeLoadOlder` re-creates: the underlying hook's `loadOlder`\n // ref changes whenever its internal `isLoading` toggles, so depending\n // on `maybeLoadOlder` would re-fire the effect on every failed page\n // and tight-loop until the server recovered. Driving off\n // `renderableEvents.length` instead means a successful page (events\n // grow) chains the next request, while a failed page (events\n // unchanged) waits for the user to retry.\n const maybeLoadOlderRef = React.useRef(maybeLoadOlder);\n React.useEffect(() => {\n maybeLoadOlderRef.current = maybeLoadOlder;\n });\n React.useEffect(() => {\n const target = scrollRef.current;\n if (!target) return;\n maybeLoadOlderRef.current(target);\n }, [renderableEvents.length, hasMoreOlderEvents]);\n\n // Create a ScrollProvider with the scroll hook values\n const scrollProviderValue = {\n scrollRef,\n autoScroll,\n setAutoScroll,\n scrollDomToBottom,\n hitBottom,\n setHitBottom,\n onChatBodyScroll,\n };\n\n // Get server status indicator props\n const isStartingStatus =\n curAgentState === AgentState.LOADING || curAgentState === AgentState.INIT;\n const isStopStatus = curAgentState === AgentState.STOPPED;\n const isPausing = curAgentState === AgentState.PAUSED;\n const serverStatusColor = getStatusColor({\n isPausing,\n isTask,\n taskStatus,\n isStartingStatus,\n isStopStatus,\n curAgentState,\n });\n const serverStatusText = getStatusText({\n isPausing,\n isTask,\n taskStatus,\n taskDetail,\n isStartingStatus,\n isStopStatus,\n curAgentState,\n errorMessage,\n t,\n });\n\n return (\n <ScrollProvider value={scrollProviderValue}>\n <div\n className=\"relative flex h-full flex-col justify-between px-4\"\n data-testid=\"chat-interface\"\n >\n {!hasSubstantiveAgentActions &&\n !hasPendingUserMessages &&\n !userEventsExist &&\n !hasModelEntries &&\n !isChatLoading &&\n !isProvisioningTask &&\n totalEvents === 0 &&\n !isArchivedConversation &&\n // With no usable LLM the suggestions can't be acted on (the input is\n // disabled). They're also a `pointer-events-auto` overlay that would\n // sit over the LlmNotConfiguredBanner below and swallow clicks on its\n // setup button — so hide them and let the banner be the lone CTA.\n !llmBlocked && (\n <ChatSuggestions\n onSuggestionsClick={(message) => setMessageToSend(message)}\n />\n )}\n {/* Note: We only hide chat suggestions when there's a user message */}\n\n <div\n ref={scrollRef}\n data-testid=\"chat-scroll-container\"\n onScroll={(e) => {\n onChatBodyScroll(e.currentTarget);\n maybeLoadOlder(e.currentTarget);\n }}\n onWheel={handleWheelForPagination}\n className=\"custom-scrollbar-always flex min-h-0 grow flex-col gap-2 overflow-x-hidden overflow-y-auto px-0 pt-4 pb-8 md:px-4\"\n >\n {isChatLoading && isReturningToConversation && (\n <ChatMessagesSkeleton />\n )}\n\n {isChatLoading && !isReturningToConversation && (\n <div className=\"flex justify-center\" data-testid=\"loading-spinner\">\n <LoadingSpinner size=\"small\" />\n </div>\n )}\n\n {isLoadingOlderEvents && (\n <div\n className=\"flex items-center justify-center gap-2 py-3 text-sm text-neutral-400\"\n data-testid=\"loading-older-events\"\n >\n <LoadingSpinner size=\"small\" />\n <span>{t(I18nKey.CHAT_INTERFACE$FETCHING_OLDER_MESSAGES)}</span>\n </div>\n )}\n\n {/*\n * Render whenever there's anything to display. Previously this\n * was gated on `conversationUserEventsExist`, but with the lazy\n * \"50 most recent\" REST fetch the initial window may not include\n * any `source: \"user\"` events (long agent runs between user\n * turns). That left the chat blank, leaving the user nothing to\n * scroll — which is why \"scroll up to load older\" appeared\n * broken. The empty-state ChatSuggestions block above still\n * keeps its own gate (`!userEventsExist && !hasSubstantiveAgentActions`)\n * so brand-new conversations show suggestions, not an empty chat.\n */}\n {/* /model entries created before any event is rendered are\n anchored to `null` and live above the message list. */}\n <ModelMessages conversationId={conversationId} anchorEventId={null} />\n\n {showConversationMessages && renderableEvents.length > 0 && (\n <Messages\n messages={renderableEvents}\n allEvents={allConversationEvents}\n />\n )}\n\n {/*\n Render the local pending-message queue independently so messages\n the user just submitted show up immediately (with a faded \"sending\"\n treatment) even before any real conversation event has come back\n from the server. Entries drain (FIFO) when the matching\n UserMessageEvent echoes back over the WebSocket, so this never\n double-renders alongside the real event list.\n */}\n <PendingUserMessages />\n\n {/* Goal-loop status sits at the end of the message flow — above the\n composer and its typing indicator — so progress stays in view. */}\n <GoalStatusBanner conversationId={conversationId} />\n </div>\n\n <div className=\"flex shrink-0 flex-col gap-[6px] pb-4\">\n <SkillInstallRestartBanner conversationId={conversationId} />\n <BtwMessages conversationId={conversationId} />\n {errorMessage && (\n <ErrorMessageBanner\n message={errorMessage}\n code={errorCode}\n onDismiss={removeErrorMessage}\n onRetry={\n errorMessage === SERVER_CONNECTION_ERROR_MESSAGE\n ? () => conversationWebSocket?.reconnect()\n : undefined\n }\n onReauth={\n isAcpAuthErrorCode(errorCode)\n ? () => navigate(\"/settings/agents\")\n : undefined\n }\n />\n )}\n\n {llmBlocked && !isArchivedConversation && <LlmNotConfiguredBanner />}\n\n {isArchivedConversation ? (\n // Archived / sandbox-error: show a read-only notice in place of\n // the chat input. The conversation history above is still visible.\n <div\n data-testid=\"archived-conversation-banner\"\n className=\"mx-1 px-4 py-3 rounded-lg bg-[var(--oh-surface)] border border-[var(--oh-border-subtle)]\"\n >\n <p className=\"text-xs font-semibold text-[var(--oh-foreground)]\">\n {sandboxStatus === \"ERROR\"\n ? t(I18nKey.CHAT_INTERFACE$ERROR_SANDBOX_TITLE)\n : t(I18nKey.CHAT_INTERFACE$ARCHIVED_SANDBOX_TITLE)}\n </p>\n <p className=\"text-xs text-[var(--oh-muted)] mt-0.5\">\n {sandboxStatus === \"ERROR\"\n ? t(I18nKey.CHAT_INTERFACE$ERROR_SANDBOX_DESCRIPTION)\n : t(I18nKey.CHAT_INTERFACE$ARCHIVED_SANDBOX_DESCRIPTION)}\n </p>\n </div>\n ) : (\n <div className=\"relative\">\n <div className=\"pointer-events-none absolute inset-x-0 bottom-full mb-1 z-20\">\n <div className=\"flex justify-between relative\">\n <div className=\"flex items-end gap-1 pointer-events-auto\">\n <ConfirmationModeEnabled />\n {isStartingStatus && (\n <ChatStatusIndicator\n statusColor={serverStatusColor}\n status={serverStatusText}\n />\n )}\n </div>\n\n {!hitBottom ? (\n <div className=\"absolute left-1/2 transform -translate-x-1/2 bottom-0 pointer-events-auto\">\n <ScrollToBottomButton onClick={scrollDomToBottom} />\n </div>\n ) : (\n curAgentState === AgentState.RUNNING && (\n <div className=\"absolute left-1/2 transform -translate-x-1/2 bottom-0 pointer-events-auto\">\n <TypingIndicator />\n </div>\n )\n )}\n </div>\n </div>\n\n <InteractiveChatBox\n onSubmit={handleSendMessage}\n disabled={isNewConversationPending || llmBlocked}\n hasStartedConversation={hasStartedConversation}\n />\n </div>\n )}\n </div>\n </div>\n </ScrollProvider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,SAAS,GACP,GACA,GACQ;CAGR,OAFI,IAAsB,WACtB,IAAsB,WACnB;AACT;AAEA,SAAgB,KAAgB;CAC9B,IAAM,EAAE,gCAA4B,6BAAyB,GAAY,GACnE,EAAE,wBAAqB,EAAqB,GAC5C,EAAE,iBAAc,cAAW,wBAAoB,uBACnD,GAAqB,GACjB,KAAW,GAAY,GACvB,EAAE,WAAQ,gBAAY,mBAAe,GAAe,GAGpD,IAAqB,GACrB,IAAwB,EAAyB,GACjD,EAAE,aAAS,EAAe,GAC1B,EACJ,qBACA,0BACA,gBACA,+BACA,uBACE,GAAkB,GAChB,KAAwB,GAC3B,MAAU,EAAM,qBACnB,GACM,KAA0B,GAC7B,MAAU,EAAM,uBACnB,GACM,IAAkB,GACrB,MAAU,EAAM,eACnB,GACM,EAAE,SAAM,EA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IAAD,EAAsB,SAAS,EAAoB,CAAA;SAChD,CAAA,CAQJ;;OACF,CAAA,GAEL,kBAAC,IAAD;QACE,UAAU;QACV,UAAU,KAA4B;QACd;OACzB,CAAA,CACE;;KAEJ;;GACF;;CACS,CAAA;AAEpB"}
|
|
1
|
+
{"version":3,"file":"chat-interface.js","names":[],"sources":["../../../../src/components/features/chat/chat-interface.tsx"],"sourcesContent":["import React from \"react\";\nimport { useNavigate } from \"react-router\";\nimport { useTracking } from \"#/hooks/use-tracking\";\nimport { useTranslation } from \"react-i18next\";\nimport { isAcpAuthErrorCode } from \"#/utils/acp-error-codes\";\nimport { convertImageToBase64 } from \"#/utils/convert-image-to-base-64\";\nimport { createChatMessage } from \"#/services/chat-service\";\nimport { BtwMessages } from \"./btw-messages\";\nimport { GoalStatusBanner } from \"./goal-status-banner\";\nimport { ModelMessages } from \"./model-messages\";\nimport { useModelStore } from \"#/stores/model-store\";\nimport { useGoalStore } from \"#/stores/goal-store\";\nimport { InteractiveChatBox } from \"./interactive-chat-box\";\nimport { AgentState } from \"#/types/agent-state\";\nimport { useFilteredEvents } from \"#/hooks/use-filtered-events\";\nimport { useScrollToBottom } from \"#/hooks/use-scroll-to-bottom\";\nimport { useLoadOlderEvents } from \"#/hooks/use-load-older-events\";\nimport { TypingIndicator } from \"./typing-indicator\";\nimport { ChatSuggestions } from \"./chat-suggestions\";\nimport { ScrollProvider } from \"#/context/scroll-context\";\nimport { useInitialQueryStore } from \"#/stores/initial-query-store\";\nimport { useSendMessage } from \"#/hooks/use-send-message\";\nimport { useAgentState } from \"#/hooks/use-agent-state\";\nimport { useIsArchivedConversation } from \"#/hooks/use-is-archived-conversation\";\nimport { useHandleBuildPlanClick } from \"#/hooks/use-handle-build-plan-click\";\n\nimport { ScrollToBottomButton } from \"#/components/shared/buttons/scroll-to-bottom-button\";\nimport { LoadingSpinner } from \"#/components/shared/loading-spinner\";\nimport { ChatMessagesSkeleton } from \"./chat-messages-skeleton\";\nimport { displayErrorToast } from \"#/utils/custom-toast-handlers\";\nimport { useErrorMessageStore } from \"#/stores/error-message-store\";\nimport { useOptimisticUserMessageStore } from \"#/stores/optimistic-user-message-store\";\nimport { SERVER_CONNECTION_ERROR_MESSAGE } from \"#/constants/server-connection-error\";\nimport { ErrorMessageBanner } from \"./error-message-banner\";\nimport { SkillInstallRestartBanner } from \"./skill-install-restart-banner\";\nimport { LlmNotConfiguredBanner } from \"#/components/features/home/llm-not-configured-banner\";\nimport { useLlmConfigured } from \"#/hooks/use-llm-configured\";\nimport { Messages } from \"#/components/conversation-events/chat/messages\";\nimport { PendingUserMessages } from \"./pending-user-messages\";\nimport { useUnifiedUploadFiles } from \"#/hooks/mutation/use-unified-upload-files\";\nimport { validateFiles } from \"#/utils/file-validation\";\nimport { useConversationStore } from \"#/stores/conversation-store\";\nimport ConfirmationModeEnabled from \"./confirmation-mode-enabled\";\nimport { useTaskPolling } from \"#/hooks/query/use-task-polling\";\nimport { matchesPendingConversationId } from \"#/utils/pending-task-message-link\";\nimport { useConversationWebSocket } from \"#/contexts/conversation-websocket-context\";\nimport ChatStatusIndicator from \"./chat-status-indicator\";\nimport { getStatusColor, getStatusText } from \"#/utils/utils\";\nimport { useNewConversationCommand } from \"#/hooks/mutation/use-new-conversation-command\";\nimport { useOptionalConversationId } from \"#/hooks/use-conversation-id\";\nimport { useActiveConversation } from \"#/hooks/query/use-active-conversation\";\nimport { I18nKey } from \"#/i18n/declaration\";\nimport { hasConversationStarted } from \"./components/resolve-picker-kind\";\n\nfunction getEntryPoint(\n hasRepository: boolean | null,\n hasReplayJson: boolean | null,\n): string {\n if (hasRepository) return \"github\";\n if (hasReplayJson) return \"replay\";\n return \"direct\";\n}\n\nexport function ChatInterface() {\n const { trackInitialQuerySubmitted, trackUserMessageSent } = useTracking();\n const { setMessageToSend } = useConversationStore();\n const { errorMessage, errorCode, removeErrorMessage, setErrorMessage } =\n useErrorMessageStore();\n const navigate = useNavigate();\n const { isTask, taskStatus, taskDetail } = useTaskPolling();\n // Hide empty-state chrome for the entire `/conversations/task-{uuid}` route,\n // including the brief READY window before redirect completes.\n const isProvisioningTask = isTask;\n const conversationWebSocket = useConversationWebSocket();\n const { send } = useSendMessage();\n const {\n renderableEvents,\n allConversationEvents,\n totalEvents,\n hasSubstantiveAgentActions,\n userEventsExist,\n } = useFilteredEvents();\n const enqueuePendingMessage = useOptimisticUserMessageStore(\n (state) => state.enqueuePendingMessage,\n );\n const markPendingMessageError = useOptimisticUserMessageStore(\n (state) => state.markPendingMessageError,\n );\n const pendingMessages = useOptimisticUserMessageStore(\n (state) => state.pendingMessages,\n );\n const { t } = useTranslation(\"openhands\");\n const scrollRef = React.useRef<HTMLDivElement>(null);\n const {\n scrollDomToBottom,\n onChatBodyScroll,\n hitBottom,\n autoScroll,\n setAutoScroll,\n setHitBottom,\n } = useScrollToBottom(scrollRef);\n const {\n mutate: newConversationCommand,\n isPending: isNewConversationPending,\n } = useNewConversationCommand();\n\n const { curAgentState } = useAgentState();\n const { handleBuildPlanClick } = useHandleBuildPlanClick();\n\n // Cloud conversations whose sandbox is MISSING or ERROR are read-only:\n // the sandbox is gone and cannot be resumed, so we hide the chat input\n // and show an explanatory banner. For local backends sandbox_status is\n // always null, so this is effectively a no-op for non-cloud use.\n const { data: activeConversation } = useActiveConversation();\n const sandboxStatus = activeConversation?.sandbox_status ?? null;\n const isArchivedConversation = useIsArchivedConversation();\n\n // Block sending in a resumed conversation that has no usable LLM, and show\n // the same setup banner as the home screen so the dead end is explained.\n const { isConfigured: isLlmConfigured, isLoading: isLlmConfigLoading } =\n useLlmConfigured();\n const llmBlocked = !isLlmConfigLoading && !isLlmConfigured;\n\n // Disable Build button while agent is running (streaming)\n const isAgentRunning =\n curAgentState === AgentState.RUNNING ||\n curAgentState === AgentState.LOADING;\n\n // Global keyboard shortcut for Build button (Cmd+Enter / Ctrl+Enter)\n // This is placed here instead of PlanPreview to avoid duplicate listeners\n // when multiple PlanPreview components exist in the chat\n React.useEffect(() => {\n if (isAgentRunning) {\n return undefined;\n }\n\n const handleKeyDown = (event: KeyboardEvent) => {\n // Check for Cmd+Enter (Mac) or Ctrl+Enter (Windows/Linux)\n if ((event.metaKey || event.ctrlKey) && event.key === \"Enter\") {\n event.preventDefault();\n event.stopPropagation();\n handleBuildPlanClick(event);\n scrollDomToBottom();\n }\n };\n\n document.addEventListener(\"keydown\", handleKeyDown);\n\n return () => {\n document.removeEventListener(\"keydown\", handleKeyDown);\n };\n }, [isAgentRunning, handleBuildPlanClick, scrollDomToBottom]);\n\n const { selectedRepository, replayJson } = useInitialQueryStore();\n const { conversationId } = useOptionalConversationId();\n\n // The live goal banner renders in the scroll stream but advances via store\n // updates (in-progress goal events are filtered out of `renderableEvents`),\n // so the bottom-following effect would not react to it. This key changes as\n // an active loop appears and advances each round; feeding it into that effect\n // keeps the banner in view when the user is pinned to the bottom.\n const activeGoalScrollKey = useGoalStore((s) => {\n const goal = conversationId\n ? s.statusByConversation[conversationId]\n : undefined;\n return goal?.active ? `${goal.iteration}:${goal.status}` : null;\n });\n const { mutateAsync: uploadFiles } = useUnifiedUploadFiles();\n\n // Lazy \"scroll up to load older events\" backfill. Initial REST fetch only\n // returns the most recent page; this hook paginates older events into the\n // store on demand so the chat doesn't load (potentially) thousands of\n // events on first render.\n const {\n isLoading: isLoadingOlderEvents,\n hasMore: hasMoreOlderEvents,\n loadOlder,\n } = useLoadOlderEvents(conversationId);\n\n // Trigger `loadOlder` and preserve the visual scroll position once the\n // older page is merged in (otherwise prepending events would jump the\n // chat far down). We fire from three places to cover the cases the\n // browser's scroll event misses:\n //\n // - `onScroll`: normal \"user scrolled near the top\" path.\n // - `onWheel`: user is already pinned at scrollTop=0 and tries to\n // wheel further up — no scroll event fires past 0.\n // - effect: content is shorter than the viewport (no scrollbar\n // at all), so the user has nothing to scroll. Re-runs\n // as more pages arrive until there's overflow or the\n // server runs out of older events.\n const SCROLL_TOP_THRESHOLD_PX = 80;\n const preserveScrollPosition = React.useRef<{\n scrollHeight: number;\n scrollTop: number;\n } | null>(null);\n const maybeLoadOlder = React.useCallback(\n (target: HTMLElement) => {\n if (isProvisioningTask || isLoadingOlderEvents || !hasMoreOlderEvents) {\n return;\n }\n\n const atTop = target.scrollTop <= SCROLL_TOP_THRESHOLD_PX;\n const noOverflow =\n target.scrollHeight <= target.clientHeight + SCROLL_TOP_THRESHOLD_PX;\n if (!atTop && !noOverflow) return;\n\n preserveScrollPosition.current = {\n scrollHeight: target.scrollHeight,\n scrollTop: target.scrollTop,\n };\n loadOlder().catch((error) => {\n preserveScrollPosition.current = null;\n const message =\n error instanceof Error && error.message\n ? error.message\n : t(I18nKey.ERROR$GENERIC);\n setErrorMessage(message);\n });\n },\n [\n hasMoreOlderEvents,\n isLoadingOlderEvents,\n isProvisioningTask,\n loadOlder,\n setErrorMessage,\n t,\n ],\n );\n\n const handleWheelForPagination = React.useCallback(\n (e: React.WheelEvent<HTMLDivElement>) => {\n // Browsers don't dispatch a scroll event when scrollTop is already\n // 0 and the user wheels upward, so onScroll alone misses this case.\n if (e.deltaY < 0 && e.currentTarget.scrollTop <= 0) {\n maybeLoadOlder(e.currentTarget);\n }\n },\n [maybeLoadOlder],\n );\n\n const hasPendingUserMessages = React.useMemo(\n () =>\n conversationId\n ? pendingMessages.some((message) =>\n matchesPendingConversationId(\n conversationId,\n message.conversationId,\n ),\n )\n : false,\n [pendingMessages, conversationId],\n );\n\n const hasModelEntries = useModelStore((s) =>\n conversationId\n ? (s.entriesByConversation[conversationId]?.length ?? 0) > 0\n : false,\n );\n const hasStartedConversation = hasConversationStarted({\n isLoadingHistory: conversationWebSocket?.isLoadingHistory === true,\n hasUserEvents: userEventsExist,\n hasPendingUserMessages,\n hasSubstantiveAgentActions,\n hasModelEntries,\n });\n\n // Show V1 messages immediately if events exist in store (e.g., remount),\n // if the user already has a locally-tracked pending bubble (home-page cloud\n // submit while history/WS catch up), or once loading completes. This\n // replaces the old transition-observation pattern (useState + useEffect\n // watching loading→loaded) which always showed skeleton on remount because\n // local state initialized to false.\n const showConversationMessages =\n allConversationEvents.length > 0 ||\n hasPendingUserMessages ||\n !conversationWebSocket?.isLoadingHistory;\n\n const isReturningToConversation = !!conversationId;\n // Only show loading skeleton when genuinely loading AND no events in store yet.\n // If events exist (e.g., remount after data was already fetched), skip skeleton.\n const isHistoryLoading = !showConversationMessages;\n const isChatLoading = isHistoryLoading && !isTask;\n\n const handleSendMessage = async (\n content: string,\n originalImages: File[],\n originalFiles: File[],\n ) => {\n // Handle /new command for V1 conversations\n if (content.trim() === \"/new\") {\n if (!conversationId) {\n displayErrorToast(t(I18nKey.CONVERSATION$CLEAR_NO_ID));\n return;\n }\n if (totalEvents === 0) {\n displayErrorToast(t(I18nKey.CONVERSATION$CLEAR_EMPTY));\n return;\n }\n if (isNewConversationPending) {\n return;\n }\n newConversationCommand();\n return;\n }\n\n // Create mutable copies of the arrays\n const images = [...originalImages];\n const files = [...originalFiles];\n if (totalEvents === 0) {\n trackInitialQuerySubmitted({\n entryPoint: getEntryPoint(\n selectedRepository !== null,\n replayJson !== null,\n ),\n queryCharacterLength: content.length,\n replayJsonSize: replayJson?.length,\n });\n } else {\n trackUserMessageSent({\n sessionMessageCount: totalEvents,\n currentMessageLength: content.length,\n });\n }\n\n // Validate file sizes before any processing\n const allFiles = [...images, ...files];\n const validation = validateFiles(allFiles);\n\n if (!validation.isValid) {\n displayErrorToast(`Error: ${validation.errorMessage}`);\n return; // Stop processing if validation fails\n }\n\n const promises = images.map((image) => convertImageToBase64(image));\n const imageUrls = await Promise.all(promises);\n\n const timestamp = new Date().toISOString();\n\n const { skipped_files: skippedFiles, uploaded_files: uploadedFiles } =\n files.length > 0\n ? await uploadFiles({ conversationId: conversationId!, files })\n : { skipped_files: [], uploaded_files: [] };\n\n skippedFiles.forEach((f) => displayErrorToast(f.reason));\n\n const filePrompt = `${t(I18nKey.CHAT_INTERFACE$AUGMENTED_PROMPT_FILES_TITLE)}: ${uploadedFiles.join(\"\\n\\n\")}`;\n const prompt =\n uploadedFiles.length > 0 ? `${content}\\n\\n${filePrompt}` : content;\n\n // Enqueue the message into the local pending queue with status \"sending\"\n // so the user immediately sees it in the chat with a faded treatment. The\n // entry is removed when the WebSocket echoes back the corresponding\n // `UserMessageEvent`. If the API call to send the message fails, the entry\n // is flipped to \"error\" with a retry link.\n const pendingId = enqueuePendingMessage({\n conversationId: conversationId!,\n // `text` is what the user sees in the bubble; `content` is what we\n // actually hand to the server (the prompt may include an appended\n // \"Files uploaded: …\" block) and is what the echo will be matched\n // against. They're different when there are file attachments.\n text: content,\n content: prompt,\n imageUrls,\n fileUrls: uploadedFiles,\n timestamp,\n });\n // Submitting a new prompt should always pull the chat back to the\n // latest message even if the user had scrolled up. This also re-arms\n // autoScroll so the streamed agent reply auto-follows.\n scrollDomToBottom();\n setMessageToSend(\"\");\n\n try {\n await send(\n createChatMessage(prompt, imageUrls, uploadedFiles, timestamp),\n );\n } catch (sendError) {\n const sendErrorMessage =\n sendError instanceof Error\n ? sendError.message\n : t(I18nKey.CHAT_INTERFACE$FAILED_TO_SEND_MESSAGE);\n markPendingMessageError(pendingId, sendErrorMessage);\n }\n };\n\n // Auto-scroll to bottom when new messages arrive — but only if the user is\n // already pinned to the bottom. Scrolling up to load older events also\n // grows `renderableEvents`, and we don't want to yank the user back to the\n // bottom in that case.\n React.useEffect(() => {\n // If a \"load older\" was just triggered, restore the scroll position so\n // the conversation appears to extend upward instead of jumping.\n if (preserveScrollPosition.current && scrollRef.current) {\n const { scrollHeight: prevHeight, scrollTop: prevTop } =\n preserveScrollPosition.current;\n const dom = scrollRef.current;\n const delta = dom.scrollHeight - prevHeight;\n if (delta > 0) {\n dom.scrollTop = prevTop + delta;\n }\n preserveScrollPosition.current = null;\n return;\n }\n\n if (autoScroll) {\n scrollDomToBottom();\n }\n // Note: We intentionally exclude autoScroll from deps because we only want\n // to scroll when message content changes, not when autoScroll state changes.\n }, [\n renderableEvents.length,\n hasPendingUserMessages,\n activeGoalScrollKey,\n scrollDomToBottom,\n ]);\n\n // Auto-load older events when the chat content doesn't overflow the\n // scroll area (no scrollbar to drag, no wheel events past 0). We\n // re-run only when the rendered list grows or `hasMore` flips, NOT\n // when `maybeLoadOlder` re-creates: the underlying hook's `loadOlder`\n // ref changes whenever its internal `isLoading` toggles, so depending\n // on `maybeLoadOlder` would re-fire the effect on every failed page\n // and tight-loop until the server recovered. Driving off\n // `renderableEvents.length` instead means a successful page (events\n // grow) chains the next request, while a failed page (events\n // unchanged) waits for the user to retry.\n const maybeLoadOlderRef = React.useRef(maybeLoadOlder);\n React.useEffect(() => {\n maybeLoadOlderRef.current = maybeLoadOlder;\n });\n React.useEffect(() => {\n const target = scrollRef.current;\n if (!target) return;\n maybeLoadOlderRef.current(target);\n }, [renderableEvents.length, hasMoreOlderEvents]);\n\n // Create a ScrollProvider with the scroll hook values\n const scrollProviderValue = {\n scrollRef,\n autoScroll,\n setAutoScroll,\n scrollDomToBottom,\n hitBottom,\n setHitBottom,\n onChatBodyScroll,\n };\n\n // Get server status indicator props\n const isStartingStatus =\n curAgentState === AgentState.LOADING || curAgentState === AgentState.INIT;\n const isStopStatus = curAgentState === AgentState.STOPPED;\n const isPausing = curAgentState === AgentState.PAUSED;\n const serverStatusColor = getStatusColor({\n isPausing,\n isTask,\n taskStatus,\n isStartingStatus,\n isStopStatus,\n curAgentState,\n });\n const serverStatusText = getStatusText({\n isPausing,\n isTask,\n taskStatus,\n taskDetail,\n isStartingStatus,\n isStopStatus,\n curAgentState,\n errorMessage,\n t,\n });\n\n return (\n <ScrollProvider value={scrollProviderValue}>\n <div\n className=\"relative flex h-full flex-col justify-between px-4\"\n data-testid=\"chat-interface\"\n >\n {!hasSubstantiveAgentActions &&\n !hasPendingUserMessages &&\n !userEventsExist &&\n !hasModelEntries &&\n !isChatLoading &&\n !isProvisioningTask &&\n totalEvents === 0 &&\n !isArchivedConversation &&\n // With no usable LLM the suggestions can't be acted on (the input is\n // disabled). They're also a `pointer-events-auto` overlay that would\n // sit over the LlmNotConfiguredBanner below and swallow clicks on its\n // setup button — so hide them and let the banner be the lone CTA.\n !llmBlocked && (\n <ChatSuggestions\n onSuggestionsClick={(message) => setMessageToSend(message)}\n />\n )}\n {/* Note: We only hide chat suggestions when there's a user message */}\n\n <div\n ref={scrollRef}\n data-testid=\"chat-scroll-container\"\n onScroll={(e) => {\n onChatBodyScroll(e.currentTarget);\n maybeLoadOlder(e.currentTarget);\n }}\n onWheel={handleWheelForPagination}\n className=\"custom-scrollbar-always flex min-h-0 grow flex-col gap-2 overflow-x-hidden overflow-y-auto px-0 pt-4 pb-8 md:px-4\"\n >\n {isChatLoading && isReturningToConversation && (\n <ChatMessagesSkeleton />\n )}\n\n {isChatLoading && !isReturningToConversation && (\n <div className=\"flex justify-center\" data-testid=\"loading-spinner\">\n <LoadingSpinner size=\"small\" />\n </div>\n )}\n\n {isLoadingOlderEvents && (\n <div\n className=\"flex items-center justify-center gap-2 py-3 text-sm text-neutral-400\"\n data-testid=\"loading-older-events\"\n >\n <LoadingSpinner size=\"small\" />\n <span>{t(I18nKey.CHAT_INTERFACE$FETCHING_OLDER_MESSAGES)}</span>\n </div>\n )}\n\n {/*\n * Render whenever there's anything to display. Previously this\n * was gated on `conversationUserEventsExist`, but with the lazy\n * \"50 most recent\" REST fetch the initial window may not include\n * any `source: \"user\"` events (long agent runs between user\n * turns). That left the chat blank, leaving the user nothing to\n * scroll — which is why \"scroll up to load older\" appeared\n * broken. The empty-state ChatSuggestions block above still\n * keeps its own gate (`!userEventsExist && !hasSubstantiveAgentActions`)\n * so brand-new conversations show suggestions, not an empty chat.\n */}\n {/* /model entries created before any event is rendered are\n anchored to `null` and live above the message list. */}\n <ModelMessages conversationId={conversationId} anchorEventId={null} />\n\n {showConversationMessages && renderableEvents.length > 0 && (\n <Messages\n messages={renderableEvents}\n allEvents={allConversationEvents}\n />\n )}\n\n {/*\n Render the local pending-message queue independently so messages\n the user just submitted show up immediately (with a faded \"sending\"\n treatment) even before any real conversation event has come back\n from the server. Entries drain (FIFO) when the matching\n UserMessageEvent echoes back over the WebSocket, so this never\n double-renders alongside the real event list.\n */}\n <PendingUserMessages />\n\n {/* Goal-loop status sits at the end of the message flow — above the\n composer and its typing indicator — so progress stays in view. */}\n <GoalStatusBanner conversationId={conversationId} />\n </div>\n\n <div className=\"flex shrink-0 flex-col gap-[6px] pb-4\">\n <SkillInstallRestartBanner conversationId={conversationId} />\n <BtwMessages conversationId={conversationId} />\n {errorMessage && (\n <ErrorMessageBanner\n message={errorMessage}\n code={errorCode}\n onDismiss={removeErrorMessage}\n onRetry={\n errorMessage === SERVER_CONNECTION_ERROR_MESSAGE\n ? () => conversationWebSocket?.reconnect()\n : undefined\n }\n onReauth={\n isAcpAuthErrorCode(errorCode)\n ? () => navigate(\"/settings/agents\")\n : undefined\n }\n />\n )}\n\n {llmBlocked && !isArchivedConversation && <LlmNotConfiguredBanner />}\n\n {isArchivedConversation ? (\n // Archived / sandbox-error: show a read-only notice in place of\n // the chat input. The conversation history above is still visible.\n <div\n data-testid=\"archived-conversation-banner\"\n className=\"mx-1 px-4 py-3 rounded-lg bg-[var(--oh-surface)] border border-[var(--oh-border-subtle)]\"\n >\n <p className=\"text-xs font-semibold text-[var(--oh-foreground)]\">\n {sandboxStatus === \"ERROR\"\n ? t(I18nKey.CHAT_INTERFACE$ERROR_SANDBOX_TITLE)\n : t(I18nKey.CHAT_INTERFACE$ARCHIVED_SANDBOX_TITLE)}\n </p>\n <p className=\"text-xs text-[var(--oh-muted)] mt-0.5\">\n {sandboxStatus === \"ERROR\"\n ? t(I18nKey.CHAT_INTERFACE$ERROR_SANDBOX_DESCRIPTION)\n : t(I18nKey.CHAT_INTERFACE$ARCHIVED_SANDBOX_DESCRIPTION)}\n </p>\n </div>\n ) : (\n <div className=\"relative\">\n <div className=\"pointer-events-none absolute inset-x-0 bottom-full mb-1 z-20\">\n <div className=\"flex justify-between relative\">\n <div className=\"flex items-end gap-1 pointer-events-auto\">\n <ConfirmationModeEnabled />\n {isStartingStatus && (\n <ChatStatusIndicator\n statusColor={serverStatusColor}\n status={serverStatusText}\n />\n )}\n </div>\n\n {!hitBottom ? (\n <div className=\"absolute left-1/2 transform -translate-x-1/2 bottom-0 pointer-events-auto\">\n <ScrollToBottomButton onClick={scrollDomToBottom} />\n </div>\n ) : (\n curAgentState === AgentState.RUNNING && (\n <div className=\"pointer-events-none absolute inset-x-9 bottom-0 flex justify-center\">\n <TypingIndicator events={allConversationEvents} />\n </div>\n )\n )}\n </div>\n </div>\n\n <InteractiveChatBox\n onSubmit={handleSendMessage}\n disabled={isNewConversationPending || llmBlocked}\n hasStartedConversation={hasStartedConversation}\n />\n </div>\n )}\n </div>\n </div>\n </ScrollProvider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,SAAS,GACP,GACA,GACQ;CAGR,OAFI,IAAsB,WACtB,IAAsB,WACnB;AACT;AAEA,SAAgB,KAAgB;CAC9B,IAAM,EAAE,gCAA4B,6BAAyB,GAAY,GACnE,EAAE,yBAAqB,EAAqB,GAC5C,EAAE,iBAAc,cAAW,wBAAoB,uBACnD,EAAqB,GACjB,KAAW,GAAY,GACvB,EAAE,WAAQ,gBAAY,mBAAe,GAAe,GAGpD,IAAqB,GACrB,IAAwB,EAAyB,GACjD,EAAE,aAAS,EAAe,GAC1B,EACJ,qBACA,0BACA,gBACA,+BACA,uBACE,GAAkB,GAChB,KAAwB,GAC3B,MAAU,EAAM,qBACnB,GACM,KAA0B,GAC7B,MAAU,EAAM,uBACnB,GACM,IAAkB,GACrB,MAAU,EAAM,eACnB,GACM,EAAE,SAAM,EAAe,WAAW,GAClC,IAAY,EAAM,OAAuB,IAAI,GAC7C,EACJ,sBACA,qBACA,cACA,eACA,mBACA,qBACE,GAAkB,CAAS,GACzB,EACJ,QAAQ,IACR,WAAW,MACT,GAA0B,GAExB,EAAE,qBAAkB,EAAc,GAClC,EAAE,4BAAyB,GAAwB,GAMnD,EAAE,MAAM,OAAu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
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/react-i18next/dist/es/useTranslation.cjs"),n=require("../../../i18n/declaration.cjs"),r=require("../../../utils/utils.cjs"),i=require("../../shared/buttons/copy-to-clipboard-button.cjs"),a=require("../markdown/markdown-renderer.cjs"),o=require("../../shared/buttons/styled-tooltip.cjs"),s=require("../../shared/text-shimmer.cjs"),c=require("./pending-stop-icon.cjs"),l=require("./user-message-body.cjs");let u=require("react");u=e.__toESM(u,1);let d=require("react/jsx-runtime");function f({type:e,message:f,children:p,actions:m,isFromPlanningAgent:h=!1,pendingStatus:g,onRetry:_,onStop:
|
|
1
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/react-i18next/dist/es/useTranslation.cjs"),n=require("../../../i18n/declaration.cjs"),r=require("../../../utils/utils.cjs"),i=require("../../shared/buttons/copy-to-clipboard-button.cjs"),a=require("../markdown/markdown-renderer.cjs"),o=require("../../shared/buttons/styled-tooltip.cjs"),s=require("../../shared/text-shimmer.cjs"),c=require("./pending-stop-icon.cjs"),l=require("./user-message-body.cjs");let u=require("react");u=e.__toESM(u,1);let d=require("react/jsx-runtime");function f({type:e,message:f,children:p,actions:m,isFromPlanningAgent:h=!1,pendingStatus:g,onRetry:_,onDismiss:v,onStop:y}){let{t:b}=t.useTranslation(`openhands`),[x,S]=u.default.useState(!1),[C,w]=u.default.useState(!1),[T,E]=u.default.useState(!1),[D,O]=u.default.useState(!1),[k,A]=u.default.useState(!0),j=u.default.useRef(null);u.default.useEffect(()=>{E(!1)},[f]);let M=async()=>{await navigator.clipboard.writeText(f),w(!0)};u.default.useEffect(()=>{let e;return C&&(e=setTimeout(()=>{w(!1)},2e3)),()=>{clearTimeout(e)}},[C]);let N=e===`user`&&(g===`error`||g===`sending`),P=g===`sending`&&y!=null,F=P&&x,I=e===`user`&&g==null,L=I&&D&&!T,R=u.default.Children.count(p)>0;u.default.useLayoutEffect(()=>{if(!P||I)return;let e=j.current;if(!e)return;let t=()=>{let t=Number.parseFloat(getComputedStyle(e).lineHeight),n=Number.isFinite(t)&&t>0?t:24;A(e.scrollHeight<=n+1)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[f,P,I]);let z=I?(0,d.jsx)(l.UserMessageBody,{message:f,isHovering:x,isExpanded:T,onTruncatableChange:O}):(0,d.jsx)(`div`,{ref:j,className:`min-w-0 text-sm leading-6 whitespace-normal [word-break:break-word]`,children:(0,d.jsx)(a.MarkdownRenderer,{includeStandard:!0,includeHeadings:!0,allowHtml:e!==`user`,components:l.chatBubbleMarkdownComponents,children:f})}),B=(0,d.jsxs)(`article`,{"data-testid":`${e}-message`,"data-pending-status":g,onMouseEnter:()=>S(!0),onMouseLeave:()=>S(!1),className:r.cn(`rounded-xl relative w-fit max-w-full flex flex-col`,R&&`gap-2`,e===`user`&&`mt-6 bg-tertiary self-end px-4 py-2.5`,e===`agent`&&`mt-6 w-full max-w-full bg-transparent`,h&&e===`agent`&&`border border-[#597ff4] bg-tertiary p-4 mt-2`,g===`error`&&`border border-[var(--oh-status-error)]/40`,!N&&`last:mb-4`),children:[(0,d.jsxs)(`div`,{className:r.cn(`absolute -top-2.5 -right-2.5 z-10`,!x||g===`sending`?`hidden`:`flex`,`items-center gap-1`),onClick:e=>e.stopPropagation(),children:[m?.map((e,t)=>e.tooltip?(0,d.jsx)(o.StyledTooltip,{content:e.tooltip,placement:`top`,children:(0,d.jsx)(`button`,{type:`button`,onClick:e.onClick,className:`button-base p-1 cursor-pointer`,"aria-label":e.tooltip,children:e.icon})},t):(0,d.jsx)(`button`,{type:`button`,onClick:e.onClick,className:`button-base p-1 cursor-pointer`,"aria-label":`Action ${t+1}`,children:e.icon},t)),(0,d.jsx)(i.CopyToClipboardButton,{isHidden:!x,isDisabled:C,onClick:M,mode:C?`copied`:`copy`})]}),z,P?(0,d.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),y?.()},"data-testid":`chat-message-stop`,"aria-label":b(n.I18nKey.BUTTON$STOP),"aria-hidden":!F,tabIndex:F?0:-1,className:r.cn(`group absolute z-10 inline-flex h-7 w-7 cursor-pointer items-center justify-center rounded-full bg-[var(--oh-color-tertiary)] text-[var(--oh-foreground)] transition-opacity duration-150`,k?`right-3 top-1/2 -translate-y-1/2`:`right-3 bottom-2.5`,F?`opacity-100`:`pointer-events-none opacity-0`),children:(0,d.jsx)(c.PendingStopIcon,{className:`block h-7 w-7 max-w-none`})}):null,L?(0,d.jsx)(`button`,{type:`button`,"data-testid":`chat-message-expand`,"aria-expanded":!1,"aria-label":b(n.I18nKey.COMMON$VIEW_MORE),className:`absolute inset-0 z-[1] cursor-pointer rounded-xl border-0 bg-transparent p-0`,onClick:()=>E(!0)}):null,p]});return e===`user`&&g===`error`?(0,d.jsxs)(`div`,{className:`flex w-fit max-w-full flex-col items-end gap-1.5 self-end last:mb-4`,children:[B,(0,d.jsxs)(`div`,{role:`alert`,"data-testid":`chat-message-error`,className:`flex items-center gap-2 text-xs text-[var(--oh-status-error)]`,children:[(0,d.jsx)(`span`,{children:b(n.I18nKey.CHAT_INTERFACE$MESSAGE_SEND_FAILED)}),_?(0,d.jsx)(`button`,{type:`button`,onClick:_,className:`cursor-pointer rounded-md border border-[var(--oh-border)] px-2 py-1 text-xs font-normal text-[var(--oh-foreground)] hover:bg-[var(--oh-interactive-hover)]`,"data-testid":`chat-message-retry`,children:b(n.I18nKey.CHAT_INTERFACE$MESSAGE_RETRY)}):null,v?(0,d.jsx)(`button`,{type:`button`,onClick:v,className:`cursor-pointer rounded-md border border-[var(--oh-border)] px-2 py-1 text-xs font-normal text-[var(--oh-foreground)] hover:bg-[var(--oh-interactive-hover)]`,"data-testid":`chat-message-dismiss`,children:b(n.I18nKey.CHAT_INTERFACE$MESSAGE_DISMISS)}):null]})]}):e===`user`&&g===`sending`?(0,d.jsxs)(`div`,{className:`flex w-full max-w-full flex-col last:mb-4`,children:[B,(0,d.jsx)(`div`,{className:`my-1 w-full py-1 text-sm`,children:(0,d.jsx)(s.TextShimmer,{as:`p`,role:`status`,"aria-live":`polite`,"data-testid":`chat-message-sending`,className:`block w-full text-sm font-normal`,duration:1,spread:2,children:b(n.I18nKey.CHAT_INTERFACE$MESSAGE_SENDING)})})]}):B}exports.ChatMessage=f;
|
|
2
2
|
//# sourceMappingURL=chat-message.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-message.cjs","names":[],"sources":["../../../../src/components/features/chat/chat-message.tsx"],"sourcesContent":["import React from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { cn } from \"#/utils/utils\";\nimport { CopyToClipboardButton } from \"#/components/shared/buttons/copy-to-clipboard-button\";\nimport type { SourceType } from \"#/types/agent-server/core/base/common\";\nimport { StyledTooltip } from \"#/components/shared/buttons/styled-tooltip\";\nimport { I18nKey } from \"#/i18n/declaration\";\nimport { TextShimmer } from \"#/components/shared/text-shimmer\";\nimport { MarkdownRenderer } from \"../markdown/markdown-renderer\";\nimport { PendingStopIcon } from \"./pending-stop-icon\";\nimport {\n UserMessageBody,\n chatBubbleMarkdownComponents,\n USER_MESSAGE_LINE_HEIGHT_PX,\n} from \"./user-message-body\";\n\nexport type ChatMessagePendingStatus = \"sending\" | \"error\";\n\ninterface ChatMessageProps {\n type: SourceType;\n message: string;\n actions?: Array<{\n icon: React.ReactNode;\n onClick: () => void;\n tooltip?: string;\n }>;\n isFromPlanningAgent?: boolean;\n pendingStatus?: ChatMessagePendingStatus;\n onRetry?: () => void;\n onStop?: () => void;\n}\n\nexport function ChatMessage({\n type,\n message,\n children,\n actions,\n isFromPlanningAgent = false,\n pendingStatus,\n onRetry,\n onStop,\n}: React.PropsWithChildren<ChatMessageProps>) {\n const { t } = useTranslation(\"openhands\");\n const [isHovering, setIsHovering] = React.useState(false);\n const [isCopy, setIsCopy] = React.useState(false);\n const [isExpanded, setIsExpanded] = React.useState(false);\n const [isTruncatable, setIsTruncatable] = React.useState(false);\n const [isSingleLinePendingMessage, setIsSingleLinePendingMessage] =\n React.useState(true);\n const pendingMessageContentRef = React.useRef<HTMLDivElement>(null);\n\n React.useEffect(() => {\n setIsExpanded(false);\n }, [message]);\n\n const handleCopyToClipboard = async () => {\n await navigator.clipboard.writeText(message);\n setIsCopy(true);\n };\n\n React.useEffect(() => {\n let timeout: NodeJS.Timeout;\n\n if (isCopy) {\n timeout = setTimeout(() => {\n setIsCopy(false);\n }, 2000);\n }\n\n return () => {\n clearTimeout(timeout);\n };\n }, [isCopy]);\n\n const isPendingUserMessage =\n type === \"user\" &&\n (pendingStatus === \"error\" || pendingStatus === \"sending\");\n const canStopPendingMessage = pendingStatus === \"sending\" && onStop != null;\n const showStopButton = canStopPendingMessage && isHovering;\n const useTruncatedUserBody = type === \"user\" && pendingStatus == null;\n const isCollapsed = useTruncatedUserBody && isTruncatable && !isExpanded;\n const hasBubbleChildren = React.Children.count(children) > 0;\n\n React.useLayoutEffect(() => {\n if (!canStopPendingMessage || useTruncatedUserBody) {\n return undefined;\n }\n\n const content = pendingMessageContentRef.current;\n if (!content) {\n return undefined;\n }\n\n const measure = () => {\n const lineHeight = Number.parseFloat(\n getComputedStyle(content).lineHeight,\n );\n const linePx =\n Number.isFinite(lineHeight) && lineHeight > 0\n ? lineHeight\n : USER_MESSAGE_LINE_HEIGHT_PX;\n\n setIsSingleLinePendingMessage(content.scrollHeight <= linePx + 1);\n };\n\n measure();\n\n const observer = new ResizeObserver(measure);\n observer.observe(content);\n\n return () => observer.disconnect();\n }, [message, canStopPendingMessage, useTruncatedUserBody]);\n\n const messageContent = useTruncatedUserBody ? (\n <UserMessageBody\n message={message}\n isHovering={isHovering}\n isExpanded={isExpanded}\n onTruncatableChange={setIsTruncatable}\n />\n ) : (\n <div\n ref={pendingMessageContentRef}\n className=\"min-w-0 text-sm leading-6 whitespace-normal [word-break:break-word]\"\n >\n <MarkdownRenderer\n includeStandard\n includeHeadings\n allowHtml={type !== \"user\"}\n components={chatBubbleMarkdownComponents}\n >\n {message}\n </MarkdownRenderer>\n </div>\n );\n\n const renderedMessageContent = messageContent;\n\n const messageBubble = (\n <article\n data-testid={`${type}-message`}\n data-pending-status={pendingStatus}\n onMouseEnter={() => setIsHovering(true)}\n onMouseLeave={() => setIsHovering(false)}\n className={cn(\n \"rounded-xl relative w-fit max-w-full flex flex-col\",\n hasBubbleChildren && \"gap-2\",\n type === \"user\" && \"mt-6 bg-tertiary self-end px-4 py-2.5\",\n type === \"agent\" && \"mt-6 w-full max-w-full bg-transparent\",\n isFromPlanningAgent &&\n type === \"agent\" &&\n \"border border-[#597ff4] bg-tertiary p-4 mt-2\",\n pendingStatus === \"error\" &&\n \"border border-[var(--oh-status-error)]/40\",\n !isPendingUserMessage && \"last:mb-4\",\n )}\n >\n <div\n className={cn(\n \"absolute -top-2.5 -right-2.5 z-10\",\n !isHovering || pendingStatus === \"sending\" ? \"hidden\" : \"flex\",\n \"items-center gap-1\",\n )}\n onClick={(event) => event.stopPropagation()}\n >\n {actions?.map((action, index) =>\n action.tooltip ? (\n <StyledTooltip key={index} content={action.tooltip} placement=\"top\">\n <button\n type=\"button\"\n onClick={action.onClick}\n className=\"button-base p-1 cursor-pointer\"\n aria-label={action.tooltip}\n >\n {action.icon}\n </button>\n </StyledTooltip>\n ) : (\n <button\n key={index}\n type=\"button\"\n onClick={action.onClick}\n className=\"button-base p-1 cursor-pointer\"\n aria-label={`Action ${index + 1}`}\n >\n {action.icon}\n </button>\n ),\n )}\n\n <CopyToClipboardButton\n isHidden={!isHovering}\n isDisabled={isCopy}\n onClick={handleCopyToClipboard}\n mode={isCopy ? \"copied\" : \"copy\"}\n />\n </div>\n\n {renderedMessageContent}\n\n {canStopPendingMessage ? (\n <button\n type=\"button\"\n onClick={(event) => {\n event.stopPropagation();\n onStop?.();\n }}\n data-testid=\"chat-message-stop\"\n aria-label={t(I18nKey.BUTTON$STOP)}\n aria-hidden={!showStopButton}\n tabIndex={showStopButton ? 0 : -1}\n className={cn(\n \"group absolute z-10 inline-flex h-7 w-7 cursor-pointer items-center justify-center rounded-full bg-[var(--oh-color-tertiary)] text-[var(--oh-foreground)] transition-opacity duration-150\",\n isSingleLinePendingMessage\n ? \"right-3 top-1/2 -translate-y-1/2\"\n : \"right-3 bottom-2.5\",\n showStopButton ? \"opacity-100\" : \"pointer-events-none opacity-0\",\n )}\n >\n <PendingStopIcon className=\"block h-7 w-7 max-w-none\" />\n </button>\n ) : null}\n\n {isCollapsed ? (\n <button\n type=\"button\"\n data-testid=\"chat-message-expand\"\n aria-expanded={false}\n aria-label={t(I18nKey.COMMON$VIEW_MORE)}\n className=\"absolute inset-0 z-[1] cursor-pointer rounded-xl border-0 bg-transparent p-0\"\n onClick={() => setIsExpanded(true)}\n />\n ) : null}\n\n {children}\n </article>\n );\n\n if (type === \"user\" && pendingStatus === \"error\") {\n return (\n <div className=\"flex w-fit max-w-full flex-col items-end gap-1.5 self-end last:mb-4\">\n {messageBubble}\n <div\n role=\"alert\"\n data-testid=\"chat-message-error\"\n className=\"flex items-center gap-2 text-xs text-[var(--oh-status-error)]\"\n >\n <span>{t(I18nKey.CHAT_INTERFACE$MESSAGE_SEND_FAILED)}</span>\n {onRetry ? (\n <button\n type=\"button\"\n onClick={onRetry}\n className=\"cursor-pointer rounded-md border border-[var(--oh-border)] px-2 py-1 text-xs font-normal text-[var(--oh-foreground)] hover:bg-[var(--oh-interactive-hover)]\"\n data-testid=\"chat-message-retry\"\n >\n {t(I18nKey.CHAT_INTERFACE$MESSAGE_RETRY)}\n </button>\n ) : null}\n </div>\n </div>\n );\n }\n\n if (type === \"user\" && pendingStatus === \"sending\") {\n return (\n <div className=\"flex w-full max-w-full flex-col last:mb-4\">\n {messageBubble}\n <div className=\"my-1 w-full py-1 text-sm\">\n <TextShimmer\n as=\"p\"\n role=\"status\"\n aria-live=\"polite\"\n data-testid=\"chat-message-sending\"\n className=\"block w-full text-sm font-normal\"\n duration={1}\n spread={2}\n >\n {t(I18nKey.CHAT_INTERFACE$MESSAGE_SENDING)}\n </TextShimmer>\n </div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AAU,SACV,cAAY,uBACZ,UAAU,mCACV,SAAU,EACV,OAAQ,WAEP,EAAE,EAAA,QAAQ,8BAA8B,CAC9B,CAAA,CACV,CAAA,CACF,IAIF,CACT"}
|
|
1
|
+
{"version":3,"file":"chat-message.cjs","names":[],"sources":["../../../../src/components/features/chat/chat-message.tsx"],"sourcesContent":["import React from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { cn } from \"#/utils/utils\";\nimport { CopyToClipboardButton } from \"#/components/shared/buttons/copy-to-clipboard-button\";\nimport type { SourceType } from \"#/types/agent-server/core/base/common\";\nimport { StyledTooltip } from \"#/components/shared/buttons/styled-tooltip\";\nimport { I18nKey } from \"#/i18n/declaration\";\nimport { TextShimmer } from \"#/components/shared/text-shimmer\";\nimport { MarkdownRenderer } from \"../markdown/markdown-renderer\";\nimport { PendingStopIcon } from \"./pending-stop-icon\";\nimport {\n UserMessageBody,\n chatBubbleMarkdownComponents,\n USER_MESSAGE_LINE_HEIGHT_PX,\n} from \"./user-message-body\";\n\nexport type ChatMessagePendingStatus = \"sending\" | \"error\";\n\ninterface ChatMessageProps {\n type: SourceType;\n message: string;\n actions?: Array<{\n icon: React.ReactNode;\n onClick: () => void;\n tooltip?: string;\n }>;\n isFromPlanningAgent?: boolean;\n pendingStatus?: ChatMessagePendingStatus;\n onRetry?: () => void;\n onDismiss?: () => void;\n onStop?: () => void;\n}\n\nexport function ChatMessage({\n type,\n message,\n children,\n actions,\n isFromPlanningAgent = false,\n pendingStatus,\n onRetry,\n onDismiss,\n onStop,\n}: React.PropsWithChildren<ChatMessageProps>) {\n const { t } = useTranslation(\"openhands\");\n const [isHovering, setIsHovering] = React.useState(false);\n const [isCopy, setIsCopy] = React.useState(false);\n const [isExpanded, setIsExpanded] = React.useState(false);\n const [isTruncatable, setIsTruncatable] = React.useState(false);\n const [isSingleLinePendingMessage, setIsSingleLinePendingMessage] =\n React.useState(true);\n const pendingMessageContentRef = React.useRef<HTMLDivElement>(null);\n\n React.useEffect(() => {\n setIsExpanded(false);\n }, [message]);\n\n const handleCopyToClipboard = async () => {\n await navigator.clipboard.writeText(message);\n setIsCopy(true);\n };\n\n React.useEffect(() => {\n let timeout: NodeJS.Timeout;\n\n if (isCopy) {\n timeout = setTimeout(() => {\n setIsCopy(false);\n }, 2000);\n }\n\n return () => {\n clearTimeout(timeout);\n };\n }, [isCopy]);\n\n const isPendingUserMessage =\n type === \"user\" &&\n (pendingStatus === \"error\" || pendingStatus === \"sending\");\n const canStopPendingMessage = pendingStatus === \"sending\" && onStop != null;\n const showStopButton = canStopPendingMessage && isHovering;\n const useTruncatedUserBody = type === \"user\" && pendingStatus == null;\n const isCollapsed = useTruncatedUserBody && isTruncatable && !isExpanded;\n const hasBubbleChildren = React.Children.count(children) > 0;\n\n React.useLayoutEffect(() => {\n if (!canStopPendingMessage || useTruncatedUserBody) {\n return undefined;\n }\n\n const content = pendingMessageContentRef.current;\n if (!content) {\n return undefined;\n }\n\n const measure = () => {\n const lineHeight = Number.parseFloat(\n getComputedStyle(content).lineHeight,\n );\n const linePx =\n Number.isFinite(lineHeight) && lineHeight > 0\n ? lineHeight\n : USER_MESSAGE_LINE_HEIGHT_PX;\n\n setIsSingleLinePendingMessage(content.scrollHeight <= linePx + 1);\n };\n\n measure();\n\n const observer = new ResizeObserver(measure);\n observer.observe(content);\n\n return () => observer.disconnect();\n }, [message, canStopPendingMessage, useTruncatedUserBody]);\n\n const messageContent = useTruncatedUserBody ? (\n <UserMessageBody\n message={message}\n isHovering={isHovering}\n isExpanded={isExpanded}\n onTruncatableChange={setIsTruncatable}\n />\n ) : (\n <div\n ref={pendingMessageContentRef}\n className=\"min-w-0 text-sm leading-6 whitespace-normal [word-break:break-word]\"\n >\n <MarkdownRenderer\n includeStandard\n includeHeadings\n allowHtml={type !== \"user\"}\n components={chatBubbleMarkdownComponents}\n >\n {message}\n </MarkdownRenderer>\n </div>\n );\n\n const renderedMessageContent = messageContent;\n\n const messageBubble = (\n <article\n data-testid={`${type}-message`}\n data-pending-status={pendingStatus}\n onMouseEnter={() => setIsHovering(true)}\n onMouseLeave={() => setIsHovering(false)}\n className={cn(\n \"rounded-xl relative w-fit max-w-full flex flex-col\",\n hasBubbleChildren && \"gap-2\",\n type === \"user\" && \"mt-6 bg-tertiary self-end px-4 py-2.5\",\n type === \"agent\" && \"mt-6 w-full max-w-full bg-transparent\",\n isFromPlanningAgent &&\n type === \"agent\" &&\n \"border border-[#597ff4] bg-tertiary p-4 mt-2\",\n pendingStatus === \"error\" &&\n \"border border-[var(--oh-status-error)]/40\",\n !isPendingUserMessage && \"last:mb-4\",\n )}\n >\n <div\n className={cn(\n \"absolute -top-2.5 -right-2.5 z-10\",\n !isHovering || pendingStatus === \"sending\" ? \"hidden\" : \"flex\",\n \"items-center gap-1\",\n )}\n onClick={(event) => event.stopPropagation()}\n >\n {actions?.map((action, index) =>\n action.tooltip ? (\n <StyledTooltip key={index} content={action.tooltip} placement=\"top\">\n <button\n type=\"button\"\n onClick={action.onClick}\n className=\"button-base p-1 cursor-pointer\"\n aria-label={action.tooltip}\n >\n {action.icon}\n </button>\n </StyledTooltip>\n ) : (\n <button\n key={index}\n type=\"button\"\n onClick={action.onClick}\n className=\"button-base p-1 cursor-pointer\"\n aria-label={`Action ${index + 1}`}\n >\n {action.icon}\n </button>\n ),\n )}\n\n <CopyToClipboardButton\n isHidden={!isHovering}\n isDisabled={isCopy}\n onClick={handleCopyToClipboard}\n mode={isCopy ? \"copied\" : \"copy\"}\n />\n </div>\n\n {renderedMessageContent}\n\n {canStopPendingMessage ? (\n <button\n type=\"button\"\n onClick={(event) => {\n event.stopPropagation();\n onStop?.();\n }}\n data-testid=\"chat-message-stop\"\n aria-label={t(I18nKey.BUTTON$STOP)}\n aria-hidden={!showStopButton}\n tabIndex={showStopButton ? 0 : -1}\n className={cn(\n \"group absolute z-10 inline-flex h-7 w-7 cursor-pointer items-center justify-center rounded-full bg-[var(--oh-color-tertiary)] text-[var(--oh-foreground)] transition-opacity duration-150\",\n isSingleLinePendingMessage\n ? \"right-3 top-1/2 -translate-y-1/2\"\n : \"right-3 bottom-2.5\",\n showStopButton ? \"opacity-100\" : \"pointer-events-none opacity-0\",\n )}\n >\n <PendingStopIcon className=\"block h-7 w-7 max-w-none\" />\n </button>\n ) : null}\n\n {isCollapsed ? (\n <button\n type=\"button\"\n data-testid=\"chat-message-expand\"\n aria-expanded={false}\n aria-label={t(I18nKey.COMMON$VIEW_MORE)}\n className=\"absolute inset-0 z-[1] cursor-pointer rounded-xl border-0 bg-transparent p-0\"\n onClick={() => setIsExpanded(true)}\n />\n ) : null}\n\n {children}\n </article>\n );\n\n if (type === \"user\" && pendingStatus === \"error\") {\n return (\n <div className=\"flex w-fit max-w-full flex-col items-end gap-1.5 self-end last:mb-4\">\n {messageBubble}\n <div\n role=\"alert\"\n data-testid=\"chat-message-error\"\n className=\"flex items-center gap-2 text-xs text-[var(--oh-status-error)]\"\n >\n <span>{t(I18nKey.CHAT_INTERFACE$MESSAGE_SEND_FAILED)}</span>\n {onRetry ? (\n <button\n type=\"button\"\n onClick={onRetry}\n className=\"cursor-pointer rounded-md border border-[var(--oh-border)] px-2 py-1 text-xs font-normal text-[var(--oh-foreground)] hover:bg-[var(--oh-interactive-hover)]\"\n data-testid=\"chat-message-retry\"\n >\n {t(I18nKey.CHAT_INTERFACE$MESSAGE_RETRY)}\n </button>\n ) : null}\n {onDismiss ? (\n <button\n type=\"button\"\n onClick={onDismiss}\n className=\"cursor-pointer rounded-md border border-[var(--oh-border)] px-2 py-1 text-xs font-normal text-[var(--oh-foreground)] hover:bg-[var(--oh-interactive-hover)]\"\n data-testid=\"chat-message-dismiss\"\n >\n {t(I18nKey.CHAT_INTERFACE$MESSAGE_DISMISS)}\n </button>\n ) : null}\n </div>\n </div>\n );\n }\n\n if (type === \"user\" && pendingStatus === \"sending\") {\n return (\n <div className=\"flex w-full max-w-full flex-col last:mb-4\">\n {messageBubble}\n <div className=\"my-1 w-full py-1 text-sm\">\n <TextShimmer\n as=\"p\"\n role=\"status\"\n aria-live=\"polite\"\n data-testid=\"chat-message-sending\"\n className=\"block w-full text-sm font-normal\"\n duration={1}\n spread={2}\n >\n {t(I18nKey.CHAT_INTERFACE$MESSAGE_SENDING)}\n </TextShimmer>\n </div>\n </div>\n );\n }\n\n return messageBubble;\n}\n"],"mappings":"2jBAiCA,SAAgB,EAAY,CAC1B,OACA,UACA,WACA,UACA,sBAAsB,GACtB,gBACA,UACA,YACA,UAC4C,CAC5C,GAAM,CAAE,KAAM,EAAA,eAAe,WAAW,EAClC,CAAC,EAAY,GAAiB,EAAA,QAAM,SAAS,EAAK,EAClD,CAAC,EAAQ,GAAa,EAAA,QAAM,SAAS,EAAK,EAC1C,CAAC,EAAY,GAAiB,EAAA,QAAM,SAAS,EAAK,EAClD,CAAC,EAAe,GAAoB,EAAA,QAAM,SAAS,EAAK,EACxD,CAAC,EAA4B,GACjC,EAAA,QAAM,SAAS,EAAI,EACf,EAA2B,EAAA,QAAM,OAAuB,IAAI,EAElE,EAAA,QAAM,cAAgB,CACpB,EAAc,EAAK,CACrB,EAAG,CAAC,CAAO,CAAC,EAEZ,IAAM,EAAwB,SAAY,CACxC,MAAM,UAAU,UAAU,UAAU,CAAO,EAC3C,EAAU,EAAI,CAChB,EAEA,EAAA,QAAM,cAAgB,CACpB,IAAI,EAQJ,OANI,IACF,EAAU,eAAiB,CACzB,EAAU,EAAK,CACjB,EAAG,GAAI,OAGI,CACX,aAAa,CAAO,CACtB,CACF,EAAG,CAAC,CAAM,CAAC,EAEX,IAAM,EACJ,IAAS,SACR,IAAkB,SAAW,IAAkB,WAC5C,EAAwB,IAAkB,WAAa,GAAU,KACjE,EAAiB,GAAyB,EAC1C,EAAuB,IAAS,QAAU,GAAiB,KAC3D,EAAc,GAAwB,GAAiB,CAAC,EACxD,EAAoB,EAAA,QAAM,SAAS,MAAM,CAAQ,EAAI,EAE3D,EAAA,QAAM,oBAAsB,CAC1B,GAAI,CAAC,GAAyB,EAC5B,OAGF,IAAM,E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CACE,KAAK,SACL,QAAS,EACT,UAAU,8JACV,cAAY,gCAEX,EAAE,EAAA,QAAQ,8BAA8B,CACnC,CAAA,EACN,IACD,GACF,IAIL,IAAS,QAAU,IAAkB,WAErC,EAAA,EAAA,MAAC,MAAD,CAAK,UAAU,qDAAf,CACG,GACD,EAAA,EAAA,KAAC,MAAD,CAAK,UAAU,qCACb,EAAA,EAAA,KAAC,EAAA,YAAD,CACE,GAAG,IACH,KAAK,SACL,YAAU,SACV,cAAY,uBACZ,UAAU,mCACV,SAAU,EACV,OAAQ,WAEP,EAAE,EAAA,QAAQ,8BAA8B,CAC9B,CAAA,CACV,CAAA,CACF,IAIF,CACT"}
|
|
@@ -12,7 +12,8 @@ interface ChatMessageProps {
|
|
|
12
12
|
isFromPlanningAgent?: boolean;
|
|
13
13
|
pendingStatus?: ChatMessagePendingStatus;
|
|
14
14
|
onRetry?: () => void;
|
|
15
|
+
onDismiss?: () => void;
|
|
15
16
|
onStop?: () => void;
|
|
16
17
|
}
|
|
17
|
-
export declare function ChatMessage({ type, message, children, actions, isFromPlanningAgent, pendingStatus, onRetry, onStop, }: React.PropsWithChildren<ChatMessageProps>): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare function ChatMessage({ type, message, children, actions, isFromPlanningAgent, pendingStatus, onRetry, onDismiss, onStop, }: React.PropsWithChildren<ChatMessageProps>): import("react/jsx-runtime").JSX.Element;
|
|
18
19
|
export {};
|
|
@@ -10,46 +10,46 @@ import { UserMessageBody as c, chatBubbleMarkdownComponents as l } from "./user-
|
|
|
10
10
|
import u from "react";
|
|
11
11
|
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
12
12
|
//#region src/components/features/chat/chat-message.tsx
|
|
13
|
-
function p({ type: p, message: m, children: h, actions: g, isFromPlanningAgent: _ = !1, pendingStatus: v, onRetry: y,
|
|
14
|
-
let { t:
|
|
13
|
+
function p({ type: p, message: m, children: h, actions: g, isFromPlanningAgent: _ = !1, pendingStatus: v, onRetry: y, onDismiss: b, onStop: x }) {
|
|
14
|
+
let { t: S } = e("openhands"), [C, w] = u.useState(!1), [T, E] = u.useState(!1), [D, O] = u.useState(!1), [k, A] = u.useState(!1), [j, M] = u.useState(!0), N = u.useRef(null);
|
|
15
15
|
u.useEffect(() => {
|
|
16
|
-
|
|
16
|
+
O(!1);
|
|
17
17
|
}, [m]);
|
|
18
|
-
let
|
|
19
|
-
await navigator.clipboard.writeText(m),
|
|
18
|
+
let P = async () => {
|
|
19
|
+
await navigator.clipboard.writeText(m), E(!0);
|
|
20
20
|
};
|
|
21
21
|
u.useEffect(() => {
|
|
22
22
|
let e;
|
|
23
|
-
return
|
|
24
|
-
|
|
23
|
+
return T && (e = setTimeout(() => {
|
|
24
|
+
E(!1);
|
|
25
25
|
}, 2e3)), () => {
|
|
26
26
|
clearTimeout(e);
|
|
27
27
|
};
|
|
28
|
-
}, [
|
|
29
|
-
let
|
|
28
|
+
}, [T]);
|
|
29
|
+
let F = p === "user" && (v === "error" || v === "sending"), I = v === "sending" && x != null, L = I && C, R = p === "user" && v == null, z = R && k && !D, B = u.Children.count(h) > 0;
|
|
30
30
|
u.useLayoutEffect(() => {
|
|
31
|
-
if (!
|
|
32
|
-
let e =
|
|
31
|
+
if (!I || R) return;
|
|
32
|
+
let e = N.current;
|
|
33
33
|
if (!e) return;
|
|
34
34
|
let t = () => {
|
|
35
35
|
let t = Number.parseFloat(getComputedStyle(e).lineHeight), n = Number.isFinite(t) && t > 0 ? t : 24;
|
|
36
|
-
|
|
36
|
+
M(e.scrollHeight <= n + 1);
|
|
37
37
|
};
|
|
38
38
|
t();
|
|
39
39
|
let n = new ResizeObserver(t);
|
|
40
40
|
return n.observe(e), () => n.disconnect();
|
|
41
41
|
}, [
|
|
42
42
|
m,
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
I,
|
|
44
|
+
R
|
|
45
45
|
]);
|
|
46
|
-
let
|
|
46
|
+
let V = R ? /* @__PURE__ */ d(c, {
|
|
47
47
|
message: m,
|
|
48
|
-
isHovering:
|
|
49
|
-
isExpanded:
|
|
50
|
-
onTruncatableChange:
|
|
48
|
+
isHovering: C,
|
|
49
|
+
isExpanded: D,
|
|
50
|
+
onTruncatableChange: A
|
|
51
51
|
}) : /* @__PURE__ */ d("div", {
|
|
52
|
-
ref:
|
|
52
|
+
ref: N,
|
|
53
53
|
className: "min-w-0 text-sm leading-6 whitespace-normal [word-break:break-word]",
|
|
54
54
|
children: /* @__PURE__ */ d(i, {
|
|
55
55
|
includeStandard: !0,
|
|
@@ -58,15 +58,15 @@ function p({ type: p, message: m, children: h, actions: g, isFromPlanningAgent:
|
|
|
58
58
|
components: l,
|
|
59
59
|
children: m
|
|
60
60
|
})
|
|
61
|
-
}),
|
|
61
|
+
}), H = /* @__PURE__ */ f("article", {
|
|
62
62
|
"data-testid": `${p}-message`,
|
|
63
63
|
"data-pending-status": v,
|
|
64
|
-
onMouseEnter: () =>
|
|
65
|
-
onMouseLeave: () =>
|
|
66
|
-
className: n("rounded-xl relative w-fit max-w-full flex flex-col",
|
|
64
|
+
onMouseEnter: () => w(!0),
|
|
65
|
+
onMouseLeave: () => w(!1),
|
|
66
|
+
className: n("rounded-xl relative w-fit max-w-full flex flex-col", B && "gap-2", p === "user" && "mt-6 bg-tertiary self-end px-4 py-2.5", p === "agent" && "mt-6 w-full max-w-full bg-transparent", _ && p === "agent" && "border border-[#597ff4] bg-tertiary p-4 mt-2", v === "error" && "border border-[var(--oh-status-error)]/40", !F && "last:mb-4"),
|
|
67
67
|
children: [
|
|
68
68
|
/* @__PURE__ */ f("div", {
|
|
69
|
-
className: n("absolute -top-2.5 -right-2.5 z-10", !
|
|
69
|
+
className: n("absolute -top-2.5 -right-2.5 z-10", !C || v === "sending" ? "hidden" : "flex", "items-center gap-1"),
|
|
70
70
|
onClick: (e) => e.stopPropagation(),
|
|
71
71
|
children: [g?.map((e, t) => e.tooltip ? /* @__PURE__ */ d(a, {
|
|
72
72
|
content: e.tooltip,
|
|
@@ -85,53 +85,63 @@ function p({ type: p, message: m, children: h, actions: g, isFromPlanningAgent:
|
|
|
85
85
|
"aria-label": `Action ${t + 1}`,
|
|
86
86
|
children: e.icon
|
|
87
87
|
}, t)), /* @__PURE__ */ d(r, {
|
|
88
|
-
isHidden: !
|
|
89
|
-
isDisabled:
|
|
90
|
-
onClick:
|
|
91
|
-
mode:
|
|
88
|
+
isHidden: !C,
|
|
89
|
+
isDisabled: T,
|
|
90
|
+
onClick: P,
|
|
91
|
+
mode: T ? "copied" : "copy"
|
|
92
92
|
})]
|
|
93
93
|
}),
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
V,
|
|
95
|
+
I ? /* @__PURE__ */ d("button", {
|
|
96
96
|
type: "button",
|
|
97
97
|
onClick: (e) => {
|
|
98
|
-
e.stopPropagation(),
|
|
98
|
+
e.stopPropagation(), x?.();
|
|
99
99
|
},
|
|
100
100
|
"data-testid": "chat-message-stop",
|
|
101
|
-
"aria-label":
|
|
102
|
-
"aria-hidden": !
|
|
103
|
-
tabIndex:
|
|
104
|
-
className: n("group absolute z-10 inline-flex h-7 w-7 cursor-pointer items-center justify-center rounded-full bg-[var(--oh-color-tertiary)] text-[var(--oh-foreground)] transition-opacity duration-150",
|
|
101
|
+
"aria-label": S(t.BUTTON$STOP),
|
|
102
|
+
"aria-hidden": !L,
|
|
103
|
+
tabIndex: L ? 0 : -1,
|
|
104
|
+
className: n("group absolute z-10 inline-flex h-7 w-7 cursor-pointer items-center justify-center rounded-full bg-[var(--oh-color-tertiary)] text-[var(--oh-foreground)] transition-opacity duration-150", j ? "right-3 top-1/2 -translate-y-1/2" : "right-3 bottom-2.5", L ? "opacity-100" : "pointer-events-none opacity-0"),
|
|
105
105
|
children: /* @__PURE__ */ d(s, { className: "block h-7 w-7 max-w-none" })
|
|
106
106
|
}) : null,
|
|
107
|
-
|
|
107
|
+
z ? /* @__PURE__ */ d("button", {
|
|
108
108
|
type: "button",
|
|
109
109
|
"data-testid": "chat-message-expand",
|
|
110
110
|
"aria-expanded": !1,
|
|
111
|
-
"aria-label":
|
|
111
|
+
"aria-label": S(t.COMMON$VIEW_MORE),
|
|
112
112
|
className: "absolute inset-0 z-[1] cursor-pointer rounded-xl border-0 bg-transparent p-0",
|
|
113
|
-
onClick: () =>
|
|
113
|
+
onClick: () => O(!0)
|
|
114
114
|
}) : null,
|
|
115
115
|
h
|
|
116
116
|
]
|
|
117
117
|
});
|
|
118
118
|
return p === "user" && v === "error" ? /* @__PURE__ */ f("div", {
|
|
119
119
|
className: "flex w-fit max-w-full flex-col items-end gap-1.5 self-end last:mb-4",
|
|
120
|
-
children: [
|
|
120
|
+
children: [H, /* @__PURE__ */ f("div", {
|
|
121
121
|
role: "alert",
|
|
122
122
|
"data-testid": "chat-message-error",
|
|
123
123
|
className: "flex items-center gap-2 text-xs text-[var(--oh-status-error)]",
|
|
124
|
-
children: [
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
124
|
+
children: [
|
|
125
|
+
/* @__PURE__ */ d("span", { children: S(t.CHAT_INTERFACE$MESSAGE_SEND_FAILED) }),
|
|
126
|
+
y ? /* @__PURE__ */ d("button", {
|
|
127
|
+
type: "button",
|
|
128
|
+
onClick: y,
|
|
129
|
+
className: "cursor-pointer rounded-md border border-[var(--oh-border)] px-2 py-1 text-xs font-normal text-[var(--oh-foreground)] hover:bg-[var(--oh-interactive-hover)]",
|
|
130
|
+
"data-testid": "chat-message-retry",
|
|
131
|
+
children: S(t.CHAT_INTERFACE$MESSAGE_RETRY)
|
|
132
|
+
}) : null,
|
|
133
|
+
b ? /* @__PURE__ */ d("button", {
|
|
134
|
+
type: "button",
|
|
135
|
+
onClick: b,
|
|
136
|
+
className: "cursor-pointer rounded-md border border-[var(--oh-border)] px-2 py-1 text-xs font-normal text-[var(--oh-foreground)] hover:bg-[var(--oh-interactive-hover)]",
|
|
137
|
+
"data-testid": "chat-message-dismiss",
|
|
138
|
+
children: S(t.CHAT_INTERFACE$MESSAGE_DISMISS)
|
|
139
|
+
}) : null
|
|
140
|
+
]
|
|
131
141
|
})]
|
|
132
142
|
}) : p === "user" && v === "sending" ? /* @__PURE__ */ f("div", {
|
|
133
143
|
className: "flex w-full max-w-full flex-col last:mb-4",
|
|
134
|
-
children: [
|
|
144
|
+
children: [H, /* @__PURE__ */ d("div", {
|
|
135
145
|
className: "my-1 w-full py-1 text-sm",
|
|
136
146
|
children: /* @__PURE__ */ d(o, {
|
|
137
147
|
as: "p",
|
|
@@ -141,10 +151,10 @@ function p({ type: p, message: m, children: h, actions: g, isFromPlanningAgent:
|
|
|
141
151
|
className: "block w-full text-sm font-normal",
|
|
142
152
|
duration: 1,
|
|
143
153
|
spread: 2,
|
|
144
|
-
children:
|
|
154
|
+
children: S(t.CHAT_INTERFACE$MESSAGE_SENDING)
|
|
145
155
|
})
|
|
146
156
|
})]
|
|
147
|
-
}) :
|
|
157
|
+
}) : H;
|
|
148
158
|
}
|
|
149
159
|
//#endregion
|
|
150
160
|
export { p as ChatMessage };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-message.js","names":[],"sources":["../../../../src/components/features/chat/chat-message.tsx"],"sourcesContent":["import React from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { cn } from \"#/utils/utils\";\nimport { CopyToClipboardButton } from \"#/components/shared/buttons/copy-to-clipboard-button\";\nimport type { SourceType } from \"#/types/agent-server/core/base/common\";\nimport { StyledTooltip } from \"#/components/shared/buttons/styled-tooltip\";\nimport { I18nKey } from \"#/i18n/declaration\";\nimport { TextShimmer } from \"#/components/shared/text-shimmer\";\nimport { MarkdownRenderer } from \"../markdown/markdown-renderer\";\nimport { PendingStopIcon } from \"./pending-stop-icon\";\nimport {\n UserMessageBody,\n chatBubbleMarkdownComponents,\n USER_MESSAGE_LINE_HEIGHT_PX,\n} from \"./user-message-body\";\n\nexport type ChatMessagePendingStatus = \"sending\" | \"error\";\n\ninterface ChatMessageProps {\n type: SourceType;\n message: string;\n actions?: Array<{\n icon: React.ReactNode;\n onClick: () => void;\n tooltip?: string;\n }>;\n isFromPlanningAgent?: boolean;\n pendingStatus?: ChatMessagePendingStatus;\n onRetry?: () => void;\n onStop?: () => void;\n}\n\nexport function ChatMessage({\n type,\n message,\n children,\n actions,\n isFromPlanningAgent = false,\n pendingStatus,\n onRetry,\n onStop,\n}: React.PropsWithChildren<ChatMessageProps>) {\n const { t } = useTranslation(\"openhands\");\n const [isHovering, setIsHovering] = React.useState(false);\n const [isCopy, setIsCopy] = React.useState(false);\n const [isExpanded, setIsExpanded] = React.useState(false);\n const [isTruncatable, setIsTruncatable] = React.useState(false);\n const [isSingleLinePendingMessage, setIsSingleLinePendingMessage] =\n React.useState(true);\n const pendingMessageContentRef = React.useRef<HTMLDivElement>(null);\n\n React.useEffect(() => {\n setIsExpanded(false);\n }, [message]);\n\n const handleCopyToClipboard = async () => {\n await navigator.clipboard.writeText(message);\n setIsCopy(true);\n };\n\n React.useEffect(() => {\n let timeout: NodeJS.Timeout;\n\n if (isCopy) {\n timeout = setTimeout(() => {\n setIsCopy(false);\n }, 2000);\n }\n\n return () => {\n clearTimeout(timeout);\n };\n }, [isCopy]);\n\n const isPendingUserMessage =\n type === \"user\" &&\n (pendingStatus === \"error\" || pendingStatus === \"sending\");\n const canStopPendingMessage = pendingStatus === \"sending\" && onStop != null;\n const showStopButton = canStopPendingMessage && isHovering;\n const useTruncatedUserBody = type === \"user\" && pendingStatus == null;\n const isCollapsed = useTruncatedUserBody && isTruncatable && !isExpanded;\n const hasBubbleChildren = React.Children.count(children) > 0;\n\n React.useLayoutEffect(() => {\n if (!canStopPendingMessage || useTruncatedUserBody) {\n return undefined;\n }\n\n const content = pendingMessageContentRef.current;\n if (!content) {\n return undefined;\n }\n\n const measure = () => {\n const lineHeight = Number.parseFloat(\n getComputedStyle(content).lineHeight,\n );\n const linePx =\n Number.isFinite(lineHeight) && lineHeight > 0\n ? lineHeight\n : USER_MESSAGE_LINE_HEIGHT_PX;\n\n setIsSingleLinePendingMessage(content.scrollHeight <= linePx + 1);\n };\n\n measure();\n\n const observer = new ResizeObserver(measure);\n observer.observe(content);\n\n return () => observer.disconnect();\n }, [message, canStopPendingMessage, useTruncatedUserBody]);\n\n const messageContent = useTruncatedUserBody ? (\n <UserMessageBody\n message={message}\n isHovering={isHovering}\n isExpanded={isExpanded}\n onTruncatableChange={setIsTruncatable}\n />\n ) : (\n <div\n ref={pendingMessageContentRef}\n className=\"min-w-0 text-sm leading-6 whitespace-normal [word-break:break-word]\"\n >\n <MarkdownRenderer\n includeStandard\n includeHeadings\n allowHtml={type !== \"user\"}\n components={chatBubbleMarkdownComponents}\n >\n {message}\n </MarkdownRenderer>\n </div>\n );\n\n const renderedMessageContent = messageContent;\n\n const messageBubble = (\n <article\n data-testid={`${type}-message`}\n data-pending-status={pendingStatus}\n onMouseEnter={() => setIsHovering(true)}\n onMouseLeave={() => setIsHovering(false)}\n className={cn(\n \"rounded-xl relative w-fit max-w-full flex flex-col\",\n hasBubbleChildren && \"gap-2\",\n type === \"user\" && \"mt-6 bg-tertiary self-end px-4 py-2.5\",\n type === \"agent\" && \"mt-6 w-full max-w-full bg-transparent\",\n isFromPlanningAgent &&\n type === \"agent\" &&\n \"border border-[#597ff4] bg-tertiary p-4 mt-2\",\n pendingStatus === \"error\" &&\n \"border border-[var(--oh-status-error)]/40\",\n !isPendingUserMessage && \"last:mb-4\",\n )}\n >\n <div\n className={cn(\n \"absolute -top-2.5 -right-2.5 z-10\",\n !isHovering || pendingStatus === \"sending\" ? \"hidden\" : \"flex\",\n \"items-center gap-1\",\n )}\n onClick={(event) => event.stopPropagation()}\n >\n {actions?.map((action, index) =>\n action.tooltip ? (\n <StyledTooltip key={index} content={action.tooltip} placement=\"top\">\n <button\n type=\"button\"\n onClick={action.onClick}\n className=\"button-base p-1 cursor-pointer\"\n aria-label={action.tooltip}\n >\n {action.icon}\n </button>\n </StyledTooltip>\n ) : (\n <button\n key={index}\n type=\"button\"\n onClick={action.onClick}\n className=\"button-base p-1 cursor-pointer\"\n aria-label={`Action ${index + 1}`}\n >\n {action.icon}\n </button>\n ),\n )}\n\n <CopyToClipboardButton\n isHidden={!isHovering}\n isDisabled={isCopy}\n onClick={handleCopyToClipboard}\n mode={isCopy ? \"copied\" : \"copy\"}\n />\n </div>\n\n {renderedMessageContent}\n\n {canStopPendingMessage ? (\n <button\n type=\"button\"\n onClick={(event) => {\n event.stopPropagation();\n onStop?.();\n }}\n data-testid=\"chat-message-stop\"\n aria-label={t(I18nKey.BUTTON$STOP)}\n aria-hidden={!showStopButton}\n tabIndex={showStopButton ? 0 : -1}\n className={cn(\n \"group absolute z-10 inline-flex h-7 w-7 cursor-pointer items-center justify-center rounded-full bg-[var(--oh-color-tertiary)] text-[var(--oh-foreground)] transition-opacity duration-150\",\n isSingleLinePendingMessage\n ? \"right-3 top-1/2 -translate-y-1/2\"\n : \"right-3 bottom-2.5\",\n showStopButton ? \"opacity-100\" : \"pointer-events-none opacity-0\",\n )}\n >\n <PendingStopIcon className=\"block h-7 w-7 max-w-none\" />\n </button>\n ) : null}\n\n {isCollapsed ? (\n <button\n type=\"button\"\n data-testid=\"chat-message-expand\"\n aria-expanded={false}\n aria-label={t(I18nKey.COMMON$VIEW_MORE)}\n className=\"absolute inset-0 z-[1] cursor-pointer rounded-xl border-0 bg-transparent p-0\"\n onClick={() => setIsExpanded(true)}\n />\n ) : null}\n\n {children}\n </article>\n );\n\n if (type === \"user\" && pendingStatus === \"error\") {\n return (\n <div className=\"flex w-fit max-w-full flex-col items-end gap-1.5 self-end last:mb-4\">\n {messageBubble}\n <div\n role=\"alert\"\n data-testid=\"chat-message-error\"\n className=\"flex items-center gap-2 text-xs text-[var(--oh-status-error)]\"\n >\n <span>{t(I18nKey.CHAT_INTERFACE$MESSAGE_SEND_FAILED)}</span>\n {onRetry ? (\n <button\n type=\"button\"\n onClick={onRetry}\n className=\"cursor-pointer rounded-md border border-[var(--oh-border)] px-2 py-1 text-xs font-normal text-[var(--oh-foreground)] hover:bg-[var(--oh-interactive-hover)]\"\n data-testid=\"chat-message-retry\"\n >\n {t(I18nKey.CHAT_INTERFACE$MESSAGE_RETRY)}\n </button>\n ) : null}\n </div>\n </div>\n );\n }\n\n if (type === \"user\" && pendingStatus === \"sending\") {\n return (\n <div className=\"flex w-full max-w-full flex-col last:mb-4\">\n {messageBubble}\n <div className=\"my-1 w-full py-1 text-sm\">\n <TextShimmer\n as=\"p\"\n role=\"status\"\n aria-live=\"polite\"\n data-testid=\"chat-message-sending\"\n className=\"block w-full text-sm font-normal\"\n duration={1}\n spread={2}\n >\n {t(I18nKey.CHAT_INTERFACE$MESSAGE_SENDING)}\n </TextShimmer>\n </div>\n </div>\n );\n }\n\n return messageBubble;\n}\n"],"mappings":";;;;;;;;;;;;AAgCA,SAAgB,EAAY,EAC1B,SACA,YACA,aACA,YACA,yBAAsB,IACtB,kBACA,YACA,aAC4C;CAC5C,IAAM,EAAE,SAAM,EAAe,WAAW,GAClC,CAAC,GAAY,KAAiB,EAAM,SAAS,EAAK,GAClD,CAAC,GAAQ,KAAa,EAAM,SAAS,EAAK,GAC1C,CAAC,GAAY,KAAiB,EAAM,SAAS,EAAK,GAClD,CAAC,GAAe,KAAoB,EAAM,SAAS,EAAK,GACxD,CAAC,GAA4B,KACjC,EAAM,SAAS,EAAI,GACf,IAA2B,EAAM,OAAuB,IAAI;CAElE,EAAM,gBAAgB;EACpB,EAAc,EAAK;CACrB,GAAG,CAAC,CAAO,CAAC;CAEZ,IAAM,IAAwB,YAAY;EAExC,AADA,MAAM,UAAU,UAAU,UAAU,CAAO,GAC3C,EAAU,EAAI;CAChB;CAEA,EAAM,gBAAgB;EACpB,IAAI;EAQJ,OANI,MACF,IAAU,iBAAiB;GACzB,EAAU,EAAK;EACjB,GAAG,GAAI,UAGI;GACX,aAAa,CAAO;EACtB;CACF,GAAG,CAAC,CAAM,CAAC;CAEX,IAAM,IACJ,MAAS,WACR,MAAkB,WAAW,MAAkB,YAC5C,IAAw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ACG,GACD,kBAAC,OAAD;GAAK,WAAU;aACb,kBAAC,GAAD;IACE,IAAG;IACH,MAAK;IACL,aAAU;IACV,eAAY;IACZ,WAAU;IACV,UAAU;IACV,QAAQ;cAEP,EAAE,EAAQ,8BAA8B;GAC9B,CAAA;EACV,CAAA,CACF;MAIF;AACT"}
|
|
1
|
+
{"version":3,"file":"chat-message.js","names":[],"sources":["../../../../src/components/features/chat/chat-message.tsx"],"sourcesContent":["import React from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { cn } from \"#/utils/utils\";\nimport { CopyToClipboardButton } from \"#/components/shared/buttons/copy-to-clipboard-button\";\nimport type { SourceType } from \"#/types/agent-server/core/base/common\";\nimport { StyledTooltip } from \"#/components/shared/buttons/styled-tooltip\";\nimport { I18nKey } from \"#/i18n/declaration\";\nimport { TextShimmer } from \"#/components/shared/text-shimmer\";\nimport { MarkdownRenderer } from \"../markdown/markdown-renderer\";\nimport { PendingStopIcon } from \"./pending-stop-icon\";\nimport {\n UserMessageBody,\n chatBubbleMarkdownComponents,\n USER_MESSAGE_LINE_HEIGHT_PX,\n} from \"./user-message-body\";\n\nexport type ChatMessagePendingStatus = \"sending\" | \"error\";\n\ninterface ChatMessageProps {\n type: SourceType;\n message: string;\n actions?: Array<{\n icon: React.ReactNode;\n onClick: () => void;\n tooltip?: string;\n }>;\n isFromPlanningAgent?: boolean;\n pendingStatus?: ChatMessagePendingStatus;\n onRetry?: () => void;\n onDismiss?: () => void;\n onStop?: () => void;\n}\n\nexport function ChatMessage({\n type,\n message,\n children,\n actions,\n isFromPlanningAgent = false,\n pendingStatus,\n onRetry,\n onDismiss,\n onStop,\n}: React.PropsWithChildren<ChatMessageProps>) {\n const { t } = useTranslation(\"openhands\");\n const [isHovering, setIsHovering] = React.useState(false);\n const [isCopy, setIsCopy] = React.useState(false);\n const [isExpanded, setIsExpanded] = React.useState(false);\n const [isTruncatable, setIsTruncatable] = React.useState(false);\n const [isSingleLinePendingMessage, setIsSingleLinePendingMessage] =\n React.useState(true);\n const pendingMessageContentRef = React.useRef<HTMLDivElement>(null);\n\n React.useEffect(() => {\n setIsExpanded(false);\n }, [message]);\n\n const handleCopyToClipboard = async () => {\n await navigator.clipboard.writeText(message);\n setIsCopy(true);\n };\n\n React.useEffect(() => {\n let timeout: NodeJS.Timeout;\n\n if (isCopy) {\n timeout = setTimeout(() => {\n setIsCopy(false);\n }, 2000);\n }\n\n return () => {\n clearTimeout(timeout);\n };\n }, [isCopy]);\n\n const isPendingUserMessage =\n type === \"user\" &&\n (pendingStatus === \"error\" || pendingStatus === \"sending\");\n const canStopPendingMessage = pendingStatus === \"sending\" && onStop != null;\n const showStopButton = canStopPendingMessage && isHovering;\n const useTruncatedUserBody = type === \"user\" && pendingStatus == null;\n const isCollapsed = useTruncatedUserBody && isTruncatable && !isExpanded;\n const hasBubbleChildren = React.Children.count(children) > 0;\n\n React.useLayoutEffect(() => {\n if (!canStopPendingMessage || useTruncatedUserBody) {\n return undefined;\n }\n\n const content = pendingMessageContentRef.current;\n if (!content) {\n return undefined;\n }\n\n const measure = () => {\n const lineHeight = Number.parseFloat(\n getComputedStyle(content).lineHeight,\n );\n const linePx =\n Number.isFinite(lineHeight) && lineHeight > 0\n ? lineHeight\n : USER_MESSAGE_LINE_HEIGHT_PX;\n\n setIsSingleLinePendingMessage(content.scrollHeight <= linePx + 1);\n };\n\n measure();\n\n const observer = new ResizeObserver(measure);\n observer.observe(content);\n\n return () => observer.disconnect();\n }, [message, canStopPendingMessage, useTruncatedUserBody]);\n\n const messageContent = useTruncatedUserBody ? (\n <UserMessageBody\n message={message}\n isHovering={isHovering}\n isExpanded={isExpanded}\n onTruncatableChange={setIsTruncatable}\n />\n ) : (\n <div\n ref={pendingMessageContentRef}\n className=\"min-w-0 text-sm leading-6 whitespace-normal [word-break:break-word]\"\n >\n <MarkdownRenderer\n includeStandard\n includeHeadings\n allowHtml={type !== \"user\"}\n components={chatBubbleMarkdownComponents}\n >\n {message}\n </MarkdownRenderer>\n </div>\n );\n\n const renderedMessageContent = messageContent;\n\n const messageBubble = (\n <article\n data-testid={`${type}-message`}\n data-pending-status={pendingStatus}\n onMouseEnter={() => setIsHovering(true)}\n onMouseLeave={() => setIsHovering(false)}\n className={cn(\n \"rounded-xl relative w-fit max-w-full flex flex-col\",\n hasBubbleChildren && \"gap-2\",\n type === \"user\" && \"mt-6 bg-tertiary self-end px-4 py-2.5\",\n type === \"agent\" && \"mt-6 w-full max-w-full bg-transparent\",\n isFromPlanningAgent &&\n type === \"agent\" &&\n \"border border-[#597ff4] bg-tertiary p-4 mt-2\",\n pendingStatus === \"error\" &&\n \"border border-[var(--oh-status-error)]/40\",\n !isPendingUserMessage && \"last:mb-4\",\n )}\n >\n <div\n className={cn(\n \"absolute -top-2.5 -right-2.5 z-10\",\n !isHovering || pendingStatus === \"sending\" ? \"hidden\" : \"flex\",\n \"items-center gap-1\",\n )}\n onClick={(event) => event.stopPropagation()}\n >\n {actions?.map((action, index) =>\n action.tooltip ? (\n <StyledTooltip key={index} content={action.tooltip} placement=\"top\">\n <button\n type=\"button\"\n onClick={action.onClick}\n className=\"button-base p-1 cursor-pointer\"\n aria-label={action.tooltip}\n >\n {action.icon}\n </button>\n </StyledTooltip>\n ) : (\n <button\n key={index}\n type=\"button\"\n onClick={action.onClick}\n className=\"button-base p-1 cursor-pointer\"\n aria-label={`Action ${index + 1}`}\n >\n {action.icon}\n </button>\n ),\n )}\n\n <CopyToClipboardButton\n isHidden={!isHovering}\n isDisabled={isCopy}\n onClick={handleCopyToClipboard}\n mode={isCopy ? \"copied\" : \"copy\"}\n />\n </div>\n\n {renderedMessageContent}\n\n {canStopPendingMessage ? (\n <button\n type=\"button\"\n onClick={(event) => {\n event.stopPropagation();\n onStop?.();\n }}\n data-testid=\"chat-message-stop\"\n aria-label={t(I18nKey.BUTTON$STOP)}\n aria-hidden={!showStopButton}\n tabIndex={showStopButton ? 0 : -1}\n className={cn(\n \"group absolute z-10 inline-flex h-7 w-7 cursor-pointer items-center justify-center rounded-full bg-[var(--oh-color-tertiary)] text-[var(--oh-foreground)] transition-opacity duration-150\",\n isSingleLinePendingMessage\n ? \"right-3 top-1/2 -translate-y-1/2\"\n : \"right-3 bottom-2.5\",\n showStopButton ? \"opacity-100\" : \"pointer-events-none opacity-0\",\n )}\n >\n <PendingStopIcon className=\"block h-7 w-7 max-w-none\" />\n </button>\n ) : null}\n\n {isCollapsed ? (\n <button\n type=\"button\"\n data-testid=\"chat-message-expand\"\n aria-expanded={false}\n aria-label={t(I18nKey.COMMON$VIEW_MORE)}\n className=\"absolute inset-0 z-[1] cursor-pointer rounded-xl border-0 bg-transparent p-0\"\n onClick={() => setIsExpanded(true)}\n />\n ) : null}\n\n {children}\n </article>\n );\n\n if (type === \"user\" && pendingStatus === \"error\") {\n return (\n <div className=\"flex w-fit max-w-full flex-col items-end gap-1.5 self-end last:mb-4\">\n {messageBubble}\n <div\n role=\"alert\"\n data-testid=\"chat-message-error\"\n className=\"flex items-center gap-2 text-xs text-[var(--oh-status-error)]\"\n >\n <span>{t(I18nKey.CHAT_INTERFACE$MESSAGE_SEND_FAILED)}</span>\n {onRetry ? (\n <button\n type=\"button\"\n onClick={onRetry}\n className=\"cursor-pointer rounded-md border border-[var(--oh-border)] px-2 py-1 text-xs font-normal text-[var(--oh-foreground)] hover:bg-[var(--oh-interactive-hover)]\"\n data-testid=\"chat-message-retry\"\n >\n {t(I18nKey.CHAT_INTERFACE$MESSAGE_RETRY)}\n </button>\n ) : null}\n {onDismiss ? (\n <button\n type=\"button\"\n onClick={onDismiss}\n className=\"cursor-pointer rounded-md border border-[var(--oh-border)] px-2 py-1 text-xs font-normal text-[var(--oh-foreground)] hover:bg-[var(--oh-interactive-hover)]\"\n data-testid=\"chat-message-dismiss\"\n >\n {t(I18nKey.CHAT_INTERFACE$MESSAGE_DISMISS)}\n </button>\n ) : null}\n </div>\n </div>\n );\n }\n\n if (type === \"user\" && pendingStatus === \"sending\") {\n return (\n <div className=\"flex w-full max-w-full flex-col last:mb-4\">\n {messageBubble}\n <div className=\"my-1 w-full py-1 text-sm\">\n <TextShimmer\n as=\"p\"\n role=\"status\"\n aria-live=\"polite\"\n data-testid=\"chat-message-sending\"\n className=\"block w-full text-sm font-normal\"\n duration={1}\n spread={2}\n >\n {t(I18nKey.CHAT_INTERFACE$MESSAGE_SENDING)}\n </TextShimmer>\n </div>\n </div>\n );\n }\n\n return messageBubble;\n}\n"],"mappings":";;;;;;;;;;;;AAiCA,SAAgB,EAAY,EAC1B,SACA,YACA,aACA,YACA,yBAAsB,IACtB,kBACA,YACA,cACA,aAC4C;CAC5C,IAAM,EAAE,SAAM,EAAe,WAAW,GAClC,CAAC,GAAY,KAAiB,EAAM,SAAS,EAAK,GAClD,CAAC,GAAQ,KAAa,EAAM,SAAS,EAAK,GAC1C,CAAC,GAAY,KAAiB,EAAM,SAAS,EAAK,GAClD,CAAC,GAAe,KAAoB,EAAM,SAAS,EAAK,GACxD,CAAC,GAA4B,KACjC,EAAM,SAAS,EAAI,GACf,IAA2B,EAAM,OAAuB,IAAI;CAElE,EAAM,gBAAgB;EACpB,EAAc,EAAK;CACrB,GAAG,CAAC,CAAO,CAAC;CAEZ,IAAM,IAAwB,YAAY;EAExC,AADA,MAAM,UAAU,UAAU,UAAU,CAAO,GAC3C,EAAU,EAAI;CAChB;CAEA,EAAM,gBAAgB;EACpB,IAAI;EAQJ,OANI,MACF,IAAU,iBAAiB;GACzB,EAAU,EAAK;EACjB,GAAG,GAAI,UAGI;GACX,aAAa,CAAO;EACtB;CACF,GAAG,CAAC,CAAM,CAAC;CAEX,IAAM,IACJ,MAAS,WACR,MAAkB,WAAW,MAAkB,YAC5C,IAAwB,MAAkB,aAAa,KAAU,MACjE,IAAiB,KAAyB,GAC1C,IAAuB,MAAS,UAAU,KAAiB,MAC3D,IAAc,KAAwB,KAAiB,CAAC,GACxD,IAAoB,EAAM,SAAS,MAAM,CAAQ,IAAI;CAE3D,EAAM,sBAAsB;EAC1B,IAAI,CAAC,KAAyB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AAY;IACZ,WAAU;IACV,UAAU;IACV,QAAQ;cAEP,EAAE,EAAQ,8BAA8B;GAC9B,CAAA;EACV,CAAA,CACF;MAIF;AACT"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/react-i18next/dist/es/useTranslation.cjs"),n=require("../../../i18n/declaration.cjs"),r=require("../../../hooks/use-conversation-id.cjs"),i=require("../../../stores/conversation-store.cjs"),a=require("../../../stores/optimistic-user-message-store.cjs"),o=require("../../../hooks/use-send-message.cjs"),s=require("../../../utils/pending-task-message-link.cjs"),c=require("../../../services/chat-service.cjs"),l=require("./chat-message.cjs"),u=require("../images/image-carousel.cjs");let d=require("react");d=e.__toESM(d,1);let f=require("react/jsx-runtime");function p(){let{t:e}=t.useTranslation(`openhands`),{conversationId:p}=r.useOptionalConversationId(),m=a.useOptimisticUserMessageStore(e=>e.pendingMessages),h=a.useOptimisticUserMessageStore(e=>e.markPendingMessageError),g=a.useOptimisticUserMessageStore(e=>e.markPendingMessageSending),_=a.useOptimisticUserMessageStore(e=>e.removePendingMessage),v=i.useConversationStore(e=>e.restoreMessageToInputIfEmpty),{send:y}=o.useSendMessage(),b=d.default.useMemo(()=>p?m.filter(e=>s.matchesPendingConversationId(p,e.conversationId)):[],[m,p]),x=d.default.useCallback(async t=>{let r=a.useOptimisticUserMessageStore.getState().pendingMessages.find(e=>e.id===t);if(r){g(t);try{await y(c.createChatMessage(r.text,r.imageUrls,r.fileUrls,r.timestamp))}catch(r){h(t,r instanceof Error?r.message:e(n.I18nKey.CHAT_INTERFACE$FAILED_TO_SEND_MESSAGE))}}},[y,h,g,e]),S=d.default.useCallback((e,t)=>{v(t),_(e)},[v,_]);return b.length===0?null:(0,f.jsx)(f.Fragment,{children:b.map(e=>(0,f.jsx)(l.ChatMessage,{type:`user`,message:e.text,pendingStatus:e.status,onRetry:e.status===`error`?()=>x(e.id):void 0,onStop:e.status===`sending`?()=>S(e.id,e.text):void 0,children:e.imageUrls.length>0&&(0,f.jsx)(u.ImageCarousel,{size:`small`,images:e.imageUrls})},e.id))})}exports.PendingUserMessages=p;
|
|
1
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../node_modules/react-i18next/dist/es/useTranslation.cjs"),n=require("../../../i18n/declaration.cjs"),r=require("../../../hooks/use-conversation-id.cjs"),i=require("../../../stores/conversation-store.cjs"),a=require("../../../stores/optimistic-user-message-store.cjs"),o=require("../../../hooks/use-send-message.cjs"),s=require("../../../utils/pending-task-message-link.cjs"),c=require("../../../services/chat-service.cjs"),l=require("./chat-message.cjs"),u=require("../images/image-carousel.cjs");let d=require("react");d=e.__toESM(d,1);let f=require("react/jsx-runtime");function p(){let{t:e}=t.useTranslation(`openhands`),{conversationId:p}=r.useOptionalConversationId(),m=a.useOptimisticUserMessageStore(e=>e.pendingMessages),h=a.useOptimisticUserMessageStore(e=>e.markPendingMessageError),g=a.useOptimisticUserMessageStore(e=>e.markPendingMessageSending),_=a.useOptimisticUserMessageStore(e=>e.removePendingMessage),v=i.useConversationStore(e=>e.restoreMessageToInputIfEmpty),{send:y}=o.useSendMessage(),b=d.default.useMemo(()=>p?m.filter(e=>s.matchesPendingConversationId(p,e.conversationId)):[],[m,p]),x=d.default.useCallback(async t=>{let r=a.useOptimisticUserMessageStore.getState().pendingMessages.find(e=>e.id===t);if(r){g(t);try{await y(c.createChatMessage(r.text,r.imageUrls,r.fileUrls,r.timestamp))}catch(r){h(t,r instanceof Error?r.message:e(n.I18nKey.CHAT_INTERFACE$FAILED_TO_SEND_MESSAGE))}}},[y,h,g,e]),S=d.default.useCallback((e,t)=>{v(t),_(e)},[v,_]),C=d.default.useCallback(e=>{_(e)},[_]);return b.length===0?null:(0,f.jsx)(f.Fragment,{children:b.map(e=>(0,f.jsx)(l.ChatMessage,{type:`user`,message:e.text,pendingStatus:e.status,onRetry:e.status===`error`?()=>x(e.id):void 0,onDismiss:e.status===`error`?()=>C(e.id):void 0,onStop:e.status===`sending`?()=>S(e.id,e.text):void 0,children:e.imageUrls.length>0&&(0,f.jsx)(u.ImageCarousel,{size:`small`,images:e.imageUrls})},e.id))})}exports.PendingUserMessages=p;
|
|
2
2
|
//# sourceMappingURL=pending-user-messages.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pending-user-messages.cjs","names":[],"sources":["../../../../src/components/features/chat/pending-user-messages.tsx"],"sourcesContent":["import React from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { I18nKey } from \"#/i18n/declaration\";\nimport { useOptimisticUserMessageStore } from \"#/stores/optimistic-user-message-store\";\nimport { useConversationStore } from \"#/stores/conversation-store\";\nimport { useSendMessage } from \"#/hooks/use-send-message\";\nimport { createChatMessage } from \"#/services/chat-service\";\nimport { useOptionalConversationId } from \"#/hooks/use-conversation-id\";\nimport { matchesPendingConversationId } from \"#/utils/pending-task-message-link\";\nimport { ImageCarousel } from \"#/components/features/images/image-carousel\";\nimport { ChatMessage } from \"./chat-message\";\n\n/**\n * Renders the queue of locally-tracked user messages that have been submitted\n * but not yet echoed back through the WebSocket. Each message shows a faded\n * \"sending\" treatment until the server echoes a real `UserMessageEvent`\n * (which removes it via `consumeMatchingPendingMessage`). If the API rejects the\n * send, the message switches to an \"error\" state with a retry button.\n *\n * The queue is global but each entry is tagged with the conversation id it\n * was enqueued from; this component filters to only entries belonging to the\n * active conversation, so switching conversations never carries pending\n * bubbles over.\n */\nexport function PendingUserMessages() {\n const { t } = useTranslation(\"openhands\");\n const { conversationId } = useOptionalConversationId();\n const pendingMessages = useOptimisticUserMessageStore(\n (state) => state.pendingMessages,\n );\n const markPendingMessageError = useOptimisticUserMessageStore(\n (state) => state.markPendingMessageError,\n );\n const markPendingMessageSending = useOptimisticUserMessageStore(\n (state) => state.markPendingMessageSending,\n );\n const removePendingMessage = useOptimisticUserMessageStore(\n (state) => state.removePendingMessage,\n );\n const restoreMessageToInputIfEmpty = useConversationStore(\n (state) => state.restoreMessageToInputIfEmpty,\n );\n const { send } = useSendMessage();\n\n const visibleMessages = React.useMemo(\n () =>\n conversationId\n ? pendingMessages.filter((message) =>\n matchesPendingConversationId(\n conversationId,\n message.conversationId,\n ),\n )\n : [],\n [pendingMessages, conversationId],\n );\n\n const handleRetry = React.useCallback(\n async (id: string) => {\n const message = useOptimisticUserMessageStore\n .getState()\n .pendingMessages.find((entry) => entry.id === id);\n if (!message) return;\n\n markPendingMessageSending(id);\n\n try {\n await send(\n createChatMessage(\n message.text,\n message.imageUrls,\n message.fileUrls,\n message.timestamp,\n ),\n );\n } catch (error) {\n const errorMessage =\n error instanceof Error\n ? error.message\n : t(I18nKey.CHAT_INTERFACE$FAILED_TO_SEND_MESSAGE);\n markPendingMessageError(id, errorMessage);\n }\n },\n [send, markPendingMessageError, markPendingMessageSending, t],\n );\n\n const handleStop = React.useCallback(\n (id: string, text: string) => {\n restoreMessageToInputIfEmpty(text);\n removePendingMessage(id);\n },\n [restoreMessageToInputIfEmpty, removePendingMessage],\n );\n\n if (visibleMessages.length === 0) {\n return null;\n }\n\n return (\n <>\n {visibleMessages.map((message) => (\n <ChatMessage\n key={message.id}\n type=\"user\"\n message={message.text}\n pendingStatus={message.status}\n onRetry={\n message.status === \"error\"\n ? () => handleRetry(message.id)\n : undefined\n }\n onStop={\n message.status === \"sending\"\n ? () => handleStop(message.id, message.text)\n : undefined\n }\n >\n {message.imageUrls.length > 0 && (\n <ImageCarousel size=\"small\" images={message.imageUrls} />\n )}\n </ChatMessage>\n ))}\n </>\n );\n}\n"],"mappings":"yoBAwBA,SAAgB,GAAsB,CACpC,GAAM,CAAE,KAAM,EAAA,eAAe,WAAW,EAClC,CAAE,kBAAmB,EAAA,0BAA0B,EAC/C,EAAkB,EAAA,8BACrB,GAAU,EAAM,eACnB,EACM,EAA0B,EAAA,8BAC7B,GAAU,EAAM,uBACnB,EACM,EAA4B,EAAA,8BAC/B,GAAU,EAAM,yBACnB,EACM,EAAuB,EAAA,8BAC1B,GAAU,E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/chat/pending-user-messages.tsx"],"sourcesContent":["import React from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { I18nKey } from \"#/i18n/declaration\";\nimport { useOptimisticUserMessageStore } from \"#/stores/optimistic-user-message-store\";\nimport { useConversationStore } from \"#/stores/conversation-store\";\nimport { useSendMessage } from \"#/hooks/use-send-message\";\nimport { createChatMessage } from \"#/services/chat-service\";\nimport { useOptionalConversationId } from \"#/hooks/use-conversation-id\";\nimport { matchesPendingConversationId } from \"#/utils/pending-task-message-link\";\nimport { ImageCarousel } from \"#/components/features/images/image-carousel\";\nimport { ChatMessage } from \"./chat-message\";\n\n/**\n * Renders the queue of locally-tracked user messages that have been submitted\n * but not yet echoed back through the WebSocket. Each message shows a faded\n * \"sending\" treatment until the server echoes a real `UserMessageEvent`\n * (which removes it via `consumeMatchingPendingMessage`). If the API rejects the\n * send, the message switches to an \"error\" state with a retry button.\n *\n * The queue is global but each entry is tagged with the conversation id it\n * was enqueued from; this component filters to only entries belonging to the\n * active conversation, so switching conversations never carries pending\n * bubbles over.\n */\nexport function PendingUserMessages() {\n const { t } = useTranslation(\"openhands\");\n const { conversationId } = useOptionalConversationId();\n const pendingMessages = useOptimisticUserMessageStore(\n (state) => state.pendingMessages,\n );\n const markPendingMessageError = useOptimisticUserMessageStore(\n (state) => state.markPendingMessageError,\n );\n const markPendingMessageSending = useOptimisticUserMessageStore(\n (state) => state.markPendingMessageSending,\n );\n const removePendingMessage = useOptimisticUserMessageStore(\n (state) => state.removePendingMessage,\n );\n const restoreMessageToInputIfEmpty = useConversationStore(\n (state) => state.restoreMessageToInputIfEmpty,\n );\n const { send } = useSendMessage();\n\n const visibleMessages = React.useMemo(\n () =>\n conversationId\n ? pendingMessages.filter((message) =>\n matchesPendingConversationId(\n conversationId,\n message.conversationId,\n ),\n )\n : [],\n [pendingMessages, conversationId],\n );\n\n const handleRetry = React.useCallback(\n async (id: string) => {\n const message = useOptimisticUserMessageStore\n .getState()\n .pendingMessages.find((entry) => entry.id === id);\n if (!message) return;\n\n markPendingMessageSending(id);\n\n try {\n await send(\n createChatMessage(\n message.text,\n message.imageUrls,\n message.fileUrls,\n message.timestamp,\n ),\n );\n } catch (error) {\n const errorMessage =\n error instanceof Error\n ? error.message\n : t(I18nKey.CHAT_INTERFACE$FAILED_TO_SEND_MESSAGE);\n markPendingMessageError(id, errorMessage);\n }\n },\n [send, markPendingMessageError, markPendingMessageSending, t],\n );\n\n const handleStop = React.useCallback(\n (id: string, text: string) => {\n restoreMessageToInputIfEmpty(text);\n removePendingMessage(id);\n },\n [restoreMessageToInputIfEmpty, removePendingMessage],\n );\n\n const handleDismiss = React.useCallback(\n (id: string) => {\n removePendingMessage(id);\n },\n [removePendingMessage],\n );\n\n if (visibleMessages.length === 0) {\n return null;\n }\n\n return (\n <>\n {visibleMessages.map((message) => (\n <ChatMessage\n key={message.id}\n type=\"user\"\n message={message.text}\n pendingStatus={message.status}\n onRetry={\n message.status === \"error\"\n ? () => handleRetry(message.id)\n : undefined\n }\n onDismiss={\n message.status === \"error\"\n ? () => handleDismiss(message.id)\n : undefined\n }\n onStop={\n message.status === \"sending\"\n ? () => handleStop(message.id, message.text)\n : undefined\n }\n >\n {message.imageUrls.length > 0 && (\n <ImageCarousel size=\"small\" images={message.imageUrls} />\n )}\n </ChatMessage>\n ))}\n </>\n );\n}\n"],"mappings":"yoBAwBA,SAAgB,GAAsB,CACpC,GAAM,CAAE,KAAM,EAAA,eAAe,WAAW,EAClC,CAAE,kBAAmB,EAAA,0BAA0B,EAC/C,EAAkB,EAAA,8BACrB,GAAU,EAAM,eACnB,EACM,EAA0B,EAAA,8BAC7B,GAAU,EAAM,uBACnB,EACM,EAA4B,EAAA,8BAC/B,GAAU,EAAM,yBACnB,EACM,EAAuB,EAAA,8BAC1B,GAAU,EAAM,oBACnB,EACM,EAA+B,EAAA,qBAClC,GAAU,EAAM,4BACnB,EACM,CAAE,QAAS,EAAA,eAAe,EAE1B,EAAkB,EAAA,QAAM,YAE1B,EACI,EA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N"}
|
|
@@ -29,12 +29,15 @@ function p() {
|
|
|
29
29
|
p
|
|
30
30
|
]), C = u.useCallback((e, t) => {
|
|
31
31
|
y(t), v(e);
|
|
32
|
-
}, [y, v])
|
|
32
|
+
}, [y, v]), w = u.useCallback((e) => {
|
|
33
|
+
v(e);
|
|
34
|
+
}, [v]);
|
|
33
35
|
return x.length === 0 ? null : /* @__PURE__ */ f(d, { children: x.map((e) => /* @__PURE__ */ f(c, {
|
|
34
36
|
type: "user",
|
|
35
37
|
message: e.text,
|
|
36
38
|
pendingStatus: e.status,
|
|
37
39
|
onRetry: e.status === "error" ? () => S(e.id) : void 0,
|
|
40
|
+
onDismiss: e.status === "error" ? () => w(e.id) : void 0,
|
|
38
41
|
onStop: e.status === "sending" ? () => C(e.id, e.text) : void 0,
|
|
39
42
|
children: e.imageUrls.length > 0 && /* @__PURE__ */ f(l, {
|
|
40
43
|
size: "small",
|