tide-commander 1.85.0 → 1.86.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{BossLogsModal-uPeGcb3I.js → BossLogsModal-BB1vCM5J.js} +1 -1
- package/dist/assets/{BossSpawnModal-D7iyXoJq.js → BossSpawnModal-wMLySpgn.js} +1 -1
- package/dist/assets/{ControlsModal-DXnnGYp5.js → ControlsModal-BklEN7j8.js} +1 -1
- package/dist/assets/{DockerLogsModal-DxmUWbDV.js → DockerLogsModal-B49O9xcw.js} +1 -1
- package/dist/assets/{EmbeddedEditor-BUi6dUs3.js → EmbeddedEditor-BX9aBsiv.js} +1 -1
- package/dist/assets/{GmailOAuthSetup-iCnmfNtc.js → GmailOAuthSetup-BzB4QGx5.js} +1 -1
- package/dist/assets/{GoogleOAuthSetup-BPMmX5ua.js → GoogleOAuthSetup-4nw4iS8V.js} +1 -1
- package/dist/assets/{IframeModal-CVJjFAPp.js → IframeModal-DGXje5GK.js} +1 -1
- package/dist/assets/{IntegrationsPanel-DpQUsPg2.js → IntegrationsPanel-CjtCtu7-.js} +2 -2
- package/dist/assets/{LogViewerModal-tBZ1aP8p.js → LogViewerModal-CnOV3Ai5.js} +1 -1
- package/dist/assets/{MonitoringModal-B4A0qczU.js → MonitoringModal-VwORpB9L.js} +1 -1
- package/dist/assets/{PM2LogsModal-i7fxasp0.js → PM2LogsModal-8bnD0XcQ.js} +1 -1
- package/dist/assets/{RestoreArchivedAreaModal-UurWP1-j.js → RestoreArchivedAreaModal-BhwpPzFY.js} +1 -1
- package/dist/assets/{Scene2DCanvas-B9DuBLip.js → Scene2DCanvas-DaRWkux-.js} +1 -1
- package/dist/assets/{SceneManager-xEBRq68j.js → SceneManager-CKz-v1rU.js} +1 -1
- package/dist/assets/{SkillsPanel-BDyKxve4.js → SkillsPanel-l0DKbOtc.js} +2 -2
- package/dist/assets/{SpawnModal-CBKT43_l.js → SpawnModal-DEAh9hdW.js} +1 -1
- package/dist/assets/{SubordinateAssignmentModal-CddDPiHW.js → SubordinateAssignmentModal-CczaDW9_.js} +1 -1
- package/dist/assets/{TriggerManagerPanel-CcVCNnhm.js → TriggerManagerPanel-aczhr8bG.js} +1 -1
- package/dist/assets/{WorkflowEditorPanel-C5meCq60.js → WorkflowEditorPanel-Pp473-yC.js} +1 -1
- package/dist/assets/index-BrntsiFl.js +2 -0
- package/dist/assets/{index-CQll-mer.js → index-Bsu-4DMd.js} +2 -2
- package/dist/assets/{index-CrpntCm1.js → index-CfEa34G0.js} +5 -5
- package/dist/assets/{index-DtDo7QHt.js → index-CsZl2cpZ.js} +3 -3
- package/dist/assets/{index-BNQjdC7D.js → index-DAsa2Q29.js} +3 -3
- package/dist/assets/{index-huFbdygq.js → index-DEEA8DzD.js} +1 -1
- package/dist/assets/{index-BfUS9DYN.js → index-Da106QNu.js} +1 -1
- package/dist/assets/{index-JUHUy-Tv.js → index-VOQ8B_0s.js} +1 -1
- package/dist/assets/{index-C7Mu39PP.js → index-bumMaJlF.js} +1 -1
- package/dist/assets/{main-Q3uQGSTr.js → main-D2EQVTAu.js} +41 -41
- package/dist/assets/{web-ko2U5w1Z.js → web-Bdm2kdQ5.js} +1 -1
- package/dist/assets/web-CZQVhlQA.js +1 -0
- package/dist/assets/{web-_0kug6fn.js → web-DlbC6v-L.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +2 -1
- package/dist/assets/index-D_wtUWqj.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ck as a}from"./main-D2EQVTAu.js";import{ImpactStyle as i,NotificationType as r}from"./index-Bsu-4DMd.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";class h extends a{constructor(){super(...arguments),this.selectionStarted=!1}async impact(t){const e=this.patternForImpact(t==null?void 0:t.style);this.vibrateWithPattern(e)}async notification(t){const e=this.patternForNotification(t==null?void 0:t.type);this.vibrateWithPattern(e)}async vibrate(t){const e=(t==null?void 0:t.duration)||300;this.vibrateWithPattern([e])}async selectionStart(){this.selectionStarted=!0}async selectionChanged(){this.selectionStarted&&this.vibrateWithPattern([70])}async selectionEnd(){this.selectionStarted=!1}patternForImpact(t=i.Heavy){return t===i.Medium?[43]:t===i.Light?[20]:[61]}patternForNotification(t=r.Success){return t===r.Warning?[30,40,30,50,60]:t===r.Error?[27,45,50]:[35,65,21]}vibrateWithPattern(t){if(navigator.vibrate)navigator.vibrate(t);else throw this.unavailable("Browser does not support the vibrate API")}}export{h as HapticsWeb};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ck as t}from"./main-D2EQVTAu.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";class o extends t{constructor(){super(),this.handleVisibilityChange=()=>{const e={isActive:document.hidden!==!0};this.notifyListeners("appStateChange",e),document.hidden?this.notifyListeners("pause",null):this.notifyListeners("resume",null)},document.addEventListener("visibilitychange",this.handleVisibilityChange,!1)}exitApp(){throw this.unimplemented("Not implemented on web.")}async getInfo(){throw this.unimplemented("Not implemented on web.")}async getLaunchUrl(){return{url:""}}async getState(){return{isActive:document.hidden!==!0}}async minimizeApp(){throw this.unimplemented("Not implemented on web.")}async toggleBackButtonHandler(){throw this.unimplemented("Not implemented on web.")}async getAppLanguage(){return{value:navigator.language.split("-")[0].toLowerCase()}}}export{o as AppWeb};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ck as s}from"./main-D2EQVTAu.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";class l extends s{constructor(){super(...arguments),this.pending=[],this.deliveredNotifications=[],this.hasNotificationSupport=()=>{if(!("Notification"in window)||!Notification.requestPermission)return!1;if(Notification.permission!=="granted")try{new Notification("")}catch(i){if(i instanceof Error&&i.name==="TypeError")return!1}return!0}}async getDeliveredNotifications(){const i=[];for(const t of this.deliveredNotifications){const e={title:t.title,id:parseInt(t.tag),body:t.body};i.push(e)}return{notifications:i}}async removeDeliveredNotifications(i){for(const t of i.notifications){const e=this.deliveredNotifications.find(n=>n.tag===String(t.id));e==null||e.close(),this.deliveredNotifications=this.deliveredNotifications.filter(()=>!e)}}async removeAllDeliveredNotifications(){for(const i of this.deliveredNotifications)i.close();this.deliveredNotifications=[]}async createChannel(){throw this.unimplemented("Not implemented on web.")}async deleteChannel(){throw this.unimplemented("Not implemented on web.")}async listChannels(){throw this.unimplemented("Not implemented on web.")}async schedule(i){if(!this.hasNotificationSupport())throw this.unavailable("Notifications not supported in this browser.");for(const t of i.notifications)this.sendNotification(t);return{notifications:i.notifications.map(t=>({id:t.id}))}}async getPending(){return{notifications:this.pending}}async registerActionTypes(){throw this.unimplemented("Not implemented on web.")}async cancel(i){this.pending=this.pending.filter(t=>!i.notifications.find(e=>e.id===t.id))}async areEnabled(){const{display:i}=await this.checkPermissions();return{value:i==="granted"}}async changeExactNotificationSetting(){throw this.unimplemented("Not implemented on web.")}async checkExactNotificationSetting(){throw this.unimplemented("Not implemented on web.")}async requestPermissions(){if(!this.hasNotificationSupport())throw this.unavailable("Notifications not supported in this browser.");return{display:this.transformNotificationPermission(await Notification.requestPermission())}}async checkPermissions(){if(!this.hasNotificationSupport())throw this.unavailable("Notifications not supported in this browser.");return{display:this.transformNotificationPermission(Notification.permission)}}transformNotificationPermission(i){switch(i){case"granted":return"granted";case"denied":return"denied";default:return"prompt"}}sendPending(){var i;const t=[],e=new Date().getTime();for(const n of this.pending)!((i=n.schedule)===null||i===void 0)&&i.at&&n.schedule.at.getTime()<=e&&(this.buildNotification(n),t.push(n));this.pending=this.pending.filter(n=>!t.find(o=>o===n))}sendNotification(i){var t;if(!((t=i.schedule)===null||t===void 0)&&t.at){const e=i.schedule.at.getTime()-new Date().getTime();this.pending.push(i),setTimeout(()=>{this.sendPending()},e);return}this.buildNotification(i)}buildNotification(i){const t=new Notification(i.title,{body:i.body,tag:String(i.id)});return t.addEventListener("click",this.onClick.bind(this,i),!1),t.addEventListener("show",this.onShow.bind(this,i),!1),t.addEventListener("close",()=>{this.deliveredNotifications=this.deliveredNotifications.filter(()=>!this)},!1),this.deliveredNotifications.push(t),t}onClick(i){const t={actionId:"tap",notification:i};this.notifyListeners("localNotificationActionPerformed",t)}onShow(i){this.notifyListeners("localNotificationReceived",i)}}export{l as LocalNotificationsWeb};
|
package/dist/index.html
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
<link rel="icon" type="image/png" sizes="16x16" href="/assets/icons/favicon-16x16.png" />
|
|
23
23
|
<link rel="apple-touch-icon" sizes="180x180" href="/assets/icons/apple-touch-icon.png" />
|
|
24
24
|
<title>Tide Commander</title>
|
|
25
|
-
<script type="module" crossorigin src="/assets/main-
|
|
25
|
+
<script type="module" crossorigin src="/assets/main-D2EQVTAu.js"></script>
|
|
26
26
|
<link rel="modulepreload" crossorigin href="/assets/vendor-react--Eh9ivFN.js">
|
|
27
27
|
<link rel="modulepreload" crossorigin href="/assets/vendor-three-Chj50gSY.js">
|
|
28
28
|
<link rel="stylesheet" crossorigin href="/assets/main-kpU9m5LW.css">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tide-commander",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.86.0",
|
|
4
4
|
"description": "Visual multi-agent orchestrator and manager for Claude Code with 3D/2D interface",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@anthropic-ai/sdk": "^0.81.0",
|
|
44
|
+
"@capacitor/app": "^8.1.0",
|
|
44
45
|
"@capacitor/haptics": "^8.0.1",
|
|
45
46
|
"@capacitor/local-notifications": "^8.0.1",
|
|
46
47
|
"@codemirror/lang-cpp": "^6.0.3",
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as a,u as Ot,z as nn,j as e,V as an,B as sn,E as ln,G as St,S as k,H as Et,J as jt,K as Mt,L as ct,M as se,N as rn,s as h,O as $t,P as Bt,U as on,v as Tt,w as Pt,I as u,W as cn,m as dn,X as un,Y as Ft,Z as Wt,_ as pn,$ as mn,a0 as fn,a1 as hn,a2 as gn,a3 as xn,a4 as bn,a5 as _n,a6 as wn,a7 as Cn,a8 as Lt,C as vn,a9 as jn,aa as Nn,ab as kn,ac as yn,ad as In,ae as An,af as Sn,ag as En,ah as Mn,ai as Tn,aj as Pn,ak as Ln,al as Rn,am as Dn,an as zn,ao as On}from"./main-Q3uQGSTr.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const $n=a.memo(function({className:c=""}){const{t:I}=Ot(["common"]),[A,T]=nn(),Y=a.useRef(null),[H,ie]=a.useState(null);a.useLayoutEffect(()=>{const C=Y.current;if(!C)return;const Z=C.querySelector(".view-mode-toggle__btn--active");Z&&ie({left:Z.offsetLeft,width:Z.offsetWidth})},[A]);const E=a.useCallback(C=>{if(C!==A){if(typeof window<"u"&&window.dispatchEvent(new CustomEvent("tide:viewmode-switch-pressed",{detail:{mode:C}})),C==="3d"){requestAnimationFrame(()=>T(C));return}T(C)}},[A,T]);return e.jsxs("div",{className:`view-mode-toggle ${c}`,ref:Y,children:[H&&e.jsx("div",{className:"view-mode-toggle__indicator",style:{left:H.left,width:H.width}}),an.map(C=>e.jsxs("button",{className:`view-mode-toggle__btn ${A===C?"view-mode-toggle__btn--active":""}`,onClick:()=>E(C),title:I(`common:viewMode.descriptions.${C}`),children:[e.jsxs("span",{className:"view-mode-toggle__icon",children:[C==="2d"&&e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),e.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"21"})]}),C==="3d"&&e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),e.jsx("path",{d:"M2 17l10 5 10-5"}),e.jsx("path",{d:"M2 12l10 5 10-5"})]}),C==="flat"&&e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"3",width:"8",height:"8",rx:"1"}),e.jsx("rect",{x:"13",y:"3",width:"8",height:"8",rx:"1"}),e.jsx("rect",{x:"3",y:"13",width:"8",height:"8",rx:"1"}),e.jsx("rect",{x:"13",y:"13",width:"8",height:"8",rx:"1"})]}),C==="dashboard"&&e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"9",rx:"1"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"5",rx:"1"}),e.jsx("rect",{x:"14",y:"12",width:"7",height:"9",rx:"1"}),e.jsx("rect",{x:"3",y:"16",width:"7",height:"5",rx:"1"})]})]}),e.jsx("span",{className:"view-mode-toggle__label",children:I(`common:viewMode.labels.${C}`)})]},C))]})}),dt=3,ut=280,Rt=320,vt=240,Dt=64,Bn=["simple","chat","advanced"],Fn={simple:"Simple",chat:"Chat",advanced:"Advanced"},Wn={simple:"○",chat:"◐",advanced:"◉"},Hn={simple:"Simple view — clean messages only",chat:"Chat view — assistant replies (no tool calls)",advanced:"Advanced view — everything including tools"},zt="flat-clear-context";function Vn(_){const c=_.split("/").filter(Boolean);return c.length===0?_:c.slice(-2).join("/")}function Gn(_){if(_.provider==="codex"){const Y=_.codexModel||"gpt-5.3-codex",H=Dn[Y];return{model:(H==null?void 0:H.label)||Y}}if(_.provider==="opencode")return{model:_.opencodeModel||"opencode"};const c=_.model||"sonnet",I=On[c],A=_.effort,T=A?zn[A]:void 0;return{model:(I==null?void 0:I.label)||c,effort:T==null?void 0:T.label}}function Xn(_,c){if(c.type==="rectangle"&&c.width&&c.height){const I=c.width/2,A=c.height/2;return _.x>=c.center.x-I&&_.x<=c.center.x+I&&_.z>=c.center.z-A&&_.z<=c.center.z+A}if(c.type==="circle"&&c.radius){const I=_.x-c.center.x,A=_.z-c.center.z;return I*I+A*A<=c.radius*c.radius}return!1}const Un=jn.memo(function({agentId:c,terminalViewMode:I,onTerminalViewModeChange:A,inspectorOpen:T,onToggleInspector:Y,onImageClick:H,onFileClick:ie,onBashClick:E,onViewMarkdown:C,onRequestClearSubordinates:Z,onOpenBuilding:Re,keyboard:Ve,canNavigateBack:Ge,canNavigateForward:De,onNavigateBack:le,onNavigateForward:D,agentInfoOpen:ye,onToggleAgentInfo:J}){var Me,ne,nt,F;const g=Nn(c),P=Bt(),me=a.useRef(null),Ie=a.useRef(null);a.useEffect(()=>{const i=Ie.current;if(!i)return;const r=o=>{o.button===3?(o.preventDefault(),o.stopPropagation(),le()):o.button===4&&(o.preventDefault(),o.stopPropagation(),D())},d=o=>{(o.button===3||o.button===4)&&o.preventDefault()};return i.addEventListener("mouseup",r),i.addEventListener("mousedown",d),()=>{i.removeEventListener("mouseup",r),i.removeEventListener("mousedown",d)}},[le,D]),a.useEffect(()=>{const i=Ie.current;if(!i)return;let r=0,d=0,o=0;const ve=250,Te=600,Pe=80,xt=1.5,K=O=>{let M=O instanceof HTMLElement?O:null;for(;M&&M!==i;){const We=window.getComputedStyle(M).overflowX;if((We==="auto"||We==="scroll")&&M.scrollWidth>M.clientWidth)return!0;M=M.parentElement}return!1},Le=O=>{const M=Date.now();if(M<o){O.preventDefault();return}if(Math.abs(O.deltaX)<=Math.abs(O.deltaY)*xt){r=0;return}if(K(O.target)){r=0;return}M-d>ve&&(r=0),d=M,r+=O.deltaX,r<=-Pe?(r=0,o=M+Te,O.preventDefault(),le()):r>=Pe&&(r=0,o=M+Te,O.preventDefault(),D())};return i.addEventListener("wheel",Le,{passive:!1}),()=>i.removeEventListener("wheel",Le)},[le,D]);const fe=$t(),ze=a.useMemo(()=>{if(!g)return null;const i=new Set,r=[];for(const d of fe.values())d.archived||d.directories.length===0||d.assignedAgentIds.includes(c)&&(i.add(d.id),r.push(d));for(const d of fe.values())d.archived||d.directories.length===0||i.has(d.id)||Xn({x:g.position.x,z:g.position.z},d)&&(i.add(d.id),r.push(d));return r.length===0?null:r.flatMap(d=>d.directories.filter(o=>o&&o.trim().length>0).map(o=>({areaId:d.id,areaName:d.name,dir:o})))},[g,c,fe]),{branches:Xe,fetchRemote:Ue,fetchingDirs:Oe}=kn(ze),Ae=a.useMemo(()=>{var d;const i=h.getAreaForAgent(c);if(!i)return[];const r=[];for(const o of P.values())o.type==="terminal"&&h.isPositionInArea(o.position,i)&&r.push({id:o.id,name:o.name,hasUrl:!!((d=o.terminalStatus)!=null&&d.url)});return r},[c,P]),he=a.useMemo(()=>{var d;const i=h.getAreaForAgent(c);if(!i)return[];const r=[];for(const o of P.values())o.type==="server"&&((d=o.pm2)!=null&&d.enabled)&&h.isPositionInArea(o.position,i)&&r.push({id:o.id,name:o.name});return r},[c,P]),re=a.useMemo(()=>{const i=h.getAreaForAgent(c);if(!i)return[];const r=[];for(const d of P.values())d.type==="database"&&d.database&&h.isPositionInArea(d.position,i)&&r.push({id:d.id,name:d.name});return r},[c,P]),[,oe]=a.useReducer(i=>i+1,0),V=((Me=me.current)==null?void 0:Me.search.searchMode)??!1,pt=a.useCallback(()=>{var i;(i=me.current)==null||i.search.toggleSearch(),oe()},[]),qe=yn(),ce=qe.isPending(zt),[$,X]=a.useState(null),G=$?P.get($):null,{height:U,onResizeStart:Se}=In(),[B,Q]=a.useState(()=>jt(k.GIT_PANEL_OPEN,!1)),[ge,Ke]=a.useState(()=>jt(k.BUILDINGS_PANEL_OPEN,!1)),[de,xe]=a.useState(!1),mt=a.useCallback(()=>{xe(i=>{const r=!i;return r&&An.setEnabled(!0),r})},[]),ft=a.useCallback(()=>xe(!1),[]),be=a.useCallback(()=>{Q(i=>{const r=!i;return se(k.GIT_PANEL_OPEN,r),r})},[]),ht=a.useCallback(()=>{Ke(i=>{const r=!i;return se(k.BUILDINGS_PANEL_OPEN,r),r})},[]),Ye=a.useCallback(()=>{Q(!1),se(k.GIT_PANEL_OPEN,!1)},[]),gt=a.useCallback(()=>{Ke(!1),se(k.BUILDINGS_PANEL_OPEN,!1)},[]),$e=Sn();a.useEffect(()=>{if(!$)return;Ae.some(r=>r.id===$)||X(null)},[$,Ae]);const[_e,ue]=a.useState(!1),Be=a.useRef(null);if(a.useEffect(()=>{if(!_e)return;const i=r=>{Be.current&&!Be.current.contains(r.target)&&ue(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[_e]),!g)return e.jsx("div",{className:"flat-chat flat-chat--empty",children:e.jsxs("div",{className:"flat-chat__placeholder",children:[e.jsx("span",{className:"flat-chat__placeholder-icon",children:"💬"}),e.jsx("span",{className:"flat-chat__placeholder-text",children:"Select an agent to start chatting"})]})});const ee=g.contextStats,Ze=!!ee,Je=ee?ee.totalTokens:g.contextUsed||0,we=ee?ee.contextWindow:g.contextLimit||2e5,x=ee?ee.usedPercent:Math.round(Je/we*100),z=Math.max(0,Math.min(100,x)),q=Math.round(z*10)/10,Ee=Math.round((100-z)*10)/10,Fe=z>=80?"#ff4a4a":z>=60?"#ff9e4a":z>=40?"#ffd700":"#4aff9e",Qe=(Je/1e3).toFixed(1),et=(we/1e3).toFixed(1),te=g.cwd,tt=te?Vn(te):null,pe=((ne=g.subordinateIds)==null?void 0:ne.length)||0,Ce=pe>0;return e.jsxs("div",{ref:Ie,className:`flat-terminal-wrapper ${B||ge||de?"flat-terminal-wrapper--with-side-panel":""}`,children:[e.jsxs("div",{className:"flat-terminal-wrapper__header",children:[e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__header-main ${ye?"flat-terminal-wrapper__header-main--active":""}`,onClick:J,title:ye?"Hide agent info":"Show agent info","aria-pressed":ye,children:[e.jsx(Ft,{agent:g,size:28}),e.jsxs("span",{className:"flat-terminal-wrapper__header-info",children:[e.jsx("span",{className:"flat-terminal-wrapper__header-name",children:g.name}),e.jsx("span",{className:"flat-terminal-wrapper__header-status",style:{color:Wt(g.status)},children:g.status})]}),g.taskLabel&&e.jsxs("span",{className:"flat-terminal-wrapper__header-task",title:g.taskLabel,children:["📋 ",g.taskLabel]}),e.jsxs("span",{className:"flat-terminal-wrapper__header-model",children:[e.jsx("img",{src:g.provider==="codex"?"/assets/codex.png":g.provider==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:g.provider,className:"flat-terminal-wrapper__header-provider-icon",title:g.provider==="codex"?"Codex Agent":g.provider==="opencode"?"OpenCode Agent":"Claude Agent"}),(()=>{const{model:i,effort:r}=Gn(g);return e.jsxs("span",{className:"flat-terminal-wrapper__header-model-chip",title:r?`Model: ${i} · Effort: ${r}`:`Model: ${i}`,children:[e.jsx("span",{className:"flat-terminal-wrapper__header-model-name",children:i}),r&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flat-terminal-wrapper__header-model-sep","aria-hidden":"true",children:"·"}),e.jsx("span",{className:"flat-terminal-wrapper__header-model-effort",children:r})]})]})})()]})]}),e.jsxs("div",{className:"flat-terminal-wrapper__header-meta",children:[e.jsx("div",{className:"flat-terminal-wrapper__view-mode",role:"group","aria-label":"Message view mode",children:Bn.map(i=>e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__view-mode-btn ${I===i?"flat-terminal-wrapper__view-mode-btn--active":""}`,onClick:()=>A(i),title:Hn[i],"aria-pressed":I===i,children:[e.jsx("span",{className:"flat-terminal-wrapper__view-mode-icon","aria-hidden":"true",children:Wn[i]}),e.jsx("span",{className:"flat-terminal-wrapper__view-mode-label",children:Fn[i]})]},i))}),e.jsxs("div",{className:"flat-terminal-wrapper__actions",role:"group","aria-label":"Terminal actions",children:[e.jsx("button",{type:"button",className:"flat-terminal-wrapper__action-btn",onClick:le,disabled:!Ge,title:"Back to previous agent","aria-label":"Back to previous agent",children:e.jsx(u,{name:"arrow-left",size:14})}),e.jsx("button",{type:"button",className:"flat-terminal-wrapper__action-btn",onClick:D,disabled:!De,title:"Forward to next agent","aria-label":"Forward to next agent",children:e.jsx(u,{name:"arrow-right",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${V?"flat-terminal-wrapper__action-btn--active":""}`,onClick:pt,title:V?"Close search":"Search messages","aria-pressed":V,children:e.jsx(u,{name:V?"cross":"search",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn flat-terminal-wrapper__action-btn--danger ${ce?"flat-terminal-wrapper__action-btn--confirm":""}`,onClick:()=>qe.handleClick(zt,()=>{var i;h.clearContext(c),(i=me.current)==null||i.historyLoader.clearHistory()}),title:ce?"Click again to confirm clear context":"Clear context",children:e.jsx(u,{name:ce?"question":"clear",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${B?"flat-terminal-wrapper__action-btn--active":""}`,onClick:be,title:B?"Hide git panel":"Show git changes","aria-pressed":B,children:e.jsx(u,{name:"git-branch",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${ge?"flat-terminal-wrapper__action-btn--active":""}`,onClick:ht,title:ge?"Hide buildings panel":"Show area buildings","aria-pressed":ge,children:e.jsx(u,{name:"buildings",size:14})}),e.jsxs("div",{className:"flat-terminal-wrapper__more",ref:Be,children:[e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${_e?"flat-terminal-wrapper__action-btn--active":""}`,onClick:()=>ue(i=>!i),title:"More actions","aria-expanded":_e,children:"⋮"}),_e&&e.jsxs("div",{className:"flat-terminal-wrapper__more-menu",role:"menu",children:[e.jsxs("button",{type:"button",role:"menuitem",className:`flat-terminal-wrapper__more-item ${de?"flat-terminal-wrapper__more-item--active":""}`,onClick:()=>{mt(),ue(!1)},title:de?"Hide Debug Panel":"Show Debug Panel",children:[e.jsx(u,{name:"bug",size:14}),e.jsx("span",{children:de?"Hide Debug Panel":"Show Debug Panel"})]}),e.jsx("div",{className:"flat-terminal-wrapper__more-divider"}),e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item",onClick:()=>{h.collapseContext(c),ue(!1)},disabled:g.status!=="idle",title:g.status!=="idle"?"Agent must be idle to collapse context":"Collapse context",children:[e.jsx(u,{name:"package",size:14}),e.jsx("span",{children:"Collapse context"})]}),Ce&&e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item flat-terminal-wrapper__more-item--danger",onClick:()=>{Z(c,pe),ue(!1)},children:[e.jsx(u,{name:"crown",size:14}),e.jsxs("span",{children:["Clear ",pe," subordinate",pe===1?"":"s"]})]}),e.jsx("div",{className:"flat-terminal-wrapper__more-divider"}),e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item flat-terminal-wrapper__more-item--danger",onClick:()=>{h.killAgent(c),ue(!1)},children:[e.jsx(u,{name:"cross",size:14}),e.jsx("span",{children:"Remove agent"})]})]})]})]}),e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__inspector-toggle ${T?"flat-terminal-wrapper__inspector-toggle--active":""}`,onClick:Y,title:T?"Hide inspector panel":"Show inspector panel","aria-label":T?"Hide inspector panel":"Show inspector panel","aria-pressed":T,children:[e.jsx("span",{className:"flat-terminal-wrapper__inspector-icon","aria-hidden":"true",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"}),e.jsx("line",{x1:"10",y1:"2.5",x2:"10",y2:"13.5"})]})}),e.jsx("span",{className:"flat-terminal-wrapper__inspector-label",children:"Inspector"})]}),e.jsx("button",{type:"button",className:"flat-terminal-wrapper__close",onClick:()=>h.deselectAll(),title:"Close chat","aria-label":"Close chat",children:e.jsx(u,{name:"cross",size:14})})]})]}),e.jsx(En,{ref:me,agentId:c,agent:g,viewMode:I,isOpen:!0,onImageClick:H,onFileClick:ie,onBashClick:E,onViewMarkdown:C,keyboard:Ve,hasModalOpen:!1}),G&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"guake-bottom-terminal-resize",onMouseDown:Se,role:"separator","aria-orientation":"horizontal","aria-label":"Resize embedded terminal"}),e.jsxs("div",{className:"flat-bottom-panel",role:"region","aria-label":`Embedded terminal: ${G.name}`,style:{height:U},children:[e.jsxs("div",{className:"flat-bottom-panel__header",children:[e.jsxs("span",{className:"flat-bottom-panel__title",children:[e.jsx(u,{name:"terminal",size:12}),e.jsx("span",{children:G.name}),!((nt=G.terminalStatus)!=null&&nt.url)&&e.jsx("span",{className:"flat-bottom-panel__muted",children:"(starting...)"})]}),e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:()=>X(null),title:"Close embedded terminal","aria-label":"Close embedded terminal",children:e.jsx(u,{name:"cross",size:12})})]}),e.jsx("div",{className:"flat-bottom-panel__body",children:(F=G.terminalStatus)!=null&&F.url?e.jsx(Mn,{terminalUrl:G.terminalStatus.url,visible:!0}):e.jsx("div",{className:"flat-bottom-panel__placeholder",children:"Starting terminal..."})})]})]}),e.jsxs("div",{className:"flat-terminal-wrapper__statusbar",role:"contentinfo",children:[g.isDetached&&e.jsxs("span",{className:"flat-terminal-wrapper__detached",title:"Reattaching session...",children:[e.jsx(u,{name:"refresh",size:12}),e.jsx("span",{children:"Reattaching"})]}),te&&tt&&e.jsxs("span",{className:"flat-terminal-wrapper__cwd",title:`Open in file explorer: ${te}`,"aria-label":`Open ${te} in file explorer`,role:"button",tabIndex:0,onClick:()=>h.openFileExplorer(te),onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),h.openFileExplorer(te))},children:[e.jsx("span",{className:"flat-terminal-wrapper__cwd-icon",children:e.jsx(u,{name:"folder",size:12})}),e.jsx("span",{className:"flat-terminal-wrapper__cwd-text",children:tt})]}),ze&&ze.map(({areaId:i,areaName:r,dir:d})=>{const o=Xe.get(d),ve=Oe.has(d),Te=d.split("/").filter(Boolean).pop()||d;return e.jsxs("span",{className:"flat-terminal-wrapper__area-dir",title:`${r}: ${d}${o?` (${o.branch}${o.ahead?` ↑${o.ahead}`:""}${o.behind?` ↓${o.behind}`:""})`:""}`,onClick:()=>h.openFileExplorerForAreaFolder(i,d),children:[e.jsx(u,{name:"folder-open",size:12}),e.jsx("span",{className:"flat-terminal-wrapper__area-dir-name",children:Te}),o&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flat-terminal-wrapper__area-dir-branch",children:[e.jsx(u,{name:"git-branch",size:10})," ",o.branch]}),o.ahead>0&&e.jsxs("span",{className:"flat-terminal-wrapper__branch-ahead",title:`${o.ahead} ahead`,children:[e.jsx(u,{name:"arrow-up",size:9}),o.ahead]}),o.behind>0&&e.jsxs("span",{className:"flat-terminal-wrapper__branch-behind",title:`${o.behind} behind`,children:[e.jsx(u,{name:"arrow-down",size:9}),o.behind]}),e.jsx("span",{className:`flat-terminal-wrapper__area-fetch ${ve?"flat-terminal-wrapper__area-fetch--fetching":""}`,title:"Git fetch",onClick:Pe=>{Pe.stopPropagation(),Ue(d)},children:e.jsx(u,{name:ve?"hourglass":"download",size:12})})]})]},`${i}:${d}`)}),e.jsxs("span",{className:"flat-terminal-wrapper__context",onClick:()=>h.setContextModalAgentId(c),title:Ze?`Context usage: ${Qe}k / ${et}k tokens (${q}% used). Click to view stats.`:"Click to fetch context stats",children:[e.jsx("span",{className:"flat-terminal-wrapper__context-icon",children:e.jsx(u,{name:"dashboard",size:12})}),e.jsx("span",{className:"flat-terminal-wrapper__context-label",children:"Ctx:"}),e.jsx("span",{className:"flat-terminal-wrapper__context-bar",children:e.jsx("span",{className:"flat-terminal-wrapper__context-bar-fill",style:{width:`${z}%`,backgroundColor:Fe}})}),e.jsxs("span",{className:"flat-terminal-wrapper__context-tokens",style:{color:Fe},children:[Qe,"k/",et,"k"]}),e.jsxs("span",{className:"flat-terminal-wrapper__context-free",children:["(",Ee,"% free)"]}),!Ze&&e.jsx("span",{className:"flat-terminal-wrapper__context-warning",title:"No context stats yet",children:e.jsx(u,{name:"warn",size:12})})]}),e.jsx("div",{className:"flat-terminal-wrapper__statusbar-spacer","aria-hidden":"true"}),Ae.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area terminals",children:Ae.map(i=>{const r=$===i.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${r?"flat-terminal-wrapper__building-btn--active":""} ${i.hasUrl?"":"flat-terminal-wrapper__building-btn--offline"}`,title:`${r?"Hide":"Show"} terminal: ${i.name}${i.hasUrl?"":" (starting...)"}`,onClick:()=>{if(r){X(null);return}i.hasUrl||h.sendBuildingCommand(i.id,"start"),X(i.id)},children:e.jsx(u,{name:"terminal",size:14})},i.id)})}),he.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area PM2 logs",children:he.map(i=>e.jsx("button",{type:"button",className:"flat-terminal-wrapper__building-btn",title:`Open logs: ${i.name}`,onClick:()=>Re(i.id),children:e.jsx(u,{name:"scroll",size:14})},i.id))}),re.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area databases",children:re.map(i=>e.jsx("button",{type:"button",className:"flat-terminal-wrapper__building-btn",title:`Open database: ${i.name}`,onClick:()=>Re(i.id),children:e.jsx(u,{name:"hard-drives",size:14})},i.id))}),e.jsx("div",{className:"flat-terminal-wrapper__theme",children:e.jsx(Tn,{})})]}),B&&e.jsx(Pn,{agentId:c,agents:$e,onClose:Ye,branchInfoMap:Xe,fetchRemote:Ue,fetchingDirs:Oe}),ge&&e.jsx(Ln,{agentId:c,onClose:gt}),de&&e.jsx(Rn,{agentId:c,onClose:ft})]})});function Zn({onAgentClick:_,onBuildingClick:c,onBuildingDoubleClick:I,onBuildingPopup:A,onOpenSpawnModal:T,onOpenBossSpawnModal:Y,onOpenAreaModal:H}){const{t:ie}=Ot(["common"]),E=sn(),C=ln(),[Z,Re]=a.useState(null),[Ve,Ge]=a.useState(null),[De,le]=a.useState(null),[D,ye]=a.useState(null),[J,g]=a.useState(null),[P,me]=a.useState(null),[Ie,fe]=a.useState(!1),ze=a.useCallback(()=>{fe(t=>!t)},[]),Xe=a.useCallback(()=>{fe(!1)},[]),[Ue,Oe]=a.useState(()=>{const t=St(k.VIEW_MODE);return t==="simple"||t==="chat"||t==="advanced"?t:"simple"}),Ae=a.useCallback(t=>{Oe(t),Et(k.VIEW_MODE,t)},[]);a.useEffect(()=>{const t=n=>{if(n.key!==k.VIEW_MODE)return;const s=n.newValue;(s==="simple"||s==="chat"||s==="advanced")&&Oe(s)};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)},[]);const[he,re]=a.useState(()=>jt(k.FLAT_INSPECTOR_OPEN,!1)),[oe,V]=a.useState(!1),pt=a.useCallback(()=>V(t=>!t),[]),qe=a.useCallback(()=>V(!1),[]);a.useEffect(()=>{window.dispatchEvent(new CustomEvent("tide-flat-agents-drawer-state",{detail:{open:oe}}))},[oe]),a.useEffect(()=>{window.dispatchEvent(new CustomEvent("tide-flat-inspector-state",{detail:{open:he}}))},[he]),a.useEffect(()=>{const t=()=>V(b=>!b),n=()=>{re(b=>{const l=!b;return se(k.FLAT_INSPECTOR_OPEN,l),l})},s=()=>{V(!1),re(!1),se(k.FLAT_INSPECTOR_OPEN,!1)},p=()=>V(!1),m=()=>{re(!1),se(k.FLAT_INSPECTOR_OPEN,!1)};return window.addEventListener("tide-toggle-flat-agents-drawer",t),window.addEventListener("tide-toggle-flat-inspector",n),window.addEventListener("tide-close-flat-side-views",s),window.addEventListener("tide-close-flat-agents-drawer-only",p),window.addEventListener("tide-close-flat-inspector-only",m),()=>{window.removeEventListener("tide-toggle-flat-agents-drawer",t),window.removeEventListener("tide-toggle-flat-inspector",n),window.removeEventListener("tide-close-flat-side-views",s),window.removeEventListener("tide-close-flat-agents-drawer-only",p),window.removeEventListener("tide-close-flat-inspector-only",m)}},[]);const ce=a.useRef(null),$=a.useRef(null),[X,G]=a.useState(()=>{const t=Mt(k.FLAT_MIDDLE_WIDTH,0);return t>=ut?t:null}),[U,Se]=a.useState(()=>{const t=Mt(k.FLAT_INSPECTOR_WIDTH,0);return t>=vt?t:null}),B=a.useCallback(t=>{if(typeof window>"u")return t;const n=U!==null?dt+U:0,s=window.innerWidth-Dt-dt-Rt-n;return Math.max(ut,Math.min(Math.max(s,ut),t))},[U]),Q=a.useCallback(t=>{var m;if(typeof window>"u")return t;const n=(m=ce.current)==null?void 0:m.querySelector(".flat-middle"),s=(n==null?void 0:n.getBoundingClientRect().width)??ut,p=window.innerWidth-Dt-s-dt-Rt-dt;return Math.max(vt,Math.min(Math.max(p,vt),t))},[]);a.useEffect(()=>{if(X===null&&U===null)return;const t=()=>{G(n=>{if(n===null)return n;const s=B(n);return s===n?n:s}),Se(n=>{if(n===null)return n;const s=Q(n);return s===n?n:s})};return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[X,U,B,Q]);const ge=a.useCallback(t=>{var s;if(t.button!==0)return;const n=(s=ce.current)==null?void 0:s.querySelector(".flat-middle");n&&(t.currentTarget.setPointerCapture(t.pointerId),$.current={kind:"middle",startX:t.clientX,startWidth:n.getBoundingClientRect().width,pointerId:t.pointerId},document.body.classList.add("flat-splitter-dragging"))},[]),Ke=a.useCallback(t=>{var s;if(t.button!==0)return;const n=(s=ce.current)==null?void 0:s.querySelector(".flat-inspector");n&&(t.currentTarget.setPointerCapture(t.pointerId),$.current={kind:"inspector",startX:t.clientX,startWidth:n.getBoundingClientRect().width,pointerId:t.pointerId},document.body.classList.add("flat-splitter-dragging"))},[]),de=a.useCallback(t=>{const n=$.current;if(!n||t.pointerId!==n.pointerId)return;const s=t.clientX-n.startX;n.kind==="middle"?G(B(n.startWidth+s)):Se(Q(n.startWidth-s))},[B,Q]),xe=a.useCallback(t=>{const n=$.current;if(!n||t.pointerId!==n.pointerId)return;try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}if($.current=null,document.body.classList.remove("flat-splitter-dragging"),!(Math.abs(t.clientX-n.startX)>2))return;const p=t.clientX-n.startX;if(n.kind==="middle"){const m=B(n.startWidth+p);G(m),ct(k.FLAT_MIDDLE_WIDTH,m)}else{const m=Q(n.startWidth-p);Se(m),ct(k.FLAT_INSPECTOR_WIDTH,m)}},[B,Q]),mt=a.useCallback(()=>{G(null),ct(k.FLAT_MIDDLE_WIDTH,0)},[]),ft=a.useCallback(()=>{Se(null),ct(k.FLAT_INSPECTOR_WIDTH,0)},[]),[be,ht]=a.useState(()=>St(k.FLAT_INSPECTOR_VIEW)==="tracking"?"tracking":"agent"),Ye=a.useCallback(t=>{ht(t),Et(k.FLAT_INSPECTOR_VIEW,t)},[]),gt=a.useCallback(()=>{re(t=>{const n=!t;return se(k.FLAT_INSPECTOR_OPEN,n),n})},[]),$e=a.useCallback(()=>{re(!1),se(k.FLAT_INSPECTOR_OPEN,!1)},[]),_e=rn(),ue=a.useCallback((t,n)=>{Re({url:t,name:n})},[]),Be=a.useCallback((t,n)=>{Ge({command:t,output:n,isLive:!1})},[]),ee=a.useCallback((t,n)=>{h.setFileViewerPath(t,n)},[]),Ze=a.useCallback(t=>{},[]),Je=a.useCallback((t,n)=>{le({agentId:t,count:n})},[]),we=a.useCallback(t=>{I?I(t):c(t)},[c,I]),x=a.useMemo(()=>C.size>0?Array.from(C)[0]:null,[C]);a.useEffect(()=>{fe(!1)},[x]);const z=a.useRef([]),q=a.useRef(-1),Ee=a.useRef(!1),Fe=a.useRef(null),[Qe,et]=a.useState(!1),[te,tt]=a.useState(!1),pe=a.useRef(!1),Ce=a.useRef(null),Me=a.useRef(!1),ne=a.useMemo(()=>new Set(E.map(t=>t.id)),[E]),nt=a.useMemo(()=>{const t=new Map(E.map(s=>[s.id,s])),n=new Map;for(const s of E)if((s.isBoss||s.class==="boss")&&s.subordinateIds&&s.subordinateIds.length>0){const p=s.subordinateIds.map(m=>t.get(m)).filter(m=>m!==void 0);p.length>0&&n.set(s.id,p)}return n},[E]),F=a.useCallback(()=>{const t=z.current,n=q.current;et(n>0),tt(n>=0&&n<t.length-1)},[]),i=a.useCallback(t=>{const n=z.current;if(n.length===0)return;let s=q.current+t;for(;s>=0&&s<n.length;){const p=n[s];if(ne.has(p)){Ee.current=!0,q.current=s,F(),h.selectAgent(p);return}s+=t}},[ne,F]),r=a.useCallback(()=>i(-1),[i]),d=a.useCallback(()=>i(1),[i]),o=a.useCallback((t,n)=>{if(typeof window>"u")return;const s=window.history.state,m={...typeof s=="object"&&s!==null?s:{},__flatAgentNav:{agentId:t}};n==="replace"?window.history.replaceState(m,"",window.location.href):window.history.pushState(m,"",window.location.href)},[]);a.useEffect(()=>{if(!x){pe.current=!1,Ce.current=null;return}if(!pe.current){o(x,"replace"),pe.current=!0,Ce.current=x;return}if(Me.current){Me.current=!1,Ce.current=x;return}Ce.current!==x&&(o(x,"push"),Ce.current=x)},[x,o]),a.useEffect(()=>{const t=n=>{var b,l;const s=(l=(b=n.state)==null?void 0:b.__flatAgentNav)==null?void 0:l.agentId;if(!s||typeof s!="string"||!ne.has(s)||s===x)return;Me.current=!0,Ee.current=!0;const p=z.current,m=p.lastIndexOf(s);m>=0?q.current=m:(p.push(s),q.current=p.length-1),F(),h.selectAgent(s)};return window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t)},[ne,x,F]),a.useEffect(()=>{if(!x){z.current=[],q.current=-1,F();return}if(Fe.current=x,Ee.current){Ee.current=!1,F();return}const t=z.current,n=q.current;if(n>=0&&t[n]===x){F();return}const s=n<t.length-1?t.slice(0,n+1):t.slice();s.push(x),s.length>100&&s.shift(),z.current=s,q.current=s.length-1,F()},[x,F]);const ve=a.useCallback(t=>{_(t),V(!1)},[_]),Te=x??"",Pe=a.useCallback(()=>{},[]),xt=a.useCallback(t=>{ve(t)},[ve]),K=he,[Le,O]=a.useState(K),[M,We]=a.useState(K);a.useEffect(()=>{if(K){O(!0);return}We(!1);const t=setTimeout(()=>O(!1),240);return()=>clearTimeout(t)},[K]),a.useEffect(()=>{if(!Le||!K)return;let t=0;const n=requestAnimationFrame(()=>{t=requestAnimationFrame(()=>We(!0))});return()=>{cancelAnimationFrame(n),cancelAnimationFrame(t)}},[Le,K]);const Nt=a.useRef(null);a.useEffect(()=>{if(x)return;const t=n=>{if(n.key!==" "&&n.key!=="Backspace")return;const s=n.target;if(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable)return;const p=Fe.current;!p||!ne.has(p)||(n.preventDefault(),h.selectAgent(p))};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[x,ne]);const[Ht,kt]=a.useState(new Set),Vt=a.useCallback(t=>{kt(n=>{const s=new Set(n);return s.has(t)?s.delete(t):s.add(t),s})},[]),[je,Gt]=a.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 768px)").matches);a.useEffect(()=>{if(typeof window>"u")return;const t=window.matchMedia("(max-width: 768px)"),n=s=>Gt(s.matches);return t.addEventListener("change",n),()=>t.removeEventListener("change",n)},[]);const[at,Xt]=a.useState(null),Ut=a.useCallback(t=>{Xt(n=>n===t?null:t)},[]),bt=$t(),st=Bt(),[qt]=on(),Ne=a.useMemo(()=>{const t=new Map,n=[];for(const f of E){const N=h.getAreaForAgent(f.id);if(!Tt((N==null?void 0:N.id)??null))continue;if(!N||N.archived){n.push(f);continue}const v=t.get(N.id);v?v.push(f):t.set(N.id,[f])}const s=new Map,p=[];for(const f of st.values()){let N=!1;for(const v of bt.values())if(!v.archived&&Pt(v.id)&&h.isPositionInArea(f.position,v)){const ae=s.get(v.id);ae?ae.push(f):s.set(v.id,[f]),N=!0;break}!N&&Tt(null)&&p.push(f)}const m=[];for(const[,f]of bt){if(f.archived||!Pt(f.id))continue;const N=t.get(f.id),v=s.get(f.id)??[];(N&&N.length>0||v.length>0)&&m.push({area:f,agents:N??[],buildings:v})}(n.length>0||p.length>0)&&m.push({area:{id:"__unassigned__",name:"Unassigned",color:"#6272a4",center:{x:0,z:0},type:"circle",radius:0,directories:[],archived:!1,assignedAgentIds:[],zIndex:0},agents:n,buildings:p});const b=m.filter(f=>f.area.id!=="__unassigned__"),l=m.filter(f=>f.area.id==="__unassigned__");let y=1,j=1;const W=new Map;if(b.length>1){let f=1/0,N=-1/0,v=1/0,ae=-1/0;for(const L of b)f=Math.min(f,L.area.center.x),N=Math.max(N,L.area.center.x),v=Math.min(v,L.area.center.z),ae=Math.max(ae,L.area.center.z);const lt=N-f||1,rt=ae-v||1;if(b.length<=4){y=b.length,j=1;const L=[...b].sort((R,_t)=>R.area.center.x-_t.area.center.x);for(let R=0;R<L.length;R++)W.set(L[R].area.id,{row:1,col:R+1})}else{const L=[...b].sort((w,S)=>w.area.center.x-S.area.center.x),R=[];for(let w=1;w<L.length;w++)R.push(L[w].area.center.x-L[w-1].area.center.x);const _t=R.reduce((w,S)=>w+S,0)/R.length||1;let yt=1;for(const w of R)w>_t*1.3&&yt++;y=Math.max(2,Math.min(yt,b.length));const wt=[...b].sort((w,S)=>w.area.center.z-S.area.center.z),ot=[];for(let w=1;w<wt.length;w++)ot.push(wt[w].area.center.z-wt[w-1].area.center.z);const Jt=ot.reduce((w,S)=>w+S,0)/ot.length||1;let It=1;for(const w of ot)w>Jt*1.3&&It++;j=Math.max(2,Math.min(It,b.length)),y=Math.max(y,Math.ceil(b.length/j)),j=Math.max(j,Math.ceil(b.length/y));const Qt=lt/y,en=rt/j,Ct=new Set;for(const w of b){let S=Math.min(y-1,Math.max(0,Math.floor((w.area.center.x-f)/Qt))),ke=Math.min(j-1,Math.max(0,Math.floor((w.area.center.z-v)/en))),He=`${ke},${S}`,At=0;const tn=j*y;for(;Ct.has(He)&&At<tn;)S++,S>=y&&(S=0,ke=(ke+1)%j),He=`${ke},${S}`,At++;Ct.has(He)&&(ke=j,S=0,He=`${ke},${S}`,j++),Ct.add(He),W.set(w.area.id,{row:ke+1,col:S+1})}}}const it=f=>{f.sort((N,v)=>{var lt,rt,L,R;const ae=(((lt=N.position)==null?void 0:lt.z)??0)-(((rt=v.position)==null?void 0:rt.z)??0);return ae!==0?ae:(((L=N.position)==null?void 0:L.x)??0)-(((R=v.position)==null?void 0:R.x)??0)})};for(const f of b)it(f.agents);for(const f of l)it(f.agents);return{groups:[...b,...l],gridCols:y,gridRows:j,positions:W}},[E,bt,st,qt]),Kt=a.useMemo(()=>{if(!D)return[];const t=E.find(n=>n.id===D.agentId);return t?[{id:"edit-agent",label:"Edit Agent",icon:e.jsx(u,{name:"edit",size:14}),onClick:()=>{window.dispatchEvent(new CustomEvent("tide:open-agent-edit",{detail:{agentId:t.id}}))}},{id:"open-chat",label:"Open Chat",icon:e.jsx(u,{name:"chat",size:14}),onClick:()=>_(t.id)},{id:"delete-agent",label:"Delete Agent",icon:e.jsx(u,{name:"trash",size:14}),danger:!0,onClick:()=>{me({agentId:t.id,name:t.name})}}]:[]},[D,E,_]),Yt=a.useMemo(()=>{var b;if(!J)return[];const t=st.get(J.buildingId);if(!t)return[];const n=[],s=t.type==="server"||t.type==="docker"||t.type==="terminal",p=t.status==="running",m=t.type==="boss";if(n.push({id:"open",label:t.type==="database"?"Open Database":t.type==="folder"?"Open Folder":t.type==="boss"?"View Boss Logs":t.type==="terminal"?"Open Terminal":t.type==="server"&&((b=t.pm2)!=null&&b.enabled)?"View PM2 Logs":"Open",icon:e.jsx(u,{name:t.type==="database"?"database":t.type==="folder"?"folder":t.type==="terminal"?"terminal":"eye",size:14}),onClick:()=>we(t.id)}),s&&(p||n.push({id:"start",label:"Start",icon:e.jsx(u,{name:"play",size:14}),onClick:()=>h.sendBuildingCommand(t.id,"start")}),p&&(n.push({id:"restart",label:"Restart",icon:e.jsx(u,{name:"refresh",size:14}),onClick:()=>h.sendBuildingCommand(t.id,"restart")}),n.push({id:"stop",label:"Stop",icon:e.jsx(u,{name:"stop",size:14}),onClick:()=>h.sendBuildingCommand(t.id,"stop")}))),m&&t.subordinateBuildingIds&&t.subordinateBuildingIds.length>0&&(n.push({id:"start-all",label:"Start All Subordinates",icon:e.jsx(u,{name:"launch",size:14}),onClick:()=>{for(const l of t.subordinateBuildingIds)h.sendBuildingCommand(l,"start")}}),n.push({id:"stop-all",label:"Stop All Subordinates",icon:e.jsx(u,{name:"pause",size:14}),onClick:()=>{for(const l of t.subordinateBuildingIds)h.sendBuildingCommand(l,"stop")}}),n.push({id:"restart-all",label:"Restart All Subordinates",icon:e.jsx(u,{name:"restart",size:14}),onClick:()=>{for(const l of t.subordinateBuildingIds)h.sendBuildingCommand(l,"restart")}})),s&&n.push({id:"health-check",label:"Health Check",icon:e.jsx(u,{name:"health",size:14}),onClick:()=>h.sendBuildingCommand(t.id,"healthCheck")}),n.push({id:"divider-edit",label:"",divider:!0,onClick:()=>{}}),n.push({id:"edit",label:"Edit Building",icon:e.jsx(u,{name:"edit",size:14}),onClick:()=>{window.dispatchEvent(new CustomEvent("tide:building-edit",{detail:{buildingId:t.id}}))}}),n.push({id:"clone",label:"Clone Building",icon:e.jsx(u,{name:"copy",size:14}),onClick:()=>{h.createBuilding({name:`${t.name} (Copy)`,type:t.type,style:t.style,color:t.color,scale:t.scale,position:{x:t.position.x+2,z:t.position.z+2},cwd:t.cwd,folderPath:t.folderPath,commands:t.commands,pm2:t.pm2,docker:t.docker,database:t.database,terminal:t.terminal,urls:t.urls,subordinateBuildingIds:t.subordinateBuildingIds})}}),t.urls&&t.urls.length>0)for(const l of t.urls)n.push({id:`url-${l.label}`,label:l.label,icon:e.jsx(u,{name:"link",size:14}),onClick:()=>window.open(l.url,"_blank","noopener,noreferrer")});return n.push({id:"divider-danger",label:"",divider:!0,onClick:()=>{}}),n.push({id:"delete",label:"Delete Building",icon:e.jsx(u,{name:"trash",size:14}),danger:!0,onClick:()=>h.deleteBuilding(t.id)}),n},[J,st,we]),Zt=a.useCallback(t=>{const n=new Set(Ne.groups.map(s=>s.area.id));n.delete(t),kt(n),requestAnimationFrame(()=>{const s=Nt.current;if(!s)return;const p=s.querySelector(`[data-area-id="${t}"]`);if(!p)return;const m=s.getBoundingClientRect(),l=p.getBoundingClientRect().top-m.top+s.scrollTop-8;s.scrollTo({top:Math.max(0,l),behavior:"smooth"})})},[Ne]);return e.jsxs("div",{ref:ce,className:`flat-view ${K?"flat-view--with-inspector":""} ${x?"flat-view--has-chat":""} ${oe?"flat-view--mobile-sidebar-open":""}`,style:(()=>{if(X===null&&U===null)return;const t={};return X!==null&&(t["--flat-middle-width"]=`${X}px`),U!==null&&(t["--flat-inspector-width"]=`${U}px`),t})(),children:[oe&&e.jsx("div",{className:"flat-mobile-sidebar-backdrop",onClick:qe,"aria-hidden":"true"}),e.jsxs("div",{className:"flat-middle",children:[e.jsx("div",{className:"flat-middle__header",children:e.jsxs("div",{className:"flat-middle__actions",children:[e.jsx("button",{className:"flat-cta-btn flat-cta-btn--agent",onClick:T,title:"Create new agent",children:"+ Agent"}),e.jsx("button",{className:"flat-cta-btn flat-cta-btn--boss",onClick:Y,title:"Create new boss agent",children:"+ Boss"}),e.jsx("button",{className:"flat-cta-btn flat-cta-btn--area",onClick:H,title:"Create new area",children:"+ Area"})]})}),e.jsx("div",{className:"flat-middle__content",children:e.jsx(cn,{activeAgentId:Te,onClose:Pe,onSelectAgent:xt,collapsedAreas:Ht,onToggleArea:Vt,agentListRef:Nt})})]}),e.jsx("div",{className:"flat-splitter flat-splitter--middle",role:"separator","aria-orientation":"vertical","aria-label":"Resize agents panel",title:"Drag to resize · Double-click to reset",onPointerDown:ge,onPointerMove:de,onPointerUp:xe,onPointerCancel:xe,onDoubleClick:mt}),e.jsxs("div",{className:"flat-right",children:[e.jsxs("button",{type:"button",className:"flat-mobile-sidebar-toggle","aria-label":oe?"Close agents sidebar":"Open agents sidebar","aria-expanded":oe,onClick:pt,children:[e.jsx(u,{name:"list",size:18}),e.jsx("span",{className:"flat-mobile-sidebar-toggle__label",children:"Agents"})]}),x?e.jsx(Un,{agentId:x,terminalViewMode:Ue,onTerminalViewModeChange:Ae,inspectorOpen:he,onToggleInspector:gt,onImageClick:ue,onFileClick:ee,onBashClick:Be,onViewMarkdown:Ze,onRequestClearSubordinates:Je,onOpenBuilding:we,keyboard:_e,canNavigateBack:Qe,canNavigateForward:te,onNavigateBack:r,onNavigateForward:d,agentInfoOpen:Ie,onToggleAgentInfo:ze}):e.jsx("div",{className:"flat-chat flat-chat--empty",children:e.jsxs("div",{className:"flat-map",children:[e.jsxs("div",{className:"flat-map__header",children:[e.jsx("span",{className:"flat-map__title",children:"🗺️ Areas"}),e.jsx("span",{className:"flat-map__hint",children:"Click an area to focus it, or an agent to chat"}),e.jsx($n,{className:"flat-map__view-mode"})]}),e.jsx("div",{className:"flat-map__grid",style:{gridTemplateColumns:`repeat(${Ne.gridCols}, 1fr)`},children:Ne.groups.length===0?e.jsx("div",{className:"flat-map__empty",children:e.jsx("span",{children:"No areas or agents yet"})}):(()=>{var n;const t=je&&at?((n=Ne.positions.get(at))==null?void 0:n.row)??null:null;return Ne.groups.map(s=>{const p=s.area.id,m=Ne.positions.get(p),b=je&&at!==p;return je&&t!=null&&(m==null?void 0:m.row)===t&&p!==at?null:e.jsxs("div",{className:`flat-map-area-card${b?" flat-map-area-card--collapsed":""}`,style:{"--area-color":s.area.color,gridRow:m==null?void 0:m.row,gridColumn:m==null?void 0:m.col},children:[e.jsxs("button",{type:"button",className:"flat-map-area-card__header",onClick:()=>je?Ut(p):Zt(p),title:je?b?`Expand ${s.area.name}`:`Collapse ${s.area.name}`:`Focus ${s.area.name} in left panel`,"aria-expanded":je?!b:void 0,children:[e.jsx("span",{className:"flat-map-area-card__color",style:{background:s.area.color}}),e.jsx("span",{className:"flat-map-area-card__name",children:s.area.name}),e.jsx("span",{className:"flat-map-area-card__count",children:s.agents.length}),je&&e.jsx(u,{name:b?"caret-down":"caret-up",size:11,className:"flat-map-area-card__caret"})]}),e.jsx("div",{className:"flat-map-area-card__agents",children:s.agents.map(l=>{const y=l.isBoss||l.class==="boss",j=y?nt.get(l.id):void 0,W=dn(l),it=W.usedPercent>=80?"#ff4a4a":W.usedPercent>=60?"#ff9e4a":W.usedPercent>=40?"#ffd700":"#4aff9e",f=`Context: ${(W.totalTokens/1e3).toFixed(1)}k / ${(W.contextWindow/1e3).toFixed(1)}k (${W.usedPercent}% used, ${W.freePercent}% free)`,N=l.latestTodos&&l.latestTodos.length>0||j&&j.length>0;return e.jsx(un,{todos:l.latestTodos,subordinates:j,position:"top",children:e.jsxs("button",{type:"button",className:`flat-map-agent-chip ${l.status}`,onClick:()=>_(l.id),onContextMenu:v=>{v.preventDefault(),v.stopPropagation(),ye({agentId:l.id,position:{x:v.clientX,y:v.clientY}})},title:N?void 0:`${y?"Boss · ":""}Open chat with ${l.name}
|
|
2
|
-
${f}`,children:[e.jsx(Ft,{agent:l,size:16}),y&&e.jsx("span",{className:"flat-map-agent-chip__crown","aria-hidden":"true",children:e.jsx(u,{name:"crown",size:11,color:"#ffd700",weight:"fill"})}),e.jsx("span",{className:"flat-map-agent-chip__name",children:l.name}),e.jsx("img",{src:l.provider==="codex"?"/assets/codex.png":l.provider==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:l.provider,className:"flat-map-agent-chip__provider-icon",title:l.provider==="codex"?"Codex Agent":l.provider==="opencode"?"OpenCode Agent":"Claude Agent"}),e.jsx("span",{className:"flat-map-agent-chip__dot",style:{backgroundColor:Wt(l.status)}}),l.latestTodos&&l.latestTodos.length>0&&e.jsx(pn,{todos:l.latestTodos,maxDots:6}),y&&j&&j.length>0&&e.jsx(mn,{subordinates:j,maxDots:6}),e.jsx("span",{className:"flat-map-agent-chip__context-bar","aria-hidden":"true",children:e.jsx("span",{className:"flat-map-agent-chip__context-bar-fill",style:{width:`${W.usedPercent}%`,backgroundColor:it}})})]})},l.id)})}),s.buildings.length>0&&e.jsx("div",{className:"flat-map-area-card__buildings",children:s.buildings.map(l=>e.jsxs("button",{type:"button",className:`flat-map-building-chip flat-map-building-chip--${l.status}`,onClick:y=>{if(A){const j=y.currentTarget.getBoundingClientRect();A(l.id,{x:j.right,y:j.top+j.height/2})}else we(l.id)},onContextMenu:y=>{y.preventDefault(),y.stopPropagation(),g({buildingId:l.id,position:{x:y.clientX,y:y.clientY}})},title:`${l.name} · ${l.type} · ${l.status}`,children:[e.jsx(u,{name:fn(l.type),size:12}),e.jsx("span",{className:"flat-map-building-chip__name",children:l.name}),e.jsx("span",{className:"flat-map-building-chip__dot",style:{backgroundColor:hn(l.status)}})]},l.id))})]},p)})})()})]})})]}),K&&e.jsx("div",{className:"flat-splitter flat-splitter--inspector",role:"separator","aria-orientation":"vertical","aria-label":"Resize inspector panel",title:"Drag to resize · Double-click to reset",onPointerDown:Ke,onPointerMove:de,onPointerUp:xe,onPointerCancel:xe,onDoubleClick:ft}),Le&&e.jsxs("aside",{className:`flat-inspector ${M?"flat-inspector--open":"flat-inspector--closing"}`,"aria-label":"Inspector panel",children:[e.jsxs("div",{className:"flat-inspector__header",children:[e.jsxs("div",{className:"flat-inspector__tabs",role:"tablist","aria-label":"Inspector view",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":be==="agent",className:`flat-inspector__tab ${be==="agent"?"flat-inspector__tab--active":""}`,onClick:()=>Ye("agent"),children:"Agent"}),e.jsx("button",{type:"button",role:"tab","aria-selected":be==="tracking",className:`flat-inspector__tab ${be==="tracking"?"flat-inspector__tab--active":""}`,onClick:()=>Ye("tracking"),children:"Tracking"})]}),e.jsx("button",{type:"button",className:"flat-inspector__close",onClick:$e,title:"Close inspector","aria-label":"Close inspector",children:"✕"})]}),e.jsx("div",{className:"flat-inspector__body",children:be==="tracking"?e.jsx(gn,{activeAgentId:x??"",onSelectAgent:t=>{_(t),window.innerWidth<=768&&$e()}}):(()=>{if(!x)return e.jsx("div",{className:"flat-inspector__empty",children:e.jsx("span",{children:"Select an agent to inspect"})});const t=E.find(n=>n.id===x);return t?e.jsx(xn,{agent:t,onFocusAgent:n=>{_(n),window.innerWidth<=768&&$e()},onKillAgent:n=>h.killAgent(n)}):e.jsx("div",{className:"flat-inspector__empty",children:e.jsx("span",{children:"Agent not found"})})})()})]}),Z&&e.jsx(bn,{url:Z.url,name:Z.name,onClose:()=>Re(null)}),Ve&&e.jsx(_n,{state:Ve,onClose:()=>Ge(null)}),De&&e.jsx(wn,{action:"clear-subordinates",selectedAgentId:De.agentId,subordinateCount:De.count,onClose:()=>le(null),onClearHistory:()=>{}}),e.jsx(Cn,{agent:x?E.find(t=>t.id===x)??null:null,isOpen:Ie&&!!x,onClose:Xe}),e.jsx(Lt,{isOpen:D!==null,position:(D==null?void 0:D.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:Kt,onClose:()=>ye(null)}),e.jsx(Lt,{isOpen:J!==null,position:(J==null?void 0:J.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:Yt,onClose:()=>g(null)}),e.jsx(vn,{isOpen:P!==null,title:ie("common:confirm.removeAgentTitle"),message:ie("common:confirm.removeAgentMessage",{name:(P==null?void 0:P.name)??""}),confirmLabel:ie("common:buttons.remove"),cancelLabel:ie("common:buttons.cancel"),variant:"danger",onConfirm:()=>{P&&h.removeAgentFromServer(P.agentId)},onClose:()=>me(null)})]})}export{Zn as FlatView};
|