@openhands/agent-canvas 1.0.0-alpha.8 → 1.0.0-alpha.9
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 +17 -6
- package/build/assets/{add-backend-modal-KMmPQNZU.js → add-backend-modal-FsnpTTgO.js} +1 -1
- package/build/assets/{agent-server-conversation-service.api-DSl9G5UR.js → agent-server-conversation-service.api-BZmUqtiO.js} +1 -1
- package/build/assets/{automation-detail-g5-RZ0da.js → automation-detail-R-99FUce.js} +1 -1
- package/build/assets/{automations-list-DHoq_0MM.js → automations-list-Dfu2c-_D.js} +1 -1
- package/build/assets/backend-form-modal-DxYjqqAK.js +1 -0
- package/build/assets/browser-HrYc5Gce.js +5 -0
- package/build/assets/conversation--ldUK72N.js +19 -0
- package/build/assets/conversation-eNrhH94O.js +1 -0
- package/build/assets/conversation-panel-B49Jpqpb.js +1 -0
- package/build/assets/{conversation-service.api-C8pYCyV6.js → conversation-service.api--f8WglOC.js} +1 -1
- package/build/assets/conversation-websocket-context-BW68-J8o.js +3 -0
- package/build/assets/{entry.client-D9uR9Blz.js → entry.client-CqqXOSvd.js} +2 -2
- package/build/assets/{files-tab-B3A1NDlZ.js → files-tab-CQHdWpQt.js} +1 -1
- package/build/assets/git-control-bar-branch-button-C8u5rzjc.js +27 -0
- package/build/assets/{git-provider-icon-DYE9n7fs.js → git-provider-icon-D-a-rcLm.js} +1 -1
- package/build/assets/{home-dIzxi5Dd.js → home-DD0GroCu.js} +1 -1
- package/build/assets/{launch-hZ0ifhcV.js → launch-B2mbfOSm.js} +1 -1
- package/build/assets/llm-settings-BEyqixPI.js +1 -0
- package/build/assets/{llm-settings-CcHqGOYL.js → llm-settings-BdiaGFbg.js} +1 -1
- package/build/assets/{manage-backends-modal-rYeyGx7j.js → manage-backends-modal-s22zCdEW.js} +1 -1
- package/build/assets/{manifest-97e839da.js → manifest-9d1c34fb.js} +1 -1
- package/build/assets/{messages-T2ewVkbp.js → messages-6aOyUu3r.js} +1 -1
- package/build/assets/{path-utils-CqJboYxo.js → path-utils-BVbe598W.js} +1 -1
- package/build/assets/{planner-tab-BrntFmb1.js → planner-tab-bN6r1G-1.js} +1 -1
- package/build/assets/{recommended-automations-launcher-BI9NhG8Y.js → recommended-automations-launcher-mJhK6Atl.js} +1 -1
- package/build/assets/{root-BS1Td78t.js → root-3t9rxEpE.js} +2 -2
- package/build/assets/{root-layout-BLjAEgle.js → root-layout-BjVwHmta.js} +2 -2
- package/build/assets/{shared-conversation-a0QV8o99.js → shared-conversation-EZV0FRIf.js} +1 -1
- package/build/assets/{sidebar-mobile-menu-toggle-DTUNI1WQ.js → sidebar-mobile-menu-toggle-BnbzzpQl.js} +1 -1
- package/build/assets/{skills-settings-DOnMn9q1.js → skills-settings-CG2hu34D.js} +1 -1
- package/build/assets/{task-list-tab-Day9nhRT.js → task-list-tab-465DDju0.js} +1 -1
- package/build/assets/{terminal-ro4SNjUU.js → terminal-CcgBEVnC.js} +1 -1
- package/build/assets/{use-active-conversation-D15D9GgR.js → use-active-conversation-DS5j9R4q.js} +1 -1
- package/build/assets/{use-agent-state-DE5dlEXJ.js → use-agent-state-D2C9SeGw.js} +1 -1
- package/build/assets/{use-create-conversation-DW7AGgLA.js → use-create-conversation-BEZg__Vv.js} +1 -1
- package/build/assets/{use-event-store-CQZCcVz-.js → use-event-store-BT_gV3ut.js} +1 -1
- package/build/assets/{use-handle-plan-click-DpgEQDAV.js → use-handle-plan-click-uOpew2LO.js} +1 -1
- package/build/assets/{use-runtime-is-ready-XFbT16BD.js → use-runtime-is-ready-pGSbPddC.js} +1 -1
- package/build/assets/{use-skills-Xe0vjPMt.js → use-skills-BIvlWblA.js} +1 -1
- package/build/assets/{use-task-list-Bs90uF2N.js → use-task-list-DDeNHprj.js} +1 -1
- package/build/assets/{use-unified-vscode-url-BOsIOd-b.js → use-unified-vscode-url-wAMzv8Sn.js} +1 -1
- package/build/assets/{use-user-conversation-Mc0mQgkl.js → use-user-conversation-B_zDoSeh.js} +1 -1
- package/build/assets/{vscode-tab-C0ShhiSU.js → vscode-tab-B0vdh9gU.js} +1 -1
- package/build/index.html +4 -4
- package/dist/api/agent-server-adapter.cjs +1 -1
- package/dist/api/agent-server-adapter.cjs.map +1 -1
- package/dist/api/agent-server-adapter.js +1 -0
- package/dist/api/agent-server-adapter.js.map +1 -1
- package/dist/api/skills-service.cjs +1 -1
- package/dist/api/skills-service.cjs.map +1 -1
- package/dist/api/skills-service.d.ts +1 -1
- package/dist/api/skills-service.js +2 -2
- package/dist/api/skills-service.js.map +1 -1
- 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 +149 -142
- package/dist/components/features/backends/backend-form-modal.js.map +1 -1
- package/dist/components/features/conversation-panel/skills-modal.cjs +1 -1
- package/dist/components/features/conversation-panel/skills-modal.cjs.map +1 -1
- package/dist/components/features/conversation-panel/skills-modal.js +1 -1
- package/dist/components/features/conversation-panel/skills-modal.js.map +1 -1
- package/dist/contexts/conversation-websocket-context.cjs +3 -3
- package/dist/contexts/conversation-websocket-context.cjs.map +1 -1
- package/dist/contexts/conversation-websocket-context.js +97 -89
- package/dist/contexts/conversation-websocket-context.js.map +1 -1
- package/dist/hooks/chat/use-slash-command.cjs +1 -1
- package/dist/hooks/chat/use-slash-command.cjs.map +1 -1
- package/dist/hooks/chat/use-slash-command.js +1 -1
- package/dist/hooks/chat/use-slash-command.js.map +1 -1
- package/dist/hooks/query/use-conversation-skills.cjs +2 -0
- package/dist/hooks/query/use-conversation-skills.cjs.map +1 -0
- package/dist/hooks/query/use-conversation-skills.d.ts +7 -0
- package/dist/hooks/query/use-conversation-skills.js +8 -0
- package/dist/hooks/query/use-conversation-skills.js.map +1 -0
- package/dist/hooks/query/use-skills.cjs +1 -1
- package/dist/hooks/query/use-skills.cjs.map +1 -1
- package/dist/hooks/query/use-skills.d.ts +6 -1
- package/dist/hooks/query/use-skills.js +3 -3
- package/dist/hooks/query/use-skills.js.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.cjs.map +1 -1
- package/dist/package.js +3 -3
- package/dist/package.js.map +1 -1
- package/dist/routes/conversation.cjs +1 -1
- package/dist/routes/conversation.cjs.map +1 -1
- package/dist/routes/conversation.js +61 -63
- package/dist/routes/conversation.js.map +1 -1
- package/dist/stores/use-event-store.cjs +1 -1
- package/dist/stores/use-event-store.cjs.map +1 -1
- package/dist/stores/use-event-store.d.ts +22 -0
- package/dist/stores/use-event-store.js +9 -1
- package/dist/stores/use-event-store.js.map +1 -1
- package/dist/ui/context-menu.d.ts +1 -1
- package/dist/ui/help-link.d.ts +1 -1
- package/package.json +3 -3
- package/scripts/dev-safe.mjs +35 -17
- package/scripts/dev-with-automation.mjs +24 -49
- package/build/assets/backend-form-modal-K6IMCr3p.js +0 -1
- package/build/assets/browser-DKG63inJ.js +0 -5
- package/build/assets/conversation-BD5WemJI.js +0 -19
- package/build/assets/conversation-C47K62n8.js +0 -1
- package/build/assets/conversation-panel-Dn-S56Gk.js +0 -1
- package/build/assets/conversation-websocket-context-Ywrxd_9p.js +0 -3
- package/build/assets/git-control-bar-branch-button-CcIpmyfM.js +0 -27
- package/build/assets/llm-settings-2036m7Wt.js +0 -1
- /package/build/assets/{link-external-Df8J52xI.js → link-external-C9d6Fo3x.js} +0 -0
- /package/build/assets/{use-llm-profiles-D3-KXwQ0.js → use-llm-profiles-O4a9V6RC.js} +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/files-tab-CQHdWpQt.js","assets/rolldown-runtime-BFRubm34.js","assets/vendor~files-tab-DtLR-QD9.js","assets/iconBase-C7N9pPOs.js","assets/react-CM_dJw1Z.js","assets/vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~dp08i1qy-CHrEOFl6.js","assets/agent-server-client-options-DT2GP6VJ.js","assets/agent-server-conversation-service.api-BZmUqtiO.js","assets/preload-helper-CT1Z6Pdu.js","assets/profiles-client-BGkKEV9j.js","assets/agent-server-compatibility-2aOx5iWd.js","assets/server-client-C3mC8Hl3.js","assets/settings-service.api-FvJGK45W.js","assets/settings-client-CwjfwoiB.js","assets/proxy-CurRmrqf.js","assets/vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~pfbaerbd-zhv9fooy.js","assets/settings-D5am1n6X.js","assets/acp-providers-DauuOsW9.js","assets/declaration-D378OjpZ.js","assets/common-SMkEaBSr.js","assets/vendor~root~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-s~kyz9p27j-CyUbhpbm.js","assets/vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~extensions~b4cctr4k-B7YVdv1X.js","assets/QueryClientProvider-B7kl84Kj.js","assets/useTranslation-CpIcQBq6.js","assets/context-CEQZwATj.js","assets/vendor~root-layout~home~conversation-panel~conversation~shared-conversation~alert-banner~pl~rqjteh0a-BP1SKG0F.js","assets/vendor~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-Ds9quNZ9.js","assets/vendor~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-BbFOrAjI.js","assets/objectWithoutPropertiesLoose-Du6eBn-V.js","assets/vendor~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-B92czPCF.js","assets/vendor~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-BW6261Sb.js","assets/vendor~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-DpAdkv8m.js","assets/vendor~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-By5W2oHN.js","assets/react-Do0CT17Y.js","assets/conversation-tab-empty-state-D8dNvo-V.js","assets/utils-D-HX7JCe.js","assets/vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~extensions~i9dbt75i-CI82Did1.js","assets/markdown-renderer-CEX4Becj.js","assets/checkmark-BJJrZUF8.js","assets/copy-C7Ti2d8C.js","assets/active-backend-context-TVbjnvmP.js","assets/health-store-BDC2rM-X.js","assets/use-active-conversation-DS5j9R4q.js","assets/conversation-service.api--f8WglOC.js","assets/use-user-conversation-B_zDoSeh.js","assets/use-conversation-id-DajhCn2A.js","assets/navigation-context-DeIPtGPp.js","assets/use-agent-state-D2C9SeGw.js","assets/conversation-state-store-Bc0slAjL.js","assets/use-runtime-is-ready-pGSbPddC.js","assets/status-CsatcFbK.js","assets/chevron-left-small-CSh-sE9L.js","assets/link-external-C9d6Fo3x.js","assets/folder-0WSMImNX.js","assets/files-tab-store-CDyVTXNT.js","assets/use-event-store-BT_gV3ut.js","assets/typography-vVUMoNUg.js","assets/dist-DZHSA2e6.js","assets/conversation-local-storage-UYl-SX-r.js","assets/git-status-mapper-BI8FyUVp.js","assets/retrieve-axios-error-message-BY-yIkIq.js","assets/browser-tab-B_BuTvrO.js","assets/vendor~browser-tab-BiVxfjJo.js","assets/browser-store-C3AqxAO7.js","assets/vscode-tab-B0vdh9gU.js","assets/use-unified-vscode-url-wAMzv8Sn.js","assets/vscode-url-helper-jesbpos5.js","assets/waiting-for-runtime-message-DWPl_Yby.js","assets/brand-button-C2nEKopC.js","assets/planner-tab-bN6r1G-1.js","assets/plan-components-DEjMuDDG.js","assets/use-handle-plan-click-uOpew2LO.js","assets/custom-toast-handlers-BOc3qeQ7.js","assets/createLucideIcon-Ddu8jDOQ.js","assets/i18n-DjAGhTis.js","assets/vendor~entry.client~root~root-layout~home~conversation-panel~conversation~skills-settings~m~o9nrx3fm-D44TR8hL.js","assets/use-create-conversation-BEZg__Vv.js","assets/useMutation-B4OUESdw.js","assets/mutation-Cz7N4XAo.js","assets/vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~skills-set~jfc6hidu-VnmIZrq3.js","assets/vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~skills-set~zm51vy4j-iOsylxCS.js","assets/use-settings-DQ7Oo1Hj.js","assets/query-keys-tAsQcc_9.js","assets/conversation-store-Z5iMCRpc.js","assets/middleware-BC9EwbB9.js","assets/lesson-plan-DRYG5SLI.js","assets/task-list-tab-465DDju0.js","assets/use-task-list-DDeNHprj.js","assets/u-check-circle-half-yDuiSZHC.js","assets/u-check-circle-DplbarS5.js","assets/terminal-CcgBEVnC.js","assets/vendor~terminal-BUxzHKcC.js","assets/vendor~terminal-T4IDBjWs.css","assets/command-store-DFN_17p1.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{t as n}from"./preload-helper-CT1Z6Pdu.js";import{A as r,L as i,M as a,k as o}from"./vendor~entry.client~root~root-layout~index-redirect~home~conversation-panel~conversation~la~cnj3raoq-DTEXlLSB.js";import{t as s}from"./react-dom-hVBnwgwZ.js";import{t as c}from"./vendor~root~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-s~kyz9p27j-CyUbhpbm.js";import{c as l,i as u,r as d,s as f}from"./path-utils-BVbe598W.js";import{t as p}from"./useMutation-B4OUESdw.js";import{o as m,t as h}from"./declaration-D378OjpZ.js";import{n as g}from"./QueryClientProvider-B7kl84Kj.js";import{t as _}from"./Trans-1j65oy9O.js";import{t as v}from"./useTranslation-CpIcQBq6.js";import{a as y,c as b,d as x,f as S,i as C,l as w,n as T,o as ee,r as E,s as D,t as O,u as k}from"./messages-6aOyUu3r.js";import{c as A,d as j,f as M,i as N,l as te,n as P,r as F,s as I,t as L,u as ne}from"./sidebar-mobile-menu-toggle-BnbzzpQl.js";import{a as R,n as z,o as re,r as ie,t as ae}from"./custom-toast-handlers-BOc3qeQ7.js";import{n as B,r as oe,t as se}from"./vendor~conversation-panel~conversation-BlCIz9XQ.js";import{a as ce,c as le,d as V,f as ue,l as H,m as de,n as fe,o as pe,s as me,t as he,u as ge}from"./conversation-websocket-context-BW68-J8o.js";import{t as _e}from"./x-JOBEVLW0.js";import{_ as U,b as ve,c as ye,d as be,k as xe,l as Se,m as Ce,o as we,t as W,u as Te,v as Ee,y as De}from"./utils-D-HX7JCe.js";import{S as Oe,r as ke}from"./agent-server-client-options-DT2GP6VJ.js";import{n as G}from"./active-backend-context-TVbjnvmP.js";import{n as Ae}from"./vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~skills-set~jfc6hidu-VnmIZrq3.js";import{a as je,i as Me,o as Ne,t as Pe}from"./agent-server-conversation-service.api-BZmUqtiO.js";import{t as Fe}from"./modal-backdrop-DTYGVmOR.js";import{n as Ie}from"./modal-body-YElmM1dV.js";import{r as Le}from"./base-modal-CQRvRHu1.js";import{d as Re,t as ze}from"./brand-button-C2nEKopC.js";import{t as Be}from"./loading-spinner-C04FGh14.js";import{n as Ve}from"./navigation-context-DeIPtGPp.js";import{h as He}from"./vendor~root-layout~home~conversation-panel~conversation~extensions-hub~skills-settings~skil~iguv7bgw-8b8V5bfO.js";import{O as Ue}from"./vendor~root-layout~home~conversation-panel~conversation~extensions-hub~skills-settings~skil~iguv7bgw-Dy7L6fMG.js";import{t as We}from"./styled-tooltip-CS3mB_1X.js";import{_ as Ge,h as Ke,m as qe,n as Je,p as Ye,s as Xe}from"./git-provider-icon-D-a-rcLm.js";import{t as Ze}from"./react-Do0CT17Y.js";import{n as Qe}from"./middleware-BC9EwbB9.js";import{i as $e,s as et}from"./conversation-local-storage-UYl-SX-r.js";import{t as K}from"./conversation-store-Z5iMCRpc.js";import{t as tt}from"./modal-close-button-C_GpQt9F.js";import{t as nt}from"./common-SMkEaBSr.js";import{t as rt}from"./use-is-authed-hXC8vxgT.js";import{t as it}from"./use-click-outside-element-835W9pC6.js";import{i as at,n as ot,r as st}from"./status-CsatcFbK.js";import{r as ct}from"./use-settings-DQ7Oo1Hj.js";import{n as lt,t as ut}from"./use-create-conversation-BEZg__Vv.js";import{r as dt}from"./conversation-service.api--f8WglOC.js";import{i as ft}from"./vendor~root-layout~conversation-panel~conversation~shared-conversation-DrXgiSCq.js";import{n as pt,t as q}from"./context-menu-list-item-Buu9nc0q.js";import{i as J,r as mt,t as ht}from"./ellipsis-button-ugUATsNo.js";import{t as gt}from"./u-edit-KAUlufD8.js";import{t as _t}from"./skills-ZyAO5dyK.js";import{t as vt}from"./terminal-LNa-iU5c.js";import{t as yt}from"./use-user-conversation-B_zDoSeh.js";import{t as bt}from"./conversation-state-store-Bc0slAjL.js";import{C as xt,D as St,E as Ct,I as wt,M as Tt,O as Et,P as Dt,S as Ot,T as kt,_ as At,a as jt,b as Mt,d as Nt,f as Pt,g as Ft,h as It,i as Lt,j as Rt,k as zt,m as Bt,n as Vt,p as Ht,r as Ut,t as Wt,v as Gt,w as Kt,x as qt,y as Jt}from"./git-control-bar-branch-button-C8u5rzjc.js";import{n as Yt,t as Y}from"./use-conversation-id-DajhCn2A.js";import{t as X}from"./use-active-conversation-DS5j9R4q.js";import{t as Z}from"./use-agent-state-D2C9SeGw.js";import{S as Xt,a as Zt,d as Qt,o as $t,t as en}from"./use-event-store-BT_gV3ut.js";import{t as tn}from"./command-store-DFN_17p1.js";import{r as nn}from"./typography-vVUMoNUg.js";import{t as rn}from"./lesson-plan-DRYG5SLI.js";import{t as an}from"./copy-C7Ti2d8C.js";import{t as on}from"./use-runtime-is-ready-pGSbPddC.js";import{r as sn}from"./plan-components-DEjMuDDG.js";import{t as cn}from"./use-breakpoint-B86yKT9n.js";import{n as ln,t as un}from"./use-unified-vscode-url-wAMzv8Sn.js";import{t as dn}from"./use-task-list-DDeNHprj.js";import{t as fn}from"./vendor~conversation-panel~conversation~alert-banner-Df7_G0zR.js";var Q=e(t(),1),pn={curAgentState:U.LOADING},mn=Ze(e=>({...pn,setCurrentAgentState:t=>e({curAgentState:t}),reset:()=>e(pn)})),hn=`openhands-last-conversation-by-backend`;function gn(e,t){return t?`${e}::${t}`:e}function _n(){if(typeof window>`u`)return{};try{let e=window.localStorage.getItem(hn);if(!e)return{};let t=JSON.parse(e);if(typeof t!=`object`||!t)return{};let n={};for(let[e,r]of Object.entries(t))typeof r==`string`&&r.length>0&&(n[e]=r);return n}catch{return{}}}function vn(e){if(!(typeof window>`u`))try{window.localStorage.setItem(hn,JSON.stringify(e))}catch{}}function yn(e,t,n){if(!n)return;let r=_n();r[gn(e,t)]=n,vn(r)}function bn(e,t){let n=_n(),r=gn(e,t);r in n&&(delete n[r],vn(n))}var xn=e=>({action:S.CHANGE_AGENT_STATE,args:{agent_state:e}}),Sn=e=>`error`in e,Cn=e=>`type`in e&&e.type===`error`,wn=()=>{let{send:e}=x(),t=en(e=>e.events);Q.useEffect(()=>{if(!t.length)return;let n=t[t.length-1];if(!($t(n)&&Zt(n))){if(Sn(n)){if(n.error_code===401){z(`Session expired.`);return}typeof n.error==`string`?z(n.error):z(n.message);return}Cn(n)&&`${n.message??``}`.startsWith(`Agent reached maximum`)&&e(xn(U.PAUSED))}},[t.length])},Tn=()=>{let{curAgentState:e}=Z();return{runtimeActive:!Ee.includes(e)}};function En({children:e}){return wn(),Tn(),e}var $=m(),Dn=e=>(0,$.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 512 512`,...e,children:(0,$.jsx)(`path`,{d:`M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209L241 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L335 175c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z`})}),On={entriesByConversation:{}},kn=(e,t,n)=>({entriesByConversation:{...e.entriesByConversation,[t]:n(e.entriesByConversation[t]??[])}}),An=Ze()(Qe(e=>({...On,addPending:(t,n)=>{let r=Ne();return e(e=>kn(e,t,e=>[...e,{id:r,question:n,status:`pending`}])),r},resolve:(t,n,r)=>e(e=>kn(e,t,e=>e.map(e=>e.id===n?{...e,response:r,status:`done`}:e))),fail:(t,n,r)=>e(e=>kn(e,t,e=>e.map(e=>e.id===n?{...e,response:r,status:`error`}:e))),dismiss:(t,n)=>e(e=>kn(e,t,e=>e.filter(e=>e.id!==n)))}),{name:`BtwStore`}));function jn({onClick:e}){let{t}=v(`openhands`);return(0,$.jsxs)(`button`,{type:`button`,onClick:e,className:`flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-normal text-success bg-success/10 hover:bg-success/20 border border-success/30 transition-colors`,children:[(0,$.jsx)(Dn,{className:`w-3.5 h-3.5 fill-success`}),(0,$.jsx)(`span`,{children:t(h.CHAT_INTERFACE$BTW_GOT_IT)})]})}function Mn({conversationId:e}){let{t}=v(`openhands`),n=An(e=>e.entriesByConversation),r=An(e=>e.dismiss),i=e?n[e]??[]:[];return!e||i.length===0?null:(0,$.jsx)(`div`,{"data-testid":`btw-messages`,className:`flex flex-col w-full`,children:i.map(n=>{let i=n.status===`pending`;return(0,$.jsx)(w,{title:(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`opacity-60`,children:t(h.CHAT_INTERFACE$BTW_PREFIX)}),(0,$.jsx)(`span`,{children:n.question}),i&&(0,$.jsx)(`span`,{"data-testid":`btw-spinner`,className:`inline-block w-3.5 h-3.5 ml-2 rounded-full border-2 border-[var(--oh-border-input)] border-t-transparent animate-spin`})]}),details:i?t(h.CHAT_INTERFACE$BTW_WAITING_FOR_ANSWER):n.response??``,initiallyExpanded:!i,chevronPosition:`before`,titleTrailing:!i&&(0,$.jsx)(jn,{onClick:()=>r(e,n.id)})},n.id)})})}var Nn=`${ve} `,Pn=(e,t)=>{let n=An(e=>e.addPending),r=An(e=>e.resolve),i=An(e=>e.fail);return(0,Q.useCallback)(a=>{let o=a.trim(),s=o===`/btw`||o.startsWith(Nn);if(!e||!s){t(a);return}let c=o.slice(ve.length).trim();if(!c)return;let l=n(e,c);d(e,c).then(({response:t})=>r(e,l,t)).catch(t=>i(e,l,t?.message??`Failed to ask agent`))},[e,t,n,r,i])};function Fn({onSuggestionsClick:e,hasRepository:t,providerTokensReady:n,isConversationReady:r=!0}){let{t:i}=v(`openhands`),{trackPullButtonClick:a}=lt(),o=n&&t&&r;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{a(),e(ye())},disabled:!o,className:W(`flex flex-row gap-1 items-center justify-center px-0.5 py-1 rounded-[100px] w-[76px] min-w-[76px]`,o?`bg-[var(--oh-surface)] hover:bg-tertiary cursor-pointer`:`bg-[rgba(71,74,84,0.50)] cursor-not-allowed`),children:[(0,$.jsx)(`div`,{className:`w-3 h-3 flex items-center justify-center`,children:(0,$.jsx)(xt,{width:12,height:12,color:`white`})}),(0,$.jsx)(`div`,{className:`font-normal text-white text-sm leading-5 max-w-[76px] truncate`,title:i(h.COMMON$PULL),children:i(h.COMMON$PULL)})]})}function In({onSuggestionsClick:e,hasRepository:t,providerTokensReady:n,currentGitProvider:r,isConversationReady:i=!0}){let{t:a}=v(`openhands`),{trackPushButtonClick:o}=lt(),s=n&&t&&i;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{o(),e(Se(r))},disabled:!s,className:W(`flex flex-row gap-1 items-center justify-center px-2 py-1 rounded-[100px] w-[77px] min-w-[77px]`,s?`bg-[var(--oh-surface)] hover:bg-tertiary cursor-pointer`:`bg-[rgba(71,74,84,0.50)] cursor-not-allowed`),children:[(0,$.jsx)(`div`,{className:`w-3 h-3 flex items-center justify-center`,children:(0,$.jsx)(Kt,{width:12,height:12,color:`white`})}),(0,$.jsx)(`div`,{className:`font-normal text-white text-sm leading-5 max-w-[77px] truncate`,title:a(h.COMMON$PUSH),children:a(h.COMMON$PUSH)})]})}function Ln({onSuggestionsClick:e,hasRepository:t,providerTokensReady:n,currentGitProvider:r,isConversationReady:i=!0}){let{t:a}=v(`openhands`),{trackCreatePrButtonClick:o}=lt(),s=n&&t&&i;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{o(),e(we(r))},disabled:!s,className:W(`flex flex-row gap-1 items-center justify-center px-2 py-1 rounded-[100px] w-[126px] min-w-[126px] h-7`,s?`bg-[var(--oh-surface)] hover:bg-tertiary cursor-pointer`:`bg-[rgba(71,74,84,0.50)] cursor-not-allowed`),children:[(0,$.jsx)(`div`,{className:`w-3 h-3 flex items-center justify-center`,children:(0,$.jsx)(Ot,{width:12,height:12,color:`white`})}),(0,$.jsx)(`div`,{className:`font-normal text-white text-sm leading-5 max-w-[126px] truncate`,title:a(h.COMMON$PULL_REQUEST),children:a(h.COMMON$PULL_REQUEST)})]})}function Rn(e){return e.kind===`BashCommand`}function zn(e){return e.kind===`BashOutput`}function Bn(e){return e.kind===`BashError`}function Vn(e,t,n){let r=(0,Q.useRef)(null),i=(0,Q.useRef)([]),a=(0,Q.useRef)([]),o=(0,Q.useRef)(new Map);return(0,Q.useEffect)(()=>{if(!n)return;let s=ke(e,t),c=new WebSocket(s);r.current=c,c.onopen=()=>{for(let{command:e,cwd:t,timeout:n,resolve:r,reject:o}of i.current)a.current.push({resolve:r,reject:o}),c.send(JSON.stringify({command:e,cwd:t,timeout:n}));i.current=[]},c.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}if(Rn(t)){let e=a.current.shift();e&&o.current.set(t.id,{...e,stdout:[],stderr:[]})}else if(zn(t)&&t.command_id){let e=o.current.get(t.command_id);e&&(t.stdout&&e.stdout.push(t.stdout),t.stderr&&e.stderr.push(t.stderr),t.exit_code!=null&&(o.current.delete(t.command_id),e.resolve({exit_code:t.exit_code,stdout:e.stdout.join(``),stderr:e.stderr.join(``)})))}else Bn(t)&&l(`Bash error: ${t.code}: ${t.detail}`)};function l(e){let t=Error(e);for(let{reject:e}of i.current)e(t);i.current=[];for(let e of a.current)e.reject(t);a.current=[];for(let e of o.current.values())e.reject(t);o.current.clear()}return c.onclose=()=>{r.current=null,l(`Bash WebSocket closed`)},c.onerror=()=>{r.current=null,l(`Bash WebSocket error`)},()=>{c.onclose=null,c.onerror=null,c.close(),r.current=null,l(`Bash WebSocket unmounted`)}},[n,e,t]),(0,Q.useCallback)((e,t,n)=>new Promise((o,s)=>{let c=r.current;if(!c||c.readyState===WebSocket.CLOSED||c.readyState===WebSocket.CLOSING){s(Error(`Bash WebSocket not available`));return}c.readyState===WebSocket.CONNECTING?i.current.push({command:e,cwd:t,timeout:n,resolve:o,reject:s}):(a.current.push({resolve:o,reject:s}),c.send(JSON.stringify({command:e,cwd:t,timeout:n})))}),[])}var Hn={"github.com":`github`,"gitlab.com":`gitlab`,"bitbucket.org":`bitbucket`,"dev.azure.com":`azure_devops`};function Un(e){return e.replace(/\.git$/,``)}function Wn(e){return e?Hn[e.toLowerCase()]??null:null}function Gn(e){let t=e.split(`/`).filter(Boolean),n=t.indexOf(`_git`);return n===-1?t.join(`/`):[...t.slice(0,n),...t.slice(n+1)].join(`/`)}function Kn(e,t,n){let r=Un(n.replace(/^\/+/,``)),i=Wn(t);return{url:e,host:t,repository:(i===`azure_devops`?Gn(r):r)||null,provider:i}}function qn(e){let t=e?.trim();if(!t)return null;let n=t.match(/^[^@\s]+@([^:\s]+):(.+)$/);if(n){let e=n[1];return Kn(t,e,n[2])}try{let e=new URL(t);return Kn(t,e.hostname||null,e.pathname)}catch{return null}}var Jn={repository:null,branch:null,provider:null,remoteUrl:null},Yn=[`r=$(git remote get-url origin 2>/dev/null)`,`b=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)`,`if [ -z "$r$b" ]; then`,`n=$(find . -mindepth 2 -maxdepth 4 -name .git 2>/dev/null | cut -c3- | sed 's|/.git$||' | sort -u)`,`c=$(printf '%s\\n' "$n" | grep -c '[^[:space:]]')`,`if [ "$c" = "1" ] && [ -n "$n" ]; then`,`r=$(git -C "$n" remote get-url origin 2>/dev/null)`,`b=$(git -C "$n" rev-parse --abbrev-ref HEAD 2>/dev/null)`,`fi`,`fi`,`printf '%s\\n%s' "$r" "$b"`].join(`
|
|
3
|
+
`);async function Xn(e,t){let n=await e(Yn,t,10);if(n.exit_code!==0)return Jn;let r=n.stdout.indexOf(`
|
|
4
|
+
`),i=(r>=0?n.stdout.slice(0,r):n.stdout).trim(),a=(r>=0?n.stdout.slice(r+1):``).trim(),o=a&&a!==`HEAD`?a:null;if(!i&&!o)return Jn;let s=qn(i);return{repository:s?.repository??null,provider:s?.provider??null,remoteUrl:i||null,branch:o}}var Zn=()=>{let{data:e}=X(),t=on(),{backend:n}=G(),r=n.kind===`local`,i=e?.id,a=e?.conversation_url,o=e?.session_api_key,s=e?.workspace?.working_dir?.trim()||Oe(),l=!!e?.selected_repository,u=!!e?.git_provider,d=!!e?.selected_branch,f=r&&t&&!!i&&(!l||!u||!d),p=Vn(a,o,f),m=(0,Q.useRef)(p);return m.current=p,c({queryKey:[`local-git-info`,i,a,o,s],queryFn:async()=>Xn((e,t,n)=>m.current(e,t,n),s),enabled:f,retry:!1,staleTime:1e4,refetchInterval:1e4,gcTime:1e3*60*5,meta:{disableToast:!0}})},Qn=()=>{let e=g(),{t}=v(`openhands`);return p({mutationFn:e=>Pe.updateConversationRepository(e.conversationId,e.repository,e.branch,e.gitProvider),onMutate:async t=>{let n=[`user`,`conversation`,t.conversationId];await e.cancelQueries({queryKey:n});let r=e.getQueriesData({queryKey:n});return e.setQueriesData({queryKey:n},e=>e&&{...e,selected_repository:t.repository,selected_branch:t.branch??null,git_provider:t.gitProvider??null}),{previousEntries:r}},onError:(n,r,i)=>{i?.previousEntries.forEach(([t,n])=>{e.setQueryData(t,n)}),z(t(h.CONVERSATION$FAILED_TO_UPDATE_REPOSITORY))},onSuccess:()=>{ie(t(h.CONVERSATION$REPOSITORY_UPDATED))},onSettled:(t,n,r)=>{e.invalidateQueries({queryKey:[`user`,`conversation`,r.conversationId]}),e.invalidateQueries({queryKey:[`user`,`conversations`]}),e.invalidateQueries({queryKey:[`local-git-info`,r.conversationId]})}})};function $n({children:e,tooltipMessage:t,testId:n,shouldShowTooltip:r}){return r?(0,$.jsx)(We,{content:t,placement:`top`,showArrow:!0,tooltipClassName:`bg-white text-black`,children:(0,$.jsx)(`span`,{"data-testid":n,className:`hover:opacity-100`,children:e})}):e}function er({isOpen:e,onClose:t,onLaunch:n,defaultProvider:r=`github`}){let{t:i}=v(`openhands`),{providers:a}=Xe(),[o,s]=(0,Q.useState)(null),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{a.length===1&&!o?s(a[0]):a.length>1&&!o&&r&&a.includes(r)&&s(r)},[a,o,r]);let f=(0,Q.useCallback)(e=>{e!==o&&(s(e),l(null),d(null))},[o]),p=(0,Q.useCallback)(e=>{e?(l(e),d(null)):(l(null),d(null))},[]),m=(0,Q.useCallback)(e=>{d(e)},[]),g=()=>{!c||!u||(n(c,u),l(null),d(null),t())},_=()=>{s(null),l(null),d(null),t()};if(!e)return null;let y=c?.git_provider||o||r,b=!!c&&!!u;return(0,$.jsx)(Fe,{onClose:_,children:(0,$.jsxs)(Ie,{width:`sm`,className:`relative items-start border border-[var(--oh-border)] !gap-4`,children:[(0,$.jsx)(tt,{onClose:_,testId:`close-open-repository-modal`}),(0,$.jsx)(`div`,{className:`w-full pr-6`,children:(0,$.jsx)(Le,{title:i(h.CONVERSATION$OPEN_REPOSITORY)})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 w-full`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-sm text-white font-normal leading-[22px]`,children:i(h.CONVERSATION$SELECT_OR_INSERT_LINK)}),a.length>1&&(0,$.jsx)(jt,{providers:a,value:o,placeholder:`Select Provider`,onChange:f})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-[10px] w-full`,children:[(0,$.jsx)(Ut,{provider:y,value:c?.id||null,repositoryName:c?.full_name||null,onChange:p,placeholder:`Search repositories...`,className:`w-full`}),(0,$.jsx)(Lt,{repository:c?.full_name||null,provider:y,selectedBranch:u,onBranchSelect:m,defaultBranch:c?.main_branch||null,placeholder:`Select branch...`,disabled:!c,className:`w-full`})]})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2 w-full`,onClick:e=>e.stopPropagation(),children:[(0,$.jsx)(ze,{type:`button`,variant:`secondary`,onClick:_,children:i(h.BUTTON$CANCEL)}),(0,$.jsx)(ze,{type:`button`,variant:`primary`,onClick:g,isDisabled:!b,children:i(h.BUTTON$LAUNCH)})]})]})})}function tr({onSuggestionsClick:e}){let{t}=v(`openhands`),{conversationId:n}=Y(),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),s=(0,Q.useRef)(null),{addRecentRepository:c}=Je(),l=V(e=>e.enqueuePendingMessage),u=V(e=>e.markPendingMessageError),{backend:d}=G(),f=d.kind===`local`,{providers:p}=Xe(),m=f||p.length>0,{data:g}=X(),{repositoryInfo:_}=Et(),{data:y}=Zn(),b=Dt(),S=(0,Q.useRef)(b);(0,Q.useEffect)(()=>{S.current=b},[b]);let{send:C}=x(),w=(0,Q.useRef)(C);(0,Q.useEffect)(()=>{w.current=C},[C]);let T=D(),{mutate:ee}=Qn(),{mutate:E,isPending:O}=ut(),k=g?.selected_repository||_?.selectedRepository,A=g?.git_provider||_?.gitProvider,j=g?.selected_branch||_?.selectedBranch,M=k||y?.repository||void 0,N=A||y?.provider,te=j||y?.branch||void 0,P=(g?.id?je(g.id):null)?.selected_workspace??null,F=P&&P.replace(/\/+$/,``).split(`/`).pop()||null,I=!!M&&!!N,L=!!g&&b===`OPEN`;(0,Q.useEffect)(()=>{if(!a)return;let e=e=>{s.current&&!s.current.contains(e.target)&&o(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a]),(0,Q.useEffect)(()=>{if(!a)return;let e=e=>{e.key===`Escape`&&o(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a]);let ne=(e,r)=>{n&&(c(e),ee({conversationId:n,repository:e.full_name,branch:r.name,gitProvider:e.git_provider},{onSuccess:()=>{if(S.current!==`OPEN`){z(t(h.CONVERSATION$CLONE_COMMAND_FAILED_DISCONNECTED));return}let i=e.git_provider.charAt(0).toUpperCase()+e.git_provider.slice(1),a=`Clone ${e.full_name} from ${i} and checkout branch ${r.name}.`,o=n?l({conversationId:n,text:a}):null;T?.scrollDomToBottom(),Promise.resolve(w.current({action:`message`,args:{content:a,timestamp:new Date().toISOString()}})).catch(e=>{o&&u(o,e instanceof Error?e.message:`Failed to send message`)})}}))},R=!f||!!M||!!F,re=f&&!I;return R||te||I?(0,$.jsxs)(`div`,{className:`flex flex-row items-center`,children:[(0,$.jsxs)(`div`,{className:`flex flex-row gap-2.5 items-center overflow-x-auto flex-nowrap relative scrollbar-hide`,children:[R?(0,$.jsx)(Vt,{selectedRepository:M,gitProvider:N,workspaceName:F,onClick:()=>i(!0),disabled:!L||re}):null,te?(0,$.jsx)(Wt,{selectedBranch:te,selectedRepository:M,gitProvider:N}):null,I?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)($n,{tooltipMessage:t(h.COMMON$GIT_TOOLS_DISABLED_CONTENT),testId:`git-control-bar-pull-button-tooltip`,shouldShowTooltip:!I,children:(0,$.jsx)(Fn,{onSuggestionsClick:e,hasRepository:I,providerTokensReady:m,isConversationReady:L})}),(0,$.jsx)($n,{tooltipMessage:t(h.COMMON$GIT_TOOLS_DISABLED_CONTENT),testId:`git-control-bar-push-button-tooltip`,shouldShowTooltip:!I,children:(0,$.jsx)(In,{onSuggestionsClick:e,hasRepository:I,providerTokensReady:m,currentGitProvider:N,isConversationReady:L})}),(0,$.jsx)($n,{tooltipMessage:t(h.COMMON$GIT_TOOLS_DISABLED_CONTENT),testId:`git-control-bar-pr-button-tooltip`,shouldShowTooltip:!I,children:(0,$.jsx)(Ln,{onSuggestionsClick:e,hasRepository:I,providerTokensReady:m,currentGitProvider:N,isConversationReady:L})})]}):null]}),(0,$.jsx)(er,{isOpen:r,onClose:()=>i(!1),onLaunch:ne,defaultProvider:N})]}):null}function nr({onSubmit:e,disabled:t=!1}){let{images:n,files:r,imagesMarkedUploadAsFile:i,clearAllFiles:a,subConversationTaskId:o}=K(),{curAgentState:s}=Z(),{data:c}=X(),{conversationId:l}=Yt(),u=l??c?.id??null,{taskStatus:d}=St(o,c?.id||null),{handleUpload:f}=Nt(),p=Pt(u,Pn(u,t=>{let{imagesToEmbed:o,imagesAsFiles:s}=wt(n,i);e(t,o,[...r,...s]),a()}));return(0,$.jsxs)(`div`,{"data-testid":`interactive-chat-box`,children:[(0,$.jsx)(Ht,{disabled:t||s===U.AWAITING_USER_CONFIRMATION||Ce(d),isNewConversationPending:t,onSubmit:p,onFilesPaste:f}),(0,$.jsx)(`div`,{className:`mt-3 pb-3`,children:(0,$.jsx)(tr,{onSuggestionsClick:e=>{p(e)}})})]})}function rr(){let e=en(e=>e.events),t=en(e=>e.uiEvents),n=Q.useMemo(()=>t.filter(pe),[t]),r=Q.useMemo(()=>e,[e]),i=Q.useMemo(()=>n.length,[n]),a=Q.useMemo(()=>r.some(e=>e.source===`agent`&&!Xt(e)&&!Qt(e)),[r]),o=ce(r);return{storeEvents:e,uiEvents:t,renderableEvents:n,allConversationEvents:r,totalEvents:i,hasSubstantiveAgentActions:a,conversationUserEventsExist:o,userEventsExist:o}}var ir=e=>`timestamp`in e?e.timestamp:void 0,ar=e=>{let t=!!e&&$e(e),n=t?void 0:e,{data:r}=yt(e??null),{data:i,isFetched:a}=me(n??void 0),o=en(e=>e.addEvents),[s,c]=Q.useState(!1),[l,u]=Q.useState(!0),d=Q.useRef(!1),f=Q.useRef(!0);return Q.useEffect(()=>{if(d.current=!1,c(!1),t){f.current=!1,u(!1);return}f.current=!0,u(!0)},[e,t]),Q.useEffect(()=>{t||!a||!i||i.hasMore||(f.current=!1,u(!1))},[t,a,i?.hasMore,n]),{isLoading:s,hasMore:l,loadOlder:Q.useCallback(async()=>{if(!e||$e(e)||d.current||!f.current||!r)return;let{events:t}=en.getState(),n=t[0];if(!n)return;let i=ir(n);if(!i){f.current=!1,u(!1);return}d.current=!0,c(!0);try{let t=await H.searchEvents(e,r?.conversation_url??null,r?.session_api_key??null,{limit:50,sortOrder:`TIMESTAMP_DESC`,timestampLt:i});if(!Array.isArray(t.items))throw Error(`Invalid older-events response: expected page.items to be an array.`);let n=[...t.items].reverse();n.length>0&&o(n),(!t.next_page_id||t.items.length<50)&&(f.current=!1,u(!1))}finally{d.current=!1,c(!1)}},[e,r,r?.conversation_url,r?.session_api_key,o])}};function or(){return(0,$.jsxs)(`div`,{className:`flex items-center space-x-1.5 rounded-full bg-[var(--oh-surface)] px-3 py-1.5`,children:[(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--oh-muted)] animate-[bounce_0.5s_infinite] translate-y-[1px] [animation-delay:0ms]`}),(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--oh-muted)] animate-[bounce_0.5s_infinite] translate-y-[1px] [animation-delay:75ms]`}),(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--oh-muted)] animate-[bounce_0.5s_infinite] translate-y-[1px] [animation-delay:150ms]`})]})}function sr({suggestion:e,onClick:t}){let{t:n}=v(`openhands`);return(0,$.jsxs)(`button`,{type:`button`,className:`list-none border border-[var(--oh-border)] rounded-[15px] hover:bg-surface-raised hover:border-[var(--oh-interactive-hover)] transition-colors flex-1 flex items-center justify-center cursor-pointer gap-[10px] h-[55px] px-4`,onClick:()=>t(e.value),children:[(0,Q.useMemo)(()=>{switch(e.label){case`INCREASE_TEST_COVERAGE`:return(0,$.jsx)(qt,{width:24,height:24,color:`#fff`});case`AUTO_MERGE_PRS`:return(0,$.jsx)(Mt,{width:19,height:20,color:`#fff`});case`FIX_README`:return(0,$.jsx)(Jt,{width:24,height:24,color:`#fff`});case`CLEAN_DEPENDENCIES`:return(0,$.jsx)(Gt,{width:24,height:24,color:`#fff`});default:return null}},[e]),(0,$.jsx)(`span`,{"data-testid":`suggestion`,className:`text-[15px] font-normal leading-5 text-white text-center cursor-pointer`,children:n(e.label)})]})}function cr({suggestions:e,onSuggestionClick:t}){return(0,$.jsx)(`div`,{"data-testid":`suggestions`,className:`grid grid-cols-2 gap-5 max-w-fit`,children:e.map((e,n)=>(0,$.jsx)(sr,{suggestion:e,onClick:t},n))})}var lr=h.SUGGESTIONS$HACKER_NEWS,ur=`Please write a bash script which displays the top story on Hacker News. It should show the title, the link, and the number of points.
|
|
5
|
+
The script should only use tools that are widely available on unix systems, like curl and grep.`,dr=h.SUGGESTIONS$HELLO_WORLD,fr=`I want to create a Hello World app in Javascript that:
|
|
6
|
+
* Displays Hello World in the middle.
|
|
7
|
+
* Has a button that when clicked, changes the greeting with a bouncing animation to fun versions of Hello.
|
|
8
|
+
* Has a counter for how many times the button has been clicked.
|
|
9
|
+
* Has another button that changes the app's background color.`,pr=h.SUGGESTIONS$TODO_APP,mr=`I want to create a VueJS app that allows me to:
|
|
10
|
+
* See all the items on my todo list
|
|
11
|
+
* add a new item to the list
|
|
12
|
+
* mark an item as done
|
|
13
|
+
* totally remove an item from the list
|
|
14
|
+
* change the text of an item
|
|
15
|
+
* set a due date on the item
|
|
16
|
+
|
|
17
|
+
This should be a client-only app with no backend. The list should persist in localStorage.`,hr={repo:At,"non-repo":{[lr]:ur,[dr]:fr,[pr]:mr}};function gr({onSuggestionsClick:e}){let{t}=v(`openhands`),{shouldHideSuggestions:n}=K();return(0,$.jsx)(Ue,{children:!n&&(0,$.jsxs)(se.div,{"data-testid":`chat-suggestions`,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3,ease:`easeInOut`},className:`pointer-events-auto absolute inset-x-4 bottom-[151px] top-0 flex flex-col items-center justify-center md:inset-x-8`,children:[(0,$.jsx)(`div`,{className:`flex flex-col items-center p-4 rounded-xl w-full`,children:(0,$.jsx)(`span`,{className:`pb-6 text-[32px] font-medium leading-5 text-white`,children:t(h.LANDING$TITLE)})}),(0,$.jsx)(cr,{suggestions:Object.entries(hr.repo).slice(0,4).map(([e,t])=>({label:e,value:t})),onSuggestionClick:e})]})})}var _r={files:[],initialPrompt:null,selectedRepository:null,selectedRepositoryProvider:null,replayJson:null},vr=Ze(e=>({..._r,addFile:t=>e(e=>({files:[...e.files,t]})),removeFile:t=>e(e=>({files:e.files.filter((e,n)=>n!==t)})),clearFiles:()=>e(()=>({files:[]})),setInitialPrompt:t=>e(()=>({initialPrompt:t})),clearInitialPrompt:()=>e(()=>({initialPrompt:null})),setSelectedRepository:t=>e(()=>({selectedRepository:t})),clearSelectedRepository:()=>e(()=>({selectedRepository:null})),setSelectedRepositoryProvider:t=>e(()=>({selectedRepositoryProvider:t})),setReplayJson:t=>e(()=>({replayJson:t})),reset:()=>e(()=>_r)})),yr=e=>(0,$.jsx)(`svg`,{width:12,height:17,viewBox:`0 0 12 17`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,$.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M11.5304 6.46978L10.4697 7.53044L6.75006 3.81077L6.75006 17.0001H5.25006L5.25006 3.81077L1.53039 7.53044L0.469727 6.46978L6.00006 0.939453L11.5304 6.46978Z`,fill:`currentColor`})});function br({onClick:e}){return(0,$.jsx)(`button`,{type:`button`,onClick:e,"data-testid":`scroll-to-bottom`,className:`flex items-center justify-center size-8 rounded-full bg-[var(--oh-surface)] text-[var(--oh-muted)] hover:bg-tertiary hover:text-white rotate-180 cursor-pointer transition-colors`,children:(0,$.jsx)(yr,{width:15,height:15})})}var xr=[{width:`w-[25%]`,height:`h-4`,align:`justify-end`},{width:`w-[60%]`,height:`h-4`,align:`justify-start`},{width:`w-[45%]`,height:`h-4`,align:`justify-start`},{width:`w-[65%]`,height:`h-20`,align:`justify-start`},{width:`w-[35%]`,height:`h-4`,align:`justify-end`},{width:`w-[50%]`,height:`h-4`,align:`justify-start`},{width:`w-[30%]`,height:`h-4`,align:`justify-end`},{width:`w-[75%]`,height:`h-4`,align:`justify-start`},{width:`w-[55%]`,height:`h-4`,align:`justify-start`}];function Sr({width:e,height:t}){return(0,$.jsx)(`div`,{className:W(`rounded-md bg-foreground/5 animate-pulse`,e,t)})}function Cr(){return(0,$.jsx)(`div`,{className:`flex flex-col gap-6 p-4 w-full h-full overflow-hidden`,"data-testid":`chat-messages-skeleton`,"aria-label":`Loading conversation`,children:xr.map((e,t)=>(0,$.jsx)(`div`,{className:W(`flex w-full`,e.align),children:(0,$.jsx)(Sr,{width:e.width,height:e.height})},t))})}var wr=220;function Tr({message:e,onDismiss:t,onRetry:n}){let{t:r,i18n:i}=v(`openhands`),[a,o]=Q.useState(!1),[s,c]=Q.useState(!1),l=Q.useRef(null),u=i.exists(e,{ns:`openhands`}),d=u?String(r(e)):e,f=d.length>wr,p=f&&!a;return Q.useLayoutEffect(()=>{let e=l.current;if(!e)return;let t=()=>{let t=Number.parseFloat(getComputedStyle(e).lineHeight);if(!Number.isFinite(t)||t<=0){c(!1);return}c(e.getBoundingClientRect().height>t*1.5)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[d,p,a,e]),(0,$.jsxs)(`div`,{className:W(`flex w-full gap-2 rounded-lg border border-[var(--oh-border)] bg-[var(--oh-surface-raised)] p-2 text-[var(--oh-foreground)]`,s?`items-start`:`items-center`),"data-testid":`error-message-banner`,children:[(0,$.jsx)(re,{"aria-hidden":!0,className:`h-4 w-4 shrink-0`,strokeWidth:2,style:{color:xe},"data-testid":`error-message-banner-icon`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{ref:l,className:W(`whitespace-pre-wrap break-words text-sm text-[var(--oh-muted)]`,p&&`line-clamp-3`),"data-testid":`error-message-banner-content`,children:u?(0,$.jsx)(_,{ns:`openhands`,i18nKey:e}):e}),f&&(0,$.jsx)(`button`,{type:`button`,className:`mt-1 cursor-pointer text-xs font-normal text-[var(--oh-foreground)] underline`,onClick:()=>o(e=>!e),"data-testid":`error-message-banner-toggle`,children:r(a?h.COMMON$VIEW_LESS:h.COMMON$VIEW_MORE)})]}),(0,$.jsxs)(`div`,{className:W(`flex shrink-0 gap-1`,s?`self-start`:`items-center`),children:[n&&(0,$.jsx)(`button`,{type:`button`,onClick: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)]`,"data-testid":`error-message-banner-retry`,children:r(h.CHAT_INTERFACE$MESSAGE_RETRY)}),t&&(0,$.jsx)(`button`,{type:`button`,onClick:t,className:`shrink-0 cursor-pointer rounded-md p-1 text-[var(--oh-muted)] hover:bg-[var(--oh-interactive-hover)] hover:text-[var(--oh-foreground)]`,"aria-label":r(h.BUTTON$CLOSE),"data-testid":`error-message-banner-dismiss`,children:(0,$.jsx)(_e,{className:`h-4 w-4`,"aria-hidden":!0})})]})]})}function Er(){let{conversationId:e}=Yt(),t=V(e=>e.pendingMessages),n=V(e=>e.markPendingMessageError),r=V(e=>e.markPendingMessageSending),{send:i}=x(),a=Q.useMemo(()=>e?t.filter(t=>zt(e,t.conversationId)):[],[t,e]),o=Q.useCallback(async e=>{let t=V.getState().pendingMessages.find(t=>t.id===e);if(t){r(e);try{await i(k(t.text,t.imageUrls,t.fileUrls,t.timestamp))}catch(t){n(e,t instanceof Error?t.message:`Failed to send message`)}}},[i,n,r]);return a.length===0?null:(0,$.jsx)($.Fragment,{children:a.map(e=>(0,$.jsx)(E,{type:`user`,message:e.text,pendingStatus:e.status,onRetry:e.status===`error`?()=>o(e.id):void 0,children:e.imageUrls.length>0&&(0,$.jsx)(T,{size:`small`,images:e.imageUrls})},e.id))})}var Dr=()=>{let{data:e}=X();return p({mutationKey:[`unified-upload-files`],mutationFn:async t=>{let{conversationId:n,files:r}=t;return dt(n,r,e)},meta:{disableToast:!0}})},Or=e=>(0,$.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,...e,children:(0,$.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12 3.25C9.92893 3.25 8.25 4.92893 8.25 7V10H7C6.44772 10 6 10.4477 6 11V19C6 19.5523 6.44772 20 7 20H17C17.5523 20 18 19.5523 18 19V11C18 10.4477 17.5523 10 17 10H15.75V7C15.75 4.92893 14.0711 3.25 12 3.25ZM14.25 10V7C14.25 5.75736 13.2426 4.75 12 4.75C10.7574 4.75 9.75 5.75736 9.75 7V10H14.25Z`,fill:`currentColor`})});function kr(){let{t:e}=v(`openhands`),{data:t}=ct();return t?.confirmation_mode?(0,$.jsx)(We,{closeDelay:100,content:e(h.COMMON$CONFIRMATION_MODE_ENABLED),tooltipClassName:`bg-white text-black hover:bg-transparent`,children:(0,$.jsx)(`div`,{className:`flex items-center justify-center w-[26px] h-[26px] rounded-lg bg-[var(--oh-surface)]`,children:(0,$.jsx)(Or,{width:15,height:15})})}):null}var Ar=e=>(0,$.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,...e,children:(0,$.jsx)(`path`,{d:`M15 12C15 12.7956 14.6839 13.5587 14.1213 14.1213C13.5587 14.6839 12.7956 15 12 15C11.2044 15 10.4413 14.6839 9.87868 14.1213C9.31607 13.5587 9 12.7956 9 12C9 11.2044 9.31607 10.4413 9.87868 9.87868C10.4413 9.31607 11.2044 9 12 9C12.7956 9 13.5587 9.31607 14.1213 9.87868C14.6839 10.4413 15 11.2044 15 12Z`,fill:`currentColor`})});function jr({status:e,statusColor:t}){return(0,$.jsx)(`div`,{"data-testid":`chat-status-indicator`,className:He(`w-full max-w-full rounded-[100px] p-1 bg-[var(--oh-surface)] flex items-center gap-1`),children:(0,$.jsxs)(Ue,{mode:`wait`,children:[(0,$.jsx)(se.span,{className:`flex-shrink-0 animate-[pulse_1.2s_ease-in-out_infinite]`,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.3},children:(0,$.jsx)(Ar,{className:`w-4 h-4`,color:t})},`dot-${e}`),(0,$.jsx)(se.span,{initial:{opacity:0,y:-2},animate:{opacity:1,y:0},exit:{opacity:0,y:2},transition:{duration:.3},className:`pr-1.5 font-normal text-[11px] leading-[16px] normal-case break-words whitespace-normal`,children:e},`text-${e}`)]})})}var Mr=()=>{let e=g(),{navigate:t}=Ve(),{t:n}=v(`openhands`),{data:r}=X();return p({mutationFn:async()=>{if(!r?.id)throw Error(`No active conversation`);let e=await Pe.createConversation(void 0,void 0,void 0,void 0,void 0,void 0,void 0,r.sandbox_id??void 0);if(e.status===`ERROR`)throw Error(e.detail||`Failed to create new conversation`);return{newConversationId:e.app_conversation_id?e.app_conversation_id:`task-${e.id}`,oldConversationId:r.id}},onMutate:()=>{R.loading(n(h.CONVERSATION$CLEARING),{...ae,id:`clear-conversation`})},onSuccess:r=>{R.dismiss(`clear-conversation`),ie(n(h.CONVERSATION$CLEAR_SUCCESS)),t(`/conversations/${r.newConversationId}`),e.invalidateQueries({queryKey:[`user`,`conversations`]}),e.invalidateQueries({queryKey:[`v1-batch-get-app-conversations`]})},onError:e=>{R.dismiss(`clear-conversation`);let t=n(h.CONVERSATION$CLEAR_UNKNOWN_ERROR);e instanceof Error?t=e.message:typeof e==`string`&&(t=e),z(n(h.CONVERSATION$CLEAR_FAILED,{error:t}))}})};function Nr(e,t){return e?`github`:t?`replay`:`direct`}function Pr(){let e=Ae(),{setMessageToSend:t}=K(),{errorMessage:n,removeErrorMessage:r,setErrorMessage:i}=ue(),{isTask:a,taskStatus:o,taskDetail:s}=Et(),c=a,l=fe(),{send:u}=x(),{renderableEvents:d,allConversationEvents:f,totalEvents:p,hasSubstantiveAgentActions:m,userEventsExist:g}=rr(),_=V(e=>e.enqueuePendingMessage),S=V(e=>e.markPendingMessageError),C=V(e=>e.pendingMessages),{t:w}=v(`openhands`),T=Q.useRef(null),{scrollDomToBottom:E,onChatBodyScroll:D,hitBottom:A,autoScroll:j,setAutoScroll:M,setHitBottom:N}=sn(T),{mutate:te,isPending:P}=Mr(),{curAgentState:F}=Z(),{handleBuildPlanClick:I}=y(),{data:L}=X(),ne=L?.sandbox_status??null,R=ne===`MISSING`||ne===`ERROR`,re=F===U.RUNNING||F===U.LOADING;Q.useEffect(()=>{if(re)return;let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),I(e),E())};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[re,I,E]);let{selectedRepository:ie,replayJson:ae}=vr(),{conversationId:B}=Yt(),{mutateAsync:oe}=Dr(),{isLoading:se,hasMore:ce,loadOlder:le}=ar(B),H=Q.useRef(null),de=Q.useCallback(e=>{if(c||se||!ce)return;let t=e.scrollTop<=80,n=e.scrollHeight<=e.clientHeight+80;!t&&!n||(H.current={scrollHeight:e.scrollHeight,scrollTop:e.scrollTop},le().catch(e=>{H.current=null,i(e instanceof Error&&e.message?e.message:w(h.ERROR$GENERIC))}))},[ce,se,c,le,i,w]),pe=Q.useCallback(e=>{e.deltaY<0&&e.currentTarget.scrollTop<=0&&de(e.currentTarget)},[de]),me=Q.useMemo(()=>B?C.some(e=>zt(B,e.conversationId)):!1,[C,B]),he=f.length>0||me||!l?.isLoadingHistory,_e=!!B,ve=!he&&!a,ye=ge(e=>B?(e.entriesByConversation[B]?.length??0)>0:!1),xe=async(n,r,i)=>{if(n.trim()===`/new`){if(!B){z(w(h.CONVERSATION$CLEAR_NO_ID));return}if(p===0){z(w(h.CONVERSATION$CLEAR_EMPTY));return}if(P)return;te();return}let a=[...r],o=[...i];p===0?e.capture(`initial_query_submitted`,{entry_point:Nr(ie!==null,ae!==null),query_character_length:n.length,replay_json_size:ae?.length}):e.capture(`user_message_sent`,{session_message_count:p,current_message_length:n.length});let s=Rt([...a,...o]);if(!s.isValid){z(`Error: ${s.errorMessage}`);return}let c=a.map(e=>Tt(e)),l=await Promise.all(c),d=new Date().toISOString(),{skipped_files:f,uploaded_files:m}=o.length>0?await oe({conversationId:B,files:o}):{skipped_files:[],uploaded_files:[]};f.forEach(e=>z(e.reason));let g=`${w(`CHAT_INTERFACE$AUGMENTED_PROMPT_FILES_TITLE`)}: ${m.join(`
|
|
18
|
+
|
|
19
|
+
`)}`,v=m.length>0?`${n}\n\n${g}`:n,y=_({conversationId:B,text:n,content:v,imageUrls:l,fileUrls:m,timestamp:d});E(),t(``);try{await u(k(v,l,m,d))}catch(e){S(y,e instanceof Error?e.message:`Failed to send message`)}};Q.useEffect(()=>{if(H.current&&T.current){let{scrollHeight:e,scrollTop:t}=H.current,n=T.current,r=n.scrollHeight-e;r>0&&(n.scrollTop=t+r),H.current=null;return}j&&E()},[d.length,me,E]);let Se=Q.useRef(de);Q.useEffect(()=>{Se.current=de}),Q.useEffect(()=>{let e=T.current;e&&Se.current(e)},[d.length,ce]);let Ce={scrollRef:T,autoScroll:j,setAutoScroll:M,scrollDomToBottom:E,hitBottom:A,setHitBottom:N,onChatBodyScroll:D},we=F===U.LOADING||F===U.INIT,W=F===U.STOPPED,Ee=F===U.PAUSED,De=Te({isPausing:Ee,isTask:a,taskStatus:o,isStartingStatus:we,isStopStatus:W,curAgentState:F}),Oe=be({isPausing:Ee,isTask:a,taskStatus:o,taskDetail:s,isStartingStatus:we,isStopStatus:W,curAgentState:F,errorMessage:n,t:w});return(0,$.jsx)(ee,{value:Ce,children:(0,$.jsxs)(`div`,{className:`relative flex h-full flex-col justify-between px-4`,"data-testid":`chat-interface`,children:[!m&&!me&&!g&&!ye&&!ve&&!c&&p===0&&!R&&(0,$.jsx)(gr,{onSuggestionsClick:e=>t(e)}),(0,$.jsxs)(`div`,{ref:T,"data-testid":`chat-scroll-container`,onScroll:e=>{D(e.currentTarget),de(e.currentTarget)},onWheel:pe,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`,children:[ve&&_e&&(0,$.jsx)(Cr,{}),ve&&!_e&&(0,$.jsx)(`div`,{className:`flex justify-center`,"data-testid":`loading-spinner`,children:(0,$.jsx)(Be,{size:`small`})}),se&&(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-3 text-sm text-neutral-400`,"data-testid":`loading-older-events`,children:[(0,$.jsx)(Be,{size:`small`}),(0,$.jsx)(`span`,{children:w(h.CHAT_INTERFACE$FETCHING_OLDER_MESSAGES)})]}),(0,$.jsx)(b,{conversationId:B,anchorEventId:null}),he&&d.length>0&&(0,$.jsx)(O,{messages:d,allEvents:f}),(0,$.jsx)(Er,{})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-[6px]`,children:[(0,$.jsx)(Mn,{conversationId:B}),n&&(0,$.jsx)(Tr,{message:n,onDismiss:r,onRetry:n===`Unable to connect to server`?()=>l?.reconnect():void 0}),R?(0,$.jsxs)(`div`,{"data-testid":`archived-conversation-banner`,className:`mx-1 px-4 py-3 rounded-lg bg-[var(--oh-surface)] border border-[var(--oh-border-subtle)]`,children:[(0,$.jsx)(`p`,{className:`text-xs font-semibold text-[var(--oh-foreground)]`,children:w(ne===`ERROR`?h.CHAT_INTERFACE$ERROR_SANDBOX_TITLE:h.CHAT_INTERFACE$ARCHIVED_SANDBOX_TITLE)}),(0,$.jsx)(`p`,{className:`text-xs text-[var(--oh-muted)] mt-0.5`,children:w(ne===`ERROR`?h.CHAT_INTERFACE$ERROR_SANDBOX_DESCRIPTION:h.CHAT_INTERFACE$ARCHIVED_SANDBOX_DESCRIPTION)})]}):(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-full mb-1 z-20`,children:(0,$.jsxs)(`div`,{className:`flex justify-between relative`,children:[(0,$.jsxs)(`div`,{className:`flex items-end gap-1 pointer-events-auto`,children:[(0,$.jsx)(kr,{}),we&&(0,$.jsx)(jr,{statusColor:De,status:Oe})]}),A?F===U.RUNNING&&(0,$.jsx)(`div`,{className:`absolute left-1/2 transform -translate-x-1/2 bottom-0 pointer-events-auto`,children:(0,$.jsx)(or,{})}):(0,$.jsx)(`div`,{className:`absolute left-1/2 transform -translate-x-1/2 bottom-0 pointer-events-auto`,children:(0,$.jsx)(br,{onClick:E})})]})}),(0,$.jsx)(nr,{onSubmit:xe,disabled:P})]})]})]})})}function Fr({isRightPanelShown:e}){return(0,$.jsx)(`div`,{className:`flex justify-center w-full h-full`,children:(0,$.jsx)(`div`,{className:`w-full min-w-0 max-w-[800px] h-full flex flex-col min-h-0 transition-all duration-300 ease-in-out`,children:(0,$.jsx)(Pr,{})})})}function Ir({className:e}){let{t}=v(`openhands`);return(0,$.jsxs)(`div`,{className:W(`bg-[var(--oh-surface)] flex h-full w-full flex-col items-center justify-center gap-3`,e),children:[(0,$.jsx)(de,{className:`h-8 w-8 shrink-0 animate-spin text-[var(--oh-text-secondary)]`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`text-base font-normal leading-5 text-[var(--oh-text-secondary)]`,children:t(h.HOME$LOADING)})]})}function Lr({children:e}){return(0,$.jsx)(`div`,{className:`absolute inset-0`,children:e})}function Rr({children:e}){return(0,$.jsx)(`div`,{className:`flex flex-col h-full w-full`,children:e})}function zr({children:e}){return(0,$.jsx)(`div`,{className:`overflow-hidden flex-grow h-full w-full relative`,children:e})}var Br=(0,Q.lazy)(()=>n(()=>import(`./files-tab-CQHdWpQt.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60]))),Vr=(0,Q.lazy)(()=>n(()=>import(`./browser-tab-B_BuTvrO.js`),__vite__mapDeps([61,1,18,23,24,4,62,3,34,35,36,45,46,63,33]))),Hr=(0,Q.lazy)(()=>n(()=>import(`./vscode-tab-B0vdh9gU.js`),__vite__mapDeps([64,1,18,23,24,4,65,7,8,5,6,9,10,11,12,13,14,15,16,17,19,20,21,22,43,40,41,42,44,45,46,49,35,36,47,48,33,50,66,67,34,68]))),Ur=(0,Q.lazy)(()=>n(()=>import(`./planner-tab-bN6r1G-1.js`),__vite__mapDeps([69,1,18,23,24,4,34,35,36,37,29,27,28,30,31,25,3,26,32,38,39,70,68,71,72,73,74,75,76,7,8,5,6,9,10,11,12,13,14,15,16,17,19,77,21,78,22,79,80,81,20,40,41,82,42,43,44,45,46,83,84,33,58,85]))),Wr=(0,Q.lazy)(()=>n(()=>import(`./task-list-tab-465DDju0.js`),__vite__mapDeps([86,1,18,23,24,4,34,35,36,87,55,33,88,89,56,57]))),Gr=(0,Q.lazy)(()=>n(()=>import(`./terminal-CcgBEVnC.js`),__vite__mapDeps([90,1,91,92,18,4,67,23,24,35,36,47,42,43,5,6,7,8,9,10,11,12,13,14,15,16,17,19,44,20,21,22,40,41,45,46,48,33,93]))),Kr={tasklist:{component:Wr},files:{component:Br},browser:{component:Vr},vscode:{component:Hr},terminal:{component:Gr},planner:{component:Ur}};function qr(){let{selectedTab:e,shouldShownAgentLoading:t}=K(),{conversationId:n}=Y(),r=(0,Q.useMemo)(()=>Kr[e]??Kr.files,[e]).component;return t?(0,$.jsx)(Ir,{}):(0,$.jsx)(Rr,{children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(Ir,{}),children:(0,$.jsx)(zr,{children:(0,$.jsx)(Lr,{children:(0,$.jsx)(r,{})},e===`terminal`?`${e}-${n}`:e)})})})}var Jr=()=>{let e=g(),t=ue(e=>e.removeErrorMessage);return p({mutationKey:[`start-conversation`],mutationFn:async e=>f(e.conversationId),onMutate:async()=>(await e.cancelQueries({queryKey:[`user`,`conversations`]}),{previousConversations:e.getQueryData([`user`,`conversations`])}),onError:(t,n,r)=>{r?.previousConversations&&e.setQueryData([`user`,`conversations`],r.previousConversations)},onSettled:(t,n,r)=>{u(e,r.conversationId)},onSuccess:(n,r)=>{t(),l(e,r.conversationId,nt.RUNNING)}})},Yr=e=>(0,$.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,...e,children:[(0,$.jsx)(`path`,{d:`M9 9H15V15H9V9Z`,fill:`currentColor`}),(0,$.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12.9 1.50004C15.3 1.65004 17.55 2.85004 19.2 4.50004C21.15 6.60004 22.2 9.15004 22.2 12.15C22.2 14.55 21.3 16.8 19.8 18.75C18.3 20.55 16.2 21.9 13.8 22.35C11.4 22.8 9 22.5 6.9 21.3C4.8 20.1 3.15 18.3 2.25 16.05C1.35 13.8 1.2 11.25 1.95 9.00004C2.7 6.60004 4.05 4.65004 6.15 3.30004C8.1 1.95004 10.5 1.35004 12.9 1.50004ZM13.65 20.85C15.6 20.4 17.4 19.35 18.75 17.7C19.95 16.05 20.7 14.1 20.55 12C20.55 9.60004 19.65 7.20004 18 5.55004C16.5 4.05004 14.7 3.15004 12.6 3.00004C10.65 2.85004 8.55 3.30004 6.9 4.50004C5.25 5.70004 4.05 7.35004 3.45 9.45004C2.85 11.4 2.85 13.5 3.75 15.45C4.65 17.4 6 18.9 7.8 19.95C9.6 21 11.7 21.3 13.65 20.85Z`,fill:`currentColor`})]}),Xr=e=>(0,$.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,...e,children:[(0,$.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M12.9 1.50004C15.3 1.65004 17.55 2.85004 19.2 4.50004C21.15 6.60004 22.2 9.15004 22.2 12.15C22.2 14.55 21.3 16.8 19.8 18.75C18.3 20.55 16.2 21.9 13.8 22.35C11.4 22.8 9 22.5 6.9 21.3C4.8 20.1 3.15 18.3 2.25 16.05C1.35 13.8 1.2 11.25 1.95 9.00004C2.7 6.60004 4.05 4.65004 6.15 3.30004C8.1 1.95004 10.5 1.35004 12.9 1.50004ZM13.65 20.85C15.6 20.4 17.4 19.35 18.75 17.7C19.95 16.05 20.7 14.1 20.55 12C20.55 9.60004 19.65 7.20004 18 5.55004C16.5 4.05004 14.7 3.15004 12.6 3.00004C10.65 2.85004 8.55 3.30004 6.9 4.50004C5.25 5.70004 4.05 7.35004 3.45 9.45004C2.85 11.4 2.85 13.5 3.75 15.45C4.65 17.4 6 18.9 7.8 19.95C9.6 21 11.7 21.3 13.65 20.85Z`,fill:`currentColor`}),(0,$.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M9 7.49998L10.1655 6.87598L16.9155 11.376V12.624L10.1655 17.124L9 16.5V7.49998ZM10.5 8.90098V15.099L15.1485 12L10.5 8.90098Z`,fill:`currentColor`})]});function Zr({icon:e,text:t,onClick:n,testId:r}){return(0,$.jsx)(q,{testId:r,onClick:n,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 w-full items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:t}),(0,$.jsx)(`span`,{className:W(`flex shrink-0 items-center text-[var(--oh-muted)] group-hover:text-[var(--oh-foreground)] group-focus-visible:text-[var(--oh-foreground)] [&_svg]:text-current`,Re),"aria-hidden":!0,children:e})]})})}function Qr({className:e=``,executionStatus:t,isPausing:n=!1}){let{curAgentState:r}=Z(),{isTask:i,taskStatus:a,taskDetail:o}=Et(),{t:s}=v(`openhands`),{errorMessage:c}=ue(),l=r===U.LOADING||r===U.INIT,u=st(t)||at(t),d=Te({isPausing:n,isTask:i,taskStatus:a,isStartingStatus:l,isStopStatus:u,curAgentState:r}),f=be({isPausing:n,isTask:i,taskStatus:a,taskDetail:o,isStartingStatus:l,isStopStatus:u,curAgentState:r,errorMessage:c,t:s});return(0,$.jsx)(`div`,{className:e,"data-testid":`server-status`,children:(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(Ar,{className:`w-6 h-6 shrink-0`,color:d}),(0,$.jsx)(`span`,{className:`text-[13px] text-white font-normal`,children:f})]})})}function $r({onClose:e,onStopServer:t,onStartServer:n,executionStatus:r,position:i=`top`,className:a=``,isPausing:o=!1}){let{t:s}=v(`openhands`),c=it(e),l=ot(r),u=at(r),d=l||u;return(0,$.jsxs)(pt,{ref:c,testId:`server-status-context-menu`,position:i,alignment:`left`,size:`default`,className:W(`left-2 w-fit min-w-42`,a),children:[(0,$.jsx)(Qr,{executionStatus:r,isPausing:o,className:`pl-0 pr-2 py-1`}),d&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ge,{inset:`menu`}),l&&t&&(0,$.jsx)(Zr,{icon:(0,$.jsx)(Yr,{width:18,height:18}),text:s(h.COMMON$STOP_RUNTIME),onClick:t,testId:`stop-server-button`}),u&&n&&(0,$.jsx)(Zr,{icon:(0,$.jsx)(Xr,{width:18,height:18}),text:s(h.COMMON$START_RUNTIME),onClick:n,testId:`start-server-button`})]})]})}var ei=e(s(),1);function ti({isPublic:e,onToggle:t,ariaLabel:n}){return(0,$.jsxs)(`label`,{className:`relative inline-flex shrink-0 cursor-pointer items-center`,children:[(0,$.jsx)(`input`,{hidden:!0,type:`checkbox`,"data-testid":`share-publicly-button`,checked:e,"aria-label":n,onChange:e=>t(e.target.checked)}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:W(`inline-flex h-3.5 w-7 items-center rounded-full px-0.5 py-px transition-colors duration-200 ease-in-out`,e?`bg-white`:`bg-base-secondary`),children:(0,$.jsx)(`span`,{className:W(`block h-2 w-2 shrink-0 rounded-full transition-transform duration-200 ease-in-out`,e?`translate-x-[calc(1rem-1px)] bg-base-secondary`:`translate-x-px bg-tertiary-light`)})})]})}function ni({onClose:e,onRename:t,onDelete:n,onStop:r,onDisplayCost:i,onShowAgentTools:a,onShowSkills:o,onShowHooks:s,onTogglePublic:c,onCopyShareLink:l,onDownloadConversation:u,shareUrl:d,position:f=`bottom`,anchorRef:p}){let m=cn(),{t:g}=v(`openhands`),{backend:_}=G(),{data:y}=X(),b=it(e),x=p?.current??null,[S,C]=Q.useState();Q.useLayoutEffect(()=>{if(!x)return;let e=()=>{let e=x.getBoundingClientRect();if(!e)return;let t={position:`fixed`,zIndex:9999};f===`top`?t.bottom=window.innerHeight-e.top+8:t.top=e.bottom+8,t.left=e.left,C(t)};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[x,f]);let w=!!(a||o||s),T=!!i,ee=!!(r||n),E=_.kind===`cloud`?h.COMMON$CLOSE_CONVERSATION_STOP_RUNTIME:h.COMMON$STOP_CONVERSATION,D=_.kind===`cloud`&&!!c,O=y?.public||!1,k=!!x,j=(0,$.jsxs)(pt,{ref:b,testId:`conversation-name-context-menu`,position:f,alignment:`left`,className:W(m?`right-0 translate-x-[34%] left-auto`:``,k?`!static !top-auto !bottom-auto !left-auto !right-auto !mt-0`:``),children:[t&&(0,$.jsx)(q,{testId:`rename-button`,onClick:t,children:(0,$.jsx)(J,{icon:(0,$.jsx)(gt,{width:16,height:16}),text:g(h.BUTTON$RENAME)})}),w&&(0,$.jsx)(Ge,{testId:`separator-tools`,inset:`menu`}),o&&(0,$.jsx)(q,{testId:`show-skills-button`,onClick:o,children:(0,$.jsx)(J,{icon:(0,$.jsx)(_t,{width:16,height:16,className:`stroke-[1.75]`,"aria-hidden":!0}),text:g(h.CONVERSATION$SHOW_SKILLS)})}),s&&(0,$.jsx)(q,{testId:`show-hooks-button`,onClick:s,children:(0,$.jsx)(J,{icon:(0,$.jsx)(kt,{width:16,height:16,"aria-hidden":!0}),text:g(h.CONVERSATION$SHOW_HOOKS)})}),a&&(0,$.jsx)(q,{testId:`show-agent-tools-button`,onClick:a,children:(0,$.jsx)(J,{icon:(0,$.jsx)(qe,{width:16,height:16}),text:g(h.BUTTON$SHOW_AGENT_TOOLS_AND_METADATA)})}),u&&(0,$.jsx)(q,{testId:`download-trajectory-button`,onClick:u,children:(0,$.jsx)(J,{icon:(0,$.jsx)(A,{width:16,height:16}),text:g(h.BUTTON$EXPORT_CONVERSATION)})}),(T||ee)&&(0,$.jsx)(Ge,{testId:`separator-info-control`,inset:`menu`}),i&&(0,$.jsx)(q,{testId:`display-cost-button`,onClick:i,children:(0,$.jsx)(J,{icon:(0,$.jsx)(I,{width:16,height:16}),text:g(h.BUTTON$DISPLAY_COST)})}),D&&c&&(0,$.jsxs)(`li`,{className:`flex w-full items-center gap-2 rounded px-2 py-2 hover:bg-[var(--oh-interactive-hover)]`,children:[(0,$.jsx)(`span`,{className:`flex shrink-0 items-center text-[var(--oh-muted)]`,"aria-hidden":!0,children:(0,$.jsx)(B,{size:16})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm`,children:g(h.CONVERSATION$SHARE_PUBLICLY)}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center`,children:[O&&d&&l&&(0,$.jsxs)(`div`,{className:`mr-2 flex items-center gap-0.5`,children:[(0,$.jsx)(`button`,{type:`button`,"data-testid":`copy-share-link-button`,onClick:l,className:`rounded p-0.5 text-[var(--oh-muted)] hover:bg-[var(--oh-interactive-selected)] hover:text-[var(--oh-foreground)] cursor-pointer [&_svg]:text-current`,title:g(h.BUTTON$COPY_TO_CLIPBOARD),children:(0,$.jsx)(an,{width:14,height:14})}),(0,$.jsx)(`a`,{"data-testid":`open-share-link-button`,href:d,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),className:`rounded p-0.5 text-[var(--oh-muted)] no-underline visited:text-[var(--oh-muted)] hover:bg-[var(--oh-interactive-selected)] hover:text-[var(--oh-foreground)] cursor-pointer [&_svg]:text-current`,title:g(h.BUTTON$OPEN_IN_NEW_TAB),children:(0,$.jsx)(oe,{size:14,"aria-hidden":!0})})]}),(0,$.jsx)(ti,{isPublic:O,onToggle:c,ariaLabel:g(h.CONVERSATION$SHARE_PUBLICLY)})]})]}),r&&(0,$.jsx)(q,{testId:`stop-button`,onClick:r,children:(0,$.jsx)(J,{icon:(0,$.jsx)(Ye,{width:16,height:16}),text:g(E)})}),n&&(0,$.jsx)(q,{testId:`delete-button`,onClick:n,children:(0,$.jsx)(J,{icon:(0,$.jsx)(mt,{width:16,height:16}),text:g(h.COMMON$DELETE_CONVERSATION)})})]});return k?typeof document>`u`||!S?null:ei.createPortal((0,$.jsx)(`div`,{style:S,children:j}),document.body):j}function ri({onClose:e}){let{t}=v(`openhands`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(tt,{onClose:e,testId:`close-metrics-modal`}),(0,$.jsx)(`div`,{className:`w-full pr-6`,children:(0,$.jsx)(Le,{title:t(h.CONVERSATION$METRICS_INFO)})})]})}function ii({currentCost:e,maxBudget:t}){let n=e/t*100;return(0,$.jsx)(`div`,{className:`w-full h-1.5 bg-tertiary rounded-full overflow-hidden mt-1`,children:(0,$.jsx)(`div`,{className:W(`h-full transition-all duration-300`,n>80?`bg-red-500`:`bg-blue-500`),style:{width:`${Math.min(100,n)}%`}})})}function ai({currentCost:e,maxBudget:t}){let{t:n}=v(`openhands`),r=e/t*100;return(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(`span`,{className:`text-xs text-[var(--oh-muted)]`,children:n(h.CONVERSATION$BUDGET_USAGE_FORMAT,{currentCost:`$${e.toFixed(4)}`,maxBudget:`$${t.toFixed(4)}`,usagePercentage:r.toFixed(2),used:n(h.CONVERSATION$USED)})})})}function oi({cost:e,maxBudgetPerTask:t}){let{t:n}=v(`openhands`);return e===null?null:(0,$.jsx)(`div`,{className:`border-b border-[var(--oh-border-subtle)]`,children:t!==null&&t>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ii,{currentCost:e,maxBudget:t}),(0,$.jsx)(ai,{currentCost:e,maxBudget:t})]}):(0,$.jsx)(`span`,{className:`text-xs text-[var(--oh-muted)]`,children:n(h.CONVERSATION$NO_BUDGET_LIMIT)})})}function si({cost:e,maxBudgetPerTask:t}){let{t:n}=v(`openhands`);return e===null?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex justify-between items-center pb-2`,children:[(0,$.jsx)(`span`,{className:`text-lg font-semibold`,children:n(h.CONVERSATION$TOTAL_COST)}),(0,$.jsxs)(`span`,{className:`font-semibold`,children:[`$`,e.toFixed(4)]})]}),(0,$.jsx)(oi,{cost:e,maxBudgetPerTask:t})]})}function ci({label:e,value:t,labelClassName:n=``,valueClassName:r=`font-semibold`}){return(0,$.jsxs)(`div`,{className:`flex justify-between items-center border-b border-[var(--oh-border-subtle)] pb-2`,children:[(0,$.jsx)(`span`,{className:n,children:e}),(0,$.jsx)(`span`,{className:r,children:t})]})}function li({usage:e}){let{t}=v(`openhands`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ci,{label:t(h.CONVERSATION$INPUT),value:e.prompt_tokens.toLocaleString()}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 pl-4 text-sm`,children:[(0,$.jsx)(`span`,{className:`text-[var(--oh-muted)]`,children:t(h.CONVERSATION$CACHE_HIT)}),(0,$.jsx)(`span`,{className:`text-right`,children:e.cache_read_tokens.toLocaleString()}),(0,$.jsx)(`span`,{className:`text-[var(--oh-muted)]`,children:t(h.CONVERSATION$CACHE_WRITE)}),(0,$.jsx)(`span`,{className:`text-right`,children:e.cache_write_tokens.toLocaleString()})]}),(0,$.jsx)(ci,{label:t(h.CONVERSATION$OUTPUT),value:e.completion_tokens.toLocaleString()}),(0,$.jsx)(ci,{label:t(h.CONVERSATION$TOTAL),value:(e.prompt_tokens+e.completion_tokens).toLocaleString(),labelClassName:`font-semibold`,valueClassName:`font-bold`})]})}function ui({perTurnToken:e,contextWindow:t}){let{t:n}=v(`openhands`),r=t>0?e/t*100:0,i=Math.min(100,r);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsx)(`span`,{className:`font-semibold`,children:n(h.CONVERSATION$CONTEXT_WINDOW)})}),(0,$.jsx)(`div`,{className:`w-full h-1.5 bg-tertiary rounded-full overflow-hidden`,children:(0,$.jsx)(`div`,{className:`h-full bg-foreground transition-all duration-300`,style:{width:`${i}%`}})}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsxs)(`span`,{className:`text-xs text-[var(--oh-muted)]`,children:[e.toLocaleString(),` / `,t.toLocaleString(),` (`,r.toFixed(2),`% `,n(h.CONVERSATION$USED),`)`]})})]})}function di(){let{t:e}=v(`openhands`);return(0,$.jsx)(`div`,{className:`text-center`,children:(0,$.jsx)(`p`,{className:`text-[var(--oh-muted)]`,children:e(h.CONVERSATION$NO_METRICS)})})}function fi(e){let{stats:t}=e;if(!t?.usage_to_metrics)return{accumulated_cost:0,max_budget_per_task:null,accumulated_token_usage:null};let n=0,r=null,i=null;for(let e of Object.values(t.usage_to_metrics))n+=e.accumulated_cost,r===null&&e.max_budget_per_task!==null&&(r=e.max_budget_per_task),e.accumulated_token_usage&&(i=i===null?{...e.accumulated_token_usage}:{prompt_tokens:i.prompt_tokens+e.accumulated_token_usage.prompt_tokens,completion_tokens:i.completion_tokens+e.accumulated_token_usage.completion_tokens,cache_read_tokens:i.cache_read_tokens+e.accumulated_token_usage.cache_read_tokens,cache_write_tokens:i.cache_write_tokens+e.accumulated_token_usage.cache_write_tokens,context_window:Math.max(i.context_window,e.accumulated_token_usage.context_window),per_turn_token:Math.max(i.per_turn_token,e.accumulated_token_usage.per_turn_token)});return{accumulated_cost:n,max_budget_per_task:r,accumulated_token_usage:i}}var pi=(e,t,n,r=!0)=>{let i=c({queryKey:[`conversation-metrics`,e,t,n],queryFn:async()=>{if(!e)throw Error(`Conversation ID is required`);return fi(await Pe.getRuntimeConversation(e,t,n))},enabled:r&&!!e&&!!t,staleTime:1e3*30,gcTime:1e3*60*5,refetchInterval:1e3*30,retry:!1});return{data:i.data,isLoading:i.isLoading,error:i.error}};function mi({isOpen:e,onOpenChange:t}){let n=le(),{data:r}=X(),i=r?.id,a=r?.conversation_url,o=r?.session_api_key,{data:s}=pi(i,a,o,e),c=(0,Q.useMemo)(()=>s?{cost:s.accumulated_cost,max_budget_per_task:s.max_budget_per_task,usage:s.accumulated_token_usage?{prompt_tokens:s.accumulated_token_usage.prompt_tokens??0,completion_tokens:s.accumulated_token_usage.completion_tokens??0,cache_read_tokens:s.accumulated_token_usage.cache_read_tokens??0,cache_write_tokens:s.accumulated_token_usage.cache_write_tokens??0,context_window:s.accumulated_token_usage.context_window??0,per_turn_token:s.accumulated_token_usage.per_turn_token??0}:null}:n,[s,n]);return e?(0,$.jsx)(Fe,{onClose:()=>t(!1),children:(0,$.jsxs)(Ie,{testID:`metrics-modal`,className:`relative items-start border border-[var(--oh-border)]`,children:[(0,$.jsx)(ri,{onClose:()=>t(!1)}),(0,$.jsxs)(`div`,{className:`w-full`,children:[(c?.cost!==null||c?.usage!==null)&&(0,$.jsx)(`div`,{className:`rounded-md border border-[var(--oh-border)] bg-surface-raised p-3`,children:(0,$.jsxs)(`div`,{className:`grid gap-3`,children:[(0,$.jsx)(si,{cost:c?.cost??null,maxBudgetPerTask:c?.max_budget_per_task??null}),c?.usage!==null&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(li,{usage:c.usage}),(0,$.jsx)(ui,{perTurnToken:c.usage.per_turn_token,contextWindow:c.usage.context_window})]})]})}),!c?.cost&&!c?.usage&&(0,$.jsx)(`div`,{className:`rounded-md border border-[var(--oh-border)] bg-surface-raised p-3`,children:(0,$.jsx)(di,{})})]})]})}):null}function hi(){let{t:e}=v(`openhands`),{conversationId:t}=Y(),{data:n}=X(),{mutate:r}=te(),[i,a]=Q.useState(`view`),[o,s]=Q.useState(!1),c=Q.useRef(null),l=Q.useRef(null),{handleDelete:u,handleStop:d,handleDownloadConversation:f,handleDisplayCost:p,handleShowAgentTools:m,handleShowSkills:g,handleShowHooks:_,handleTogglePublic:y,handleCopyShareLink:b,shareUrl:x,handleConfirmDelete:S,handleConfirmStop:C,metricsModalVisible:w,setMetricsModalVisible:T,systemModalVisible:ee,setSystemModalVisible:E,skillsModalVisible:D,setSkillsModalVisible:O,hooksModalVisible:k,setHooksModalVisible:A,confirmDeleteModalVisible:M,setConfirmDeleteModalVisible:N,confirmStopModalVisible:P,setConfirmStopModalVisible:F,systemMessage:I,shouldShowStop:L,shouldShowDownloadConversation:R,shouldShowDisplayCost:z,shouldShowAgentTools:re,shouldShowSkills:ae,shouldShowHooks:B}=Ct({conversationId:t,executionStatus:n?.execution_status,showOptions:!0,onContextMenuToggle:s});return Q.useEffect(()=>{i===`edit`&&c.current?.focus()},[i]),n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 h-[22px] text-base font-normal text-left pl-0 lg:pl-1 min-w-0`,"data-testid":`conversation-name`,children:[i===`edit`?(0,$.jsx)(`input`,{ref:c,"data-testid":`conversation-name-input`,onClick:e=>{i===`edit`&&(e.preventDefault(),e.stopPropagation())},onBlur:()=>{if(c.current?.value&&t){let i=c.current.value.trim();i!==n?.title&&r({conversationId:t,newTitle:i},{onSuccess:()=>{ie(e(h.CONVERSATION$TITLE_UPDATED))}})}else c.current&&(c.current.value=n?.title??``);a(`view`)},onKeyUp:e=>{e.nativeEvent.isComposing||e.key===`Enter`&&e.currentTarget.blur()},type:`text`,defaultValue:n.title||``,className:`text-white leading-5 bg-transparent border-none outline-none text-base font-normal w-fit max-w-fit field-sizing-content`}):(0,$.jsx)(`div`,{className:`text-white leading-5 truncate`,"data-testid":`conversation-name-title`,onDoubleClick:()=>{a(`edit`)},title:n.title||``,children:n.title}),i!==`edit`&&(0,$.jsxs)(`div`,{ref:l,className:`relative flex items-center shrink-0`,children:[(0,$.jsx)(ht,{onClick:e=>{e.preventDefault(),e.stopPropagation(),s(!o)}}),o&&(0,$.jsx)(ni,{onClose:()=>s(!1),onRename:e=>{e.preventDefault(),e.stopPropagation(),a(`edit`),s(!1)},onDelete:u,onStop:L?d:void 0,onDisplayCost:z?p:void 0,onShowAgentTools:re?m:void 0,onShowSkills:ae?g:void 0,onShowHooks:B?_:void 0,onTogglePublic:y,onCopyShareLink:b,shareUrl:x,onDownloadConversation:R?f:void 0,position:`bottom`,anchorRef:l})]})]}),(0,$.jsx)(mi,{isOpen:w,onOpenChange:T}),(0,$.jsx)(Ft,{isOpen:ee,onClose:()=>E(!1),systemMessage:I||null}),D&&(0,$.jsx)(It,{onClose:()=>O(!1)}),k&&(0,$.jsx)(Bt,{onClose:()=>A(!1)}),M&&(0,$.jsx)(j,{onConfirm:S,onCancel:()=>N(!1),conversationTitle:n?.title||``}),P&&(0,$.jsx)(ne,{onConfirm:C,onCancel:()=>F(!1)})]}):null}function gi({children:e,tooltip:t,ariaLabel:n}){return(0,$.jsx)(We,{content:t,placement:`bottom`,tooltipClassName:`bg-white text-black text-xs font-medium leading-5`,children:(0,$.jsx)(`span`,{"data-aria-label":n,children:e})})}function _i({className:e}){let{t}=v(`openhands`),n=cn(),r=a(),{conversationId:i}=Y(),{isRightPanelShown:o,setHasRightPanelToggled:s,setIsRightPanelShown:c,setSelectedTab:l}=K(),u=()=>{if(n){if(!i)return;s(!0),c(!0);let{selectedTab:e}=K.getState();e||l(`files`),r(`/conversations/${i}/panel`);return}let e=!o;if(s(e),e){let{selectedTab:e}=K.getState();e||l(`files`)}},d=t(n?h.COMMON$SHOW_PANEL:o?h.COMMON$HIDE_PANEL:h.COMMON$SHOW_PANEL),f=n?!1:o;return(0,$.jsx)(gi,{tooltip:d,ariaLabel:d,children:(0,$.jsx)(`button`,{type:`button`,onClick:u,className:W(F,e),"aria-label":d,"aria-pressed":f,"data-testid":`right-panel-toggle`,children:(0,$.jsx)(P,{className:`w-5 h-5 -scale-x-100`})})})}function vi(){let{conversationId:e}=Y(),{data:t}=X(),{curAgentState:n}=Z(),{isTask:r,taskStatus:i}=Et(),{mutate:a}=Ke(),{mutate:o}=Jr(),{providers:s}=Xe(),c=t?.execution_status??null,l=Te({isPausing:!1,isTask:r,taskStatus:i,isStartingStatus:n===U.LOADING||n===U.INIT,isStopStatus:st(c),curAgentState:n});return(0,$.jsxs)(`div`,{className:`flex items-center justify-between w-full`,children:[(0,$.jsxs)(`div`,{className:`flex items-center min-w-0`,children:[(0,$.jsxs)(`div`,{className:`group relative shrink-0`,children:[(0,$.jsx)(Ar,{className:`ml-[3.5px] w-6 h-6 cursor-pointer`,color:l}),(0,$.jsx)($r,{onClose:()=>{},onStopServer:ot(c)?t=>{t.preventDefault(),t.stopPropagation(),e&&a({conversationId:e})}:void 0,onStartServer:at(c)?t=>{t.preventDefault(),t.stopPropagation(),e&&o({conversationId:e,providers:s})}:void 0,executionStatus:c,position:`bottom`,className:`opacity-0 invisible pointer-events-none group-hover:opacity-100 group-hover:visible group-hover:pointer-events-auto bottom-full left-0 mt-0 min-h-fit`,isPausing:!1})]}),(0,$.jsx)(hi,{})]}),(0,$.jsx)(_i,{className:`mr-2`})]})}var yi=e=>(0,$.jsx)(`svg`,{viewBox:`0 0 18 18`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,$.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M2.4375 9C2.4375 5.37563 5.37563 2.4375 9 2.4375C12.6244 2.4375 15.5625 5.37563 15.5625 9C15.5625 12.6244 12.6244 15.5625 9 15.5625C5.37563 15.5625 2.4375 12.6244 2.4375 9ZM4.13812 6.5625C4.81317 5.21867 6.02897 4.19333 7.49996 3.77204C7.15155 4.17641 6.85182 4.65395 6.60713 5.17892C6.40828 5.60556 6.24263 6.06975 6.11494 6.5625H4.13812ZM3.72196 7.6875C3.61778 8.10783 3.5625 8.54746 3.5625 9C3.5625 9.45254 3.61778 9.89217 3.72196 10.3125H5.89738C5.84161 9.88758 5.8125 9.44852 5.8125 8.99998C5.8125 8.55142 5.84161 8.11239 5.89737 7.6875H3.72196ZM7.0333 7.6875C6.97087 8.10689 6.9375 8.54634 6.9375 8.99998C6.9375 9.45367 6.97087 9.89313 7.0333 10.3125H10.9667C11.0291 9.89311 11.0625 9.45367 11.0625 9.00002C11.0625 8.54637 11.0291 8.1069 10.9667 7.6875H7.0333ZM12.1026 7.6875C12.1584 8.1124 12.1875 8.55145 12.1875 9.00002C12.1875 9.44858 12.1584 9.88762 12.1026 10.3125H14.278C14.3822 9.89217 14.4375 9.45254 14.4375 9C14.4375 8.54746 14.3822 8.10783 14.278 7.6875H12.1026ZM13.8619 6.5625H11.885C11.7574 6.06976 11.5917 5.6056 11.3929 5.17897C11.1482 4.65397 10.8484 4.1764 10.5 3.77203C11.971 4.19331 13.1868 5.21866 13.8619 6.5625ZM10.7171 6.5625H7.28293C7.38007 6.23971 7.49559 5.93571 7.62681 5.65419C7.99835 4.85708 8.48101 4.26914 8.99997 3.92442C9.51895 4.26913 10.0016 4.8571 10.3732 5.65424C10.5044 5.93575 10.6199 6.23973 10.7171 6.5625ZM4.13812 11.4375H6.11496C6.24963 11.9572 6.42655 12.4452 6.64015 12.8909C6.87835 13.3879 7.16685 13.8413 7.50006 14.228C6.02902 13.8067 4.81318 12.7814 4.13812 11.4375ZM10.7171 11.4375H7.28295C7.3869 11.7829 7.51191 12.1068 7.65465 12.4047C8.02305 13.1733 8.49456 13.7398 9.00007 14.0756C9.51902 13.7308 10.0017 13.1429 10.3732 12.3458C10.5044 12.0643 10.6199 11.7603 10.7171 11.4375ZM11.3929 12.8211C11.5917 12.3944 11.7574 11.9303 11.8851 11.4375H13.8619C13.1868 12.7813 11.971 13.8067 10.5 14.228C10.8485 13.8236 11.1482 13.346 11.3929 12.8211Z`,fill:`currentColor`})}),bi=e=>(0,$.jsxs)(`svg`,{width:20,height:20,viewBox:`0 0 20 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[(0,$.jsx)(`path`,{d:`M3 10.5L6.5 14L14 6`,stroke:`currentColor`,strokeWidth:2.2,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,$.jsx)(`path`,{d:`M7 10.5L10.5 14L18 6`,stroke:`currentColor`,strokeWidth:2.2,strokeLinecap:`round`,strokeLinejoin:`round`})]});function xi({tabValue:e,icon:t,onClick:n,isActive:r,label:i,className:a,measureOnly:o}){return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{n()},...o?{}:{"data-testid":`conversation-tab-${e}`},"data-tab-measure":o?`true`:void 0,className:W(`flex items-center gap-2 rounded-md cursor-pointer`,`pl-1.5 pr-2 py-1 lg:py-1.5`,`text-[var(--oh-muted)] bg-transparent`,r&&`bg-[var(--oh-interactive-active)] text-white`,r?`hover:text-white hover:bg-[var(--oh-interactive-hover)]`:`hover:text-white hover:bg-white/5`,r?`focus-within:text-white`:`focus-within:text-[var(--oh-muted)]`,a),children:[(0,$.jsx)(t,{className:W(`w-5 h-5 text-inherit flex-shrink-0`)}),r&&i&&(0,$.jsx)(`span`,{className:`text-sm font-normal whitespace-nowrap`,children:i})]})}function Si(){let{curAgentState:e}=Z(),{t}=v(`openhands`),{data:n,refetch:r}=un(),i=De.includes(e);return(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:t(h.COMMON$CODE)}),i?null:(0,$.jsx)(ft,{className:`w-3 h-3 text-inherit cursor-pointer`,onClick:async e=>{e.preventDefault(),e.stopPropagation();let t=n?.url;t||=(await r()).data?.url??null,t&&window.open(t,`_blank`,`noopener,noreferrer`)}})]})}var Ci=e=>(0,$.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,...e,children:(0,$.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M7.13832 8.76476C8.25957 8.17949 9.52697 7.9727 10.7515 8.14436L14.9025 2.52826L21.4717 9.09737L15.8555 13.2484C16.0272 14.4729 15.8204 15.7403 15.2351 16.8616C15.1872 16.9535 15.1366 17.0444 15.0836 17.1343C14.8318 17.5605 14.5228 17.9624 14.1566 18.3286L10.4443 14.6163L4.75207 20.3085H3.69141V19.2478L9.38361 13.5556L5.6713 9.84332C6.03755 9.47708 6.43936 9.16808 6.86562 8.91632C6.95547 8.86326 7.04641 8.81274 7.13832 8.76476ZM15.0735 4.82054L19.1794 8.92641L14.2461 12.5727L14.3701 13.4567C14.492 14.3266 14.3596 15.2233 13.9758 16.0265L7.97338 10.0241C8.77665 9.64035 9.67335 9.50789 10.5432 9.62984L11.4272 9.75376L15.0735 4.82054Z`,fill:`currentColor`})}),wi=e=>(0,$.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,...e,children:(0,$.jsx)(`path`,{d:`M10.9706 10.1586C10.2819 10.0621 9.56905 10.1784 8.93842 10.5075C8.88672 10.5345 8.83557 10.5629 8.78504 10.5928C8.54529 10.7344 8.3193 10.9082 8.11331 11.1142L9.83702 12.8372L7.00054 15.75L7 17H8.25064L11.1628 14.1632L12.8857 15.8865C13.0917 15.6805 13.2655 15.4545 13.4071 15.2147C13.437 15.1642 13.4654 15.1131 13.4924 15.0614C13.8215 14.4308 13.9378 13.718 13.8413 13.0293L17 10.6946L13.3053 7L10.9706 10.1586Z`,fill:`currentColor`})});function Ti({isOpen:e,onClose:t,ignoreOutsideClickRef:n}){let r=it(t,n),{t:i}=v(`openhands`),{conversationId:a}=Y(),{state:o,setUnpinnedTabs:s,setSelectedTab:c}=et(a),{selectedTab:l,isRightPanelShown:u,setSelectedTab:d}=K(),{navigateToTab:f}=C(),{hasTaskList:p}=dn(),{backend:m}=G(),g=[{tab:`planner`,icon:rn,i18nKey:h.COMMON$PLANNER},{tab:`files`,icon:Jt,i18nKey:h.COMMON$FILES},{tab:`vscode`,icon:ln,i18nKey:h.COMMON$CODE},{tab:`terminal`,icon:vt,i18nKey:h.COMMON$TERMINAL},{tab:`browser`,icon:yi,i18nKey:h.COMMON$BROWSER}];p&&g.unshift({tab:`tasklist`,icon:bi,i18nKey:h.COMMON$TASK_LIST});let _=g.filter(({tab:e})=>e!==`vscode`&&e!==`planner`||m.kind===`cloud`);if(!e)return null;let y=e=>{f(e),t()},b=(e,t)=>{if(t.preventDefault(),t.stopPropagation(),o.unpinnedTabs.includes(e))s(o.unpinnedTabs.filter(t=>t!==e));else{let t=[...o.unpinnedTabs,e];if(s(t),l===e&&u){let n=_.find(({tab:n})=>n!==e&&!t.includes(n));n&&(d(n.tab),c(n.tab))}}};return(0,$.jsx)(pt,{ref:r,alignment:`right`,position:`bottom`,className:`z-[9999] mt-2 w-fit`,children:_.map(({tab:e,icon:t,i18nKey:n})=>{let r=!o.unpinnedTabs.includes(e);return(0,$.jsx)(`li`,{className:`list-none`,children:(0,$.jsxs)(`div`,{className:W(`flex h-[30px] w-full min-w-0 items-stretch rounded`,`hover:bg-[var(--oh-interactive-hover)]`),children:[(0,$.jsxs)(`button`,{type:`button`,"data-testid":`conversation-tabs-menu-open-${e}`,className:W(`flex min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-l p-2 text-start`,`text-white transition-colors`),onClick:()=>y(e),children:[(0,$.jsx)(t,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`text-sm`,children:i(n)})]}),(0,$.jsx)(`button`,{type:`button`,"data-testid":`conversation-tabs-menu-pin-${e}`,className:W(`flex shrink-0 cursor-pointer items-center justify-center rounded-r px-2`,`text-white transition-colors hover:bg-white/10`),"aria-pressed":r,"aria-label":r?`Unpin tab from bar`:`Pin tab to bar`,onClick:t=>b(e,t),children:r?(0,$.jsx)(wi,{className:`-mr-[5px] ml-auto h-7 w-7`}):(0,$.jsx)(Ci,{className:`ml-auto h-4.5 w-4.5`})})]})},e)})})}function Ei({variant:e=`default`}){let{conversationId:t}=Y(),{setSelectedTab:n,planContent:r}=K(),[i,a]=(0,Q.useState)(!1),{state:o}=et(t),{hasTaskList:s}=dn(),{backend:c}=G(),{handleBuildPlanClick:l}=y(),{curAgentState:u}=Z(),{selectTab:d,isTabActive:f,onTabChange:p,selectedTab:m,isRightPanelShown:g}=C();(0,Q.useEffect)(()=>{n(o.selectedTab)},[n,o.selectedTab]),(0,Q.useEffect)(()=>{g&&(m||p(`files`))},[g,m,p]);let{t:_,i18n:b}=v(`openhands`),x=[{tabValue:`files`,isActive:f(`files`),icon:Jt,onClick:()=>d(`files`),tooltipContent:_(h.COMMON$FILES),tooltipAriaLabel:_(h.COMMON$FILES),label:_(h.COMMON$FILES)},{tabValue:`planner`,isActive:f(`planner`),icon:rn,onClick:()=>d(`planner`),tooltipContent:_(h.COMMON$PLANNER),tooltipAriaLabel:_(h.COMMON$PLANNER),label:_(h.COMMON$PLANNER)},{tabValue:`vscode`,isActive:f(`vscode`),icon:ln,onClick:()=>d(`vscode`),tooltipContent:(0,$.jsx)(Si,{}),tooltipAriaLabel:_(h.COMMON$CODE),label:_(h.COMMON$CODE)},{tabValue:`terminal`,isActive:f(`terminal`),icon:vt,onClick:()=>d(`terminal`),tooltipContent:_(h.COMMON$TERMINAL),tooltipAriaLabel:_(h.COMMON$TERMINAL),label:_(h.COMMON$TERMINAL),className:`pl-2`},{tabValue:`browser`,isActive:f(`browser`),icon:yi,onClick:()=>d(`browser`),tooltipContent:_(h.COMMON$BROWSER),tooltipAriaLabel:_(h.COMMON$BROWSER),label:_(h.COMMON$BROWSER)}];s&&x.splice(1,0,{tabValue:`tasklist`,isActive:f(`tasklist`),icon:bi,onClick:()=>d(`tasklist`),tooltipContent:_(h.COMMON$TASK_LIST),tooltipAriaLabel:_(h.COMMON$TASK_LIST),label:_(h.COMMON$TASK_LIST)});let S=x.filter(e=>e.tabValue===`vscode`&&c.kind!==`cloud`||e.tabValue===`planner`&&c.kind!==`cloud`?!1:o.unpinnedTabs.includes(e.tabValue)?m===e.tabValue:!0),w=o.unpinnedTabs.join(`,`),T=u===U.RUNNING||u===U.LOADING||!r,ee=(0,Q.useRef)(null),E=(0,Q.useRef)(null),D=(0,Q.useRef)(null),O=(0,Q.useRef)(null),[k,A]=(0,Q.useState)(S.length);(0,Q.useLayoutEffect)(()=>{let e=ee.current,t=E.current,n=D.current;if(!e||!t||!n)return;let r=()=>{let r=t.querySelectorAll(`[data-tab-measure="true"]`),i=r.length,a=e.getBoundingClientRect().width;if(a===0){A(i);return}let o=Array.from(r).map(e=>e.getBoundingClientRect().width);if(o.length!==i||i===0){A(Math.max(0,i));return}let s=n.getBoundingClientRect().width,c=getComputedStyle(e).columnGap||getComputedStyle(e).gap,l=parseFloat(c)||6,u=0;for(let e=i;e>=0;--e){let t=s;for(let n=0;n<e;n+=1)t+=o[n]??0;if(e>0&&(t+=e*l),t<=a+.5){u=e;break}}A(e=>e===u?e:u)};if(r(),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(r);return i.observe(e),()=>i.disconnect()},[w,S.length,s,c.kind,m,g,b.language]);let j=Math.min(k,S.length);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:W(`relative w-full min-w-0`,e===`compact`?`flex h-full min-h-0 items-center py-0 pl-0 pr-1`:`min-h-10 p-1`),children:[(0,$.jsx)(`div`,{ref:E,"aria-hidden":!0,className:`pointer-events-none absolute top-0 left-[-10000px] flex flex-nowrap items-center gap-1.5`,children:S.map(({tabValue:e,icon:t,isActive:n,tooltipContent:r,tooltipAriaLabel:i,label:a,className:o},s)=>(0,$.jsx)(gi,{tooltip:r,ariaLabel:i,children:(0,$.jsx)(xi,{tabValue:e,icon:t,onClick:()=>{},isActive:n,label:a,className:W(o,`shrink-0`),measureOnly:!0})},`measure-${e}-${s}`))}),(0,$.jsx)(`div`,{ref:ee,className:`flex w-full min-w-0 flex-nowrap items-center justify-start`,children:(0,$.jsxs)(`div`,{className:`flex w-fit max-w-full min-w-0 flex-nowrap items-center gap-1.5`,children:[(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-nowrap items-center gap-1.5 overflow-x-hidden`,children:S.slice(0,j).map(({tabValue:e,icon:t,onClick:n,isActive:r,tooltipContent:i,tooltipAriaLabel:a,label:o,className:s},c)=>(0,$.jsx)(gi,{tooltip:i,ariaLabel:a,children:(0,$.jsx)(xi,{tabValue:e,icon:t,onClick:n,isActive:r,label:o,className:W(s,`shrink-0`)})},`${e}-${c}`))}),(0,$.jsxs)(`div`,{ref:D,className:`relative shrink-0`,children:[(0,$.jsx)(ht,{ref:O,onClick:()=>a(!i),ariaLabel:_(h.COMMON$MORE_OPTIONS),iconClassName:e===`compact`?N:void 0}),(0,$.jsx)(Ti,{isOpen:i,onClose:()=>a(!1),ignoreOutsideClickRef:O})]})]})})]}),f(`planner`)&&(0,$.jsx)(`div`,{className:W(`flex h-10 min-h-10 shrink-0 items-center border-t border-[var(--oh-border)] pl-[10px] pr-1`),children:(0,$.jsx)(`button`,{type:`button`,onClick:l,disabled:T,className:W(`flex h-5 min-w-17 items-center justify-center rounded bg-white px-2 transition-opacity`,T?`cursor-not-allowed opacity-50`:`cursor-pointer hover:opacity-90`),"data-testid":`planner-tab-build-button`,children:(0,$.jsxs)(nn.Text,{className:`text-[11px] font-normal leading-5 text-black`,children:[_(h.COMMON$BUILD),` ⌘↩`]})})})]})}function Di({onMouseDown:e,className:t,isDragging:n=!1}){let[r,i]=(0,Q.useState)(!1),a=n||r;return(0,$.jsxs)(`div`,{className:W(`relative z-10 w-0 shrink-0 self-stretch`,t),"aria-hidden":!0,children:[(0,$.jsx)(`div`,{className:`absolute inset-y-0 left-1/2 w-3 min-w-[12px] -translate-x-1/2 cursor-ew-resize`,onMouseDown:e,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1)}),(0,$.jsx)(`div`,{className:W(`pointer-events-none absolute inset-y-0 left-1/2 w-px -translate-x-1/2 transition-colors`,a?`bg-white`:`bg-transparent`),"aria-hidden":!0})]})}var Oi=200;function ki({defaultLeftWidth:e=50,minLeftWidth:t=30,maxLeftWidth:n=80,storageKey:r=`desktop-layout-panel-width`}={}){let[i,a]=fn(r,e),o=(0,Q.useCallback)(e=>Math.max(t,Math.min(n,e)),[t,n]),[s,c]=(0,Q.useState)(()=>o(i)),[l,u]=(0,Q.useState)(!1),d=(0,Q.useRef)(null),f=(0,Q.useCallback)(e=>{e.preventDefault(),u(!0)},[]),p=(0,Q.useCallback)(e=>{if(!l||!d.current)return;let t=d.current.getBoundingClientRect();c(o((e.clientX-t.left)/t.width*100))},[l,o]),m=(0,Q.useCallback)(()=>{l&&(u(!1),a(s))},[l,s,a]);return(0,Q.useLayoutEffect)(()=>{if(!l)return;let e=document.createElement(`div`);return e.setAttribute(`aria-hidden`,`true`),e.dataset.panelDragShield=``,Object.assign(e.style,{position:`fixed`,inset:`0`,zIndex:String(Oi),cursor:`ew-resize`}),document.body.appendChild(e),document.addEventListener(`mousemove`,p),document.addEventListener(`mouseup`,m),document.body.style.cursor=`ew-resize`,document.body.style.userSelect=`none`,()=>{document.removeEventListener(`mousemove`,p),document.removeEventListener(`mouseup`,m),document.body.style.cursor=``,document.body.style.userSelect=``,e.remove()}},[l,p,m]),{leftWidth:s,rightWidth:100-s,isDragging:l,containerRef:d,handleMouseDown:f}}function Ai(e){return e?`translate-x-0 opacity-100`:`w-0 translate-x-full opacity-0`}function ji(){let e=cn(),t=cn(767),{isRightPanelShown:n}=K(),{leftWidth:r,rightWidth:i,isDragging:a,containerRef:o,handleMouseDown:s}=ki({defaultLeftWidth:50,minLeftWidth:30,maxLeftWidth:80,storageKey:`desktop-layout-panel-width`});return(0,$.jsx)(`div`,{className:W(e?`relative min-h-0 flex-1 flex flex-col`:`h-full flex flex-col overflow-hidden`),children:(0,$.jsxs)(`div`,{ref:o,className:W(`flex flex-1 overflow-hidden`,e?`flex-col`:`transition-all duration-300 ease-in-out`),style:e?void 0:{transitionProperty:a?`none`:`all`},children:[(0,$.jsxs)(`div`,{className:W(`flex flex-col bg-base overflow-hidden`,e?`flex-1`:`transition-all duration-300 ease-in-out`),style:e?void 0:{width:n?`${r}%`:`100%`,transitionProperty:a?`none`:`all`},children:[(0,$.jsxs)(`div`,{"data-testid":`chat-pane-header`,className:W(`flex h-10 min-h-10 shrink-0 items-center`,t&&`gap-2 pl-2.5`),children:[t?(0,$.jsx)(L,{}):null,(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(vi,{})})]}),(0,$.jsx)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:(0,$.jsx)(Fr,{isRightPanelShown:!e&&n})})]}),!e&&n&&(0,$.jsx)(Di,{onMouseDown:s,isDragging:a}),!e&&(0,$.jsx)(`div`,{className:W(`transition-all duration-300 ease-in-out overflow-hidden`,Ai(n)),style:{width:n?`${i}%`:`0%`,transitionProperty:a?`opacity, transform`:`all`},children:(0,$.jsx)(`div`,{className:`flex h-full w-full flex-col`,children:(0,$.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0 bg-[var(--oh-surface)] border-l border-[var(--oh-border)] overflow-hidden`,children:[(0,$.jsx)(`div`,{"data-testid":`tabs-pane-header`,className:`flex shrink-0 flex-col border-b border-[var(--oh-border)]`,children:(0,$.jsx)(Ei,{})}),(0,$.jsx)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:(0,$.jsx)(qr,{})})]})})})]})})}function Mi({onNavigateBack:e}){let{t}=v(`openhands`),{setIsRightPanelShown:n,setHasRightPanelToggled:r,setSelectedTab:i}=K();return Q.useLayoutEffect(()=>(n(!0),r(!0),K.getState().selectedTab||i(`files`),()=>{n(!1),r(!1)}),[n,r,i]),(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-[var(--oh-surface)]`,children:[(0,$.jsxs)(`div`,{"data-testid":`conversation-mobile-panel-top`,className:`flex h-10 min-h-10 shrink-0 items-center gap-1.5 border-b border-[var(--oh-border)] pl-2.5`,children:[(0,$.jsx)(`button`,{type:`button`,"data-testid":`conversation-mobile-panel-back`,onClick:()=>{e()},"aria-label":t(h.COMMON$BACK),className:F,children:(0,$.jsx)(M,{size:20,className:N,"aria-hidden":!0,strokeWidth:2})}),(0,$.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 items-center self-stretch`,children:(0,$.jsx)(`div`,{"data-testid":`tabs-pane-header`,className:`flex h-full min-h-0 w-full min-w-0 flex-col justify-center`,children:(0,$.jsx)(Ei,{variant:`compact`})})})]}),(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-[var(--oh-surface)]`,children:(0,$.jsx)(qr,{})})]})}var Ni=1e3*60*5,Pi=1e3*60*15,Fi=e=>{let t=e||[],n=G();return c({queryKey:[`v1`,`sub-conversations`,t,n.backend.id,n.orgId],queryFn:async()=>t.length===0?[]:Pe.batchGetAppConversations(t),enabled:t.length>0,staleTime:Ni,gcTime:Pi,retry:!1})};function Ii({children:e,conversationId:t}){let{data:n}=X(),{data:r}=Fi(n?.sub_conversation_ids??[]),i=r?.filter(e=>e!==null);return(0,$.jsx)(he,{conversationId:t,conversationUrl:n?.sandbox_status===`PAUSED`?null:n?.conversation_url,sessionApiKey:n?.session_api_key,subConversationIds:n?.sub_conversation_ids,subConversations:i,children:e})}function Li(){let{t:e}=v(`openhands`),{conversationId:t}=Y(),n=r(`/conversations/:conversationId/panel`),{isTask:i,taskStatus:s,taskDetail:c}=Et(),l=G(),u=Q.useRef(l.backend.id),d=Q.useRef(l.orgId),f=u.current!==l.backend.id||d.current!==l.orgId,{data:p,isFetched:m}=X(),{data:g}=rt(),{resetConversationState:_}=K(),y=a(),b=o(),x=tn(e=>e.clearTerminal),S=bt(e=>e.reset),C=mn(e=>e.setCurrentAgentState),w=ue(e=>e.removeErrorMessage);Q.useEffect(()=>{x(),_(),S(),C(U.LOADING),w()},[t,x,_,S,C,w]),Q.useEffect(()=>{if(i&&s===`ERROR`){z(c||e(h.CONVERSATION$FAILED_TO_START_FROM_TASK));let t=b.state?.resumedFromConversationId;y(t?`/conversations/${t}`:`/conversations`,{replace:!0})}},[i,s,c,e,y,b.state]),Q.useEffect(()=>{!m||!g||f||p||(bn(l.backend.id,l.orgId),z(e(h.CONVERSATION$NOT_EXIST_OR_NO_PERMISSION)),y(`/conversations`))},[p,m,g,y,e,f,l.backend.id,l.orgId]),Q.useEffect(()=>{f||t&&(t.startsWith(`task-`)||yn(l.backend.id,l.orgId,t))},[t,f,l.backend.id,l.orgId]);let T=Q.useRef(null);return Q.useEffect(()=>{!m||!p||l.backend.kind===`cloud`&&p.sandbox_status===`PAUSED`&&p.sandbox_id&&T.current!==p.id&&(T.current=p.id,Me(p.sandbox_id).catch(()=>{z(e(h.CONVERSATION$FAILED_TO_START_FROM_TASK))}))},[m,p?.id,p?.sandbox_status,p?.sandbox_id,l.backend.kind,e]),(0,$.jsx)(Ii,{conversationId:t,children:(0,$.jsx)(En,{children:(0,$.jsx)(`div`,{"data-testid":`app-route`,className:`flex h-full flex-col`,children:n?(0,$.jsx)(Mi,{onNavigateBack:()=>y(`/conversations/${t}`)}):(0,$.jsx)(ji,{})})})})}function Ri(){return(0,$.jsx)(Li,{})}var zi=i(Ri);export{zi as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./conversation--ldUK72N.js";export{e as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./conversation--ldUK72N.js";export{e as default};
|
package/build/assets/{conversation-service.api-C8pYCyV6.js → conversation-service.api--f8WglOC.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as e,c as t,n,t as r}from"./agent-server-client-options-DT2GP6VJ.js";import{i,r as a,s as o}from"./vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~dp08i1qy-CHrEOFl6.js";import{a as s,n as c,t as l}from"./agent-server-conversation-service.api-
|
|
1
|
+
import{S as e,c as t,n,t as r}from"./agent-server-client-options-DT2GP6VJ.js";import{i,r as a,s as o}from"./vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~dp08i1qy-CHrEOFl6.js";import{a as s,n as c,t as l}from"./agent-server-conversation-service.api-BZmUqtiO.js";var u=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function d(e){let t=e.split(/[\\/]+/).filter(Boolean),n=t[t.length-1];if(!n||n===`.`||n===`..`)throw Error(`Invalid file name`);return n}function f(e){return e.startsWith(`/`)?e:`/${e}`}function p(e,t){let n=d(e);return`${f(t.replace(/\/+$/,``))}/${n}`}async function m(t,n){if(n?.id===t&&n.workspace?.working_dir?.trim())return n.workspace.working_dir.trim();let r=s(t);return r?.selected_workspace?.trim()?r.selected_workspace.trim():u.test(t)?l.resolveConversationWorkingDir(t):e()}var h=5;async function g(e,n){if(n?.id===e&&n.conversation_url?.trim()&&n.session_api_key?.trim())return{conversationUrl:n.conversation_url.trim(),sessionApiKey:n.session_api_key.trim()};if(t().backend.kind===`cloud`){let[t]=await c([e]);return{conversationUrl:t?.conversation_url?.trim()??null,sessionApiKey:t?.session_api_key?.trim()??null}}return{conversationUrl:null,sessionApiKey:null}}function _(e){if(!e.conversationUrl||!e.sessionApiKey)throw Error(`Conversation sandbox is still starting. Wait for it to finish, then try again.`);return{conversationUrl:e.conversationUrl,sessionApiKey:e.sessionApiKey}}async function v(e,n,r){let i=await m(e,r),a=await g(e,r),o=t().backend.kind===`cloud`,s=r?.id===e?r.session_api_key??a.sessionApiKey:a.sessionApiKey,c=r?.id===e?r.conversation_url??a.conversationUrl:a.conversationUrl;if(o){let e=_({conversationUrl:c,sessionApiKey:s});return y({files:n,workingDir:i,conversationUrl:e.conversationUrl,sessionApiKey:e.sessionApiKey})}return y({files:n,workingDir:i,conversationUrl:c,sessionApiKey:s})}async function y(e){let{files:t,workingDir:n,conversationUrl:i,sessionApiKey:o}=e,s=new a(r({conversationUrl:i,sessionApiKey:o,workingDir:n})),c=async e=>{try{let t=d(e.name),r=p(e.name,n);return await s.fileUpload(e,r),{uploadedFile:t,skippedFile:null}}catch(t){return{uploadedFile:null,skippedFile:{name:e.name,reason:t instanceof Error?t.message:`Upload failed`}}}},l=[];for(let e=0;e<t.length;e+=h){let n=t.slice(e,e+h);l.push(...await Promise.all(n.map(c)))}return{uploaded_files:l.flatMap(e=>e.uploadedFile?[e.uploadedFile]:[]),skipped_files:l.flatMap(e=>e.skippedFile?[e.skippedFile]:[])}}var b=class{static currentConversation=null;static setCurrentConversation(e){this.currentConversation=e}static getClientOverrides(){return{sessionApiKey:this.currentConversation?.session_api_key}}static async getVSCodeUrl(t){let n=this.currentConversation?.id===t?this.currentConversation?.workspace?.working_dir??e():e();return{vscode_url:await new o(r(this.getClientOverrides())).getUrl({baseUrl:typeof window<`u`?window.location.origin:void 0,workspaceDir:n})}}static async getTrajectory(e){return{trajectory:(await new i(n(this.getClientOverrides()),e).search({limit:1e4})).items??[]}}static async uploadFiles(e,t){return v(e,t,this.currentConversation)}};export{g as n,v as r,b as t};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{t as n}from"./vendor~root~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-s~kyz9p27j-CyUbhpbm.js";import{i as r,l as i,n as a}from"./path-utils-BVbe598W.js";import{t as o}from"./useMutation-B4OUESdw.js";import{o as s}from"./declaration-D378OjpZ.js";import{n as ee}from"./QueryClientProvider-B7kl84Kj.js";import{t as c}from"./createLucideIcon-Ddu8jDOQ.js";import{a as l,c as u,i as d,n as f,t as p}from"./agent-server-client-options-DT2GP6VJ.js";import{n as m}from"./vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~skills-set~jfc6hidu-VnmIZrq3.js";import{i as h}from"./vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~dp08i1qy-CHrEOFl6.js";import{o as g,s as _,t as v}from"./agent-server-conversation-service.api-BZmUqtiO.js";import{t as y}from"./proxy-CurRmrqf.js";import{t as b}from"./react-Do0CT17Y.js";import{n as x}from"./middleware-BC9EwbB9.js";import{a as te}from"./conversation-local-storage-UYl-SX-r.js";import{t as S}from"./conversation-store-Z5iMCRpc.js";import{t as C}from"./use-user-conversation-B_zDoSeh.js";import{t as ne}from"./conversation-state-store-Bc0slAjL.js";import{C as w,_ as T,a as E,b as re,c as ie,d as ae,f as oe,g as se,h as ce,i as D,l as le,m as ue,o as de,p as fe,r as O,s as pe,t as k,u as me,v as A,x as he,y as ge}from"./use-event-store-BT_gV3ut.js";import{t as _e}from"./command-store-DFN_17p1.js";import{t as ve}from"./browser-store-C3AqxAO7.js";import{t as j}from"./files-tab-store-CDyVTXNT.js";var M=c(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),N=e(t(),1),ye=(e,t)=>{let[n,r]=N.useState(!1),[i,a]=N.useState(null),[o,s]=N.useState([]),[ee,c]=N.useState(null),[l,u]=N.useState(!1),d=N.useRef(null),f=N.useRef(0),p=N.useRef(null),m=N.useRef(!0),h=N.useRef(new WeakSet),g=N.useRef(t);N.useEffect(()=>{g.current=t},[t]);let _=N.useCallback(()=>{let t=e;if(g.current?.queryParams){let n=Object.entries(g.current.queryParams).reduce((e,[t,n])=>(e[t]=String(n),e),{});t=`${e}?${new URLSearchParams(n).toString()}`}let n=new WebSocket(t);d.current=n,h.current.add(n),n.onopen=e=>{r(!0),c(null),u(!1),f.current=0,g.current?.onOpen?.(e)},n.onmessage=e=>{a(e.data),s(t=>[...t,e.data]),g.current?.onMessage?.(e)},n.onclose=e=>{let t=h.current.has(n);r(!1),e.code!==1e3&&(c(Error(`WebSocket closed with code ${e.code}: ${e.reason||`Connection closed unexpectedly`}`)),t&&g.current?.onError?.(e)),g.current?.onClose?.(e);let i=g.current?.reconnect?.enabled??!1,a=g.current?.reconnect?.maxAttempts??1/0;i&&t&&m.current&&f.current<a?(u(!0),f.current+=1,p.current=setTimeout(()=>{_()},3e3)):u(!1)},n.onerror=e=>{r(!1),g.current?.onError?.(e)}},[e]);N.useEffect(()=>(m.current=!0,f.current=0,e&&e.trim()!==``&&_(),()=>{if(m.current=!1,p.current&&=(clearTimeout(p.current),null),d.current){let{readyState:e}=d.current;h.current.delete(d.current),(e===WebSocket.CONNECTING||e===WebSocket.OPEN)&&d.current.close(),d.current=null}}),[e,_]);let v=N.useCallback(e=>{d.current?.readyState===WebSocket.OPEN&&d.current.send(e)},[]),y=N.useCallback(()=>{m.current=!1,u(!1),p.current&&=(clearTimeout(p.current),null),d.current&&(h.current.delete(d.current),d.current.close())},[]),b=N.useCallback(()=>{if(m.current=!0,f.current=0,u(!0),c(null),p.current&&=(clearTimeout(p.current),null),d.current){let e=d.current;h.current.delete(e),d.current=null,(e.readyState===WebSocket.CONNECTING||e.readyState===WebSocket.OPEN)&&e.close()}_()},[_]);return{isConnected:n,lastMessage:i,messages:o,error:ee,socket:d.current,sendMessage:v,isReconnecting:l,attemptCount:f.current,disconnect:y,reconnect:b}},P=`Unable to connect to server`,F={errorMessage:null,errorType:null},be=b(e=>({...F,setErrorMessage:(t,n=`conversation`)=>e(()=>({errorMessage:t,errorType:n})),removeErrorMessage:()=>e(()=>({errorMessage:null,errorType:null})),clearConnectionError:()=>e(e=>e.errorType===`connection`?{errorMessage:null,errorType:null}:e)})),I=15e4,L={pendingMessages:[]},R=()=>`pending-${Date.now()}-${Math.random().toString(36).slice(2,10)}`,xe=b((e,t)=>({...L,enqueuePendingMessage:n=>{let r=R(),i={id:r,conversationId:n.conversationId,text:n.text,content:n.content??n.text,status:`sending`,imageUrls:n.imageUrls??[],fileUrls:n.fileUrls??[],timestamp:n.timestamp??new Date().toISOString()};return e(e=>({pendingMessages:[...e.pendingMessages,i]})),setTimeout(()=>{t().pendingMessages.find(e=>e.id===r)?.status===`sending`&&t().markPendingMessageError(r,`Send timed out`)},I),r},markPendingMessageError:(t,n)=>e(e=>({pendingMessages:e.pendingMessages.map(e=>e.id===t?{...e,status:`error`,errorMessage:n}:e)})),markPendingMessageSending:t=>e(e=>({pendingMessages:e.pendingMessages.map(e=>e.id===t?{...e,status:`sending`,errorMessage:void 0}:e)})),removePendingMessage:t=>e(e=>({pendingMessages:e.pendingMessages.filter(e=>e.id!==t)})),consumeMatchingPendingMessage:(t,n)=>{let r=null;return e(e=>{let i=e.pendingMessages.map((e,t)=>({m:e,i:t})).filter(({m:e})=>e.status===`sending`&&e.conversationId===t);if(i.length===0)return e;let a=i.find(({m:e})=>e.content===n)??i[0];return r=a.m,{pendingMessages:[...e.pendingMessages.slice(0,a.i),...e.pendingMessages.slice(a.i+1)]}}),r},clearPendingMessages:()=>e(()=>({...L})),reassignPendingMessages:(t,n)=>e(e=>({pendingMessages:e.pendingMessages.map(e=>e.conversationId===t?{...e,conversationId:n}:e)}))})),z=new Set([`files`,`browser`,`vscode`,`terminal`,`planner`,`tasklist`]);function B(e){let t=S.getState();t.setSelectedTab(e),t.isRightPanelShown||(t.setHasRightPanelToggled(!0),t.setIsRightPanelShown(!0))}function V(e){return z.has(e)}function Se(e){switch(e.command){case`navigate_to_file`:case`show_preview`:B(`files`),e.path&&j.getState().setSelectedPath(e.path);return;case`open_tab`:e.tab&&V(e.tab)?B(e.tab):e.tab&&console.warn(`[canvas_ui] Ignoring open_tab with unknown tab: ${e.tab}`);return}}var H=(e,t,n)=>({entriesByConversation:{...e.entriesByConversation,[t]:[...e.entriesByConversation[t]??[],n]}}),U=b()(x(e=>({entriesByConversation:{},activeProfileByConversation:{},show:(t,n,r)=>e(e=>H(e,t,{id:g(),anchorEventId:n,profiles:r})),recordSwitch:(t,n,r)=>e(e=>({...H(e,t,{id:g(),anchorEventId:n,profiles:[],switchedTo:r}),activeProfileByConversation:{...e.activeProfileByConversation,[t]:r}})),clearActiveProfile:t=>e(e=>{if(!(t in e.activeProfileByConversation))return e;let n={...e.activeProfileByConversation};return delete n[t],{activeProfileByConversation:n}}),clear:t=>e(e=>{let n={...e.entriesByConversation};delete n[t];let r={...e.activeProfileByConversation};return delete r[t],{entriesByConversation:n,activeProfileByConversation:r}}),clearAll:()=>e({entriesByConversation:{},activeProfileByConversation:{}})}),{name:`ModelStore`})),Ce=(e,t,n)=>{let{action:r}=e;if((r.kind===`StrReplaceEditorAction`||r.kind===`FileEditorAction`||r.kind===`ExecuteBashAction`)&&n.invalidateQueries({queryKey:[`file_changes`,t]},{cancelRefetch:!1}),(r.kind===`StrReplaceEditorAction`||r.kind===`FileEditorAction`)&&r.path){let e=a(r.path);n.invalidateQueries({queryKey:[`file_diff`,t,e]})}e.tool_name===`SwitchLLMTool`&&(n.invalidateQueries({queryKey:[`user`,`conversation`,t]}),U.getState().clearActiveProfile(t))},W=class{static async respondToConfirmation(e,t,n,r){let i=u().backend;return i.kind===`cloud`?y({backend:i,method:`POST`,hostOverride:d(t),path:`/api/conversations/${e}/events/respond_to_confirmation`,body:n,authMode:`session-api-key`,sessionApiKey:r}):new _(p({conversationUrl:t,sessionApiKey:r})).respondToConfirmation(e,n)}static async getEventCount(e,t,n){let r=u().backend;return r.kind===`cloud`?y({backend:r,method:`GET`,hostOverride:d(t),path:`/api/conversations/${e}/events/count`,authMode:`session-api-key`,sessionApiKey:n}):new _(p({conversationUrl:t,sessionApiKey:n})).getEventCount(e)}static async searchEvents(e,t,n,r={}){let i=u().backend,a=r.limit??100;if(i.kind===`cloud`){let t=Math.min(a,100),n=!!(r.sortOrder||r.pageId||r.timestampGte||r.timestampLt),o=new URLSearchParams;o.set(`limit`,String(t)),r.sortOrder&&o.set(`sort_order`,r.sortOrder),r.pageId&&o.set(`page_id`,r.pageId),r.timestampGte&&o.set(`timestamp__gte`,r.timestampGte),r.timestampLt&&o.set(`timestamp__lt`,r.timestampLt);let s=t=>y({backend:i,method:`GET`,path:`/api/v1/conversation/${e}/events/search?${t.toString()}`});try{let e=await s(o);return{items:e?.items??[],next_page_id:e?.next_page_id??null}}catch(e){if(!n)throw e;return console.warn(`[EventService] Cloud backend doesn't support pagination filters. Falling back to initial load only. Server needs OpenHands/OpenHands#14399.`),{items:[],next_page_id:null}}}let o=await new h(f({conversationUrl:t,sessionApiKey:n}),e).search({limit:a,...r.pageId?{page_id:r.pageId}:{},...r.sortOrder?{sort_order:r.sortOrder}:{},...r.timestampGte?{timestamp__gte:r.timestampGte}:{},...r.timestampLt?{timestamp__lt:r.timestampLt}:{}});return{items:o?.items??[],next_page_id:o?.next_page_id??null}}};function G({message:e,source:t,metadata:n={},posthog:r}){if(!r)return;let i=Error(e);r.captureException(i,{error_source:t||`unknown`,...n})}var we=()=>o({mutationKey:[`read-conversation-file`],mutationFn:async({conversationId:e,filePath:t})=>v.readConversationFile(e,t)}),Te=b(e=>({cost:null,max_budget_per_task:null,usage:null,setMetrics:t=>e(t)})),Ee=e=>{let{data:t}=C(e??null);return n({queryKey:[`conversation-history`,e,t?.conversation_url??null,t?.session_api_key??null],enabled:!!e&&!!t,queryFn:async()=>{if(!e)return{events:[],hasMore:!1,nextPageId:null};let n=await W.searchEvents(e,t?.conversation_url??null,t?.session_api_key??null,{limit:50,sortOrder:`TIMESTAMP_DESC`});if(!Array.isArray(n.items))throw Error(`Invalid conversation history response: expected page.items to be an array.`);return{events:[...n.items].reverse(),hasMore:!!n.next_page_id||n.items.length>=50,nextPageId:n.next_page_id??null}},staleTime:1/0,gcTime:1800*1e3})},K=e=>{if(ae(e))return!1;if(D(e)){let t=e.action.kind;return!(!t||t===`ExecuteBashAction`&&e.source===`user`||t===`PlanningFileEditorAction`||t===`SwitchLLMAction`)}return A(e)?!(e.observation.kind===`SwitchLLMObservation`&&!e.observation.is_error):T(e)||E(e)||se(e)?!0:O(e)?e.status===`completed`||e.status===`failed`:!1},q=e=>e.some(e=>e.source===`user`),J=()=>{let{uiEvents:e}=k.getState();for(let t=e.length-1;t>=0;--t){let n=e[t];if(K(n))return String(n.id)}return null};function De(e,t,n=J()){U.getState().recordSwitch(e,n,t)}var Oe=s(),ke=(0,N.createContext)(void 0);function Ae(e){return e.llm_message.content.filter(e=>e.type===`text`).map(e=>e.text).join(``)}function Y({children:e,conversationId:t,conversationUrl:n,sessionApiKey:a,subConversations:o,subConversationIds:s}){let[c,u]=(0,N.useState)(`CONNECTING`),[d,f]=(0,N.useState)(`CONNECTING`),h=N.useRef(!1),g=N.useRef(!1),v=m(),y=ee(),b=k(e=>e.addEvent),x=k(e=>e.addEvents),C=k(e=>e.clearEventsForConversation),{setErrorMessage:T,removeErrorMessage:se,clearConnectionError:O}=be(),A=xe(e=>e.consumeMatchingPendingMessage),{setExecutionStatus:j}=ne(),{appendInput:M,appendOutput:F}=_e(),[I,L]=(0,N.useState)(!0),[R,z]=(0,N.useState)(null),{setPlanContent:B}=S(),{mutate:V}=we(),H=(0,N.useRef)(0),U=(0,N.useRef)(null),K=e=>e?.toUpperCase().endsWith(`PLAN.MD`)??!1,q=(0,N.useCallback)(()=>{O()},[O]),J=(0,N.useCallback)(e=>{if(e.value.usage_to_metrics?.agent){let t=e.value.usage_to_metrics.agent,n={cost:t.accumulated_cost,max_budget_per_task:t.max_budget_per_task??null,usage:t.accumulated_token_usage?{prompt_tokens:t.accumulated_token_usage.prompt_tokens,completion_tokens:t.accumulated_token_usage.completion_tokens,cache_read_tokens:t.accumulated_token_usage.cache_read_tokens,cache_write_tokens:t.accumulated_token_usage.cache_write_tokens,context_window:t.accumulated_token_usage.context_window,per_turn_token:t.accumulated_token_usage.per_turn_token}:null};Te.getState().setMetrics(n)}},[]),{data:Y,isPending:X,isError:je}=Ee(t),Me=!!t&&X;(0,N.useLayoutEffect)(()=>{let e=t??null;k.getState().loadedConversationId!==e&&C(e)},[t,C]),(0,N.useLayoutEffect)(()=>{if(!(!Y||Y.events.length===0)&&(x(Y.events),t))for(let e of Y.events)w(e)&&A(t,Ae(e))},[Y,x,t,A]);let Ne=(0,N.useMemo)(()=>{if(X)return null;let e=Y?.events??[],t=e[e.length-1];return!t||!(`timestamp`in t)||!t.timestamp?null:t.timestamp},[Y,X]),Pe=(0,N.useMemo)(()=>!t||!n||X&&!je?null:l(t,n),[t,n,X,je]),Z=(0,N.useMemo)(()=>{if(!o?.length)return null;let e=o[0];return!e?.id||!e.conversation_url?null:l(e.id,e.conversation_url)},[o]),Fe=(0,N.useMemo)(()=>Z?c===`CONNECTING`||d===`CONNECTING`?`CONNECTING`:c===`OPEN`&&d===`OPEN`?`OPEN`:c===`CLOSED`&&d===`CLOSED`?`CLOSED`:c===`CLOSING`||d===`CLOSING`?`CLOSING`:`CLOSED`:c,[c,d,Z]);(0,N.useEffect)(()=>{R!==null&&H.current>=R&&I&&L(!1)},[R,I,H]),(0,N.useEffect)(()=>{if(!I&&U.current){let{path:e,conversationId:t}=U.current;V({conversationId:t,filePath:e},{onSuccess:e=>{B(e)},onError:e=>{console.warn(`Failed to read conversation file:`,e)}}),U.current=null}},[I,V,B]),(0,N.useEffect)(()=>{h.current=!1,L(!!s?.length),z(null),H.current=0,U.current=null},[s]),(0,N.useEffect)(()=>{h.current=!1,g.current=!1,U.current=null},[t]);let Ie=(0,N.useMemo)(()=>Me||I,[Me,I]),Le=(0,N.useCallback)(e=>{try{let n=JSON.parse(e.data);if(de(n)){let e=!k.getState().eventIds.has(n.id)&&he(n)?n:null;if(b(n),oe(n)){let e=n;G({message:e.detail,source:`conversation`,metadata:{eventId:e.id,errorCode:e.code},posthog:v}),T(e.detail)}else q();if(E(n)&&G({message:n.error,source:`agent`,metadata:{eventId:n.id,toolName:n.tool_name,toolCallId:n.tool_call_id},posthog:v}),w(n)&&t&&(A(t,Ae(n)),te(t,{draftMessage:null})),D(n)&&Ce(n,t||`test-conversation-id`,y),ae(n)&&(ce(n)&&j(n.value.execution_status),pe(n)&&j(n.value),re(n)&&J(n)),fe(n)&&M(n.action.command),ue(n)&&F(n.observation.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
2
|
+
`)),le(n)){let{screenshot_data:e}=n.observation;if(e){let t=e.startsWith(`data:`)?e:`data:image/png;base64,${e}`;ve.getState().setScreenshotSrc(t)}}ie(n)&&ve.getState().setUrl(n.action.url),t&&e&&!e.observation.is_error&&(De(t,e.observation.profile_name),e.observation.active_model&&i(y,t,e.observation.active_model),r(y,t)),me(n)&&Se(n.action)}}catch(e){console.warn(`Failed to parse WebSocket message as JSON:`,e)}},[b,T,A,y,t,j,M,F,J,q,v]),Re=(0,N.useCallback)(e=>{try{let n=JSON.parse(e.data);if(I&&(H.current+=1,R!==null&&H.current>=R&&L(!1)),de(n)){if(b({...n,isFromPlanningAgent:!0}),oe(n)){let e=n;G({message:e.detail,source:`planning_conversation`,metadata:{eventId:e.id,errorCode:e.code},posthog:v}),T(e.detail)}else q();if(E(n)&&G({message:n.error,source:`planning_agent`,metadata:{eventId:n.id,toolName:n.tool_name,toolCallId:n.tool_call_id},posthog:v}),w(n)&&t&&(A(t,Ae(n)),te(t,{draftMessage:null})),D(n)&&Ce(n,o?.[0]?.id||`test-conversation-id`,y),ae(n)&&(ce(n)&&j(n.value.execution_status),pe(n)&&j(n.value),re(n)&&J(n)),fe(n)&&M(n.action.command),ue(n)&&F(n.observation.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
3
|
+
`)),ge(n)){let{path:e}=n.observation;if(K(e)){let t=o?.[0]?.id;t&&e&&(I?U.current={path:e,conversationId:t}:V({conversationId:t,filePath:e},{onSuccess:e=>{B(e)},onError:e=>{console.warn(`Failed to read conversation file:`,e)}}))}}}}catch(e){console.warn(`Failed to parse WebSocket message as JSON:`,e)}},[b,I,R,T,A,y,o,t,j,M,F,V,B,J,q,v]),ze=(0,N.useMemo)(()=>{let e=Ne?{resend_mode:`since`,after_timestamp:Ne}:{resend_mode:`all`};return a&&(e.session_api_key=a),{queryParams:e,reconnect:{enabled:!0},onOpen:()=>{u(`OPEN`),h.current=!0,O()},onClose:()=>{u(`CLOSED`)},onError:()=>{u(`CLOSED`),h.current&&T(P,`connection`)},onMessage:Le}},[Le,T,O,a,Ne]),Be=(0,N.useMemo)(()=>{let e={resend_all:!0};a&&(e.session_api_key=a);let t=o?.[0];return{queryParams:e,reconnect:{enabled:!0},onOpen:async()=>{if(f(`OPEN`),g.current=!0,O(),t?.id&&t.conversation_url)try{let e=await W.getEventCount(t.id,t.conversation_url,t.session_api_key);z(e),e===0&&L(!1)}catch{L(!1)}},onClose:()=>{f(`CLOSED`)},onError:()=>{f(`CLOSED`),g.current&&T(P,`connection`)},onMessage:Re}},[Re,T,O,a,o]),{socket:Q,reconnect:Ve}=ye(Pe||``,ze),{socket:$,reconnect:He}=ye(Z||``,Be),Ue=(0,N.useCallback)(()=>{if(se(),S.getState().conversationMode===`plan`&&Z){He();return}Ve()},[Z,Ve,He,se]),We=(0,N.useCallback)(async e=>{let n=S.getState().conversationMode===`plan`?$:Q;if(n?.readyState!==WebSocket.OPEN){if(!t){let e=Error(`No conversation ID available`);throw T(e.message),e}try{return await new _(p()).sendEvent(t,{role:`user`,content:e.content},{run:!0}),{queued:!0}}catch(e){throw T(e instanceof Error?e.message:`Failed to queue message for delivery`),e}}try{return n.send(JSON.stringify({...e,run:!0})),{queued:!1}}catch(e){throw T(e instanceof Error?e.message:`Failed to send message`),e}},[Q,$,T,t]);(0,N.useEffect)(()=>{Q&&Pe&&(()=>{switch(Q.readyState){case WebSocket.CONNECTING:u(`CONNECTING`);break;case WebSocket.OPEN:u(`OPEN`);break;case WebSocket.CLOSING:u(`CLOSING`);break;case WebSocket.CLOSED:u(`CLOSED`);break;default:u(`CLOSED`);break}})()},[Q,Pe]),(0,N.useEffect)(()=>{$&&Z&&(()=>{switch($.readyState){case WebSocket.CONNECTING:f(`CONNECTING`);break;case WebSocket.OPEN:f(`OPEN`);break;case WebSocket.CLOSING:f(`CLOSING`);break;case WebSocket.CLOSED:f(`CLOSED`);break;default:f(`CLOSED`);break}})()},[$,Z]);let Ge=(0,N.useMemo)(()=>({connectionState:Fe,sendMessage:We,isLoadingHistory:Ie,reconnect:Ue}),[Fe,We,Ie,Ue]);return(0,Oe.jsx)(ke.Provider,{value:Ge,children:e})}var X=()=>(0,N.useContext)(ke)||null;export{q as a,Te as c,xe as d,be as f,J as i,W as l,M as m,X as n,K as o,P as p,De as r,Ee as s,Y as t,U as u};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browser-
|
|
2
|
-
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{t as n}from"./preload-helper-CT1Z6Pdu.js";import{n as r}from"./vendor~entry.client-Du9GpFmX.js";import{t as i}from"./vendor~entry.client-CySJvEhK.js";import{o as a}from"./declaration-D378OjpZ.js";import{n as o,t as s}from"./providers-DXvCAN_u.js";import{s as c}from"./i18n-DjAGhTis.js";var l=e(t(),1),u=i();function d({mockApi:e=void 0,hasWindow:t=typeof window<`u`}={}){return t&&e===`true`}var f=a();async function p(){if(await c(),d()){let{worker:e}=await n(async()=>{let{worker:e}=await import(`./browser-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browser-HrYc5Gce.js","assets/vendor~browser-Dr71AdrG.js","assets/vendor~browser-BpdPBhgZ.js","assets/settings-D5am1n6X.js","assets/common-SMkEaBSr.js","assets/automation-XLxhq3I8.js","assets/query-client-config-Ba7qAAoO.js","assets/rolldown-runtime-BFRubm34.js","assets/vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~extensions~b4cctr4k-B7YVdv1X.js","assets/mutation-Cz7N4XAo.js","assets/custom-toast-handlers-BOc3qeQ7.js","assets/createLucideIcon-Ddu8jDOQ.js","assets/react-CM_dJw1Z.js","assets/declaration-D378OjpZ.js","assets/utils-D-HX7JCe.js","assets/vendor~entry.client~root~root-layout~home~conversation-panel~conversation~launch~extensions~i9dbt75i-CI82Did1.js","assets/i18n-DjAGhTis.js","assets/vendor~entry.client~root~root-layout~home~conversation-panel~conversation~skills-settings~m~o9nrx3fm-D44TR8hL.js","assets/health-store-BDC2rM-X.js","assets/retrieve-axios-error-message-BY-yIkIq.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{t as n}from"./preload-helper-CT1Z6Pdu.js";import{n as r}from"./vendor~entry.client-Du9GpFmX.js";import{t as i}from"./vendor~entry.client-CySJvEhK.js";import{o as a}from"./declaration-D378OjpZ.js";import{n as o,t as s}from"./providers-DXvCAN_u.js";import{s as c}from"./i18n-DjAGhTis.js";var l=e(t(),1),u=i();function d({mockApi:e=void 0,hasWindow:t=typeof window<`u`}={}){return t&&e===`true`}var f=a();async function p(){if(await c(),d()){let{worker:e}=await n(async()=>{let{worker:e}=await import(`./browser-HrYc5Gce.js`);return{worker:e}},__vite__mapDeps([0,1,2,3,4,5]));await e.start({onUnhandledRequest:`bypass`});let{queryClient:t}=await n(async()=>{let{queryClient:e}=await import(`./query-client-config-Ba7qAAoO.js`).then(e=>e.i);return{queryClient:e}},__vite__mapDeps([6,7,8,9,10,11,12,13,14,15,16,17,18,19]));window.__TEST_INVALIDATE_QUERIES__=e=>void t.invalidateQueries(e?{queryKey:e}:void 0)}}p().then(()=>(0,l.startTransition)(()=>{(0,u.hydrateRoot)(document,(0,f.jsx)(l.StrictMode,{children:(0,f.jsx)(s,{analytics:o,withStyleRoot:!1,children:(0,f.jsx)(r,{})})}))}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{t as n}from"./vendor~root~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-s~kyz9p27j-CyUbhpbm.js";import{o as r,t as i}from"./declaration-D378OjpZ.js";import{n as a}from"./QueryClientProvider-B7kl84Kj.js";import{t as o}from"./useTranslation-CpIcQBq6.js";import{t as s}from"./retrieve-axios-error-message-BY-yIkIq.js";import{t as c,v as l}from"./utils-D-HX7JCe.js";import{c as u,i as d,t as f,v as p}from"./agent-server-client-options-DT2GP6VJ.js";import{n as m}from"./active-backend-context-TVbjnvmP.js";import{r as h,u as g}from"./vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~dp08i1qy-CHrEOFl6.js";import{a as _}from"./agent-server-conversation-service.api-DSl9G5UR.js";import{t as v}from"./proxy-CurRmrqf.js";import{t as y}from"./react-Do0CT17Y.js";import{s as b}from"./conversation-local-storage-UYl-SX-r.js";import{a as x}from"./vendor~root-layout~home~conversation-panel~conversation~shared-conversation~alert-banner~pl~rqjteh0a-BP1SKG0F.js";import{t as S}from"./folder-0WSMImNX.js";import{t as C}from"./chevron-left-small-CSh-sE9L.js";import{t as w}from"./git-status-mapper-BI8FyUVp.js";import{n as T,t as E}from"./use-conversation-id-DajhCn2A.js";import{n as D,t as O}from"./link-external-Df8J52xI.js";import{t as k}from"./use-active-conversation-D15D9GgR.js";import{t as A}from"./use-agent-state-DE5dlEXJ.js";import{t as ee}from"./use-event-store-CQZCcVz-.js";import{t as j}from"./files-tab-store-CDyVTXNT.js";import{r as te}from"./typography-vVUMoNUg.js";import{ot as ne,st as re}from"./vendor~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-Ds9quNZ9.js";import{t as M}from"./markdown-renderer-CEX4Becj.js";import{t as N}from"./use-runtime-is-ready-XFbT16BD.js";import{t as ie}from"./conversation-tab-empty-state-D8dNvo-V.js";import{a as ae,c as oe,i as se,n as ce,o as le,r as ue,s as de,t as fe}from"./vendor~files-tab-DtLR-QD9.js";var P=e(t(),1),F=class{static async executeCommand(e,t,n,r,i=30){let a=u().backend;if(a.kind===`cloud`&&e){let o=await v({backend:a,method:`POST`,hostOverride:d(e),path:`/api/bash/execute_bash_command`,body:{command:n,...r?{cwd:r}:{},timeout:Math.floor(i)},authMode:`session-api-key`,sessionApiKey:t,timeoutSeconds:i+10});return{exit_code:o.exit_code??-1,stdout:o.stdout??``,stderr:o.stderr??``}}let o=await new h(f({conversationUrl:e,sessionApiKey:t})).executeCommand(n,r,i);return{exit_code:o.exit_code,stdout:o.stdout,stderr:o.stderr}}static async downloadFile(e,t,n){let r=u().backend;return r.kind===`cloud`&&e?(await v({backend:r,method:`GET`,hostOverride:d(e),path:`/api/file/download?path=${encodeURIComponent(n)}`,authMode:`session-api-key`,sessionApiKey:t,responseType:`blob`})).arrayBuffer():new g(f({conversationUrl:e,sessionApiKey:t})).downloadFile(n)}},I=2e3,pe=[`.git`,`node_modules`,`.venv`,`venv`,`__pycache__`,`dist`,`build`,`.next`,`.cache`,`.pytest_cache`,`.mypy_cache`,`.turbo`,`.parcel-cache`,`target`];function me(){return`find . \\( ${pe.map(e=>`-name '${e}' -prune`).join(` -o `)} \\) -o -type f -print 2>/dev/null | sort | head -n ${I}`}function he(e){return e.startsWith(`./`)?e.slice(2):e}function ge(){let{data:e}=k(),t=N(),r=e?.id,i=e?.conversation_url,a=e?.session_api_key,o=e?.workspace?.working_dir?.trim();return n({queryKey:[`workspace-files`,r,i,a,o],queryFn:async()=>{let e=await F.executeCommand(i,a,me(),o,30);if(e.exit_code!==0)throw Error(e.stderr?.trim()||`Failed to list workspace files`);let t=e.stdout.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).map(he);return Array.from(new Set(t)).slice(0,I)},enabled:t&&!!r&&!!o,retry:!1,staleTime:1e3*30,gcTime:1e3*60*5,meta:{disableToast:!0}})}function _e(){let{data:e}=k(),t=N(),r=e?.id,i=e?.conversation_url,a=e?.session_api_key,o=u().backend.kind===`local`,s=n({queryKey:[`workspace-session`,r,i,a],queryFn:async()=>({baseUrl:await new h(f({conversationUrl:i,sessionApiKey:a})).startWorkspaceSession(r)}),enabled:t&&!!r&&o,staleTime:1/0,gcTime:1/0,retry:!1});return{data:s.data??null,isLoading:s.isLoading,isError:s.isError,error:s.error??null}}function ve(e,t){let n=(t??``).replace(/^\/+/,``);return n?`${e}${n.split(`/`).map(e=>encodeURIComponent(e)).join(`/`)}`:e}var L=y(e=>({count:0,bump:()=>e(e=>({count:e.count+1}))}));function R(e,t){return e===null?null:`${e}${e.includes(`?`)?`&`:`?`}v=${t}`}var ye=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`ico`,`svg`,`avif`]),be=new Set([`pdf`]);function z(e){let t=e.lastIndexOf(`.`);return t===-1?``:e.slice(t+1).toLowerCase()}function xe(e){switch(z(e)){case`html`:case`htm`:return`text/html`;case`css`:return`text/css`;case`js`:case`mjs`:case`cjs`:return`text/javascript`;case`json`:return`application/json`;case`md`:case`markdown`:return`text/markdown`;case`svg`:return`image/svg+xml`;case`png`:return`image/png`;case`jpg`:case`jpeg`:return`image/jpeg`;case`gif`:return`image/gif`;case`webp`:return`image/webp`;case`bmp`:return`image/bmp`;case`ico`:return`image/x-icon`;case`avif`:return`image/avif`;case`pdf`:return`application/pdf`;default:return`text/plain`}}function Se(e){let t=z(e);return ye.has(t)?`image`:be.has(t)?`pdf`:`text`}function B(e){let t=new Uint8Array(e,0,Math.min(e.byteLength,8e3));for(let e=0;e<t.length;e+=1)if(t[e]===0)return!0;return!1}function V(e){let t=new Uint8Array(e),n=32768,r=``;for(let e=0;e<t.length;e+=n)r+=String.fromCharCode.apply(null,t.subarray(e,e+n));return btoa(r)}function H(e){let{data:t}=k(),r=N(),{data:i}=_e(),a=L(e=>e.count),o=t?.id,s=t?.conversation_url,c=t?.session_api_key,l=i?.baseUrl,d=u().backend.kind===`cloud`;return n({queryKey:[`workspace-file-content`,o,s,c,d?`cloud`:l,e,a],queryFn:async()=>{if(!e)throw Error(`No path`);let t=Se(e),n=xe(e);if(d){let r=await F.downloadFile(s,c,e);return t===`text`?B(r)?{path:e,kind:`binary`,text:null,staticUrl:`data:application/octet-stream;base64,${V(r)}`,mimeType:`application/octet-stream`}:{path:e,kind:`text`,text:new TextDecoder(`utf-8`,{fatal:!1}).decode(r),staticUrl:`data:${n};charset=utf-8;base64,${V(r)}`,mimeType:n}:{path:e,kind:t,text:null,staticUrl:`data:${n};base64,${V(r)}`,mimeType:n}}if(!l)throw Error(`No workspace session`);let r=ve(l,e);if(t!==`text`)return{path:e,kind:t,text:null,staticUrl:r,mimeType:n};let i=await fetch(r,{credentials:`include`});if(!i.ok)throw Error(`Failed to read ${e}: ${i.status}`);let a=await i.arrayBuffer();return B(a)?{path:e,kind:`binary`,text:null,staticUrl:r,mimeType:`application/octet-stream`}:{path:e,kind:`text`,text:new TextDecoder(`utf-8`,{fatal:!1}).decode(a),staticUrl:r,mimeType:n}},enabled:r&&!!o&&!!e&&(d||!!l),retry:!1,staleTime:1e3*5,gcTime:1e3*60,meta:{disableToast:!0}})}function Ce(){let{data:e,isLoading:t}=k(),n=e?.id?_(e.id):null;return{hasAttachedSource:!!e?.selected_repository||!!n?.selected_workspace,isLoading:t}}function we(e){let{data:t}=k(),r=N(),{backend:i}=m(),a=i.kind===`local`,o=t?.id,s=t?.conversation_url,c=t?.session_api_key,l=t?.workspace?.working_dir?.trim(),u=(e?.enabled??!0)&&a&&r&&!!o&&!!l,d=n({queryKey:[`has-git-commits`,o,s,c,l],queryFn:async()=>(await F.executeCommand(s,c,`git rev-parse --verify HEAD`,l,10)).exit_code===0,enabled:u,retry:!1,staleTime:6e4,gcTime:5*6e4,meta:{disableToast:!0}});return{hasCommits:d.data??null,isLoading:d.isLoading}}var Te=new Set([`FileEditorObservation`,`StrReplaceEditorObservation`,`PlanningFileEditorObservation`]),Ee=new Set([`view`]);function De(e){let t=e.observation;return!(!t||typeof t.kind!=`string`||!Te.has(t.kind)||t.command&&Ee.has(t.command))}function Oe(){let e=a(),t=ee(e=>e.events),n=L(e=>e.bump),r=(0,P.useRef)(new Set),i=(0,P.useRef)(new WeakSet);(0,P.useEffect)(()=>{let a=[];for(let e of t){let t=`id`in e?e.id:void 0;(t===void 0?i.current.has(e):r.current.has(t))||(t===void 0?i.current.add(e):r.current.add(t),De(e)&&a.push(e))}a.length!==0&&(e.invalidateQueries({queryKey:[`workspace-files`]}),e.invalidateQueries({queryKey:[`workspace-file-content`]}),e.invalidateQueries({queryKey:[`file_changes`]}),n())},[t,e,n])}function U(e){return e.startsWith(`/`)?e:`/${e}`}var W=class{static async getGitChanges(e,t,n){let r=u().backend;if(r.kind===`cloud`&&e){let i=new URLSearchParams;i.set(`path`,U(n));let a=await v({backend:r,method:`GET`,hostOverride:d(e),path:`/api/git/changes?${i.toString()}`,authMode:`session-api-key`,sessionApiKey:t});if(!Array.isArray(a))throw Error(`Invalid response from runtime - runtime may be unavailable`);return a.map(e=>({status:w(String(e.status)),path:e.path}))}let i=await new h(f({conversationUrl:e,sessionApiKey:t})).gitChanges(n,{ref:`HEAD`});if(!Array.isArray(i))throw Error(`Invalid response from runtime - runtime may be unavailable`);return i.map(e=>({status:w(String(e.status)),path:e.path}))}static async getGitChangeDiff(e,t,n){let r=u().backend;if(r.kind===`cloud`&&e){let i=new URLSearchParams;i.set(`path`,U(n));let a=await v({backend:r,method:`GET`,hostOverride:d(e),path:`/api/git/diff?${i.toString()}`,authMode:`session-api-key`,sessionApiKey:t});return{modified:a?.modified??``,original:a?.original??``,...a?.diff?{diff:a.diff}:{}}}let i=await new h(f({conversationUrl:e,sessionApiKey:t})).gitDiff(n,{ref:`HEAD`});return{modified:i.modified??``,original:i.original??``,...i.diff?{diff:i.diff}:{}}}};function G(e,t){let n=t?.trim();if(n)return n;if(!e)return p;let r=e.split(`/`);return`${p}/${r[r.length-1]}`}var K=()=>{let{conversationId:e}=E(),{data:t}=k(),[r,i]=P.useState([]),a=P.useRef(null),o=N(),s=t?.conversation_url,c=t?.session_api_key,l=t?.selected_repository,u=t?.workspace?.working_dir?.trim(),d=P.useMemo(()=>G(l,u),[l,u]),f=n({queryKey:[`file_changes`,e,s,c,d],queryFn:async()=>{if(!e)throw Error(`No conversation ID`);return W.getGitChanges(s,c,d)},retry:!1,staleTime:1e3*60*5,gcTime:1e3*60*15,refetchOnMount:`always`,enabled:o&&!!e,meta:{disableToast:!0}});return P.useEffect(()=>{if(!f.isFetching&&f.isSuccess&&f.data){let e=f.data;if(e!==a.current)if(a.current=e,Array.isArray(e)){let t=new Set(e.map(e=>e.path)),n=new Set(r.map(e=>e.path)),a=e.filter(e=>!n.has(e.path)),o=r.filter(e=>t.has(e.path));i([...a,...o])}else i([e])}},[f.isFetching,f.isSuccess,f.data]),{data:r,isLoading:f.isLoading,isFetching:f.isFetching,isSuccess:f.isSuccess,isError:f.isError,error:f.error,refetch:f.refetch}},ke=[`index.html`,`index.htm`,`readme.md`,`readme`,`main.html`,`app.html`,`index.js`,`index.ts`,`index.tsx`,`index.jsx`,`main.py`,`app.py`,`main.go`,`main.rs`,`main.java`,`main.c`,`main.cpp`,`package.json`,`pyproject.toml`,`cargo.toml`,`go.mod`,`pom.xml`,`dockerfile`,`makefile`],Ae=[`license`,`license.md`,`license.txt`,`changelog.md`,`agents.md`,`tsconfig.json`,`.env.sample`,`.env.example`];function je(e){let t=e.lastIndexOf(`/`);return(t===-1?e:e.slice(t+1)).toLowerCase()}function q(e){return e.split(`/`).filter(Boolean).length-1}function J(e){let t=je(e),n=ke.indexOf(t);if(n!==-1)return n;let r=Ae.indexOf(t);return r===-1?1e4:1e3+r}function Y(e){return[...e].sort((e,t)=>{let n=q(e)-q(t);if(n!==0)return n;let r=J(e)-J(t);return r===0?e.localeCompare(t):r})}var X=r(),Me=e=>(0,X.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,...e,children:(0,X.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M10.8615 8.16992L14.2799 12.158L10.8615 16.1461L9.72266 15.1699L12.3043 12.158L9.72266 9.14611L10.8615 8.16992Z`,fill:`currentColor`})});function Ne({paths:e,selectedPath:t,onSelectFile:n,isTreeVisible:r,onToggleTree:a}){let{t:s}=o(`openhands`),l=(0,P.useMemo)(()=>Y(e),[e]);return(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-[var(--oh-border)] px-2 py-1.5 min-h-[34px]`,"data-testid":`file-quick-row`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:a,"data-testid":`file-quick-row-tree-toggle`,"aria-pressed":r,"aria-label":s(r?i.FILES$HIDE_FILE_TREE:i.FILES$SHOW_FILE_TREE),title:s(r?i.FILES$HIDE_FILE_TREE:i.FILES$SHOW_FILE_TREE),className:c(`shrink-0 inline-flex items-center justify-center w-6 h-6 rounded-md cursor-pointer`,`text-[var(--oh-text-tertiary)] hover:bg-tertiary`,r&&`bg-[var(--oh-surface-raised)]`),children:r?(0,X.jsx)(C,{className:`w-3 h-3`}):(0,X.jsx)(Me,{className:`w-3 h-3`})}),l.length>0&&(0,X.jsx)(`div`,{className:`flex flex-nowrap items-center gap-1.5 overflow-hidden flex-1 min-w-0`,children:l.map(e=>{let r=t===e;return(0,X.jsx)(`button`,{type:`button`,onClick:()=>n(e),title:e,"data-testid":`file-quick-row-item-${e}`,className:c(`inline-flex items-center px-2 py-0.5 text-xs whitespace-nowrap rounded-md cursor-pointer`,r?`bg-[var(--oh-interactive-hover)] text-white`:`bg-[var(--oh-surface-raised)] text-[var(--oh-text-tertiary)] hover:bg-tertiary`),children:e},e)})})]})}function Z(e){e.children.sort((e,t)=>e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1);for(let t of e.children)t.isDirectory&&Z(t)}function Pe(e,t,n,r,i){let a=t.get(e);a||(a=new Map,t.set(e,a));let o=a.get(n);if(o)return!i&&!o.isDirectory&&(o.isDirectory=!0),o;let s={name:n,path:r,isDirectory:!i,children:[]};return e.children.push(s),a.set(n,s),s}function Fe(e){let t={name:``,path:``,isDirectory:!0,children:[]},n=new Map;for(let r of e){let e=r.split(`/`).filter(Boolean);if(e.length>0){let r=t,i=``;for(let t=0;t<e.length;t+=1){let a=e[t];i=i?`${i}/${a}`:a;let o=t===e.length-1;r=Pe(r,n,a,i,o)}}}return Z(t),t}function Q({node:e,depth:t,selectedPath:n,onSelectFile:r}){let[i,a]=(0,P.useState)(!1),o=8+t*12;if(e.isDirectory)return(0,X.jsxs)(`li`,{children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),"aria-expanded":i,"data-testid":`file-tree-dir-${e.path}`,className:c(`flex w-full items-center gap-1.5 py-1 pr-2 text-left text-sm text-white`,`hover:bg-tertiary cursor-pointer`),style:{paddingLeft:`${o}px`},children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:c(`inline-block w-3 text-[10px] text-[var(--oh-muted)] transition-transform`,i?`rotate-90`:`rotate-0`),children:`▶`}),(0,X.jsx)(S,{className:`w-3.5 h-3.5 shrink-0`}),(0,X.jsx)(`span`,{className:`truncate`,children:e.name})]}),i&&e.children.length>0&&(0,X.jsx)(`ul`,{children:e.children.map(e=>(0,X.jsx)(Q,{node:e,depth:t+1,selectedPath:n,onSelectFile:r},e.path))})]});let s=n===e.path;return(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,onClick:()=>r(e.path),"data-testid":`file-tree-file-${e.path}`,className:c(`flex w-full items-center gap-1.5 py-1 pr-2 text-left text-sm`,`hover:bg-tertiary cursor-pointer`,s?`bg-[var(--oh-interactive-hover)] text-white`:`text-[var(--oh-text-tertiary)]`),style:{paddingLeft:`${o+16}px`},children:[(0,X.jsx)(D,{className:`w-3.5 h-3.5 shrink-0`}),(0,X.jsx)(`span`,{className:`truncate`,children:e.name})]})})}function Ie({paths:e,selectedPath:t,onSelectFile:n}){let{t:r}=o(`openhands`),a=(0,P.useMemo)(()=>Fe(e),[e]);return a.children.length===0?(0,X.jsx)(`div`,{className:`px-3 py-4 text-sm text-[var(--oh-muted)]`,children:r(i.FILES$NO_FILES)}):(0,X.jsx)(`ul`,{className:`py-1 custom-scrollbar-always`,"data-testid":`file-tree-view`,children:a.children.map(e=>(0,X.jsx)(Q,{node:e,depth:0,selectedPath:t,onSelectFile:n},e.path))})}var Le={js:`javascript`,jsx:`jsx`,mjs:`javascript`,cjs:`javascript`,ts:`typescript`,tsx:`tsx`,py:`python`,pyi:`python`,pyw:`python`,html:`markup`,htm:`markup`,svg:`markup`,xml:`markup`,css:`css`,scss:`scss`,sass:`sass`,less:`less`,json:`json`,json5:`json5`,yaml:`yaml`,yml:`yaml`,toml:`toml`,ini:`ini`,cfg:`ini`,properties:`properties`,conf:`ini`,env:`bash`,md:`markdown`,markdown:`markdown`,mdx:`markdown`,sh:`bash`,bash:`bash`,zsh:`bash`,fish:`bash`,bat:`batch`,cmd:`batch`,ps1:`powershell`,ps:`powershell`,c:`c`,h:`c`,cpp:`cpp`,cc:`cpp`,cxx:`cpp`,hpp:`cpp`,hh:`cpp`,cs:`csharp`,java:`java`,kt:`kotlin`,kts:`kotlin`,scala:`scala`,rs:`rust`,go:`go`,rb:`ruby`,php:`php`,swift:`swift`,m:`objectivec`,mm:`objectivec`,hs:`haskell`,ex:`elixir`,exs:`elixir`,erl:`erlang`,fs:`fsharp`,fsx:`fsharp`,ml:`ocaml`,mli:`ocaml`,clj:`clojure`,cljs:`clojure`,cljc:`clojure`,lua:`lua`,pl:`perl`,pm:`perl`,r:`r`,jl:`julia`,dart:`dart`,groovy:`groovy`,gradle:`groovy`,tf:`hcl`,hcl:`hcl`,dockerfile:`docker`,sql:`sql`,graphql:`graphql`,gql:`graphql`,proto:`protobuf`,diff:`diff`,patch:`diff`,nix:`nix`,sol:`solidity`},Re={dockerfile:`docker`,makefile:`makefile`,gnumakefile:`makefile`,".bashrc":`bash`,".zshrc":`bash`,".profile":`bash`,".env":`bash`,".gitignore":`bash`,".dockerignore":`bash`};function ze(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`)),n=e.slice(t+1),r=n.lastIndexOf(`.`);return r<=0?``:n.slice(r+1).toLowerCase()}function Be(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return e.slice(t+1).toLowerCase()}function Ve(e,t){let n=Re[Be(e)];if(n)return n;let r=ze(e);if(r&&Le[r])return Le[r];if(t){if(t===`text/html`)return`markup`;if(t===`text/css`)return`css`;if(t===`application/json`)return`json`;if(t===`text/markdown`)return`markdown`;if(t===`application/javascript`||t===`text/javascript`)return`javascript`;if(t===`application/x-yaml`||t===`text/yaml`)return`yaml`}return null}function He({path:e,text:t,mimeType:n}){let r=Ve(e,n);return r?(0,X.jsx)(`div`,{"data-testid":`file-content-viewer-highlighted`,"data-language":r,className:`h-full w-full overflow-auto bg-[var(--oh-surface)] custom-scrollbar-always`,children:(0,X.jsx)(ne,{language:r,style:re,showLineNumbers:!0,wrapLongLines:!1,customStyle:{margin:0,padding:`1rem`,background:`transparent`,fontSize:`0.75rem`,lineHeight:`1.25rem`,minHeight:`100%`},codeTagProps:{style:{background:`transparent`,fontFamily:`inherit`}},lineNumberStyle:{color:`var(--oh-border)`,minWidth:`2.5em`,paddingRight:`1em`,userSelect:`none`},children:t})}):(0,X.jsx)(`pre`,{"data-testid":`file-content-viewer-plain`,className:`h-full w-full overflow-auto whitespace-pre-wrap break-words bg-[var(--oh-surface)] p-4 text-xs leading-5 text-white custom-scrollbar-always`,children:t})}var Ue=new Set([`html`,`htm`,`svg`]),We=new Set([`md`,`markdown`,`mdx`]);function Ge(e){let t=e.lastIndexOf(`.`);return t===-1?``:e.slice(t+1).toLowerCase()}function Ke({path:e,viewMode:t}){let{t:n}=o(`openhands`),r=H(e),a=L(e=>e.count);if(r.isLoading)return(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center text-sm text-[var(--oh-muted)]`,children:n(i.FILES$LOADING_FILES)});if(r.isError||!r.data)return(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center text-sm text-[var(--oh-muted)]`,"data-testid":`file-content-viewer-error`,children:r.error?.message??n(i.FILES$LOAD_ERROR)});let{kind:s,text:c,staticUrl:l,mimeType:u}=r.data,d=R(l,a);return t===`plain`?s===`text`&&c!==null?(0,X.jsx)(He,{path:e,text:c,mimeType:u??void 0}):(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center text-sm text-[var(--oh-muted)]`,"data-testid":`file-content-viewer-binary-fallback`,children:n(i.FILES$BINARY_FALLBACK)}):s===`image`?(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center bg-[var(--oh-surface)] p-4`,"data-testid":`file-content-viewer-image`,children:(0,X.jsx)(`img`,{src:d,alt:e,className:`max-h-full max-w-full object-contain`})}):s===`pdf`?(0,X.jsx)(`iframe`,{title:e,src:d,sandbox:`allow-same-origin`,"data-testid":`file-content-viewer-iframe`,className:`h-full w-full bg-white`}):s===`binary`?(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center text-sm text-[var(--oh-muted)]`,"data-testid":`file-content-viewer-binary-fallback`,children:n(i.FILES$BINARY_FALLBACK)}):u===`text/html`||Ue.has(Ge(e))?(0,X.jsx)(`iframe`,{title:e,src:d,sandbox:`allow-same-origin`,"data-testid":`file-content-viewer-iframe`,className:`h-full w-full bg-white`}):s===`text`&&We.has(Ge(e))?(0,X.jsx)(`div`,{"data-testid":`file-content-viewer-markdown`,className:`h-full w-full overflow-auto bg-[var(--oh-surface)] text-white custom-scrollbar-always`,children:(0,X.jsx)(`div`,{className:`prose prose-sm prose-invert max-w-none p-6 [--tw-prose-body:#fff] [--tw-prose-bold:#fff] [--tw-prose-headings:#fff] [--tw-prose-lead:#fff] [--tw-prose-counters:#fff] [--tw-prose-quotes:#fff] [--tw-prose-quote-borders:var(--oh-border-subtle)] [--tw-prose-bullets:var(--oh-muted)] [--tw-prose-hr:var(--oh-border-subtle)] [--tw-prose-captions:var(--oh-muted)] [--tw-prose-kbd:#fff]`,children:(0,X.jsx)(M,{content:c??``,includeStandard:!0,includeHeadings:!0})})}):s===`text`&&c!==null?(0,X.jsx)(He,{path:e,text:c,mimeType:u??void 0}):(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center text-sm text-[var(--oh-muted)]`,"data-testid":`file-content-viewer-binary-fallback`,children:n(i.FILES$BINARY_FALLBACK)})}function qe({value:e,options:t,onChange:n,ariaLabel:r,testId:i}){return(0,X.jsx)(`div`,{role:`radiogroup`,"aria-label":r,"data-testid":i,className:`inline-flex items-center rounded-md bg-[var(--oh-surface-raised)] p-0.5 text-xs`,children:t.map(t=>{let r=t.value===e;return(0,X.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":r,"data-testid":i?`${i}-option-${t.value}`:void 0,onClick:()=>n(t.value),className:c(`px-2 py-0.5 rounded cursor-pointer transition-colors`,r?`bg-[var(--oh-interactive-hover)] text-white`:`text-[var(--oh-muted)] hover:text-white`),children:t.label},t.value)})})}var Je=e=>(0,X.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 13 15`,fill:`none`,...e,children:(0,X.jsx)(`path`,{d:`M6.59467 0.21967C6.88756 -0.0732233 7.36244 -0.0732233 7.65533 0.21967L9.90533 2.46967C10.1982 2.76256 10.1982 3.23744 9.90533 3.53033L7.65533 5.78033C7.36244 6.07322 6.88756 6.07322 6.59467 5.78033C6.30178 5.48744 6.30178 5.01256 6.59467 4.71967L7.56434 3.75H6.375C3.71421 3.75 1.5 5.96421 1.5 8.625C1.5 11.2858 3.71421 13.5 6.375 13.5C9.03579 13.5 11.25 11.2858 11.25 8.625C11.25 8.21079 11.5858 7.875 12 7.875C12.4142 7.875 12.75 8.21079 12.75 8.625C12.75 12.1142 9.86421 15 6.375 15C2.88579 15 0 12.1142 0 8.625C0 5.13579 2.88579 2.25 6.375 2.25H7.56434L6.59467 1.28033C6.30178 0.987437 6.30178 0.512563 6.59467 0.21967Z`,fill:`currentColor`})}),Ye=e=>{switch(e.split(`.`).pop()?.toLowerCase()){case`js`:case`jsx`:return`javascript`;case`ts`:case`tsx`:return`typescript`;case`py`:return`python`;case`html`:return`html`;case`css`:return`css`;case`json`:return`json`;case`md`:return`markdown`;case`yml`:case`yaml`:return`yaml`;case`sh`:case`bash`:return`bash`;case`dockerfile`:return`dockerfile`;case`rs`:return`rust`;case`go`:return`go`;case`java`:return`java`;case`cpp`:case`cc`:case`cxx`:return`cpp`;case`c`:return`c`;case`rb`:return`ruby`;case`php`:return`php`;case`sql`:return`sql`;default:return`text`}},Xe=e=>(0,X.jsx)(`svg`,{width:13,height:8,viewBox:`0 0 13 8`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,X.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M0.259766 6.17427L6.26425 0.715628L12.2688 6.17427L11.2597 7.28418L6.26425 2.74282L1.26878 7.28418L0.259766 6.17427Z`,fill:`currentColor`})}),Ze=e=>{let{conversationId:t}=E(),{data:r}=k(),i=r?.conversation_url,a=r?.session_api_key,o=r?.selected_repository,s=r?.workspace?.working_dir?.trim(),c=P.useMemo(()=>`${G(o,s)}/${e.filePath}`,[o,e.filePath,s]),l=e.type===`D`;return n({queryKey:[`file_diff`,t,i,a,c],queryFn:async()=>{if(!t)throw Error(`No conversation ID`);return W.getGitChangeDiff(i,a,c)},enabled:e.enabled&&!l,staleTime:1e3*60*5,gcTime:1e3*60*15})};function Qe({className:e}){return(0,X.jsx)(`div`,{className:`flex items-center justify-center`,children:(0,X.jsx)(`div`,{className:c(`animate-spin rounded-full border-4 border-[var(--oh-border)] border-t-white`,e),role:`status`,"aria-label":`Loading`})})}function $e({height:e,children:t}){return(0,X.jsx)(`div`,{"data-testid":`editor-container`,className:`w-full border-b border-[var(--oh-border)] overflow-hidden h-[var(--editor-height)]`,style:{"--editor-height":`${e}px`},children:t})}var et=[{mode:`old`,icon:le},{mode:`diff`,icon:ae},{mode:`new`,icon:fe}],tt={renderValidationDecorations:`off`,readOnly:!0,scrollBeyondLastLine:!1,minimap:{enabled:!1},automaticLayout:!0,scrollbar:{alwaysConsumeMouseWheel:!1}},nt={A:se,D:ue,M:ce,R:`Renamed`,U:`Untracked`},rt=e=>{e.editor.defineTheme(`custom-diff-theme`,{base:`vs-dark`,inherit:!0,rules:[{token:`comment`,foreground:`6a9955`},{token:`keyword`,foreground:`569cd6`},{token:`string`,foreground:`ce9178`},{token:`number`,foreground:`b5cea8`}],colors:{"diffEditor.insertedTextBackground":`#014b01AA`,"diffEditor.removedTextBackground":`#750000AA`,"diffEditor.insertedLineBackground":`#003f00AA`,"diffEditor.removedLineBackground":`#5a0000AA`,"diffEditor.border":`var(--oh-border-subtle)`,"editorUnnecessaryCode.border":`#00000000`,"editorUnnecessaryCode.opacity":`rgba(0, 0, 0, 0.467)`}})};function it({path:e,type:t}){let{t:n}=o(`openhands`),[r,a]=P.useState(!0),[s,l]=P.useState(400),[u,d]=P.useState(`diff`),f=P.useRef(null),p=P.useRef(null),m=t===`A`||t===`U`,h=t===`D`,g=P.useMemo(()=>{if(t===`R`){let t=e.split(/\s+/).slice(1);return t[t.length-1]}return e},[e,t]),{data:_,isLoading:v,isSuccess:y,isRefetching:b}=Ze({filePath:g,type:t,enabled:!r}),x=P.useCallback(()=>{if(!f.current)return;let e=f.current.getOriginalEditor(),t=f.current.getModifiedEditor();e&&t&&l(Math.max(e.getContentHeight(),t.getContentHeight())+20)},[]),S=P.useCallback(()=>{p.current&&l(p.current.getContentHeight()+20)},[]),C=e=>{f.current=e,x(),e.getOriginalEditor().onDidContentSizeChange(x),e.getModifiedEditor().onDidContentSizeChange(x)},w=e=>{p.current=e,S(),e.onDidContentSizeChange(S)},T=(t===`U`?nt.A:nt[t])||`?`,E=typeof T==`string`?(0,X.jsx)(te.Text,{children:T}):P.createElement(T,{className:`w-5 h-5`}),D=v||b,O=Ye(g),k=O===`markdown`,A=u===`old`?_?.original??``:_?.modified??``;return(0,X.jsxs)(`div`,{"data-testid":`file-diff-viewer-outer`,className:`w-full flex flex-col`,children:[(0,X.jsx)(`div`,{className:`flex justify-between items-center px-3 py-2.5 border-b border-[var(--oh-border)] hover:cursor-pointer`,onClick:()=>a(e=>!e),children:(0,X.jsxs)(`span`,{className:`text-sm w-full text-content flex items-center gap-2`,children:[D?(0,X.jsx)(Qe,{className:`w-4 h-4`}):E,(0,X.jsx)(`strong`,{className:`w-full truncate font-medium`,children:g}),!r&&!h&&(0,X.jsx)(`span`,{className:`flex items-center gap-0.5 shrink-0`,onClick:e=>e.stopPropagation(),children:et.map(({mode:e,icon:t})=>(0,X.jsx)(`button`,{"data-testid":`view-mode-${e}`,type:`button`,"aria-pressed":u===e,onClick:()=>d(e),className:c(`p-1 rounded transition-colors cursor-pointer`,u===e?`bg-[var(--oh-interactive-hover)] text-white`:`text-[var(--oh-muted)] hover:bg-[var(--oh-interactive-hover)] hover:text-white`),children:(0,X.jsx)(t,{className:`w-4 h-4`})},e))}),(0,X.jsx)(`button`,{"data-testid":`collapse`,type:`button`,children:(0,X.jsx)(Xe,{className:c(`w-4 h-4 transition-transform`,r&&`transform rotate-180`)})})]})}),!r&&h&&(0,X.jsx)(`div`,{"data-testid":`file-deleted-message`,className:`w-full border-b border-[var(--oh-border)] p-4 bg-base text-[var(--oh-text-dim)] text-sm`,children:n(i.DIFF_VIEWER$FILE_DELETED)}),!r&&!h&&y&&(u===`diff`?(0,X.jsx)($e,{height:s,children:(0,X.jsx)(oe,{"data-testid":`file-diff-viewer`,className:`w-full h-full`,language:O,original:m?``:_?.original??``,modified:h?``:_?.modified??``,theme:`custom-diff-theme`,onMount:C,beforeMount:rt,options:{...tt,renderSideBySide:!m&&!h,hideUnchangedRegions:{enabled:!0}}})}):k?(0,X.jsx)(`div`,{className:`w-full border-b border-[var(--oh-border)] overflow-auto p-4 bg-base prose prose-invert max-w-none`,"data-testid":`markdown-preview`,children:(0,X.jsx)(M,{content:A,includeStandard:!0,includeHeadings:!0})}):(0,X.jsx)($e,{height:s,children:(0,X.jsx)(de,{"data-testid":`file-single-viewer`,className:`w-full h-full`,language:O,value:A,theme:`custom-diff-theme`,beforeMount:rt,onMount:w,options:tt})}))]})}function at(){let{t:e}=o(`openhands`);return(0,X.jsx)(ie,{icon:(0,X.jsx)(x,{}),children:e(i.DIFF_VIEWER$NO_CHANGES)})}var ot=[{key:i.TIPS$CUSTOMIZE_MICROAGENT,link:`https://docs.all-hands.dev/usage/prompting/microagents-repo`},{key:i.TIPS$SETUP_SCRIPT,link:`https://docs.all-hands.dev/usage/prompting/repository#setup-script`},{key:i.TIPS$VSCODE_INSTANCE},{key:i.TIPS$SAVE_WORK},{key:i.TIPS$SPECIFY_FILES,link:`https://docs.all-hands.dev/usage/prompting/prompting-best-practices`},{key:i.TIPS$HEADLESS_MODE,link:`https://docs.all-hands.dev/usage/how-to/headless-mode`},{key:i.TIPS$CLI_MODE,link:`https://docs.all-hands.dev/usage/how-to/cli-mode`},{key:i.TIPS$GITHUB_HOOK,link:`https://docs.all-hands.dev/usage/cloud/github-installation#working-on-github-issues-and-pull-requests-using-openhands`},{key:i.TIPS$BLOG_SIGNUP,link:`https://www.all-hands.dev/blog`},{key:i.TIPS$API_USAGE,link:`https://docs.all-hands.dev/api-reference/health-check`}];function st(){return ot[Math.floor(Math.random()*ot.length)]}function ct(){let{t:e}=o(`openhands`),[t,n]=P.useState(st());return P.useEffect(()=>{n(st())},[]),(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`h4`,{className:`font-bold`,children:[e(i.TIPS$PROTIP),`:`]}),(0,X.jsxs)(`p`,{children:[e(t.key),t.link&&(0,X.jsxs)(X.Fragment,{children:[` `,(0,X.jsx)(`a`,{href:t.link,target:`_blank`,rel:`noopener noreferrer`,className:`underline`,children:e(i.TIPS$LEARN_MORE)})]})]})]})}var $=/not a git repository/i;function lt({children:e}){return(0,X.jsx)(`div`,{className:`w-full h-full flex flex-col items-center text-center justify-center text-2xl text-tertiary-light`,children:e})}function ut(){let{t:e}=o(`openhands`),{data:t,isSuccess:n,isError:r,error:a,isLoading:c}=K(),[u,d]=P.useState(null),{curAgentState:f}=A(),p=!l.includes(f),m=a&&$.test(s(a));return P.useEffect(()=>{if(!p)d([i.DIFF_VIEWER$WAITING_FOR_RUNTIME]);else if(a){let e=s(a);$.test(e)?d([i.DIFF_VIEWER$NOT_A_GIT_REPO,i.DIFF_VIEWER$ASK_OH]):d([e])}else d(c?[i.DIFF_VIEWER$LOADING]:null)},[p,m,c,a,d]),(0,X.jsx)(`main`,{className:`h-full w-full flex flex-col items-stretch`,children:!n||!t.length?(0,X.jsxs)(`div`,{className:`flex flex-col h-full w-full`,children:[(0,X.jsxs)(`div`,{className:`flex-1 flex items-center justify-center`,children:[u&&(0,X.jsx)(lt,{children:u.map(t=>(0,X.jsx)(`span`,{children:e(t)},t))}),!u&&n&&t.length===0&&(0,X.jsx)(at,{})]}),!r&&n&&t.length===0&&(0,X.jsx)(`div`,{className:`w-full text-m bg-tertiary p-4 text-left`,children:(0,X.jsx)(ct,{})})]}):(0,X.jsx)(`div`,{className:`h-full overflow-y-auto flex flex-col items-stretch custom-scrollbar-always`,children:t.slice(0,100).map(e=>(0,X.jsx)(it,{path:e.path,type:e.status},e.path))})})}function dt(){let{t:e}=o(`openhands`);Oe();let{hasAttachedSource:t,isLoading:n}=Ce(),{hasCommits:r}=we({enabled:t}),{conversationId:s}=T(),{state:c,setFilesTabDiffView:l,setFilesTabContentViewMode:u}=b(s??``),d=(t||n)&&r!==!1,f=c.filesTabDiffView??d,p=c.filesTabContentViewMode,[m,h]=(0,P.useState)(!1),g=ge(),_=(0,P.useMemo)(()=>g.data??[],[g.data]),v=j(e=>e.selectedPath),y=j(e=>e.setSelectedPath),x=H(v),S=L(e=>e.count),C=R(x.data?.staticUrl??null,S);(0,P.useEffect)(()=>{if(v||_.length===0)return;let[e]=Y(_);e&&y(e)},[_,v]);let w=a(),{refetch:E,isFetching:D}=K();return(0,X.jsxs)(`main`,{className:`h-full w-full flex flex-col items-stretch`,"data-testid":`files-tab`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1.5 border-b border-[var(--oh-border)]`,children:[(0,X.jsx)(qe,{ariaLabel:e(i.FILES$DIFF_VIEW),testId:`files-tab-diff-toggle`,value:f?`on`:`off`,options:[{value:`on`,label:e(i.FILES$DIFF_VIEW)},{value:`off`,label:e(i.COMMON$FILES)}],onChange:e=>l(e===`on`)}),!f&&(0,X.jsx)(qe,{ariaLabel:e(i.FILES$RICH),testId:`files-tab-content-mode-toggle`,value:p,options:[{value:`rich`,label:e(i.FILES$RICH)},{value:`plain`,label:e(i.FILES$PLAIN)}],onChange:u}),(0,X.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[!f&&C&&(0,X.jsx)(`a`,{href:C,target:`_blank`,rel:`noopener noreferrer`,"aria-label":e(i.FILES$OPEN_IN_NEW_WINDOW),title:e(i.FILES$OPEN_IN_NEW_WINDOW),"data-testid":`files-tab-open-in-new-window`,className:`flex items-center justify-center w-[26px] py-1 rounded-[7px] hover:bg-[var(--oh-interactive-hover)] cursor-pointer text-white`,children:(0,X.jsx)(O,{width:14,height:14})}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>{E(),w.invalidateQueries({queryKey:[`workspace-files`]}),w.invalidateQueries({queryKey:[`workspace-file-content`]})},disabled:D,"aria-label":e(i.FILES$REFRESH),title:e(i.FILES$REFRESH),"data-testid":`files-tab-refresh`,className:`flex items-center justify-center w-[26px] py-1 rounded-[7px] hover:enabled:bg-[var(--oh-interactive-hover)] cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed`,children:(0,X.jsx)(Je,{width:12.75,height:15,color:`#ffffff`,className:D?`animate-spin`:``})})]})]}),f?(0,X.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,X.jsx)(ut,{})}):(0,X.jsx)(`div`,{className:`flex flex-1 flex-col min-h-0`,children:g.isLoading?(0,X.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-[var(--oh-muted)]`,children:e(i.FILES$LOADING_FILES)}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ne,{paths:_,selectedPath:v,onSelectFile:y,isTreeVisible:m,onToggleTree:()=>h(e=>!e)}),(0,X.jsxs)(`div`,{className:`flex flex-1 min-h-0`,children:[m&&(0,X.jsx)(`aside`,{className:`w-56 shrink-0 border-r border-[var(--oh-border)] overflow-y-auto custom-scrollbar-always`,"data-testid":`files-tab-tree`,children:(0,X.jsx)(Ie,{paths:_,selectedPath:v,onSelectFile:y})}),(0,X.jsx)(`section`,{className:`flex-1 min-w-0 min-h-0`,"data-testid":`files-tab-content`,children:v?(0,X.jsx)(Ke,{path:v,viewMode:p}):(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center text-sm text-[var(--oh-muted)]`,children:e(i.FILES$NO_FILE_SELECTED)})})]})]})})]})}export{dt as default};
|
|
1
|
+
import{a as e}from"./rolldown-runtime-BFRubm34.js";import{t}from"./react-CM_dJw1Z.js";import{t as n}from"./vendor~root~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-s~kyz9p27j-CyUbhpbm.js";import{o as r,t as i}from"./declaration-D378OjpZ.js";import{n as a}from"./QueryClientProvider-B7kl84Kj.js";import{t as o}from"./useTranslation-CpIcQBq6.js";import{t as s}from"./retrieve-axios-error-message-BY-yIkIq.js";import{t as c,v as l}from"./utils-D-HX7JCe.js";import{c as u,i as d,t as f,v as p}from"./agent-server-client-options-DT2GP6VJ.js";import{n as m}from"./active-backend-context-TVbjnvmP.js";import{r as h,u as g}from"./vendor~root-layout~home~conversation-panel~conversation~launch~extensions-hub~skills-settin~dp08i1qy-CHrEOFl6.js";import{a as _}from"./agent-server-conversation-service.api-BZmUqtiO.js";import{t as v}from"./proxy-CurRmrqf.js";import{t as y}from"./react-Do0CT17Y.js";import{s as b}from"./conversation-local-storage-UYl-SX-r.js";import{a as x}from"./vendor~root-layout~home~conversation-panel~conversation~shared-conversation~alert-banner~pl~rqjteh0a-BP1SKG0F.js";import{t as S}from"./folder-0WSMImNX.js";import{t as C}from"./chevron-left-small-CSh-sE9L.js";import{t as w}from"./git-status-mapper-BI8FyUVp.js";import{n as T,t as E}from"./use-conversation-id-DajhCn2A.js";import{t as D}from"./use-active-conversation-DS5j9R4q.js";import{n as O,t as k}from"./link-external-C9d6Fo3x.js";import{t as A}from"./use-agent-state-D2C9SeGw.js";import{t as ee}from"./use-event-store-BT_gV3ut.js";import{t as j}from"./files-tab-store-CDyVTXNT.js";import{r as te}from"./typography-vVUMoNUg.js";import{ot as ne,st as re}from"./vendor~home~conversation-panel~conversation~shared-conversation~planner-tab~files-tab-Ds9quNZ9.js";import{t as M}from"./markdown-renderer-CEX4Becj.js";import{t as N}from"./use-runtime-is-ready-pGSbPddC.js";import{t as ie}from"./conversation-tab-empty-state-D8dNvo-V.js";import{a as ae,c as oe,i as se,n as ce,o as le,r as ue,s as de,t as fe}from"./vendor~files-tab-DtLR-QD9.js";var P=e(t(),1),F=class{static async executeCommand(e,t,n,r,i=30){let a=u().backend;if(a.kind===`cloud`&&e){let o=await v({backend:a,method:`POST`,hostOverride:d(e),path:`/api/bash/execute_bash_command`,body:{command:n,...r?{cwd:r}:{},timeout:Math.floor(i)},authMode:`session-api-key`,sessionApiKey:t,timeoutSeconds:i+10});return{exit_code:o.exit_code??-1,stdout:o.stdout??``,stderr:o.stderr??``}}let o=await new h(f({conversationUrl:e,sessionApiKey:t})).executeCommand(n,r,i);return{exit_code:o.exit_code,stdout:o.stdout,stderr:o.stderr}}static async downloadFile(e,t,n){let r=u().backend;return r.kind===`cloud`&&e?(await v({backend:r,method:`GET`,hostOverride:d(e),path:`/api/file/download?path=${encodeURIComponent(n)}`,authMode:`session-api-key`,sessionApiKey:t,responseType:`blob`})).arrayBuffer():new g(f({conversationUrl:e,sessionApiKey:t})).downloadFile(n)}},I=2e3,pe=[`.git`,`node_modules`,`.venv`,`venv`,`__pycache__`,`dist`,`build`,`.next`,`.cache`,`.pytest_cache`,`.mypy_cache`,`.turbo`,`.parcel-cache`,`target`];function me(){return`find . \\( ${pe.map(e=>`-name '${e}' -prune`).join(` -o `)} \\) -o -type f -print 2>/dev/null | sort | head -n ${I}`}function he(e){return e.startsWith(`./`)?e.slice(2):e}function ge(){let{data:e}=D(),t=N(),r=e?.id,i=e?.conversation_url,a=e?.session_api_key,o=e?.workspace?.working_dir?.trim();return n({queryKey:[`workspace-files`,r,i,a,o],queryFn:async()=>{let e=await F.executeCommand(i,a,me(),o,30);if(e.exit_code!==0)throw Error(e.stderr?.trim()||`Failed to list workspace files`);let t=e.stdout.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).map(he);return Array.from(new Set(t)).slice(0,I)},enabled:t&&!!r&&!!o,retry:!1,staleTime:1e3*30,gcTime:1e3*60*5,meta:{disableToast:!0}})}function _e(){let{data:e}=D(),t=N(),r=e?.id,i=e?.conversation_url,a=e?.session_api_key,o=u().backend.kind===`local`,s=n({queryKey:[`workspace-session`,r,i,a],queryFn:async()=>({baseUrl:await new h(f({conversationUrl:i,sessionApiKey:a})).startWorkspaceSession(r)}),enabled:t&&!!r&&o,staleTime:1/0,gcTime:1/0,retry:!1});return{data:s.data??null,isLoading:s.isLoading,isError:s.isError,error:s.error??null}}function ve(e,t){let n=(t??``).replace(/^\/+/,``);return n?`${e}${n.split(`/`).map(e=>encodeURIComponent(e)).join(`/`)}`:e}var L=y(e=>({count:0,bump:()=>e(e=>({count:e.count+1}))}));function R(e,t){return e===null?null:`${e}${e.includes(`?`)?`&`:`?`}v=${t}`}var ye=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`ico`,`svg`,`avif`]),be=new Set([`pdf`]);function z(e){let t=e.lastIndexOf(`.`);return t===-1?``:e.slice(t+1).toLowerCase()}function xe(e){switch(z(e)){case`html`:case`htm`:return`text/html`;case`css`:return`text/css`;case`js`:case`mjs`:case`cjs`:return`text/javascript`;case`json`:return`application/json`;case`md`:case`markdown`:return`text/markdown`;case`svg`:return`image/svg+xml`;case`png`:return`image/png`;case`jpg`:case`jpeg`:return`image/jpeg`;case`gif`:return`image/gif`;case`webp`:return`image/webp`;case`bmp`:return`image/bmp`;case`ico`:return`image/x-icon`;case`avif`:return`image/avif`;case`pdf`:return`application/pdf`;default:return`text/plain`}}function Se(e){let t=z(e);return ye.has(t)?`image`:be.has(t)?`pdf`:`text`}function B(e){let t=new Uint8Array(e,0,Math.min(e.byteLength,8e3));for(let e=0;e<t.length;e+=1)if(t[e]===0)return!0;return!1}function V(e){let t=new Uint8Array(e),n=32768,r=``;for(let e=0;e<t.length;e+=n)r+=String.fromCharCode.apply(null,t.subarray(e,e+n));return btoa(r)}function H(e){let{data:t}=D(),r=N(),{data:i}=_e(),a=L(e=>e.count),o=t?.id,s=t?.conversation_url,c=t?.session_api_key,l=i?.baseUrl,d=u().backend.kind===`cloud`;return n({queryKey:[`workspace-file-content`,o,s,c,d?`cloud`:l,e,a],queryFn:async()=>{if(!e)throw Error(`No path`);let t=Se(e),n=xe(e);if(d){let r=await F.downloadFile(s,c,e);return t===`text`?B(r)?{path:e,kind:`binary`,text:null,staticUrl:`data:application/octet-stream;base64,${V(r)}`,mimeType:`application/octet-stream`}:{path:e,kind:`text`,text:new TextDecoder(`utf-8`,{fatal:!1}).decode(r),staticUrl:`data:${n};charset=utf-8;base64,${V(r)}`,mimeType:n}:{path:e,kind:t,text:null,staticUrl:`data:${n};base64,${V(r)}`,mimeType:n}}if(!l)throw Error(`No workspace session`);let r=ve(l,e);if(t!==`text`)return{path:e,kind:t,text:null,staticUrl:r,mimeType:n};let i=await fetch(r,{credentials:`include`});if(!i.ok)throw Error(`Failed to read ${e}: ${i.status}`);let a=await i.arrayBuffer();return B(a)?{path:e,kind:`binary`,text:null,staticUrl:r,mimeType:`application/octet-stream`}:{path:e,kind:`text`,text:new TextDecoder(`utf-8`,{fatal:!1}).decode(a),staticUrl:r,mimeType:n}},enabled:r&&!!o&&!!e&&(d||!!l),retry:!1,staleTime:1e3*5,gcTime:1e3*60,meta:{disableToast:!0}})}function Ce(){let{data:e,isLoading:t}=D(),n=e?.id?_(e.id):null;return{hasAttachedSource:!!e?.selected_repository||!!n?.selected_workspace,isLoading:t}}function we(e){let{data:t}=D(),r=N(),{backend:i}=m(),a=i.kind===`local`,o=t?.id,s=t?.conversation_url,c=t?.session_api_key,l=t?.workspace?.working_dir?.trim(),u=(e?.enabled??!0)&&a&&r&&!!o&&!!l,d=n({queryKey:[`has-git-commits`,o,s,c,l],queryFn:async()=>(await F.executeCommand(s,c,`git rev-parse --verify HEAD`,l,10)).exit_code===0,enabled:u,retry:!1,staleTime:6e4,gcTime:5*6e4,meta:{disableToast:!0}});return{hasCommits:d.data??null,isLoading:d.isLoading}}var Te=new Set([`FileEditorObservation`,`StrReplaceEditorObservation`,`PlanningFileEditorObservation`]),Ee=new Set([`view`]);function De(e){let t=e.observation;return!(!t||typeof t.kind!=`string`||!Te.has(t.kind)||t.command&&Ee.has(t.command))}function Oe(){let e=a(),t=ee(e=>e.events),n=L(e=>e.bump),r=(0,P.useRef)(new Set),i=(0,P.useRef)(new WeakSet);(0,P.useEffect)(()=>{let a=[];for(let e of t){let t=`id`in e?e.id:void 0;(t===void 0?i.current.has(e):r.current.has(t))||(t===void 0?i.current.add(e):r.current.add(t),De(e)&&a.push(e))}a.length!==0&&(e.invalidateQueries({queryKey:[`workspace-files`]}),e.invalidateQueries({queryKey:[`workspace-file-content`]}),e.invalidateQueries({queryKey:[`file_changes`]}),n())},[t,e,n])}function U(e){return e.startsWith(`/`)?e:`/${e}`}var W=class{static async getGitChanges(e,t,n){let r=u().backend;if(r.kind===`cloud`&&e){let i=new URLSearchParams;i.set(`path`,U(n));let a=await v({backend:r,method:`GET`,hostOverride:d(e),path:`/api/git/changes?${i.toString()}`,authMode:`session-api-key`,sessionApiKey:t});if(!Array.isArray(a))throw Error(`Invalid response from runtime - runtime may be unavailable`);return a.map(e=>({status:w(String(e.status)),path:e.path}))}let i=await new h(f({conversationUrl:e,sessionApiKey:t})).gitChanges(n,{ref:`HEAD`});if(!Array.isArray(i))throw Error(`Invalid response from runtime - runtime may be unavailable`);return i.map(e=>({status:w(String(e.status)),path:e.path}))}static async getGitChangeDiff(e,t,n){let r=u().backend;if(r.kind===`cloud`&&e){let i=new URLSearchParams;i.set(`path`,U(n));let a=await v({backend:r,method:`GET`,hostOverride:d(e),path:`/api/git/diff?${i.toString()}`,authMode:`session-api-key`,sessionApiKey:t});return{modified:a?.modified??``,original:a?.original??``,...a?.diff?{diff:a.diff}:{}}}let i=await new h(f({conversationUrl:e,sessionApiKey:t})).gitDiff(n,{ref:`HEAD`});return{modified:i.modified??``,original:i.original??``,...i.diff?{diff:i.diff}:{}}}};function G(e,t){let n=t?.trim();if(n)return n;if(!e)return p;let r=e.split(`/`);return`${p}/${r[r.length-1]}`}var K=()=>{let{conversationId:e}=E(),{data:t}=D(),[r,i]=P.useState([]),a=P.useRef(null),o=N(),s=t?.conversation_url,c=t?.session_api_key,l=t?.selected_repository,u=t?.workspace?.working_dir?.trim(),d=P.useMemo(()=>G(l,u),[l,u]),f=n({queryKey:[`file_changes`,e,s,c,d],queryFn:async()=>{if(!e)throw Error(`No conversation ID`);return W.getGitChanges(s,c,d)},retry:!1,staleTime:1e3*60*5,gcTime:1e3*60*15,refetchOnMount:`always`,enabled:o&&!!e,meta:{disableToast:!0}});return P.useEffect(()=>{if(!f.isFetching&&f.isSuccess&&f.data){let e=f.data;if(e!==a.current)if(a.current=e,Array.isArray(e)){let t=new Set(e.map(e=>e.path)),n=new Set(r.map(e=>e.path)),a=e.filter(e=>!n.has(e.path)),o=r.filter(e=>t.has(e.path));i([...a,...o])}else i([e])}},[f.isFetching,f.isSuccess,f.data]),{data:r,isLoading:f.isLoading,isFetching:f.isFetching,isSuccess:f.isSuccess,isError:f.isError,error:f.error,refetch:f.refetch}},ke=[`index.html`,`index.htm`,`readme.md`,`readme`,`main.html`,`app.html`,`index.js`,`index.ts`,`index.tsx`,`index.jsx`,`main.py`,`app.py`,`main.go`,`main.rs`,`main.java`,`main.c`,`main.cpp`,`package.json`,`pyproject.toml`,`cargo.toml`,`go.mod`,`pom.xml`,`dockerfile`,`makefile`],Ae=[`license`,`license.md`,`license.txt`,`changelog.md`,`agents.md`,`tsconfig.json`,`.env.sample`,`.env.example`];function je(e){let t=e.lastIndexOf(`/`);return(t===-1?e:e.slice(t+1)).toLowerCase()}function q(e){return e.split(`/`).filter(Boolean).length-1}function J(e){let t=je(e),n=ke.indexOf(t);if(n!==-1)return n;let r=Ae.indexOf(t);return r===-1?1e4:1e3+r}function Y(e){return[...e].sort((e,t)=>{let n=q(e)-q(t);if(n!==0)return n;let r=J(e)-J(t);return r===0?e.localeCompare(t):r})}var X=r(),Me=e=>(0,X.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,...e,children:(0,X.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M10.8615 8.16992L14.2799 12.158L10.8615 16.1461L9.72266 15.1699L12.3043 12.158L9.72266 9.14611L10.8615 8.16992Z`,fill:`currentColor`})});function Ne({paths:e,selectedPath:t,onSelectFile:n,isTreeVisible:r,onToggleTree:a}){let{t:s}=o(`openhands`),l=(0,P.useMemo)(()=>Y(e),[e]);return(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-[var(--oh-border)] px-2 py-1.5 min-h-[34px]`,"data-testid":`file-quick-row`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:a,"data-testid":`file-quick-row-tree-toggle`,"aria-pressed":r,"aria-label":s(r?i.FILES$HIDE_FILE_TREE:i.FILES$SHOW_FILE_TREE),title:s(r?i.FILES$HIDE_FILE_TREE:i.FILES$SHOW_FILE_TREE),className:c(`shrink-0 inline-flex items-center justify-center w-6 h-6 rounded-md cursor-pointer`,`text-[var(--oh-text-tertiary)] hover:bg-tertiary`,r&&`bg-[var(--oh-surface-raised)]`),children:r?(0,X.jsx)(C,{className:`w-3 h-3`}):(0,X.jsx)(Me,{className:`w-3 h-3`})}),l.length>0&&(0,X.jsx)(`div`,{className:`flex flex-nowrap items-center gap-1.5 overflow-hidden flex-1 min-w-0`,children:l.map(e=>{let r=t===e;return(0,X.jsx)(`button`,{type:`button`,onClick:()=>n(e),title:e,"data-testid":`file-quick-row-item-${e}`,className:c(`inline-flex items-center px-2 py-0.5 text-xs whitespace-nowrap rounded-md cursor-pointer`,r?`bg-[var(--oh-interactive-hover)] text-white`:`bg-[var(--oh-surface-raised)] text-[var(--oh-text-tertiary)] hover:bg-tertiary`),children:e},e)})})]})}function Z(e){e.children.sort((e,t)=>e.isDirectory===t.isDirectory?e.name.localeCompare(t.name):e.isDirectory?-1:1);for(let t of e.children)t.isDirectory&&Z(t)}function Pe(e,t,n,r,i){let a=t.get(e);a||(a=new Map,t.set(e,a));let o=a.get(n);if(o)return!i&&!o.isDirectory&&(o.isDirectory=!0),o;let s={name:n,path:r,isDirectory:!i,children:[]};return e.children.push(s),a.set(n,s),s}function Fe(e){let t={name:``,path:``,isDirectory:!0,children:[]},n=new Map;for(let r of e){let e=r.split(`/`).filter(Boolean);if(e.length>0){let r=t,i=``;for(let t=0;t<e.length;t+=1){let a=e[t];i=i?`${i}/${a}`:a;let o=t===e.length-1;r=Pe(r,n,a,i,o)}}}return Z(t),t}function Q({node:e,depth:t,selectedPath:n,onSelectFile:r}){let[i,a]=(0,P.useState)(!1),o=8+t*12;if(e.isDirectory)return(0,X.jsxs)(`li`,{children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),"aria-expanded":i,"data-testid":`file-tree-dir-${e.path}`,className:c(`flex w-full items-center gap-1.5 py-1 pr-2 text-left text-sm text-white`,`hover:bg-tertiary cursor-pointer`),style:{paddingLeft:`${o}px`},children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:c(`inline-block w-3 text-[10px] text-[var(--oh-muted)] transition-transform`,i?`rotate-90`:`rotate-0`),children:`▶`}),(0,X.jsx)(S,{className:`w-3.5 h-3.5 shrink-0`}),(0,X.jsx)(`span`,{className:`truncate`,children:e.name})]}),i&&e.children.length>0&&(0,X.jsx)(`ul`,{children:e.children.map(e=>(0,X.jsx)(Q,{node:e,depth:t+1,selectedPath:n,onSelectFile:r},e.path))})]});let s=n===e.path;return(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,onClick:()=>r(e.path),"data-testid":`file-tree-file-${e.path}`,className:c(`flex w-full items-center gap-1.5 py-1 pr-2 text-left text-sm`,`hover:bg-tertiary cursor-pointer`,s?`bg-[var(--oh-interactive-hover)] text-white`:`text-[var(--oh-text-tertiary)]`),style:{paddingLeft:`${o+16}px`},children:[(0,X.jsx)(O,{className:`w-3.5 h-3.5 shrink-0`}),(0,X.jsx)(`span`,{className:`truncate`,children:e.name})]})})}function Ie({paths:e,selectedPath:t,onSelectFile:n}){let{t:r}=o(`openhands`),a=(0,P.useMemo)(()=>Fe(e),[e]);return a.children.length===0?(0,X.jsx)(`div`,{className:`px-3 py-4 text-sm text-[var(--oh-muted)]`,children:r(i.FILES$NO_FILES)}):(0,X.jsx)(`ul`,{className:`py-1 custom-scrollbar-always`,"data-testid":`file-tree-view`,children:a.children.map(e=>(0,X.jsx)(Q,{node:e,depth:0,selectedPath:t,onSelectFile:n},e.path))})}var $={js:`javascript`,jsx:`jsx`,mjs:`javascript`,cjs:`javascript`,ts:`typescript`,tsx:`tsx`,py:`python`,pyi:`python`,pyw:`python`,html:`markup`,htm:`markup`,svg:`markup`,xml:`markup`,css:`css`,scss:`scss`,sass:`sass`,less:`less`,json:`json`,json5:`json5`,yaml:`yaml`,yml:`yaml`,toml:`toml`,ini:`ini`,cfg:`ini`,properties:`properties`,conf:`ini`,env:`bash`,md:`markdown`,markdown:`markdown`,mdx:`markdown`,sh:`bash`,bash:`bash`,zsh:`bash`,fish:`bash`,bat:`batch`,cmd:`batch`,ps1:`powershell`,ps:`powershell`,c:`c`,h:`c`,cpp:`cpp`,cc:`cpp`,cxx:`cpp`,hpp:`cpp`,hh:`cpp`,cs:`csharp`,java:`java`,kt:`kotlin`,kts:`kotlin`,scala:`scala`,rs:`rust`,go:`go`,rb:`ruby`,php:`php`,swift:`swift`,m:`objectivec`,mm:`objectivec`,hs:`haskell`,ex:`elixir`,exs:`elixir`,erl:`erlang`,fs:`fsharp`,fsx:`fsharp`,ml:`ocaml`,mli:`ocaml`,clj:`clojure`,cljs:`clojure`,cljc:`clojure`,lua:`lua`,pl:`perl`,pm:`perl`,r:`r`,jl:`julia`,dart:`dart`,groovy:`groovy`,gradle:`groovy`,tf:`hcl`,hcl:`hcl`,dockerfile:`docker`,sql:`sql`,graphql:`graphql`,gql:`graphql`,proto:`protobuf`,diff:`diff`,patch:`diff`,nix:`nix`,sol:`solidity`},Le={dockerfile:`docker`,makefile:`makefile`,gnumakefile:`makefile`,".bashrc":`bash`,".zshrc":`bash`,".profile":`bash`,".env":`bash`,".gitignore":`bash`,".dockerignore":`bash`};function Re(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`)),n=e.slice(t+1),r=n.lastIndexOf(`.`);return r<=0?``:n.slice(r+1).toLowerCase()}function ze(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return e.slice(t+1).toLowerCase()}function Be(e,t){let n=Le[ze(e)];if(n)return n;let r=Re(e);if(r&&$[r])return $[r];if(t){if(t===`text/html`)return`markup`;if(t===`text/css`)return`css`;if(t===`application/json`)return`json`;if(t===`text/markdown`)return`markdown`;if(t===`application/javascript`||t===`text/javascript`)return`javascript`;if(t===`application/x-yaml`||t===`text/yaml`)return`yaml`}return null}function Ve({path:e,text:t,mimeType:n}){let r=Be(e,n);return r?(0,X.jsx)(`div`,{"data-testid":`file-content-viewer-highlighted`,"data-language":r,className:`h-full w-full overflow-auto bg-[var(--oh-surface)] custom-scrollbar-always`,children:(0,X.jsx)(ne,{language:r,style:re,showLineNumbers:!0,wrapLongLines:!1,customStyle:{margin:0,padding:`1rem`,background:`transparent`,fontSize:`0.75rem`,lineHeight:`1.25rem`,minHeight:`100%`},codeTagProps:{style:{background:`transparent`,fontFamily:`inherit`}},lineNumberStyle:{color:`var(--oh-border)`,minWidth:`2.5em`,paddingRight:`1em`,userSelect:`none`},children:t})}):(0,X.jsx)(`pre`,{"data-testid":`file-content-viewer-plain`,className:`h-full w-full overflow-auto whitespace-pre-wrap break-words bg-[var(--oh-surface)] p-4 text-xs leading-5 text-white custom-scrollbar-always`,children:t})}var He=new Set([`html`,`htm`,`svg`]),Ue=new Set([`md`,`markdown`,`mdx`]);function We(e){let t=e.lastIndexOf(`.`);return t===-1?``:e.slice(t+1).toLowerCase()}function Ge({path:e,viewMode:t}){let{t:n}=o(`openhands`),r=H(e),a=L(e=>e.count);if(r.isLoading)return(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center text-sm text-[var(--oh-muted)]`,children:n(i.FILES$LOADING_FILES)});if(r.isError||!r.data)return(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center text-sm text-[var(--oh-muted)]`,"data-testid":`file-content-viewer-error`,children:r.error?.message??n(i.FILES$LOAD_ERROR)});let{kind:s,text:c,staticUrl:l,mimeType:u}=r.data,d=R(l,a);return t===`plain`?s===`text`&&c!==null?(0,X.jsx)(Ve,{path:e,text:c,mimeType:u??void 0}):(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center text-sm text-[var(--oh-muted)]`,"data-testid":`file-content-viewer-binary-fallback`,children:n(i.FILES$BINARY_FALLBACK)}):s===`image`?(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center bg-[var(--oh-surface)] p-4`,"data-testid":`file-content-viewer-image`,children:(0,X.jsx)(`img`,{src:d,alt:e,className:`max-h-full max-w-full object-contain`})}):s===`pdf`?(0,X.jsx)(`iframe`,{title:e,src:d,sandbox:`allow-same-origin`,"data-testid":`file-content-viewer-iframe`,className:`h-full w-full bg-white`}):s===`binary`?(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center text-sm text-[var(--oh-muted)]`,"data-testid":`file-content-viewer-binary-fallback`,children:n(i.FILES$BINARY_FALLBACK)}):u===`text/html`||He.has(We(e))?(0,X.jsx)(`iframe`,{title:e,src:d,sandbox:`allow-same-origin`,"data-testid":`file-content-viewer-iframe`,className:`h-full w-full bg-white`}):s===`text`&&Ue.has(We(e))?(0,X.jsx)(`div`,{"data-testid":`file-content-viewer-markdown`,className:`h-full w-full overflow-auto bg-[var(--oh-surface)] text-white custom-scrollbar-always`,children:(0,X.jsx)(`div`,{className:`prose prose-sm prose-invert max-w-none p-6 [--tw-prose-body:#fff] [--tw-prose-bold:#fff] [--tw-prose-headings:#fff] [--tw-prose-lead:#fff] [--tw-prose-counters:#fff] [--tw-prose-quotes:#fff] [--tw-prose-quote-borders:var(--oh-border-subtle)] [--tw-prose-bullets:var(--oh-muted)] [--tw-prose-hr:var(--oh-border-subtle)] [--tw-prose-captions:var(--oh-muted)] [--tw-prose-kbd:#fff]`,children:(0,X.jsx)(M,{content:c??``,includeStandard:!0,includeHeadings:!0})})}):s===`text`&&c!==null?(0,X.jsx)(Ve,{path:e,text:c,mimeType:u??void 0}):(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center text-sm text-[var(--oh-muted)]`,"data-testid":`file-content-viewer-binary-fallback`,children:n(i.FILES$BINARY_FALLBACK)})}function Ke({value:e,options:t,onChange:n,ariaLabel:r,testId:i}){return(0,X.jsx)(`div`,{role:`radiogroup`,"aria-label":r,"data-testid":i,className:`inline-flex items-center rounded-md bg-[var(--oh-surface-raised)] p-0.5 text-xs`,children:t.map(t=>{let r=t.value===e;return(0,X.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":r,"data-testid":i?`${i}-option-${t.value}`:void 0,onClick:()=>n(t.value),className:c(`px-2 py-0.5 rounded cursor-pointer transition-colors`,r?`bg-[var(--oh-interactive-hover)] text-white`:`text-[var(--oh-muted)] hover:text-white`),children:t.label},t.value)})})}var qe=e=>(0,X.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 13 15`,fill:`none`,...e,children:(0,X.jsx)(`path`,{d:`M6.59467 0.21967C6.88756 -0.0732233 7.36244 -0.0732233 7.65533 0.21967L9.90533 2.46967C10.1982 2.76256 10.1982 3.23744 9.90533 3.53033L7.65533 5.78033C7.36244 6.07322 6.88756 6.07322 6.59467 5.78033C6.30178 5.48744 6.30178 5.01256 6.59467 4.71967L7.56434 3.75H6.375C3.71421 3.75 1.5 5.96421 1.5 8.625C1.5 11.2858 3.71421 13.5 6.375 13.5C9.03579 13.5 11.25 11.2858 11.25 8.625C11.25 8.21079 11.5858 7.875 12 7.875C12.4142 7.875 12.75 8.21079 12.75 8.625C12.75 12.1142 9.86421 15 6.375 15C2.88579 15 0 12.1142 0 8.625C0 5.13579 2.88579 2.25 6.375 2.25H7.56434L6.59467 1.28033C6.30178 0.987437 6.30178 0.512563 6.59467 0.21967Z`,fill:`currentColor`})}),Je=e=>{switch(e.split(`.`).pop()?.toLowerCase()){case`js`:case`jsx`:return`javascript`;case`ts`:case`tsx`:return`typescript`;case`py`:return`python`;case`html`:return`html`;case`css`:return`css`;case`json`:return`json`;case`md`:return`markdown`;case`yml`:case`yaml`:return`yaml`;case`sh`:case`bash`:return`bash`;case`dockerfile`:return`dockerfile`;case`rs`:return`rust`;case`go`:return`go`;case`java`:return`java`;case`cpp`:case`cc`:case`cxx`:return`cpp`;case`c`:return`c`;case`rb`:return`ruby`;case`php`:return`php`;case`sql`:return`sql`;default:return`text`}},Ye=e=>(0,X.jsx)(`svg`,{width:13,height:8,viewBox:`0 0 13 8`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,X.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M0.259766 6.17427L6.26425 0.715628L12.2688 6.17427L11.2597 7.28418L6.26425 2.74282L1.26878 7.28418L0.259766 6.17427Z`,fill:`currentColor`})}),Xe=e=>{let{conversationId:t}=E(),{data:r}=D(),i=r?.conversation_url,a=r?.session_api_key,o=r?.selected_repository,s=r?.workspace?.working_dir?.trim(),c=P.useMemo(()=>`${G(o,s)}/${e.filePath}`,[o,e.filePath,s]),l=e.type===`D`;return n({queryKey:[`file_diff`,t,i,a,c],queryFn:async()=>{if(!t)throw Error(`No conversation ID`);return W.getGitChangeDiff(i,a,c)},enabled:e.enabled&&!l,staleTime:1e3*60*5,gcTime:1e3*60*15})};function Ze({className:e}){return(0,X.jsx)(`div`,{className:`flex items-center justify-center`,children:(0,X.jsx)(`div`,{className:c(`animate-spin rounded-full border-4 border-[var(--oh-border)] border-t-white`,e),role:`status`,"aria-label":`Loading`})})}function Qe({height:e,children:t}){return(0,X.jsx)(`div`,{"data-testid":`editor-container`,className:`w-full border-b border-[var(--oh-border)] overflow-hidden h-[var(--editor-height)]`,style:{"--editor-height":`${e}px`},children:t})}var $e=[{mode:`old`,icon:le},{mode:`diff`,icon:ae},{mode:`new`,icon:fe}],et={renderValidationDecorations:`off`,readOnly:!0,scrollBeyondLastLine:!1,minimap:{enabled:!1},automaticLayout:!0,scrollbar:{alwaysConsumeMouseWheel:!1}},tt={A:se,D:ue,M:ce,R:`Renamed`,U:`Untracked`},nt=e=>{e.editor.defineTheme(`custom-diff-theme`,{base:`vs-dark`,inherit:!0,rules:[{token:`comment`,foreground:`6a9955`},{token:`keyword`,foreground:`569cd6`},{token:`string`,foreground:`ce9178`},{token:`number`,foreground:`b5cea8`}],colors:{"diffEditor.insertedTextBackground":`#014b01AA`,"diffEditor.removedTextBackground":`#750000AA`,"diffEditor.insertedLineBackground":`#003f00AA`,"diffEditor.removedLineBackground":`#5a0000AA`,"diffEditor.border":`var(--oh-border-subtle)`,"editorUnnecessaryCode.border":`#00000000`,"editorUnnecessaryCode.opacity":`rgba(0, 0, 0, 0.467)`}})};function rt({path:e,type:t}){let{t:n}=o(`openhands`),[r,a]=P.useState(!0),[s,l]=P.useState(400),[u,d]=P.useState(`diff`),f=P.useRef(null),p=P.useRef(null),m=t===`A`||t===`U`,h=t===`D`,g=P.useMemo(()=>{if(t===`R`){let t=e.split(/\s+/).slice(1);return t[t.length-1]}return e},[e,t]),{data:_,isLoading:v,isSuccess:y,isRefetching:b}=Xe({filePath:g,type:t,enabled:!r}),x=P.useCallback(()=>{if(!f.current)return;let e=f.current.getOriginalEditor(),t=f.current.getModifiedEditor();e&&t&&l(Math.max(e.getContentHeight(),t.getContentHeight())+20)},[]),S=P.useCallback(()=>{p.current&&l(p.current.getContentHeight()+20)},[]),C=e=>{f.current=e,x(),e.getOriginalEditor().onDidContentSizeChange(x),e.getModifiedEditor().onDidContentSizeChange(x)},w=e=>{p.current=e,S(),e.onDidContentSizeChange(S)},T=(t===`U`?tt.A:tt[t])||`?`,E=typeof T==`string`?(0,X.jsx)(te.Text,{children:T}):P.createElement(T,{className:`w-5 h-5`}),D=v||b,O=Je(g),k=O===`markdown`,A=u===`old`?_?.original??``:_?.modified??``;return(0,X.jsxs)(`div`,{"data-testid":`file-diff-viewer-outer`,className:`w-full flex flex-col`,children:[(0,X.jsx)(`div`,{className:`flex justify-between items-center px-3 py-2.5 border-b border-[var(--oh-border)] hover:cursor-pointer`,onClick:()=>a(e=>!e),children:(0,X.jsxs)(`span`,{className:`text-sm w-full text-content flex items-center gap-2`,children:[D?(0,X.jsx)(Ze,{className:`w-4 h-4`}):E,(0,X.jsx)(`strong`,{className:`w-full truncate font-medium`,children:g}),!r&&!h&&(0,X.jsx)(`span`,{className:`flex items-center gap-0.5 shrink-0`,onClick:e=>e.stopPropagation(),children:$e.map(({mode:e,icon:t})=>(0,X.jsx)(`button`,{"data-testid":`view-mode-${e}`,type:`button`,"aria-pressed":u===e,onClick:()=>d(e),className:c(`p-1 rounded transition-colors cursor-pointer`,u===e?`bg-[var(--oh-interactive-hover)] text-white`:`text-[var(--oh-muted)] hover:bg-[var(--oh-interactive-hover)] hover:text-white`),children:(0,X.jsx)(t,{className:`w-4 h-4`})},e))}),(0,X.jsx)(`button`,{"data-testid":`collapse`,type:`button`,children:(0,X.jsx)(Ye,{className:c(`w-4 h-4 transition-transform`,r&&`transform rotate-180`)})})]})}),!r&&h&&(0,X.jsx)(`div`,{"data-testid":`file-deleted-message`,className:`w-full border-b border-[var(--oh-border)] p-4 bg-base text-[var(--oh-text-dim)] text-sm`,children:n(i.DIFF_VIEWER$FILE_DELETED)}),!r&&!h&&y&&(u===`diff`?(0,X.jsx)(Qe,{height:s,children:(0,X.jsx)(oe,{"data-testid":`file-diff-viewer`,className:`w-full h-full`,language:O,original:m?``:_?.original??``,modified:h?``:_?.modified??``,theme:`custom-diff-theme`,onMount:C,beforeMount:nt,options:{...et,renderSideBySide:!m&&!h,hideUnchangedRegions:{enabled:!0}}})}):k?(0,X.jsx)(`div`,{className:`w-full border-b border-[var(--oh-border)] overflow-auto p-4 bg-base prose prose-invert max-w-none`,"data-testid":`markdown-preview`,children:(0,X.jsx)(M,{content:A,includeStandard:!0,includeHeadings:!0})}):(0,X.jsx)(Qe,{height:s,children:(0,X.jsx)(de,{"data-testid":`file-single-viewer`,className:`w-full h-full`,language:O,value:A,theme:`custom-diff-theme`,beforeMount:nt,onMount:w,options:et})}))]})}function it(){let{t:e}=o(`openhands`);return(0,X.jsx)(ie,{icon:(0,X.jsx)(x,{}),children:e(i.DIFF_VIEWER$NO_CHANGES)})}var at=[{key:i.TIPS$CUSTOMIZE_MICROAGENT,link:`https://docs.all-hands.dev/usage/prompting/microagents-repo`},{key:i.TIPS$SETUP_SCRIPT,link:`https://docs.all-hands.dev/usage/prompting/repository#setup-script`},{key:i.TIPS$VSCODE_INSTANCE},{key:i.TIPS$SAVE_WORK},{key:i.TIPS$SPECIFY_FILES,link:`https://docs.all-hands.dev/usage/prompting/prompting-best-practices`},{key:i.TIPS$HEADLESS_MODE,link:`https://docs.all-hands.dev/usage/how-to/headless-mode`},{key:i.TIPS$CLI_MODE,link:`https://docs.all-hands.dev/usage/how-to/cli-mode`},{key:i.TIPS$GITHUB_HOOK,link:`https://docs.all-hands.dev/usage/cloud/github-installation#working-on-github-issues-and-pull-requests-using-openhands`},{key:i.TIPS$BLOG_SIGNUP,link:`https://www.all-hands.dev/blog`},{key:i.TIPS$API_USAGE,link:`https://docs.all-hands.dev/api-reference/health-check`}];function ot(){return at[Math.floor(Math.random()*at.length)]}function st(){let{t:e}=o(`openhands`),[t,n]=P.useState(ot());return P.useEffect(()=>{n(ot())},[]),(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`h4`,{className:`font-bold`,children:[e(i.TIPS$PROTIP),`:`]}),(0,X.jsxs)(`p`,{children:[e(t.key),t.link&&(0,X.jsxs)(X.Fragment,{children:[` `,(0,X.jsx)(`a`,{href:t.link,target:`_blank`,rel:`noopener noreferrer`,className:`underline`,children:e(i.TIPS$LEARN_MORE)})]})]})]})}var ct=/not a git repository/i;function lt({children:e}){return(0,X.jsx)(`div`,{className:`w-full h-full flex flex-col items-center text-center justify-center text-2xl text-tertiary-light`,children:e})}function ut(){let{t:e}=o(`openhands`),{data:t,isSuccess:n,isError:r,error:a,isLoading:c}=K(),[u,d]=P.useState(null),{curAgentState:f}=A(),p=!l.includes(f),m=a&&ct.test(s(a));return P.useEffect(()=>{if(!p)d([i.DIFF_VIEWER$WAITING_FOR_RUNTIME]);else if(a){let e=s(a);ct.test(e)?d([i.DIFF_VIEWER$NOT_A_GIT_REPO,i.DIFF_VIEWER$ASK_OH]):d([e])}else d(c?[i.DIFF_VIEWER$LOADING]:null)},[p,m,c,a,d]),(0,X.jsx)(`main`,{className:`h-full w-full flex flex-col items-stretch`,children:!n||!t.length?(0,X.jsxs)(`div`,{className:`flex flex-col h-full w-full`,children:[(0,X.jsxs)(`div`,{className:`flex-1 flex items-center justify-center`,children:[u&&(0,X.jsx)(lt,{children:u.map(t=>(0,X.jsx)(`span`,{children:e(t)},t))}),!u&&n&&t.length===0&&(0,X.jsx)(it,{})]}),!r&&n&&t.length===0&&(0,X.jsx)(`div`,{className:`w-full text-m bg-tertiary p-4 text-left`,children:(0,X.jsx)(st,{})})]}):(0,X.jsx)(`div`,{className:`h-full overflow-y-auto flex flex-col items-stretch custom-scrollbar-always`,children:t.slice(0,100).map(e=>(0,X.jsx)(rt,{path:e.path,type:e.status},e.path))})})}function dt(){let{t:e}=o(`openhands`);Oe();let{hasAttachedSource:t,isLoading:n}=Ce(),{hasCommits:r}=we({enabled:t}),{conversationId:s}=T(),{state:c,setFilesTabDiffView:l,setFilesTabContentViewMode:u}=b(s??``),d=(t||n)&&r!==!1,f=c.filesTabDiffView??d,p=c.filesTabContentViewMode,[m,h]=(0,P.useState)(!1),g=ge(),_=(0,P.useMemo)(()=>g.data??[],[g.data]),v=j(e=>e.selectedPath),y=j(e=>e.setSelectedPath),x=H(v),S=L(e=>e.count),C=R(x.data?.staticUrl??null,S);(0,P.useEffect)(()=>{if(v||_.length===0)return;let[e]=Y(_);e&&y(e)},[_,v]);let w=a(),{refetch:E,isFetching:D}=K();return(0,X.jsxs)(`main`,{className:`h-full w-full flex flex-col items-stretch`,"data-testid":`files-tab`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1.5 border-b border-[var(--oh-border)]`,children:[(0,X.jsx)(Ke,{ariaLabel:e(i.FILES$DIFF_VIEW),testId:`files-tab-diff-toggle`,value:f?`on`:`off`,options:[{value:`on`,label:e(i.FILES$DIFF_VIEW)},{value:`off`,label:e(i.COMMON$FILES)}],onChange:e=>l(e===`on`)}),!f&&(0,X.jsx)(Ke,{ariaLabel:e(i.FILES$RICH),testId:`files-tab-content-mode-toggle`,value:p,options:[{value:`rich`,label:e(i.FILES$RICH)},{value:`plain`,label:e(i.FILES$PLAIN)}],onChange:u}),(0,X.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[!f&&C&&(0,X.jsx)(`a`,{href:C,target:`_blank`,rel:`noopener noreferrer`,"aria-label":e(i.FILES$OPEN_IN_NEW_WINDOW),title:e(i.FILES$OPEN_IN_NEW_WINDOW),"data-testid":`files-tab-open-in-new-window`,className:`flex items-center justify-center w-[26px] py-1 rounded-[7px] hover:bg-[var(--oh-interactive-hover)] cursor-pointer text-white`,children:(0,X.jsx)(k,{width:14,height:14})}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>{E(),w.invalidateQueries({queryKey:[`workspace-files`]}),w.invalidateQueries({queryKey:[`workspace-file-content`]})},disabled:D,"aria-label":e(i.FILES$REFRESH),title:e(i.FILES$REFRESH),"data-testid":`files-tab-refresh`,className:`flex items-center justify-center w-[26px] py-1 rounded-[7px] hover:enabled:bg-[var(--oh-interactive-hover)] cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed`,children:(0,X.jsx)(qe,{width:12.75,height:15,color:`#ffffff`,className:D?`animate-spin`:``})})]})]}),f?(0,X.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,X.jsx)(ut,{})}):(0,X.jsx)(`div`,{className:`flex flex-1 flex-col min-h-0`,children:g.isLoading?(0,X.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-[var(--oh-muted)]`,children:e(i.FILES$LOADING_FILES)}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ne,{paths:_,selectedPath:v,onSelectFile:y,isTreeVisible:m,onToggleTree:()=>h(e=>!e)}),(0,X.jsxs)(`div`,{className:`flex flex-1 min-h-0`,children:[m&&(0,X.jsx)(`aside`,{className:`w-56 shrink-0 border-r border-[var(--oh-border)] overflow-y-auto custom-scrollbar-always`,"data-testid":`files-tab-tree`,children:(0,X.jsx)(Ie,{paths:_,selectedPath:v,onSelectFile:y})}),(0,X.jsx)(`section`,{className:`flex-1 min-w-0 min-h-0`,"data-testid":`files-tab-content`,children:v?(0,X.jsx)(Ge,{path:v,viewMode:p}):(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center text-sm text-[var(--oh-muted)]`,children:e(i.FILES$NO_FILE_SELECTED)})})]})]})})]})}export{dt as default};
|