pikiloom 0.4.74 → 0.4.75

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.
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SessionPanel--D5NGYgd.js","assets/react-vendor-C7Sl8SE7.js","assets/index-BDSh0L9U.js","assets/router-DHISdpPk.js","assets/index-BO-FYAny.css","assets/Modal-Qwlap_Fl.js","assets/Select-dIxoi_TN.js","assets/DirBrowser-zKX7wmty.js","assets/markdown-DxQYQFeH.js","assets/ExtensionsTab-DKLjCr4u.js"])))=>i.map(i=>d[i]);
2
- import{c as C,a as ie,u as le,i as ct,f as _t,A as js,s as zt,S as ge,B as dt,g as dn,w as ws,b as ks,C as fn,d as ys,r as In,e as Ln,h as Ns,n as Ss,j as Cs,k as _n,l as Dt,m as We,D as Gt,o as Is,p as Wn,_ as Bn,T as Ls,q as Ts}from"./index-BDSh0L9U.js";import{j as e,r as i,a as gn}from"./react-vendor-C7Sl8SE7.js";import{I as Es}from"./Select-dIxoi_TN.js";import{M as Kt,a as Ht}from"./Modal-Qwlap_Fl.js";import{D as Ms}from"./DirBrowser-zKX7wmty.js";import{n as As,r as Ps,M as mn}from"./markdown-DxQYQFeH.js";import{WorkspaceExtensionsBody as Rs}from"./ExtensionsTab-DKLjCr4u.js";function _s({open:t,className:n}){return e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:C("shrink-0 text-fg-5/40 transition-transform duration-200",t&&"rotate-180",n),children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})}function ut({open:t,onToggle:n,dot:s,label:a,preview:r,badge:c,collapsedContent:p,children:d,className:m}){return e.jsxs("div",{className:C("rounded-md border border-edge bg-panel overflow-hidden","shadow-[0_2px_8px_rgba(0,0,0,0.06)]",m),children:[e.jsxs("button",{onClick:n,className:"w-full flex items-center gap-2.5 px-3.5 py-2.5 text-left hover:bg-panel-h/40 transition-colors",children:[s&&e.jsx("span",{className:C("h-[7px] w-[7px] shrink-0 rounded-full",s.color,s.pulse&&"animate-pulse")}),e.jsx("span",{className:"text-[10.5px] font-semibold uppercase tracking-[0.14em] text-fg-5",children:a}),e.jsx("span",{className:"flex-1 min-w-0 overflow-hidden",children:r}),c,e.jsx(_s,{open:t})]}),!t&&p,t&&d&&e.jsx("div",{className:"border-t border-edge",children:d})]})}const Ws=5e3,Bs=15e3,Ft=8,Ut=30,$s=1,lt=new Map,Ie=new Map,on=new Set,$n=[];let Wt=0;function an(t){return typeof t=="number"&&Number.isFinite(t)}function qe(t,n,s,a){for(t.delete(n),t.set(n,s);t.size>a;){const r=t.keys().next().value;if(!r)break;t.delete(r)}}function On(t,n){const s=t.get(n);return!s?.value||s.expiresAt<=Date.now()?null:(qe(t,n,s,t===Ie?Ut:Ft),s.value)}function Dn(t){return{workdir:t.workdir,agent:t.agent,sessionId:t.sessionId,rich:t.rich??!0,lastNTurns:an(t.lastNTurns)?t.lastNTurns:void 0,turnOffset:an(t.turnOffset)?t.turnOffset:void 0,turnLimit:an(t.turnLimit)?t.turnLimit:void 0}}function bn(t){const n=Dn(t);return[n.workdir,n.agent,n.sessionId,n.rich?"rich":"plain",n.lastNTurns??"",n.turnOffset??"",n.turnLimit??""].join("::")}function Fn(){for(;Wt<$s;){const t=$n.shift();if(!t)return;Wt+=1,t().finally(()=>{Wt=Math.max(0,Wt-1),Fn()})}}async function Os(t,n={}){const s=t;if(!n.force){const c=On(lt,s);if(c)return c}const a=lt.get(s);if(a?.promise)return a.promise;const r=ie.getWorkspaceSessions(t,n.request).then(c=>(qe(lt,s,{value:c,expiresAt:c.ok?Date.now()+Ws:0},Ft),c)).finally(()=>{const c=lt.get(s);c?.promise&&qe(lt,s,{value:c.value,expiresAt:c.expiresAt},Ft)});return qe(lt,s,{value:a?.value,expiresAt:a?.expiresAt??0,promise:r},Ft),r}function Ds(t,n={}){const s=bn(t),a=Ie.get(s);return a?.value?.ok&&(n.allowStale||a.expiresAt>Date.now())?a.value:null}async function Fs(t,n={}){const s=Dn(t),a=bn(s);if(!n.force){const p=On(Ie,a);if(p?.ok)return p}const r=Ie.get(a);if(r?.promise)return r.promise;const c=ie.getSessionMessages(s.workdir,s.agent,s.sessionId,{rich:s.rich,lastNTurns:s.lastNTurns,turnOffset:s.turnOffset,turnLimit:s.turnLimit},n.request).then(p=>(qe(Ie,a,{value:p,expiresAt:p.ok?Date.now()+Bs:0},Ut),p)).finally(()=>{const p=Ie.get(a);p?.promise&&qe(Ie,a,{value:p.value,expiresAt:p.expiresAt},Ut)});return qe(Ie,a,{value:r?.value,expiresAt:r?.expiresAt??0,promise:c},Ut),c}function Us(t){const n=bn(t);Ds(t)||on.has(n)||Ie.get(n)?.promise||(on.add(n),$n.push(async()=>{try{await Fs(t)}catch{}finally{on.delete(n)}}),Fn())}function Co(t){const n=t.streaming||t.liveStreamPhase==="streaming",s=t.queuedTaskCount>0||t.pendingQueuedCount>0||t.streamPhase==="queued";return n||s}function Io(t){const{pendingTaskId:n,streamTaskId:s,queuedTaskIds:a}=t;return!n||n===s?!1:!!a&&a.includes(n)}function zs(t){const{queuedTaskIds:n,streamPhase:s,streamTaskId:a,localTaskId:r}=t,c=[];n&&n.length&&c.push(...n),s==="queued"&&a&&!c.includes(a)&&c.unshift(a),r&&!c.includes(r)&&(s==="queued"||!s)&&c.push(r);const p=s==="streaming"?a??null:null;return p?c.filter(d=>d!==p):c}function Lo(t,n){return t==null||n==null?!0:t===n}function To(t){return t.liveTurnStreaming||t.pendingBubbleDots||t.streamPhase==="done"&&!t.streaming&&t.queuedTaskCount===0&&t.pendingQueuedCount===0?!1:t.sessionRunning||t.streaming||t.streamPhase==="streaming"||t.streamPhase==="queued"||t.queuedTaskCount>0||t.pendingQueuedCount>0}function ht(t){return(t||"").replace(/\s+/g," ").trim()}function Ks(t,n){return ht(t)===ht(n)}function Hs(t,n){const s=ht(t),a=ht(n);return!!s&&!!a&&s!==a&&s.endsWith(a)}function Vs(t,n){return n&&(!t||Hs(n,t))?n:t||n||null}function Eo(t,n){return!Vs(t,n)}function Gs(t){for(let n=t.length-1;n>=0;n--){const s=t[n].plan;if(s?.steps?.length)return s}return null}function Mo(t,n){if(Ks(t,n))return!0;const s=ht(t),a=ht(n);if(!s||!a||s.length>=a.length||!/(?:\.\.\.|…)$/.test(s))return!1;const r=s.replace(/(?:\s*(?:\.\.\.|…))+$/,"").trim(),c=r.length-4;return c<32?!1:a.startsWith(r.slice(0,c))}function Ao(t){const n=t.richMessages?.length?t.richMessages:t.messages?.map(p=>({role:p.role,text:p.text,blocks:[{type:"text",content:p.text}]}))||[],s=Qs(n),a=Math.max(t.window?.totalTurns??t.totalTurns??s.length,s.length),r=t.window?.endTurn??a,c=t.window?.startTurn??Math.max(0,r-s.length);return{turns:s,startTurn:c,endTurn:r,totalTurns:a,hasOlder:t.window?.hasOlder??c>0}}function Po(t,n){const s=Math.max(0,t.startTurn-n.startTurn);return{turns:[...n.turns.slice(0,s),...t.turns],startTurn:n.startTurn,endTurn:t.endTurn,totalTurns:Math.max(t.totalTurns,n.totalTurns),hasOlder:n.hasOlder}}function Ro(t,n){if(n.startTurn<=t.startTurn)return n;const s=Math.max(0,n.startTurn-t.startTurn);return{turns:[...t.turns.slice(0,s),...n.turns],startTurn:t.startTurn,endTurn:n.endTurn,totalTurns:n.totalTurns,hasOlder:t.startTurn>0}}function qs(t,n){const s=[t.text,n.text].filter(Boolean);return{role:t.role,text:s.join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SessionPanel-CEoPMHDr.js","assets/react-vendor-C7Sl8SE7.js","assets/index-D_s24-jk.js","assets/router-DHISdpPk.js","assets/index-BO-FYAny.css","assets/Modal-Bsippcly.js","assets/Select-CaMLVBWh.js","assets/DirBrowser-D8CSsHGw.js","assets/markdown-DxQYQFeH.js","assets/ExtensionsTab-DoENefbA.js"])))=>i.map(i=>d[i]);
2
+ import{c as C,a as ie,u as le,i as ct,f as _t,A as js,s as zt,S as ge,B as dt,g as dn,w as ws,b as ks,C as fn,d as ys,r as In,e as Ln,h as Ns,n as Ss,j as Cs,k as _n,l as Dt,m as We,D as Gt,o as Is,p as Wn,_ as Bn,T as Ls,q as Ts}from"./index-D_s24-jk.js";import{j as e,r as i,a as gn}from"./react-vendor-C7Sl8SE7.js";import{I as Es}from"./Select-CaMLVBWh.js";import{M as Kt,a as Ht}from"./Modal-Bsippcly.js";import{D as Ms}from"./DirBrowser-D8CSsHGw.js";import{n as As,r as Ps,M as mn}from"./markdown-DxQYQFeH.js";import{WorkspaceExtensionsBody as Rs}from"./ExtensionsTab-DoENefbA.js";function _s({open:t,className:n}){return e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:C("shrink-0 text-fg-5/40 transition-transform duration-200",t&&"rotate-180",n),children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})}function ut({open:t,onToggle:n,dot:s,label:a,preview:r,badge:c,collapsedContent:p,children:d,className:m}){return e.jsxs("div",{className:C("rounded-md border border-edge bg-panel overflow-hidden","shadow-[0_2px_8px_rgba(0,0,0,0.06)]",m),children:[e.jsxs("button",{onClick:n,className:"w-full flex items-center gap-2.5 px-3.5 py-2.5 text-left hover:bg-panel-h/40 transition-colors",children:[s&&e.jsx("span",{className:C("h-[7px] w-[7px] shrink-0 rounded-full",s.color,s.pulse&&"animate-pulse")}),e.jsx("span",{className:"text-[10.5px] font-semibold uppercase tracking-[0.14em] text-fg-5",children:a}),e.jsx("span",{className:"flex-1 min-w-0 overflow-hidden",children:r}),c,e.jsx(_s,{open:t})]}),!t&&p,t&&d&&e.jsx("div",{className:"border-t border-edge",children:d})]})}const Ws=5e3,Bs=15e3,Ft=8,Ut=30,$s=1,lt=new Map,Ie=new Map,on=new Set,$n=[];let Wt=0;function an(t){return typeof t=="number"&&Number.isFinite(t)}function qe(t,n,s,a){for(t.delete(n),t.set(n,s);t.size>a;){const r=t.keys().next().value;if(!r)break;t.delete(r)}}function On(t,n){const s=t.get(n);return!s?.value||s.expiresAt<=Date.now()?null:(qe(t,n,s,t===Ie?Ut:Ft),s.value)}function Dn(t){return{workdir:t.workdir,agent:t.agent,sessionId:t.sessionId,rich:t.rich??!0,lastNTurns:an(t.lastNTurns)?t.lastNTurns:void 0,turnOffset:an(t.turnOffset)?t.turnOffset:void 0,turnLimit:an(t.turnLimit)?t.turnLimit:void 0}}function bn(t){const n=Dn(t);return[n.workdir,n.agent,n.sessionId,n.rich?"rich":"plain",n.lastNTurns??"",n.turnOffset??"",n.turnLimit??""].join("::")}function Fn(){for(;Wt<$s;){const t=$n.shift();if(!t)return;Wt+=1,t().finally(()=>{Wt=Math.max(0,Wt-1),Fn()})}}async function Os(t,n={}){const s=t;if(!n.force){const c=On(lt,s);if(c)return c}const a=lt.get(s);if(a?.promise)return a.promise;const r=ie.getWorkspaceSessions(t,n.request).then(c=>(qe(lt,s,{value:c,expiresAt:c.ok?Date.now()+Ws:0},Ft),c)).finally(()=>{const c=lt.get(s);c?.promise&&qe(lt,s,{value:c.value,expiresAt:c.expiresAt},Ft)});return qe(lt,s,{value:a?.value,expiresAt:a?.expiresAt??0,promise:r},Ft),r}function Ds(t,n={}){const s=bn(t),a=Ie.get(s);return a?.value?.ok&&(n.allowStale||a.expiresAt>Date.now())?a.value:null}async function Fs(t,n={}){const s=Dn(t),a=bn(s),r=Ie.get(a);if(!n.force){const p=On(Ie,a);if(p?.ok)return p;if(r?.promise)return r.promise}const c=ie.getSessionMessages(s.workdir,s.agent,s.sessionId,{rich:s.rich,lastNTurns:s.lastNTurns,turnOffset:s.turnOffset,turnLimit:s.turnLimit},n.request).then(p=>(qe(Ie,a,{value:p,expiresAt:p.ok?Date.now()+Bs:0},Ut),p)).finally(()=>{const p=Ie.get(a);p?.promise&&qe(Ie,a,{value:p.value,expiresAt:p.expiresAt},Ut)});return qe(Ie,a,{value:r?.value,expiresAt:r?.expiresAt??0,promise:c},Ut),c}function Us(t){const n=bn(t);Ds(t)||on.has(n)||Ie.get(n)?.promise||(on.add(n),$n.push(async()=>{try{await Fs(t)}catch{}finally{on.delete(n)}}),Fn())}function Co(t){const n=t.streaming||t.liveStreamPhase==="streaming",s=t.queuedTaskCount>0||t.pendingQueuedCount>0||t.streamPhase==="queued";return n||s}function Io(t){const{pendingTaskId:n,streamTaskId:s,queuedTaskIds:a}=t;return!n||n===s?!1:!!a&&a.includes(n)}function zs(t){const{queuedTaskIds:n,streamPhase:s,streamTaskId:a,localTaskId:r}=t,c=[];n&&n.length&&c.push(...n),s==="queued"&&a&&!c.includes(a)&&c.unshift(a),r&&!c.includes(r)&&(s==="queued"||!s)&&c.push(r);const p=s==="streaming"?a??null:null;return p?c.filter(d=>d!==p):c}function Lo(t,n){return t==null||n==null?!0:t===n}function To(t){return t.liveTurnStreaming||t.pendingBubbleDots||t.streamPhase==="done"&&!t.streaming&&t.queuedTaskCount===0&&t.pendingQueuedCount===0?!1:t.sessionRunning||t.streaming||t.streamPhase==="streaming"||t.streamPhase==="queued"||t.queuedTaskCount>0||t.pendingQueuedCount>0}function ht(t){return(t||"").replace(/\s+/g," ").trim()}function Ks(t,n){return ht(t)===ht(n)}function Hs(t,n){const s=ht(t),a=ht(n);return!!s&&!!a&&s!==a&&s.endsWith(a)}function Vs(t,n){return n&&(!t||Hs(n,t))?n:t||n||null}function Eo(t,n){return!Vs(t,n)}function Gs(t){for(let n=t.length-1;n>=0;n--){const s=t[n].plan;if(s?.steps?.length)return s}return null}function Mo(t,n){if(Ks(t,n))return!0;const s=ht(t),a=ht(n);if(!s||!a||s.length>=a.length||!/(?:\.\.\.|…)$/.test(s))return!1;const r=s.replace(/(?:\s*(?:\.\.\.|…))+$/,"").trim(),c=r.length-4;return c<32?!1:a.startsWith(r.slice(0,c))}function Ao(t){const n=t.richMessages?.length?t.richMessages:t.messages?.map(p=>({role:p.role,text:p.text,blocks:[{type:"text",content:p.text}]}))||[],s=Qs(n),a=Math.max(t.window?.totalTurns??t.totalTurns??s.length,s.length),r=t.window?.endTurn??a,c=t.window?.startTurn??Math.max(0,r-s.length);return{turns:s,startTurn:c,endTurn:r,totalTurns:a,hasOlder:t.window?.hasOlder??c>0}}function Po(t,n){const s=Math.max(0,t.startTurn-n.startTurn);return{turns:[...n.turns.slice(0,s),...t.turns],startTurn:n.startTurn,endTurn:t.endTurn,totalTurns:Math.max(t.totalTurns,n.totalTurns),hasOlder:n.hasOlder}}function Ro(t,n){if(n.startTurn<=t.startTurn)return n;const s=Math.max(0,n.startTurn-t.startTurn);return{turns:[...t.turns.slice(0,s),...n.turns],startTurn:t.startTurn,endTurn:n.endTurn,totalTurns:n.totalTurns,hasOlder:t.startTurn>0}}function qs(t,n){const s=[t.text,n.text].filter(Boolean);return{role:t.role,text:s.join(`
3
3
 
4
4
  `),blocks:[...t.blocks,...n.blocks],usage:n.usage??t.usage??null}}function Qs(t){const n=[];let s={user:null,assistant:null};for(const a of t)if(a.role==="user"){if(s.assistant&&Un(a.text))continue;(s.user||s.assistant)&&(n.push(s),s={user:null,assistant:null}),s.user=a}else s.assistant?s.assistant=qs(s.assistant,a):s.assistant=a;return(s.user||s.assistant)&&n.push(s),n}const Ys=new Set(["task-notification","system-reminder","persisted-output","local-command-stdout","local-command-caveat","local-command-stderr","ide_opened_file","ide_diagnostics","ide_selection","event","analysis","case_id","tool-use-id","output-file"]),Xs=["continued from a previous","summary below covers","earlier portion of the conversation","Summary:","Key Technical Concepts"];function Un(t){const s=t.trim().match(/^<([a-z][a-z0-9_-]*)\b/i);return s&&Ys.has(s[1].toLowerCase())?!0:Xs.some(a=>t.includes(a))}function vn(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:`${t}`}function zn(t){return`${vn(t)} tok`}function Kn(t){return t>=85?"bg-rose-400/70":t>=60?"bg-amber-400/70":"bg-emerald-400/70"}function Zs(t){const n=Math.floor(t/1e3);if(n<60)return`${n}s`;const s=Math.floor(n/60),a=n%60;return s<60?`${s}m${a.toString().padStart(2,"0")}s`:`${Math.floor(s/60)}h${(s%60).toString().padStart(2,"0")}m`}function Hn(t,n){const s=t.split(`
5
5
  `).filter(a=>a.trim());return s.length<=n?s.join(`
@@ -19,5 +19,5 @@ import{c as C,a as ie,u as le,i as ct,f as _t,A as js,s as zt,S as ge,B as dt,g
19
19
  `),[d,m]=i.useState(null),v=i.useMemo(()=>qt({workdir:s}),[s]);return!p.trim()&&r.length===0&&c.length===0?null:e.jsxs(e.Fragment,{children:[p.trim()&&e.jsx("div",{className:"session-md text-[13.5px] leading-[1.75] text-fg-2",children:e.jsx(mn,{remarkPlugins:jn,components:v,children:p})}),r.length>0&&e.jsx("div",{className:"flex flex-wrap gap-3 mt-2",children:r.map((g,j)=>e.jsx(Fr,{block:g,onLightbox:m,t:n},j))}),c.length>0&&e.jsx("div",{className:"flex flex-col gap-2 mt-2",children:c.map((g,j)=>e.jsx(Jn,{url:g.content,fileName:g.fileName||"file",fileSize:g.fileSize,caption:g.fileCaption},j))}),d&&e.jsx(rs,{src:d,onClose:()=>m(null)})]})}const Bo=i.memo(function({turn:n,turnIndex:s,agent:a,meta:r,model:c,effort:p,providerName:d,t:m,workdir:v,onResend:g,onEdit:j,onFork:y,hideHeaderUsage:N,isTail:$}){const O=n.user&&Un(n.user.text),A=y&&typeof s=="number"?()=>y(s):void 0,P=i.useMemo(()=>qt({workdir:v}),[v]),z=!!n.assistant&&_r(n.assistant);return e.jsxs("div",{className:C("session-turn",$&&"session-turn--live"),children:[n.user&&!O&&e.jsx(os,{text:n.user.text,blocks:n.user.blocks,t:m,onResend:g,onEdit:j,onFork:A}),O&&n.user&&!n.assistant&&e.jsx("div",{className:"mb-4 px-4 py-3 rounded-lg bg-[rgba(255,255,255,0.02)] border border-edge/20 text-[12.5px] leading-[1.7] text-fg-4",children:e.jsx(mn,{remarkPlugins:jn,components:P,children:n.user.text})}),z&&e.jsxs(e.Fragment,{children:[e.jsx(Vr,{agent:a,meta:r,model:c,effort:p,providerName:d,previewMeta:n.assistant.usage??null,hideContextUsage:N}),e.jsx("div",{className:"mb-6",children:e.jsx(Rr,{message:n.assistant,t:m,workdir:v})})]})]})});function rs({src:t,onClose:n}){return i.useEffect(()=>{const s=a=>{a.key==="Escape"&&n()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[n]),gn.createPortal(e.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/80 backdrop-blur-sm cursor-zoom-out",onClick:n,children:e.jsx("img",{src:t,className:"max-w-[90vw] max-h-[90vh] object-contain rounded-lg shadow-2xl",onClick:s=>s.stopPropagation()})}),document.body)}const zr=1500,Kr=16,Mn=8;function Hr(t){const n=t.split(`
20
20
  `);return n.length<=Mn?t:n.slice(0,Mn).join(`
21
21
  `)}function os({text:t,blocks:n,t:s,onResend:a,onEdit:r,onFork:c}){const[p,d]=i.useState(!1),[m,v]=i.useState(!1),[g,j]=i.useState(null),y=t?t.split(`
22
- `).length:0,N=!!t&&(t.length>zr||y>Kr),[$,O]=i.useState(!1),A=t?N&&!$?Hr(t):t:"",P=!!(a||r||c),z=n?.filter(M=>M.type==="image")||[],H=()=>{navigator.clipboard.writeText(t).then(()=>{v(!0),setTimeout(()=>v(!1),1500)}).catch(()=>{})},Y=s("hub.expand").replace("{chars}",t?t.length.toLocaleString():"0").replace("{lines}",String(y));return e.jsxs("div",{className:"flex flex-col items-end mb-5 group/bubble",onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[e.jsxs("div",{className:"max-w-[72%] rounded-md border border-fg-6 bg-panel px-4 py-3 text-[13.5px] leading-[1.72] text-fg shadow-sm",children:[t&&e.jsxs("div",{className:"whitespace-pre-wrap break-words",children:[A,N&&!$&&e.jsx("span",{className:"text-fg-5/60",children:"…"})]}),N&&e.jsx("button",{type:"button",onClick:()=>O(M=>!M),className:"mt-2 text-[11.5px] text-fg-4 hover:text-fg-2 underline decoration-fg-5/40 underline-offset-2 transition-colors",children:$?s("hub.collapse"):Y}),z.length>0&&e.jsx("div",{className:C("flex flex-wrap gap-2",t&&"mt-2"),children:z.map((M,te)=>e.jsx("img",{src:M.content,className:"max-w-[280px] max-h-[200px] rounded border border-fg-6/50 object-cover cursor-zoom-in hover:opacity-90 transition-opacity",onClick:()=>j(M.content)},te))})]}),g&&e.jsx(rs,{src:g,onClose:()=>j(null)}),P&&e.jsxs("div",{className:C("flex items-center gap-1 mt-1.5 mr-1 transition-all duration-200",p?"opacity-100 translate-y-0":"opacity-0 -translate-y-1 pointer-events-none"),children:[e.jsx(Bt,{label:s(m?"hub.copied":"hub.copy"),onClick:H,children:m?e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#34d399",strokeWidth:"2",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}):e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}),a&&e.jsx(Bt,{label:s("hub.rerun"),onClick:()=>a(t),children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("polyline",{points:"23 4 23 10 17 10"}),e.jsx("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})}),r&&e.jsx(Bt,{label:s("hub.edit"),onClick:()=>r(t),children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),c&&e.jsx(Bt,{label:s("hub.fork"),onClick:c,children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("circle",{cx:"6",cy:"6",r:"2"}),e.jsx("circle",{cx:"18",cy:"6",r:"2"}),e.jsx("circle",{cx:"12",cy:"20",r:"2"}),e.jsx("path",{d:"M6 8v3a3 3 0 0 0 3 3h6a3 3 0 0 0 3-3V8"}),e.jsx("path",{d:"M12 14v4"})]})})]})]})}function Bt({label:t,onClick:n,children:s}){return e.jsx("button",{onClick:n,title:t,className:"flex items-center justify-center w-7 h-7 rounded border border-fg-6 bg-panel text-fg-4 shadow-sm hover:text-fg-2 hover:border-edge-h hover:bg-panel-h transition-colors",children:s})}function Vr({agent:t,meta:n,model:s,effort:a,providerName:r,previewMeta:c,hideContextUsage:p}){const d=p?null:c?.contextPercent??null,m=p?0:c?.contextUsedTokens??0,v=p?0:c?.turnOutputTokens??0,g=d!=null||m>0||v>0,j=c?.providerName??r??null;return e.jsxs("div",{className:"flex items-center gap-1.5 mt-1 mb-3",children:[e.jsx(dt,{brand:t,size:13}),e.jsx("span",{style:{color:n.color},className:"text-[12px] font-semibold opacity-70",children:n.label}),(s||a)&&e.jsxs("span",{className:"text-[10px] font-mono text-fg-5/50",children:[s||"",s&&a?" · ":"",a||""]}),j&&e.jsxs("span",{className:"text-[10px] font-mono text-fg-5/70 px-1.5 py-px rounded bg-fg-5/8",title:`This turn is routed through ${j} (BYOK), not the agent CLI's native auth.`,children:["via ",j]}),g&&e.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-[10px] font-mono text-fg-5/55",title:Gr(c),children:[d!=null&&e.jsx(qr,{pct:d}),e.jsx("span",{children:d!=null?`${d.toFixed(1)}%`:""}),m>0&&e.jsxs("span",{className:"text-fg-5/40",children:["· ",zn(m)]}),v>0&&e.jsxs("span",{className:"text-fg-5/40",children:["· ↑",vn(v)]})]})]})}function Gr(t){if(!t)return"";const n=[];return t.contextPercent!=null&&n.push(`Context: ${t.contextPercent.toFixed(1)}%`),t.inputTokens!=null&&n.push(`Input: ${t.inputTokens.toLocaleString()}`),t.turnOutputTokens!=null?n.push(`Output (turn): ${t.turnOutputTokens.toLocaleString()}`):t.outputTokens!=null&&n.push(`Output: ${t.outputTokens.toLocaleString()}`),t.cachedInputTokens!=null&&n.push(`Cached: ${t.cachedInputTokens.toLocaleString()}`),n.join(" · ")}function qr({pct:t}){return e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${Kn(t)}`})}function An(t,n,s){return t==="zh-CN"?n:s}function Qr({open:t,onClose:n,workdir:s}){const a=le(c=>c.locale),r=s.split("/").pop()||s;return e.jsxs(Kt,{open:t,onClose:n,wide:!0,children:[e.jsx(Ht,{title:An(a,`${r} — 项目扩展`,`${r} — Project Extensions`),description:An(a,"仅对当前工作区生效。直接操作项目目录中的 .mcp.json 与 .pikiloom/skills/。","Project-scoped only. Operates directly on .mcp.json and .pikiloom/skills/ in the workspace directory."),onClose:n}),t?e.jsx(Rs,{workdir:s}):null]})}let Pn=Bn(()=>import("./SessionPanel--D5NGYgd.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]));function hn(){return Pn??=Bn(()=>import("./SessionPanel--D5NGYgd.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])),Pn}const Yr=i.lazy(async()=>({default:(await hn()).SessionPanel})),cn=5,Xr=240,Zr=120,Jr=12,eo=900*1e3,q=(t,n)=>`${t}:${n}`;function to(t){const n=new Map;for(const d of t)n.set(q(d.agent||"",d.sessionId),d);const s=new Map,a=new Set;for(const d of t){const m=d.migratedFrom;if(!m||m.kind!=="fork"||!m.sessionId)continue;const v=q(m.agent||d.agent||"",m.sessionId);n.has(v)&&(a.add(q(d.agent||"",d.sessionId)),s.has(v)||s.set(v,[]),s.get(v).push(d))}const r=[],c=new Set,p=(d,m)=>{const v=q(d.agent||"",d.sessionId);if(c.has(v))return;c.add(v),r.push(Object.assign({},d,{__forkDepth:m}));const g=s.get(v);if(g)for(const j of g)p(j,m+1)};for(const d of t){const m=q(d.agent||"",d.sessionId);a.has(m)||p(d,0)}for(const d of t)p(d,0);return r}let no=0;function vt(){return`mk-${Date.now().toString(36)}-${(++no).toString(36)}`}function $t(t){try{const n=localStorage.getItem(t);if(n!=null)return n;const s=sessionStorage.getItem(t);if(s!=null){try{localStorage.setItem(t,s),sessionStorage.removeItem(t)}catch{}return s}}catch{}return null}function Ot(t,n){try{localStorage.setItem(t,n)}catch{}}const so=[1,2,3,6],pn=6;function ro(t){for(const n of so)if(n>=t)return n;return pn}function Rn(){const t=typeof window<"u"?window.innerWidth:1280;return t>=1920?3:t>=1280?2:1}function Ge(t,n){const s=ro(t);return s>n?s:n}function oo(t){return t==="vscode"||t==="cursor"||t==="windsurf"||t==="finder"||t==="default"}function io(t,n){const s=String(t||"").toLowerCase();return s.includes("cursor")?"cursor":s.includes("windsurf")?"windsurf":s.includes("code")||n==="darwin"?"vscode":"default"}function is(t){switch(t){case"cursor":return"hub.openTargetCursor";case"windsurf":return"hub.openTargetWindsurf";case"finder":return"hub.openTargetFinder";case"default":return"hub.openTargetDefault";default:return"hub.openTargetVsCode"}}const ao=i.memo(function({active:n=!0}){const s=le(o=>o.locale),a=le(o=>o.state?.runtimeWorkdir??null),r=i.useMemo(()=>ys(s),[s]),[c,p]=i.useState([]),[d,m]=i.useState({}),[v,g]=i.useState({}),[j,y]=i.useState(!0),[N,$]=i.useState(()=>{const o=$t("pikiloom-layout-mode");return o==="1"||o==="2"||o==="3"||o==="6"?Number(o):Rn()}),[O,A]=i.useState(()=>{const o=$t("pikiloom-layout-floor");return o==="1"||o==="2"||o==="3"||o==="6"?Number(o):Rn()}),[P,z]=i.useState(()=>{try{const o=$t("pikiloom-open-sessions");if(o){const h=JSON.parse(o);if(Array.isArray(h))return h.map(u=>({...u,mountKey:u.mountKey||vt()}))}}catch{}return[]}),[H,Y]=i.useState(()=>{const o=$t("pikiloom-active-slot");if(o!=null){const h=Number(o);if(Number.isFinite(h)&&h>=0)return h}return 0}),M=i.useCallback(o=>{$(o),Ot("pikiloom-layout-mode",String(o))},[]),te=i.useCallback(o=>{A(o),Ot("pikiloom-layout-floor",String(o))},[]),T=i.useCallback(o=>{z(h=>{const u=typeof o=="function"?o(h):o,x=u.map(({pendingPrompt:b,pendingImageUrls:k,...S})=>S);return Ot("pikiloom-open-sessions",JSON.stringify(x)),u})},[]),D=i.useCallback(o=>{Y(h=>{const u=typeof o=="function"?o(h):o;return Ot("pikiloom-active-slot",String(u)),u})},[]),I=i.useCallback(o=>{M(o),te(o)},[M,te]);i.useEffect(()=>{T(o=>o.length>N?o.slice(0,N):o),D(o=>o>=N?N-1:o)},[N]);const[Z,R]=i.useState(!1),ne=i.useRef(N);ne.current=N;const Q=i.useRef(O);Q.current=O;const pe=i.useRef(H);pe.current=H;const V=i.useRef(P);V.current=P;const wt=i.useRef(-1),me=P[H]??null,pt=i.useCallback(o=>{if(!o){T([]),D(0);return}const h=o.mountKey?o:{...o,mountKey:vt()};T(u=>{const x=u.findIndex(k=>k.agent===h.agent&&k.sessionId===h.sessionId);if(x>=0)return D(x),u;if(u.length<ne.current){const k=[...u,h];return D(k.length-1),k}if(ne.current<pn){const k=[...u,h];return M(Ge(k.length,Q.current)),D(k.length-1),k}const b=[...u];return b[pe.current]=h,b})},[T,D,M]),[Qe,Ye]=i.useState(!1),[se,$e]=i.useState(null),[Oe,Xe]=i.useState(""),[re,De]=i.useState("all"),[be,Ze]=i.useState({}),[Le,kt]=i.useState({}),ve=i.useDeferredValue(Oe),ce=i.useRef(!1),Je=i.useRef({}),Te=i.useRef(d);Te.current=d;const yt=i.useRef(be);yt.current=be;const Ee=i.useRef(new Set),je=i.useRef({});i.useEffect(()=>()=>{for(const o of Object.values(je.current))clearTimeout(o)},[]),i.useEffect(()=>{T(o=>{let h=!1;const u=o.map(x=>{const b=Le[x.workdir];if(!b)return x;const k=In(b,x.agent,x.sessionId);return k===x.sessionId?x:(h=!0,{...x,sessionId:k})});return h?u:o})},[Le,T]);const we=i.useCallback(async()=>{try{const o=await ie.getWorkspaces(),h=o.ok?o.workspaces:[];h.length&&p(u=>u.length===h.length&&u.every((x,b)=>x.path===h[b].path&&x.name===h[b].name)?u:h),ce.current=!0}catch{ce.current=!0}finally{y(!1)}},[]);i.useEffect(()=>{we()},[we]);const E=i.useCallback(async(o,h={})=>{if(!Je.current[o]){Je.current[o]=!0,h.background||g(u=>({...u,[o]:!0}));try{const u=await Os(o,{force:h.force});i.startTransition(()=>{kt(x=>{const b=u.promotions||{},k=x[o];return k&&Object.keys(k).length===Object.keys(b).length&&Object.entries(b).every(([S,_])=>k[S]===_)?x:{...x,[o]:b}}),m(x=>{const b=u.sessions||[],k=x[o]||[],S=new Set(b.map(U=>q(U.agent||"",U.sessionId))),_=k.filter(U=>{if(U.runState!=="running")return!1;const W=q(U.agent||"",U.sessionId);if(S.has(W))return!1;const F=yt.current[W];return!(F?.resolvedKey&&F.resolvedKey!==W)});return{...x,[o]:_.length?[..._,...b]:b}})})}catch{h.background||i.startTransition(()=>{m(u=>({...u,[o]:[]}))})}finally{Je.current[o]=!1,h.background||g(u=>({...u,[o]:!1}))}}},[]),xe=i.useRef(a);i.useEffect(()=>{a!==xe.current&&(xe.current=a,!(!a||!ce.current)&&we().then(()=>{E(a,{force:!0})}))},[a,we,E]);const J=i.useCallback((o,h)=>{const u=o.agent||"";!u||!o.sessionId||(hn(),Us({workdir:h,agent:u,sessionId:o.sessionId,rich:!0,turnOffset:0,turnLimit:Jr}))},[]),Nt=i.useCallback((o,h,u=Zr)=>{const x=`${h}:${q(o.agent||"",o.sessionId)}`,b=je.current[x];b&&clearTimeout(b),je.current[x]=setTimeout(()=>{delete je.current[x],J(o,h)},u)},[J]),Me=i.useCallback((o,h)=>{const u=`${h}:${q(o.agent||"",o.sessionId)}`,x=je.current[u];x&&(clearTimeout(x),delete je.current[u])},[]);i.useEffect(()=>{n&&hn()},[n]),i.useEffect(()=>{if(!n)return;const o=[];return c.forEach((h,u)=>{if(d[h.path]||v[h.path])return;const x=setTimeout(()=>{E(h.path)},u*90);o.push(x)}),()=>{for(const h of o)clearTimeout(h)}},[n,E,v,d,c]);const et=i.useRef(new Map);Ln(n&&ce.current&&c.length>0?"sessions-changed":null,i.useCallback(o=>{if(typeof document<"u"&&document.visibilityState==="hidden")return;const h=o.key,u=h?c.filter(k=>(Te.current[k.path]||[]).some(S=>q(S.agent||"",S.sessionId)===h)):c,x=u.length?u:c,b=et.current;for(const k of x)b.has(k.path)&&clearTimeout(b.get(k.path)),b.set(k.path,setTimeout(()=>{b.delete(k.path),E(k.path,{background:!0,force:!0})},300))},[c,E]));const Fe=i.useCallback(o=>{const h=o.agent||"";return!h||!o.sessionId?o:Ns(o,be[q(h,o.sessionId)]||null)},[be]);Ln("stream-update",i.useCallback(o=>{const h=o.key;if(!h)return;const u=Ss(h,o.snapshot??null);Ze(x=>{if(!u){const W=x[h];return!W||W.phase==="done"?x:{...x,[h]:{...W,phase:"done",updatedAt:Date.now()}}}const b=(W,F)=>!!W&&!!F&&W.phase===F.phase&&W.resolvedKey===F.resolvedKey&&W.sessionId===F.sessionId&&W.incomplete===F.incomplete&&W.error===F.error,k=b(x[h],u),S=u.resolvedKey===h||b(x[u.resolvedKey],{...u,key:u.resolvedKey});if(k&&S)return x;const _=Date.now()-eo,U={};for(const[W,F]of Object.entries(x))F.phase==="done"&&F.updatedAt<_||(U[W]=F);return U[h]=u,u.resolvedKey!==h&&(U[u.resolvedKey]={...u,key:u.resolvedKey}),U})},[])),Cs(i.useCallback(()=>{if(!(!n||!ce.current||c.length===0))for(const o of c)E(o.path,{background:!0,force:!0})},[n,c,E])),i.useEffect(()=>{if(!n||!ce.current||c.length===0)return;const o=()=>{if(!(typeof document<"u"&&document.visibilityState==="hidden"))for(const u of c)E(u.path,{background:!0,force:!0})};if(o(),typeof document>"u"||typeof window>"u")return;const h=()=>{document.visibilityState==="visible"&&o()};return document.addEventListener("visibilitychange",h),window.addEventListener("focus",h),()=>{document.removeEventListener("visibilitychange",h),window.removeEventListener("focus",h)}},[n,E,c]),i.useEffect(()=>{if(!n)return;const o=[];return c.forEach((h,u)=>{const x=(d[h.path]||[])[0];if(!x)return;const b=`${h.path}:${q(x.agent||"",x.sessionId)}`;if(Ee.current.has(b))return;const k=setTimeout(()=>{Ee.current.add(b),J(x,h.path)},Xr+u*120);o.push(k)}),()=>{for(const h of o)clearTimeout(h)}},[n,d,J,c]);const Qt=i.useCallback(async o=>{try{(await ie.addWorkspace(o)).ok&&(Ye(!1),await we(),E(o))}catch{}},[we,E]),[fe,ke]=i.useState(null),[ye,St]=i.useState(!1),[de,Ue]=i.useState(null),tt=i.useCallback(o=>{ke(o)},[]),nt=i.useCallback(async()=>{const o=fe;if(o){St(!0);try{await ie.removeWorkspace(o),p(h=>h.filter(u=>u.path!==o)),m(h=>{const u={...h};return delete u[o],u}),T(h=>{const u=h.filter(x=>x.workdir!==o);return u.length!==h.length&&M(Ge(u.length,Q.current)),u}),D(0),ke(null)}catch{}finally{St(!1)}}},[fe]),st=i.useCallback(o=>{E(o,{force:!0})},[E]),[Ae,Ne]=i.useState(null),[ze,xt]=i.useState(!1),[ue,rt]=i.useState(!1),ot=le(o=>o.toast),[ae,Pe]=i.useState(null),Ct=i.useCallback((o,h,u)=>{Pe({anchor:{right:o.right,bottom:o.bottom},target:{workdir:u,agent:h.agent||"",sessionId:h.sessionId,title:_n(h).slice(0,120)||h.sessionId.slice(0,16)}})},[]);i.useEffect(()=>{if(!ae)return;const o=()=>Pe(null),h=u=>{u.key==="Escape"&&o()};return window.addEventListener("mousedown",o),window.addEventListener("scroll",o,!0),window.addEventListener("resize",o),window.addEventListener("keydown",h),()=>{window.removeEventListener("mousedown",o),window.removeEventListener("scroll",o,!0),window.removeEventListener("resize",o),window.removeEventListener("keydown",h)}},[ae]);const ft=i.useCallback(o=>{xt(!1),Ne(o),Pe(null)},[]),Se=i.useCallback(async()=>{const o=Ae;if(o){rt(!0);try{const h=await ie.deleteSession(o.workdir,o.agent,o.sessionId,ze);if(!h.ok){const u=h.error?.includes("still running")?r("session.deleteRunningError"):h.error||r("session.deleteFailed");ot(u,!1);return}m(u=>{const x=u[o.workdir];if(!x)return u;const b=x.filter(k=>!(k.agent===o.agent&&k.sessionId===o.sessionId));return b.length===x.length?u:{...u,[o.workdir]:b}}),T(u=>{const x=u.filter(b=>!(b.workdir===o.workdir&&b.agent===o.agent&&b.sessionId===o.sessionId));return x.length!==u.length&&M(Ge(x.length,Q.current)),x}),Ne(null)}catch(h){ot(h?.message||r("session.deleteFailed"),!1)}finally{rt(!1)}}},[Ae,ze,r,ot]),It=i.useCallback(o=>{T(h=>{let u=!1;const x=h.map(b=>b.mountKey===o&&(b.pendingPrompt!=null||b.pendingImageUrls)?(u=!0,{...b,pendingPrompt:null,pendingImageUrls:void 0}):b);return u?x:h})},[T]),Ke=i.useCallback((o,h,u)=>{J({agent:o.agent,sessionId:o.sessionId,runState:"running"},o.workdir),m(k=>{const S=k[o.workdir]||[];if(S.some(W=>W.sessionId===o.sessionId&&W.agent===o.agent))return k;const U={sessionId:o.sessionId,agent:o.agent,runState:"running",lastQuestion:h,createdAt:new Date().toISOString(),runUpdatedAt:new Date().toISOString()};return{...k,[o.workdir]:[U,...S]}});const x=wt.current,b={...o,mountKey:vt(),pendingPrompt:h||null,pendingImageUrls:u&&u.length?u:void 0};i.startTransition(()=>{$e(null),T(k=>{if(x>=k.length)return[...k,b];const S=[...k];return S[x]=b,S}),D(x>=0?x:0)}),E(o.workdir,{background:!0,force:!0})},[E,J,T,D]),Lt=i.useCallback(o=>{V.current.length>=ne.current&&ne.current<pn&&M(Ge(ne.current+1,Q.current)),$e(o)},[M]),Tt=i.useCallback(()=>{$e(null),M(Ge(V.current.length,Q.current))},[M]),Et=i.useCallback((o,h)=>{J(o,h);const u=o.agent||"";V.current.some(x=>x.agent===u&&x.sessionId===o.sessionId)&&M(Ge(V.current.length,Q.current)),$e(null),i.startTransition(()=>{pt({agent:u,sessionId:o.sessionId,workdir:h})})},[J,M]),Mt=i.useCallback((o,h)=>{J({agent:o.agent,sessionId:o.sessionId,runState:"running"},o.workdir),i.startTransition(()=>{h!=null?(T(u=>{if(h>=u.length)return u;const x=[...u],b=u[h],k=b.agent===o.agent&&ct(b.sessionId)&&!ct(o.sessionId);return x[h]={...b,agent:o.agent,sessionId:o.sessionId,workdir:o.workdir,mountKey:k?b.mountKey:vt(),pendingPrompt:k?b.pendingPrompt:null,pendingImageUrls:k?b.pendingImageUrls:void 0},x}),D(h)):pt({...o,mountKey:vt()})}),E(o.workdir,{background:!0,force:!0})},[E,J]),he=i.useCallback(o=>{let h=o;if(re==="running"?h=h.filter(u=>Dt(u)==="running"):re==="review"&&(h=h.filter(u=>Dt(u)==="incomplete")),ve.trim()){const u=ve.toLowerCase();h=h.filter(x=>(x.lastMessageText||"").toLowerCase().includes(u)||(x.lastQuestion||"").toLowerCase().includes(u)||(x.lastAnswer||"").toLowerCase().includes(u)||(x.title||"").toLowerCase().includes(u)||(x.agent||"").toLowerCase().includes(u))}return h},[ve,re]),At=i.useMemo(()=>{const o={};for(const h of c){const u=(d[h.path]||[]).map(Fe),x=Le[h.path],b=new Map;for(const S of u){const _=q(S.agent||"",S.sessionId),U=be[_],W=x?In(x,S.agent||"",S.sessionId):S.sessionId,F=U?.resolvedKey&&U.resolvedKey!==_?U.resolvedKey:W!==S.sessionId?q(S.agent||"",W):_,Re=b.get(F);if(!Re){b.set(F,S);continue}q(Re.agent||"",Re.sessionId)!==F&&_===F&&b.set(F,S)}const k=he([...b.values()]);o[h.path]=to(k)}return o},[c,d,be,Le,he,Fe]),gt=i.useCallback(o=>{const h=(d[o.workdir]||[]).find(u=>u.sessionId===o.sessionId&&u.agent===o.agent)??{sessionId:o.sessionId,agent:o.agent,runState:"running"};return Fe(h)},[Fe,d]),Yt=i.useMemo(()=>new Set(P.map(o=>q(o.agent,o.sessionId))),[P]),Xt=me?q(me.agent,me.sessionId):null,it=i.useCallback(o=>{T(h=>{const u=h.filter((x,b)=>b!==o);return u.length===0?D(0):pe.current>=u.length&&D(u.length-1),M(Ge(u.length,Q.current)),u})},[T,D,M]);return e.jsxs("div",{className:"h-full overflow-hidden p-4 flex gap-3 mx-auto",children:[e.jsxs("div",{className:"panel-isolated w-[252px] shrink-0 flex flex-col overflow-hidden rounded-xl border border-edge bg-panel backdrop-blur-sm",style:{boxShadow:"var(--th-card-shadow)"},children:[e.jsxs("div",{className:"px-3 pt-3 pb-2 space-y-2",children:[e.jsxs("div",{className:"relative group",children:[e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-fg-5/40 group-focus-within:text-fg-4 transition-colors",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("input",{value:Oe,onChange:o=>Xe(o.target.value),placeholder:r("hub.search"),className:"w-full rounded-lg border border-edge/40 bg-inset/50 pl-8 pr-7 py-1.5 text-[12px] text-fg outline-none placeholder:text-fg-5/30 focus:border-primary/30 focus:bg-inset focus:shadow-[0_0_0_3px_rgba(99,102,241,0.06)] transition-all duration-200"}),Oe&&e.jsx("button",{onClick:()=>Xe(""),className:"absolute right-2 top-1/2 -translate-y-1/2 p-0.5 rounded text-fg-5/30 hover:text-fg-4 transition-colors",children:e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.jsx("div",{className:"flex items-center rounded-lg bg-inset/30 border border-edge/20 p-0.5",children:["all","running","review"].map(o=>e.jsx("button",{onClick:()=>De(o),className:C("flex-1 px-2 py-[5px] rounded-md text-[11px] font-medium transition-all duration-200",re===o?"bg-panel-h text-fg-2 shadow-[0_1px_2px_rgba(0,0,0,0.1),inset_0_1px_0_rgba(255,255,255,0.04)]":"text-fg-5/60 hover:text-fg-4"),children:r(`hub.filter${o[0].toUpperCase()+o.slice(1)}`)},o))})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:j?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ge,{className:"h-4 w-4 text-fg-5"})}):c.length===0&&!Qe?e.jsx("div",{className:"py-12 text-center text-[13px] text-fg-5",children:r("hub.noWorkspaces")}):c.map(o=>e.jsx(ho,{workspace:o,sessions:At[o.path]||[],loading:!!v[o.path]||!(o.path in d),isActive:o.path===a,removable:o.removable!==!1,selectedKey:Xt,openSessionKeys:Yt,onSelectSession:Et,onNewSession:Lt,onRefresh:st,onRemove:tt,onExtensions:Ue,onWarmSession:Nt,onCancelWarmSession:Me,onSessionMenuOpen:Ct,t:r},o.path))}),e.jsxs("div",{className:"shrink-0 border-t border-edge/20 px-3 py-2 space-y-1.5",children:[e.jsx("div",{className:"flex items-center rounded-md bg-inset/30 border border-edge/20 p-0.5",children:[1,2,3,6].map(o=>e.jsx("button",{onClick:()=>I(o),className:C("flex-1 flex items-center justify-center p-1.5 rounded transition-all",N===o?"bg-panel-h text-fg-2 shadow-[0_1px_2px_rgba(0,0,0,0.1)]":"text-fg-5/40 hover:text-fg-4"),title:r(`hub.layout${o}`),children:o===1?e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"1.5"})}):o===2?e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("rect",{x:"1",y:"2",width:"6",height:"12",rx:"1.5"}),e.jsx("rect",{x:"9",y:"2",width:"6",height:"12",rx:"1.5"})]}):o===3?e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("rect",{x:"0.5",y:"2",width:"4",height:"12",rx:"1"}),e.jsx("rect",{x:"6",y:"2",width:"4",height:"12",rx:"1"}),e.jsx("rect",{x:"11.5",y:"2",width:"4",height:"12",rx:"1"})]}):e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.2",children:[e.jsx("rect",{x:"0.5",y:"1",width:"4",height:"5.5",rx:"0.8"}),e.jsx("rect",{x:"6",y:"1",width:"4",height:"5.5",rx:"0.8"}),e.jsx("rect",{x:"11.5",y:"1",width:"4",height:"5.5",rx:"0.8"}),e.jsx("rect",{x:"0.5",y:"9.5",width:"4",height:"5.5",rx:"0.8"}),e.jsx("rect",{x:"6",y:"9.5",width:"4",height:"5.5",rx:"0.8"}),e.jsx("rect",{x:"11.5",y:"9.5",width:"4",height:"5.5",rx:"0.8"})]})},o))}),e.jsxs(We,{variant:"ghost",size:"sm",onClick:()=>Ye(o=>!o),className:"w-full",children:[e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),r("hub.addWorkspace")]})]})]}),e.jsx("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden gap-0",children:e.jsx("div",{className:"flex-1 min-h-0 grid gap-3",style:{gridTemplateColumns:`repeat(${N===6?3:N}, 1fr)`,gridTemplateRows:N===6?"repeat(2, 1fr)":"1fr"},children:(()=>{const o=se?P.length<N?P.length:H:-1;return wt.current=o,Array.from({length:N},(h,u)=>{if(se&&u===o)return e.jsx("div",{className:"min-w-0 overflow-hidden rounded-xl border border-edge bg-panel flex flex-col",style:{boxShadow:"var(--th-card-shadow)"},children:e.jsx(co,{workdir:se,workspaceName:c.find(S=>S.path===se)?.name||se.split("/").pop()||"",onSessionCreated:Ke,onClose:Tt,t:r},se)},`new-${se}`);const x=P[u]??null;if(!x)return e.jsx("div",{className:"min-w-0 overflow-hidden rounded-xl border border-dashed border-edge/40 bg-panel/30 flex items-center justify-center",children:e.jsxs("div",{className:"text-center px-4",children:[e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",className:"mx-auto text-fg-5/20 mb-2",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"16"}),e.jsx("line",{x1:"8",y1:"12",x2:"16",y2:"12"})]}),e.jsx("div",{className:"text-[12px] text-fg-5/40",children:r("hub.emptySlot")})]})},`empty-${u}`);const b=gt(x),k=u===H;return e.jsxs("div",{className:C("min-w-0 overflow-hidden rounded-xl border bg-panel flex flex-col transition-[border-color,box-shadow] duration-200",k?"border-primary/40 ring-[3px] ring-primary/[0.06]":"border-edge hover:border-edge-h"),style:{boxShadow:k?"var(--th-card-shadow), 0 0 0 1px rgba(14,165,233,0.08)":"var(--th-card-shadow)"},onClick:()=>D(u),children:[e.jsxs("div",{className:C("shrink-0 flex items-center gap-2 px-2.5 h-8 border-b border-edge/30",k?"bg-primary/[0.03]":"bg-panel/60"),children:[(()=>{const S=Dt(b);return e.jsx(Gt,{variant:S==="running"?"ok":S==="waiting"?"info":S==="incomplete"?"warn":"idle",pulse:S==="running"||S==="waiting"})})(),e.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-0",children:[e.jsx("span",{className:"shrink-0 text-[10px] font-medium text-fg-5",children:x.workdir.split("/").pop()||x.workdir}),e.jsx("span",{className:"shrink-0 text-fg-6 text-[10px] mx-1",children:"/"}),e.jsx("span",{className:"min-w-0 truncate text-[11px] font-medium text-fg-3",children:b.title||b.lastQuestion?.slice(0,60)||(ct(x.sessionId)?r("hub.newSession"):x.sessionId.slice(0,12))})]}),e.jsxs("div",{className:"shrink-0 flex items-center gap-2.5 pl-4 text-[9px] text-fg-5/50 tabular-nums",children:[e.jsx("span",{title:r("hub.created"),children:Is(b.createdAt)}),b.runUpdatedAt&&e.jsx("span",{title:r("hub.updated"),children:Wn(b.runUpdatedAt)}),!!b.numTurns&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"opacity-60",children:e.jsx("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"})}),b.numTurns]}),e.jsx("button",{"data-filetree-toggle":!0,onClick:S=>{S.stopPropagation(),R(_=>!_)},className:C("p-0.5 rounded transition-colors",Z?"text-fg-3 bg-panel-h":"text-fg-5/40 hover:text-fg-3 hover:bg-panel-h"),title:r("hub.files"),children:e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M2 6a2 2 0 012-2h5l2 2h9a2 2 0 012 2v10a2 2 0 01-2 2H4a2 2 0 01-2-2V6z"})})}),e.jsx("button",{onClick:S=>{S.stopPropagation(),it(u)},className:"p-0.5 rounded text-fg-5/40 hover:text-fg-2 hover:bg-panel-h transition-colors",title:r("hub.closePanel"),children:e.jsxs("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(i.Suspense,{fallback:e.jsx("div",{className:"h-full"}),children:e.jsx(Yr,{session:b,workdir:x.workdir,active:n&&k,onSessionChange:S=>Mt(S,u),initialPendingPrompt:x.pendingPrompt??null,initialPendingImageUrls:x.pendingImageUrls,onPendingPromptConsumed:()=>It(x.mountKey)},x.mountKey)})})]},x.mountKey||q(x.agent,x.sessionId))})})()})}),Z&&me&&e.jsx(xo,{workdir:me.workdir,onClose:()=>R(!1),t:r}),e.jsx(lo,{open:Qe,initialPath:a||void 0,onAdd:Qt,onClose:()=>Ye(!1),t:r}),e.jsxs(Kt,{open:!!fe,onClose:()=>!ye&&ke(null),children:[e.jsx(Ht,{title:r("hub.removeWorkspace"),onClose:()=>!ye&&ke(null)}),e.jsx("div",{className:"text-[13px] text-fg-3 leading-relaxed",children:r("modal.confirmRemoveWorkspace")}),e.jsx("div",{className:"mt-1 text-[12px] text-fg-5",children:r("modal.confirmRemoveWorkspaceHint")}),fe&&e.jsx("div",{className:"mt-3 rounded-md bg-inset/50 border border-edge/30 px-3 py-2 font-mono text-[11px] text-fg-4 break-all",children:fe}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx(We,{variant:"ghost",onClick:()=>ke(null),disabled:ye,children:r("modal.cancel")}),e.jsx(We,{variant:"primary",onClick:nt,disabled:ye,className:"!bg-red-500/90 !border-red-500/50 hover:!bg-red-500 !text-white",children:r(ye?"modal.removing":"modal.remove")})]})]}),ae&&(()=>{const h=Math.max(8,Math.min(ae.anchor.right-160,window.innerWidth-160-8)),u=Math.min(ae.anchor.bottom+4,window.innerHeight-60);return e.jsx("div",{className:"fixed z-[60] min-w-[160px] rounded-md border border-edge bg-panel/95 backdrop-blur-md py-1",style:{left:h,top:u,boxShadow:"0 8px 24px rgba(0,0,0,0.20), 0 2px 6px rgba(0,0,0,0.10)"},onMouseDown:x=>x.stopPropagation(),role:"menu",children:e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>ft(ae.target),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left text-[12px] text-fg-2 hover:bg-panel-h/60 hover:text-red-400 transition-colors",children:[e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("path",{d:"M19 6l-1 14a2 2 0 01-2 2H8a2 2 0 01-2-2L5 6"}),e.jsx("path",{d:"M10 11v6"}),e.jsx("path",{d:"M14 11v6"}),e.jsx("path",{d:"M9 6V4a2 2 0 012-2h2a2 2 0 012 2v2"})]}),r("session.delete")]})})})(),e.jsxs(Kt,{open:!!Ae,onClose:()=>!ue&&Ne(null),children:[e.jsx(Ht,{title:r("session.deleteTitle"),onClose:()=>!ue&&Ne(null)}),e.jsx("div",{className:"text-[13px] text-fg-3 leading-relaxed",children:r("session.deleteHint")}),Ae&&e.jsxs("div",{className:"mt-3 rounded-md bg-inset/50 border border-edge/30 px-3 py-2 text-[11px] text-fg-4 break-all",children:[e.jsx("span",{className:"font-mono text-fg-5",children:Ae.agent}),e.jsx("span",{className:"mx-1.5 text-fg-5/50",children:"·"}),e.jsx("span",{children:Ae.title})]}),e.jsxs("div",{className:"mt-4 space-y-2",children:[e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"delete-session-scope",checked:!ze,onChange:()=>xt(!1),disabled:ue,className:"mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-[12px] text-fg-2",children:r("session.deletePikiloomOnly")}),e.jsx("div",{className:"text-[11px] text-fg-5 leading-snug mt-0.5",children:r("session.deletePikiloomOnlyHint")})]})]}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"delete-session-scope",checked:ze,onChange:()=>xt(!0),disabled:ue,className:"mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-[12px] text-fg-2",children:r("session.deletePurgeNative")}),e.jsx("div",{className:"text-[11px] text-fg-5 leading-snug mt-0.5",children:r("session.deletePurgeNativeHint")})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx(We,{variant:"ghost",onClick:()=>Ne(null),disabled:ue,children:r("modal.cancel")}),e.jsx(We,{variant:"primary",onClick:Se,disabled:ue,className:"!bg-red-500/90 !border-red-500/50 hover:!bg-red-500 !text-white",children:r(ue?"session.deleting":"modal.remove")})]})]}),e.jsx(Qr,{open:!!de,onClose:()=>Ue(null),workdir:de||""})]})});function lo({open:t,initialPath:n,onAdd:s,onClose:a,t:r}){const[c,p]=i.useState(""),d=i.useCallback(m=>p(m),[]);return i.useEffect(()=>{t&&p("")},[t]),e.jsxs(Kt,{open:t,onClose:a,children:[e.jsx(Ht,{title:r("hub.addWorkspace"),onClose:a}),e.jsx(Ms,{initialPath:n,maxHeight:360,minHeight:200,onSelect:d,t:r}),e.jsxs("div",{className:"flex gap-2 mt-4",children:[e.jsx(We,{disabled:!c,onClick:()=>c&&s(c),className:"flex-1",children:r("hub.add")}),e.jsx(We,{variant:"secondary",onClick:a,className:"flex-1",children:r("hub.cancel")})]})]})}function co({workdir:t,workspaceName:n,onSessionCreated:s,onClose:a,t:r}){const[c,p]=i.useState(null),[d,m]=i.useState([]),v=i.useRef(null),g=i.useRef([]),j=i.useMemo(()=>({sessionId:"",agent:"",runState:"completed"}),[]),y=i.useCallback(()=>{},[]),N=i.useCallback((A,P)=>{p(A||null),v.current=A||null;const z=P||[];m(z),g.current=z},[]),$=i.useCallback(A=>{const P=g.current;g.current=[],s(A,v.current||void 0,P.length?P:void 0)},[s]),O=!!c||d.length>0;return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-4 h-10 border-b border-edge/50 bg-panel/40 backdrop-blur-md z-10",children:[e.jsx("span",{className:"flex-1 min-w-0 text-[13px] font-medium text-fg truncate",children:r("hub.newSession")}),e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-fg-5/60 shrink-0",children:[e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"opacity-60",children:e.jsx("path",{d:"M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z"})}),e.jsx("span",{className:"max-w-[80px] truncate",children:n})]}),e.jsx(Gt,{variant:O?"ok":"idle",pulse:O}),!O&&e.jsx("button",{onClick:a,className:"p-1 rounded text-fg-5 hover:text-fg-2 transition-colors",children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:O?e.jsxs("div",{className:"max-w-[900px] mx-auto px-6 py-6 space-y-0",children:[e.jsx(os,{text:c||"",blocks:d.map(A=>({type:"image",content:A})),t:r}),e.jsx("div",{className:"mt-3 mb-4 animate-in",children:e.jsx(ts,{className:"text-fg-5"})})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("div",{className:"text-center space-y-1.5",children:e.jsx("div",{className:"text-[13px] text-fg-5",children:r("hub.newSessionHint")})})})}),e.jsx(xr,{session:j,workdir:t,onStreamQueued:y,onSendStart:N,onSessionChange:$,t:r,streamPhase:null})]})}function uo({git:t}){if(!t)return null;const n=[t.detached?`detached HEAD${t.shortSha?` @ ${t.shortSha}`:""}`:`branch ${t.branch??"?"}`,t.upstream?`upstream ${t.upstream}`:t.detached?"":"no upstream",t.ahead||t.behind?`↑${t.ahead} ahead · ↓${t.behind} behind`:"",t.changed>0?`${t.changed} changed (${t.staged} staged · ${t.unstaged} unstaged · ${t.untracked} untracked)`:"clean"].filter(Boolean).join(`
22
+ `).length:0,N=!!t&&(t.length>zr||y>Kr),[$,O]=i.useState(!1),A=t?N&&!$?Hr(t):t:"",P=!!(a||r||c),z=n?.filter(M=>M.type==="image")||[],H=()=>{navigator.clipboard.writeText(t).then(()=>{v(!0),setTimeout(()=>v(!1),1500)}).catch(()=>{})},Y=s("hub.expand").replace("{chars}",t?t.length.toLocaleString():"0").replace("{lines}",String(y));return e.jsxs("div",{className:"flex flex-col items-end mb-5 group/bubble",onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[e.jsxs("div",{className:"max-w-[72%] rounded-md border border-fg-6 bg-panel px-4 py-3 text-[13.5px] leading-[1.72] text-fg shadow-sm",children:[t&&e.jsxs("div",{className:"whitespace-pre-wrap break-words",children:[A,N&&!$&&e.jsx("span",{className:"text-fg-5/60",children:"…"})]}),N&&e.jsx("button",{type:"button",onClick:()=>O(M=>!M),className:"mt-2 text-[11.5px] text-fg-4 hover:text-fg-2 underline decoration-fg-5/40 underline-offset-2 transition-colors",children:$?s("hub.collapse"):Y}),z.length>0&&e.jsx("div",{className:C("flex flex-wrap gap-2",t&&"mt-2"),children:z.map((M,te)=>e.jsx("img",{src:M.content,className:"max-w-[280px] max-h-[200px] rounded border border-fg-6/50 object-cover cursor-zoom-in hover:opacity-90 transition-opacity",onClick:()=>j(M.content)},te))})]}),g&&e.jsx(rs,{src:g,onClose:()=>j(null)}),P&&e.jsxs("div",{className:C("flex items-center gap-1 mt-1.5 mr-1 transition-all duration-200",p?"opacity-100 translate-y-0":"opacity-0 -translate-y-1 pointer-events-none"),children:[e.jsx(Bt,{label:s(m?"hub.copied":"hub.copy"),onClick:H,children:m?e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#34d399",strokeWidth:"2",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}):e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}),a&&e.jsx(Bt,{label:s("hub.rerun"),onClick:()=>a(t),children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("polyline",{points:"23 4 23 10 17 10"}),e.jsx("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})}),r&&e.jsx(Bt,{label:s("hub.edit"),onClick:()=>r(t),children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),c&&e.jsx(Bt,{label:s("hub.fork"),onClick:c,children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("circle",{cx:"6",cy:"6",r:"2"}),e.jsx("circle",{cx:"18",cy:"6",r:"2"}),e.jsx("circle",{cx:"12",cy:"20",r:"2"}),e.jsx("path",{d:"M6 8v3a3 3 0 0 0 3 3h6a3 3 0 0 0 3-3V8"}),e.jsx("path",{d:"M12 14v4"})]})})]})]})}function Bt({label:t,onClick:n,children:s}){return e.jsx("button",{onClick:n,title:t,className:"flex items-center justify-center w-7 h-7 rounded border border-fg-6 bg-panel text-fg-4 shadow-sm hover:text-fg-2 hover:border-edge-h hover:bg-panel-h transition-colors",children:s})}function Vr({agent:t,meta:n,model:s,effort:a,providerName:r,previewMeta:c,hideContextUsage:p}){const d=p?null:c?.contextPercent??null,m=p?0:c?.contextUsedTokens??0,v=p?0:c?.turnOutputTokens??0,g=d!=null||m>0||v>0,j=c?.providerName??r??null;return e.jsxs("div",{className:"flex items-center gap-1.5 mt-1 mb-3",children:[e.jsx(dt,{brand:t,size:13}),e.jsx("span",{style:{color:n.color},className:"text-[12px] font-semibold opacity-70",children:n.label}),(s||a)&&e.jsxs("span",{className:"text-[10px] font-mono text-fg-5/50",children:[s||"",s&&a?" · ":"",a||""]}),j&&e.jsxs("span",{className:"text-[10px] font-mono text-fg-5/70 px-1.5 py-px rounded bg-fg-5/8",title:`This turn is routed through ${j} (BYOK), not the agent CLI's native auth.`,children:["via ",j]}),g&&e.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-[10px] font-mono text-fg-5/55",title:Gr(c),children:[d!=null&&e.jsx(qr,{pct:d}),e.jsx("span",{children:d!=null?`${d.toFixed(1)}%`:""}),m>0&&e.jsxs("span",{className:"text-fg-5/40",children:["· ",zn(m)]}),v>0&&e.jsxs("span",{className:"text-fg-5/40",children:["· ↑",vn(v)]})]})]})}function Gr(t){if(!t)return"";const n=[];return t.contextPercent!=null&&n.push(`Context: ${t.contextPercent.toFixed(1)}%`),t.inputTokens!=null&&n.push(`Input: ${t.inputTokens.toLocaleString()}`),t.turnOutputTokens!=null?n.push(`Output (turn): ${t.turnOutputTokens.toLocaleString()}`):t.outputTokens!=null&&n.push(`Output: ${t.outputTokens.toLocaleString()}`),t.cachedInputTokens!=null&&n.push(`Cached: ${t.cachedInputTokens.toLocaleString()}`),n.join(" · ")}function qr({pct:t}){return e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${Kn(t)}`})}function An(t,n,s){return t==="zh-CN"?n:s}function Qr({open:t,onClose:n,workdir:s}){const a=le(c=>c.locale),r=s.split("/").pop()||s;return e.jsxs(Kt,{open:t,onClose:n,wide:!0,children:[e.jsx(Ht,{title:An(a,`${r} — 项目扩展`,`${r} — Project Extensions`),description:An(a,"仅对当前工作区生效。直接操作项目目录中的 .mcp.json 与 .pikiloom/skills/。","Project-scoped only. Operates directly on .mcp.json and .pikiloom/skills/ in the workspace directory."),onClose:n}),t?e.jsx(Rs,{workdir:s}):null]})}let Pn=Bn(()=>import("./SessionPanel-CEoPMHDr.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]));function hn(){return Pn??=Bn(()=>import("./SessionPanel-CEoPMHDr.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])),Pn}const Yr=i.lazy(async()=>({default:(await hn()).SessionPanel})),cn=5,Xr=240,Zr=120,Jr=12,eo=900*1e3,q=(t,n)=>`${t}:${n}`;function to(t){const n=new Map;for(const d of t)n.set(q(d.agent||"",d.sessionId),d);const s=new Map,a=new Set;for(const d of t){const m=d.migratedFrom;if(!m||m.kind!=="fork"||!m.sessionId)continue;const v=q(m.agent||d.agent||"",m.sessionId);n.has(v)&&(a.add(q(d.agent||"",d.sessionId)),s.has(v)||s.set(v,[]),s.get(v).push(d))}const r=[],c=new Set,p=(d,m)=>{const v=q(d.agent||"",d.sessionId);if(c.has(v))return;c.add(v),r.push(Object.assign({},d,{__forkDepth:m}));const g=s.get(v);if(g)for(const j of g)p(j,m+1)};for(const d of t){const m=q(d.agent||"",d.sessionId);a.has(m)||p(d,0)}for(const d of t)p(d,0);return r}let no=0;function vt(){return`mk-${Date.now().toString(36)}-${(++no).toString(36)}`}function $t(t){try{const n=localStorage.getItem(t);if(n!=null)return n;const s=sessionStorage.getItem(t);if(s!=null){try{localStorage.setItem(t,s),sessionStorage.removeItem(t)}catch{}return s}}catch{}return null}function Ot(t,n){try{localStorage.setItem(t,n)}catch{}}const so=[1,2,3,6],pn=6;function ro(t){for(const n of so)if(n>=t)return n;return pn}function Rn(){const t=typeof window<"u"?window.innerWidth:1280;return t>=1920?3:t>=1280?2:1}function Ge(t,n){const s=ro(t);return s>n?s:n}function oo(t){return t==="vscode"||t==="cursor"||t==="windsurf"||t==="finder"||t==="default"}function io(t,n){const s=String(t||"").toLowerCase();return s.includes("cursor")?"cursor":s.includes("windsurf")?"windsurf":s.includes("code")||n==="darwin"?"vscode":"default"}function is(t){switch(t){case"cursor":return"hub.openTargetCursor";case"windsurf":return"hub.openTargetWindsurf";case"finder":return"hub.openTargetFinder";case"default":return"hub.openTargetDefault";default:return"hub.openTargetVsCode"}}const ao=i.memo(function({active:n=!0}){const s=le(o=>o.locale),a=le(o=>o.state?.runtimeWorkdir??null),r=i.useMemo(()=>ys(s),[s]),[c,p]=i.useState([]),[d,m]=i.useState({}),[v,g]=i.useState({}),[j,y]=i.useState(!0),[N,$]=i.useState(()=>{const o=$t("pikiloom-layout-mode");return o==="1"||o==="2"||o==="3"||o==="6"?Number(o):Rn()}),[O,A]=i.useState(()=>{const o=$t("pikiloom-layout-floor");return o==="1"||o==="2"||o==="3"||o==="6"?Number(o):Rn()}),[P,z]=i.useState(()=>{try{const o=$t("pikiloom-open-sessions");if(o){const h=JSON.parse(o);if(Array.isArray(h))return h.map(u=>({...u,mountKey:u.mountKey||vt()}))}}catch{}return[]}),[H,Y]=i.useState(()=>{const o=$t("pikiloom-active-slot");if(o!=null){const h=Number(o);if(Number.isFinite(h)&&h>=0)return h}return 0}),M=i.useCallback(o=>{$(o),Ot("pikiloom-layout-mode",String(o))},[]),te=i.useCallback(o=>{A(o),Ot("pikiloom-layout-floor",String(o))},[]),T=i.useCallback(o=>{z(h=>{const u=typeof o=="function"?o(h):o,x=u.map(({pendingPrompt:b,pendingImageUrls:k,...S})=>S);return Ot("pikiloom-open-sessions",JSON.stringify(x)),u})},[]),D=i.useCallback(o=>{Y(h=>{const u=typeof o=="function"?o(h):o;return Ot("pikiloom-active-slot",String(u)),u})},[]),I=i.useCallback(o=>{M(o),te(o)},[M,te]);i.useEffect(()=>{T(o=>o.length>N?o.slice(0,N):o),D(o=>o>=N?N-1:o)},[N]);const[Z,R]=i.useState(!1),ne=i.useRef(N);ne.current=N;const Q=i.useRef(O);Q.current=O;const pe=i.useRef(H);pe.current=H;const V=i.useRef(P);V.current=P;const wt=i.useRef(-1),me=P[H]??null,pt=i.useCallback(o=>{if(!o){T([]),D(0);return}const h=o.mountKey?o:{...o,mountKey:vt()};T(u=>{const x=u.findIndex(k=>k.agent===h.agent&&k.sessionId===h.sessionId);if(x>=0)return D(x),u;if(u.length<ne.current){const k=[...u,h];return D(k.length-1),k}if(ne.current<pn){const k=[...u,h];return M(Ge(k.length,Q.current)),D(k.length-1),k}const b=[...u];return b[pe.current]=h,b})},[T,D,M]),[Qe,Ye]=i.useState(!1),[se,$e]=i.useState(null),[Oe,Xe]=i.useState(""),[re,De]=i.useState("all"),[be,Ze]=i.useState({}),[Le,kt]=i.useState({}),ve=i.useDeferredValue(Oe),ce=i.useRef(!1),Je=i.useRef({}),Te=i.useRef(d);Te.current=d;const yt=i.useRef(be);yt.current=be;const Ee=i.useRef(new Set),je=i.useRef({});i.useEffect(()=>()=>{for(const o of Object.values(je.current))clearTimeout(o)},[]),i.useEffect(()=>{T(o=>{let h=!1;const u=o.map(x=>{const b=Le[x.workdir];if(!b)return x;const k=In(b,x.agent,x.sessionId);return k===x.sessionId?x:(h=!0,{...x,sessionId:k})});return h?u:o})},[Le,T]);const we=i.useCallback(async()=>{try{const o=await ie.getWorkspaces(),h=o.ok?o.workspaces:[];h.length&&p(u=>u.length===h.length&&u.every((x,b)=>x.path===h[b].path&&x.name===h[b].name)?u:h),ce.current=!0}catch{ce.current=!0}finally{y(!1)}},[]);i.useEffect(()=>{we()},[we]);const E=i.useCallback(async(o,h={})=>{if(!Je.current[o]){Je.current[o]=!0,h.background||g(u=>({...u,[o]:!0}));try{const u=await Os(o,{force:h.force});i.startTransition(()=>{kt(x=>{const b=u.promotions||{},k=x[o];return k&&Object.keys(k).length===Object.keys(b).length&&Object.entries(b).every(([S,_])=>k[S]===_)?x:{...x,[o]:b}}),m(x=>{const b=u.sessions||[],k=x[o]||[],S=new Set(b.map(U=>q(U.agent||"",U.sessionId))),_=k.filter(U=>{if(U.runState!=="running")return!1;const W=q(U.agent||"",U.sessionId);if(S.has(W))return!1;const F=yt.current[W];return!(F?.resolvedKey&&F.resolvedKey!==W)});return{...x,[o]:_.length?[..._,...b]:b}})})}catch{h.background||i.startTransition(()=>{m(u=>({...u,[o]:[]}))})}finally{Je.current[o]=!1,h.background||g(u=>({...u,[o]:!1}))}}},[]),xe=i.useRef(a);i.useEffect(()=>{a!==xe.current&&(xe.current=a,!(!a||!ce.current)&&we().then(()=>{E(a,{force:!0})}))},[a,we,E]);const J=i.useCallback((o,h)=>{const u=o.agent||"";!u||!o.sessionId||(hn(),Us({workdir:h,agent:u,sessionId:o.sessionId,rich:!0,turnOffset:0,turnLimit:Jr}))},[]),Nt=i.useCallback((o,h,u=Zr)=>{const x=`${h}:${q(o.agent||"",o.sessionId)}`,b=je.current[x];b&&clearTimeout(b),je.current[x]=setTimeout(()=>{delete je.current[x],J(o,h)},u)},[J]),Me=i.useCallback((o,h)=>{const u=`${h}:${q(o.agent||"",o.sessionId)}`,x=je.current[u];x&&(clearTimeout(x),delete je.current[u])},[]);i.useEffect(()=>{n&&hn()},[n]),i.useEffect(()=>{if(!n)return;const o=[];return c.forEach((h,u)=>{if(d[h.path]||v[h.path])return;const x=setTimeout(()=>{E(h.path)},u*90);o.push(x)}),()=>{for(const h of o)clearTimeout(h)}},[n,E,v,d,c]);const et=i.useRef(new Map);Ln(n&&ce.current&&c.length>0?"sessions-changed":null,i.useCallback(o=>{if(typeof document<"u"&&document.visibilityState==="hidden")return;const h=o.key,u=h?c.filter(k=>(Te.current[k.path]||[]).some(S=>q(S.agent||"",S.sessionId)===h)):c,x=u.length?u:c,b=et.current;for(const k of x)b.has(k.path)&&clearTimeout(b.get(k.path)),b.set(k.path,setTimeout(()=>{b.delete(k.path),E(k.path,{background:!0,force:!0})},300))},[c,E]));const Fe=i.useCallback(o=>{const h=o.agent||"";return!h||!o.sessionId?o:Ns(o,be[q(h,o.sessionId)]||null)},[be]);Ln("stream-update",i.useCallback(o=>{const h=o.key;if(!h)return;const u=Ss(h,o.snapshot??null);Ze(x=>{if(!u){const W=x[h];return!W||W.phase==="done"?x:{...x,[h]:{...W,phase:"done",updatedAt:Date.now()}}}const b=(W,F)=>!!W&&!!F&&W.phase===F.phase&&W.resolvedKey===F.resolvedKey&&W.sessionId===F.sessionId&&W.incomplete===F.incomplete&&W.error===F.error,k=b(x[h],u),S=u.resolvedKey===h||b(x[u.resolvedKey],{...u,key:u.resolvedKey});if(k&&S)return x;const _=Date.now()-eo,U={};for(const[W,F]of Object.entries(x))F.phase==="done"&&F.updatedAt<_||(U[W]=F);return U[h]=u,u.resolvedKey!==h&&(U[u.resolvedKey]={...u,key:u.resolvedKey}),U})},[])),Cs(i.useCallback(()=>{if(!(!n||!ce.current||c.length===0))for(const o of c)E(o.path,{background:!0,force:!0})},[n,c,E])),i.useEffect(()=>{if(!n||!ce.current||c.length===0)return;const o=()=>{if(!(typeof document<"u"&&document.visibilityState==="hidden"))for(const u of c)E(u.path,{background:!0,force:!0})};if(o(),typeof document>"u"||typeof window>"u")return;const h=()=>{document.visibilityState==="visible"&&o()};return document.addEventListener("visibilitychange",h),window.addEventListener("focus",h),()=>{document.removeEventListener("visibilitychange",h),window.removeEventListener("focus",h)}},[n,E,c]),i.useEffect(()=>{if(!n)return;const o=[];return c.forEach((h,u)=>{const x=(d[h.path]||[])[0];if(!x)return;const b=`${h.path}:${q(x.agent||"",x.sessionId)}`;if(Ee.current.has(b))return;const k=setTimeout(()=>{Ee.current.add(b),J(x,h.path)},Xr+u*120);o.push(k)}),()=>{for(const h of o)clearTimeout(h)}},[n,d,J,c]);const Qt=i.useCallback(async o=>{try{(await ie.addWorkspace(o)).ok&&(Ye(!1),await we(),E(o))}catch{}},[we,E]),[fe,ke]=i.useState(null),[ye,St]=i.useState(!1),[de,Ue]=i.useState(null),tt=i.useCallback(o=>{ke(o)},[]),nt=i.useCallback(async()=>{const o=fe;if(o){St(!0);try{await ie.removeWorkspace(o),p(h=>h.filter(u=>u.path!==o)),m(h=>{const u={...h};return delete u[o],u}),T(h=>{const u=h.filter(x=>x.workdir!==o);return u.length!==h.length&&M(Ge(u.length,Q.current)),u}),D(0),ke(null)}catch{}finally{St(!1)}}},[fe]),st=i.useCallback(o=>{E(o,{force:!0})},[E]),[Ae,Ne]=i.useState(null),[ze,xt]=i.useState(!1),[ue,rt]=i.useState(!1),ot=le(o=>o.toast),[ae,Pe]=i.useState(null),Ct=i.useCallback((o,h,u)=>{Pe({anchor:{right:o.right,bottom:o.bottom},target:{workdir:u,agent:h.agent||"",sessionId:h.sessionId,title:_n(h).slice(0,120)||h.sessionId.slice(0,16)}})},[]);i.useEffect(()=>{if(!ae)return;const o=()=>Pe(null),h=u=>{u.key==="Escape"&&o()};return window.addEventListener("mousedown",o),window.addEventListener("scroll",o,!0),window.addEventListener("resize",o),window.addEventListener("keydown",h),()=>{window.removeEventListener("mousedown",o),window.removeEventListener("scroll",o,!0),window.removeEventListener("resize",o),window.removeEventListener("keydown",h)}},[ae]);const ft=i.useCallback(o=>{xt(!1),Ne(o),Pe(null)},[]),Se=i.useCallback(async()=>{const o=Ae;if(o){rt(!0);try{const h=await ie.deleteSession(o.workdir,o.agent,o.sessionId,ze);if(!h.ok){const u=h.error?.includes("still running")?r("session.deleteRunningError"):h.error||r("session.deleteFailed");ot(u,!1);return}m(u=>{const x=u[o.workdir];if(!x)return u;const b=x.filter(k=>!(k.agent===o.agent&&k.sessionId===o.sessionId));return b.length===x.length?u:{...u,[o.workdir]:b}}),T(u=>{const x=u.filter(b=>!(b.workdir===o.workdir&&b.agent===o.agent&&b.sessionId===o.sessionId));return x.length!==u.length&&M(Ge(x.length,Q.current)),x}),Ne(null)}catch(h){ot(h?.message||r("session.deleteFailed"),!1)}finally{rt(!1)}}},[Ae,ze,r,ot]),It=i.useCallback(o=>{T(h=>{let u=!1;const x=h.map(b=>b.mountKey===o&&(b.pendingPrompt!=null||b.pendingImageUrls)?(u=!0,{...b,pendingPrompt:null,pendingImageUrls:void 0}):b);return u?x:h})},[T]),Ke=i.useCallback((o,h,u)=>{J({agent:o.agent,sessionId:o.sessionId,runState:"running"},o.workdir),m(k=>{const S=k[o.workdir]||[];if(S.some(W=>W.sessionId===o.sessionId&&W.agent===o.agent))return k;const U={sessionId:o.sessionId,agent:o.agent,runState:"running",lastQuestion:h,createdAt:new Date().toISOString(),runUpdatedAt:new Date().toISOString()};return{...k,[o.workdir]:[U,...S]}});const x=wt.current,b={...o,mountKey:vt(),pendingPrompt:h||null,pendingImageUrls:u&&u.length?u:void 0};i.startTransition(()=>{$e(null),T(k=>{if(x>=k.length)return[...k,b];const S=[...k];return S[x]=b,S}),D(x>=0?x:0)}),E(o.workdir,{background:!0,force:!0})},[E,J,T,D]),Lt=i.useCallback(o=>{V.current.length>=ne.current&&ne.current<pn&&M(Ge(ne.current+1,Q.current)),$e(o)},[M]),Tt=i.useCallback(()=>{$e(null),M(Ge(V.current.length,Q.current))},[M]),Et=i.useCallback((o,h)=>{J(o,h);const u=o.agent||"";V.current.some(x=>x.agent===u&&x.sessionId===o.sessionId)&&M(Ge(V.current.length,Q.current)),$e(null),i.startTransition(()=>{pt({agent:u,sessionId:o.sessionId,workdir:h})})},[J,M]),Mt=i.useCallback((o,h)=>{J({agent:o.agent,sessionId:o.sessionId,runState:"running"},o.workdir),i.startTransition(()=>{h!=null?(T(u=>{if(h>=u.length)return u;const x=[...u],b=u[h],k=b.agent===o.agent&&ct(b.sessionId)&&!ct(o.sessionId);return x[h]={...b,agent:o.agent,sessionId:o.sessionId,workdir:o.workdir,mountKey:k?b.mountKey:vt(),pendingPrompt:k?b.pendingPrompt:null,pendingImageUrls:k?b.pendingImageUrls:void 0},x}),D(h)):pt({...o,mountKey:vt()})}),E(o.workdir,{background:!0,force:!0})},[E,J]),he=i.useCallback(o=>{let h=o;if(re==="running"?h=h.filter(u=>Dt(u)==="running"):re==="review"&&(h=h.filter(u=>Dt(u)==="incomplete")),ve.trim()){const u=ve.toLowerCase();h=h.filter(x=>(x.lastMessageText||"").toLowerCase().includes(u)||(x.lastQuestion||"").toLowerCase().includes(u)||(x.lastAnswer||"").toLowerCase().includes(u)||(x.title||"").toLowerCase().includes(u)||(x.agent||"").toLowerCase().includes(u))}return h},[ve,re]),At=i.useMemo(()=>{const o={};for(const h of c){const u=(d[h.path]||[]).map(Fe),x=Le[h.path],b=new Map;for(const S of u){const _=q(S.agent||"",S.sessionId),U=be[_],W=x?In(x,S.agent||"",S.sessionId):S.sessionId,F=U?.resolvedKey&&U.resolvedKey!==_?U.resolvedKey:W!==S.sessionId?q(S.agent||"",W):_,Re=b.get(F);if(!Re){b.set(F,S);continue}q(Re.agent||"",Re.sessionId)!==F&&_===F&&b.set(F,S)}const k=he([...b.values()]);o[h.path]=to(k)}return o},[c,d,be,Le,he,Fe]),gt=i.useCallback(o=>{const h=(d[o.workdir]||[]).find(u=>u.sessionId===o.sessionId&&u.agent===o.agent)??{sessionId:o.sessionId,agent:o.agent,runState:"running"};return Fe(h)},[Fe,d]),Yt=i.useMemo(()=>new Set(P.map(o=>q(o.agent,o.sessionId))),[P]),Xt=me?q(me.agent,me.sessionId):null,it=i.useCallback(o=>{T(h=>{const u=h.filter((x,b)=>b!==o);return u.length===0?D(0):pe.current>=u.length&&D(u.length-1),M(Ge(u.length,Q.current)),u})},[T,D,M]);return e.jsxs("div",{className:"h-full overflow-hidden p-4 flex gap-3 mx-auto",children:[e.jsxs("div",{className:"panel-isolated w-[252px] shrink-0 flex flex-col overflow-hidden rounded-xl border border-edge bg-panel backdrop-blur-sm",style:{boxShadow:"var(--th-card-shadow)"},children:[e.jsxs("div",{className:"px-3 pt-3 pb-2 space-y-2",children:[e.jsxs("div",{className:"relative group",children:[e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-fg-5/40 group-focus-within:text-fg-4 transition-colors",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("input",{value:Oe,onChange:o=>Xe(o.target.value),placeholder:r("hub.search"),className:"w-full rounded-lg border border-edge/40 bg-inset/50 pl-8 pr-7 py-1.5 text-[12px] text-fg outline-none placeholder:text-fg-5/30 focus:border-primary/30 focus:bg-inset focus:shadow-[0_0_0_3px_rgba(99,102,241,0.06)] transition-all duration-200"}),Oe&&e.jsx("button",{onClick:()=>Xe(""),className:"absolute right-2 top-1/2 -translate-y-1/2 p-0.5 rounded text-fg-5/30 hover:text-fg-4 transition-colors",children:e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.jsx("div",{className:"flex items-center rounded-lg bg-inset/30 border border-edge/20 p-0.5",children:["all","running","review"].map(o=>e.jsx("button",{onClick:()=>De(o),className:C("flex-1 px-2 py-[5px] rounded-md text-[11px] font-medium transition-all duration-200",re===o?"bg-panel-h text-fg-2 shadow-[0_1px_2px_rgba(0,0,0,0.1),inset_0_1px_0_rgba(255,255,255,0.04)]":"text-fg-5/60 hover:text-fg-4"),children:r(`hub.filter${o[0].toUpperCase()+o.slice(1)}`)},o))})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:j?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ge,{className:"h-4 w-4 text-fg-5"})}):c.length===0&&!Qe?e.jsx("div",{className:"py-12 text-center text-[13px] text-fg-5",children:r("hub.noWorkspaces")}):c.map(o=>e.jsx(ho,{workspace:o,sessions:At[o.path]||[],loading:!!v[o.path]||!(o.path in d),isActive:o.path===a,removable:o.removable!==!1,selectedKey:Xt,openSessionKeys:Yt,onSelectSession:Et,onNewSession:Lt,onRefresh:st,onRemove:tt,onExtensions:Ue,onWarmSession:Nt,onCancelWarmSession:Me,onSessionMenuOpen:Ct,t:r},o.path))}),e.jsxs("div",{className:"shrink-0 border-t border-edge/20 px-3 py-2 space-y-1.5",children:[e.jsx("div",{className:"flex items-center rounded-md bg-inset/30 border border-edge/20 p-0.5",children:[1,2,3,6].map(o=>e.jsx("button",{onClick:()=>I(o),className:C("flex-1 flex items-center justify-center p-1.5 rounded transition-all",N===o?"bg-panel-h text-fg-2 shadow-[0_1px_2px_rgba(0,0,0,0.1)]":"text-fg-5/40 hover:text-fg-4"),title:r(`hub.layout${o}`),children:o===1?e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"1.5"})}):o===2?e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("rect",{x:"1",y:"2",width:"6",height:"12",rx:"1.5"}),e.jsx("rect",{x:"9",y:"2",width:"6",height:"12",rx:"1.5"})]}):o===3?e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("rect",{x:"0.5",y:"2",width:"4",height:"12",rx:"1"}),e.jsx("rect",{x:"6",y:"2",width:"4",height:"12",rx:"1"}),e.jsx("rect",{x:"11.5",y:"2",width:"4",height:"12",rx:"1"})]}):e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.2",children:[e.jsx("rect",{x:"0.5",y:"1",width:"4",height:"5.5",rx:"0.8"}),e.jsx("rect",{x:"6",y:"1",width:"4",height:"5.5",rx:"0.8"}),e.jsx("rect",{x:"11.5",y:"1",width:"4",height:"5.5",rx:"0.8"}),e.jsx("rect",{x:"0.5",y:"9.5",width:"4",height:"5.5",rx:"0.8"}),e.jsx("rect",{x:"6",y:"9.5",width:"4",height:"5.5",rx:"0.8"}),e.jsx("rect",{x:"11.5",y:"9.5",width:"4",height:"5.5",rx:"0.8"})]})},o))}),e.jsxs(We,{variant:"ghost",size:"sm",onClick:()=>Ye(o=>!o),className:"w-full",children:[e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),r("hub.addWorkspace")]})]})]}),e.jsx("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden gap-0",children:e.jsx("div",{className:"flex-1 min-h-0 grid gap-3",style:{gridTemplateColumns:`repeat(${N===6?3:N}, 1fr)`,gridTemplateRows:N===6?"repeat(2, 1fr)":"1fr"},children:(()=>{const o=se?P.length<N?P.length:H:-1;return wt.current=o,Array.from({length:N},(h,u)=>{if(se&&u===o)return e.jsx("div",{className:"min-w-0 overflow-hidden rounded-xl border border-edge bg-panel flex flex-col",style:{boxShadow:"var(--th-card-shadow)"},children:e.jsx(co,{workdir:se,workspaceName:c.find(S=>S.path===se)?.name||se.split("/").pop()||"",onSessionCreated:Ke,onClose:Tt,t:r},se)},`new-${se}`);const x=P[u]??null;if(!x)return e.jsx("div",{className:"min-w-0 overflow-hidden rounded-xl border border-dashed border-edge/40 bg-panel/30 flex items-center justify-center",children:e.jsxs("div",{className:"text-center px-4",children:[e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",className:"mx-auto text-fg-5/20 mb-2",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"16"}),e.jsx("line",{x1:"8",y1:"12",x2:"16",y2:"12"})]}),e.jsx("div",{className:"text-[12px] text-fg-5/40",children:r("hub.emptySlot")})]})},`empty-${u}`);const b=gt(x),k=u===H;return e.jsxs("div",{className:C("min-w-0 overflow-hidden rounded-xl border bg-panel flex flex-col transition-[border-color,box-shadow] duration-200",k?"border-primary/40 ring-[3px] ring-primary/[0.06]":"border-edge hover:border-edge-h"),style:{boxShadow:k?"var(--th-card-shadow), 0 0 0 1px rgba(14,165,233,0.08)":"var(--th-card-shadow)"},onClick:()=>D(u),children:[e.jsxs("div",{className:C("shrink-0 flex items-center gap-2 px-2.5 h-8 border-b border-edge/30",k?"bg-primary/[0.03]":"bg-panel/60"),children:[(()=>{const S=Dt(b);return e.jsx(Gt,{variant:S==="running"?"ok":S==="waiting"?"info":S==="incomplete"?"warn":"idle",pulse:S==="running"||S==="waiting"})})(),e.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-0",children:[e.jsx("span",{className:"shrink-0 text-[10px] font-medium text-fg-5",children:x.workdir.split("/").pop()||x.workdir}),e.jsx("span",{className:"shrink-0 text-fg-6 text-[10px] mx-1",children:"/"}),e.jsx("span",{className:"min-w-0 truncate text-[11px] font-medium text-fg-3",children:b.title||b.lastQuestion?.slice(0,60)||(ct(x.sessionId)?r("hub.newSession"):x.sessionId.slice(0,12))})]}),e.jsxs("div",{className:"shrink-0 flex items-center gap-2.5 pl-4 text-[9px] text-fg-5/50 tabular-nums",children:[e.jsx("span",{title:r("hub.created"),children:Is(b.createdAt)}),b.runUpdatedAt&&e.jsx("span",{title:r("hub.updated"),children:Wn(b.runUpdatedAt)}),!!b.numTurns&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"opacity-60",children:e.jsx("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"})}),b.numTurns]}),e.jsx("button",{"data-filetree-toggle":!0,onClick:S=>{S.stopPropagation(),R(_=>!_)},className:C("p-0.5 rounded transition-colors",Z?"text-fg-3 bg-panel-h":"text-fg-5/40 hover:text-fg-3 hover:bg-panel-h"),title:r("hub.files"),children:e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M2 6a2 2 0 012-2h5l2 2h9a2 2 0 012 2v10a2 2 0 01-2 2H4a2 2 0 01-2-2V6z"})})}),e.jsx("button",{onClick:S=>{S.stopPropagation(),it(u)},className:"p-0.5 rounded text-fg-5/40 hover:text-fg-2 hover:bg-panel-h transition-colors",title:r("hub.closePanel"),children:e.jsxs("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(i.Suspense,{fallback:e.jsx("div",{className:"h-full"}),children:e.jsx(Yr,{session:b,workdir:x.workdir,active:n&&k,onSessionChange:S=>Mt(S,u),initialPendingPrompt:x.pendingPrompt??null,initialPendingImageUrls:x.pendingImageUrls,onPendingPromptConsumed:()=>It(x.mountKey)},x.mountKey)})})]},x.mountKey||q(x.agent,x.sessionId))})})()})}),Z&&me&&e.jsx(xo,{workdir:me.workdir,onClose:()=>R(!1),t:r}),e.jsx(lo,{open:Qe,initialPath:a||void 0,onAdd:Qt,onClose:()=>Ye(!1),t:r}),e.jsxs(Kt,{open:!!fe,onClose:()=>!ye&&ke(null),children:[e.jsx(Ht,{title:r("hub.removeWorkspace"),onClose:()=>!ye&&ke(null)}),e.jsx("div",{className:"text-[13px] text-fg-3 leading-relaxed",children:r("modal.confirmRemoveWorkspace")}),e.jsx("div",{className:"mt-1 text-[12px] text-fg-5",children:r("modal.confirmRemoveWorkspaceHint")}),fe&&e.jsx("div",{className:"mt-3 rounded-md bg-inset/50 border border-edge/30 px-3 py-2 font-mono text-[11px] text-fg-4 break-all",children:fe}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx(We,{variant:"ghost",onClick:()=>ke(null),disabled:ye,children:r("modal.cancel")}),e.jsx(We,{variant:"primary",onClick:nt,disabled:ye,className:"!bg-red-500/90 !border-red-500/50 hover:!bg-red-500 !text-white",children:r(ye?"modal.removing":"modal.remove")})]})]}),ae&&(()=>{const h=Math.max(8,Math.min(ae.anchor.right-160,window.innerWidth-160-8)),u=Math.min(ae.anchor.bottom+4,window.innerHeight-60);return e.jsx("div",{className:"fixed z-[60] min-w-[160px] rounded-md border border-edge bg-panel/95 backdrop-blur-md py-1",style:{left:h,top:u,boxShadow:"0 8px 24px rgba(0,0,0,0.20), 0 2px 6px rgba(0,0,0,0.10)"},onMouseDown:x=>x.stopPropagation(),role:"menu",children:e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>ft(ae.target),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left text-[12px] text-fg-2 hover:bg-panel-h/60 hover:text-red-400 transition-colors",children:[e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("path",{d:"M19 6l-1 14a2 2 0 01-2 2H8a2 2 0 01-2-2L5 6"}),e.jsx("path",{d:"M10 11v6"}),e.jsx("path",{d:"M14 11v6"}),e.jsx("path",{d:"M9 6V4a2 2 0 012-2h2a2 2 0 012 2v2"})]}),r("session.delete")]})})})(),e.jsxs(Kt,{open:!!Ae,onClose:()=>!ue&&Ne(null),children:[e.jsx(Ht,{title:r("session.deleteTitle"),onClose:()=>!ue&&Ne(null)}),e.jsx("div",{className:"text-[13px] text-fg-3 leading-relaxed",children:r("session.deleteHint")}),Ae&&e.jsxs("div",{className:"mt-3 rounded-md bg-inset/50 border border-edge/30 px-3 py-2 text-[11px] text-fg-4 break-all",children:[e.jsx("span",{className:"font-mono text-fg-5",children:Ae.agent}),e.jsx("span",{className:"mx-1.5 text-fg-5/50",children:"·"}),e.jsx("span",{children:Ae.title})]}),e.jsxs("div",{className:"mt-4 space-y-2",children:[e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"delete-session-scope",checked:!ze,onChange:()=>xt(!1),disabled:ue,className:"mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-[12px] text-fg-2",children:r("session.deletePikiloomOnly")}),e.jsx("div",{className:"text-[11px] text-fg-5 leading-snug mt-0.5",children:r("session.deletePikiloomOnlyHint")})]})]}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"delete-session-scope",checked:ze,onChange:()=>xt(!0),disabled:ue,className:"mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-[12px] text-fg-2",children:r("session.deletePurgeNative")}),e.jsx("div",{className:"text-[11px] text-fg-5 leading-snug mt-0.5",children:r("session.deletePurgeNativeHint")})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx(We,{variant:"ghost",onClick:()=>Ne(null),disabled:ue,children:r("modal.cancel")}),e.jsx(We,{variant:"primary",onClick:Se,disabled:ue,className:"!bg-red-500/90 !border-red-500/50 hover:!bg-red-500 !text-white",children:r(ue?"session.deleting":"modal.remove")})]})]}),e.jsx(Qr,{open:!!de,onClose:()=>Ue(null),workdir:de||""})]})});function lo({open:t,initialPath:n,onAdd:s,onClose:a,t:r}){const[c,p]=i.useState(""),d=i.useCallback(m=>p(m),[]);return i.useEffect(()=>{t&&p("")},[t]),e.jsxs(Kt,{open:t,onClose:a,children:[e.jsx(Ht,{title:r("hub.addWorkspace"),onClose:a}),e.jsx(Ms,{initialPath:n,maxHeight:360,minHeight:200,onSelect:d,t:r}),e.jsxs("div",{className:"flex gap-2 mt-4",children:[e.jsx(We,{disabled:!c,onClick:()=>c&&s(c),className:"flex-1",children:r("hub.add")}),e.jsx(We,{variant:"secondary",onClick:a,className:"flex-1",children:r("hub.cancel")})]})]})}function co({workdir:t,workspaceName:n,onSessionCreated:s,onClose:a,t:r}){const[c,p]=i.useState(null),[d,m]=i.useState([]),v=i.useRef(null),g=i.useRef([]),j=i.useMemo(()=>({sessionId:"",agent:"",runState:"completed"}),[]),y=i.useCallback(()=>{},[]),N=i.useCallback((A,P)=>{p(A||null),v.current=A||null;const z=P||[];m(z),g.current=z},[]),$=i.useCallback(A=>{const P=g.current;g.current=[],s(A,v.current||void 0,P.length?P:void 0)},[s]),O=!!c||d.length>0;return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-4 h-10 border-b border-edge/50 bg-panel/40 backdrop-blur-md z-10",children:[e.jsx("span",{className:"flex-1 min-w-0 text-[13px] font-medium text-fg truncate",children:r("hub.newSession")}),e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-fg-5/60 shrink-0",children:[e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"opacity-60",children:e.jsx("path",{d:"M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z"})}),e.jsx("span",{className:"max-w-[80px] truncate",children:n})]}),e.jsx(Gt,{variant:O?"ok":"idle",pulse:O}),!O&&e.jsx("button",{onClick:a,className:"p-1 rounded text-fg-5 hover:text-fg-2 transition-colors",children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:O?e.jsxs("div",{className:"max-w-[900px] mx-auto px-6 py-6 space-y-0",children:[e.jsx(os,{text:c||"",blocks:d.map(A=>({type:"image",content:A})),t:r}),e.jsx("div",{className:"mt-3 mb-4 animate-in",children:e.jsx(ts,{className:"text-fg-5"})})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("div",{className:"text-center space-y-1.5",children:e.jsx("div",{className:"text-[13px] text-fg-5",children:r("hub.newSessionHint")})})})}),e.jsx(xr,{session:j,workdir:t,onStreamQueued:y,onSendStart:N,onSessionChange:$,t:r,streamPhase:null})]})}function uo({git:t}){if(!t)return null;const n=[t.detached?`detached HEAD${t.shortSha?` @ ${t.shortSha}`:""}`:`branch ${t.branch??"?"}`,t.upstream?`upstream ${t.upstream}`:t.detached?"":"no upstream",t.ahead||t.behind?`↑${t.ahead} ahead · ↓${t.behind} behind`:"",t.changed>0?`${t.changed} changed (${t.staged} staged · ${t.unstaged} unstaged · ${t.untracked} untracked)`:"clean"].filter(Boolean).join(`
23
23
  `);return e.jsx(Ls,{content:n,className:C("shrink-0 items-center",t.changed>0?"text-amber-400/80":t.ahead||t.behind?"text-sky-400/70":"text-fg-5/50"),onClick:s=>s.stopPropagation(),children:e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"6",cy:"6",r:"2.5"}),e.jsx("circle",{cx:"6",cy:"18",r:"2.5"}),e.jsx("circle",{cx:"18",cy:"8",r:"2.5"}),e.jsx("path",{d:"M6 8.5v7"}),e.jsx("path",{d:"M18 10.5c0 4.5-6 3-6 7.5"})]})})}const ho=i.memo(function({workspace:n,sessions:s,loading:a,isActive:r,selectedKey:c,openSessionKeys:p,onSelectSession:d,onNewSession:m,onRefresh:v,onRemove:g,onExtensions:j,removable:y,onWarmSession:N,onCancelWarmSession:$,onSessionMenuOpen:O,t:A}){const[P,z]=i.useState(!0),[H,Y]=i.useState(cn);i.useEffect(()=>{Y(cn)},[s.length]);const M=s.slice(0,H),te=s.length-H,T=n.path,[D,I]=i.useState(null),Z=i.useCallback(()=>{ie.getWorkspaceGit(T).then(R=>I(R.git)).catch(()=>I(null))},[T]);return i.useEffect(()=>{Z()},[Z]),e.jsxs("div",{className:"border-b border-edge/30",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 cursor-pointer hover:bg-panel-h/50 transition-colors",onClick:()=>z(R=>!R),children:[e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:C("shrink-0 text-fg-5 transition-transform duration-150",P&&"rotate-90"),children:e.jsx("polyline",{points:"9 6 15 12 9 18"})}),e.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-1.5",children:[e.jsx("span",{className:C("min-w-0 truncate text-[12px] font-semibold",r?"text-primary":"text-fg-3"),children:n.name}),e.jsx(uo,{git:D})]}),r&&e.jsx(Gt,{variant:"ok"}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{onClick:R=>{R.stopPropagation(),m(T)},className:"p-1 rounded text-fg-5 hover:text-primary hover:bg-panel-h/60 transition-colors",title:A("hub.newSession"),children:e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}),e.jsx("button",{onClick:R=>{R.stopPropagation(),j(T)},className:"p-1 rounded text-fg-5 hover:text-primary hover:bg-panel-h/60 transition-colors",title:A("hub.extensions"),children:e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 22v-5"}),e.jsx("path",{d:"M9 8V2"}),e.jsx("path",{d:"M15 8V2"}),e.jsx("path",{d:"M18 8v5a6 6 0 0 1-12 0V8z"})]})}),e.jsx("button",{onClick:R=>{R.stopPropagation(),v(T),Z()},className:"p-1 rounded text-fg-5 hover:text-fg-2 hover:bg-panel-h/60 transition-colors",children:e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[e.jsx("polyline",{points:"23 4 23 10 17 10"}),e.jsx("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})}),y&&!r&&e.jsx("button",{onClick:R=>{R.stopPropagation(),g(T)},className:"p-1 rounded text-fg-5 hover:text-red-400 hover:bg-panel-h/60 transition-colors",title:A("hub.removeWorkspace"),children:e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),P&&e.jsx("div",{className:"pb-1",children:a?e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(ge,{className:"h-3 w-3 text-fg-5"})}):s.length===0?e.jsx("div",{className:"py-3 text-center text-[11px] text-fg-5",children:A("sessions.noSessions")}):e.jsxs(e.Fragment,{children:[M.map(R=>{const ne=q(R.agent||"",R.sessionId),Q=R.__forkDepth||0;return e.jsx(po,{session:R,isSelected:c===ne,isOpen:p?.has(ne)??!1,forkDepth:Q,onClick:()=>d(R,T),onWarm:()=>N(R,T),onCancelWarm:()=>$(R,T),onShowMenu:pe=>O(pe,R,T),menuLabel:A("session.openActions")},ne)}),te>0&&e.jsxs("button",{onClick:()=>Y(R=>R+cn),className:"flex items-center gap-1.5 w-full px-3 py-1.5 text-[11px] text-fg-5 hover:text-fg-3 hover:bg-panel-h/50 transition-colors",children:[e.jsxs("span",{children:["+ ",A("hub.nMore").replace("{n}",String(te))]}),e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})]})]})})]})}),po=i.memo(function({session:n,isSelected:s,isOpen:a,forkDepth:r=0,onClick:c,onWarm:p,onCancelWarm:d,onShowMenu:m,menuLabel:v}){const g=dn(n.agent||""),j=Dt(n),y=_n(n).slice(0,500)||(ct(n.sessionId)?"":n.sessionId.slice(0,16)),N=Ts(n,y).slice(0,500),$=n.model?zt(n.model):null,O=r>0?Math.min(r,3)*14:0,A=a?10:12,P=i.useRef(null);return e.jsxs("div",{className:"relative group",children:[e.jsxs("button",{onClick:c,onMouseEnter:p,onFocus:p,onMouseLeave:d,onBlur:d,className:C("w-full pr-3 py-2 text-left transition-all duration-100",s?"bg-selected hover:bg-selected-h":a?"bg-panel-h/30 hover:bg-panel-h/50":"hover:bg-panel-h/50"),style:{paddingLeft:A+O,...a?{borderLeft:`2px solid ${s?g.color:`${g.color}30`}`}:{}},children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-fg-5",children:[r>0&&e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-fg-5/60 shrink-0","aria-label":"Fork",children:[e.jsx("circle",{cx:"6",cy:"6",r:"2"}),e.jsx("circle",{cx:"18",cy:"6",r:"2"}),e.jsx("circle",{cx:"12",cy:"20",r:"2"}),e.jsx("path",{d:"M6 8v3a3 3 0 0 0 3 3h6a3 3 0 0 0 3-3V8"}),e.jsx("path",{d:"M12 14v4"})]}),e.jsx(dt,{brand:n.agent||"",size:10}),e.jsx("span",{className:"font-medium shrink-0",style:{color:g.color},children:g.shortLabel}),$&&e.jsx("span",{className:"truncate max-w-[72px] font-mono text-fg-5/40 text-[9px]",children:$}),e.jsxs("div",{className:"ml-auto flex items-center gap-1.5 shrink-0 transition-opacity group-hover:opacity-0 group-focus-within:opacity-0",children:[!!n.numTurns&&e.jsxs("span",{className:"flex items-center gap-0.5 text-fg-5/50 tabular-nums",children:[e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"opacity-50",children:e.jsx("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"})}),n.numTurns]}),e.jsx("span",{className:"tabular-nums",children:Wn(n.runUpdatedAt||n.createdAt)})]})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx(Gt,{variant:j==="running"?"ok":j==="waiting"?"info":j==="incomplete"?"warn":"idle",pulse:j==="running"||j==="waiting"}),e.jsx("span",{className:"truncate text-[12px] leading-snug text-fg-2",children:y})]}),N&&e.jsx("div",{className:"mt-0.5 pl-[11px]",children:e.jsx("span",{className:"block truncate text-[10px] leading-snug text-fg-5",children:N})})]}),e.jsx("button",{ref:P,type:"button","aria-label":v,"aria-haspopup":"menu",onMouseDown:z=>{z.stopPropagation()},onClick:z=>{z.stopPropagation(),z.preventDefault(),P.current&&m(P.current.getBoundingClientRect())},className:"absolute top-1.5 right-1.5 p-1 rounded text-fg-5 opacity-0 group-hover:opacity-100 focus-visible:opacity-100 hover:bg-panel-h hover:text-fg-2 transition-opacity",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"5",r:"1.5"}),e.jsx("circle",{cx:"12",cy:"12",r:"1.5"}),e.jsx("circle",{cx:"12",cy:"19",r:"1.5"})]})})]})}),xo=i.memo(function({workdir:n,onClose:s,t:a}){const r=le(g=>g.state?.hostApp??null),c=le(g=>g.state?.platform??null),p=le(g=>g.toast),[d,m]=i.useState(()=>io(r,c)),v=i.useCallback(async g=>{try{const j=await ie.openInEditor(g,d);if(!j.ok)throw new Error(j.error||`Failed to open ${g}`)}catch(j){p(j?.message||String(j),!1)}},[d,p]);return e.jsxs("div",{className:"fixed z-50 w-[280px] max-h-[calc(100vh-100px)] flex flex-col rounded-xl border border-edge bg-panel/95 backdrop-blur-md overflow-hidden",style:{boxShadow:"0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.12)",right:16,top:80},children:[e.jsxs("div",{className:"shrink-0 flex items-center gap-1.5 px-2.5 py-1.5 border-b border-edge/30",children:[e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"shrink-0 text-fg-5",children:e.jsx("path",{d:"M2 6a2 2 0 012-2h5l2 2h9a2 2 0 012 2v10a2 2 0 01-2 2H4a2 2 0 01-2-2V6z"})}),e.jsx("span",{className:"flex-1 text-[10px] font-semibold text-fg-4 uppercase tracking-wider",children:a("hub.files")}),e.jsx("button",{onClick:s,className:"p-0.5 rounded text-fg-5/40 hover:text-fg-2 transition-colors",title:a("hub.closePanel"),children:e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.jsxs("div",{className:"shrink-0 px-2.5 py-1.5 border-b border-edge/20 flex items-center gap-2",children:[e.jsx(Es,{value:d,options:(c==="darwin"?["vscode","finder"]:["vscode"]).map(g=>({value:g,label:a(is(g))})),onChange:g=>{oo(g)&&m(g)},renderIcon:g=>e.jsx(as,{target:g,size:14})}),e.jsx(We,{size:"sm",variant:"ghost",onClick:()=>v(n),className:"flex-1 min-w-0 text-[11px]",children:a("hub.openProject")})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-1 py-1.5",children:e.jsx(fo,{basePath:n,openTarget:d,onOpenPath:v,t:a})})]})});function as({target:t,size:n=16}){return t==="default"?e.jsxs("svg",{width:n,height:n,viewBox:"0 0 16 16",className:"shrink-0 text-fg-4",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M6 3H4a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-2"}),e.jsx("path",{d:"M9 2h5v5"}),e.jsx("path",{d:"M14 2L7 9"})]}):e.jsx(dt,{brand:t,size:n})}function fo({basePath:t,includeHidden:n=!1,openTarget:s,onOpenPath:a,t:r}){const[c,p]=i.useState([]),[d,m]=i.useState(!0);i.useEffect(()=>{let g=!1;return m(!0),ie.lsDir(t,!0,n).then(j=>{!g&&j.ok&&p(j.dirs.slice(0,50).map(y=>({entry:y,expanded:!1,children:null,loading:!1})))}).catch(()=>{}).finally(()=>{g||m(!1)}),()=>{g=!0}},[t,n]);const v=i.useCallback(g=>{const j=y=>y.map(N=>N.entry.path===g?N.expanded?{...N,expanded:!1}:N.children===null?(ie.lsDir(g,!0,n).then($=>{$.ok&&p(O=>xn(O,g,{children:$.dirs.slice(0,50).map(A=>({entry:A,expanded:!1,children:null,loading:!1})),loading:!1}))}).catch(()=>{p($=>xn($,g,{children:[],loading:!1}))}),{...N,loading:!0,expanded:!0}):{...N,expanded:!0}:N.children?{...N,children:j(N.children)}:N);p(y=>j(y))},[n]);return d?e.jsx("div",{className:"flex justify-center py-3",children:e.jsx(ge,{className:"h-3 w-3 text-fg-5"})}):c.length===0?e.jsx("div",{className:"py-3 text-center text-[11px] text-fg-5",children:"—"}):e.jsx("div",{className:"space-y-px",children:e.jsx(ls,{nodes:c,depth:0,onToggle:v,openTarget:s,onOpenPath:a,t:r})})}function ls({nodes:t,depth:n,onToggle:s,openTarget:a,onOpenPath:r,t:c}){return e.jsx(e.Fragment,{children:t.map(p=>e.jsx(go,{node:p,depth:n,onToggle:s,openTarget:a,onOpenPath:r,t:c},p.entry.path))})}function go({node:t,depth:n,onToggle:s,openTarget:a,onOpenPath:r,t:c}){const{entry:p,expanded:d,children:m,loading:v}=t,g=n*14,[j,y]=i.useState(!1),N=c(is(a)),$=c("hub.openWithTarget").replace("{target}",N);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{onClick:p.isDir?()=>s(p.path):void 0,onMouseEnter:()=>y(!0),onMouseLeave:()=>y(!1),className:C("flex items-center gap-1.5 py-1 rounded text-[11px] text-fg-3 transition-colors",p.isDir?"hover:bg-panel-h/50 cursor-pointer":"hover:bg-panel-h/50 cursor-default"),style:{paddingLeft:8+g,paddingRight:8},children:[p.isDir?v?e.jsx(ge,{className:"h-2 w-2 text-fg-5 shrink-0"}):e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:C("shrink-0 text-fg-5/40 transition-transform duration-150",d&&"rotate-90"),children:e.jsx("polyline",{points:"9 6 15 12 9 18"})}):e.jsx("span",{className:"w-2 shrink-0"}),p.isDir?e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",className:"shrink-0 text-blue-400/70",children:e.jsx("path",{d:"M2 6a2 2 0 012-2h5l2 2h9a2 2 0 012 2v10a2 2 0 01-2 2H4a2 2 0 01-2-2V6z",fill:"currentColor",opacity:"0.25",stroke:"currentColor",strokeWidth:"1.5"})}):e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"shrink-0 text-fg-5",children:[e.jsx("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]}),e.jsx("span",{className:"truncate flex-1",children:p.name}),j&&e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e.jsx("button",{onClick:O=>{O.stopPropagation(),r(p.path)},className:"inline-flex items-center gap-1 rounded px-1 py-0.5 text-fg-5 hover:text-blue-400 transition-colors",title:$,children:e.jsx(as,{target:a,subtle:!0})}),!p.isDir&&e.jsx(mo,{filePath:p.path,t:c})]})]}),p.isDir&&d&&m&&m.length>0&&e.jsx(ls,{nodes:m,depth:n+1,onToggle:s,openTarget:a,onOpenPath:r,t:c})]})}function mo({filePath:t,t:n}){const[s,a]=i.useState(!1);return e.jsx("button",{onClick:r=>{r.stopPropagation(),navigator.clipboard.writeText(t).then(()=>{a(!0),setTimeout(()=>a(!1),1500)}).catch(()=>{})},className:C("p-0.5 rounded transition-colors",s?"text-ok":"text-fg-5 hover:text-fg-3"),title:n("hub.copied"),children:s?e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}):e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]})})}function xn(t,n,s){return t.map(a=>a.entry.path===n?{...a,...s}:a.children?{...a,children:xn(a.children,n,s)}:a)}const $o=Object.freeze(Object.defineProperty({__proto__:null,SessionWorkspace:ao},Symbol.toStringTag,{value:"Module"}));export{xr as I,Wo as L,Ir as R,Bo as T,os as U,Po as a,es as b,Ks as c,Lo as d,Vs as e,Eo as f,Hs as g,jt as h,Mo as i,_o as j,To as k,Fs as l,Ro as m,Ao as n,Io as o,Ds as p,_r as q,ts as r,Co as s,Vr as t,Mr as u,$o as v};