claude-code-session-manager 0.140.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/dist/assets/{AppSettings-CMFEM68R.js → AppSettings-DExeJhqQ.js} +1 -1
- package/dist/assets/{History--JwsFnbn.js → History-DJMiuXyK.js} +1 -1
- package/dist/assets/{HomeClaudeConfig-ijEXs--3.js → HomeClaudeConfig-CTp2tkZ4.js} +2 -2
- package/dist/assets/{Panel-CALyU0pe.js → Panel-Bf1Cf8UL.js} +1 -1
- package/dist/assets/{ProjectClaudeConfig-sdlA-fUb.js → ProjectClaudeConfig-BWPpypf9.js} +1 -1
- package/dist/assets/{Scheduler-YT3j8SUa.js → Scheduler-cyr61UAC.js} +1 -1
- package/dist/assets/{SkillReferenceGraph-CxAuwhNN.js → SkillReferenceGraph-Ba4TkX2C.js} +1 -1
- package/dist/assets/{Skills-DtRzghn5.js → Skills-C1v91GEO.js} +1 -1
- package/dist/assets/{TiptapBody-DApeu7x8.js → TiptapBody-BrcWVpiW.js} +1 -1
- package/dist/assets/{ViewTabs-B7qLXRAH.js → ViewTabs-DXhOWFG0.js} +1 -1
- package/dist/assets/{VoiceButton-DtStfv1H.js → VoiceButton-qivnDV6K.js} +1 -1
- package/dist/assets/{historyTotals-ydfnwepc.js → historyTotals-CMCPTKqC.js} +1 -1
- package/dist/assets/{index-CtxruO1L.js → index-B2TQz3nd.js} +3 -3
- package/dist/index.html +1 -1
- package/dist-web/app.js +1 -1
- package/package.json +1 -1
- package/plugins/session-manager-dev/skills/builder/SKILL.md +4 -2
- package/plugins/session-manager-dev/skills/develop/SKILL.md +3 -0
- package/scripts/scheduler-mcp-server.cjs +5 -0
- package/src/main/build-info.json +4 -4
- package/src/main/ipcSchemas.cjs +10 -0
- package/src/main/lib/mcpToolCatalog.cjs +11 -2
- package/src/main/lib/prd/prdCreate.cjs +27 -1
- package/src/main/lib/prd/prdFrontmatter.cjs +28 -3
- package/src/main/lib/scheduler/preflightCheck.cjs +97 -0
- package/src/main/lib/scheduler/reviewNotice.cjs +39 -0
- package/src/main/scheduler/prdParser.cjs +16 -1
- package/src/main/scheduler/reviewLadder.cjs +36 -3
- package/src/main/scheduler/starvation.cjs +69 -0
- package/src/main/scheduler.cjs +335 -25
- package/src/main/templates/PRD_AUTHORING.md +9 -1
|
@@ -1,4 +1,4 @@
|
|
|
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-CtxruO1L.js";import{f as zs,a as Qs,s as Ys,u as Xt}from"./historyTotals-ydfnwepc.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(`
|
|
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
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
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
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(`
|
|
@@ -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.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{ac as Ae,aR as u,ba as W,aB as e,b as Ie,a9 as Pe,ah as Kt,bk as Rn,aA as In,g as Mn,t as Un,u as $n,W as Bn,j as Fn,k as Hn,am as Gn,bf as G,m as K,al as ss,aj as Wn,b1 as ns,au as qn,a7 as Fs,bl as Oe,c as ye,aC as Vt,ag as Hs,bb as Et,bn as Gs,bu as zt,y as Kn,B as Vn,V as Ws,x as zn,by as qs,U as ze,bw as os,bq as Yn,aF as Xn,aJ as Jn,b0 as Qn,ax as Ks,J as Zn,as as eo,an as Vs,aZ as to,bg as zs}from"./index-
|
|
1
|
+
import{ac as Ae,aR as u,ba as W,aB as e,b as Ie,a9 as Pe,ah as Kt,bk as Rn,aA as In,g as Mn,t as Un,u as $n,W as Bn,j as Fn,k as Hn,am as Gn,bf as G,m as K,al as ss,aj as Wn,b1 as ns,au as qn,a7 as Fs,bl as Oe,c as ye,aC as Vt,ag as Hs,bb as Et,bn as Gs,bu as zt,y as Kn,B as Vn,V as Ws,x as zn,by as qs,U as ze,bw as os,bq as Yn,aF as Xn,aJ as Jn,b0 as Qn,ax as Ks,J as Zn,as as eo,an as Vs,aZ as to,bg as zs}from"./index-B2TQz3nd.js";import{s as is,V as Ys,T as Me,S as Xs}from"./ViewTabs-DXhOWFG0.js";import{P as qe}from"./Panel-Bf1Cf8UL.js";import{b as so,c as no,T as oo}from"./TiptapBody-BrcWVpiW.js";const bt=[{id:"permissions",label:"Permissions",tab:"permissions",keys:["permissions"]},{id:"hooks",label:"Hooks",tab:"hooks",keys:["hooks","disableAllHooks","allowedHttpHookUrls","httpHookAllowedEnvVars"]},{id:"mcp",label:"MCP Servers",tab:null,keys:["enabledMcpjsonServers","disabledMcpjsonServers","enableAllProjectMcpServers"]},{id:"plugins",label:"Plugins",tab:null,keys:["enabledPlugins"]}],rs=new Set(bt.flatMap(t=>t.keys)),Js=[{id:"essentials",title:"Essentials",summary:"The knobs you reach for first.",keys:["model","language","outputStyle"]},{id:"git",title:"Git & Commits",summary:"How Claude writes commits and pull requests on your behalf.",keys:["attribution","includeGitInstructions","includeCoAuthoredBy"]},{id:"memory",title:"Memory & Plans",summary:"Context Claude keeps between sessions and where it files plans.",keys:["autoMemoryEnabled","plansDirectory","claudeMdExcludes","respectGitignore"]},{id:"model",title:"Model & Reasoning",summary:"Model allow/override lists, reasoning depth, and fast-mode toggles — machine-wide, with no per-Epic override yet. An Epic's Agent persona model (Agent Library) still wins over Essentials' plain model default.",advanced:!0,keys:["availableModels","modelOverrides","effortLevel","fastMode","fastModePerSessionOptIn","alwaysThinkingEnabled","fallbackModel","enforceAvailableModels","teammateDefaultModel","advisorModel"]},{id:"interface",title:"Interface",summary:"Visual polish — spinners, progress bars, motion.",keys:["spinnerTipsEnabled","spinnerTipsOverride","spinnerVerbs","terminalProgressBarEnabled","showTurnDuration","prefersReducedMotion","companyAnnouncements","statusLine","teammateMode"]},{id:"updates",title:"Updates & Cleanup",summary:"Release channel and how long transcripts stick around.",keys:["autoUpdatesChannel","cleanupPeriodDays"]},{id:"env",title:"Environment & Auth",summary:"Environment variables and auth-helper scripts.",keys:["env","apiKeyHelper","awsCredentialExport","awsAuthRefresh"]},{id:"hooks",title:"Hooks",summary:"Scripts Claude runs before/after tool use.",keys:["hooks","disableAllHooks","allowedHttpHookUrls","httpHookAllowedEnvVars"]},{id:"mcp",title:"MCP Servers",summary:"External tool providers Claude can talk to.",keys:["enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers"]},{id:"plugins",title:"Plugins",summary:"Installed plugins, marketplaces, and per-plugin configuration.",keys:["enabledPlugins","extraKnownMarketplaces","skippedPlugins","skippedMarketplaces","pluginConfigs"]},{id:"filesystem",title:"File Picker & Sandbox",summary:"How Claude browses files and the sandbox it runs in.",keys:["fileSuggestion","sandbox","worktree"]},{id:"login",title:"Login",summary:"Which login method to force on startup.",keys:["forceLoginMethod","forceLoginOrgUUID"]},{id:"feedback",title:"Feedback",summary:"Session-quality surveys.",keys:["feedbackSurveyRate"]},{id:"advanced",title:"Advanced / Enterprise",summary:"Managed-settings-only keys and enterprise allow/denylists.",advanced:!0,keys:["allowedMcpServers","deniedMcpServers","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","strictKnownMarketplaces","blockedMarketplaces","pluginTrustMessage","otelHeadersHelper","skipWebFetchPreflight"]}],io={mcp:"MCP",url:"URL",urls:"URLs",http:"HTTP",ui:"UI",id:"ID",uuid:"UUID",api:"API",aws:"AWS",otel:"OTel",json:"JSON"};function Ye(t){return t.replace(/^\$/,"").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").toLowerCase().split(/\s+/).filter(Boolean).map((o,i)=>{const a=io[o];return a||(i===0?o.charAt(0).toUpperCase()+o.slice(1):o)}).join(" ")}function Qs(t){const s=new Set,n=[];for(const i of Js){const a=i.keys.filter(r=>t.has(r)&&!rs.has(r));a.forEach(r=>s.add(r)),a.length!==0&&n.push({id:i.id,title:i.title,summary:i.summary,advanced:!!i.advanced,keys:a})}const o=Array.from(t).filter(i=>!s.has(i)&&i!=="$schema"&&!rs.has(i)).sort();return o.length>0&&n.push({id:"other",title:"Other",summary:"Keys not yet grouped.",advanced:!1,keys:o}),n}function ro(t,s){return Qs(t).map(n=>({id:n.id,title:n.title,advanced:n.advanced,total:n.keys.length,setCount:n.keys.filter(o=>s.has(o)).length}))}const Yt=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/,At="disable-model-invocation",Zs=/^\s*disable-model-invocation\s*:/;function ao(t){const s=t.match(Yt);if(!s)return!1;for(const n of s[1].split(/\r?\n/)){if(!Zs.test(n))continue;const o=n.slice(n.indexOf(":")+1).trim().toLowerCase();return o==="true"||o==="yes"}return!1}function lo(t){const s=t.trim();return s.length>=2&&(s[0]==='"'&&s[s.length-1]==='"'||s[0]==="'"&&s[s.length-1]==="'")?s.slice(1,-1):s}function He(t){return t.length-t.trimStart().length}function it(t){const s=t.match(Yt);if(!s)return{name:null,description:null,body:t};const n=s[1].split(/\r?\n/),o=s[2]??"";let i=null,a=null;for(let r=0;r<n.length;r++){const l=n[r],d=l.match(/^(\s*)(name|description)\s*:(.*)$/);if(!d)continue;const[,,c,p]=d,m=p.trim(),g=He(l);let h;if(m===""||m===">-"||m===">"||m==="|-"||m==="|"){const f=[];let b=r+1;for(;b<n.length&&n[b].trim()!==""&&He(n[b])>g;)f.push(n[b].trim()),b++;h=f.join(" ")}else h=lo(m);c==="name"?i=h:a=h}return{name:i,description:a,body:o}}function co(t,s){const n=t.match(Yt);if(!n){if(!s)return t;const r=t.startsWith(`
|
|
2
2
|
`)?"":`
|
|
3
3
|
`;return`---
|
|
4
4
|
${At}: true
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{aX as ba,aR as H,R as Pt,aB as N,S as Wf,ay as Uf,a9 as ka}from"./index-
|
|
1
|
+
import{aX as ba,aR as H,R as Pt,aB as N,S as Wf,ay as Uf,a9 as ka}from"./index-B2TQz3nd.js";var zi={exports:{}},$i={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* use-sync-external-store-shim.production.js
|
|
4
4
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bl as g,aR as u,as as b,aB as n,bj as p}from"./index-
|
|
1
|
+
import{bl as g,aR as u,as as b,aB as n,bj as p}from"./index-B2TQz3nd.js";function h(e,t){return t&&(e===t||e.startsWith(t+"/"))?"~"+e.slice(t.length):e}function w({path:e,keyPath:t,note:i}){const s=g(),[o,l]=u.useState(void 0);u.useEffect(()=>{let r=!0;const d=()=>{window.api.config.readText(e,{maxBytes:1}).then(a=>{r&&l(a.exists?a.mtimeMs:null)}).catch(()=>{r&&l(void 0)})};d();const m=window.api.config.onChanged(a=>{a.path===e&&d()});return()=>{r=!1,m()}},[e]);const f=h(e,s)+(t&&t.length?` › ${t.join(".")}`:""),c=o===void 0?"":o===null?"created on first save":b(o),x=()=>{p.getState().openFile(e),window.dispatchEvent(new CustomEvent("sm:open-editor"))};return n.jsxs("button",{type:"button","data-testid":"source-chip",title:i??`Open ${e} in the editor`,onClick:x,className:"inline-flex items-center gap-1.5 max-w-full text-[11px] px-2 py-0.5 rounded border border-line bg-bg-elev text-fg-dim hover:bg-bg-hi",children:[n.jsx("span",{className:"font-mono truncate","data-testid":"source-chip-path",children:f}),c&&n.jsxs("span",{className:"text-fg-dim/70 shrink-0","data-testid":"source-chip-age",children:["· ",c]})]})}function j({checked:e,onChange:t,label:i,disabled:s}){return n.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${s?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:[n.jsx("button",{type:"button",role:"switch","aria-checked":e,disabled:s,onClick:()=>!s&&t(!e),className:`relative inline-flex shrink-0 items-center w-8 h-[18px] rounded-full transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent ${e?"bg-accent":"bg-line"}`,children:n.jsx("span",{"data-testid":"toggle-thumb","aria-hidden":!0,className:`absolute left-0.5 top-0.5 w-3.5 h-3.5 rounded-full bg-bg-hi shadow-sm transition-transform ${e?"translate-x-3.5":"translate-x-0"}`})}),i&&n.jsx("span",{"data-testid":"toggle-label",className:"whitespace-nowrap text-fg-dim",children:i})]})}function N({options:e,active:t,onChange:i}){return n.jsx("div",{className:"flex rounded border border-line overflow-hidden",children:e.map(({key:s,label:o})=>n.jsx("button",{onClick:()=>i(s),className:`px-2 py-0.5 text-xs ${t===s?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:o},s))})}export{w as S,j as T,N as V,h as s};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bz as o,bx as m,af as j,aB as e,b2 as l,bw as b,aE as R}from"./index-
|
|
1
|
+
import{bz as o,bx as m,af as j,aB as e,b2 as l,bw as b,aE as R}from"./index-B2TQz3nd.js";let u=0;const T=1e3;function w(n){const s=performance.now();s-u<T||(u=s,R.debug("voice","mic.gate.click_rejected",{reason:n}))}function k(){const n=o(t=>t.isRecording),s=o(t=>t.error),i=o(t=>t.loadingProgress),r=o(m(l)),x=()=>{const t=o.getState(),{canRecord:h,reason:a}=l(t);if(t.isRecording)return t.stopRecording();if(t.wizardArmed&&!t.wizardOpen){t.openWizard();return}if(a==="error"||a==="load-timeout"){t.resetAndRetryModel();return}if(!h)return w(a);const c=b.getState().activeTabId;c&&t.startRecording(c)},d=j(r.reason,{loadingPct:i,errorMessage:s,isRecording:n}),g=r.reason==="unsupported",p=!r.canRecord,f=r.reason==="loading"?"text-fg-faint animate-pulse cursor-wait":r.reason==="error"||r.reason==="load-timeout"?"text-red-400 cursor-pointer":r.reason==="permission-denied"?"text-amber-400 cursor-pointer":r.reason==="idle"?"text-fg-faint cursor-pointer":r.reason==="unsupported"?"text-fg-faint cursor-not-allowed":n?"text-red-400 ring-2 ring-red-400 animate-pulse":"text-fg-dim hover:text-fg";return e.jsx("button",{onClick:x,disabled:g,"aria-disabled":p,"aria-label":d,title:d,"data-testid":"mic-button","data-state":r.reason,className:`p-1.5 rounded transition-colors ${f}`,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"9",y:"1",width:"6",height:"12",rx:"3"}),e.jsx("path",{d:"M5 10a7 7 0 0 0 14 0"}),e.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"}),e.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"})]})})}function v(){const n=o(i=>i.ttsEnabled),s=o(i=>i.toggleTTS);return e.jsxs("button",{onClick:s,title:n?"Read Claude replies aloud: ON":"Read Claude replies aloud: OFF",className:`px-1.5 py-1 rounded transition-colors flex items-center gap-1 ${n?"text-accent":"text-fg-dim hover:text-fg"}`,children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),n?e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),e.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}):e.jsxs(e.Fragment,{children:[e.jsx("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),e.jsx("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]})]}),e.jsx("span",{className:"text-[10px] font-medium tracking-wide",children:"TTS"})]})}export{v as T,k as V};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bC as s}from"./index-
|
|
1
|
+
import{bC as s}from"./index-B2TQz3nd.js";function a(t){const e=Number.isFinite(t)?t:0,r=Math.abs(e)<1?4:2;return`$${e.toFixed(r)}`}function u(t){const e=Number.isFinite(t)?t:0,r=Math.abs(e);return r>=1e9?`${(e/1e9).toFixed(1)}B`:r>=1e6?`${(e/1e6).toFixed(1)}M`:r>=1e3?`${(e/1e3).toFixed(1)}K`:`${Math.round(e)}`}function f(t){const e=Number.isFinite(t)?t:0;return Math.round(e).toLocaleString("en-US")}function m(t){const e=Math.max(0,Math.round(Number.isFinite(t)?t:0));if(e<60)return`${e}m`;const r=Math.floor(e/60),n=e%60;return n===0?`${r}h`:`${r}h ${n}m`}function h(t){return Number.isFinite(t)?t>0&&t<1?"<1%":`${t.toFixed(1)}%`:"0.0%"}async function l(t,e=5e3){try{return{ok:!0,data:await s(Promise.resolve().then(()=>window.api.history.dashboard({rangeDays:t})),e,"history.dashboard")}}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}}function c(t){return`${a(t.costUsd)} · ${u(t.tokens)} tok`}function b(t,e){const r=e!=null&&e.day?t.days.filter(o=>o.date===e.day).flatMap(o=>Object.values(o.byProject)):[t.totals];let n=0,i=0;for(const o of r)n+=o.estimatedCostUsd,i+=o.inputTokens+o.outputTokens+o.cacheReadTokens+o.cacheCreationTokens;return{costUsd:n,tokens:i,label:c({costUsd:n,tokens:i})}}export{c as a,l as f,f as i,m,h as p,b as s,u as t,a as u};
|