cogpit 2.0.1 → 2.1.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.
Files changed (29) hide show
  1. package/README.md +4 -4
  2. package/dist/cli.js +15978 -11502
  3. package/dist/web/assets/CommandPaletteHost-C-ParO8t.js +1 -0
  4. package/dist/web/assets/ConfigBrowser-Co4eu81Z.js +1 -0
  5. package/dist/web/assets/{HighlightedEditor-D4DdiaD3.js → HighlightedEditor-j81AHVZZ.js} +2 -2
  6. package/dist/web/assets/{KeyboardShortcutsDialog-CaqJ90ox.js → KeyboardShortcutsDialog-CluzMowK.js} +1 -1
  7. package/dist/web/assets/{MobileFileChanges-BjHkXuyc.js → MobileFileChanges-DiOncgtO.js} +1 -1
  8. package/dist/web/assets/{PreviewPanel-DVORy2rT.js → PreviewPanel-i4Yn68yV.js} +1 -1
  9. package/dist/web/assets/{ProjectFilesPanel-WiqiZyLW.js → ProjectFilesPanel-DPLFARWn.js} +3 -3
  10. package/dist/web/assets/ProjectSwitcherModal-BUXfKNzX.js +1 -0
  11. package/dist/web/assets/{TerminalOutput-zSNcaPSy.js → TerminalOutput-DLRMV4_Y.js} +1 -1
  12. package/dist/web/assets/{ThemeSelectorModal-D0yWwDku.js → ThemeSelectorModal-Cmx9maEq.js} +1 -1
  13. package/dist/web/assets/{WorkflowsPanel-Doy9QzhU.js → WorkflowsPanel-Cgm_kbHR.js} +1 -1
  14. package/dist/web/assets/WorktreePanel-h3DRRXek.js +1 -0
  15. package/dist/web/assets/{index-BPqm0HzF.js → index-Cgnw8FK8.js} +1 -1
  16. package/dist/web/assets/{index-BG9ZLZQ3.js → index-DUI5EaV5.js} +4 -4
  17. package/dist/web/assets/index-DocqIkvS.js +144 -0
  18. package/dist/web/assets/index-cjmnKg1q.js +1 -0
  19. package/dist/web/assets/session-parser.worker-DTq2tkdd.js +29 -0
  20. package/dist/web/assets/{vendor-ui-BmLOQ5Or.js → vendor-ui-CIBbYCBQ.js} +151 -146
  21. package/dist/web/index.html +3 -3
  22. package/package.json +3 -2
  23. package/dist/web/assets/CommandPaletteHost-CyKWHB_t.js +0 -1
  24. package/dist/web/assets/ConfigBrowser-CmApjOBh.js +0 -1
  25. package/dist/web/assets/ProjectSwitcherModal-CxLemcBj.js +0 -1
  26. package/dist/web/assets/WorktreePanel-CgWELvag.js +0 -1
  27. package/dist/web/assets/index-C3E35E2A.js +0 -138
  28. package/dist/web/assets/index-C4XoqTra.js +0 -1
  29. package/dist/web/assets/session-parser.worker-DJxJ4O8Q.js +0 -22
@@ -8,16 +8,16 @@
8
8
  <meta name="apple-mobile-web-app-capable" content="yes" />
9
9
  <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
10
10
  <meta name="theme-color" content="#09090b" />
11
- <title>Cogpit - Claude Code Session Dashboard</title>
11
+ <title>Cogpit - Agent Session Dashboard</title>
12
12
  <script src="/theme-bootstrap.js"></script>
13
13
  <style>
14
14
  html, body, #root { height: 100%; height: 100dvh; margin: 0; overflow: hidden; }
15
15
  .dark body { background: #09090b; color: #fafafa; }
16
16
  body { background: #fafafa; color: #09090b; }
17
17
  </style>
18
- <script type="module" crossorigin src="/assets/index-C3E35E2A.js"></script>
18
+ <script type="module" crossorigin src="/assets/index-DocqIkvS.js"></script>
19
19
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-gGw_S5I_.js">
20
- <link rel="modulepreload" crossorigin href="/assets/vendor-ui-BmLOQ5Or.js">
20
+ <link rel="modulepreload" crossorigin href="/assets/vendor-ui-CIBbYCBQ.js">
21
21
  <link rel="modulepreload" crossorigin href="/assets/vendor-markdown-BE1gYnO9.js">
22
22
  <link rel="modulepreload" crossorigin href="/assets/vendor-shiki-DOn6sF-i.js">
23
23
  <link rel="stylesheet" crossorigin href="/assets/index-Bif4Kdtn.css">
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cogpit",
3
- "version": "2.0.1",
4
- "description": "Run Cogpit's local Claude Code and Codex interface without installing it",
3
+ "version": "2.1.0",
4
+ "description": "Run Cogpit's local Claude Code, Codex, and GitHub Copilot CLI interface without installing it",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -13,6 +13,7 @@
13
13
  "keywords": [
14
14
  "claude-code",
15
15
  "codex",
16
+ "github-copilot",
16
17
  "agent",
17
18
  "cogpit"
18
19
  ],
@@ -1 +0,0 @@
1
- import{c as oe,j as u,r as M}from"./vendor-react-gGw_S5I_.js";import{aq as h,ar as Q,ah as le,N as ce,J as re,as as de,at as me,O as ue,C as he,M as ge,x as fe,au as ve,av as Y,aw as W,ax as we,ay as Ce,az as je,aA as Se,w as ye}from"./index-C3E35E2A.js";import{S as xe,p as Z,q as be,P as Pe,L as Te,H as Oe,F as Ne,r as ke,g as ee,G as Fe,e as Ie,l as Ee,s as $e,t as Re,u as Ae,v as De,w as te,x as Le,y as Me,z as He,K as qe,f as Ke,A as ze,B as Be,D as ne,I as Ge,J as pe,N as Ue}from"./vendor-ui-BmLOQ5Or.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";function a(t,e,s,c,i,m,d){return{id:t,label:e,icon:c,run:i,shortcut:m,description:d,value:`${e} ${s}`}}function _(...t){return t.filter(e=>e!==!1&&e!==void 0)}function We(t){const e=oe.c(40);let s,c,i,m,d,v,w,r,C,g,y,f,x,k,b;if(e[0]!==t){const $=_(a("home","Go to dashboard","home overview",Oe,t.onGoHome),a("mission-control",t.showMission?"Exit Mission Control":"Open Mission Control","live sessions blocked waiting answer everything at once",Te,t.onToggleMissionControl,h("missionControl")),a("new-session","Start a new session","project agent chat create",Pe,t.onNewSession,h("newSession")),t.onDuplicateSession&&a("duplicate-session","Duplicate this session","copy fork clone branch thread",be,t.onDuplicateSession),t.canFocusComposer&&a("focus-composer","Focus message composer","chat prompt input",Z,t.onFocusComposer,h("focusComposer")),t.onFindInConversation&&a("find-in-conversation","Find in conversation","search text transcript turns matches",xe,t.onFindInConversation,h("findInConversation"))),I=(t.projects??[]).slice(0,8).map(n=>a(`project-${n.dirName}`,n.shortName,`${n.path} ${n.dirName} project workspace`,Ne,()=>{var l;return(l=t.onOpenProject)==null?void 0:l.call(t,n.dirName)},void 0,`${n.path} · ${n.sessionCount} session${n.sessionCount===1?"":"s"}`)),o=(t.recentSessions??[]).slice(0,10).map(n=>{const j=(n.aiTitle||n.name||n.slug||n.lastUserMessage||n.firstUserMessage||n.sessionId).replace(/\s+/g," ").trim().slice(0,160)||n.sessionId,B=[n.projectShortName,n.gitBranch].filter(Boolean).join(" · ");return a(`session-${n.dirName}-${n.fileName}`,j,`${n.projectShortName} ${n.cwd??""} ${n.gitBranch??""} ${n.sessionId} recent thread conversation`,Z,()=>{var q;return(q=t.onOpenSession)==null?void 0:q.call(t,n.dirName,n.fileName)},void 0,B)}),E=t.devices??[],P=E.length>1&&t.onSwitchDevice?E.slice(0,Q.length).map((n,l)=>a(`device-${n.id}`,n.isActive?`${n.name} (current)`:`Switch to ${n.name}`,`device machine host remote ${n.id}`,n.isLocal?ke:ee,()=>{var j;return(j=t.onSwitchDevice)==null?void 0:j.call(t,n.id)},h(Q[l]))):[],R=_(a("toggle-sidebar",t.showSidebar?"Hide session sidebar":"Show session sidebar","projects navigation panel",Re,t.onToggleSidebar,h("toggleSidebar")),t.hasSession&&a("toggle-stats",t.showStats?"Hide session analytics":"Show session analytics","stats tokens usage panel",$e,t.onToggleStats,h("toggleStats")),t.onToggleProjectFiles&&a("project-files",t.showProjectFiles?"Close project files":"Open project files","browse edit save workspace source code",Ee,t.onToggleProjectFiles,h("projectFiles")),t.hasFileChanges&&a("toggle-file-changes",t.showFileChanges?"Hide file changes":"Show file changes","diff edits review panel",Ie,t.onToggleFileChanges),t.supportsWorktrees&&t.canOpenTerminal&&a("toggle-worktrees",t.showWorktrees?"Hide worktrees":"Show worktrees","git branches panel",Fe,t.onToggleWorktrees)),A=_(t.onOpenProjectInEditor&&a("open-project-editor","Open project in editor","code cursor vscode zed workspace",pe,t.onOpenProjectInEditor),t.onRevealProject&&a("reveal-project","Reveal project in file manager","finder explorer folder directory",Ge,t.onRevealProject),t.onCopyResumeCommand&&a("copy-resume-command","Copy resume command","cli claude codex terminal clipboard continue session",ne,t.onCopyResumeCommand),t.onCopyProjectPath&&a("copy-project-path","Copy project path","workspace directory clipboard",ne,t.onCopyProjectPath),t.onOpenIntegratedTerminal&&a("integrated-terminal","New integrated terminal","embedded shell command line process panel",Be,t.onOpenIntegratedTerminal,h("newIntegratedTerminal")),t.canOpenTerminal&&a("terminal","Open in system terminal","external shell command line app",ze,t.onOpenTerminal,h("systemTerminal")),t.onTogglePreview&&a("preview","Toggle development preview","browser localhost dev server website",Ke,t.onTogglePreview,h("preview")),t.onOpenKeyboardShortcuts&&a("keyboard-shortcuts","Customize keyboard shortcuts","keybindings hotkeys settings",qe,t.onOpenKeyboardShortcuts),t.onOpenConfig&&a("config",t.showConfig?"Close agent configuration":"Open agent configuration","skills commands claude settings files",He,t.onOpenConfig),a("settings","Open Cogpit settings","preferences network",Me,t.onOpenSettings),a("theme","Change theme & chat width","appearance light dark oled width narrow wide",Le,t.onOpenTheme,h("themeSelector")),a("expand","Expand all groups","conversation details",te,t.onExpandAll,h("expandAll")),a("expand-payloads","Expand all tool payloads","raw input result diff conversation details",te,t.onExpandToolPayloads,h("expandToolPayloads")),a("collapse","Collapse all","conversation groups payloads details",De,t.onCollapseAll),t.onKillAll&&a("kill-all","Kill all agent processes","stop terminate halt everything runaway",Ae,t.onKillAll),t.onOpenDevices&&a("manage-devices","Manage devices…","remote machines hub hosts edit rename remove switch",Ue,()=>{var n;return(n=t.onOpenDevices)==null?void 0:n.call(t,"manage")}),t.onOpenDevices&&a("add-device","Add device…","remote machine hub host connect pair new",ee,()=>{var n;return(n=t.onOpenDevices)==null?void 0:n.call(t,"add")})),D=[{value:"Navigation",items:$},...o.length>0?[{value:"Recent sessions",items:o}]:[],...I.length>0?[{value:"Projects",items:I}]:[],...P.length>0?[{value:"Devices",items:P}]:[],{value:"View",items:R},{value:"Tools",items:A}],F=function(l){t.onOpenChange(!1),l.run()};i=me,x=t.open,k=t.onOpenChange,b="Command palette",v="Search for a Cogpit action to run.",w="max-w-xl",c=ue,C="Search commands",g=!0,e[16]===Symbol.for("react.memo_cache_sentinel")?(y=u.jsx(he,{"aria-label":"Search commands",autoFocus:!0,placeholder:"Search commands..."}),e[16]=y):y=e[16],e[17]!==t.loadingNavigation?(f=t.loadingNavigation&&u.jsxs("div",{className:"motion-enter flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",role:"status",children:[u.jsx(le,{className:"size-3.5"}),"Loading projects and sessions..."]}),e[17]=t.loadingNavigation,e[18]=f):f=e[18],s=ge,m="max-h-[min(26rem,60vh)]",e[19]===Symbol.for("react.memo_cache_sentinel")?(d=u.jsx(fe,{children:"No matching actions."}),e[19]=d):d=e[19],r=D.map(n=>u.jsx(ce,{heading:n.value,children:n.items.map(l=>{const j=l.icon;return u.jsxs(re,{value:l.value,onSelect:()=>F(l),children:[u.jsx(j,{"aria-hidden":"true"}),u.jsxs("span",{className:"min-w-0 flex-1",children:[u.jsx("span",{className:"block truncate",children:l.label}),l.description&&u.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:l.description})]}),l.shortcut&&u.jsx(de,{children:l.shortcut})]},l.id)})},n.value)),e[0]=t,e[1]=s,e[2]=c,e[3]=i,e[4]=m,e[5]=d,e[6]=v,e[7]=w,e[8]=r,e[9]=C,e[10]=g,e[11]=y,e[12]=f,e[13]=x,e[14]=k,e[15]=b}else s=e[1],c=e[2],i=e[3],m=e[4],d=e[5],v=e[6],w=e[7],r=e[8],C=e[9],g=e[10],y=e[11],f=e[12],x=e[13],k=e[14],b=e[15];let T;e[20]!==s||e[21]!==m||e[22]!==d||e[23]!==r?(T=u.jsxs(s,{className:m,children:[d,r]}),e[20]=s,e[21]=m,e[22]=d,e[23]=r,e[24]=T):T=e[24];let O;e[25]!==c||e[26]!==T||e[27]!==C||e[28]!==g||e[29]!==y||e[30]!==f?(O=u.jsxs(c,{label:C,loop:g,children:[y,f,T]}),e[25]=c,e[26]=T,e[27]=C,e[28]=g,e[29]=y,e[30]=f,e[31]=O):O=e[31];let N;return e[32]!==i||e[33]!==v||e[34]!==w||e[35]!==O||e[36]!==x||e[37]!==k||e[38]!==b?(N=u.jsx(i,{open:x,onOpenChange:k,title:b,description:v,className:w,children:O}),e[32]=i,e[33]=v,e[34]=w,e[35]=O,e[36]=x,e[37]=k,e[38]=b,e[39]=N):N=e[39],N}async function ae(t,e){const s=await ye(t,{signal:e});if(!s.ok)throw new Error(`Request failed (${s.status})`);const c=await s.json();return Array.isArray(c)?c:[]}function Ye(t){var J;const e=oe.c(48);let s,c,i,m,d,v;e[0]!==t?({open:i,currentProjectDirName:s,projectCwd:d,onProcessStarted:c,launchTerminalRequest:v,...m}=t,e[0]=t,e[1]=s,e[2]=c,e[3]=i,e[4]=m,e[5]=d,e[6]=v):(s=e[1],c=e[2],i=e[3],m=e[4],d=e[5],v=e[6]);const w=v===void 0?0:v,r=ve();let C;e[7]===Symbol.for("react.memo_cache_sentinel")?(C=[],e[7]=C):C=e[7];const[g,y]=M.useState(C);let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=[],e[8]=f):f=e[8];const[x,k]=M.useState(f),[b,T]=M.useState(!1),O=M.useRef(0);let N,$;e[9]!==i?(N=()=>{if(!i)return;const S=new AbortController;return T(!0),Promise.allSettled([ae("/api/projects",S.signal),ae("/api/active-sessions?limit=12&perProject=3",S.signal)]).then(H=>{const[V,X]=H;S.signal.aborted||(y(V.status==="fulfilled"?V.value:[]),k(X.status==="fulfilled"?X.value:[]),T(!1))}),()=>S.abort()},$=[i],e[9]=i,e[10]=N,e[11]=$):(N=e[10],$=e[11]),M.useEffect(N,$);let I;e:{if(d){I=d;break e}if(!s){I=null;break e}let S;e[12]!==s||e[13]!==g?(S=((J=g.find(H=>H.dirName===s))==null?void 0:J.path)??null,e[12]=s,e[13]=g,e[14]=S):S=e[14],I=S}const o=I;let E;e[15]!==c||e[16]!==r||e[17]!==o?(E=()=>{if(!o)return;const S=r.spawnTerminal({cwd:o}),H=o.replace(/\/+$/,"").split("/").at(-1)||"Terminal";c({id:S,name:H,type:"terminal",status:"running",source:o})},e[15]=c,e[16]=r,e[17]=o,e[18]=E):E=e[18];const P=E;let R,A;e[19]!==P||e[20]!==w||e[21]!==r.status||e[22]!==o?(R=()=>{w<=O.current||!o||r.status!=="connected"||(O.current=w,P())},A=[P,w,r.status,o],e[19]=P,e[20]=w,e[21]=r.status,e[22]=o,e[23]=R,e[24]=A):(R=e[23],A=e[24]),M.useEffect(R,A);let D;e[25]!==s||e[26]!==o?(D={path:o,dirName:s},e[25]=s,e[26]=o,e[27]=D):D=e[27];const F=D;let n;e[28]!==F?(n=()=>Ce(F),e[28]=F,e[29]=n):n=e[29];const l=n;let j;e[30]!==F?(j=()=>je(F),e[30]=F,e[31]=j):j=e[31];const B=j,q=!Y()&&W("hostFiles"),se=W("hostFiles")&&(!Y()||we());let K;e[32]!==o?(K=()=>{o&&Se(o)},e[32]=o,e[33]=K):K=e[33];const ie=K;let L;e[34]!==P||e[35]!==r.status||e[36]!==o?(L=o&&r.status==="connected"&&W("terminal")?P:void 0,e[34]=P,e[35]=r.status,e[36]=o,e[37]=L):L=e[37];const G=o&&se?l:void 0,p=o&&q?B:void 0,U=o?ie:void 0;let z;return e[38]!==b||e[39]!==i||e[40]!==m||e[41]!==g||e[42]!==x||e[43]!==L||e[44]!==G||e[45]!==p||e[46]!==U?(z=u.jsx(We,{...m,open:i,projects:g,recentSessions:x,loadingNavigation:b,onOpenIntegratedTerminal:L,onOpenProjectInEditor:G,onRevealProject:p,onCopyProjectPath:U}),e[38]=b,e[39]=i,e[40]=m,e[41]=g,e[42]=x,e[43]=L,e[44]=G,e[45]=p,e[46]=U,e[47]=z):z=e[47],z}export{Ye as CommandPaletteHost};
@@ -1 +0,0 @@
1
- import{c as G,j as t,r as o}from"./vendor-react-gGw_S5I_.js";import{T as P,a8 as je,a9 as W,aC as X,ac as be,ad as q,aG as se,B as z,w as A,a$ as ye,b0 as Ce,b1 as ke,b2 as ve,b3 as Ne,b4 as Se,b5 as V,b6 as we,b7 as Z,b8 as De,U as ee,Z as ae,b9 as Te,_ as le,$ as ie,a1 as re,a2 as oe,a3 as ce,a4 as de,a5 as ue,ah as Ee,E as Re,y as Ie,z as Oe,G as ze,H as Le,R as Ae,m as $e,I as te,n as Be,aa as Ge,q as Fe,ba as Me}from"./index-C3E35E2A.js";import{af as Pe,B as Ue,b as _e,ab as Ve,ag as He,ah as Ke,ai as me,aj as xe,ak as Je,al as Qe,o as H,X as K,P as Ye,am as fe,an as We,T as Xe,a8 as qe,S as Ze}from"./vendor-ui-BmLOQ5Or.js";import{H as et}from"./HighlightedEditor-D4DdiaD3.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const tt={agent:"bg-muted text-muted-foreground",skill:"bg-muted text-muted-foreground",command:"bg-muted text-muted-foreground",instructions:"bg-muted text-muted-foreground",settings:"bg-muted text-muted-foreground"},nt={agents:{subdir:"agents",fileType:"agent"},skills:{subdir:"skills",fileType:"skill"},commands:{subdir:"commands",fileType:"command"}},ne=["instructions","agents","skills","commands","settings"],st={instructions:{label:"Instructions",icon:He,color:"text-muted-foreground"},agents:{label:"Agents",icon:Ve,color:"text-muted-foreground"},skills:{label:"Skills",icon:_e,color:"text-muted-foreground"},commands:{label:"Commands",icon:Ue,color:"text-muted-foreground"},settings:{label:"Settings",icon:Pe,color:"text-muted-foreground"}};function J(l,e,i){const n=[];for(const s of l)s.type==="directory"&&s.children?n.push(...J(s.children,e,i)):s.type==="file"&&n.push({name:s.name,path:s.path,fileType:s.fileType||"unknown",description:s.description||"",scope:e,pluginName:i,readOnly:s.readOnly??e==="plugin",cli:s.cli,linkTarget:s.linkTarget});return n}function at(l){const e={instructions:[],agents:[],skills:[],commands:[],settings:[]};for(const i of l){const n=J(i.items,i.scope,i.pluginName);for(const s of n)switch(s.fileType){case"instructions":e.instructions.push(s);break;case"agent":e.agents.push(s);break;case"skill":e.skills.push(s);break;case"command":e.commands.push(s);break;case"settings":default:e.settings.push(s)}}return e}function he(l){const e=G.c(5),{scope:i,pluginName:n}=l;if(i==="plugin"&&n){let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(Ke,{"data-icon":"inline-start",className:"size-3"}),e[0]=r):r=e[0];let u;return e[1]!==n?(u=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[r,n]}),e[1]=n,e[2]=u):u=e[2],u}if(i==="project"){let r;return e[3]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[t.jsx(me,{"data-icon":"inline-start",className:"size-3"}),"project"]}),e[3]=r):r=e[3],r}let s;return e[4]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[t.jsx(xe,{"data-icon":"inline-start",className:"size-3"}),"global"]}),e[4]=s):s=e[4],s}const lt={claude:{letter:"C",label:"Loaded by Claude Code"},codex:{letter:"X",label:"Loaded by Codex CLI"}};function pe(l){const e=G.c(10),{cli:i,variant:n}=l,s=n===void 0?"compact":n;if(!i)return null;if(i.length===0){let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(Je,{"data-icon":"inline-start",className:"size-3"}),e[0]=m):m=e[0];const c=s==="full"&&"unlinked";let d;return e[1]!==c?(d=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-warning",title:"Present in the shared source directory but not linked into Claude or Codex",children:[m,c]}),e[1]=c,e[2]=d):d=e[2],d}let r;if(e[3]!==i||e[4]!==s){let m;e[6]!==s?(m=c=>{const d=lt[c];return t.jsx("span",{title:d.label,className:s==="full"?"flex h-5 items-center justify-center rounded border bg-muted px-1.5 text-xs font-medium text-muted-foreground":"flex size-5 items-center justify-center rounded border bg-muted text-xs font-medium text-muted-foreground",children:s==="full"?c:d.letter},c)},e[6]=s,e[7]=m):m=e[7],r=i.map(m),e[3]=i,e[4]=s,e[5]=r}else r=e[5];let u;return e[8]!==r?(u=t.jsx("span",{className:"flex items-center gap-0.5 shrink-0",children:r}),e[8]=r,e[9]=u):u=e[9],u}function ge(l){const e=G.c(10),{linkTarget:i,variant:n,className:s}=l,r=n===void 0?"compact":n;if(!i)return null;let u;e[0]!==s?(u=P("flex min-w-0 shrink-0 items-center gap-1 text-info",s),e[0]=s,e[1]=u):u=e[1];const m=`Symlink → ${i}`;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx(Qe,{"data-icon":"inline-start",className:"size-3 shrink-0"}),e[2]=c):c=e[2];let d;e[3]!==i||e[4]!==r?(d=r==="full"&&t.jsxs("span",{className:"truncate font-mono text-xs",children:["→ ",i]}),e[3]=i,e[4]=r,e[5]=d):d=e[5];let g;return e[6]!==u||e[7]!==m||e[8]!==d?(g=t.jsxs("span",{className:u,title:m,children:[c,d]}),e[6]=u,e[7]=m,e[8]=d,e[9]=g):g=e[9],g}function it({globalDir:l,projectDir:e,fileType:i,onCreated:n,onCancel:s}){const[r,u]=o.useState(""),[m,c]=o.useState(e?"project":"global"),[d,g]=o.useState(!1),N=o.useRef(null),k=o.useId();o.useEffect(()=>{var h;(h=N.current)==null||h.focus()},[]);const S=m==="project"&&e?e:l,f=!!l&&!!e;async function w(){if(!(!r.trim()||!S)){g(!0);try{const h=await A("/api/config-browser/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dir:S,fileType:i,name:r.trim()})});if(h.ok){const p=await h.json();n(p.path,i,m)}}finally{g(!1)}}}return t.jsxs(je,{className:"gap-3 px-3 py-2",children:[f&&t.jsxs(W,{children:[t.jsx(X,{children:"Scope"}),t.jsxs(be,{"aria-label":"File scope",value:[m],onValueChange:h=>{const p=h[0];(p==="global"||p==="project")&&c(p)},variant:"outline",size:"sm",spacing:0,className:"w-full",children:[t.jsxs(q,{value:"global",className:"flex-1",children:[t.jsx(xe,{"data-icon":"inline-start"}),"Global"]}),t.jsxs(q,{value:"project",className:"flex-1",children:[t.jsx(me,{"data-icon":"inline-start"}),"Project"]})]})]}),t.jsxs(W,{children:[t.jsxs(X,{htmlFor:k,children:[i.charAt(0).toUpperCase()+i.slice(1)," name"]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(se,{id:k,ref:N,type:"text",value:r,onChange:h=>u(h.target.value),onKeyDown:h=>{h.key==="Enter"&&w(),h.key==="Escape"&&s()},placeholder:`${i} name...`,className:"h-7 min-w-0 flex-1 text-xs",disabled:d}),t.jsx(z,{variant:"ghost",size:"icon-xs","aria-label":`Create ${i}`,onClick:()=>void w(),disabled:d||!r.trim()||!S,children:t.jsx(H,{"data-icon":"inline-start"})}),t.jsx(z,{variant:"ghost",size:"icon-xs","aria-label":"Cancel create",onClick:s,children:t.jsx(K,{"data-icon":"inline-start"})})]})]})]})}function rt(l){const e=G.c(50),{category:i,items:n,selectedPath:s,onSelect:r,onNewFile:u,onDeleteItem:m,onRenameItem:c,renamingPath:d,renameValue:g,onRenameValueChange:N,onRenameSubmit:k,onRenameCancel:S,creatingInCategory:f,onCreated:w,onCancelCreate:h}=l,p=st[i],j=p.icon;if(n.length===0&&!u)return null;let D;e[0]!==p.color?(D=P("size-3.5",p.color),e[0]=p.color,e[1]=D):D=e[1];let T;e[2]!==j||e[3]!==D?(T=t.jsx(j,{"data-icon":"inline-start",className:D}),e[2]=j,e[3]=D,e[4]=T):T=e[4];let y;e[5]!==p.label?(y=t.jsx("span",{className:"flex-1 text-xs font-medium text-muted-foreground",children:p.label}),e[5]=p.label,e[6]=y):y=e[6];let R;e[7]!==n.length?(R=t.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:n.length}),e[7]=n.length,e[8]=R):R=e[8];let C;e[9]!==i||e[10]!==u?(C=u&&t.jsxs(ye,{children:[t.jsx(Ce,{render:t.jsx(z,{variant:"ghost",size:"icon-xs",className:"opacity-0 transition-opacity group-hover:opacity-100","aria-label":`New ${i.slice(0,-1)}`,onClick:u}),children:t.jsx(Ye,{"data-icon":"inline-start"})}),t.jsxs(ke,{children:["New ",i.slice(0,-1)]})]}),e[9]=i,e[10]=u,e[11]=C):C=e[11];let v;e[12]!==T||e[13]!==y||e[14]!==R||e[15]!==C?(v=t.jsxs("div",{className:"group flex h-8 items-center gap-1.5 px-3",children:[T,y,R,C]}),e[12]=T,e[13]=y,e[14]=R,e[15]=C,e[16]=v):v=e[16];let E;if(e[17]!==n||e[18]!==m||e[19]!==S||e[20]!==c||e[21]!==k||e[22]!==N||e[23]!==r||e[24]!==g||e[25]!==d||e[26]!==s){let B;e[28]!==m||e[29]!==S||e[30]!==c||e[31]!==k||e[32]!==N||e[33]!==r||e[34]!==g||e[35]!==d||e[36]!==s?(B=b=>{const U=s===b.path;if(d===b.path)return t.jsxs("div",{className:"flex items-center gap-1 border-l-2 border-foreground/30 bg-accent px-3 py-1",children:[t.jsx(se,{value:g,onChange:L=>N(L.target.value),onKeyDown:L=>{L.key==="Enter"&&k(),L.key==="Escape"&&S()},autoFocus:!0,className:"h-7 min-w-0 flex-1 text-xs"}),t.jsx(z,{variant:"ghost",size:"icon-xs","aria-label":"Save name",onClick:k,disabled:!g.trim(),children:t.jsx(H,{"data-icon":"inline-start"})}),t.jsx(z,{variant:"ghost",size:"icon-xs","aria-label":"Cancel rename",onClick:S,children:t.jsx(K,{"data-icon":"inline-start"})})]},b.path);const F=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-sm",children:b.name}),t.jsx(ge,{linkTarget:b.linkTarget}),b.readOnly&&t.jsx(fe,{className:"size-2.5 shrink-0 text-muted-foreground/40"})]}),b.description&&t.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:b.description})]}),t.jsx(pe,{cli:b.cli}),t.jsx(he,{scope:b.scope,pluginName:b.pluginName})]}),M=P("flex w-full items-center gap-2 border-l-2 px-3 py-2 text-left text-sm transition-colors",U?"border-foreground/30 bg-accent text-accent-foreground":"border-transparent text-muted-foreground hover:bg-accent hover:text-foreground");return!m||!c?t.jsx("button",{type:"button",className:M,onClick:()=>r(b),children:F},b.path):t.jsxs(ve,{children:[t.jsx(Ne,{render:t.jsx("button",{type:"button",className:M,onClick:()=>r(b)}),children:F}),t.jsx(Se,{className:"min-w-36",children:b.readOnly?t.jsx(V,{children:t.jsx(we,{children:"Read-only file"})}):t.jsxs(t.Fragment,{children:[t.jsx(V,{children:t.jsx(Z,{onClick:()=>c(b),children:"Rename"})}),t.jsx(De,{}),t.jsx(V,{children:t.jsx(Z,{variant:"destructive",onClick:()=>m(b),children:"Delete"})})]})})]},b.path)},e[28]=m,e[29]=S,e[30]=c,e[31]=k,e[32]=N,e[33]=r,e[34]=g,e[35]=d,e[36]=s,e[37]=B):B=e[37],E=n.map(B),e[17]=n,e[18]=m,e[19]=S,e[20]=c,e[21]=k,e[22]=N,e[23]=r,e[24]=g,e[25]=d,e[26]=s,e[27]=E}else E=e[27];let I;e[38]!==f||e[39]!==n.length?(I=n.length===0&&!f&&t.jsx("p",{className:"px-3 py-1 text-xs text-muted-foreground",children:"None configured"}),e[38]=f,e[39]=n.length,e[40]=I):I=e[40];let O;e[41]!==f||e[42]!==h||e[43]!==w?(O=f&&t.jsx(it,{globalDir:f.globalDir,projectDir:f.projectDir,fileType:f.fileType,onCreated:w,onCancel:h}),e[41]=f,e[42]=h,e[43]=w,e[44]=O):O=e[44];let $;return e[45]!==v||e[46]!==E||e[47]!==I||e[48]!==O?($=t.jsxs("section",{children:[v,E,I,O]}),e[45]=v,e[46]=E,e[47]=I,e[48]=O,e[49]=$):$=e[49],$}function ot({file:l,onDeleted:e,readOnly:i=!1}){const[n,s]=o.useState(null),[r,u]=o.useState(null),[m,c]=o.useState(!0),[d,g]=o.useState(!1),[N,k]=o.useState(!1),[S,f]=o.useState(!1),[w,h]=o.useState(!1),p=n!==null&&n!==r,j=i||l.readOnly;o.useEffect(()=>{c(!0),s(null),u(null),k(!1),f(!1),A(`/api/config-browser/file?path=${encodeURIComponent(l.path)}`).then(C=>C.json()).then(C=>{s(C.content??""),u(C.content??"")}).catch(()=>{s(""),u("")}).finally(()=>c(!1))},[l.path]);const D=o.useCallback(async()=>{if(!(!p||j)){g(!0);try{(await A("/api/config-browser/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:l.path,content:n})})).ok&&(u(n),k(!0),setTimeout(()=>k(!1),2e3))}finally{g(!1)}}},[n,l.path,p,j]),T=o.useCallback(()=>{s(r)},[r]),y=o.useCallback(async()=>{if(!j){h(!0);try{(await A(`/api/config-browser/file?path=${encodeURIComponent(l.path)}`,{method:"DELETE"})).ok&&(f(!1),e())}catch{}finally{h(!1)}}},[l.path,j,e]);o.useEffect(()=>{function C(v){!j&&(v.metaKey||v.ctrlKey)&&v.key==="s"&&(v.preventDefault(),D())}return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[D,j]);function R(){return N?"Saved!":d?"Saving...":"Save"}return t.jsxs("div",{className:"flex flex-1 flex-col min-h-0 min-w-0",children:[t.jsxs("div",{className:"flex min-h-11 shrink-0 items-center gap-2 border-b bg-card px-4 py-2",children:[t.jsx(ee,{variant:"outline",className:P("h-5 text-xs",tt[l.fileType]||"bg-muted text-muted-foreground"),children:l.fileType}),t.jsx(he,{scope:l.scope,pluginName:l.pluginName}),t.jsx(pe,{cli:l.cli,variant:"full"}),j&&t.jsxs(ee,{variant:"outline",className:"h-5 bg-muted text-xs text-muted-foreground",children:[t.jsx(fe,{"data-icon":"inline-start",className:"size-3"})," read-only"]}),p&&t.jsx("span",{className:"size-2 shrink-0 rounded-full bg-warning",title:"Unsaved changes"}),t.jsxs("div",{className:"flex items-center gap-2 ml-auto min-w-0",children:[t.jsx(ge,{linkTarget:l.linkTarget,variant:"full"}),t.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",title:l.path,children:l.path})]})]}),m?t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:"Loading..."}):t.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:[t.jsx(et,{value:n??"",onChange:s,readOnly:j,filePath:l.path}),!j&&t.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-t bg-card px-4 py-2",children:[t.jsxs(z,{size:"xs",onClick:D,disabled:!p||d,children:[t.jsx(H,{"data-icon":"inline-start"}),R()]}),t.jsxs(z,{variant:"outline",size:"xs",onClick:T,disabled:!p,children:[t.jsx(We,{"data-icon":"inline-start"}),"Discard"]}),t.jsx("div",{className:"flex-1"}),t.jsxs(ae,{open:S,onOpenChange:f,children:[t.jsxs(Te,{render:t.jsx(z,{variant:"outline",size:"xs"}),children:[t.jsx(Xe,{"data-icon":"inline-start"}),"Delete"]}),t.jsxs(le,{size:"sm",children:[t.jsxs(ie,{children:[t.jsx(re,{children:"Delete configuration file?"}),t.jsxs(oe,{children:['Delete "',l.name,'" permanently? This action cannot be undone.']})]}),t.jsxs(ce,{children:[t.jsx(de,{size:"sm",disabled:w,children:"Cancel"}),t.jsxs(ue,{variant:"destructive",size:"sm",disabled:w,onClick:()=>void y(),children:[w&&t.jsx(Ee,{"data-icon":"inline-start"}),w?"Deleting...":"Delete file"]})]})]})]})]})]})]})}function ct(){const l=G.c(1);let e;return l[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(Re,{className:"border-0",children:t.jsxs(Ie,{children:[t.jsx(Oe,{variant:"icon",children:t.jsx(qe,{})}),t.jsx(ze,{children:"Select a configuration file"}),t.jsx(Le,{children:"Browse instructions, agents, skills, commands, and settings from the sidebar."})]})}),l[0]=e):e=l[0],e}function dt(l){return l.cli?l.cli.length>0?l.cli.join(" "):"unlinked":""}function ut(l,e){if(!e)return l;const i=e.toLowerCase();return l.filter(n=>[n.name,n.description,n.path,n.linkTarget??"",dt(n)].some(r=>r.toLowerCase().includes(i)))}const jt=o.memo(function({projectPath:e,initialFilePath:i}){var L,Y;const n=Ae("configWrite"),[s,r]=o.useState([]),[u,m]=o.useState(!0),[c,d]=o.useState(null),[g,N]=o.useState(null),[k,S]=o.useState(""),[f,w]=o.useState(null),[h,p]=o.useState(""),[j,D]=o.useState(null),T=o.useRef(!1),y=o.useCallback(async()=>{if(!n){r([]),d(null),m(!1);return}m(!0);try{const a=e?`/api/config-browser/tree?cwd=${encodeURIComponent(e)}`:"/api/config-browser/tree",x=await A(a);if(x.ok){const _=await x.json();r(_.sections||[])}}finally{m(!1)}},[n,e]);o.useEffect(()=>{y()},[y]),o.useEffect(()=>{if(!i||u||T.current)return;const a=s.flatMap(x=>J(x.items,x.scope,x.pluginName)).find(x=>x.path===i);a&&(d(a),T.current=!0)},[i,u,s]);const R=at(s),C=Object.fromEntries(ne.map(a=>[a,ut(R[a],k)])),v=(L=s.find(a=>a.scope==="global"))==null?void 0:L.baseDir,E=(Y=s.find(a=>a.scope==="project"))==null?void 0:Y.baseDir,I=o.useCallback(a=>{d(a),N(null)},[]),O=o.useCallback((a,x,_)=>{N(null),y(),d({path:a,name:a.split("/").pop()||"",fileType:x,readOnly:!1,scope:_,description:""})},[y]),$=o.useCallback(()=>{d(null),y()},[y]),B=o.useCallback(a=>{if(!n||!v&&!E)return;const x=nt[a];x&&N({category:a,globalDir:v?`${v}/${x.subdir}`:null,projectDir:E?`${E}/${x.subdir}`:null,fileType:x.fileType})},[n,v,E]),b=o.useCallback(a=>{!n||a.readOnly||D(a)},[n]),U=o.useCallback(async()=>{if(!n||!j||j.readOnly)return;const a=j;D(null);try{(await A(`/api/config-browser/file?path=${encodeURIComponent(a.path)}`,{method:"DELETE"})).ok&&((c==null?void 0:c.path)===a.path&&d(null),y())}catch{}},[n,y,j,c]),Q=o.useCallback(a=>{if(!n||a.readOnly)return;const x=a.name==="SKILL.md"?a.path.split("/").slice(-2,-1)[0]||a.name:a.name.replace(/\.[^.]+$/,"");w(a),p(x)},[n]),F=o.useCallback(async()=>{if(!(!n||!f||!h.trim()))try{const a=await A("/api/config-browser/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPath:f.path,newName:h.trim()})});if(a.ok){const x=await a.json();w(null),p(""),await y(),x.newPath&&d({...f,path:x.newPath,name:x.newPath.split("/").pop()||f.name})}}catch{}},[n,f,h,y]),M=o.useCallback(()=>{w(null),p("")},[]);return n?t.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0",children:[t.jsxs("div",{className:"flex min-h-0 w-80 shrink-0 flex-col border-r bg-sidebar",children:[t.jsxs("div",{className:"flex h-11 items-center gap-2 border-b px-3",children:[t.jsx("span",{className:"text-sm font-medium text-foreground",children:"Configuration"}),e&&t.jsx("span",{className:"ml-auto truncate text-xs text-muted-foreground",title:e,children:e.split("/").pop()})]}),t.jsx("div",{className:"border-b p-2",children:t.jsxs($e,{children:[t.jsx(te,{children:t.jsx(Ze,{"data-icon":"inline-start"})}),t.jsx(Be,{value:k,onChange:a=>S(a.target.value),placeholder:"Search configuration"}),k&&t.jsx(te,{align:"inline-end",children:t.jsx(Ge,{size:"icon-xs","aria-label":"Clear search",onClick:()=>S(""),children:t.jsx(K,{"data-icon":"inline-start"})})})]})}),t.jsx(Fe,{className:"flex-1",children:t.jsx("div",{className:"flex flex-col gap-1 py-2",children:u?t.jsx("div",{className:"flex flex-col gap-2 px-3 py-2","aria-label":"Loading configuration",children:Array.from({length:6},(a,x)=>t.jsx(Me,{className:"h-8 w-full"},x))}):ne.map(a=>{const x=a==="agents"||a==="skills"||a==="commands";return t.jsx(rt,{category:a,items:C[a],selectedPath:(c==null?void 0:c.path)??null,onSelect:I,onNewFile:n&&x?()=>B(a):void 0,onDeleteItem:n?b:void 0,onRenameItem:n?Q:void 0,renamingPath:(f==null?void 0:f.path)??null,renameValue:h,onRenameValueChange:p,onRenameSubmit:F,onRenameCancel:M,creatingInCategory:n&&(g==null?void 0:g.category)===a?g:null,onCreated:O,onCancelCreate:()=>N(null)},a)})})})]}),c?t.jsx(ot,{file:c,onDeleted:$,readOnly:!n}):t.jsx(ct,{}),t.jsx(ae,{open:j!==null,onOpenChange:a=>{a||D(null)},children:t.jsxs(le,{size:"sm",children:[t.jsxs(ie,{children:[t.jsx(re,{children:"Delete configuration file?"}),t.jsxs(oe,{children:['Delete "',j==null?void 0:j.name,'" permanently? This action cannot be undone.']})]}),t.jsxs(ce,{children:[t.jsx(de,{size:"sm",children:"Cancel"}),t.jsx(ue,{variant:"destructive",size:"sm",onClick:()=>void U(),children:"Delete file"})]})]})})]}):t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"Server configuration is available to administrators only."})});export{jt as ConfigBrowser};
@@ -1 +0,0 @@
1
- import{c as U,r as A,j as t}from"./vendor-react-gGw_S5I_.js";import{v as X,w as Y,i as Z,j as _,k as ee,C as te,x as se,E as ae,y as ne,z as oe,G as ie,H as le,J as q,L as J,M as re,N as de,h as ce,O as me,D as he,P as ue,Q as fe}from"./index-C3E35E2A.js";import{F as Q,a as xe}from"./vendor-ui-BmLOQ5Or.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";function ge(v){const e=U.c(56),{open:l,onClose:n,onNewSession:c,onNewFolder:H,defaultAgentKind:O,currentProjectDirName:u,currentProjectCwd:m}=v;let S;e[0]===Symbol.for("react.memo_cache_sentinel")?(S=[],e[0]=S):S=e[0];const[i,R]=A.useState(S),[r,W]=A.useState("");let P,D;e[1]!==l?(P=()=>{l&&(W(""),Y("/api/projects").then(pe).then(s=>R(s)).catch(()=>R([])))},D=[l],e[1]=l,e[2]=P,e[3]=D):(P=e[2],D=e[3]),A.useEffect(P,D);let E,F;e[4]!==m||e[5]!==u||e[6]!==n||e[7]!==c||e[8]!==l||e[9]!==i?(E=()=>{if(!l)return;const s=function(h){var g;if(ue("newSession",h)&&u){h.preventDefault();const V=m?fe(i,m)??((g=i.find(B=>B.path===m))==null?void 0:g.dirName)??u:u;c(V,m??void 0),n()}};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},F=[l,i,u,m,c,n],e[4]=m,e[5]=u,e[6]=n,e[7]=c,e[8]=l,e[9]=i,e[10]=E,e[11]=F):(E=e[10],F=e[11]),A.useEffect(E,F);const{names:d}=X();let T;e:{if(!r){T=i;break e}let s;if(e[12]!==r||e[13]!==d||e[14]!==i){const a=r.toLowerCase();s=i.filter(h=>{var g;return h.path.toLowerCase().includes(a)||h.shortName.toLowerCase().includes(a)||h.dirName.toLowerCase().includes(a)||((g=d[h.dirName])==null?void 0:g.toLowerCase().includes(a))}),e[12]=r,e[13]=d,e[14]=i,e[15]=s}else s=e[15];T=s}const G=T;let o,f,b;e[16]!==r?(o=r.trim(),f=o.replace(/[\\/]+$/,"")||o,b=o.startsWith("/")||/^[a-z]:[\\/]/i.test(o)||o.startsWith("\\\\"),e[16]=r,e[17]=o,e[18]=f,e[19]=b):(o=e[17],f=e[18],b=e[19]);const I=b;let L;e[20]!==I||e[21]!==f||e[22]!==i?(L=I&&!i.some(s=>(s.path.replace(/[\\/]+$/,"")||s.path)===f),e[20]=I,e[21]=f,e[22]=i,e[23]=L):L=e[23];const K=L;let k;e[24]!==n||e[25]!==c?(k=s=>{c(s.dirName,s.path),n()},e[24]=n,e[25]=c,e[26]=k):k=e[26];const y=k;let x;e[27]!==n?(x=s=>{s||n()},e[27]=n,e[28]=x):x=e[28];let z;e[29]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsxs(Z,{className:"sr-only",children:[t.jsx(_,{children:"Start a session"}),t.jsx(ee,{children:"Choose a project or enter an absolute folder path."})]}),e[29]=z):z=e[29];let p;e[30]!==r?(p=t.jsx(te,{autoFocus:!0,placeholder:"Search projects or paste an absolute path...",value:r,onValueChange:W}),e[30]=r,e[31]=p):p=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsx(se,{className:"py-0",children:t.jsx(ae,{className:"border-0 py-8",children:t.jsxs(ne,{children:[t.jsx(oe,{variant:"icon",children:t.jsx(Q,{})}),t.jsx(ie,{children:"No projects found"}),t.jsx(le,{children:"Try another name or paste an absolute path."})]})})}),e[32]=M):M=e[32];let N;e[33]!==K||e[34]!==O||e[35]!==o||e[36]!==n||e[37]!==H?(N=K&&t.jsxs(q,{value:`folder:${o}`,className:"motion-list-item h-auto gap-3 px-3 py-2.5",onSelect:()=>{H(o),n()},children:[t.jsx(xe,{"data-icon":"inline-start",className:"size-4 shrink-0 text-foreground"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-sm font-medium",children:"Start in this folder"}),t.jsxs("div",{className:"truncate text-xs text-muted-foreground",children:[o," · ",O==="codex"?"Codex":"Claude"]})]})]}),e[33]=K,e[34]=O,e[35]=o,e[36]=n,e[37]=H,e[38]=N):N=e[38];let j;if(e[39]!==G||e[40]!==y||e[41]!==d){let s;e[43]!==y||e[44]!==d?(s=a=>t.jsxs(q,{value:`project:${a.dirName}`,className:"motion-list-item h-auto gap-3 px-3 py-2.5",onSelect:()=>y(a),children:[t.jsx(Q,{"data-icon":"inline-start",className:"size-4 shrink-0 text-muted-foreground"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate text-sm font-medium",children:d[a.dirName]||J(a.path)}),t.jsxs("div",{className:"text-xs text-muted-foreground",children:[d[a.dirName]&&t.jsx("span",{className:"mr-1.5",children:J(a.path)}),a.sessionCount," session",a.sessionCount!==1?"s":"",a.lastModified&&t.jsxs(t.Fragment,{children:[" · ",new Date(a.lastModified).toLocaleDateString()]})]})]})]},a.dirName),e[43]=y,e[44]=d,e[45]=s):s=e[45],j=G.map(s),e[39]=G,e[40]=y,e[41]=d,e[42]=j}else j=e[42];let C;e[46]!==N||e[47]!==j?(C=t.jsxs(re,{className:"max-h-80 p-1",children:[M,t.jsxs(de,{className:"p-0",children:[N,j]})]}),e[46]=N,e[47]=j,e[48]=C):C=e[48];let w;e[49]!==p||e[50]!==C?(w=t.jsxs(ce,{className:"max-w-md gap-0 overflow-hidden p-0",children:[z,t.jsxs(me,{shouldFilter:!1,className:"rounded-none p-0",children:[p,C]})]}),e[49]=p,e[50]=C,e[51]=w):w=e[51];let $;return e[52]!==l||e[53]!==x||e[54]!==w?($=t.jsx(he,{open:l,onOpenChange:x,children:w}),e[52]=l,e[53]=x,e[54]=w,e[55]=$):$=e[55],$}function pe(v){return v.ok?v.json():[]}export{ge as ProjectSwitcherModal};
@@ -1 +0,0 @@
1
- import{r as h,j as e}from"./vendor-react-gGw_S5I_.js";import{R as Y,d as Z,c as K,S as Q,a as _,B as x,T as S,b as ee,E as se,y as te,z as ne,G as re,H as ae,U as ie,V as le,W as oe,X as ce,Y as de,Z as A,_ as R,$ as E,a0 as he,a1 as T,a2 as U,a3 as z,a4 as $,a5 as F,w as u,a6 as c}from"./index-C3E35E2A.js";import{G as P,b as xe,c as me,E as ue,d as pe,T as O,C as je,e as ge}from"./vendor-ui-BmLOQ5Or.js";import"./vendor-shiki-DOn6sF-i.js";import"./vendor-markdown-BE1gYnO9.js";const fe={M:"text-warning",A:"text-success",D:"text-destructive",R:"text-info"};function we({open:I,onOpenChange:H,worktrees:v,loading:p,dirName:a,onRefetch:j,onOpenSession:M}){const o=Y("hostFiles"),[B,y]=h.useState(null),[G,b]=h.useState(null),[J,m]=h.useState(!1),[t,d]=h.useState(null),[r,g]=h.useState(null),C=async s=>{if(!(!o||!a)){y(s.name);try{await u(`/api/worktrees/${encodeURIComponent(a)}/${encodeURIComponent(s.name)}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({force:s.isDirty})}),j()}catch(n){c.error(`Failed to delete worktree: ${n instanceof Error?n.message:"Unknown error"}`)}finally{y(null)}}},W=s=>{if(!(!o||!a)){if(s.isDirty){d({worktree:s,reason:"dirty"});return}if(s.commitsAhead>0){d({worktree:s,reason:"unpushed"});return}C(s)}},L=()=>{if(!t)return;const{worktree:s,reason:n}=t;if(n==="dirty"&&s.commitsAhead>0){d({worktree:s,reason:"unpushed"});return}d(null),C(s)},q=async s=>{if(!(!o||!a)){b(s.name);try{const n=await u(`/api/worktrees/${encodeURIComponent(a)}/create-pr`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreeName:s.name,title:s.name.replace(/-/g," ")})});if(n.ok){const l=await n.json();l.url?window.open(l.url,"_blank","noopener,noreferrer"):c.warning("PR created but no URL was returned")}else{const l=await n.json().catch(()=>({error:"Unknown error"}));c.error(`Failed to create PR: ${l.error||"Unknown error"}`)}}catch(n){c.error(`Error creating PR: ${n instanceof Error?n.message:"Unknown error"}`)}finally{b(null)}}},V=async()=>{if(!(!o||!a)){m(!0);try{const s=await u(`/api/worktrees/${encodeURIComponent(a)}/cleanup`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});if(s.ok){const{stale:n}=await s.json();n.length===0?c.info("No stale worktrees found"):g(n.map(l=>l.name))}}catch(s){c.error(`Cleanup failed: ${s instanceof Error?s.message:"Unknown error"}`)}finally{m(!1)}}},X=async()=>{if(!o||!a||!r)return;const s=r;g(null),m(!0);try{await u(`/api/worktrees/${encodeURIComponent(a)}/cleanup`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirm:!0,names:s})}),j()}catch(n){c.error(`Cleanup failed: ${n instanceof Error?n.message:"Unknown error"}`)}finally{m(!1)}};return e.jsxs(Z,{open:I,onOpenChange:H,children:[e.jsxs(K,{children:[e.jsxs(Q,{children:[e.jsxs("div",{className:"flex items-center justify-between pr-8",children:[e.jsxs(_,{className:"flex items-center gap-2",children:[e.jsx(P,{"data-icon":"inline-start",className:"size-4"}),"Worktrees"]}),e.jsxs("div",{className:"flex items-center gap-1",children:[o&&e.jsx(x,{variant:"ghost",size:"icon-xs",onClick:V,disabled:J,"aria-label":"Cleanup stale worktrees",children:e.jsx(xe,{"data-icon":"inline-start"})}),e.jsx(x,{variant:"ghost",size:"icon-xs",onClick:j,disabled:p,"aria-label":"Refresh worktrees",children:e.jsx(me,{"data-icon":"inline-start",className:S(p&&"animate-spin")})})]})]}),e.jsx(ee,{children:"Review isolated branches and their file changes."})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-2 overflow-y-auto p-3",children:[!a&&e.jsx("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:"Select a project to view worktrees"}),a&&v.length===0&&!p&&e.jsx(se,{className:"border-0 py-16",children:e.jsxs(te,{children:[e.jsx(ne,{variant:"icon",children:e.jsx(P,{})}),e.jsx(re,{children:"No worktrees"}),e.jsx(ae,{children:"Create a new session with “Isolate in worktree” enabled"})]})}),v.map(s=>{var w,N,D;const n=((w=s.changedFiles)==null?void 0:w.reduce((i,k)=>i+k.additions,0))??0,l=((N=s.changedFiles)==null?void 0:N.reduce((i,k)=>i+k.deletions,0))??0,f=((D=s.changedFiles)==null?void 0:D.length)??0;return e.jsxs("div",{className:"rounded-lg border bg-card p-3 transition-colors hover:bg-accent/40",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:s.name}),s.isDirty&&e.jsx("span",{className:"flex size-2 shrink-0 rounded-full bg-warning",title:"Uncommitted changes"}),s.commitsAhead>0&&e.jsxs(ie,{variant:"outline",className:"h-5 shrink-0 px-1.5 text-xs",children:[s.commitsAhead," ahead"]})]}),e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[s.linkedSessions.length>0&&e.jsx(x,{variant:"ghost",size:"icon-xs",onClick:()=>M(s.linkedSessions[0]),"aria-label":"Open session",children:e.jsx(ue,{"data-icon":"inline-start"})}),o&&e.jsxs(e.Fragment,{children:[e.jsx(x,{variant:"ghost",size:"icon-xs",onClick:()=>q(s),disabled:G===s.name||s.commitsAhead===0,"aria-label":"Create PR",children:e.jsx(pe,{"data-icon":"inline-start"})}),e.jsx(x,{variant:"ghost",size:"icon-xs",onClick:()=>W(s),disabled:B===s.name,className:"text-destructive hover:bg-destructive/10 hover:text-destructive","aria-label":"Delete worktree",children:e.jsx(O,{"data-icon":"inline-start"})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-mono shrink-0",children:s.head}),e.jsx("span",{className:"truncate",children:s.headMessage})]}),s.createdAt&&e.jsx("div",{className:"mt-0.5 text-xs text-muted-foreground",children:le(s.createdAt)}),f>0&&e.jsxs(oe,{className:"mt-2",children:[e.jsxs(ce,{className:"group flex w-full items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(je,{"data-icon":"inline-start",className:"size-3 transition-transform group-data-panel-open:rotate-90 motion-reduce:transition-none"}),e.jsx(ge,{"data-icon":"inline-start",className:"size-3"}),e.jsxs("span",{children:[f," file",f!==1?"s":""," changed"]}),e.jsxs("span",{className:"ml-1",children:[e.jsxs("span",{className:"text-success",children:["+",n]})," ",e.jsxs("span",{className:"text-destructive",children:["-",l]})]})]}),e.jsx(de,{children:e.jsx("div",{className:"mt-1.5 flex flex-col gap-px rounded-md bg-muted/40 p-1.5",children:s.changedFiles.map(i=>e.jsxs("div",{className:"flex items-center gap-2 px-1 py-0.5 font-mono text-xs",children:[e.jsx("span",{className:S("shrink-0 w-3 text-center",fe[i.status]??"text-muted-foreground"),children:i.status}),e.jsx("span",{className:"truncate text-foreground/80",children:i.path}),e.jsxs("span",{className:"ml-auto shrink-0 text-muted-foreground",children:[e.jsxs("span",{className:"text-success",children:["+",i.additions]})," ",e.jsxs("span",{className:"text-destructive",children:["-",i.deletions]})]})]},i.path))})})]})]},s.name)})]})]}),e.jsx(A,{open:t!==null,onOpenChange:s=>{s||d(null)},children:e.jsxs(R,{size:"sm",children:[e.jsxs(E,{children:[e.jsx(he,{className:"bg-destructive/10 text-destructive",children:e.jsx(O,{})}),e.jsx(T,{children:(t==null?void 0:t.reason)==="dirty"?"Delete worktree with uncommitted changes?":"Delete worktree with unpushed commits?"}),e.jsxs(U,{children:[(t==null?void 0:t.reason)==="dirty"?`"${t.worktree.name}" has uncommitted changes.`:`"${t==null?void 0:t.worktree.name}" has ${t==null?void 0:t.worktree.commitsAhead} unpushed commit(s).`," "," ","Deleting it cannot be undone."]})]}),e.jsxs(z,{children:[e.jsx($,{size:"sm",children:"Cancel"}),e.jsx(F,{variant:"destructive",size:"sm",onClick:L,children:(t==null?void 0:t.reason)==="dirty"&&t.worktree.commitsAhead>0?"Continue":"Delete worktree"})]})]})}),e.jsx(A,{open:r!==null,onOpenChange:s=>{s||g(null)},children:e.jsxs(R,{children:[e.jsxs(E,{children:[e.jsx(T,{children:"Remove stale worktrees?"}),e.jsxs(U,{children:[r==null?void 0:r.length," stale worktree",(r==null?void 0:r.length)===1?"":"s"," will be removed: ",r==null?void 0:r.join(", "),"."]})]}),e.jsxs(z,{children:[e.jsx($,{size:"sm",children:"Cancel"}),e.jsx(F,{variant:"destructive",size:"sm",onClick:()=>void X(),children:"Remove worktrees"})]})]})})]})}export{we as WorktreePanel};