openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 7.17 kB
JavaScript
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{Cs as t,Qo as n,Wo as r,Y as i,Z as a,us as o}from"./_4____________________________.js";import{GN as s,Il as c,JN as l,MN as u,Nl as d,fN as f,iv as p,jN as m,jh as h,jl as g,kh as _,ov as v,pN as y,ty as b}from"./_2_____________________________.js";import{Kn as x,h as S,m as C,qn as w}from"./deferred-ui-support-DZEPWjAk.js";import{B as T,F as E,J as D,O,U as k,d as A,gt as j,j as M,u as N,x as P}from"./_6____________________.js";import{c as F,l as I,s as L}from"./_5_________________________.js";import{a as R,i as z,n as B,o as V,r as H,s as U,t as W}from"./session-menu-view-BuY68cTZ.js";function G(e,t,n){let i=`session-menu-${++J}`,a=b(),[o,s]=T(`root`),c,u=D(e,{get worktreePath(){return e.work?.worktreePath??null}}),d=()=>u,m=!1,h=()=>{m||(m=!0,e.onClose())},g=()=>{c?.close()&&h()},_=new V(()=>{t.updateComplete.then(()=>{o()===`icon`?v.appearance.focusFirst():c?.focusFirst()})},d,t=>e.onAction(t),g),v=H(_,d,{controls:a}),y=e=>{_.handleKeydown(e,v.appearance)||F(c?.overlay.surface,e)},x,S;j(()=>()=>{x?.(),S?.()});let C=()=>e.selectionCount>1,w=()=>C()?l(`chat.sidebar.sessionMenuMany`,{count:String(e.selectionCount)}):l(`chat.sidebar.sessionMenu`,{session:e.session.label}),O=(t,n=!1)=>e.disabled||n||!!e.actionDisabledReasons[t],k=t=>{e.actionDisabledReasons[t.kind]||(g(),e.onAction(t))},N=e=>({kind:`content`,id:e,content:K()}),P=N(`primary-divider`),I=N(`pr-divider`),R=N(`advanced-divider`),B=E(()=>e.compact&&o()!==`root`?v.compact(o()):[...v.primary(),...!C()&&e.nestedSession?[{id:`new-nested-session`,label:l(e.nestedSession.creating?`sessionsView.creatingNestedSession`:`sessionsView.newNestedSession`),class:`session-menu__item`,labelClass:`session-menu__text`,disabled:e.disabled||e.nestedSession.creating||!!e.nestedSession.disabledReason,attributes:{title:e.nestedSession.disabledReason},icon:(()=>{var e=q();return A(e,M(f,{name:`plus`})),e})(),closeOnSelect:!1}]:[],P,...v.organization(),...C()?[]:e.pluginActions.map(t=>({id:`plugin:${t.id}`,label:t.label,class:`session-menu__item`,labelClass:`session-menu__text`,disabled:O(`plugin`,t.disabled),attributes:{title:e.actionDisabledReasons.plugin},icon:(()=>{var e=q();return A(e,M(f,{name:`plug`})),e})(),closeOnSelect:!1})),...!C()&&e.work?.pullRequestUrl?[I,{id:`open-pr`,label:l(`sessionsView.openPullRequest`),class:`session-menu__item`,labelClass:`session-menu__text`,disabled:e.disabled,attributes:{"data-new-tab-action":``,"data-shortcut":`g`,"aria-keyshortcuts":`G`},icon:(()=>{var e=q();return A(e,M(f,{name:`gitPullRequest`})),e})(),details:M(W,{shortcut:`g`}),closeOnSelect:!1}]:[],R,...!C()&&e.cloudWorkerStopAllowed?[{id:`stop-cloud-worker`,label:e.cloudWorkerStopLabel||l(`sessionsView.stopCloudWorker`),class:`session-menu__item session-menu__item--destructive`,labelClass:`session-menu__text`,variant:`danger`,disabled:O(`stop-cloud-worker`),attributes:{title:e.actionDisabledReasons[`stop-cloud-worker`]},icon:(()=>{var e=q();return A(e,M(f,{name:`stop`})),e})(),closeOnSelect:!1}]:[],...C()?[v.deleteAction()]:v.advanced()]),U=(t,n)=>{n.preventDefault();let r=t.id,i=z(r);if(i)v.prepareView(i),s(i),j(()=>_.focusCurrentView());else if(!_.handleSelect(r)){if(r.startsWith(`plugin:`)){let t=e.pluginActions.find(e=>e.id===r.slice(7));t&&e.selectionCount===1&&!O(`plugin`,t.disabled)&&k({kind:`plugin`,id:t.id})}else if(r===`new-nested-session`){let t=e.nestedSession;t&&!e.disabled&&!t.creating&&!t.disabledReason&&t.onCreate()}else r===`stop-cloud-worker`?k({kind:r}):r===`open-pr`&&e.work?.pullRequestUrl&&k({kind:`open-pr`,url:e.work.pullRequestUrl})}},G=()=>{e.anchor===n&&c?.overlay.surface.isConnected&&h()},Y=e=>{e.target===c?.overlay.surface&&G()};return M(p,{controls:a,id:i,get class(){return[`session-menu`,{"session-menu--compact":e.compact}]},panelClass:`session-menu__panel`,placement:`bottom-start`,get label(){return w()},get items(){return B()},onSelect:U,get triggerAttributes(){return L({x:Math.max(8,Math.min(n.x,window.innerWidth-248)),y:Math.max(8,Math.min(n.y,window.innerHeight-468))})},ref:t=>{c=t,e.trigger&&t.overlay.setReturnTarget(e.trigger),x?.(),S?.(),x=r(t.overlay.surface,`keydown`,y,!0),S=r(t.overlay.surface,`overlay-after-hide`,Y),t.open()||G()},get onBeforeShow(){return _.loadOwners},onEscape:e=>_.handleKeydown(e,v.appearance)?!0:[...c?.overlay.children??[]].some(e=>e.open)||e.target instanceof HTMLInputElement&&e.target.hasAttribute(`data-search`)&&e.target.value?!1:(g(),!0),onOpenChange:e=>{e?m=!1:_.advanced.close()}})}var K,q,J,Y;function X(){return(X=e((()=>{N(),k(),s(),u(),I(),U(),R(),w(),B(),y(),v(),K=P(`<div class=session-menu__separator role=separator>`),q=P(`<span class=session-menu__icon aria-hidden=true>`),J=0,Y=m(`openclaw-session-menu`,(e,t)=>M(O,{get when(){return e.anchor},keyed:!0,children:n=>G(e,t,n)}),{properties:{session:{default:x,attribute:!1},compact:{default:!1,attribute:!1},involvingMeContext:{default:!1,attribute:!1},navigationAllowed:{default:!1,attribute:!1},copyMarkdownAllowed:{default:!1,attribute:!1},splitAllowed:{default:!1,attribute:!1},selectionCount:{default:1,attribute:!1},anchor:{default:{x:0,y:0},attribute:!1},trigger:{default:null,attribute:!1},disabled:{default:!1,attribute:!1},actionDisabledReasons:{default:{},attribute:!1},nestedSession:{default:null,attribute:!1},forkDisabled:{default:!1,attribute:!1},forkFromLastCompleted:{default:!1,attribute:!1},archiveAllowed:{default:!1,attribute:!1},snoozeAllowed:{default:!1,attribute:!1},deleteAllowed:{default:!1,attribute:!1},cloudWorkerStopAllowed:{default:!1,attribute:!1},cloudWorkerStopLabel:{default:``,attribute:!1},groups:{default:[],attribute:!1},currentOwner:{default:null,attribute:!1},work:{default:null,attribute:!1},pluginActions:{default:[],attribute:!1},onAction:{default:()=>{},attribute:!1},onClose:{default:()=>{},attribute:!1}}})})))()}async function Z(e){try{let t=await e.loadPullRequests?.();return h(t?.pullRequests??[])?.url??null}catch{return null}}async function ee(e){let t=e.worktreeId;if(!t||e.execNode||!S())return null;try{return(await e.client.request(`worktrees.list`,{})).worktrees.find(e=>e.id===t&&e.removedAt===void 0)?.path??null}catch{return null}}async function Q(e){let[t,n]=await Promise.all([Z(e),ee(e)]);return{pullRequestUrl:t,worktreePath:n}}function te(e,n){let r={},a=null,s,c=0;function l(){c+=1,s?.(),s=void 0,a?.unwatch(r),a=null}function u(f){let p=++c,m=e.sessionDataContext,h=m?.gateway.snapshot,g=h?.phase===`connected`?h.client:null;if(n(f.worktreeId?{pullRequestUrl:null,worktreePath:null}:null),!f.worktreeId||!m||(s=m.gateway.subscribe(e=>{e.phase===`connected`&&e.client!==g&&(l(),u(f))}),!g))return;let{selectedAgentId:_}=e.getSessionNavigationState(),v=a=d(m.gateway),y=t(f.key,o(f.key)?.agentId??_);Q({client:g,loadPullRequests:i(m.gateway.snapshot,`controlUi.sessionPullRequests.subscribe`,`operator.read`)?()=>v.load(r,y):void 0,worktreeId:f.worktreeId,execNode:f.execNode}).then(t=>{p===c&&e.sessionDataContext?.gateway===m.gateway&&m.gateway.snapshot.client===g&&n(t)})}return{load:u,release:l}}function $(){return($=e((()=>{c(),C(),a(),_(),g(),n()})))()}export{X as a,Y as i,Q as n,$ as r,te as t};