dorkos 0.82.0 → 0.83.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/README.md +4 -0
- package/dist/bin/cli.js +8195 -2918
- package/dist/client/assets/{AboutPage-WmtNTKyp.js → AboutPage-BCPZr0Kt.js} +1 -1
- package/dist/client/assets/{AppearancePage-D7ZHuThu.js → AppearancePage-CJfCCSBv.js} +1 -1
- package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-wUJCR3vL.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-Rg6hvlIh.js} +1 -1
- package/dist/client/assets/{BlintzCanvas-BXKUjnNQ.js → BlintzCanvas-CUSuHP_Q.js} +23 -23
- package/dist/client/assets/{CanvasCsvContent-BLAtnhdQ.js → CanvasCsvContent-B3gnlTxe.js} +1 -1
- package/dist/client/assets/{CanvasFileContent-VogEwZeM.js → CanvasFileContent-C2PyVniO.js} +2 -2
- package/dist/client/assets/{CanvasModel3dContent-DCTC7eOc.js → CanvasModel3dContent-BU77_Cf0.js} +2 -2
- package/dist/client/assets/{CodeMirrorDiff-Cpi43Atp.js → CodeMirrorDiff-Dsell_F0.js} +1 -1
- package/dist/client/assets/{CodeMirrorEditor-CviERH82.js → CodeMirrorEditor-DW4-Dilh.js} +1 -1
- package/dist/client/assets/ConnectionAccessLists-C6PZsSaI.js +1 -0
- package/dist/client/assets/ConnectionsPage-d1mpye9j.js +1 -0
- package/dist/client/assets/{ConventionPage-Coim_h2z.js → ConventionPage-Dto1Cfs1.js} +3 -3
- package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-lqp1rgj8.js → FloatingTanStackRouterDevtools-CqogiFob-B8JWq1xE.js} +1 -1
- package/dist/client/assets/HandlePage-D9x_OTks.js +1 -0
- package/dist/client/assets/{LexicalField-DPe-aAXb.js → LexicalField-BymSjNLW.js} +1 -1
- package/dist/client/assets/{ManagesPage-BZS2TdZL.js → ManagesPage-D0ykMsYy.js} +1 -1
- package/dist/client/assets/{Model3dViewer-qs0tZlVU.js → Model3dViewer-DpzkRmRI.js} +1 -1
- package/dist/client/assets/NamePage-zm23PjaF.js +1 -0
- package/dist/client/assets/{NotificationsPage-gmiItsT0.js → NotificationsPage-C4Ol8NO6.js} +1 -1
- package/dist/client/assets/PermissionsPage-BEtP78wl.js +1 -0
- package/dist/client/assets/{PersonalityPopover-Dej6dI7y.js → PersonalityPopover-xJuTkLLJ.js} +1 -1
- package/dist/client/assets/PhotoPage-DlqgNQWM.js +1 -0
- package/dist/client/assets/{RoomsPage-3_HuXajd.js → RoomsPage-CeB_8k-m.js} +1 -1
- package/dist/client/assets/{RunsOnPopover-DbSoBFaL.js → RunsOnPopover-DT6aWGUP.js} +1 -1
- package/dist/client/assets/{SessionsPage-Dc_lqBom.js → SessionsPage-CoZhOOr9.js} +2 -2
- package/dist/client/assets/SkillsPage-C8bahTTW.js +1 -0
- package/dist/client/assets/{TasksPage-DvzTPDnw.js → TasksPage-CuFN--Cj.js} +1 -1
- package/dist/client/assets/ToolsPage-C5cJiedq.js +2 -0
- package/dist/client/assets/{TopologyGraph-C-BTnRXU.js → TopologyGraph-3rXK5QTB.js} +1 -1
- package/dist/client/assets/{agent-browser-DT3ABR4l.js → agent-browser-DaDOSH9H.js} +1 -1
- package/dist/client/assets/{highlighted-body-KPVGNVTW-CVFODbIg.js → highlighted-body-KPVGNVTW-CGXZGdzv.js} +1 -1
- package/dist/client/assets/{index-Dh-3NGE9.js → index-3xtUyFwf.js} +1 -1
- package/dist/client/assets/{index-CN1plkKF.js → index-4zzP7Qsj.js} +1 -1
- package/dist/client/assets/{index-DN8DYUEX.js → index-B2AJ6tkg.js} +1 -1
- package/dist/client/assets/{index-PRwgIfzy.js → index-B9qRpVKa.js} +3 -3
- package/dist/client/assets/{index-DDXrdlj0.js → index-BMR65QI4.js} +435 -425
- package/dist/client/assets/{index-BrgOWbRQ.js → index-BabO0TEf.js} +2 -2
- package/dist/client/assets/{index-BZaMgVdg.js → index-Bco5PCIk.js} +1 -1
- package/dist/client/assets/{index-CaZw0EC7.js → index-Bg2WUou4.js} +1 -1
- package/dist/client/assets/{index-B8oHvyN5.js → index-BiKxY3b6.js} +1 -1
- package/dist/client/assets/{index-ClnyhFUL.js → index-C4yxotik.js} +1 -1
- package/dist/client/assets/index-C9o2w5d_.js +1 -0
- package/dist/client/assets/{index-DiFc1nSZ.js → index-CUDguphz.js} +1 -1
- package/dist/client/assets/{index-DGr90Ygi.js → index-CUXXDUxt.js} +1 -1
- package/dist/client/assets/{index-DbsvSNI-.js → index-CXeb3CZh.js} +1 -1
- package/dist/client/assets/{index-D_gnDrw3.js → index-Cc8vG2jf.js} +1 -1
- package/dist/client/assets/{index-PrqHZbD1.js → index-Ce4ArSsI.js} +1 -1
- package/dist/client/assets/{index-ByCzVYkU.js → index-CemK6fUn.js} +1 -1
- package/dist/client/assets/{index-nEQI8fB2.js → index-Ck1VEXu0.js} +1 -1
- package/dist/client/assets/{index-W25uMuZA.js → index-D4OPDslu.js} +1 -1
- package/dist/client/assets/index-D9vFzXJR.js +1 -0
- package/dist/client/assets/{index-DjY4p5H5.js → index-DPpw-DKV.js} +1 -1
- package/dist/client/assets/{index-DiFG9bwF.js → index-DQdV5YDl.js} +1 -1
- package/dist/client/assets/{index-Cca_q1vW.js → index-DT376l6b.js} +3 -3
- package/dist/client/assets/index-DZ-SO2sz.css +1 -0
- package/dist/client/assets/{index-DIkpB_1y.js → index-DdpxcyXN.js} +1 -1
- package/dist/client/assets/{index-lciid4H8.js → index-FOgsYoCt.js} +1 -1
- package/dist/client/assets/{index-CgakJfik.js → index-MUbvQBCQ.js} +1 -1
- package/dist/client/assets/{index-DEA1uIWn.js → index-Rf5Yz119.js} +1 -1
- package/dist/client/assets/index-Ygg0URfB.js +1 -0
- package/dist/client/assets/{index-J8BMKg6y.js → index-bR1UztQC.js} +1 -1
- package/dist/client/assets/{index-Dm6W0lml.js → index-dDcguWyg.js} +1 -1
- package/dist/client/assets/{index-BuU7EEtP.js → index-i6WvrE1p.js} +1 -1
- package/dist/client/assets/{index-B3P6TTvD.js → index-oU5xA1N3.js} +3 -3
- package/dist/client/assets/{index-DF5k9E7k.js → index-pBoKYStL.js} +1 -1
- package/dist/client/assets/{index-ClmokM0M.js → index-rJuQe7Pl.js} +1 -1
- package/dist/client/assets/{index-DgjZhEr3.js → index-z0vAkUHY.js} +1 -1
- package/dist/client/assets/{index-kzr7_3di.js → index-zrZDQvuW.js} +11 -11
- package/dist/client/assets/{room-files-source-CSKgcbkn.js → room-files-source-BXF5daqI.js} +2 -2
- package/dist/client/assets/{soul-file-BHeAw6R9.js → soul-file-C1wnpxhH.js} +1 -1
- package/dist/client/assets/{use-mesh-update-BP_UXq60.js → use-mesh-update-CZIA8V07.js} +1 -1
- package/dist/client/assets/{use-personality-commit-DyJAMzzb.js → use-personality-commit-OViAsTwD.js} +1 -1
- package/dist/client/index.html +5 -4
- package/dist/drizzle/0107_productive_peter_parker.sql +5 -0
- package/dist/drizzle/0108_magical_morph.sql +2 -0
- package/dist/drizzle/0109_aspiring_union_jack.sql +5 -0
- package/dist/drizzle/0110_ambiguous_wendigo.sql +1 -0
- package/dist/drizzle/meta/0107_snapshot.json +8966 -0
- package/dist/drizzle/meta/0108_snapshot.json +8980 -0
- package/dist/drizzle/meta/0109_snapshot.json +8987 -0
- package/dist/drizzle/meta/0110_snapshot.json +8994 -0
- package/dist/drizzle/meta/_journal.json +28 -0
- package/dist/server/index.js +82622 -70829
- package/dist/server/index.js.map +2 -2
- package/package.json +1 -2
- package/dist/client/assets/ConnectionAccessLists-Be1b30nn.js +0 -1
- package/dist/client/assets/ConnectionsPage-BVN7GiuC.js +0 -1
- package/dist/client/assets/HandlePage-DnzPN8N_.js +0 -1
- package/dist/client/assets/NamePage-DyWqRDIe.js +0 -1
- package/dist/client/assets/PhotoPage-GtCoB8dK.js +0 -1
- package/dist/client/assets/SkillsPage-C0qMUkgs.js +0 -1
- package/dist/client/assets/ToolsPage-Cwc96TTa.js +0 -2
- package/dist/client/assets/index-BUxNND2H.js +0 -1
- package/dist/client/assets/index-C08DUVQ4.css +0 -1
- package/dist/client/assets/index-CGqPFWQw.js +0 -1
- package/dist/client/assets/index-CXWMnEDK.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{e3 as we,fY as re,aY as W,ef as le,z as U,r as l,fZ as ke,f_ as z,f$ as H,g0 as S,e8 as oe,g1 as J,g2 as q,cV as Ee,g3 as Re,by as je,g4 as Ne,A as V,g5 as De,g6 as Te,ew as Se,g7 as Oe,af as se,g8 as Fe,j as t,aD as ce,ak as de,aP as _e,C as Pe,g9 as Me,da as ue,ga as Le,fc as he,fh as Ae,aj as ae,gb as fe,gc as pe,gd as Ie,eD as ze,eE as Ke,eF as He,eG as K,eH as B,dp as $e,B as Y,dF as Ye,dG as Qe,dH as Ue,dI as qe,dJ as Be,dK as We,dL as Ge,dM as Ve,fn as Xe,ge as Ze,ah as X,gf as me,gg as Je,aX as et,gh as tt,gi as nt,gj as st,gk as at,ee,gl as xe,D as rt,aN as ot,gm as it,gn as lt}from"./index-BMR65QI4.js";import{p as ct,F as dt,w as ut,c as ht}from"./room-files-source-BXF5daqI.js";import{N as Xt,R as Zt}from"./room-files-source-BXF5daqI.js";/**
|
|
2
2
|
* @license lucide-react v1.44.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const ge={name:"file-plus",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]};ge.node;const ft=we(ge),pt=[".git",".dork",".claude",".agents","node_modules"];function mt(e){return e.startsWith(".")||pt.includes(e)}const te=["ROOM.md","README.md"];function ne(e){return te.some(s=>s.toLowerCase()===e.toLowerCase())}function xt(e){return e.filter(s=>!mt(s.name))}function gt(e){if(e.reduce((p,x)=>x.type==="file"&&ne(x.name)?p+1:p,0)===0)return e;const n=[],m=[];for(const p of e)p.type==="file"&&ne(p.name)?n.push(p):m.push(p);return n.sort((p,x)=>te.findIndex(h=>h.toLowerCase()===p.name.toLowerCase())-te.findIndex(h=>h.toLowerCase()===x.name.toLowerCase())),[...n,...m]}function G(e,s,n){return["file-explorer","tree",e.scopeKey,s,e.filtersHidden?n:null]}function ye(e,s,n,m){return{queryKey:G(e,s,n),queryFn:()=>e.list(s,{showHidden:n}),staleTime:re.FILE_TREE_STALE_TIME_MS,gcTime:re.FILE_TREE_GC_TIME_MS,placeholderData:p=>p??m.getQueryData(G(e,s,!n))}}const yt=["CONFLICT","COPY_INTO_SELF","DIR_NOT_EMPTY","NOT_FOUND","REFUSE_ROOT","OUTSIDE_BOUNDARY"];function ve(e){const s=le(e);return s!==void 0&&yt.includes(s)?s:void 0}const Ce="Can’t copy a folder into itself",vt={CONFLICT:"That name already exists",COPY_INTO_SELF:Ce,DIR_NOT_EMPTY:"This folder isn’t empty",NOT_FOUND:"That item no longer exists",REFUSE_ROOT:"Can’t modify the working directory root",OUTSIDE_BOUNDARY:"That path is outside the working directory"};function $(e,s){const n=ve(e);W.error(n?vt[n]:s)}const Ct=/ copy(?: \d+)?$/;function bt({name:e,isDir:s,taken:n}){const m=new Set(n);if(!m.has(e))return e;const p=s?-1:e.lastIndexOf("."),x=p>0,h=x?e.slice(p):"",a=(x?e.slice(0,p):e).replace(Ct,"");for(let f=1;;f+=1){const v=f===1?`${a} copy${h}`:`${a} copy ${f}${h}`;if(!m.has(v))return v}}function ie(e,s,n){return{name:s,path:e,type:n,size:0,mtime:Date.now(),isSymlink:!1}}function wt(e){const s=B(),{source:n,showHidden:m,queryClient:p,inFlightRef:x}=e,h=n.cwd??"",[a,f]=l.useState(null),v=l.useCallback(async r=>{x.current+=1;try{return await r()}finally{x.current-=1}},[x]),i=l.useMemo(()=>{const r=d=>G(n,d,m);return{getChildren:d=>{var g;return((g=p.getQueryData(r(d)))==null?void 0:g.entries)??[]},isLoaded:d=>p.getQueryData(r(d))!==void 0,takenNames:async d=>(await s.readFileTree(h,{path:d===z?void 0:d,showHidden:!0})).entries.map(C=>C.name),snapshot:d=>p.getQueryData(r(d)),setChildren:(d,g)=>{p.setQueryData(r(d),C=>({entries:ke(g((C==null?void 0:C.entries)??[]))}))},restore:(d,g)=>{p.setQueryData(r(d),g)},invalidate:d=>{p.invalidateQueries({queryKey:r(d),exact:!0})}}},[p,s,h,n,m]),E=l.useCallback((r,d,g)=>v(async()=>{const C=Q(r,d),w=!i.getChildren(r).some(y=>y.path===C),j=i.snapshot(r);w&&i.setChildren(r,y=>[...y,ie(C,d,g)]);try{return await s.createEntry(h,C,g),!0}catch(y){return w&&i.restore(r,j),$(y,`Couldn’t create ${g==="dir"?"folder":"file"}`),!1}finally{i.invalidate(r)}}),[s,h,i,v]),T=l.useCallback((r,d)=>v(async()=>{if(d===r.name||d.length===0)return!0;const g=H(r.path),C=Q(g,d),w=i.getChildren(g).some(N=>N.path===C),j=i.snapshot(g),y={...r,name:d,path:C};w||i.setChildren(g,N=>N.map(A=>A.path===r.path?y:A));try{return await s.renameEntry(h,r.path,C),S.getState().remapExpandedPaths(r.path,C),!0}catch(N){return w||i.restore(g,j),$(N,"Couldn’t rename"),!1}finally{i.invalidate(g)}}),[s,h,i,v]),b=l.useCallback(r=>v(async()=>{const d=H(r.path),g=i.snapshot(d);i.setChildren(d,C=>C.filter(w=>w.path!==r.path));try{await s.deleteEntry(h,r.path,{recursive:!0}),S.getState().dropExpandedPaths(r.path)}catch(C){i.restore(d,g),$(C,"Couldn’t delete")}finally{i.invalidate(d)}}),[s,h,i,v]),M=l.useCallback(r=>v(async()=>{const d=H(r.path);if(r.type==="file"){const g=i.snapshot(d);i.setChildren(d,C=>C.filter(w=>w.path!==r.path));try{await s.deleteEntry(h,r.path),S.getState().dropExpandedPaths(r.path)}catch(C){i.restore(d,g),$(C,"Couldn’t delete")}finally{i.invalidate(d)}return}try{await s.deleteEntry(h,r.path),i.setChildren(d,g=>g.filter(C=>C.path!==r.path)),S.getState().dropExpandedPaths(r.path),i.invalidate(d)}catch(g){if(ve(g)==="DIR_NOT_EMPTY"){f(r);return}$(g,"Couldn’t delete")}}),[s,h,i,v]),_=l.useCallback(async()=>{const r=a;f(null),r&&await b(r)},[a,b]),O=l.useCallback(()=>f(null),[]),P=l.useCallback((r,d)=>v(async()=>{const g=H(r),C=oe(r),w=Q(d,C);if(d===g||w===r||J(d,r))return;const j=i.getChildren(g).find(c=>c.path===r);if(!j)return;const y=i.isLoaded(d),N=y&&i.getChildren(d).some(c=>c.path===w),A={...j,name:C,path:w},u=i.snapshot(g),o=y?i.snapshot(d):void 0;i.setChildren(g,c=>c.filter(k=>k.path!==r)),y&&!N&&i.setChildren(d,c=>[...c,A]);try{await s.renameEntry(h,r,w),S.getState().remapExpandedPaths(r,w)}catch(c){i.restore(g,u),y&&!N&&i.restore(d,o),$(c,"Couldn’t move")}finally{i.invalidate(g),y&&i.invalidate(d)}}),[s,h,i,v]),R=l.useCallback((r,d)=>v(async()=>{if(r.isDir&&J(d,r.path)){W.error(Ce);return}let g;try{g=await i.takenNames(d)}catch(N){$(N,"Couldn’t copy");return}const C=bt({name:oe(r.path),isDir:r.isDir,taken:g}),w=Q(d,C),j=i.isLoaded(d),y=j?i.snapshot(d):void 0;if(j){const N=i.getChildren(H(r.path)).find(u=>u.path===r.path),A=N?{...N,name:C,path:w}:ie(w,C,r.isDir?"dir":"file");i.setChildren(d,u=>[...u,A])}try{await s.copyEntry(h,r.path,w)}catch(N){j&&i.restore(d,y),$(N,"Couldn’t copy")}finally{i.invalidate(d)}}),[s,h,i,v]);return{createEntry:E,renameEntry:T,removeEntry:M,moveEntry:P,copyEntry:R,pendingRecursiveDelete:a,confirmRecursiveDelete:_,cancelRecursiveDelete:O}}function kt(e){return e!=null&&e.startsWith("darwin")?"Reveal in Finder":e!=null&&e.startsWith("win32")?"Reveal in File Explorer":"Show in File Manager"}function Et(e,s){const n=e.includes("\\")&&!e.includes("/"),m=e.replace(/[\\/]+$/,""),p=n?s.split("/").join("\\"):s;return`${m}${n?"\\":"/"}${p}`}function Rt(e){const s=B(),{data:n}=Ee(),m=l.useMemo(()=>s.supportsReveal?kt(n==null?void 0:n.platform):null,[s.supportsReveal,n==null?void 0:n.platform]),p=l.useCallback(async v=>{if(e)try{await s.revealEntry(e,v.path)}catch(i){$(i,"Couldn’t open the file manager")}},[s,e]),{copy:x}=Re(),h=l.useCallback(async(v,i)=>{const E=i==="absolute"&&e?Et(e,v.path):v.path;await x(E)||W.error("Couldn’t copy to the clipboard")},[e,x]),a=l.useCallback(v=>{je(Ne(v.path))||W.error("Open a chat first to add a file to it")},[]),f=l.useCallback(v=>{S.getState().setClipboard({path:v.path,isDir:v.type==="dir"});try{navigator.clipboard.writeText(v.path).catch(()=>{})}catch{}},[]);return{revealLabel:m,reveal:p,copyPath:h,addToChat:a,copyToClipboard:f}}const jt={scopeKey:"",cwd:null,writable:!1,provenance:!1,filtersHidden:!0,preview:"canvas",editable:!1,list:()=>Promise.resolve({entries:[]})};function Nt(e){var u,o;const s=B(),n=V(),{setTheme:m}=Te(),p=S(c=>c.showHidden),x=S(c=>c.expanded),h=S(c=>c.loadExplorerForCwd),a=S(c=>c.pruneMissing),f=(e==null?void 0:e.scopeKey)??null,v=(e==null?void 0:e.cwd)??null;l.useEffect(()=>{h(f)},[f,h]);const i=l.useMemo(()=>[z,...De(x)],[x]),E=Se({queries:e?i.map(c=>ye(e,c,p,n)):[]}),T=(e==null?void 0:e.filtersHidden)??!0,b=l.useMemo(()=>{const c={};return i.forEach((k,F)=>{var U;const L=E[F];let I=((U=L==null?void 0:L.data)==null?void 0:U.entries)??[];!p&&!T&&(I=xt(I)),k===z&&(I=gt(I)),c[k]={entries:I,loading:(L==null?void 0:L.isLoading)??!1,error:(L==null?void 0:L.isError)??!1}}),c},[i,E,p,T]),M=l.useRef(0),_=l.useRef({});l.useEffect(()=>{M.current>0||i.forEach((c,k)=>{var L,I,U;const F=(I=(L=E[k])==null?void 0:L.data)==null?void 0:I.entries;!F||(U=E[k])!=null&&U.isError||_.current[c]!==F&&(_.current[c]=F,a(c,F.map(D=>D.name)))})},[i,E,a]);const O=l.useMemo(()=>Oe(x,b),[x,b]),P=!!e&&!!((u=b[z])!=null&&u.loading),R=!!e&&!!((o=b[z])!=null&&o.error),r=l.useMemo(()=>{var k;const c=new Set;for(const F of i)F!==z&&((k=b[F])!=null&&k.error)&&c.add(F);return c},[i,b]),d=l.useCallback(c=>{if(c.type!=="dir")return;const k=S.getState();k.setDirExpanded(c.path,!k.expanded[c.path])},[]),g=l.useCallback(c=>{if(c===z)return;const k=S.getState();k.expanded[c]||k.setDirExpanded(c,!0)},[]),C=(e==null?void 0:e.preview)==="canvas",w=l.useCallback(c=>{if(c.type!=="file"||!C)return;const k={getStore:se.getState,setTheme:m,supportsTerminal:s.supportsTerminal};Fe(k,{action:"open_file",sourcePath:c.path},"user")},[C,m,s]),j=l.useCallback(()=>{f!==null&&n.invalidateQueries({queryKey:["file-explorer","tree",f]})},[n,f]),y=l.useCallback(c=>{e!==null&&n.invalidateQueries({queryKey:G(e,c,p),exact:!0})},[n,e,p]);l.useEffect(()=>{if(e!=null&&e.events)return e.events(j)},[e,j]);const N=wt({source:e??jt,showHidden:p,queryClient:n,inFlightRef:M}),A=Rt(v);return{rows:O,rootLoading:P,rootError:R,errorPaths:r,toggleExpand:d,ensureExpanded:g,openFile:w,reload:j,retryDir:y,...N,...A}}function Tt(e){const{transport:s,cwd:n}=e;return{scopeKey:n,cwd:n,writable:!0,provenance:!1,filtersHidden:!0,preview:"canvas",editable:!1,list(m,p){return s.readFileTree(n,{path:m===""?void 0:m,showHidden:p.showHidden})}}}const Dt=12;function St({row:e,selected:s,renaming:n,error:m,onSelect:p,onActivate:x,onRetry:h,onSubmitRename:a,onCancelRename:f,onNewFile:v,onNewFolder:i,onStartRename:E,onDelete:T,onMove:b,onCopyInto:M,onCopy:_,onPaste:O,onDuplicate:P,canPasteInto:R,revealLabel:r,onReveal:d,onAddToChat:g,onCopyPath:C,readOnly:w=!1,provenance:j=!1}){const{entry:y,depth:N,expanded:A,loading:u}=e,o=y.type==="dir",c=o?y.path:H(y.path),[k,F]=l.useState(!1),L=!o&&N===0&&ne(y.name),I=ct(y.lastCommit),U=t.jsxs("div",{role:"treeitem","aria-label":y.name,"aria-expanded":o?A:void 0,"aria-selected":s,tabIndex:-1,onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),p(y),x(y))},draggable:!n&&!w,onDragStart:D=>{w||(D.dataTransfer.setData("text/plain",y.path),D.dataTransfer.setData(Ie,y.path),D.dataTransfer.effectAllowed="copyMove")},onDragOver:D=>{D.stopPropagation(),!(w||!o||!pe(D.dataTransfer.types))&&(D.preventDefault(),D.dataTransfer.dropEffect=D.altKey?"copy":"move",F(!0))},onDragLeave:()=>F(!1),onDrop:D=>{if(D.stopPropagation(),w||!o)return;F(!1);const Z=fe(D.dataTransfer);Z!==null&&(D.preventDefault(),D.altKey?M(Z,y.path):b(Z,y.path))},onClick:()=>{p(y),x(y)},className:ae("flex w-full cursor-pointer items-center gap-1 py-1 pr-2 text-sm transition-colors",s?"bg-accent text-foreground":"hover:bg-accent/50",k&&"ring-ring/60 bg-accent ring-1"),style:{paddingLeft:N*Dt+8},children:[t.jsx("span",{className:"flex size-4 flex-shrink-0 items-center justify-center",children:o&&(u?t.jsx(ce,{size:"xs",className:"text-muted-foreground"}):m?t.jsx("button",{type:"button","aria-label":"Retry loading",title:"Couldn’t load. Retry",onClick:D=>{D.stopPropagation(),h()},className:"flex items-center justify-center",children:t.jsx(de,{className:"text-destructive size-3.5"})}):A?t.jsx(_e,{className:"text-muted-foreground size-3.5"}):t.jsx(Pe,{className:"text-muted-foreground size-3.5"}))}),o?A?t.jsx(Me,{className:"size-(--size-icon-sm) flex-shrink-0 text-sky-500"}):t.jsx(ue,{className:"size-(--size-icon-sm) flex-shrink-0 text-sky-500"}):y.isSymlink===!0?t.jsx(Ae,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}):t.jsx(he,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}),n?t.jsx(Ot,{initialName:y.name,onSubmit:D=>a(y,D),onCancel:f}):t.jsx("span",{className:"min-w-0 flex-1 truncate",children:y.name}),L&&!n&&t.jsx(Le,{"aria-label":"Pinned to the top",className:"text-muted-foreground/60 size-3 flex-shrink-0"}),j&&!n&&t.jsx("span",{className:"text-muted-foreground/70 text-2xs max-w-[45%] flex-shrink-0 truncate tabular-nums",title:I.title??void 0,children:I.label})]});return w?U:t.jsxs(ze,{children:[t.jsx(Ke,{asChild:!0,children:U}),t.jsxs(He,{className:"w-52",children:[t.jsx(K,{onClick:()=>v(c),children:"New file"}),t.jsx(K,{onClick:()=>i(c),children:"New folder"}),t.jsx(q,{}),r&&t.jsx(K,{onClick:()=>d(y),children:r}),t.jsx(K,{movesFocus:!0,onClick:()=>g(y),children:"Add to chat"}),t.jsx(q,{}),t.jsx(K,{onClick:()=>_(y),children:"Copy"}),t.jsx(K,{disabled:!R(c),onClick:()=>O(c),children:"Paste"}),t.jsx(K,{onClick:()=>P(y),children:"Duplicate"}),t.jsx(q,{}),t.jsx(K,{onClick:()=>C(y,"absolute"),children:"Copy path"}),t.jsx(K,{onClick:()=>C(y,"relative"),children:"Copy relative path"}),t.jsx(q,{}),t.jsx(K,{onClick:()=>E(y),children:"Rename"}),t.jsx(K,{variant:"destructive",onClick:()=>T(y),children:"Delete"})]})]})}function Ot({initialName:e,onSubmit:s,onCancel:n}){const m=l.useRef(null),[p,x]=l.useState(e);l.useEffect(()=>{const a=m.current;if(!a)return;a.focus();const f=e.lastIndexOf(".");a.setSelectionRange(0,f>0?f:e.length)},[e]);const h=()=>{const a=p.trim();a&&a!==e?s(a):n()};return t.jsx("input",{ref:m,type:"text",value:p,"aria-label":"New name",onChange:a=>x(a.target.value),onClick:a=>a.stopPropagation(),onBlur:h,onKeyDown:a=>{a.key==="Enter"?h():a.key==="Escape"&&n()},className:"border-border bg-background min-w-0 flex-1 rounded border px-1 py-0 text-sm outline-none"})}const Ft=100,_t=28,Pt=250;function Mt(e){const{rows:s,selectedPath:n,renamingPath:m,errorPaths:p,onSelectPath:x,onRetryDir:h}=e,a=l.useRef(null),f=S(o=>o.setScrollTop),v=S(o=>o.scopeKey),i=l.useCallback(o=>o.type==="dir"?e.onToggle(o):e.onOpen(o),[e]),E=Lt(e,i),T=s.length>Ft,b=$e({count:s.length,getScrollElement:()=>a.current,estimateSize:()=>_t,overscan:12,enabled:T}),M=l.useRef({scope:void 0,done:!1}),_=l.useRef(null);l.useLayoutEffect(()=>{const o=M.current;if(o.scope!==v&&(o.scope=v,o.done=!1),o.done||s.length===0)return;const c=a.current;if(!c)return;const k=S.getState().scrollTop;if(k<=0){o.done=!0;return}T?b.scrollToOffset(k):c.scrollTop=k,_.current=c.scrollTop,c.scrollTop>=k&&(o.done=!0)},[s.length,v,T,b]);const O=l.useRef(null),P=l.useRef(null),R=l.useCallback(()=>{const o=a.current;o&&o.scrollTop!==_.current&&(M.current.done=!0,O.current=o.scrollTop,P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{P.current=null,O.current!==null&&f(O.current)},Pt))},[f]);l.useEffect(()=>()=>{P.current&&clearTimeout(P.current),O.current!==null&&f(O.current)},[f]);const r=l.useRef(void 0);l.useEffect(()=>{var F,L;const o=r.current;if(r.current=n,o===void 0||n===o||n===null)return;const c=s.findIndex(I=>I.entry.path===n);if(c<0)return;const k=a.current;k&&(T?b.scrollToIndex(c,{align:"auto"}):(L=(F=k.querySelector(`[data-row-index="${c}"]`))==null?void 0:F.scrollIntoView)==null||L.call(F,{block:"nearest"}),_.current=k.scrollTop)},[n,s,T,b]);const[d,g]=l.useState(!1),{onCopyInto:C,onMove:w}=e,j=e.readOnly===!0,y=l.useCallback(o=>{j||!pe(o.dataTransfer.types)||(o.preventDefault(),o.dataTransfer.dropEffect=o.altKey?"copy":"move",g(!0))},[j]),N=l.useCallback((o,c)=>{const k=s.find(F=>F.entry.path===o);k&&C({path:o,isDir:k.entry.type==="dir"},c)},[s,C]),A=l.useCallback(o=>{if(g(!1),j)return;const c=fe(o.dataTransfer);c!==null&&(o.preventDefault(),o.altKey?N(c,z):w(c,z))},[N,w,j]),u=o=>t.jsx(St,{row:o,selected:o.entry.path===n,renaming:o.entry.path===m,error:o.entry.type==="dir"&&o.expanded&&p.has(o.entry.path),onSelect:c=>x(c.path),onActivate:i,onRetry:()=>h(o.entry.path),onSubmitRename:e.onSubmitRename,onCancelRename:e.onCancelRename,onStartRename:e.onStartRename,onNewFile:e.onNewFile,onNewFolder:e.onNewFolder,onDelete:e.onDelete,onMove:e.onMove,onCopyInto:N,onCopy:e.onCopy,onPaste:e.onPaste,onDuplicate:e.onDuplicate,canPasteInto:e.canPasteInto,revealLabel:e.revealLabel,onReveal:e.onReveal,onAddToChat:e.onAddToChat,onCopyPath:e.onCopyPath,readOnly:e.readOnly,provenance:e.provenance});return t.jsx("div",{ref:a,role:"tree","aria-label":"File explorer",tabIndex:0,onKeyDown:E,onScroll:R,onDragOver:y,onDragLeave:()=>g(!1),onDrop:A,className:ae("focus-visible:ring-ring/40 h-full overflow-auto outline-none focus-visible:ring-1 focus-visible:ring-inset",d&&"ring-ring/60 bg-accent/30 ring-1 ring-inset"),children:T?t.jsx("div",{style:{height:b.getTotalSize()},className:"relative w-full",children:b.getVirtualItems().map(o=>t.jsx("div",{"data-row-index":o.index,className:"absolute top-0 left-0 w-full",style:{transform:`translateY(${o.start}px)`},children:u(s[o.index])},s[o.index].entry.path))}):s.map((o,c)=>t.jsx("div",{"data-row-index":c,children:u(o)},o.entry.path))})}function At(e){return e?e.type==="dir"?e.path:H(e.path):z}function Lt(e,s){const{rows:n,selectedPath:m,renamingPath:p,onSelectPath:x}=e;return l.useCallback(h=>{var v,i,E,T;if(p!==null)return;const a=n.findIndex(b=>b.entry.path===m),f=a>=0?n[a]:void 0;if(h.metaKey||h.ctrlKey){if(e.readOnly===!0)return;const b=h.key.toLowerCase();if(b==="c"&&f){h.preventDefault(),e.onCopy(f.entry);return}if(b==="v"){h.preventDefault(),e.onPaste(At(f==null?void 0:f.entry));return}return}switch(h.key){case"ArrowDown":h.preventDefault(),x(((v=n[Math.min(a+1,n.length-1)])==null?void 0:v.entry.path)??((i=n[0])==null?void 0:i.entry.path));break;case"ArrowUp":h.preventDefault(),x(((E=n[Math.max(a-1,0)])==null?void 0:E.entry.path)??((T=n[0])==null?void 0:T.entry.path));break;case"ArrowRight":(f==null?void 0:f.entry.type)==="dir"&&!f.expanded&&(h.preventDefault(),e.onToggle(f.entry));break;case"ArrowLeft":if(!f)break;if(h.preventDefault(),f.entry.type==="dir"&&f.expanded)e.onToggle(f.entry);else{const b=H(f.entry.path);b&&x(b)}break;case"Enter":f&&(h.preventDefault(),s(f.entry));break;case"F2":f&&e.readOnly!==!0&&(h.preventDefault(),e.onStartRename(f.entry));break;case"Delete":case"Backspace":f&&e.readOnly!==!0&&(h.preventDefault(),e.onDelete(f.entry));break}},[n,m,p,x,e,s])}function It({source:e,className:s}={}){var A;const n=B(),m=se(u=>u.selectedCwd),p=l.useMemo(()=>m?Tt({transport:n,cwd:m}):null,[n,m]),x=e===void 0?p:e,h=x!==null&&!x.writable,a=Nt(x),{rows:f,rootLoading:v,rootError:i,errorPaths:E}=a,T=S(u=>u.setCommands),b=S(u=>u.selectedPath),M=S(u=>u.setSelectedPath),_=S(u=>u.clipboard),[O,P]=l.useState(null),[R,r]=l.useState(null),[d,g]=l.useState(null),C=l.useCallback(u=>_!==null&&!(_.isDir&&J(u,_.path)),[_]),w=l.useCallback((u,o)=>{a.ensureExpanded(u),r(null),P({parent:u,type:o})},[a]),j=l.useRef({startCreate:w,reload:a.reload});l.useEffect(()=>{j.current={startCreate:w,reload:a.reload}}),l.useEffect(()=>{if(!h)return T({newFile:()=>j.current.startCreate(z,"file"),newFolder:()=>j.current.startCreate(z,"dir"),refresh:()=>j.current.reload()}),()=>T(null)},[T,h]);const y=l.useCallback(async u=>{if(!O)return;const o=O;P(null),await a.createEntry(o.parent,u,o.type)&&M(Q(o.parent,u))},[O,a,M]),N=l.useCallback(async(u,o)=>{r(null),await a.renameEntry(u,o)&&M(Q(H(u.path),o))},[a,M]);return x===null?e!==void 0?null:t.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-6 text-center text-sm",children:"Select a working directory to browse its files."}):t.jsxs("div",{className:ae("flex h-full flex-col",s),children:[t.jsxs("div",{className:"min-h-0 flex-1",children:[O&&t.jsx(zt,{type:O.type,onSubmit:u=>void y(u),onCancel:()=>P(null)}),v&&f.length===0?t.jsx("div",{className:"flex h-20 items-center justify-center",children:t.jsx(ce,{size:"md",className:"text-muted-foreground",label:"Loading files"})}):i&&f.length===0?t.jsxs("div",{className:"text-muted-foreground flex h-20 flex-col items-center justify-center gap-2 text-xs",children:[t.jsx("span",{children:"Couldn’t load files."}),t.jsxs(Y,{variant:"outline",size:"xs",onClick:a.reload,children:[t.jsx(de,{}),"Retry"]})]}):f.length===0&&!O?t.jsx("div",{className:"text-muted-foreground/60 flex h-20 items-center justify-center text-xs",children:"Empty directory"}):t.jsx(Mt,{rows:f,selectedPath:b,renamingPath:R,errorPaths:E,onSelectPath:M,onToggle:a.toggleExpand,onOpen:u=>{x.preview==="inline"?g(u.path):a.openFile(u)},onRetryDir:a.retryDir,onSubmitRename:(u,o)=>void N(u,o),onCancelRename:()=>r(null),onStartRename:u=>r(u.path),onNewFile:u=>w(u,"file"),onNewFolder:u=>w(u,"dir"),onDelete:u=>void a.removeEntry(u),onMove:(u,o)=>void a.moveEntry(u,o),onCopyInto:(u,o)=>void a.copyEntry(u,o),onCopy:a.copyToClipboard,onPaste:u=>{_&&a.copyEntry(_,u)},onDuplicate:u=>void a.copyEntry({path:u.path,isDir:u.type==="dir"},H(u.path)),canPasteInto:C,readOnly:h,provenance:x.provenance,revealLabel:a.revealLabel,onReveal:u=>void a.reveal(u),onAddToChat:a.addToChat,onCopyPath:(u,o)=>void a.copyPath(u,o)})]}),x.preview==="inline"&&t.jsx(dt,{source:x,path:d,onClose:()=>g(null)}),t.jsx(Ye,{open:a.pendingRecursiveDelete!==null,onOpenChange:u=>!u&&a.cancelRecursiveDelete(),children:t.jsxs(Ue,{children:[t.jsxs(Be,{children:[t.jsx(Qe,{children:"Delete this folder?"}),t.jsxs(qe,{children:["“",(A=a.pendingRecursiveDelete)==null?void 0:A.name,"” isn’t empty. Deleting it removes everything inside. This can’t be undone."]})]}),t.jsxs(We,{children:[t.jsx(Ge,{onClick:a.cancelRecursiveDelete,children:"Cancel"}),t.jsx(Ve,{onClick:()=>void a.confirmRecursiveDelete(),className:"bg-destructive hover:bg-destructive/90 dark:bg-destructive/60 text-white",children:"Delete"})]})]})})]})}function zt({type:e,onSubmit:s,onCancel:n}){const m=l.useRef(null),[p,x]=l.useState("");l.useEffect(()=>{var a;(a=m.current)==null||a.focus()},[]);const h=()=>{const a=p.trim();a?s(a):n()};return t.jsxs("div",{className:"flex items-center gap-1 px-3 py-1",children:[e==="dir"?t.jsx(ue,{className:"size-(--size-icon-sm) flex-shrink-0 text-sky-500"}):t.jsx(he,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}),t.jsx("input",{ref:m,type:"text",value:p,"aria-label":e==="dir"?"New folder name":"New file name",placeholder:e==="dir"?"folder-name":"file-name",onChange:a=>x(a.target.value),onBlur:h,onKeyDown:a=>{a.key==="Enter"?h():a.key==="Escape"&&n()},className:"border-border bg-background min-w-0 flex-1 rounded border px-1 py-0 text-sm outline-none"})]})}function be(){const e=S(m=>m.showHidden),s=S(m=>m.setShowHidden),n=e?"Hide hidden files":"Show hidden files";return t.jsx(Y,{variant:"ghost",size:"icon-xs","aria-label":n,title:n,onClick:()=>s(!e),children:e?t.jsx(Xe,{className:"text-muted-foreground"}):t.jsx(Ze,{className:"text-muted-foreground"})})}function Kt({cwd:e}){const s=B(),{data:n}=X({queryKey:["file-explorer","workspace",e],queryFn:()=>s.resolveWorkspace(e),staleTime:6e4});return n!=null&&n.branch?t.jsxs("span",{className:"text-muted-foreground bg-muted/50 text-2xs inline-flex min-w-0 items-center gap-1 rounded px-1.5 py-0.5",title:`Workspace ${n.key} on ${n.branch}`,children:[t.jsx(me,{className:"size-3 flex-shrink-0"}),t.jsx("span",{className:"truncate",children:n.branch})]}):null}function qt(){const e=se(n=>n.selectedCwd),s=S(n=>n.commands);return e?t.jsxs(t.Fragment,{children:[t.jsx(Kt,{cwd:e}),t.jsx(Y,{variant:"ghost",size:"icon-xs","aria-label":"New file",title:"New file",onClick:()=>s==null?void 0:s.newFile(),children:t.jsx(ft,{className:"text-muted-foreground"})}),t.jsx(Y,{variant:"ghost",size:"icon-xs","aria-label":"New folder",title:"New folder",onClick:()=>s==null?void 0:s.newFolder(),children:t.jsx(Je,{className:"text-muted-foreground"})}),t.jsx(be,{}),t.jsx(Y,{variant:"ghost",size:"icon-xs","aria-label":"Refresh",title:"Refresh",onClick:()=>s==null?void 0:s.refresh(),children:t.jsx(et,{className:"text-muted-foreground"})})]}):null}function Ht({roomId:e}){const s=B(),n=V(),m=X(xe(s,e));l.useEffect(()=>ut(n,e,()=>{n.invalidateQueries({queryKey:ee.repoStatus(e)})}),[n,e]);const p=l.useMemo(()=>{var f;return((f=m.data)==null?void 0:f.kind)==="ok"?tt(m.data.status):[]},[m.data]),x=nt(p),h=st(p);if(!h)return null;const a=p.map((f,v)=>`${x[v]}: ${at(f)}`);return t.jsxs("span",{"data-slot":"pending-work-badge",title:a.join(`
|
|
7
|
-
`),className:"text-muted-foreground bg-muted/50 text-2xs inline-flex min-w-0 items-center gap-1 rounded px-1.5 py-0.5",children:[t.jsx(me,{className:"size-3 flex-shrink-0"}),t.jsxs("span",{className:"sr-only",children:["Not merged into the room yet. ",a.join(". "),"."]}),t.jsx("span",{"aria-hidden":"true",className:"truncate",children:h})]})}const $t={added:"added",modified:"changed",deleted:"deleted",untracked:"new"},Yt=new Map([["OPERATOR_ONLY","Only the person who owns this DorkOS can decide what happens to those changes."],["ROOM_FILE_NOT_FOUND","One of those changes is not there any more, so nothing was discarded. The list below has been refreshed."],["MERGE_IN_FLIGHT","Something else is writing to this room’s files right now. Nothing was changed. Try again in a moment."],["MAIN_CHECKOUT_DIRTY","This room’s files are on another branch, which DorkOS will not move for you. Put them back on main yourself."],["ROOM_REPO_GIT_UNAVAILABLE","This computer doesn’t have git installed, and a room’s files are a git repository."],["ROOM_HAS_NO_REPO","This room does not have files of its own any more."],["ROOM_REPOS_DISABLED","Rooms cannot have files of their own on this install right now."]]);function
|
|
6
|
+
*/const ge={name:"file-plus",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]};ge.node;const ft=we(ge),pt=[".git",".dork",".claude",".agents","node_modules"];function mt(e){return e.startsWith(".")||pt.includes(e)}const te=["ROOM.md","README.md"];function ne(e){return te.some(s=>s.toLowerCase()===e.toLowerCase())}function xt(e){return e.filter(s=>!mt(s.name))}function gt(e){if(e.reduce((p,x)=>x.type==="file"&&ne(x.name)?p+1:p,0)===0)return e;const n=[],m=[];for(const p of e)p.type==="file"&&ne(p.name)?n.push(p):m.push(p);return n.sort((p,x)=>te.findIndex(h=>h.toLowerCase()===p.name.toLowerCase())-te.findIndex(h=>h.toLowerCase()===x.name.toLowerCase())),[...n,...m]}function G(e,s,n){return["file-explorer","tree",e.scopeKey,s,e.filtersHidden?n:null]}function ye(e,s,n,m){return{queryKey:G(e,s,n),queryFn:()=>e.list(s,{showHidden:n}),staleTime:re.FILE_TREE_STALE_TIME_MS,gcTime:re.FILE_TREE_GC_TIME_MS,placeholderData:p=>p??m.getQueryData(G(e,s,!n))}}const yt=["CONFLICT","COPY_INTO_SELF","DIR_NOT_EMPTY","NOT_FOUND","REFUSE_ROOT","OUTSIDE_BOUNDARY"];function ve(e){const s=le(e);return s!==void 0&&yt.includes(s)?s:void 0}const Ce="Can’t copy a folder into itself",vt={CONFLICT:"That name already exists",COPY_INTO_SELF:Ce,DIR_NOT_EMPTY:"This folder isn’t empty",NOT_FOUND:"That item no longer exists",REFUSE_ROOT:"Can’t modify the working directory root",OUTSIDE_BOUNDARY:"That path is outside the working directory"};function $(e,s){const n=ve(e);W.error(n?vt[n]:s)}const Ct=/ copy(?: \d+)?$/;function bt({name:e,isDir:s,taken:n}){const m=new Set(n);if(!m.has(e))return e;const p=s?-1:e.lastIndexOf("."),x=p>0,h=x?e.slice(p):"",a=(x?e.slice(0,p):e).replace(Ct,"");for(let f=1;;f+=1){const v=f===1?`${a} copy${h}`:`${a} copy ${f}${h}`;if(!m.has(v))return v}}function ie(e,s,n){return{name:s,path:e,type:n,size:0,mtime:Date.now(),isSymlink:!1}}function wt(e){const s=U(),{source:n,showHidden:m,queryClient:p,inFlightRef:x}=e,h=n.cwd??"",[a,f]=l.useState(null),v=l.useCallback(async r=>{x.current+=1;try{return await r()}finally{x.current-=1}},[x]),i=l.useMemo(()=>{const r=d=>G(n,d,m);return{getChildren:d=>{var g;return((g=p.getQueryData(r(d)))==null?void 0:g.entries)??[]},isLoaded:d=>p.getQueryData(r(d))!==void 0,takenNames:async d=>(await s.readFileTree(h,{path:d===z?void 0:d,showHidden:!0})).entries.map(C=>C.name),snapshot:d=>p.getQueryData(r(d)),setChildren:(d,g)=>{p.setQueryData(r(d),C=>({entries:ke(g((C==null?void 0:C.entries)??[]))}))},restore:(d,g)=>{p.setQueryData(r(d),g)},invalidate:d=>{p.invalidateQueries({queryKey:r(d),exact:!0})}}},[p,s,h,n,m]),E=l.useCallback((r,d,g)=>v(async()=>{const C=q(r,d),w=!i.getChildren(r).some(y=>y.path===C),j=i.snapshot(r);w&&i.setChildren(r,y=>[...y,ie(C,d,g)]);try{return await s.createEntry(h,C,g),!0}catch(y){return w&&i.restore(r,j),$(y,`Couldn’t create ${g==="dir"?"folder":"file"}`),!1}finally{i.invalidate(r)}}),[s,h,i,v]),D=l.useCallback((r,d)=>v(async()=>{if(d===r.name||d.length===0)return!0;const g=H(r.path),C=q(g,d),w=i.getChildren(g).some(N=>N.path===C),j=i.snapshot(g),y={...r,name:d,path:C};w||i.setChildren(g,N=>N.map(L=>L.path===r.path?y:L));try{return await s.renameEntry(h,r.path,C),S.getState().remapExpandedPaths(r.path,C),!0}catch(N){return w||i.restore(g,j),$(N,"Couldn’t rename"),!1}finally{i.invalidate(g)}}),[s,h,i,v]),b=l.useCallback(r=>v(async()=>{const d=H(r.path),g=i.snapshot(d);i.setChildren(d,C=>C.filter(w=>w.path!==r.path));try{await s.deleteEntry(h,r.path,{recursive:!0}),S.getState().dropExpandedPaths(r.path)}catch(C){i.restore(d,g),$(C,"Couldn’t delete")}finally{i.invalidate(d)}}),[s,h,i,v]),M=l.useCallback(r=>v(async()=>{const d=H(r.path);if(r.type==="file"){const g=i.snapshot(d);i.setChildren(d,C=>C.filter(w=>w.path!==r.path));try{await s.deleteEntry(h,r.path),S.getState().dropExpandedPaths(r.path)}catch(C){i.restore(d,g),$(C,"Couldn’t delete")}finally{i.invalidate(d)}return}try{await s.deleteEntry(h,r.path),i.setChildren(d,g=>g.filter(C=>C.path!==r.path)),S.getState().dropExpandedPaths(r.path),i.invalidate(d)}catch(g){if(ve(g)==="DIR_NOT_EMPTY"){f(r);return}$(g,"Couldn’t delete")}}),[s,h,i,v]),_=l.useCallback(async()=>{const r=a;f(null),r&&await b(r)},[a,b]),O=l.useCallback(()=>f(null),[]),P=l.useCallback((r,d)=>v(async()=>{const g=H(r),C=oe(r),w=q(d,C);if(d===g||w===r||J(d,r))return;const j=i.getChildren(g).find(c=>c.path===r);if(!j)return;const y=i.isLoaded(d),N=y&&i.getChildren(d).some(c=>c.path===w),L={...j,name:C,path:w},u=i.snapshot(g),o=y?i.snapshot(d):void 0;i.setChildren(g,c=>c.filter(k=>k.path!==r)),y&&!N&&i.setChildren(d,c=>[...c,L]);try{await s.renameEntry(h,r,w),S.getState().remapExpandedPaths(r,w)}catch(c){i.restore(g,u),y&&!N&&i.restore(d,o),$(c,"Couldn’t move")}finally{i.invalidate(g),y&&i.invalidate(d)}}),[s,h,i,v]),R=l.useCallback((r,d)=>v(async()=>{if(r.isDir&&J(d,r.path)){W.error(Ce);return}let g;try{g=await i.takenNames(d)}catch(N){$(N,"Couldn’t copy");return}const C=bt({name:oe(r.path),isDir:r.isDir,taken:g}),w=q(d,C),j=i.isLoaded(d),y=j?i.snapshot(d):void 0;if(j){const N=i.getChildren(H(r.path)).find(u=>u.path===r.path),L=N?{...N,name:C,path:w}:ie(w,C,r.isDir?"dir":"file");i.setChildren(d,u=>[...u,L])}try{await s.copyEntry(h,r.path,w)}catch(N){j&&i.restore(d,y),$(N,"Couldn’t copy")}finally{i.invalidate(d)}}),[s,h,i,v]);return{createEntry:E,renameEntry:D,removeEntry:M,moveEntry:P,copyEntry:R,pendingRecursiveDelete:a,confirmRecursiveDelete:_,cancelRecursiveDelete:O}}function kt(e){return e!=null&&e.startsWith("darwin")?"Reveal in Finder":e!=null&&e.startsWith("win32")?"Reveal in File Explorer":"Show in File Manager"}function Et(e,s){const n=e.includes("\\")&&!e.includes("/"),m=e.replace(/[\\/]+$/,""),p=n?s.split("/").join("\\"):s;return`${m}${n?"\\":"/"}${p}`}function Rt(e){const s=U(),{data:n}=Ee(),m=l.useMemo(()=>s.supportsReveal?kt(n==null?void 0:n.platform):null,[s.supportsReveal,n==null?void 0:n.platform]),p=l.useCallback(async v=>{if(e)try{await s.revealEntry(e,v.path)}catch(i){$(i,"Couldn’t open the file manager")}},[s,e]),{copy:x}=Re(),h=l.useCallback(async(v,i)=>{const E=i==="absolute"&&e?Et(e,v.path):v.path;await x(E)||W.error("Couldn’t copy to the clipboard")},[e,x]),a=l.useCallback(v=>{je(Ne(v.path))||W.error("Open a chat first to add a file to it")},[]),f=l.useCallback(v=>{S.getState().setClipboard({path:v.path,isDir:v.type==="dir"});try{navigator.clipboard.writeText(v.path).catch(()=>{})}catch{}},[]);return{revealLabel:m,reveal:p,copyPath:h,addToChat:a,copyToClipboard:f}}const jt={scopeKey:"",cwd:null,writable:!1,provenance:!1,filtersHidden:!0,preview:"canvas",editable:!1,list:()=>Promise.resolve({entries:[]})};function Nt(e){var u,o;const s=U(),n=V(),{setTheme:m}=De(),p=S(c=>c.showHidden),x=S(c=>c.expanded),h=S(c=>c.loadExplorerForCwd),a=S(c=>c.pruneMissing),f=(e==null?void 0:e.scopeKey)??null,v=(e==null?void 0:e.cwd)??null;l.useEffect(()=>{h(f)},[f,h]);const i=l.useMemo(()=>[z,...Te(x)],[x]),E=Se({queries:e?i.map(c=>ye(e,c,p,n)):[]}),D=(e==null?void 0:e.filtersHidden)??!0,b=l.useMemo(()=>{const c={};return i.forEach((k,F)=>{var Q;const A=E[F];let I=((Q=A==null?void 0:A.data)==null?void 0:Q.entries)??[];!p&&!D&&(I=xt(I)),k===z&&(I=gt(I)),c[k]={entries:I,loading:(A==null?void 0:A.isLoading)??!1,error:(A==null?void 0:A.isError)??!1}}),c},[i,E,p,D]),M=l.useRef(0),_=l.useRef({});l.useEffect(()=>{M.current>0||i.forEach((c,k)=>{var A,I,Q;const F=(I=(A=E[k])==null?void 0:A.data)==null?void 0:I.entries;!F||(Q=E[k])!=null&&Q.isError||_.current[c]!==F&&(_.current[c]=F,a(c,F.map(T=>T.name)))})},[i,E,a]);const O=l.useMemo(()=>Oe(x,b),[x,b]),P=!!e&&!!((u=b[z])!=null&&u.loading),R=!!e&&!!((o=b[z])!=null&&o.error),r=l.useMemo(()=>{var k;const c=new Set;for(const F of i)F!==z&&((k=b[F])!=null&&k.error)&&c.add(F);return c},[i,b]),d=l.useCallback(c=>{if(c.type!=="dir")return;const k=S.getState();k.setDirExpanded(c.path,!k.expanded[c.path])},[]),g=l.useCallback(c=>{if(c===z)return;const k=S.getState();k.expanded[c]||k.setDirExpanded(c,!0)},[]),C=(e==null?void 0:e.preview)==="canvas",w=l.useCallback(c=>{if(c.type!=="file"||!C)return;const k={getStore:se.getState,setTheme:m,supportsTerminal:s.supportsTerminal};Fe(k,{action:"open_file",sourcePath:c.path},"user")},[C,m,s]),j=l.useCallback(()=>{f!==null&&n.invalidateQueries({queryKey:["file-explorer","tree",f]})},[n,f]),y=l.useCallback(c=>{e!==null&&n.invalidateQueries({queryKey:G(e,c,p),exact:!0})},[n,e,p]);l.useEffect(()=>{if(e!=null&&e.events)return e.events(j)},[e,j]);const N=wt({source:e??jt,showHidden:p,queryClient:n,inFlightRef:M}),L=Rt(v);return{rows:O,rootLoading:P,rootError:R,errorPaths:r,toggleExpand:d,ensureExpanded:g,openFile:w,reload:j,retryDir:y,...N,...L}}function Dt(e){const{transport:s,cwd:n}=e;return{scopeKey:n,cwd:n,writable:!0,provenance:!1,filtersHidden:!0,preview:"canvas",editable:!1,list(m,p){return s.readFileTree(n,{path:m===""?void 0:m,showHidden:p.showHidden})}}}const Tt=12;function St({row:e,selected:s,renaming:n,error:m,onSelect:p,onActivate:x,onRetry:h,onSubmitRename:a,onCancelRename:f,onNewFile:v,onNewFolder:i,onStartRename:E,onDelete:D,onMove:b,onCopyInto:M,onCopy:_,onPaste:O,onDuplicate:P,canPasteInto:R,revealLabel:r,onReveal:d,onAddToChat:g,onCopyPath:C,readOnly:w=!1,provenance:j=!1}){const{entry:y,depth:N,expanded:L,loading:u}=e,o=y.type==="dir",c=o?y.path:H(y.path),[k,F]=l.useState(!1),A=!o&&N===0&&ne(y.name),I=ct(y.lastCommit),Q=t.jsxs("div",{role:"treeitem","aria-label":y.name,"aria-expanded":o?L:void 0,"aria-selected":s,tabIndex:-1,onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),p(y),x(y))},draggable:!n&&!w,onDragStart:T=>{w||(T.dataTransfer.setData("text/plain",y.path),T.dataTransfer.setData(Ie,y.path),T.dataTransfer.effectAllowed="copyMove")},onDragOver:T=>{T.stopPropagation(),!(w||!o||!pe(T.dataTransfer.types))&&(T.preventDefault(),T.dataTransfer.dropEffect=T.altKey?"copy":"move",F(!0))},onDragLeave:()=>F(!1),onDrop:T=>{if(T.stopPropagation(),w||!o)return;F(!1);const Z=fe(T.dataTransfer);Z!==null&&(T.preventDefault(),T.altKey?M(Z,y.path):b(Z,y.path))},onClick:()=>{p(y),x(y)},className:ae("flex w-full cursor-pointer items-center gap-1 py-1 pr-2 text-sm transition-colors",s?"bg-accent text-foreground":"hover:bg-accent/50",k&&"ring-ring/60 bg-accent ring-1"),style:{paddingLeft:N*Tt+8},children:[t.jsx("span",{className:"flex size-4 flex-shrink-0 items-center justify-center",children:o&&(u?t.jsx(ce,{size:"xs",className:"text-muted-foreground"}):m?t.jsx("button",{type:"button","aria-label":"Retry loading",title:"Couldn’t load. Retry",onClick:T=>{T.stopPropagation(),h()},className:"flex items-center justify-center",children:t.jsx(de,{className:"text-destructive size-3.5"})}):L?t.jsx(_e,{className:"text-muted-foreground size-3.5"}):t.jsx(Pe,{className:"text-muted-foreground size-3.5"}))}),o?L?t.jsx(Me,{className:"size-(--size-icon-sm) flex-shrink-0 text-sky-500"}):t.jsx(ue,{className:"size-(--size-icon-sm) flex-shrink-0 text-sky-500"}):y.isSymlink===!0?t.jsx(Le,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}):t.jsx(he,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}),n?t.jsx(Ot,{initialName:y.name,onSubmit:T=>a(y,T),onCancel:f}):t.jsx("span",{className:"min-w-0 flex-1 truncate",children:y.name}),A&&!n&&t.jsx(Ae,{"aria-label":"Pinned to the top",className:"text-muted-foreground/60 size-3 flex-shrink-0"}),j&&!n&&t.jsx("span",{className:"text-muted-foreground/70 text-2xs max-w-[45%] flex-shrink-0 truncate tabular-nums",title:I.title??void 0,children:I.label})]});return w?Q:t.jsxs(ze,{children:[t.jsx(Ke,{asChild:!0,children:Q}),t.jsxs(He,{className:"w-52",children:[t.jsx(K,{onClick:()=>v(c),children:"New file"}),t.jsx(K,{onClick:()=>i(c),children:"New folder"}),t.jsx(B,{}),r&&t.jsx(K,{onClick:()=>d(y),children:r}),t.jsx(K,{movesFocus:!0,onClick:()=>g(y),children:"Add to chat"}),t.jsx(B,{}),t.jsx(K,{onClick:()=>_(y),children:"Copy"}),t.jsx(K,{disabled:!R(c),onClick:()=>O(c),children:"Paste"}),t.jsx(K,{onClick:()=>P(y),children:"Duplicate"}),t.jsx(B,{}),t.jsx(K,{onClick:()=>C(y,"absolute"),children:"Copy path"}),t.jsx(K,{onClick:()=>C(y,"relative"),children:"Copy relative path"}),t.jsx(B,{}),t.jsx(K,{onClick:()=>E(y),children:"Rename"}),t.jsx(K,{variant:"destructive",onClick:()=>D(y),children:"Delete"})]})]})}function Ot({initialName:e,onSubmit:s,onCancel:n}){const m=l.useRef(null),[p,x]=l.useState(e);l.useEffect(()=>{const a=m.current;if(!a)return;a.focus();const f=e.lastIndexOf(".");a.setSelectionRange(0,f>0?f:e.length)},[e]);const h=()=>{const a=p.trim();a&&a!==e?s(a):n()};return t.jsx("input",{ref:m,type:"text",value:p,"aria-label":"New name",onChange:a=>x(a.target.value),onClick:a=>a.stopPropagation(),onBlur:h,onKeyDown:a=>{a.key==="Enter"?h():a.key==="Escape"&&n()},className:"border-border bg-background min-w-0 flex-1 rounded border px-1 py-0 text-sm outline-none"})}const Ft=100,_t=28,Pt=250;function Mt(e){const{rows:s,selectedPath:n,renamingPath:m,errorPaths:p,onSelectPath:x,onRetryDir:h}=e,a=l.useRef(null),f=S(o=>o.setScrollTop),v=S(o=>o.scopeKey),i=l.useCallback(o=>o.type==="dir"?e.onToggle(o):e.onOpen(o),[e]),E=At(e,i),D=s.length>Ft,b=$e({count:s.length,getScrollElement:()=>a.current,estimateSize:()=>_t,overscan:12,enabled:D}),M=l.useRef({scope:void 0,done:!1}),_=l.useRef(null);l.useLayoutEffect(()=>{const o=M.current;if(o.scope!==v&&(o.scope=v,o.done=!1),o.done||s.length===0)return;const c=a.current;if(!c)return;const k=S.getState().scrollTop;if(k<=0){o.done=!0;return}D?b.scrollToOffset(k):c.scrollTop=k,_.current=c.scrollTop,c.scrollTop>=k&&(o.done=!0)},[s.length,v,D,b]);const O=l.useRef(null),P=l.useRef(null),R=l.useCallback(()=>{const o=a.current;o&&o.scrollTop!==_.current&&(M.current.done=!0,O.current=o.scrollTop,P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{P.current=null,O.current!==null&&f(O.current)},Pt))},[f]);l.useEffect(()=>()=>{P.current&&clearTimeout(P.current),O.current!==null&&f(O.current)},[f]);const r=l.useRef(void 0);l.useEffect(()=>{var F,A;const o=r.current;if(r.current=n,o===void 0||n===o||n===null)return;const c=s.findIndex(I=>I.entry.path===n);if(c<0)return;const k=a.current;k&&(D?b.scrollToIndex(c,{align:"auto"}):(A=(F=k.querySelector(`[data-row-index="${c}"]`))==null?void 0:F.scrollIntoView)==null||A.call(F,{block:"nearest"}),_.current=k.scrollTop)},[n,s,D,b]);const[d,g]=l.useState(!1),{onCopyInto:C,onMove:w}=e,j=e.readOnly===!0,y=l.useCallback(o=>{j||!pe(o.dataTransfer.types)||(o.preventDefault(),o.dataTransfer.dropEffect=o.altKey?"copy":"move",g(!0))},[j]),N=l.useCallback((o,c)=>{const k=s.find(F=>F.entry.path===o);k&&C({path:o,isDir:k.entry.type==="dir"},c)},[s,C]),L=l.useCallback(o=>{if(g(!1),j)return;const c=fe(o.dataTransfer);c!==null&&(o.preventDefault(),o.altKey?N(c,z):w(c,z))},[N,w,j]),u=o=>t.jsx(St,{row:o,selected:o.entry.path===n,renaming:o.entry.path===m,error:o.entry.type==="dir"&&o.expanded&&p.has(o.entry.path),onSelect:c=>x(c.path),onActivate:i,onRetry:()=>h(o.entry.path),onSubmitRename:e.onSubmitRename,onCancelRename:e.onCancelRename,onStartRename:e.onStartRename,onNewFile:e.onNewFile,onNewFolder:e.onNewFolder,onDelete:e.onDelete,onMove:e.onMove,onCopyInto:N,onCopy:e.onCopy,onPaste:e.onPaste,onDuplicate:e.onDuplicate,canPasteInto:e.canPasteInto,revealLabel:e.revealLabel,onReveal:e.onReveal,onAddToChat:e.onAddToChat,onCopyPath:e.onCopyPath,readOnly:e.readOnly,provenance:e.provenance});return t.jsx("div",{ref:a,role:"tree","aria-label":"File explorer",tabIndex:0,onKeyDown:E,onScroll:R,onDragOver:y,onDragLeave:()=>g(!1),onDrop:L,className:ae("focus-visible:ring-ring/40 h-full overflow-auto outline-none focus-visible:ring-1 focus-visible:ring-inset",d&&"ring-ring/60 bg-accent/30 ring-1 ring-inset"),children:D?t.jsx("div",{style:{height:b.getTotalSize()},className:"relative w-full",children:b.getVirtualItems().map(o=>t.jsx("div",{"data-row-index":o.index,className:"absolute top-0 left-0 w-full",style:{transform:`translateY(${o.start}px)`},children:u(s[o.index])},s[o.index].entry.path))}):s.map((o,c)=>t.jsx("div",{"data-row-index":c,children:u(o)},o.entry.path))})}function Lt(e){return e?e.type==="dir"?e.path:H(e.path):z}function At(e,s){const{rows:n,selectedPath:m,renamingPath:p,onSelectPath:x}=e;return l.useCallback(h=>{var v,i,E,D;if(p!==null)return;const a=n.findIndex(b=>b.entry.path===m),f=a>=0?n[a]:void 0;if(h.metaKey||h.ctrlKey){if(e.readOnly===!0)return;const b=h.key.toLowerCase();if(b==="c"&&f){h.preventDefault(),e.onCopy(f.entry);return}if(b==="v"){h.preventDefault(),e.onPaste(Lt(f==null?void 0:f.entry));return}return}switch(h.key){case"ArrowDown":h.preventDefault(),x(((v=n[Math.min(a+1,n.length-1)])==null?void 0:v.entry.path)??((i=n[0])==null?void 0:i.entry.path));break;case"ArrowUp":h.preventDefault(),x(((E=n[Math.max(a-1,0)])==null?void 0:E.entry.path)??((D=n[0])==null?void 0:D.entry.path));break;case"ArrowRight":(f==null?void 0:f.entry.type)==="dir"&&!f.expanded&&(h.preventDefault(),e.onToggle(f.entry));break;case"ArrowLeft":if(!f)break;if(h.preventDefault(),f.entry.type==="dir"&&f.expanded)e.onToggle(f.entry);else{const b=H(f.entry.path);b&&x(b)}break;case"Enter":f&&(h.preventDefault(),s(f.entry));break;case"F2":f&&e.readOnly!==!0&&(h.preventDefault(),e.onStartRename(f.entry));break;case"Delete":case"Backspace":f&&e.readOnly!==!0&&(h.preventDefault(),e.onDelete(f.entry));break}},[n,m,p,x,e,s])}function It({source:e,className:s}={}){var L;const n=U(),m=se(u=>u.selectedCwd),p=l.useMemo(()=>m?Dt({transport:n,cwd:m}):null,[n,m]),x=e===void 0?p:e,h=x!==null&&!x.writable,a=Nt(x),{rows:f,rootLoading:v,rootError:i,errorPaths:E}=a,D=S(u=>u.setCommands),b=S(u=>u.selectedPath),M=S(u=>u.setSelectedPath),_=S(u=>u.clipboard),[O,P]=l.useState(null),[R,r]=l.useState(null),[d,g]=l.useState(null),C=l.useCallback(u=>_!==null&&!(_.isDir&&J(u,_.path)),[_]),w=l.useCallback((u,o)=>{a.ensureExpanded(u),r(null),P({parent:u,type:o})},[a]),j=l.useRef({startCreate:w,reload:a.reload});l.useEffect(()=>{j.current={startCreate:w,reload:a.reload}}),l.useEffect(()=>{if(!h)return D({newFile:()=>j.current.startCreate(z,"file"),newFolder:()=>j.current.startCreate(z,"dir"),refresh:()=>j.current.reload()}),()=>D(null)},[D,h]);const y=l.useCallback(async u=>{if(!O)return;const o=O;P(null),await a.createEntry(o.parent,u,o.type)&&M(q(o.parent,u))},[O,a,M]),N=l.useCallback(async(u,o)=>{r(null),await a.renameEntry(u,o)&&M(q(H(u.path),o))},[a,M]);return x===null?e!==void 0?null:t.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-6 text-center text-sm",children:"Select a working directory to browse its files."}):t.jsxs("div",{className:ae("flex h-full flex-col",s),children:[t.jsxs("div",{className:"min-h-0 flex-1",children:[O&&t.jsx(zt,{type:O.type,onSubmit:u=>void y(u),onCancel:()=>P(null)}),v&&f.length===0?t.jsx("div",{className:"flex h-20 items-center justify-center",children:t.jsx(ce,{size:"md",className:"text-muted-foreground",label:"Loading files"})}):i&&f.length===0?t.jsxs("div",{className:"text-muted-foreground flex h-20 flex-col items-center justify-center gap-2 text-xs",children:[t.jsx("span",{children:"Couldn’t load files."}),t.jsxs(Y,{variant:"outline",size:"xs",onClick:a.reload,children:[t.jsx(de,{}),"Retry"]})]}):f.length===0&&!O?t.jsx("div",{className:"text-muted-foreground/60 flex h-20 items-center justify-center text-xs",children:"Empty directory"}):t.jsx(Mt,{rows:f,selectedPath:b,renamingPath:R,errorPaths:E,onSelectPath:M,onToggle:a.toggleExpand,onOpen:u=>{x.preview==="inline"?g(u.path):a.openFile(u)},onRetryDir:a.retryDir,onSubmitRename:(u,o)=>void N(u,o),onCancelRename:()=>r(null),onStartRename:u=>r(u.path),onNewFile:u=>w(u,"file"),onNewFolder:u=>w(u,"dir"),onDelete:u=>void a.removeEntry(u),onMove:(u,o)=>void a.moveEntry(u,o),onCopyInto:(u,o)=>void a.copyEntry(u,o),onCopy:a.copyToClipboard,onPaste:u=>{_&&a.copyEntry(_,u)},onDuplicate:u=>void a.copyEntry({path:u.path,isDir:u.type==="dir"},H(u.path)),canPasteInto:C,readOnly:h,provenance:x.provenance,revealLabel:a.revealLabel,onReveal:u=>void a.reveal(u),onAddToChat:a.addToChat,onCopyPath:(u,o)=>void a.copyPath(u,o)})]}),x.preview==="inline"&&t.jsx(dt,{source:x,path:d,onClose:()=>g(null)}),t.jsx(Ye,{open:a.pendingRecursiveDelete!==null,onOpenChange:u=>!u&&a.cancelRecursiveDelete(),children:t.jsxs(Qe,{children:[t.jsxs(Ue,{children:[t.jsx(qe,{children:"Delete this folder?"}),t.jsxs(Be,{children:["“",(L=a.pendingRecursiveDelete)==null?void 0:L.name,"” isn’t empty. Deleting it removes everything inside. This can’t be undone."]})]}),t.jsxs(We,{children:[t.jsx(Ge,{onClick:a.cancelRecursiveDelete,children:"Cancel"}),t.jsx(Ve,{onClick:()=>void a.confirmRecursiveDelete(),className:"bg-destructive hover:bg-destructive/90 dark:bg-destructive/60 text-white",children:"Delete"})]})]})})]})}function zt({type:e,onSubmit:s,onCancel:n}){const m=l.useRef(null),[p,x]=l.useState("");l.useEffect(()=>{var a;(a=m.current)==null||a.focus()},[]);const h=()=>{const a=p.trim();a?s(a):n()};return t.jsxs("div",{className:"flex items-center gap-1 px-3 py-1",children:[e==="dir"?t.jsx(ue,{className:"size-(--size-icon-sm) flex-shrink-0 text-sky-500"}):t.jsx(he,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}),t.jsx("input",{ref:m,type:"text",value:p,"aria-label":e==="dir"?"New folder name":"New file name",placeholder:e==="dir"?"folder-name":"file-name",onChange:a=>x(a.target.value),onBlur:h,onKeyDown:a=>{a.key==="Enter"?h():a.key==="Escape"&&n()},className:"border-border bg-background min-w-0 flex-1 rounded border px-1 py-0 text-sm outline-none"})]})}function be(){const e=S(m=>m.showHidden),s=S(m=>m.setShowHidden),n=e?"Hide hidden files":"Show hidden files";return t.jsx(Y,{variant:"ghost",size:"icon-xs","aria-label":n,title:n,onClick:()=>s(!e),children:e?t.jsx(Xe,{className:"text-muted-foreground"}):t.jsx(Ze,{className:"text-muted-foreground"})})}function Kt({cwd:e}){const s=U(),{data:n}=X({queryKey:["file-explorer","workspace",e],queryFn:()=>s.resolveWorkspace(e),staleTime:6e4});return n!=null&&n.branch?t.jsxs("span",{className:"text-muted-foreground bg-muted/50 text-2xs inline-flex min-w-0 items-center gap-1 rounded px-1.5 py-0.5",title:`Workspace ${n.key} on ${n.branch}`,children:[t.jsx(me,{className:"size-3 flex-shrink-0"}),t.jsx("span",{className:"truncate",children:n.branch})]}):null}function Bt(){const e=se(n=>n.selectedCwd),s=S(n=>n.commands);return e?t.jsxs(t.Fragment,{children:[t.jsx(Kt,{cwd:e}),t.jsx(Y,{variant:"ghost",size:"icon-xs","aria-label":"New file",title:"New file",onClick:()=>s==null?void 0:s.newFile(),children:t.jsx(ft,{className:"text-muted-foreground"})}),t.jsx(Y,{variant:"ghost",size:"icon-xs","aria-label":"New folder",title:"New folder",onClick:()=>s==null?void 0:s.newFolder(),children:t.jsx(Je,{className:"text-muted-foreground"})}),t.jsx(be,{}),t.jsx(Y,{variant:"ghost",size:"icon-xs","aria-label":"Refresh",title:"Refresh",onClick:()=>s==null?void 0:s.refresh(),children:t.jsx(et,{className:"text-muted-foreground"})})]}):null}function Ht({roomId:e}){const s=U(),n=V(),m=X(xe(s,e));l.useEffect(()=>ut(n,e,()=>{n.invalidateQueries({queryKey:ee.repoStatus(e)})}),[n,e]);const p=l.useMemo(()=>{var f;return((f=m.data)==null?void 0:f.kind)==="ok"?tt(m.data.status):[]},[m.data]),x=nt(p),h=st(p);if(!h)return null;const a=p.map((f,v)=>`${x[v]}: ${at(f)}`);return t.jsxs("span",{"data-slot":"pending-work-badge",title:a.join(`
|
|
7
|
+
`),className:"text-muted-foreground bg-muted/50 text-2xs inline-flex min-w-0 items-center gap-1 rounded px-1.5 py-0.5",children:[t.jsx(me,{className:"size-3 flex-shrink-0"}),t.jsxs("span",{className:"sr-only",children:["Not merged into the room yet. ",a.join(". "),"."]}),t.jsx("span",{"aria-hidden":"true",className:"truncate",children:h})]})}const $t={added:"added",modified:"changed",deleted:"deleted",untracked:"new"},Yt=new Map([["OPERATOR_ONLY","Only the person who owns this DorkOS can decide what happens to those changes."],["ROOM_FILE_NOT_FOUND","One of those changes is not there any more, so nothing was discarded. The list below has been refreshed."],["MERGE_IN_FLIGHT","Something else is writing to this room’s files right now. Nothing was changed. Try again in a moment."],["MAIN_CHECKOUT_DIRTY","This room’s files are on another branch, which DorkOS will not move for you. Put them back on main yourself."],["ROOM_REPO_GIT_UNAVAILABLE","This computer doesn’t have git installed, and a room’s files are a git repository."],["ROOM_HAS_NO_REPO","This room does not have files of its own any more."],["ROOM_REPOS_DISABLED","Rooms cannot have files of their own on this install right now."]]);function Qt({roomId:e}){var O,P;const s=U(),n=V(),m=X(xe(s,e)),[p,x]=l.useState([]),[h,a]=l.useState(!1),[f,v]=l.useState(null),i=rt({mutationFn:R=>s.repairRoomMain(e,R),onSuccess:()=>{x([]),a(!1),v(null),n.invalidateQueries({queryKey:ee.repoStatus(e)})},onError:R=>{a(!1);const r=Yt.get(le(R)??"");v(r??"That didn’t work. Try again in a moment."),n.invalidateQueries({queryKey:ee.repoStatus(e)})}});if(((O=m.data)==null?void 0:O.kind)==="unavailable")return t.jsx("p",{role:"alert","data-slot":"room-main-warning",className:"border-border/60 text-muted-foreground rounded-lg border px-3 py-2.5 text-xs",children:"DorkOS couldn’t check whether this room’s files are in order. If saving here is refused, this is why. Try again in a moment."});const E=((P=m.data)==null?void 0:P.kind)==="ok"?m.data.status.main:void 0;if(E===void 0||!E.dirty)return null;const D=E.branch!=="main",b=p.filter(R=>E.strays.some(r=>r.path===R)),M=h&&b.length>0,_=R=>x(r=>r.includes(R)?r.filter(d=>d!==R):[...r,R]);return t.jsxs("div",{role:"alert","data-slot":"room-main-warning",className:"border-border/60 bg-muted/40 space-y-3 rounded-lg border px-3 py-2.5 text-sm",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(ot,{className:"text-muted-foreground mt-0.5 size-(--size-icon-sm) flex-shrink-0"}),t.jsxs("div",{className:"min-w-0 space-y-1",children:[t.jsx("p",{className:"font-medium",children:"Somebody changed this room’s files outside DorkOS"}),t.jsx("p",{className:"text-muted-foreground text-xs",children:D?`This room’s files are on ${E.branch??"no branch"} instead of main. Nobody can save a file here and no agent can merge into it until they are back on main. DorkOS will not move a branch it did not move, in case there is work on it.`:"Nobody can save a file here, and no agent can merge its work in, until these are dealt with."})]})]}),!D&&t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"space-y-1.5",children:E.strays.map(R=>t.jsxs("li",{className:"flex items-center gap-2",children:[t.jsx(it,{id:`stray-${e}-${R.path}`,checked:b.includes(R.path),onCheckedChange:()=>_(R.path),disabled:i.isPending}),t.jsx("label",{htmlFor:`stray-${e}-${R.path}`,className:"min-w-0 flex-1 cursor-pointer truncate font-mono text-xs",title:R.path,children:R.path}),t.jsx("span",{className:"text-muted-foreground flex-shrink-0 text-xs",children:$t[R.kind]})]},R.path))}),E.strayCount>E.strays.length&&t.jsxs("p",{className:"text-muted-foreground text-xs",children:["…and ",E.strayCount-E.strays.length," more, not listed here. Keeping them all still keeps every one."]}),M?t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-xs",children:b.length===1?"Throw away that change? It cannot be brought back.":`Throw away those ${b.length} changes? They cannot be brought back.`}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(Y,{type:"button",variant:"ghost",size:"sm",disabled:i.isPending,onClick:()=>a(!1),children:"Cancel"}),t.jsx(Y,{type:"button",variant:"destructive",size:"sm",disabled:i.isPending,onClick:()=>i.mutate({action:"discard",paths:[...b]}),children:"Yes, discard"})]})]}):t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(Y,{type:"button",variant:"outline",size:"sm",disabled:i.isPending,onClick:()=>i.mutate({action:"commit"}),children:"Keep them all"}),t.jsx(Y,{type:"button",variant:"ghost",size:"sm",disabled:i.isPending||b.length===0,onClick:()=>a(!0),children:b.length===0?"Discard…":`Discard ${b.length}`})]})]}),f!==null&&t.jsx("p",{className:"text-destructive text-xs",children:f})]})}function Wt({roomId:e}){const s=U(),n=V(),m=S(v=>v.showHidden),p=l.useMemo(()=>ht({transport:s,queryClient:n,roomId:e}),[s,n,e]),x=X(ye(p,z,m,n)),h=x.isSuccess&&x.data.absent!==!0||x.isError,[a,f]=l.useState(null);return h&&a!==e&&f(e),!h&&a!==e?null:t.jsxs("section",{"aria-label":"Room files",className:"space-y-2",children:[t.jsxs("header",{className:"flex items-center gap-2",children:[t.jsx(lt,{className:"text-muted-foreground size-(--size-icon-sm) flex-shrink-0"}),t.jsx("h3",{className:"text-muted-foreground text-xs font-medium tracking-wide uppercase",children:"Files"}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(Ht,{roomId:e})}),t.jsx(be,{})]}),t.jsx(Qt,{roomId:e}),t.jsx("div",{"data-slot":"room-files-body",className:"border-border/60 h-72 overflow-hidden rounded-lg border",children:t.jsx(It,{source:p})})]})}export{It as FileExplorer,Bt as FileExplorerActions,dt as FilePreviewDialog,pt as HIDDEN_ENTRY_NAMES,be as HiddenEntriesToggle,Xt as NO_PROVENANCE,te as PINNED_ENTRY_NAMES,Zt as ROOM_FILES_REFRESH_INTERVAL_MS,Wt as RoomFilesSection,ht as createRoomFilesSource,Dt as createSessionCwdSource,G as explorerDirQueryKey,ye as explorerDirQueryOptions,mt as isHiddenEntryName,ne as isPinnedEntryName,gt as pinnedFirst,ct as provenanceLine,xe as roomRepoStatusQueryOptions,xt as withoutHidden};
|