@ironmussa/funny 0.1.10 → 0.1.11
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/bin/funny.js +8 -1
- package/package.json +2 -2
- package/packages/client/dist/assets/{AcceptInvitePage-CwYQtIVI.js → AcceptInvitePage-D7Il7Oy6.js} +1 -1
- package/packages/client/dist/assets/{ActivityPane-BqtiKQoc.js → ActivityPane-ZLkciVNI.js} +1 -1
- package/packages/client/dist/assets/{AddProjectView-BTUbNCf5.js → AddProjectView-BoxURbXr.js} +1 -1
- package/packages/client/dist/assets/{AllThreadsView-SgG-25oj.js → AllThreadsView-BmiDeocL.js} +1 -1
- package/packages/client/dist/assets/{AnalyticsView--eEfsZ7M.js → AnalyticsView-BX-KDDKJ.js} +1 -1
- package/packages/client/dist/assets/{App-DD7u4SAw.js → App-B6BGo4yf.js} +3 -3
- package/packages/client/dist/assets/{AutomationInboxView-By8MsYYO.js → AutomationInboxView-8IGMoS_S.js} +1 -1
- package/packages/client/dist/assets/{BrowserPanel-Cq089yp_.js → BrowserPanel-Bzdg58ZG.js} +1 -1
- package/packages/client/dist/assets/{BrowserPreview-REscPcXd.js → BrowserPreview-BOxVGzyc.js} +1 -1
- package/packages/client/dist/assets/{CircuitBreakerDialog-CsddJfvm.js → CircuitBreakerDialog-B4OWgguW.js} +1 -1
- package/packages/client/dist/assets/{CommandPalette-CI9t7rz5.js → CommandPalette-MMYtBRjJ.js} +1 -1
- package/packages/client/dist/assets/{CommentsPane-BFha7ll9.js → CommentsPane-CpkEXWbc.js} +1 -1
- package/packages/client/dist/assets/{CsvTable-HqueUd-d.js → CsvTable-BOI06_8F.js} +1 -1
- package/packages/client/dist/assets/{FileSearchDialog-BBLwpk_T.js → FileSearchDialog-C8O2b1og.js} +1 -1
- package/packages/client/dist/assets/{FileTree-0rn6jPHG.js → FileTree-BrArkMtz.js} +1 -1
- package/packages/client/dist/assets/{FolderPicker-NfYl0JOO.js → FolderPicker-CrcjKOtR.js} +1 -1
- package/packages/client/dist/assets/{GeneralSettingsView-CTrMytqS.js → GeneralSettingsView-h7BZ9Tqb.js} +2 -2
- package/packages/client/dist/assets/{GitProgressModal-DZRRb0Wv.js → GitProgressModal-D_VHqQRJ.js} +1 -1
- package/packages/client/dist/assets/{LiveColumnsView-DayolaGm.js → LiveColumnsView-DMHvLL0i.js} +1 -1
- package/packages/client/dist/assets/{LoginPage-BM8wco-G.js → LoginPage-C96WmzM4.js} +1 -1
- package/packages/client/dist/assets/{MediaPreview-Boc_Efcs.js → MediaPreview-kFmnVZEY.js} +1 -1
- package/packages/client/dist/assets/{MediaPreviewDialog-BvgtE3i6.js → MediaPreviewDialog-C9--Xfxu.js} +1 -1
- package/packages/client/dist/assets/{MermaidBlock-XIvP1J5s.js → MermaidBlock-BjQsl7KO.js} +1 -1
- package/packages/client/dist/assets/{MobilePage-528TrvBe.js → MobilePage-DoXo78uX.js} +2 -2
- package/packages/client/dist/assets/{MonacoEditorDialog-PIV1zMvf.js → MonacoEditorDialog-Cb71l4qC.js} +1 -1
- package/packages/client/dist/assets/{OrchestratorView-DyGhY-_D.js → OrchestratorView-DlrqZ8eO.js} +1 -1
- package/packages/client/dist/assets/{PreferencesPanel-BWEoYcWd.js → PreferencesPanel-BKPNAbb_.js} +1 -1
- package/packages/client/dist/assets/{PreviewBrowser-CMOLaONB.js → PreviewBrowser-CCR1deT4.js} +1 -1
- package/packages/client/dist/assets/{ProjectFilesPane-6h4yPJAD.js → ProjectFilesPane-ByjOGBzy.js} +1 -1
- package/packages/client/dist/assets/{ProjectHeader-CMxS5sHZ.js → ProjectHeader-DyRotlSA.js} +1 -1
- package/packages/client/dist/assets/{ProjectHooksSettings-CVJ-nm6H.js → ProjectHooksSettings-C4lxevV5.js} +1 -1
- package/packages/client/dist/assets/{ReviewPane-BzRzkCjt.js → ReviewPane-CX27KpWD.js} +1 -1
- package/packages/client/dist/assets/{SearchablePicker-BjX782MP.js → SearchablePicker-DVLrO1bu.js} +1 -1
- package/packages/client/dist/assets/{SettingsDetailView-DNPOyp0D.js → SettingsDetailView-BYyct5cK.js} +1 -1
- package/packages/client/dist/assets/{SettingsPageContent-S-wTMLuj.js → SettingsPageContent-CNfazaPs.js} +3 -3
- package/packages/client/dist/assets/{SetupWizard-fmU23YxJ.js → SetupWizard-DKwWUPoq.js} +1 -1
- package/packages/client/dist/assets/{Sidebar-Bw2Ioplc.js → Sidebar-CSu3eGez.js} +1 -1
- package/packages/client/dist/assets/{StashTab-Cg0Maipz.js → StashTab-C9d1yxU6.js} +1 -1
- package/packages/client/dist/assets/{TestRunnerPane-Bmx-1-73.js → TestRunnerPane-Cy-y0Urm.js} +1 -1
- package/packages/client/dist/assets/{TextSearchDialog-HKGHYT_o.js → TextSearchDialog-BlKI10Hy.js} +1 -1
- package/packages/client/dist/assets/{ThreadPowerline-JsNrt5F9.js → ThreadPowerline-DHjTbyCI.js} +1 -1
- package/packages/client/dist/assets/{ThreadStatusPin-R_yWmCoT.js → ThreadStatusPin-A5CcOVmG.js} +1 -1
- package/packages/client/dist/assets/{ThreadView-BDULTg_h.js → ThreadView-DsgcIKK-.js} +1 -1
- package/packages/client/dist/assets/{app-store-zHVd_RAl.js → app-store-CkfLtj-u.js} +1 -1
- package/packages/client/dist/assets/{automation-store-5RQ6ZEv3.js → automation-store-C7h4pWDb.js} +1 -1
- package/packages/client/dist/assets/{browser-panel-store-CfH8N_j3.js → browser-panel-store-BgjlFYk_.js} +2 -2
- package/packages/client/dist/assets/{button-QOkjXCsI.js → button-DL_y-bQm.js} +1 -1
- package/packages/client/dist/assets/{combine-BILvIlmd.js → combine-CDqDdXyw.js} +1 -1
- package/packages/client/dist/assets/{comment-store-DLNudBAH.js → comment-store-CMaCEsqD.js} +1 -1
- package/packages/client/dist/assets/{diff-parse-ChUK9GaG.js → diff-parse-SiWPZji5.js} +1 -1
- package/packages/client/dist/assets/{element-9KNKtLXh.js → element-JSHlqA80.js} +1 -1
- package/packages/client/dist/assets/{go-to-thread-D6Trf864.js → go-to-thread-Cvaa8Olw.js} +1 -1
- package/packages/client/dist/assets/{index-CAhq2HfW.js → index-BzzHdwZo.js} +2 -2
- package/packages/client/dist/assets/{input-6aKHjE5F.js → input-CCAE3mfQ.js} +1 -1
- package/packages/client/dist/assets/{items-CQJpN5w7.js → items-sHyHEl8t.js} +1 -1
- package/packages/client/dist/assets/{job-store-CMznU474.js → job-store-RXu4rpqJ.js} +1 -1
- package/packages/client/dist/assets/{kbd-CfA3upXH.js → kbd-Kex_rsEZ.js} +1 -1
- package/packages/client/dist/assets/{loading-state-CiP7DrB8.js → loading-state-B7VFf2px.js} +1 -1
- package/packages/client/dist/assets/{markdown-components-CaozR9zQ.js → markdown-components-CMS8J4V7.js} +1 -1
- package/packages/client/dist/assets/{native-git-store-1aY8koIG.js → native-git-store-Bu37WJNp.js} +1 -1
- package/packages/client/dist/assets/{orchestrator-store-B3cSUPy-.js → orchestrator-store-DLpxPxmm.js} +1 -1
- package/packages/client/dist/assets/{pipeline-approval-store-DDI5MtT0.js → pipeline-approval-store-VbySAyV9.js} +1 -1
- package/packages/client/dist/assets/{pr-detail-store-b2ZoxQFv.js → pr-detail-store-B-QD9rdh.js} +1 -1
- package/packages/client/dist/assets/{providers-CXnyofPN.js → providers-ySjYUuYV.js} +1 -1
- package/packages/client/dist/assets/{sidebar-chsp_x2A.js → sidebar-C4wtc5Cc.js} +1 -1
- package/packages/client/dist/assets/{tabs-DEUV5jFu.js → tabs-B3Tl2l09.js} +1 -1
- package/packages/client/dist/assets/{test-store-BDiRn2yK.js → test-store-Co9-McXa.js} +1 -1
- package/packages/client/dist/assets/{tooltip-icon-button-B5IohTsG.js → tooltip-icon-button-BsKucPEz.js} +1 -1
- package/packages/client/dist/assets/use-active-thread-id-DziVmncf.js +1 -0
- package/packages/client/dist/assets/{use-branch-switch-BGT_u9P1.js → use-branch-switch-3Q6NlO39.js} +1 -1
- package/packages/client/dist/assets/{use-image-lightbox-9mwEVC_V.js → use-image-lightbox-wBZdo-IW.js} +1 -1
- package/packages/client/dist/assets/{use-stable-navigate-BxdZa-Ti.js → use-stable-navigate-Dub9C1RE.js} +1 -1
- package/packages/client/dist/assets/{use-terminal-scope-CiW1SN3R.js → use-terminal-scope-CBl6Yy6Z.js} +1 -1
- package/packages/client/dist/assets/{use-thread-creation-DOTmwLZD.js → use-thread-creation-DRU3zJqT.js} +1 -1
- package/packages/client/dist/assets/{use-thread-search-BndwYsGw.js → use-thread-search-GmysdcbC.js} +1 -1
- package/packages/client/dist/assets/{use-todo-panel-CnifRS4_.js → use-todo-panel-DSumqCz3.js} +1 -1
- package/packages/client/dist/assets/{use-unified-prompt-model-groups-BgMV8ZK5.js → use-unified-prompt-model-groups-Bs9hZTeP.js} +1 -1
- package/packages/client/dist/assets/{use-ws-XNYpFLUp.js → use-ws-Rxo3-IBs.js} +3 -3
- package/packages/client/dist/assets/{visualizer-loader-LOQJ8YOT.js → visualizer-loader-Dr0yRhgU.js} +1 -1
- package/packages/client/dist/assets/{watcher-store-Dzhw8Q9b.js → watcher-store-DbYkaPlg.js} +1 -1
- package/packages/client/dist/index.html +1 -1
- package/packages/runtime/dist/index.js +2 -2
- package/packages/runtime/dist/index.js.map +1 -1
- package/packages/client/dist/assets/use-active-thread-id-CegcpJuJ.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{ar as t,jr as n,lr as r,w as i,zn as a,zr as o}from"./icons-sqwAEN28.js";import{o as s}from"./markdown-DBtwZWLP.js";import{P as c,lt as l}from"./index-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{ar as t,jr as n,lr as r,w as i,zn as a,zr as o}from"./icons-sqwAEN28.js";import{o as s}from"./markdown-DBtwZWLP.js";import{P as c,lt as l}from"./index-BzzHdwZo.js";import{t as u}from"./button-DL_y-bQm.js";import{t as d}from"./loading-state-B7VFf2px.js";var f=e(o(),1),p=e(s(),1);function m({current:e,total:t}){return(0,p.jsx)(`div`,{className:`flex items-center justify-center gap-2`,children:Array.from({length:t},(t,n)=>(0,p.jsx)(`div`,{className:l(`h-1.5 rounded-full transition-all duration-300`,n===e?`w-6 bg-primary`:n<e?`w-1.5 bg-primary/60`:`w-1.5 bg-muted-foreground/25`)},n))})}function h({onNext:e}){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`space-y-3 text-center`,children:[(0,p.jsx)(`div`,{className:`flex items-center justify-center`,children:(0,p.jsx)(i,{className:`text-primary size-8`})}),(0,p.jsx)(`h1`,{className:`text-foreground text-2xl font-semibold`,children:`Welcome to funny`}),(0,p.jsx)(`p`,{className:`text-muted-foreground text-sm leading-relaxed`,children:`Orchestrate multiple Claude Code agents in parallel. Each agent works on its own git branch, so they never conflict.`})]}),(0,p.jsxs)(`div`,{className:`text-muted-foreground space-y-2 text-sm`,children:[(0,p.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,p.jsx)(`span`,{className:`text-primary mt-0.5 font-mono text-xs`,children:`1.`}),(0,p.jsx)(`span`,{children:`Create a project by pointing to any git repository`})]}),(0,p.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,p.jsx)(`span`,{className:`text-primary mt-0.5 font-mono text-xs`,children:`2.`}),(0,p.jsx)(`span`,{children:`Spin up threads: each runs a Claude Code agent`})]}),(0,p.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,p.jsx)(`span`,{className:`text-primary mt-0.5 font-mono text-xs`,children:`3.`}),(0,p.jsx)(`span`,{children:`Review changes, commit, and merge when ready`})]})]}),(0,p.jsxs)(u,{className:`w-full`,onClick:e,children:[`Get Started`,(0,p.jsx)(n,{className:`icon-base ml-1`})]})]})}function g({onNext:e}){let[i,o]=(0,f.useState)(null),[s,l]=(0,f.useState)(!0),m=(0,f.useCallback)(async()=>{l(!0);let e=await c.setupStatus();e.isOk()?o(e.value.claudeCli):o({available:!1,path:null,error:`server_unreachable`,version:null}),l(!1)},[]);return(0,f.useEffect)(()=>{m()},[m]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`space-y-1 text-center`,children:[(0,p.jsx)(`h2`,{className:`text-foreground text-lg font-semibold`,children:`Claude Code CLI`}),(0,p.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`funny needs the Claude Code CLI to run agents.`})]}),(0,p.jsx)(`div`,{className:`border-border bg-muted/30 space-y-3 rounded-lg border p-4`,children:s?(0,p.jsx)(d,{fill:!1,layout:`inline`,className:`py-2`,testId:`setup-wizard-checking`,label:`Checking…`}):i?.available?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(r,{className:`icon-lg text-status-success`}),(0,p.jsx)(`span`,{className:`text-foreground text-sm font-medium`,children:`Claude CLI found`})]}),i.version&&(0,p.jsx)(`div`,{className:`text-muted-foreground font-mono text-xs`,children:i.version}),i.path&&(0,p.jsx)(`div`,{className:`text-muted-foreground truncate font-mono text-xs`,children:i.path})]}):i?.error===`server_unreachable`?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(t,{className:`icon-lg text-status-error`}),(0,p.jsx)(`span`,{className:`text-foreground text-sm font-medium`,children:`Server not reachable`})]}),(0,p.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Could not connect to the funny server. Make sure the server is running and try again.`})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(t,{className:`icon-lg text-status-error`}),(0,p.jsx)(`span`,{className:`text-foreground text-sm font-medium`,children:`Claude CLI not found`})]}),(0,p.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Install the Claude Code CLI to continue. Visit the official documentation for installation instructions.`}),(0,p.jsxs)(`a`,{href:`https://docs.anthropic.com/en/docs/claude-code/overview`,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary inline-flex items-center gap-1.5 text-xs hover:underline`,children:[`Installation Guide`,(0,p.jsx)(a,{className:`icon-xs`})]})]})}),(0,p.jsxs)(`div`,{className:`flex gap-2`,children:[!s&&!i?.available&&(0,p.jsx)(u,{variant:`outline`,className:`flex-1`,onClick:m,children:`Check Again`}),(0,p.jsxs)(u,{className:`flex-1`,disabled:s||!i?.available&&i?.error!==`server_unreachable`,onClick:e,children:[`Continue`,(0,p.jsx)(n,{className:`icon-base ml-1`})]})]})]})}function _({onFinish:e}){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`space-y-3 text-center`,children:[(0,p.jsx)(r,{className:`text-status-success mx-auto size-10`}),(0,p.jsx)(`h2`,{className:`text-foreground text-lg font-semibold`,children:`You're all set!`}),(0,p.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Everything is configured. Add your first project to get started.`})]}),(0,p.jsxs)(u,{className:`w-full`,onClick:e,children:[`Enter funny`,(0,p.jsx)(n,{className:`icon-base ml-1`})]})]})}function v({onComplete:e}){let[t,n]=(0,f.useState)(0),[r,i]=(0,f.useState)(null);(0,f.useEffect)(()=>{let e=!1;return c.bootstrap().then(t=>{e||i(t.isOk()&&t.value.mode===`standalone`?`standalone`:`team`)}),()=>{e=!0}},[]);let a=async()=>{(await c.completeSetup()).isErr()&&await c.completeSetup(),localStorage.setItem(`funny:setupCompleted`,`true`),e()};if(r===null)return(0,p.jsx)(`div`,{className:`bg-background flex min-h-screen items-center justify-center`,children:(0,p.jsx)(`div`,{className:`border-border bg-card w-full max-w-md rounded-lg border p-8 shadow-lg`,children:(0,p.jsx)(d,{testId:`setup-wizard-loading`,label:`Loading…`})})});let o=r===`team`?[(0,p.jsx)(h,{onNext:()=>n(1)},`welcome`),(0,p.jsx)(_,{onFinish:a},`done`)]:[(0,p.jsx)(h,{onNext:()=>n(1)},`welcome`),(0,p.jsx)(g,{onNext:()=>n(2)},`claude`),(0,p.jsx)(_,{onFinish:a},`done`)];return(0,p.jsx)(`div`,{className:`bg-background flex min-h-screen items-center justify-center`,children:(0,p.jsxs)(`div`,{className:`border-border bg-card w-full max-w-md space-y-6 rounded-lg border p-8 shadow-lg`,children:[(0,p.jsx)(m,{current:t,total:o.length}),o[t]]})})}export{v as SetupWizard};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{B as t,Bn as n,Cr as r,Ft as i,Kt as a,L as o,Lr as s,Mr as c,Q as l,Rn as u,W as d,Xt as f,_t as p,b as m,bn as h,br as g,d as _,dt as v,ft as y,hn as b,hr as x,i as S,k as ee,ot as te,p as C,qn as ne,qt as re,r as ie,vn as ae,w as oe,y as se,yn as ce,zn as w,zr as T}from"./icons-sqwAEN28.js";import{o as E}from"./markdown-DBtwZWLP.js";import{t as D}from"./useTranslation-DAPPK3Hy.js";import{G as O,M as k,N as le,P as ue,W as A,_t as j,d as M,dt as N,ft as de,k as P,lt as F,ot as I,pt as L,q as R,st as fe,ut as z}from"./index-CAhq2HfW.js";import{i as pe,t as B}from"./button-QOkjXCsI.js";import{$n as me,$r as he,An as ge,B as V,Bn as _e,Dn as ve,Dr as H,Ft as ye,Gn as be,Gr as xe,Ir as Se,Jn as U,Jr as Ce,Kn as we,Lt as Te,Mn as Ee,Mt as De,Nt as Oe,On as ke,Or as Ae,Qn as je,Rr as Me,Rt as W,Un as G,V as K,Xn as Ne,Xr as Pe,Yr as Fe,Zn as Ie,at as Le,ct as Re,er as ze,in as Be,jn as Ve,mt as He,pt as Ue,qr as We,r as Ge,rn as Ke,sr as qe,st as Je,t as Ye,tr as Xe,ut as Ze,xn as Qe,yr as q,z as J}from"./items-CQJpN5w7.js";import{n as $e,r as et,t as tt}from"./adapter-g71mvnZo.js";import{n as nt}from"./use-terminal-scope-CiW1SN3R.js";import{n as rt,t as it}from"./kbd-CfA3upXH.js";import{t as Y}from"./use-stable-navigate-BxdZa-Ti.js";import{c as at,i as ot,n as st,o as ct,r as lt,s as ut,t as dt,u as ft}from"./sidebar-chsp_x2A.js";import{t as X}from"./use-active-thread-id-CegcpJuJ.js";import{t as pt}from"./tooltip-icon-button-B5IohTsG.js";import{t as mt}from"./FolderPicker-NfYl0JOO.js";import{a as ht,c as gt,i as _t,n as vt,o as yt,r as bt,t as xt}from"./element-9KNKtLXh.js";import{i as St,n as Ct,r as Z}from"./ThreadStatusPin-R_yWmCoT.js";import{n as wt}from"./job-store-CMznU474.js";import{t as Tt}from"./watcher-store-Dzhw8Q9b.js";import{t as Et}from"./use-branch-switch-BGT_u9P1.js";import{n as Dt,t as Ot}from"./go-to-thread-D6Trf864.js";import{n as kt}from"./automation-store-5RQ6ZEv3.js";import{n as At}from"./PreferencesPanel-BWEoYcWd.js";import{t as jt}from"./use-minute-tick-C-e4HaZD.js";import{t as Mt}from"./drag-preview-D7uMScNk.js";var Q=e(T(),1);function Nt({projectsScrollRef:e,threadsScrollRef:t,projects:n,reorderProjects:r}){(0,Q.useEffect)(()=>{let n=[];e.current&&n.push({el:e.current,type:`sidebar-project`}),t.current&&n.push({el:t.current,type:`grid-thread`});let r=e=>{let t=e.el.scrollHeight>e.el.clientHeight;t&&!e.cleanup?e.cleanup=xt({element:e.el,canScroll:({source:t})=>t.data.type===e.type}):!t&&e.cleanup&&(e.cleanup(),e.cleanup=void 0)},i=new ResizeObserver(()=>{for(let e of n)r(e)}),a=[];for(let e of n){r(e),i.observe(e.el);for(let t of Array.from(e.el.children))i.observe(t);let t=new MutationObserver(()=>{for(let t of Array.from(e.el.children))i.observe(t);r(e)});t.observe(e.el,{childList:!0,subtree:!0}),a.push(t)}return()=>{i.disconnect();for(let e of a)e.disconnect();for(let e of n)e.cleanup?.()}},[e,t]),(0,Q.useEffect)(()=>et({onDrop:({source:e,location:t})=>{let i=t.current.dropTargets;if(!i.length||e.data.type!==`sidebar-project`)return;let a=i[0].data;if(a.type!==`sidebar-project`)return;let o=e.data.projectId,s=a.projectId;if(o===s)return;let c=n.findIndex(e=>e.id===o),l=n.findIndex(e=>e.id===s);if(c===-1||l===-1)return;let u=[...n],[d]=u.splice(c,1);u.splice(l,0,d),r(u.map(e=>e.id))}}),[n,r])}function Pt({selectedProjectId:e,projectsScrollRef:t,settingsNavOpen:n}){let r=H(e=>e.revealNonce),i=H(e=>e.revealIntent),a=H(e=>e.toggleProject),o=X();(0,Q.useEffect)(()=>{e&&(H.getState().expandedProjects.has(e)||a(e))},[e,r,a]),(0,Q.useEffect)(()=>{if(n||!e)return;let r=!1,a=(n=!1)=>{if(r)return!0;let a=t.current;if(!a)return!1;let s=o?a.querySelector(`[data-project-id="${e}"] [data-testid="thread-item-${o}"]`):null;if(o&&!s&&!n)return!1;let c=s??a.querySelector(`[data-testid="project-item-${e}"]`)??a.querySelector(`[data-project-id="${e}"]`);return c?(de(a,c,i),r=!0,!0):!1},s=requestAnimationFrame(()=>{a(!1)}),c=window.setTimeout(()=>a(!0),300);return()=>{cancelAnimationFrame(s),window.clearTimeout(c)}},[e,o,r,i,n,t])}var $=e(E(),1);function Ft(){let e=j(),{t}=D(),n=q(e=>e.activeSettingsPage),r=q(e=>e.settingsReturnPath),i=q(e=>e.setSettingsReturnPath),a=H(e=>e.selectedProjectId),o=H(e=>e.selectedProjectId?e.projects.find(t=>t.id===e.selectedProjectId):void 0),s=P(e=>e.user),l=Ye({selectedProjectId:a,isProjectAdmin:o?.role===`owner`||o?.role===`admin`||o?.userId===s?.id}),u=e=>a?`/projects/${a}/settings/${e}`:`/settings/${e}`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ot,{className:`px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(pt,{onClick:()=>{let t=r??(a?`/projects/${a}`:`/`);i(null),e(W(t))},className:`text-muted-foreground hover:text-foreground`,"data-testid":`settings-back`,tooltip:t(`common.back`),children:(0,$.jsx)(c,{className:`icon-sm`})}),(0,$.jsx)(`h1`,{className:`text-sm font-medium`,children:t(`settings.title`)})]})}),(0,$.jsx)(st,{className:`px-2 pb-2`,children:(0,$.jsx)(ct,{children:l.map(r=>{let i=r.icon;return(0,$.jsx)(at,{children:(0,$.jsxs)(ut,{isActive:n===r.id,onClick:()=>e(W(u(r.id))),"data-testid":`settings-nav-${r.id}`,children:[(0,$.jsx)(i,{className:`icon-base`}),(0,$.jsx)(`span`,{children:t(Ge[r.id]??r.label)})]})},r.id)})})})]})}var It=pe(`flex w-full items-center gap-2 rounded-md transition-colors`,{variants:{size:{sm:`px-2 py-1 text-xs`,md:`px-2 py-1.5 text-sm`},isActive:{true:`bg-sidebar-accent font-medium text-sidebar-accent-foreground`,false:`text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground`}},defaultVariants:{size:`md`,isActive:!1}}),Lt={sm:fe.sm,md:fe.base},Rt=(0,Q.forwardRef)(function({icon:e,label:t,count:n,size:r=`md`,isActive:i=!1,className:a,...o},s){return(0,$.jsxs)(`button`,{ref:s,className:F(It({size:r,isActive:i}),a),...o,children:[(0,$.jsx)(e,{className:F(Lt[r],`shrink-0`)}),(0,$.jsx)(`span`,{className:`truncate`,children:t}),n!==void 0&&n>0&&(0,$.jsx)(Le,{variant:`secondary`,size:`xs`,className:`ml-auto shrink-0`,children:n})]})}),zt=6e4,Bt=3e5;function Vt(){let e=j(),t=kt(e=>e.inboxCount),n=kt(e=>e.loadInbox),r=q(e=>e.automationInboxOpen),i=P(e=>e.isAuthenticated),a=(0,Q.useRef)(n);return a.current=n,(0,Q.useEffect)(()=>{if(!i)return;let e=0,t,n=async()=>{try{await a.current(),e=0}catch{e++}let r=Math.min(zt*2**e,Bt);t=setTimeout(n,r)};return n(),()=>clearTimeout(t)},[i]),(0,$.jsx)(Rt,{icon:f,label:`Automation Inbox`,count:t,isActive:r,"data-testid":`sidebar-automation-inbox`,onClick:()=>{e(W(r?`/`:`/inbox`))}})}var Ht=[{keys:[`Ctrl`,`K`],labelKey:`shortcuts.commandPalette`},{keys:[`Ctrl`,`Shift`,`P`],labelKey:`shortcuts.commandPaletteAlt`},{keys:[`Ctrl`,`P`],labelKey:`shortcuts.fileSearch`},{keys:[`Ctrl`,`F`],labelKey:`shortcuts.searchInThread`},{keys:[`Ctrl`,`Shift`,`F`],labelKey:`shortcuts.textSearch`},{keys:[`Ctrl`,`Shift`,`L`],labelKey:`shortcuts.searchAcrossThreads`},{keys:[`Ctrl`,`B`],labelKey:`shortcuts.toggleSidebar`},{keys:[`Ctrl`,`,`],labelKey:`shortcuts.projectSettings`},{keys:[`Alt`,`N`],labelKey:`shortcuts.newThread`},{keys:[`Alt`,`S`],labelKey:`shortcuts.newScratchThread`},{keys:[`Alt`,`]`],labelKey:`shortcuts.nextThread`},{keys:[`Alt`,`[`],labelKey:`shortcuts.prevThread`},{keys:[`Alt`,`←`],labelKey:`shortcuts.backThread`},{keys:[`Alt`,`→`],labelKey:`shortcuts.forwardThread`},{keys:[`Alt`,`G`],labelKey:`shortcuts.toggleReview`},{keys:[`Alt`,`F`],labelKey:`shortcuts.toggleFiles`},{keys:[`Alt`,`H`],labelKey:`shortcuts.toggleShare`},{keys:[`Alt`,`M`],labelKey:`shortcuts.toggleComments`},{keys:[`Ctrl`,"`"],labelKey:`shortcuts.toggleTerminal`},{keys:[`?`],labelKey:`shortcuts.openShortcuts`}];function Ut(){let{t:e}=D();return(0,$.jsx)(xe,{open:q(e=>e.keyboardShortcutsOpen),onOpenChange:q(e=>e.setKeyboardShortcutsOpen),children:(0,$.jsxs)(We,{"data-testid":`keyboard-shortcuts-dialog`,children:[(0,$.jsxs)(Pe,{children:[(0,$.jsx)(he,{children:e(`shortcuts.title`)}),(0,$.jsx)(Ce,{children:e(`shortcuts.description`)})]}),(0,$.jsx)(`ul`,{className:`divide-border flex flex-col divide-y`,children:Ht.map(t=>(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-4 py-2 text-sm`,"data-testid":`shortcut-row-${t.labelKey}`,children:[(0,$.jsx)(`span`,{className:`text-foreground`,children:e(t.labelKey)}),(0,$.jsx)(rt,{children:t.keys.map((e,t)=>(0,$.jsxs)(Q.Fragment,{children:[t>0&&(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`+`}),(0,$.jsx)(it,{children:e})]},`${e}-${t}`))})]},t.labelKey))})]})})}var Wt=`h-4 shrink-0 rounded px-1 py-0 text-[9px] leading-none font-medium`;function Gt(e){switch(e.status){case`pending`:return`pending`;case`fired`:return`woke agent`;case`done`:return`concluded`;case`cancelled`:return`cancelled`;case`expired`:return e.wakeCount>=e.maxWakes?`hit wake limit`:`timed out`;default:return e.status}}function Kt(e){switch(e){case`pending`:return`default`;case`fired`:return`secondary`;case`expired`:return`destructive`;default:return`outline`}}function qt({watcher:e,now:t}){let{t:n}=D(),r=Tt(e=>e.cancelWatcher),i=Ct.includes(e.status),a=e.status===`pending`,o=a?St(e.nextWakeAt,t):Ke(e.updatedAt,n),s=a?e.nextWakeAt:e.updatedAt,c=`${a?`fires`:`fired`} ${Z(s)}`,l=a?`Next wake ${Z(e.nextWakeAt)} · created ${Z(e.createdAt)}`:`Last update ${Z(e.updatedAt)} · created ${Z(e.createdAt)}`;return(0,$.jsxs)(A,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsxs)(`div`,{className:`hover:bg-accent flex items-start justify-between gap-2 rounded-md px-2 py-1.5`,"data-testid":`watcher-row-${e.id}`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.label}),(0,$.jsx)(Le,{variant:Kt(e.status),className:Wt,children:Gt(e)})]}),(0,$.jsxs)(`p`,{className:`text-muted-foreground truncate text-xs`,children:[o?`${o} · `:null,`checked `,e.wakeCount,`×`,e.maxWakes?` / ${e.maxWakes}`:``]}),(0,$.jsx)(`p`,{className:`text-muted-foreground/70 truncate text-xs`,children:c})]}),i?(0,$.jsx)(B,{variant:`ghost`,size:`icon-xs`,className:`text-muted-foreground size-6 shrink-0`,"data-testid":`watcher-cancel-${e.id}`,onClick:()=>void r(e.id),"aria-label":`Cancel watcher`,children:(0,$.jsx)(S,{className:`icon-sm`})}):null]})}),(0,$.jsx)(O,{children:l})]})}function Jt(e){switch(e.status){case`running`:return`running`;case`exited`:return`done`;case`failed`:return`failed (${e.exitCode??`?`})`;case`killed`:return`killed`;case`cancelled`:return`cancelled`;default:return e.status}}function Yt(e){switch(e){case`running`:return`default`;case`failed`:case`killed`:return`destructive`;default:return`outline`}}function Xt({job:e,scopeId:t,onOpened:n}){let{t:r}=D(),i=wt(e=>e.cancelJob),[a,o]=(0,Q.useState)(!1),s=e.status===`running`,c=()=>{let r=t??Ae(e.threadId)?.projectId??null;r&&(ht({job:e,projectId:r}),n())};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(A,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:c,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},className:`hover:bg-accent flex cursor-pointer items-start justify-between gap-2 rounded-md px-2 py-1.5`,"data-testid":`job-row-${e.id}`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.label||e.command}),(0,$.jsx)(Le,{variant:Yt(e.status),className:Wt,children:Jt(e)})]}),(0,$.jsxs)(`p`,{className:`text-muted-foreground truncate text-xs`,children:[`started `,Ke(e.startedAt,r),s?null:` · ended ${Ke(e.updatedAt,r)}`]}),(0,$.jsx)(`p`,{className:`text-muted-foreground/70 truncate font-mono text-xs`,children:e.command})]}),s?(0,$.jsx)(B,{variant:`ghost`,size:`icon-xs`,className:`text-muted-foreground size-6 shrink-0`,"data-testid":`job-cancel-${e.id}`,onClick:e=>{e.stopPropagation(),o(!0)},"aria-label":`Kill job`,title:`Kill this process`,children:(0,$.jsx)(S,{className:`icon-sm`})}):null]})}),(0,$.jsxs)(O,{children:[(0,$.jsx)(`div`,{children:`Started ${Z(e.startedAt)}${s?``:` · ended ${Z(e.updatedAt)}`}`}),(0,$.jsx)(`div`,{className:`text-muted-foreground`,children:`Open output in the terminal panel`})]})]}),(0,$.jsx)(qe,{open:a,onOpenChange:o,title:`Kill process?`,description:`This stops the running process: ${e.label||e.command}`,confirmLabel:`Kill`,cancelLabel:`Cancel`,variant:`destructive`,onCancel:()=>o(!1),onConfirm:()=>{o(!1),i(e.id)}})]})}function Zt(){let[e,t]=(0,Q.useState)(!1),[n,r]=(0,Q.useState)(()=>Date.now()),{scopeId:i}=nt(),a=Tt(e=>e.watchersById),o=Tt(e=>e.loadWatchers),c=wt(e=>e.jobsById),l=wt(e=>e.loadJobs),u=(0,Q.useMemo)(()=>{let e=e=>+!Ct.includes(e);return Object.values(a).sort((t,n)=>e(t.status)-e(n.status)||n.createdAt.localeCompare(t.createdAt))},[a]),d=(0,Q.useMemo)(()=>Object.values(c).sort((e,t)=>(e.status===`running`?0:1)-(t.status===`running`?0:1)||t.startedAt.localeCompare(e.startedAt)),[c]),f=(0,Q.useMemo)(()=>u.filter(e=>Ct.includes(e.status)).length+d.filter(e=>e.status===`running`).length,[u,d]);return(0,Q.useEffect)(()=>{o(),l()},[o,l]),(0,Q.useEffect)(()=>{if(!e)return;o(),l(),r(Date.now());let t=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(t)},[e,o,l]),(0,$.jsxs)(ge,{open:e,onOpenChange:t,children:[(0,$.jsx)(Ee,{asChild:!0,children:(0,$.jsx)(Rt,{icon:s,label:`Watchers`,count:f,isActive:e,"data-testid":`sidebar-watchers`})}),(0,$.jsx)(Ve,{side:`top`,align:`start`,className:`w-80 p-1`,"data-testid":`watcher-panel`,children:d.length===0&&u.length===0?(0,$.jsx)(`p`,{className:`text-muted-foreground px-2 py-4 text-center text-sm`,children:`No background activity yet.`}):(0,$.jsxs)(Be,{className:F(`max-h-96`,d.length+u.length>6&&`h-96`),children:[d.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`text-muted-foreground px-2 py-1.5 text-xs font-medium`,children:`Background jobs`}),(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:d.map(e=>(0,$.jsx)(Xt,{job:e,scopeId:i,onOpened:()=>t(!1)},e.id))})]}),u.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`text-muted-foreground px-2 py-1.5 text-xs font-medium`,children:`Watchers`}),(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:u.map(e=>(0,$.jsx)(qt,{watcher:e,now:n},e.id))})]})]})})]})}function Qt(){let{t:e}=D(),t=Y(),n=P(e=>e.user),r=P(e=>e.logout),a=q(e=>e.setKeyboardShortcutsOpen);return(0,$.jsxs)(lt,{className:`pb-4`,children:[(0,$.jsxs)(`div`,{className:`px-1`,children:[(0,$.jsx)(Vt,{}),(0,$.jsx)(Zt,{})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[n?(0,$.jsxs)(be,{children:[(0,$.jsx)(Xe,{asChild:!0,children:(0,$.jsxs)(B,{variant:`ghost`,"data-testid":`sidebar-user-menu`,className:`hover:bg-sidebar-accent h-auto min-w-0 flex-1 justify-start gap-2 px-1 py-1`,children:[(0,$.jsx)(ve,{size:`sm`,children:(0,$.jsx)(ke,{className:`text-xs`,name:n.displayName||void 0,children:n.displayName?.split(` `).map(e=>e[0]).join(``).slice(0,2).toUpperCase()||(0,$.jsx)(C,{className:`icon-sm`})})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 text-left`,children:[(0,$.jsx)(`p`,{className:`text-sidebar-foreground truncate text-sm font-medium`,children:n.displayName}),(0,$.jsxs)(`p`,{className:`text-muted-foreground truncate text-xs`,children:[`@`,n.username]})]})]})}),(0,$.jsxs)(we,{side:`top`,align:`start`,className:`w-48`,children:[(0,$.jsxs)(U,{"data-testid":`sidebar-user-shortcuts`,onClick:()=>a(!0),children:[(0,$.jsx)(re,{className:`icon-sm`}),e(`shortcuts.title`)]}),(0,$.jsx)(Ie,{}),(0,$.jsxs)(U,{"data-testid":`sidebar-logout`,onClick:r,children:[(0,$.jsx)(i,{className:`icon-sm`}),e(`auth.logout`)]})]})]}):null,(0,$.jsxs)(A,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(B,{variant:`ghost`,size:`icon-xs`,"data-testid":`sidebar-settings`,onClick:()=>t(W(`/preferences/general`)),className:F(`size-7 shrink-0 text-muted-foreground`,!n&&`ml-auto`),children:(0,$.jsx)(o,{className:`icon-base`})})}),(0,$.jsx)(O,{side:`top`,children:e(`settings.title`)})]})]}),(0,$.jsx)(Ut,{})]})}function $t({onPick:e,testId:t=`menu-open-editor`}){let{t:n}=D();return(0,$.jsxs)(je,{children:[(0,$.jsxs)(ze,{"data-testid":t,children:[(0,$.jsx)(w,{}),n(`thread.openInEditor`,`Open in Editor`)]}),(0,$.jsx)(Ne,{children:(0,$.jsx)(me,{children:Object.keys(M).map(n=>(0,$.jsx)(U,{"data-testid":`${t}-${n}`,onClick:t=>{t.stopPropagation(),e(n)},className:`cursor-pointer`,children:M[n]},n))})})]})}function en({projectId:e,projectName:t,open:n,onOpenChange:r}){let[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(``),u=H(e=>e.setProjectLocalPath);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(xe,{open:n&&!i,onOpenChange:r,children:(0,$.jsxs)(We,{"data-testid":`setup-project-dialog`,children:[(0,$.jsxs)(Pe,{children:[(0,$.jsxs)(he,{className:`flex items-center gap-2`,children:[(0,$.jsx)(se,{className:`icon-base text-status-warning`}),`Set up local directory`]}),(0,$.jsxs)(Ce,{children:[(0,$.jsx)(`strong`,{children:t}),` is a shared team project. To create threads, you need to select your local clone of this repository.`]})]}),c&&(0,$.jsx)(`p`,{className:`text-status-error text-sm`,"data-testid":`setup-project-error`,children:c}),(0,$.jsxs)(Fe,{children:[(0,$.jsx)(B,{variant:`outline`,onClick:()=>r(!1),"data-testid":`setup-project-cancel`,children:`Cancel`}),(0,$.jsxs)(B,{onClick:()=>a(!0),disabled:o,"data-testid":`setup-project-browse`,children:[(0,$.jsx)(ce,{className:`icon-sm mr-1.5`}),o?`Saving...`:`Browse...`]})]})]})}),i&&(0,$.jsx)(mt,{onSelect:async t=>{a(!1),s(!0),l(``);let n=await u(e,t);s(!1),n?r(!1):l(`Failed to set directory. Make sure the path is a valid git repository.`)},onClose:()=>a(!1)})]})}function tn({project:e,open:t,onOpenChange:n}){return e.needsSetup?(0,$.jsx)(en,{projectId:e.id,projectName:e.name,open:t,onOpenChange:n}):null}function nn({onClick:e,...t}){let{t:n}=D();return(0,$.jsx)(`button`,{onClick:e,className:`text-muted-foreground/60 hover:text-foreground py-1.5 pl-7 text-sm transition-colors`,...t,children:n(`sidebar.viewAll`)})}var rn=(0,Q.memo)(function({thread:e,projectId:t,projectPath:n,projectName:r,projectColor:i,isSelected:a,gitStatus:o,onSelectThread:s,onRenameThread:c,onArchiveThread:l,onPinThread:u,onDeleteThread:d}){let f=(0,Q.useRef)(null),[p,m]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let n=f.current;if(n)return tt({element:n,getInitialData:()=>({type:`grid-thread`,threadId:e.id,projectId:t}),onGenerateDragPreview:({nativeSetDragImage:e})=>Mt({nativeSetDragImage:e,source:n}),onDragStart:()=>m(!0),onDrop:()=>m(!1)})},[e.id,t]);let h=(0,Q.useCallback)(()=>s(t,e.id),[s,t,e.id]),g=(0,Q.useCallback)(n=>c(t,e.id,n),[c,t,e.id]),_=(0,Q.useCallback)(()=>l(t,e.id,e.title),[l,t,e.id,e.title]),v=(0,Q.useCallback)(()=>u(t,e.id,!e.pinned),[u,t,e.id,e.pinned]),y=(0,Q.useCallback)(()=>d(t,e.id,e.title),[d,t,e.id,e.title]),b=e.status===`running`||e.status===`setting_up`;return(0,$.jsx)(`div`,{ref:f,className:F(p&&`opacity-50`),children:(0,$.jsx)(bt,{thread:e,projectPath:n,projectColor:i,isSelected:a,onSelect:h,href:W(`/projects/${t}/threads/${e.id}`),onRename:g,onArchive:b?void 0:_,onPin:v,onDelete:b?void 0:y,gitStatus:o})})});function an(e,t){if(e.threads!==t.threads||e.threadsLoaded!==t.threadsLoaded||e.isExpanded!==t.isExpanded||e.isSelected!==t.isSelected||e.onToggle!==t.onToggle||e.onSelectProject!==t.onSelectProject||e.onNewThread!==t.onNewThread||e.onRenameProject!==t.onRenameProject||e.onDeleteProject!==t.onDeleteProject||e.onCloseProject!==t.onCloseProject||e.onReopenProject!==t.onReopenProject||e.onSelectThread!==t.onSelectThread||e.onRenameThread!==t.onRenameThread||e.onArchiveThread!==t.onArchiveThread||e.onPinThread!==t.onPinThread||e.onDeleteThread!==t.onDeleteThread||e.onShowAllThreads!==t.onShowAllThreads||e.onShowIssues!==t.onShowIssues)return!1;let n=e.project,r=t.project;return!(n.id!==r.id||n.name!==r.name||n.path!==r.path||n.color!==r.color||n.isTeamProject!==r.isTeamProject||n.organizationName!==r.organizationName||n.needsSetup!==r.needsSetup)}var on=(0,Q.memo)(function({project:e,threads:t,threadsLoaded:r,isExpanded:i,isSelected:a,onToggle:s,onSelectProject:c,onNewThread:l,onRenameProject:f,onDeleteProject:p,onCloseProject:_,onReopenProject:v,onSelectThread:y,onRenameThread:S,onArchiveThread:C,onPinThread:ne,onDeleteThread:re,onShowAllThreads:ae,onShowIssues:ce}){let w=Y(),{t:T}=D(),[E,k]=(0,Q.useState)(!1),[le,j]=(0,Q.useState)(!1),M=(0,Q.useMemo)(()=>new Map(t.map(e=>[e.id,_e(e)])),[t]),N=(0,Q.useMemo)(()=>{let{statusByBranch:e}=G.getState(),t={};for(let[n,r]of M)e[r]&&(t[n]=e[r]);return t},[M,G((0,Q.useCallback)(e=>{let t=``;for(let[n,r]of M){let i=e.statusByBranch[r];i&&(t+=`${n}:${i.state}:${i.dirtyFileCount}:${i.unpushedCommitCount}:${i.unpulledCommitCount}:${i.linesAdded}:${i.linesDeleted},`)}return t},[M]))]),de=(0,Q.useMemo)(()=>t.map(e=>e.id),[t]),P=X(),L=(0,Q.useMemo)(()=>P&&de.includes(P)?P:null,[P,de]),fe=a&&!L,z=(0,Q.useMemo)(()=>t.toSorted((e,t)=>e.pinned&&!t.pinned?-1:!e.pinned&&t.pinned?1:new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime()).slice(0,5),[t]);(0,Q.useEffect)(()=>{G.getState().ensureStatusForThreads(z)},[z]);let pe=(0,Q.useRef)(null),[me,he]=(0,Q.useState)(!1),[ge,ve]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{let t=pe.current;if(!t)return;let n=tt({element:t,getInitialData:()=>({type:`sidebar-project`,projectId:e.id}),onDragStart:()=>he(!0),onDrop:()=>he(!1)}),r=$e({element:t,getData:()=>({type:`sidebar-project`,projectId:e.id}),canDrop:({source:t})=>t.data.type===`sidebar-project`&&t.data.projectId!==e.id,onDragEnter:()=>ve(!0),onDragLeave:()=>ve(!1),onDrop:()=>ve(!1)});return()=>{n(),r()}},[e.id]),(0,$.jsxs)(K,{open:i,className:`min-w-0`,"data-project-id":e.id,children:[(0,$.jsxs)(`div`,{ref:pe,"data-testid":`project-item-${e.id}`,className:F(`group/project flex items-center rounded-md select-none`,fe?`bg-accent text-foreground`:`hover:bg-accent/50 text-muted-foreground hover:text-foreground`,me&&`opacity-50`,ge&&`ring-2 ring-ring`),onClick:()=>c(e.id),children:[(0,$.jsxs)(`div`,{className:F(`flex-1 flex items-center gap-0 px-2 py-1 text-xs text-left min-w-0`,me?`cursor-grabbing`:`cursor-pointer`),children:[(0,$.jsx)(J,{"data-testid":`project-toggle-${e.id}`,className:`hover:bg-accent/80 -ml-0.5 shrink-0 rounded p-0.5`,onClick:t=>{t.stopPropagation(),s(e.id)},children:(0,$.jsx)(x,{className:F(`icon-sm transition-transform duration-200`,i&&`rotate-90`)})}),(0,$.jsxs)(`span`,{"data-testid":`project-name-${e.id}`,className:`ml-1.5 flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,$.jsx)(b,{className:`icon-sm text-muted-foreground shrink-0`}),(0,$.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.name}),e.needsSetup&&(0,$.jsxs)(A,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(`button`,{"data-testid":`project-needs-setup-${e.id}`,className:`shrink-0`,onClick:e=>{e.stopPropagation(),j(!0)},children:(0,$.jsx)(se,{className:`icon-sm text-status-warning`})})}),(0,$.jsx)(O,{side:`right`,children:`Local directory not configured`})]})]})]}),(0,$.jsx)(`div`,{className:`mr-2 flex items-center gap-0.5`,children:(0,$.jsx)(`div`,{className:F(`flex items-center gap-0.5`,E?`opacity-100`:`opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto`),children:(0,$.jsxs)(be,{open:E,onOpenChange:k,children:[(0,$.jsx)(Xe,{asChild:!0,children:(0,$.jsx)(B,{variant:`ghost`,size:`icon-xs`,tabIndex:-1,"data-testid":`project-more-actions-${e.id}`,onClick:e=>e.stopPropagation(),className:`text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(n,{className:`icon-sm`})})}),(0,$.jsxs)(we,{align:`start`,side:`bottom`,children:[(0,$.jsxs)(U,{"data-testid":`project-menu-open-directory`,onClick:async t=>{t.stopPropagation();let n=await ue.openDirectory({path:e.path});n.isErr()&&console.error(`Failed to open directory:`,n.error)},children:[(0,$.jsx)(h,{className:`icon-sm`}),T(`sidebar.openDirectory`)]}),(0,$.jsxs)(U,{"data-testid":`project-menu-open-terminal`,onClick:t=>{t.stopPropagation(),yt({projectId:e.id,cwd:e.path})},children:[(0,$.jsx)(oe,{className:`icon-sm`}),T(`sidebar.openTerminal`)]}),(0,$.jsx)($t,{testId:`project-menu-open-editor`,onPick:t=>Qe(e.path,t)}),(0,$.jsxs)(U,{"data-testid":`project-menu-settings`,onClick:t=>{t.stopPropagation(),k(!1),w(W(`/projects/${e.id}/settings/general`))},children:[(0,$.jsx)(o,{className:`icon-sm`}),T(`sidebar.settings`)]}),(0,$.jsxs)(U,{"data-testid":`project-menu-analytics`,onClick:t=>{t.stopPropagation(),k(!1),w(W(`/projects/${e.id}/analytics`))},children:[(0,$.jsx)(g,{className:`icon-sm`}),T(`sidebar.analytics`)]}),(0,$.jsxs)(U,{"data-testid":`project-menu-view-designs`,onClick:t=>{t.stopPropagation(),k(!1),w(W(`/projects/${e.id}/designs`))},children:[(0,$.jsx)(ee,{className:`icon-sm`}),T(`sidebar.viewDesigns`)]}),(0,$.jsxs)(U,{"data-testid":`project-menu-create-automation`,onClick:t=>{t.stopPropagation(),k(!1),w(W(`/projects/${e.id}/settings/automations`),{state:{openCreateAutomation:!0}})},children:[(0,$.jsx)(ie,{className:`icon-sm`}),T(`sidebar.createAutomation`)]}),(0,$.jsx)(Ie,{}),(0,$.jsxs)(U,{"data-testid":`project-menu-rename`,onClick:t=>{t.stopPropagation(),k(!1),f(e.id,e.name)},children:[(0,$.jsx)(te,{className:`icon-sm`}),T(`sidebar.renameProject`)]}),v?(0,$.jsxs)(U,{"data-testid":`project-menu-reopen`,onClick:t=>{t.stopPropagation(),k(!1),v(e.id,e.name)},children:[(0,$.jsx)(d,{className:`icon-sm`}),T(`sidebar.reopenProject`)]}):_&&(0,$.jsxs)(U,{"data-testid":`project-menu-close`,onClick:t=>{t.stopPropagation(),k(!1),_(e.id,e.name)},children:[(0,$.jsx)(u,{className:`icon-sm`}),T(`sidebar.closeProject`)]}),(0,$.jsxs)(U,{"data-testid":`project-menu-delete`,onClick:t=>{t.stopPropagation(),k(!1),p(e.id,e.name)},className:`text-status-error focus:text-status-error`,children:[(0,$.jsx)(m,{className:`icon-sm`}),T(`sidebar.deleteProject`)]})]})]})})})]}),(0,$.jsx)(V,{className:`data-[state=open]:animate-slide-down`,children:(0,$.jsxs)(`div`,{className:`mt-0.5 min-w-0`,children:[t.length===0&&!r&&(0,$.jsx)(`div`,{"aria-hidden":!0,"data-testid":`project-threads-skeleton-${e.id}`,className:`flex flex-col gap-0.5 px-2 py-1`,children:Array.from({length:3}).map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 py-1`,children:[(0,$.jsx)(I,{className:`size-3.5 rounded-full`}),(0,$.jsx)(I,{className:`h-3`,style:{width:`${55+t*23%30}%`}})]},t))}),t.length===0&&r&&(0,$.jsx)(`p`,{className:`text-muted-foreground px-2 py-2 text-xs`,children:T(`sidebar.noThreads`)}),z.map(t=>(0,$.jsx)(rn,{thread:t,projectId:e.id,projectPath:e.path,projectName:e.name,projectColor:e.color,isSelected:L===t.id,gitStatus:N[t.id],onSelectThread:y,onRenameThread:S,onArchiveThread:C,onPinThread:ne,onDeleteThread:re},t.id)),t.length>5&&(0,$.jsx)(nn,{"data-testid":`project-view-all-${e.id}`,onClick:()=>ae(e.id)})]})}),(0,$.jsx)(tn,{project:e,open:le,onOpenChange:j})]})},an),sn=[];function cn({projects:e,projectsInitialized:t,selectedProjectId:n,expandedProjects:r,threadsByProject:i,scrollRef:a,topSentinelRef:o,...s}){let{t:c}=D(),l=Y(),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!0),[m,h]=(0,Q.useState)(!1),g=(0,Q.useRef)(null),{onCloseProject:_,onReopenProject:v,...y}=s,{activeProjects:b,closedProjects:S}=(0,Q.useMemo)(()=>{let t=[],n=[];for(let r of e)r.closed?n.push(r):t.push(r);return{activeProjects:t,closedProjects:n}},[e]);(0,Q.useEffect)(()=>{let e=a.current,t=o.current,n=g.current;if(!e||!t||!n)return;let r=new IntersectionObserver(r=>{for(let i of r)i.target===t?d(e.scrollTop>0):i.target===n&&p(i.isIntersecting)},{root:e,threshold:0});return r.observe(t),r.observe(n),()=>r.disconnect()},[a,o]);let ee=(0,Q.useRef)({}),te=(0,Q.useMemo)(()=>{let e=ee.current,t={};for(let n of b){let r=i[n.id],a=(Array.isArray(r)?r:[]).filter(e=>!e.archived),o=e[n.id];o&&o.length===a.length&&o.every((e,t)=>_t(e,a[t]))?t[n.id]=o:t[n.id]=a}return ee.current=t,t},[i,b]),C=(0,Q.useMemo)(()=>{let e={};for(let t of b)e[t.id]=Array.isArray(i[t.id]);return e},[i,b]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between px-4 pt-4 pb-2`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>l(W(`/list`)),"data-testid":`sidebar-projects-open-list`,className:`text-muted-foreground hover:text-foreground text-xs font-semibold tracking-wider uppercase transition-colors`,children:c(`sidebar.projects`)}),(0,$.jsxs)(A,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(B,{variant:`ghost`,"data-testid":`sidebar-add-project`,size:`icon`,className:`text-muted-foreground hover:text-foreground size-5`,onClick:()=>l(W(`/new`)),children:(0,$.jsx)(ae,{className:`icon-sm`})})}),(0,$.jsx)(O,{side:`right`,children:c(`sidebar.addProject`)})]})]}),(0,$.jsxs)(st,{ref:a,className:`relative px-2 contain-paint`,onScroll:e=>{let t=e.currentTarget;d(t.scrollTop>0),p(t.scrollHeight-t.scrollTop-t.clientHeight<1)},children:[(0,$.jsx)(`div`,{ref:o,"aria-hidden":!0,className:`h-px shrink-0`}),(0,$.jsx)(`div`,{className:F(`sticky top-0 left-0 right-0 h-8 -mt-px -mb-8 bg-linear-to-b from-sidebar to-transparent pointer-events-none z-10 shrink-0`,u?`opacity-100`:`opacity-0`)}),!t&&e.length===0&&(0,$.jsx)(`div`,{"aria-hidden":!0,"data-testid":`sidebar-projects-skeleton`,className:`flex flex-col gap-1.5`,children:Array.from({length:6}).map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1`,children:[(0,$.jsx)(I,{className:`size-3.5 rounded`}),(0,$.jsx)(I,{className:`size-3.5 rounded`}),(0,$.jsx)(I,{className:`h-3 flex-1`,style:{maxWidth:`${60+t*37%35}%`}})]},t))}),t&&b.length===0&&S.length===0&&(0,$.jsx)(`button`,{"data-testid":`sidebar-no-projects-cta`,onClick:()=>l(W(`/new`)),className:`text-muted-foreground hover:text-foreground w-full cursor-pointer px-2 py-2 text-left text-xs transition-colors`,children:c(`sidebar.noProjects`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:b.map(e=>(0,$.jsx)(on,{project:e,threads:te[e.id]??sn,threadsLoaded:C[e.id]??!1,isExpanded:r.has(e.id),isSelected:n===e.id,onCloseProject:_,...y},e.id))}),S.length>0&&(0,$.jsxs)(K,{open:m,onOpenChange:h,className:`mt-3`,"data-testid":`sidebar-closed-projects`,children:[(0,$.jsxs)(J,{"data-testid":`sidebar-closed-projects-toggle`,className:`text-muted-foreground hover:text-foreground flex w-full items-center gap-1 rounded px-2 py-1 text-xs font-semibold tracking-wider uppercase`,children:[(0,$.jsx)(x,{className:F(`icon-sm transition-transform duration-200`,m&&`rotate-90`)}),(0,$.jsxs)(`span`,{children:[c(`sidebar.closedProjects`),` (`,S.length,`)`]})]}),(0,$.jsx)(V,{className:`data-[state=open]:animate-slide-down`,children:(0,$.jsx)(`div`,{className:`mt-1 flex flex-col gap-1.5`,children:S.map(e=>(0,$.jsx)(on,{project:e,threads:sn,threadsLoaded:!1,isExpanded:!1,isSelected:n===e.id,onReopenProject:v,...y},e.id))})})]}),(0,$.jsx)(`div`,{className:F(`sticky bottom-0 left-0 right-0 h-8 -mt-8 bg-linear-to-t from-sidebar to-transparent pointer-events-none z-10 shrink-0 transition-opacity`,f?`opacity-0`:`opacity-100`)}),(0,$.jsx)(`div`,{ref:g,"aria-hidden":!0,className:`h-2 shrink-0`})]})]})}var ln=5;function un({onRenameThread:e,onDeleteThread:t}){let{t:n}=D(),r=Y(),i=De(),a=X(),o=q(e=>e.startNewScratchThread),[s,c]=(0,Q.useState)(!1),u=(0,Q.useMemo)(()=>i.slice(0,ln),[i]),d=(0,Q.useCallback)(()=>{o(),r(W(`/scratch/new`))},[o,r]),f=(0,Q.useCallback)(()=>{r(W(`/list?scratch=1`))},[r]);return(0,$.jsx)(`div`,{className:`shrink-0 px-2 pt-2 pb-2`,"data-testid":`sidebar-scratch-section`,children:(0,$.jsxs)(K,{open:s,onOpenChange:c,className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:F(`group/quickchats flex items-center rounded-md select-none`,`hover:bg-accent/50 text-muted-foreground hover:text-foreground`),children:[(0,$.jsxs)(J,{"data-testid":`sidebar-scratch-toggle`,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-0 px-2 py-1 text-left text-xs`,children:[(0,$.jsx)(`span`,{className:`-ml-0.5 shrink-0 rounded p-0.5`,children:(0,$.jsx)(x,{className:F(`icon-sm transition-transform duration-200`,s&&`rotate-90`)})}),(0,$.jsxs)(`span`,{className:`ml-1.5 flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,$.jsx)(p,{className:`icon-sm text-muted-foreground shrink-0`}),(0,$.jsx)(`span`,{className:`truncate text-sm font-medium`,children:n(`sidebar.scratchTitle`,{defaultValue:`Quick Chats`})})]})]}),(0,$.jsx)(`div`,{className:`mr-2 flex items-center gap-0.5`,children:(0,$.jsxs)(A,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(B,{variant:`ghost`,size:`icon-xs`,tabIndex:-1,"data-testid":`sidebar-scratch-new`,onClick:e=>{e.stopPropagation(),d()},className:`text-muted-foreground hover:text-foreground`,"aria-label":n(`sidebar.scratchNew`,{defaultValue:`New quick chat`}),children:(0,$.jsx)(l,{className:`icon-sm`})})}),(0,$.jsx)(O,{side:`right`,children:n(`sidebar.scratchNew`,{defaultValue:`New quick chat`})})]})})]}),(0,$.jsx)(V,{className:`data-[state=open]:animate-slide-down`,children:(0,$.jsxs)(`div`,{className:`mt-0.5 min-w-0`,children:[u.length===0&&(0,$.jsx)(`p`,{className:`text-muted-foreground px-2 py-2 text-xs`,children:n(`sidebar.noQuickChats`,{defaultValue:`No quick chats yet`})}),u.map(n=>(0,$.jsx)(dn,{thread:n,isSelected:a===n.id,onRenameThread:e,onDeleteThread:t},n.id)),i.length>ln&&(0,$.jsx)(nn,{"data-testid":`sidebar-scratch-view-all`,onClick:f})]})})]})})}function dn({thread:e,isSelected:t,onRenameThread:n,onDeleteThread:r}){let i=Y(),a=(0,Q.useCallback)(()=>{i(W(Se(e)))},[i,e]),o=(0,Q.useCallback)(t=>n(``,e.id,t),[n,e.id]),s=(0,Q.useCallback)(()=>r(e.id,``,e.title,!1),[r,e.id,e.title]);return(0,$.jsx)(bt,{thread:e,projectPath:``,isSelected:t,onSelect:a,href:W(Se(e)),onRename:o,onDelete:s})}function fn(){let{t:e}=D(),t=Oe(),n=X(),[r,i]=(0,Q.useState)(!0);return t.length===0?null:(0,$.jsx)(`div`,{className:`shrink-0 px-2 pt-2 pb-2`,"data-testid":`sidebar-shared-section`,children:(0,$.jsxs)(K,{open:r,onOpenChange:i,className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:F(`group/shared flex items-center rounded-md select-none`,`hover:bg-accent/50 text-muted-foreground hover:text-foreground`),children:(0,$.jsxs)(J,{"data-testid":`sidebar-shared-toggle`,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-0 px-2 py-1 text-left text-xs`,children:[(0,$.jsx)(`span`,{className:`-ml-0.5 shrink-0 rounded p-0.5`,children:(0,$.jsx)(x,{className:F(`icon-sm transition-transform duration-200`,r&&`rotate-90`)})}),(0,$.jsxs)(`span`,{className:`ml-1.5 flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,$.jsx)(_,{className:`icon-sm text-muted-foreground shrink-0`}),(0,$.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e(`sidebar.sharedTitle`,{defaultValue:`Shared with me`})})]})]})}),(0,$.jsx)(V,{className:`data-[state=open]:animate-slide-down`,children:(0,$.jsx)(`div`,{className:`mt-0.5 min-w-0`,children:t.map(e=>(0,$.jsx)(pn,{thread:e,isSelected:n===e.id},e.id))})})]})})}function pn({thread:e,isSelected:t}){let n=Y(),r=W(Se(e));return(0,$.jsx)(bt,{thread:e,projectPath:``,isSelected:t,onSelect:(0,Q.useCallback)(()=>{n(r)},[n,r]),href:r})}var mn=new Set([`running`,`waiting`,`pending`]),hn=new Set([`completed`,`failed`,`stopped`,`interrupted`]),gn=new Set([...mn,...hn]);function _n(e,t){return _t(e,t)&&e.projectName===t.projectName&&e.projectPath===t.projectPath&&e.projectColor===t.projectColor}function vn({onRenameThread:e,onArchiveThread:t,onDeleteThread:n}){let{t:r}=D();jt();let i=Y(),a=ye(),o=De(),s=X(),c=H(e=>e.projects),l=(0,Q.useRef)(new Map),{threads:u,totalCount:d}=(0,Q.useMemo)(()=>{let e=[],t=new Map(c.map(e=>[e.id,{name:e.name,path:e.path,color:e.color}])),n=(t,n,r,i)=>{if(!gn.has(t.status)||t.archived||t.stage===`done`)return;let a={...t,projectName:n,projectPath:r,projectColor:i},o=l.current.get(t.id);e.push(o&&_n(o,a)?o:a)};for(let[e,r]of Object.entries(a)){let i=t.get(e);for(let t of r)n(t,i?.name??e,i?.path??``,i?.color)}for(let e of o)n(e,r(`sidebar.scratchTitle`,{defaultValue:`Quick Chats`}),``);e.sort((e,t)=>{let n=e.status===`running`;if(n!==(t.status===`running`))return n?-1:1;let r=e.completedAt??e.createdAt,i=t.completedAt??t.createdAt;return new Date(i).getTime()-new Date(r).getTime()});let i=e.slice(0,5),s=new Map;for(let e of i)s.set(e.id,e);return l.current=s,{threads:i,totalCount:e.length}},[a,o,c,r]),f=(0,Q.useMemo)(()=>new Map(u.map(e=>[e.id,_e(e)])),[u]),p=(0,Q.useMemo)(()=>{let{statusByBranch:e}=G.getState(),t={};for(let[n,r]of f)e[r]&&(t[n]=e[r]);return t},[f,G((0,Q.useCallback)(e=>{let t=``;for(let[n,r]of f){let i=e.statusByBranch[r];i&&(t+=`${n}:${i.state}:${i.dirtyFileCount}:${i.unpushedCommitCount}:${i.unpulledCommitCount}:${i.linesAdded}:${i.linesDeleted},`)}return t},[f]))]);(0,Q.useEffect)(()=>{G.getState().ensureStatusForThreads(u)},[u]);let{ensureBranch:m,branchSwitchDialog:h}=Et(),g=(0,Q.useRef)(u);g.current=u;let _=(0,Q.useCallback)(async(e,t)=>{let n=g.current.find(t=>t.id===e),r=Me(n),a=Te.getState(),o=a.activeThread??(a.selectedThreadId?a.threadsById[a.selectedThreadId]:void 0);if(!r&&n&&L(n,o)){let r=z(n);if(Te.getState().prefetchThread(e),!await m(t,r))return}Ot(i,n??{id:e,projectId:t,isScratch:!1})},[i,m]),v=(0,Q.useCallback)((t,n)=>{e(t.id,t.projectId,n)},[e]),y=(0,Q.useCallback)(e=>{t(e.id,e.projectId,e.title,e.mode===`worktree`&&!!N(e)&&e.provider!==`external`)},[t]),b=(0,Q.useCallback)(e=>{n(e.id,e.projectId,e.title,e.mode===`worktree`&&!!N(e)&&e.provider!==`external`)},[n]);return u.length===0?(0,$.jsx)(`p`,{"data-testid":`activity-no-threads`,className:`text-muted-foreground px-2 py-2 text-xs`,children:r(`sidebar.noThreads`)}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[u.map(e=>(0,$.jsx)(yn,{thread:e,isSelected:s===e.id,isRunning:mn.has(e.status),gitStatus:p[e.id],onSelect:_,onRename:v,onArchive:y,onDelete:b},e.id)),d>5&&(0,$.jsx)(nn,{onClick:()=>i(W(`/list?sort=updated`))})]}),h]})}var yn=(0,Q.memo)(function({thread:e,isSelected:t,isRunning:n,gitStatus:r,onSelect:i,onRename:a,onArchive:o,onDelete:s}){let{t:c}=D(),l=(0,Q.useRef)(e);l.current=e;let u=(0,Q.useRef)(null),[d,f]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let t=u.current;if(t)return tt({element:t,getInitialData:()=>({type:`grid-thread`,threadId:e.id,projectId:e.projectId}),onGenerateDragPreview:({nativeSetDragImage:e})=>Mt({nativeSetDragImage:e,source:t}),onDragStart:()=>f(!0),onDrop:()=>f(!1)})},[e.id,e.projectId]);let p=(0,Q.useCallback)(()=>i(e.id,e.projectId),[i,e.id,e.projectId]),m=(0,Q.useCallback)(e=>a(l.current,e),[a,l]),h=(0,Q.useCallback)(()=>o(l.current),[o,l]),g=(0,Q.useCallback)(()=>s(l.current),[s,l]);return(0,$.jsx)(`div`,{ref:u,className:F(d&&`opacity-50`),children:(0,$.jsx)(bt,{thread:e,projectPath:e.projectPath,isSelected:t,subtitle:e.projectName,projectColor:e.projectColor,timeValue:n?void 0:Ke(e.completedAt??e.createdAt,c),gitStatus:r,href:Dt(e),onSelect:p,onRename:m,onArchive:n?void 0:h,onDelete:g})})});function bn({scrollRef:e,topSentinelRef:t,onRenameThread:n,onArchiveThread:r,onDeleteThread:i}){let{t:a}=D(),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!0);return(0,Q.useEffect)(()=>{if(!c)return;let n=e.current,r=t.current;if(!n||!r)return;let i=new IntersectionObserver(()=>{s(n.scrollTop>0)},{root:n,threshold:0});return i.observe(r),()=>i.disconnect()},[e,t,c]),(0,$.jsxs)(K,{open:c,onOpenChange:l,className:F(`flex shrink-0 flex-col contain-paint`,c&&`max-h-[40%] min-h-20`),children:[(0,$.jsxs)(J,{"data-testid":`sidebar-activity-toggle`,className:F(`group/activity mx-2 flex items-center gap-1 rounded-md px-2 pb-2 pt-3 text-left cursor-pointer select-none`,`text-muted-foreground hover:bg-accent/50 hover:text-foreground`),children:[(0,$.jsx)(x,{className:F(`icon-sm transition-transform duration-200`,c&&`rotate-90`)}),(0,$.jsx)(`h2`,{className:`text-xs font-semibold tracking-wider uppercase`,children:a(`sidebar.threadsTitle`)})]}),(0,$.jsx)(V,{className:`data-[state=open]:animate-slide-down flex min-h-0 flex-1 flex-col`,children:(0,$.jsxs)(Be,{viewportRef:e,viewportProps:{onScroll:e=>s(e.currentTarget.scrollTop>0)},className:`relative min-h-0 flex-1 px-2 pb-2`,children:[(0,$.jsx)(`div`,{ref:t,"aria-hidden":!0,className:`h-px shrink-0`}),(0,$.jsx)(`div`,{className:F(`sticky top-0 left-0 right-0 h-8 -mt-px -mb-8 bg-linear-to-b from-sidebar to-transparent pointer-events-none z-10`,o?`opacity-100`:`opacity-0`)}),(0,$.jsx)(vn,{onRenameThread:n,onArchiveThread:r,onDeleteThread:i})]})})]})}var xn=`__personal__`;function Sn(){let e=P(e=>e.isAuthenticated),t=P(e=>e.setActiveOrg),[n,i]=(0,Q.useState)([]),a=P(e=>e.activeOrgId),[o,s]=(0,Q.useState)(a),[c,l]=(0,Q.useState)(!0),u=H(e=>e.loadProjects),d=j();(0,Q.useEffect)(()=>{s(a)},[a]),(0,Q.useEffect)(()=>{if(!e){l(!1);return}let n=!1;return(async()=>{try{let e=await k.organization.list();if(!n&&e.data&&i(e.data.map(e=>({id:e.id,name:e.name,slug:e.slug}))),!n&&!P.getState().activeOrgId){let r=le((await k.getSession()).data);if(!n&&r){s(r);let n=e.data?.find(e=>e.id===r);t(r,n?.name??null,n?.slug??null)}}}catch(e){console.error(`[OrgSwitcher] Failed to load orgs:`,e)}finally{n||l(!1)}})(),()=>{n=!0}},[e,t]);let f=(0,Q.useCallback)(async()=>{Te.setState({threadsById:{},threadIdsByProject:{},scratchThreadIds:[],threadTotalByProject:{},scratchThreadTotal:0,selectedThreadId:null,activeThread:null}),await u()},[u]),p=(0,Q.useCallback)(async e=>{if(e===xn)try{await k.organization.setActive({organizationId:null}),s(null),P.getState().setActiveOrg(null,null,null),await f(),d(`/`)}catch(e){console.error(`[OrgSwitcher] Failed to switch to personal:`,e)}else try{await k.organization.setActive({organizationId:e}),s(e);let t=n.find(t=>t.id===e);P.getState().setActiveOrg(e,t?.name??null,t?.slug??null),await f(),t?.slug&&d(`/${t.slug}/`)}catch(e){console.error(`[OrgSwitcher] Failed to switch org:`,e)}},[n,f,d]);return c||n.length===0?null:(0,$.jsxs)(Je,{value:o??xn,onValueChange:p,children:[(0,$.jsx)(Ue,{"data-testid":`org-switcher-trigger`,size:`sm`,className:`w-full border-none bg-transparent shadow-none`,children:(0,$.jsx)(He,{})}),(0,$.jsxs)(Re,{children:[(0,$.jsx)(Ze,{value:xn,size:`sm`,"data-testid":`org-switcher-item-personal`,children:(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(C,{className:`icon-sm text-muted-foreground shrink-0`}),(0,$.jsx)(`span`,{children:`Personal`})]})}),n.map(e=>(0,$.jsx)(Ze,{value:e.id,size:`sm`,"data-testid":`org-switcher-item-${e.id}`,children:(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(r,{className:`icon-sm text-muted-foreground shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.name})]})},e.id))]})]})}function Cn(){let{t:e}=D(),n=Y(),{toggleSidebar:r}=ft();return(0,$.jsxs)(ot,{className:`group/header flex-row items-center justify-between px-2 py-2`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(Sn,{})}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity group-hover/header:opacity-100`,children:[(0,$.jsxs)(A,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(B,{variant:`ghost`,size:`icon-sm`,tabIndex:-1,"data-testid":`sidebar-search`,onClick:()=>n(W(`/list`)),className:`text-muted-foreground`,children:(0,$.jsx)(t,{className:`icon-base`})})}),(0,$.jsx)(O,{side:`bottom`,children:e(`sidebar.search`,`Search`)})]}),(0,$.jsxs)(A,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(B,{variant:`ghost`,size:`icon-sm`,tabIndex:-1,"data-testid":`sidebar-kanban`,onClick:()=>n(W(`/kanban`)),className:`text-muted-foreground`,children:(0,$.jsx)(ne,{className:`icon-base`})})}),(0,$.jsx)(O,{side:`bottom`,children:`Kanban`})]}),(0,$.jsxs)(A,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(B,{variant:`ghost`,size:`icon-sm`,tabIndex:-1,"data-testid":`sidebar-grid`,onClick:()=>n(W(`/grid`)),className:`text-muted-foreground`,children:(0,$.jsx)(a,{className:`icon-base`})})}),(0,$.jsx)(O,{side:`bottom`,children:`Grid`})]}),(0,$.jsxs)(A,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(B,{variant:`ghost`,size:`icon-sm`,tabIndex:-1,"data-testid":`sidebar-analytics`,onClick:()=>n(W(`/analytics`)),className:`text-muted-foreground`,children:(0,$.jsx)(g,{className:`icon-base`})})}),(0,$.jsx)(O,{side:`bottom`,children:e(`sidebar.analytics`)})]}),(0,$.jsxs)(A,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(B,{variant:`ghost`,size:`icon-sm`,tabIndex:-1,"data-testid":`sidebar-collapse`,onClick:r,className:`text-muted-foreground`,children:(0,$.jsx)(y,{className:`icon-base`})})}),(0,$.jsx)(O,{side:`bottom`,children:e(`sidebar.collapse`,`Collapse sidebar`)})]})]})]})}function wn({singleProjectId:e}={}){let{state:t}=ft();return t===`collapsed`?(0,$.jsx)(En,{}):(0,$.jsx)(Tn,{singleProjectId:e})}function Tn({singleProjectId:e}){let t=Y(),n=H(e=>e.projects),r=e?n.filter(t=>t.id===e):n,i=H(e=>e.initialized),a=H(e=>e.selectedProjectId),o=H(e=>e.expandedProjects),s=H(e=>e.toggleProject),c=H(e=>e.reorderProjects),l=ye(),u=q(e=>e.settingsOpen),d=q(e=>e.generalSettingsOpen),f=u||d,p=q(e=>e.startNewThread),m=q(e=>e.showGlobalSearch),{archiveConfirm:h,setArchiveConfirm:g,deleteThreadConfirm:_,setDeleteThreadConfirm:v,renameProjectState:y,setRenameProjectState:b,deleteProjectConfirm:x,setDeleteProjectConfirm:S,actionLoading:ee,issuesProjectId:te,setIssuesProjectId:C,handleArchiveConfirm:ne,handleDeleteThreadConfirm:re,handleRenameProjectConfirm:ie,handleDeleteProjectConfirm:ae,handleSelectThread:oe,handleArchiveThread:se,handleArchiveThreadFromList:ce,handleRenameThread:w,handlePinThread:T,handleDeleteThread:E,handleDeleteThreadFromList:D,handleRenameProject:O,handleDeleteProject:k,handleCloseProject:le,handleReopenProject:ue,handleShowIssues:A,branchSwitchDialog:j}=vt(),M=(0,Q.useRef)(null),N=(0,Q.useRef)(null),P=(0,Q.useRef)(null),I=(0,Q.useRef)(null);Pt({selectedProjectId:a,projectsScrollRef:M,settingsNavOpen:f}),Nt({projectsScrollRef:M,threadsScrollRef:N,projects:r,reorderProjects:c});let L=(0,Q.useCallback)(e=>{s(e)},[s]),R=(0,Q.useCallback)(e=>{(0,Q.startTransition)(()=>{H.getState().selectProject(e),q.getState().setReviewPaneOpen(!1),t(W(`/projects/${e}`))}),requestAnimationFrame(()=>{let t=M.current,n=t?.querySelector(`[data-project-id="${e}"]`);t&&n&&de(t,n,`nearest`),document.querySelector(`[data-testid="prompt-editor"]`)?.focus()})},[t]),fe=(0,Q.useCallback)(e=>{(0,Q.startTransition)(()=>{p(e),t(W(`/projects/${e}`))})},[p,t]),z=(0,Q.useCallback)(e=>{m(),t(W(`/list?project=${e}`))},[m,t]);return(0,$.jsxs)(dt,{collapsible:`none`,className:`h-full w-full select-none`,children:[u&&(0,$.jsx)(Ft,{}),d&&(0,$.jsx)(At,{}),(0,$.jsxs)(`div`,{className:F(f?`hidden`:`contents`),children:[(0,$.jsx)(Cn,{}),(0,$.jsx)(bn,{scrollRef:N,topSentinelRef:P,onRenameThread:w,onArchiveThread:ce,onDeleteThread:D}),(0,$.jsx)(cn,{projects:r,projectsInitialized:i,selectedProjectId:a,expandedProjects:o,threadsByProject:l,scrollRef:M,topSentinelRef:I,onToggle:L,onSelectProject:R,onNewThread:fe,onRenameProject:O,onDeleteProject:k,onCloseProject:le,onReopenProject:ue,onSelectThread:oe,onRenameThread:w,onArchiveThread:se,onPinThread:T,onDeleteThread:E,onShowAllThreads:z,onShowIssues:A}),(0,$.jsx)(un,{onRenameThread:w,onDeleteThread:D}),(0,$.jsx)(fn,{}),(0,$.jsx)(Qt,{})]}),(0,$.jsx)(gt,{archiveConfirm:h,setArchiveConfirm:g,handleArchiveConfirm:ne,deleteThreadConfirm:_,setDeleteThreadConfirm:v,handleDeleteThreadConfirm:re,renameProjectState:y,setRenameProjectState:b,handleRenameProjectConfirm:ie,deleteProjectConfirm:x,setDeleteProjectConfirm:S,handleDeleteProjectConfirm:ae,issuesProjectId:te,setIssuesProjectId:C,actionLoading:ee}),j]})}function En(){let{t:e}=D(),{toggleSidebar:t}=ft();return(0,$.jsx)(`div`,{className:`border-sidebar-border bg-sidebar flex h-full w-full flex-col items-center border-r py-2`,children:(0,$.jsxs)(A,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(B,{"data-testid":`sidebar-expand`,variant:`ghost`,size:`icon-sm`,onClick:t,className:`text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(v,{className:`icon-base`})})}),(0,$.jsx)(O,{side:`right`,children:e(`sidebar.show`,`Show sidebar`)})]})})}export{wn as AppSidebar};
|
|
1
|
+
import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{B as t,Bn as n,Cr as r,Ft as i,Kt as a,L as o,Lr as s,Mr as c,Q as l,Rn as u,W as d,Xt as f,_t as p,b as m,bn as h,br as g,d as _,dt as v,ft as y,hn as b,hr as x,i as S,k as ee,ot as te,p as C,qn as ne,qt as re,r as ie,vn as ae,w as oe,y as se,yn as ce,zn as w,zr as T}from"./icons-sqwAEN28.js";import{o as E}from"./markdown-DBtwZWLP.js";import{t as D}from"./useTranslation-DAPPK3Hy.js";import{G as O,M as k,N as le,P as ue,W as A,_t as j,d as M,dt as N,ft as de,k as P,lt as F,ot as I,pt as L,q as R,st as fe,ut as z}from"./index-BzzHdwZo.js";import{i as pe,t as B}from"./button-DL_y-bQm.js";import{$n as me,$r as he,An as ge,B as V,Bn as _e,Dn as ve,Dr as H,Ft as ye,Gn as be,Gr as xe,Ir as Se,Jn as U,Jr as Ce,Kn as we,Lt as Te,Mn as Ee,Mt as De,Nt as Oe,On as ke,Or as Ae,Qn as je,Rr as Me,Rt as W,Un as G,V as K,Xn as Ne,Xr as Pe,Yr as Fe,Zn as Ie,at as Le,ct as Re,er as ze,in as Be,jn as Ve,mt as He,pt as Ue,qr as We,r as Ge,rn as Ke,sr as qe,st as Je,t as Ye,tr as Xe,ut as Ze,xn as Qe,yr as q,z as J}from"./items-sHyHEl8t.js";import{n as $e,r as et,t as tt}from"./adapter-g71mvnZo.js";import{n as nt}from"./use-terminal-scope-CBl6Yy6Z.js";import{n as rt,t as it}from"./kbd-Kex_rsEZ.js";import{t as Y}from"./use-stable-navigate-Dub9C1RE.js";import{c as at,i as ot,n as st,o as ct,r as lt,s as ut,t as dt,u as ft}from"./sidebar-C4wtc5Cc.js";import{t as X}from"./use-active-thread-id-DziVmncf.js";import{t as pt}from"./tooltip-icon-button-BsKucPEz.js";import{t as mt}from"./FolderPicker-CrcjKOtR.js";import{a as ht,c as gt,i as _t,n as vt,o as yt,r as bt,t as xt}from"./element-JSHlqA80.js";import{i as St,n as Ct,r as Z}from"./ThreadStatusPin-A5CcOVmG.js";import{n as wt}from"./job-store-RXu4rpqJ.js";import{t as Tt}from"./watcher-store-DbYkaPlg.js";import{t as Et}from"./use-branch-switch-3Q6NlO39.js";import{n as Dt,t as Ot}from"./go-to-thread-Cvaa8Olw.js";import{n as kt}from"./automation-store-C7h4pWDb.js";import{n as At}from"./PreferencesPanel-BKPNAbb_.js";import{t as jt}from"./use-minute-tick-C-e4HaZD.js";import{t as Mt}from"./drag-preview-D7uMScNk.js";var Q=e(T(),1);function Nt({projectsScrollRef:e,threadsScrollRef:t,projects:n,reorderProjects:r}){(0,Q.useEffect)(()=>{let n=[];e.current&&n.push({el:e.current,type:`sidebar-project`}),t.current&&n.push({el:t.current,type:`grid-thread`});let r=e=>{let t=e.el.scrollHeight>e.el.clientHeight;t&&!e.cleanup?e.cleanup=xt({element:e.el,canScroll:({source:t})=>t.data.type===e.type}):!t&&e.cleanup&&(e.cleanup(),e.cleanup=void 0)},i=new ResizeObserver(()=>{for(let e of n)r(e)}),a=[];for(let e of n){r(e),i.observe(e.el);for(let t of Array.from(e.el.children))i.observe(t);let t=new MutationObserver(()=>{for(let t of Array.from(e.el.children))i.observe(t);r(e)});t.observe(e.el,{childList:!0,subtree:!0}),a.push(t)}return()=>{i.disconnect();for(let e of a)e.disconnect();for(let e of n)e.cleanup?.()}},[e,t]),(0,Q.useEffect)(()=>et({onDrop:({source:e,location:t})=>{let i=t.current.dropTargets;if(!i.length||e.data.type!==`sidebar-project`)return;let a=i[0].data;if(a.type!==`sidebar-project`)return;let o=e.data.projectId,s=a.projectId;if(o===s)return;let c=n.findIndex(e=>e.id===o),l=n.findIndex(e=>e.id===s);if(c===-1||l===-1)return;let u=[...n],[d]=u.splice(c,1);u.splice(l,0,d),r(u.map(e=>e.id))}}),[n,r])}function Pt({selectedProjectId:e,projectsScrollRef:t,settingsNavOpen:n}){let r=H(e=>e.revealNonce),i=H(e=>e.revealIntent),a=H(e=>e.toggleProject),o=X();(0,Q.useEffect)(()=>{e&&(H.getState().expandedProjects.has(e)||a(e))},[e,r,a]),(0,Q.useEffect)(()=>{if(n||!e)return;let r=!1,a=(n=!1)=>{if(r)return!0;let a=t.current;if(!a)return!1;let s=o?a.querySelector(`[data-project-id="${e}"] [data-testid="thread-item-${o}"]`):null;if(o&&!s&&!n)return!1;let c=s??a.querySelector(`[data-testid="project-item-${e}"]`)??a.querySelector(`[data-project-id="${e}"]`);return c?(de(a,c,i),r=!0,!0):!1},s=requestAnimationFrame(()=>{a(!1)}),c=window.setTimeout(()=>a(!0),300);return()=>{cancelAnimationFrame(s),window.clearTimeout(c)}},[e,o,r,i,n,t])}var $=e(E(),1);function Ft(){let e=j(),{t}=D(),n=q(e=>e.activeSettingsPage),r=q(e=>e.settingsReturnPath),i=q(e=>e.setSettingsReturnPath),a=H(e=>e.selectedProjectId),o=H(e=>e.selectedProjectId?e.projects.find(t=>t.id===e.selectedProjectId):void 0),s=P(e=>e.user),l=Ye({selectedProjectId:a,isProjectAdmin:o?.role===`owner`||o?.role===`admin`||o?.userId===s?.id}),u=e=>a?`/projects/${a}/settings/${e}`:`/settings/${e}`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ot,{className:`px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(pt,{onClick:()=>{let t=r??(a?`/projects/${a}`:`/`);i(null),e(W(t))},className:`text-muted-foreground hover:text-foreground`,"data-testid":`settings-back`,tooltip:t(`common.back`),children:(0,$.jsx)(c,{className:`icon-sm`})}),(0,$.jsx)(`h1`,{className:`text-sm font-medium`,children:t(`settings.title`)})]})}),(0,$.jsx)(st,{className:`px-2 pb-2`,children:(0,$.jsx)(ct,{children:l.map(r=>{let i=r.icon;return(0,$.jsx)(at,{children:(0,$.jsxs)(ut,{isActive:n===r.id,onClick:()=>e(W(u(r.id))),"data-testid":`settings-nav-${r.id}`,children:[(0,$.jsx)(i,{className:`icon-base`}),(0,$.jsx)(`span`,{children:t(Ge[r.id]??r.label)})]})},r.id)})})})]})}var It=pe(`flex w-full items-center gap-2 rounded-md transition-colors`,{variants:{size:{sm:`px-2 py-1 text-xs`,md:`px-2 py-1.5 text-sm`},isActive:{true:`bg-sidebar-accent font-medium text-sidebar-accent-foreground`,false:`text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground`}},defaultVariants:{size:`md`,isActive:!1}}),Lt={sm:fe.sm,md:fe.base},Rt=(0,Q.forwardRef)(function({icon:e,label:t,count:n,size:r=`md`,isActive:i=!1,className:a,...o},s){return(0,$.jsxs)(`button`,{ref:s,className:F(It({size:r,isActive:i}),a),...o,children:[(0,$.jsx)(e,{className:F(Lt[r],`shrink-0`)}),(0,$.jsx)(`span`,{className:`truncate`,children:t}),n!==void 0&&n>0&&(0,$.jsx)(Le,{variant:`secondary`,size:`xs`,className:`ml-auto shrink-0`,children:n})]})}),zt=6e4,Bt=3e5;function Vt(){let e=j(),t=kt(e=>e.inboxCount),n=kt(e=>e.loadInbox),r=q(e=>e.automationInboxOpen),i=P(e=>e.isAuthenticated),a=(0,Q.useRef)(n);return a.current=n,(0,Q.useEffect)(()=>{if(!i)return;let e=0,t,n=async()=>{try{await a.current(),e=0}catch{e++}let r=Math.min(zt*2**e,Bt);t=setTimeout(n,r)};return n(),()=>clearTimeout(t)},[i]),(0,$.jsx)(Rt,{icon:f,label:`Automation Inbox`,count:t,isActive:r,"data-testid":`sidebar-automation-inbox`,onClick:()=>{e(W(r?`/`:`/inbox`))}})}var Ht=[{keys:[`Ctrl`,`K`],labelKey:`shortcuts.commandPalette`},{keys:[`Ctrl`,`Shift`,`P`],labelKey:`shortcuts.commandPaletteAlt`},{keys:[`Ctrl`,`P`],labelKey:`shortcuts.fileSearch`},{keys:[`Ctrl`,`F`],labelKey:`shortcuts.searchInThread`},{keys:[`Ctrl`,`Shift`,`F`],labelKey:`shortcuts.textSearch`},{keys:[`Ctrl`,`Shift`,`L`],labelKey:`shortcuts.searchAcrossThreads`},{keys:[`Ctrl`,`B`],labelKey:`shortcuts.toggleSidebar`},{keys:[`Ctrl`,`,`],labelKey:`shortcuts.projectSettings`},{keys:[`Alt`,`N`],labelKey:`shortcuts.newThread`},{keys:[`Alt`,`S`],labelKey:`shortcuts.newScratchThread`},{keys:[`Alt`,`]`],labelKey:`shortcuts.nextThread`},{keys:[`Alt`,`[`],labelKey:`shortcuts.prevThread`},{keys:[`Alt`,`←`],labelKey:`shortcuts.backThread`},{keys:[`Alt`,`→`],labelKey:`shortcuts.forwardThread`},{keys:[`Alt`,`G`],labelKey:`shortcuts.toggleReview`},{keys:[`Alt`,`F`],labelKey:`shortcuts.toggleFiles`},{keys:[`Alt`,`H`],labelKey:`shortcuts.toggleShare`},{keys:[`Alt`,`M`],labelKey:`shortcuts.toggleComments`},{keys:[`Ctrl`,"`"],labelKey:`shortcuts.toggleTerminal`},{keys:[`?`],labelKey:`shortcuts.openShortcuts`}];function Ut(){let{t:e}=D();return(0,$.jsx)(xe,{open:q(e=>e.keyboardShortcutsOpen),onOpenChange:q(e=>e.setKeyboardShortcutsOpen),children:(0,$.jsxs)(We,{"data-testid":`keyboard-shortcuts-dialog`,children:[(0,$.jsxs)(Pe,{children:[(0,$.jsx)(he,{children:e(`shortcuts.title`)}),(0,$.jsx)(Ce,{children:e(`shortcuts.description`)})]}),(0,$.jsx)(`ul`,{className:`divide-border flex flex-col divide-y`,children:Ht.map(t=>(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-4 py-2 text-sm`,"data-testid":`shortcut-row-${t.labelKey}`,children:[(0,$.jsx)(`span`,{className:`text-foreground`,children:e(t.labelKey)}),(0,$.jsx)(rt,{children:t.keys.map((e,t)=>(0,$.jsxs)(Q.Fragment,{children:[t>0&&(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`+`}),(0,$.jsx)(it,{children:e})]},`${e}-${t}`))})]},t.labelKey))})]})})}var Wt=`h-4 shrink-0 rounded px-1 py-0 text-[9px] leading-none font-medium`;function Gt(e){switch(e.status){case`pending`:return`pending`;case`fired`:return`woke agent`;case`done`:return`concluded`;case`cancelled`:return`cancelled`;case`expired`:return e.wakeCount>=e.maxWakes?`hit wake limit`:`timed out`;default:return e.status}}function Kt(e){switch(e){case`pending`:return`default`;case`fired`:return`secondary`;case`expired`:return`destructive`;default:return`outline`}}function qt({watcher:e,now:t}){let{t:n}=D(),r=Tt(e=>e.cancelWatcher),i=Ct.includes(e.status),a=e.status===`pending`,o=a?St(e.nextWakeAt,t):Ke(e.updatedAt,n),s=a?e.nextWakeAt:e.updatedAt,c=`${a?`fires`:`fired`} ${Z(s)}`,l=a?`Next wake ${Z(e.nextWakeAt)} · created ${Z(e.createdAt)}`:`Last update ${Z(e.updatedAt)} · created ${Z(e.createdAt)}`;return(0,$.jsxs)(A,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsxs)(`div`,{className:`hover:bg-accent flex items-start justify-between gap-2 rounded-md px-2 py-1.5`,"data-testid":`watcher-row-${e.id}`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.label}),(0,$.jsx)(Le,{variant:Kt(e.status),className:Wt,children:Gt(e)})]}),(0,$.jsxs)(`p`,{className:`text-muted-foreground truncate text-xs`,children:[o?`${o} · `:null,`checked `,e.wakeCount,`×`,e.maxWakes?` / ${e.maxWakes}`:``]}),(0,$.jsx)(`p`,{className:`text-muted-foreground/70 truncate text-xs`,children:c})]}),i?(0,$.jsx)(B,{variant:`ghost`,size:`icon-xs`,className:`text-muted-foreground size-6 shrink-0`,"data-testid":`watcher-cancel-${e.id}`,onClick:()=>void r(e.id),"aria-label":`Cancel watcher`,children:(0,$.jsx)(S,{className:`icon-sm`})}):null]})}),(0,$.jsx)(O,{children:l})]})}function Jt(e){switch(e.status){case`running`:return`running`;case`exited`:return`done`;case`failed`:return`failed (${e.exitCode??`?`})`;case`killed`:return`killed`;case`cancelled`:return`cancelled`;default:return e.status}}function Yt(e){switch(e){case`running`:return`default`;case`failed`:case`killed`:return`destructive`;default:return`outline`}}function Xt({job:e,scopeId:t,onOpened:n}){let{t:r}=D(),i=wt(e=>e.cancelJob),[a,o]=(0,Q.useState)(!1),s=e.status===`running`,c=()=>{let r=t??Ae(e.threadId)?.projectId??null;r&&(ht({job:e,projectId:r}),n())};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(A,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:c,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},className:`hover:bg-accent flex cursor-pointer items-start justify-between gap-2 rounded-md px-2 py-1.5`,"data-testid":`job-row-${e.id}`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.label||e.command}),(0,$.jsx)(Le,{variant:Yt(e.status),className:Wt,children:Jt(e)})]}),(0,$.jsxs)(`p`,{className:`text-muted-foreground truncate text-xs`,children:[`started `,Ke(e.startedAt,r),s?null:` · ended ${Ke(e.updatedAt,r)}`]}),(0,$.jsx)(`p`,{className:`text-muted-foreground/70 truncate font-mono text-xs`,children:e.command})]}),s?(0,$.jsx)(B,{variant:`ghost`,size:`icon-xs`,className:`text-muted-foreground size-6 shrink-0`,"data-testid":`job-cancel-${e.id}`,onClick:e=>{e.stopPropagation(),o(!0)},"aria-label":`Kill job`,title:`Kill this process`,children:(0,$.jsx)(S,{className:`icon-sm`})}):null]})}),(0,$.jsxs)(O,{children:[(0,$.jsx)(`div`,{children:`Started ${Z(e.startedAt)}${s?``:` · ended ${Z(e.updatedAt)}`}`}),(0,$.jsx)(`div`,{className:`text-muted-foreground`,children:`Open output in the terminal panel`})]})]}),(0,$.jsx)(qe,{open:a,onOpenChange:o,title:`Kill process?`,description:`This stops the running process: ${e.label||e.command}`,confirmLabel:`Kill`,cancelLabel:`Cancel`,variant:`destructive`,onCancel:()=>o(!1),onConfirm:()=>{o(!1),i(e.id)}})]})}function Zt(){let[e,t]=(0,Q.useState)(!1),[n,r]=(0,Q.useState)(()=>Date.now()),{scopeId:i}=nt(),a=Tt(e=>e.watchersById),o=Tt(e=>e.loadWatchers),c=wt(e=>e.jobsById),l=wt(e=>e.loadJobs),u=(0,Q.useMemo)(()=>{let e=e=>+!Ct.includes(e);return Object.values(a).sort((t,n)=>e(t.status)-e(n.status)||n.createdAt.localeCompare(t.createdAt))},[a]),d=(0,Q.useMemo)(()=>Object.values(c).sort((e,t)=>(e.status===`running`?0:1)-(t.status===`running`?0:1)||t.startedAt.localeCompare(e.startedAt)),[c]),f=(0,Q.useMemo)(()=>u.filter(e=>Ct.includes(e.status)).length+d.filter(e=>e.status===`running`).length,[u,d]);return(0,Q.useEffect)(()=>{o(),l()},[o,l]),(0,Q.useEffect)(()=>{if(!e)return;o(),l(),r(Date.now());let t=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(t)},[e,o,l]),(0,$.jsxs)(ge,{open:e,onOpenChange:t,children:[(0,$.jsx)(Ee,{asChild:!0,children:(0,$.jsx)(Rt,{icon:s,label:`Watchers`,count:f,isActive:e,"data-testid":`sidebar-watchers`})}),(0,$.jsx)(Ve,{side:`top`,align:`start`,className:`w-80 p-1`,"data-testid":`watcher-panel`,children:d.length===0&&u.length===0?(0,$.jsx)(`p`,{className:`text-muted-foreground px-2 py-4 text-center text-sm`,children:`No background activity yet.`}):(0,$.jsxs)(Be,{className:F(`max-h-96`,d.length+u.length>6&&`h-96`),children:[d.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`text-muted-foreground px-2 py-1.5 text-xs font-medium`,children:`Background jobs`}),(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:d.map(e=>(0,$.jsx)(Xt,{job:e,scopeId:i,onOpened:()=>t(!1)},e.id))})]}),u.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`text-muted-foreground px-2 py-1.5 text-xs font-medium`,children:`Watchers`}),(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:u.map(e=>(0,$.jsx)(qt,{watcher:e,now:n},e.id))})]})]})})]})}function Qt(){let{t:e}=D(),t=Y(),n=P(e=>e.user),r=P(e=>e.logout),a=q(e=>e.setKeyboardShortcutsOpen);return(0,$.jsxs)(lt,{className:`pb-4`,children:[(0,$.jsxs)(`div`,{className:`px-1`,children:[(0,$.jsx)(Vt,{}),(0,$.jsx)(Zt,{})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[n?(0,$.jsxs)(be,{children:[(0,$.jsx)(Xe,{asChild:!0,children:(0,$.jsxs)(B,{variant:`ghost`,"data-testid":`sidebar-user-menu`,className:`hover:bg-sidebar-accent h-auto min-w-0 flex-1 justify-start gap-2 px-1 py-1`,children:[(0,$.jsx)(ve,{size:`sm`,children:(0,$.jsx)(ke,{className:`text-xs`,name:n.displayName||void 0,children:n.displayName?.split(` `).map(e=>e[0]).join(``).slice(0,2).toUpperCase()||(0,$.jsx)(C,{className:`icon-sm`})})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 text-left`,children:[(0,$.jsx)(`p`,{className:`text-sidebar-foreground truncate text-sm font-medium`,children:n.displayName}),(0,$.jsxs)(`p`,{className:`text-muted-foreground truncate text-xs`,children:[`@`,n.username]})]})]})}),(0,$.jsxs)(we,{side:`top`,align:`start`,className:`w-48`,children:[(0,$.jsxs)(U,{"data-testid":`sidebar-user-shortcuts`,onClick:()=>a(!0),children:[(0,$.jsx)(re,{className:`icon-sm`}),e(`shortcuts.title`)]}),(0,$.jsx)(Ie,{}),(0,$.jsxs)(U,{"data-testid":`sidebar-logout`,onClick:r,children:[(0,$.jsx)(i,{className:`icon-sm`}),e(`auth.logout`)]})]})]}):null,(0,$.jsxs)(A,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(B,{variant:`ghost`,size:`icon-xs`,"data-testid":`sidebar-settings`,onClick:()=>t(W(`/preferences/general`)),className:F(`size-7 shrink-0 text-muted-foreground`,!n&&`ml-auto`),children:(0,$.jsx)(o,{className:`icon-base`})})}),(0,$.jsx)(O,{side:`top`,children:e(`settings.title`)})]})]}),(0,$.jsx)(Ut,{})]})}function $t({onPick:e,testId:t=`menu-open-editor`}){let{t:n}=D();return(0,$.jsxs)(je,{children:[(0,$.jsxs)(ze,{"data-testid":t,children:[(0,$.jsx)(w,{}),n(`thread.openInEditor`,`Open in Editor`)]}),(0,$.jsx)(Ne,{children:(0,$.jsx)(me,{children:Object.keys(M).map(n=>(0,$.jsx)(U,{"data-testid":`${t}-${n}`,onClick:t=>{t.stopPropagation(),e(n)},className:`cursor-pointer`,children:M[n]},n))})})]})}function en({projectId:e,projectName:t,open:n,onOpenChange:r}){let[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(``),u=H(e=>e.setProjectLocalPath);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(xe,{open:n&&!i,onOpenChange:r,children:(0,$.jsxs)(We,{"data-testid":`setup-project-dialog`,children:[(0,$.jsxs)(Pe,{children:[(0,$.jsxs)(he,{className:`flex items-center gap-2`,children:[(0,$.jsx)(se,{className:`icon-base text-status-warning`}),`Set up local directory`]}),(0,$.jsxs)(Ce,{children:[(0,$.jsx)(`strong`,{children:t}),` is a shared team project. To create threads, you need to select your local clone of this repository.`]})]}),c&&(0,$.jsx)(`p`,{className:`text-status-error text-sm`,"data-testid":`setup-project-error`,children:c}),(0,$.jsxs)(Fe,{children:[(0,$.jsx)(B,{variant:`outline`,onClick:()=>r(!1),"data-testid":`setup-project-cancel`,children:`Cancel`}),(0,$.jsxs)(B,{onClick:()=>a(!0),disabled:o,"data-testid":`setup-project-browse`,children:[(0,$.jsx)(ce,{className:`icon-sm mr-1.5`}),o?`Saving...`:`Browse...`]})]})]})}),i&&(0,$.jsx)(mt,{onSelect:async t=>{a(!1),s(!0),l(``);let n=await u(e,t);s(!1),n?r(!1):l(`Failed to set directory. Make sure the path is a valid git repository.`)},onClose:()=>a(!1)})]})}function tn({project:e,open:t,onOpenChange:n}){return e.needsSetup?(0,$.jsx)(en,{projectId:e.id,projectName:e.name,open:t,onOpenChange:n}):null}function nn({onClick:e,...t}){let{t:n}=D();return(0,$.jsx)(`button`,{onClick:e,className:`text-muted-foreground/60 hover:text-foreground py-1.5 pl-7 text-sm transition-colors`,...t,children:n(`sidebar.viewAll`)})}var rn=(0,Q.memo)(function({thread:e,projectId:t,projectPath:n,projectName:r,projectColor:i,isSelected:a,gitStatus:o,onSelectThread:s,onRenameThread:c,onArchiveThread:l,onPinThread:u,onDeleteThread:d}){let f=(0,Q.useRef)(null),[p,m]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let n=f.current;if(n)return tt({element:n,getInitialData:()=>({type:`grid-thread`,threadId:e.id,projectId:t}),onGenerateDragPreview:({nativeSetDragImage:e})=>Mt({nativeSetDragImage:e,source:n}),onDragStart:()=>m(!0),onDrop:()=>m(!1)})},[e.id,t]);let h=(0,Q.useCallback)(()=>s(t,e.id),[s,t,e.id]),g=(0,Q.useCallback)(n=>c(t,e.id,n),[c,t,e.id]),_=(0,Q.useCallback)(()=>l(t,e.id,e.title),[l,t,e.id,e.title]),v=(0,Q.useCallback)(()=>u(t,e.id,!e.pinned),[u,t,e.id,e.pinned]),y=(0,Q.useCallback)(()=>d(t,e.id,e.title),[d,t,e.id,e.title]),b=e.status===`running`||e.status===`setting_up`;return(0,$.jsx)(`div`,{ref:f,className:F(p&&`opacity-50`),children:(0,$.jsx)(bt,{thread:e,projectPath:n,projectColor:i,isSelected:a,onSelect:h,href:W(`/projects/${t}/threads/${e.id}`),onRename:g,onArchive:b?void 0:_,onPin:v,onDelete:b?void 0:y,gitStatus:o})})});function an(e,t){if(e.threads!==t.threads||e.threadsLoaded!==t.threadsLoaded||e.isExpanded!==t.isExpanded||e.isSelected!==t.isSelected||e.onToggle!==t.onToggle||e.onSelectProject!==t.onSelectProject||e.onNewThread!==t.onNewThread||e.onRenameProject!==t.onRenameProject||e.onDeleteProject!==t.onDeleteProject||e.onCloseProject!==t.onCloseProject||e.onReopenProject!==t.onReopenProject||e.onSelectThread!==t.onSelectThread||e.onRenameThread!==t.onRenameThread||e.onArchiveThread!==t.onArchiveThread||e.onPinThread!==t.onPinThread||e.onDeleteThread!==t.onDeleteThread||e.onShowAllThreads!==t.onShowAllThreads||e.onShowIssues!==t.onShowIssues)return!1;let n=e.project,r=t.project;return!(n.id!==r.id||n.name!==r.name||n.path!==r.path||n.color!==r.color||n.isTeamProject!==r.isTeamProject||n.organizationName!==r.organizationName||n.needsSetup!==r.needsSetup)}var on=(0,Q.memo)(function({project:e,threads:t,threadsLoaded:r,isExpanded:i,isSelected:a,onToggle:s,onSelectProject:c,onNewThread:l,onRenameProject:f,onDeleteProject:p,onCloseProject:_,onReopenProject:v,onSelectThread:y,onRenameThread:S,onArchiveThread:C,onPinThread:ne,onDeleteThread:re,onShowAllThreads:ae,onShowIssues:ce}){let w=Y(),{t:T}=D(),[E,k]=(0,Q.useState)(!1),[le,j]=(0,Q.useState)(!1),M=(0,Q.useMemo)(()=>new Map(t.map(e=>[e.id,_e(e)])),[t]),N=(0,Q.useMemo)(()=>{let{statusByBranch:e}=G.getState(),t={};for(let[n,r]of M)e[r]&&(t[n]=e[r]);return t},[M,G((0,Q.useCallback)(e=>{let t=``;for(let[n,r]of M){let i=e.statusByBranch[r];i&&(t+=`${n}:${i.state}:${i.dirtyFileCount}:${i.unpushedCommitCount}:${i.unpulledCommitCount}:${i.linesAdded}:${i.linesDeleted},`)}return t},[M]))]),de=(0,Q.useMemo)(()=>t.map(e=>e.id),[t]),P=X(),L=(0,Q.useMemo)(()=>P&&de.includes(P)?P:null,[P,de]),fe=a&&!L,z=(0,Q.useMemo)(()=>t.toSorted((e,t)=>e.pinned&&!t.pinned?-1:!e.pinned&&t.pinned?1:new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime()).slice(0,5),[t]);(0,Q.useEffect)(()=>{G.getState().ensureStatusForThreads(z)},[z]);let pe=(0,Q.useRef)(null),[me,he]=(0,Q.useState)(!1),[ge,ve]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{let t=pe.current;if(!t)return;let n=tt({element:t,getInitialData:()=>({type:`sidebar-project`,projectId:e.id}),onDragStart:()=>he(!0),onDrop:()=>he(!1)}),r=$e({element:t,getData:()=>({type:`sidebar-project`,projectId:e.id}),canDrop:({source:t})=>t.data.type===`sidebar-project`&&t.data.projectId!==e.id,onDragEnter:()=>ve(!0),onDragLeave:()=>ve(!1),onDrop:()=>ve(!1)});return()=>{n(),r()}},[e.id]),(0,$.jsxs)(K,{open:i,className:`min-w-0`,"data-project-id":e.id,children:[(0,$.jsxs)(`div`,{ref:pe,"data-testid":`project-item-${e.id}`,className:F(`group/project flex items-center rounded-md select-none`,fe?`bg-accent text-foreground`:`hover:bg-accent/50 text-muted-foreground hover:text-foreground`,me&&`opacity-50`,ge&&`ring-2 ring-ring`),onClick:()=>c(e.id),children:[(0,$.jsxs)(`div`,{className:F(`flex-1 flex items-center gap-0 px-2 py-1 text-xs text-left min-w-0`,me?`cursor-grabbing`:`cursor-pointer`),children:[(0,$.jsx)(J,{"data-testid":`project-toggle-${e.id}`,className:`hover:bg-accent/80 -ml-0.5 shrink-0 rounded p-0.5`,onClick:t=>{t.stopPropagation(),s(e.id)},children:(0,$.jsx)(x,{className:F(`icon-sm transition-transform duration-200`,i&&`rotate-90`)})}),(0,$.jsxs)(`span`,{"data-testid":`project-name-${e.id}`,className:`ml-1.5 flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,$.jsx)(b,{className:`icon-sm text-muted-foreground shrink-0`}),(0,$.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.name}),e.needsSetup&&(0,$.jsxs)(A,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(`button`,{"data-testid":`project-needs-setup-${e.id}`,className:`shrink-0`,onClick:e=>{e.stopPropagation(),j(!0)},children:(0,$.jsx)(se,{className:`icon-sm text-status-warning`})})}),(0,$.jsx)(O,{side:`right`,children:`Local directory not configured`})]})]})]}),(0,$.jsx)(`div`,{className:`mr-2 flex items-center gap-0.5`,children:(0,$.jsx)(`div`,{className:F(`flex items-center gap-0.5`,E?`opacity-100`:`opacity-0 pointer-events-none group-hover/project:opacity-100 group-hover/project:pointer-events-auto`),children:(0,$.jsxs)(be,{open:E,onOpenChange:k,children:[(0,$.jsx)(Xe,{asChild:!0,children:(0,$.jsx)(B,{variant:`ghost`,size:`icon-xs`,tabIndex:-1,"data-testid":`project-more-actions-${e.id}`,onClick:e=>e.stopPropagation(),className:`text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(n,{className:`icon-sm`})})}),(0,$.jsxs)(we,{align:`start`,side:`bottom`,children:[(0,$.jsxs)(U,{"data-testid":`project-menu-open-directory`,onClick:async t=>{t.stopPropagation();let n=await ue.openDirectory({path:e.path});n.isErr()&&console.error(`Failed to open directory:`,n.error)},children:[(0,$.jsx)(h,{className:`icon-sm`}),T(`sidebar.openDirectory`)]}),(0,$.jsxs)(U,{"data-testid":`project-menu-open-terminal`,onClick:t=>{t.stopPropagation(),yt({projectId:e.id,cwd:e.path})},children:[(0,$.jsx)(oe,{className:`icon-sm`}),T(`sidebar.openTerminal`)]}),(0,$.jsx)($t,{testId:`project-menu-open-editor`,onPick:t=>Qe(e.path,t)}),(0,$.jsxs)(U,{"data-testid":`project-menu-settings`,onClick:t=>{t.stopPropagation(),k(!1),w(W(`/projects/${e.id}/settings/general`))},children:[(0,$.jsx)(o,{className:`icon-sm`}),T(`sidebar.settings`)]}),(0,$.jsxs)(U,{"data-testid":`project-menu-analytics`,onClick:t=>{t.stopPropagation(),k(!1),w(W(`/projects/${e.id}/analytics`))},children:[(0,$.jsx)(g,{className:`icon-sm`}),T(`sidebar.analytics`)]}),(0,$.jsxs)(U,{"data-testid":`project-menu-view-designs`,onClick:t=>{t.stopPropagation(),k(!1),w(W(`/projects/${e.id}/designs`))},children:[(0,$.jsx)(ee,{className:`icon-sm`}),T(`sidebar.viewDesigns`)]}),(0,$.jsxs)(U,{"data-testid":`project-menu-create-automation`,onClick:t=>{t.stopPropagation(),k(!1),w(W(`/projects/${e.id}/settings/automations`),{state:{openCreateAutomation:!0}})},children:[(0,$.jsx)(ie,{className:`icon-sm`}),T(`sidebar.createAutomation`)]}),(0,$.jsx)(Ie,{}),(0,$.jsxs)(U,{"data-testid":`project-menu-rename`,onClick:t=>{t.stopPropagation(),k(!1),f(e.id,e.name)},children:[(0,$.jsx)(te,{className:`icon-sm`}),T(`sidebar.renameProject`)]}),v?(0,$.jsxs)(U,{"data-testid":`project-menu-reopen`,onClick:t=>{t.stopPropagation(),k(!1),v(e.id,e.name)},children:[(0,$.jsx)(d,{className:`icon-sm`}),T(`sidebar.reopenProject`)]}):_&&(0,$.jsxs)(U,{"data-testid":`project-menu-close`,onClick:t=>{t.stopPropagation(),k(!1),_(e.id,e.name)},children:[(0,$.jsx)(u,{className:`icon-sm`}),T(`sidebar.closeProject`)]}),(0,$.jsxs)(U,{"data-testid":`project-menu-delete`,onClick:t=>{t.stopPropagation(),k(!1),p(e.id,e.name)},className:`text-status-error focus:text-status-error`,children:[(0,$.jsx)(m,{className:`icon-sm`}),T(`sidebar.deleteProject`)]})]})]})})})]}),(0,$.jsx)(V,{className:`data-[state=open]:animate-slide-down`,children:(0,$.jsxs)(`div`,{className:`mt-0.5 min-w-0`,children:[t.length===0&&!r&&(0,$.jsx)(`div`,{"aria-hidden":!0,"data-testid":`project-threads-skeleton-${e.id}`,className:`flex flex-col gap-0.5 px-2 py-1`,children:Array.from({length:3}).map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 py-1`,children:[(0,$.jsx)(I,{className:`size-3.5 rounded-full`}),(0,$.jsx)(I,{className:`h-3`,style:{width:`${55+t*23%30}%`}})]},t))}),t.length===0&&r&&(0,$.jsx)(`p`,{className:`text-muted-foreground px-2 py-2 text-xs`,children:T(`sidebar.noThreads`)}),z.map(t=>(0,$.jsx)(rn,{thread:t,projectId:e.id,projectPath:e.path,projectName:e.name,projectColor:e.color,isSelected:L===t.id,gitStatus:N[t.id],onSelectThread:y,onRenameThread:S,onArchiveThread:C,onPinThread:ne,onDeleteThread:re},t.id)),t.length>5&&(0,$.jsx)(nn,{"data-testid":`project-view-all-${e.id}`,onClick:()=>ae(e.id)})]})}),(0,$.jsx)(tn,{project:e,open:le,onOpenChange:j})]})},an),sn=[];function cn({projects:e,projectsInitialized:t,selectedProjectId:n,expandedProjects:r,threadsByProject:i,scrollRef:a,topSentinelRef:o,...s}){let{t:c}=D(),l=Y(),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!0),[m,h]=(0,Q.useState)(!1),g=(0,Q.useRef)(null),{onCloseProject:_,onReopenProject:v,...y}=s,{activeProjects:b,closedProjects:S}=(0,Q.useMemo)(()=>{let t=[],n=[];for(let r of e)r.closed?n.push(r):t.push(r);return{activeProjects:t,closedProjects:n}},[e]);(0,Q.useEffect)(()=>{let e=a.current,t=o.current,n=g.current;if(!e||!t||!n)return;let r=new IntersectionObserver(r=>{for(let i of r)i.target===t?d(e.scrollTop>0):i.target===n&&p(i.isIntersecting)},{root:e,threshold:0});return r.observe(t),r.observe(n),()=>r.disconnect()},[a,o]);let ee=(0,Q.useRef)({}),te=(0,Q.useMemo)(()=>{let e=ee.current,t={};for(let n of b){let r=i[n.id],a=(Array.isArray(r)?r:[]).filter(e=>!e.archived),o=e[n.id];o&&o.length===a.length&&o.every((e,t)=>_t(e,a[t]))?t[n.id]=o:t[n.id]=a}return ee.current=t,t},[i,b]),C=(0,Q.useMemo)(()=>{let e={};for(let t of b)e[t.id]=Array.isArray(i[t.id]);return e},[i,b]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between px-4 pt-4 pb-2`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>l(W(`/list`)),"data-testid":`sidebar-projects-open-list`,className:`text-muted-foreground hover:text-foreground text-xs font-semibold tracking-wider uppercase transition-colors`,children:c(`sidebar.projects`)}),(0,$.jsxs)(A,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(B,{variant:`ghost`,"data-testid":`sidebar-add-project`,size:`icon`,className:`text-muted-foreground hover:text-foreground size-5`,onClick:()=>l(W(`/new`)),children:(0,$.jsx)(ae,{className:`icon-sm`})})}),(0,$.jsx)(O,{side:`right`,children:c(`sidebar.addProject`)})]})]}),(0,$.jsxs)(st,{ref:a,className:`relative px-2 contain-paint`,onScroll:e=>{let t=e.currentTarget;d(t.scrollTop>0),p(t.scrollHeight-t.scrollTop-t.clientHeight<1)},children:[(0,$.jsx)(`div`,{ref:o,"aria-hidden":!0,className:`h-px shrink-0`}),(0,$.jsx)(`div`,{className:F(`sticky top-0 left-0 right-0 h-8 -mt-px -mb-8 bg-linear-to-b from-sidebar to-transparent pointer-events-none z-10 shrink-0`,u?`opacity-100`:`opacity-0`)}),!t&&e.length===0&&(0,$.jsx)(`div`,{"aria-hidden":!0,"data-testid":`sidebar-projects-skeleton`,className:`flex flex-col gap-1.5`,children:Array.from({length:6}).map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1`,children:[(0,$.jsx)(I,{className:`size-3.5 rounded`}),(0,$.jsx)(I,{className:`size-3.5 rounded`}),(0,$.jsx)(I,{className:`h-3 flex-1`,style:{maxWidth:`${60+t*37%35}%`}})]},t))}),t&&b.length===0&&S.length===0&&(0,$.jsx)(`button`,{"data-testid":`sidebar-no-projects-cta`,onClick:()=>l(W(`/new`)),className:`text-muted-foreground hover:text-foreground w-full cursor-pointer px-2 py-2 text-left text-xs transition-colors`,children:c(`sidebar.noProjects`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:b.map(e=>(0,$.jsx)(on,{project:e,threads:te[e.id]??sn,threadsLoaded:C[e.id]??!1,isExpanded:r.has(e.id),isSelected:n===e.id,onCloseProject:_,...y},e.id))}),S.length>0&&(0,$.jsxs)(K,{open:m,onOpenChange:h,className:`mt-3`,"data-testid":`sidebar-closed-projects`,children:[(0,$.jsxs)(J,{"data-testid":`sidebar-closed-projects-toggle`,className:`text-muted-foreground hover:text-foreground flex w-full items-center gap-1 rounded px-2 py-1 text-xs font-semibold tracking-wider uppercase`,children:[(0,$.jsx)(x,{className:F(`icon-sm transition-transform duration-200`,m&&`rotate-90`)}),(0,$.jsxs)(`span`,{children:[c(`sidebar.closedProjects`),` (`,S.length,`)`]})]}),(0,$.jsx)(V,{className:`data-[state=open]:animate-slide-down`,children:(0,$.jsx)(`div`,{className:`mt-1 flex flex-col gap-1.5`,children:S.map(e=>(0,$.jsx)(on,{project:e,threads:sn,threadsLoaded:!1,isExpanded:!1,isSelected:n===e.id,onReopenProject:v,...y},e.id))})})]}),(0,$.jsx)(`div`,{className:F(`sticky bottom-0 left-0 right-0 h-8 -mt-8 bg-linear-to-t from-sidebar to-transparent pointer-events-none z-10 shrink-0 transition-opacity`,f?`opacity-0`:`opacity-100`)}),(0,$.jsx)(`div`,{ref:g,"aria-hidden":!0,className:`h-2 shrink-0`})]})]})}var ln=5;function un({onRenameThread:e,onDeleteThread:t}){let{t:n}=D(),r=Y(),i=De(),a=X(),o=q(e=>e.startNewScratchThread),[s,c]=(0,Q.useState)(!1),u=(0,Q.useMemo)(()=>i.slice(0,ln),[i]),d=(0,Q.useCallback)(()=>{o(),r(W(`/scratch/new`))},[o,r]),f=(0,Q.useCallback)(()=>{r(W(`/list?scratch=1`))},[r]);return(0,$.jsx)(`div`,{className:`shrink-0 px-2 pt-2 pb-2`,"data-testid":`sidebar-scratch-section`,children:(0,$.jsxs)(K,{open:s,onOpenChange:c,className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:F(`group/quickchats flex items-center rounded-md select-none`,`hover:bg-accent/50 text-muted-foreground hover:text-foreground`),children:[(0,$.jsxs)(J,{"data-testid":`sidebar-scratch-toggle`,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-0 px-2 py-1 text-left text-xs`,children:[(0,$.jsx)(`span`,{className:`-ml-0.5 shrink-0 rounded p-0.5`,children:(0,$.jsx)(x,{className:F(`icon-sm transition-transform duration-200`,s&&`rotate-90`)})}),(0,$.jsxs)(`span`,{className:`ml-1.5 flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,$.jsx)(p,{className:`icon-sm text-muted-foreground shrink-0`}),(0,$.jsx)(`span`,{className:`truncate text-sm font-medium`,children:n(`sidebar.scratchTitle`,{defaultValue:`Quick Chats`})})]})]}),(0,$.jsx)(`div`,{className:`mr-2 flex items-center gap-0.5`,children:(0,$.jsxs)(A,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(B,{variant:`ghost`,size:`icon-xs`,tabIndex:-1,"data-testid":`sidebar-scratch-new`,onClick:e=>{e.stopPropagation(),d()},className:`text-muted-foreground hover:text-foreground`,"aria-label":n(`sidebar.scratchNew`,{defaultValue:`New quick chat`}),children:(0,$.jsx)(l,{className:`icon-sm`})})}),(0,$.jsx)(O,{side:`right`,children:n(`sidebar.scratchNew`,{defaultValue:`New quick chat`})})]})})]}),(0,$.jsx)(V,{className:`data-[state=open]:animate-slide-down`,children:(0,$.jsxs)(`div`,{className:`mt-0.5 min-w-0`,children:[u.length===0&&(0,$.jsx)(`p`,{className:`text-muted-foreground px-2 py-2 text-xs`,children:n(`sidebar.noQuickChats`,{defaultValue:`No quick chats yet`})}),u.map(n=>(0,$.jsx)(dn,{thread:n,isSelected:a===n.id,onRenameThread:e,onDeleteThread:t},n.id)),i.length>ln&&(0,$.jsx)(nn,{"data-testid":`sidebar-scratch-view-all`,onClick:f})]})})]})})}function dn({thread:e,isSelected:t,onRenameThread:n,onDeleteThread:r}){let i=Y(),a=(0,Q.useCallback)(()=>{i(W(Se(e)))},[i,e]),o=(0,Q.useCallback)(t=>n(``,e.id,t),[n,e.id]),s=(0,Q.useCallback)(()=>r(e.id,``,e.title,!1),[r,e.id,e.title]);return(0,$.jsx)(bt,{thread:e,projectPath:``,isSelected:t,onSelect:a,href:W(Se(e)),onRename:o,onDelete:s})}function fn(){let{t:e}=D(),t=Oe(),n=X(),[r,i]=(0,Q.useState)(!0);return t.length===0?null:(0,$.jsx)(`div`,{className:`shrink-0 px-2 pt-2 pb-2`,"data-testid":`sidebar-shared-section`,children:(0,$.jsxs)(K,{open:r,onOpenChange:i,className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:F(`group/shared flex items-center rounded-md select-none`,`hover:bg-accent/50 text-muted-foreground hover:text-foreground`),children:(0,$.jsxs)(J,{"data-testid":`sidebar-shared-toggle`,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-0 px-2 py-1 text-left text-xs`,children:[(0,$.jsx)(`span`,{className:`-ml-0.5 shrink-0 rounded p-0.5`,children:(0,$.jsx)(x,{className:F(`icon-sm transition-transform duration-200`,r&&`rotate-90`)})}),(0,$.jsxs)(`span`,{className:`ml-1.5 flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,$.jsx)(_,{className:`icon-sm text-muted-foreground shrink-0`}),(0,$.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e(`sidebar.sharedTitle`,{defaultValue:`Shared with me`})})]})]})}),(0,$.jsx)(V,{className:`data-[state=open]:animate-slide-down`,children:(0,$.jsx)(`div`,{className:`mt-0.5 min-w-0`,children:t.map(e=>(0,$.jsx)(pn,{thread:e,isSelected:n===e.id},e.id))})})]})})}function pn({thread:e,isSelected:t}){let n=Y(),r=W(Se(e));return(0,$.jsx)(bt,{thread:e,projectPath:``,isSelected:t,onSelect:(0,Q.useCallback)(()=>{n(r)},[n,r]),href:r})}var mn=new Set([`running`,`waiting`,`pending`]),hn=new Set([`completed`,`failed`,`stopped`,`interrupted`]),gn=new Set([...mn,...hn]);function _n(e,t){return _t(e,t)&&e.projectName===t.projectName&&e.projectPath===t.projectPath&&e.projectColor===t.projectColor}function vn({onRenameThread:e,onArchiveThread:t,onDeleteThread:n}){let{t:r}=D();jt();let i=Y(),a=ye(),o=De(),s=X(),c=H(e=>e.projects),l=(0,Q.useRef)(new Map),{threads:u,totalCount:d}=(0,Q.useMemo)(()=>{let e=[],t=new Map(c.map(e=>[e.id,{name:e.name,path:e.path,color:e.color}])),n=(t,n,r,i)=>{if(!gn.has(t.status)||t.archived||t.stage===`done`)return;let a={...t,projectName:n,projectPath:r,projectColor:i},o=l.current.get(t.id);e.push(o&&_n(o,a)?o:a)};for(let[e,r]of Object.entries(a)){let i=t.get(e);for(let t of r)n(t,i?.name??e,i?.path??``,i?.color)}for(let e of o)n(e,r(`sidebar.scratchTitle`,{defaultValue:`Quick Chats`}),``);e.sort((e,t)=>{let n=e.status===`running`;if(n!==(t.status===`running`))return n?-1:1;let r=e.completedAt??e.createdAt,i=t.completedAt??t.createdAt;return new Date(i).getTime()-new Date(r).getTime()});let i=e.slice(0,5),s=new Map;for(let e of i)s.set(e.id,e);return l.current=s,{threads:i,totalCount:e.length}},[a,o,c,r]),f=(0,Q.useMemo)(()=>new Map(u.map(e=>[e.id,_e(e)])),[u]),p=(0,Q.useMemo)(()=>{let{statusByBranch:e}=G.getState(),t={};for(let[n,r]of f)e[r]&&(t[n]=e[r]);return t},[f,G((0,Q.useCallback)(e=>{let t=``;for(let[n,r]of f){let i=e.statusByBranch[r];i&&(t+=`${n}:${i.state}:${i.dirtyFileCount}:${i.unpushedCommitCount}:${i.unpulledCommitCount}:${i.linesAdded}:${i.linesDeleted},`)}return t},[f]))]);(0,Q.useEffect)(()=>{G.getState().ensureStatusForThreads(u)},[u]);let{ensureBranch:m,branchSwitchDialog:h}=Et(),g=(0,Q.useRef)(u);g.current=u;let _=(0,Q.useCallback)(async(e,t)=>{let n=g.current.find(t=>t.id===e),r=Me(n),a=Te.getState(),o=a.activeThread??(a.selectedThreadId?a.threadsById[a.selectedThreadId]:void 0);if(!r&&n&&L(n,o)){let r=z(n);if(Te.getState().prefetchThread(e),!await m(t,r))return}Ot(i,n??{id:e,projectId:t,isScratch:!1})},[i,m]),v=(0,Q.useCallback)((t,n)=>{e(t.id,t.projectId,n)},[e]),y=(0,Q.useCallback)(e=>{t(e.id,e.projectId,e.title,e.mode===`worktree`&&!!N(e)&&e.provider!==`external`)},[t]),b=(0,Q.useCallback)(e=>{n(e.id,e.projectId,e.title,e.mode===`worktree`&&!!N(e)&&e.provider!==`external`)},[n]);return u.length===0?(0,$.jsx)(`p`,{"data-testid":`activity-no-threads`,className:`text-muted-foreground px-2 py-2 text-xs`,children:r(`sidebar.noThreads`)}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[u.map(e=>(0,$.jsx)(yn,{thread:e,isSelected:s===e.id,isRunning:mn.has(e.status),gitStatus:p[e.id],onSelect:_,onRename:v,onArchive:y,onDelete:b},e.id)),d>5&&(0,$.jsx)(nn,{onClick:()=>i(W(`/list?sort=updated`))})]}),h]})}var yn=(0,Q.memo)(function({thread:e,isSelected:t,isRunning:n,gitStatus:r,onSelect:i,onRename:a,onArchive:o,onDelete:s}){let{t:c}=D(),l=(0,Q.useRef)(e);l.current=e;let u=(0,Q.useRef)(null),[d,f]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let t=u.current;if(t)return tt({element:t,getInitialData:()=>({type:`grid-thread`,threadId:e.id,projectId:e.projectId}),onGenerateDragPreview:({nativeSetDragImage:e})=>Mt({nativeSetDragImage:e,source:t}),onDragStart:()=>f(!0),onDrop:()=>f(!1)})},[e.id,e.projectId]);let p=(0,Q.useCallback)(()=>i(e.id,e.projectId),[i,e.id,e.projectId]),m=(0,Q.useCallback)(e=>a(l.current,e),[a,l]),h=(0,Q.useCallback)(()=>o(l.current),[o,l]),g=(0,Q.useCallback)(()=>s(l.current),[s,l]);return(0,$.jsx)(`div`,{ref:u,className:F(d&&`opacity-50`),children:(0,$.jsx)(bt,{thread:e,projectPath:e.projectPath,isSelected:t,subtitle:e.projectName,projectColor:e.projectColor,timeValue:n?void 0:Ke(e.completedAt??e.createdAt,c),gitStatus:r,href:Dt(e),onSelect:p,onRename:m,onArchive:n?void 0:h,onDelete:g})})});function bn({scrollRef:e,topSentinelRef:t,onRenameThread:n,onArchiveThread:r,onDeleteThread:i}){let{t:a}=D(),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!0);return(0,Q.useEffect)(()=>{if(!c)return;let n=e.current,r=t.current;if(!n||!r)return;let i=new IntersectionObserver(()=>{s(n.scrollTop>0)},{root:n,threshold:0});return i.observe(r),()=>i.disconnect()},[e,t,c]),(0,$.jsxs)(K,{open:c,onOpenChange:l,className:F(`flex shrink-0 flex-col contain-paint`,c&&`max-h-[40%] min-h-20`),children:[(0,$.jsxs)(J,{"data-testid":`sidebar-activity-toggle`,className:F(`group/activity mx-2 flex items-center gap-1 rounded-md px-2 pb-2 pt-3 text-left cursor-pointer select-none`,`text-muted-foreground hover:bg-accent/50 hover:text-foreground`),children:[(0,$.jsx)(x,{className:F(`icon-sm transition-transform duration-200`,c&&`rotate-90`)}),(0,$.jsx)(`h2`,{className:`text-xs font-semibold tracking-wider uppercase`,children:a(`sidebar.threadsTitle`)})]}),(0,$.jsx)(V,{className:`data-[state=open]:animate-slide-down flex min-h-0 flex-1 flex-col`,children:(0,$.jsxs)(Be,{viewportRef:e,viewportProps:{onScroll:e=>s(e.currentTarget.scrollTop>0)},className:`relative min-h-0 flex-1 px-2 pb-2`,children:[(0,$.jsx)(`div`,{ref:t,"aria-hidden":!0,className:`h-px shrink-0`}),(0,$.jsx)(`div`,{className:F(`sticky top-0 left-0 right-0 h-8 -mt-px -mb-8 bg-linear-to-b from-sidebar to-transparent pointer-events-none z-10`,o?`opacity-100`:`opacity-0`)}),(0,$.jsx)(vn,{onRenameThread:n,onArchiveThread:r,onDeleteThread:i})]})})]})}var xn=`__personal__`;function Sn(){let e=P(e=>e.isAuthenticated),t=P(e=>e.setActiveOrg),[n,i]=(0,Q.useState)([]),a=P(e=>e.activeOrgId),[o,s]=(0,Q.useState)(a),[c,l]=(0,Q.useState)(!0),u=H(e=>e.loadProjects),d=j();(0,Q.useEffect)(()=>{s(a)},[a]),(0,Q.useEffect)(()=>{if(!e){l(!1);return}let n=!1;return(async()=>{try{let e=await k.organization.list();if(!n&&e.data&&i(e.data.map(e=>({id:e.id,name:e.name,slug:e.slug}))),!n&&!P.getState().activeOrgId){let r=le((await k.getSession()).data);if(!n&&r){s(r);let n=e.data?.find(e=>e.id===r);t(r,n?.name??null,n?.slug??null)}}}catch(e){console.error(`[OrgSwitcher] Failed to load orgs:`,e)}finally{n||l(!1)}})(),()=>{n=!0}},[e,t]);let f=(0,Q.useCallback)(async()=>{Te.setState({threadsById:{},threadIdsByProject:{},scratchThreadIds:[],threadTotalByProject:{},scratchThreadTotal:0,selectedThreadId:null,activeThread:null}),await u()},[u]),p=(0,Q.useCallback)(async e=>{if(e===xn)try{await k.organization.setActive({organizationId:null}),s(null),P.getState().setActiveOrg(null,null,null),await f(),d(`/`)}catch(e){console.error(`[OrgSwitcher] Failed to switch to personal:`,e)}else try{await k.organization.setActive({organizationId:e}),s(e);let t=n.find(t=>t.id===e);P.getState().setActiveOrg(e,t?.name??null,t?.slug??null),await f(),t?.slug&&d(`/${t.slug}/`)}catch(e){console.error(`[OrgSwitcher] Failed to switch org:`,e)}},[n,f,d]);return c||n.length===0?null:(0,$.jsxs)(Je,{value:o??xn,onValueChange:p,children:[(0,$.jsx)(Ue,{"data-testid":`org-switcher-trigger`,size:`sm`,className:`w-full border-none bg-transparent shadow-none`,children:(0,$.jsx)(He,{})}),(0,$.jsxs)(Re,{children:[(0,$.jsx)(Ze,{value:xn,size:`sm`,"data-testid":`org-switcher-item-personal`,children:(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(C,{className:`icon-sm text-muted-foreground shrink-0`}),(0,$.jsx)(`span`,{children:`Personal`})]})}),n.map(e=>(0,$.jsx)(Ze,{value:e.id,size:`sm`,"data-testid":`org-switcher-item-${e.id}`,children:(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(r,{className:`icon-sm text-muted-foreground shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.name})]})},e.id))]})]})}function Cn(){let{t:e}=D(),n=Y(),{toggleSidebar:r}=ft();return(0,$.jsxs)(ot,{className:`group/header flex-row items-center justify-between px-2 py-2`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(Sn,{})}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity group-hover/header:opacity-100`,children:[(0,$.jsxs)(A,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(B,{variant:`ghost`,size:`icon-sm`,tabIndex:-1,"data-testid":`sidebar-search`,onClick:()=>n(W(`/list`)),className:`text-muted-foreground`,children:(0,$.jsx)(t,{className:`icon-base`})})}),(0,$.jsx)(O,{side:`bottom`,children:e(`sidebar.search`,`Search`)})]}),(0,$.jsxs)(A,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(B,{variant:`ghost`,size:`icon-sm`,tabIndex:-1,"data-testid":`sidebar-kanban`,onClick:()=>n(W(`/kanban`)),className:`text-muted-foreground`,children:(0,$.jsx)(ne,{className:`icon-base`})})}),(0,$.jsx)(O,{side:`bottom`,children:`Kanban`})]}),(0,$.jsxs)(A,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(B,{variant:`ghost`,size:`icon-sm`,tabIndex:-1,"data-testid":`sidebar-grid`,onClick:()=>n(W(`/grid`)),className:`text-muted-foreground`,children:(0,$.jsx)(a,{className:`icon-base`})})}),(0,$.jsx)(O,{side:`bottom`,children:`Grid`})]}),(0,$.jsxs)(A,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(B,{variant:`ghost`,size:`icon-sm`,tabIndex:-1,"data-testid":`sidebar-analytics`,onClick:()=>n(W(`/analytics`)),className:`text-muted-foreground`,children:(0,$.jsx)(g,{className:`icon-base`})})}),(0,$.jsx)(O,{side:`bottom`,children:e(`sidebar.analytics`)})]}),(0,$.jsxs)(A,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(B,{variant:`ghost`,size:`icon-sm`,tabIndex:-1,"data-testid":`sidebar-collapse`,onClick:r,className:`text-muted-foreground`,children:(0,$.jsx)(y,{className:`icon-base`})})}),(0,$.jsx)(O,{side:`bottom`,children:e(`sidebar.collapse`,`Collapse sidebar`)})]})]})]})}function wn({singleProjectId:e}={}){let{state:t}=ft();return t===`collapsed`?(0,$.jsx)(En,{}):(0,$.jsx)(Tn,{singleProjectId:e})}function Tn({singleProjectId:e}){let t=Y(),n=H(e=>e.projects),r=e?n.filter(t=>t.id===e):n,i=H(e=>e.initialized),a=H(e=>e.selectedProjectId),o=H(e=>e.expandedProjects),s=H(e=>e.toggleProject),c=H(e=>e.reorderProjects),l=ye(),u=q(e=>e.settingsOpen),d=q(e=>e.generalSettingsOpen),f=u||d,p=q(e=>e.startNewThread),m=q(e=>e.showGlobalSearch),{archiveConfirm:h,setArchiveConfirm:g,deleteThreadConfirm:_,setDeleteThreadConfirm:v,renameProjectState:y,setRenameProjectState:b,deleteProjectConfirm:x,setDeleteProjectConfirm:S,actionLoading:ee,issuesProjectId:te,setIssuesProjectId:C,handleArchiveConfirm:ne,handleDeleteThreadConfirm:re,handleRenameProjectConfirm:ie,handleDeleteProjectConfirm:ae,handleSelectThread:oe,handleArchiveThread:se,handleArchiveThreadFromList:ce,handleRenameThread:w,handlePinThread:T,handleDeleteThread:E,handleDeleteThreadFromList:D,handleRenameProject:O,handleDeleteProject:k,handleCloseProject:le,handleReopenProject:ue,handleShowIssues:A,branchSwitchDialog:j}=vt(),M=(0,Q.useRef)(null),N=(0,Q.useRef)(null),P=(0,Q.useRef)(null),I=(0,Q.useRef)(null);Pt({selectedProjectId:a,projectsScrollRef:M,settingsNavOpen:f}),Nt({projectsScrollRef:M,threadsScrollRef:N,projects:r,reorderProjects:c});let L=(0,Q.useCallback)(e=>{s(e)},[s]),R=(0,Q.useCallback)(e=>{(0,Q.startTransition)(()=>{H.getState().selectProject(e),q.getState().setReviewPaneOpen(!1),t(W(`/projects/${e}`))}),requestAnimationFrame(()=>{let t=M.current,n=t?.querySelector(`[data-project-id="${e}"]`);t&&n&&de(t,n,`nearest`),document.querySelector(`[data-testid="prompt-editor"]`)?.focus()})},[t]),fe=(0,Q.useCallback)(e=>{(0,Q.startTransition)(()=>{p(e),t(W(`/projects/${e}`))})},[p,t]),z=(0,Q.useCallback)(e=>{m(),t(W(`/list?project=${e}`))},[m,t]);return(0,$.jsxs)(dt,{collapsible:`none`,className:`h-full w-full select-none`,children:[u&&(0,$.jsx)(Ft,{}),d&&(0,$.jsx)(At,{}),(0,$.jsxs)(`div`,{className:F(f?`hidden`:`contents`),children:[(0,$.jsx)(Cn,{}),(0,$.jsx)(bn,{scrollRef:N,topSentinelRef:P,onRenameThread:w,onArchiveThread:ce,onDeleteThread:D}),(0,$.jsx)(cn,{projects:r,projectsInitialized:i,selectedProjectId:a,expandedProjects:o,threadsByProject:l,scrollRef:M,topSentinelRef:I,onToggle:L,onSelectProject:R,onNewThread:fe,onRenameProject:O,onDeleteProject:k,onCloseProject:le,onReopenProject:ue,onSelectThread:oe,onRenameThread:w,onArchiveThread:se,onPinThread:T,onDeleteThread:E,onShowAllThreads:z,onShowIssues:A}),(0,$.jsx)(un,{onRenameThread:w,onDeleteThread:D}),(0,$.jsx)(fn,{}),(0,$.jsx)(Qt,{})]}),(0,$.jsx)(gt,{archiveConfirm:h,setArchiveConfirm:g,handleArchiveConfirm:ne,deleteThreadConfirm:_,setDeleteThreadConfirm:v,handleDeleteThreadConfirm:re,renameProjectState:y,setRenameProjectState:b,handleRenameProjectConfirm:ie,deleteProjectConfirm:x,setDeleteProjectConfirm:S,handleDeleteProjectConfirm:ae,issuesProjectId:te,setIssuesProjectId:C,actionLoading:ee}),j]})}function En(){let{t:e}=D(),{toggleSidebar:t}=ft();return(0,$.jsx)(`div`,{className:`border-sidebar-border bg-sidebar flex h-full w-full flex-col items-center border-r py-2`,children:(0,$.jsxs)(A,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(B,{"data-testid":`sidebar-expand`,variant:`ghost`,size:`icon-sm`,onClick:t,className:`text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(v,{className:`icon-base`})})}),(0,$.jsx)(O,{side:`right`,children:e(`sidebar.show`,`Show sidebar`)})]})})}export{wn as AppSidebar};
|