claude-code-session-manager 0.139.0 → 0.141.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -4
- package/dist/assets/AppSettings-DExeJhqQ.js +2 -0
- package/dist/assets/History-DJMiuXyK.js +2 -0
- package/dist/assets/{HomeClaudeConfig-CGD2Onjv.js → HomeClaudeConfig-CTp2tkZ4.js} +2 -2
- package/dist/assets/{Panel-Csyd9HbD.js → Panel-Bf1Cf8UL.js} +1 -1
- package/dist/assets/{ProjectClaudeConfig-C-jlYpC_.js → ProjectClaudeConfig-BWPpypf9.js} +1 -1
- package/dist/assets/Scheduler-cyr61UAC.js +16 -0
- package/dist/assets/{SkillReferenceGraph-DcscPXAG.js → SkillReferenceGraph-Ba4TkX2C.js} +1 -1
- package/dist/assets/{Skills-BpGRKOcY.js → Skills-C1v91GEO.js} +26 -26
- package/dist/assets/{TiptapBody-DSU3769X.js → TiptapBody-BrcWVpiW.js} +1 -1
- package/dist/assets/{ViewTabs-C0PRZx4_.js → ViewTabs-DXhOWFG0.js} +1 -1
- package/dist/assets/{VoiceButton-D2rMurNg.js → VoiceButton-qivnDV6K.js} +1 -1
- package/dist/assets/{historyTotals-TcIQs2sh.js → historyTotals-CMCPTKqC.js} +1 -1
- package/dist/assets/index-B2TQz3nd.js +3121 -0
- package/dist/assets/{index-BCySPdtU.css → index-DKXdXfka.css} +1 -1
- package/dist/index.html +2 -2
- package/dist-web/app.css +1 -1
- package/dist-web/app.js +423 -426
- package/package.json +5 -2
- package/plugins/AGENTS.md +60 -0
- package/plugins/CLAUDE.md +1 -60
- package/plugins/session-manager-dev/skills/builder/SKILL.md +4 -2
- package/plugins/session-manager-dev/skills/develop/SKILL.md +29 -19
- package/plugins/session-manager-dev/skills/maintaining-md-network/SKILL.md +5 -4
- package/plugins/session-manager-dev/skills/maintaining-md-network/audit.md +4 -2
- package/plugins/session-manager-dev/skills/maintaining-md-network/drift-check.md +16 -12
- package/plugins/session-manager-dev/skills/maintaining-md-network/migrate-to-agents-md.md +15 -0
- package/plugins/session-manager-dev/skills/maintaining-md-network/placement.md +50 -2
- package/plugins/session-manager-dev/skills/maintaining-md-network/plan.md +10 -10
- package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/drift-check.cjs +117 -112
- package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/mdDuplicates.cjs +182 -0
- package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/mdLinks.cjs +340 -0
- package/scripts/README.md +1 -0
- package/scripts/hooks/guard-tool-risk.cjs +91 -0
- package/scripts/hooks/lib/guard-tool-risk-policy.cjs +217 -0
- package/scripts/ops-sweep.cjs +53 -23
- package/scripts/scheduler-mcp-server.cjs +205 -18
- package/src/main/build-info.json +4 -4
- package/src/main/config.cjs +112 -8
- package/src/main/docEdit.cjs +6 -1
- package/src/main/files.cjs +7 -27
- package/src/main/health.cjs +48 -15
- package/src/main/historyAggregator.cjs +88 -5
- package/src/main/historyDashboard.cjs +69 -4
- package/src/main/index.cjs +56 -2
- package/src/main/ipcSchemas.cjs +122 -16
- package/src/main/lib/AGENTS.md +54 -0
- package/src/main/lib/CLAUDE.md +1 -54
- package/src/main/lib/agent-cli/adapters/codex.cjs +5 -2
- package/src/main/lib/agent-cli/agentCliIpc.cjs +18 -2
- package/src/main/lib/agent-cli/agentCliSessionStore.cjs +1 -0
- package/src/main/lib/agent-cli/agentCliTurn.cjs +20 -2
- package/src/main/lib/agent-cli/geminiContextDefaults.cjs +94 -0
- package/src/main/lib/claude/effectiveModelInfo.cjs +90 -20
- package/src/main/lib/claude/jobSandboxPolicy.cjs +202 -0
- package/src/main/lib/claude/personaToolScope.cjs +12 -6
- package/src/main/lib/claude/rateLimitDetect.cjs +13 -2
- package/src/main/lib/claude/runClaudeP.cjs +6 -1
- package/src/main/lib/claude/toolRiskIpc.cjs +177 -0
- package/src/main/lib/claude/toolRiskMarks.cjs +373 -0
- package/src/main/lib/demo-video-kit/seedKit.cjs +27 -6
- package/src/main/lib/ephemeralCwd.cjs +37 -2
- package/src/main/lib/epic/delegationReadiness.cjs +42 -9
- package/src/main/lib/epic/epicAdminRoutes.cjs +25 -5
- package/src/main/lib/epic/epicOutsideRead.cjs +118 -1
- package/src/main/lib/epic/epicOutsideState.cjs +2 -2
- package/src/main/lib/epic/epicSweepValidator.cjs +7 -2
- package/src/main/lib/epic/epicValidationHook.cjs +24 -4
- package/src/main/lib/epic/guardSpawnSettings.cjs +57 -1
- package/src/main/lib/externalContract.cjs +31 -5
- package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +55 -1
- package/src/main/lib/feedback-remote/crossProjectReply.cjs +106 -11
- package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +47 -19
- package/src/main/lib/feedback-remote/needsYouStore.cjs +6 -2
- package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +98 -1
- package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +5 -0
- package/src/main/lib/git/branchSweep.cjs +209 -4
- package/src/main/lib/git/gitWorktree.cjs +41 -5
- package/src/main/lib/guardShims.cjs +1 -1
- package/src/main/lib/historyRollup.cjs +26 -0
- package/src/main/lib/insideHome.cjs +27 -1
- package/src/main/lib/mcpToolCatalog.cjs +132 -13
- package/src/main/lib/mdDocCensus.cjs +59 -78
- package/src/main/lib/mdDocRefs.cjs +71 -93
- package/src/main/lib/mdNetworkScan.cjs +245 -250
- package/src/main/lib/mdReviewRecord.cjs +22 -9
- package/src/main/lib/memoryMdNetwork.cjs +5 -12
- package/src/main/lib/opsOwnership.cjs +18 -2
- package/src/main/lib/opsRetentionSettings.cjs +28 -4
- package/src/main/lib/persona-macro/macroJobDispatch.cjs +90 -20
- package/src/main/lib/persona-macro/macroJobIpc.cjs +144 -46
- package/src/main/lib/persona-macro/macroJobStatus.cjs +87 -9
- package/src/main/lib/persona-macro/macroLibrary.cjs +95 -5
- package/src/main/lib/persona-macro/personaImportHealth.cjs +78 -17
- package/src/main/lib/persona-macro/projectVideoToolCheck.cjs +96 -0
- package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +11 -0
- package/src/main/lib/prd/depSlugResolve.cjs +104 -4
- package/src/main/lib/prd/prdAdminRoutes.cjs +35 -2
- package/src/main/lib/prd/prdCreate.cjs +377 -23
- package/src/main/lib/prd/prdDisposition.cjs +11 -2
- package/src/main/lib/prd/prdFrontmatter.cjs +121 -3
- package/src/main/lib/process/loginItem.cjs +171 -0
- package/src/main/lib/process/loginItemPlan.cjs +193 -0
- package/src/main/lib/project-pages/playerBridge.cjs +4 -0
- package/src/main/lib/project-pages/videoReview.cjs +268 -0
- package/src/main/lib/project-pages/videoReviewIpc.cjs +229 -0
- package/src/main/lib/scheduler/cpuSample.cjs +131 -4
- package/src/main/lib/scheduler/fixPlanSlug.cjs +4 -3
- package/src/main/lib/scheduler/loadGate.cjs +24 -6
- package/src/main/lib/scheduler/planRecordHarvest.cjs +108 -0
- package/src/main/lib/scheduler/planRecordRetention.cjs +144 -0
- package/src/main/lib/scheduler/preflightCheck.cjs +97 -0
- package/src/main/lib/scheduler/queueStore.cjs +7 -0
- package/src/main/lib/scheduler/rcaReport.cjs +21 -1
- package/src/main/lib/scheduler/reaperHelpers.cjs +35 -5
- package/src/main/lib/scheduler/reviewNotice.cjs +39 -0
- package/src/main/lib/scheduler/runLogRetention.cjs +104 -3
- package/src/main/lib/scheduler/scheduleJobSchema.cjs +3 -0
- package/src/main/lib/scheduler/schedulerBatch.cjs +25 -48
- package/src/main/lib/scheduler/schedulerPaths.cjs +3 -0
- package/src/main/lib/scheduler/sessionSlots.cjs +176 -21
- package/src/main/lib/scheduler/validationQuality.cjs +282 -0
- package/src/main/lib/scheduler/validatorVerdictSchema.cjs +254 -0
- package/src/main/lib/tasks/taskAdminRoutes.cjs +641 -0
- package/src/main/lib/tasks/taskIpc.cjs +80 -0
- package/src/main/lib/tasks/taskLedger.cjs +502 -0
- package/src/main/lib/tasks/taskRun.cjs +313 -0
- package/src/main/lib/tasks/taskSwitch.cjs +120 -0
- package/src/main/loginItemIpc.cjs +35 -0
- package/src/main/loopEfficiencyHandlers.cjs +10 -1
- package/src/main/projectPages.cjs +6 -15
- package/src/main/promptSessionEvents.cjs +9 -1
- package/src/main/queueOps.cjs +260 -3
- package/src/main/runVerify.cjs +53 -25
- package/src/main/scheduler/AGENTS.md +26 -0
- package/src/main/scheduler/CLAUDE.md +1 -26
- package/src/main/scheduler/budget.cjs +239 -9
- package/src/main/scheduler/cancelDependents.cjs +154 -0
- package/src/main/scheduler/prdParser.cjs +19 -1
- package/src/main/scheduler/reviewLadder.cjs +36 -3
- package/src/main/scheduler/starvation.cjs +89 -18
- package/src/main/scheduler.cjs +1080 -89
- package/src/main/supervisor.cjs +5 -1
- package/src/main/templates/PRD_AUTHORING.md +14 -1
- package/src/main/validationQualityHandlers.cjs +199 -0
- package/src/main/webRemote.cjs +10 -2
- package/src/preload/api.d.ts +364 -21
- package/src/preload/apiSurface.json +89 -10
- package/src/preload/index.cjs +23 -2
- package/src/seed/agents/validator.md +19 -8
- package/dist/assets/AppSettings-CUfWY9vN.js +0 -2
- package/dist/assets/History-DDnqaLyw.js +0 -2
- package/dist/assets/Scheduler-NLs08fx7.js +0 -16
- package/dist/assets/index-C-d0DCre.js +0 -3124
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{aY as Me,ad as _e,aK as le,aq as Le,b6 as ks,ab as Ss,av as Ce,ap as fe,at as ne,ba as W,bs as Be,br as he,bv as Ht,aR as f,an as me,bB as $s,aB as t,d as Qe,I as be,L as kt,r as Cs,K as ue,w as Ps,Y as Ms,f as Ds,_ as As,b5 as Rs,bp as it,bi as Is,b0 as Ts,ak as St,aI as Wt,bA as Pe,T as He,aP as Oe,b as lt,b4 as ot,X as Ut,G as Gt,q as Vt,s as Es,n as dt,Q as ct,O as _s,h as ie,i as H,ar as zt,bt as Ls,aQ as Os,z as Fs,aT as Qt,bE as Yt,a0 as qs,aW as Ye,aL as $t,bj as Ct,m as Se,N as Pt,a_ as Mt,l as Bs,b8 as Hs,a7 as Ws,x as Kt,Z as Us,by as Jt,ag as Gs,bw as Dt,b3 as Vs}from"./index-B2TQz3nd.js";import{f as zs,a as Qs,s as Ys,u as Xt}from"./historyTotals-CMCPTKqC.js";import"./monaco-editor-BsIlgG7c.js";function Ks(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 Js(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 Xs(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 h=Js(o,s),w=n.has(o.slug);u.add(o.slug);const x=w?[]:(d.get(o.slug)??[]).filter(m=>!u.has(m.slug)).map(m=>c(m,p+1,u));return u.delete(o.slug),{row:o,depth:p,children:x,blockers:h,blocked:h.some(m=>!m.missing&&m.status!=="completed"),hasNeedsReviewBlocker:h.some(m=>m.needsReview),hasMissingDep:h.some(m=>m.missing),cycle:w,parallelEligible:(o.dependsOn??[]).length===0&&!l.has(o.slug)}}return i.map(o=>c(o,0,new Set))}function Zt(e,s,n){const a=new Map((n??e).map(o=>[o.slug,o])),l=Ks(e),d=[],i=new Map,r=new Map;for(const o of e){const p=Me(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),h=Xs(u,a,l),w={};for(const x of u){const m=x.status??"unknown";w[m]=(w[m]??0)+1}return{epicId:p.epicId,label:p.label,known:p.known,nodes:h,counts:w,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 We(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 Zs=15e4,st=e=>e==="completed"||e==="skipped",$e=e=>e==="running"||e==="investigating",en=e=>e==="failed"||e==="needs_review"||e==="quarantined",tn=e=>e==="failed"||e==="needs_review"||e==="quarantined";function es(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 ts(e,s){const n=e.estimateMinutes?e.estimateMinutes*6e4:null;return n?`${Math.min(99,Math.floor(s/n*100))}%`:Le(s)}function sn(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?Zs:s/n}function Fe(e){const s=le(e);return s===null?1/0:Number(s)}function nt(e,s){const n=Fe(e.slug)-Fe(s.slug);return n!==0&&!Number.isNaN(n)?n:e.slug.localeCompare(s.slug)}function nn(e){let s=0;for(const n of e.statusHistory??[])n.to==="pending"&&n.from!==null&&s++;return s}function an(e){return e.some(n=>$e(n.status))?"active":e.every(n=>st(n.status))?"done":e.filter(n=>n.status!=="quarantined").length===0?"draft":"queued"}function rn(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 ln(e,s){return e._firstNum!==s._firstNum?e._firstNum<s._firstNum?-1:1:e._firstSlug.localeCompare(s._firstSlug)}function on(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 dn(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 on(e,s)}function cn(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 un(e,s){const n=new Map(e.map(r=>[r.row.slug,r])),a=new Set,l=[],d=e.filter(r=>Ss(r.row.slug).startsWith("validate-")).sort((r,c)=>nt({slug:r.row.slug},{slug:c.row.slug}));for(const r of d)a.has(r.row.slug)||l.push({nodes:cn(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 dn(i,r))l.push({nodes:c,validateSlug:null})}return l}function pn(e){return e.replace(/^validate[\s:-]*/i,"").trim()}function ut(e,s){if(e.length===0)return[];const n=_e(e),a=s.now??Date.now(),l=s.avgDurationMs??sn(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(h=>i.get(h)===void 0||i.get(h).status==="completed"),c=new Map;n.filter(r).sort(nt).forEach((u,h)=>c.set(u.slug,h));const o=Zt(n,s.sessions,n),p=[];for(const u of o){const h=We(u.nodes),w=new Set(h.map(P=>P.row.slug)),x=new Map(h.map(P=>[P.row.slug,P])),m=[];for(const P of un(h,w)){const $=P.nodes,_=new Set($.map(S=>S.row.slug)),g=new Map,y=new Set,j=S=>{const M=x.get(S);return(M.row.dependsOn??[]).filter(B=>_.has(B)&&!(M.cycle&&x.get(B).cycle))},C=S=>{const M=g.get(S);if(M!==void 0)return M;if(y.has(S))return 0;y.add(S);let B=0;for(const V of j(S))B=Math.max(B,C(V));return y.delete(S),g.set(S,B+1),B+1};for(const S of $)C(S.row.slug);const A=$.map(S=>{const M=S.row,B=(M.dependsOn??[]).filter(V=>w.has(V));return{slug:M.slug,title:M.title,status:M.status,stage:g.get(M.slug),prdNumber:le(M.slug),rowKind:"dep",rowTrailing:"",cycle:S.cycle,estimateMinutes:M.estimateMinutes??null,deps:B,crossEpicDeps:(M.dependsOn??[]).filter(V=>!w.has(V)),blockers:S.blockers,job:M}});A.sort(nt);const F=A.reduce((S,M)=>Math.max(S,M.stage),0),G=new Map;for(const S of A){const M=S.job,B=x.get(S.slug),V=M.status;let Y;if(st(V)){const b=M.startedAt&&M.finishedAt?Date.parse(M.finishedAt)-Date.parse(M.startedAt):NaN;Y={kind:"done",trailing:b>0?Le(b):"",held:!1,blocked:!1}}else if($e(V)){const b=M.startedAt?Math.max(0,a-Date.parse(M.startedAt)):null;Y={kind:"running",trailing:b===null?"":ts(M,b),held:!1,blocked:!1}}else if(V==="failed")Y={kind:"failed",trailing:"failed",held:!1,blocked:!1};else if(V==="needs_review")Y={kind:"review",trailing:"review",held:!1,blocked:!1};else if(V==="quarantined")Y={kind:"quarantined",trailing:"quarantined",held:!1,blocked:!1};else{const b=B.blockers.filter(k=>!k.missing&&k.status!=="completed");if(b.length>0){const k=b.some(D=>tn(D.status)),R=b[0].slug;Y={kind:"dep",trailing:`←${le(R)??R}`,held:!k,blocked:k}}else if(M.heldReason)Y={kind:"gate",trailing:"gate",held:!0,blocked:!1};else{const k=nn(M),R=c.get(M.slug)??0;Y=k>0?{kind:"retry",trailing:`${k} ${k===1?"retry":"retries"}`,held:!1,blocked:!1}:{kind:"eta",trailing:es(R*l/d),held:!1,blocked:!1}}}G.set(S.slug,Y)}const z=[];for(let S=1;S<=F;S++){const M=A.filter(L=>L.stage===S),B=M.find(L=>{const te=G.get(L.slug).kind;return L.status==="pending"&&(te==="eta"||te==="retry")});if(B){const L=G.get(B.slug);L.kind="next",L.trailing="next"}let V=0,Y=0,b=0,k=0,R=0,D=0;for(const L of M){const te=G.get(L.slug);L.rowKind=te.kind,L.rowTrailing=te.trailing,st(L.status)?V++:$e(L.status)?Y++:L.status==="pending"?(R++,te.held&&b++,te.blocked&&k++):en(L.status)&&D++}const T=V===M.length?"done":Y>0?"running":k+D>0?"blocked":b>0?"held":"pending",O={n:S,rows:M,doneCount:V,runningCount:Y,heldCount:b,blockedCount:k};z.push({...O,state:T,summary:rn(T,O,R,D)})}let K=0;for(const S of A){const M=S.estimateMinutes?S.estimateMinutes*6e4:l;if(S.status==="pending")K+=M;else if($e(S.status)){const B=S.job.startedAt?Math.max(0,a-Date.parse(S.job.startedAt)):0;K+=Math.max(0,M-B)}}const X=A.reduce((S,M)=>Math.min(S,Fe(M.slug)),1/0),ee=A.reduce((S,M)=>Math.max(S,Fe(M.slug)),-1/0),Q=u.known?ks(u.label).title:u.label,I=P.validateSlug?A.find(S=>S.slug===P.validateSlug):void 0,q=I&&pn(I.title)||Q;m.push({epicId:u.epicId,waveIndex:0,index:0,label:q,epicLabel:Q,validateSlug:P.validateSlug,width:z.reduce((S,M)=>Math.max(S,M.rows.length),0),status:an(A),prdCount:A.length,stageCount:F,doneCount:z.reduce((S,M)=>S+M.doneCount,0),runningCount:z.reduce((S,M)=>S+M.runningCount,0),heldCount:z.reduce((S,M)=>S+M.heldCount,0),blockedCount:z.reduce((S,M)=>S+M.blockedCount,0),etaMs:K/d,stages:z,_firstNum:X,_lastNum:ee,_firstSlug:A[0].slug})}m.sort(ln),m.forEach((P,$)=>{P.waveIndex=$+1});const N=m.filter(P=>P.validateSlug===null);N.forEach((P,$)=>{N.length>1&&(P.label=`${P.label} · plan ${$+1}/${N.length}`)});for(const P of m)p.push(P)}return p.sort((u,h)=>{if(u._lastNum!==h._lastNum)return u._lastNum>h._lastNum?-1:1;const w=(u.epicId??"").localeCompare(h.epicId??"");return w!==0?w:u.waveIndex-h.waveIndex}),p.map(({_firstNum:u,_lastNum:h,_firstSlug:w,...x},m)=>({...x,index:m+1}))}function fn(e,s=Date.now()){const n=_e(e),a=new Map(n.map(x=>[x.slug,x])),l=new Date(s).toDateString();let d=0,i=0,r=0,c=0,o=0,p=0,u=0;for(const x of n)x.status==="pending"?(i++,(x.dependsOn??[]).every(N=>a.get(N)===void 0||a.get(N).status==="completed")&&d++):$e(x.status)?u++:x.status==="failed"?r++:x.status==="needs_review"?c++:x.status==="quarantined"?o++:x.status==="completed"&&x.finishedAt&&new Date(Date.parse(x.finishedAt)).toDateString()===l&&p++;let h=null;const w=r+o;if(w>0){for(const x of ut(n,{sessions:{},now:s}))for(const m of x.stages)if(m.rows.some(N=>N.status==="failed"||N.status==="quarantined")){(h===null||m.n<h)&&(h=m.n);break}}return{readyNow:d,totalQueued:i,heldByDeps:i-d,needsYou:w,needsYouStage:h,failedCount:r,needsReviewCount:c,doneToday:p,inFlight:u}}function hn(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 h=null;for(const x of p.deps){if(!s.has(x)||p.cycle&&n(x))continue;const m=i(x);(!h||d(m,h))&&(h=m)}l.delete(c);const w=h?{chain:[...h.chain,c],est:h.est+u}:{chain:[c],est:u};return a.set(c,w),w};let r=null;for(const c of s.keys()){const o=i(c);(!r||d(o,r))&&(r=o)}return r?r.chain:[]}const xn=300*6e4,gn={five_hour:"5-hour",session:"5-hour",weekly_all:"weekly",weekly:"weekly"};function mn(e){return gn[e]??e.replace(/_/g," ")}function ss({snap:e,now:s,avgDurationMs:n,runningJobs:a}){const{config:l,jobs:d,paused:i,nextReset:r,utilization:c,utilizationWindow:o,effectiveConcurrency:p}=e;let u=0,h=0;for(const $ of d)$.status==="pending"?u++:$.status==="completed"&&h++;const w=a.length,x=u+w,m=(p==null?void 0:p.cap)??5;if(w>0){const $=a.reduce((C,A)=>(C.startedAt??"")<(A.startedAt??"")?C:A),_=$.startedAt?s-Date.parse($.startedAt):0,g=h+w,y=h+x,j=w>1?` · ${w}/${m} parallel`:"";return{kind:"running",line1:`Running ${g}/${y}${j} · ${Ce(_)}`,line2:w===1?$.title:a.map(C=>C.title).join(", "),tooltip:a.map(C=>`${C.slug} (g${C.parallelGroup})`).join("; ")}}if(i){const $=i.resumeAt?Date.parse(i.resumeAt)-s:null;return{kind:"paused",line1:{rate_limit:"Paused — tokens exhausted",auth:"Paused — authentication failed",network:"Paused — network unreachable",reset_failure:"Paused — billing data unavailable",manual:"Paused — manual (you paused the queue)"}[i.reason]??`Paused — ${i.reason}`,line2:i.reason==="auth"?"Run `claude` in any terminal to refresh credentials, then Resume":$!==null&&$>0?`auto-resume ${fe(Date.parse(i.resumeAt))} (in ${ne($)})`:i.resumeAt?"resuming…":"no auto-resume scheduled",tooltip:i.resumeAt??"",action:{label:"Resume",onClick:()=>window.api.schedule.resume(),title:"Clear the pause and resume queue immediately"}}}if(x===0)return{kind:"idle",line1:"No work queued",line2:null};if((l.firePolicy??"when-available")==="manual")return{kind:"manual",line1:`Manual · ${u} pending`,line2:"click Fire next batch now to fire",action:{label:"Fire next batch now",onClick:()=>window.api.schedule.forceTick().then(W.fromOutcome).catch(()=>W.error("Failed to fire batch")),title:"Bypasses the billing-usage poll. Use when the meter is rate-limited or you want immediate progress."}};const P=l.utilizationThreshold??90;if(c==null)return{kind:"auto-soon",line1:`Auto · ${u} pending`,line2:"checking token availability…"};if(c>=P){const $=r?Date.parse(r)-s:null,_=o?mn(o):null,g=$===null||Number.isNaN($)||$>xn,y=$&&$>0?`resets ${fe(Date.parse(r))} (in ${ne($)})`:null;let j;return g?j=`${_??"binding"} window — long hold${y?`, ${y}`:", reset time unknown"}`:j=y?`${_?`${_} window `:""}next ${y}`:"will fire when usage drops",{kind:"auto-throttled",line1:`Auto · throttled (util ${c.toFixed(0)}% ≥ ${P}%)`,line2:j}}return{kind:"auto-soon",line1:`Auto · ${u} pending · util ${c.toFixed(0)}%`,line2:"fires within 2 min (poll cycle)"}}const bn=15e3,wn=new Set(["failed","quarantined"]);function vn(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 At(){const s=Array.from(document.querySelectorAll("[data-job-row]")).find(a=>wn.has(a.dataset.jobStatus??""));if(!s)return;const n=vn(s);n&&Ts(n,s,{block:"nearest",behavior:"smooth"})}function jn(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 ${ne(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?ne(e.idleMs):"?"} with ${e.dispatchable} dispatchable`;case"running":default:return`running: ${e.runningCount} in flight, ${e.pending} pending`}}function yn(e){const[s,n]=f.useState(null),a=it(),l=Is(),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,W.error(`Queue health refresh failed: ${u instanceof Error?u.message:String(u)}`))}))};o();const p=setInterval(o,bn);return()=>{i=!1,clearInterval(p)}},[e,d]),s}const Nn={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 kn(e,s,n){return e==="paused"||e==="launch-blocked"?"paused":e==="running"||e==="saturated"?"running":e?"idle":s?"paused":n>0?"running":"idle"}const Ke="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 Sn(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 ${ne(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 ${ne(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 $n({now:e}){const s=Be(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:Sn(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 ${ne(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(([h,w])=>`${h}=${w}`).join(" ")}),")",u.claudeVersion?` since CLI ${u.claudeVersion}`:"","."]}),t.jsx("div",{className:"opacity-80",children:u.hint})]})},`launch-mitigation-${p}`))]})}function Cn({scopeCwd:e,subView:s,onSubView:n,filterText:a,onFilterText:l,planMode:d,onPlanMode:i,planToolsRef:r}){const c=Be(D=>D.snapshot),o=he(D=>D.sessions),p=yn(e),u=Ht(),[h,w]=f.useState(()=>Date.now()),[x,m]=f.useState("—");f.useEffect(()=>{const D=setInterval(()=>w(Date.now()),3e4);return()=>clearInterval(D)},[]),f.useEffect(()=>{let D=!0;return zs(30).then(T=>{if(!D||!T.ok||!T.data)return;const O=new Date,L=Ue=>String(Ue).padStart(2,"0"),te=`${O.getFullYear()}-${L(O.getMonth()+1)}-${L(O.getDate())}`;m(Qs(Ys(T.data,{day:te})))}),()=>{D=!1}},[]);const N=f.useMemo(()=>((c==null?void 0:c.jobs)??[]).filter(D=>!e||D.cwd===e),[c,e]),P=f.useMemo(()=>fn(N,h),[N,h]),$=f.useMemo(()=>{const D=ut(N,{sessions:o,now:h}),T=O=>D.filter(L=>L.status===O).length;return{active:T("active"),queued:T("queued"),draft:T("draft")}},[N,o,h]),_=f.useMemo(()=>{const D=new Date(h).toDateString(),T=[];for(const O of N)if(O.status==="completed"&&O.startedAt&&O.finishedAt&&new Date(Date.parse(O.finishedAt)).toDateString()===D){const L=Date.parse(O.finishedAt)-Date.parse(O.startedAt);L>0&&T.push(L)}return T.length?Math.round(T.reduce((O,L)=>O+L,0)/T.length/6e4):null},[N,h]);if(!c)return null;const g=p&&!p.unknown?p.verdict??null:null,y=p&&!p.unknown?p.slots??null:null,j=c.paused,C=kn((g==null?void 0:g.kind)??null,!!j,P.inFlight),A=Nn[C],F=N.filter(D=>D.status==="pending").length,G=N.filter(D=>D.status==="running").length,z=ss({snap:{...c,jobs:N},now:h,avgDurationMs:0,runningJobs:N.filter(D=>D.status==="running")}),K=p!=null&&p.unknown?`Queue health: unknown — ${p.reason??"state unavailable"}`:g?jn(g,(p==null?void 0:p.oldestRunningAgeMs)??null):"queue health loading…",X=me(c.lastRunAt?Date.parse(c.lastRunAt):null,h),ee=p!=null&&p.lastDispatchAttemptAt?me(Date.parse(p.lastDispatchAttemptAt),h):"never",Q=[K,z.line1,g?`dispatchable ${g.dispatchable} · needs_review ${g.needsReviewCount}`:null,(p==null?void 0:p.oldestRunningAgeMs)!=null?`oldest running ${ne(p.oldestRunningAgeMs)} (any project)`:null,`last batch fired ${X} (lastRunAt — advances only when a job launches)`,`last dispatch attempt ${ee} (advances on every driver evaluation)`].filter(Boolean).join(`
|
|
2
|
+
`),I=c.utilization,q=c.pollHealth,S=q!=null&&!q.lastPollOk,M=$s(c.utilizationWindow),B=c.nextReset?Date.parse(c.nextReset):null,V=B?B>h?ne(B-h):"soon":"—",Y=(u==null?void 0:u.total)??5,b=(u==null?void 0:u.envOverride)===!0,k=c.config.firePolicy??"when-available",R=F===0&&G===0;return t.jsxs("div",{"data-testid":"scheduler-top-bands",className:"shrink-0 px-[18px]",children:[t.jsxs(Qe,{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 ${A.text}`,"data-testid":"scheduler-state-word","data-state":C,children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${A.dot}`,"aria-hidden":"true"}),C]}),t.jsxs("span",{className:"font-mono text-[12px] text-fg-faint whitespace-nowrap","data-testid":"scheduler-meta",children:[P.inFlight," in flight · ",P.heldByDeps," held · last batch ",X]}),t.jsxs(be,{title:Q,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:Q}),kt.scheduler&&t.jsx(Cs,{content:kt.scheduler})]}),t.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>window.api.schedule.rescan().then(W.fromOutcome).catch(()=>W.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:Ke,children:"Refresh"}),j?t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),title:"Clear the pause and resume queue immediately",className:Ke,children:"Resume"}):t.jsx("button",{type:"button",onClick:()=>window.api.schedule.pause(),title:"Stop NEW dispatch. Running jobs are not killed.",className:Ke,children:"Pause"}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.forceTick().then(W.fromOutcome).catch(()=>W.error("Failed to fire batch")),disabled:R,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($n,{now:h}),t.jsxs(Qe,{height:70,testId:"scheduler-kpi-band",children:[t.jsx(ue,{testId:"kpi-window",label:M?`${M} used`:"Window used",info:S?`Billing poll failing — this reading may be outdated (last good reading ${me(q.lastPollAt,h)}). Machine-wide ${M??"binding"} window.`:`Share of the machine-wide ${M??"binding"} billing window consumed — the window closest to its limit.`,value:I==null?"—":`${Math.round(I)}%`,sub:`resets in ${V}`,third:t.jsx(Ps,{pct:I??0,tone:S?"bg-amber-500":"bg-accent"})}),t.jsx(ue,{testId:"kpi-slots",label:"Slots",info:`Machine-wide session pool (${(y==null?void 0:y.source)==="env"?"SM_SESSION_SLOTS override":"Home tab cap"}), not scoped to this project`,value:y?`${y.inUse}/${y.total}`:"—",sub:"in use",third:y?t.jsx(Ms,{filled:y.inUse,total:y.total}):null}),t.jsx(ue,{testId:"kpi-ready",label:"Ready now",info:"Pending rows whose dependsOn chain is fully satisfied right now",value:P.readyNow,sub:`of ${P.totalQueued} queued`,third:`${P.heldByDeps} held by deps`}),P.needsYou>0?t.jsx(ue,{testId:"kpi-needs-you",label:"Needs you",value:t.jsx("button",{type:"button","data-testid":"kpi-needs-you-jump",onClick:At,className:"font-semibold text-accent hover:underline",title:"Scroll to the first failed / quarantined row",children:P.needsYou}),sub:t.jsx("button",{type:"button",onClick:At,className:"hover:underline",children:P.needsYouStage!=null?`blocking stage ${P.needsYouStage}`:"need attention"}),third:[P.failedCount>0&&`${P.failedCount} failed`,P.needsYou-P.failedCount>0&&`${P.needsYou-P.failedCount} quarantined`].filter(Boolean).join(" · ")}):t.jsx(ue,{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"}),P.needsReviewCount>0&&t.jsx(ue,{testId:"kpi-being-fixed",label:"Being fixed",value:P.needsReviewCount,sub:"the scheduler is handling them"}),t.jsx(ue,{testId:"kpi-done",label:"Done today",value:P.doneToday,sub:_!=null?`avg ${_}m`:"avg —",third:t.jsx("span",{"data-testid":"kpi-done-spend",children:x})}),t.jsx(ue,{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:k,onChange:D=>window.api.schedule.setConfig({firePolicy:D.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(As,{value:Y,min:0,max:(u==null?void 0:u.max)??10,disabled:b,onChange:D=>{Rs(D).catch(T=>{W.error(`Could not set session slots: ${T instanceof Error?T.message:String(T)}`)})},title:b?"pinned by SM_SESSION_SLOTS — unset the env var to edit":"Machine-wide claude -p session slots, shared with chat runs"}),b&&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:k==="when-available"?t.jsxs("span",{children:["pause above"," ",t.jsx(Ds,{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). Not the executor rate-limit pause — click to edit",onCommit:D=>window.api.schedule.setConfig({utilizationThreshold:D})})]}):null})]}),t.jsxs(Qe,{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:[$.active," active · ",$.queued," queued · ",$.draft," draft · ",N.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:D=>l(D.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(([D,T])=>t.jsx("button",{type:"button","data-testid":`plan-mode-${D}`,"aria-pressed":d===D&&s==="queue",onClick:()=>{i(D),n("queue")},className:`px-2 py-0.5 text-[12px] ${d===D&&s==="queue"?"bg-bg-elev font-semibold text-fg":"text-fg-dim hover:text-fg"}`,children:T},D))}),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(([D,T,O])=>t.jsx("button",{type:"button",onClick:()=>n(D),"aria-pressed":s===D,title:O,className:`text-[12.5px] ${s===D?"font-semibold text-fg":"text-fg-faint hover:text-fg-dim"}`,children:T},D))]})]})]})}function ns({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 as(e,s=60){const n=e.trim();return n.length<=s?n:`${n.slice(0,s-1)}…`}function Pn(e){return We([e]).filter(s=>s.children.length===0).map(s=>s.row.slug)}function rs(e){return e.nodes.map(s=>({rootSlug:s.row.slug,label:s.row.title||s.row.slug,terminals:Pn(s)}))}function Mn(e){const s=new Map;for(const n of e){const a=rs(n);n.nodes.forEach((l,d)=>{const i=a.filter((r,c)=>c!==d);for(const r of We([l]))s.set(r.row.slug,i)})}return s}function is({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(W.fromOutcome).catch(()=>W.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: ",as(d.label,40)]},d.rootSlug))]})}function Dn(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 St(i))l.add(r)}const d=[];for(const i of s)i.archived!==!0||a.has(i.slug)||n&&i.cwd!==n||St(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 An=[],Rn=new Set(["failed","needs_review","quarantined"]);function In(e){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 Tn(e){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 En(e){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 _n({row:e,elapsedMs:s,listIndex:n,onFocused:a,headChoices:l=An}){const[d,i]=f.useState(!1),r=e.job,c=s!==null&&e.rowKind==="running"?ts(r,s):e.rowTrailing,o=e.status==="completed"||e.status==="skipped",p=e.rowKind==="dep"&&e.blockers.some(h=>!h.missing&&h.status!==null&&Rn.has(h.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(h=>!h),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 ${Tn(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] ${En(e)}`,children:c})]}),d&&t.jsx(Ln,{row:e,elapsedMs:s,headChoices:l})]})}const ls=f.memo(_n);function Ln({row:e,elapsedMs:s,headChoices:n}){const a=e.job,[l,d]=f.useState(!1),i=he(w=>w.sessions),r=f.useMemo(()=>Me(a,i),[a,i]),c=r.known&&r.epicId?i[r.epicId]:null,o=f.useCallback(w=>Wt(w),[]),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",h=a.error?a.error.split(`
|
|
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 ${fe(Date.parse(a.startedAt))}`,a.finishedAt&&` · finished ${fe(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(w=>w.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(w=>`${w.slug} (${w.missing?"missing":(w.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]}),h&&t.jsx("div",{className:`${p} text-accent/80`,children:h}),!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(W.fromOutcome).catch(()=>W.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(is,{job:a,headChoices:n})]}),l&&a.runId&&t.jsx(He,{runId:a.runId,slug:a.slug,title:a.title||a.slug,onClose:()=>d(!1)})]})}const pe=190,On=7,Fn=5,qn=[],os=e=>e==="completed"||e==="skipped",ds=e=>e==="running"||e==="investigating",cs=e=>e==="failed"||e==="needs_review"||e==="quarantined";function Re(e){return ds(e.status)?0:cs(e.status)?1:os(e.status)?3:2}const Bn={done:"text-sage",running:"text-accent",held:"text-fg-faint",pending:"text-fg-faint",blocked:"text-butter"},Hn={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=>os(n.status))?`+${e.length} done`:e.every(n=>n.rowKind==="dep"&&n.blockers.some(a=>!a.missing&&a.status!==null&&cs(a.status)))?`+${e.length} blocked`:`+${e.length} in stage ${s}`}function Un({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(g=>!(a.has(g.slug)&&(g.status==="completed"||g.status==="failed"))).map((g,y)=>({r:g,i:y})).sort((g,y)=>Re(g.r)-Re(y.r)||g.i-y.i).map(g=>g.r),[e.rows,a]),p=f.useMemo(()=>o.filter(g=>Re(g)<=1).length,[o]),u=Math.max(e.state==="done"?Fn:On,p),h=r?o:o.slice(0,u),w=r?[]:o.slice(u),x=o.find(g=>g.status==="failed"),m=o.find(g=>g.status==="needs_review"),N=p>0&&(x!==void 0||m!==void 0),P=h.reduce((g,y,j)=>Re(y)<=1?j:g,-1),$=g=>t.jsx(ls,{row:g,elapsedMs:ds(g.status)&&g.job.startedAt?n-Date.parse(g.job.startedAt):null,listIndex:l.get(g.slug)??0,onFocused:i,headChoices:d.get(g.slug)??qn},g.slug),_="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:pe},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 ${Hn[e.state]}`}),t.jsxs("span",{className:`text-[10px] font-semibold uppercase tracking-wide ${Bn[e.state]}`,children:["Stage ",e.n]}),e.state==="blocked"&&t.jsx(be,{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:h.map((g,y)=>t.jsxs("div",{children:[$(g),N&&y===P&&t.jsxs("div",{"data-testid":"stage-attention-actions",className:"flex gap-1.5 px-2 py-1.5 border-t border-rule-inner",children:[x&&t.jsxs("button",{type:"button","data-testid":"stage-retry",title:`Reset ${x.slug} to pending`,onClick:()=>{window.api.schedule.resetJob(x.slug,x.job.cwd??void 0).then(j=>{j.ok||W.error(j.error??`Failed to reset ${x.slug}`)}).catch(()=>W.error(`Failed to reset ${x.slug}`))},className:_,children:["Retry ",x.prdNumber?`#${x.prdNumber}`:x.slug]}),m&&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&&Wt(s)},className:_,children:["Review ",m.prdNumber?`#${m.prdNumber}`:m.slug]})]})]},g.slug))}),(w.length>0||r&&o.length>u)&&t.jsx("button",{type:"button","data-testid":"stage-footer","aria-expanded":r,onClick:()=>c(g=>!g),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(w,e.n)} ▾`})]})}const je=6,Je=4,Ee=4,Rt=12,It=5,us=2,Tt=4,Gn={done:"bg-sage",running:"bg-accent",attention:"bg-butter",failed:"bg-red-600",pending:"bg-fg-faint/50"};function Vn(e){return e==="completed"||e==="skipped"?"done":e==="running"||e==="investigating"?"running":e==="failed"?"failed":e==="needs_review"||e==="quarantined"?"attention":"pending"}function zn(e){const s=[],n=[],a=[];let l=It;for(const d of e){const i=Math.max(1,Math.ceil(d.rows.length/Ee));n.push(l),a.push(i*je),d.rows.forEach((r,c)=>{s.push({x:l+Math.floor(c/Ee)*je,y:us+c%Ee*je,tone:Vn(r.status),title:`${r.prdNumber?`#${r.prdNumber}`:r.slug} ${r.title} — ${r.status}`})}),l+=i*je+Rt}return{dots:s,stageX:n,stageW:a,width:Math.max(0,l-Rt)+It}}function ye(e,s){return e.findIndex(n=>n.rows.some(a=>s(a.status)))}const at=e=>e==="running"||e==="investigating",rt=e=>e==="failed"||e==="needs_review"||e==="quarantined";function Qn({stages:e,first:s,perView:n,onSeek:a}){const l=f.useMemo(()=>zn(e),[e]),d=f.useMemo(()=>ye(e,at)>=0,[e]),i=f.useMemo(()=>ye(e,rt)>=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),h=x=>{const m=x.currentTarget.getBoundingClientRect(),N=x.clientX-m.left;let P=0;for(let $=0;$<c;$++)l.stageX[$]<=N&&(P=$);a(Math.max(0,Math.min(c-1,P-Math.floor(n/2))))},w="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(be,{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:Ee*je-(je-Je)+2*us},onPointerDown:x=>{var m,N;r.current=!0,(N=(m=x.currentTarget).setPointerCapture)==null||N.call(m,x.pointerId),h(x)},onPointerMove:x=>{r.current&&h(x)},onPointerUp:()=>{r.current=!1},onPointerCancel:()=>{r.current=!1},children:[l.dots.map((x,m)=>t.jsx("span",{title:x.title,"data-tone":x.tone,className:`absolute rounded-[1px] ${Gn[x.tone]}`,style:{left:x.x,top:x.y,width:Je,height:Je}},m)),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-Tt,width:u-p+2*Tt}})]}),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(ye(e,at)),className:`${w} 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(ye(e,rt)),className:`${w} text-fg-dim hover:text-fg border-l border-line`,children:"Blockers"})]})]})}const Yn=148;function Kn({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:Yn},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(be,{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 Jn=[],Xn=e=>e==="running"||e==="investigating";function Zn(e){const s=hn(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 ea({plan:e,now:s,indexBySlug:n,headChoicesBySlug:a,onRowFocused:l}){const d=f.useMemo(()=>Zn(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(ls,{row:i,elapsedMs:Xn(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)??Jn})}),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 Et=1,_t=1350,ta={active:"border-l-accent",queued:"border-l-rule-structural",done:"border-l-sage",draft:"border-l-fg-faint/40 border-dashed"},sa={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"}},na=e=>String(e).padStart(2,"0");function aa({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 ra({plan:e,mode:s="graph",now:n,hidden:a,indexBySlug:l,headChoicesBySlug:d,onRowFocused:i,onOpenPrds:r}){var ee,Q;const[c,o]=f.useState(e.status==="active"||e.status==="queued"),[p,u]=f.useState(!1),h=f.useRef(null),[w,x]=f.useState(0),[m,N]=f.useState(_t),P=f.useMemo(()=>{const I=ye(e.stages,at);return I>=0?I:Math.max(0,ye(e.stages,rt))},[e.stages]);f.useLayoutEffect(()=>{if(!c)return;const I=h.current,q=(I==null?void 0:I.clientWidth)||_t,S=Math.max(0,Math.min(P,e.stageCount-Math.max(1,Math.ceil(q/pe))));I!=null&&I.clientWidth&&N(I.clientWidth),I&&(I.scrollLeft=S*pe),x(S)},[c]);const $=f.useMemo(()=>{let I=null;for(const q of e.stages)for(const S of q.rows){if(!S.job.runId)continue;const M=S.job.finishedAt?Date.parse(S.job.finishedAt):0;(!I||M>I.at)&&(I={runId:S.job.runId,slug:S.slug,title:S.title,at:M})}return I},[e.stages]),_=Oe((Q=(ee=e.stages[0])==null?void 0:ee.rows[0])==null?void 0:Q.job.cwd)??"—",g=sa[e.status],y=Math.max(1,Math.ceil(m/pe)),j=Math.max(0,Math.min(w-Et,e.stageCount)),C=Math.min(e.stageCount,w+y+Et),A=I=>{const q=Math.max(0,Math.min(e.stageCount-1,I));h.current&&(h.current.scrollLeft=q*pe),x(q)},F=Math.min(e.stageCount,w+y),G=I=>{const q=I.currentTarget,S=Math.floor(q.scrollLeft/pe);S!==w&&x(S),q.clientWidth&&q.clientWidth!==m&&N(q.clientWidth)},z="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",K=(()=>{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(()=>W.error("Failed to pause the scheduler"))},className:z,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(W.fromOutcome).catch(()=>W.error("Failed to fire the next batch"))},className:z,children:"Run now"});case"done":return t.jsx("button",{type:"button","data-testid":"plan-action",disabled:!$,title:$?`Open the run log of ${$.slug}, the plan's last run`:"No run log recorded for this plan",onClick:()=>u(!0),className:z,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 I,q;return r==null?void 0:r(((q=(I=e.stages[0])==null?void 0:I.rows[0])==null?void 0:q.slug)??null)},className:z,children:"Schedule…"})}})(),X=e.etaMs>0?` · ${es(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] ${ta[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(I=>!I),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:na(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 ${g.cls}`,children:g.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:[_," · ",e.epicLabel," · ",e.prdCount," PRD",e.prdCount===1?"":"s"," · ",e.width," wide · ",e.stageCount," stage",e.stageCount===1?"":"s"]}):t.jsxs(t.Fragment,{children:[_," · ",e.prdCount," PRD",e.prdCount===1?"":"s",e.width>1?` · ${e.width} wide`:""," · ",e.stageCount," stage",e.stageCount===1?"":"s"]})}),t.jsx(be,{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,X]}),t.jsx(aa,{plan:e}),K]}),c&&s==="critical"&&t.jsx(ea,{plan:e,now:n,indexBySlug:l,headChoicesBySlug:d,onRowFocused:i}),c&&s!=="critical"&&e.status==="active"&&t.jsx(Qn,{stages:e.stages,first:w,perView:y,onSeek:A}),c&&s!=="critical"&&t.jsxs("div",{className:"flex border-t border-rule-structural",children:[t.jsxs("div",{ref:h,"data-testid":"plan-stages",onScroll:G,className:"flex flex-1 min-w-0 overflow-x-auto",children:[j>0&&t.jsx("div",{"aria-hidden":"true",className:"shrink-0",style:{width:j*pe}}),e.stages.slice(j,C).map(I=>t.jsx(Un,{stage:I,epicId:e.epicId,now:n,hidden:a,indexBySlug:l,headChoicesBySlug:d,onRowFocused:i},I.n)),C<e.stageCount&&t.jsx("div",{"aria-hidden":"true",className:"shrink-0",style:{width:(e.stageCount-C)*pe}})]}),t.jsx(Kn,{stages:e.stages.slice(F),onSeek:A})]}),p&&$&&t.jsx(He,{runId:$.runId,slug:$.slug,title:$.title||$.slug,onClose:()=>u(!1)})]})}function ia({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(lt,{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 la=[],oa=[],da={depth:0,blockers:la,blocked:!1,hasNeedsReviewBlocker:!1,hasMissingDep:!1,cycle:!1,parallelEligible:!1};function ca(e){return e.missing?`${e.slug} (missing)`:e.needsReview?`${e.slug} (needs review)`:`${e.slug} (${(e.status??"unknown").replace(/_/g," ")})`}function ua(e){return e.missing?"text-accent":e.needsReview?"text-butter font-semibold":e.status==="completed"?"text-sage":"text-amber-400/90"}function pa({job:e,eta:s,elapsedMs:n,avgDurationMs:a,listIndex:l,onFocused:d,hold:i,backlog:r=da,headChoices:c=oa}){const[o,p]=f.useState(!1),[u,h]=f.useState(!1),w=he(C=>C.sessions),x=f.useMemo(()=>Me(e,w),[e,w]),m=x.known&&x.epicId?w[x.epicId]:null,N=f.useCallback(C=>{ot(C),window.dispatchEvent(new CustomEvent("sm:navigate",{detail:"terminal"}))},[]),P=e.status==="running",$=e.status==="failed";let _=null;P&&n!==null?_=`${Le(n)} elapsed`:e.status==="completed"&&e.startedAt&&e.finishedAt?_=`took ${Ce(Date.parse(e.finishedAt)-Date.parse(e.startedAt))}`:s&&(_=s);const g=e.error??null,y=$&&g?g.split(`
|
|
4
|
+
`)[0]:e.status==="needs_review"&&e.verifierVerdict?Pe(e.verifierVerdict):null,j=P&&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-index":l,"data-depth":r.depth,onClick:()=>p(C=>!C),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":`${le(e.slug)?`PRD ${le(e.slug)}, `:""}${e.title}, ${e.status}${_?`, ${_}`:""}`,title:e.title,children:[t.jsx(Ut,{status:e.status}),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:[le(e.slug)&&t.jsx(Gt,{n:le(e.slug)}),e.title,t.jsx(Vt,{leaked:e.leakedDescendants}),t.jsx(Es,{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(C=>C.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((C,A)=>t.jsxs("span",{className:ua(C),children:[A>0&&", ",ca(C)]},C.slug))]}),y&&t.jsx("div",{className:`text-[12.5px] mt-0.5 ${$?"text-accent/80":"text-fg-faint"}`,children:y}),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(dt,{epicId:x.epicId,label:x.label?as(x.label):null,onOpen:N,testId:"job-row-prompt-session-chip",className:"mt-0.5"})]}),t.jsx(ct,{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(_s,{status:e.status,overrun:e.overrun}),_,t.jsx("span",{className:`text-fg-faint inline-flex transition-transform duration-150 ${o?"rotate-90":""}`,"aria-hidden":"true",children:t.jsx(lt,{name:"chevron",size:14})})]})]}),P&&!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,j*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(ie,{label:"Status",children:[t.jsx(H,{k:"result",v:e.exitCode!==null?`exit ${e.exitCode}`:"—"}),t.jsx(H,{k:"state",v:e.status.replace(/_/g," ")}),e.verifierVerdict&&t.jsx(H,{k:"verdict",v:Pe(e.verifierVerdict)}),e.leakedDescendants&&e.leakedDescendants.length>0&&t.jsx(H,{k:"leaked",v:zt(e.leakedDescendants),wrap:!0}),e.leftoverCount!=null&&e.leftoverCount>0&&t.jsx(H,{k:"uncommitted",v:`${e.leftoverCount} file${e.leftoverCount===1?"":"s"}${e.leftoverPathsTruncated?"+":""}: ${(e.leftoverPaths??[]).join(", ")}${e.salvagePatch?` — salvaged to ${e.salvagePatch}`:""}`,wrap:!0}),g&&t.jsx(H,{k:"error",v:g.split(`
|
|
5
|
+
`)[0],wrap:!0})]}),e.statusHistory&&e.statusHistory.length>0&&t.jsx(ie,{label:"History",children:t.jsx("div",{className:"grid gap-1",children:e.statusHistory.map((C,A)=>t.jsxs("div",{className:"font-mono text-xs leading-relaxed",children:[t.jsxs("div",{className:"text-fg",children:[C.from??"(new)"," → ",C.to,t.jsxs("span",{className:"text-fg-faint",children:[" · ",fe(Date.parse(C.at))]})]}),C.reason&&t.jsx("div",{className:"text-fg-faint break-words",children:C.reason})]},A))})}),t.jsxs(ie,{label:"Timing",children:[t.jsx(H,{k:"started",v:e.startedAt?fe(Date.parse(e.startedAt)):"—"}),t.jsx(H,{k:"finished",v:e.finishedAt?fe(Date.parse(e.finishedAt)):"—"}),t.jsx(H,{k:"duration",v:e.startedAt&&e.finishedAt?Ce(Date.parse(e.finishedAt)-Date.parse(e.startedAt)):P&&n!==null?Le(n):"—"})]}),t.jsxs(ie,{label:"Location",children:[t.jsx(H,{k:"group",v:`${e.parallelGroup} · ${e.slug}`}),t.jsx(H,{k:"cwd",v:e.cwd??"—",wrap:!0}),t.jsx(H,{k:"session",v:x.label??x.epicId??"—",wrap:!0}),t.jsx(H,{k:"session id",v:x.epicId??"—",wrap:!0}),t.jsx(H,{k:"prompt id",v:e.sourcePromptId??"—",wrap:!0}),t.jsx(H,{k:"source tab",v:e.sourceTabId??"—",wrap:!0})]}),t.jsx(ie,{label:"Actions",children:t.jsxs("div",{className:"flex flex-col gap-1.5 items-start",children:[m&&t.jsx("button",{type:"button","data-testid":"job-row-prompt-session-link",title:m.goalText,onClick:()=>N(m.id),className:"text-[13px] font-semibold text-accent hover:text-accent/80 bg-transparent border-0 cursor-pointer p-0",children:"view epic →"}),e.runId&&t.jsx("button",{type:"button",onClick:()=>h(!0),className:"text-[13px] font-semibold text-fg-dim hover:text-fg bg-transparent border-0 cursor-pointer p-0",children:"view log →"}),e.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(e.slug).then(W.fromOutcome).catch(()=>W.error("Failed to adopt PRD"))},className:"text-[13px] font-semibold text-accent hover:text-accent/80 bg-transparent border-0 cursor-pointer p-0",children:"adopt PRD →"}),e.status!=="pending"&&e.status!=="running"&&e.status!=="quarantined"&&t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resetJob(e.slug,e.cwd??void 0),className:"text-[13px] font-semibold text-fg-dim hover:text-fg bg-transparent border-0 cursor-pointer p-0",children:"reset to pending →"}),e.disposition&&(e.status==="pending"||e.status==="quarantined")&&t.jsx(is,{job:e,headChoices:c})]})})]}),u&&e.runId&&t.jsx(He,{runId:e.runId,slug:e.slug,title:e.title||e.slug,onClose:()=>h(!1)})]})}const fa=f.memo(pa);function ha({supervisorConfig:e,onSetConfig:s,onBack:n}){const[a,l]=f.useState([]),[d,i]=f.useState(()=>Date.now()),r=it();f.useEffect(()=>{if(!r)return;window.api.supervisor.getLog().then(l).catch(()=>{}),i(Date.now());const o=setInterval(()=>i(Date.now()),5e3);return()=>clearInterval(o)},[r]);const c={enabled:(e==null?void 0:e.enabled)??!0,intervalMinutes:(e==null?void 0:e.intervalMinutes)??15,maxConcurrentProbes:(e==null?void 0:e.maxConcurrentProbes)??2,probeStaleThresholdMinutes:(e==null?void 0:e.probeStaleThresholdMinutes)??10};return t.jsxs("div",{className:"bg-bg-elev/60",children:[t.jsxs("div",{className:"px-3 py-2 flex items-center gap-2 border-b border-line",children:[t.jsx("button",{type:"button",onClick:n,className:"text-[10px] text-fg-faint hover:text-fg-dim",title:"Back to queue",children:"← queue"}),t.jsx("span",{className:"text-[11px] font-medium text-fg-dim",children:"Supervisor"}),t.jsx("button",{type:"button",onClick:()=>window.api.supervisor.getLog().then(l).catch(()=>{}),className:"ml-auto text-[10px] text-fg-faint hover:text-fg-dim underline",title:"Refresh log",children:"refresh"})]}),t.jsxs("div",{className:"px-3 py-2 space-y-1.5 border-b border-line",children:[t.jsx("div",{className:"text-[9px] text-fg-faint uppercase tracking-wider",children:"Config"}),t.jsxs("div",{className:"flex items-center gap-3 flex-wrap text-[10px] text-fg-faint",children:[t.jsxs("label",{className:"flex items-center gap-1",children:[t.jsx("input",{type:"checkbox",checked:c.enabled,onChange:o=>s({enabled:o.target.checked}),className:"cursor-pointer"}),t.jsx("span",{children:"enabled"})]}),t.jsxs("label",{className:"flex items-center gap-1",title:"How often to check for wedged jobs (minutes)",children:[t.jsx("span",{children:"interval"}),t.jsx("input",{type:"number",min:5,max:60,value:c.intervalMinutes,onChange:o=>s({intervalMinutes:Number(o.target.value)}),className:"w-10 bg-bg border border-line rounded px-1 py-0.5 font-mono"}),t.jsx("span",{children:"min"})]}),t.jsxs("label",{className:"flex items-center gap-1",title:"Max concurrent Opus probes per tick",children:[t.jsx("span",{children:"probes"}),t.jsx("input",{type:"number",min:1,max:5,value:c.maxConcurrentProbes,onChange:o=>s({maxConcurrentProbes:Number(o.target.value)}),className:"w-8 bg-bg border border-line rounded px-1 py-0.5 font-mono"})]}),t.jsxs("label",{className:"flex items-center gap-1",title:"Probe a job only if no JSONL event in this many minutes",children:[t.jsx("span",{children:"stale"}),t.jsx("input",{type:"number",min:5,max:30,value:c.probeStaleThresholdMinutes,onChange:o=>s({probeStaleThresholdMinutes:Number(o.target.value)}),className:"w-8 bg-bg border border-line rounded px-1 py-0.5 font-mono"}),t.jsx("span",{children:"min"})]})]})]}),t.jsxs("div",{className:"px-3 py-2",children:[t.jsxs("div",{className:"text-[9px] text-fg-faint uppercase tracking-wider mb-1",children:["Recent probes (last ",a.length,")"]}),a.length===0?t.jsx("div",{className:"text-[10px] text-fg-faint italic",children:"No probes yet."}):t.jsx("div",{className:"space-y-0.5 max-h-64 overflow-y-auto",children:a.map((o,p)=>t.jsx(xa,{entry:o,now:d},`${o.ts}-${p}`))})]})]})}function xa({entry:e,now:s}){const n=e.action!=="none",a=ne(s-e.ts);return t.jsxs("div",{className:`text-[10px] px-1.5 py-1 rounded font-mono ${n?"bg-red-500/10 border border-red-500/20":"bg-bg/40"}`,title:e.reason,children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsxs("span",{className:"text-fg-faint shrink-0",children:[a," ago"]}),t.jsx("span",{className:`shrink-0 px-1 rounded ${e.verdict==="stuck"?"text-red-400 bg-red-500/10":"text-green-500/70"}`,children:e.verdict}),t.jsx("span",{className:"truncate text-fg-dim",children:e.jobSlug}),n&&t.jsxs("span",{className:"shrink-0 text-red-400",children:[e.action,e.targetPid?` pid=${e.targetPid}`:""]}),e.costUsd!==null&&t.jsxs("span",{className:"shrink-0 text-fg-faint",children:["$",e.costUsd.toFixed(3)]})]}),t.jsx("div",{className:"text-fg-faint truncate mt-0.5",children:e.reason})]})}const ga=[{title:"Start a session",body:"In Sessions, pick an Agent and a Mission, describe the outcome you want, then Approve & start. Its thread writes the PRD files into that session's own folder."},{title:"Queue what it wrote",body:"The PRDs tab lists every file the session produced. Queue one, or the whole session, and they appear here."},{title:"Leave it alone",body:"Jobs start themselves inside your window, pause on rate-limit, and resume at the reset. History records how each ended."}],ma=[{term:"Session",def:"One goal, one Claude session, and the folder of PRDs written to reach it."},{term:"PRD",def:"One markdown file = one job. Authored by the session."},{term:"5-hour window",def:"Your Claude billing window, on a rolling clock."},{term:"Session pool",def:"5 slots shared with terminal and session chats."}];function ba({navigate:e}){return t.jsx("div",{className:"overflow-y-auto h-full",children:t.jsx("div",{className:"px-9 py-6 max-w-[900px] mx-auto",children:t.jsxs("div",{className:"bg-bg-hi border border-line rounded-2xl px-9 py-8",children:[t.jsx("h2",{className:"m-0 font-serif text-[25px] font-semibold text-fg",children:"Nothing to run yet — the scheduler needs a session."}),t.jsx("p",{className:"mt-2 mb-6 text-[14.5px] text-fg-dim leading-relaxed max-w-[580px]",children:"You don't write PRDs here. A session breaks its goal into numbered PRD files, and this page runs them in order. Two steps, once."}),t.jsx("div",{className:"grid grid-cols-3 gap-3.5",children:ga.map((s,n)=>{const a=n===0;return t.jsxs("div",{className:`bg-bg border rounded-xl px-4 py-4 flex flex-col gap-2 ${a?"border-accent shadow-[0_0_0_3px_rgba(184,92,52,.09)]":"border-line"}`,children:[t.jsx("span",{className:`w-6 h-6 rounded-full grid place-items-center font-mono text-[12px] font-semibold ${a?"bg-accent text-white":"bg-bg-elev text-fg-dim"}`,children:n+1}),t.jsx("h3",{className:"m-0 text-[15px] font-semibold text-fg",children:s.title}),t.jsx("p",{className:"m-0 text-[13.5px] text-fg-dim leading-relaxed",children:s.body}),a&&t.jsx("button",{type:"button",onClick:()=>e==null?void 0:e("terminal"),className:"self-start bg-accent text-white rounded-lg px-3.5 py-1.5 text-[13px] font-semibold mt-1",children:"Go to Sessions →"})]},s.title)})}),t.jsx("dl",{className:"flex mt-[22px] pt-4 border-t border-line gap-5 flex-wrap",children:ma.map(({term:s,def:n})=>t.jsxs("div",{className:"flex-1 min-w-[150px]",children:[t.jsx("dt",{className:"text-[13.5px] font-semibold text-fg mb-0.5",children:s}),t.jsx("dd",{className:"m-0 text-[12.5px] text-fg-faint leading-relaxed",children:n})]},s))})]})})})}const wa=5e3;let Ie=null,ke=null;async function Lt(e){const s=Date.now();return!(e!=null&&e.fresh)&&Ie&&s-Ie.at<wa?Ie.result:ke||(ke=(async()=>{try{const n=await window.api.schedule.lintQueue();return Ie={result:n,at:Date.now()},n}finally{ke=null}})(),ke)}function va({health:e,jobCount:s,lastRunAt:n,nextReset:a,now:l,onOpenSupervisor:d}){const[i,r]=f.useState(!1),[c,o]=f.useState(null),[p,u]=f.useState(!1),h=`${s}:${n??""}`;f.useEffect(()=>{let j=!0;return u(!0),Lt().then(C=>{j&&o(C)}).catch(()=>{}).finally(()=>{j&&u(!1)}),()=>{j=!1}},[h]);let w=0,x=0;const m=c?c.reports.filter(j=>j.findings.length>0):[];for(const j of m)for(const C of j.findings)C.severity==="error"?w++:x++;const N=w===0&&x===0,P=c?`graph lint ${w} error${w===1?"":"s"}, ${x} warn${x===1?"":"s"}`:`graph lint ${p?"scanning…":"idle"}`,$=(e==null?void 0:e.consecutiveFailures)??0,g=[e?`${$} poll failure${$===1?"":"s"} in current streak`:null,P].filter(Boolean).join(" · "),y="text-accent hover:underline bg-transparent border-0 p-0 cursor-pointer text-[12px]";return t.jsxs("div",{"data-testid":"scheduler-footer",className:"border-t border-rule-structural",children:[t.jsxs("div",{className:"h-[28px] flex items-center gap-2 px-[18px] font-mono text-[11.5px] text-fg-faint",children:[t.jsx("span",{"data-testid":"footer-summary",className:"truncate",children:g}),t.jsx("button",{type:"button","data-testid":"footer-info","aria-expanded":i,onClick:()=>r(j=>!j),className:"bg-transparent border-0 p-0 cursor-pointer",children:t.jsx(be,{title:"Scheduler poll health and queue-lint findings — click for the full detail"})}),t.jsxs("span",{className:"ml-auto flex items-center gap-3 shrink-0",children:[t.jsxs("span",{"data-testid":"footer-timing",children:[a?t.jsxs("span",{title:`next 5h reset: ${a}`,children:["reset ",ne(Date.parse(a)-l)]}):null,a&&n?" · ":null,n?t.jsxs("span",{title:n,children:["last run ",ne(l-Date.parse(n))," ago"]}):null]}),t.jsx("button",{type:"button","data-testid":"footer-supervisor",onClick:d,title:"Open supervisor log and settings",className:y,children:"supervisor"}),t.jsx("button",{type:"button","data-testid":"footer-folder",onClick:()=>window.api.schedule.openFolder(),className:y,children:"folder"})]})]}),i&&t.jsxs("div",{"data-testid":"footer-detail",className:"px-[18px] pb-2 space-y-2 font-mono text-[12px] text-fg-dim border-t border-rule-inner pt-2",children:[e&&t.jsxs("div",{className:"space-y-0.5",children:[t.jsxs("div",{children:["booted: ",me(e.bootedAt,l)]}),t.jsxs("div",{children:["last poll: ",me(e.lastPollAt,l)," · ",e.lastPollOk?"ok":"failed"]}),e.backoffNextAt!==null&&e.backoffNextAt>l&&t.jsxs("div",{children:["retry in: ",ne(e.backoffNextAt-l)]}),e.nextResetCached&&t.jsxs("div",{children:["cached reset: ",fe(Date.parse(e.nextResetCached))]}),e.runningJobs.length>0&&t.jsxs("div",{children:["running: ",e.runningJobs.map(j=>`${j.slug}(pid ${j.pid})`).join(", ")]})]}),c&&t.jsxs("div",{className:"space-y-1",children:[N?t.jsxs("div",{className:"text-sage",children:["✓ no issues in ",c.reports.length," PRD",c.reports.length!==1?"s":""]}):m.map(j=>t.jsxs("div",{children:[t.jsx("div",{className:"text-fg-dim truncate",title:j.slug,children:j.slug}),j.findings.map((C,A)=>t.jsxs("div",{className:`pl-3 truncate ${C.severity==="error"?"text-accent/80":"text-butter/90"}`,title:C.snippet,children:[C.severity==="error"?"✗":"⚠"," L",C.line,": ",C.snippet]},`${j.slug}-${A}`))]},j.slug)),t.jsx("button",{type:"button","data-testid":"footer-rerun-lint",onClick:()=>{u(!0),Lt({fresh:!0}).then(o).catch(()=>{}).finally(()=>u(!1))},className:"text-fg-faint hover:text-fg-dim underline",children:p?"…":"rerun lint"})]})]})]})}const ja=5,ya=1440*60*1e3,Te=10,Na=["all","running","investigating","pending","completed","skipped","needs_review","failed","quarantined"];async function ka(e){if(!e)return{text:"",status:"all"};const s=await Qt(e);return{text:"",status:Na.includes(s.queueFilterStatus)?s.queueFilterStatus:"all"}}function Sa(e,s){return e?Yt(e,{queueFilterStatus:s.status}):Promise.resolve()}function Ot(e,s){if(s.status==="all"&&!s.text)return e;const n=s.text.toLowerCase();return e.filter(a=>{if(s.status!=="all"&&a.status!==s.status)return!1;if(!n)return!0;const l=Oe(a.cwd)??"";return a.title.toLowerCase().includes(n)||a.slug.toLowerCase().includes(n)||l.toLowerCase().includes(n)})}async function $a(e){if(!e)return new Set;const s=await Qt(e);return Array.isArray(s.hiddenCompletedSlugs)?new Set(s.hiddenCompletedSlugs.filter(n=>typeof n=="string")):new Set}function Ca(e,s){return e?Yt(e,{hiddenCompletedSlugs:[...s]}):Promise.resolve()}function Pa({scopeCwd:e=null,navigate:s,filterText:n,planMode:a="graph",onOpenPrds:l,planToolsEl:d=null}){var Nt;const i=Be(v=>v.snapshot),r=f.useMemo(()=>!i||!e?i:{...i,jobs:i.jobs.filter(v=>v.cwd===e)},[i,e]),[c,o]=f.useState(null),[p,u]=f.useState(()=>Date.now()),[h,w]=f.useState(new Set),[x,m]=f.useState(!1),[N,P]=f.useState({text:"",status:"all"}),$=f.useMemo(()=>n===void 0?N:{...N,text:n},[N,n]),[_,g]=f.useState(!1),[y,j]=f.useState("queue"),C=f.useRef(null),[A,F]=f.useState(0),[G,z]=f.useState(""),K=it(),X=f.useRef(!1),ee=f.useRef(!1),Q=f.useRef(h);Q.current=h;const I=f.useRef(N);I.current=N,f.useEffect(()=>{let v=!1;return X.current=!1,ee.current=!1,$a(e).then(E=>{!v&&!X.current&&w(E)}),ka(e).then(E=>{!v&&!ee.current&&P(E)}),()=>{v=!0}},[e]),f.useEffect(()=>(window.api.schedule.health().then(o).catch(()=>{}),window.api.schedule.onState(()=>{window.api.schedule.health().then(o).catch(()=>{})})),[]),f.useEffect(()=>{if(!K)return;u(Date.now());const v=setInterval(()=>u(Date.now()),1e3);return()=>clearInterval(v)},[K]);const q=f.useMemo(()=>{if(!r)return 15e4;const v=[];for(const E of r.jobs)if(E.status==="completed"&&E.startedAt&&E.finishedAt){const U=Date.parse(E.finishedAt)-Date.parse(E.startedAt);U>0&&v.push(U)}return v.length===0?15e4:v.reduce((E,U)=>E+U,0)/v.length},[r]),S=f.useRef(new Map);f.useEffect(()=>{if(!r)return;const v=[];for(const E of r.jobs){const U=S.current.get(E.slug);U&&U!==E.status&&v.push(`${E.title}: ${U} → ${E.status}`),S.current.set(E.slug,E.status)}v.length>0&&z(v.join("; "))},[r]);const M=f.useMemo(()=>{var E;const v=new Map;for(const U of((E=r==null?void 0:r.lastTick)==null?void 0:E.holds)??[])v.set(U.slug,U);return v},[r==null?void 0:r.lastTick]),B=he(v=>v.sessions),V=f.useMemo(()=>r?Zt(_e(r.jobs),B,i!=null&&i.jobs?_e(i.jobs):void 0):[],[r,B,i]),Y=Ls(e),b=f.useMemo(()=>r?Ot(Dn(r.jobs,Y,e),$):[],[r,Y,e,$]),k=(Nt=r==null?void 0:r.effectiveConcurrency)==null?void 0:Nt.cap,R=f.useMemo(()=>a==="list"?[]:ut(b,{sessions:B,avgDurationMs:q,concurrency:k}),[a,b,B,q,k]),[D,T]=f.useState(1),O=R.map(v=>`${v.epicId??""}#${v.waveIndex}`).join(",");f.useEffect(()=>{T(1)},[e,$.status,$.text,O]);const L=Math.max(1,Math.ceil(R.length/Te)),te=Math.min(D,L),Ue=f.useMemo(()=>R.slice((te-1)*Te,te*Te),[R,te]),fs=f.useMemo(()=>{const v=new Map;let E=0;for(const U of R)for(const J of U.stages)for(const re of J.rows)v.set(re.slug,E++);return v},[R]),hs=f.useMemo(()=>Mn(V),[V]),xs=h,ht=f.useCallback(v=>{var we;const E=(we=C.current)==null?void 0:we.querySelectorAll("[data-job-row]");if(!E||E.length===0)return;const U=Array.from(E),J=U.findIndex(ae=>ae.dataset.jobIndex===String(A)),re=ae=>{const xe=U[ae];if(!xe)return;const ge=Number(xe.dataset.jobIndex);F(ge),xe.focus()};v.key==="ArrowDown"?(v.preventDefault(),re(J===-1?0:Math.min(J+1,U.length-1))):v.key==="ArrowUp"&&(v.preventDefault(),re(J===-1?U.length-1:Math.max(J-1,0)))},[A]),xt=f.useCallback(v=>{F(v)},[]),gt=f.useCallback(v=>{const E=I.current;ee.current=!0,I.current=v,P(v),Sa(e,v).catch(()=>{I.current===v&&(I.current=E,P(E),W.error("Couldn't save queue filter — reverted."))})},[e]),mt=f.useCallback(v=>{const E=Q.current;X.current=!0,Q.current=v,w(v),Ca(e,v).catch(()=>{Q.current===v&&(Q.current=E,w(E),W.error("Couldn't save hidden completed jobs — reverted."))})},[e]);if(!r)return null;if(y==="supervisor")return t.jsx(ha,{supervisorConfig:r.config.supervisor,onSetConfig:v=>window.api.schedule.setConfig({supervisor:v}),onBack:()=>j("queue")});const{jobs:se,paused:bt,lastRunAt:gs,nextReset:ms,effectiveConcurrency:Ge}=r;if(se.length===0)return t.jsx(ba,{navigate:s});const oe={pending:0,running:0,investigating:0,completed:0,needs_review:0,failed:0};for(const v of se)v.status in oe&&oe[v.status]++;const Ve=se.filter(v=>v.status==="running"),bs=ss({snap:r,now:p,avgDurationMs:q,runningJobs:Ve}),Ne=Ot(se,$),ws=Ma(Ne),{inline:De,collapsedCount:ze}=Da(Ne,h,p,x),vs=Aa(De,se,ws,q,bs.kind,p),wt=()=>{const v=new Set(h);for(const E of se)(E.status==="completed"||E.status==="failed")&&v.add(E.slug);mt(v)},vt=async()=>{const v=se.filter(J=>J.status!=="running").length;if(v===0)return;const E=`Archive ${v} non-running PRD${v===1?"":"s"} and remove from the queue?
|
|
6
|
+
|
|
7
|
+
Files are moved to prds-archived/<timestamp>/ and can be restored from disk. Running jobs are kept.`;if(!window.confirm(E))return;const U=await window.api.schedule.clearQueue();U.ok||W.error(`Clear queue failed: ${U.error??"unknown error"}`)},jt=()=>{mt(new Set),m(!1)},yt=a==="list"?De.some(v=>v.status==="completed"):se.some(v=>(v.status==="completed"||v.status==="skipped")&&!h.has(v.slug)),js=se.filter(v=>(v.status==="completed"||v.status==="failed")&&h.has(v.slug)).length,de=a==="list",Ae=de?"":"px-[18px] py-2";return t.jsxs("div",{className:"overflow-y-auto h-full",children:[t.jsx("div",{"aria-live":"polite","aria-atomic":"true",className:"sr-only",children:G}),t.jsxs("div",{className:de?"px-9 py-6 max-w-[1100px] mx-auto space-y-4":"",children:[c&&c.consecutiveFailures>5&&c.lastFailureKind==="meter_rate_limited"&&!bt&&!_&&t.jsx("div",{className:Ae,children:t.jsxs("div",{className:de?"flex items-center gap-3 px-4 py-3 bg-amber-400/15 border border-amber-400/30 rounded-xl":"flex items-center gap-3 -mx-[18px] px-[18px] py-1 bg-amber-400/15 border-y border-amber-400/30",children:[t.jsx("span",{"aria-hidden":"true",children:"⚠"}),t.jsxs("span",{className:"text-[13.5px] text-amber-400/90",children:[t.jsx("strong",{className:"font-semibold",children:"Usage meter unavailable"})," — last good reading"," ",me(c.lastPollAt,p),". Firing on a conservative estimate until it recovers."]}),t.jsx("button",{type:"button",onClick:()=>g(!0),className:"ml-auto text-[12px] text-amber-400/70 hover:text-amber-400 shrink-0",title:"Dismiss this banner. The scheduler continues firing normally.",children:"Dismiss"})]})}),de&&Ve.length>0&&(()=>{const v=(Ge==null?void 0:Ge.cap)??5,E=se.filter(U=>U.status==="pending").length;return t.jsxs("div",{className:`flex items-center gap-2 text-[12px] font-mono ${Ae}`,children:[t.jsxs("span",{className:"px-2 py-0.5 rounded bg-amber-400/20 text-amber-400 shrink-0",children:[Ve.length,"/",v," running"]}),E>0&&t.jsxs("span",{className:"text-fg-faint",children:["+",E," ready in this group"]})]})})(),de&&se.length>0&&t.jsx("div",{className:Ae,children:t.jsx(Ia,{showText:n===void 0,filter:$,onChange:gt})}),!de&&t.jsxs("div",{"data-testid":"plan-graph",children:[d&&Os.createPortal(t.jsx(Ra,{jobCount:Ne.length,counts:oe,filter:$,onFilter:gt,hiddenInGraph:js,onUnhideAll:jt,hasInlineCompleted:yt,onClearCompleted:wt,onClearQueue:vt,clearQueueDisabled:se.every(v=>v.status==="running")}),d),R.length===0&&t.jsx("div",{className:"px-[18px] py-6 text-[13px] text-fg-faint italic",children:"no matching jobs"}),t.jsx("div",{ref:C,role:"list","aria-label":"Job queue",onKeyDown:ht,children:Ue.map(v=>t.jsx(ra,{plan:v,mode:a,now:p,hidden:xs,indexBySlug:fs,headChoicesBySlug:hs,onRowFocused:xt,onOpenPrds:l},`${v.epicId??"__none__"}#${v.waveIndex}`))}),t.jsx(Fs,{page:te,pageSize:Te,totalItems:R.length,onPageChange:T})]}),de&&t.jsxs("div",{className:"bg-bg-hi border border-line rounded-2xl overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-[18px] py-3 bg-bg-elev",children:[t.jsxs("span",{className:"font-serif text-base font-semibold text-fg",children:[Ne.length," job",Ne.length!==1?"s":""]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("span",{className:"font-mono text-[12px] text-fg-faint",children:[oe.pending,"p · ",oe.running,"r · ",oe.completed,"d",oe.failed>0&&t.jsxs("span",{className:"text-accent",children:[" · ",oe.failed,"f"]})]}),yt&&t.jsx("button",{type:"button",onClick:wt,className:"text-[12.5px] text-fg-dim hover:text-fg bg-transparent border-0 cursor-pointer font-medium",title:"Hide completed jobs from this view (queue.json unchanged — they remain in history)",children:"Clear completed"}),t.jsx("button",{type:"button",onClick:vt,disabled:se.every(v=>v.status==="running"),className:"text-[12px] text-accent border border-accent/40 hover:bg-accent/10 rounded-md px-2.5 py-1 cursor-pointer font-medium disabled:opacity-40 disabled:cursor-not-allowed",title:"Archive every non-running PRD (moved to prds-archived/<timestamp>/) and remove them from the queue. Running jobs are kept.",children:"Archive & clear queue…"})]})]}),De.length===0&&ze===0&&t.jsx("div",{className:"px-[18px] py-6 text-[13px] text-fg-faint italic",children:"no matching jobs"}),t.jsx("div",{ref:C,role:"list","aria-label":"Job queue",onKeyDown:ht,children:(()=>{const v=new Set(De.map(J=>J.slug));let E=0;return V.map(J=>{const re=rs(J),we=J.nodes.map(ae=>{const xe=We([ae]).filter(ge=>v.has(ge.row.slug)).map(ge=>({node:ge,listIndex:E++}));return{headRootSlug:ae.row.slug,rows:xe}}).filter(ae=>ae.rows.length>0);return{section:J,heads:we,headChoices:re}}).filter(J=>J.heads.length>0).map(({section:J,heads:re,headChoices:we})=>t.jsx(ia,{section:J,children:re.map(({headRootSlug:ae,rows:xe},ge)=>t.jsxs("div",{"data-testid":"backlog-head-group",children:[re.length>1&&t.jsxs("div",{className:"px-[18px] pt-2.5 pb-1 text-[11px] font-mono uppercase tracking-wide text-fg-faint bg-bg-elev/30 border-t border-line/60","data-testid":"backlog-head-label",children:["Plan ",ge+1," of ",re.length]}),xe.map(({node:ce,listIndex:ys})=>t.jsx(fa,{job:ce.row,backlog:ce,eta:vs.get(ce.row.slug)??null,elapsedMs:ce.row.status==="running"&&ce.row.startedAt?p-Date.parse(ce.row.startedAt):null,avgDurationMs:q,listIndex:ys,hold:M.get(ce.row.slug),onFocused:xt,headChoices:we.filter(Ns=>Ns.rootSlug!==ae)},ce.row.slug))]},ae))},J.epicId??"__none__"))})()}),ze>0&&t.jsxs("button",{type:"button",onClick:()=>m(v=>!v),className:"w-full text-left text-[12px] text-fg-faint hover:text-fg-dim px-[18px] py-3 border-t border-line",title:x?"Re-collapse old/cleared completed":"Show all completed (incl. cleared and >24h)",children:[x?"▾":"▸"," ",ze," more completed",t.jsx("span",{className:"ml-1.5 font-mono text-[11.5px] text-fg-faint",children:"· fresh & capped at 5 shown inline"}),h.size>0&&t.jsx("span",{className:"ml-2 underline",onClick:v=>{v.stopPropagation(),jt()},children:"un-hide"})]})]}),de&&!bt&&t.jsx("div",{className:Ae,children:t.jsxs("div",{className:"flex gap-2.5 bg-sage/10 border border-sage/30 rounded-xl px-3.5 py-2.5 text-[13.5px] text-fg-dim leading-relaxed",children:[t.jsx("span",{"aria-hidden":"true",children:"✓"}),t.jsxs("span",{children:[t.jsx("strong",{className:"font-semibold text-fg",children:"Nothing needed from you."})," ","Close the app if you like — jobs keep running, and History shows how each one ended."]})]})})]}),t.jsx(va,{health:c,jobCount:se.length,lastRunAt:gs,nextReset:ms,now:p,onOpenSupervisor:()=>j("supervisor")})]})}function Ma(e){const s=new Map(e.map(d=>[d.slug,d])),n=d=>(d.dependsOn??[]).filter(i=>{var r;return((r=s.get(i))==null?void 0:r.status)!=="completed"}).length,a=e.filter(d=>d.status==="running"||d.status==="pending").sort((d,i)=>n(d)-n(i)||d.slug.localeCompare(i.slug)),l=new Map;return a.forEach((d,i)=>l.set(d.slug,i)),l}function Da(e,s,n,a){if(a)return{inline:e,collapsedCount:0};const l=e.filter(o=>o.status==="completed").sort((o,p)=>{const u=o.finishedAt?Date.parse(o.finishedAt):0;return(p.finishedAt?Date.parse(p.finishedAt):0)-u}),d=new Set;let i=0;for(const o of l){if(i>=ja)break;s.has(o.slug)||o.finishedAt&&n-Date.parse(o.finishedAt)>ya||(d.add(o.slug),i++)}const r=[];let c=0;for(const o of e){if(o.status==="failed"&&s.has(o.slug)){c++;continue}if(o.status!=="completed"){r.push(o);continue}d.has(o.slug)?r.push(o):c++}return{inline:r,collapsedCount:c}}function Aa(e,s,n,a,l,d){const i=new Map;if(l==="paused"||l==="manual"||l==="auto-throttled"){for(const o of e)i.set(o.slug,null);return i}const r=s.find(o=>o.status==="running"&&o.startedAt),c=r!=null&&r.startedAt?d-Date.parse(r.startedAt):0;for(const o of e){if(o.status!=="pending"){i.set(o.slug,null);continue}const p=n.get(o.slug)??0;let u=p*a;p>0&&(u-=Math.min(a,c)),i.set(o.slug,u<=5e3?"~now":`~${Ce(u)}`)}return i}const ps=[{label:"All",value:"all"},{label:"Running",value:"running"},{label:"Investigating",value:"investigating"},{label:"Pending",value:"pending"},{label:"Completed",value:"completed"},{label:"Skipped",value:"skipped"},{label:"Needs review",value:"needs_review"},{label:"Failed",value:"failed"},{label:"Quarantined",value:"quarantined"}];function Ra({jobCount:e,counts:s,filter:n,onFilter:a,hiddenInGraph:l,onUnhideAll:d,hasInlineCompleted:i,onClearCompleted:r,onClearQueue:c,clearQueueDisabled:o}){const p="block w-full text-left px-2 py-1 text-[12px] hover:bg-bg-hi disabled:opacity-40 disabled:cursor-not-allowed bg-transparent border-0 cursor-pointer";return t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"font-mono text-[11.5px] text-fg-faint whitespace-nowrap","data-testid":"plan-tools-counts",children:[e," job",e!==1?"s":""," · ",s.pending,"p · ",s.running,"r · ",s.completed,"d",s.failed>0&&t.jsxs("span",{className:"text-accent",children:[" · ",s.failed,"f"]})]}),l>0&&t.jsxs("button",{type:"button",onClick:d,className:"text-[12px] text-fg-faint hover:text-fg-dim underline bg-transparent border-0 cursor-pointer whitespace-nowrap",title:"Show the completed/failed jobs hidden by Clear completed",children:[l," hidden · un-hide"]}),t.jsx("select",{"data-testid":"scheduler-status-filter","aria-label":"Filter by status",value:n.status,onChange:u=>a({...n,status:u.target.value}),className:"bg-bg-hi border border-line rounded px-1 py-0.5 text-[12px] text-fg-dim",title:"Filter the plan graph by job status",children:ps.map(u=>t.jsx("option",{value:u.value,children:u.value==="all"?"all statuses":u.label.toLowerCase()},u.value))}),t.jsx(be,{title:"Queue actions",testId:"plan-tools-menu",popoverTestId:"plan-tools-menu-popover",alignRight:!0,glyph:"⋯",widthCls:"w-52",children:t.jsxs("div",{className:"-mx-3 -my-2",children:[i&&t.jsx("button",{type:"button",onClick:r,className:`${p} text-fg-dim`,title:"Hide completed jobs from this view (queue.json unchanged — they remain in history)",children:"Clear completed"}),t.jsx("button",{type:"button",onClick:c,disabled:o,className:`${p} text-accent`,title:"Archive every non-running PRD (moved to prds-archived/<timestamp>/) and remove them from the queue. Running jobs are kept.",children:"Archive & clear queue…"})]})})]})}function Ia({filter:e,onChange:s,showText:n}){const a=ps;return t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[n&&t.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-[320px]",children:[t.jsx("span",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-fg-faint inline-flex","aria-hidden":"true",children:t.jsx(lt,{name:"search",size:15})}),t.jsx("input",{type:"text",value:e.text,onChange:l=>s({...e,text:l.target.value}),placeholder:"filter jobs…",className:"w-full bg-bg-hi border border-line rounded-xl py-2 pl-9 pr-3 text-[13.5px] text-fg placeholder:text-fg-faint focus:outline-none focus:border-fg-faint","aria-label":"Filter jobs by title, slug, or project"})]}),t.jsx(ns,{options:a,value:e.status,onChange:l=>s({...e,status:l})})]})}const Ta=new Set(["discussion","portfolio"]);new Set(qs.map(e=>e.tag).filter(e=>!Ta.has(e)));const Ea=["title","cwd","estimateMinutes","parallelGroup","sourcePromptId","sourceTabId","tag","agentType","dependsOn","disposition","planId"];function _a(e,s){return!Array.isArray(e)||!Array.isArray(s)?!1:e.length===s.length&&e.every((n,a)=>n===s[a])}function La(e){if(e==null)return"";if(typeof e=="boolean"||typeof e=="number")return String(e);const s=String(e);return s===""||/^(true|false|null|~)$/.test(s)||/^-?\d+(\.\d+)?$/.test(s)||/^\s|\s$/.test(s)||s.startsWith("'")||s.startsWith('"')||s.includes(`
|
|
8
|
+
`)?s.includes("'")?`"${s.replace(/"/g,'\\"')}"`:`'${s}'`:s}function Oa(e,s){var l;const n=[];for(const d of Ea){const i=e[d];if(i==null||i===""||Array.isArray(i)&&i.length===0)continue;const r=(l=e._raw)==null?void 0:l[d];if(r&&(Array.isArray(i)?_a(r.parsed,i):r.parsed===i)){n.push(r.line);continue}if(typeof i=="number"){n.push(`${d}: ${i}`);continue}if(Array.isArray(i)){n.push(`${d}: [${i.join(", ")}]`);continue}n.push(`${d}: ${La(i)}`)}if(e.extras)for(const d of Object.keys(e.extras)){const i=e.extras[d];!i||!i.lines.length||n.push(i.lines.join(`
|
|
9
|
+
`))}return`---
|
|
10
|
+
${n.join(`
|
|
11
|
+
`)}
|
|
12
|
+
---
|
|
13
|
+
${s}`}function Xe(e){return e.filter(s=>!s.archived)}function Fa(e){ot(e),window.dispatchEvent(new CustomEvent("sm:navigate",{detail:"terminal"}))}function Ze({label:e,tip:s,onClick:n,disabled:a,primary:l}){return t.jsx(Ws,{content:s,align:"bottom-center",children:t.jsx("button",{title:s,onClick:n,disabled:a,className:`px-2 py-0.5 text-xs rounded border disabled:opacity-40 disabled:cursor-not-allowed ${l?"text-accent border-accent/50 hover:bg-bg-hi":"text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,children:e})})}function qa({scopeCwd:e=null}){const[s,n]=f.useState([]),[a,l]=f.useState(null),[d,i]=f.useState(null),[r,c]=f.useState(null),[o,p]=f.useState(!1),[u,h]=f.useState(!0),[w,x]=f.useState(new Set),[m,N]=f.useState(!1),[P,$]=f.useState(!1),[_,g]=f.useState(!1),[y,j]=f.useState(null);f.useEffect(()=>{let b=!0;return Ye(e??void 0).then(k=>{b&&(n(Xe(k)),h(!1))}).catch(k=>{b&&(h(!1),W.error(`Scheduler: failed to load PRD list — ${k instanceof Error?k.message:"unknown error"}`))}),()=>{b=!1}},[e]);const C=Be(b=>b.snapshot),A=he(b=>b.sessions);f.useEffect(()=>{C&&l(C)},[C]);const F=f.useMemo(()=>[...s].filter(b=>!e||b.cwd===e).sort((b,k)=>k.mtimeMs-b.mtimeMs||b.slug.localeCompare(k.slug)),[s,e]);f.useEffect(()=>{const b=Hs();b&&i(b);const k=R=>i(R.detail);return window.addEventListener("sm:select-prd",k),()=>window.removeEventListener("sm:select-prd",k)},[]);const G=f.useMemo(()=>(a==null?void 0:a.jobs.find(b=>b.slug===d))??null,[a,d]),z=$t(G);function K(b){var R;const k=(R=s.find(D=>D.slug===b))==null?void 0:R.cwd;return k?`${k}/session-manager-operations/scheduler/prds/${b}.md`:null}f.useEffect(()=>{if(!d)return;const b=K(d);b&&Ct.getState().openFile(b)},[d,s]);function X(b){i(b),c(null),p(!1)}function ee(){i(null)}async function Q(){if(!d)return;if(!(G!=null&&G.runId)){c("no log available (job has not run yet)"),p(k=>!k);return}const b=await window.api.schedule.readLog(G.runId,d);c(b.ok?b.text??"":`error: ${b.error}`),p(k=>!k)}if(u)return t.jsx(Se,{title:"loading PRDs…"});const I=b=>{x(k=>{const R=new Set(k);return R.has(b)?R.delete(b):R.add(b),R})};!(F.length>0&&F.every(b=>w.has(b.slug)))&&F.some(b=>w.has(b.slug));const S=()=>x(new Set);async function M(){try{const b=await Ye(e??void 0);n(Xe(b))}catch{}}async function B(){const b=`new-prd-${Date.now()}`,k=Oa({title:"New PRD",cwd:"",estimateMinutes:60,parallelGroup:99},`## Task
|
|
14
|
+
|
|
15
|
+
Describe the task here.
|
|
16
|
+
`);try{const R=await window.api.schedule.writePrd(b,k);if(!R.ok){W.error(`Failed to create PRD: ${R.error}`);return}const D=await Ye(e??void 0);n(Xe(D)),X(b)}catch(R){W.error(`Failed to create PRD: ${R instanceof Error?R.message:String(R)}`)}}async function V(){var b;g(!0),j(null);try{const k=[...w],R=await window.api.schedule.archivePrds(k);if(!R.ok)j(R.error??"archive failed");else{const D=((b=R.results)==null?void 0:b.filter(T=>!T.ok))??[];D.length>0&&W.warn(`Archive: ${D.length} of ${R.results.length} PRD${D.length===1?"":"s"} failed to move`),S(),N(!1),await M()}}catch(k){j(k instanceof Error?k.message:String(k))}finally{g(!1)}}async function Y(b,k){g(!0),j(null);try{const R=[];for(const T of w){const O={slug:T};b!==null&&(O.parallelGroup=b),k!==null&&(O.estimateMinutes=k),R.push(O)}const D=await window.api.schedule.retagPrds(R);if(!D.ok)j(D.error??"retag failed");else{S(),$(!1),await M();for(const T of D.results)if(T.newSlug&&T.newSlug!==T.slug){const O=K(T.slug),L=K(T.newSlug);O&&L&&Ct.getState().renameOpenFile(O,L)}d&&D.results.some(T=>T.slug===d&&T.newSlug&&T.newSlug!==T.slug)&&i(null)}}catch(R){j(R instanceof Error?R.message:String(R))}finally{g(!1)}}return t.jsxs(t.Fragment,{children:[d?t.jsxs("div",{className:"h-full flex flex-col min-h-0",children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-line flex-wrap shrink-0",children:[t.jsx("button",{type:"button",onClick:ee,className:"text-[11px] text-fg-faint hover:text-fg",children:"← PRDs"}),t.jsx("span",{className:"font-mono text-xs text-fg-dim truncate",children:d}),t.jsx(Pt,{status:z}),t.jsx("div",{className:"flex-1"}),t.jsx(Ze,{label:"Reset",tip:"Reset failed job to pending",onClick:()=>{var b;window.api.schedule.resetJob(d,((b=s.find(k=>k.slug===d))==null?void 0:b.cwd)||void 0)},disabled:z!=="failed"}),t.jsx(Ze,{label:"Run now",tip:"Run all pending jobs immediately",onClick:()=>{Mt()}}),t.jsx(Ze,{label:o?"Hide log":"Last run log",tip:"Toggle most recent run log",onClick:Q})]}),t.jsx("div",{className:"flex-1 min-h-0",children:t.jsx(Bs,{})}),o&&r!==null&&t.jsxs("div",{className:"border-t border-line max-h-64 overflow-auto bg-bg-elev",children:[t.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-2 border-b border-line sticky top-0 bg-bg-elev",children:[t.jsxs("span",{className:"text-[10px] text-fg-faint font-mono",children:["run log",G!=null&&G.runId?` — ${G.runId}`:""]}),t.jsx("button",{onClick:()=>p(!1),className:"ml-auto text-[10px] text-fg-faint hover:text-fg",children:"close"})]}),t.jsx("pre",{className:"p-3 text-[11px] font-mono text-fg-dim whitespace-pre-wrap",children:r})]})]}):t.jsxs("div",{className:"px-6 py-5 overflow-auto",children:[t.jsxs("div",{className:"flex items-start justify-between mb-5 gap-4",children:[t.jsxs("p",{className:"text-[14px] text-fg-dim leading-relaxed max-w-[560px]",children:["PRDs are the source the scheduler runs from. Each one becomes a"," ",t.jsx("code",{className:"font-mono text-[13px]",children:"claude -p"})," job when you queue it. This is where you write and edit the source — to watch a run in progress, use the Queue tab."]}),t.jsx("button",{type:"button",onClick:B,className:"shrink-0 bg-accent text-white rounded-lg px-4 py-[9px] text-[13.5px] font-semibold leading-none",children:"+ New PRD"})]}),w.size>0&&t.jsxs("div",{className:"mb-4 px-4 py-2 bg-bg border border-line rounded-lg flex items-center gap-2",children:[t.jsxs("span",{className:"text-xs text-fg-dim",children:[w.size," selected"]}),t.jsx("div",{className:"flex-1"}),t.jsx("button",{type:"button",onClick:()=>N(!0),className:"text-xs px-3 py-1.5 rounded border border-line text-fg-dim hover:text-fg hover:bg-bg-hi",children:"Archive…"}),t.jsx("button",{type:"button",onClick:()=>$(!0),className:"text-xs px-3 py-1.5 rounded border border-line text-fg-dim hover:text-fg hover:bg-bg-hi",children:"Retag…"}),t.jsx("button",{type:"button",onClick:S,className:"text-xs px-3 py-1.5 rounded border border-line text-fg-dim hover:text-fg hover:bg-bg-hi",children:"Clear"})]}),F.length===0?t.jsx(Se,{title:"no PRDs found"}):t.jsx("div",{className:"grid gap-3",children:F.map(b=>{const k=a==null?void 0:a.jobs.find(L=>L.slug===b.slug),R=$t(k),D=Me({epicId:b.epicId??(k==null?void 0:k.epicId)??null,sourcePromptId:b.sourcePromptId??(k==null?void 0:k.sourcePromptId)??null,sourceTabId:(k==null?void 0:k.sourceTabId)??null},A),T=(k==null?void 0:k.status)==="running",O=(k==null?void 0:k.status)==="needs_review";return t.jsxs("div",{className:"flex items-stretch bg-bg-elev border border-line rounded-2xl overflow-hidden",children:[t.jsx("label",{className:"flex items-center px-3 cursor-pointer hover:bg-bg-hi",children:t.jsx("input",{type:"checkbox",checked:w.has(b.slug),onChange:()=>I(b.slug),className:"accent-accent w-3.5 h-3.5"})}),t.jsxs("div",{className:"flex-1 min-w-0 py-4 pr-2",children:[t.jsxs("div",{className:"flex items-center gap-2.5 mb-[5px] flex-wrap",children:[le(b.slug)&&t.jsx(Gt,{n:le(b.slug)}),t.jsx("button",{type:"button",onClick:()=>X(b.slug),className:"font-serif text-[18px] font-semibold text-fg leading-tight hover:underline text-left",children:b.title||b.slug}),t.jsx(Pt,{status:R}),(k==null?void 0:k.status)&&t.jsx("span",{className:"sr-only",children:k.status})]}),t.jsxs("div",{className:"flex items-center gap-4 font-mono text-xs text-fg-faint flex-wrap",children:[t.jsx(ct,{cwd:b.cwd}),t.jsx(dt,{epicId:D.epicId,label:D.label,onOpen:Fa}),b.estimateMinutes!=null&&t.jsxs("span",{children:[b.estimateMinutes,"m"]}),t.jsxs("span",{className:"opacity-60",title:"parallelGroup — a unique-per-PRD display hint, never an ordering barrier. dependsOn is the real ordering primitive.",children:["g",b.parallelGroup]}),b.dependsOn&&b.dependsOn.length>0&&t.jsxs("span",{title:`depends on: ${b.dependsOn.join(", ")}`,children:["⛓ ",b.dependsOn.length," dep",b.dependsOn.length===1?"":"s"]}),t.jsxs("span",{children:["edited ",me(b.mtimeMs,Date.now())]})]}),t.jsx("button",{type:"button",onClick:()=>X(b.slug),className:"mt-1.5 font-mono text-[11px] text-fg-faint hover:text-fg-dim leading-none",children:b.slug}),O&&t.jsxs("div",{className:"mt-3 space-y-2",children:[(k==null?void 0:k.verifierVerdict)&&t.jsxs("div",{className:"text-xs text-fg-faint",children:["verdict: ",t.jsx("span",{className:"font-mono",children:Pe(k.verifierVerdict)})]}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resetJob(b.slug,b.cwd||void 0),className:"text-xs px-2.5 py-1 rounded border border-line text-fg-dim hover:text-fg hover:bg-bg-hi",children:"Re-fire"})]})]}),t.jsx("div",{className:"flex flex-col gap-2 items-stretch px-[18px] py-4",children:t.jsx("button",{type:"button",onClick:()=>{Mt()},disabled:T,className:"bg-fg text-bg rounded-lg px-[18px] py-2 text-[13px] font-semibold whitespace-nowrap disabled:opacity-50",children:T?"Running…":"Queue job"})})]},b.slug)})})]}),t.jsx(Ba,{open:m,count:w.size,busy:_,onClose:()=>N(!1),onConfirm:V}),t.jsx(Ha,{open:P,count:w.size,busy:_,onClose:()=>$(!1),onConfirm:Y})]})}function Ba({open:e,count:s,busy:n,onClose:a,onConfirm:l}){return t.jsxs(Kt,{open:e,onClose:a,title:"Archive PRDs",children:[t.jsxs("p",{className:"text-xs text-fg-dim",children:["Move ",t.jsx("span",{className:"font-mono",children:s})," PRD",s===1?"":"s"," to"," ",t.jsx("span",{className:"font-mono",children:"prds-archived/<timestamp>/"}),"?"]}),t.jsx("p",{className:"text-[10px] text-fg-faint mt-2",children:"Files are renamed, never deleted. Restore manually from disk if needed."}),t.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[t.jsx("button",{type:"button",onClick:a,disabled:n,className:"px-2 py-1 text-xs border border-line rounded text-fg-dim hover:text-fg disabled:opacity-40",children:"Cancel"}),t.jsx("button",{type:"button",onClick:l,disabled:n||s===0,className:"px-2 py-1 text-xs border border-accent/60 text-accent rounded hover:bg-bg-hi disabled:opacity-40",children:n?"Archiving…":`Archive ${s}`})]})]})}function Ha({open:e,count:s,busy:n,onClose:a,onConfirm:l}){const[d,i]=f.useState(""),[r,c]=f.useState(""),[o,p]=f.useState(null);f.useEffect(()=>{e&&(i(""),c(""),p(null))},[e]);function u(){p(null);let h=null,w=null;if(d.trim()){const x=Number(d);if(!Number.isInteger(x)||x<0||x>999){p("parallelGroup must be 0–999");return}h=x}if(r.trim()){const x=Number(r);if(!Number.isInteger(x)||x<=0){p("estimateMinutes must be a positive integer");return}w=x}if(h===null&&w===null){p("set at least one field");return}l(h,w)}return t.jsxs(Kt,{open:e,onClose:a,title:"Retag PRDs",children:[t.jsxs("p",{className:"text-xs text-fg-dim",children:["Update ",t.jsx("span",{className:"font-mono",children:s})," PRD",s===1?"":"s",". Leave a field blank to keep its current value."]}),t.jsxs("p",{className:"text-[10px] text-fg-faint mt-2",children:["Changing parallelGroup on an ",t.jsx("span",{className:"font-mono",children:"NN-kebab"})," slug renames the file. Every change is logged to ",t.jsx("span",{className:"font-mono",children:"retag-log.jsonl"})," so it's reversible."]}),t.jsxs("div",{className:"mt-3 space-y-2",children:[t.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[t.jsx("span",{className:"w-32 text-fg-faint",children:"parallelGroup:"}),t.jsx("input",{type:"number",min:0,max:999,value:d,onChange:h=>i(h.target.value),placeholder:"(unchanged)",className:"flex-1 bg-bg border border-line rounded px-2 py-1 font-mono text-xs"})]}),t.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[t.jsx("span",{className:"w-32 text-fg-faint",children:"estimateMinutes:"}),t.jsx("input",{type:"number",min:1,value:r,onChange:h=>c(h.target.value),placeholder:"(unchanged)",className:"flex-1 bg-bg border border-line rounded px-2 py-1 font-mono text-xs"})]})]}),o&&t.jsx("div",{className:"mt-2 text-[10px] text-red-300",children:o}),t.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[t.jsx("button",{type:"button",onClick:a,disabled:n,className:"px-2 py-1 text-xs border border-line rounded text-fg-dim hover:text-fg disabled:opacity-40",children:"Cancel"}),t.jsx("button",{type:"button",onClick:u,disabled:n||s===0,className:"px-2 py-1 text-xs border border-accent/60 text-accent rounded hover:bg-bg-hi disabled:opacity-40",children:n?"Retagging…":`Retag ${s}`})]})]})}function Wa(e){ot(e),window.dispatchEvent(new CustomEvent("sm:navigate",{detail:"terminal"}))}function Ft(e){return e?e.slice(0,10):""}const Ua=[{value:"all",label:"All"},{value:"completed",label:"Completed"},{value:"skipped",label:"Skipped"},{value:"failed",label:"Failed"}];function Ga({scopeCwd:e=null}){const[s,n]=f.useState(null),[a,l]=f.useState(!0),[d,i]=f.useState(""),[r,c]=f.useState(""),[o,p]=f.useState(""),[u,h]=f.useState("all");f.useEffect(()=>{l(!0),window.api.schedule.getHistory().then(N=>n(N)).catch(N=>n({ok:!1,jobs:[],error:N instanceof Error?N.message:String(N)})).finally(()=>l(!1))},[]);const w=f.useMemo(()=>{if(!(s!=null&&s.jobs))return[];const N=new Set;for(const P of s.jobs){const $=Oe(P.cwd);$&&N.add($)}return[...N].sort()},[s]),x=f.useMemo(()=>s!=null&&s.jobs?s.jobs.filter(N=>!(e&&N.cwd!==e||u!=="all"&&N.status!==u||d&&Oe(N.cwd)!==d||r&&Ft(N.finishedAt)<r||o&&Ft(N.finishedAt)>o)):[],[s,u,d,r,o,e]);if(a)return t.jsx(Se,{title:"Loading history…"});if(!(s!=null&&s.ok)||s.error)return t.jsxs("div",{className:"p-4 text-xs text-red-300",children:["Failed to load history: ",(s==null?void 0:s.error)??"unknown error"]});if(s.jobs.length===0)return t.jsx(Se,{title:"No history yet",hint:"Completed and failed jobs appear here."});const m=u!=="all"||!!d||!!r||!!o;return t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-4 py-2.5 border-b border-line flex-wrap",children:[t.jsx(ns,{options:Ua,value:u,onChange:h,pillPadding:"px-3 py-1"}),t.jsx("span",{className:"w-px h-4 bg-line mx-1","aria-hidden":"true"}),w.length>0&&t.jsxs("select",{value:d,onChange:N=>i(N.target.value),className:"bg-bg-hi border border-line rounded-lg px-2 py-1 text-[12.5px] text-fg-dim max-w-[12rem] font-medium",children:[t.jsx("option",{value:"",children:"All projects"}),w.map(N=>t.jsx("option",{value:N,children:N},N))]}),t.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] text-fg-faint",children:[t.jsx("span",{children:"from"}),t.jsx("input",{type:"date",value:r,onChange:N=>c(N.target.value),className:"bg-bg-hi border border-line rounded-lg px-2 py-1 text-fg-dim font-mono text-[12px]"})]}),t.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] text-fg-faint",children:[t.jsx("span",{children:"to"}),t.jsx("input",{type:"date",value:o,onChange:N=>p(N.target.value),className:"bg-bg-hi border border-line rounded-lg px-2 py-1 text-fg-dim font-mono text-[12px]"})]}),t.jsxs("span",{className:"text-[12px] text-fg-faint ml-auto font-mono",children:[x.length," / ",s.jobs.length]}),m&&t.jsx("button",{type:"button",onClick:()=>{h("all"),i(""),c(""),p("")},className:"text-[12px] text-fg-faint hover:text-fg-dim underline",children:"clear"})]}),t.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:x.length===0?t.jsx(Se,{title:"No matches",hint:"Try adjusting the filters."}):t.jsxs("div",{className:"mx-4 my-3 bg-bg-hi border border-line rounded-2xl overflow-hidden",children:[t.jsx("div",{className:"flex items-center px-[18px] py-3 bg-bg-elev",children:t.jsxs("span",{className:"font-serif text-base font-semibold text-fg",children:[x.length," job",x.length!==1?"s":""]})}),x.map(N=>t.jsx(Va,{job:N},`${N.slug}-${N.finishedAt??""}`))]})})]})}function Va({job:e}){const[s,n]=f.useState(!1),[a,l]=f.useState(!1),d=he(h=>h.sessions),i=f.useMemo(()=>Me(e,d),[e,d]),r=e.startedAt&&e.finishedAt?Date.parse(e.finishedAt)-Date.parse(e.startedAt):null,c=e.startedAt?new Date(e.startedAt).toLocaleString():"—",o=e.finishedAt?new Date(e.finishedAt).toLocaleString():"—",p=r!==null?Ce(r):"—",u=e.exitCode!==null?String(e.exitCode):"—";return t.jsxs("div",{className:"border-t border-line/60",children:[t.jsxs("button",{type:"button",className:`w-full text-left grid items-center gap-4 px-[18px] py-3.5 cursor-pointer transition-colors hover:bg-bg-elev ${s?"bg-bg-elev":"bg-transparent"}`,style:{gridTemplateColumns:"116px 1fr auto auto"},onClick:()=>n(h=>!h),"aria-expanded":s,children:[t.jsx(Ut,{status:e.status}),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 text-pretty",children:[e.title,t.jsx(Vt,{leaked:e.leakedDescendants})]}),e.error&&!s&&(e.status==="failed"||e.status==="needs_review")&&t.jsx("div",{className:"text-[12.5px] mt-0.5 text-accent/80 truncate",children:e.error}),i.epicId&&t.jsx("span",{className:"flex mt-0.5",children:t.jsx(dt,{epicId:i.epicId,label:i.label,onOpen:Wa})})]}),t.jsx(ct,{cwd:e.cwd}),t.jsxs("span",{className:"inline-flex items-center gap-2.5 font-mono text-xs text-fg-faint whitespace-nowrap",children:[p,t.jsx("span",{className:"inline-flex transition-transform duration-150",style:{transform:s?"rotate(90deg)":"none"},"aria-hidden":"true",children:"›"})]})]}),s&&t.jsxs("div",{className:"grid gap-5 px-[18px] pt-1 pb-5 bg-bg-elev",style:{gridTemplateColumns:"repeat(auto-fit, minmax(160px, 1fr))"},children:[t.jsxs(ie,{label:"Status",children:[t.jsx(H,{k:"result",v:u}),t.jsx(H,{k:"state",v:e.status.replace("_"," ")}),e.verifierVerdict&&t.jsx(H,{k:"verifier",v:Pe(e.verifierVerdict)}),e.leakedDescendants&&e.leakedDescendants.length>0&&t.jsx(H,{k:"leaked",v:zt(e.leakedDescendants),wrap:!0})]}),t.jsxs(ie,{label:"Timing",children:[t.jsx(H,{k:"started",v:c}),t.jsx(H,{k:"finished",v:o}),t.jsx(H,{k:"duration",v:p})]}),t.jsxs(ie,{label:"Location",children:[t.jsx(H,{k:"group",v:e.parallelGroup!=null?String(e.parallelGroup):"—"}),t.jsx(H,{k:"slug",v:e.slug}),t.jsx(H,{k:"epic",v:i.label??i.epicId??"—",wrap:!0}),e.cwd&&t.jsx(H,{k:"cwd",v:e.cwd,wrap:!0})]}),t.jsx(ie,{label:"Actions",children:t.jsxs("div",{className:"flex flex-col gap-2 items-start",children:[e.runId&&t.jsx("button",{type:"button",onClick:h=>{h.stopPropagation(),l(!0)},className:"text-[13px] font-semibold text-fg-dim hover:text-fg bg-transparent border-0 p-0 cursor-pointer",children:"view log →"}),e.status!=="pending"&&t.jsx("button",{type:"button",onClick:h=>{h.stopPropagation(),window.api.schedule.resetJob(e.slug,e.cwd??void 0)},className:"text-[13px] font-semibold text-fg-dim hover:text-fg bg-transparent border-0 p-0 cursor-pointer",children:"reset to pending →"}),e.error&&t.jsx("p",{className:"text-[12px] text-accent/90 mt-1 break-words whitespace-pre-wrap max-w-sm m-0",children:e.error})]})})]}),a&&e.runId&&t.jsx(He,{runId:e.runId,slug:e.slug,title:e.title||e.slug,onClose:()=>l(!1)})]})}function za(){const e=Ht(),[s,n]=f.useState(null);return f.useEffect(()=>{var l,d;let a=!0;return(d=(l=window.api.schedule).worktreeBase)==null||d.call(l).then(i=>{a&&n(i)}).catch(()=>{}),()=>{a=!1}},[]),t.jsxs("div",{className:"max-w-[760px] space-y-6",children:[t.jsxs("section",{className:"border border-line rounded-xl bg-bg-hi px-5 py-4",children:[t.jsx("h2",{className:"m-0 mb-1 font-serif text-[18px] font-semibold text-fg",children:"Session pool"}),t.jsxs("p",{className:"mt-0 mb-3 text-[13px] text-fg-dim leading-relaxed",children:["One machine-wide pool of concurrent Claude sessions. Scheduler jobs and Epic chat runs each request a slot before launching; work waits when the pool is full. Adjustable from 0 (pauses new launches) to ",(e==null?void 0:e.max)??10," on the Home tab, default 5 — or pin it with"," ",t.jsx("code",{className:"font-mono text-[12px]",children:"SM_SESSION_SLOTS"})," (clamped 0–",(e==null?void 0:e.max)??10,")."]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Us,{total:(e==null?void 0:e.total)??5,inUse:(e==null?void 0:e.inUse)??0,size:"md"}),t.jsx("span",{className:"ml-2 font-mono text-[12.5px] text-fg-faint",children:e?`${e.inUse} / ${e.total} in use`:"loading…"})]}),e&&e.holders.length>0&&t.jsx("ul",{className:"mt-2 mb-0 pl-0 list-none space-y-0.5",children:e.holders.map((a,l)=>t.jsxs("li",{className:"font-mono text-[12px] text-fg-dim",children:[a.owner," ",t.jsxs("span",{className:"text-fg-faint",children:["since ",new Date(a.at).toLocaleTimeString()]})]},l))})]}),t.jsxs("section",{className:"border border-line rounded-xl bg-bg-hi px-5 py-4",children:[t.jsx("h2",{className:"m-0 mb-1 font-serif text-[18px] font-semibold text-fg",children:"On disk"}),t.jsxs("p",{className:"mt-0 mb-2 text-[13px] text-fg-dim leading-relaxed",children:["Global runtime state is deliberately small — everything project-scoped lives inside that project's ",t.jsx("code",{className:"font-mono text-[12px]",children:"session-manager-operations/"})," folder."]}),t.jsxs("ul",{className:"m-0 pl-0 list-none space-y-1 font-mono text-[12px] text-fg-dim",children:[t.jsxs("li",{children:["~/.claude/session-manager/scheduler-machine.json ",t.jsx("span",{className:"text-fg-faint",children:"— policy + pause state"})]}),t.jsxs("li",{"data-testid":"worktree-base-path",children:[s??"…","/session-manager-epic-worktrees/ ",t.jsx("span",{className:"text-fg-faint",children:"— Epic git worktrees (SM_WORKTREE_ROOT overrides)"})]}),t.jsxs("li",{children:["<project>/session-manager-operations/scheduler/state/ ",t.jsx("span",{className:"text-fg-faint",children:"— per-project queue + history"})]}),t.jsxs("li",{children:["<project>/session-manager-operations/scheduler/epics/<epic>/prds/ ",t.jsx("span",{className:"text-fg-faint",children:"— PRD sources, per session"})]})]})]})]})}function Qa(e){return typeof e.slotWaitMs=="number"?qe(e.slotWaitMs):typeof e.slotWaitSec=="number"?qe(e.slotWaitSec*1e3):"—"}function Ya(e){return e.quota?e.quota.rateLimited?e.quota.resetsAt?`rate limited · resets ${ft(e.quota.resetsAt)}`:"rate limited":"ok":"—"}function Z({label:e,children:s}){return t.jsxs(t.Fragment,{children:[t.jsx("dt",{className:"text-fg-faint",children:e}),t.jsx("dd",{className:"font-mono text-fg break-all","data-testid":`task-detail-fact-${e.replace(/\s+/g,"-").toLowerCase()}`,children:s})]})}function qt({label:e,testid:s,text:n,sha:a,bytes:l,truncated:d,onCopy:i}){return t.jsxs("section",{className:"mt-3","data-testid":s,children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1 text-[12px]",children:[t.jsx("h4",{className:"font-semibold text-fg uppercase tracking-wider",children:e}),d&&t.jsx("span",{"data-testid":`${s}-truncated`,title:"The stored copy was capped at 1 MiB; the sha256 is of the full text.",className:"px-1.5 py-px rounded border border-honey/50 text-honey-dark text-[11px]",children:"truncated"}),typeof l=="number"&&t.jsxs("span",{className:"text-fg-faint font-mono text-[11px]",children:[l," B"]}),t.jsx("button",{type:"button","data-testid":`${s}-copy`,disabled:n===void 0,onClick:()=>{n!==void 0&&i(e,n)},className:"ml-auto px-1.5 py-px rounded border border-line text-[11px] text-fg-dim hover:bg-bg-elev disabled:opacity-50",children:"Copy"})]}),t.jsxs("div",{className:"text-[11px] font-mono text-fg-faint break-all mb-1","data-testid":`${s}-sha`,children:["sha256 ",a??"—"]}),t.jsx("pre",{className:"max-h-[320px] overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] text-fg bg-bg-hi border border-line rounded p-2",children:n??"(no body stored)"})]})}function Ka({cwd:e,taskId:s,onClose:n}){var p,u,h,w;const a=Jt(x=>x.show),[l,d]=f.useState(null),[i,r]=f.useState("loading");f.useEffect(()=>{let x=!0;return r("loading"),d(null),window.api.tasks.get({cwd:e,id:s}).then(m=>{if(x){if(!m.ok){r("error"),a("error",`Task ${s}: ${m.error}`);return}if(!m.task){r("missing");return}d(m.task),r("ready")}}).catch(m=>{x&&(r("error"),a("error",`Task ${s}: ${m instanceof Error?m.message:String(m)}`))}),()=>{x=!1}},[e,s,a]),f.useEffect(()=>{const x=m=>{m.key==="Escape"&&n()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[n]);const c=f.useCallback(async(x,m)=>{await Gs(m)?a("info",`${x} copied`):a("error",`Copy ${x.toLowerCase()} failed`)},[a]),o=l==null?void 0:l.caller;return t.jsxs("aside",{className:"h-full overflow-y-auto px-4 py-4 border-l border-line bg-bg","data-testid":"task-detail",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.jsxs("h3",{className:"text-[13px] font-semibold text-fg font-mono truncate",title:s,children:["Task ",s]}),(l==null?void 0:l.source)==="direct"&&t.jsx("span",{"data-testid":"task-detail-badge-direct",title:"Imported: this call ran directly, outside Session Manager's slot cap.",className:"inline-block px-1.5 py-px rounded border border-honey/50 text-honey-dark text-[11px] whitespace-nowrap",children:"ran without SM"}),t.jsx("button",{type:"button","data-testid":"task-detail-close",onClick:n,"aria-label":"Close Task detail",className:"ml-auto px-2 py-0.5 rounded border border-line text-[12px] text-fg-dim hover:bg-bg-elev",children:"Close"})]}),i==="loading"&&t.jsx("div",{className:"text-[12px] text-fg-faint",children:"Loading…"}),i==="missing"&&t.jsx("div",{className:"text-[12px] text-fg-faint","data-testid":"task-detail-missing",children:"This Task is no longer in the ledger."}),i==="error"&&t.jsx("div",{className:"text-[12px] text-accent-dark",children:"Could not load this Task."}),l&&t.jsxs(t.Fragment,{children:[t.jsxs("dl",{className:"grid grid-cols-[110px_1fr] gap-x-3 gap-y-0.5 text-[12px]",children:[t.jsx(Z,{label:"Status",children:l.status}),t.jsx(Z,{label:"Exit code",children:typeof l.exitCode=="number"?l.exitCode:"—"}),t.jsx(Z,{label:"Agent",children:l.agent??"—"}),t.jsx(Z,{label:"Model",children:l.model??"—"}),t.jsx(Z,{label:"Effort",children:l.effort??"—"}),t.jsx(Z,{label:"Mission",children:l.missionId??"—"}),t.jsx(Z,{label:"Pipeline",children:(o==null?void 0:o.pipeline)??"—"}),t.jsx(Z,{label:"Run",children:(o==null?void 0:o.runId)??"—"}),t.jsx(Z,{label:"Step",children:(o==null?void 0:o.step)??"—"}),t.jsx(Z,{label:"Attempt",children:typeof(o==null?void 0:o.attempt)=="number"?o.attempt:"—"}),t.jsx(Z,{label:"Started",children:ft(l.startedAt)}),t.jsx(Z,{label:"Quota",children:Ya(l)}),t.jsx(Z,{label:"Slot wait",children:Qa(l)}),t.jsx(Z,{label:"Duration",children:qe(l.durationMs)}),t.jsx(Z,{label:"Cost",children:typeof l.costUsd=="number"?Xt(l.costUsd):"—"}),l.error&&t.jsx(Z,{label:"Error",children:l.error})]}),t.jsx(qt,{label:"Prompt",testid:"task-detail-prompt",text:(p=l.body)==null?void 0:p.prompt,sha:l.promptSha256,bytes:l.promptBytes,truncated:((u=l.body)==null?void 0:u.promptTruncated)===!0,onCopy:(x,m)=>{c(x,m)}}),t.jsx(qt,{label:"Output",testid:"task-detail-output",text:(h=l.body)==null?void 0:h.output,sha:l.outputSha256,bytes:l.outputBytes,truncated:((w=l.body)==null?void 0:w.outputTruncated)===!0,onCopy:(x,m)=>{c(x,m)}})]})]})}const Ja=15e3,Xa=200,pt="Ungrouped",Za="(no run)",ve=["pipeline","step","agent","status"];function et(e,s){var n,a;return s==="pipeline"?((n=e.caller)==null?void 0:n.pipeline)||pt:s==="step"?((a=e.caller)==null?void 0:a.step)||void 0:s==="agent"?e.agent||void 0:e.status||void 0}function tt(e){const s=e.startedAt?Date.parse(e.startedAt):NaN;return Number.isFinite(s)?s:0}const er=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"});function ft(e){if(!e)return"—";const s=new Date(e);return Number.isNaN(s.getTime())?"—":er.format(s)}function qe(e){if(typeof e!="number"||!Number.isFinite(e)||e<0)return"—";if(e<6e4)return`${(e/1e3).toFixed(1)}s`;const s=Math.round(e/1e3),n=Math.floor(s/3600),a=Math.floor(s%3600/60),l=s%60;return n>0?`${n}h ${String(a).padStart(2,"0")}m`:`${a}m ${String(l).padStart(2,"0")}s`}function tr(e){var l,d,i;const s=new Map;for(const r of e){const c=((l=r.caller)==null?void 0:l.pipeline)||pt,o=((d=r.caller)==null?void 0:d.runId)||Za;let p=s.get(c);p||(p=new Map,s.set(c,p));const u=p.get(o);u?u.push(r):p.set(o,[r])}const n=r=>r.reduce((c,o)=>Math.max(c,tt(o)),0),a=[];for(const[r,c]of s){const o=[];for(const[p,u]of c){const h=[...u].sort((w,x)=>tt(x)-tt(w));o.push({runId:p,rows:h,newest:n(h)})}o.sort((p,u)=>u.newest-p.newest),a.push({pipeline:r,runs:o,newest:((i=o[0])==null?void 0:i.newest)??0})}return a.sort((r,c)=>c.newest-r.newest),a}const sr={ok:"text-sage-dark border-sage/50 bg-sage/15",running:"text-accent-dark border-accent/40",error:"text-accent-dark border-accent/40 bg-accent/15",spawn_failed:"text-accent-dark border-accent/40 bg-accent/15",timeout:"text-honey-dark border-honey/50",rate_limited:"text-honey-dark border-honey/50",interrupted:"text-honey-dark border-honey/50",caller_gone:"text-fg-dim border-line"};function nr({t:e}){var n;const s=[e.status];return typeof e.exitCode=="number"&&s.push(`exit ${e.exitCode}`),(n=e.quota)!=null&&n.rateLimited&&s.push("quota"),t.jsx("span",{"data-testid":"tasks-status-chip",title:e.error??void 0,className:`inline-block px-1.5 py-px rounded border text-[11px] font-mono whitespace-nowrap ${sr[e.status]??"text-fg-dim border-line"}`,children:s.join(" · ")})}function ar({scopeCwd:e}){const s=Jt(g=>g.show),[n,a]=f.useState(null),l=f.useCallback(()=>a(null),[]),[d,i]=f.useState([]),[r,c]=f.useState(!1),[o,p]=f.useState({}),[u,h]=f.useState({pipeline:[],step:[],agent:[],status:[]}),[w,x]=f.useState(null),m=f.useCallback(async(g,y,j)=>{const C={cwd:g};for(const A of ve){const F=y[A];F&&!(A==="pipeline"&&F===pt)&&(C[A]=F)}C.limit=Xa;try{const A=await window.api.tasks.list(C);if(!j())return;if(!A.ok){s("error",`Tasks: ${A.error}`);return}i(A.tasks),c(!0),h(F=>{const G={...F};let z=!1;for(const K of ve){const X=new Set(F[K]);for(const ee of A.tasks){const Q=et(ee,K);Q&&X.add(Q)}X.size!==F[K].length&&(G[K]=[...X].sort(),z=!0)}return z?G:F})}catch(A){j()&&s("error",`Tasks: ${A instanceof Error?A.message:String(A)}`)}},[s]);f.useEffect(()=>{if(!e)return;let g=!0;const y=()=>g;m(e,o,y);const j=setInterval(()=>{m(e,o,y)},Ja);return()=>{g=!1,clearInterval(j)}},[e,o,m]),f.useEffect(()=>{if(!e)return;let g=!0;return window.api.tasks.getSwitch({cwd:e}).then(y=>{g&&(y.ok?x(y.enabled):s("error",`Tasks switch: ${y.error}`))}).catch(y=>{g&&s("error",`Tasks switch: ${y instanceof Error?y.message:String(y)}`)}),()=>{g=!1}},[e,s]);const N=f.useCallback(async g=>{if(e)try{const y=await window.api.tasks.setSwitch({cwd:e,enabled:g});y.ok?x(y.enabled):s("error",`Tasks switch: ${y.error}`)}catch(y){s("error",`Tasks switch: ${y instanceof Error?y.message:String(y)}`)}},[e,s]),P=f.useMemo(()=>{const g={};for(const y of ve){const j=new Set(u[y]);for(const A of d){const F=et(A,y);F&&j.add(F)}const C=o[y];C&&j.add(C),g[y]=[...j].sort()}return g},[d,u,o]),$=n!==null,_=f.useMemo(()=>{const g=d.filter(y=>ve.every(j=>!o[j]||et(y,j)===o[j]));return tr(g)},[d,o]);return e?t.jsxs("div",{className:"h-full flex min-h-0","data-testid":"tasks-view",children:[t.jsxs("div",{className:"flex-1 min-w-0 h-full overflow-y-auto px-9 py-4","data-testid":"tasks-list",children:[t.jsx("div",{className:"flex items-center mb-2","data-testid":"tasks-header",children:t.jsxs("label",{className:"flex items-center gap-2 text-[12px] text-fg-dim",title:"While off, scripts that call the Tasks endpoint get HTTP 403.",children:[t.jsx("input",{type:"checkbox","data-testid":"tasks-switch",checked:w===!0,disabled:w===null,onChange:g=>{N(g.target.checked)},className:"cursor-pointer"}),t.jsx("span",{className:"text-fg",children:"Scripts may run Tasks"}),t.jsx("span",{className:"text-fg-faint",children:"— while off, scripts get 403."})]})}),t.jsx("div",{className:"flex items-center gap-3 flex-wrap mb-3","data-testid":"tasks-filters",children:ve.map(g=>t.jsxs("label",{className:"flex items-center gap-1 text-[12px] text-fg-dim",children:[t.jsx("span",{className:"capitalize",children:g}),t.jsxs("select",{"data-testid":`tasks-filter-${g}`,value:o[g]??"",onChange:y=>{const j=y.target.value;p(C=>{const A={...C};return j?A[g]=j:delete A[g],A})},className:"bg-bg-hi border border-line rounded px-1.5 py-0.5 text-[12px] text-fg",children:[t.jsx("option",{value:"",children:"all"}),P[g].map(y=>t.jsx("option",{value:y,children:y},y))]})]},g))}),r&&_.length===0&&t.jsxs("div",{className:"text-[13px] text-fg-faint py-6","data-testid":"tasks-empty",children:["No Tasks yet for this project",ve.some(g=>o[g])?" matching these filters":"","."]}),_.map(g=>t.jsxs("section",{"data-testid":`tasks-group-${g.pipeline}`,className:"mb-4",children:[t.jsx("h3",{className:"text-[12px] font-semibold text-fg uppercase tracking-wider mb-1",children:g.pipeline}),g.runs.map(y=>t.jsxs("div",{className:"mb-2 border border-line rounded",children:[t.jsxs("div",{className:"px-2 py-1 text-[11px] font-mono text-fg-faint border-b border-line",children:["run ",y.runId]}),y.rows.map(j=>{var C,A;return t.jsxs("button",{type:"button","data-testid":`tasks-row-${j.taskId}`,onClick:()=>a(j.taskId),"aria-pressed":n===j.taskId,className:`w-full text-left pl-2 pr-2 py-1 flex items-center gap-3 text-[12px] hover:bg-bg-elev border-b border-line last:border-b-0 ${n===j.taskId?"bg-bg-elev":""}`,children:[t.jsx("span",{className:"w-[170px] shrink-0 font-mono text-fg-dim",children:ft(j.startedAt)}),!$&&t.jsx("span",{"data-testid":"tasks-cell-step",className:"w-[90px] shrink-0 truncate text-fg-faint",title:(C=j.caller)==null?void 0:C.step,children:((A=j.caller)==null?void 0:A.step)??"—"}),t.jsx("span",{className:"w-[120px] shrink-0 truncate text-fg",children:j.agent??"—"}),!$&&t.jsx("span",{"data-testid":"tasks-cell-model",className:"w-[90px] shrink-0 truncate text-fg-dim",children:j.model??"—"}),t.jsx("span",{className:"w-[70px] shrink-0 font-mono text-fg-dim",children:qe(j.durationMs)}),t.jsx("span",{className:"w-[70px] shrink-0 font-mono text-fg-dim",children:typeof j.costUsd=="number"?Xt(j.costUsd):"—"}),t.jsxs("span",{className:"flex-1 min-w-0 flex flex-wrap items-center gap-1",children:[t.jsx(nr,{t:j}),j.source==="direct"&&t.jsx("span",{"data-testid":"tasks-badge-direct",title:"Imported: this call ran directly, outside Session Manager's slot cap.",className:"inline-block px-1.5 py-px rounded border border-honey/50 text-honey-dark text-[11px] whitespace-nowrap",children:"ran without SM"})]})]},j.taskId)})]},y.runId))]},g.pipeline))]}),n&&t.jsx("div",{className:"w-[46%] max-w-[720px] shrink-0 h-full min-h-0",children:t.jsx(Ka,{cwd:e,taskId:n,onClose:l},n)})]}):t.jsx("div",{className:"h-full flex items-center justify-center text-[13px] text-fg-faint","data-testid":"tasks-view",children:"Open a project to see its Tasks"})}const Bt="sm.schedulerTab.subView";function rr({navigate:e}={}){var x;const[s,n]=f.useState("graph"),[a,l]=f.useState(""),[d,i]=f.useState(null),[r,c]=f.useState(()=>{const m=localStorage.getItem(Bt);return m==="prds"||m==="history"||m==="machine"||m==="tasks"?m:"queue"}),o=Dt(m=>m.tabs),p=Dt(m=>m.activeTabId),u=((x=o.find(m=>m.id===p))==null?void 0:x.cwd)??null,h=u;f.useEffect(()=>{u&&(he.getState().hydrate(u),he.getState().hydrateArchived(u))},[u]);const w=f.useCallback(m=>{m&&Vs(m),c("prds")},[]);return f.useEffect(()=>{localStorage.setItem(Bt,r)},[r]),t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(Cn,{scopeCwd:h,subView:r,onSubView:c,filterText:a,onFilterText:l,planMode:s,onPlanMode:n,planToolsRef:i}),t.jsxs("div",{className:"flex-1 min-h-0",children:[r==="queue"&&t.jsx(Pa,{scopeCwd:h,navigate:e,filterText:a,planMode:s,onOpenPrds:w,planToolsEl:d}),r==="prds"&&t.jsx(qa,{scopeCwd:h}),r==="history"&&t.jsx(Ga,{scopeCwd:h}),r==="tasks"&&t.jsx(ar,{scopeCwd:h},h??""),r==="machine"&&t.jsx("div",{className:"h-full overflow-y-auto px-9 py-6",children:t.jsx(za,{})})]})]})}const dr=f.memo(rr);export{dr as Scheduler};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{aR as Z,R as wo,ay as ko,aB as tr}from"./index-
|
|
1
|
+
import{aR as Z,R as wo,ay as ko,aB as tr}from"./index-B2TQz3nd.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.
|