claude-code-session-manager 0.144.0 → 0.146.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/assets/{AppSettings-Z68gQiVE.js → AppSettings-BXfkoKQq.js} +2 -2
  2. package/dist/assets/{History-C3E6y_7t.js → History-l7pBt_vO.js} +1 -1
  3. package/dist/assets/HomeClaudeConfig-DtFwZxTx.js +5 -0
  4. package/dist/assets/{Panel-CnfWs46Z.js → Panel-C5hihgUD.js} +1 -1
  5. package/dist/assets/{ProjectClaudeConfig-CP0Wsg-H.js → ProjectClaudeConfig-B3pODrM-.js} +1 -1
  6. package/dist/assets/{Scheduler-D8un7N3B.js → Scheduler-IU9wo8_u.js} +1 -1
  7. package/dist/assets/{SkillReferenceGraph-DRtZV1Al.js → SkillReferenceGraph-Bmen0OOC.js} +1 -1
  8. package/dist/assets/{Skills-Bg5O2Hyn.js → Skills-jYVxqJr2.js} +1 -1
  9. package/dist/assets/{TiptapBody-BdzoBmqu.js → TiptapBody-Dp2gtbb-.js} +1 -1
  10. package/dist/assets/{Toggle-Dt5K1OXt.js → Toggle-C_0yUCS5.js} +1 -1
  11. package/dist/assets/{VoiceButton-CTLyRgdF.js → VoiceButton-BRPzqDa-.js} +1 -1
  12. package/dist/assets/{historyTotals-B2_KWBga.js → historyTotals-pAv-MFnY.js} +1 -1
  13. package/dist/assets/{index-446b69rr.js → index-C6nhp7m_.js} +496 -496
  14. package/dist/index.html +1 -1
  15. package/dist-web/app.js +427 -427
  16. package/package.json +1 -1
  17. package/plugins/session-manager-dev/skills/develop/SKILL.md +11 -6
  18. package/plugins/session-manager-dev/skills/maintaining-md-network/SKILL.md +1 -1
  19. package/plugins/session-manager-dev/skills/maintaining-md-network/weekly-consolidation.md +8 -4
  20. package/plugins/session-manager-dev/skills/send-feedback/SKILL.md +13 -8
  21. package/scripts/scheduler-mcp-server.cjs +4 -3
  22. package/src/main/adminRouteRegistry.cjs +1 -1
  23. package/src/main/build-info.json +4 -4
  24. package/src/main/chatRunner.cjs +35 -5
  25. package/src/main/config.cjs +12 -0
  26. package/src/main/index.cjs +2 -2
  27. package/src/main/ipcSchemas.cjs +5 -0
  28. package/src/main/lib/claude/claudeJsonApproval.cjs +129 -0
  29. package/src/main/lib/claude/headlessMcpServers.cjs +1 -1
  30. package/src/main/lib/claude/personaToolScope.cjs +23 -8
  31. package/src/main/lib/demo-video-kit/resumableRun.cjs +36 -15
  32. package/src/main/lib/demo-video-kit/seedKit.cjs +2 -2
  33. package/src/main/lib/epic/epicOutsideRead.cjs +43 -8
  34. package/src/main/lib/epic/epicSpawnCwd.cjs +1 -0
  35. package/src/main/lib/epic/planReviewInput.cjs +5 -6
  36. package/src/main/lib/epic/scriptStartedBy.cjs +19 -4
  37. package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +219 -48
  38. package/src/main/lib/feedback-remote/localAdminHttp.cjs +5 -1
  39. package/src/main/lib/feedback-remote/serviceMcpSession.cjs +6 -3
  40. package/src/main/lib/feedback-remote/serviceMcpTools.cjs +23 -3
  41. package/src/main/lib/feedback-remote/servicePairings.cjs +48 -0
  42. package/src/main/lib/feedback-remote/serviceStdioBridge.cjs +11 -6
  43. package/src/main/lib/git/gitWorktree.cjs +17 -0
  44. package/src/main/lib/mcpToolCatalog.cjs +6 -3
  45. package/src/main/lib/opsOwnership.cjs +2 -0
  46. package/src/main/lib/prd/prdCreate.cjs +2 -1
  47. package/src/main/lib/prd/prdMcpReachWarnings.cjs +3 -1
  48. package/src/main/lib/prd/prdSandboxWarnings.cjs +1 -1
  49. package/src/main/lib/scheduler/planReleaseRoute.cjs +53 -5
  50. package/src/main/lib/scheduler/planReviewStore.cjs +24 -2
  51. package/src/main/lib/scheduler/rcaReport.cjs +1 -0
  52. package/src/main/lib/scheduler/reviewNotice.cjs +3 -1
  53. package/src/main/lib/scheduler/terminalRunOutcome.cjs +1 -0
  54. package/src/main/lib/tasks/memoryConsolidation.cjs +21 -12
  55. package/src/main/lib/tasks/weeklyConsolidationInputs.cjs +131 -11
  56. package/src/main/runVerify.cjs +107 -3
  57. package/src/main/scheduler/gitTreeGuard.cjs +6 -0
  58. package/src/main/scheduler/planReviewHold.cjs +11 -5
  59. package/src/main/scheduler/prdPaths.cjs +10 -1
  60. package/src/main/scheduler.cjs +230 -27
  61. package/src/main/templates/PRD_AUTHORING.md +2 -2
  62. package/src/main/webRemote.cjs +22 -0
  63. package/src/preload/api.d.ts +8 -0
  64. package/src/preload/apiSurface.json +11 -0
  65. package/src/preload/index.cjs +2 -0
  66. package/dist/assets/HomeClaudeConfig-Yd1vXzBn.js +0 -5
@@ -1,4 +1,4 @@
1
- import{a_ as De,ad as Oe,aM as oe,as as Le,b8 as Cs,ab as Ms,bu as Ue,bt as he,bx as Vt,aT as f,ag as zt,ap as be,av as re,bD as Ps,aD as t,d as Je,I as we,L as Ct,q as Ds,bc as Y,K as pe,v as As,X as Rs,f as Ts,Z as Is,b7 as Es,br as ct,bk as _s,b2 as Os,am as Mt,aK as Yt,bC as Pe,ar as ke,S as We,aR as Fe,b as ut,b6 as pt,ax as qe,W as Qt,z as Kt,p as Jt,r as Ls,n as ft,N as ht,O as Fs,h as le,i as V,at as Xt,bv as qs,aS as Bs,y as Hs,aV as Zt,bG as es,$ as Us,aY as Xe,aN as Pt,bl as Dt,m as Ce,G as At,b0 as Rt,l as Ws,ba as Gs,a6 as Vs,w as ts,Y as zs,bA as ss,ai as Ys,by as Tt,b5 as Qs}from"./index-446b69rr.js";import{f as Ks,a as Js,s as Xs,u as ns}from"./historyTotals-B2_KWBga.js";import"./monaco-editor-BsIlgG7c.js";function Zs(e){const s=new Map(e.map(i=>[i.slug,i])),n=new Map,a=new Set,l=[];function d(i){n.set(i,1),l.push(i);const r=s.get(i);for(const c of(r==null?void 0:r.dependsOn)??[]){if(!s.has(c))continue;const o=n.get(c);if(o===1){const p=l.indexOf(c);for(let u=p;u<l.length;u++)a.add(l[u])}else o===void 0&&d(c)}l.pop(),n.set(i,2)}for(const i of e)n.has(i.slug)||d(i.slug);return a}function en(e,s){return(e.dependsOn??[]).map(n=>{const a=s.get(n);return a?{slug:n,status:a.status,missing:!1,needsReview:a.status==="needs_review"}:{slug:n,status:null,missing:!0,needsReview:!1}})}function tn(e,s,n){const a=new Set(e.map(o=>o.slug)),l=new Set;for(const o of e)for(const p of o.dependsOn??[])a.has(p)&&l.add(p);const d=new Map,i=[];for(const o of e){const p=n.has(o.slug)?void 0:(o.dependsOn??[]).find(u=>a.has(u)&&!n.has(u));p?(d.has(p)||d.set(p,[]),d.get(p).push(o)):i.push(o)}const r=(o,p)=>o.slug.localeCompare(p.slug);i.sort(r);for(const o of d.values())o.sort(r);function c(o,p,u){const x=en(o,s),b=n.has(o.slug);u.add(o.slug);const h=b?[]:(d.get(o.slug)??[]).filter(g=>!u.has(g.slug)).map(g=>c(g,p+1,u));return u.delete(o.slug),{row:o,depth:p,children:h,blockers:x,blocked:x.some(g=>!g.missing&&g.status!=="completed"),hasNeedsReviewBlocker:x.some(g=>g.needsReview),hasMissingDep:x.some(g=>g.missing),cycle:b,parallelEligible:(o.dependsOn??[]).length===0&&!l.has(o.slug)}}return i.map(o=>c(o,0,new Set))}function as(e,s,n){const a=new Map((n??e).map(o=>[o.slug,o])),l=Zs(e),d=[],i=new Map,r=new Map;for(const o of e){const p=De(o,s),u=p.epicId??"__none__";i.has(u)||(d.push(u),i.set(u,[]),r.set(u,{epicId:p.epicId,label:p.known&&p.label?p.label:p.epicId?`Epic ${p.epicId.slice(0,12)}…`:"No Epic",known:p.known})),i.get(u).push(o)}const c=d.map(o=>{const p=r.get(o),u=i.get(o),x=tn(u,a,l),b={};for(const h of u){const g=h.status??"unknown";b[g]=(b[g]??0)+1}return{epicId:p.epicId,label:p.label,known:p.known,nodes:x,counts:b,total:u.length}});return c.sort((o,p)=>o.epicId===null?1:p.epicId===null?-1:o.known!==p.known?o.known?-1:1:o.label.localeCompare(p.label)),c}function Ge(e){const s=[],n=a=>{s.push(a);for(const l of a.children)n(l)};for(const a of e)n(a);return s}const sn=15e4,rt=e=>e==="completed"||e==="skipped",Me=e=>e==="running"||e==="investigating",nn=e=>e==="failed"||e==="needs_review"||e==="quarantined",an=e=>e==="failed"||e==="needs_review"||e==="quarantined",me=e=>(e==null?void 0:e.cancelled)===!0,rn=e=>rt(e.status)||me(e);function rs(e){if(e<=5e3)return"~now";if(e<6e4)return`~${Math.round(e/1e3)}s`;const s=Math.round(e/6e4);return s<60?`~${s}m`:`~${Math.floor(s/60)}h${String(s%60).padStart(2,"0")}m`}function is(e,s){const n=e.estimateMinutes?e.estimateMinutes*6e4:null;return n?`${Math.min(99,Math.floor(s/n*100))}%`:Le(s)}function ln(e){let s=0,n=0;for(const a of e)if(a.status==="completed"&&a.startedAt&&a.finishedAt){const l=Date.parse(a.finishedAt)-Date.parse(a.startedAt);l>0&&(s+=l,n++)}return n===0?sn:s/n}function Be(e){const s=oe(e);return s===null?1/0:Number(s)}function it(e,s){const n=Be(e.slug)-Be(s.slug);return n!==0&&!Number.isNaN(n)?n:e.slug.localeCompare(s.slug)}function on(e){let s=0;for(const n of e.statusHistory??[])n.to==="pending"&&n.from!==null&&s++;return s}function dn(e){return e.some(n=>Me(n.status))?"active":e.every(rn)?"done":e.filter(n=>n.status!=="quarantined").length===0?"draft":"queued"}function cn(e,s,n,a){switch(e){case"done":return`${s.doneCount}/${s.rows.length} done`;case"running":return`${s.runningCount} running · ${n}`;case"held":return`${s.heldCount} held`;case"blocked":return`${s.blockedCount+a} blocked`;default:return`${n} ready`}}function un(e,s){return e._firstNum!==s._firstNum?e._firstNum<s._firstNum?-1:1:e._firstSlug.localeCompare(s._firstSlug)}function pn(e,s){const n=new Map(e.map(d=>[d.row.slug,d.row.slug])),a=d=>{for(;n.get(d)!==d;)n.set(d,n.get(n.get(d))),d=n.get(d);return d};for(const d of e)for(const i of d.row.dependsOn??[])s.has(i)&&n.set(a(d.row.slug),a(i));const l=new Map;for(const d of e){const i=a(d.row.slug),r=l.get(i);r?r.push(d):l.set(i,[d])}return[...l.values()]}function fn(e,s){if(e.length>0&&e.every(n=>!!n.row.planId)){const n=new Map;for(const a of e){const l=n.get(a.row.planId);l?l.push(a):n.set(a.row.planId,[a])}return[...n.values()]}return pn(e,s)}function hn(e,s,n,a){const l=[],d=[e];for(a.add(e.row.slug);d.length>0;){const i=d.pop();l.push(i);for(const r of i.row.dependsOn??[])if(n.has(r)&&!a.has(r)){a.add(r);const c=s.get(r);c&&d.push(c)}}return l}function xn(e,s){const n=new Map(e.map(r=>[r.row.slug,r])),a=new Set,l=[],d=e.filter(r=>Ms(r.row.slug).startsWith("validate-")).sort((r,c)=>it({slug:r.row.slug},{slug:c.row.slug}));for(const r of d)a.has(r.row.slug)||l.push({nodes:hn(r,n,s,a),validateSlug:r.row.slug});const i=e.filter(r=>!a.has(r.row.slug));if(i.length>0){const r=new Set(i.map(c=>c.row.slug));for(const c of fn(i,r))l.push({nodes:c,validateSlug:null})}return l}function gn(e){return e.replace(/^validate[\s:-]*/i,"").trim()}function xt(e,s){if(e.length===0)return[];const n=Oe(e),a=s.now??Date.now(),l=s.avgDurationMs??ln(n),d=Math.max(1,s.concurrency??1),i=new Map(n.map(u=>[u.slug,u])),r=u=>u.status==="pending"&&(u.dependsOn??[]).every(x=>i.get(x)===void 0||i.get(x).status==="completed"),c=new Map;n.filter(r).sort(it).forEach((u,x)=>c.set(u.slug,x));const o=as(n,s.sessions,n),p=[];for(const u of o){const x=Ge(u.nodes),b=new Set(x.map($=>$.row.slug)),h=new Map(x.map($=>[$.row.slug,$])),g=[];for(const $ of xn(x,b)){const P=$.nodes,J=new Set(P.map(N=>N.row.slug)),S=new Map,E=new Set,T=N=>{const k=h.get(N);return(k.row.dependsOn??[]).filter(H=>J.has(H)&&!(k.cycle&&h.get(H).cycle))},L=N=>{const k=S.get(N);if(k!==void 0)return k;if(E.has(N))return 0;E.add(N);let H=0;for(const Q of T(N))H=Math.max(H,L(Q));return E.delete(N),S.set(N,H+1),H+1};for(const N of P)L(N.row.slug);const y=P.map(N=>{const k=N.row,H=(k.dependsOn??[]).filter(Q=>b.has(Q));return{slug:k.slug,title:k.title,status:k.status,stage:S.get(k.slug),prdNumber:oe(k.slug),rowKind:"dep",rowTrailing:"",cycle:N.cycle,estimateMinutes:k.estimateMinutes??null,deps:H,crossEpicDeps:(k.dependsOn??[]).filter(Q=>!b.has(Q)),blockers:N.blockers,...me(k)?{cancelled:!0}:{},job:k}});y.sort(it);const M=y.reduce((N,k)=>Math.max(N,k.stage),0),D=new Map;for(const N of y){const k=N.job,H=h.get(N.slug),Q=k.status;let K;if(rt(Q)){const m=k.startedAt&&k.finishedAt?Date.parse(k.finishedAt)-Date.parse(k.startedAt):NaN;K={kind:"done",trailing:m>0?Le(m):"",held:!1,blocked:!1}}else if(Me(Q)){const m=k.startedAt?Math.max(0,a-Date.parse(k.startedAt)):null;K={kind:"running",trailing:m===null?"":is(k,m),held:!1,blocked:!1}}else if(me(k))K={kind:"cancelled",trailing:"cancelled",held:!1,blocked:!1};else if(Q==="failed")K={kind:"failed",trailing:"failed",held:!1,blocked:!1};else if(Q==="needs_review")K={kind:"review",trailing:"review",held:!1,blocked:!1};else if(Q==="quarantined")K={kind:"quarantined",trailing:"quarantined",held:!1,blocked:!1};else{const m=H.blockers.filter(j=>!j.missing&&j.status!=="completed");if(m.length>0){const j=m.some(W=>an(W.status)&&!me(i.get(W.slug))),R=m[0].slug;K={kind:"dep",trailing:`←${oe(R)??R}`,held:!j,blocked:j}}else if(k.heldReason)K={kind:"gate",trailing:"gate",held:!0,blocked:!1};else{const j=on(k),R=c.get(k.slug)??0;K=j>0?{kind:"retry",trailing:`${j} ${j===1?"retry":"retries"}`,held:!1,blocked:!1}:{kind:"eta",trailing:rs(R*l/d),held:!1,blocked:!1}}}D.set(N.slug,K)}const F=[];for(let N=1;N<=M;N++){const k=y.filter(B=>B.stage===N),H=k.find(B=>{const ne=D.get(B.slug).kind;return B.status==="pending"&&(ne==="eta"||ne==="retry")});if(H){const B=D.get(H.slug);B.kind="next",B.trailing="next"}let Q=0,K=0,m=0,j=0,R=0,W=0,C=0;for(const B of k){const ne=D.get(B.slug);B.rowKind=ne.kind,B.rowTrailing=ne.trailing,me(B)?C++:rt(B.status)?Q++:Me(B.status)?K++:B.status==="pending"?(R++,ne.held&&m++,ne.blocked&&j++):nn(B.status)&&W++}const O=Q+C===k.length?"done":K>0?"running":j+W>0?"blocked":m>0?"held":"pending",G={n:N,rows:k,doneCount:Q,runningCount:K,heldCount:m,blockedCount:j};F.push({...G,state:O,summary:cn(O,G,R,W)})}let _=0;for(const N of y){const k=N.estimateMinutes?N.estimateMinutes*6e4:l;if(N.status==="pending")_+=k;else if(Me(N.status)){const H=N.job.startedAt?Math.max(0,a-Date.parse(N.job.startedAt)):0;_+=Math.max(0,k-H)}}const U=y.reduce((N,k)=>Math.min(N,Be(k.slug)),1/0),te=y.reduce((N,k)=>Math.max(N,Be(k.slug)),-1/0),X=u.known?Cs(u.label).title:u.label,A=$.validateSlug?y.find(N=>N.slug===$.validateSlug):void 0,q=A&&gn(A.title)||X;g.push({epicId:u.epicId,waveIndex:0,index:0,label:q,epicLabel:X,validateSlug:$.validateSlug,width:F.reduce((N,k)=>Math.max(N,k.rows.length),0),status:dn(y),prdCount:y.length,stageCount:M,doneCount:F.reduce((N,k)=>N+k.doneCount,0),runningCount:F.reduce((N,k)=>N+k.runningCount,0),heldCount:F.reduce((N,k)=>N+k.heldCount,0),blockedCount:F.reduce((N,k)=>N+k.blockedCount,0),etaMs:_/d,stages:F,_firstNum:U,_lastNum:te,_firstSlug:y[0].slug})}g.sort(un),g.forEach(($,P)=>{$.waveIndex=P+1});const v=g.filter($=>$.validateSlug===null);v.forEach(($,P)=>{v.length>1&&($.label=`${$.label} · plan ${P+1}/${v.length}`)});for(const $ of g)p.push($)}return p.sort((u,x)=>{if(u._lastNum!==x._lastNum)return u._lastNum>x._lastNum?-1:1;const b=(u.epicId??"").localeCompare(x.epicId??"");return b!==0?b:u.waveIndex-x.waveIndex}),p.map(({_firstNum:u,_lastNum:x,_firstSlug:b,...h},g)=>({...h,index:g+1}))}function mn(e,s=Date.now()){const n=Oe(e),a=new Map(n.map(h=>[h.slug,h])),l=new Date(s).toDateString();let d=0,i=0,r=0,c=0,o=0,p=0,u=0;for(const h of n)if(h.status==="pending")i++,(h.dependsOn??[]).every(v=>a.get(v)===void 0||a.get(v).status==="completed")&&d++;else if(Me(h.status))u++;else{if(me(h))continue;h.status==="failed"?r++:h.status==="needs_review"?c++:h.status==="quarantined"?o++:h.status==="completed"&&h.finishedAt&&new Date(Date.parse(h.finishedAt)).toDateString()===l&&p++}let x=null;const b=r+o;if(b>0){for(const h of xt(n,{sessions:{},now:s}))for(const g of h.stages)if(g.rows.some(v=>!me(v)&&(v.status==="failed"||v.status==="quarantined"))){(x===null||g.n<x)&&(x=g.n);break}}return{readyNow:d,totalQueued:i,heldByDeps:i-d,needsYou:b,needsYouStage:x,failedCount:r,needsReviewCount:c,doneToday:p,inFlight:u}}function bn(e){const s=new Map;for(const c of e.stages)for(const o of c.rows)s.set(o.slug,o);const n=c=>{var o;return((o=s.get(c))==null?void 0:o.cycle)===!0},a=new Map,l=new Set,d=(c,o)=>c.chain.length!==o.chain.length?c.chain.length>o.chain.length:c.est!==o.est?c.est>o.est:c.chain.join("\0")<o.chain.join("\0"),i=c=>{const o=a.get(c);if(o)return o;const p=s.get(c),u=p.estimateMinutes??0;if(l.has(c))return{chain:[c],est:u};l.add(c);let x=null;for(const h of p.deps){if(!s.has(h)||p.cycle&&n(h))continue;const g=i(h);(!x||d(g,x))&&(x=g)}l.delete(c);const b=x?{chain:[...x.chain,c],est:x.est+u}:{chain:[c],est:u};return a.set(c,b),b};let r=null;for(const c of s.keys()){const o=i(c);(!r||d(o,r))&&(r=o)}return r?r.chain:[]}const wn=15e3,vn=new Set(["failed","quarantined"]);function jn(e){for(let s=e.parentElement;s;s=s.parentElement){const n=getComputedStyle(s).overflowY;if(n==="auto"||n==="scroll")return s}return null}function It(){const s=Array.from(document.querySelectorAll("[data-job-row]")).find(a=>vn.has(a.dataset.jobStatus??""));if(!s)return;const n=jn(s);n&&Os(n,s,{block:"nearest",behavior:"smooth"})}function yn(e,s){var n;switch(e.kind){case"paused":return`paused: scheduler is paused (${e.reason??"manual"})`;case"launch-blocked":return`launch-blocked: ${e.agentType} jobs can't launch${(n=e.block)!=null&&n.kind?` (${e.block.kind})`:""}`;case"idle":return"idle: 0 pending";case"saturated":{const a=s!=null?`, oldest ${re(s)}`:"";return`saturated: ${e.totalSlots??"?"} slot(s) busy${a}`}case"blocked":{const a=e.blockedChains.length;return`blocked: ${e.pending} pending, ${e.dispatchable} dispatchable — ${a} chain${a===1?"":"s"} stuck behind a failed/skipped dependency`}case"stalled":return`stalled: no dispatch attempt in ${e.idleMs!=null?re(e.idleMs):"?"} with ${e.dispatchable} dispatchable`;case"running":default:return`running: ${e.runningCount} in flight, ${e.pending} pending`}}function Nn(e){const[s,n]=f.useState(null),a=ct(),l=_s(),d=a&&l;return f.useEffect(()=>{if(!d)return;let i=!0,r=!1,c=!1;const o=()=>{r||(r=!0,window.api.schedule.queueHealth(e).then(u=>{r=!1,c=!1,i&&n(u)},u=>{r=!1,!c&&(c=!0,Y.error(`Queue health refresh failed: ${u instanceof Error?u.message:String(u)}`))}))};o();const p=setInterval(o,wn);return()=>{i=!1,clearInterval(p)}},[e,d]),s}const kn={running:{dot:"bg-sage",text:"text-sage-dark"},paused:{dot:"bg-amber-500",text:"text-amber-600"},idle:{dot:"bg-fg-faint",text:"text-fg-faint"}};function Sn(e,s,n){return e==="paused"||e==="launch-blocked"?"paused":e==="running"||e==="saturated"?"running":e?"idle":s?"paused":n>0?"running":"idle"}const Ze="px-2.5 py-1.5 rounded border border-line text-[12.5px] font-medium text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-40 disabled:cursor-not-allowed whitespace-nowrap";function $n(e,s,n,a){var l;if(e==="agent"){const d=((l=a==null?void 0:a.cwd)==null?void 0:l.split("/").filter(Boolean).pop())||"another session",i=a!=null&&a.reason?` — "${a.reason}"`:"",r=s?new Date(s).getTime()-n:null,c=r==null?"":r>0?` — auto-resumes in ${re(r)}`:" — auto-resume pending";return`Paused by an agent in ${d}${i}${c}. Click Resume to restart now.`}if(e==="auth")return"Scheduler paused: Claude sign-in expired or invalid. Restart the app or re-run `claude login`, then Resume.";if(e==="rate_limit"){if(s){const d=new Date(s).getTime()-n;return d>0?`Paused for rate limit — resumes in ${re(d)}`:"Paused for rate limit — resume pending"}return"Paused for rate limit"}return e==="network"?"Paused: billing endpoint unreachable for 30+ min.":e==="manual"?"Scheduler paused manually — no new jobs start; running jobs continue. Click Resume to restart.":`Scheduler paused (${e})`}function Cn({now:e}){const s=Ue(p=>p.snapshot);if(!s)return null;const n=s.paused,a=Object.entries(s.launchBlocks??{}),l=Object.entries(s.launchMitigations??{}),d=(n==null?void 0:n.reason)==="auth"||(n==null?void 0:n.reason)==="network",i="flex items-start gap-3 border-b px-0 py-1.5 text-[12.5px]",r="bg-red-950/10 border-red-700/30 text-red-800",c="bg-amber-400/10 border-amber-600/30 text-amber-700",o="shrink-0 px-2 py-0.5 rounded border border-current/40 hover:bg-white/20 text-[12px] font-medium";return t.jsxs(t.Fragment,{children:[n&&t.jsxs("div",{"data-testid":"pause-banner",className:`${i} ${d?r:c}`,children:[t.jsx("span",{className:"flex-1 leading-snug",children:$n(n.reason,n.resumeAt,e,n.by)}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),className:o,children:"Resume"})]}),a.map(([p,u])=>t.jsxs("div",{"data-testid":"launch-block-banner",className:`${i} ${r}`,children:[t.jsxs("div",{className:"flex-1 leading-snug min-w-0",children:[t.jsxs("div",{className:"font-medium",children:["Launches for ",t.jsx("span",{className:"font-mono",children:p})," jobs are failing before any work starts",u.httpStatus?` (HTTP ${u.httpStatus}, ${u.kind})`:` (${u.kind})`,u.exhausted?" — held until the Claude CLI version changes or you press Retry now.":u.until?` — next automatic probe ${new Date(u.until).getTime()>e?`in ${re(new Date(u.until).getTime()-e)}`:"on the next tick"}.`:"."]}),t.jsx("div",{className:"opacity-80",children:u.hint}),t.jsxs("div",{className:"font-mono text-[11.5px] opacity-70 truncate",title:u.message,children:[u.attempts," failed probe",u.attempts===1?"":"s",u.claudeVersion?` · CLI ${u.claudeVersion}`:"",u.lastSlug?` · last: ${u.lastSlug}`:""," · ",u.message]})]}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),className:o,children:"Retry now"})]},`launch-block-${p}`)),l.map(([p,u])=>t.jsx("div",{"data-testid":"launch-mitigation-banner",className:`${i} ${c}`,children:t.jsxs("div",{className:"flex-1 leading-snug min-w-0",children:[t.jsxs("div",{className:"font-medium",children:[t.jsx("span",{className:"font-mono",children:p})," jobs are running in degraded mode"," ","(",t.jsx("span",{className:"font-mono",children:Object.entries(u.env).map(([x,b])=>`${x}=${b}`).join(" ")}),")",u.claudeVersion?` since CLI ${u.claudeVersion}`:"","."]}),t.jsx("div",{className:"opacity-80",children:u.hint})]})},`launch-mitigation-${p}`))]})}function Mn({scopeCwd:e,subView:s,onSubView:n,filterText:a,onFilterText:l,planMode:d,onPlanMode:i,planToolsRef:r}){const c=Ue(C=>C.snapshot),o=he(C=>C.sessions),p=Nn(e),u=Vt(),[x,b]=f.useState(()=>Date.now()),[h,g]=f.useState("—");f.useEffect(()=>{const C=setInterval(()=>b(Date.now()),3e4);return()=>clearInterval(C)},[]),f.useEffect(()=>{let C=!0;return Ks(30).then(O=>{if(!C||!O.ok||!O.data)return;const G=new Date,B=ze=>String(ze).padStart(2,"0"),ne=`${G.getFullYear()}-${B(G.getMonth()+1)}-${B(G.getDate())}`;g(Js(Xs(O.data,{day:ne})))}),()=>{C=!1}},[]);const v=f.useMemo(()=>((c==null?void 0:c.jobs)??[]).filter(C=>!e||C.cwd===e),[c,e]),$=f.useMemo(()=>mn(v,x),[v,x]),P=f.useMemo(()=>{const C=xt(v,{sessions:o,now:x}),O=G=>C.filter(B=>B.status===G).length;return{active:O("active"),queued:O("queued"),draft:O("draft")}},[v,o,x]),J=f.useMemo(()=>{const C=new Date(x).toDateString(),O=[];for(const G of v)if(G.status==="completed"&&G.startedAt&&G.finishedAt&&new Date(Date.parse(G.finishedAt)).toDateString()===C){const B=Date.parse(G.finishedAt)-Date.parse(G.startedAt);B>0&&O.push(B)}return O.length?Math.round(O.reduce((G,B)=>G+B,0)/O.length/6e4):null},[v,x]);if(!c)return null;const S=p&&!p.unknown?p.verdict??null:null,E=p&&!p.unknown?p.slots??null:null,T=c.paused,L=Sn((S==null?void 0:S.kind)??null,!!T,$.inFlight),y=kn[L],M=v.filter(C=>C.status==="pending").length,D=v.filter(C=>C.status==="running").length,F=zt({snap:{...c,jobs:v},now:x,avgDurationMs:0,runningJobs:v.filter(C=>C.status==="running")}),_=p!=null&&p.unknown?`Queue health: unknown — ${p.reason??"state unavailable"}`:S?yn(S,(p==null?void 0:p.oldestRunningAgeMs)??null):"queue health loading…",U=be(c.lastRunAt?Date.parse(c.lastRunAt):null,x),te=p!=null&&p.lastDispatchAttemptAt?be(Date.parse(p.lastDispatchAttemptAt),x):"never",X=[_,F.line1,S?`dispatchable ${S.dispatchable} · needs_review ${S.needsReviewCount}`:null,(p==null?void 0:p.oldestRunningAgeMs)!=null?`oldest running ${re(p.oldestRunningAgeMs)} (any project)`:null,`last batch fired ${U} (lastRunAt — advances only when a job launches)`,`last dispatch attempt ${te} (advances on every driver evaluation)`].filter(Boolean).join(`
1
+ import{a_ as De,ad as Oe,aM as oe,as as Le,b8 as Cs,ab as Ms,bu as Ue,bt as he,bx as Vt,aT as f,ag as zt,ap as be,av as re,bD as Ps,aD as t,d as Je,I as we,L as Ct,q as Ds,bc as Y,K as pe,v as As,X as Rs,f as Ts,Z as Is,b7 as Es,br as ct,bk as _s,b2 as Os,am as Mt,aK as Yt,bC as Pe,ar as ke,S as We,aR as Fe,b as ut,b6 as pt,ax as qe,W as Qt,z as Kt,p as Jt,r as Ls,n as ft,N as ht,O as Fs,h as le,i as V,at as Xt,bv as qs,aS as Bs,y as Hs,aV as Zt,bG as es,$ as Us,aY as Xe,aN as Pt,bl as Dt,m as Ce,G as At,b0 as Rt,l as Ws,ba as Gs,a6 as Vs,w as ts,Y as zs,bA as ss,ai as Ys,by as Tt,b5 as Qs}from"./index-C6nhp7m_.js";import{f as Ks,a as Js,s as Xs,u as ns}from"./historyTotals-pAv-MFnY.js";import"./monaco-editor-BsIlgG7c.js";function Zs(e){const s=new Map(e.map(i=>[i.slug,i])),n=new Map,a=new Set,l=[];function d(i){n.set(i,1),l.push(i);const r=s.get(i);for(const c of(r==null?void 0:r.dependsOn)??[]){if(!s.has(c))continue;const o=n.get(c);if(o===1){const p=l.indexOf(c);for(let u=p;u<l.length;u++)a.add(l[u])}else o===void 0&&d(c)}l.pop(),n.set(i,2)}for(const i of e)n.has(i.slug)||d(i.slug);return a}function en(e,s){return(e.dependsOn??[]).map(n=>{const a=s.get(n);return a?{slug:n,status:a.status,missing:!1,needsReview:a.status==="needs_review"}:{slug:n,status:null,missing:!0,needsReview:!1}})}function tn(e,s,n){const a=new Set(e.map(o=>o.slug)),l=new Set;for(const o of e)for(const p of o.dependsOn??[])a.has(p)&&l.add(p);const d=new Map,i=[];for(const o of e){const p=n.has(o.slug)?void 0:(o.dependsOn??[]).find(u=>a.has(u)&&!n.has(u));p?(d.has(p)||d.set(p,[]),d.get(p).push(o)):i.push(o)}const r=(o,p)=>o.slug.localeCompare(p.slug);i.sort(r);for(const o of d.values())o.sort(r);function c(o,p,u){const x=en(o,s),b=n.has(o.slug);u.add(o.slug);const h=b?[]:(d.get(o.slug)??[]).filter(g=>!u.has(g.slug)).map(g=>c(g,p+1,u));return u.delete(o.slug),{row:o,depth:p,children:h,blockers:x,blocked:x.some(g=>!g.missing&&g.status!=="completed"),hasNeedsReviewBlocker:x.some(g=>g.needsReview),hasMissingDep:x.some(g=>g.missing),cycle:b,parallelEligible:(o.dependsOn??[]).length===0&&!l.has(o.slug)}}return i.map(o=>c(o,0,new Set))}function as(e,s,n){const a=new Map((n??e).map(o=>[o.slug,o])),l=Zs(e),d=[],i=new Map,r=new Map;for(const o of e){const p=De(o,s),u=p.epicId??"__none__";i.has(u)||(d.push(u),i.set(u,[]),r.set(u,{epicId:p.epicId,label:p.known&&p.label?p.label:p.epicId?`Epic ${p.epicId.slice(0,12)}…`:"No Epic",known:p.known})),i.get(u).push(o)}const c=d.map(o=>{const p=r.get(o),u=i.get(o),x=tn(u,a,l),b={};for(const h of u){const g=h.status??"unknown";b[g]=(b[g]??0)+1}return{epicId:p.epicId,label:p.label,known:p.known,nodes:x,counts:b,total:u.length}});return c.sort((o,p)=>o.epicId===null?1:p.epicId===null?-1:o.known!==p.known?o.known?-1:1:o.label.localeCompare(p.label)),c}function Ge(e){const s=[],n=a=>{s.push(a);for(const l of a.children)n(l)};for(const a of e)n(a);return s}const sn=15e4,rt=e=>e==="completed"||e==="skipped",Me=e=>e==="running"||e==="investigating",nn=e=>e==="failed"||e==="needs_review"||e==="quarantined",an=e=>e==="failed"||e==="needs_review"||e==="quarantined",me=e=>(e==null?void 0:e.cancelled)===!0,rn=e=>rt(e.status)||me(e);function rs(e){if(e<=5e3)return"~now";if(e<6e4)return`~${Math.round(e/1e3)}s`;const s=Math.round(e/6e4);return s<60?`~${s}m`:`~${Math.floor(s/60)}h${String(s%60).padStart(2,"0")}m`}function is(e,s){const n=e.estimateMinutes?e.estimateMinutes*6e4:null;return n?`${Math.min(99,Math.floor(s/n*100))}%`:Le(s)}function ln(e){let s=0,n=0;for(const a of e)if(a.status==="completed"&&a.startedAt&&a.finishedAt){const l=Date.parse(a.finishedAt)-Date.parse(a.startedAt);l>0&&(s+=l,n++)}return n===0?sn:s/n}function Be(e){const s=oe(e);return s===null?1/0:Number(s)}function it(e,s){const n=Be(e.slug)-Be(s.slug);return n!==0&&!Number.isNaN(n)?n:e.slug.localeCompare(s.slug)}function on(e){let s=0;for(const n of e.statusHistory??[])n.to==="pending"&&n.from!==null&&s++;return s}function dn(e){return e.some(n=>Me(n.status))?"active":e.every(rn)?"done":e.filter(n=>n.status!=="quarantined").length===0?"draft":"queued"}function cn(e,s,n,a){switch(e){case"done":return`${s.doneCount}/${s.rows.length} done`;case"running":return`${s.runningCount} running · ${n}`;case"held":return`${s.heldCount} held`;case"blocked":return`${s.blockedCount+a} blocked`;default:return`${n} ready`}}function un(e,s){return e._firstNum!==s._firstNum?e._firstNum<s._firstNum?-1:1:e._firstSlug.localeCompare(s._firstSlug)}function pn(e,s){const n=new Map(e.map(d=>[d.row.slug,d.row.slug])),a=d=>{for(;n.get(d)!==d;)n.set(d,n.get(n.get(d))),d=n.get(d);return d};for(const d of e)for(const i of d.row.dependsOn??[])s.has(i)&&n.set(a(d.row.slug),a(i));const l=new Map;for(const d of e){const i=a(d.row.slug),r=l.get(i);r?r.push(d):l.set(i,[d])}return[...l.values()]}function fn(e,s){if(e.length>0&&e.every(n=>!!n.row.planId)){const n=new Map;for(const a of e){const l=n.get(a.row.planId);l?l.push(a):n.set(a.row.planId,[a])}return[...n.values()]}return pn(e,s)}function hn(e,s,n,a){const l=[],d=[e];for(a.add(e.row.slug);d.length>0;){const i=d.pop();l.push(i);for(const r of i.row.dependsOn??[])if(n.has(r)&&!a.has(r)){a.add(r);const c=s.get(r);c&&d.push(c)}}return l}function xn(e,s){const n=new Map(e.map(r=>[r.row.slug,r])),a=new Set,l=[],d=e.filter(r=>Ms(r.row.slug).startsWith("validate-")).sort((r,c)=>it({slug:r.row.slug},{slug:c.row.slug}));for(const r of d)a.has(r.row.slug)||l.push({nodes:hn(r,n,s,a),validateSlug:r.row.slug});const i=e.filter(r=>!a.has(r.row.slug));if(i.length>0){const r=new Set(i.map(c=>c.row.slug));for(const c of fn(i,r))l.push({nodes:c,validateSlug:null})}return l}function gn(e){return e.replace(/^validate[\s:-]*/i,"").trim()}function xt(e,s){if(e.length===0)return[];const n=Oe(e),a=s.now??Date.now(),l=s.avgDurationMs??ln(n),d=Math.max(1,s.concurrency??1),i=new Map(n.map(u=>[u.slug,u])),r=u=>u.status==="pending"&&(u.dependsOn??[]).every(x=>i.get(x)===void 0||i.get(x).status==="completed"),c=new Map;n.filter(r).sort(it).forEach((u,x)=>c.set(u.slug,x));const o=as(n,s.sessions,n),p=[];for(const u of o){const x=Ge(u.nodes),b=new Set(x.map($=>$.row.slug)),h=new Map(x.map($=>[$.row.slug,$])),g=[];for(const $ of xn(x,b)){const P=$.nodes,J=new Set(P.map(N=>N.row.slug)),S=new Map,E=new Set,T=N=>{const k=h.get(N);return(k.row.dependsOn??[]).filter(H=>J.has(H)&&!(k.cycle&&h.get(H).cycle))},L=N=>{const k=S.get(N);if(k!==void 0)return k;if(E.has(N))return 0;E.add(N);let H=0;for(const Q of T(N))H=Math.max(H,L(Q));return E.delete(N),S.set(N,H+1),H+1};for(const N of P)L(N.row.slug);const y=P.map(N=>{const k=N.row,H=(k.dependsOn??[]).filter(Q=>b.has(Q));return{slug:k.slug,title:k.title,status:k.status,stage:S.get(k.slug),prdNumber:oe(k.slug),rowKind:"dep",rowTrailing:"",cycle:N.cycle,estimateMinutes:k.estimateMinutes??null,deps:H,crossEpicDeps:(k.dependsOn??[]).filter(Q=>!b.has(Q)),blockers:N.blockers,...me(k)?{cancelled:!0}:{},job:k}});y.sort(it);const M=y.reduce((N,k)=>Math.max(N,k.stage),0),D=new Map;for(const N of y){const k=N.job,H=h.get(N.slug),Q=k.status;let K;if(rt(Q)){const m=k.startedAt&&k.finishedAt?Date.parse(k.finishedAt)-Date.parse(k.startedAt):NaN;K={kind:"done",trailing:m>0?Le(m):"",held:!1,blocked:!1}}else if(Me(Q)){const m=k.startedAt?Math.max(0,a-Date.parse(k.startedAt)):null;K={kind:"running",trailing:m===null?"":is(k,m),held:!1,blocked:!1}}else if(me(k))K={kind:"cancelled",trailing:"cancelled",held:!1,blocked:!1};else if(Q==="failed")K={kind:"failed",trailing:"failed",held:!1,blocked:!1};else if(Q==="needs_review")K={kind:"review",trailing:"review",held:!1,blocked:!1};else if(Q==="quarantined")K={kind:"quarantined",trailing:"quarantined",held:!1,blocked:!1};else{const m=H.blockers.filter(j=>!j.missing&&j.status!=="completed");if(m.length>0){const j=m.some(W=>an(W.status)&&!me(i.get(W.slug))),R=m[0].slug;K={kind:"dep",trailing:`←${oe(R)??R}`,held:!j,blocked:j}}else if(k.heldReason)K={kind:"gate",trailing:"gate",held:!0,blocked:!1};else{const j=on(k),R=c.get(k.slug)??0;K=j>0?{kind:"retry",trailing:`${j} ${j===1?"retry":"retries"}`,held:!1,blocked:!1}:{kind:"eta",trailing:rs(R*l/d),held:!1,blocked:!1}}}D.set(N.slug,K)}const F=[];for(let N=1;N<=M;N++){const k=y.filter(B=>B.stage===N),H=k.find(B=>{const ne=D.get(B.slug).kind;return B.status==="pending"&&(ne==="eta"||ne==="retry")});if(H){const B=D.get(H.slug);B.kind="next",B.trailing="next"}let Q=0,K=0,m=0,j=0,R=0,W=0,C=0;for(const B of k){const ne=D.get(B.slug);B.rowKind=ne.kind,B.rowTrailing=ne.trailing,me(B)?C++:rt(B.status)?Q++:Me(B.status)?K++:B.status==="pending"?(R++,ne.held&&m++,ne.blocked&&j++):nn(B.status)&&W++}const O=Q+C===k.length?"done":K>0?"running":j+W>0?"blocked":m>0?"held":"pending",G={n:N,rows:k,doneCount:Q,runningCount:K,heldCount:m,blockedCount:j};F.push({...G,state:O,summary:cn(O,G,R,W)})}let _=0;for(const N of y){const k=N.estimateMinutes?N.estimateMinutes*6e4:l;if(N.status==="pending")_+=k;else if(Me(N.status)){const H=N.job.startedAt?Math.max(0,a-Date.parse(N.job.startedAt)):0;_+=Math.max(0,k-H)}}const U=y.reduce((N,k)=>Math.min(N,Be(k.slug)),1/0),te=y.reduce((N,k)=>Math.max(N,Be(k.slug)),-1/0),X=u.known?Cs(u.label).title:u.label,A=$.validateSlug?y.find(N=>N.slug===$.validateSlug):void 0,q=A&&gn(A.title)||X;g.push({epicId:u.epicId,waveIndex:0,index:0,label:q,epicLabel:X,validateSlug:$.validateSlug,width:F.reduce((N,k)=>Math.max(N,k.rows.length),0),status:dn(y),prdCount:y.length,stageCount:M,doneCount:F.reduce((N,k)=>N+k.doneCount,0),runningCount:F.reduce((N,k)=>N+k.runningCount,0),heldCount:F.reduce((N,k)=>N+k.heldCount,0),blockedCount:F.reduce((N,k)=>N+k.blockedCount,0),etaMs:_/d,stages:F,_firstNum:U,_lastNum:te,_firstSlug:y[0].slug})}g.sort(un),g.forEach(($,P)=>{$.waveIndex=P+1});const v=g.filter($=>$.validateSlug===null);v.forEach(($,P)=>{v.length>1&&($.label=`${$.label} · plan ${P+1}/${v.length}`)});for(const $ of g)p.push($)}return p.sort((u,x)=>{if(u._lastNum!==x._lastNum)return u._lastNum>x._lastNum?-1:1;const b=(u.epicId??"").localeCompare(x.epicId??"");return b!==0?b:u.waveIndex-x.waveIndex}),p.map(({_firstNum:u,_lastNum:x,_firstSlug:b,...h},g)=>({...h,index:g+1}))}function mn(e,s=Date.now()){const n=Oe(e),a=new Map(n.map(h=>[h.slug,h])),l=new Date(s).toDateString();let d=0,i=0,r=0,c=0,o=0,p=0,u=0;for(const h of n)if(h.status==="pending")i++,(h.dependsOn??[]).every(v=>a.get(v)===void 0||a.get(v).status==="completed")&&d++;else if(Me(h.status))u++;else{if(me(h))continue;h.status==="failed"?r++:h.status==="needs_review"?c++:h.status==="quarantined"?o++:h.status==="completed"&&h.finishedAt&&new Date(Date.parse(h.finishedAt)).toDateString()===l&&p++}let x=null;const b=r+o;if(b>0){for(const h of xt(n,{sessions:{},now:s}))for(const g of h.stages)if(g.rows.some(v=>!me(v)&&(v.status==="failed"||v.status==="quarantined"))){(x===null||g.n<x)&&(x=g.n);break}}return{readyNow:d,totalQueued:i,heldByDeps:i-d,needsYou:b,needsYouStage:x,failedCount:r,needsReviewCount:c,doneToday:p,inFlight:u}}function bn(e){const s=new Map;for(const c of e.stages)for(const o of c.rows)s.set(o.slug,o);const n=c=>{var o;return((o=s.get(c))==null?void 0:o.cycle)===!0},a=new Map,l=new Set,d=(c,o)=>c.chain.length!==o.chain.length?c.chain.length>o.chain.length:c.est!==o.est?c.est>o.est:c.chain.join("\0")<o.chain.join("\0"),i=c=>{const o=a.get(c);if(o)return o;const p=s.get(c),u=p.estimateMinutes??0;if(l.has(c))return{chain:[c],est:u};l.add(c);let x=null;for(const h of p.deps){if(!s.has(h)||p.cycle&&n(h))continue;const g=i(h);(!x||d(g,x))&&(x=g)}l.delete(c);const b=x?{chain:[...x.chain,c],est:x.est+u}:{chain:[c],est:u};return a.set(c,b),b};let r=null;for(const c of s.keys()){const o=i(c);(!r||d(o,r))&&(r=o)}return r?r.chain:[]}const wn=15e3,vn=new Set(["failed","quarantined"]);function jn(e){for(let s=e.parentElement;s;s=s.parentElement){const n=getComputedStyle(s).overflowY;if(n==="auto"||n==="scroll")return s}return null}function It(){const s=Array.from(document.querySelectorAll("[data-job-row]")).find(a=>vn.has(a.dataset.jobStatus??""));if(!s)return;const n=jn(s);n&&Os(n,s,{block:"nearest",behavior:"smooth"})}function yn(e,s){var n;switch(e.kind){case"paused":return`paused: scheduler is paused (${e.reason??"manual"})`;case"launch-blocked":return`launch-blocked: ${e.agentType} jobs can't launch${(n=e.block)!=null&&n.kind?` (${e.block.kind})`:""}`;case"idle":return"idle: 0 pending";case"saturated":{const a=s!=null?`, oldest ${re(s)}`:"";return`saturated: ${e.totalSlots??"?"} slot(s) busy${a}`}case"blocked":{const a=e.blockedChains.length;return`blocked: ${e.pending} pending, ${e.dispatchable} dispatchable — ${a} chain${a===1?"":"s"} stuck behind a failed/skipped dependency`}case"stalled":return`stalled: no dispatch attempt in ${e.idleMs!=null?re(e.idleMs):"?"} with ${e.dispatchable} dispatchable`;case"running":default:return`running: ${e.runningCount} in flight, ${e.pending} pending`}}function Nn(e){const[s,n]=f.useState(null),a=ct(),l=_s(),d=a&&l;return f.useEffect(()=>{if(!d)return;let i=!0,r=!1,c=!1;const o=()=>{r||(r=!0,window.api.schedule.queueHealth(e).then(u=>{r=!1,c=!1,i&&n(u)},u=>{r=!1,!c&&(c=!0,Y.error(`Queue health refresh failed: ${u instanceof Error?u.message:String(u)}`))}))};o();const p=setInterval(o,wn);return()=>{i=!1,clearInterval(p)}},[e,d]),s}const kn={running:{dot:"bg-sage",text:"text-sage-dark"},paused:{dot:"bg-amber-500",text:"text-amber-600"},idle:{dot:"bg-fg-faint",text:"text-fg-faint"}};function Sn(e,s,n){return e==="paused"||e==="launch-blocked"?"paused":e==="running"||e==="saturated"?"running":e?"idle":s?"paused":n>0?"running":"idle"}const Ze="px-2.5 py-1.5 rounded border border-line text-[12.5px] font-medium text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-40 disabled:cursor-not-allowed whitespace-nowrap";function $n(e,s,n,a){var l;if(e==="agent"){const d=((l=a==null?void 0:a.cwd)==null?void 0:l.split("/").filter(Boolean).pop())||"another session",i=a!=null&&a.reason?` — "${a.reason}"`:"",r=s?new Date(s).getTime()-n:null,c=r==null?"":r>0?` — auto-resumes in ${re(r)}`:" — auto-resume pending";return`Paused by an agent in ${d}${i}${c}. Click Resume to restart now.`}if(e==="auth")return"Scheduler paused: Claude sign-in expired or invalid. Restart the app or re-run `claude login`, then Resume.";if(e==="rate_limit"){if(s){const d=new Date(s).getTime()-n;return d>0?`Paused for rate limit — resumes in ${re(d)}`:"Paused for rate limit — resume pending"}return"Paused for rate limit"}return e==="network"?"Paused: billing endpoint unreachable for 30+ min.":e==="manual"?"Scheduler paused manually — no new jobs start; running jobs continue. Click Resume to restart.":`Scheduler paused (${e})`}function Cn({now:e}){const s=Ue(p=>p.snapshot);if(!s)return null;const n=s.paused,a=Object.entries(s.launchBlocks??{}),l=Object.entries(s.launchMitigations??{}),d=(n==null?void 0:n.reason)==="auth"||(n==null?void 0:n.reason)==="network",i="flex items-start gap-3 border-b px-0 py-1.5 text-[12.5px]",r="bg-red-950/10 border-red-700/30 text-red-800",c="bg-amber-400/10 border-amber-600/30 text-amber-700",o="shrink-0 px-2 py-0.5 rounded border border-current/40 hover:bg-white/20 text-[12px] font-medium";return t.jsxs(t.Fragment,{children:[n&&t.jsxs("div",{"data-testid":"pause-banner",className:`${i} ${d?r:c}`,children:[t.jsx("span",{className:"flex-1 leading-snug",children:$n(n.reason,n.resumeAt,e,n.by)}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),className:o,children:"Resume"})]}),a.map(([p,u])=>t.jsxs("div",{"data-testid":"launch-block-banner",className:`${i} ${r}`,children:[t.jsxs("div",{className:"flex-1 leading-snug min-w-0",children:[t.jsxs("div",{className:"font-medium",children:["Launches for ",t.jsx("span",{className:"font-mono",children:p})," jobs are failing before any work starts",u.httpStatus?` (HTTP ${u.httpStatus}, ${u.kind})`:` (${u.kind})`,u.exhausted?" — held until the Claude CLI version changes or you press Retry now.":u.until?` — next automatic probe ${new Date(u.until).getTime()>e?`in ${re(new Date(u.until).getTime()-e)}`:"on the next tick"}.`:"."]}),t.jsx("div",{className:"opacity-80",children:u.hint}),t.jsxs("div",{className:"font-mono text-[11.5px] opacity-70 truncate",title:u.message,children:[u.attempts," failed probe",u.attempts===1?"":"s",u.claudeVersion?` · CLI ${u.claudeVersion}`:"",u.lastSlug?` · last: ${u.lastSlug}`:""," · ",u.message]})]}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),className:o,children:"Retry now"})]},`launch-block-${p}`)),l.map(([p,u])=>t.jsx("div",{"data-testid":"launch-mitigation-banner",className:`${i} ${c}`,children:t.jsxs("div",{className:"flex-1 leading-snug min-w-0",children:[t.jsxs("div",{className:"font-medium",children:[t.jsx("span",{className:"font-mono",children:p})," jobs are running in degraded mode"," ","(",t.jsx("span",{className:"font-mono",children:Object.entries(u.env).map(([x,b])=>`${x}=${b}`).join(" ")}),")",u.claudeVersion?` since CLI ${u.claudeVersion}`:"","."]}),t.jsx("div",{className:"opacity-80",children:u.hint})]})},`launch-mitigation-${p}`))]})}function Mn({scopeCwd:e,subView:s,onSubView:n,filterText:a,onFilterText:l,planMode:d,onPlanMode:i,planToolsRef:r}){const c=Ue(C=>C.snapshot),o=he(C=>C.sessions),p=Nn(e),u=Vt(),[x,b]=f.useState(()=>Date.now()),[h,g]=f.useState("—");f.useEffect(()=>{const C=setInterval(()=>b(Date.now()),3e4);return()=>clearInterval(C)},[]),f.useEffect(()=>{let C=!0;return Ks(30).then(O=>{if(!C||!O.ok||!O.data)return;const G=new Date,B=ze=>String(ze).padStart(2,"0"),ne=`${G.getFullYear()}-${B(G.getMonth()+1)}-${B(G.getDate())}`;g(Js(Xs(O.data,{day:ne})))}),()=>{C=!1}},[]);const v=f.useMemo(()=>((c==null?void 0:c.jobs)??[]).filter(C=>!e||C.cwd===e),[c,e]),$=f.useMemo(()=>mn(v,x),[v,x]),P=f.useMemo(()=>{const C=xt(v,{sessions:o,now:x}),O=G=>C.filter(B=>B.status===G).length;return{active:O("active"),queued:O("queued"),draft:O("draft")}},[v,o,x]),J=f.useMemo(()=>{const C=new Date(x).toDateString(),O=[];for(const G of v)if(G.status==="completed"&&G.startedAt&&G.finishedAt&&new Date(Date.parse(G.finishedAt)).toDateString()===C){const B=Date.parse(G.finishedAt)-Date.parse(G.startedAt);B>0&&O.push(B)}return O.length?Math.round(O.reduce((G,B)=>G+B,0)/O.length/6e4):null},[v,x]);if(!c)return null;const S=p&&!p.unknown?p.verdict??null:null,E=p&&!p.unknown?p.slots??null:null,T=c.paused,L=Sn((S==null?void 0:S.kind)??null,!!T,$.inFlight),y=kn[L],M=v.filter(C=>C.status==="pending").length,D=v.filter(C=>C.status==="running").length,F=zt({snap:{...c,jobs:v},now:x,avgDurationMs:0,runningJobs:v.filter(C=>C.status==="running")}),_=p!=null&&p.unknown?`Queue health: unknown — ${p.reason??"state unavailable"}`:S?yn(S,(p==null?void 0:p.oldestRunningAgeMs)??null):"queue health loading…",U=be(c.lastRunAt?Date.parse(c.lastRunAt):null,x),te=p!=null&&p.lastDispatchAttemptAt?be(Date.parse(p.lastDispatchAttemptAt),x):"never",X=[_,F.line1,S?`dispatchable ${S.dispatchable} · needs_review ${S.needsReviewCount}`:null,(p==null?void 0:p.oldestRunningAgeMs)!=null?`oldest running ${re(p.oldestRunningAgeMs)} (any project)`:null,`last batch fired ${U} (lastRunAt — advances only when a job launches)`,`last dispatch attempt ${te} (advances on every driver evaluation)`].filter(Boolean).join(`
2
2
  `),A=c.utilization,q=c.pollHealth,N=q!=null&&!q.lastPollOk,k=Ps(c.utilizationWindow),H=c.nextReset?Date.parse(c.nextReset):null,Q=H?H>x?re(H-x):"soon":"—",K=typeof c.effectiveUtilizationThreshold=="number"?Math.round(c.effectiveUtilizationThreshold*10)/10:null,m=(u==null?void 0:u.total)??5,j=(u==null?void 0:u.envOverride)===!0,R=c.config.firePolicy??"when-available",W=M===0&&D===0;return t.jsxs("div",{"data-testid":"scheduler-top-bands",className:"shrink-0 px-[18px]",children:[t.jsxs(Je,{height:40,testId:"queue-health-header",className:"gap-3",children:[t.jsx("h1",{className:"m-0 font-serif text-[21px] font-semibold leading-none tracking-tight text-fg",children:"Scheduler"}),t.jsx("span",{className:"w-px h-[20px] bg-rule-structural","aria-hidden":"true"}),t.jsxs("span",{className:`inline-flex items-center gap-1.5 text-[12.5px] font-medium ${y.text}`,"data-testid":"scheduler-state-word","data-state":L,children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${y.dot}`,"aria-hidden":"true"}),L]}),t.jsxs("span",{className:"font-mono text-[12px] text-fg-faint whitespace-nowrap","data-testid":"scheduler-meta",children:[$.inFlight," in flight · ",$.heldByDeps," held · last batch ",U]}),t.jsxs(we,{title:X,testId:"scheduler-verdict-info",popoverTestId:"scheduler-info-popover",children:[t.jsx("pre",{className:"m-0 mb-2 whitespace-pre-wrap font-mono text-[11.5px] text-fg-dim",children:X}),Ct.scheduler&&t.jsx(Ds,{content:Ct.scheduler})]}),t.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>window.api.schedule.rescan().then(Y.fromOutcome).catch(()=>Y.error("Failed to rescan")),title:"Re-scan the prds/ folder. Use when you've added or edited PRDs on disk and want the queue to reflect them immediately.",className:Ze,children:"Refresh"}),T?t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),title:"Clear the pause and resume queue immediately",className:Ze,children:"Resume"}):t.jsx("button",{type:"button",onClick:()=>window.api.schedule.pause(),title:"Stop NEW dispatch. Running jobs are not killed.",className:Ze,children:"Pause"}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.forceTick().then(Y.fromOutcome).catch(()=>Y.error("Failed to fire batch")),disabled:W,title:"Bypasses the billing-usage poll. Use when the meter is rate-limited or you want immediate progress.",className:"px-3 py-1.5 rounded bg-accent text-white text-[12.5px] font-semibold whitespace-nowrap disabled:opacity-40 disabled:cursor-not-allowed hover:opacity-90",children:"Fire next batch"})]})]}),t.jsx(Cn,{now:x}),t.jsxs(Je,{height:70,testId:"scheduler-kpi-band",children:[t.jsx(pe,{testId:"kpi-window",label:k?`${k} used`:"Window used",info:N?`Billing poll failing — this reading may be outdated (last good reading ${be(q.lastPollAt,x)}). Machine-wide ${k??"binding"} window.`:`Share of the machine-wide ${k??"binding"} billing window consumed — the window closest to its limit.`,value:A==null?"—":`${Math.round(A)}%`,sub:`resets in ${Q}`,third:t.jsx(As,{pct:A??0,tone:N?"bg-amber-500":"bg-accent"})}),t.jsx(pe,{testId:"kpi-slots",label:"Slots",info:`Machine-wide session pool (${(E==null?void 0:E.source)==="env"?"SM_SESSION_SLOTS override":"Home tab cap"}), not scoped to this project`,value:E?`${E.inUse}/${E.total}`:"—",sub:"in use",third:E?t.jsx(Rs,{filled:E.inUse,total:E.total}):null}),t.jsx(pe,{testId:"kpi-ready",label:"Ready now",info:"Pending rows whose dependsOn chain is fully satisfied right now",value:$.readyNow,sub:`of ${$.totalQueued} queued`,third:`${$.heldByDeps} held by deps`}),$.needsYou>0?t.jsx(pe,{testId:"kpi-needs-you",label:"Needs you",value:t.jsx("button",{type:"button","data-testid":"kpi-needs-you-jump",onClick:It,className:"font-semibold text-accent hover:underline",title:"Scroll to the first failed / quarantined row",children:$.needsYou}),sub:t.jsx("button",{type:"button",onClick:It,className:"hover:underline",children:$.needsYouStage!=null?`blocking stage ${$.needsYouStage}`:"need attention"}),third:[$.failedCount>0&&`${$.failedCount} failed`,$.needsYou-$.failedCount>0&&`${$.needsYou-$.failedCount} quarantined`].filter(Boolean).join(" · ")}):t.jsx(pe,{testId:"kpi-needs-you",label:"Needs you",value:t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[15px]",children:[t.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-sage","aria-hidden":"true"}),"all clear"]}),third:"0 failed · 0 quarantined"}),$.needsReviewCount>0&&t.jsx(pe,{testId:"kpi-being-fixed",label:"Being fixed",value:$.needsReviewCount,sub:"the scheduler is handling them"}),t.jsx(pe,{testId:"kpi-done",label:"Done today",value:$.doneToday,sub:J!=null?`avg ${J}m`:"avg —",third:t.jsx("span",{"data-testid":"kpi-done-spend",children:h})}),t.jsx(pe,{testId:"kpi-concurrency",label:"Concurrency",info:"Start-jobs policy, concurrency cap and utilization threshold",infoTestId:"kpi-concurrency-info",infoAlignRight:!0,infoContent:t.jsxs("label",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-fg",children:"Start jobs"}),t.jsxs("select",{"data-testid":"kpi-fire-policy",value:R,onChange:C=>window.api.schedule.setConfig({firePolicy:C.target.value}),className:"border border-line bg-bg-hi rounded px-1 py-0.5 text-[12px] text-fg-dim",title:"when-available: poll usage and fire when tokens are below threshold. manual: only on Run now.","aria-label":"Start jobs policy",children:[t.jsx("option",{value:"when-available",children:"when available"}),t.jsx("option",{value:"manual",children:"manually"})]})]}),value:t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(Is,{value:m,min:0,max:(u==null?void 0:u.max)??10,disabled:j,onChange:C=>{Es(C).catch(O=>{Y.error(`Could not set session slots: ${O instanceof Error?O.message:String(O)}`)})},title:j?"pinned by SM_SESSION_SLOTS — unset the env var to edit":"Machine-wide claude -p session slots, shared with chat runs"}),j&&t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-amber-600 bg-amber-400/10 border border-amber-400/30 rounded px-1 py-0",title:"Pinned by SM_SESSION_SLOTS — unset the env var to edit",children:"env"})]}),sub:"at once",third:R==="when-available"?t.jsxs("span",{children:["pause above"," ",t.jsx(Ts,{value:c.config.utilizationThreshold??90,min:0,max:100,testId:"kpi-threshold",title:"Holds new dispatches when the highest of the 5-hour and weekly usage windows is at/above this percent (when-available policy only). The cap rises from this value toward 99% as the usage window's reset nears (99% in the final 2 days of the week). Not the executor rate-limit pause — click to edit",onCommit:C=>window.api.schedule.setConfig({utilizationThreshold:C})}),K!=null&&K!==(c.config.utilizationThreshold??90)&&t.jsxs("span",{"data-testid":"kpi-threshold-effective",title:"Cap in force now — pro-rated toward 99% as the usage window's reset nears",children:[" · now ",K,"%"]})]}):null})]}),t.jsxs(Je,{height:30,testId:"scheduler-plans-toolbar",className:"gap-3",children:[t.jsx("span",{className:"text-[10.5px] font-semibold uppercase tracking-wide text-fg-faint",children:"Plans"}),t.jsxs("span",{className:"font-mono text-[12px] text-fg-faint whitespace-nowrap","data-testid":"scheduler-plans-meta",children:[P.active," active · ",P.queued," queued · ",P.draft," draft · ",v.length," PRDs"]}),t.jsxs("span",{className:"ml-auto flex items-center gap-3",children:[t.jsx("span",{ref:r,className:"contents","data-testid":"scheduler-plan-tools"}),t.jsx("input",{type:"text",value:a,onChange:C=>l(C.target.value),placeholder:"filter PRDs…","aria-label":"Filter PRDs by title, slug, or project","data-testid":"scheduler-filter-input",className:"w-[180px] bg-bg-hi border border-line rounded px-2 py-0.5 text-[12px] text-fg placeholder:text-fg-faint focus:outline-none focus:border-fg-faint"}),t.jsx("span",{className:"inline-flex border border-line rounded overflow-hidden",role:"group","aria-label":"Plan view mode",children:[["graph","Graph"],["list","List"],["critical","Critical path"]].map(([C,O])=>t.jsx("button",{type:"button","data-testid":`plan-mode-${C}`,"aria-pressed":d===C&&s==="queue",onClick:()=>{i(C),n("queue")},className:`px-2 py-0.5 text-[12px] ${d===C&&s==="queue"?"bg-bg-elev font-semibold text-fg":"text-fg-dim hover:text-fg"}`,children:O},C))}),t.jsx("span",{className:"w-px h-[16px] bg-rule-structural","aria-hidden":"true"}),[["prds","PRDs","Authored PRD source files on disk — edit, lint, archive, or queue them."],["history","History","The last 50 completed and failed jobs."],["tasks","Tasks","This project’s single Claude calls, grouped by caller pipeline and run."],["machine","Machine","Machine-wide config that applies to every project — not this project’s live queue."]].map(([C,O,G])=>t.jsx("button",{type:"button",onClick:()=>n(C),"aria-pressed":s===C,title:G,className:`text-[12.5px] ${s===C?"font-semibold text-fg":"text-fg-faint hover:text-fg-dim"}`,children:O},C))]})]})]})}function ls({options:e,value:s,onChange:n,pillPadding:a="px-3 py-1.5"}){return t.jsx("div",{className:"flex gap-1.5 flex-wrap",children:e.map(l=>{const d=l.value===s;return t.jsxs("button",{type:"button",onClick:()=>n(l.value),className:`rounded-full ${a} text-[12.5px] border transition-colors ${d?"bg-accent text-white border-accent font-semibold":"bg-bg-hi text-fg-dim border-line hover:border-fg-faint font-medium"}`,children:[l.label,l.count!==void 0&&t.jsxs("span",{children:[" ",l.count]})]},l.value)})})}function os(e,s=60){const n=e.trim();return n.length<=s?n:`${n.slice(0,s-1)}…`}function Pn(e){return Ge([e]).filter(s=>s.children.length===0).map(s=>s.row.slug)}function ds(e){return e.nodes.map(s=>({rootSlug:s.row.slug,label:s.row.title||s.row.slug,terminals:Pn(s)}))}function Dn(e){const s=new Map;for(const n of e){const a=ds(n);n.nodes.forEach((l,d)=>{const i=a.filter((r,c)=>c!==d);for(const r of Ge([l]))s.set(r.row.slug,i)})}return s}function cs({job:e,headChoices:s}){const[n,a]=f.useState(!1),l=f.useCallback((d,i)=>{a(!0),window.api.schedule.setPrdDisposition({slug:e.slug,cwd:e.cwd??void 0,disposition:d,dependsOn:i}).then(Y.fromOutcome).catch(()=>Y.error("Failed to change disposition")).finally(()=>a(!1))},[e.slug,e.cwd]);return e.disposition!=="append"&&s.length===0?null:t.jsxs("select",{"data-testid":"job-row-disposition-control",disabled:n,value:"",onChange:d=>{const i=d.target.value;if(i==="__new-head__")l("new-head");else if(i){const r=s.find(c=>c.rootSlug===i);r&&l("append",r.terminals)}},className:"text-[13px] font-semibold text-fg-dim hover:text-fg bg-transparent border border-line/60 rounded px-1.5 py-0.5 cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",title:"Change this wave's relationship to the rest of the Epic's plan",children:[t.jsx("option",{value:"",disabled:!0,children:"change disposition…"}),e.disposition==="append"&&t.jsx("option",{value:"__new-head__",children:"promote to new head"}),s.map(d=>t.jsxs("option",{value:d.rootSlug,children:["attach behind: ",os(d.label,40)]},d.rootSlug))]})}function An(e,s,n=null){if(s.length===0||e.length===0)return e;const a=new Set,l=new Set;for(const i of e){a.add(i.slug);for(const r of Mt(i))l.add(r)}const d=[];for(const i of s)i.archived!==!0||a.has(i.slug)||n&&i.cwd!==n||Mt(i).some(r=>l.has(r))&&(a.add(i.slug),d.push({slug:i.slug,title:i.title,cwd:i.cwd,parallelGroup:i.parallelGroup,estimateMinutes:i.estimateMinutes,bodyPreview:"",status:i.archivedStatus??"completed",runId:null,startedAt:null,finishedAt:null,exitCode:null,error:null,dependsOn:i.dependsOn??void 0,sourcePromptId:i.sourcePromptId??null,epicId:i.epicId??null,synthetic:!0}));return d.length===0?e:[...e,...d]}const Rn=[],Tn=new Set(["failed","needs_review","quarantined"]);function In(e){if(e.cancelled===!0)return"bg-fg-faint/40";switch(e.status){case"completed":case"skipped":return"bg-sage";case"running":case"investigating":return"bg-accent";case"failed":return"bg-accent";case"needs_review":return"bg-butter";case"quarantined":return"bg-butter/60";default:return e.rowKind==="eta"||e.rowKind==="next"||e.rowKind==="retry"?"border border-fg-faint bg-transparent":"bg-fg-faint/40"}}function En(e){if(e.cancelled===!0)return"";switch(e.status){case"running":case"investigating":return"bg-butter/10";case"failed":return"bg-accent/10";case"needs_review":return"bg-butter/25";default:return""}}function _n(e){if(e.cancelled===!0)return"text-fg-faint";switch(e.rowKind){case"running":case"dep":case"failed":return"text-accent";case"review":return"text-butter font-semibold";default:return"text-fg-faint"}}function On({row:e,elapsedMs:s,listIndex:n,onFocused:a,headChoices:l=Rn}){const[d,i]=f.useState(!1),r=e.job,c=s!==null&&e.rowKind==="running"?is(r,s):e.rowTrailing,o=e.status==="completed"||e.status==="skipped",p=e.rowKind==="dep"&&e.blockers.some(x=>!x.missing&&x.status!==null&&Tn.has(x.status)),u=o||p;return t.jsxs("div",{role:"listitem","data-testid":"prd-row","data-slug":e.slug,className:"border-t border-rule-inner first:border-t-0",children:[t.jsxs("button",{type:"button","data-job-row":!0,"data-job-status":r.status,"data-job-index":n,onClick:()=>i(x=>!x),onFocus:()=>a(n),"aria-expanded":d,"aria-label":`${e.prdNumber?`PRD ${e.prdNumber}, `:""}${r.title}, ${r.status}${c?`, ${c}`:""}`,title:r.title,className:`w-full h-[31px] py-1 px-2 text-left flex items-center gap-1.5 hover:bg-bg/40 focus:outline-none focus:ring-1 focus:ring-accent focus:ring-inset ${En(e)}`,children:[t.jsx("span",{"aria-hidden":"true",className:`shrink-0 w-[7px] h-[7px] rounded-full ${In(e)}`}),t.jsx("span",{className:"shrink-0 font-mono text-[10.5px] text-fg-faint w-[30px]",children:e.prdNumber?`#${e.prdNumber}`:""}),t.jsx("span",{className:`flex-1 min-w-0 truncate text-[12.5px] leading-tight ${u?"text-fg-faint":"text-fg font-medium"}`,children:r.title}),t.jsx("span",{"data-testid":"prd-row-trailing",className:`shrink-0 font-mono text-[10.5px] ${_n(e)}`,children:c})]}),d&&t.jsx(Ln,{row:e,elapsedMs:s,headChoices:l})]})}const us=f.memo(On);function Ln({row:e,elapsedMs:s,headChoices:n}){const a=e.job,[l,d]=f.useState(!1),i=he(b=>b.sessions),r=f.useMemo(()=>De(a,i),[a,i]),c=r.known&&r.epicId?i[r.epicId]:null,o=f.useCallback(b=>Yt(b),[]),p="font-mono text-[11.5px] text-fg-dim leading-snug break-words",u="text-[12px] font-semibold bg-transparent border-0 cursor-pointer p-0",x=a.error?a.error.split(`
3
3
  `)[0]:null;return t.jsxs("div",{"data-testid":"prd-row-detail",className:"px-3 py-2 bg-bg-elev/50 border-t border-rule-inner flex flex-col gap-1",children:[t.jsxs("div",{className:p,children:[a.status.replace(/_/g," "),a.exitCode!==null&&` · exit ${a.exitCode}`,a.verifierVerdict&&` · ${Pe(a.verifierVerdict)}`,a.startedAt&&` · started ${ke(Date.parse(a.startedAt))}`,a.finishedAt&&` · finished ${ke(Date.parse(a.finishedAt))}`,s===null&&e.rowTrailing&&e.rowKind==="done"?` · took ${e.rowTrailing}`:""]}),e.cycle&&t.jsxs("div",{className:`${p} text-accent`,"data-testid":"job-row-cycle-warning",children:["⚠ dependsOn cycle — ",e.blockers.map(b=>b.slug).join(" ↔ ")||"self-referencing"]}),!e.cycle&&e.blockers.length>0&&t.jsxs("div",{className:p,"data-testid":"job-row-blockers",children:["depends on ",e.blockers.map(b=>`${b.slug} (${b.missing?"missing":(b.status??"unknown").replace(/_/g," ")})`).join(", ")]}),a.status==="pending"&&a.heldReason&&t.jsxs("div",{className:`${p} text-amber-400/90`,"data-testid":"job-row-held-reason",children:["held · ",a.heldReason]}),x&&t.jsx("div",{className:`${p} text-accent/80`,children:x}),!a.synthetic&&t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 pt-0.5",children:[c&&t.jsx("button",{type:"button","data-testid":"job-row-prompt-session-link",title:c.goalText,onClick:()=>o(c.id),className:`${u} text-accent hover:text-accent/80`,children:"view epic →"}),a.runId&&t.jsx("button",{type:"button",onClick:()=>d(!0),className:`${u} text-fg-dim hover:text-fg`,children:"view log →"}),a.status==="quarantined"&&t.jsx("button",{type:"button","data-testid":"job-row-adopt-prd",title:"Stamp this PRD's provenance so the scheduler will run it — no unstamped PRD runs automatically.",onClick:()=>{window.api.schedule.adoptPrd(a.slug).then(Y.fromOutcome).catch(()=>Y.error("Failed to adopt PRD"))},className:`${u} text-accent hover:text-accent/80`,children:"adopt PRD →"}),a.status!=="pending"&&a.status!=="running"&&a.status!=="quarantined"&&t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resetJob(a.slug,a.cwd??void 0),className:`${u} text-fg-dim hover:text-fg`,children:"reset to pending →"}),a.disposition&&(a.status==="pending"||a.status==="quarantined")&&t.jsx(cs,{job:a,headChoices:n})]}),l&&a.runId&&t.jsx(We,{runId:a.runId,slug:a.slug,title:a.title||a.slug,onClose:()=>d(!1)})]})}const fe=190,Fn=7,qn=5,Bn=[],ps=e=>e==="completed"||e==="skipped",fs=e=>e==="running"||e==="investigating",hs=e=>e==="failed"||e==="needs_review"||e==="quarantined",lt=e=>e.cancelled===!0;function Te(e){return lt(e)?3:fs(e.status)?0:hs(e.status)?1:ps(e.status)?3:2}const Hn={done:"text-sage",running:"text-accent",held:"text-fg-faint",pending:"text-fg-faint",blocked:"text-butter"},Un={done:"bg-sage",running:"bg-accent",held:"bg-fg-faint/50",pending:"bg-fg-faint/50",blocked:"bg-butter"};function Wn(e,s){return e.every(n=>ps(n.status))?`+${e.length} done`:e.every(n=>n.rowKind==="dep"&&n.blockers.some(a=>!a.missing&&a.status!==null&&hs(a.status)))?`+${e.length} blocked`:`+${e.length} in stage ${s}`}function Gn({stage:e,epicId:s,now:n,hidden:a,indexBySlug:l,headChoicesBySlug:d,onRowFocused:i}){const[r,c]=f.useState(!1),o=f.useMemo(()=>e.rows.filter(S=>!(a.has(S.slug)&&(S.status==="completed"||S.status==="failed"))).map((S,E)=>({r:S,i:E})).sort((S,E)=>Te(S.r)-Te(E.r)||S.i-E.i).map(S=>S.r),[e.rows,a]),p=f.useMemo(()=>o.filter(S=>Te(S)<=1).length,[o]),u=Math.max(e.state==="done"?qn:Fn,p),x=r?o:o.slice(0,u),b=r?[]:o.slice(u),h=o.find(S=>S.status==="failed"&&!lt(S)),g=o.find(S=>S.status==="needs_review"&&!lt(S)),v=p>0&&(h!==void 0||g!==void 0),$=x.reduce((S,E,T)=>Te(E)<=1?T:S,-1),P=S=>t.jsx(us,{row:S,elapsedMs:fs(S.status)&&S.job.startedAt?n-Date.parse(S.job.startedAt):null,listIndex:l.get(S.slug)??0,onFocused:i,headChoices:d.get(S.slug)??Bn},S.slug),J="flex-1 min-w-0 truncate h-[24px] text-[11.5px] font-medium text-fg-dim hover:text-fg border border-rule-structural rounded-sm bg-transparent cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed";return t.jsxs("div",{"data-testid":"stage-column","data-stage":e.n,style:{width:fe},className:"shrink-0 border-l border-rule-structural first:border-l-0 flex flex-col self-stretch",children:[t.jsxs("div",{className:"h-[30px] shrink-0 flex items-center gap-1.5 px-2 border-b border-rule-inner","data-testid":"stage-header",children:[t.jsx("span",{"aria-hidden":"true",className:`w-[7px] h-[7px] rounded-full shrink-0 ${Un[e.state]}`}),t.jsxs("span",{className:`text-[10px] font-semibold uppercase tracking-wide ${Hn[e.state]}`,children:["Stage ",e.n]}),e.state==="blocked"&&t.jsx(we,{title:"Rows in this stage are failed / need review / are quarantined, or wait on one that is."}),t.jsx("span",{"data-testid":"stage-summary",className:"ml-auto font-mono text-[10.5px] text-fg-dim truncate",children:e.summary})]}),t.jsx("div",{role:"presentation",children:x.map((S,E)=>t.jsxs("div",{children:[P(S),v&&E===$&&t.jsxs("div",{"data-testid":"stage-attention-actions",className:"flex gap-1.5 px-2 py-1.5 border-t border-rule-inner",children:[h&&t.jsxs("button",{type:"button","data-testid":"stage-retry",title:`Reset ${h.slug} to pending`,onClick:()=>{window.api.schedule.resetJob(h.slug,h.job.cwd??void 0).then(T=>{T.ok||Y.error(T.error??`Failed to reset ${h.slug}`)}).catch(()=>Y.error(`Failed to reset ${h.slug}`))},className:J,children:["Retry ",h.prdNumber?`#${h.prdNumber}`:h.slug]}),g&&t.jsxs("button",{type:"button","data-testid":"stage-review",disabled:!s,title:s?"Open the authoring Epic — a needs_review PRD is a question routed back to it":"No authoring Epic recorded for this plan",onClick:()=>{s&&Yt(s)},className:J,children:["Review ",g.prdNumber?`#${g.prdNumber}`:g.slug]})]})]},S.slug))}),(b.length>0||r&&o.length>u)&&t.jsx("button",{type:"button","data-testid":"stage-footer","aria-expanded":r,onClick:()=>c(S=>!S),className:"mt-auto h-[26px] border-t border-rule-inner font-mono text-[11px] text-fg-faint hover:text-fg-dim bg-transparent cursor-pointer",children:r?"show less ▴":`${Wn(b,e.n)} ▾`})]})}const ye=6,et=4,_e=4,Et=12,_t=5,xs=2,Ot=4,Vn={done:"bg-sage",running:"bg-accent",attention:"bg-butter",failed:"bg-red-600",pending:"bg-fg-faint/50",cancelled:"bg-fg-faint/40"};function zn(e,s){return s?"cancelled":e==="completed"||e==="skipped"?"done":e==="running"||e==="investigating"?"running":e==="failed"?"failed":e==="needs_review"||e==="quarantined"?"attention":"pending"}function Yn(e){const s=[],n=[],a=[];let l=_t;for(const d of e){const i=Math.max(1,Math.ceil(d.rows.length/_e));n.push(l),a.push(i*ye),d.rows.forEach((r,c)=>{const o=r.cancelled===!0;s.push({x:l+Math.floor(c/_e)*ye,y:xs+c%_e*ye,tone:zn(r.status,o),title:`${r.prdNumber?`#${r.prdNumber}`:r.slug} ${r.title} — ${o?"cancelled":r.status}`})}),l+=i*ye+Et}return{dots:s,stageX:n,stageW:a,width:Math.max(0,l-Et)+_t}}function Ne(e,s){return e.findIndex(n=>n.rows.some(a=>s(a.status)))}const ot=e=>e==="running"||e==="investigating",dt=e=>e==="failed"||e==="needs_review"||e==="quarantined";function Qn({stages:e,first:s,perView:n,onSeek:a}){const l=f.useMemo(()=>Yn(e),[e]),d=f.useMemo(()=>Ne(e,ot)>=0,[e]),i=f.useMemo(()=>Ne(e,dt)>=0,[e]),r=f.useRef(!1),c=e.length,o=Math.min(c-1,s+n-1),p=l.stageX[Math.min(s,c-1)]??0,u=(l.stageX[o]??0)+(l.stageW[o]??0),x=h=>{const g=h.currentTarget.getBoundingClientRect(),v=h.clientX-g.left;let $=0;for(let P=0;P<c;P++)l.stageX[P]<=v&&($=P);a(Math.max(0,Math.min(c-1,$-Math.floor(n/2))))},b="px-2 h-[20px] text-[11.5px] disabled:opacity-40 disabled:cursor-not-allowed";return t.jsxs("div",{"data-testid":"plan-minimap",className:"h-[28px] flex items-center gap-3 px-3 border-t border-rule-inner",children:[t.jsxs("span",{className:"shrink-0 flex items-center gap-1 text-[10.5px] font-semibold uppercase tracking-wide text-fg-faint",children:["Whole graph",t.jsx(we,{title:"Every PRD in this plan as one dot, grouped by stage. The rust box is the range of stages shown below — drag it to scroll."})]}),t.jsxs("div",{"data-testid":"plan-minimap-dots",role:"presentation",className:"relative shrink min-w-0 overflow-hidden cursor-ew-resize touch-none",style:{width:l.width,height:_e*ye-(ye-et)+2*xs},onPointerDown:h=>{var g,v;r.current=!0,(v=(g=h.currentTarget).setPointerCapture)==null||v.call(g,h.pointerId),x(h)},onPointerMove:h=>{r.current&&x(h)},onPointerUp:()=>{r.current=!1},onPointerCancel:()=>{r.current=!1},children:[l.dots.map((h,g)=>t.jsx("span",{title:h.title,"data-tone":h.tone,className:`absolute rounded-[1px] ${Vn[h.tone]}`,style:{left:h.x,top:h.y,width:et,height:et}},g)),t.jsx("span",{"data-testid":"plan-minimap-brush","aria-hidden":"true",className:"absolute top-0 bottom-0 border border-accent bg-accent/10 rounded-[2px] pointer-events-none",style:{left:p-Ot,width:u-p+2*Ot}})]}),t.jsxs("span",{className:"ml-auto shrink-0 font-mono text-[11.5px] text-fg-faint","data-testid":"plan-minimap-range",children:["stages ",Math.min(s+1,c),"–",o+1," of ",c]}),t.jsxs("span",{className:"shrink-0 inline-flex border border-line rounded overflow-hidden",role:"group","aria-label":"Jump the stage window",children:[t.jsx("button",{type:"button","data-testid":"minimap-running",disabled:!d,title:d?"Scroll to the lowest stage with a running PRD":"No stage has a running PRD",onClick:()=>a(Ne(e,ot)),className:`${b} text-fg-dim hover:text-fg`,children:"Running"}),t.jsx("button",{type:"button","data-testid":"minimap-blockers",disabled:!i,title:i?"Scroll to the lowest stage with a failed / needs-review / quarantined PRD":"No stage has a failed, needs-review or quarantined PRD",onClick:()=>a(Ne(e,dt)),className:`${b} text-fg-dim hover:text-fg border-l border-line`,children:"Blockers"})]})]})}const Kn=148;function Jn({stages:e,onSeek:s}){if(e.length===0)return null;const n=e[0].n,a=e[e.length-1].n;return t.jsxs("div",{"data-testid":"further-stages",style:{width:Kn},className:"shrink-0 border-l border-rule-structural flex flex-col",children:[t.jsxs("div",{className:"h-[30px] shrink-0 flex items-center px-2 border-b border-rule-inner text-[10.5px] font-semibold uppercase tracking-wide text-fg-faint",children:["Stage ",n,"–",a]}),t.jsxs("div",{className:"h-[22px] shrink-0 flex items-center gap-1 px-2 text-[10.5px] font-semibold uppercase tracking-wide text-fg-faint",children:["Further stages",t.jsx(we,{title:"Stages beyond the visible window. Click one to scroll the stage columns to it."})]}),e.map(l=>{const d=l.rows.length===0?0:l.doneCount/l.rows.length*100;return t.jsxs("button",{type:"button","data-testid":"further-stage-row","data-stage":l.n,title:`${l.summary} — scroll to stage ${l.n}`,onClick:()=>s(l.n-1),className:"h-[26px] px-2 flex items-center gap-2 border-t border-rule-inner bg-transparent hover:bg-bg-hi cursor-pointer text-left",children:[t.jsxs("span",{className:"font-mono text-[10.5px] text-fg-dim w-[50px] whitespace-nowrap shrink-0",children:["stage ",l.n]}),t.jsx("span",{role:"progressbar","aria-valuenow":l.doneCount,"aria-valuemin":0,"aria-valuemax":l.rows.length,className:"flex-1 h-[4px] rounded-sm bg-rule-inner overflow-hidden",children:t.jsx("span",{className:"block h-full bg-sage",style:{width:`${d}%`}})})]},l.n)})]})}const Xn=[],Zn=e=>e==="running"||e==="investigating";function ea(e){const s=bn(e),n=new Map,a=new Map;for(const r of e.stages){a.set(r.n,r.rows.length);for(const c of r.rows)n.set(c.slug,c)}const l=new Map;let d=0;const i=[];for(const r of s){const c=n.get(r);d+=c.estimateMinutes??0,l.set(c.stage,(l.get(c.stage)??0)+1),i.push({row:c,totalMinutes:d,othersInStage:0})}for(const r of i)r.othersInStage=(a.get(r.row.stage)??0)-(l.get(r.row.stage)??0);return i}function ta({plan:e,now:s,indexBySlug:n,headChoicesBySlug:a,onRowFocused:l}){const d=f.useMemo(()=>ea(e),[e]);return t.jsx("div",{"data-testid":"critical-path",className:"border-t border-rule-structural max-w-[640px]",children:d.map(({row:i,totalMinutes:r,othersInStage:c})=>t.jsxs("div",{"data-testid":"critical-entry","data-slug":i.slug,children:[t.jsxs("div",{className:"flex items-start",children:[t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx(us,{row:i,elapsedMs:Zn(i.status)&&i.job.startedAt?s-Date.parse(i.job.startedAt):null,listIndex:n.get(i.slug)??0,onFocused:l,headChoices:a.get(i.slug)??Xn})}),t.jsxs("span",{"data-testid":"critical-est",className:"shrink-0 h-[31px] px-3 flex items-center gap-2 font-mono text-[11.5px] text-fg-faint border-t border-rule-inner",children:[t.jsx("span",{title:"estimateMinutes",children:i.estimateMinutes?`${i.estimateMinutes}m`:"—"}),t.jsxs("span",{className:"text-fg-dim",title:"Running total along the chain",children:["Σ ",r,"m"]})]})]}),c>0&&t.jsxs("div",{"data-testid":"critical-others",className:"h-[22px] px-3 flex items-center font-mono text-[11.5px] text-fg-faint border-t border-rule-inner",children:["stage ",i.stage," · +",c," not on the critical path"]})]},i.slug))})}const Lt=1,Ft=1350,sa={active:"border-l-accent",queued:"border-l-rule-structural",done:"border-l-sage",draft:"border-l-fg-faint/40 border-dashed"},na={active:{label:"ACTIVE",cls:"bg-accent text-white border border-accent"},queued:{label:"QUEUED",cls:"text-fg-dim border border-fg-faint"},done:{label:"DONE",cls:"text-sage-dark border border-sage"},draft:{label:"DRAFT",cls:"text-fg-faint border border-dashed border-fg-faint"}},aa=e=>String(e).padStart(2,"0");function ra({plan:e}){const s=Math.max(1,e.prdCount),n=e.doneCount/s*100,a=e.runningCount/s*100;return t.jsxs("span",{"data-testid":"plan-progress",role:"progressbar","aria-valuenow":e.doneCount,"aria-valuemin":0,"aria-valuemax":e.prdCount,className:"flex w-[160px] h-[5px] rounded-sm overflow-hidden bg-rule-inner shrink-0",children:[t.jsx("span",{className:"h-full bg-sage",style:{width:`${n}%`}}),t.jsx("span",{className:"h-full bg-accent",style:{width:`${a}%`}})]})}function ia({plan:e,mode:s="graph",now:n,hidden:a,indexBySlug:l,headChoicesBySlug:d,onRowFocused:i,onOpenPrds:r}){var te,X;const[c,o]=f.useState(e.status==="active"||e.status==="queued"),[p,u]=f.useState(!1),x=f.useRef(null),[b,h]=f.useState(0),[g,v]=f.useState(Ft),$=f.useMemo(()=>{const A=Ne(e.stages,ot);return A>=0?A:Math.max(0,Ne(e.stages,dt))},[e.stages]);f.useLayoutEffect(()=>{if(!c)return;const A=x.current,q=(A==null?void 0:A.clientWidth)||Ft,N=Math.max(0,Math.min($,e.stageCount-Math.max(1,Math.ceil(q/fe))));A!=null&&A.clientWidth&&v(A.clientWidth),A&&(A.scrollLeft=N*fe),h(N)},[c]);const P=f.useMemo(()=>{let A=null;for(const q of e.stages)for(const N of q.rows){if(!N.job.runId)continue;const k=N.job.finishedAt?Date.parse(N.job.finishedAt):0;(!A||k>A.at)&&(A={runId:N.job.runId,slug:N.slug,title:N.title,at:k})}return A},[e.stages]),J=Fe((X=(te=e.stages[0])==null?void 0:te.rows[0])==null?void 0:X.job.cwd)??"—",S=na[e.status],E=Math.max(1,Math.ceil(g/fe)),T=Math.max(0,Math.min(b-Lt,e.stageCount)),L=Math.min(e.stageCount,b+E+Lt),y=A=>{const q=Math.max(0,Math.min(e.stageCount-1,A));x.current&&(x.current.scrollLeft=q*fe),h(q)},M=Math.min(e.stageCount,b+E),D=A=>{const q=A.currentTarget,N=Math.floor(q.scrollLeft/fe);N!==b&&h(N),q.clientWidth&&q.clientWidth!==g&&v(q.clientWidth)},F="h-[24px] px-3 text-[12px] font-medium text-fg border border-rule-structural rounded-sm bg-transparent hover:bg-bg-hi cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed shrink-0",_=(()=>{switch(e.status){case"active":return t.jsx("button",{type:"button","data-testid":"plan-action",title:"Pauses the WHOLE scheduler (machine-wide) — there is no per-plan pause.",onClick:()=>{window.api.schedule.pause().catch(()=>Y.error("Failed to pause the scheduler"))},className:F,children:"Pause plan"});case"queued":return t.jsx("button",{type:"button","data-testid":"plan-action",title:"Fires the next scheduler batch machine-wide (force tick) — it does not target this plan.",onClick:()=>{window.api.schedule.forceTick().then(Y.fromOutcome).catch(()=>Y.error("Failed to fire the next batch"))},className:F,children:"Run now"});case"done":return t.jsx("button",{type:"button","data-testid":"plan-action",disabled:!P,title:P?`Open the run log of ${P.slug}, the plan's last run`:"No run log recorded for this plan",onClick:()=>u(!0),className:F,children:"View run"});case"draft":return t.jsx("button",{type:"button","data-testid":"plan-action",title:"Open the PRDs sub-view on this plan's first PRD (the PRDs view has no per-Epic filter).",onClick:()=>{var A,q;return r==null?void 0:r(((q=(A=e.stages[0])==null?void 0:A.rows[0])==null?void 0:q.slug)??null)},className:F,children:"Schedule…"})}})(),U=e.etaMs>0?` · ${rs(e.etaMs)} left`:"";return t.jsxs("section",{"data-testid":"plan-band","data-epic-id":e.epicId??"","data-plan-status":e.status,className:`border-l-[3px] ${sa[e.status]} border-b border-rule-structural`,children:[t.jsxs("div",{className:"h-[32px] flex items-center gap-2.5 px-3","data-testid":"plan-header",children:[t.jsx("button",{type:"button","aria-expanded":c,"aria-label":c?"Collapse plan":"Expand plan","data-testid":"plan-toggle",onClick:()=>o(A=>!A),className:"shrink-0 w-[14px] text-[11px] text-fg-faint hover:text-fg bg-transparent border-0 cursor-pointer p-0",children:c?"▾":"▸"}),t.jsx("span",{className:"font-mono text-[11.5px] text-fg-faint shrink-0",children:aa(e.index)}),t.jsx("span",{className:"font-serif text-[15px] font-bold text-fg truncate shrink-0 max-w-[320px]",title:e.epicLabel!==e.label?`${e.label} — ${e.epicLabel}`:e.label,"data-testid":"plan-label",children:e.label}),t.jsx("span",{"data-testid":"plan-chip",className:`shrink-0 rounded-sm px-1.5 py-[1px] text-[10px] font-bold tracking-wide ${S.cls}`,children:S.label}),t.jsx("span",{"aria-hidden":"true",className:"shrink-0 w-px h-[16px] bg-rule-structural"}),t.jsx("span",{className:"font-mono text-[11.5px] text-fg-faint truncate min-w-0","data-testid":"plan-meta",children:e.validateSlug!=null&&e.epicLabel!==e.label?t.jsxs(t.Fragment,{children:[J," · ",e.epicLabel," · ",e.prdCount," PRD",e.prdCount===1?"":"s"," · ",e.width," wide · ",e.stageCount," stage",e.stageCount===1?"":"s"]}):t.jsxs(t.Fragment,{children:[J," · ",e.prdCount," PRD",e.prdCount===1?"":"s",e.width>1?` · ${e.width} wide`:""," · ",e.stageCount," stage",e.stageCount===1?"":"s"]})}),t.jsx(we,{title:`${e.doneCount} done · ${e.runningCount} running · ${e.heldCount} held · ${e.blockedCount} blocked`}),t.jsxs("span",{className:"ml-auto font-mono text-[11.5px] text-fg-dim shrink-0","data-testid":"plan-progress-label",children:[e.doneCount,"/",e.prdCount,U]}),t.jsx(ra,{plan:e}),_]}),c&&s==="critical"&&t.jsx(ta,{plan:e,now:n,indexBySlug:l,headChoicesBySlug:d,onRowFocused:i}),c&&s!=="critical"&&e.status==="active"&&t.jsx(Qn,{stages:e.stages,first:b,perView:E,onSeek:y}),c&&s!=="critical"&&t.jsxs("div",{className:"flex border-t border-rule-structural",children:[t.jsxs("div",{ref:x,"data-testid":"plan-stages",onScroll:D,className:"flex flex-1 min-w-0 overflow-x-auto",children:[T>0&&t.jsx("div",{"aria-hidden":"true",className:"shrink-0",style:{width:T*fe}}),e.stages.slice(T,L).map(A=>t.jsx(Gn,{stage:A,epicId:e.epicId,now:n,hidden:a,indexBySlug:l,headChoicesBySlug:d,onRowFocused:i},A.n)),L<e.stageCount&&t.jsx("div",{"aria-hidden":"true",className:"shrink-0",style:{width:(e.stageCount-L)*fe}})]}),t.jsx(Jn,{stages:e.stages.slice(M),onSeek:y})]}),p&&P&&t.jsx(We,{runId:P.runId,slug:P.slug,title:P.title||P.slug,onClose:()=>u(!1)})]})}function la({section:e,children:s}){const[n,a]=f.useState(!0),l=Object.entries(e.counts).map(([d,i])=>`${i} ${d.replace(/_/g," ")}`).join(" · ");return t.jsxs("div",{className:"border-t border-line","data-testid":"backlog-epic-section","data-epic-id":e.epicId??"",children:[t.jsxs("button",{type:"button",onClick:()=>a(d=>!d),className:"w-full flex items-center gap-2.5 px-[18px] py-2.5 bg-bg-elev/60 hover:bg-bg-elev text-left","aria-expanded":n,title:e.label,children:[t.jsx("span",{className:`text-fg-faint inline-flex shrink-0 transition-transform duration-150 ${n?"rotate-90":""}`,"aria-hidden":"true",children:t.jsx(ut,{name:"chevron",size:12})}),t.jsx("span",{className:"font-serif text-[14.5px] font-semibold text-fg truncate","data-testid":"backlog-epic-label",children:e.label}),t.jsxs("span",{className:"font-mono text-[11px] text-fg-faint shrink-0",children:[e.total," PRD",e.total===1?"":"s"]}),t.jsx("span",{className:"font-mono text-[11px] text-fg-faint truncate",children:l})]}),n&&s]})}const oa=[],da=[],ca={depth:0,blockers:oa,blocked:!1,hasNeedsReviewBlocker:!1,hasMissingDep:!1,cycle:!1,parallelEligible:!1};function ua(e){return e.missing?`${e.slug} (missing)`:e.needsReview?`${e.slug} (needs review)`:`${e.slug} (${(e.status??"unknown").replace(/_/g," ")})`}function pa(e){return e.missing?"text-accent":e.needsReview?"text-butter font-semibold":e.status==="completed"?"text-sage":"text-amber-400/90"}function fa({job:e,eta:s,elapsedMs:n,avgDurationMs:a,listIndex:l,onFocused:d,hold:i,backlog:r=ca,headChoices:c=da}){const[o,p]=f.useState(!1),[u,x]=f.useState(!1),b=he(y=>y.sessions),h=f.useMemo(()=>De(e,b),[e,b]),g=h.known&&h.epicId?b[h.epicId]:null,v=f.useCallback(y=>{pt(y),window.dispatchEvent(new CustomEvent("sm:navigate",{detail:"terminal"}))},[]),$=e.status==="running",P=e.cancelled===!0,J=e.status==="failed"&&!P;let S=null;$&&n!==null?S=`${Le(n)} elapsed`:e.status==="completed"&&e.startedAt&&e.finishedAt?S=`took ${qe(Date.parse(e.finishedAt)-Date.parse(e.startedAt))}`:s&&(S=s);const E=e.error??null,T=J&&E?E.split(`
4
4
  `)[0]:e.status==="needs_review"&&e.verifierVerdict?Pe(e.verifierVerdict):null,L=$&&n!==null?Math.min(.99,n/a):0;return t.jsxs("div",{role:"listitem",className:"border-t border-line",children:[t.jsxs("button",{type:"button","data-job-row":!0,"data-job-status":e.status,"data-job-cancelled":P?"true":void 0,"data-job-index":l,"data-depth":r.depth,onClick:()=>p(y=>!y),onFocus:()=>d(l),style:r.depth>0?{paddingLeft:18+r.depth*20}:void 0,className:`w-full text-left grid grid-cols-[116px_1fr_auto_auto] items-center gap-4 px-[18px] py-3.5 hover:bg-bg/40 focus:outline-none focus:ring-1 focus:ring-accent focus:ring-inset ${o?"bg-bg-elev/40":""}`,"aria-expanded":o,"aria-label":`${oe(e.slug)?`PRD ${oe(e.slug)}, `:""}${e.title}, ${P?"cancelled":e.status}${S?`, ${S}`:""}`,title:e.title,children:[t.jsx(Qt,{status:e.status,cancelled:P}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-baseline gap-2 text-[14.5px] font-medium text-fg leading-snug",children:[oe(e.slug)&&t.jsx(Kt,{n:oe(e.slug)}),e.title,t.jsx(Jt,{leaked:e.leakedDescendants}),t.jsx(Ls,{count:e.leftoverCount,truncated:e.leftoverPathsTruncated,salvagePatch:e.salvagePatch}),r.parallelEligible&&t.jsx("span",{"data-testid":"job-row-parallel-eligible",title:"No dependsOn, and nothing in this Epic depends on it — can run any time a slot is free",className:"text-[10px] font-semibold uppercase tracking-wide text-sage/90 bg-sage/10 border border-sage/30 rounded px-1.5 py-0.5",children:"parallel"})]}),r.cycle&&t.jsxs("div",{className:"text-[12.5px] mt-0.5 text-accent font-mono","data-testid":"job-row-cycle-warning",children:["⚠ dependsOn cycle — ",r.blockers.map(y=>y.slug).join(" ↔ ")||"self-referencing"]}),!r.cycle&&r.blockers.length>0&&t.jsxs("div",{className:"text-[12.5px] mt-0.5 font-mono","data-testid":"job-row-blockers",children:[t.jsx("span",{className:r.blocked||r.hasMissingDep?"text-amber-400/90":"text-fg-faint",children:r.blocked||r.hasMissingDep?"blocked by ":"depends on "}),r.blockers.map((y,M)=>t.jsxs("span",{className:pa(y),children:[M>0&&", ",ua(y)]},y.slug))]}),T&&t.jsx("div",{className:`text-[12.5px] mt-0.5 ${J?"text-accent/80":"text-fg-faint"}`,children:T}),i&&t.jsx("div",{className:"text-[12.5px] mt-0.5 text-amber-400/90 font-mono","data-testid":"job-row-hold",children:i.dep?t.jsxs(t.Fragment,{children:["held · waiting on ",i.dep," (",i.depStatus,")"]}):t.jsxs(t.Fragment,{children:["held · ",i.reason??"launch blocked"]})}),!i&&e.status==="pending"&&e.heldReason&&t.jsxs("div",{className:"text-[12.5px] mt-0.5 text-amber-400/90 font-mono","data-testid":"job-row-held-reason",children:["held · ",e.heldReason]}),t.jsx(ft,{epicId:h.epicId,label:h.label?os(h.label):null,onOpen:v,testId:"job-row-prompt-session-chip",className:"mt-0.5"})]}),t.jsx(ht,{cwd:e.cwd}),t.jsxs("span",{className:"inline-flex items-center gap-2.5 font-mono text-xs text-fg-faint shrink-0",children:[t.jsx(Fs,{status:e.status,overrun:e.overrun}),S,t.jsx("span",{className:`text-fg-faint inline-flex transition-transform duration-150 ${o?"rotate-90":""}`,"aria-hidden":"true",children:t.jsx(ut,{name:"chevron",size:14})})]})]}),$&&!o&&t.jsx("div",{className:"h-1 bg-line mx-[18px] mb-3 rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full bg-accent transition-all duration-1000",style:{width:`${Math.max(4,L*100)}%`}})}),o&&t.jsxs("div",{className:"px-[18px] py-5 grid grid-cols-[repeat(auto-fit,minmax(160px,1fr))] gap-5 bg-bg-elev/50 border-t border-line",children:[t.jsxs(le,{label:"Status",children:[t.jsx(V,{k:"result",v:e.exitCode!==null?`exit ${e.exitCode}`:"—"}),t.jsx(V,{k:"state",v:e.status.replace(/_/g," ")}),e.verifierVerdict&&t.jsx(V,{k:"verdict",v:Pe(e.verifierVerdict)}),e.leakedDescendants&&e.leakedDescendants.length>0&&t.jsx(V,{k:"leaked",v:Xt(e.leakedDescendants),wrap:!0}),e.leftoverCount!=null&&e.leftoverCount>0&&t.jsx(V,{k:"uncommitted",v:`${e.leftoverCount} file${e.leftoverCount===1?"":"s"}${e.leftoverPathsTruncated?"+":""}: ${(e.leftoverPaths??[]).join(", ")}${e.salvagePatch?` — salvaged to ${e.salvagePatch}`:""}`,wrap:!0}),E&&t.jsx(V,{k:"error",v:E.split(`
@@ -1,4 +1,4 @@
1
- import{aT as Z,R as wo,aA as ko,aD as tr}from"./index-446b69rr.js";import"./monaco-editor-BsIlgG7c.js";function Ao(e,n){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var i,o,a,s,u=[],l=!0,f=!1;try{if(a=(r=r.call(e)).next,n===0){if(Object(r)!==r)return;l=!1}else for(;!(l=(i=a.call(r)).done)&&(u.push(i.value),u.length!==n);l=!0);}catch(h){f=!0,o=h}finally{try{if(!l&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(f)throw o}}return u}}function Co(e,n,r){return n=zo(n),n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function er(e,n){return To(e)||Ao(e,n)||ci(e,n)||Eo()}function So(e){return Mo(e)||Po(e)||ci(e)||Oo()}function Mo(e){if(Array.isArray(e))return gn(e)}function To(e){if(Array.isArray(e))return e}function Po(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function ci(e,n){if(e){if(typeof e=="string")return gn(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return gn(e,n)}}function gn(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,i=new Array(n);r<n;r++)i[r]=e[r];return i}function Oo(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
1
+ import{aT as Z,R as wo,aA as ko,aD as tr}from"./index-C6nhp7m_.js";import"./monaco-editor-BsIlgG7c.js";function Ao(e,n){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var i,o,a,s,u=[],l=!0,f=!1;try{if(a=(r=r.call(e)).next,n===0){if(Object(r)!==r)return;l=!1}else for(;!(l=(i=a.call(r)).done)&&(u.push(i.value),u.length!==n);l=!0);}catch(h){f=!0,o=h}finally{try{if(!l&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(f)throw o}}return u}}function Co(e,n,r){return n=zo(n),n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function er(e,n){return To(e)||Ao(e,n)||ci(e,n)||Eo()}function So(e){return Mo(e)||Po(e)||ci(e)||Oo()}function Mo(e){if(Array.isArray(e))return gn(e)}function To(e){if(Array.isArray(e))return e}function Po(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function ci(e,n){if(e){if(typeof e=="string")return gn(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return gn(e,n)}}function gn(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,i=new Array(n);r<n;r++)i[r]=e[r];return i}function Oo(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Eo(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
3
3
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ro(e,n){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(e)}function zo(e){var n=Ro(e,"string");return typeof n=="symbol"?n:String(n)}var No=function(n,r){var i=new Set(r);return Object.assign.apply(Object,[{}].concat(So(Object.entries(n).filter(function(o){var a=er(o,1),s=a[0];return!i.has(s)}).map(function(o){var a=er(o,2),s=a[0],u=a[1];return Co({},s,u)}))))};function yn(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,i=Array(n);r<n;r++)i[r]=e[r];return i}function Io(e){if(Array.isArray(e))return e}function $o(e){if(Array.isArray(e))return yn(e)}function Do(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function jo(e,n){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var i,o,a,s,u=[],l=!0,f=!1;try{if(a=(r=r.call(e)).next,n!==0)for(;!(l=(i=a.call(r)).done)&&(u.push(i.value),u.length!==n);l=!0);}catch(h){f=!0,o=h}finally{try{if(!l&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(f)throw o}}return u}}function Fo(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
4
4
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Lo(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
@@ -1,4 +1,4 @@
1
- import{ac as Ae,aT as u,bc as W,aD as e,b as Ie,a9 as je,q as Rn,aj as Kt,bm as In,aC as Mn,g as Un,s as $n,t as Bn,V as Fn,j as Hn,k as Gn,ao as Wn,bh as G,m as K,an as ss,al as qn,b3 as ns,aS as Kn,aw as Vn,a6 as Fs,bn as Oe,c as ye,aE as Vt,ai as Hs,bd as Et,bp as Gs,bw as zt,x as zn,a8 as Ws,B as Xn,U as qs,w as Yn,bA as Ks,T as ze,by as os,bs as Jn,aH as Qn,aL as Zn,b2 as eo,az as Vs,J as to,au as so,ap as zs,a$ as no,bi as Xs}from"./index-446b69rr.js";import{s as is,T as Me,S as Ys}from"./Toggle-Dt5K1OXt.js";import{P as qe}from"./Panel-CnfWs46Z.js";import{b as oo,c as io,T as ro}from"./TiptapBody-BdzoBmqu.js";const bt=[{id:"permissions",label:"Permissions",tab:"permissions",keys:["permissions"]},{id:"hooks",label:"Hooks",tab:"hooks",keys:["hooks","disableAllHooks","allowedHttpHookUrls","httpHookAllowedEnvVars"]},{id:"mcp",label:"MCP Servers",tab:null,keys:["enabledMcpjsonServers","disabledMcpjsonServers","enableAllProjectMcpServers"]},{id:"plugins",label:"Plugins",tab:null,keys:["enabledPlugins"]}],rs=new Set(bt.flatMap(t=>t.keys)),Js=[{id:"essentials",title:"Essentials",summary:"The knobs you reach for first.",keys:["model","language","outputStyle"]},{id:"git",title:"Git & Commits",summary:"How Claude writes commits and pull requests on your behalf.",keys:["attribution","includeGitInstructions","includeCoAuthoredBy"]},{id:"memory",title:"Memory & Plans",summary:"Context Claude keeps between sessions and where it files plans.",keys:["autoMemoryEnabled","plansDirectory","claudeMdExcludes","respectGitignore"]},{id:"model",title:"Model & Reasoning",summary:"Model allow/override lists, reasoning depth, and fast-mode toggles — machine-wide, with no per-Epic override yet. An Epic's Agent persona model (Agent Library) still wins over Essentials' plain model default.",advanced:!0,keys:["availableModels","modelOverrides","effortLevel","fastMode","fastModePerSessionOptIn","alwaysThinkingEnabled","fallbackModel","enforceAvailableModels","teammateDefaultModel","advisorModel"]},{id:"interface",title:"Interface",summary:"Visual polish — spinners, progress bars, motion.",keys:["spinnerTipsEnabled","spinnerTipsOverride","spinnerVerbs","terminalProgressBarEnabled","showTurnDuration","prefersReducedMotion","companyAnnouncements","statusLine","teammateMode"]},{id:"updates",title:"Updates & Cleanup",summary:"Release channel and how long transcripts stick around.",keys:["autoUpdatesChannel","cleanupPeriodDays"]},{id:"env",title:"Environment & Auth",summary:"Environment variables and auth-helper scripts.",keys:["env","apiKeyHelper","awsCredentialExport","awsAuthRefresh"]},{id:"hooks",title:"Hooks",summary:"Scripts Claude runs before/after tool use.",keys:["hooks","disableAllHooks","allowedHttpHookUrls","httpHookAllowedEnvVars"]},{id:"mcp",title:"MCP Servers",summary:"External tool providers Claude can talk to.",keys:["enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers"]},{id:"plugins",title:"Plugins",summary:"Installed plugins, marketplaces, and per-plugin configuration.",keys:["enabledPlugins","extraKnownMarketplaces","skippedPlugins","skippedMarketplaces","pluginConfigs"]},{id:"filesystem",title:"File Picker & Sandbox",summary:"How Claude browses files and the sandbox it runs in.",keys:["fileSuggestion","sandbox","worktree"]},{id:"login",title:"Login",summary:"Which login method to force on startup.",keys:["forceLoginMethod","forceLoginOrgUUID"]},{id:"feedback",title:"Feedback",summary:"Session-quality surveys.",keys:["feedbackSurveyRate"]},{id:"advanced",title:"Advanced / Enterprise",summary:"Managed-settings-only keys and enterprise allow/denylists.",advanced:!0,keys:["allowedMcpServers","deniedMcpServers","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","strictKnownMarketplaces","blockedMarketplaces","pluginTrustMessage","otelHeadersHelper","skipWebFetchPreflight"]}],ao={mcp:"MCP",url:"URL",urls:"URLs",http:"HTTP",ui:"UI",id:"ID",uuid:"UUID",api:"API",aws:"AWS",otel:"OTel",json:"JSON"};function Xe(t){return t.replace(/^\$/,"").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").toLowerCase().split(/\s+/).filter(Boolean).map((o,i)=>{const a=ao[o];return a||(i===0?o.charAt(0).toUpperCase()+o.slice(1):o)}).join(" ")}function Qs(t){const s=new Set,n=[];for(const i of Js){const a=i.keys.filter(r=>t.has(r)&&!rs.has(r));a.forEach(r=>s.add(r)),a.length!==0&&n.push({id:i.id,title:i.title,summary:i.summary,advanced:!!i.advanced,keys:a})}const o=Array.from(t).filter(i=>!s.has(i)&&i!=="$schema"&&!rs.has(i)).sort();return o.length>0&&n.push({id:"other",title:"Other",summary:"Keys not yet grouped.",advanced:!1,keys:o}),n}function lo(t,s){return Qs(t).map(n=>({id:n.id,title:n.title,advanced:n.advanced,total:n.keys.length,setCount:n.keys.filter(o=>s.has(o)).length}))}const Xt=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/,At="disable-model-invocation",Zs=/^\s*disable-model-invocation\s*:/;function co(t){const s=t.match(Xt);if(!s)return!1;for(const n of s[1].split(/\r?\n/)){if(!Zs.test(n))continue;const o=n.slice(n.indexOf(":")+1).trim().toLowerCase();return o==="true"||o==="yes"}return!1}function po(t){const s=t.trim();return s.length>=2&&(s[0]==='"'&&s[s.length-1]==='"'||s[0]==="'"&&s[s.length-1]==="'")?s.slice(1,-1):s}function He(t){return t.length-t.trimStart().length}function it(t){const s=t.match(Xt);if(!s)return{name:null,description:null,body:t};const n=s[1].split(/\r?\n/),o=s[2]??"";let i=null,a=null;for(let r=0;r<n.length;r++){const l=n[r],d=l.match(/^(\s*)(name|description)\s*:(.*)$/);if(!d)continue;const[,,c,p]=d,m=p.trim(),g=He(l);let h;if(m===""||m===">-"||m===">"||m==="|-"||m==="|"){const f=[];let b=r+1;for(;b<n.length&&n[b].trim()!==""&&He(n[b])>g;)f.push(n[b].trim()),b++;h=f.join(" ")}else h=po(m);c==="name"?i=h:a=h}return{name:i,description:a,body:o}}function uo(t,s){const n=t.match(Xt);if(!n){if(!s)return t;const r=t.startsWith(`
1
+ import{ac as Ae,aT as u,bc as W,aD as e,b as Ie,a9 as je,q as Rn,aj as Kt,bm as In,aC as Mn,g as Un,s as $n,t as Bn,V as Fn,j as Hn,k as Gn,ao as Wn,bh as G,m as K,an as ss,al as qn,b3 as ns,aS as Kn,aw as Vn,a6 as Fs,bn as Oe,c as ye,aE as Vt,ai as Hs,bd as Et,bp as Gs,bw as zt,x as zn,a8 as Ws,B as Xn,U as qs,w as Yn,bA as Ks,T as ze,by as os,bs as Jn,aH as Qn,aL as Zn,b2 as eo,az as Vs,J as to,au as so,ap as zs,a$ as no,bi as Xs}from"./index-C6nhp7m_.js";import{s as is,T as Me,S as Ys}from"./Toggle-C_0yUCS5.js";import{P as qe}from"./Panel-C5hihgUD.js";import{b as oo,c as io,T as ro}from"./TiptapBody-Dp2gtbb-.js";const bt=[{id:"permissions",label:"Permissions",tab:"permissions",keys:["permissions"]},{id:"hooks",label:"Hooks",tab:"hooks",keys:["hooks","disableAllHooks","allowedHttpHookUrls","httpHookAllowedEnvVars"]},{id:"mcp",label:"MCP Servers",tab:null,keys:["enabledMcpjsonServers","disabledMcpjsonServers","enableAllProjectMcpServers"]},{id:"plugins",label:"Plugins",tab:null,keys:["enabledPlugins"]}],rs=new Set(bt.flatMap(t=>t.keys)),Js=[{id:"essentials",title:"Essentials",summary:"The knobs you reach for first.",keys:["model","language","outputStyle"]},{id:"git",title:"Git & Commits",summary:"How Claude writes commits and pull requests on your behalf.",keys:["attribution","includeGitInstructions","includeCoAuthoredBy"]},{id:"memory",title:"Memory & Plans",summary:"Context Claude keeps between sessions and where it files plans.",keys:["autoMemoryEnabled","plansDirectory","claudeMdExcludes","respectGitignore"]},{id:"model",title:"Model & Reasoning",summary:"Model allow/override lists, reasoning depth, and fast-mode toggles — machine-wide, with no per-Epic override yet. An Epic's Agent persona model (Agent Library) still wins over Essentials' plain model default.",advanced:!0,keys:["availableModels","modelOverrides","effortLevel","fastMode","fastModePerSessionOptIn","alwaysThinkingEnabled","fallbackModel","enforceAvailableModels","teammateDefaultModel","advisorModel"]},{id:"interface",title:"Interface",summary:"Visual polish — spinners, progress bars, motion.",keys:["spinnerTipsEnabled","spinnerTipsOverride","spinnerVerbs","terminalProgressBarEnabled","showTurnDuration","prefersReducedMotion","companyAnnouncements","statusLine","teammateMode"]},{id:"updates",title:"Updates & Cleanup",summary:"Release channel and how long transcripts stick around.",keys:["autoUpdatesChannel","cleanupPeriodDays"]},{id:"env",title:"Environment & Auth",summary:"Environment variables and auth-helper scripts.",keys:["env","apiKeyHelper","awsCredentialExport","awsAuthRefresh"]},{id:"hooks",title:"Hooks",summary:"Scripts Claude runs before/after tool use.",keys:["hooks","disableAllHooks","allowedHttpHookUrls","httpHookAllowedEnvVars"]},{id:"mcp",title:"MCP Servers",summary:"External tool providers Claude can talk to.",keys:["enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers"]},{id:"plugins",title:"Plugins",summary:"Installed plugins, marketplaces, and per-plugin configuration.",keys:["enabledPlugins","extraKnownMarketplaces","skippedPlugins","skippedMarketplaces","pluginConfigs"]},{id:"filesystem",title:"File Picker & Sandbox",summary:"How Claude browses files and the sandbox it runs in.",keys:["fileSuggestion","sandbox","worktree"]},{id:"login",title:"Login",summary:"Which login method to force on startup.",keys:["forceLoginMethod","forceLoginOrgUUID"]},{id:"feedback",title:"Feedback",summary:"Session-quality surveys.",keys:["feedbackSurveyRate"]},{id:"advanced",title:"Advanced / Enterprise",summary:"Managed-settings-only keys and enterprise allow/denylists.",advanced:!0,keys:["allowedMcpServers","deniedMcpServers","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","strictKnownMarketplaces","blockedMarketplaces","pluginTrustMessage","otelHeadersHelper","skipWebFetchPreflight"]}],ao={mcp:"MCP",url:"URL",urls:"URLs",http:"HTTP",ui:"UI",id:"ID",uuid:"UUID",api:"API",aws:"AWS",otel:"OTel",json:"JSON"};function Xe(t){return t.replace(/^\$/,"").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").toLowerCase().split(/\s+/).filter(Boolean).map((o,i)=>{const a=ao[o];return a||(i===0?o.charAt(0).toUpperCase()+o.slice(1):o)}).join(" ")}function Qs(t){const s=new Set,n=[];for(const i of Js){const a=i.keys.filter(r=>t.has(r)&&!rs.has(r));a.forEach(r=>s.add(r)),a.length!==0&&n.push({id:i.id,title:i.title,summary:i.summary,advanced:!!i.advanced,keys:a})}const o=Array.from(t).filter(i=>!s.has(i)&&i!=="$schema"&&!rs.has(i)).sort();return o.length>0&&n.push({id:"other",title:"Other",summary:"Keys not yet grouped.",advanced:!1,keys:o}),n}function lo(t,s){return Qs(t).map(n=>({id:n.id,title:n.title,advanced:n.advanced,total:n.keys.length,setCount:n.keys.filter(o=>s.has(o)).length}))}const Xt=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/,At="disable-model-invocation",Zs=/^\s*disable-model-invocation\s*:/;function co(t){const s=t.match(Xt);if(!s)return!1;for(const n of s[1].split(/\r?\n/)){if(!Zs.test(n))continue;const o=n.slice(n.indexOf(":")+1).trim().toLowerCase();return o==="true"||o==="yes"}return!1}function po(t){const s=t.trim();return s.length>=2&&(s[0]==='"'&&s[s.length-1]==='"'||s[0]==="'"&&s[s.length-1]==="'")?s.slice(1,-1):s}function He(t){return t.length-t.trimStart().length}function it(t){const s=t.match(Xt);if(!s)return{name:null,description:null,body:t};const n=s[1].split(/\r?\n/),o=s[2]??"";let i=null,a=null;for(let r=0;r<n.length;r++){const l=n[r],d=l.match(/^(\s*)(name|description)\s*:(.*)$/);if(!d)continue;const[,,c,p]=d,m=p.trim(),g=He(l);let h;if(m===""||m===">-"||m===">"||m==="|-"||m==="|"){const f=[];let b=r+1;for(;b<n.length&&n[b].trim()!==""&&He(n[b])>g;)f.push(n[b].trim()),b++;h=f.join(" ")}else h=po(m);c==="name"?i=h:a=h}return{name:i,description:a,body:o}}function uo(t,s){const n=t.match(Xt);if(!n){if(!s)return t;const r=t.startsWith(`
2
2
  `)?"":`
3
3
  `;return`---
4
4
  ${At}: true
@@ -1,4 +1,4 @@
1
- import{aZ as ba,aT as H,R as Pt,aD as N,Q as Wf,aA as Uf,a9 as ka}from"./index-446b69rr.js";var zi={exports:{}},$i={};/**
1
+ import{aZ as ba,aT as H,R as Pt,aD as N,Q as Wf,aA as Uf,a9 as ka}from"./index-C6nhp7m_.js";var zi={exports:{}},$i={};/**
2
2
  * @license React
3
3
  * use-sync-external-store-shim.production.js
4
4
  *
@@ -1 +1 @@
1
- import{bn as g,aT as d,au as p,aD as s,bl as b}from"./index-446b69rr.js";function h(e,t){return t&&(e===t||e.startsWith(t+"/"))?"~"+e.slice(t.length):e}function v({path:e,keyPath:t,note:i}){const n=g(),[a,l]=d.useState(void 0);d.useEffect(()=>{let r=!0;const u=()=>{window.api.config.readText(e,{maxBytes:1}).then(o=>{r&&l(o.exists?o.mtimeMs:null)}).catch(()=>{r&&l(void 0)})};u();const x=window.api.config.onChanged(o=>{o.path===e&&u()});return()=>{r=!1,x()}},[e]);const f=h(e,n)+(t&&t.length?` › ${t.join(".")}`:""),c=a===void 0?"":a===null?"created on first save":p(a),m=()=>{b.getState().openFile(e),window.dispatchEvent(new CustomEvent("sm:open-editor"))};return s.jsxs("button",{type:"button","data-testid":"source-chip",title:i??`Open ${e} in the editor`,onClick:m,className:"inline-flex items-center gap-1.5 max-w-full text-[11px] px-2 py-0.5 rounded border border-line bg-bg-elev text-fg-dim hover:bg-bg-hi",children:[s.jsx("span",{className:"font-mono truncate","data-testid":"source-chip-path",children:f}),c&&s.jsxs("span",{className:"text-fg-dim/70 shrink-0","data-testid":"source-chip-age",children:["· ",c]})]})}function j({checked:e,onChange:t,label:i,disabled:n}){return s.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${n?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:[s.jsx("button",{type:"button",role:"switch","aria-checked":e,disabled:n,onClick:()=>!n&&t(!e),className:`relative inline-flex shrink-0 items-center w-8 h-[18px] rounded-full transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent ${e?"bg-accent":"bg-line"}`,children:s.jsx("span",{"data-testid":"toggle-thumb","aria-hidden":!0,className:`absolute left-0.5 top-0.5 w-3.5 h-3.5 rounded-full bg-bg-hi shadow-sm transition-transform ${e?"translate-x-3.5":"translate-x-0"}`})}),i&&s.jsx("span",{"data-testid":"toggle-label",className:"whitespace-nowrap text-fg-dim",children:i})]})}export{v as S,j as T,h as s};
1
+ import{bn as g,aT as d,au as p,aD as s,bl as b}from"./index-C6nhp7m_.js";function h(e,t){return t&&(e===t||e.startsWith(t+"/"))?"~"+e.slice(t.length):e}function v({path:e,keyPath:t,note:i}){const n=g(),[a,l]=d.useState(void 0);d.useEffect(()=>{let r=!0;const u=()=>{window.api.config.readText(e,{maxBytes:1}).then(o=>{r&&l(o.exists?o.mtimeMs:null)}).catch(()=>{r&&l(void 0)})};u();const x=window.api.config.onChanged(o=>{o.path===e&&u()});return()=>{r=!1,x()}},[e]);const f=h(e,n)+(t&&t.length?` › ${t.join(".")}`:""),c=a===void 0?"":a===null?"created on first save":p(a),m=()=>{b.getState().openFile(e),window.dispatchEvent(new CustomEvent("sm:open-editor"))};return s.jsxs("button",{type:"button","data-testid":"source-chip",title:i??`Open ${e} in the editor`,onClick:m,className:"inline-flex items-center gap-1.5 max-w-full text-[11px] px-2 py-0.5 rounded border border-line bg-bg-elev text-fg-dim hover:bg-bg-hi",children:[s.jsx("span",{className:"font-mono truncate","data-testid":"source-chip-path",children:f}),c&&s.jsxs("span",{className:"text-fg-dim/70 shrink-0","data-testid":"source-chip-age",children:["· ",c]})]})}function j({checked:e,onChange:t,label:i,disabled:n}){return s.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${n?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:[s.jsx("button",{type:"button",role:"switch","aria-checked":e,disabled:n,onClick:()=>!n&&t(!e),className:`relative inline-flex shrink-0 items-center w-8 h-[18px] rounded-full transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent ${e?"bg-accent":"bg-line"}`,children:s.jsx("span",{"data-testid":"toggle-thumb","aria-hidden":!0,className:`absolute left-0.5 top-0.5 w-3.5 h-3.5 rounded-full bg-bg-hi shadow-sm transition-transform ${e?"translate-x-3.5":"translate-x-0"}`})}),i&&s.jsx("span",{"data-testid":"toggle-label",className:"whitespace-nowrap text-fg-dim",children:i})]})}export{v as S,j as T,h as s};
@@ -1 +1 @@
1
- import{bB as o,bz as m,ah as j,aD as e,b4 as l,by as b,aG as R}from"./index-446b69rr.js";let u=0;const T=1e3;function y(n){const s=performance.now();s-u<T||(u=s,R.debug("voice","mic.gate.click_rejected",{reason:n}))}function k(){const n=o(t=>t.isRecording),s=o(t=>t.error),i=o(t=>t.loadingProgress),r=o(m(l)),x=()=>{const t=o.getState(),{canRecord:h,reason:a}=l(t);if(t.isRecording)return t.stopRecording();if(t.wizardArmed&&!t.wizardOpen){t.openWizard();return}if(a==="error"||a==="load-timeout"){t.resetAndRetryModel();return}if(!h)return y(a);const c=b.getState().activeTabId;c&&t.startRecording(c)},d=j(r.reason,{loadingPct:i,errorMessage:s,isRecording:n}),g=r.reason==="unsupported",p=!r.canRecord,f=r.reason==="loading"?"text-fg-faint animate-pulse cursor-wait":r.reason==="error"||r.reason==="load-timeout"?"text-red-400 cursor-pointer":r.reason==="permission-denied"?"text-amber-400 cursor-pointer":r.reason==="idle"?"text-fg-faint cursor-pointer":r.reason==="unsupported"?"text-fg-faint cursor-not-allowed":n?"text-red-400 ring-2 ring-red-400 animate-pulse":"text-fg-dim hover:text-fg";return e.jsx("button",{onClick:x,disabled:g,"aria-disabled":p,"aria-label":d,title:d,"data-testid":"mic-button","data-state":r.reason,className:`p-1.5 rounded transition-colors ${f}`,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"9",y:"1",width:"6",height:"12",rx:"3"}),e.jsx("path",{d:"M5 10a7 7 0 0 0 14 0"}),e.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"}),e.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"})]})})}function v(){const n=o(i=>i.ttsEnabled),s=o(i=>i.toggleTTS);return e.jsxs("button",{onClick:s,title:n?"Read Claude replies aloud: ON":"Read Claude replies aloud: OFF",className:`px-1.5 py-1 rounded transition-colors flex items-center gap-1 ${n?"text-accent":"text-fg-dim hover:text-fg"}`,children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),n?e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),e.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}):e.jsxs(e.Fragment,{children:[e.jsx("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),e.jsx("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]})]}),e.jsx("span",{className:"text-[10px] font-medium tracking-wide",children:"TTS"})]})}export{v as T,k as V};
1
+ import{bB as o,bz as m,ah as j,aD as e,b4 as l,by as b,aG as R}from"./index-C6nhp7m_.js";let u=0;const T=1e3;function y(n){const s=performance.now();s-u<T||(u=s,R.debug("voice","mic.gate.click_rejected",{reason:n}))}function k(){const n=o(t=>t.isRecording),s=o(t=>t.error),i=o(t=>t.loadingProgress),r=o(m(l)),x=()=>{const t=o.getState(),{canRecord:h,reason:a}=l(t);if(t.isRecording)return t.stopRecording();if(t.wizardArmed&&!t.wizardOpen){t.openWizard();return}if(a==="error"||a==="load-timeout"){t.resetAndRetryModel();return}if(!h)return y(a);const c=b.getState().activeTabId;c&&t.startRecording(c)},d=j(r.reason,{loadingPct:i,errorMessage:s,isRecording:n}),g=r.reason==="unsupported",p=!r.canRecord,f=r.reason==="loading"?"text-fg-faint animate-pulse cursor-wait":r.reason==="error"||r.reason==="load-timeout"?"text-red-400 cursor-pointer":r.reason==="permission-denied"?"text-amber-400 cursor-pointer":r.reason==="idle"?"text-fg-faint cursor-pointer":r.reason==="unsupported"?"text-fg-faint cursor-not-allowed":n?"text-red-400 ring-2 ring-red-400 animate-pulse":"text-fg-dim hover:text-fg";return e.jsx("button",{onClick:x,disabled:g,"aria-disabled":p,"aria-label":d,title:d,"data-testid":"mic-button","data-state":r.reason,className:`p-1.5 rounded transition-colors ${f}`,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"9",y:"1",width:"6",height:"12",rx:"3"}),e.jsx("path",{d:"M5 10a7 7 0 0 0 14 0"}),e.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"}),e.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"})]})})}function v(){const n=o(i=>i.ttsEnabled),s=o(i=>i.toggleTTS);return e.jsxs("button",{onClick:s,title:n?"Read Claude replies aloud: ON":"Read Claude replies aloud: OFF",className:`px-1.5 py-1 rounded transition-colors flex items-center gap-1 ${n?"text-accent":"text-fg-dim hover:text-fg"}`,children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),n?e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),e.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}):e.jsxs(e.Fragment,{children:[e.jsx("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),e.jsx("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]})]}),e.jsx("span",{className:"text-[10px] font-medium tracking-wide",children:"TTS"})]})}export{v as T,k as V};
@@ -1 +1 @@
1
- import{bE as s}from"./index-446b69rr.js";function a(t){const e=Number.isFinite(t)?t:0,r=Math.abs(e)<1?4:2;return`$${e.toFixed(r)}`}function u(t){const e=Number.isFinite(t)?t:0,r=Math.abs(e);return r>=1e9?`${(e/1e9).toFixed(1)}B`:r>=1e6?`${(e/1e6).toFixed(1)}M`:r>=1e3?`${(e/1e3).toFixed(1)}K`:`${Math.round(e)}`}function f(t){const e=Number.isFinite(t)?t:0;return Math.round(e).toLocaleString("en-US")}function m(t){const e=Math.max(0,Math.round(Number.isFinite(t)?t:0));if(e<60)return`${e}m`;const r=Math.floor(e/60),n=e%60;return n===0?`${r}h`:`${r}h ${n}m`}function h(t){return Number.isFinite(t)?t>0&&t<1?"<1%":`${t.toFixed(1)}%`:"0.0%"}async function l(t,e=5e3){try{return{ok:!0,data:await s(Promise.resolve().then(()=>window.api.history.dashboard({rangeDays:t})),e,"history.dashboard")}}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}}function c(t){return`${a(t.costUsd)} · ${u(t.tokens)} tok`}function b(t,e){const r=e!=null&&e.day?t.days.filter(o=>o.date===e.day).flatMap(o=>Object.values(o.byProject)):[t.totals];let n=0,i=0;for(const o of r)n+=o.estimatedCostUsd,i+=o.inputTokens+o.outputTokens+o.cacheReadTokens+o.cacheCreationTokens;return{costUsd:n,tokens:i,label:c({costUsd:n,tokens:i})}}export{c as a,l as f,f as i,m,h as p,b as s,u as t,a as u};
1
+ import{bE as s}from"./index-C6nhp7m_.js";function a(t){const e=Number.isFinite(t)?t:0,r=Math.abs(e)<1?4:2;return`$${e.toFixed(r)}`}function u(t){const e=Number.isFinite(t)?t:0,r=Math.abs(e);return r>=1e9?`${(e/1e9).toFixed(1)}B`:r>=1e6?`${(e/1e6).toFixed(1)}M`:r>=1e3?`${(e/1e3).toFixed(1)}K`:`${Math.round(e)}`}function f(t){const e=Number.isFinite(t)?t:0;return Math.round(e).toLocaleString("en-US")}function m(t){const e=Math.max(0,Math.round(Number.isFinite(t)?t:0));if(e<60)return`${e}m`;const r=Math.floor(e/60),n=e%60;return n===0?`${r}h`:`${r}h ${n}m`}function h(t){return Number.isFinite(t)?t>0&&t<1?"<1%":`${t.toFixed(1)}%`:"0.0%"}async function l(t,e=5e3){try{return{ok:!0,data:await s(Promise.resolve().then(()=>window.api.history.dashboard({rangeDays:t})),e,"history.dashboard")}}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}}function c(t){return`${a(t.costUsd)} · ${u(t.tokens)} tok`}function b(t,e){const r=e!=null&&e.day?t.days.filter(o=>o.date===e.day).flatMap(o=>Object.values(o.byProject)):[t.totals];let n=0,i=0;for(const o of r)n+=o.estimatedCostUsd,i+=o.inputTokens+o.outputTokens+o.cacheReadTokens+o.cacheCreationTokens;return{costUsd:n,tokens:i,label:c({costUsd:n,tokens:i})}}export{c as a,l as f,f as i,m,h as p,b as s,u as t,a as u};