claude-code-session-manager 0.92.1 → 0.94.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/DataModel-B0LDnnSL.js +1 -0
- package/dist/assets/{History-BOR_fJNr.js → History-C685Kytt.js} +2 -2
- package/dist/assets/{Hooks-BtD436iL.js → Hooks-CwLnp0Z_.js} +3 -3
- package/dist/assets/HostBilko-CwEHEKYk.js +1 -0
- package/dist/assets/{Library-DeKdY-tD.js → Library-BU9np05E.js} +25 -25
- package/dist/assets/{MarkdownEditor-CbzC-Oqf.js → MarkdownEditor-B74ogK2f.js} +1 -1
- package/dist/assets/McpServers-BLM3ftzP.js +2 -0
- package/dist/assets/{Memory-B68AJjg2.js → Memory-DAP1t8bA.js} +6 -6
- package/dist/assets/{Permissions-Cr0RRvNy.js → Permissions-3pGLJmxQ.js} +3 -3
- package/dist/assets/Plugins-Q1KoLEzn.js +2 -0
- package/dist/assets/ProvenanceBadge-BnjBQiV9.js +1 -0
- package/dist/assets/{SaveBar-87ZJfscX.js → SaveBar-Zq2NfcPf.js} +1 -1
- package/dist/assets/Scheduler-D488ebKm.js +16 -0
- package/dist/assets/{ScopeSwitcher-CKzpqjJ_.js → ScopeSwitcher-Cnojv22D.js} +1 -1
- package/dist/assets/Settings-D5Lhj7ga.js +3 -0
- package/dist/assets/{SkillReferenceGraph-D_-wg4r9.js → SkillReferenceGraph-BRDiE6Hv.js} +2 -2
- package/dist/assets/Skills-BQDqp-EN.js +3 -0
- package/dist/assets/SystemPrompt-tFr19Od6.js +1 -0
- package/dist/assets/TagLibrary-BjyrnaRE.js +1 -0
- package/dist/assets/{TiptapBody-DYXIp8aG.js → TiptapBody-DGzSg3BO.js} +1 -1
- package/dist/assets/{Toggle-CDXR5l3m.js → Toggle-DzoROibf.js} +1 -1
- package/dist/assets/index-CCl4tz-u.js +3079 -0
- package/dist/assets/{index-D3P_jldk.css → index-CKH5Uxik.css} +1 -1
- package/dist/assets/settingsSchema-BYKVe1WM.js +1 -0
- package/dist/index.html +2 -2
- package/package.json +6 -3
- package/scripts/README.md +3 -0
- package/src/main/__tests__/agentEffortResolve.test.cjs +117 -0
- package/src/main/__tests__/agentLibrary.test.cjs +21 -0
- package/src/main/__tests__/agentModelResolve.test.cjs +16 -0
- package/src/main/__tests__/agentOverlayWrite.test.cjs +95 -0
- package/src/main/__tests__/chat-cancel-terminal.test.cjs +5 -2
- package/src/main/__tests__/chat-exit-close-race.test.cjs +8 -2
- package/src/main/__tests__/chat-mcp-consent-notice.test.cjs +5 -2
- package/src/main/__tests__/chatRunner-session-flag-retry.test.cjs +44 -0
- package/src/main/__tests__/intradayRefresh.test.cjs +39 -0
- package/src/main/__tests__/openExternalApp-spawn-error.test.cjs +25 -0
- package/src/main/__tests__/opsErrorLog.test.cjs +22 -0
- package/src/main/__tests__/personaMerge.test.cjs +169 -0
- package/src/main/__tests__/prdCreatePlanId.test.cjs +132 -0
- package/src/main/__tests__/promptSessionsCreateEpicHandler.test.cjs +13 -0
- package/src/main/__tests__/pty-epic-worktree-spawn-cwd.test.cjs +21 -0
- package/src/main/__tests__/rateLimitPollerStreak.test.cjs +14 -0
- package/src/main/__tests__/runVerify-atomic-verdicts.test.cjs +26 -0
- package/src/main/__tests__/runVerify-landed-commit-outranks.test.cjs +11 -1
- package/src/main/__tests__/runVerify-transcript-commit-evidence.test.cjs +11 -1
- package/src/main/__tests__/runVerify.test.cjs +12 -1
- package/src/main/__tests__/scheduler-prd-persona-spawn.test.cjs +47 -2
- package/src/main/__tests__/transcriptsUsageFor.test.cjs +112 -1
- package/src/main/agentLibrary.cjs +86 -40
- package/src/main/build-info.json +4 -4
- package/src/main/chatRunner.cjs +50 -10
- package/src/main/git.cjs +9 -2
- package/src/main/historyAggregator.cjs +2 -19
- package/src/main/index.cjs +17 -8
- package/src/main/ipcSchemas.cjs +25 -3
- package/src/main/lib/__tests__/childWithLog.test.cjs +180 -0
- package/src/main/lib/__tests__/delegationReadiness.test.cjs +19 -0
- package/src/main/lib/__tests__/effectiveModelInfo.test.cjs +10 -5
- package/src/main/lib/__tests__/gitCacheBound.test.cjs +69 -0
- package/src/main/lib/__tests__/modelCatalog.test.cjs +202 -0
- package/src/main/lib/agentEffortResolve.cjs +74 -0
- package/src/main/lib/agentModelResolve.cjs +52 -59
- package/src/main/lib/agentPersonaSchema.cjs +5 -0
- package/src/main/lib/childWithLog.cjs +92 -51
- package/src/main/lib/delegationReadiness.cjs +3 -1
- package/src/main/lib/effectiveModelInfo.cjs +38 -20
- package/src/main/lib/epicMint.cjs +5 -2
- package/src/main/lib/epicSpawnPlan.cjs +27 -8
- package/src/main/lib/epicTranscriptPath.cjs +5 -1
- package/src/main/lib/epicWorktreeMerge.cjs +7 -6
- package/src/main/lib/headTailBuffer.cjs +43 -0
- package/src/main/lib/intradayRefresh.cjs +33 -0
- package/src/main/lib/lruCache.cjs +39 -0
- package/src/main/lib/modelCatalog.cjs +243 -0
- package/src/main/lib/openExternalApp.cjs +27 -9
- package/src/main/lib/opsErrorLog.cjs +22 -0
- package/src/main/lib/personaMerge.cjs +166 -0
- package/src/main/lib/prdCreate.cjs +23 -5
- package/src/main/lib/prdDisposition.cjs +46 -0
- package/src/main/lib/prdFrontmatter.cjs +6 -2
- package/src/main/lib/promptSessionSchema.cjs +5 -0
- package/src/main/lib/promptSessionsCreateEpic.cjs +5 -3
- package/src/main/lib/rendererRecovery.cjs +141 -0
- package/src/main/lib/scheduleJobSchema.cjs +3 -0
- package/src/main/runVerify.cjs +3 -1
- package/src/main/scheduler/prdParser.cjs +2 -0
- package/src/main/scheduler.cjs +381 -262
- package/src/main/templates/PRD_AUTHORING.md +4 -0
- package/src/main/transcripts.cjs +54 -11
- package/src/preload/api.d.ts +56 -3
- package/src/preload/index.cjs +4 -0
- package/dist/assets/AgentLibrary-Ci6u03bq.js +0 -3
- package/dist/assets/DataModel-BIqcjsv2.js +0 -1
- package/dist/assets/HostBilko-CMe5cH3H.js +0 -1
- package/dist/assets/ListDetail-CtVjrHKB.js +0 -1
- package/dist/assets/McpServers-DKN75Shn.js +0 -2
- package/dist/assets/Panel-C2YTW-qP.js +0 -1
- package/dist/assets/Plugins-DbZkJs5l.js +0 -2
- package/dist/assets/ProvenanceBadge-kJ__BOQv.js +0 -1
- package/dist/assets/Scheduler-DdEaxku8.js +0 -16
- package/dist/assets/Settings-CjywVsNB.js +0 -3
- package/dist/assets/Skills-Cd_yPO_l.js +0 -3
- package/dist/assets/SystemPrompt-2z6eGPSF.js +0 -1
- package/dist/assets/TagLibrary-DcaWQSp4.js +0 -1
- package/dist/assets/index-D5H_H5wC.js +0 -3074
- package/dist/assets/settingsSchema-JRDfjgHb.js +0 -3
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import{ay as Ce,ao as te,aC as ts,ac as ke,a6 as se,aa as z,aH as J,aT as Ee,aR as oe,au as h,aX as ss,a4 as pe,ah as t,c as Fe,I as he,L as rt,o as ns,K as ue,r as as,H as rs,d as is,Q as ls,am as kt,aW as Se,y as Ie,as as Re,a as Ke,aB as Qe,a7 as it,G as St,t as Ct,n as $t,p as os,m as ze,v as Xe,O as ds,D as ee,f as B,a8 as Dt,aQ as Pt,at as cs,T as us,ap as lt,aL as ot,l as ye,u as dt,k as ps,aF as hs,U as fs,s as At,aN as xs,aK as ve,z as gs,C as ms,aU as bs,av as ws,N as vs,aY as js,aV as ct,aA as ys}from"./index-D5H_H5wC.js";import{l as Ns}from"./listSkills-QORduPIk.js";import{T as ks}from"./Toggle-CDXR5l3m.js";import"./monaco-editor-BW5C4Iv1.js";function Ss(e){const s=new Map(e.map(l=>[l.slug,l])),n=new Map,a=new Set,c=[];function p(l){n.set(l,1),c.push(l);const i=s.get(l);for(const d of(i==null?void 0:i.dependsOn)??[]){if(!s.has(d))continue;const r=n.get(d);if(r===1){const o=c.indexOf(d);for(let u=o;u<c.length;u++)a.add(c[u])}else r===void 0&&p(d)}c.pop(),n.set(l,2)}for(const l of e)n.has(l.slug)||p(l.slug);return a}function Cs(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 $s(e,s,n){const a=new Set(e.map(r=>r.slug)),c=new Set;for(const r of e)for(const o of r.dependsOn??[])a.has(o)&&c.add(o);const p=new Map,l=[];for(const r of e){const o=n.has(r.slug)?void 0:(r.dependsOn??[]).find(u=>a.has(u)&&!n.has(u));o?(p.has(o)||p.set(o,[]),p.get(o).push(r)):l.push(r)}const i=(r,o)=>r.slug.localeCompare(o.slug);l.sort(i);for(const r of p.values())r.sort(i);function d(r,o,u){const f=Cs(r,s),m=n.has(r.slug);u.add(r.slug);const g=m?[]:(p.get(r.slug)??[]).filter(b=>!u.has(b.slug)).map(b=>d(b,o+1,u));return u.delete(r.slug),{row:r,depth:o,children:g,blockers:f,blocked:f.some(b=>!b.missing&&b.status!=="completed"),hasNeedsReviewBlocker:f.some(b=>b.needsReview),hasMissingDep:f.some(b=>b.missing),cycle:m,parallelEligible:(r.dependsOn??[]).length===0&&!c.has(r.slug)}}return l.map(r=>d(r,0,new Set))}function Mt(e,s,n){const a=new Map((n??e).map(r=>[r.slug,r])),c=Ss(e),p=[],l=new Map,i=new Map;for(const r of e){const o=Ce(r,s),u=o.epicId??"__none__";l.has(u)||(p.push(u),l.set(u,[]),i.set(u,{epicId:o.epicId,label:o.known&&o.label?o.label:o.epicId?`Epic ${o.epicId.slice(0,12)}…`:"No Epic",known:o.known})),l.get(u).push(r)}const d=p.map(r=>{const o=i.get(r),u=l.get(r),f=$s(u,a,c),m={};for(const g of u){const b=g.status??"unknown";m[b]=(m[b]??0)+1}return{epicId:o.epicId,label:o.label,known:o.known,nodes:f,counts:m,total:u.length}});return d.sort((r,o)=>r.epicId===null?1:o.epicId===null?-1:r.known!==o.known?r.known?-1:1:r.label.localeCompare(o.label)),d}function Te(e){const s=[],n=a=>{s.push(a);for(const c of a.children)n(c)};for(const a of e)n(a);return s}const Ds=15e4,Ve=e=>e==="completed"||e==="skipped",Ne=e=>e==="running"||e==="investigating",Rt=e=>e==="failed"||e==="needs_review"||e==="quarantined",Ps=e=>e==="failed"||e==="needs_review"||e==="quarantined";function Et(e){const s=Math.max(0,Math.floor(e/1e3)),n=Math.floor(s/3600),a=Math.floor(s%3600/60),c=s%60;return n>0?`${n}h${String(a).padStart(2,"0")}m`:a>0?`${a}m${String(c).padStart(2,"0")}s`:`${c}s`}function It(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 Tt(e,s){const n=e.estimateMinutes?e.estimateMinutes*6e4:null;return n?`${Math.min(99,Math.floor(s/n*100))}%`:Et(s)}function As(e){let s=0,n=0;for(const a of e)if(a.status==="completed"&&a.startedAt&&a.finishedAt){const c=Date.parse(a.finishedAt)-Date.parse(a.startedAt);c>0&&(s+=c,n++)}return n===0?Ds:s/n}function Je(e){const s=te(e);return s===null?1/0:Number(s)}function ut(e,s){const n=Je(e.slug)-Je(s.slug);return n!==0&&!Number.isNaN(n)?n:e.slug.localeCompare(s.slug)}function Ms(e){let s=0;for(const n of e.statusHistory??[])n.to==="pending"&&n.from!==null&&s++;return s}function Rs(e){return e.some(n=>Ne(n.status))?"active":e.every(n=>Ve(n.status))?"done":e.filter(n=>n.status!=="quarantined").length===0?"draft":"queued"}function Es(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 Ze(e,s){if(e.length===0)return[];const n=s.now??Date.now(),a=s.avgDurationMs??As(e),c=Math.max(1,s.concurrency??1),p=new Map(e.map(o=>[o.slug,o])),l=o=>o.status==="pending"&&(o.dependsOn??[]).every(u=>p.get(u)===void 0||p.get(u).status==="completed"),i=new Map;e.filter(l).sort(ut).forEach((o,u)=>i.set(o.slug,u));const d=Mt(e,s.sessions,e),r=[];for(const o of d){const u=Te(o.nodes),f=new Set(u.map(k=>k.row.slug)),m=new Map(u.map(k=>[k.row.slug,k])),g=new Map,b=new Set,w=k=>{const S=m.get(k);return(S.row.dependsOn??[]).filter(_=>f.has(_)&&!(S.cycle&&m.get(_).cycle))},D=k=>{const S=g.get(k);if(S!==void 0)return S;if(b.has(k))return 0;b.add(k);let _=0;for(const O of w(k))_=Math.max(_,D(O));return b.delete(k),g.set(k,_+1),_+1};for(const k of u)D(k.row.slug);const $=u.map(k=>{const S=k.row,_=(S.dependsOn??[]).filter(O=>f.has(O));return{slug:S.slug,title:S.title,status:S.status,stage:g.get(S.slug),prdNumber:te(S.slug),rowKind:"dep",rowTrailing:"",cycle:k.cycle,estimateMinutes:S.estimateMinutes??null,deps:_,crossEpicDeps:(S.dependsOn??[]).filter(O=>!f.has(O)),blockers:k.blockers,job:S}});$.sort(ut);const I=$.reduce((k,S)=>Math.max(k,S.stage),0),x=new Map;for(const k of $){const S=k.job,_=m.get(k.slug),O=S.status;let H;if(Ve(O)){const L=S.startedAt&&S.finishedAt?Date.parse(S.finishedAt)-Date.parse(S.startedAt):NaN;H={kind:"done",trailing:L>0?Et(L):"",held:!1,blocked:!1}}else if(Ne(O)){const L=S.startedAt?Math.max(0,n-Date.parse(S.startedAt)):null;H={kind:"running",trailing:L===null?"":Tt(S,L),held:!1,blocked:!1}}else if(O==="failed")H={kind:"failed",trailing:"failed",held:!1,blocked:!1};else if(O==="needs_review")H={kind:"review",trailing:"review",held:!1,blocked:!1};else if(O==="quarantined")H={kind:"quarantined",trailing:"quarantined",held:!1,blocked:!1};else{const L=_.blockers.filter(U=>!U.missing&&U.status!=="completed");if(L.length>0){const U=L.some(A=>Ps(A.status)),Y=L[0].slug;H={kind:"dep",trailing:`←${te(Y)??Y}`,held:!U,blocked:U}}else if(S.heldReason)H={kind:"gate",trailing:"gate",held:!0,blocked:!1};else{const U=Ms(S),Y=i.get(S.slug)??0;H=U>0?{kind:"retry",trailing:`${U} ${U===1?"retry":"retries"}`,held:!1,blocked:!1}:{kind:"eta",trailing:It(Y*a/c),held:!1,blocked:!1}}}x.set(k.slug,H)}const E=[];for(let k=1;k<=I;k++){const S=$.filter(q=>q.stage===k),_=S.find(q=>{const W=x.get(q.slug).kind;return q.status==="pending"&&(W==="eta"||W==="retry")});if(_){const q=x.get(_.slug);q.kind="next",q.trailing="next"}let O=0,H=0,L=0,U=0,Y=0,A=0;for(const q of S){const W=x.get(q.slug);q.rowKind=W.kind,q.rowTrailing=W.trailing,Ve(q.status)?O++:Ne(q.status)?H++:q.status==="pending"?(Y++,W.held&&L++,W.blocked&&U++):Rt(q.status)&&A++}const G=O===S.length?"done":H>0?"running":U+A>0?"blocked":L>0?"held":"pending",F={n:k,rows:S,doneCount:O,runningCount:H,heldCount:L,blockedCount:U};E.push({...F,state:G,summary:Es(G,F,Y,A)})}let N=0;for(const k of $){const S=k.estimateMinutes?k.estimateMinutes*6e4:a;if(k.status==="pending")N+=S;else if(Ne(k.status)){const _=k.job.startedAt?Math.max(0,n-Date.parse(k.job.startedAt)):0;N+=Math.max(0,S-_)}}const P=$.reduce((k,S)=>Math.min(k,Je(S.slug)),1/0);r.push({epicId:o.epicId,index:0,label:o.known?ts(o.label).title:o.label,status:Rs($),prdCount:$.length,stageCount:I,doneCount:E.reduce((k,S)=>k+S.doneCount,0),runningCount:E.reduce((k,S)=>k+S.runningCount,0),heldCount:E.reduce((k,S)=>k+S.heldCount,0),blockedCount:E.reduce((k,S)=>k+S.blockedCount,0),etaMs:N/c,stages:E,_firstNum:P})}return r.sort((o,u)=>o._firstNum!==u._firstNum?o._firstNum<u._firstNum?-1:1:(o.epicId??"").localeCompare(u.epicId??"")),r.map(({_firstNum:o,...u},f)=>({...u,index:f+1}))}function Is(e,s=Date.now()){const n=new Map(e.map(f=>[f.slug,f])),a=new Date(s).toDateString();let c=0,p=0,l=0,i=0,d=0,r=0,o=0;for(const f of e)f.status==="pending"?(p++,(f.dependsOn??[]).every(g=>n.get(g)===void 0||n.get(g).status==="completed")&&c++):Ne(f.status)?o++:f.status==="failed"?l++:f.status==="needs_review"?i++:f.status==="quarantined"?d++:f.status==="completed"&&f.finishedAt&&new Date(Date.parse(f.finishedAt)).toDateString()===a&&r++;let u=null;if(l+i+d>0){for(const f of Ze(e,{sessions:{},now:s}))for(const m of f.stages)if(m.rows.some(g=>Rt(g.status))){(u===null||m.n<u)&&(u=m.n);break}}return{readyNow:c,totalQueued:p,heldByDeps:p-c,needsYou:l+i+d,needsYouStage:u,failedCount:l,needsReviewCount:i,doneToday:r,inFlight:o}}function Ts(e){const s=new Map;for(const d of e.stages)for(const r of d.rows)s.set(r.slug,r);const n=d=>{var r;return((r=s.get(d))==null?void 0:r.cycle)===!0},a=new Map,c=new Set,p=(d,r)=>d.chain.length!==r.chain.length?d.chain.length>r.chain.length:d.est!==r.est?d.est>r.est:d.chain.join("\0")<r.chain.join("\0"),l=d=>{const r=a.get(d);if(r)return r;const o=s.get(d),u=o.estimateMinutes??0;if(c.has(d))return{chain:[d],est:u};c.add(d);let f=null;for(const g of o.deps){if(!s.has(g)||o.cycle&&n(g))continue;const b=l(g);(!f||p(b,f))&&(f=b)}c.delete(d);const m=f?{chain:[...f.chain,d],est:f.est+u}:{chain:[d],est:u};return a.set(d,m),m};let i=null;for(const d of s.keys()){const r=l(d);(!i||p(r,i))&&(i=r)}return i?i.chain:[]}function _t({snap:e,now:s,avgDurationMs:n,runningJobs:a}){const{config:c,jobs:p,paused:l,nextReset:i,utilization:d,effectiveConcurrency:r}=e;let o=0,u=0;for(const D of p)D.status==="pending"?o++:D.status==="completed"&&u++;const f=a.length,m=o+f,g=(r==null?void 0:r.cap)??5;if(f>0){const D=a.reduce((N,P)=>(N.startedAt??"")<(P.startedAt??"")?N:P),$=D.startedAt?s-Date.parse(D.startedAt):0,I=u+f,x=u+m,E=f>1?` · ${f}/${g} parallel`:"";return{kind:"running",line1:`Running ${I}/${x}${E} · ${ke($)}`,line2:f===1?D.title:a.map(N=>N.title).join(", "),tooltip:a.map(N=>`${N.slug} (g${N.parallelGroup})`).join("; ")}}if(l){const D=l.resumeAt?Date.parse(l.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)"}[l.reason]??`Paused — ${l.reason}`,line2:l.reason==="auth"?"Run `claude` in any terminal to refresh credentials, then Resume":D!==null&&D>0?`auto-resume ${se(Date.parse(l.resumeAt))} (in ${z(D)})`:l.resumeAt?"resuming…":"no auto-resume scheduled",tooltip:l.resumeAt??"",action:{label:"Resume",onClick:()=>window.api.schedule.resume(),title:"Clear the pause and resume queue immediately"}}}if(m===0)return{kind:"idle",line1:"No work queued",line2:null};const b=c.firePolicy??"when-available";if(b==="manual")return{kind:"manual",line1:`Manual · ${o} pending`,line2:"click Fire next batch now to fire",action:{label:"Fire next batch now",onClick:()=>window.api.schedule.forceTick().then(J.fromOutcome).catch(()=>J.error("Failed to fire batch")),title:"Bypasses the billing-usage poll. Use when the meter is rate-limited or you want immediate progress."}};if(b==="on-reset"){if(!i)return{kind:"on-reset",line1:"On-reset · waiting for billing data",line2:null};const D=Date.parse(i)+c.offsetMinutes*6e4,$=D-s;return{kind:"on-reset",line1:`On-reset · ${o} pending`,line2:$>0?`fires ${se(D)} (in ${z($)})`:"firing now…"}}const w=c.utilizationThreshold??90;if(d==null)return{kind:"auto-soon",line1:`Auto · ${o} pending`,line2:"checking token availability…"};if(d>=w){const D=i?Date.parse(i)-s:null;return{kind:"auto-throttled",line1:`Auto · throttled (util ${d.toFixed(0)}% ≥ ${w}%)`,line2:D&&D>0?`next reset ${se(Date.parse(i))} (in ${z(D)})`:"will fire when usage drops"}}return{kind:"auto-soon",line1:`Auto · ${o} pending · util ${d.toFixed(0)}%`,line2:"fires within 2 min (poll cycle)"}}const _s=15e3,Os=new Set(["failed","needs_review","quarantined"]);function pt(){var n;const s=Array.from(document.querySelectorAll("[data-job-row]")).find(a=>Os.has(a.dataset.jobStatus??""));(n=s==null?void 0:s.scrollIntoView)==null||n.call(s,{block:"center",behavior:"smooth"})}function Ls(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 ${z(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?z(e.idleMs):"?"} with ${e.dispatchable} dispatchable`;case"running":default:return`running: ${e.runningCount} in flight, ${e.pending} pending`}}function Fs(e){const[s,n]=h.useState(null);return h.useEffect(()=>{let a=!0;const c=()=>{window.api.schedule.queueHealth(e).then(l=>{a&&n(l)}).catch(()=>{})};c();const p=setInterval(c,_s);return()=>{a=!1,clearInterval(p)}},[e]),s}const qs={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 Bs(e,s,n){return e==="paused"||e==="launch-blocked"?"paused":e==="running"||e==="saturated"?"running":e?"idle":s?"paused":n>0?"running":"idle"}function Hs(e){return e>=1e9?`${(e/1e9).toFixed(1)}B`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}k`:String(e)}const qe="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 Gs(e,s,n){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 a=new Date(s).getTime()-n;return a>0?`Paused for rate limit — resumes in ${z(a)}`:"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 Us({now:e}){const s=Ee(o=>o.snapshot);if(!s)return null;const n=s.paused,a=Object.entries(s.launchBlocks??{}),c=Object.entries(s.launchMitigations??{}),p=(n==null?void 0:n.reason)==="auth"||(n==null?void 0:n.reason)==="network",l="flex items-start gap-3 border-b px-0 py-1.5 text-[12.5px]",i="bg-red-950/10 border-red-700/30 text-red-800",d="bg-amber-400/10 border-amber-600/30 text-amber-700",r="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:`${l} ${p?i:d}`,children:[t.jsx("span",{className:"flex-1 leading-snug",children:Gs(n.reason,n.resumeAt,e)}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),className:r,children:"Resume"})]}),a.map(([o,u])=>t.jsxs("div",{"data-testid":"launch-block-banner",className:`${l} ${i}`,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:o})," 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 ${z(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:r,children:"Retry now"})]},`launch-block-${o}`)),c.map(([o,u])=>t.jsx("div",{"data-testid":"launch-mitigation-banner",className:`${l} ${d}`,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:o})," jobs are running in degraded mode"," ","(",t.jsx("span",{className:"font-mono",children:Object.entries(u.env).map(([f,m])=>`${f}=${m}`).join(" ")}),")",u.claudeVersion?` since CLI ${u.claudeVersion}`:"","."]}),t.jsx("div",{className:"opacity-80",children:u.hint})]})},`launch-mitigation-${o}`))]})}function Vs({scopeCwd:e,subView:s,onSubView:n,filterText:a,onFilterText:c,planMode:p,onPlanMode:l,planToolsRef:i}){const d=Ee(y=>y.snapshot),r=oe(y=>y.sessions),o=Fs(e),[u,f]=h.useState(()=>Date.now()),[m,g]=h.useState("—");h.useEffect(()=>{const y=setInterval(()=>f(Date.now()),3e4);return()=>clearInterval(y)},[]),h.useEffect(()=>{let y=!0;return ss(Promise.resolve().then(()=>window.api.history.dashboard({rangeDays:30})),5e3,"history.dashboard").then(M=>{if(!y)return;const R=M.totals,K=R.inputTokens+R.outputTokens+R.cacheReadTokens+R.cacheCreationTokens;g(`$${R.estimatedCostUsd.toFixed(2)} · ${Hs(K)} tok`)}).catch(()=>{}),()=>{y=!1}},[]);const b=h.useMemo(()=>((d==null?void 0:d.jobs)??[]).filter(y=>!e||y.cwd===e),[d,e]),w=h.useMemo(()=>Is(b,u),[b,u]),D=h.useMemo(()=>{const y=Ze(b,{sessions:r,now:u}),M=R=>y.filter(K=>K.status===R).length;return{active:M("active"),queued:M("queued"),draft:M("draft")}},[b,r,u]),$=h.useMemo(()=>{const y=new Date(u).toDateString(),M=[];for(const R of b)if(R.status==="completed"&&R.startedAt&&R.finishedAt&&new Date(Date.parse(R.finishedAt)).toDateString()===y){const K=Date.parse(R.finishedAt)-Date.parse(R.startedAt);K>0&&M.push(K)}return M.length?Math.round(M.reduce((R,K)=>R+K,0)/M.length/6e4):null},[b,u]);if(!d)return null;const I=o&&!o.unknown?o.verdict??null:null,x=o&&!o.unknown?o.slots??null:null,E=d.paused,N=Bs((I==null?void 0:I.kind)??null,!!E,w.inFlight),P=qs[N],k=b.filter(y=>y.status==="pending").length,S=b.filter(y=>y.status==="running").length,_=_t({snap:{...d,jobs:b},now:u,avgDurationMs:0,runningJobs:b.filter(y=>y.status==="running")}),O=o!=null&&o.unknown?`Queue health: unknown — ${o.reason??"state unavailable"}`:I?Ls(I,(o==null?void 0:o.oldestRunningAgeMs)??null):"queue health loading…",H=pe(d.lastRunAt?Date.parse(d.lastRunAt):null,u),L=o!=null&&o.lastDispatchAttemptAt?pe(Date.parse(o.lastDispatchAttemptAt),u):"never",U=[O,_.line1,I?`dispatchable ${I.dispatchable} · needs_review ${I.needsReviewCount}`:null,(o==null?void 0:o.oldestRunningAgeMs)!=null?`oldest running ${z(o.oldestRunningAgeMs)} (any project)`:null,`last batch fired ${H} (lastRunAt — advances only when a job launches)`,`last dispatch attempt ${L} (advances on every driver evaluation)`].filter(Boolean).join(`
|
|
2
|
-
`),Y=d.utilization,A=d.pollHealth,G=A!=null&&!A.lastPollOk,F=d.nextReset?Date.parse(d.nextReset):null,q=F?F>u?z(F-u):"soon":"—",W=d.effectiveConcurrency,be=(W==null?void 0:W.cap)??5,de=(W==null?void 0:W.source)==="env",v=d.config.firePolicy??"when-available",C=k===0&&S===0;return t.jsxs("div",{"data-testid":"scheduler-top-bands",className:"shrink-0 px-[18px]",children:[t.jsxs(Fe,{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 ${P.text}`,"data-testid":"scheduler-state-word","data-state":N,children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${P.dot}`,"aria-hidden":"true"}),N]}),t.jsxs("span",{className:"font-mono text-[12px] text-fg-faint whitespace-nowrap","data-testid":"scheduler-meta",children:[w.inFlight," in flight · ",w.heldByDeps," held · last batch ",H]}),t.jsxs(he,{title:U,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:U}),rt.scheduler&&t.jsx(ns,{content:rt.scheduler})]}),t.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>window.api.schedule.rescan().then(J.fromOutcome).catch(()=>J.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:qe,children:"Refresh"}),E?t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),title:"Clear the pause and resume queue immediately",className:qe,children:"Resume"}):t.jsx("button",{type:"button",onClick:()=>window.api.schedule.pause(),title:"Stop NEW dispatch. Running jobs are not killed.",className:qe,children:"Pause"}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.forceTick().then(J.fromOutcome).catch(()=>J.error("Failed to fire batch")),disabled:C,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(Us,{now:u}),t.jsxs(Fe,{height:70,testId:"scheduler-kpi-band",children:[t.jsx(ue,{testId:"kpi-window",label:"Window used",info:G?`Billing poll failing — this reading may be outdated (last good reading ${pe(A.lastPollAt,u)}). Machine-wide 5h window.`:"Share of the machine-wide 5h billing window consumed.",value:Y==null?"—":`${Math.round(Y)}%`,sub:`resets in ${q}`,third:t.jsx(as,{pct:Y??0,tone:G?"bg-amber-500":"bg-accent"})}),t.jsx(ue,{testId:"kpi-slots",label:"Slots",info:`Machine-wide session pool (${(x==null?void 0:x.source)==="env"?"SM_SESSION_SLOTS override":"Home tab cap"}), not scoped to this project`,value:x?`${x.inUse}/${x.total}`:"—",sub:"in use",third:x?t.jsx(rs,{filled:x.inUse,total:x.total}):null}),t.jsx(ue,{testId:"kpi-ready",label:"Ready now",info:"Pending rows whose dependsOn chain is fully satisfied right now",value:w.readyNow,sub:`of ${w.totalQueued} queued`,third:`${w.heldByDeps} held by deps`}),w.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:pt,className:"font-semibold text-accent hover:underline",title:"Scroll to the first failed / needs-review / quarantined row",children:w.needsYou}),sub:t.jsx("button",{type:"button",onClick:pt,className:"hover:underline",children:w.needsYouStage!=null?`blocking stage ${w.needsYouStage}`:"need attention"}),third:[w.failedCount>0&&`${w.failedCount} failed`,w.needsReviewCount>0&&`${w.needsReviewCount} needs review`,w.needsYou-w.failedCount-w.needsReviewCount>0&&`${w.needsYou-w.failedCount-w.needsReviewCount} 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 needs review"}),t.jsx(ue,{testId:"kpi-done",label:"Done today",value:w.doneToday,sub:$!=null?`avg ${$}m`:"avg —",third:t.jsx("span",{"data-testid":"kpi-done-spend",children:m})}),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:v,onChange:y=>window.api.schedule.setConfig({firePolicy:y.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. on-reset: fire after each 5h reset. manual: only on Run now.","aria-label":"Start jobs policy",children:[t.jsx("option",{value:"when-available",children:"when available"}),t.jsx("option",{value:"on-reset",children:"only on reset"}),t.jsx("option",{value:"manual",children:"manually"})]})]}),value:t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(ls,{value:be,min:0,max:10,disabled:de,onChange:y=>{window.api.schedule.setSessionSlots(Math.max(0,Math.min(10,y)))},title:de?"pinned by SM_SESSION_SLOTS — unset the env var to edit":"Machine-wide claude -p session slots, shared with chat runs"}),de&&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:v==="when-available"?t.jsxs("span",{children:["pause above"," ",t.jsx(is,{value:d.config.utilizationThreshold??90,min:0,max:100,testId:"kpi-threshold",title:"Fire only when 5h utilization is below this percent — click to edit",onCommit:y=>window.api.schedule.setConfig({utilizationThreshold:y})})]}):null})]}),t.jsxs(Fe,{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:[D.active," active · ",D.queued," queued · ",D.draft," draft · ",b.length," PRDs"]}),t.jsxs("span",{className:"ml-auto flex items-center gap-3",children:[t.jsx("span",{ref:i,className:"contents","data-testid":"scheduler-plan-tools"}),t.jsx("input",{type:"text",value:a,onChange:y=>c(y.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(([y,M])=>t.jsx("button",{type:"button","data-testid":`plan-mode-${y}`,"aria-pressed":p===y&&s==="queue",onClick:()=>{l(y),n("queue")},className:`px-2 py-0.5 text-[12px] ${p===y&&s==="queue"?"bg-bg-elev font-semibold text-fg":"text-fg-dim hover:text-fg"}`,children:M},y))}),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."],["machine","Machine","Machine-wide config that applies to every project — not this project’s live queue."]].map(([y,M,R])=>t.jsx("button",{type:"button",onClick:()=>n(y),"aria-pressed":s===y,title:R,className:`text-[12.5px] ${s===y?"font-semibold text-fg":"text-fg-faint hover:text-fg-dim"}`,children:M},y))]})]})]})}function Ot({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(c=>{const p=c.value===s;return t.jsxs("button",{type:"button",onClick:()=>n(c.value),className:`rounded-full ${a} text-[12.5px] border transition-colors ${p?"bg-accent text-white border-accent font-semibold":"bg-bg-hi text-fg-dim border-line hover:border-fg-faint font-medium"}`,children:[c.label,c.count!==void 0&&t.jsxs("span",{children:[" ",c.count]})]},c.value)})})}function Lt(e,s=60){const n=e.trim();return n.length<=s?n:`${n.slice(0,s-1)}…`}function Js(e){return Te([e]).filter(s=>s.children.length===0).map(s=>s.row.slug)}function Ft(e){return e.nodes.map(s=>({rootSlug:s.row.slug,label:s.row.title||s.row.slug,terminals:Js(s)}))}function Ws(e){const s=new Map;for(const n of e){const a=Ft(n);n.nodes.forEach((c,p)=>{const l=a.filter((i,d)=>d!==p);for(const i of Te([c]))s.set(i.row.slug,l)})}return s}function qt({job:e,headChoices:s}){const[n,a]=h.useState(!1),c=h.useCallback((p,l)=>{a(!0),window.api.schedule.setPrdDisposition({slug:e.slug,cwd:e.cwd??void 0,disposition:p,dependsOn:l}).then(J.fromOutcome).catch(()=>J.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:p=>{const l=p.target.value;if(l==="__new-head__")c("new-head");else if(l){const i=s.find(d=>d.rootSlug===l);i&&c("append",i.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(p=>t.jsxs("option",{value:p.rootSlug,children:["attach behind: ",Lt(p.label,40)]},p.rootSlug))]})}const Ys=[],Ks=new Set(["failed","needs_review","quarantined"]);function Qs(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 zs(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 Xs(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 Zs({row:e,elapsedMs:s,listIndex:n,onFocused:a,headChoices:c=Ys}){const[p,l]=h.useState(!1),i=e.job,d=s!==null&&e.rowKind==="running"?Tt(i,s):e.rowTrailing,r=e.status==="completed"||e.status==="skipped",o=e.rowKind==="dep"&&e.blockers.some(f=>!f.missing&&f.status!==null&&Ks.has(f.status)),u=r||o;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":i.status,"data-job-index":n,onClick:()=>l(f=>!f),onFocus:()=>a(n),"aria-expanded":p,"aria-label":`${e.prdNumber?`PRD ${e.prdNumber}, `:""}${i.title}, ${i.status}${d?`, ${d}`:""}`,title:i.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 ${zs(e)}`,children:[t.jsx("span",{"aria-hidden":"true",className:`shrink-0 w-[7px] h-[7px] rounded-full ${Qs(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:i.title}),t.jsx("span",{"data-testid":"prd-row-trailing",className:`shrink-0 font-mono text-[10.5px] ${Xs(e)}`,children:d})]}),p&&t.jsx(en,{row:e,elapsedMs:s,headChoices:c})]})}const Bt=h.memo(Zs);function en({row:e,elapsedMs:s,headChoices:n}){const a=e.job,[c,p]=h.useState(!1),l=oe(m=>m.sessions),i=h.useMemo(()=>Ce(a,l),[a,l]),d=i.known&&i.epicId?l[i.epicId]:null,r=h.useCallback(m=>kt(m),[]),o="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",f=a.error?a.error.split(`
|
|
3
|
-
`)[0]:null;return t.jsxs("div",{"data-testid":"prd-row-detail",className:"px-3 py-2 bg-bg-elev/50 border-t border-rule-inner flex flex-col gap-1",children:[t.jsxs("div",{className:o,children:[a.status.replace(/_/g," "),a.exitCode!==null&&` · exit ${a.exitCode}`,a.verifierVerdict&&` · ${Se(a.verifierVerdict)}`,a.startedAt&&` · started ${se(Date.parse(a.startedAt))}`,a.finishedAt&&` · finished ${se(Date.parse(a.finishedAt))}`,s===null&&e.rowTrailing&&e.rowKind==="done"?` · took ${e.rowTrailing}`:""]}),e.cycle&&t.jsxs("div",{className:`${o} text-accent`,"data-testid":"job-row-cycle-warning",children:["⚠ dependsOn cycle — ",e.blockers.map(m=>m.slug).join(" ↔ ")||"self-referencing"]}),!e.cycle&&e.blockers.length>0&&t.jsxs("div",{className:o,"data-testid":"job-row-blockers",children:["depends on ",e.blockers.map(m=>`${m.slug} (${m.missing?"missing":(m.status??"unknown").replace(/_/g," ")})`).join(", ")]}),a.status==="pending"&&a.heldReason&&t.jsxs("div",{className:`${o} text-amber-400/90`,"data-testid":"job-row-held-reason",children:["held · ",a.heldReason]}),f&&t.jsx("div",{className:`${o} text-accent/80`,children:f}),t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 pt-0.5",children:[d&&t.jsx("button",{type:"button","data-testid":"job-row-prompt-session-link",title:d.goalText,onClick:()=>r(d.id),className:`${u} text-accent hover:text-accent/80`,children:"view epic →"}),a.runId&&t.jsx("button",{type:"button",onClick:()=>p(!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(J.fromOutcome).catch(()=>J.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),className:`${u} text-fg-dim hover:text-fg`,children:"reset to pending →"}),a.disposition&&(a.status==="pending"||a.status==="quarantined")&&t.jsx(qt,{job:a,headChoices:n})]}),c&&a.runId&&t.jsx(Ie,{runId:a.runId,slug:a.slug,title:a.title||a.slug,onClose:()=>p(!1)})]})}const le=190,tn=7,sn=5,nn=[],Ht=e=>e==="completed"||e==="skipped",Gt=e=>e==="running"||e==="investigating",Ut=e=>e==="failed"||e==="needs_review"||e==="quarantined";function Pe(e){return Gt(e.status)?0:Ut(e.status)?1:Ht(e.status)?3:2}const an={done:"text-sage",running:"text-accent",held:"text-fg-faint",pending:"text-fg-faint",blocked:"text-butter"},rn={done:"bg-sage",running:"bg-accent",held:"bg-fg-faint/50",pending:"bg-fg-faint/50",blocked:"bg-butter"};function ln(e,s){return e.every(n=>Ht(n.status))?`+${e.length} done`:e.every(n=>n.rowKind==="dep"&&n.blockers.some(a=>!a.missing&&a.status!==null&&Ut(a.status)))?`+${e.length} blocked`:`+${e.length} in stage ${s}`}function on({stage:e,epicId:s,now:n,hidden:a,indexBySlug:c,headChoicesBySlug:p,onRowFocused:l}){const[i,d]=h.useState(!1),r=h.useMemo(()=>e.rows.filter(x=>!(a.has(x.slug)&&(x.status==="completed"||x.status==="failed"))).map((x,E)=>({r:x,i:E})).sort((x,E)=>Pe(x.r)-Pe(E.r)||x.i-E.i).map(x=>x.r),[e.rows,a]),o=h.useMemo(()=>r.filter(x=>Pe(x)<=1).length,[r]),u=Math.max(e.state==="done"?sn:tn,o),f=i?r:r.slice(0,u),m=i?[]:r.slice(u),g=r.find(x=>x.status==="failed"),b=r.find(x=>x.status==="needs_review"),w=o>0&&(g!==void 0||b!==void 0),D=f.reduce((x,E,N)=>Pe(E)<=1?N:x,-1),$=x=>t.jsx(Bt,{row:x,elapsedMs:Gt(x.status)&&x.job.startedAt?n-Date.parse(x.job.startedAt):null,listIndex:c.get(x.slug)??0,onFocused:l,headChoices:p.get(x.slug)??nn},x.slug),I="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:le},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 ${rn[e.state]}`}),t.jsxs("span",{className:`text-[10px] font-semibold uppercase tracking-wide ${an[e.state]}`,children:["Stage ",e.n]}),e.state==="blocked"&&t.jsx(he,{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:f.map((x,E)=>t.jsxs("div",{children:[$(x),w&&E===D&&t.jsxs("div",{"data-testid":"stage-attention-actions",className:"flex gap-1.5 px-2 py-1.5 border-t border-rule-inner",children:[g&&t.jsxs("button",{type:"button","data-testid":"stage-retry",title:`Reset ${g.slug} to pending`,onClick:()=>{window.api.schedule.resetJob(g.slug).then(N=>{N.ok||J.error(N.error??`Failed to reset ${g.slug}`)}).catch(()=>J.error(`Failed to reset ${g.slug}`))},className:I,children:["Retry ",g.prdNumber?`#${g.prdNumber}`:g.slug]}),b&&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&&kt(s)},className:I,children:["Review ",b.prdNumber?`#${b.prdNumber}`:b.slug]})]})]},x.slug))}),(m.length>0||i&&r.length>u)&&t.jsx("button",{type:"button","data-testid":"stage-footer","aria-expanded":i,onClick:()=>d(x=>!x),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:i?"show less ▴":`${ln(m,e.n)} ▾`})]})}const ge=6,Be=4,Me=4,ht=12,ft=5,Vt=2,xt=4,dn={done:"bg-sage",running:"bg-accent",attention:"bg-butter",failed:"bg-red-600",pending:"bg-fg-faint/50"};function cn(e){return e==="completed"||e==="skipped"?"done":e==="running"||e==="investigating"?"running":e==="failed"?"failed":e==="needs_review"||e==="quarantined"?"attention":"pending"}function un(e){const s=[],n=[],a=[];let c=ft;for(const p of e){const l=Math.max(1,Math.ceil(p.rows.length/Me));n.push(c),a.push(l*ge),p.rows.forEach((i,d)=>{s.push({x:c+Math.floor(d/Me)*ge,y:Vt+d%Me*ge,tone:cn(i.status),title:`${i.prdNumber?`#${i.prdNumber}`:i.slug} ${i.title} — ${i.status}`})}),c+=l*ge+ht}return{dots:s,stageX:n,stageW:a,width:Math.max(0,c-ht)+ft}}function me(e,s){return e.findIndex(n=>n.rows.some(a=>s(a.status)))}const We=e=>e==="running"||e==="investigating",Ye=e=>e==="failed"||e==="needs_review"||e==="quarantined";function pn({stages:e,first:s,perView:n,onSeek:a}){const c=h.useMemo(()=>un(e),[e]),p=h.useMemo(()=>me(e,We)>=0,[e]),l=h.useMemo(()=>me(e,Ye)>=0,[e]),i=h.useRef(!1),d=e.length,r=Math.min(d-1,s+n-1),o=c.stageX[Math.min(s,d-1)]??0,u=(c.stageX[r]??0)+(c.stageW[r]??0),f=g=>{const b=g.currentTarget.getBoundingClientRect(),w=g.clientX-b.left;let D=0;for(let $=0;$<d;$++)c.stageX[$]<=w&&(D=$);a(Math.max(0,Math.min(d-1,D-Math.floor(n/2))))},m="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(he,{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:c.width,height:Me*ge-(ge-Be)+2*Vt},onPointerDown:g=>{var b,w;i.current=!0,(w=(b=g.currentTarget).setPointerCapture)==null||w.call(b,g.pointerId),f(g)},onPointerMove:g=>{i.current&&f(g)},onPointerUp:()=>{i.current=!1},onPointerCancel:()=>{i.current=!1},children:[c.dots.map((g,b)=>t.jsx("span",{title:g.title,"data-tone":g.tone,className:`absolute rounded-[1px] ${dn[g.tone]}`,style:{left:g.x,top:g.y,width:Be,height:Be}},b)),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:o-xt,width:u-o+2*xt}})]}),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,d),"–",r+1," of ",d]}),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:!p,title:p?"Scroll to the lowest stage with a running PRD":"No stage has a running PRD",onClick:()=>a(me(e,We)),className:`${m} text-fg-dim hover:text-fg`,children:"Running"}),t.jsx("button",{type:"button","data-testid":"minimap-blockers",disabled:!l,title:l?"Scroll to the lowest stage with a failed / needs-review / quarantined PRD":"No stage has a failed, needs-review or quarantined PRD",onClick:()=>a(me(e,Ye)),className:`${m} text-fg-dim hover:text-fg border-l border-line`,children:"Blockers"})]})]})}const hn=148;function fn({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:hn},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(he,{title:"Stages beyond the visible window. Click one to scroll the stage columns to it."})]}),e.map(c=>{const p=c.rows.length===0?0:c.doneCount/c.rows.length*100;return t.jsxs("button",{type:"button","data-testid":"further-stage-row","data-stage":c.n,title:`${c.summary} — scroll to stage ${c.n}`,onClick:()=>s(c.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 ",c.n]}),t.jsx("span",{role:"progressbar","aria-valuenow":c.doneCount,"aria-valuemin":0,"aria-valuemax":c.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:`${p}%`}})})]},c.n)})]})}const xn=[],gn=e=>e==="running"||e==="investigating";function mn(e){const s=Ts(e),n=new Map,a=new Map;for(const i of e.stages){a.set(i.n,i.rows.length);for(const d of i.rows)n.set(d.slug,d)}const c=new Map;let p=0;const l=[];for(const i of s){const d=n.get(i);p+=d.estimateMinutes??0,c.set(d.stage,(c.get(d.stage)??0)+1),l.push({row:d,totalMinutes:p,othersInStage:0})}for(const i of l)i.othersInStage=(a.get(i.row.stage)??0)-(c.get(i.row.stage)??0);return l}function bn({plan:e,now:s,indexBySlug:n,headChoicesBySlug:a,onRowFocused:c}){const p=h.useMemo(()=>mn(e),[e]);return t.jsx("div",{"data-testid":"critical-path",className:"border-t border-rule-structural max-w-[640px]",children:p.map(({row:l,totalMinutes:i,othersInStage:d})=>t.jsxs("div",{"data-testid":"critical-entry","data-slug":l.slug,children:[t.jsxs("div",{className:"flex items-start",children:[t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx(Bt,{row:l,elapsedMs:gn(l.status)&&l.job.startedAt?s-Date.parse(l.job.startedAt):null,listIndex:n.get(l.slug)??0,onFocused:c,headChoices:a.get(l.slug)??xn})}),t.jsxs("span",{"data-testid":"critical-est",className:"shrink-0 h-[31px] px-3 flex items-center gap-2 font-mono text-[11.5px] text-fg-faint border-t border-rule-inner",children:[t.jsx("span",{title:"estimateMinutes",children:l.estimateMinutes?`${l.estimateMinutes}m`:"—"}),t.jsxs("span",{className:"text-fg-dim",title:"Running total along the chain",children:["Σ ",i,"m"]})]})]}),d>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 ",l.stage," · +",d," not on the critical path"]})]},l.slug))})}const gt=1,mt=1350,wn={active:"border-l-accent",queued:"border-l-rule-structural",done:"border-l-sage",draft:"border-l-fg-faint/40 border-dashed"},vn={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"}},jn=e=>String(e).padStart(2,"0");function yn({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 Nn({plan:e,mode:s="graph",now:n,hidden:a,indexBySlug:c,headChoicesBySlug:p,onRowFocused:l,onOpenPrds:i}){var U,Y;const[d,r]=h.useState(e.status==="active"||e.status==="queued"),[o,u]=h.useState(!1),f=h.useRef(null),[m,g]=h.useState(0),[b,w]=h.useState(mt),D=h.useMemo(()=>{const A=me(e.stages,We);return A>=0?A:Math.max(0,me(e.stages,Ye))},[e.stages]);h.useLayoutEffect(()=>{if(!d)return;const A=f.current,G=(A==null?void 0:A.clientWidth)||mt,F=Math.max(0,Math.min(D,e.stageCount-Math.max(1,Math.ceil(G/le))));A!=null&&A.clientWidth&&w(A.clientWidth),A&&(A.scrollLeft=F*le),g(F)},[d]);const $=h.useMemo(()=>{let A=null;for(const G of e.stages)for(const F of G.rows){if(!F.job.runId)continue;const q=F.job.finishedAt?Date.parse(F.job.finishedAt):0;(!A||q>A.at)&&(A={runId:F.job.runId,slug:F.slug,title:F.title,at:q})}return A},[e.stages]),I=Re((Y=(U=e.stages[0])==null?void 0:U.rows[0])==null?void 0:Y.job.cwd)??"—",x=vn[e.status],E=Math.max(1,Math.ceil(b/le)),N=Math.max(0,Math.min(m-gt,e.stageCount)),P=Math.min(e.stageCount,m+E+gt),k=A=>{const G=Math.max(0,Math.min(e.stageCount-1,A));f.current&&(f.current.scrollLeft=G*le),g(G)},S=Math.min(e.stageCount,m+E),_=A=>{const G=A.currentTarget,F=Math.floor(G.scrollLeft/le);F!==m&&g(F),G.clientWidth&&G.clientWidth!==b&&w(G.clientWidth)},O="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",H=(()=>{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(()=>J.error("Failed to pause the scheduler"))},className:O,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(J.fromOutcome).catch(()=>J.error("Failed to fire the next batch"))},className:O,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:O,children:"View run"});case"draft":return t.jsx("button",{type:"button","data-testid":"plan-action",title:"Open the PRDs sub-view on this plan's first PRD (the PRDs view has no per-Epic filter).",onClick:()=>{var A,G;return i==null?void 0:i(((G=(A=e.stages[0])==null?void 0:A.rows[0])==null?void 0:G.slug)??null)},className:O,children:"Schedule…"})}})(),L=e.etaMs>0?` · ${It(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] ${wn[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":d,"aria-label":d?"Collapse plan":"Expand plan","data-testid":"plan-toggle",onClick:()=>r(A=>!A),className:"shrink-0 w-[14px] text-[11px] text-fg-faint hover:text-fg bg-transparent border-0 cursor-pointer p-0",children:d?"▾":"▸"}),t.jsx("span",{className:"font-mono text-[11.5px] text-fg-faint shrink-0",children:jn(e.index)}),t.jsx("span",{className:"font-serif text-[15px] font-bold text-fg truncate shrink-0 max-w-[320px]",title: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 ${x.cls}`,children:x.label}),t.jsx("span",{"aria-hidden":"true",className:"shrink-0 w-px h-[16px] bg-rule-structural"}),t.jsxs("span",{className:"font-mono text-[11.5px] text-fg-faint truncate min-w-0","data-testid":"plan-meta",children:[I," · ",e.prdCount," PRD",e.prdCount===1?"":"s"," · ",e.stageCount," stage",e.stageCount===1?"":"s"]}),t.jsx(he,{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,L]}),t.jsx(yn,{plan:e}),H]}),d&&s==="critical"&&t.jsx(bn,{plan:e,now:n,indexBySlug:c,headChoicesBySlug:p,onRowFocused:l}),d&&s!=="critical"&&e.status==="active"&&t.jsx(pn,{stages:e.stages,first:m,perView:E,onSeek:k}),d&&s!=="critical"&&t.jsxs("div",{className:"flex border-t border-rule-structural",children:[t.jsxs("div",{ref:f,"data-testid":"plan-stages",onScroll:_,className:"flex flex-1 min-w-0 overflow-x-auto",children:[N>0&&t.jsx("div",{"aria-hidden":"true",className:"shrink-0",style:{width:N*le}}),e.stages.slice(N,P).map(A=>t.jsx(on,{stage:A,epicId:e.epicId,now:n,hidden:a,indexBySlug:c,headChoicesBySlug:p,onRowFocused:l},A.n)),P<e.stageCount&&t.jsx("div",{"aria-hidden":"true",className:"shrink-0",style:{width:(e.stageCount-P)*le}})]}),t.jsx(fn,{stages:e.stages.slice(S),onSeek:k})]}),o&&$&&t.jsx(Ie,{runId:$.runId,slug:$.slug,title:$.title||$.slug,onClose:()=>u(!1)})]})}function kn({section:e,children:s}){const[n,a]=h.useState(!0),c=Object.entries(e.counts).map(([p,l])=>`${l} ${p.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(p=>!p),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(Ke,{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:c})]}),n&&s]})}const Sn=[],Cn=[],$n={depth:0,blockers:Sn,blocked:!1,hasNeedsReviewBlocker:!1,hasMissingDep:!1,cycle:!1,parallelEligible:!1};function Dn(e){return e.missing?`${e.slug} (missing)`:e.needsReview?`${e.slug} (needs review)`:`${e.slug} (${(e.status??"unknown").replace(/_/g," ")})`}function Pn(e){return e.missing?"text-accent":e.needsReview?"text-butter font-semibold":e.status==="completed"?"text-sage":"text-amber-400/90"}function An({job:e,eta:s,elapsedMs:n,avgDurationMs:a,listIndex:c,onFocused:p,hold:l,backlog:i=$n,headChoices:d=Cn}){const[r,o]=h.useState(!1),[u,f]=h.useState(!1),m=oe(P=>P.sessions),g=h.useMemo(()=>Ce(e,m),[e,m]),b=g.known&&g.epicId?m[g.epicId]:null,w=h.useCallback(P=>{Qe(P),window.dispatchEvent(new CustomEvent("sm:navigate",{detail:"terminal"}))},[]),D=e.status==="running",$=e.status==="failed";let I=null;D&&n!==null?I=`${it(n)} elapsed`:e.status==="completed"&&e.startedAt&&e.finishedAt?I=`took ${ke(Date.parse(e.finishedAt)-Date.parse(e.startedAt))}`:s&&(I=s);const x=e.error??null,E=$&&x?x.split(`
|
|
4
|
-
`)[0]:e.status==="needs_review"&&e.verifierVerdict?Se(e.verifierVerdict):null,N=D&&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":c,"data-depth":i.depth,onClick:()=>o(P=>!P),onFocus:()=>p(c),style:i.depth>0?{paddingLeft:18+i.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 ${r?"bg-bg-elev/40":""}`,"aria-expanded":r,"aria-label":`${te(e.slug)?`PRD ${te(e.slug)}, `:""}${e.title}, ${e.status}${I?`, ${I}`:""}`,title:e.title,children:[t.jsx(St,{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:[te(e.slug)&&t.jsx(Ct,{n:te(e.slug)}),e.title,t.jsx($t,{leaked:e.leakedDescendants}),t.jsx(os,{count:e.leftoverCount,truncated:e.leftoverPathsTruncated,salvagePatch:e.salvagePatch}),i.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"})]}),i.cycle&&t.jsxs("div",{className:"text-[12.5px] mt-0.5 text-accent font-mono","data-testid":"job-row-cycle-warning",children:["⚠ dependsOn cycle — ",i.blockers.map(P=>P.slug).join(" ↔ ")||"self-referencing"]}),!i.cycle&&i.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:i.blocked||i.hasMissingDep?"text-amber-400/90":"text-fg-faint",children:i.blocked||i.hasMissingDep?"blocked by ":"depends on "}),i.blockers.map((P,k)=>t.jsxs("span",{className:Pn(P),children:[k>0&&", ",Dn(P)]},P.slug))]}),E&&t.jsx("div",{className:`text-[12.5px] mt-0.5 ${$?"text-accent/80":"text-fg-faint"}`,children:E}),l&&t.jsx("div",{className:"text-[12.5px] mt-0.5 text-amber-400/90 font-mono","data-testid":"job-row-hold",children:l.dep?t.jsxs(t.Fragment,{children:["held · waiting on ",l.dep," (",l.depStatus,")"]}):t.jsxs(t.Fragment,{children:["held · ",l.reason??"launch blocked"]})}),!l&&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(ze,{epicId:g.epicId,label:g.label?Lt(g.label):null,onOpen:w,testId:"job-row-prompt-session-chip",className:"mt-0.5"})]}),t.jsx(Xe,{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(ds,{status:e.status,overrun:e.overrun}),I,t.jsx("span",{className:`text-fg-faint inline-flex transition-transform duration-150 ${r?"rotate-90":""}`,"aria-hidden":"true",children:t.jsx(Ke,{name:"chevron",size:14})})]})]}),D&&!r&&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,N*100)}%`}})}),r&&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(ee,{label:"Status",children:[t.jsx(B,{k:"result",v:e.exitCode!==null?`exit ${e.exitCode}`:"—"}),t.jsx(B,{k:"state",v:e.status.replace(/_/g," ")}),e.verifierVerdict&&t.jsx(B,{k:"verdict",v:Se(e.verifierVerdict)}),e.leakedDescendants&&e.leakedDescendants.length>0&&t.jsx(B,{k:"leaked",v:Dt(e.leakedDescendants),wrap:!0}),e.leftoverCount!=null&&e.leftoverCount>0&&t.jsx(B,{k:"uncommitted",v:`${e.leftoverCount} file${e.leftoverCount===1?"":"s"}${e.leftoverPathsTruncated?"+":""}: ${(e.leftoverPaths??[]).join(", ")}${e.salvagePatch?` — salvaged to ${e.salvagePatch}`:""}`,wrap:!0}),x&&t.jsx(B,{k:"error",v:x.split(`
|
|
5
|
-
`)[0],wrap:!0})]}),e.statusHistory&&e.statusHistory.length>0&&t.jsx(ee,{label:"History",children:t.jsx("div",{className:"grid gap-1",children:e.statusHistory.map((P,k)=>t.jsxs("div",{className:"font-mono text-xs leading-relaxed",children:[t.jsxs("div",{className:"text-fg",children:[P.from??"(new)"," → ",P.to,t.jsxs("span",{className:"text-fg-faint",children:[" · ",se(Date.parse(P.at))]})]}),P.reason&&t.jsx("div",{className:"text-fg-faint break-words",children:P.reason})]},k))})}),t.jsxs(ee,{label:"Timing",children:[t.jsx(B,{k:"started",v:e.startedAt?se(Date.parse(e.startedAt)):"—"}),t.jsx(B,{k:"finished",v:e.finishedAt?se(Date.parse(e.finishedAt)):"—"}),t.jsx(B,{k:"duration",v:e.startedAt&&e.finishedAt?ke(Date.parse(e.finishedAt)-Date.parse(e.startedAt)):D&&n!==null?it(n):"—"})]}),t.jsxs(ee,{label:"Location",children:[t.jsx(B,{k:"group",v:`${e.parallelGroup} · ${e.slug}`}),t.jsx(B,{k:"cwd",v:e.cwd??"—",wrap:!0}),t.jsx(B,{k:"session",v:g.label??g.epicId??"—",wrap:!0}),t.jsx(B,{k:"session id",v:g.epicId??"—",wrap:!0}),t.jsx(B,{k:"prompt id",v:e.sourcePromptId??"—",wrap:!0}),t.jsx(B,{k:"source tab",v:e.sourceTabId??"—",wrap:!0})]}),t.jsx(ee,{label:"Actions",children:t.jsxs("div",{className:"flex flex-col gap-1.5 items-start",children:[b&&t.jsx("button",{type:"button","data-testid":"job-row-prompt-session-link",title:b.goalText,onClick:()=>w(b.id),className:"text-[13px] font-semibold text-accent hover:text-accent/80 bg-transparent border-0 cursor-pointer p-0",children:"view epic →"}),e.runId&&t.jsx("button",{type:"button",onClick:()=>f(!0),className:"text-[13px] font-semibold text-fg-dim hover:text-fg bg-transparent border-0 cursor-pointer p-0",children:"view log →"}),e.status==="quarantined"&&t.jsx("button",{type:"button","data-testid":"job-row-adopt-prd",title:"Stamp this PRD's provenance so the scheduler will run it — no unstamped PRD runs automatically.",onClick:()=>{window.api.schedule.adoptPrd(e.slug).then(J.fromOutcome).catch(()=>J.error("Failed to adopt PRD"))},className:"text-[13px] font-semibold text-accent hover:text-accent/80 bg-transparent border-0 cursor-pointer p-0",children:"adopt PRD →"}),e.status!=="pending"&&e.status!=="running"&&e.status!=="quarantined"&&t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resetJob(e.slug),className:"text-[13px] font-semibold text-fg-dim hover:text-fg bg-transparent border-0 cursor-pointer p-0",children:"reset to pending →"}),e.disposition&&(e.status==="pending"||e.status==="quarantined")&&t.jsx(qt,{job:e,headChoices:d})]})})]}),u&&e.runId&&t.jsx(Ie,{runId:e.runId,slug:e.slug,title:e.title||e.slug,onClose:()=>f(!1)})]})}const Mn=h.memo(An);function Rn({supervisorConfig:e,onSetConfig:s,onBack:n}){const[a,c]=h.useState([]),[p,l]=h.useState(()=>Date.now()),i=Pt();h.useEffect(()=>{if(!i)return;window.api.supervisor.getLog().then(c).catch(()=>{}),l(Date.now());const r=setInterval(()=>l(Date.now()),5e3);return()=>clearInterval(r)},[i]);const d={enabled:(e==null?void 0:e.enabled)??!0,intervalMinutes:(e==null?void 0:e.intervalMinutes)??15,maxConcurrentProbes:(e==null?void 0:e.maxConcurrentProbes)??2,probeStaleThresholdMinutes:(e==null?void 0:e.probeStaleThresholdMinutes)??10};return t.jsxs("div",{className:"bg-bg-elev/60",children:[t.jsxs("div",{className:"px-3 py-2 flex items-center gap-2 border-b border-line",children:[t.jsx("button",{type:"button",onClick:n,className:"text-[10px] text-fg-faint hover:text-fg-dim",title:"Back to queue",children:"← queue"}),t.jsx("span",{className:"text-[11px] font-medium text-fg-dim",children:"Supervisor"}),t.jsx("button",{type:"button",onClick:()=>window.api.supervisor.getLog().then(c).catch(()=>{}),className:"ml-auto text-[10px] text-fg-faint hover:text-fg-dim underline",title:"Refresh log",children:"refresh"})]}),t.jsxs("div",{className:"px-3 py-2 space-y-1.5 border-b border-line",children:[t.jsx("div",{className:"text-[9px] text-fg-faint uppercase tracking-wider",children:"Config"}),t.jsxs("div",{className:"flex items-center gap-3 flex-wrap text-[10px] text-fg-faint",children:[t.jsxs("label",{className:"flex items-center gap-1",children:[t.jsx("input",{type:"checkbox",checked:d.enabled,onChange:r=>s({enabled:r.target.checked}),className:"cursor-pointer"}),t.jsx("span",{children:"enabled"})]}),t.jsxs("label",{className:"flex items-center gap-1",title:"How often to check for wedged jobs (minutes)",children:[t.jsx("span",{children:"interval"}),t.jsx("input",{type:"number",min:5,max:60,value:d.intervalMinutes,onChange:r=>s({intervalMinutes:Number(r.target.value)}),className:"w-10 bg-bg border border-line rounded px-1 py-0.5 font-mono"}),t.jsx("span",{children:"min"})]}),t.jsxs("label",{className:"flex items-center gap-1",title:"Max concurrent Opus probes per tick",children:[t.jsx("span",{children:"probes"}),t.jsx("input",{type:"number",min:1,max:5,value:d.maxConcurrentProbes,onChange:r=>s({maxConcurrentProbes:Number(r.target.value)}),className:"w-8 bg-bg border border-line rounded px-1 py-0.5 font-mono"})]}),t.jsxs("label",{className:"flex items-center gap-1",title:"Probe a job only if no JSONL event in this many minutes",children:[t.jsx("span",{children:"stale"}),t.jsx("input",{type:"number",min:5,max:30,value:d.probeStaleThresholdMinutes,onChange:r=>s({probeStaleThresholdMinutes:Number(r.target.value)}),className:"w-8 bg-bg border border-line rounded px-1 py-0.5 font-mono"}),t.jsx("span",{children:"min"})]})]})]}),t.jsxs("div",{className:"px-3 py-2",children:[t.jsxs("div",{className:"text-[9px] text-fg-faint uppercase tracking-wider mb-1",children:["Recent probes (last ",a.length,")"]}),a.length===0?t.jsx("div",{className:"text-[10px] text-fg-faint italic",children:"No probes yet."}):t.jsx("div",{className:"space-y-0.5 max-h-64 overflow-y-auto",children:a.map((r,o)=>t.jsx(En,{entry:r,now:p},`${r.ts}-${o}`))})]})]})}function En({entry:e,now:s}){const n=e.action!=="none",a=z(s-e.ts);return t.jsxs("div",{className:`text-[10px] px-1.5 py-1 rounded font-mono ${n?"bg-red-500/10 border border-red-500/20":"bg-bg/40"}`,title:e.reason,children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsxs("span",{className:"text-fg-faint shrink-0",children:[a," ago"]}),t.jsx("span",{className:`shrink-0 px-1 rounded ${e.verdict==="stuck"?"text-red-400 bg-red-500/10":"text-green-500/70"}`,children:e.verdict}),t.jsx("span",{className:"truncate text-fg-dim",children:e.jobSlug}),n&&t.jsxs("span",{className:"shrink-0 text-red-400",children:[e.action,e.targetPid?` pid=${e.targetPid}`:""]}),e.costUsd!==null&&t.jsxs("span",{className:"shrink-0 text-fg-faint",children:["$",e.costUsd.toFixed(3)]})]}),t.jsx("div",{className:"text-fg-faint truncate mt-0.5",children:e.reason})]})}const In=[{title:"Start a session",body:"In Sessions, pick an Agent and a Mission, describe the outcome you want, then Approve & start. Its thread writes the PRD files into that session's own folder."},{title:"Queue what it wrote",body:"The PRDs tab lists every file the session produced. Queue one, or the whole session, and they appear here."},{title:"Leave it alone",body:"Jobs start themselves inside your window, pause on rate-limit, and resume at the reset. History records how each ended."}],Tn=[{term:"Session",def:"One goal, one Claude session, and the folder of PRDs written to reach it."},{term:"PRD",def:"One markdown file = one job. Authored by the session."},{term:"5-hour window",def:"Your Claude billing window, on a rolling clock."},{term:"Session pool",def:"5 slots shared with terminal and session chats."}];function _n({navigate:e}){return t.jsx("div",{className:"overflow-y-auto h-full",children:t.jsx("div",{className:"px-9 py-6 max-w-[900px] mx-auto",children:t.jsxs("div",{className:"bg-bg-hi border border-line rounded-2xl px-9 py-8",children:[t.jsx("h2",{className:"m-0 font-serif text-[25px] font-semibold text-fg",children:"Nothing to run yet — the scheduler needs a session."}),t.jsx("p",{className:"mt-2 mb-6 text-[14.5px] text-fg-dim leading-relaxed max-w-[580px]",children:"You don't write PRDs here. A session breaks its goal into numbered PRD files, and this page runs them in order. Two steps, once."}),t.jsx("div",{className:"grid grid-cols-3 gap-3.5",children:In.map((s,n)=>{const a=n===0;return t.jsxs("div",{className:`bg-bg border rounded-xl px-4 py-4 flex flex-col gap-2 ${a?"border-accent shadow-[0_0_0_3px_rgba(184,92,52,.09)]":"border-line"}`,children:[t.jsx("span",{className:`w-6 h-6 rounded-full grid place-items-center font-mono text-[12px] font-semibold ${a?"bg-accent text-white":"bg-bg-elev text-fg-dim"}`,children:n+1}),t.jsx("h3",{className:"m-0 text-[15px] font-semibold text-fg",children:s.title}),t.jsx("p",{className:"m-0 text-[13.5px] text-fg-dim leading-relaxed",children:s.body}),a&&t.jsx("button",{type:"button",onClick:()=>e==null?void 0:e("terminal"),className:"self-start bg-accent text-white rounded-lg px-3.5 py-1.5 text-[13px] font-semibold mt-1",children:"Go to Sessions →"})]},s.title)})}),t.jsx("dl",{className:"flex mt-[22px] pt-4 border-t border-line gap-5 flex-wrap",children:Tn.map(({term:s,def:n})=>t.jsxs("div",{className:"flex-1 min-w-[150px]",children:[t.jsx("dt",{className:"text-[13.5px] font-semibold text-fg mb-0.5",children:s}),t.jsx("dd",{className:"m-0 text-[12.5px] text-fg-faint leading-relaxed",children:n})]},s))})]})})})}const On=5e3;let Ae=null,je=null;async function bt(e){const s=Date.now();return!(e!=null&&e.fresh)&&Ae&&s-Ae.at<On?Ae.result:je||(je=(async()=>{try{const n=await window.api.schedule.lintQueue();return Ae={result:n,at:Date.now()},n}finally{je=null}})(),je)}function Ln({health:e,jobCount:s,lastRunAt:n,nextReset:a,now:c,onOpenSupervisor:p}){const[l,i]=h.useState(!1),[d,r]=h.useState(null),[o,u]=h.useState(!1),f=`${s}:${n??""}`;h.useEffect(()=>{let N=!0;return u(!0),bt().then(P=>{N&&r(P)}).catch(()=>{}).finally(()=>{N&&u(!1)}),()=>{N=!1}},[f]);let m=0,g=0;const b=d?d.reports.filter(N=>N.findings.length>0):[];for(const N of b)for(const P of N.findings)P.severity==="error"?m++:g++;const w=m===0&&g===0,D=d?`graph lint ${m} error${m===1?"":"s"}, ${g} warn${g===1?"":"s"}`:`graph lint ${o?"scanning…":"idle"}`,$=(e==null?void 0:e.consecutiveFailures)??0,x=[e?`${$} poll failure${$===1?"":"s"} since boot`:null,D].filter(Boolean).join(" · "),E="text-accent hover:underline bg-transparent border-0 p-0 cursor-pointer text-[12px]";return t.jsxs("div",{"data-testid":"scheduler-footer",className:"border-t border-rule-structural",children:[t.jsxs("div",{className:"h-[28px] flex items-center gap-2 px-[18px] font-mono text-[11.5px] text-fg-faint",children:[t.jsx("span",{"data-testid":"footer-summary",className:"truncate",children:x}),t.jsx("button",{type:"button","data-testid":"footer-info","aria-expanded":l,onClick:()=>i(N=>!N),className:"bg-transparent border-0 p-0 cursor-pointer",children:t.jsx(he,{title:"Scheduler poll health and queue-lint findings — click for the full detail"})}),t.jsxs("span",{className:"ml-auto flex items-center gap-3 shrink-0",children:[t.jsxs("span",{"data-testid":"footer-timing",children:[a?t.jsxs("span",{title:`next 5h reset: ${a}`,children:["reset ",z(Date.parse(a)-c)]}):null,a&&n?" · ":null,n?t.jsxs("span",{title:n,children:["last run ",z(c-Date.parse(n))," ago"]}):null]}),t.jsx("button",{type:"button","data-testid":"footer-supervisor",onClick:p,title:"Open supervisor log and settings",className:E,children:"supervisor"}),t.jsx("button",{type:"button","data-testid":"footer-folder",onClick:()=>window.api.schedule.openFolder(),className:E,children:"folder"})]})]}),l&&t.jsxs("div",{"data-testid":"footer-detail",className:"px-[18px] pb-2 space-y-2 font-mono text-[12px] text-fg-dim border-t border-rule-inner pt-2",children:[e&&t.jsxs("div",{className:"space-y-0.5",children:[t.jsxs("div",{children:["booted: ",pe(e.bootedAt,c)]}),t.jsxs("div",{children:["last poll: ",pe(e.lastPollAt,c)," · ",e.lastPollOk?"ok":"failed"]}),e.backoffNextAt!==null&&e.backoffNextAt>c&&t.jsxs("div",{children:["retry in: ",z(e.backoffNextAt-c)]}),e.nextResetCached&&t.jsxs("div",{children:["cached reset: ",se(Date.parse(e.nextResetCached))]}),e.runningJobs.length>0&&t.jsxs("div",{children:["running: ",e.runningJobs.map(N=>`${N.slug}(pid ${N.pid})`).join(", ")]})]}),d&&t.jsxs("div",{className:"space-y-1",children:[w?t.jsxs("div",{className:"text-sage",children:["✓ no issues in ",d.reports.length," PRD",d.reports.length!==1?"s":""]}):b.map(N=>t.jsxs("div",{children:[t.jsx("div",{className:"text-fg-dim truncate",title:N.slug,children:N.slug}),N.findings.map((P,k)=>t.jsxs("div",{className:`pl-3 truncate ${P.severity==="error"?"text-accent/80":"text-butter/90"}`,title:P.snippet,children:[P.severity==="error"?"✗":"⚠"," L",P.line,": ",P.snippet]},`${N.slug}-${k}`))]},N.slug)),t.jsx("button",{type:"button","data-testid":"footer-rerun-lint",onClick:()=>{u(!0),bt({fresh:!0}).then(r).catch(()=>{}).finally(()=>u(!1))},className:"text-fg-faint hover:text-fg-dim underline",children:o?"…":"rerun lint"})]})]})]})}const Fn=5,qn=1440*60*1e3,Jt="sm.scheduler.hiddenCompletedSlugs",He="sm.scheduler.focusedJobIndex",Wt="sm.scheduler.queueFilter",Bn=["all","running","investigating","pending","completed","skipped","needs_review","failed","quarantined"];function Hn(){try{const e=localStorage.getItem(Wt);if(!e)return{text:"",status:"all"};const s=JSON.parse(e);return{text:"",status:Bn.includes(s.status)?s.status:"all"}}catch{return{text:"",status:"all"}}}function wt(e){try{localStorage.setItem(Wt,JSON.stringify({status:e.status}))}catch{}}function vt(e,s){if(s.status==="all"&&!s.text)return e;const n=s.text.toLowerCase();return e.filter(a=>{if(s.status!=="all"&&a.status!==s.status)return!1;if(!n)return!0;const c=Re(a.cwd)??"";return a.title.toLowerCase().includes(n)||a.slug.toLowerCase().includes(n)||c.toLowerCase().includes(n)})}function Gn(){try{const e=localStorage.getItem(Jt);if(!e)return new Set;const s=JSON.parse(e);return Array.isArray(s)?new Set(s.filter(n=>typeof n=="string")):new Set}catch{return new Set}}function jt(e){try{localStorage.setItem(Jt,JSON.stringify([...e]))}catch{}}function Un({scopeCwd:e=null,navigate:s,filterText:n,planMode:a="graph",onOpenPrds:c,planToolsEl:p=null}){var at;const l=Ee(j=>j.snapshot),i=h.useMemo(()=>!l||!e?l:{...l,jobs:l.jobs.filter(j=>j.cwd===e)},[l,e]),[d,r]=h.useState(null),[o,u]=h.useState(()=>Date.now()),[f,m]=h.useState(()=>Gn()),[g,b]=h.useState(!1),[w,D]=h.useState(()=>Hn()),$=h.useMemo(()=>n===void 0?w:{...w,text:n},[w,n]),[I,x]=h.useState(!1),[E,N]=h.useState("queue"),P=h.useRef(null),[k,S]=h.useState(()=>{try{return Number(localStorage.getItem(He))||0}catch{return 0}}),[_,O]=h.useState(""),H=Pt();h.useEffect(()=>(window.api.schedule.health().then(r).catch(()=>{}),window.api.schedule.onState(()=>{window.api.schedule.health().then(r).catch(()=>{})})),[]),h.useEffect(()=>{if(!H)return;u(Date.now());const j=setInterval(()=>u(Date.now()),1e3);return()=>clearInterval(j)},[H]);const L=h.useMemo(()=>{if(!i)return 15e4;const j=[];for(const T of i.jobs)if(T.status==="completed"&&T.startedAt&&T.finishedAt){const V=Date.parse(T.finishedAt)-Date.parse(T.startedAt);V>0&&j.push(V)}return j.length===0?15e4:j.reduce((T,V)=>T+V,0)/j.length},[i]),U=h.useRef(new Map);h.useEffect(()=>{if(!i)return;const j=[];for(const T of i.jobs){const V=U.current.get(T.slug);V&&V!==T.status&&j.push(`${T.title}: ${V} → ${T.status}`),U.current.set(T.slug,T.status)}j.length>0&&O(j.join("; "))},[i]);const Y=h.useMemo(()=>{var T;const j=new Map;for(const V of((T=i==null?void 0:i.lastTick)==null?void 0:T.holds)??[])j.set(V.slug,V);return j},[i==null?void 0:i.lastTick]),A=oe(j=>j.sessions),G=h.useMemo(()=>i?Mt(i.jobs,A,l==null?void 0:l.jobs):[],[i,A,l]),F=h.useMemo(()=>i?vt(i.jobs,$):[],[i,$]),q=(at=i==null?void 0:i.effectiveConcurrency)==null?void 0:at.cap,W=h.useMemo(()=>a==="list"?[]:Ze(F,{sessions:A,avgDurationMs:L,concurrency:q}),[a,F,A,L,q]),be=h.useMemo(()=>{const j=new Map;let T=0;for(const V of W)for(const Q of V.stages)for(const Z of Q.rows)j.set(Z.slug,T++);return j},[W]),de=h.useMemo(()=>Ws(G),[G]),v=f,C=h.useCallback(j=>{var xe;const T=(xe=P.current)==null?void 0:xe.querySelectorAll("[data-job-row]");if(!T||T.length===0)return;const V=Array.from(T),Q=V.findIndex(X=>X.dataset.jobIndex===String(k)),Z=X=>{const ce=V[X];if(!ce)return;const re=Number(ce.dataset.jobIndex);S(re);try{localStorage.setItem(He,String(re))}catch{}ce.focus()};j.key==="ArrowDown"?(j.preventDefault(),Z(Q===-1?0:Math.min(Q+1,V.length-1))):j.key==="ArrowUp"&&(j.preventDefault(),Z(Q===-1?V.length-1:Math.max(Q-1,0)))},[k]),y=h.useCallback(j=>{S(j);try{localStorage.setItem(He,String(j))}catch{}},[]);if(!i)return null;if(E==="supervisor")return t.jsx(Rn,{supervisorConfig:i.config.supervisor,onSetConfig:j=>window.api.schedule.setConfig({supervisor:j}),onBack:()=>N("queue")});const{jobs:M,paused:R,lastRunAt:K,nextReset:fe,effectiveConcurrency:_e}=i;if(M.length===0)return t.jsx(_n,{navigate:s});const ne={pending:0,running:0,investigating:0,completed:0,needs_review:0,failed:0};for(const j of M)j.status in ne&&ne[j.status]++;const Oe=M.filter(j=>j.status==="running"),Kt=_t({snap:i,now:o,avgDurationMs:L,runningJobs:Oe}),we=vt(M,$),Qt=Vn(we),{inline:$e,collapsedCount:Le}=Jn(we,f,o,g),zt=Wn($e,M,Qt,L,Kt.kind,o),et=()=>{const j=new Set(f);for(const T of M)(T.status==="completed"||T.status==="failed")&&j.add(T.slug);m(j),jt(j)},tt=async()=>{const j=M.filter(Q=>Q.status!=="running").length;if(j===0)return;const T=`Archive ${j} non-running PRD${j===1?"":"s"} and remove from the queue?
|
|
6
|
-
|
|
7
|
-
Files are moved to prds-archived/<timestamp>/ and can be restored from disk. Running jobs are kept.`;if(!window.confirm(T))return;const V=await window.api.schedule.clearQueue();V.ok||J.error(`Clear queue failed: ${V.error??"unknown error"}`)},st=()=>{m(new Set),jt(new Set),b(!1)},nt=a==="list"?$e.some(j=>j.status==="completed"):M.some(j=>(j.status==="completed"||j.status==="skipped")&&!f.has(j.slug)),Xt=M.filter(j=>(j.status==="completed"||j.status==="failed")&&f.has(j.slug)).length,ae=a==="list",De=ae?"":"px-[18px] py-2";return t.jsxs("div",{className:"overflow-y-auto h-full",children:[t.jsx("div",{"aria-live":"polite","aria-atomic":"true",className:"sr-only",children:_}),t.jsxs("div",{className:ae?"px-9 py-6 max-w-[1100px] mx-auto space-y-4":"",children:[d&&d.consecutiveFailures>5&&d.lastFailureKind==="meter_rate_limited"&&!R&&!I&&t.jsx("div",{className:De,children:t.jsxs("div",{className:ae?"flex items-center gap-3 px-4 py-3 bg-amber-400/15 border border-amber-400/30 rounded-xl":"flex items-center gap-3 -mx-[18px] px-[18px] py-1 bg-amber-400/15 border-y border-amber-400/30",children:[t.jsx("span",{"aria-hidden":"true",children:"⚠"}),t.jsxs("span",{className:"text-[13.5px] text-amber-400/90",children:[t.jsx("strong",{className:"font-semibold",children:"Usage meter unavailable"})," — last good reading"," ",pe(d.lastPollAt,o),". Firing on a conservative estimate until it recovers."]}),t.jsx("button",{type:"button",onClick:()=>x(!0),className:"ml-auto text-[12px] text-amber-400/70 hover:text-amber-400 shrink-0",title:"Dismiss this banner. The scheduler continues firing normally.",children:"Dismiss"})]})}),ae&&Oe.length>0&&(()=>{const j=(_e==null?void 0:_e.cap)??5,T=M.filter(V=>V.status==="pending").length;return t.jsxs("div",{className:`flex items-center gap-2 text-[12px] font-mono ${De}`,children:[t.jsxs("span",{className:"px-2 py-0.5 rounded bg-amber-400/20 text-amber-400 shrink-0",children:[Oe.length,"/",j," running"]}),T>0&&t.jsxs("span",{className:"text-fg-faint",children:["+",T," ready in this group"]})]})})(),ae&&M.length>0&&t.jsx("div",{className:De,children:t.jsx(Kn,{showText:n===void 0,filter:$,onChange:j=>{D(j),wt(j)}})}),!ae&&t.jsxs("div",{"data-testid":"plan-graph",children:[p&&cs.createPortal(t.jsx(Yn,{jobCount:we.length,counts:ne,filter:$,onFilter:j=>{D(j),wt(j)},hiddenInGraph:Xt,onUnhideAll:st,hasInlineCompleted:nt,onClearCompleted:et,onClearQueue:tt,clearQueueDisabled:M.every(j=>j.status==="running")}),p),W.length===0&&t.jsx("div",{className:"px-[18px] py-6 text-[13px] text-fg-faint italic",children:"no matching jobs"}),t.jsx("div",{ref:P,role:"list","aria-label":"Job queue",onKeyDown:C,children:W.map(j=>t.jsx(Nn,{plan:j,mode:a,now:o,hidden:v,indexBySlug:be,headChoicesBySlug:de,onRowFocused:y,onOpenPrds:c},j.epicId??"__none__"))})]}),ae&&t.jsxs("div",{className:"bg-bg-hi border border-line rounded-2xl overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-[18px] py-3 bg-bg-elev",children:[t.jsxs("span",{className:"font-serif text-base font-semibold text-fg",children:[we.length," job",we.length!==1?"s":""]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("span",{className:"font-mono text-[12px] text-fg-faint",children:[ne.pending,"p · ",ne.running,"r · ",ne.completed,"d",ne.failed>0&&t.jsxs("span",{className:"text-accent",children:[" · ",ne.failed,"f"]})]}),nt&&t.jsx("button",{type:"button",onClick:et,className:"text-[12.5px] text-fg-dim hover:text-fg bg-transparent border-0 cursor-pointer font-medium",title:"Hide completed jobs from this view (queue.json unchanged — they remain in history)",children:"Clear completed"}),t.jsx("button",{type:"button",onClick:tt,disabled:M.every(j=>j.status==="running"),className:"text-[12px] text-accent border border-accent/40 hover:bg-accent/10 rounded-md px-2.5 py-1 cursor-pointer font-medium disabled:opacity-40 disabled:cursor-not-allowed",title:"Archive every non-running PRD (moved to prds-archived/<timestamp>/) and remove them from the queue. Running jobs are kept.",children:"Archive & clear queue…"})]})]}),$e.length===0&&Le===0&&t.jsx("div",{className:"px-[18px] py-6 text-[13px] text-fg-faint italic",children:"no matching jobs"}),t.jsx("div",{ref:P,role:"list","aria-label":"Job queue",onKeyDown:C,children:(()=>{const j=new Set($e.map(Q=>Q.slug));let T=0;return G.map(Q=>{const Z=Ft(Q),xe=Q.nodes.map(X=>{const ce=Te([X]).filter(re=>j.has(re.row.slug)).map(re=>({node:re,listIndex:T++}));return{headRootSlug:X.row.slug,rows:ce}}).filter(X=>X.rows.length>0);return{section:Q,heads:xe,headChoices:Z}}).filter(Q=>Q.heads.length>0).map(({section:Q,heads:Z,headChoices:xe})=>t.jsx(kn,{section:Q,children:Z.map(({headRootSlug:X,rows:ce},re)=>t.jsxs("div",{"data-testid":"backlog-head-group",children:[Z.length>1&&t.jsxs("div",{className:"px-[18px] pt-2.5 pb-1 text-[11px] font-mono uppercase tracking-wide text-fg-faint bg-bg-elev/30 border-t border-line/60","data-testid":"backlog-head-label",children:["Plan ",re+1," of ",Z.length]}),ce.map(({node:ie,listIndex:Zt})=>t.jsx(Mn,{job:ie.row,backlog:ie,eta:zt.get(ie.row.slug)??null,elapsedMs:ie.row.status==="running"&&ie.row.startedAt?o-Date.parse(ie.row.startedAt):null,avgDurationMs:L,listIndex:Zt,hold:Y.get(ie.row.slug),onFocused:y,headChoices:xe.filter(es=>es.rootSlug!==X)},ie.row.slug))]},X))},Q.epicId??"__none__"))})()}),Le>0&&t.jsxs("button",{type:"button",onClick:()=>b(j=>!j),className:"w-full text-left text-[12px] text-fg-faint hover:text-fg-dim px-[18px] py-3 border-t border-line",title:g?"Re-collapse old/cleared completed":"Show all completed (incl. cleared and >24h)",children:[g?"▾":"▸"," ",Le," more completed",t.jsx("span",{className:"ml-1.5 font-mono text-[11.5px] text-fg-faint",children:"· fresh & capped at 5 shown inline"}),f.size>0&&t.jsx("span",{className:"ml-2 underline",onClick:j=>{j.stopPropagation(),st()},children:"un-hide"})]})]}),ae&&!R&&t.jsx("div",{className:De,children:t.jsxs("div",{className:"flex gap-2.5 bg-sage/10 border border-sage/30 rounded-xl px-3.5 py-2.5 text-[13.5px] text-fg-dim leading-relaxed",children:[t.jsx("span",{"aria-hidden":"true",children:"✓"}),t.jsxs("span",{children:[t.jsx("strong",{className:"font-semibold text-fg",children:"Nothing needed from you."})," ","Close the app if you like — jobs keep running, and History shows how each one ended."]})]})})]}),t.jsx(Ln,{health:d,jobCount:M.length,lastRunAt:K,nextReset:fe,now:o,onOpenSupervisor:()=>N("supervisor")})]})}function Vn(e){const s=new Map(e.map(p=>[p.slug,p])),n=p=>(p.dependsOn??[]).filter(l=>{var i;return((i=s.get(l))==null?void 0:i.status)!=="completed"}).length,a=e.filter(p=>p.status==="running"||p.status==="pending").sort((p,l)=>n(p)-n(l)||p.slug.localeCompare(l.slug)),c=new Map;return a.forEach((p,l)=>c.set(p.slug,l)),c}function Jn(e,s,n,a){if(a)return{inline:e,collapsedCount:0};const c=e.filter(r=>r.status==="completed").sort((r,o)=>{const u=r.finishedAt?Date.parse(r.finishedAt):0;return(o.finishedAt?Date.parse(o.finishedAt):0)-u}),p=new Set;let l=0;for(const r of c){if(l>=Fn)break;s.has(r.slug)||r.finishedAt&&n-Date.parse(r.finishedAt)>qn||(p.add(r.slug),l++)}const i=[];let d=0;for(const r of e){if(r.status==="failed"&&s.has(r.slug)){d++;continue}if(r.status!=="completed"){i.push(r);continue}p.has(r.slug)?i.push(r):d++}return{inline:i,collapsedCount:d}}function Wn(e,s,n,a,c,p){const l=new Map;if(c==="paused"||c==="manual"||c==="auto-throttled"){for(const r of e)l.set(r.slug,null);return l}const i=s.find(r=>r.status==="running"&&r.startedAt),d=i!=null&&i.startedAt?p-Date.parse(i.startedAt):0;for(const r of e){if(r.status!=="pending"){l.set(r.slug,null);continue}const o=n.get(r.slug)??0;let u=o*a;o>0&&(u-=Math.min(a,d)),l.set(r.slug,u<=5e3?"~now":`~${ke(u)}`)}return l}const Yt=[{label:"All",value:"all"},{label:"Running",value:"running"},{label:"Investigating",value:"investigating"},{label:"Pending",value:"pending"},{label:"Completed",value:"completed"},{label:"Skipped",value:"skipped"},{label:"Needs review",value:"needs_review"},{label:"Failed",value:"failed"},{label:"Quarantined",value:"quarantined"}];function Yn({jobCount:e,counts:s,filter:n,onFilter:a,hiddenInGraph:c,onUnhideAll:p,hasInlineCompleted:l,onClearCompleted:i,onClearQueue:d,clearQueueDisabled:r}){const o="block w-full text-left px-2 py-1 text-[12px] hover:bg-bg-hi disabled:opacity-40 disabled:cursor-not-allowed bg-transparent border-0 cursor-pointer";return t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"font-mono text-[11.5px] text-fg-faint whitespace-nowrap","data-testid":"plan-tools-counts",children:[e," job",e!==1?"s":""," · ",s.pending,"p · ",s.running,"r · ",s.completed,"d",s.failed>0&&t.jsxs("span",{className:"text-accent",children:[" · ",s.failed,"f"]})]}),c>0&&t.jsxs("button",{type:"button",onClick:p,className:"text-[12px] text-fg-faint hover:text-fg-dim underline bg-transparent border-0 cursor-pointer whitespace-nowrap",title:"Show the completed/failed jobs hidden by Clear completed",children:[c," hidden · un-hide"]}),t.jsx("select",{"data-testid":"scheduler-status-filter","aria-label":"Filter by status",value:n.status,onChange:u=>a({...n,status:u.target.value}),className:"bg-bg-hi border border-line rounded px-1 py-0.5 text-[12px] text-fg-dim",title:"Filter the plan graph by job status",children:Yt.map(u=>t.jsx("option",{value:u.value,children:u.value==="all"?"all statuses":u.label.toLowerCase()},u.value))}),t.jsx(he,{title:"Queue actions",testId:"plan-tools-menu",popoverTestId:"plan-tools-menu-popover",alignRight:!0,glyph:"⋯",widthCls:"w-52",children:t.jsxs("div",{className:"-mx-3 -my-2",children:[l&&t.jsx("button",{type:"button",onClick:i,className:`${o} text-fg-dim`,title:"Hide completed jobs from this view (queue.json unchanged — they remain in history)",children:"Clear completed"}),t.jsx("button",{type:"button",onClick:d,disabled:r,className:`${o} text-accent`,title:"Archive every non-running PRD (moved to prds-archived/<timestamp>/) and remove them from the queue. Running jobs are kept.",children:"Archive & clear queue…"})]})})]})}function Kn({filter:e,onChange:s,showText:n}){const a=Yt;return t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[n&&t.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-[320px]",children:[t.jsx("span",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-fg-faint inline-flex","aria-hidden":"true",children:t.jsx(Ke,{name:"search",size:15})}),t.jsx("input",{type:"text",value:e.text,onChange:c=>s({...e,text:c.target.value}),placeholder:"filter jobs…",className:"w-full bg-bg-hi border border-line rounded-xl py-2 pl-9 pr-3 text-[13.5px] text-fg placeholder:text-fg-faint focus:outline-none focus:border-fg-faint","aria-label":"Filter jobs by title, slug, or project"})]}),t.jsx(Ot,{options:a,value:e.status,onChange:c=>s({...e,status:c})})]})}new Set(us.map(e=>e.tag).filter(e=>e!=="discussion"));const Qn=["title","cwd","estimateMinutes","parallelGroup","sourcePromptId","sourceTabId","tag","agentType","dependsOn","disposition"];function zn(e,s){return!Array.isArray(e)||!Array.isArray(s)?!1:e.length===s.length&&e.every((n,a)=>n===s[a])}function Xn(e){if(e==null)return"";if(typeof e=="boolean"||typeof e=="number")return String(e);const s=String(e);return s===""||/^(true|false|null|~)$/.test(s)||/^-?\d+(\.\d+)?$/.test(s)||/^\s|\s$/.test(s)||s.startsWith("'")||s.startsWith('"')||s.includes(`
|
|
8
|
-
`)?s.includes("'")?`"${s.replace(/"/g,'\\"')}"`:`'${s}'`:s}function Zn(e,s){var c;const n=[];for(const p of Qn){const l=e[p];if(l==null||l===""||Array.isArray(l)&&l.length===0)continue;const i=(c=e._raw)==null?void 0:c[p];if(i&&(Array.isArray(l)?zn(i.parsed,l):i.parsed===l)){n.push(i.line);continue}if(typeof l=="number"){n.push(`${p}: ${l}`);continue}if(Array.isArray(l)){n.push(`${p}: [${l.join(", ")}]`);continue}n.push(`${p}: ${Xn(l)}`)}if(e.extras)for(const p of Object.keys(e.extras)){const l=e.extras[p];!l||!l.lines.length||n.push(l.lines.join(`
|
|
9
|
-
`))}return`---
|
|
10
|
-
${n.join(`
|
|
11
|
-
`)}
|
|
12
|
-
---
|
|
13
|
-
${s}`}function Ge(e){return e.filter(s=>!s.archived)}function ea(e){Qe(e),window.dispatchEvent(new CustomEvent("sm:navigate",{detail:"terminal"}))}function Ue({label:e,tip:s,onClick:n,disabled:a,primary:c}){return t.jsx(fs,{content:s,align:"bottom-center",children:t.jsx("button",{title:s,onClick:n,disabled:a,className:`px-2 py-0.5 text-xs rounded border disabled:opacity-40 disabled:cursor-not-allowed ${c?"text-accent border-accent/50 hover:bg-bg-hi":"text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,children:e})})}function ta({scopeCwd:e=null}){const[s,n]=h.useState([]),[a,c]=h.useState(null),[p,l]=h.useState(null),[i,d]=h.useState(null),[r,o]=h.useState(!1),[u,f]=h.useState(!0),[m,g]=h.useState(new Set),[b,w]=h.useState(!1),[D,$]=h.useState(!1),[I,x]=h.useState(!1),[E,N]=h.useState(null);h.useEffect(()=>{let v=!0;return window.api.schedule.listPrds().then(C=>{v&&(n(Ge(C)),f(!1))}).catch(C=>{v&&(f(!1),J.error(`Scheduler: failed to load PRD list — ${C instanceof Error?C.message:"unknown error"}`))}),()=>{v=!1}},[]);const P=Ee(v=>v.snapshot),k=oe(v=>v.sessions);h.useEffect(()=>{P&&c(P)},[P]);const S=h.useMemo(()=>[...s].filter(v=>!e||v.cwd===e).sort((v,C)=>C.mtimeMs-v.mtimeMs||v.slug.localeCompare(C.slug)),[s,e]);h.useEffect(()=>{const v=hs();v&&l(v);const C=y=>l(y.detail);return window.addEventListener("sm:select-prd",C),()=>window.removeEventListener("sm:select-prd",C)},[]);const _=h.useMemo(()=>(a==null?void 0:a.jobs.find(v=>v.slug===p))??null,[a,p]),O=lt(_);function H(v){var y;const C=(y=s.find(M=>M.slug===v))==null?void 0:y.cwd;return C?`${C}/session-manager-operations/scheduler/prds/${v}.md`:null}h.useEffect(()=>{if(!p)return;const v=H(p);v&&ot.getState().openFile(v)},[p,s]);function L(v){l(v),d(null),o(!1)}function U(){l(null)}async function Y(){if(!p)return;if(!(_!=null&&_.runId)){d("no log available (job has not run yet)"),o(C=>!C);return}const v=await window.api.schedule.readLog(_.runId,p);d(v.ok?v.text??"":`error: ${v.error}`),o(C=>!C)}if(u)return t.jsx(ye,{title:"loading PRDs…"});const A=v=>{g(C=>{const y=new Set(C);return y.has(v)?y.delete(v):y.add(v),y})};!(S.length>0&&S.every(v=>m.has(v.slug)))&&S.some(v=>m.has(v.slug));const F=()=>g(new Set);async function q(){try{const v=await window.api.schedule.listPrds();n(Ge(v))}catch{}}async function W(){const v=`new-prd-${Date.now()}`,C=Zn({title:"New PRD",cwd:"",estimateMinutes:60,parallelGroup:99},`## Task
|
|
14
|
-
|
|
15
|
-
Describe the task here.
|
|
16
|
-
`);try{const y=await window.api.schedule.writePrd(v,C);if(!y.ok){J.error(`Failed to create PRD: ${y.error}`);return}const M=await window.api.schedule.listPrds();n(Ge(M)),L(v)}catch(y){J.error(`Failed to create PRD: ${y instanceof Error?y.message:String(y)}`)}}async function be(){var v;x(!0),N(null);try{const C=[...m],y=await window.api.schedule.archivePrds(C);if(!y.ok)N(y.error??"archive failed");else{const M=((v=y.results)==null?void 0:v.filter(R=>!R.ok))??[];M.length>0&&J.warn(`Archive: ${M.length} of ${y.results.length} PRD${M.length===1?"":"s"} failed to move`),F(),w(!1),await q()}}catch(C){N(C instanceof Error?C.message:String(C))}finally{x(!1)}}async function de(v,C){x(!0),N(null);try{const y=[];for(const R of m){const K={slug:R};v!==null&&(K.parallelGroup=v),C!==null&&(K.estimateMinutes=C),y.push(K)}const M=await window.api.schedule.retagPrds(y);if(!M.ok)N(M.error??"retag failed");else{F(),$(!1),await q();for(const R of M.results)if(R.newSlug&&R.newSlug!==R.slug){const K=H(R.slug),fe=H(R.newSlug);K&&fe&&ot.getState().renameOpenFile(K,fe)}p&&M.results.some(R=>R.slug===p&&R.newSlug&&R.newSlug!==R.slug)&&l(null)}}catch(y){N(y instanceof Error?y.message:String(y))}finally{x(!1)}}return t.jsxs(t.Fragment,{children:[p?t.jsxs("div",{className:"h-full flex flex-col min-h-0",children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-line flex-wrap shrink-0",children:[t.jsx("button",{type:"button",onClick:U,className:"text-[11px] text-fg-faint hover:text-fg",children:"← PRDs"}),t.jsx("span",{className:"font-mono text-xs text-fg-dim truncate",children:p}),t.jsx(dt,{status:O}),t.jsx("div",{className:"flex-1"}),t.jsx(Ue,{label:"Reset",tip:"Reset failed job to pending",onClick:()=>{window.api.schedule.resetJob(p)},disabled:O!=="failed"}),t.jsx(Ue,{label:"Run now",tip:"Run all pending jobs immediately",onClick:()=>{window.api.schedule.runNow()}}),t.jsx(Ue,{label:r?"Hide log":"Last run log",tip:"Toggle most recent run log",onClick:Y})]}),t.jsx("div",{className:"flex-1 min-h-0",children:t.jsx(ps,{})}),r&&i!==null&&t.jsxs("div",{className:"border-t border-line max-h-64 overflow-auto bg-bg-elev",children:[t.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-2 border-b border-line sticky top-0 bg-bg-elev",children:[t.jsxs("span",{className:"text-[10px] text-fg-faint font-mono",children:["run log",_!=null&&_.runId?` — ${_.runId}`:""]}),t.jsx("button",{onClick:()=>o(!1),className:"ml-auto text-[10px] text-fg-faint hover:text-fg",children:"close"})]}),t.jsx("pre",{className:"p-3 text-[11px] font-mono text-fg-dim whitespace-pre-wrap",children:i})]})]}):t.jsxs("div",{className:"px-6 py-5 overflow-auto",children:[t.jsxs("div",{className:"flex items-start justify-between mb-5 gap-4",children:[t.jsxs("p",{className:"text-[14px] text-fg-dim leading-relaxed max-w-[560px]",children:["PRDs are the source the scheduler runs from. Each one becomes a"," ",t.jsx("code",{className:"font-mono text-[13px]",children:"claude -p"})," job when you queue it. This is where you write and edit the source — to watch a run in progress, use the Queue tab."]}),t.jsx("button",{type:"button",onClick:W,className:"shrink-0 bg-accent text-white rounded-lg px-4 py-[9px] text-[13.5px] font-semibold leading-none",children:"+ New PRD"})]}),m.size>0&&t.jsxs("div",{className:"mb-4 px-4 py-2 bg-bg border border-line rounded-lg flex items-center gap-2",children:[t.jsxs("span",{className:"text-xs text-fg-dim",children:[m.size," selected"]}),t.jsx("div",{className:"flex-1"}),t.jsx("button",{type:"button",onClick:()=>w(!0),className:"text-xs px-3 py-1.5 rounded border border-line text-fg-dim hover:text-fg hover:bg-bg-hi",children:"Archive…"}),t.jsx("button",{type:"button",onClick:()=>$(!0),className:"text-xs px-3 py-1.5 rounded border border-line text-fg-dim hover:text-fg hover:bg-bg-hi",children:"Retag…"}),t.jsx("button",{type:"button",onClick:F,className:"text-xs px-3 py-1.5 rounded border border-line text-fg-dim hover:text-fg hover:bg-bg-hi",children:"Clear"})]}),S.length===0?t.jsx(ye,{title:"no PRDs found"}):t.jsx("div",{className:"grid gap-3",children:S.map(v=>{const C=a==null?void 0:a.jobs.find(fe=>fe.slug===v.slug),y=lt(C),M=Ce({epicId:v.epicId??(C==null?void 0:C.epicId)??null,sourcePromptId:v.sourcePromptId??(C==null?void 0:C.sourcePromptId)??null,sourceTabId:(C==null?void 0:C.sourceTabId)??null},k),R=(C==null?void 0:C.status)==="running",K=(C==null?void 0:C.status)==="needs_review";return t.jsxs("div",{className:"flex items-stretch bg-bg-elev border border-line rounded-2xl overflow-hidden",children:[t.jsx("label",{className:"flex items-center px-3 cursor-pointer hover:bg-bg-hi",children:t.jsx("input",{type:"checkbox",checked:m.has(v.slug),onChange:()=>A(v.slug),className:"accent-accent w-3.5 h-3.5"})}),t.jsxs("div",{className:"flex-1 min-w-0 py-4 pr-2",children:[t.jsxs("div",{className:"flex items-center gap-2.5 mb-[5px] flex-wrap",children:[te(v.slug)&&t.jsx(Ct,{n:te(v.slug)}),t.jsx("button",{type:"button",onClick:()=>L(v.slug),className:"font-serif text-[18px] font-semibold text-fg leading-tight hover:underline text-left",children:v.title||v.slug}),t.jsx(dt,{status:y}),(C==null?void 0:C.status)&&t.jsx("span",{className:"sr-only",children:C.status})]}),t.jsxs("div",{className:"flex items-center gap-4 font-mono text-xs text-fg-faint flex-wrap",children:[t.jsx(Xe,{cwd:v.cwd}),t.jsx(ze,{epicId:M.epicId,label:M.label,onOpen:ea}),v.estimateMinutes!=null&&t.jsxs("span",{children:[v.estimateMinutes,"m"]}),t.jsxs("span",{className:"opacity-60",title:"parallelGroup — a unique-per-PRD display hint, never an ordering barrier. dependsOn is the real ordering primitive.",children:["g",v.parallelGroup]}),v.dependsOn&&v.dependsOn.length>0&&t.jsxs("span",{title:`depends on: ${v.dependsOn.join(", ")}`,children:["⛓ ",v.dependsOn.length," dep",v.dependsOn.length===1?"":"s"]}),t.jsxs("span",{children:["edited ",pe(v.mtimeMs,Date.now())]})]}),t.jsx("button",{type:"button",onClick:()=>L(v.slug),className:"mt-1.5 font-mono text-[11px] text-fg-faint hover:text-fg-dim leading-none",children:v.slug}),K&&t.jsxs("div",{className:"mt-3 space-y-2",children:[(C==null?void 0:C.verifierVerdict)&&t.jsxs("div",{className:"text-xs text-fg-faint",children:["verdict: ",t.jsx("span",{className:"font-mono",children:Se(C.verifierVerdict)})]}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resetJob(v.slug),className:"text-xs px-2.5 py-1 rounded border border-line text-fg-dim hover:text-fg hover:bg-bg-hi",children:"Re-fire"})]})]}),t.jsx("div",{className:"flex flex-col gap-2 items-stretch px-[18px] py-4",children:t.jsx("button",{type:"button",onClick:()=>window.api.schedule.runNow(),disabled:R,className:"bg-fg text-bg rounded-lg px-[18px] py-2 text-[13px] font-semibold whitespace-nowrap disabled:opacity-50",children:R?"Running…":"Queue job"})})]},v.slug)})})]}),t.jsx(sa,{open:b,count:m.size,busy:I,onClose:()=>w(!1),onConfirm:be}),t.jsx(na,{open:D,count:m.size,busy:I,onClose:()=>$(!1),onConfirm:de})]})}function sa({open:e,count:s,busy:n,onClose:a,onConfirm:c}){return t.jsxs(At,{open:e,onClose:a,title:"Archive PRDs",children:[t.jsxs("p",{className:"text-xs text-fg-dim",children:["Move ",t.jsx("span",{className:"font-mono",children:s})," PRD",s===1?"":"s"," to"," ",t.jsx("span",{className:"font-mono",children:"prds-archived/<timestamp>/"}),"?"]}),t.jsx("p",{className:"text-[10px] text-fg-faint mt-2",children:"Files are renamed, never deleted. Restore manually from disk if needed."}),t.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[t.jsx("button",{type:"button",onClick:a,disabled:n,className:"px-2 py-1 text-xs border border-line rounded text-fg-dim hover:text-fg disabled:opacity-40",children:"Cancel"}),t.jsx("button",{type:"button",onClick:c,disabled:n||s===0,className:"px-2 py-1 text-xs border border-accent/60 text-accent rounded hover:bg-bg-hi disabled:opacity-40",children:n?"Archiving…":`Archive ${s}`})]})]})}function na({open:e,count:s,busy:n,onClose:a,onConfirm:c}){const[p,l]=h.useState(""),[i,d]=h.useState(""),[r,o]=h.useState(null);h.useEffect(()=>{e&&(l(""),d(""),o(null))},[e]);function u(){o(null);let f=null,m=null;if(p.trim()){const g=Number(p);if(!Number.isInteger(g)||g<0||g>999){o("parallelGroup must be 0–999");return}f=g}if(i.trim()){const g=Number(i);if(!Number.isInteger(g)||g<=0){o("estimateMinutes must be a positive integer");return}m=g}if(f===null&&m===null){o("set at least one field");return}c(f,m)}return t.jsxs(At,{open:e,onClose:a,title:"Retag PRDs",children:[t.jsxs("p",{className:"text-xs text-fg-dim",children:["Update ",t.jsx("span",{className:"font-mono",children:s})," PRD",s===1?"":"s",". Leave a field blank to keep its current value."]}),t.jsxs("p",{className:"text-[10px] text-fg-faint mt-2",children:["Changing parallelGroup on an ",t.jsx("span",{className:"font-mono",children:"NN-kebab"})," slug renames the file. Every change is logged to ",t.jsx("span",{className:"font-mono",children:"retag-log.jsonl"})," so it's reversible."]}),t.jsxs("div",{className:"mt-3 space-y-2",children:[t.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[t.jsx("span",{className:"w-32 text-fg-faint",children:"parallelGroup:"}),t.jsx("input",{type:"number",min:0,max:999,value:p,onChange:f=>l(f.target.value),placeholder:"(unchanged)",className:"flex-1 bg-bg border border-line rounded px-2 py-1 font-mono text-xs"})]}),t.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[t.jsx("span",{className:"w-32 text-fg-faint",children:"estimateMinutes:"}),t.jsx("input",{type:"number",min:1,value:i,onChange:f=>d(f.target.value),placeholder:"(unchanged)",className:"flex-1 bg-bg border border-line rounded px-2 py-1 font-mono text-xs"})]})]}),r&&t.jsx("div",{className:"mt-2 text-[10px] text-red-300",children:r}),t.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[t.jsx("button",{type:"button",onClick:a,disabled:n,className:"px-2 py-1 text-xs border border-line rounded text-fg-dim hover:text-fg disabled:opacity-40",children:"Cancel"}),t.jsx("button",{type:"button",onClick:u,disabled:n||s===0,className:"px-2 py-1 text-xs border border-accent/60 text-accent rounded hover:bg-bg-hi disabled:opacity-40",children:n?"Retagging…":`Retag ${s}`})]})]})}function aa(e){Qe(e),window.dispatchEvent(new CustomEvent("sm:navigate",{detail:"terminal"}))}function yt(e){return e?e.slice(0,10):""}const ra=[{value:"all",label:"All"},{value:"completed",label:"Completed"},{value:"skipped",label:"Skipped"},{value:"failed",label:"Failed"}];function ia({scopeCwd:e=null}){const[s,n]=h.useState(null),[a,c]=h.useState(!0),[p,l]=h.useState(""),[i,d]=h.useState(""),[r,o]=h.useState(""),[u,f]=h.useState("all");h.useEffect(()=>{c(!0),window.api.schedule.getHistory().then(w=>n(w)).catch(w=>n({ok:!1,jobs:[],error:w instanceof Error?w.message:String(w)})).finally(()=>c(!1))},[]);const m=h.useMemo(()=>{if(!(s!=null&&s.jobs))return[];const w=new Set;for(const D of s.jobs){const $=Re(D.cwd);$&&w.add($)}return[...w].sort()},[s]),g=h.useMemo(()=>s!=null&&s.jobs?s.jobs.filter(w=>!(e&&w.cwd!==e||u!=="all"&&w.status!==u||p&&Re(w.cwd)!==p||i&&yt(w.finishedAt)<i||r&&yt(w.finishedAt)>r)):[],[s,u,p,i,r,e]);if(a)return t.jsx(ye,{title:"Loading history…"});if(!(s!=null&&s.ok)||s.error)return t.jsxs("div",{className:"p-4 text-xs text-red-300",children:["Failed to load history: ",(s==null?void 0:s.error)??"unknown error"]});if(s.jobs.length===0)return t.jsx(ye,{title:"No history yet",hint:"Completed and failed jobs appear here."});const b=u!=="all"||!!p||!!i||!!r;return t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-4 py-2.5 border-b border-line flex-wrap",children:[t.jsx(Ot,{options:ra,value:u,onChange:f,pillPadding:"px-3 py-1"}),t.jsx("span",{className:"w-px h-4 bg-line mx-1","aria-hidden":"true"}),m.length>0&&t.jsxs("select",{value:p,onChange:w=>l(w.target.value),className:"bg-bg-hi border border-line rounded-lg px-2 py-1 text-[12.5px] text-fg-dim max-w-[12rem] font-medium",children:[t.jsx("option",{value:"",children:"All projects"}),m.map(w=>t.jsx("option",{value:w,children:w},w))]}),t.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] text-fg-faint",children:[t.jsx("span",{children:"from"}),t.jsx("input",{type:"date",value:i,onChange:w=>d(w.target.value),className:"bg-bg-hi border border-line rounded-lg px-2 py-1 text-fg-dim font-mono text-[12px]"})]}),t.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] text-fg-faint",children:[t.jsx("span",{children:"to"}),t.jsx("input",{type:"date",value:r,onChange:w=>o(w.target.value),className:"bg-bg-hi border border-line rounded-lg px-2 py-1 text-fg-dim font-mono text-[12px]"})]}),t.jsxs("span",{className:"text-[12px] text-fg-faint ml-auto font-mono",children:[g.length," / ",s.jobs.length]}),b&&t.jsx("button",{type:"button",onClick:()=>{f("all"),l(""),d(""),o("")},className:"text-[12px] text-fg-faint hover:text-fg-dim underline",children:"clear"})]}),t.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:g.length===0?t.jsx(ye,{title:"No matches",hint:"Try adjusting the filters."}):t.jsxs("div",{className:"mx-4 my-3 bg-bg-hi border border-line rounded-2xl overflow-hidden",children:[t.jsx("div",{className:"flex items-center px-[18px] py-3 bg-bg-elev",children:t.jsxs("span",{className:"font-serif text-base font-semibold text-fg",children:[g.length," job",g.length!==1?"s":""]})}),g.map(w=>t.jsx(la,{job:w},`${w.slug}-${w.finishedAt??""}`))]})})]})}function la({job:e}){const[s,n]=h.useState(!1),[a,c]=h.useState(!1),p=oe(f=>f.sessions),l=h.useMemo(()=>Ce(e,p),[e,p]),i=e.startedAt&&e.finishedAt?Date.parse(e.finishedAt)-Date.parse(e.startedAt):null,d=e.startedAt?new Date(e.startedAt).toLocaleString():"—",r=e.finishedAt?new Date(e.finishedAt).toLocaleString():"—",o=i!==null?ke(i):"—",u=e.exitCode!==null?String(e.exitCode):"—";return t.jsxs("div",{className:"border-t border-line/60",children:[t.jsxs("button",{type:"button",className:`w-full text-left grid items-center gap-4 px-[18px] py-3.5 cursor-pointer transition-colors hover:bg-bg-elev ${s?"bg-bg-elev":"bg-transparent"}`,style:{gridTemplateColumns:"116px 1fr auto auto"},onClick:()=>n(f=>!f),"aria-expanded":s,children:[t.jsx(St,{status:e.status}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-baseline gap-2 text-[14.5px] font-medium text-fg leading-snug text-pretty",children:[e.title,t.jsx($t,{leaked:e.leakedDescendants})]}),e.error&&!s&&(e.status==="failed"||e.status==="needs_review")&&t.jsx("div",{className:"text-[12.5px] mt-0.5 text-accent/80 truncate",children:e.error}),l.epicId&&t.jsx("span",{className:"flex mt-0.5",children:t.jsx(ze,{epicId:l.epicId,label:l.label,onOpen:aa})})]}),t.jsx(Xe,{cwd:e.cwd}),t.jsxs("span",{className:"inline-flex items-center gap-2.5 font-mono text-xs text-fg-faint whitespace-nowrap",children:[o,t.jsx("span",{className:"inline-flex transition-transform duration-150",style:{transform:s?"rotate(90deg)":"none"},"aria-hidden":"true",children:"›"})]})]}),s&&t.jsxs("div",{className:"grid gap-5 px-[18px] pt-1 pb-5 bg-bg-elev",style:{gridTemplateColumns:"repeat(auto-fit, minmax(160px, 1fr))"},children:[t.jsxs(ee,{label:"Status",children:[t.jsx(B,{k:"result",v:u}),t.jsx(B,{k:"state",v:e.status.replace("_"," ")}),e.verifierVerdict&&t.jsx(B,{k:"verifier",v:Se(e.verifierVerdict)}),e.leakedDescendants&&e.leakedDescendants.length>0&&t.jsx(B,{k:"leaked",v:Dt(e.leakedDescendants),wrap:!0})]}),t.jsxs(ee,{label:"Timing",children:[t.jsx(B,{k:"started",v:d}),t.jsx(B,{k:"finished",v:r}),t.jsx(B,{k:"duration",v:o})]}),t.jsxs(ee,{label:"Location",children:[t.jsx(B,{k:"group",v:e.parallelGroup!=null?String(e.parallelGroup):"—"}),t.jsx(B,{k:"slug",v:e.slug}),t.jsx(B,{k:"epic",v:l.label??l.epicId??"—",wrap:!0}),e.cwd&&t.jsx(B,{k:"cwd",v:e.cwd,wrap:!0})]}),t.jsx(ee,{label:"Actions",children:t.jsxs("div",{className:"flex flex-col gap-2 items-start",children:[e.runId&&t.jsx("button",{type:"button",onClick:f=>{f.stopPropagation(),c(!0)},className:"text-[13px] font-semibold text-fg-dim hover:text-fg bg-transparent border-0 p-0 cursor-pointer",children:"view log →"}),e.status!=="pending"&&t.jsx("button",{type:"button",onClick:f=>{f.stopPropagation(),window.api.schedule.resetJob(e.slug)},className:"text-[13px] font-semibold text-fg-dim hover:text-fg bg-transparent border-0 p-0 cursor-pointer",children:"reset to pending →"}),e.error&&t.jsx("p",{className:"text-[12px] text-accent/90 mt-1 break-words whitespace-pre-wrap max-w-sm m-0",children:e.error})]})})]}),a&&e.runId&&t.jsx(Ie,{runId:e.runId,slug:e.slug,title:e.title||e.slug,onClose:()=>c(!1)})]})}function oa(e){return e?Object.values(e).reduce((s,n)=>s+(n??[]).reduce((a,c)=>{var p;return a+(((p=c.hooks)==null?void 0:p.length)??0)},0),0):0}function da(e){var s,n,a;return e?(((s=e.allow)==null?void 0:s.length)??0)+(((n=e.deny)==null?void 0:n.length)??0)+(((a=e.ask)==null?void 0:a.length)??0):0}function ca({navigate:e}){const s=xs(),n=ve(x=>x.files),a=ve(x=>x.loadJson),c=ve(x=>x.loadText),p=ve(x=>x.watchFile),l=ve(x=>x.unwatchFile),i=s?gs.resolve("user",s,null):null,d=s?ms.resolve("user",s,null):null,r=s?`${s}/.claude.json`:null;h.useEffect(()=>{const x=[i,r].filter(Boolean);x.forEach(N=>{n[N]||a(N),p(N)});const E=[d].filter(Boolean);return E.forEach(N=>{n[N]||c(N),p(N)}),()=>{[...x,...E].forEach(N=>l(N))}},[i,d,r]);const[o,u]=h.useState(null);h.useEffect(()=>{if(!s)return;let x=!1;return(async()=>{const E=await Ns(`${s}/.claude/skills`);x||u(E.length)})(),()=>{x=!0}},[s]);const f=i?n[i]:null,m=r?n[r]:null,g=d?n[d]:null,b=h.useMemo(()=>{if(!(f!=null&&f.exists)||f.parseError)return null;const x=f.diskData;return x===null||typeof x!="object"||Array.isArray(x)?{}:x},[f]),w=h.useMemo(()=>{if(!(m!=null&&m.exists)||m.parseError)return null;const x=m.diskData;return x===null||typeof x!="object"||Array.isArray(x)?{}:x},[m]),D=f?f.parseError?"invalid JSON":null:"loading…",$=m?m.parseError?"invalid JSON":null:"loading…",I=[{key:"settings",title:"Settings",summary:D??(b?`${Object.keys(b).length} top-level key${Object.keys(b).length===1?"":"s"} configured`:"not configured")},{key:"permissions",title:"Permissions",summary:D??(b?`${da(b.permissions)} rule(s) configured`:"not configured")},{key:"hooks",title:"Hooks",summary:D??(b?`${oa(b.hooks)} hook(s) configured`:"not configured")},{key:"mcp",title:"MCP Servers",summary:$??(w?`${Object.keys(w.mcpServers??{}).length} MCP server(s)`:"not configured")},{key:"system-prompt",title:"System Prompt",summary:g!=null&&g.exists&&g.diskRaw.trim().length>0?`configured (${g.diskRaw.length.toLocaleString()} chars)`:"not set"},{key:"skills",title:"Skills",summary:o===null?"loading…":`${o} skill(s) installed`}];return t.jsxs("section",{className:"border border-line rounded-xl bg-bg-hi px-5 py-4",children:[t.jsx("h2",{className:"m-0 mb-1 font-serif text-[18px] font-semibold text-fg",children:"Global Controls"}),t.jsx("p",{className:"mt-0 mb-3 text-[13px] text-fg-dim leading-relaxed",children:"Machine-wide (user-scope) config state for the tabs that default to global here on Home. Read-only summary — open a card to edit."}),t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:I.map(x=>t.jsxs("button",{type:"button",onClick:()=>e==null?void 0:e(x.key),className:"text-left border border-line rounded-lg bg-bg px-3 py-2.5 hover:border-accent transition-colors",children:[t.jsx("div",{className:"text-[13px] font-medium text-fg",children:x.title}),t.jsx("div",{className:"mt-0.5 text-[12px] text-fg-dim",children:x.summary})]},x.key))})]})}function ua({navigate:e}){const s=bs(),[n,a]=h.useState(!1),[c,p]=h.useState(!1),[l,i]=h.useState(null);h.useEffect(()=>{let r=!0;return ws().then(o=>{r&&a(o.openToHomeOnLaunch===!0)}),()=>{r=!1}},[]),h.useEffect(()=>{var o,u;let r=!0;return(u=(o=window.api.schedule).worktreeBase)==null||u.call(o).then(f=>{r&&i(f)}).catch(()=>{}),()=>{r=!1}},[]);const d=async r=>{a(r),p(!0);try{await js({openToHomeOnLaunch:r})}catch{a(!r),J.error('Failed to save "Open to Home on launch" — try again.')}finally{p(!1)}};return t.jsxs("div",{className:"max-w-[760px] space-y-6",children:[t.jsx(ca,{navigate:e}),t.jsxs("section",{className:"border border-line rounded-xl bg-bg-hi px-5 py-4",children:[t.jsx("h2",{className:"m-0 mb-1 font-serif text-[18px] font-semibold text-fg",children:"Session pool"}),t.jsxs("p",{className:"mt-0 mb-3 text-[13px] text-fg-dim leading-relaxed",children:["One machine-wide pool of concurrent Claude sessions. Scheduler jobs and Epic chat runs each request a slot before launching; work waits when the pool is full. Adjustable from 0 (pauses new launches) to 10 on the Home tab, default 5 — or pin it with"," ",t.jsx("code",{className:"font-mono text-[12px]",children:"SM_SESSION_SLOTS"})," (clamped 0–10)."]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(vs,{total:(s==null?void 0:s.total)??5,inUse:(s==null?void 0:s.inUse)??0,size:"md"}),t.jsx("span",{className:"ml-2 font-mono text-[12.5px] text-fg-faint",children:s?`${s.inUse} / ${s.total} in use`:"loading…"})]}),s&&s.holders.length>0&&t.jsx("ul",{className:"mt-2 mb-0 pl-0 list-none space-y-0.5",children:s.holders.map((r,o)=>t.jsxs("li",{className:"font-mono text-[12px] text-fg-dim",children:[r.owner," ",t.jsxs("span",{className:"text-fg-faint",children:["since ",new Date(r.at).toLocaleTimeString()]})]},o))})]}),t.jsxs("section",{className:"border border-line rounded-xl bg-bg-hi px-5 py-4",children:[t.jsx("h2",{className:"m-0 mb-1 font-serif text-[18px] font-semibold text-fg",children:"Behavior"}),t.jsx("p",{className:"mt-0 mb-3 text-[13px] text-fg-dim leading-relaxed",children:"Cross-project app behavior, independent of any single project's config."}),t.jsx(ks,{checked:n,onChange:d,disabled:c,label:"Open to Home on launch"})]}),t.jsxs("section",{className:"border border-line rounded-xl bg-bg-hi px-5 py-4",children:[t.jsx("h2",{className:"m-0 mb-1 font-serif text-[18px] font-semibold text-fg",children:"On disk"}),t.jsxs("p",{className:"mt-0 mb-2 text-[13px] text-fg-dim leading-relaxed",children:["Global runtime state is deliberately small — everything project-scoped lives inside that project's ",t.jsx("code",{className:"font-mono text-[12px]",children:"session-manager-operations/"})," folder."]}),t.jsxs("ul",{className:"m-0 pl-0 list-none space-y-1 font-mono text-[12px] text-fg-dim",children:[t.jsxs("li",{children:["~/.claude/session-manager/scheduler-machine.json ",t.jsx("span",{className:"text-fg-faint",children:"— policy + pause state"})]}),t.jsxs("li",{"data-testid":"worktree-base-path",children:[l??"…","/session-manager-epic-worktrees/ ",t.jsx("span",{className:"text-fg-faint",children:"— Epic git worktrees (SM_WORKTREE_ROOT overrides)"})]}),t.jsxs("li",{children:["<project>/session-manager-operations/scheduler/state/ ",t.jsx("span",{className:"text-fg-faint",children:"— per-project queue + history"})]}),t.jsxs("li",{children:["<project>/session-manager-operations/scheduler/epics/<epic>/prds/ ",t.jsx("span",{className:"text-fg-faint",children:"— PRD sources, per session"})]})]})]})]})}const Nt="sm.schedulerTab.subView";function pa({navigate:e}={}){var g;const[s,n]=h.useState("graph"),[a,c]=h.useState(""),[p,l]=h.useState(null),[i,d]=h.useState(()=>{const b=localStorage.getItem(Nt);return b==="prds"||b==="history"||b==="machine"?b:"queue"}),r=ct(b=>b.tabs),o=ct(b=>b.activeTabId),u=((g=r.find(b=>b.id===o))==null?void 0:g.cwd)??null,f=u;h.useEffect(()=>{u&&(oe.getState().hydrate(u),oe.getState().hydrateArchived(u))},[u]);const m=h.useCallback(b=>{b&&ys(b),d("prds")},[]);return h.useEffect(()=>{localStorage.setItem(Nt,i)},[i]),t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(Vs,{scopeCwd:f,subView:i,onSubView:d,filterText:a,onFilterText:c,planMode:s,onPlanMode:n,planToolsRef:l}),t.jsxs("div",{className:"flex-1 min-h-0",children:[i==="queue"&&t.jsx(Un,{scopeCwd:f,navigate:e,filterText:a,planMode:s,onOpenPrds:m,planToolsEl:p}),i==="prds"&&t.jsx(ta,{scopeCwd:f}),i==="history"&&t.jsx(ia,{scopeCwd:f}),i==="machine"&&t.jsx("div",{className:"h-full overflow-y-auto px-9 py-6",children:t.jsx(ua,{navigate:e})})]})]})}const ma=h.memo(pa);export{ma as Scheduler};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{au as d,ah as e,S as O,a as Q,l as R,aS as X,R as ee,aH as te,aN as se,aV as $,aP as ne,aK as M,aj as ae,an as re,J as le,V as ie,z as H,az as oe}from"./index-D5H_H5wC.js";import{P as ce}from"./Panel-C2YTW-qP.js";import{S as de}from"./ScopeSwitcher-CKzpqjJ_.js";import{S as K}from"./SaveBar-87ZJfscX.js";import{u as ue,s as G,E as xe}from"./settingsSchema-JRDfjgHb.js";import{T as L}from"./Toggle-CDXR5l3m.js";import"./monaco-editor-BW5C4Iv1.js";const pe=[{id:"essentials",title:"Essentials",summary:"The knobs you reach for first.",keys:["model","language","outputStyle","permissions"]},{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"]}],me={mcp:"MCP",url:"URL",urls:"URLs",http:"HTTP",ui:"UI",id:"ID",uuid:"UUID",api:"API",aws:"AWS",otel:"OTel",json:"JSON"};function V(s){return s.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((l,a)=>{const r=me[l];return r||(a===0?l.charAt(0).toUpperCase()+l.slice(1):l)}).join(" ")}function W(s){const n=new Set,t=[];for(const a of pe){const r=a.keys.filter(i=>s.has(i));r.forEach(i=>n.add(i)),r.length!==0&&t.push({id:a.id,title:a.title,summary:a.summary,advanced:!!a.advanced,keys:r})}const l=Array.from(s).filter(a=>!n.has(a)&&a!=="$schema").sort();return l.length>0&&t.push({id:"other",title:"Other",summary:"Keys not yet grouped.",advanced:!1,keys:l}),t}function fe(s,n){return W(s).map(t=>({id:t.id,title:t.title,advanced:t.advanced,total:t.keys.length,setCount:t.keys.filter(l=>n.has(l)).length}))}const he={};function z(s,n){if(n)return{text:n,authored:!1};const t=he[s];return t?{text:t,authored:!0}:null}const ge={essentials:"star",git:"link",memory:"memory",model:"sparkle",interface:"eye",updates:"reload",env:"keys",hooks:"hooks",mcp:"mcp",plugins:"plugins",filesystem:"folder",login:"lock",feedback:"send",advanced:"shield",other:"dot"},be=["user","project","local","default"],ye={user:"user",project:"project",local:"local",default:"default"};function je({node:s,targetScope:n,onOverride:t,schema:l}){const[a,r]=d.useState(""),[i,p]=d.useState(!1),[m,v]=d.useState(!0),x=s.kind==="object"?s:null,w=x?Object.keys(x.children):[],g=l.rootKeys(),y=new Set([...w,...g]),u=d.useMemo(()=>W(y),[Array.from(y).sort().join(",")]),b=d.useMemo(()=>fe(y,new Set(w)),[Array.from(y).sort().join(","),w.join(",")]),[C,E]=d.useState(null),f=d.useRef(null),S=o=>{const j=u.find(N=>N.id===o);j!=null&&j.advanced&&!i&&p(!0),E(o)};d.useEffect(()=>{if(!C)return;E(null);const o=f.current,j=document.getElementById(`settings-group-${C}`);if(!o||!j)return;const N=j.getBoundingClientRect().top-o.getBoundingClientRect().top;o.scrollBy({top:N,behavior:"smooth"})},[C]);const k=d.useMemo(()=>u.filter(o=>i||!o.advanced).map(o=>({...o,keys:o.keys.filter(j=>{const N=(x==null?void 0:x.children[j])!==void 0;if(!m&&!N)return!1;if(!a.trim())return!0;const h=l.at([j]);return[j,V(j),(h==null?void 0:h.description)??""].join(" ").toLowerCase().includes(a.toLowerCase())})})).filter(o=>o.keys.length>0),[u,a,i,m,x,l]);return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 flex items-center gap-3 text-xs",children:[e.jsxs("span",{className:"text-fg-faint",children:["writing overrides to"," ",e.jsx("span",{className:"text-fg-dim font-medium",children:O[n].label})]}),e.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:m,onChange:o=>v(o.target.checked),className:"accent-accent"}),"show not-yet-configured"]}),e.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:o=>p(o.target.checked),className:"accent-accent"}),"show advanced"]}),e.jsx("div",{className:"flex-1"}),e.jsx("input",{value:a,onChange:o=>r(o.target.value),placeholder:"search settings…",className:"bg-bg border border-line rounded px-2 py-1 text-xs text-fg w-64"})]}),e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsx(ve,{groups:b,onJump:S}),e.jsxs("div",{ref:f,className:"flex-1 overflow-auto py-3",children:[k.map(o=>e.jsx(Ne,{id:o.id,title:o.title,summary:o.summary,advanced:o.advanced,children:o.keys.map(j=>{const N=x==null?void 0:x.children[j],h=l.at([j]);return e.jsx(we,{keyName:j,node:N,info:h,targetScope:n,onOverride:(c,T)=>t([j],c,T)},j)})},o.id)),k.length===0&&e.jsxs("div",{className:"px-6 py-12 text-center text-fg-faint text-sm",children:['no settings match "',a,'"']})]})]})]})}function ve({groups:s,onJump:n}){return e.jsx("nav",{className:"shrink-0 w-48 border-r border-line bg-bg-elev/30 overflow-y-auto py-3",children:s.map(t=>e.jsxs("button",{onClick:()=>n(t.id),className:"w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-bg-hi transition-colors",title:`jump to ${t.title}`,children:[e.jsx(Q,{name:ge[t.id]??"dot",size:15,className:"text-fg-faint shrink-0"}),e.jsx("span",{className:"flex-1 min-w-0 truncate text-xs text-fg-dim",children:t.title}),e.jsxs("span",{className:"text-[10px] text-fg-faint font-mono shrink-0",children:[t.setCount,"/",t.total]})]},t.id))})}function Ne({id:s,title:n,summary:t,advanced:l,children:a}){const[r,i]=d.useState(!0);return e.jsxs("section",{id:`settings-group-${s}`,className:"mx-4 mb-4 rounded-lg border border-line shadow-sm bg-bg-elev/50 overflow-hidden",children:[e.jsxs("header",{className:"px-4 py-3 bg-bg-elev cursor-pointer hover:bg-bg-hi flex items-center gap-3 border-b border-line",onClick:()=>i(!r),children:[e.jsx("span",{className:"text-fg-faint w-3",children:r?"▾":"▸"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-fg text-base font-semibold",children:n}),l&&e.jsx("span",{className:"text-[9px] px-1.5 py-0 rounded border border-yellow-900/40 bg-yellow-950/30 text-yellow-500/80 uppercase tracking-wide",children:"advanced"})]}),e.jsx("p",{className:"text-fg-dim text-sm mt-0.5",children:t})]})]}),r&&e.jsx("div",{className:"divide-y divide-line/60",children:a})]})}function we({keyName:s,node:n,info:t,targetScope:l,onOverride:a}){const[r,i]=d.useState(!1),[p,m]=d.useState(!1),v=V(s),x=n!==void 0,g=(n==null?void 0:n.kind)==="leaf"?n:null,y=(n==null?void 0:n.kind)==="object"||(n==null?void 0:n.kind)==="array",u=t==null?void 0:t.default,b=g&&u!==void 0&&Y(g.value,u),C=Pe({isSet:x,leafNode:g,defaultVal:u,isDefault:!!b,node:n}),E=Se(g,u),f=E.length>=2,S=!!g&&!b,k=z(s,t==null?void 0:t.description);return e.jsx("div",{className:"px-4 py-3 hover:bg-bg-elev/20",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("button",{onClick:()=>i(!r),className:"text-fg-faint hover:text-fg w-3 mt-0.5",title:r?"collapse":"expand",children:r?"▾":"▸"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-2 flex-wrap",children:[e.jsx("h3",{className:"text-fg text-sm",children:v}),e.jsx(Re,{kind:C.kind,label:C.label}),f&&e.jsxs("button",{onClick:o=>{o.stopPropagation(),r||i(!0),m(j=>!j)},className:"text-[9px] px-1.5 py-0 rounded border border-blue-900/40 bg-blue-950/30 text-blue-300/90 uppercase tracking-wide hover:bg-blue-900/40",title:"this key is defined in multiple scopes — click to expand",children:["drift · ",E.map(o=>ye[o]).join(" · ")]}),S&&g&&e.jsx("button",{onClick:o=>{o.stopPropagation(),a(void 0,g.winner)},className:"text-[9px] px-1.5 py-0 rounded border border-line bg-bg-elev text-fg-faint uppercase tracking-wide hover:text-fg hover:bg-bg-hi",title:`reset · delete from ${O[g.winner].label}`,children:"↺ reset"}),(t==null?void 0:t.deprecated)&&e.jsx("span",{className:"text-[9px] px-1 py-0 rounded border border-yellow-900/40 bg-yellow-950/30 text-yellow-500/80 uppercase tracking-wide",children:"deprecated"}),(t==null?void 0:t.required)&&!x&&e.jsx("span",{className:"text-[9px] px-1 py-0 rounded border border-red-900/40 bg-red-950/30 text-red-400/80 uppercase tracking-wide",children:"required"})]}),k&&e.jsx("p",{className:`text-fg-dim text-xs mt-0.5 leading-relaxed ${k.authored?"inline-block border-b border-dotted border-fg-faint/70 cursor-help":""}`,title:k.authored?"In-app-authored description — not from the official Claude Code schema":void 0,children:Me(k.text)}),r&&p&&g&&e.jsx(ke,{leaf:g,defaultVal:u,onReset:o=>a(void 0,o)}),r&&e.jsx(Ce,{keyName:s,node:n,info:t,targetScope:l,onOverride:o=>a(o)})]}),e.jsx("div",{className:"shrink-0",children:!r&&e.jsx(Ae,{node:n,info:t,onSet:o=>{a(o)},disabled:y&&x})})]})})}function Se(s,n){if(!s)return[];const t=new Set;t.add(s.winner);for(const l of s.shadowed)t.add(l.scope);return n!==void 0&&t.add("default"),be.filter(l=>t.has(l))}function ke({leaf:s,defaultVal:n,onReset:t}){const l={};l[s.winner]={value:s.value,winner:!0};for(const a of s.shadowed)l[a.scope]={value:a.value,winner:!1};return e.jsxs("div",{className:"mt-2 border border-line rounded bg-bg-elev/40 text-xs",children:[e.jsx("div",{className:"px-2 py-1 text-fg-faint border-b border-line/60",children:"Values across all scopes (winner highlighted · reset removes that scope's value):"}),e.jsxs("div",{className:"divide-y divide-line/60",children:[["user","project","local"].map(a=>{const r=l[a],i=r!==void 0;return e.jsxs("div",{className:"grid grid-cols-[5rem_1fr_auto] gap-2 px-2 py-1 items-center",children:[e.jsx("span",{className:"text-fg-faint",children:O[a].label}),e.jsx("span",{className:`font-mono truncate ${r!=null&&r.winner?"text-accent":"text-fg-dim"}`,children:i?P(r.value):e.jsx("span",{className:"text-fg-faint",children:"—"})}),i?e.jsx("button",{onClick:()=>t(a),className:"text-[9px] px-1.5 py-0 rounded border border-line text-fg-faint uppercase tracking-wide hover:text-fg hover:bg-bg-hi",title:`delete this key from ${O[a].label}`,children:"↺"}):e.jsx("span",{})]},a)}),e.jsxs("div",{className:"grid grid-cols-[5rem_1fr_auto] gap-2 px-2 py-1 items-center",children:[e.jsx("span",{className:"text-fg-faint",children:"Default"}),e.jsx("span",{className:"font-mono text-fg-dim truncate",children:n!==void 0?P(n):e.jsx("span",{className:"text-fg-faint",children:"—"})}),e.jsx("span",{})]})]})]})}function Ce({keyName:s,node:n,info:t,targetScope:l,onOverride:a}){const i=(n==null?void 0:n.kind)==="leaf"?n:null,p=z(s,t==null?void 0:t.description);return e.jsxs("div",{className:"mt-3 space-y-2 text-xs",children:[p&&e.jsx("p",{className:`text-fg-dim leading-relaxed whitespace-pre-wrap ${p.authored?"inline-block border-b border-dotted border-fg-faint/70 cursor-help":""}`,title:p.authored?"In-app-authored description — not from the official Claude Code schema":void 0,children:p.text}),e.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-fg-faint",children:[(t==null?void 0:t.type)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Type"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:Array.isArray(t.type)?t.type.join(" | "):t.type})]}),(t==null?void 0:t.default)!==void 0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Default"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:P(t.default)})]}),(t==null?void 0:t.enum)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Options"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:t.enum.map(m=>String(m)).join(" | ")})]}),i&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Current"}),e.jsxs("dd",{className:"font-mono",children:[e.jsx("span",{className:"text-fg-dim",children:P(i.value)}),e.jsxs("span",{className:"ml-2 text-fg-faint",children:["from ",O[i.winner].label]})]})]}),i&&i.shadowed.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Shadowed"}),e.jsx("dd",{className:"space-y-0.5",children:i.shadowed.map((m,v)=>e.jsxs("div",{className:"font-mono text-fg-faint line-through",children:[P(m.value)," —"," ",e.jsx("span",{className:"no-underline",children:O[m.scope].label})]},v))})]}),(n==null?void 0:n.kind)==="array"&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Accumulated"}),e.jsxs("dd",{className:"text-fg-dim",children:[n.items.length," items across all scopes"]})]})]}),e.jsx("div",{className:"pt-2 flex items-center gap-2 flex-wrap border-t border-line/60",children:e.jsx(Ee,{keyName:s,node:n,info:t,onChange:a,targetScope:l})})]})}function Ee({node:s,info:n,onChange:t,targetScope:l}){const r=(s==null?void 0:s.kind)==="leaf"?s.value:n==null?void 0:n.default,i=q(n==null?void 0:n.type);if(i==="boolean"){const p=r===!0;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-fg-faint",children:"Set to:"}),e.jsx("div",{className:"inline-flex rounded border border-line overflow-hidden",children:[{v:!0,label:"on"},{v:!1,label:"off"}].map(({v:m,label:v})=>e.jsx("button",{onClick:()=>t(m),className:`px-3 py-0.5 text-xs transition-colors ${p===m?"bg-accent text-bg":"bg-bg-elev text-fg-dim hover:bg-bg-hi hover:text-fg"}`,children:v},v))}),e.jsxs("span",{className:"text-fg-faint",children:["→ ",O[l].label]})]})}return n!=null&&n.enum?e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-fg-faint",children:"Choose:"}),n.enum.map(p=>{const m=Y(r,p);return e.jsx("button",{onClick:()=>t(p),className:`px-2 py-0.5 text-xs rounded border ${m?"bg-accent text-bg border-accent":"bg-bg-elev text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,children:String(p)},String(p))}),e.jsxs("span",{className:"text-fg-faint",children:["→ ",O[l].label]})]}):i==="integer"||i==="number"?e.jsx(Oe,{value:typeof r=="number"?r:void 0,integer:i==="integer",onCommit:t,target:O[l].label}):i==="string"?e.jsx(Te,{value:typeof r=="string"?r:"",onCommit:t,target:O[l].label}):e.jsxs("div",{className:"text-fg-faint",children:["Complex value (",i??"object/array",") — use the"," ",e.jsx("span",{className:"text-fg-dim",children:"Raw"})," tab to edit."]})}function Oe({value:s,integer:n,onCommit:t,target:l}){const[a,r]=d.useState(s!==void 0?String(s):""),i=()=>{const p=n?parseInt(a,10):parseFloat(a);Number.isNaN(p)||t(p)};return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-fg-faint",children:"Set to:"}),e.jsx("input",{type:"number",value:a,onChange:p=>r(p.target.value),onBlur:i,onKeyDown:p=>{p.key==="Enter"&&p.target.blur()},className:"w-24 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),e.jsxs("button",{onClick:i,className:"px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",l]})]})}function Te({value:s,onCommit:n,target:t}){const[l,a]=d.useState(s);return e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx("span",{className:"text-fg-faint shrink-0",children:"Set to:"}),e.jsx("input",{type:"text",value:l,onChange:r=>a(r.target.value),onKeyDown:r=>{r.key==="Enter"&&n(l)},className:"flex-1 min-w-0 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),e.jsxs("button",{onClick:()=>n(l),className:"shrink-0 px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",t]})]})}function Ae({node:s,info:n,onSet:t,disabled:l}){const a=(s==null?void 0:s.kind)==="leaf",r=q(n==null?void 0:n.type);if(l)return null;if(r==="boolean"){const i=a&&s.value===!0;return e.jsx("button",{onClick:()=>t(!i),className:`px-2.5 py-0.5 text-xs rounded border transition-colors ${i?"bg-accent/15 text-accent border-accent/40 hover:bg-accent hover:text-bg":"bg-bg-elev text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,title:"toggle",children:i?"on":"off"})}return null}function Pe({isSet:s,leafNode:n,defaultVal:t,isDefault:l,node:a}){return s?(a==null?void 0:a.kind)==="array"?{kind:"accumulated",label:`${a.items.length} items`}:(a==null?void 0:a.kind)==="object"?{kind:"set",label:"configured"}:n?l?{kind:"default",label:`= default · ${O[n.winner].label}`}:n.shadowed.length>0?{kind:"override",label:`overriding ${n.shadowed.length} scope(s)`}:{kind:"set",label:`set in ${O[n.winner].label}`}:{kind:"set",label:"configured"}:t!==void 0?{kind:"default",label:`using default: ${P(t)}`}:{kind:"unset",label:"not configured"}}function Re({kind:s,label:n}){const t={set:"bg-accent/15 text-accent border-accent/30",default:"bg-bg-hi text-fg-dim border-line",unset:"bg-bg-elev text-fg-faint border-line",override:"bg-purple-950/30 text-purple-400/80 border-purple-900/40",accumulated:"bg-blue-950/30 text-blue-400/80 border-blue-900/40"}[s];return e.jsx("span",{className:`text-[9px] px-1.5 py-0 rounded border uppercase tracking-wide ${t}`,children:n})}function q(s){if(s)return Array.isArray(s)?s.find(t=>t!=="null")??s[0]:s}function Y(s,n){return s===n?!0:typeof s!=typeof n?!1:s&&n&&typeof s=="object"?JSON.stringify(s)===JSON.stringify(n):!1}function Me(s){const n=s.trim().split(`
|
|
2
|
-
`)[0],t=n.match(/^([^.!?]+[.!?])/);return t?t[1]:n.length>120?n.slice(0,120)+"…":n}function P(s){if(typeof s=="string")return s===""?'""':JSON.stringify(s);if(s===null)return"null";if(s===void 0)return"—";if(typeof s=="object"){const n=JSON.stringify(s);return n.length>60?n.slice(0,60)+"…":n}return String(s)}const Ie=1440*60*1e3;function U(s){if(!s)return"never";const n=new Date(s).getTime();return Number.isNaN(n)?"never":new Date(n).toLocaleString()}function J(s){return s?new Date(s).toLocaleString():"never"}function De(){return e.jsxs("div",{className:"p-4 max-w-3xl space-y-8 text-sm",children:[e.jsx(Le,{}),e.jsx("hr",{className:"border-line"}),e.jsx(_e,{})]})}function Le(){const[s,n]=d.useState(null),[t,l]=d.useState(null),[a,r]=d.useState(null),[i,p]=d.useState(null),[m,v]=d.useState(!1),[x,w]=d.useState(null),[g,y]=d.useState(null);if(d.useEffect(()=>{let f=!1;return Promise.all([window.api.otel.getConfig(),window.api.otel.status(),window.api.otel.configPath()]).then(([S,k,o])=>{f||(n(S),r(S),l(k),p(o))}).catch(S=>{console.warn("[telemetry] load failed:",S==null?void 0:S.message)}),()=>{f=!0}},[]),!a||!s)return e.jsx(R,{title:"loading…"});const u=JSON.stringify(a)!==JSON.stringify(s),b=(f,S)=>{w(null),r({...a,[f]:S})},C=async()=>{v(!0),w(null);try{const f=await window.api.otel.setConfig(a);!f.ok&&f.error&&w(f.error),n(f.config),r(f.config),l(f.status),y(Date.now())}catch(f){w(f instanceof Error?f.message:String(f))}finally{v(!1)}},E=()=>{w(null),r(s)};return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-fg text-base font-medium",children:"OpenTelemetry export"}),e.jsx("p",{className:"text-fg-dim text-xs leading-relaxed",children:"When enabled, every classified transcript event (tool_use, todo_write, plan, usage, agent_spawn) is mirrored as a 0-duration OTLP/HTTP span. Point this at a local collector (Jaeger, Grafana Tempo, SigNoz, Honeycomb) for cross-session analysis."}),i&&e.jsxs("p",{className:"text-fg-faint text-[11px]",children:["stored at ",e.jsx("span",{className:"font-mono",children:i})]})]}),e.jsxs("section",{className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg",children:"Export transcripts to OTEL"}),e.jsx("div",{className:"text-fg-faint text-xs",children:"Toggle off to disable all span emission immediately."})]}),e.jsx(L,{checked:a.enabled,onChange:f=>b("enabled",f),label:a.enabled?"on":"off"})]}),e.jsxs("label",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"OTLP/HTTP traces endpoint"}),e.jsx("input",{type:"text",value:a.endpoint,onChange:f=>b("endpoint",f.target.value),placeholder:"http://localhost:4318/v1/traces",className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),e.jsxs("label",{className:"block space-y-1",children:[e.jsxs("span",{className:"text-fg-dim text-xs",children:["Headers (newline-separated ",e.jsx("span",{className:"font-mono",children:"Key: Value"}),")"]}),e.jsx("textarea",{value:a.headers,onChange:f=>b("headers",f.target.value),placeholder:"x-honeycomb-team: YOUR_API_KEY",rows:3,className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),e.jsxs("label",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"Service name"}),e.jsx("input",{type:"text",value:a.serviceName,onChange:f=>b("serviceName",f.target.value),placeholder:"session-manager",className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),e.jsxs("div",{className:"flex items-start justify-between gap-3 pt-1",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg",children:"Include content (PII)"}),e.jsxs("div",{className:"text-fg-faint text-xs leading-relaxed",children:["Adds tool inputs, plan text, and agent prompts to span attributes. Off by default — matches upstream Claude Code's ",e.jsx("span",{className:"font-mono",children:"OTEL_LOG_USER_PROMPTS"})," opt-in."]})]}),e.jsx(L,{checked:a.includeContent,onChange:f=>b("includeContent",f),label:a.includeContent?"on":"off"})]})]}),t&&e.jsxs("section",{className:"border border-line rounded p-3 text-xs space-y-1",children:[e.jsx("div",{className:"text-fg-dim",children:"Runtime status"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"enabled:"})," ",e.jsx("span",{className:t.enabled?"text-accent":"text-fg-dim",children:String(t.enabled)})]}),t.error&&e.jsxs("div",{className:"text-red-400 break-words",children:[e.jsx("span",{className:"text-fg-faint",children:"error:"})," ",t.error]}),!t.error&&t.enabled&&e.jsx("div",{className:"text-fg-faint",children:"spans batched and exported in the background. Verify by enabling and pointing at a local Jaeger."})]}),e.jsxs("footer",{className:"flex items-center gap-3 pt-2 border-t border-line",children:[e.jsx("button",{onClick:C,disabled:!u||m,className:"px-3 py-1 text-xs rounded bg-accent text-bg disabled:opacity-50 disabled:cursor-not-allowed",children:m?"saving…":"Save"}),e.jsx("button",{onClick:E,disabled:!u||m,className:"px-3 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg disabled:opacity-50 disabled:cursor-not-allowed",children:"Revert"}),x&&e.jsx("span",{className:"text-red-400 text-xs",children:x}),!x&&g&&!u&&e.jsx("span",{className:"text-fg-faint text-xs",children:"saved"})]})]})}function _e(){const[s,n]=d.useState(null),[t,l]=d.useState(null),[a,r]=d.useState("Copy"),[i,p]=d.useState(!1),[m,v]=d.useState(null),[x,w]=d.useState(null),[g,y]=d.useState(null),[u,b]=d.useState(!1),C=()=>{window.api.telemetry.status().then(l).catch(h=>{console.warn("[product-telemetry] status reload failed:",h==null?void 0:h.message)})};if(d.useEffect(()=>{let h=!1;return Promise.all([window.api.telemetry.getConfig(),window.api.telemetry.status()]).then(([c,T])=>{h||(n(c),l(T))}).catch(c=>{console.warn("[product-telemetry] load failed:",c==null?void 0:c.message)}),()=>{h=!0}},[]),!s||!t)return e.jsx(R,{title:"loading…"});const E=async h=>{w(null);try{const c=await window.api.telemetry.setConfig(h);n(c.config),l(c.status)}catch(c){w(c instanceof Error?c.message:String(c))}},f=h=>{E({...s,enabled:h})},S=h=>{E({...s,enabled:h.turnOff?!1:s.enabled,noticeAckedAt:new Date().toISOString()})},k=async()=>{try{await navigator.clipboard.writeText(s.installId),r("Copied"),setTimeout(()=>r("Copy"),1500)}catch{}},o=async()=>{p(!0),v(null);try{const h=await window.api.telemetry.flushNow();v(`sent ${h.sent.length}, failed ${h.failed.length}`),C()}catch(h){v(h instanceof Error?h.message:String(h))}finally{p(!1)}},j=async()=>{if(u){b(!1);return}try{const h=await window.api.telemetry.recentRecords();y(h),b(!0)}catch(h){console.warn("[product-telemetry] recentRecords failed:",h instanceof Error?h.message:h)}},N=s.lastDailyFlushAt?new Date(s.lastDailyFlushAt).getTime()+Ie:null;return e.jsxs("div",{className:"space-y-5","data-testid":"product-telemetry-section",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-fg text-base font-medium",children:"Product telemetry (bilko.run)"}),e.jsxs("p",{className:"text-fg-dim text-xs leading-relaxed",children:["Anonymous, strictly non-identifying usage/error reporting that helps improve this app. On by default; switchable off in one click. See"," ",e.jsx("span",{className:"font-mono",children:"session-manager-operations/architecture/telemetry.md"})," for the full data model."]})]}),!s.noticeAckedAt&&e.jsxs("section",{"data-testid":"telemetry-first-run-notice",className:"border border-accent rounded p-3 space-y-2 text-xs",children:[e.jsx("div",{className:"text-fg font-medium",children:"This app sends anonymous product telemetry"}),e.jsx("p",{className:"text-fg-dim leading-relaxed",children:"Collected: a coarse machine profile (OS/arch/app version, no hardware id), error and warning counts, and session counts — sent on start-up, after an update, and once a day."}),e.jsx("p",{className:"text-fg-dim leading-relaxed",children:"Never collected: prompts, transcripts, file paths, project names, email, or username."}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx("button",{onClick:()=>S({turnOff:!1}),className:"px-3 py-1 rounded bg-accent text-bg",children:"OK"}),e.jsx("button",{onClick:()=>S({turnOff:!0}),className:"px-3 py-1 rounded border border-line text-fg-dim hover:text-fg",children:"Turn off"})]})]}),e.jsxs("section",{className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg",children:"Send anonymous product telemetry"}),e.jsx("div",{className:"text-fg-faint text-xs",children:"Sent on start-up, after an update, and once a day. Strictly anonymous — an install id only, never an email, name, or other identifier."})]}),e.jsx(L,{checked:s.enabled,onChange:f,label:s.enabled?"on":"off"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-fg-dim text-xs",children:"Anonymous install id"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",readOnly:!0,value:s.installId,"aria-label":"Anonymous install identifier",className:"flex-1 bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"}),e.jsx("button",{onClick:k,className:"px-2 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg",children:a})]})]}),e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("div",{className:"text-fg-faint",children:"Endpoint"}),e.jsx("div",{className:"font-mono text-fg-dim break-all",children:s.endpoint})]}),e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("div",{className:"text-fg-faint",children:"Send cadence"}),e.jsx("div",{className:"text-fg-dim",children:"on start-up, after an update, and once a day"})]}),x&&e.jsx("div",{className:"text-red-400 text-xs",children:x})]}),t.pendingCount>0&&t.sentCount===0&&e.jsxs("section",{"data-testid":"telemetry-never-delivered-warning",className:"border border-red-400 rounded p-3 text-xs space-y-1 text-red-400",children:[e.jsx("div",{className:"font-medium",children:"Never delivered"}),e.jsxs("div",{className:"leading-relaxed",children:[t.pendingCount," record",t.pendingCount===1?"":"s",' queued but none have ever been sent to bilko.run on this install. Check the endpoint/network, or click "Send now" below.']})]}),e.jsxs("section",{className:"border border-line rounded p-3 text-xs space-y-1.5",children:[e.jsx("div",{className:"text-fg-dim",children:"Runtime status"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"last send:"})," ",J(t.lastFlushAt)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"next daily send due:"})," ",U(N?new Date(N).toISOString():null)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"queued records:"})," ",t.pendingCount]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"delivered so far:"})," ",t.sentCount]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"de-duplicated:"})," ",t.dedupedAppends]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"evicted:"})," ",t.evictedCount]}),t.backlog&&e.jsxs("div",{className:"text-fg-faint",children:["last backlog drain (",t.backlog.reason,", ",U(t.backlog.ranAt),"):"," ",t.backlog.linesEnqueued," enqueued, ",t.backlog.linesConfirmed," confirmed,"," ",t.backlog.watermarksRewound," watermarks rewound"]}),t.lastError&&e.jsxs("div",{className:"text-red-400 break-words",children:[e.jsx("span",{className:"text-fg-faint",children:"last error:"})," ",t.lastError.message," ","(",J(t.lastError.at),")"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:o,disabled:i,className:"px-3 py-1 text-xs rounded bg-accent text-bg disabled:opacity-50 disabled:cursor-not-allowed",children:i?"sending…":"Send now"}),m&&e.jsx("span",{className:"text-fg-faint text-xs",children:m})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("button",{onClick:j,className:"px-3 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg",children:u?"Hide last records":"Inspect last records sent"}),u&&e.jsx("pre",{"data-testid":"telemetry-inspector-json",className:"bg-bg border border-line rounded p-2 text-[11px] font-mono overflow-auto max-h-96 whitespace-pre-wrap",children:JSON.stringify(g??[],null,2)})]})]})}function Fe(){const{model:s,setModel:n}=X();return e.jsxs("div",{className:"p-4 max-w-3xl space-y-5 text-sm",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-fg text-base font-medium",children:"Session Manager preferences"}),e.jsx("p",{className:"text-fg-dim text-xs leading-relaxed",children:"Native app preferences, stored locally — not part of Claude Code's own settings."})]}),e.jsx("section",{className:"border border-line rounded p-3 space-y-3",children:e.jsxs("label",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"Default model for raw sessions"}),e.jsx("select",{value:s,onChange:t=>n(t.target.value),className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs",children:ee.map(t=>e.jsx("option",{value:t,children:t.charAt(0).toUpperCase()+t.slice(1)},t))}),e.jsx("span",{className:"text-fg-faint text-[11px]",children:"Used when opening a raw interactive session without an explicit per-launch override."})]})})]})}function $e({cwd:s}){const[n,t]=d.useState(!1),[l,a]=d.useState(!1),[r,i]=d.useState(!1),[p,m]=d.useState(!1);d.useEffect(()=>{var y,u;let g=!1;return t(!1),Promise.resolve((u=(y=window.api.promptSessions)==null?void 0:y.getWorktreeDisabled)==null?void 0:u.call(y,{cwd:s})).then(b=>{g||(a((b==null?void 0:b.disabled)??!1),i((b==null?void 0:b.disabled)??!1),t(!0))},()=>{g||t(!0)}),()=>{g=!0}},[s]);const v=n&&r!==l,x=()=>{var g,y;m(!0),Promise.resolve((y=(g=window.api.promptSessions)==null?void 0:g.setWorktreeDisabled)==null?void 0:y.call(g,{cwd:s,disabled:r})).then(u=>{a((u==null?void 0:u.disabled)??r),i((u==null?void 0:u.disabled)??r)}).catch(u=>te.error(u instanceof Error?u.message:String(u))).finally(()=>m(!1))},w=()=>i(l);return e.jsxs("div",{"data-testid":"settings-epic-isolation",className:"border-b border-line bg-bg-elev px-3 py-2.5 text-[11.5px] leading-snug",children:[e.jsxs("label",{className:"flex items-start gap-2",children:[e.jsx("input",{type:"checkbox",checked:r,disabled:!n||p,onChange:g=>i(g.target.checked),"data-testid":"settings-epic-isolation-checkbox",className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-semibold text-fg",children:"Disable Epic worktree isolation for this project"}),e.jsxs("span",{className:"block text-fg-dim",children:["Off by default — each active Epic runs in its own isolated ",e.jsx("code",{children:"git worktree"})," (branch"," ",e.jsx("code",{children:"sm-epic/<id>"}),"), merged back to main at an explicit checkpoint. Turning this on makes every new Epic in this project run directly in the shared working tree instead, same as before this feature existed."]})]})]}),v&&e.jsx(K,{dirty:v,busy:p,onSave:x,onRevert:w})]})}const B={user:{title:"Global settings",body:"This is the real ~/.claude/settings.json on disk — the same file the claude CLI reads on every session it starts. Edits apply machine-wide, to every project and every session."},project:{title:"Project settings",body:"This is the real <project>/.claude/settings.json on disk, checked into git. Edits apply to every current and future session in this project, for anyone who clones it."},local:{title:"Local settings",body:"This is the real <project>/.claude/settings.local.json on disk, gitignored. Edits apply to every current and future session in this project, on this machine only."}};function He(){const s=se(),n=$(c=>c.tabs),t=$(c=>c.activeTabId),l=n.find(c=>c.id===t)??null,a=(l==null?void 0:l.cwd)??null,r=ne(c=>c.navFace),i=d.useRef(!1),p=d.useRef(r),[m,v]=d.useState(()=>r==="project"&&a?"project":"user"),[x,w]=d.useState("effective");d.useEffect(()=>{if(p.current!==r){if(p.current=r,i.current){i.current=!1;return}v(r==="project"&&a?"project":"user")}},[r,a]),d.useEffect(()=>{r==="project"&&(x==="telemetry"||x==="app")&&w("effective")},[r,x]);const g=c=>{i.current=!0,v(c)},y=ue(H,s,a),u=y[m]??null,b=M(c=>c.files),C=M(c=>c.setDraft),E=M(c=>c.saveJson),f=M(c=>c.revert),[S,k]=d.useState(null),o=d.useMemo(()=>ae(re(b,y)),[b,y]),j=(c,T,A)=>{var F;const I=y[A??m];if(!I)return;k(null);const _=((F=b[I])==null?void 0:F.draftRaw)??"";let D={};if(_.trim())try{D=JSON.parse(_)}catch{D={}}const Z=oe(D,c,T);C(I,JSON.stringify(Z,null,2)+`
|
|
3
|
-
`)};if(!s)return e.jsx(R,{title:"loading…"});const N=u?b[u]:null,h=c=>c!=="user"&&!a;return e.jsx(ce,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(ie,{options:[{key:"effective",label:"Guided"},{key:"tree",label:"Tree"},{key:"raw",label:"Raw"},...r==="home"?[{key:"telemetry",label:"Telemetry"},{key:"app",label:"Session Manager"}]:[]],active:x,onChange:w}),x!=="telemetry"&&x!=="app"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx(de,{scopes:H.scopes,active:m,onChange:g,annotate:c=>{if(h(c))return{exists:!1};const T=y[c];if(!T)return null;const A=b[T];return{exists:(A==null?void 0:A.exists)??!1,dirty:(A==null?void 0:A.dirty)??!1}}}),e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:x==="effective"?`overrides → ${u??"—"}`:u??"—"})]}),e.jsx("div",{className:"flex-1"}),e.jsx("a",{href:"https://code.claude.com/docs/en/settings",target:"_blank",rel:"noreferrer",className:"text-fg-faint hover:text-fg-dim underline-offset-2 hover:underline",children:"schema reference ↗"})]}),footer:x!=="telemetry"&&x!=="app"&&u&&N?e.jsx(K,{dirty:N.dirty,busy:N.busy,parseError:S||N.parseError,lastSavedAt:N.lastSavedAt,leading:N.exists?null:e.jsx("span",{children:"file will be created on save"}),onSave:async()=>{k(null);const c=await E(u);c.ok||k(c.error??"save failed")},onRevert:()=>{k(null),f(u)}}):null,children:x==="telemetry"?e.jsx(De,{}):x==="app"?e.jsx(Fe,{}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-testid":"settings-scope-note",className:"sticky top-0 z-10 border-b border-line bg-bg-elev px-3 py-2 text-[11.5px] leading-snug",children:[e.jsx("span",{className:"font-semibold text-fg",children:B[m].title}),e.jsx("span",{className:"mx-1.5 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-dim",children:B[m].body}),u&&e.jsx("span",{className:"ml-1.5 font-mono text-fg-faint",children:u})]}),m==="project"&&a&&e.jsx($e,{cwd:a}),h(m)?e.jsx(R,{title:"no active project",hint:"open a tab in a project directory to edit project or local settings"}):x==="effective"?e.jsx(je,{node:o,targetScope:m,onOverride:j,schema:G()}):x==="tree"?e.jsx(xe,{node:o,targetScope:m,onOverride:j,schema:G()}):u&&N?e.jsx(le,{path:u,value:N.draftRaw,onChange:c=>{k(null),C(u,c)}}):e.jsx(R,{title:"resolving…"})]})})}const qe=d.memo(He);export{B as SETTINGS_SCOPE_NOTES,qe as Settings};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{au as l,aN as J,aI as Q,aP as U,aK as f,ah as t,l as R,aH as L}from"./index-D5H_H5wC.js";import{P as D}from"./Panel-C2YTW-qP.js";import{L as X}from"./ListDetail-CtVjrHKB.js";import{M as Y}from"./MarkdownEditor-CbzC-Oqf.js";import{S as Z}from"./SaveBar-87ZJfscX.js";import{S as I}from"./ScopeSwitcher-CKzpqjJ_.js";import{T as _}from"./Toggle-CDXR5l3m.js";import{P as V}from"./ProvenanceBadge-kJ__BOQv.js";import{l as ee}from"./listSkills-QORduPIk.js";import{S as te,V as F}from"./Library-DeKdY-tD.js";import{p as se,r as ae,s as ne}from"./skillFrontmatter-Dif5JIg7.js";import"./monaco-editor-BW5C4Iv1.js";function re(d,m){return{user:{skills:`${d}/.claude/skills`,commands:`${d}/.claude/commands`},project:m?{skills:`${m}/.claude/skills`,commands:`${m}/.claude/commands`}:null}}function le(){const d=J(),m=Q(),h=(m==null?void 0:m.cwd)??null,x=U(e=>e.navFace),j=l.useRef(!1),T=l.useRef(x),[p,N]=l.useState(()=>x==="project"&&h?"project":"user"),[v,k]=l.useState([]),[r,C]=l.useState(null),[w,E]=l.useState("installed"),[$,B]=l.useState(""),b=l.useMemo(()=>d?re(d,h):null,[d,h]);l.useEffect(()=>{if(T.current!==x){if(T.current=x,j.current){j.current=!1;return}N(x==="project"&&h?"project":"user")}},[x,h]),l.useEffect(()=>{if(!b)return;let e=!1;const i=p==="user"?b.user:b.project;if(!i){k([]);return}return(async()=>{var c;const n=[],s=await ee(i.skills);for(const a of s)n.push({kind:"skills",scope:p,name:a.name,path:a.path,dir:a.dir,disabled:ae(a.text),description:se(a.text).description??void 0});const o=await window.api.config.listDir(i.commands,{filesOnly:!0});for(const a of o.entries)a.name.endsWith(".md")&&n.push({kind:"commands",scope:p,name:a.name.replace(/\.md$/,""),path:a.path,dir:null,disabled:!1});e||(n.sort((a,A)=>a.kind===A.kind?a.name.localeCompare(A.name):a.kind==="skills"?-1:1),k(n),n.find(a=>a.path===r)||C(((c=n[0])==null?void 0:c.path)??null))})(),()=>{e=!0}},[p,b]);const S=f(e=>e.files),P=f(e=>e.loadText),H=f(e=>e.setDraft),K=f(e=>e.saveText),O=f(e=>e.revert),W=f(e=>e.watchFile),M=f(e=>e.unwatchFile);async function q(e,i){const n=await window.api.config.readText(e.path);if(!n.exists)return;const s=ne(n.text,i);if(s===n.text)return;const o=await window.api.config.writeText(e.path,s);if(!o.ok){L.error(o.error??"failed to update skill");return}k(c=>c.map(a=>a.path===e.path?{...a,disabled:i}:a)),S[e.path]&&P(e.path)}async function z(e){if(!e.dir||!window.confirm(`Remove skill "${e.name}"?
|
|
2
|
-
|
|
3
|
-
Its folder moves to the trash (recoverable); reinstall any time from the Library.`))return;const i=await window.api.files.delete(e.dir);if(!i.ok){L.error(i.error??"failed to remove skill");return}L.info(`Removed "${e.name}" — moved to trash`),M(e.path),k(n=>n.filter(s=>s.path!==e.path)),C(n=>{var o;return n!==e.path?n:((o=v.filter(c=>c.path!==e.path)[0])==null?void 0:o.path)??null})}l.useEffect(()=>{if(r)return S[r]||P(r),W(r),()=>M(r)},[r]);const[G,y]=l.useState(null);if(!d)return t.jsx(R,{title:"loading…"});if(w==="library")return t.jsx(D,{toolbar:t.jsx(F,{active:w,onChange:E,installedLabel:"Installed",libraryLabel:"Library"}),children:t.jsx(te,{})});if(p==="project"&&!h)return t.jsx(D,{toolbar:t.jsxs(t.Fragment,{children:[t.jsx(F,{active:w,onChange:E}),t.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),t.jsx(I,{scopes:["user","project"],active:p,onChange:e=>{j.current=!0,N(e)}})]}),children:t.jsx(R,{title:"no active project",hint:"open a tab in a project directory to view project skills & commands"})});const u=v.find(e=>e.path===r)??null,g=r?S[r]:null;return t.jsx(D,{toolbar:t.jsxs(t.Fragment,{children:[t.jsx(F,{active:w,onChange:E}),t.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),t.jsx(I,{scopes:["user","project"],active:p,onChange:e=>{j.current=!0,N(e)}}),t.jsxs("span",{className:"ml-3 text-fg-faint",children:[v.length," ",v.length===1?"item":"items"]}),t.jsx("div",{className:"flex-1"}),u&&t.jsx(V,{scope:u.scope,input:{type:u.kind==="commands"?"command":"skill",name:u.name}}),t.jsx("span",{className:"ml-2 text-fg-faint truncate",children:(u==null?void 0:u.path)??""})]}),footer:r&&g?t.jsx(Z,{dirty:g.dirty,busy:g.busy,parseError:G,lastSavedAt:g.lastSavedAt,onSave:async()=>{y(null);const e=await K(r);e.ok||y(e.error??"save failed")},onRevert:()=>{y(null),O(r)}}):null,children:t.jsx(X,{sidebar:t.jsxs("div",{className:"py-1",children:[t.jsx("div",{className:"px-2 pb-1",children:t.jsx("input",{value:$,onChange:e=>B(e.target.value),placeholder:"filter…",className:"w-full bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"})}),["skills","commands"].map(e=>{const i=$.toLowerCase(),n=v.filter(s=>s.kind===e&&(!i||s.name.toLowerCase().includes(i)));return t.jsxs("div",{className:"mb-3",children:[t.jsx("div",{className:"px-3 py-1 text-xs uppercase tracking-wider text-fg-faint",children:e==="skills"?"Skills":"Slash Commands"}),n.length===0?t.jsx("div",{className:"px-3 py-1 text-xs text-fg-faint italic",children:"none"}):n.map(s=>{var c;const o=s.kind==="skills";return t.jsxs("div",{className:`w-full px-3 py-1 text-xs flex items-center justify-between gap-2 ${r===s.path?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[t.jsxs("button",{onClick:()=>C(s.path),className:"flex-1 min-w-0 text-left",children:[t.jsxs("div",{className:`truncate ${s.disabled?"line-through opacity-50":""}`,title:s.disabled?"Disabled — Claude will not auto-invoke this skill":void 0,children:[s.kind==="commands"?"/":"",s.name]}),s.description&&t.jsx("div",{className:"truncate text-fg-faint",children:s.description})]}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[t.jsx(V,{interactive:!1,scope:s.scope,input:{type:s.kind==="commands"?"command":"skill",name:s.name}}),((c=S[s.path])==null?void 0:c.dirty)&&t.jsx("span",{className:"w-1 h-1 rounded-full bg-accent"}),o&&t.jsx(_,{checked:!s.disabled,onChange:a=>void q(s,!a)}),s.kind==="skills"&&t.jsx("button",{onClick:a=>{a.stopPropagation(),z(s)},title:"Remove skill — moves the folder to trash; reinstall from the Library","aria-label":`Remove ${s.name}`,className:"text-fg-faint hover:text-red-400 leading-none px-0.5",children:"✕"})]})]},s.path)})]},e)})]}),detail:r&&g?t.jsx("div",{className:"h-full",children:t.jsx(Y,{path:r,value:g.draftRaw,onChange:e=>{y(null),H(r,e)}})}):t.jsx(R,{title:v.length===0?"no skills or commands":"select an item"})})})}const je=l.memo(le);export{je as Skills};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{au as l,aH as $,ah as e,aM as B,af as I,ag as V,aD as _,a0 as z,e as H,g as M,q as L,M as D,j as q,a3 as K,aN as G,C as J,aK as h,l as P}from"./index-D5H_H5wC.js";import{P as T}from"./Panel-C2YTW-qP.js";import{S as Q}from"./SaveBar-87ZJfscX.js";import{f as W,V as A}from"./Library-DeKdY-tD.js";import"./monaco-editor-BW5C4Iv1.js";function F(t){return t.split("/").pop()||t}function X({activePath:t,selectedPath:o,onSelect:f}){const[n,i]=l.useState([]),m=l.useRef(0),r=l.useRef(f);if(r.current=f,l.useEffect(()=>{if(m.current+=1,r.current(null),!t){i([]);return}const a=m.current;let x=!1;return window.api.config.parseImports(t).then(c=>{x||m.current!==a||(c.ok?i(c.imports):(i([]),$.error(c.error||"failed to parse @-imports")))}),()=>{x=!0}},[t]),n.length===0||!t)return null;const b=o===t||o===null;return e.jsxs("div",{className:"w-64 shrink-0 border-r border-line bg-bg-elev overflow-auto","data-testid":"referenced-files-rail",children:[e.jsxs("div",{className:"px-3 py-2 text-[10px] uppercase tracking-wide text-fg-faint border-b border-line",children:["Documents · ",n.length+1]}),e.jsxs("button",{type:"button",onClick:()=>f(null),"aria-current":b,"data-testid":"referenced-file-root",className:`w-full text-left px-3 py-2 border-b border-line ${b?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg"}`,children:[e.jsx("div",{className:"text-[11.5px] font-medium truncate",children:F(t)}),e.jsx("div",{className:"text-[10px] text-fg-faint truncate",title:t,children:"this system prompt"})]}),n.map(a=>{const x=!a.ok||!a.exists,c=o===a.path;return e.jsxs("button",{type:"button",onClick:()=>f(a),"aria-current":c,"data-testid":"referenced-file-row",className:`w-full text-left px-3 py-2 border-b border-line last:border-b-0 ${c?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[11.5px] font-medium truncate flex-1",children:F(a.path)}),x&&e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded text-[9px] uppercase tracking-wide text-amber-400/90 border border-amber-400/30","data-testid":"referenced-file-missing",children:"missing"})]}),e.jsx("div",{className:"text-[10px] text-fg-faint truncate",title:a.path,children:a.path}),e.jsxs("div",{className:"text-[10px] text-fg-faint",children:[a.sizeBytes.toLocaleString()," bytes · ~",a.tokenEstimate.toLocaleString()," tokens"]})]},a.path)})]})}function U(t){return t.split("/").filter(Boolean).pop()||t}function Y({path:t,value:o,onChange:f,onSave:n,readOnly:i,defaultMode:m,headerRight:r,hideStatusBar:b}){const a=B(),x=I(t),c=V(t),S=_(t),[E,w]=l.useState(()=>i&&c?"preview":m??z(t)),[g,C]=l.useState(!0),[p,R]=l.useState(null),N=l.useRef(null),d=l.useRef(null),v=l.useCallback(s=>{N.current=s},[]),y=l.useCallback(()=>N.current,[]),k=i?c?["preview","edit"]:[]:S?["edit","preview","split"]:c?["edit","preview"]:[],u=c?E:"edit",j=e.jsx(H,{path:t,name:U(t),value:o,onChange:f,onSave:()=>n==null?void 0:n(),onReady:v,onCursor:R,readOnly:i});return e.jsxs("div",{className:"flex flex-col h-full min-h-0","data-testid":"document-editor-pane",children:[e.jsxs("div",{className:"flex items-center gap-1 px-2 h-7 shrink-0 border-b border-line bg-bg-elev",children:[e.jsx("span",{className:"text-[11px] font-medium text-fg truncate",children:U(t)}),i&&e.jsx("span",{className:"ml-1 px-1.5 py-0.5 rounded text-[9px] uppercase tracking-wide text-fg-faint border border-line",children:"read-only"}),e.jsx("div",{className:"flex-1"}),r,x&&(u==="preview"||u==="split")&&e.jsx("button",{onClick:()=>C(s=>!s),"data-testid":"document-outline-toggle",className:`px-2 py-0.5 text-[10px] border border-line rounded ${g?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Toggle document outline",children:"Outline"}),k.length>0&&e.jsx("div",{className:"flex items-center ml-1 rounded border border-line overflow-hidden","data-testid":"document-mode-toggle",children:k.map(s=>e.jsx("button",{onClick:()=>w(s),className:`px-2 py-0.5 text-[10px] capitalize transition-colors ${u===s?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,children:s},s))})]}),e.jsx("div",{className:"flex-1 min-h-0",children:u==="split"&&x?e.jsxs("div",{className:"flex h-full",children:[g&&e.jsx(M,{text:o,scrollRef:d}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col border-r border-line",children:[!i&&e.jsx(L,{getEditor:y}),e.jsx("div",{className:"flex-1 min-h-0",children:j})]}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(D,{ref:d,text:o,flush:!0,wideMeasure:a.wideMeasure})})]}):u==="preview"&&x?e.jsxs("div",{className:"flex h-full",children:[g&&e.jsx(M,{text:o,scrollRef:d}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(D,{ref:d,text:o,wideMeasure:a.wideMeasure})})]}):x?e.jsxs("div",{className:"flex flex-col h-full",children:[!i&&e.jsx(L,{getEditor:y}),e.jsx("div",{className:"flex-1 min-h-0",children:j})]}):j}),!b&&e.jsx(q,{text:o,cursor:p,language:K(t)||void 0})]})}const O={title:"User system prompt",body:"This is the real ~/.claude/CLAUDE.md on disk — the instructions the claude CLI loads into every session it starts on this machine, in every project. A project's own CLAUDE.md / CLAUDE.local.md are read from that project's directory when a session launches there; they are not edited here."};function Z(t){return Math.round(t.length/4)}function ee(){const t=G(),[o,f]=l.useState("installed"),n=l.useMemo(()=>t?J.resolve("user",t,null):null,[t]),[i,m]=l.useState(null),r=(i==null?void 0:i.path)??n,b=!!i&&(!i.ok||!i.exists),a=h(s=>s.files),x=h(s=>s.loadText),c=h(s=>s.setDraft),S=h(s=>s.saveText),E=h(s=>s.revert),w=h(s=>s.watchFile),g=h(s=>s.unwatchFile);l.useEffect(()=>{if(n)return x(n,!0),w(n),()=>{g(n)}},[n]),l.useEffect(()=>{if(!(!r||r===n))return x(r,!0),w(r),()=>{g(r)}},[r,n]);const[C,p]=l.useState(null),R=l.useCallback(s=>{p(null),m(s)},[]);if(!t)return e.jsx(P,{title:"loading…"});if(o==="library")return e.jsx(T,{toolbar:e.jsx(A,{active:o,onChange:f,installedLabel:"Editor",libraryLabel:"Presets"}),children:e.jsx(W,{})});const N=n?a[n]:null,d=r?a[r]:null,v=(d==null?void 0:d.draftRaw)??"",y=Z(v),k=v.length,u=b,j=async()=>{if(!r)return;p(null);const s=await S(r);s.ok||p(s.error??"save failed")};return e.jsx(T,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(A,{active:o,onChange:f,installedLabel:"Editor",libraryLabel:"Presets"}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-dim",children:"User scope"}),e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:r??"—"}),e.jsx("div",{className:"flex-1"}),e.jsxs("span",{className:"text-fg-faint",children:[k.toLocaleString()," chars · ~",y.toLocaleString()," tokens"]})]}),footer:r&&d&&!u?e.jsx(Q,{dirty:d.dirty,busy:d.busy,parseError:C,lastSavedAt:d.lastSavedAt,leading:d.exists?i?e.jsx("span",{children:"editing an imported file"}):null:e.jsx("span",{children:"file will be created on save"}),onSave:j,onRevert:()=>{p(null),E(r)}}):null,children:n&&N?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{"data-testid":"system-prompt-scope-note",className:"shrink-0 border-b border-line bg-bg-elev px-3 py-2 text-[11.5px] leading-snug",children:[e.jsx("span",{className:"font-semibold text-fg",children:O.title}),e.jsx("span",{className:"mx-1.5 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-dim",children:O.body}),e.jsx("span",{className:"ml-1.5 font-mono text-fg-faint",children:n})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex",children:[e.jsx(X,{activePath:n,selectedPath:r,onSelect:R}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[u&&e.jsx("div",{"data-testid":"system-prompt-missing-note",className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 text-[11px] text-amber-400/90",children:"This import does not resolve to a readable file — the CLI will skip it."}),r&&e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Y,{path:r,value:v,readOnly:u,defaultMode:"split",onChange:s=>{p(null),c(r,s)},onSave:()=>{j()}},r)})]})]})]}):e.jsx(P,{title:"resolving…"})})}const ie=l.memo(ee);export{ie as SystemPrompt};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{au as o,T as g,ah as e,l as w,aG as v,aH as u,X as y}from"./index-D5H_H5wC.js";import{P as T}from"./Panel-C2YTW-qP.js";import{L as k}from"./ListDetail-CtVjrHKB.js";import"./monaco-editor-BW5C4Iv1.js";const E=new Set(g.map(a=>a.tag));function j(a){return a.filter(n=>E.has(n))}function P(){const[a,n]=o.useState(g[0].tag),[l,x]=o.useState(null),[p,m]=o.useState(!1),r=o.useRef(!0);o.useEffect(()=>()=>{r.current=!1},[]);const c=async()=>{try{const t=await window.api.agents.listPersonas();r.current&&x(t)}catch(t){if(!r.current)return;x([]),u.error(t.message||"failed to load agent personas")}};o.useEffect(()=>{c()},[]),o.useEffect(()=>window.api.agents.onChanged(()=>c()),[]);const f=g.find(t=>t.tag===a)??null,h=async(t,i)=>{try{await window.api.agents.savePersona({name:t.name,originalName:t.name,description:t.description??"",tools:t.tools,model:t.model??"inherit",color:t.color??"",tags:j([...t.tags,i]),body:t.body}),m(!1),await c()}catch(d){u.error(d.message||"failed to assign tag")}},s=async(t,i)=>{try{await window.api.agents.savePersona({name:t.name,originalName:t.name,description:t.description??"",tools:t.tools,model:t.model??"inherit",color:t.color??"",tags:j(t.tags.filter(d=>d!==i)),body:t.body}),await c()}catch(d){u.error(d.message||"failed to remove tag")}};return e.jsx(T,{toolbar:e.jsxs("span",{className:"text-fg-faint",children:[g.length," tag",g.length===1?"":"s"]}),children:e.jsx(k,{sidebar:e.jsx("div",{className:"py-1",children:g.map(t=>{const i=v(t.tag),d=a===t.tag,b=(l==null?void 0:l.filter(N=>N.tags.includes(t.tag)).length)??0;return e.jsxs("button",{onClick:()=>{n(t.tag),m(!1)},className:`w-full text-left px-3 py-1.5 text-xs flex items-center gap-2 border-l-2 ${d?"bg-bg-hi text-fg border-accent":"text-fg-dim hover:text-fg hover:bg-bg-hi border-transparent"}`,children:[e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-mono font-semibold ${i.bg} ${i.text} ${i.border?"border border-current/30":""}`,children:["#",t.tag]}),e.jsx("span",{className:"truncate",children:t.label}),b>0&&e.jsx("span",{className:"ml-auto text-[10.5px] text-fg-faint font-mono shrink-0",children:b})]},t.tag)})}),detail:f?e.jsx(S,{entry:f,personas:l,adding:p,setAdding:m,onAssign:h,onUnassign:s}):e.jsx(w,{title:"select a tag"})})})}const A=o.memo(P);function S({entry:a,personas:n,adding:l,setAdding:x,onAssign:p,onUnassign:m}){const r=v(a.tag),c=y(a.tag),f=(n==null?void 0:n.filter(s=>s.tags.includes(a.tag)))??[],h=(n==null?void 0:n.filter(s=>!s.tags.includes(a.tag)))??[];return e.jsxs("div",{className:"p-4 space-y-4 max-w-3xl",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsxs("span",{className:`px-2 py-1 rounded text-xs font-mono font-semibold ${r.bg} ${r.text} ${r.border?"border border-current/30":""}`,children:["#",a.tag]}),e.jsx("span",{className:"text-sm font-semibold text-fg",children:a.label})]}),e.jsx("div",{className:"text-xs text-fg-dim leading-relaxed",children:a.description}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"/develop eagerness"}),e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] rounded border border-line text-fg-dim font-mono",children:a.developEagerness})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"develops via"}),e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] rounded border border-line text-fg-dim font-mono",children:a.developsVia})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"agents carrying this tag"}),n===null?e.jsx("div",{className:"text-xs text-fg-faint italic",children:"loading…"}):e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[f.map(s=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 bg-bg-elev border border-line rounded px-2 py-0.5 text-[11px] font-mono text-fg-dim",children:[s.name,e.jsx("button",{onClick:()=>m(s,a.tag),title:"Remove this tag from the agent",className:"text-fg-faint hover:text-fg",children:"×"})]},s.name)),f.length===0&&!l&&e.jsx("span",{className:"text-xs text-fg-faint italic mr-1",children:"no agent carries this tag yet."}),l?h.length>0?e.jsxs("select",{autoFocus:!0,defaultValue:"",onChange:s=>{const t=n.find(i=>i.name===s.target.value);t&&p(t,a.tag)},onBlur:()=>x(!1),className:"bg-bg border border-line rounded px-2 py-0.5 text-[11px] text-fg font-mono",children:[e.jsx("option",{value:"",disabled:!0,children:"pick an agent…"}),h.map(s=>e.jsx("option",{value:s.name,children:s.name},s.name))]}):e.jsx("span",{className:"text-xs text-fg-faint italic",children:"every agent already carries this tag."}):e.jsx("button",{onClick:()=>x(!0),className:"px-2 py-0.5 rounded-full text-[11px] font-mono border border-line text-fg-faint hover:text-fg hover:bg-bg-hi",children:"+ assign agent"})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"opening framing — sent before the human's goal"}),e.jsx("pre",{className:"text-xs text-fg-dim whitespace-pre-wrap bg-bg-elev border border-line rounded p-3 leading-relaxed font-sans",children:c.initialPromptTemplate})]})]})}export{A as TagLibrary};
|