claude-code-session-manager 0.126.0 → 0.128.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/bin/cli.cjs +71 -9
- package/bin/supervise.cjs +84 -0
- package/dist/assets/{AgentLibrary-bzeuZN4F.js → AgentLibrary-cNQU5YWy.js} +1 -1
- package/dist/assets/{Button-8dWfDDuQ.js → Button-9dIPAOBg.js} +1 -1
- package/dist/assets/{DataModel-D4ybBPZN.js → DataModel-DrDJ6ysw.js} +1 -1
- package/dist/assets/{History-hsztE6yh.js → History-4rrDdWNP.js} +1 -1
- package/dist/assets/{Hooks-CRmZMQaW.js → Hooks-Bj_jF5Pa.js} +1 -1
- package/dist/assets/{Library-Czt3Bojd.js → Library-D-Wsxrh7.js} +1 -1
- package/dist/assets/{ListDetail-Cr6Ct_WX.js → ListDetail-D7Om0H8j.js} +1 -1
- package/dist/assets/{McpServers-CeXJ2bng.js → McpServers-CbIbSd5o.js} +1 -1
- package/dist/assets/{Memory-caujO8O3.js → Memory-DgQlvQrO.js} +1 -1
- package/dist/assets/{Panel-D64i9tGz.js → Panel-DZHiD8Ar.js} +1 -1
- package/dist/assets/{Permissions-DpWOIrvr.js → Permissions-CfzduF4B.js} +1 -1
- package/dist/assets/{Plugins-Bd1ekP5P.js → Plugins-D-AG5nAo.js} +2 -2
- package/dist/assets/{ProvenanceBadge-B96A_uZf.js → ProvenanceBadge-B9JSEjll.js} +1 -1
- package/dist/assets/{SaveBar-D0Y2t-Ao.js → SaveBar-mVKig6hL.js} +1 -1
- package/dist/assets/{Scheduler-Y5_YbNrC.js → Scheduler-DFTCnh60.js} +1 -1
- package/dist/assets/{ScopeSwitcher-BmWA_dP9.js → ScopeSwitcher-s8J-yr7Z.js} +1 -1
- package/dist/assets/{Settings-Bcf65bpL.js → Settings-BTmxRMaP.js} +1 -1
- package/dist/assets/{SkillReferenceGraph-BeSNXloA.js → SkillReferenceGraph-C5lKqf5y.js} +1 -1
- package/dist/assets/{Skills-DwnQKJVc.js → Skills-CxOacq0k.js} +1 -1
- package/dist/assets/{SystemPrompt-Dih6SCmL.js → SystemPrompt-BCWg5FAz.js} +1 -1
- package/dist/assets/{TagLibrary-BZ-Kp10P.js → TagLibrary-BnF0_PkG.js} +1 -1
- package/dist/assets/{TiptapBody-C2nEUmF7.js → TiptapBody-C2Iu6rZd.js} +1 -1
- package/dist/assets/{Toggle-Dw8-zNQo.js → Toggle-C-oD66BG.js} +1 -1
- package/dist/assets/{ViewTabs-CoYPKGN-.js → ViewTabs-Cs4v7vLY.js} +1 -1
- package/dist/assets/{historyTotals-BbKcNpV7.js → historyTotals-CbRSLD8f.js} +1 -1
- package/dist/assets/{index-BnKaYERU.css → index-DtdWBGrI.css} +1 -1
- package/dist/assets/index-DzY_GXYY.js +3081 -0
- package/dist/assets/{settingsSchema-6doG_61l.js → settingsSchema-bSBfHuan.js} +1 -1
- package/dist/assets/{skillFrontmatter-BYMYWDfb.js → skillFrontmatter-BEseWm8r.js} +1 -1
- package/dist/assets/{useAgentsDirWatch-Cqabjieh.js → useAgentsDirWatch-CdyHxKCI.js} +1 -1
- package/dist/index.html +2 -2
- package/dist-web/app.css +1 -1
- package/dist-web/app.js +343 -341
- package/package.json +1 -1
- package/plugins/session-manager-dev/skills/develop/SKILL.md +3 -2
- package/scripts/scheduler-mcp-server.cjs +209 -7
- package/src/main/build-info.json +4 -4
- package/src/main/chatRunner.cjs +37 -4
- package/src/main/crashDiagnostics.cjs +83 -8
- package/src/main/health.cjs +16 -5
- package/src/main/index.cjs +46 -0
- package/src/main/ipcSchemas.cjs +107 -0
- package/src/main/lib/chatBootRecovery.cjs +136 -0
- package/src/main/lib/chatInflight.cjs +88 -0
- package/src/main/lib/claude/agentModelResolve.cjs +26 -7
- package/src/main/lib/claude/personaToolScope.cjs +40 -2
- package/src/main/lib/demo-video-kit/capture.cjs +113 -0
- package/src/main/lib/demo-video-kit/character.cjs +97 -0
- package/src/main/lib/demo-video-kit/checks.cjs +150 -0
- package/src/main/lib/demo-video-kit/frames.cjs +200 -0
- package/src/main/lib/demo-video-kit/seedKit.cjs +52 -0
- package/src/main/lib/demo-video-kit/sound.cjs +312 -0
- package/src/main/lib/epic/epicDelegationStats.cjs +1 -0
- package/src/main/lib/epic/epicSweepValidator.cjs +60 -6
- package/src/main/lib/epic/epicValidationHook.cjs +31 -3
- package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +71 -15
- package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +185 -34
- package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +15 -0
- package/src/main/lib/mcpToolCatalog.cjs +93 -14
- package/src/main/lib/opsOwnership.cjs +9 -5
- package/src/main/lib/persona-macro/builtinMacros.cjs +30 -5
- package/src/main/lib/persona-macro/macroJobDispatch.cjs +116 -0
- package/src/main/lib/persona-macro/macroJobIpc.cjs +50 -0
- package/src/main/lib/persona-macro/macroJobStatus.cjs +112 -0
- package/src/main/lib/persona-macro/macroLibrary.cjs +73 -3
- package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +100 -0
- package/src/main/lib/prd/prdCreate.cjs +17 -2
- package/src/main/lib/prd/prdFrontmatter.cjs +7 -2
- package/src/main/lib/process/childWithLog.cjs +38 -95
- package/src/main/lib/process/memoryScope.cjs +140 -0
- package/src/main/lib/process/ozonePlatform.cjs +15 -0
- package/src/main/lib/process/procIdentity.cjs +10 -3
- package/src/main/lib/process/scopeOomPolicy.cjs +69 -0
- package/src/main/lib/project-pages/pagesLibrary.cjs +171 -0
- package/src/main/lib/project-pages/playerBridge.cjs +129 -0
- package/src/main/lib/scheduler/cpuSample.cjs +147 -0
- package/src/main/lib/scheduler/definitionOfDone.cjs +40 -0
- package/src/main/lib/scheduler/jobLeftovers.cjs +204 -0
- package/src/main/lib/scheduler/jobSupervisorRecord.cjs +2 -1
- package/src/main/lib/scheduler/loadGate.cjs +116 -45
- package/src/main/lib/scheduler/queueStore.cjs +5 -2
- package/src/main/lib/scheduler/scheduleJobSchema.cjs +2 -0
- package/src/main/lib/scheduler/schedulerBatch.cjs +10 -3
- package/src/main/lib/scheduler/schedulerConfig.cjs +7 -2
- package/src/main/lib/smfileHeaders.cjs +11 -3
- package/src/main/lib/telemetry/crashTelemetry.cjs +8 -4
- package/src/main/projectPages.cjs +107 -30
- package/src/main/promptSessionsIpc.cjs +131 -0
- package/src/main/scheduler/budget.cjs +31 -0
- package/src/main/scheduler/prdParser.cjs +2 -0
- package/src/main/scheduler/prdPaths.cjs +54 -0
- package/src/main/scheduler/reviewLadder.cjs +17 -0
- package/src/main/scheduler/starvation.cjs +22 -0
- package/src/main/scheduler.cjs +548 -77
- package/src/main/seedSchedulerMcp.cjs +10 -1
- package/src/main/templates/PRD_AUTHORING.md +5 -2
- package/src/main/transcripts.cjs +8 -0
- package/src/main/usage.cjs +4 -2
- package/src/main/webRemote.cjs +3 -1
- package/src/preload/api.d.ts +113 -7
- package/src/preload/apiSurface.json +70 -0
- package/src/preload/index.cjs +13 -0
- package/src/seed/agents/demo-video-builder.md +141 -43
- package/src/seed/agents/project-home-builder.md +26 -13
- package/dist/assets/index-DgPUERhe.js +0 -3079
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{aI as Pe,at as ie,ac as Te,aO as xs,ag as Ce,ab as ue,ae as te,aT as q,b7 as Fe,b5 as pe,b9 as _t,aB as f,a9 as xe,bd as ms,al as t,b as ze,I as me,L as wt,p as bs,K as ge,t as ws,Q as vs,d as js,U as ys,aN as Ns,b4 as nt,aZ as ks,a4 as vt,ar as Ot,bc as $e,G as qe,ay as _e,A as at,aM as rt,N as Lt,w as Ft,o as qt,q as Ss,n as it,y as lt,O as Cs,D as re,f as B,ad as Bt,b8 as $s,aA as Ps,v as Ds,aD as Ht,bg as Gt,V as As,au as jt,a_ as yt,m as ke,x as Nt,aJ as kt,l as Rs,aR as Ms,X as Is,u as Vt,b0 as Es,aW as ye,H as Ts,C as _s,aC as Os,T as Ls,bf as Fs,ba as St,aL as qs}from"./index-DgPUERhe.js";import{f as Bs,a as Hs,s as Gs}from"./historyTotals-BbKcNpV7.js";import{l as Vs}from"./listSkills-C1aWKf0T.js";import{T as Ws}from"./Toggle-Dw8-zNQo.js";import"./monaco-editor-BsIlgG7c.js";function Us(e){const s=new Map(e.map(i=>[i.slug,i])),n=new Map,a=new Set,c=[];function l(i){n.set(i,1),c.push(i);const r=s.get(i);for(const d of(r==null?void 0:r.dependsOn)??[]){if(!s.has(d))continue;const o=n.get(d);if(o===1){const p=c.indexOf(d);for(let u=p;u<c.length;u++)a.add(c[u])}else o===void 0&&l(d)}c.pop(),n.set(i,2)}for(const i of e)n.has(i.slug)||l(i.slug);return a}function zs(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 Qs(e,s,n){const a=new Set(e.map(o=>o.slug)),c=new Set;for(const o of e)for(const p of o.dependsOn??[])a.has(p)&&c.add(p);const l=new Map,i=[];for(const o of e){const p=n.has(o.slug)?void 0:(o.dependsOn??[]).find(u=>a.has(u)&&!n.has(u));p?(l.has(p)||l.set(p,[]),l.get(p).push(o)):i.push(o)}const r=(o,p)=>o.slug.localeCompare(p.slug);i.sort(r);for(const o of l.values())o.sort(r);function d(o,p,u){const h=zs(o,s),g=n.has(o.slug);u.add(o.slug);const x=g?[]:(l.get(o.slug)??[]).filter(v=>!u.has(v.slug)).map(v=>d(v,p+1,u));return u.delete(o.slug),{row:o,depth:p,children:x,blockers:h,blocked:h.some(v=>!v.missing&&v.status!=="completed"),hasNeedsReviewBlocker:h.some(v=>v.needsReview),hasMissingDep:h.some(v=>v.missing),cycle:g,parallelEligible:(o.dependsOn??[]).length===0&&!c.has(o.slug)}}return i.map(o=>d(o,0,new Set))}function Wt(e,s,n){const a=new Map((n??e).map(o=>[o.slug,o])),c=Us(e),l=[],i=new Map,r=new Map;for(const o of e){const p=Pe(o,s),u=p.epicId??"__none__";i.has(u)||(l.push(u),i.set(u,[]),r.set(u,{epicId:p.epicId,label:p.known&&p.label?p.label:p.epicId?`Epic ${p.epicId.slice(0,12)}…`:"No Epic",known:p.known})),i.get(u).push(o)}const d=l.map(o=>{const p=r.get(o),u=i.get(o),h=Qs(u,a,c),g={};for(const x of u){const v=x.status??"unknown";g[v]=(g[v]??0)+1}return{epicId:p.epicId,label:p.label,known:p.known,nodes:h,counts:g,total:u.length}});return d.sort((o,p)=>o.epicId===null?1:p.epicId===null?-1:o.known!==p.known?o.known?-1:1:o.label.localeCompare(p.label)),d}function Be(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}function Xe(e){return String(e??"").replace(/^\d+-/,"")}function Oe(e){const s=new Set,n=new Map;for(const a of e){s.add(a.slug);const c=Xe(a.slug),l=n.get(c);l?l.push(a.slug):n.set(c,[a.slug])}return e.map(a=>{const c=a.dependsOn;if(!c||c.length===0)return a;let l=!1;const i=c.map(r=>{if(s.has(r))return r;const d=n.get(Xe(r));return d&&d.length===1?(l=!0,d[0]):r});return l?{...a,dependsOn:i}:a})}const Js=15e4,Ze=e=>e==="completed"||e==="skipped",Se=e=>e==="running"||e==="investigating",Ut=e=>e==="failed"||e==="needs_review"||e==="quarantined",Ys=e=>e==="failed"||e==="needs_review"||e==="quarantined";function zt(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 Qt(e,s){const n=e.estimateMinutes?e.estimateMinutes*6e4:null;return n?`${Math.min(99,Math.floor(s/n*100))}%`:Te(s)}function Ks(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?Js:s/n}function Le(e){const s=ie(e);return s===null?1/0:Number(s)}function et(e,s){const n=Le(e.slug)-Le(s.slug);return n!==0&&!Number.isNaN(n)?n:e.slug.localeCompare(s.slug)}function Xs(e){let s=0;for(const n of e.statusHistory??[])n.to==="pending"&&n.from!==null&&s++;return s}function Zs(e){return e.some(n=>Se(n.status))?"active":e.every(n=>Ze(n.status))?"done":e.filter(n=>n.status!=="quarantined").length===0?"draft":"queued"}function en(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 tn(e,s){return e._firstNum!==s._firstNum?e._firstNum<s._firstNum?-1:1:e._firstSlug.localeCompare(s._firstSlug)}function sn(e,s){const n=new Map(e.map(l=>[l.row.slug,l.row.slug])),a=l=>{for(;n.get(l)!==l;)n.set(l,n.get(n.get(l))),l=n.get(l);return l};for(const l of e)for(const i of l.row.dependsOn??[])s.has(i)&&n.set(a(l.row.slug),a(i));const c=new Map;for(const l of e){const i=a(l.row.slug),r=c.get(i);r?r.push(l):c.set(i,[l])}return[...c.values()]}function nn(e,s){if(e.length>0&&e.every(n=>!!n.row.planId)){const n=new Map;for(const a of e){const c=n.get(a.row.planId);c?c.push(a):n.set(a.row.planId,[a])}return[...n.values()]}return sn(e,s)}function an(e,s,n,a){const c=[],l=[e];for(a.add(e.row.slug);l.length>0;){const i=l.pop();c.push(i);for(const r of i.row.dependsOn??[])if(n.has(r)&&!a.has(r)){a.add(r);const d=s.get(r);d&&l.push(d)}}return c}function rn(e,s){const n=new Map(e.map(r=>[r.row.slug,r])),a=new Set,c=[],l=e.filter(r=>Xe(r.row.slug).startsWith("validate-")).sort((r,d)=>et({slug:r.row.slug},{slug:d.row.slug}));for(const r of l)a.has(r.row.slug)||c.push({nodes:an(r,n,s,a),validateSlug:r.row.slug});const i=e.filter(r=>!a.has(r.row.slug));if(i.length>0){const r=new Set(i.map(d=>d.row.slug));for(const d of nn(i,r))c.push({nodes:d,validateSlug:null})}return c}function ln(e){return e.replace(/^validate[\s:-]*/i,"").trim()}function ot(e,s){if(e.length===0)return[];const n=Oe(e),a=s.now??Date.now(),c=s.avgDurationMs??Ks(n),l=Math.max(1,s.concurrency??1),i=new Map(n.map(u=>[u.slug,u])),r=u=>u.status==="pending"&&(u.dependsOn??[]).every(h=>i.get(h)===void 0||i.get(h).status==="completed"),d=new Map;n.filter(r).sort(et).forEach((u,h)=>d.set(u.slug,h));const o=Wt(n,s.sessions,n),p=[];for(const u of o){const h=Be(u.nodes),g=new Set(h.map(k=>k.row.slug)),x=new Map(h.map(k=>[k.row.slug,k])),v=[];for(const k of rn(h,g)){const S=k.nodes,_=new Set(S.map(N=>N.row.slug)),m=new Map,R=new Set,P=N=>{const C=x.get(N);return(C.row.dependsOn??[]).filter(F=>_.has(F)&&!(C.cycle&&x.get(F).cycle))},D=N=>{const C=m.get(N);if(C!==void 0)return C;if(R.has(N))return 0;R.add(N);let F=0;for(const W of P(N))F=Math.max(F,D(W));return R.delete(N),m.set(N,F+1),F+1};for(const N of S)D(N.row.slug);const O=S.map(N=>{const C=N.row,F=(C.dependsOn??[]).filter(W=>g.has(W));return{slug:C.slug,title:C.title,status:C.status,stage:m.get(C.slug),prdNumber:ie(C.slug),rowKind:"dep",rowTrailing:"",cycle:N.cycle,estimateMinutes:C.estimateMinutes??null,deps:F,crossEpicDeps:(C.dependsOn??[]).filter(W=>!g.has(W)),blockers:N.blockers,job:C}});O.sort(et);const K=O.reduce((N,C)=>Math.max(N,C.stage),0),z=new Map;for(const N of O){const C=N.job,F=x.get(N.slug),W=C.status;let H;if(Ze(W)){const b=C.startedAt&&C.finishedAt?Date.parse(C.finishedAt)-Date.parse(C.startedAt):NaN;H={kind:"done",trailing:b>0?Te(b):"",held:!1,blocked:!1}}else if(Se(W)){const b=C.startedAt?Math.max(0,a-Date.parse(C.startedAt)):null;H={kind:"running",trailing:b===null?"":Qt(C,b),held:!1,blocked:!1}}else if(W==="failed")H={kind:"failed",trailing:"failed",held:!1,blocked:!1};else if(W==="needs_review")H={kind:"review",trailing:"review",held:!1,blocked:!1};else if(W==="quarantined")H={kind:"quarantined",trailing:"quarantined",held:!1,blocked:!1};else{const b=F.blockers.filter(j=>!j.missing&&j.status!=="completed");if(b.length>0){const j=b.some(G=>Ys(G.status)),A=b[0].slug;H={kind:"dep",trailing:`←${ie(A)??A}`,held:!j,blocked:j}}else if(C.heldReason)H={kind:"gate",trailing:"gate",held:!0,blocked:!1};else{const j=Xs(C),A=d.get(C.slug)??0;H=j>0?{kind:"retry",trailing:`${j} ${j===1?"retry":"retries"}`,held:!1,blocked:!1}:{kind:"eta",trailing:zt(A*c/l),held:!1,blocked:!1}}}z.set(N.slug,H)}const Q=[];for(let N=1;N<=K;N++){const C=O.filter(E=>E.stage===N),F=C.find(E=>{const U=z.get(E.slug).kind;return E.status==="pending"&&(U==="eta"||U==="retry")});if(F){const E=z.get(F.slug);E.kind="next",E.trailing="next"}let W=0,H=0,b=0,j=0,A=0,G=0;for(const E of C){const U=z.get(E.slug);E.rowKind=U.kind,E.rowTrailing=U.trailing,Ze(E.status)?W++:Se(E.status)?H++:E.status==="pending"?(A++,U.held&&b++,U.blocked&&j++):Ut(E.status)&&G++}const $=W===C.length?"done":H>0?"running":j+G>0?"blocked":b>0?"held":"pending",T={n:N,rows:C,doneCount:W,runningCount:H,heldCount:b,blockedCount:j};Q.push({...T,state:$,summary:en($,T,A,G)})}let X=0;for(const N of O){const C=N.estimateMinutes?N.estimateMinutes*6e4:c;if(N.status==="pending")X+=C;else if(Se(N.status)){const F=N.job.startedAt?Math.max(0,a-Date.parse(N.job.startedAt)):0;X+=Math.max(0,C-F)}}const Z=O.reduce((N,C)=>Math.min(N,Le(C.slug)),1/0),se=O.reduce((N,C)=>Math.max(N,Le(C.slug)),-1/0),Y=u.known?xs(u.label).title:u.label,M=k.validateSlug?O.find(N=>N.slug===k.validateSlug):void 0,L=M&&ln(M.title)||Y;v.push({epicId:u.epicId,waveIndex:0,index:0,label:L,epicLabel:Y,validateSlug:k.validateSlug,width:Q.reduce((N,C)=>Math.max(N,C.rows.length),0),status:Zs(O),prdCount:O.length,stageCount:K,doneCount:Q.reduce((N,C)=>N+C.doneCount,0),runningCount:Q.reduce((N,C)=>N+C.runningCount,0),heldCount:Q.reduce((N,C)=>N+C.heldCount,0),blockedCount:Q.reduce((N,C)=>N+C.blockedCount,0),etaMs:X/l,stages:Q,_firstNum:Z,_lastNum:se,_firstSlug:O[0].slug})}v.sort(tn),v.forEach((k,S)=>{k.waveIndex=S+1});const y=v.filter(k=>k.validateSlug===null);y.forEach((k,S)=>{y.length>1&&(k.label=`${k.label} · plan ${S+1}/${y.length}`)});for(const k of v)p.push(k)}return p.sort((u,h)=>{if(u._lastNum!==h._lastNum)return u._lastNum>h._lastNum?-1:1;const g=(u.epicId??"").localeCompare(h.epicId??"");return g!==0?g:u.waveIndex-h.waveIndex}),p.map(({_firstNum:u,_lastNum:h,_firstSlug:g,...x},v)=>({...x,index:v+1}))}function on(e,s=Date.now()){const n=Oe(e),a=new Map(n.map(g=>[g.slug,g])),c=new Date(s).toDateString();let l=0,i=0,r=0,d=0,o=0,p=0,u=0;for(const g of n)g.status==="pending"?(i++,(g.dependsOn??[]).every(v=>a.get(v)===void 0||a.get(v).status==="completed")&&l++):Se(g.status)?u++:g.status==="failed"?r++:g.status==="needs_review"?d++:g.status==="quarantined"?o++:g.status==="completed"&&g.finishedAt&&new Date(Date.parse(g.finishedAt)).toDateString()===c&&p++;let h=null;if(r+d+o>0){for(const g of ot(n,{sessions:{},now:s}))for(const x of g.stages)if(x.rows.some(v=>Ut(v.status))){(h===null||x.n<h)&&(h=x.n);break}}return{readyNow:l,totalQueued:i,heldByDeps:i-l,needsYou:r+d+o,needsYouStage:h,failedCount:r,needsReviewCount:d,doneToday:p,inFlight:u}}function dn(e){const s=new Map;for(const d of e.stages)for(const o of d.rows)s.set(o.slug,o);const n=d=>{var o;return((o=s.get(d))==null?void 0:o.cycle)===!0},a=new Map,c=new Set,l=(d,o)=>d.chain.length!==o.chain.length?d.chain.length>o.chain.length:d.est!==o.est?d.est>o.est:d.chain.join("\0")<o.chain.join("\0"),i=d=>{const o=a.get(d);if(o)return o;const p=s.get(d),u=p.estimateMinutes??0;if(c.has(d))return{chain:[d],est:u};c.add(d);let h=null;for(const x of p.deps){if(!s.has(x)||p.cycle&&n(x))continue;const v=i(x);(!h||l(v,h))&&(h=v)}c.delete(d);const g=h?{chain:[...h.chain,d],est:h.est+u}:{chain:[d],est:u};return a.set(d,g),g};let r=null;for(const d of s.keys()){const o=i(d);(!r||l(o,r))&&(r=o)}return r?r.chain:[]}const cn=300*6e4,un={five_hour:"5-hour",session:"5-hour",weekly_all:"weekly",weekly:"weekly"};function pn(e){return un[e]??e.replace(/_/g," ")}function Jt({snap:e,now:s,avgDurationMs:n,runningJobs:a}){const{config:c,jobs:l,paused:i,nextReset:r,utilization:d,utilizationWindow:o,effectiveConcurrency:p}=e;let u=0,h=0;for(const S of l)S.status==="pending"?u++:S.status==="completed"&&h++;const g=a.length,x=u+g,v=(p==null?void 0:p.cap)??5;if(g>0){const S=a.reduce((D,O)=>(D.startedAt??"")<(O.startedAt??"")?D:O),_=S.startedAt?s-Date.parse(S.startedAt):0,m=h+g,R=h+x,P=g>1?` · ${g}/${v} parallel`:"";return{kind:"running",line1:`Running ${m}/${R}${P} · ${Ce(_)}`,line2:g===1?S.title:a.map(D=>D.title).join(", "),tooltip:a.map(D=>`${D.slug} (g${D.parallelGroup})`).join("; ")}}if(i){const S=i.resumeAt?Date.parse(i.resumeAt)-s:null;return{kind:"paused",line1:{rate_limit:"Paused — tokens exhausted",auth:"Paused — authentication failed",network:"Paused — network unreachable",reset_failure:"Paused — billing data unavailable",manual:"Paused — manual (you paused the queue)"}[i.reason]??`Paused — ${i.reason}`,line2:i.reason==="auth"?"Run `claude` in any terminal to refresh credentials, then Resume":S!==null&&S>0?`auto-resume ${ue(Date.parse(i.resumeAt))} (in ${te(S)})`:i.resumeAt?"resuming…":"no auto-resume scheduled",tooltip:i.resumeAt??"",action:{label:"Resume",onClick:()=>window.api.schedule.resume(),title:"Clear the pause and resume queue immediately"}}}if(x===0)return{kind:"idle",line1:"No work queued",line2:null};if((c.firePolicy??"when-available")==="manual")return{kind:"manual",line1:`Manual · ${u} pending`,line2:"click Fire next batch now to fire",action:{label:"Fire next batch now",onClick:()=>window.api.schedule.forceTick().then(q.fromOutcome).catch(()=>q.error("Failed to fire batch")),title:"Bypasses the billing-usage poll. Use when the meter is rate-limited or you want immediate progress."}};const k=c.utilizationThreshold??90;if(d==null)return{kind:"auto-soon",line1:`Auto · ${u} pending`,line2:"checking token availability…"};if(d>=k){const S=r?Date.parse(r)-s:null,_=o?pn(o):null,m=S===null||Number.isNaN(S)||S>cn,R=S&&S>0?`resets ${ue(Date.parse(r))} (in ${te(S)})`:null;let P;return m?P=`${_??"binding"} window — long hold${R?`, ${R}`:", reset time unknown"}`:P=R?`${_?`${_} window `:""}next ${R}`:"will fire when usage drops",{kind:"auto-throttled",line1:`Auto · throttled (util ${d.toFixed(0)}% ≥ ${k}%)`,line2:P}}return{kind:"auto-soon",line1:`Auto · ${u} pending · util ${d.toFixed(0)}%`,line2:"fires within 2 min (poll cycle)"}}const fn=15e3,hn=new Set(["failed","needs_review","quarantined"]);function Ct(){var n;const s=Array.from(document.querySelectorAll("[data-job-row]")).find(a=>hn.has(a.dataset.jobStatus??""));(n=s==null?void 0:s.scrollIntoView)==null||n.call(s,{block:"center",behavior:"smooth"})}function gn(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 ${te(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?te(e.idleMs):"?"} with ${e.dispatchable} dispatchable`;case"running":default:return`running: ${e.runningCount} in flight, ${e.pending} pending`}}function xn(e){const[s,n]=f.useState(null),a=nt(),c=ks(),l=a&&c;return f.useEffect(()=>{if(!l)return;let i=!0,r=!1,d=!1;const o=()=>{r||(r=!0,window.api.schedule.queueHealth(e).then(u=>{r=!1,d=!1,i&&n(u)},u=>{r=!1,!d&&(d=!0,q.error(`Queue health refresh failed: ${u instanceof Error?u.message:String(u)}`))}))};o();const p=setInterval(o,fn);return()=>{i=!1,clearInterval(p)}},[e,l]),s}const mn={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 bn(e,s,n){return e==="paused"||e==="launch-blocked"?"paused":e==="running"||e==="saturated"?"running":e?"idle":s?"paused":n>0?"running":"idle"}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 wn(e,s,n,a){var c;if(e==="agent"){const l=((c=a==null?void 0:a.cwd)==null?void 0:c.split("/").filter(Boolean).pop())||"another session",i=a!=null&&a.reason?` — "${a.reason}"`:"",r=s?new Date(s).getTime()-n:null,d=r==null?"":r>0?` — auto-resumes in ${te(r)}`:" — auto-resume pending";return`Paused by an agent in ${l}${i}${d}. Click Resume to restart now.`}if(e==="auth")return"Scheduler paused: Claude sign-in expired or invalid. Restart the app or re-run `claude login`, then Resume.";if(e==="rate_limit"){if(s){const l=new Date(s).getTime()-n;return l>0?`Paused for rate limit — resumes in ${te(l)}`:"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 vn({now:e}){const s=Fe(p=>p.snapshot);if(!s)return null;const n=s.paused,a=Object.entries(s.launchBlocks??{}),c=Object.entries(s.launchMitigations??{}),l=(n==null?void 0:n.reason)==="auth"||(n==null?void 0:n.reason)==="network",i="flex items-start gap-3 border-b px-0 py-1.5 text-[12.5px]",r="bg-red-950/10 border-red-700/30 text-red-800",d="bg-amber-400/10 border-amber-600/30 text-amber-700",o="shrink-0 px-2 py-0.5 rounded border border-current/40 hover:bg-white/20 text-[12px] font-medium";return t.jsxs(t.Fragment,{children:[n&&t.jsxs("div",{"data-testid":"pause-banner",className:`${i} ${l?r:d}`,children:[t.jsx("span",{className:"flex-1 leading-snug",children:wn(n.reason,n.resumeAt,e,n.by)}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),className:o,children:"Resume"})]}),a.map(([p,u])=>t.jsxs("div",{"data-testid":"launch-block-banner",className:`${i} ${r}`,children:[t.jsxs("div",{className:"flex-1 leading-snug min-w-0",children:[t.jsxs("div",{className:"font-medium",children:["Launches for ",t.jsx("span",{className:"font-mono",children:p})," jobs are failing before any work starts",u.httpStatus?` (HTTP ${u.httpStatus}, ${u.kind})`:` (${u.kind})`,u.exhausted?" — held until the Claude CLI version changes or you press Retry now.":u.until?` — next automatic probe ${new Date(u.until).getTime()>e?`in ${te(new Date(u.until).getTime()-e)}`:"on the next tick"}.`:"."]}),t.jsx("div",{className:"opacity-80",children:u.hint}),t.jsxs("div",{className:"font-mono text-[11.5px] opacity-70 truncate",title:u.message,children:[u.attempts," failed probe",u.attempts===1?"":"s",u.claudeVersion?` · CLI ${u.claudeVersion}`:"",u.lastSlug?` · last: ${u.lastSlug}`:""," · ",u.message]})]}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),className:o,children:"Retry now"})]},`launch-block-${p}`)),c.map(([p,u])=>t.jsx("div",{"data-testid":"launch-mitigation-banner",className:`${i} ${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:p})," jobs are running in degraded mode"," ","(",t.jsx("span",{className:"font-mono",children:Object.entries(u.env).map(([h,g])=>`${h}=${g}`).join(" ")}),")",u.claudeVersion?` since CLI ${u.claudeVersion}`:"","."]}),t.jsx("div",{className:"opacity-80",children:u.hint})]})},`launch-mitigation-${p}`))]})}function jn({scopeCwd:e,subView:s,onSubView:n,filterText:a,onFilterText:c,planMode:l,onPlanMode:i,planToolsRef:r}){const d=Fe($=>$.snapshot),o=pe($=>$.sessions),p=xn(e),u=_t(),[h,g]=f.useState(()=>Date.now()),[x,v]=f.useState("—");f.useEffect(()=>{const $=setInterval(()=>g(Date.now()),3e4);return()=>clearInterval($)},[]),f.useEffect(()=>{let $=!0;return Bs(30).then(T=>{if(!$||!T.ok||!T.data)return;const E=new Date,U=Ge=>String(Ge).padStart(2,"0"),He=`${E.getFullYear()}-${U(E.getMonth()+1)}-${U(E.getDate())}`;v(Hs(Gs(T.data,{day:He})))}),()=>{$=!1}},[]);const y=f.useMemo(()=>((d==null?void 0:d.jobs)??[]).filter($=>!e||$.cwd===e),[d,e]),k=f.useMemo(()=>on(y,h),[y,h]),S=f.useMemo(()=>{const $=ot(y,{sessions:o,now:h}),T=E=>$.filter(U=>U.status===E).length;return{active:T("active"),queued:T("queued"),draft:T("draft")}},[y,o,h]),_=f.useMemo(()=>{const $=new Date(h).toDateString(),T=[];for(const E of y)if(E.status==="completed"&&E.startedAt&&E.finishedAt&&new Date(Date.parse(E.finishedAt)).toDateString()===$){const U=Date.parse(E.finishedAt)-Date.parse(E.startedAt);U>0&&T.push(U)}return T.length?Math.round(T.reduce((E,U)=>E+U,0)/T.length/6e4):null},[y,h]);if(!d)return null;const m=p&&!p.unknown?p.verdict??null:null,R=p&&!p.unknown?p.slots??null:null,P=d.paused,D=bn((m==null?void 0:m.kind)??null,!!P,k.inFlight),O=mn[D],K=y.filter($=>$.status==="pending").length,z=y.filter($=>$.status==="running").length,Q=Jt({snap:{...d,jobs:y},now:h,avgDurationMs:0,runningJobs:y.filter($=>$.status==="running")}),X=p!=null&&p.unknown?`Queue health: unknown — ${p.reason??"state unavailable"}`:m?gn(m,(p==null?void 0:p.oldestRunningAgeMs)??null):"queue health loading…",Z=xe(d.lastRunAt?Date.parse(d.lastRunAt):null,h),se=p!=null&&p.lastDispatchAttemptAt?xe(Date.parse(p.lastDispatchAttemptAt),h):"never",Y=[X,Q.line1,m?`dispatchable ${m.dispatchable} · needs_review ${m.needsReviewCount}`:null,(p==null?void 0:p.oldestRunningAgeMs)!=null?`oldest running ${te(p.oldestRunningAgeMs)} (any project)`:null,`last batch fired ${Z} (lastRunAt — advances only when a job launches)`,`last dispatch attempt ${se} (advances on every driver evaluation)`].filter(Boolean).join(`
|
|
1
|
+
import{aI as Pe,at as ie,ac as Te,aO as xs,ag as Ce,ab as ue,ae as te,aT as q,b7 as Fe,b5 as pe,b9 as _t,aB as f,a9 as xe,bd as ms,al as t,b as ze,I as me,L as wt,p as bs,K as ge,t as ws,Q as vs,d as js,U as ys,aN as Ns,b4 as nt,aZ as ks,a4 as vt,ar as Ot,bc as $e,G as qe,ay as _e,A as at,aM as rt,N as Lt,w as Ft,o as qt,q as Ss,n as it,y as lt,O as Cs,D as re,f as B,ad as Bt,b8 as $s,aA as Ps,v as Ds,aD as Ht,bg as Gt,V as As,au as jt,a_ as yt,m as ke,x as Nt,aJ as kt,l as Rs,aR as Ms,X as Is,u as Vt,b0 as Es,aW as ye,H as Ts,C as _s,aC as Os,T as Ls,bf as Fs,ba as St,aL as qs}from"./index-DzY_GXYY.js";import{f as Bs,a as Hs,s as Gs}from"./historyTotals-CbRSLD8f.js";import{l as Vs}from"./listSkills-C1aWKf0T.js";import{T as Ws}from"./Toggle-C-oD66BG.js";import"./monaco-editor-BsIlgG7c.js";function Us(e){const s=new Map(e.map(i=>[i.slug,i])),n=new Map,a=new Set,c=[];function l(i){n.set(i,1),c.push(i);const r=s.get(i);for(const d of(r==null?void 0:r.dependsOn)??[]){if(!s.has(d))continue;const o=n.get(d);if(o===1){const p=c.indexOf(d);for(let u=p;u<c.length;u++)a.add(c[u])}else o===void 0&&l(d)}c.pop(),n.set(i,2)}for(const i of e)n.has(i.slug)||l(i.slug);return a}function zs(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 Qs(e,s,n){const a=new Set(e.map(o=>o.slug)),c=new Set;for(const o of e)for(const p of o.dependsOn??[])a.has(p)&&c.add(p);const l=new Map,i=[];for(const o of e){const p=n.has(o.slug)?void 0:(o.dependsOn??[]).find(u=>a.has(u)&&!n.has(u));p?(l.has(p)||l.set(p,[]),l.get(p).push(o)):i.push(o)}const r=(o,p)=>o.slug.localeCompare(p.slug);i.sort(r);for(const o of l.values())o.sort(r);function d(o,p,u){const h=zs(o,s),g=n.has(o.slug);u.add(o.slug);const x=g?[]:(l.get(o.slug)??[]).filter(v=>!u.has(v.slug)).map(v=>d(v,p+1,u));return u.delete(o.slug),{row:o,depth:p,children:x,blockers:h,blocked:h.some(v=>!v.missing&&v.status!=="completed"),hasNeedsReviewBlocker:h.some(v=>v.needsReview),hasMissingDep:h.some(v=>v.missing),cycle:g,parallelEligible:(o.dependsOn??[]).length===0&&!c.has(o.slug)}}return i.map(o=>d(o,0,new Set))}function Wt(e,s,n){const a=new Map((n??e).map(o=>[o.slug,o])),c=Us(e),l=[],i=new Map,r=new Map;for(const o of e){const p=Pe(o,s),u=p.epicId??"__none__";i.has(u)||(l.push(u),i.set(u,[]),r.set(u,{epicId:p.epicId,label:p.known&&p.label?p.label:p.epicId?`Epic ${p.epicId.slice(0,12)}…`:"No Epic",known:p.known})),i.get(u).push(o)}const d=l.map(o=>{const p=r.get(o),u=i.get(o),h=Qs(u,a,c),g={};for(const x of u){const v=x.status??"unknown";g[v]=(g[v]??0)+1}return{epicId:p.epicId,label:p.label,known:p.known,nodes:h,counts:g,total:u.length}});return d.sort((o,p)=>o.epicId===null?1:p.epicId===null?-1:o.known!==p.known?o.known?-1:1:o.label.localeCompare(p.label)),d}function Be(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}function Xe(e){return String(e??"").replace(/^\d+-/,"")}function Oe(e){const s=new Set,n=new Map;for(const a of e){s.add(a.slug);const c=Xe(a.slug),l=n.get(c);l?l.push(a.slug):n.set(c,[a.slug])}return e.map(a=>{const c=a.dependsOn;if(!c||c.length===0)return a;let l=!1;const i=c.map(r=>{if(s.has(r))return r;const d=n.get(Xe(r));return d&&d.length===1?(l=!0,d[0]):r});return l?{...a,dependsOn:i}:a})}const Js=15e4,Ze=e=>e==="completed"||e==="skipped",Se=e=>e==="running"||e==="investigating",Ut=e=>e==="failed"||e==="needs_review"||e==="quarantined",Ys=e=>e==="failed"||e==="needs_review"||e==="quarantined";function zt(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 Qt(e,s){const n=e.estimateMinutes?e.estimateMinutes*6e4:null;return n?`${Math.min(99,Math.floor(s/n*100))}%`:Te(s)}function Ks(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?Js:s/n}function Le(e){const s=ie(e);return s===null?1/0:Number(s)}function et(e,s){const n=Le(e.slug)-Le(s.slug);return n!==0&&!Number.isNaN(n)?n:e.slug.localeCompare(s.slug)}function Xs(e){let s=0;for(const n of e.statusHistory??[])n.to==="pending"&&n.from!==null&&s++;return s}function Zs(e){return e.some(n=>Se(n.status))?"active":e.every(n=>Ze(n.status))?"done":e.filter(n=>n.status!=="quarantined").length===0?"draft":"queued"}function en(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 tn(e,s){return e._firstNum!==s._firstNum?e._firstNum<s._firstNum?-1:1:e._firstSlug.localeCompare(s._firstSlug)}function sn(e,s){const n=new Map(e.map(l=>[l.row.slug,l.row.slug])),a=l=>{for(;n.get(l)!==l;)n.set(l,n.get(n.get(l))),l=n.get(l);return l};for(const l of e)for(const i of l.row.dependsOn??[])s.has(i)&&n.set(a(l.row.slug),a(i));const c=new Map;for(const l of e){const i=a(l.row.slug),r=c.get(i);r?r.push(l):c.set(i,[l])}return[...c.values()]}function nn(e,s){if(e.length>0&&e.every(n=>!!n.row.planId)){const n=new Map;for(const a of e){const c=n.get(a.row.planId);c?c.push(a):n.set(a.row.planId,[a])}return[...n.values()]}return sn(e,s)}function an(e,s,n,a){const c=[],l=[e];for(a.add(e.row.slug);l.length>0;){const i=l.pop();c.push(i);for(const r of i.row.dependsOn??[])if(n.has(r)&&!a.has(r)){a.add(r);const d=s.get(r);d&&l.push(d)}}return c}function rn(e,s){const n=new Map(e.map(r=>[r.row.slug,r])),a=new Set,c=[],l=e.filter(r=>Xe(r.row.slug).startsWith("validate-")).sort((r,d)=>et({slug:r.row.slug},{slug:d.row.slug}));for(const r of l)a.has(r.row.slug)||c.push({nodes:an(r,n,s,a),validateSlug:r.row.slug});const i=e.filter(r=>!a.has(r.row.slug));if(i.length>0){const r=new Set(i.map(d=>d.row.slug));for(const d of nn(i,r))c.push({nodes:d,validateSlug:null})}return c}function ln(e){return e.replace(/^validate[\s:-]*/i,"").trim()}function ot(e,s){if(e.length===0)return[];const n=Oe(e),a=s.now??Date.now(),c=s.avgDurationMs??Ks(n),l=Math.max(1,s.concurrency??1),i=new Map(n.map(u=>[u.slug,u])),r=u=>u.status==="pending"&&(u.dependsOn??[]).every(h=>i.get(h)===void 0||i.get(h).status==="completed"),d=new Map;n.filter(r).sort(et).forEach((u,h)=>d.set(u.slug,h));const o=Wt(n,s.sessions,n),p=[];for(const u of o){const h=Be(u.nodes),g=new Set(h.map(k=>k.row.slug)),x=new Map(h.map(k=>[k.row.slug,k])),v=[];for(const k of rn(h,g)){const S=k.nodes,_=new Set(S.map(N=>N.row.slug)),m=new Map,R=new Set,P=N=>{const C=x.get(N);return(C.row.dependsOn??[]).filter(F=>_.has(F)&&!(C.cycle&&x.get(F).cycle))},D=N=>{const C=m.get(N);if(C!==void 0)return C;if(R.has(N))return 0;R.add(N);let F=0;for(const W of P(N))F=Math.max(F,D(W));return R.delete(N),m.set(N,F+1),F+1};for(const N of S)D(N.row.slug);const O=S.map(N=>{const C=N.row,F=(C.dependsOn??[]).filter(W=>g.has(W));return{slug:C.slug,title:C.title,status:C.status,stage:m.get(C.slug),prdNumber:ie(C.slug),rowKind:"dep",rowTrailing:"",cycle:N.cycle,estimateMinutes:C.estimateMinutes??null,deps:F,crossEpicDeps:(C.dependsOn??[]).filter(W=>!g.has(W)),blockers:N.blockers,job:C}});O.sort(et);const K=O.reduce((N,C)=>Math.max(N,C.stage),0),z=new Map;for(const N of O){const C=N.job,F=x.get(N.slug),W=C.status;let H;if(Ze(W)){const b=C.startedAt&&C.finishedAt?Date.parse(C.finishedAt)-Date.parse(C.startedAt):NaN;H={kind:"done",trailing:b>0?Te(b):"",held:!1,blocked:!1}}else if(Se(W)){const b=C.startedAt?Math.max(0,a-Date.parse(C.startedAt)):null;H={kind:"running",trailing:b===null?"":Qt(C,b),held:!1,blocked:!1}}else if(W==="failed")H={kind:"failed",trailing:"failed",held:!1,blocked:!1};else if(W==="needs_review")H={kind:"review",trailing:"review",held:!1,blocked:!1};else if(W==="quarantined")H={kind:"quarantined",trailing:"quarantined",held:!1,blocked:!1};else{const b=F.blockers.filter(j=>!j.missing&&j.status!=="completed");if(b.length>0){const j=b.some(G=>Ys(G.status)),A=b[0].slug;H={kind:"dep",trailing:`←${ie(A)??A}`,held:!j,blocked:j}}else if(C.heldReason)H={kind:"gate",trailing:"gate",held:!0,blocked:!1};else{const j=Xs(C),A=d.get(C.slug)??0;H=j>0?{kind:"retry",trailing:`${j} ${j===1?"retry":"retries"}`,held:!1,blocked:!1}:{kind:"eta",trailing:zt(A*c/l),held:!1,blocked:!1}}}z.set(N.slug,H)}const Q=[];for(let N=1;N<=K;N++){const C=O.filter(E=>E.stage===N),F=C.find(E=>{const U=z.get(E.slug).kind;return E.status==="pending"&&(U==="eta"||U==="retry")});if(F){const E=z.get(F.slug);E.kind="next",E.trailing="next"}let W=0,H=0,b=0,j=0,A=0,G=0;for(const E of C){const U=z.get(E.slug);E.rowKind=U.kind,E.rowTrailing=U.trailing,Ze(E.status)?W++:Se(E.status)?H++:E.status==="pending"?(A++,U.held&&b++,U.blocked&&j++):Ut(E.status)&&G++}const $=W===C.length?"done":H>0?"running":j+G>0?"blocked":b>0?"held":"pending",T={n:N,rows:C,doneCount:W,runningCount:H,heldCount:b,blockedCount:j};Q.push({...T,state:$,summary:en($,T,A,G)})}let X=0;for(const N of O){const C=N.estimateMinutes?N.estimateMinutes*6e4:c;if(N.status==="pending")X+=C;else if(Se(N.status)){const F=N.job.startedAt?Math.max(0,a-Date.parse(N.job.startedAt)):0;X+=Math.max(0,C-F)}}const Z=O.reduce((N,C)=>Math.min(N,Le(C.slug)),1/0),se=O.reduce((N,C)=>Math.max(N,Le(C.slug)),-1/0),Y=u.known?xs(u.label).title:u.label,M=k.validateSlug?O.find(N=>N.slug===k.validateSlug):void 0,L=M&&ln(M.title)||Y;v.push({epicId:u.epicId,waveIndex:0,index:0,label:L,epicLabel:Y,validateSlug:k.validateSlug,width:Q.reduce((N,C)=>Math.max(N,C.rows.length),0),status:Zs(O),prdCount:O.length,stageCount:K,doneCount:Q.reduce((N,C)=>N+C.doneCount,0),runningCount:Q.reduce((N,C)=>N+C.runningCount,0),heldCount:Q.reduce((N,C)=>N+C.heldCount,0),blockedCount:Q.reduce((N,C)=>N+C.blockedCount,0),etaMs:X/l,stages:Q,_firstNum:Z,_lastNum:se,_firstSlug:O[0].slug})}v.sort(tn),v.forEach((k,S)=>{k.waveIndex=S+1});const y=v.filter(k=>k.validateSlug===null);y.forEach((k,S)=>{y.length>1&&(k.label=`${k.label} · plan ${S+1}/${y.length}`)});for(const k of v)p.push(k)}return p.sort((u,h)=>{if(u._lastNum!==h._lastNum)return u._lastNum>h._lastNum?-1:1;const g=(u.epicId??"").localeCompare(h.epicId??"");return g!==0?g:u.waveIndex-h.waveIndex}),p.map(({_firstNum:u,_lastNum:h,_firstSlug:g,...x},v)=>({...x,index:v+1}))}function on(e,s=Date.now()){const n=Oe(e),a=new Map(n.map(g=>[g.slug,g])),c=new Date(s).toDateString();let l=0,i=0,r=0,d=0,o=0,p=0,u=0;for(const g of n)g.status==="pending"?(i++,(g.dependsOn??[]).every(v=>a.get(v)===void 0||a.get(v).status==="completed")&&l++):Se(g.status)?u++:g.status==="failed"?r++:g.status==="needs_review"?d++:g.status==="quarantined"?o++:g.status==="completed"&&g.finishedAt&&new Date(Date.parse(g.finishedAt)).toDateString()===c&&p++;let h=null;if(r+d+o>0){for(const g of ot(n,{sessions:{},now:s}))for(const x of g.stages)if(x.rows.some(v=>Ut(v.status))){(h===null||x.n<h)&&(h=x.n);break}}return{readyNow:l,totalQueued:i,heldByDeps:i-l,needsYou:r+d+o,needsYouStage:h,failedCount:r,needsReviewCount:d,doneToday:p,inFlight:u}}function dn(e){const s=new Map;for(const d of e.stages)for(const o of d.rows)s.set(o.slug,o);const n=d=>{var o;return((o=s.get(d))==null?void 0:o.cycle)===!0},a=new Map,c=new Set,l=(d,o)=>d.chain.length!==o.chain.length?d.chain.length>o.chain.length:d.est!==o.est?d.est>o.est:d.chain.join("\0")<o.chain.join("\0"),i=d=>{const o=a.get(d);if(o)return o;const p=s.get(d),u=p.estimateMinutes??0;if(c.has(d))return{chain:[d],est:u};c.add(d);let h=null;for(const x of p.deps){if(!s.has(x)||p.cycle&&n(x))continue;const v=i(x);(!h||l(v,h))&&(h=v)}c.delete(d);const g=h?{chain:[...h.chain,d],est:h.est+u}:{chain:[d],est:u};return a.set(d,g),g};let r=null;for(const d of s.keys()){const o=i(d);(!r||l(o,r))&&(r=o)}return r?r.chain:[]}const cn=300*6e4,un={five_hour:"5-hour",session:"5-hour",weekly_all:"weekly",weekly:"weekly"};function pn(e){return un[e]??e.replace(/_/g," ")}function Jt({snap:e,now:s,avgDurationMs:n,runningJobs:a}){const{config:c,jobs:l,paused:i,nextReset:r,utilization:d,utilizationWindow:o,effectiveConcurrency:p}=e;let u=0,h=0;for(const S of l)S.status==="pending"?u++:S.status==="completed"&&h++;const g=a.length,x=u+g,v=(p==null?void 0:p.cap)??5;if(g>0){const S=a.reduce((D,O)=>(D.startedAt??"")<(O.startedAt??"")?D:O),_=S.startedAt?s-Date.parse(S.startedAt):0,m=h+g,R=h+x,P=g>1?` · ${g}/${v} parallel`:"";return{kind:"running",line1:`Running ${m}/${R}${P} · ${Ce(_)}`,line2:g===1?S.title:a.map(D=>D.title).join(", "),tooltip:a.map(D=>`${D.slug} (g${D.parallelGroup})`).join("; ")}}if(i){const S=i.resumeAt?Date.parse(i.resumeAt)-s:null;return{kind:"paused",line1:{rate_limit:"Paused — tokens exhausted",auth:"Paused — authentication failed",network:"Paused — network unreachable",reset_failure:"Paused — billing data unavailable",manual:"Paused — manual (you paused the queue)"}[i.reason]??`Paused — ${i.reason}`,line2:i.reason==="auth"?"Run `claude` in any terminal to refresh credentials, then Resume":S!==null&&S>0?`auto-resume ${ue(Date.parse(i.resumeAt))} (in ${te(S)})`:i.resumeAt?"resuming…":"no auto-resume scheduled",tooltip:i.resumeAt??"",action:{label:"Resume",onClick:()=>window.api.schedule.resume(),title:"Clear the pause and resume queue immediately"}}}if(x===0)return{kind:"idle",line1:"No work queued",line2:null};if((c.firePolicy??"when-available")==="manual")return{kind:"manual",line1:`Manual · ${u} pending`,line2:"click Fire next batch now to fire",action:{label:"Fire next batch now",onClick:()=>window.api.schedule.forceTick().then(q.fromOutcome).catch(()=>q.error("Failed to fire batch")),title:"Bypasses the billing-usage poll. Use when the meter is rate-limited or you want immediate progress."}};const k=c.utilizationThreshold??90;if(d==null)return{kind:"auto-soon",line1:`Auto · ${u} pending`,line2:"checking token availability…"};if(d>=k){const S=r?Date.parse(r)-s:null,_=o?pn(o):null,m=S===null||Number.isNaN(S)||S>cn,R=S&&S>0?`resets ${ue(Date.parse(r))} (in ${te(S)})`:null;let P;return m?P=`${_??"binding"} window — long hold${R?`, ${R}`:", reset time unknown"}`:P=R?`${_?`${_} window `:""}next ${R}`:"will fire when usage drops",{kind:"auto-throttled",line1:`Auto · throttled (util ${d.toFixed(0)}% ≥ ${k}%)`,line2:P}}return{kind:"auto-soon",line1:`Auto · ${u} pending · util ${d.toFixed(0)}%`,line2:"fires within 2 min (poll cycle)"}}const fn=15e3,hn=new Set(["failed","needs_review","quarantined"]);function Ct(){var n;const s=Array.from(document.querySelectorAll("[data-job-row]")).find(a=>hn.has(a.dataset.jobStatus??""));(n=s==null?void 0:s.scrollIntoView)==null||n.call(s,{block:"center",behavior:"smooth"})}function gn(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 ${te(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?te(e.idleMs):"?"} with ${e.dispatchable} dispatchable`;case"running":default:return`running: ${e.runningCount} in flight, ${e.pending} pending`}}function xn(e){const[s,n]=f.useState(null),a=nt(),c=ks(),l=a&&c;return f.useEffect(()=>{if(!l)return;let i=!0,r=!1,d=!1;const o=()=>{r||(r=!0,window.api.schedule.queueHealth(e).then(u=>{r=!1,d=!1,i&&n(u)},u=>{r=!1,!d&&(d=!0,q.error(`Queue health refresh failed: ${u instanceof Error?u.message:String(u)}`))}))};o();const p=setInterval(o,fn);return()=>{i=!1,clearInterval(p)}},[e,l]),s}const mn={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 bn(e,s,n){return e==="paused"||e==="launch-blocked"?"paused":e==="running"||e==="saturated"?"running":e?"idle":s?"paused":n>0?"running":"idle"}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 wn(e,s,n,a){var c;if(e==="agent"){const l=((c=a==null?void 0:a.cwd)==null?void 0:c.split("/").filter(Boolean).pop())||"another session",i=a!=null&&a.reason?` — "${a.reason}"`:"",r=s?new Date(s).getTime()-n:null,d=r==null?"":r>0?` — auto-resumes in ${te(r)}`:" — auto-resume pending";return`Paused by an agent in ${l}${i}${d}. Click Resume to restart now.`}if(e==="auth")return"Scheduler paused: Claude sign-in expired or invalid. Restart the app or re-run `claude login`, then Resume.";if(e==="rate_limit"){if(s){const l=new Date(s).getTime()-n;return l>0?`Paused for rate limit — resumes in ${te(l)}`:"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 vn({now:e}){const s=Fe(p=>p.snapshot);if(!s)return null;const n=s.paused,a=Object.entries(s.launchBlocks??{}),c=Object.entries(s.launchMitigations??{}),l=(n==null?void 0:n.reason)==="auth"||(n==null?void 0:n.reason)==="network",i="flex items-start gap-3 border-b px-0 py-1.5 text-[12.5px]",r="bg-red-950/10 border-red-700/30 text-red-800",d="bg-amber-400/10 border-amber-600/30 text-amber-700",o="shrink-0 px-2 py-0.5 rounded border border-current/40 hover:bg-white/20 text-[12px] font-medium";return t.jsxs(t.Fragment,{children:[n&&t.jsxs("div",{"data-testid":"pause-banner",className:`${i} ${l?r:d}`,children:[t.jsx("span",{className:"flex-1 leading-snug",children:wn(n.reason,n.resumeAt,e,n.by)}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),className:o,children:"Resume"})]}),a.map(([p,u])=>t.jsxs("div",{"data-testid":"launch-block-banner",className:`${i} ${r}`,children:[t.jsxs("div",{className:"flex-1 leading-snug min-w-0",children:[t.jsxs("div",{className:"font-medium",children:["Launches for ",t.jsx("span",{className:"font-mono",children:p})," jobs are failing before any work starts",u.httpStatus?` (HTTP ${u.httpStatus}, ${u.kind})`:` (${u.kind})`,u.exhausted?" — held until the Claude CLI version changes or you press Retry now.":u.until?` — next automatic probe ${new Date(u.until).getTime()>e?`in ${te(new Date(u.until).getTime()-e)}`:"on the next tick"}.`:"."]}),t.jsx("div",{className:"opacity-80",children:u.hint}),t.jsxs("div",{className:"font-mono text-[11.5px] opacity-70 truncate",title:u.message,children:[u.attempts," failed probe",u.attempts===1?"":"s",u.claudeVersion?` · CLI ${u.claudeVersion}`:"",u.lastSlug?` · last: ${u.lastSlug}`:""," · ",u.message]})]}),t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),className:o,children:"Retry now"})]},`launch-block-${p}`)),c.map(([p,u])=>t.jsx("div",{"data-testid":"launch-mitigation-banner",className:`${i} ${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:p})," jobs are running in degraded mode"," ","(",t.jsx("span",{className:"font-mono",children:Object.entries(u.env).map(([h,g])=>`${h}=${g}`).join(" ")}),")",u.claudeVersion?` since CLI ${u.claudeVersion}`:"","."]}),t.jsx("div",{className:"opacity-80",children:u.hint})]})},`launch-mitigation-${p}`))]})}function jn({scopeCwd:e,subView:s,onSubView:n,filterText:a,onFilterText:c,planMode:l,onPlanMode:i,planToolsRef:r}){const d=Fe($=>$.snapshot),o=pe($=>$.sessions),p=xn(e),u=_t(),[h,g]=f.useState(()=>Date.now()),[x,v]=f.useState("—");f.useEffect(()=>{const $=setInterval(()=>g(Date.now()),3e4);return()=>clearInterval($)},[]),f.useEffect(()=>{let $=!0;return Bs(30).then(T=>{if(!$||!T.ok||!T.data)return;const E=new Date,U=Ge=>String(Ge).padStart(2,"0"),He=`${E.getFullYear()}-${U(E.getMonth()+1)}-${U(E.getDate())}`;v(Hs(Gs(T.data,{day:He})))}),()=>{$=!1}},[]);const y=f.useMemo(()=>((d==null?void 0:d.jobs)??[]).filter($=>!e||$.cwd===e),[d,e]),k=f.useMemo(()=>on(y,h),[y,h]),S=f.useMemo(()=>{const $=ot(y,{sessions:o,now:h}),T=E=>$.filter(U=>U.status===E).length;return{active:T("active"),queued:T("queued"),draft:T("draft")}},[y,o,h]),_=f.useMemo(()=>{const $=new Date(h).toDateString(),T=[];for(const E of y)if(E.status==="completed"&&E.startedAt&&E.finishedAt&&new Date(Date.parse(E.finishedAt)).toDateString()===$){const U=Date.parse(E.finishedAt)-Date.parse(E.startedAt);U>0&&T.push(U)}return T.length?Math.round(T.reduce((E,U)=>E+U,0)/T.length/6e4):null},[y,h]);if(!d)return null;const m=p&&!p.unknown?p.verdict??null:null,R=p&&!p.unknown?p.slots??null:null,P=d.paused,D=bn((m==null?void 0:m.kind)??null,!!P,k.inFlight),O=mn[D],K=y.filter($=>$.status==="pending").length,z=y.filter($=>$.status==="running").length,Q=Jt({snap:{...d,jobs:y},now:h,avgDurationMs:0,runningJobs:y.filter($=>$.status==="running")}),X=p!=null&&p.unknown?`Queue health: unknown — ${p.reason??"state unavailable"}`:m?gn(m,(p==null?void 0:p.oldestRunningAgeMs)??null):"queue health loading…",Z=xe(d.lastRunAt?Date.parse(d.lastRunAt):null,h),se=p!=null&&p.lastDispatchAttemptAt?xe(Date.parse(p.lastDispatchAttemptAt),h):"never",Y=[X,Q.line1,m?`dispatchable ${m.dispatchable} · needs_review ${m.needsReviewCount}`:null,(p==null?void 0:p.oldestRunningAgeMs)!=null?`oldest running ${te(p.oldestRunningAgeMs)} (any project)`:null,`last batch fired ${Z} (lastRunAt — advances only when a job launches)`,`last dispatch attempt ${se} (advances on every driver evaluation)`].filter(Boolean).join(`
|
|
2
2
|
`),M=d.utilization,L=d.pollHealth,N=L!=null&&!L.lastPollOk,C=ms(d.utilizationWindow),F=d.nextReset?Date.parse(d.nextReset):null,W=F?F>h?te(F-h):"soon":"—",H=d.effectiveConcurrency,b=(H==null?void 0:H.cap)??5,j=(H==null?void 0:H.source)==="env",A=d.config.firePolicy??"when-available",G=K===0&&z===0;return t.jsxs("div",{"data-testid":"scheduler-top-bands",className:"shrink-0 px-[18px]",children:[t.jsxs(ze,{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 ${O.text}`,"data-testid":"scheduler-state-word","data-state":D,children:[t.jsx("span",{className:`w-2 h-2 rounded-full ${O.dot}`,"aria-hidden":"true"}),D]}),t.jsxs("span",{className:"font-mono text-[12px] text-fg-faint whitespace-nowrap","data-testid":"scheduler-meta",children:[k.inFlight," in flight · ",k.heldByDeps," held · last batch ",Z]}),t.jsxs(me,{title:Y,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:Y}),wt.scheduler&&t.jsx(bs,{content:wt.scheduler})]}),t.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>window.api.schedule.rescan().then(q.fromOutcome).catch(()=>q.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"}),P?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(q.fromOutcome).catch(()=>q.error("Failed to fire batch")),disabled:G,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(vn,{now:h}),t.jsxs(ze,{height:70,testId:"scheduler-kpi-band",children:[t.jsx(ge,{testId:"kpi-window",label:C?`${C} used`:"Window used",info:N?`Billing poll failing — this reading may be outdated (last good reading ${xe(L.lastPollAt,h)}). Machine-wide ${C??"binding"} window.`:`Share of the machine-wide ${C??"binding"} billing window consumed — the window closest to its limit.`,value:M==null?"—":`${Math.round(M)}%`,sub:`resets in ${W}`,third:t.jsx(ws,{pct:M??0,tone:N?"bg-amber-500":"bg-accent"})}),t.jsx(ge,{testId:"kpi-slots",label:"Slots",info:`Machine-wide session pool (${(R==null?void 0:R.source)==="env"?"SM_SESSION_SLOTS override":"Home tab cap"}), not scoped to this project`,value:R?`${R.inUse}/${R.total}`:"—",sub:"in use",third:R?t.jsx(vs,{filled:R.inUse,total:R.total}):null}),t.jsx(ge,{testId:"kpi-ready",label:"Ready now",info:"Pending rows whose dependsOn chain is fully satisfied right now",value:k.readyNow,sub:`of ${k.totalQueued} queued`,third:`${k.heldByDeps} held by deps`}),k.needsYou>0?t.jsx(ge,{testId:"kpi-needs-you",label:"Needs you",value:t.jsx("button",{type:"button","data-testid":"kpi-needs-you-jump",onClick:Ct,className:"font-semibold text-accent hover:underline",title:"Scroll to the first failed / needs-review / quarantined row",children:k.needsYou}),sub:t.jsx("button",{type:"button",onClick:Ct,className:"hover:underline",children:k.needsYouStage!=null?`blocking stage ${k.needsYouStage}`:"need attention"}),third:[k.failedCount>0&&`${k.failedCount} failed`,k.needsReviewCount>0&&`${k.needsReviewCount} needs review`,k.needsYou-k.failedCount-k.needsReviewCount>0&&`${k.needsYou-k.failedCount-k.needsReviewCount} quarantined`].filter(Boolean).join(" · ")}):t.jsx(ge,{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(ge,{testId:"kpi-done",label:"Done today",value:k.doneToday,sub:_!=null?`avg ${_}m`:"avg —",third:t.jsx("span",{"data-testid":"kpi-done-spend",children:x})}),t.jsx(ge,{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:A,onChange:$=>window.api.schedule.setConfig({firePolicy:$.target.value}),className:"border border-line bg-bg-hi rounded px-1 py-0.5 text-[12px] text-fg-dim",title:"when-available: poll usage and fire when tokens are below threshold. manual: only on Run now.","aria-label":"Start jobs policy",children:[t.jsx("option",{value:"when-available",children:"when available"}),t.jsx("option",{value:"manual",children:"manually"})]})]}),value:t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(ys,{value:b,min:0,max:(u==null?void 0:u.max)??10,disabled:j,onChange:$=>{Ns($).catch(T=>{q.error(`Could not set session slots: ${T instanceof Error?T.message:String(T)}`)})},title:j?"pinned by SM_SESSION_SLOTS — unset the env var to edit":"Machine-wide claude -p session slots, shared with chat runs"}),j&&t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-amber-600 bg-amber-400/10 border border-amber-400/30 rounded px-1 py-0",title:"Pinned by SM_SESSION_SLOTS — unset the env var to edit",children:"env"})]}),sub:"at once",third:A==="when-available"?t.jsxs("span",{children:["pause above"," ",t.jsx(js,{value:d.config.utilizationThreshold??90,min:0,max:100,testId:"kpi-threshold",title:"Holds new dispatches when the highest of the 5-hour and weekly usage windows is at/above this percent (when-available policy only). Not the executor rate-limit pause — click to edit",onCommit:$=>window.api.schedule.setConfig({utilizationThreshold:$})})]}):null})]}),t.jsxs(ze,{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:[S.active," active · ",S.queued," queued · ",S.draft," draft · ",y.length," PRDs"]}),t.jsxs("span",{className:"ml-auto flex items-center gap-3",children:[t.jsx("span",{ref:r,className:"contents","data-testid":"scheduler-plan-tools"}),t.jsx("input",{type:"text",value:a,onChange:$=>c($.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(([$,T])=>t.jsx("button",{type:"button","data-testid":`plan-mode-${$}`,"aria-pressed":l===$&&s==="queue",onClick:()=>{i($),n("queue")},className:`px-2 py-0.5 text-[12px] ${l===$&&s==="queue"?"bg-bg-elev font-semibold text-fg":"text-fg-dim hover:text-fg"}`,children:T},$))}),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(([$,T,E])=>t.jsx("button",{type:"button",onClick:()=>n($),"aria-pressed":s===$,title:E,className:`text-[12.5px] ${s===$?"font-semibold text-fg":"text-fg-faint hover:text-fg-dim"}`,children:T},$))]})]})]})}function Yt({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 l=c.value===s;return t.jsxs("button",{type:"button",onClick:()=>n(c.value),className:`rounded-full ${a} text-[12.5px] border transition-colors ${l?"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 Kt(e,s=60){const n=e.trim();return n.length<=s?n:`${n.slice(0,s-1)}…`}function yn(e){return Be([e]).filter(s=>s.children.length===0).map(s=>s.row.slug)}function Xt(e){return e.nodes.map(s=>({rootSlug:s.row.slug,label:s.row.title||s.row.slug,terminals:yn(s)}))}function Nn(e){const s=new Map;for(const n of e){const a=Xt(n);n.nodes.forEach((c,l)=>{const i=a.filter((r,d)=>d!==l);for(const r of Be([c]))s.set(r.row.slug,i)})}return s}function Zt({job:e,headChoices:s}){const[n,a]=f.useState(!1),c=f.useCallback((l,i)=>{a(!0),window.api.schedule.setPrdDisposition({slug:e.slug,cwd:e.cwd??void 0,disposition:l,dependsOn:i}).then(q.fromOutcome).catch(()=>q.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:l=>{const i=l.target.value;if(i==="__new-head__")c("new-head");else if(i){const r=s.find(d=>d.rootSlug===i);r&&c("append",r.terminals)}},className:"text-[13px] font-semibold text-fg-dim hover:text-fg bg-transparent border border-line/60 rounded px-1.5 py-0.5 cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",title:"Change this wave's relationship to the rest of the Epic's plan",children:[t.jsx("option",{value:"",disabled:!0,children:"change disposition…"}),e.disposition==="append"&&t.jsx("option",{value:"__new-head__",children:"promote to new head"}),s.map(l=>t.jsxs("option",{value:l.rootSlug,children:["attach behind: ",Kt(l.label,40)]},l.rootSlug))]})}function kn(e,s,n=null){if(s.length===0||e.length===0)return e;const a=new Set,c=new Set;for(const i of e){a.add(i.slug);for(const r of vt(i))c.add(r)}const l=[];for(const i of s)i.archived!==!0||a.has(i.slug)||n&&i.cwd!==n||vt(i).some(r=>c.has(r))&&(a.add(i.slug),l.push({slug:i.slug,title:i.title,cwd:i.cwd,parallelGroup:i.parallelGroup,estimateMinutes:i.estimateMinutes,bodyPreview:"",status:i.archivedStatus??"completed",runId:null,startedAt:null,finishedAt:null,exitCode:null,error:null,dependsOn:i.dependsOn??void 0,sourcePromptId:i.sourcePromptId??null,epicId:i.epicId??null,synthetic:!0}));return l.length===0?e:[...e,...l]}const Sn=[],Cn=new Set(["failed","needs_review","quarantined"]);function $n(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 Pn(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 Dn(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 An({row:e,elapsedMs:s,listIndex:n,onFocused:a,headChoices:c=Sn}){const[l,i]=f.useState(!1),r=e.job,d=s!==null&&e.rowKind==="running"?Qt(r,s):e.rowTrailing,o=e.status==="completed"||e.status==="skipped",p=e.rowKind==="dep"&&e.blockers.some(h=>!h.missing&&h.status!==null&&Cn.has(h.status)),u=o||p;return t.jsxs("div",{role:"listitem","data-testid":"prd-row","data-slug":e.slug,className:"border-t border-rule-inner first:border-t-0",children:[t.jsxs("button",{type:"button","data-job-row":!0,"data-job-status":r.status,"data-job-index":n,onClick:()=>i(h=>!h),onFocus:()=>a(n),"aria-expanded":l,"aria-label":`${e.prdNumber?`PRD ${e.prdNumber}, `:""}${r.title}, ${r.status}${d?`, ${d}`:""}`,title:r.title,className:`w-full h-[31px] py-1 px-2 text-left flex items-center gap-1.5 hover:bg-bg/40 focus:outline-none focus:ring-1 focus:ring-accent focus:ring-inset ${Pn(e)}`,children:[t.jsx("span",{"aria-hidden":"true",className:`shrink-0 w-[7px] h-[7px] rounded-full ${$n(e)}`}),t.jsx("span",{className:"shrink-0 font-mono text-[10.5px] text-fg-faint w-[30px]",children:e.prdNumber?`#${e.prdNumber}`:""}),t.jsx("span",{className:`flex-1 min-w-0 truncate text-[12.5px] leading-tight ${u?"text-fg-faint":"text-fg font-medium"}`,children:r.title}),t.jsx("span",{"data-testid":"prd-row-trailing",className:`shrink-0 font-mono text-[10.5px] ${Dn(e)}`,children:d})]}),l&&t.jsx(Rn,{row:e,elapsedMs:s,headChoices:c})]})}const es=f.memo(An);function Rn({row:e,elapsedMs:s,headChoices:n}){const a=e.job,[c,l]=f.useState(!1),i=pe(g=>g.sessions),r=f.useMemo(()=>Pe(a,i),[a,i]),d=r.known&&r.epicId?i[r.epicId]:null,o=f.useCallback(g=>Ot(g),[]),p="font-mono text-[11.5px] text-fg-dim leading-snug break-words",u="text-[12px] font-semibold bg-transparent border-0 cursor-pointer p-0",h=a.error?a.error.split(`
|
|
3
3
|
`)[0]:null;return t.jsxs("div",{"data-testid":"prd-row-detail",className:"px-3 py-2 bg-bg-elev/50 border-t border-rule-inner flex flex-col gap-1",children:[t.jsxs("div",{className:p,children:[a.status.replace(/_/g," "),a.exitCode!==null&&` · exit ${a.exitCode}`,a.verifierVerdict&&` · ${$e(a.verifierVerdict)}`,a.startedAt&&` · started ${ue(Date.parse(a.startedAt))}`,a.finishedAt&&` · finished ${ue(Date.parse(a.finishedAt))}`,s===null&&e.rowTrailing&&e.rowKind==="done"?` · took ${e.rowTrailing}`:""]}),e.cycle&&t.jsxs("div",{className:`${p} text-accent`,"data-testid":"job-row-cycle-warning",children:["⚠ dependsOn cycle — ",e.blockers.map(g=>g.slug).join(" ↔ ")||"self-referencing"]}),!e.cycle&&e.blockers.length>0&&t.jsxs("div",{className:p,"data-testid":"job-row-blockers",children:["depends on ",e.blockers.map(g=>`${g.slug} (${g.missing?"missing":(g.status??"unknown").replace(/_/g," ")})`).join(", ")]}),a.status==="pending"&&a.heldReason&&t.jsxs("div",{className:`${p} text-amber-400/90`,"data-testid":"job-row-held-reason",children:["held · ",a.heldReason]}),h&&t.jsx("div",{className:`${p} text-accent/80`,children:h}),!a.synthetic&&t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 pt-0.5",children:[d&&t.jsx("button",{type:"button","data-testid":"job-row-prompt-session-link",title:d.goalText,onClick:()=>o(d.id),className:`${u} text-accent hover:text-accent/80`,children:"view epic →"}),a.runId&&t.jsx("button",{type:"button",onClick:()=>l(!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(q.fromOutcome).catch(()=>q.error("Failed to adopt PRD"))},className:`${u} text-accent hover:text-accent/80`,children:"adopt PRD →"}),a.status!=="pending"&&a.status!=="running"&&a.status!=="quarantined"&&t.jsx("button",{type:"button",onClick:()=>window.api.schedule.resetJob(a.slug,a.cwd??void 0),className:`${u} text-fg-dim hover:text-fg`,children:"reset to pending →"}),a.disposition&&(a.status==="pending"||a.status==="quarantined")&&t.jsx(Zt,{job:a,headChoices:n})]}),c&&a.runId&&t.jsx(qe,{runId:a.runId,slug:a.slug,title:a.title||a.slug,onClose:()=>l(!1)})]})}const ce=190,Mn=7,In=5,En=[],ts=e=>e==="completed"||e==="skipped",ss=e=>e==="running"||e==="investigating",ns=e=>e==="failed"||e==="needs_review"||e==="quarantined";function Re(e){return ss(e.status)?0:ns(e.status)?1:ts(e.status)?3:2}const Tn={done:"text-sage",running:"text-accent",held:"text-fg-faint",pending:"text-fg-faint",blocked:"text-butter"},_n={done:"bg-sage",running:"bg-accent",held:"bg-fg-faint/50",pending:"bg-fg-faint/50",blocked:"bg-butter"};function On(e,s){return e.every(n=>ts(n.status))?`+${e.length} done`:e.every(n=>n.rowKind==="dep"&&n.blockers.some(a=>!a.missing&&a.status!==null&&ns(a.status)))?`+${e.length} blocked`:`+${e.length} in stage ${s}`}function Ln({stage:e,epicId:s,now:n,hidden:a,indexBySlug:c,headChoicesBySlug:l,onRowFocused:i}){const[r,d]=f.useState(!1),o=f.useMemo(()=>e.rows.filter(m=>!(a.has(m.slug)&&(m.status==="completed"||m.status==="failed"))).map((m,R)=>({r:m,i:R})).sort((m,R)=>Re(m.r)-Re(R.r)||m.i-R.i).map(m=>m.r),[e.rows,a]),p=f.useMemo(()=>o.filter(m=>Re(m)<=1).length,[o]),u=Math.max(e.state==="done"?In:Mn,p),h=r?o:o.slice(0,u),g=r?[]:o.slice(u),x=o.find(m=>m.status==="failed"),v=o.find(m=>m.status==="needs_review"),y=p>0&&(x!==void 0||v!==void 0),k=h.reduce((m,R,P)=>Re(R)<=1?P:m,-1),S=m=>t.jsx(es,{row:m,elapsedMs:ss(m.status)&&m.job.startedAt?n-Date.parse(m.job.startedAt):null,listIndex:c.get(m.slug)??0,onFocused:i,headChoices:l.get(m.slug)??En},m.slug),_="flex-1 min-w-0 truncate h-[24px] text-[11.5px] font-medium text-fg-dim hover:text-fg border border-rule-structural rounded-sm bg-transparent cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed";return t.jsxs("div",{"data-testid":"stage-column","data-stage":e.n,style:{width:ce},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 ${_n[e.state]}`}),t.jsxs("span",{className:`text-[10px] font-semibold uppercase tracking-wide ${Tn[e.state]}`,children:["Stage ",e.n]}),e.state==="blocked"&&t.jsx(me,{title:"Rows in this stage are failed / need review / are quarantined, or wait on one that is."}),t.jsx("span",{"data-testid":"stage-summary",className:"ml-auto font-mono text-[10.5px] text-fg-dim truncate",children:e.summary})]}),t.jsx("div",{role:"presentation",children:h.map((m,R)=>t.jsxs("div",{children:[S(m),y&&R===k&&t.jsxs("div",{"data-testid":"stage-attention-actions",className:"flex gap-1.5 px-2 py-1.5 border-t border-rule-inner",children:[x&&t.jsxs("button",{type:"button","data-testid":"stage-retry",title:`Reset ${x.slug} to pending`,onClick:()=>{window.api.schedule.resetJob(x.slug,x.job.cwd??void 0).then(P=>{P.ok||q.error(P.error??`Failed to reset ${x.slug}`)}).catch(()=>q.error(`Failed to reset ${x.slug}`))},className:_,children:["Retry ",x.prdNumber?`#${x.prdNumber}`:x.slug]}),v&&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&&Ot(s)},className:_,children:["Review ",v.prdNumber?`#${v.prdNumber}`:v.slug]})]})]},m.slug))}),(g.length>0||r&&o.length>u)&&t.jsx("button",{type:"button","data-testid":"stage-footer","aria-expanded":r,onClick:()=>d(m=>!m),className:"mt-auto h-[26px] border-t border-rule-inner font-mono text-[11px] text-fg-faint hover:text-fg-dim bg-transparent cursor-pointer",children:r?"show less ▴":`${On(g,e.n)} ▾`})]})}const we=6,Je=4,Ee=4,$t=12,Pt=5,as=2,Dt=4,Fn={done:"bg-sage",running:"bg-accent",attention:"bg-butter",failed:"bg-red-600",pending:"bg-fg-faint/50"};function qn(e){return e==="completed"||e==="skipped"?"done":e==="running"||e==="investigating"?"running":e==="failed"?"failed":e==="needs_review"||e==="quarantined"?"attention":"pending"}function Bn(e){const s=[],n=[],a=[];let c=Pt;for(const l of e){const i=Math.max(1,Math.ceil(l.rows.length/Ee));n.push(c),a.push(i*we),l.rows.forEach((r,d)=>{s.push({x:c+Math.floor(d/Ee)*we,y:as+d%Ee*we,tone:qn(r.status),title:`${r.prdNumber?`#${r.prdNumber}`:r.slug} ${r.title} — ${r.status}`})}),c+=i*we+$t}return{dots:s,stageX:n,stageW:a,width:Math.max(0,c-$t)+Pt}}function ve(e,s){return e.findIndex(n=>n.rows.some(a=>s(a.status)))}const tt=e=>e==="running"||e==="investigating",st=e=>e==="failed"||e==="needs_review"||e==="quarantined";function Hn({stages:e,first:s,perView:n,onSeek:a}){const c=f.useMemo(()=>Bn(e),[e]),l=f.useMemo(()=>ve(e,tt)>=0,[e]),i=f.useMemo(()=>ve(e,st)>=0,[e]),r=f.useRef(!1),d=e.length,o=Math.min(d-1,s+n-1),p=c.stageX[Math.min(s,d-1)]??0,u=(c.stageX[o]??0)+(c.stageW[o]??0),h=x=>{const v=x.currentTarget.getBoundingClientRect(),y=x.clientX-v.left;let k=0;for(let S=0;S<d;S++)c.stageX[S]<=y&&(k=S);a(Math.max(0,Math.min(d-1,k-Math.floor(n/2))))},g="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(me,{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:Ee*we-(we-Je)+2*as},onPointerDown:x=>{var v,y;r.current=!0,(y=(v=x.currentTarget).setPointerCapture)==null||y.call(v,x.pointerId),h(x)},onPointerMove:x=>{r.current&&h(x)},onPointerUp:()=>{r.current=!1},onPointerCancel:()=>{r.current=!1},children:[c.dots.map((x,v)=>t.jsx("span",{title:x.title,"data-tone":x.tone,className:`absolute rounded-[1px] ${Fn[x.tone]}`,style:{left:x.x,top:x.y,width:Je,height:Je}},v)),t.jsx("span",{"data-testid":"plan-minimap-brush","aria-hidden":"true",className:"absolute top-0 bottom-0 border border-accent bg-accent/10 rounded-[2px] pointer-events-none",style:{left:p-Dt,width:u-p+2*Dt}})]}),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),"–",o+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:!l,title:l?"Scroll to the lowest stage with a running PRD":"No stage has a running PRD",onClick:()=>a(ve(e,tt)),className:`${g} text-fg-dim hover:text-fg`,children:"Running"}),t.jsx("button",{type:"button","data-testid":"minimap-blockers",disabled:!i,title:i?"Scroll to the lowest stage with a failed / needs-review / quarantined PRD":"No stage has a failed, needs-review or quarantined PRD",onClick:()=>a(ve(e,st)),className:`${g} text-fg-dim hover:text-fg border-l border-line`,children:"Blockers"})]})]})}const Gn=148;function Vn({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:Gn},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(me,{title:"Stages beyond the visible window. Click one to scroll the stage columns to it."})]}),e.map(c=>{const l=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:`${l}%`}})})]},c.n)})]})}const Wn=[],Un=e=>e==="running"||e==="investigating";function zn(e){const s=dn(e),n=new Map,a=new Map;for(const r of e.stages){a.set(r.n,r.rows.length);for(const d of r.rows)n.set(d.slug,d)}const c=new Map;let l=0;const i=[];for(const r of s){const d=n.get(r);l+=d.estimateMinutes??0,c.set(d.stage,(c.get(d.stage)??0)+1),i.push({row:d,totalMinutes:l,othersInStage:0})}for(const r of i)r.othersInStage=(a.get(r.row.stage)??0)-(c.get(r.row.stage)??0);return i}function Qn({plan:e,now:s,indexBySlug:n,headChoicesBySlug:a,onRowFocused:c}){const l=f.useMemo(()=>zn(e),[e]);return t.jsx("div",{"data-testid":"critical-path",className:"border-t border-rule-structural max-w-[640px]",children:l.map(({row:i,totalMinutes:r,othersInStage:d})=>t.jsxs("div",{"data-testid":"critical-entry","data-slug":i.slug,children:[t.jsxs("div",{className:"flex items-start",children:[t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx(es,{row:i,elapsedMs:Un(i.status)&&i.job.startedAt?s-Date.parse(i.job.startedAt):null,listIndex:n.get(i.slug)??0,onFocused:c,headChoices:a.get(i.slug)??Wn})}),t.jsxs("span",{"data-testid":"critical-est",className:"shrink-0 h-[31px] px-3 flex items-center gap-2 font-mono text-[11.5px] text-fg-faint border-t border-rule-inner",children:[t.jsx("span",{title:"estimateMinutes",children:i.estimateMinutes?`${i.estimateMinutes}m`:"—"}),t.jsxs("span",{className:"text-fg-dim",title:"Running total along the chain",children:["Σ ",r,"m"]})]})]}),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 ",i.stage," · +",d," not on the critical path"]})]},i.slug))})}const At=1,Rt=1350,Jn={active:"border-l-accent",queued:"border-l-rule-structural",done:"border-l-sage",draft:"border-l-fg-faint/40 border-dashed"},Yn={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"}},Kn=e=>String(e).padStart(2,"0");function Xn({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 Zn({plan:e,mode:s="graph",now:n,hidden:a,indexBySlug:c,headChoicesBySlug:l,onRowFocused:i,onOpenPrds:r}){var se,Y;const[d,o]=f.useState(e.status==="active"||e.status==="queued"),[p,u]=f.useState(!1),h=f.useRef(null),[g,x]=f.useState(0),[v,y]=f.useState(Rt),k=f.useMemo(()=>{const M=ve(e.stages,tt);return M>=0?M:Math.max(0,ve(e.stages,st))},[e.stages]);f.useLayoutEffect(()=>{if(!d)return;const M=h.current,L=(M==null?void 0:M.clientWidth)||Rt,N=Math.max(0,Math.min(k,e.stageCount-Math.max(1,Math.ceil(L/ce))));M!=null&&M.clientWidth&&y(M.clientWidth),M&&(M.scrollLeft=N*ce),x(N)},[d]);const S=f.useMemo(()=>{let M=null;for(const L of e.stages)for(const N of L.rows){if(!N.job.runId)continue;const C=N.job.finishedAt?Date.parse(N.job.finishedAt):0;(!M||C>M.at)&&(M={runId:N.job.runId,slug:N.slug,title:N.title,at:C})}return M},[e.stages]),_=_e((Y=(se=e.stages[0])==null?void 0:se.rows[0])==null?void 0:Y.job.cwd)??"—",m=Yn[e.status],R=Math.max(1,Math.ceil(v/ce)),P=Math.max(0,Math.min(g-At,e.stageCount)),D=Math.min(e.stageCount,g+R+At),O=M=>{const L=Math.max(0,Math.min(e.stageCount-1,M));h.current&&(h.current.scrollLeft=L*ce),x(L)},K=Math.min(e.stageCount,g+R),z=M=>{const L=M.currentTarget,N=Math.floor(L.scrollLeft/ce);N!==g&&x(N),L.clientWidth&&L.clientWidth!==v&&y(L.clientWidth)},Q="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",X=(()=>{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(()=>q.error("Failed to pause the scheduler"))},className:Q,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(q.fromOutcome).catch(()=>q.error("Failed to fire the next batch"))},className:Q,children:"Run now"});case"done":return t.jsx("button",{type:"button","data-testid":"plan-action",disabled:!S,title:S?`Open the run log of ${S.slug}, the plan's last run`:"No run log recorded for this plan",onClick:()=>u(!0),className:Q,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 M,L;return r==null?void 0:r(((L=(M=e.stages[0])==null?void 0:M.rows[0])==null?void 0:L.slug)??null)},className:Q,children:"Schedule…"})}})(),Z=e.etaMs>0?` · ${zt(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] ${Jn[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:()=>o(M=>!M),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:Kn(e.index)}),t.jsx("span",{className:"font-serif text-[15px] font-bold text-fg truncate shrink-0 max-w-[320px]",title:e.epicLabel!==e.label?`${e.label} — ${e.epicLabel}`:e.label,"data-testid":"plan-label",children:e.label}),t.jsx("span",{"data-testid":"plan-chip",className:`shrink-0 rounded-sm px-1.5 py-[1px] text-[10px] font-bold tracking-wide ${m.cls}`,children:m.label}),t.jsx("span",{"aria-hidden":"true",className:"shrink-0 w-px h-[16px] bg-rule-structural"}),t.jsx("span",{className:"font-mono text-[11.5px] text-fg-faint truncate min-w-0","data-testid":"plan-meta",children:e.validateSlug!=null&&e.epicLabel!==e.label?t.jsxs(t.Fragment,{children:[_," · ",e.epicLabel," · ",e.prdCount," PRD",e.prdCount===1?"":"s"," · ",e.width," wide · ",e.stageCount," stage",e.stageCount===1?"":"s"]}):t.jsxs(t.Fragment,{children:[_," · ",e.prdCount," PRD",e.prdCount===1?"":"s",e.width>1?` · ${e.width} wide`:""," · ",e.stageCount," stage",e.stageCount===1?"":"s"]})}),t.jsx(me,{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,Z]}),t.jsx(Xn,{plan:e}),X]}),d&&s==="critical"&&t.jsx(Qn,{plan:e,now:n,indexBySlug:c,headChoicesBySlug:l,onRowFocused:i}),d&&s!=="critical"&&e.status==="active"&&t.jsx(Hn,{stages:e.stages,first:g,perView:R,onSeek:O}),d&&s!=="critical"&&t.jsxs("div",{className:"flex border-t border-rule-structural",children:[t.jsxs("div",{ref:h,"data-testid":"plan-stages",onScroll:z,className:"flex flex-1 min-w-0 overflow-x-auto",children:[P>0&&t.jsx("div",{"aria-hidden":"true",className:"shrink-0",style:{width:P*ce}}),e.stages.slice(P,D).map(M=>t.jsx(Ln,{stage:M,epicId:e.epicId,now:n,hidden:a,indexBySlug:c,headChoicesBySlug:l,onRowFocused:i},M.n)),D<e.stageCount&&t.jsx("div",{"aria-hidden":"true",className:"shrink-0",style:{width:(e.stageCount-D)*ce}})]}),t.jsx(Vn,{stages:e.stages.slice(K),onSeek:O})]}),p&&S&&t.jsx(qe,{runId:S.runId,slug:S.slug,title:S.title||S.slug,onClose:()=>u(!1)})]})}function ea({section:e,children:s}){const[n,a]=f.useState(!0),c=Object.entries(e.counts).map(([l,i])=>`${i} ${l.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(l=>!l),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(at,{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 ta=[],sa=[],na={depth:0,blockers:ta,blocked:!1,hasNeedsReviewBlocker:!1,hasMissingDep:!1,cycle:!1,parallelEligible:!1};function aa(e){return e.missing?`${e.slug} (missing)`:e.needsReview?`${e.slug} (needs review)`:`${e.slug} (${(e.status??"unknown").replace(/_/g," ")})`}function ra(e){return e.missing?"text-accent":e.needsReview?"text-butter font-semibold":e.status==="completed"?"text-sage":"text-amber-400/90"}function ia({job:e,eta:s,elapsedMs:n,avgDurationMs:a,listIndex:c,onFocused:l,hold:i,backlog:r=na,headChoices:d=sa}){const[o,p]=f.useState(!1),[u,h]=f.useState(!1),g=pe(D=>D.sessions),x=f.useMemo(()=>Pe(e,g),[e,g]),v=x.known&&x.epicId?g[x.epicId]:null,y=f.useCallback(D=>{rt(D),window.dispatchEvent(new CustomEvent("sm:navigate",{detail:"terminal"}))},[]),k=e.status==="running",S=e.status==="failed";let _=null;k&&n!==null?_=`${Te(n)} elapsed`:e.status==="completed"&&e.startedAt&&e.finishedAt?_=`took ${Ce(Date.parse(e.finishedAt)-Date.parse(e.startedAt))}`:s&&(_=s);const m=e.error??null,R=S&&m?m.split(`
|
|
4
4
|
`)[0]:e.status==="needs_review"&&e.verifierVerdict?$e(e.verifierVerdict):null,P=k&&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":r.depth,onClick:()=>p(D=>!D),onFocus:()=>l(c),style:r.depth>0?{paddingLeft:18+r.depth*20}:void 0,className:`w-full text-left grid grid-cols-[116px_1fr_auto_auto] items-center gap-4 px-[18px] py-3.5 hover:bg-bg/40 focus:outline-none focus:ring-1 focus:ring-accent focus:ring-inset ${o?"bg-bg-elev/40":""}`,"aria-expanded":o,"aria-label":`${ie(e.slug)?`PRD ${ie(e.slug)}, `:""}${e.title}, ${e.status}${_?`, ${_}`:""}`,title:e.title,children:[t.jsx(Lt,{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:[ie(e.slug)&&t.jsx(Ft,{n:ie(e.slug)}),e.title,t.jsx(qt,{leaked:e.leakedDescendants}),t.jsx(Ss,{count:e.leftoverCount,truncated:e.leftoverPathsTruncated,salvagePatch:e.salvagePatch}),r.parallelEligible&&t.jsx("span",{"data-testid":"job-row-parallel-eligible",title:"No dependsOn, and nothing in this Epic depends on it — can run any time a slot is free",className:"text-[10px] font-semibold uppercase tracking-wide text-sage/90 bg-sage/10 border border-sage/30 rounded px-1.5 py-0.5",children:"parallel"})]}),r.cycle&&t.jsxs("div",{className:"text-[12.5px] mt-0.5 text-accent font-mono","data-testid":"job-row-cycle-warning",children:["⚠ dependsOn cycle — ",r.blockers.map(D=>D.slug).join(" ↔ ")||"self-referencing"]}),!r.cycle&&r.blockers.length>0&&t.jsxs("div",{className:"text-[12.5px] mt-0.5 font-mono","data-testid":"job-row-blockers",children:[t.jsx("span",{className:r.blocked||r.hasMissingDep?"text-amber-400/90":"text-fg-faint",children:r.blocked||r.hasMissingDep?"blocked by ":"depends on "}),r.blockers.map((D,O)=>t.jsxs("span",{className:ra(D),children:[O>0&&", ",aa(D)]},D.slug))]}),R&&t.jsx("div",{className:`text-[12.5px] mt-0.5 ${S?"text-accent/80":"text-fg-faint"}`,children:R}),i&&t.jsx("div",{className:"text-[12.5px] mt-0.5 text-amber-400/90 font-mono","data-testid":"job-row-hold",children:i.dep?t.jsxs(t.Fragment,{children:["held · waiting on ",i.dep," (",i.depStatus,")"]}):t.jsxs(t.Fragment,{children:["held · ",i.reason??"launch blocked"]})}),!i&&e.status==="pending"&&e.heldReason&&t.jsxs("div",{className:"text-[12.5px] mt-0.5 text-amber-400/90 font-mono","data-testid":"job-row-held-reason",children:["held · ",e.heldReason]}),t.jsx(it,{epicId:x.epicId,label:x.label?Kt(x.label):null,onOpen:y,testId:"job-row-prompt-session-chip",className:"mt-0.5"})]}),t.jsx(lt,{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(Cs,{status:e.status,overrun:e.overrun}),_,t.jsx("span",{className:`text-fg-faint inline-flex transition-transform duration-150 ${o?"rotate-90":""}`,"aria-hidden":"true",children:t.jsx(at,{name:"chevron",size:14})})]})]}),k&&!o&&t.jsx("div",{className:"h-1 bg-line mx-[18px] mb-3 rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full bg-accent transition-all duration-1000",style:{width:`${Math.max(4,P*100)}%`}})}),o&&t.jsxs("div",{className:"px-[18px] py-5 grid grid-cols-[repeat(auto-fit,minmax(160px,1fr))] gap-5 bg-bg-elev/50 border-t border-line",children:[t.jsxs(re,{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:$e(e.verifierVerdict)}),e.leakedDescendants&&e.leakedDescendants.length>0&&t.jsx(B,{k:"leaked",v:Bt(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}),m&&t.jsx(B,{k:"error",v:m.split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{al as i,S as d}from"./index-
|
|
1
|
+
import{al as i,S as d}from"./index-DzY_GXYY.js";function a({scopes:l,active:n,onChange:o,annotate:s}){return i.jsx("div",{className:"inline-flex rounded border border-line overflow-hidden",children:l.map(t=>{const r=d[t],e=s==null?void 0:s(t),c=t===n;return i.jsxs("button",{title:r.hint,onClick:()=>o(t),className:`px-2.5 py-1 text-xs flex items-center gap-1.5 transition-colors ${c?"bg-bg-hi text-fg":"bg-bg-elev text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[i.jsx("span",{children:r.label}),(e==null?void 0:e.dirty)&&i.jsx("span",{className:"w-1 h-1 rounded-full bg-accent",title:"unsaved edits"}),e&&e.exists===!1&&!e.dirty&&i.jsx("span",{className:"w-1 h-1 rounded-full bg-fg-faint",title:"not yet created"})]},t)})})}export{a as S};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{aB as l,al as e,S as T,A as B,m as G,W as Ee,a1 as Re,aT as ue,bb as Q,a as q,aV as Ae,b6 as Te,b3 as Pe,aY as Ie,c as ne,az as De,b0 as Oe,ba as ae,b2 as Le,aW as W,an as Me,as as $e,J as Fe,H as re,aK as Be}from"./index-DgPUERhe.js";import{P as _e}from"./Panel-D64i9tGz.js";import{S as Ue}from"./ScopeSwitcher-BmWA_dP9.js";import{S as me}from"./SaveBar-D0Y2t-Ao.js";import{u as He,s as ie,E as Ge}from"./settingsSchema-6doG_61l.js";import{V as Je}from"./ViewTabs-CoYPKGN-.js";import{T as J}from"./Toggle-Dw8-zNQo.js";import"./monaco-editor-BsIlgG7c.js";import"./claude-settings-schema-COigsajx.js";const Ke=[{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"]}],We={mcp:"MCP",url:"URL",urls:"URLs",http:"HTTP",ui:"UI",id:"ID",uuid:"UUID",api:"API",aws:"AWS",otel:"OTel",json:"JSON"};function fe(t){return t.replace(/^\$/,"").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").toLowerCase().split(/\s+/).filter(Boolean).map((i,r)=>{const a=We[i];return a||(r===0?i.charAt(0).toUpperCase()+i.slice(1):i)}).join(" ")}function he(t){const s=new Set,n=[];for(const r of Ke){const a=r.keys.filter(c=>t.has(c));a.forEach(c=>s.add(c)),a.length!==0&&n.push({id:r.id,title:r.title,summary:r.summary,advanced:!!r.advanced,keys:a})}const i=Array.from(t).filter(r=>!s.has(r)&&r!=="$schema").sort();return i.length>0&&n.push({id:"other",title:"Other",summary:"Keys not yet grouped.",advanced:!1,keys:i}),n}function ze(t,s){return he(t).map(n=>({id:n.id,title:n.title,advanced:n.advanced,total:n.keys.length,setCount:n.keys.filter(i=>s.has(i)).length}))}const Ve={};function ge(t,s){if(s)return{text:s,authored:!1};const n=Ve[t];return n?{text:n,authored:!0}:null}const qe={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"},Xe=["user","project","local","default"],Ye={user:"user",project:"project",local:"local",default:"default"};function Ze({node:t,targetScope:s,onOverride:n,schema:i}){const[r,a]=l.useState(""),[c,x]=l.useState(!1),[f,y]=l.useState(!0),u=t.kind==="object"?t:null,S=u?Object.keys(u.children):[],o=i.rootKeys(),v=new Set([...S,...o]),p=l.useMemo(()=>he(v),[Array.from(v).sort().join(",")]),w=l.useMemo(()=>ze(v,new Set(S)),[Array.from(v).sort().join(","),S.join(",")]),[C,A]=l.useState(null),g=l.useRef(null),E=m=>{const N=p.find(h=>h.id===m);N!=null&&N.advanced&&!c&&x(!0),A(m)};l.useEffect(()=>{if(!C)return;A(null);const m=g.current,N=document.getElementById(`settings-group-${C}`);if(!m||!N)return;const h=N.getBoundingClientRect().top-m.getBoundingClientRect().top;m.scrollBy({top:h,behavior:"smooth"})},[C]);const R=l.useMemo(()=>p.filter(m=>c||!m.advanced).map(m=>({...m,keys:m.keys.filter(N=>{const h=(u==null?void 0:u.children[N])!==void 0;if(!f&&!h)return!1;if(!r.trim())return!0;const k=i.at([N]);return[N,fe(N),(k==null?void 0:k.description)??""].join(" ").toLowerCase().includes(r.toLowerCase())})})).filter(m=>m.keys.length>0),[p,r,c,f,u,i]);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:T[s].label})]}),e.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:f,onChange:m=>y(m.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:c,onChange:m=>x(m.target.checked),className:"accent-accent"}),"show advanced"]}),e.jsx("div",{className:"flex-1"}),e.jsx("input",{value:r,onChange:m=>a(m.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(Qe,{groups:w,onJump:E}),e.jsxs("div",{ref:g,className:"flex-1 overflow-auto py-3",children:[R.map(m=>e.jsx(et,{id:m.id,title:m.title,summary:m.summary,advanced:m.advanced,children:m.keys.map(N=>{const h=u==null?void 0:u.children[N],k=i.at([N]);return e.jsx(tt,{keyName:N,node:h,info:k,targetScope:s,onOverride:(b,O)=>n([N],b,O)},N)})},m.id)),R.length===0&&e.jsxs("div",{className:"px-6 py-12 text-center text-fg-faint text-sm",children:['no settings match "',r,'"']})]})]})]})}function Qe({groups:t,onJump:s}){return e.jsx("nav",{className:"shrink-0 w-48 border-r border-line bg-bg-elev/30 overflow-y-auto py-3",children:t.map(n=>e.jsxs("button",{onClick:()=>s(n.id),className:"w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-bg-hi transition-colors",title:`jump to ${n.title}`,children:[e.jsx(B,{name:qe[n.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:n.title}),e.jsxs("span",{className:"text-[10px] text-fg-faint font-mono shrink-0",children:[n.setCount,"/",n.total]})]},n.id))})}function et({id:t,title:s,summary:n,advanced:i,children:r}){const[a,c]=l.useState(!0);return e.jsxs("section",{id:`settings-group-${t}`,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:()=>c(!a),children:[e.jsx("span",{className:"text-fg-faint w-3",children:a?"▾":"▸"}),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:s}),i&&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:n})]})]}),a&&e.jsx("div",{className:"divide-y divide-line/60",children:r})]})}function tt({keyName:t,node:s,info:n,targetScope:i,onOverride:r}){const[a,c]=l.useState(!1),[x,f]=l.useState(!1),y=fe(t),u=s!==void 0,o=(s==null?void 0:s.kind)==="leaf"?s:null,v=(s==null?void 0:s.kind)==="object"||(s==null?void 0:s.kind)==="array",p=n==null?void 0:n.default,w=o&&p!==void 0&&ve(o.value,p),C=ct({isSet:u,leafNode:o,defaultVal:p,isDefault:!!w,node:s}),A=st(o,p),g=A.length>=2,E=!!o&&!w,R=ge(t,n==null?void 0:n.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:()=>c(!a),className:"text-fg-faint hover:text-fg w-3 mt-0.5",title:a?"collapse":"expand",children:a?"▾":"▸"}),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:y}),e.jsx(dt,{kind:C.kind,label:C.label}),g&&e.jsxs("button",{onClick:m=>{m.stopPropagation(),a||c(!0),f(N=>!N)},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 · ",A.map(m=>Ye[m]).join(" · ")]}),E&&o&&e.jsx("button",{onClick:m=>{m.stopPropagation(),r(void 0,o.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 ${T[o.winner].label}`,children:"↺ reset"}),(n==null?void 0:n.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"}),(n==null?void 0:n.required)&&!u&&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"})]}),R&&e.jsx("p",{className:`text-fg-dim text-xs mt-0.5 leading-relaxed ${R.authored?"inline-block border-b border-dotted border-fg-faint/70 cursor-help":""}`,title:R.authored?"In-app-authored description — not from the official Claude Code schema":void 0,children:xt(R.text)}),a&&x&&o&&e.jsx(nt,{leaf:o,defaultVal:p,onReset:m=>r(void 0,m)}),a&&e.jsx(at,{keyName:t,node:s,info:n,targetScope:i,onOverride:m=>r(m)})]}),e.jsx("div",{className:"shrink-0",children:!a&&e.jsx(ot,{node:s,info:n,onSet:m=>{r(m)},disabled:v&&u})})]})})}function st(t,s){if(!t)return[];const n=new Set;n.add(t.winner);for(const i of t.shadowed)n.add(i.scope);return s!==void 0&&n.add("default"),Xe.filter(i=>n.has(i))}function nt({leaf:t,defaultVal:s,onReset:n}){const i={};i[t.winner]={value:t.value,winner:!0};for(const r of t.shadowed)i[r.scope]={value:r.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(r=>{const a=i[r],c=a!==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:T[r].label}),e.jsx("span",{className:`font-mono truncate ${a!=null&&a.winner?"text-accent":"text-fg-dim"}`,children:c?F(a.value):e.jsx("span",{className:"text-fg-faint",children:"—"})}),c?e.jsx("button",{onClick:()=>n(r),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 ${T[r].label}`,children:"↺"}):e.jsx("span",{})]},r)}),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:s!==void 0?F(s):e.jsx("span",{className:"text-fg-faint",children:"—"})}),e.jsx("span",{})]})]})]})}function at({keyName:t,node:s,info:n,targetScope:i,onOverride:r}){const c=(s==null?void 0:s.kind)==="leaf"?s:null,x=ge(t,n==null?void 0:n.description);return e.jsxs("div",{className:"mt-3 space-y-2 text-xs",children:[x&&e.jsx("p",{className:`text-fg-dim leading-relaxed whitespace-pre-wrap ${x.authored?"inline-block border-b border-dotted border-fg-faint/70 cursor-help":""}`,title:x.authored?"In-app-authored description — not from the official Claude Code schema":void 0,children:x.text}),e.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-fg-faint",children:[(n==null?void 0:n.type)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Type"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:Array.isArray(n.type)?n.type.join(" | "):n.type})]}),(n==null?void 0:n.default)!==void 0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Default"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:F(n.default)})]}),(n==null?void 0:n.enum)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Options"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:n.enum.map(f=>String(f)).join(" | ")})]}),c&&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:F(c.value)}),e.jsxs("span",{className:"ml-2 text-fg-faint",children:["from ",T[c.winner].label]})]})]}),c&&c.shadowed.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Shadowed"}),e.jsx("dd",{className:"space-y-0.5",children:c.shadowed.map((f,y)=>e.jsxs("div",{className:"font-mono text-fg-faint line-through",children:[F(f.value)," —"," ",e.jsx("span",{className:"no-underline",children:T[f.scope].label})]},y))})]}),(s==null?void 0:s.kind)==="array"&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Accumulated"}),e.jsxs("dd",{className:"text-fg-dim",children:[s.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(rt,{keyName:t,node:s,info:n,onChange:r,targetScope:i})})]})}function rt({node:t,info:s,onChange:n,targetScope:i}){const a=(t==null?void 0:t.kind)==="leaf"?t.value:s==null?void 0:s.default,c=be(s==null?void 0:s.type);if(c==="boolean"){const x=a===!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:f,label:y})=>e.jsx("button",{onClick:()=>n(f),className:`px-3 py-0.5 text-xs transition-colors ${x===f?"bg-accent text-bg":"bg-bg-elev text-fg-dim hover:bg-bg-hi hover:text-fg"}`,children:y},y))}),e.jsxs("span",{className:"text-fg-faint",children:["→ ",T[i].label]})]})}return s!=null&&s.enum?e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-fg-faint",children:"Choose:"}),s.enum.map(x=>{const f=ve(a,x);return e.jsx("button",{onClick:()=>n(x),className:`px-2 py-0.5 text-xs rounded border ${f?"bg-accent text-bg border-accent":"bg-bg-elev text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,children:String(x)},String(x))}),e.jsxs("span",{className:"text-fg-faint",children:["→ ",T[i].label]})]}):c==="integer"||c==="number"?e.jsx(it,{value:typeof a=="number"?a:void 0,integer:c==="integer",onCommit:n,target:T[i].label}):c==="string"?e.jsx(lt,{value:typeof a=="string"?a:"",onCommit:n,target:T[i].label}):e.jsxs("div",{className:"text-fg-faint",children:["Complex value (",c??"object/array",") — use the"," ",e.jsx("span",{className:"text-fg-dim",children:"Raw"})," tab to edit."]})}function it({value:t,integer:s,onCommit:n,target:i}){const[r,a]=l.useState(t!==void 0?String(t):""),c=()=>{const x=s?parseInt(r,10):parseFloat(r);Number.isNaN(x)||n(x)};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:r,onChange:x=>a(x.target.value),onBlur:c,onKeyDown:x=>{x.key==="Enter"&&x.target.blur()},className:"w-24 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),e.jsxs("button",{onClick:c,className:"px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",i]})]})}function lt({value:t,onCommit:s,target:n}){const[i,r]=l.useState(t);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:i,onChange:a=>r(a.target.value),onKeyDown:a=>{a.key==="Enter"&&s(i)},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:()=>s(i),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 → ",n]})]})}function ot({node:t,info:s,onSet:n,disabled:i}){const r=(t==null?void 0:t.kind)==="leaf",a=be(s==null?void 0:s.type);if(i)return null;if(a==="boolean"){const c=r&&t.value===!0;return e.jsx("button",{onClick:()=>n(!c),className:`px-2.5 py-0.5 text-xs rounded border transition-colors ${c?"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:c?"on":"off"})}return null}function ct({isSet:t,leafNode:s,defaultVal:n,isDefault:i,node:r}){return t?(r==null?void 0:r.kind)==="array"?{kind:"accumulated",label:`${r.items.length} items`}:(r==null?void 0:r.kind)==="object"?{kind:"set",label:"configured"}:s?i?{kind:"default",label:`= default · ${T[s.winner].label}`}:s.shadowed.length>0?{kind:"override",label:`overriding ${s.shadowed.length} scope(s)`}:{kind:"set",label:`set in ${T[s.winner].label}`}:{kind:"set",label:"configured"}:n!==void 0?{kind:"default",label:`using default: ${F(n)}`}:{kind:"unset",label:"not configured"}}function dt({kind:t,label:s}){const n={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"}[t];return e.jsx("span",{className:`text-[9px] px-1.5 py-0 rounded border uppercase tracking-wide ${n}`,children:s})}function be(t){if(t)return Array.isArray(t)?t.find(n=>n!=="null")??t[0]:t}function ve(t,s){return t===s?!0:typeof t!=typeof s?!1:t&&s&&typeof t=="object"?JSON.stringify(t)===JSON.stringify(s):!1}function xt(t){const s=t.trim().split(`
|
|
1
|
+
import{aB as l,al as e,S as T,A as B,m as G,W as Ee,a1 as Re,aT as ue,bb as Q,a as q,aV as Ae,b6 as Te,b3 as Pe,aY as Ie,c as ne,az as De,b0 as Oe,ba as ae,b2 as Le,aW as W,an as Me,as as $e,J as Fe,H as re,aK as Be}from"./index-DzY_GXYY.js";import{P as _e}from"./Panel-DZHiD8Ar.js";import{S as Ue}from"./ScopeSwitcher-s8J-yr7Z.js";import{S as me}from"./SaveBar-mVKig6hL.js";import{u as He,s as ie,E as Ge}from"./settingsSchema-bSBfHuan.js";import{V as Je}from"./ViewTabs-Cs4v7vLY.js";import{T as J}from"./Toggle-C-oD66BG.js";import"./monaco-editor-BsIlgG7c.js";import"./claude-settings-schema-COigsajx.js";const Ke=[{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"]}],We={mcp:"MCP",url:"URL",urls:"URLs",http:"HTTP",ui:"UI",id:"ID",uuid:"UUID",api:"API",aws:"AWS",otel:"OTel",json:"JSON"};function fe(t){return t.replace(/^\$/,"").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").toLowerCase().split(/\s+/).filter(Boolean).map((i,r)=>{const a=We[i];return a||(r===0?i.charAt(0).toUpperCase()+i.slice(1):i)}).join(" ")}function he(t){const s=new Set,n=[];for(const r of Ke){const a=r.keys.filter(c=>t.has(c));a.forEach(c=>s.add(c)),a.length!==0&&n.push({id:r.id,title:r.title,summary:r.summary,advanced:!!r.advanced,keys:a})}const i=Array.from(t).filter(r=>!s.has(r)&&r!=="$schema").sort();return i.length>0&&n.push({id:"other",title:"Other",summary:"Keys not yet grouped.",advanced:!1,keys:i}),n}function ze(t,s){return he(t).map(n=>({id:n.id,title:n.title,advanced:n.advanced,total:n.keys.length,setCount:n.keys.filter(i=>s.has(i)).length}))}const Ve={};function ge(t,s){if(s)return{text:s,authored:!1};const n=Ve[t];return n?{text:n,authored:!0}:null}const qe={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"},Xe=["user","project","local","default"],Ye={user:"user",project:"project",local:"local",default:"default"};function Ze({node:t,targetScope:s,onOverride:n,schema:i}){const[r,a]=l.useState(""),[c,x]=l.useState(!1),[f,y]=l.useState(!0),u=t.kind==="object"?t:null,S=u?Object.keys(u.children):[],o=i.rootKeys(),v=new Set([...S,...o]),p=l.useMemo(()=>he(v),[Array.from(v).sort().join(",")]),w=l.useMemo(()=>ze(v,new Set(S)),[Array.from(v).sort().join(","),S.join(",")]),[C,A]=l.useState(null),g=l.useRef(null),E=m=>{const N=p.find(h=>h.id===m);N!=null&&N.advanced&&!c&&x(!0),A(m)};l.useEffect(()=>{if(!C)return;A(null);const m=g.current,N=document.getElementById(`settings-group-${C}`);if(!m||!N)return;const h=N.getBoundingClientRect().top-m.getBoundingClientRect().top;m.scrollBy({top:h,behavior:"smooth"})},[C]);const R=l.useMemo(()=>p.filter(m=>c||!m.advanced).map(m=>({...m,keys:m.keys.filter(N=>{const h=(u==null?void 0:u.children[N])!==void 0;if(!f&&!h)return!1;if(!r.trim())return!0;const k=i.at([N]);return[N,fe(N),(k==null?void 0:k.description)??""].join(" ").toLowerCase().includes(r.toLowerCase())})})).filter(m=>m.keys.length>0),[p,r,c,f,u,i]);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:T[s].label})]}),e.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:f,onChange:m=>y(m.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:c,onChange:m=>x(m.target.checked),className:"accent-accent"}),"show advanced"]}),e.jsx("div",{className:"flex-1"}),e.jsx("input",{value:r,onChange:m=>a(m.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(Qe,{groups:w,onJump:E}),e.jsxs("div",{ref:g,className:"flex-1 overflow-auto py-3",children:[R.map(m=>e.jsx(et,{id:m.id,title:m.title,summary:m.summary,advanced:m.advanced,children:m.keys.map(N=>{const h=u==null?void 0:u.children[N],k=i.at([N]);return e.jsx(tt,{keyName:N,node:h,info:k,targetScope:s,onOverride:(b,O)=>n([N],b,O)},N)})},m.id)),R.length===0&&e.jsxs("div",{className:"px-6 py-12 text-center text-fg-faint text-sm",children:['no settings match "',r,'"']})]})]})]})}function Qe({groups:t,onJump:s}){return e.jsx("nav",{className:"shrink-0 w-48 border-r border-line bg-bg-elev/30 overflow-y-auto py-3",children:t.map(n=>e.jsxs("button",{onClick:()=>s(n.id),className:"w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-bg-hi transition-colors",title:`jump to ${n.title}`,children:[e.jsx(B,{name:qe[n.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:n.title}),e.jsxs("span",{className:"text-[10px] text-fg-faint font-mono shrink-0",children:[n.setCount,"/",n.total]})]},n.id))})}function et({id:t,title:s,summary:n,advanced:i,children:r}){const[a,c]=l.useState(!0);return e.jsxs("section",{id:`settings-group-${t}`,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:()=>c(!a),children:[e.jsx("span",{className:"text-fg-faint w-3",children:a?"▾":"▸"}),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:s}),i&&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:n})]})]}),a&&e.jsx("div",{className:"divide-y divide-line/60",children:r})]})}function tt({keyName:t,node:s,info:n,targetScope:i,onOverride:r}){const[a,c]=l.useState(!1),[x,f]=l.useState(!1),y=fe(t),u=s!==void 0,o=(s==null?void 0:s.kind)==="leaf"?s:null,v=(s==null?void 0:s.kind)==="object"||(s==null?void 0:s.kind)==="array",p=n==null?void 0:n.default,w=o&&p!==void 0&&ve(o.value,p),C=ct({isSet:u,leafNode:o,defaultVal:p,isDefault:!!w,node:s}),A=st(o,p),g=A.length>=2,E=!!o&&!w,R=ge(t,n==null?void 0:n.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:()=>c(!a),className:"text-fg-faint hover:text-fg w-3 mt-0.5",title:a?"collapse":"expand",children:a?"▾":"▸"}),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:y}),e.jsx(dt,{kind:C.kind,label:C.label}),g&&e.jsxs("button",{onClick:m=>{m.stopPropagation(),a||c(!0),f(N=>!N)},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 · ",A.map(m=>Ye[m]).join(" · ")]}),E&&o&&e.jsx("button",{onClick:m=>{m.stopPropagation(),r(void 0,o.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 ${T[o.winner].label}`,children:"↺ reset"}),(n==null?void 0:n.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"}),(n==null?void 0:n.required)&&!u&&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"})]}),R&&e.jsx("p",{className:`text-fg-dim text-xs mt-0.5 leading-relaxed ${R.authored?"inline-block border-b border-dotted border-fg-faint/70 cursor-help":""}`,title:R.authored?"In-app-authored description — not from the official Claude Code schema":void 0,children:xt(R.text)}),a&&x&&o&&e.jsx(nt,{leaf:o,defaultVal:p,onReset:m=>r(void 0,m)}),a&&e.jsx(at,{keyName:t,node:s,info:n,targetScope:i,onOverride:m=>r(m)})]}),e.jsx("div",{className:"shrink-0",children:!a&&e.jsx(ot,{node:s,info:n,onSet:m=>{r(m)},disabled:v&&u})})]})})}function st(t,s){if(!t)return[];const n=new Set;n.add(t.winner);for(const i of t.shadowed)n.add(i.scope);return s!==void 0&&n.add("default"),Xe.filter(i=>n.has(i))}function nt({leaf:t,defaultVal:s,onReset:n}){const i={};i[t.winner]={value:t.value,winner:!0};for(const r of t.shadowed)i[r.scope]={value:r.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(r=>{const a=i[r],c=a!==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:T[r].label}),e.jsx("span",{className:`font-mono truncate ${a!=null&&a.winner?"text-accent":"text-fg-dim"}`,children:c?F(a.value):e.jsx("span",{className:"text-fg-faint",children:"—"})}),c?e.jsx("button",{onClick:()=>n(r),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 ${T[r].label}`,children:"↺"}):e.jsx("span",{})]},r)}),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:s!==void 0?F(s):e.jsx("span",{className:"text-fg-faint",children:"—"})}),e.jsx("span",{})]})]})]})}function at({keyName:t,node:s,info:n,targetScope:i,onOverride:r}){const c=(s==null?void 0:s.kind)==="leaf"?s:null,x=ge(t,n==null?void 0:n.description);return e.jsxs("div",{className:"mt-3 space-y-2 text-xs",children:[x&&e.jsx("p",{className:`text-fg-dim leading-relaxed whitespace-pre-wrap ${x.authored?"inline-block border-b border-dotted border-fg-faint/70 cursor-help":""}`,title:x.authored?"In-app-authored description — not from the official Claude Code schema":void 0,children:x.text}),e.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-fg-faint",children:[(n==null?void 0:n.type)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Type"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:Array.isArray(n.type)?n.type.join(" | "):n.type})]}),(n==null?void 0:n.default)!==void 0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Default"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:F(n.default)})]}),(n==null?void 0:n.enum)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Options"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:n.enum.map(f=>String(f)).join(" | ")})]}),c&&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:F(c.value)}),e.jsxs("span",{className:"ml-2 text-fg-faint",children:["from ",T[c.winner].label]})]})]}),c&&c.shadowed.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Shadowed"}),e.jsx("dd",{className:"space-y-0.5",children:c.shadowed.map((f,y)=>e.jsxs("div",{className:"font-mono text-fg-faint line-through",children:[F(f.value)," —"," ",e.jsx("span",{className:"no-underline",children:T[f.scope].label})]},y))})]}),(s==null?void 0:s.kind)==="array"&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Accumulated"}),e.jsxs("dd",{className:"text-fg-dim",children:[s.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(rt,{keyName:t,node:s,info:n,onChange:r,targetScope:i})})]})}function rt({node:t,info:s,onChange:n,targetScope:i}){const a=(t==null?void 0:t.kind)==="leaf"?t.value:s==null?void 0:s.default,c=be(s==null?void 0:s.type);if(c==="boolean"){const x=a===!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:f,label:y})=>e.jsx("button",{onClick:()=>n(f),className:`px-3 py-0.5 text-xs transition-colors ${x===f?"bg-accent text-bg":"bg-bg-elev text-fg-dim hover:bg-bg-hi hover:text-fg"}`,children:y},y))}),e.jsxs("span",{className:"text-fg-faint",children:["→ ",T[i].label]})]})}return s!=null&&s.enum?e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-fg-faint",children:"Choose:"}),s.enum.map(x=>{const f=ve(a,x);return e.jsx("button",{onClick:()=>n(x),className:`px-2 py-0.5 text-xs rounded border ${f?"bg-accent text-bg border-accent":"bg-bg-elev text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,children:String(x)},String(x))}),e.jsxs("span",{className:"text-fg-faint",children:["→ ",T[i].label]})]}):c==="integer"||c==="number"?e.jsx(it,{value:typeof a=="number"?a:void 0,integer:c==="integer",onCommit:n,target:T[i].label}):c==="string"?e.jsx(lt,{value:typeof a=="string"?a:"",onCommit:n,target:T[i].label}):e.jsxs("div",{className:"text-fg-faint",children:["Complex value (",c??"object/array",") — use the"," ",e.jsx("span",{className:"text-fg-dim",children:"Raw"})," tab to edit."]})}function it({value:t,integer:s,onCommit:n,target:i}){const[r,a]=l.useState(t!==void 0?String(t):""),c=()=>{const x=s?parseInt(r,10):parseFloat(r);Number.isNaN(x)||n(x)};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:r,onChange:x=>a(x.target.value),onBlur:c,onKeyDown:x=>{x.key==="Enter"&&x.target.blur()},className:"w-24 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),e.jsxs("button",{onClick:c,className:"px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",i]})]})}function lt({value:t,onCommit:s,target:n}){const[i,r]=l.useState(t);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:i,onChange:a=>r(a.target.value),onKeyDown:a=>{a.key==="Enter"&&s(i)},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:()=>s(i),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 → ",n]})]})}function ot({node:t,info:s,onSet:n,disabled:i}){const r=(t==null?void 0:t.kind)==="leaf",a=be(s==null?void 0:s.type);if(i)return null;if(a==="boolean"){const c=r&&t.value===!0;return e.jsx("button",{onClick:()=>n(!c),className:`px-2.5 py-0.5 text-xs rounded border transition-colors ${c?"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:c?"on":"off"})}return null}function ct({isSet:t,leafNode:s,defaultVal:n,isDefault:i,node:r}){return t?(r==null?void 0:r.kind)==="array"?{kind:"accumulated",label:`${r.items.length} items`}:(r==null?void 0:r.kind)==="object"?{kind:"set",label:"configured"}:s?i?{kind:"default",label:`= default · ${T[s.winner].label}`}:s.shadowed.length>0?{kind:"override",label:`overriding ${s.shadowed.length} scope(s)`}:{kind:"set",label:`set in ${T[s.winner].label}`}:{kind:"set",label:"configured"}:n!==void 0?{kind:"default",label:`using default: ${F(n)}`}:{kind:"unset",label:"not configured"}}function dt({kind:t,label:s}){const n={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"}[t];return e.jsx("span",{className:`text-[9px] px-1.5 py-0 rounded border uppercase tracking-wide ${n}`,children:s})}function be(t){if(t)return Array.isArray(t)?t.find(n=>n!=="null")??t[0]:t}function ve(t,s){return t===s?!0:typeof t!=typeof s?!1:t&&s&&typeof t=="object"?JSON.stringify(t)===JSON.stringify(s):!1}function xt(t){const s=t.trim().split(`
|
|
2
2
|
`)[0],n=s.match(/^([^.!?]+[.!?])/);return n?n[1]:s.length>120?s.slice(0,120)+"…":s}function F(t){if(typeof t=="string")return t===""?'""':JSON.stringify(t);if(t===null)return"null";if(t===void 0)return"—";if(typeof t=="object"){const s=JSON.stringify(t);return s.length>60?s.slice(0,60)+"…":s}return String(t)}const pt=1440*60*1e3;function le(t){if(!t)return"never";const s=new Date(t).getTime();return Number.isNaN(s)?"never":new Date(s).toLocaleString()}function oe(t){return t?new Date(t).toLocaleString():"never"}function ut(){return e.jsxs("div",{className:"p-4 max-w-3xl space-y-8 text-sm",children:[e.jsx(mt,{}),e.jsx("hr",{className:"border-line"}),e.jsx(ft,{})]})}function mt(){const[t,s]=l.useState(null),[n,i]=l.useState(null),[r,a]=l.useState(null),[c,x]=l.useState(null),[f,y]=l.useState(!1),[u,S]=l.useState(null),[o,v]=l.useState(null);if(l.useEffect(()=>{let g=!1;return Promise.all([window.api.otel.getConfig(),window.api.otel.status(),window.api.otel.configPath()]).then(([E,R,m])=>{g||(s(E),a(E),i(R),x(m))}).catch(E=>{console.warn("[telemetry] load failed:",E==null?void 0:E.message)}),()=>{g=!0}},[]),!r||!t)return e.jsx(G,{title:"loading…"});const p=JSON.stringify(r)!==JSON.stringify(t),w=(g,E)=>{S(null),a({...r,[g]:E})},C=async()=>{y(!0),S(null);try{const g=await window.api.otel.setConfig(r);!g.ok&&g.error&&S(g.error),s(g.config),a(g.config),i(g.status),v(Date.now())}catch(g){S(g instanceof Error?g.message:String(g))}finally{y(!1)}},A=()=>{S(null),a(t)};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."}),c&&e.jsxs("p",{className:"text-fg-faint text-[11px]",children:["stored at ",e.jsx("span",{className:"font-mono",children:c})]})]}),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(J,{checked:r.enabled,onChange:g=>w("enabled",g),label:r.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:r.endpoint,onChange:g=>w("endpoint",g.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:r.headers,onChange:g=>w("headers",g.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:r.serviceName,onChange:g=>w("serviceName",g.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(J,{checked:r.includeContent,onChange:g=>w("includeContent",g),label:r.includeContent?"on":"off"})]})]}),n&&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:n.enabled?"text-accent":"text-fg-dim",children:String(n.enabled)})]}),n.error&&e.jsxs("div",{className:"text-red-400 break-words",children:[e.jsx("span",{className:"text-fg-faint",children:"error:"})," ",n.error]}),!n.error&&n.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:!p||f,className:"px-3 py-1 text-xs rounded bg-accent text-bg disabled:opacity-50 disabled:cursor-not-allowed",children:f?"saving…":"Save"}),e.jsx("button",{onClick:A,disabled:!p||f,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"}),u&&e.jsx("span",{className:"text-red-400 text-xs",children:u}),!u&&o&&!p&&e.jsx("span",{className:"text-fg-faint text-xs",children:"saved"})]})]})}function ft(){const[t,s]=l.useState(null),[n,i]=l.useState(null),[r,a]=l.useState("Copy"),[c,x]=l.useState(!1),[f,y]=l.useState(null),[u,S]=l.useState(null),[o,v]=l.useState(null),[p,w]=l.useState(!1),C=()=>{window.api.telemetry.status().then(i).catch(h=>{console.warn("[product-telemetry] status reload failed:",h==null?void 0:h.message)})};if(l.useEffect(()=>{let h=!1;return Promise.all([window.api.telemetry.getConfig(),window.api.telemetry.status()]).then(([k,b])=>{h||(s(k),i(b))}).catch(k=>{console.warn("[product-telemetry] load failed:",k==null?void 0:k.message)}),()=>{h=!0}},[]),!t||!n)return e.jsx(G,{title:"loading…"});const A=async h=>{S(null);try{const k=await window.api.telemetry.setConfig(h);s(k.config),i(k.status)}catch(k){S(k instanceof Error?k.message:String(k))}},g=h=>{A({...t,enabled:h})},E=async()=>{await Re(t.installId)?(a("Copied"),setTimeout(()=>a("Copy"),1500)):ue.error("Could not copy install id to the clipboard")},R=async()=>{x(!0),y(null);try{const h=await window.api.telemetry.flushNow();y(`sent ${h.sent.length}, failed ${h.failed.length}`),C()}catch(h){y(h instanceof Error?h.message:String(h))}finally{x(!1)}},m=async()=>{if(p){w(!1);return}try{const h=await window.api.telemetry.recentRecords();v(h),w(!0)}catch(h){console.warn("[product-telemetry] recentRecords failed:",h instanceof Error?h.message:h)}},N=t.lastDailyFlushAt?new Date(t.lastDailyFlushAt).getTime()+pt: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."]})]}),e.jsx(Ee,{cfg:t,onSaved:(h,k)=>{s(h),i(k)}}),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(J,{checked:t.enabled,onChange:g,label:t.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:t.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:E,className:"px-2 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg",children:r})]})]}),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:t.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"})]}),u&&e.jsx("div",{className:"text-red-400 text-xs",children:u})]}),n.pendingCount>0&&n.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:[n.pendingCount," record",n.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:"})," ",oe(n.lastFlushAt)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"next daily send due:"})," ",le(N?new Date(N).toISOString():null)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"queued records:"})," ",n.pendingCount]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"delivered so far:"})," ",n.sentCount]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"de-duplicated:"})," ",n.dedupedAppends]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"evicted:"})," ",n.evictedCount]}),n.backlog&&e.jsxs("div",{className:"text-fg-faint",children:["last backlog drain (",n.backlog.reason,", ",le(n.backlog.ranAt),"):"," ",n.backlog.linesEnqueued," enqueued, ",n.backlog.linesConfirmed," confirmed,"," ",n.backlog.watermarksRewound," watermarks rewound"]}),n.lastError&&e.jsxs("div",{className:"text-red-400 break-words",children:[e.jsx("span",{className:"text-fg-faint",children:"last error:"})," ",n.lastError.message," ","(",oe(n.lastError.at),")"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:R,disabled:c,className:"px-3 py-1 text-xs rounded bg-accent text-bg disabled:opacity-50 disabled:cursor-not-allowed",children:c?"sending…":"Send now"}),f&&e.jsx("span",{className:"text-fg-faint text-xs",children:f})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("button",{onClick:m,className:"px-3 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg",children:p?"Hide last records":"Inspect last records sent"}),p&&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(o??[],null,2)})]})]})}function z({children:t,right:s}){return e.jsxs("div",{className:"flex items-baseline justify-between mb-2.5",children:[e.jsx("span",{className:"text-[11.5px] font-bold uppercase tracking-[0.8px] text-fg-faint",children:t}),s]})}function Y({kind:t="soft",icon:s,children:n,onClick:i,disabled:r,testId:a}){return e.jsxs("button",{type:"button","data-testid":a,onClick:i,disabled:r,className:`shrink-0 inline-flex items-center gap-2 rounded-lg px-3.5 py-2 text-[13px] font-semibold transition-colors disabled:opacity-50 ${t==="soft"?"bg-bg-hi border border-line text-fg hover:bg-bg":"text-fg-dim hover:text-fg"}`,children:[s&&e.jsx(B,{name:s,size:15}),n]})}function ht({icon:t,title:s,subtitle:n,badge:i,action:r,testId:a}){return e.jsxs("div",{"data-testid":a,className:"flex items-center gap-3.5 bg-bg-hi border border-line rounded-xl px-[18px] py-3.5",children:[e.jsx("span",{className:"w-[34px] h-[34px] rounded-lg bg-bg border border-line grid place-items-center text-fg-dim shrink-0",children:e.jsx(B,{name:t,size:17})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-0.5",children:[e.jsx("span",{className:"text-sm font-semibold text-fg truncate",children:s}),i]}),e.jsx("div",{className:"font-mono text-[11.5px] text-fg-faint truncate",children:n})]}),r]})}function gt({onClick:t,disabled:s,testId:n,children:i="Revoke"}){return e.jsx("button",{"data-testid":n,onClick:t,disabled:s,className:"shrink-0 rounded-lg border border-line bg-bg text-accent px-3.5 py-1.5 text-[12.5px] font-semibold hover:bg-bg-hi disabled:opacity-50 transition-colors",children:i})}function ce({code:t,onConfirm:s,testId:n,codeTestId:i,confirmTestId:r,peer:a="browser"}){return e.jsxs("div",{"data-testid":n,className:"flex items-start gap-3.5 px-5 py-4 rounded-2xl border border-accent/40 bg-accent/[0.06]",children:[e.jsx("span",{className:"w-[38px] h-[38px] rounded-[11px] shrink-0 grid place-items-center bg-bg-hi text-accent",children:e.jsx(B,{name:"shield",size:20})}),e.jsxs("div",{className:"flex-1 min-w-0 text-sm text-fg",children:[e.jsx("strong",{className:"font-semibold",children:"Verify E2E session."})," Compare this code with the ",a," — they must match.",e.jsx("div",{"data-testid":i,className:"my-2 text-3xl font-mono tracking-[0.3em] text-center text-accent select-all",children:t}),e.jsx("p",{className:"text-[12.5px] text-fg-faint mb-3",children:"If the codes match, confirm below. Mutating commands are blocked until confirmed."}),e.jsx("button",{"data-testid":r,onClick:s,className:"rounded-lg bg-accent text-white px-4 py-2 text-[13px] font-semibold hover:opacity-90 transition-opacity",children:"Codes match — confirm"})]})]})}function bt({children:t,testId:s}){return e.jsx("div",{"data-testid":s,className:"bg-bg-hi border border-line rounded-xl p-5 text-center text-[13.5px] text-fg-faint italic font-serif",children:t})}function de({label:t,hint:s,on:n,onChange:i,warn:r,disabled:a,first:c,testId:x}){return e.jsxs("div",{className:`flex items-center justify-between gap-4 px-[18px] py-[15px] ${c?"":"border-t border-rule"} ${a?"opacity-50":""}`,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-fg mb-0.5",children:t}),e.jsxs("div",{className:`text-[12.5px] leading-snug flex items-center gap-1.5 ${r?"text-honey-dark":"text-fg-faint"}`,children:[r&&e.jsx("span",{"aria-hidden":!0,children:"⚠"}),s]})]}),e.jsx("span",{"data-testid":x,className:"inline-flex",children:e.jsx(J,{checked:n,onChange:a?()=>{}:i,disabled:a})})]})}function vt({device:t,online:s,onRevoke:n,revoking:i}){const r=t.lastConnectedAt?new Date(t.lastConnectedAt).toLocaleString():`paired ${new Date(t.issuedAt).toLocaleDateString()}`;return e.jsx(ht,{testId:"settings-remote-device",icon:"wifi",title:t.deviceName,badge:s?e.jsx(q,{tone:"default",className:"!text-sage !border-sage/40",children:"online"}):void 0,subtitle:`${t.deviceId} · last seen ${r}`,action:e.jsx(gt,{testId:"settings-remote-revoke",onClick:()=>n(t.deviceId),disabled:i})})}const L=t=>(t==null?void 0:t.message)||String(t);function yt(){var se;const t=Q(d=>d.show),[s,n]=l.useState(null),[i,r]=l.useState(!0),[a,c]=l.useState(!1),[x,f]=l.useState(!1),[y,u]=l.useState("idle"),[S,o]=l.useState(""),[v,p]=l.useState(null),[w,C]=l.useState(!1),[A,g]=l.useState([]),[E,R]=l.useState(!1),m=l.useRef(null);l.useEffect(()=>{let d=!1;const j=()=>window.api.webRemote.getStatus().then(D=>{d||n(D)}).catch(()=>{});window.api.webRemote.getStatus().then(D=>{d||(n(D),r(!1))}).catch(D=>{d||(t("error",`Remote status: ${L(D)}`),r(!1))});const ke=window.api.webRemote.onStatus(D=>n(D)),Se=window.api.webRemote.onTokenRevoked(()=>{t("warn","Remote device token was revoked. Re-pair to reconnect."),j()}),Ce=window.api.webRemote.onRevokedAll(({revokedCount:D})=>{t("info",`Panic: all ${D} device(s) revoked and sessions torn down.`),j()});return()=>{d=!0,ke(),Se(),Ce()}},[t]),l.useEffect(()=>{if(y!=="enter-otp")return;const d=setTimeout(()=>{var j;return(j=m.current)==null?void 0:j.focus()},50);return()=>clearTimeout(d)},[y]);const N=async()=>n(await window.api.webRemote.getStatus()),h=async()=>{if(s){c(!0);try{const d=s.enabled?await window.api.webRemote.disable():await window.api.webRemote.enable();d&&d.ok===!1&&t("error",d.error||"Failed to change remote state."),await N()}catch(d){t("error",`Failed: ${L(d)}`)}finally{c(!1)}}},k=async()=>{if(s){f(!0);try{const d=s.remoteControlEnabled?await window.api.webRemote.disableControl():await window.api.webRemote.enableControl();d&&d.ok===!1&&t("error",d.error||"Failed to change command writes."),await N()}catch(d){t("error",`Failed: ${L(d)}`)}finally{f(!1)}}},b=async()=>{const d=S.trim().toUpperCase();if(!/^[A-Z0-9]{8}$/.test(d)){t("warn","Pairing code must be 8 alphanumeric characters.");return}u("pairing");try{const j=await window.api.webRemote.pair(d);if(!j.ok){t("error",j.error||"Pairing failed."),u("enter-otp");return}t("info","Device paired successfully."),o(""),u("idle"),await N()}catch(j){t("error",`Pairing error: ${L(j)}`),u("enter-otp")}},O=async d=>{p(d);try{const j=await window.api.webRemote.revokeDevice(d);if(!j.ok){t("error",j.error||"Revoke failed.");return}await N()}catch(j){t("error",`Revoke error: ${L(j)}`)}finally{p(null)}},I=async()=>{C(!0);try{const d=await window.api.webRemote.revokeAll();d.ok||t("error",d.error||"Panic revoke failed.")}catch(d){t("error",`Panic revoke error: ${L(d)}`)}finally{C(!1)}},ee=async()=>{if(E){R(!1);return}try{const d=await window.api.webRemote.auditTail(100);if(!d.ok){t("error",`Audit log: ${d.error||"unavailable"}`);return}g(d.lines??[]),R(!0)}catch(d){t("error",`Audit log: ${L(d)}`)}},$=async d=>{try{const j=await window.api.webRemote.confirmSas(d);j!=null&&j.ok||t("error",`SAS confirm failed: ${(j==null?void 0:j.error)??"unexpected state — reconnect the mobile app"}`)}catch(j){t("error",`SAS confirm failed: ${L(j)}`)}};if(i)return e.jsx("div",{className:"p-6 text-fg-faint text-sm",children:"Loading…"});const P=(s==null?void 0:s.enabled)??!1,M=(s==null?void 0:s.remoteControlEnabled)??!1,K=(s==null?void 0:s.connected)??!1,_=(s==null?void 0:s.e2eActive)??!1,je=(s==null?void 0:s.e2eAuthenticated)??!1,we=(s==null?void 0:s.e2eState)??"idle",te=(s==null?void 0:s.pendingSas)??null,X=((s==null?void 0:s.clients)??[]).filter(d=>d.state==="pending_sas"&&d.pendingSas),U=(s==null?void 0:s.devices)??[],H=P&&K,Ne=K?((se=U.reduce((d,j)=>j.lastConnectedAt&&(!d||(d.lastConnectedAt??"")<j.lastConnectedAt)?j:d,null))==null?void 0:se.deviceId)??null:null;return e.jsxs("div",{"data-testid":"settings-remote",className:"p-4 max-w-[760px] space-y-[22px]",children:[X.length>0?X.map((d,j)=>e.jsxs("div",{"data-testid":"settings-remote-sas-row",children:[X.length>1&&e.jsxs("div",{className:"text-[12px] font-semibold text-fg-dim mb-1",children:["Browser ",j+1]}),e.jsx(ce,{testId:j===0?"settings-remote-sas":void 0,codeTestId:j===0?"settings-remote-sas-code":void 0,confirmTestId:j===0?"settings-remote-sas-confirm":void 0,code:d.pendingSas,onConfirm:()=>$(d.key)})]},d.key)):te&&e.jsx(ce,{testId:"settings-remote-sas",codeTestId:"settings-remote-sas-code",confirmTestId:"settings-remote-sas-confirm",code:te,onConfirm:()=>$()}),we==="failed"&&e.jsxs("div",{className:"flex items-center gap-3.5 px-5 py-4 rounded-2xl border border-[#eccdbe] bg-[#f8e8e0]",children:[e.jsx("span",{className:"w-4 h-4 rounded-full bg-accent text-white grid place-items-center text-[11px] font-bold shrink-0",children:"!"}),e.jsxs("div",{className:"text-[13px] text-[#9a3f1f]",children:[e.jsx("strong",{className:"font-semibold",children:"E2E key exchange failed."})," ",e.jsx("span",{className:"text-fg-dim",children:"The session key could not be established. Reconnect the mobile app to retry."})]})]}),e.jsxs("div",{className:`flex items-center gap-3.5 px-5 py-4 rounded-2xl border ${H?"border-[#e8cdb9] bg-[#f5e9df]":"border-line bg-bg-hi"}`,children:[e.jsx("span",{className:`w-[38px] h-[38px] rounded-[11px] shrink-0 grid place-items-center ${H?"bg-[#f0d9c8] text-accent":"bg-[#e4ebd6] text-sage"}`,children:e.jsx(B,{name:H?"wifi":"shield",size:20})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[14.5px] font-semibold text-fg mb-0.5",children:H?"Remote control is active":P?"Remote control is idle":"Remote control is off"}),e.jsx("div",{className:"text-[13px] text-fg-dim leading-snug",children:H?"A web session can send commands to this machine. Revoke below if unexpected.":P&&(s==null?void 0:s.linkState)==="repair-needed"?"The relay no longer recognises this device. Re-pair it with a new code to reconnect.":P?"The relay is on but no device is connected. Pair a device to begin.":"The relay connection is closed — no remote commands are accepted. Enable it below only when you need it."})]}),_&&je?e.jsx(q,{tone:"default",className:"!text-sage !border-sage/40",children:"E2E authenticated"}):_?e.jsx(q,{tone:"warn",children:"E2E · awaiting SAS"}):e.jsx(q,{tone:"dim",children:"relay only · not E2E yet"})]}),e.jsxs("div",{children:[e.jsx(z,{children:"Remote control"}),e.jsxs("div",{className:"bg-bg-hi border border-line rounded-2xl overflow-hidden",children:[e.jsx(de,{first:!0,testId:"settings-remote-enable",label:"Allow remote control from the web",hint:"Master switch. When off, the relay refuses every connection.",on:P,disabled:a,onChange:()=>{a||h()}}),e.jsx(de,{testId:"settings-remote-control",label:"Allow command writes (pty + scheduler)",hint:M?"A paired device can run shell commands and queue jobs on this machine.":"Paired devices can watch session output but cannot send commands.",warn:M,disabled:!P||x,on:M&&P,onChange:()=>{P&&!x&&k()}})]})]}),e.jsxs("div",{children:[e.jsx(z,{children:"Pair a device"}),y==="idle"?e.jsxs("div",{className:"flex items-center justify-between gap-4 bg-bg-hi border border-line rounded-2xl px-5 py-[18px]",children:[e.jsxs("div",{"data-testid":"settings-remote-pair-hint",className:"text-[13.5px] text-fg-dim leading-relaxed max-w-[420px]",children:["On your phone open ",e.jsx("strong",{className:"text-fg font-semibold",children:"bilko.run/projects/session-manager"}),", sign in, and tap"," ",e.jsx("strong",{className:"text-fg font-semibold",children:"Generate pairing code"}),". Enter the 8-character code here."]}),e.jsx(Y,{testId:"settings-remote-pair-start",kind:"soft",icon:"link",onClick:()=>u("enter-otp"),children:"Pair Device…"})]}):e.jsxs("div",{className:"flex items-center gap-5 bg-bg-hi border border-accent/40 rounded-2xl px-6 py-[22px]",children:[e.jsx("span",{className:"w-[52px] h-[52px] rounded-xl bg-bg border border-line grid place-items-center text-accent shrink-0",children:e.jsx(B,{name:"link",size:24})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[11.5px] font-bold uppercase tracking-[0.8px] text-fg-faint mb-2",children:"Enter the code from your phone"}),e.jsx("input",{ref:m,"data-testid":"settings-remote-otp",value:S,onChange:d=>o(d.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"")),onKeyDown:d=>{d.key==="Enter"&&b()},maxLength:8,placeholder:"XXXXXXXX",disabled:y==="pairing",className:"w-full bg-transparent border-0 outline-none font-mono text-[30px] font-semibold tracking-[6px] text-fg placeholder:text-fg-faint/40 disabled:opacity-50"})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx(Y,{testId:"settings-remote-pair-confirm",kind:"soft",onClick:b,disabled:y==="pairing"||S.length<8,children:y==="pairing"?"Pairing…":"Confirm"}),e.jsx(Y,{kind:"ghost",onClick:()=>{u("idle"),o("")},disabled:y==="pairing",children:"cancel"})]})]})]}),e.jsxs("div",{children:[e.jsx(z,{right:U.length>0?e.jsxs("span",{className:"text-[11.5px] text-fg-faint",children:[U.length," paired"]}):void 0,children:"Paired devices"}),U.length===0?e.jsx(bt,{children:"No devices paired yet."}):e.jsx("div",{className:"space-y-2",children:U.map(d=>e.jsx(vt,{device:d,online:d.deviceId===Ne,onRevoke:O,revoking:v===d.deviceId},d.deviceId))})]}),e.jsxs("div",{children:[e.jsx(z,{right:e.jsx("button",{"data-testid":"settings-remote-audit-toggle",onClick:ee,className:"text-[12px] text-fg-faint hover:text-fg-dim transition-colors",children:E?"Hide":"Show last 100 · 0600, stays on this machine"}),children:"Audit log"}),E&&e.jsx("div",{className:"bg-bg-hi border border-line rounded-xl overflow-auto max-h-64 mb-2",children:A.length===0?e.jsx("p",{className:"p-4 text-[12.5px] text-fg-faint",children:"No entries today."}):e.jsx("pre",{"data-testid":"settings-remote-audit",className:"p-4 text-[12px] text-fg-dim font-mono whitespace-pre-wrap leading-relaxed",children:A.join(`
|
|
3
3
|
`)})}),e.jsxs("p",{className:"text-[12px] text-fg-faint",children:["Full log at"," ",e.jsx("code",{className:"font-mono text-fg-faint",children:"~/.claude/session-manager/logs/remote-audit-YYYY-MM-DD.log"})," ","(0600, never leaves this machine)"]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 bg-[#f8e8e0] border border-[#eccdbe] rounded-2xl px-5 py-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"w-4 h-4 rounded-full bg-accent text-white grid place-items-center text-[11px] font-bold shrink-0",children:"!"}),e.jsx("span",{className:"text-sm font-semibold text-[#9a3f1f]",children:"Panic — disconnect & revoke everything"})]}),e.jsx("div",{className:"text-[12.5px] text-fg-dim leading-snug max-w-[440px]",children:"Tears down every active session and invalidates all paired-device tokens. Devices must re-pair. Use if you suspect compromise."})]}),e.jsx("button",{"data-testid":"settings-remote-revoke-all",onClick:I,disabled:w,className:"shrink-0 rounded-lg bg-accent text-white px-[18px] py-2 text-[13px] font-semibold hover:opacity-90 disabled:opacity-50 transition-opacity",children:w?"Revoking…":"Revoke all"})]})]})}const V="px-2 py-1 rounded border border-line text-xs text-fg hover:bg-bg-hi disabled:opacity-50";function jt(){const t=Ae(),s=Q(x=>x.show),n=async x=>{try{const y=await x();y&&y.ok===!1&&s("error",y.error??"Update action failed")}catch(f){s("error",f instanceof Error?f.message:String(f))}};if(!t)return null;const{state:i}=t,r=i==="unsupported",a=t.latest?`v${t.latest}`:"—",c=()=>{window.confirm("Installing now will stop all running jobs and terminals. Continue?")&&n(()=>window.api.updater.install(!0))};return e.jsxs("section",{"data-testid":"settings-updates",className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-fg text-xs font-medium",children:"Updates"}),e.jsxs("div",{className:"text-fg-dim text-xs flex gap-4",children:[e.jsxs("span",{children:["Current v",t.current]}),e.jsxs("span",{children:["Latest ",a]})]})]}),r?e.jsx("p",{className:"text-fg-faint text-[11px]",children:"Auto-update runs only in the installed Windows app or the Linux AppImage. npx builds update via npx."}):e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(J,{checked:t.enabled,onChange:x=>void n(()=>window.api.updater.setEnabled(x)),label:"Update automatically"}),e.jsx("button",{type:"button","data-testid":"updates-check",className:V,disabled:i==="checking"||i==="downloading",onClick:()=>void n(()=>window.api.updater.check()),children:"Check for updates"})]}),i==="checking"&&e.jsx("p",{className:"text-fg-dim text-xs",children:"Checking…"}),i==="downloading"&&e.jsxs("p",{className:"text-fg-dim text-xs",children:["Downloading… ",t.progress!=null?`${Math.round(t.progress)}%`:""]}),i==="ready"&&e.jsxs("button",{type:"button","data-testid":"updates-install",className:V,onClick:()=>void n(()=>window.api.updater.install(!1)),children:["Restart to install v",t.latest]}),i==="deferred"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-fg-dim text-xs",children:["Waiting for ",t.busyReason??"work"," to finish"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",className:V,onClick:c,children:"Install now"}),e.jsx("button",{type:"button",className:V,onClick:()=>void n(()=>window.api.updater.cancelDeferred()),children:"Cancel"})]})]}),i==="error"&&e.jsx("p",{className:"text-red-400 text-xs",children:t.error})]})}const wt=[{key:"maxAgeDays",label:"Run logs: keep for",unit:"days",min:3,max:3650},{key:"runsArchiveDays",label:"Runs archive: keep for",unit:"days",min:1,max:3650},{key:"auditLogMonths",label:"Audit log: keep for",unit:"months",min:1,max:120},{key:"reservedMarkersKeep",label:"Reserved markers: keep",unit:"markers",min:1,max:1e5}],Nt="w-24 px-2 py-1 rounded border border-line bg-transparent text-xs text-fg";function xe(t,s){return s==="maxAgeDays"?t.runLogs.maxAgeDays:t[s]}function kt(t,s){return t==="maxAgeDays"?{runLogs:{maxAgeDays:s}}:{[t]:s}}function ye(t){if(!Number.isFinite(t)||t<=0)return"0 B";const s=["B","KB","MB","GB","TB"];let n=0,i=t;for(;i>=1024&&n<s.length-1;)i/=1024,n++;return`${n===0?i:i.toFixed(1)} ${s[n]}`}function Z(t,s,n){return`${t}: ${ye(s)} in ${n.toLocaleString("en-US")} files`}function St(){const t=Q(o=>o.show),[s,n]=l.useState(null),[i,r]=l.useState({}),[a,c]=l.useState(null),x=l.useCallback(o=>t("error",o instanceof Error?o.message:String(o)),[t]),f=l.useCallback(async()=>{try{c(await window.api.opsRetention.preview())}catch(o){x(o)}},[x]);l.useEffect(()=>{let o=!0;return window.api.opsRetention.get().then(v=>{o&&n(v)}).catch(v=>{o&&x(v)}),f(),()=>{o=!1}},[x,f]);const y=async o=>{if(!s)return;const v=i[o.key];if(v===void 0)return;const p=Number(v);if(r(C=>{const{[o.key]:A,...g}=C;return g}),v.trim()===""||!Number.isFinite(p))return;const w=Math.min(o.max,Math.max(o.min,Math.round(p)));if(w!==xe(s,o.key))try{n(await window.api.opsRetention.set(kt(o.key,w))),await f()}catch(C){x(C)}},u=a?a.runLogs.bytes+a.runsArchive.bytes+a.tmp.bytes:0,S=a?a.runLogs.files+a.runsArchive.entries+a.tmp.files:0;return e.jsxs("section",{"data-testid":"settings-ops-retention",className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-fg text-xs font-medium",children:"Ops data retention"}),e.jsx("p",{className:"text-fg-faint text-[11px]",children:"How long the daily sweep keeps scheduler and audit data. Machine-wide."})]}),s&&e.jsxs("div",{className:"space-y-2",children:[wt.map(o=>e.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg-dim",children:[e.jsx("span",{className:"w-48",children:o.label}),e.jsx("input",{type:"number","data-testid":`ops-retention-${o.key}`,className:Nt,min:o.min,max:o.max,value:i[o.key]??String(xe(s,o.key)),onChange:v=>r(p=>({...p,[o.key]:v.target.value})),onBlur:()=>void y(o)}),e.jsx("span",{className:"text-fg-faint",children:o.unit})]},o.key)),e.jsx("p",{className:"text-fg-dim text-xs",children:"Archived transcripts: kept forever"})]}),a&&e.jsxs("div",{"data-testid":"ops-retention-preview",className:"space-y-1 text-xs text-fg-dim",children:[e.jsxs("div",{className:"text-fg",children:["Current policy would free ",ye(u)," in ",S.toLocaleString("en-US")," files"]}),e.jsx("div",{children:Z("Run logs",a.runLogs.bytes,a.runLogs.files)}),e.jsx("div",{children:Z("Runs archive",a.runsArchive.bytes,a.runsArchive.entries)}),e.jsx("div",{children:Z("Stale temp files",a.tmp.bytes,a.tmp.files)}),e.jsx("p",{className:"text-fg-faint text-[11px]",children:"Nothing is deleted until the daily sweep runs."})]})]})}const Ct={compact:"Compact",roomy:"Roomy"};function Et(){const{model:t,setModel:s}=Te(),{catalog:n}=Pe(null),{density:i,setDensity:r}=Ie();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.jsxs("section",{className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"Default model for raw sessions"}),e.jsx(ne,{options:De(n),value:t,onChange:s,mono:!0}),e.jsx("span",{className:"text-fg-faint text-[11px]",children:"Used when opening a raw interactive session without an explicit per-launch override."})]}),e.jsxs("div",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"Density"}),e.jsx(ne,{options:["compact","roomy"],value:i,onChange:a=>r(a),labels:Ct}),e.jsx("span",{className:"text-fg-faint text-[11px]",children:"Compact tightens spacing across the app's chrome; Roomy is the default."})]})]}),e.jsx(jt,{}),e.jsx(St,{})]})}function Rt({cwd:t}){const[s,n]=l.useState(!1),[i,r]=l.useState(!1),[a,c]=l.useState(!1),[x,f]=l.useState(!1);l.useEffect(()=>{var v,p;let o=!1;return n(!1),Promise.resolve((p=(v=window.api.promptSessions)==null?void 0:v.getWorktreeDisabled)==null?void 0:p.call(v,{cwd:t})).then(w=>{o||(r((w==null?void 0:w.disabled)??!1),c((w==null?void 0:w.disabled)??!1),n(!0))},()=>{o||n(!0)}),()=>{o=!0}},[t]);const y=s&&a!==i,u=()=>{var o,v;f(!0),Promise.resolve((v=(o=window.api.promptSessions)==null?void 0:o.setWorktreeDisabled)==null?void 0:v.call(o,{cwd:t,disabled:a})).then(p=>{r((p==null?void 0:p.disabled)??a),c((p==null?void 0:p.disabled)??a)}).catch(p=>ue.error(p instanceof Error?p.message:String(p))).finally(()=>f(!1))},S=()=>c(i);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:a,disabled:!s||x,onChange:o=>c(o.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."]})]})]}),y&&e.jsx(me,{dirty:y,busy:x,onSave:u,onRevert:S})]})}const pe={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 At(){const t=Oe(),s=ae(b=>b.tabs),n=ae(b=>b.activeTabId),i=s.find(b=>b.id===n)??null,r=(i==null?void 0:i.cwd)??null,a=Le(b=>b.navFace),c=l.useRef(!1),x=l.useRef(a),[f,y]=l.useState(()=>a==="project"&&r?"project":"user"),[u,S]=l.useState("effective");l.useEffect(()=>{if(x.current!==a){if(x.current=a,c.current){c.current=!1;return}y(a==="project"&&r?"project":"user")}},[a,r]),l.useEffect(()=>{a==="project"&&(u==="telemetry"||u==="remote"||u==="app")&&S("effective")},[a,u]);const o=b=>{c.current=!0,y(b)},v=He(re,t,r),p=v[f]??null,w=W(b=>b.files),C=W(b=>b.setDraft),A=W(b=>b.saveJson),g=W(b=>b.revert),[E,R]=l.useState(null),m=l.useMemo(()=>Me($e(w,v)),[w,v]),N=(b,O,I)=>{var _;const $=v[I??f];if(!$)return;R(null);const P=((_=w[$])==null?void 0:_.draftRaw)??"";let M={};if(P.trim())try{M=JSON.parse(P)}catch{M={}}const K=Be(M,b,O);C($,JSON.stringify(K,null,2)+`
|
|
4
4
|
`)};if(!t)return e.jsx(G,{title:"loading…"});const h=p?w[p]:null,k=b=>b!=="user"&&!r;return e.jsx(_e,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(Je,{options:[{key:"effective",label:"Guided"},{key:"tree",label:"Tree"},{key:"raw",label:"Raw"},...a==="home"?[{key:"telemetry",label:"Telemetry"},{key:"remote",label:"Phone remote"},{key:"app",label:"Session Manager"}]:[]],active:u,onChange:S}),u!=="telemetry"&&u!=="remote"&&u!=="app"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx(Ue,{scopes:re.scopes,active:f,onChange:o,annotate:b=>{if(k(b))return{exists:!1};const O=v[b];if(!O)return null;const I=w[O];return{exists:(I==null?void 0:I.exists)??!1,dirty:(I==null?void 0:I.dirty)??!1}}}),e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:u==="effective"?`overrides → ${p??"—"}`:p??"—"})]}),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:u!=="telemetry"&&u!=="remote"&&u!=="app"&&p&&h?e.jsx(me,{dirty:h.dirty,busy:h.busy,parseError:E||h.parseError,lastSavedAt:h.lastSavedAt,leading:h.exists?null:e.jsx("span",{children:"file will be created on save"}),onSave:async()=>{R(null);const b=await A(p);b.ok||R(b.error??"save failed")},onRevert:()=>{R(null),g(p)}}):null,children:u==="telemetry"?e.jsx(ut,{}):u==="remote"?e.jsx(yt,{}):u==="app"?e.jsx(Et,{}):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:pe[f].title}),e.jsx("span",{className:"mx-1.5 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-dim",children:pe[f].body}),p&&e.jsx("span",{className:"ml-1.5 font-mono text-fg-faint",children:p})]}),f==="project"&&r&&e.jsx(Rt,{cwd:r}),k(f)?e.jsx(G,{title:"no active project",hint:"open a tab in a project directory to edit project or local settings"}):u==="effective"?e.jsx(Ze,{node:m,targetScope:f,onOverride:N,schema:ie()}):u==="tree"?e.jsx(Ge,{node:m,targetScope:f,onOverride:N,schema:ie()}):p&&h?e.jsx(Fe,{path:p,value:h.draftRaw,onChange:b=>{R(null),C(p,b)}}):e.jsx(G,{title:"resolving…"})]})})}const Bt=l.memo(At);export{pe as SETTINGS_SCOPE_NOTES,Bt as Settings};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{aB as Z,R as wo,ai as ko,al as tr}from"./index-
|
|
1
|
+
import{aB as Z,R as wo,ai as ko,al as tr}from"./index-DzY_GXYY.js";import"./monaco-editor-BsIlgG7c.js";function Ao(e,n){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var i,o,a,s,u=[],l=!0,f=!1;try{if(a=(r=r.call(e)).next,n===0){if(Object(r)!==r)return;l=!1}else for(;!(l=(i=a.call(r)).done)&&(u.push(i.value),u.length!==n);l=!0);}catch(h){f=!0,o=h}finally{try{if(!l&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(f)throw o}}return u}}function Co(e,n,r){return n=zo(n),n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function er(e,n){return To(e)||Ao(e,n)||ci(e,n)||Eo()}function So(e){return Mo(e)||Po(e)||ci(e)||Oo()}function Mo(e){if(Array.isArray(e))return gn(e)}function To(e){if(Array.isArray(e))return e}function Po(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function ci(e,n){if(e){if(typeof e=="string")return gn(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return gn(e,n)}}function gn(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,i=new Array(n);r<n;r++)i[r]=e[r];return i}function Oo(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
2
2
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Eo(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
3
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ro(e,n){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(e)}function zo(e){var n=Ro(e,"string");return typeof n=="symbol"?n:String(n)}var No=function(n,r){var i=new Set(r);return Object.assign.apply(Object,[{}].concat(So(Object.entries(n).filter(function(o){var a=er(o,1),s=a[0];return!i.has(s)}).map(function(o){var a=er(o,2),s=a[0],u=a[1];return Co({},s,u)}))))};function yn(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,i=Array(n);r<n;r++)i[r]=e[r];return i}function Io(e){if(Array.isArray(e))return e}function $o(e){if(Array.isArray(e))return yn(e)}function Do(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function jo(e,n){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var i,o,a,s,u=[],l=!0,f=!1;try{if(a=(r=r.call(e)).next,n!==0)for(;!(l=(i=a.call(r)).done)&&(u.push(i.value),u.length!==n);l=!0);}catch(h){f=!0,o=h}finally{try{if(!l&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(f)throw o}}return u}}function Fo(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
4
4
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Lo(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{aB as a,b0 as ce,aU as de,b2 as ue,aT as E,aW as d,aX as fe,al as s,m as T}from"./index-
|
|
1
|
+
import{aB as a,b0 as ce,aU as de,b2 as ue,aT as E,aW as d,aX as fe,al as s,m as T}from"./index-DzY_GXYY.js";import{P as B}from"./Panel-DZHiD8Ar.js";import{L as me}from"./ListDetail-D7Om0H8j.js";import{p as pe,r as he,M as xe,s as ve}from"./skillFrontmatter-BEseWm8r.js";import{S as ge}from"./SaveBar-mVKig6hL.js";import{S as Q}from"./ScopeSwitcher-s8J-yr7Z.js";import{T as ke}from"./Toggle-C-oD66BG.js";import{P as Y}from"./ProvenanceBadge-B9JSEjll.js";import{l as je}from"./listSkills-C1aWKf0T.js";import{S as be,V as I}from"./Library-D-Wsxrh7.js";import"./monaco-editor-BsIlgG7c.js";import"./Button-9dIPAOBg.js";const Se=250,we=2e3;function ye(m,p){return{user:{skills:`${m}/.claude/skills`,commands:`${m}/.claude/commands`},project:p?{skills:`${p}/.claude/skills`,commands:`${p}/.claude/commands`}:null}}function Ce(){const m=ce(),p=de(),x=(p==null?void 0:p.cwd)??null,v=ue(t=>t.navFace),S=a.useRef(!1),V=a.useRef(v),[u,$]=a.useState(()=>v==="project"&&x?"project":"user"),[f,w]=a.useState([]),[o,D]=a.useState(null),[y,L]=a.useState("installed"),[O,Z]=a.useState(""),[q,H]=a.useState([]),[U,F]=a.useState(null),C=a.useMemo(()=>m?ye(m,x):null,[m,x]);a.useEffect(()=>{if(V.current!==v){if(V.current=v,S.current){S.current=!1;return}$(v==="project"&&x?"project":"user")}},[v,x]);const c=a.useMemo(()=>C?u==="user"?C.user:C.project:null,[u,C]),P=a.useRef(0),N=a.useCallback(async()=>{const t=++P.current;if(!c){w([]),H([]);return}const l=[],n=[];try{const e=await je(c.skills);n.push(...e.errors);for(const r of e.entries)l.push({kind:"skills",scope:u,name:r.name,path:r.path,dir:r.dir,disabled:he(r.text),description:pe(r.text).description??void 0})}catch(e){n.push({path:c.skills,error:e instanceof Error?e.message:String(e)})}try{const e=await window.api.config.listDir(c.commands,{filesOnly:!0});e.ok||n.push({path:c.commands,error:e.error??"failed to list directory"});for(const r of e.entries)r.name.endsWith(".md")&&l.push({kind:"commands",scope:u,name:r.name.replace(/\.md$/,""),path:r.path,dir:null,disabled:!1})}catch(e){n.push({path:c.commands,error:e instanceof Error?e.message:String(e)})}if(P.current===t){for(const e of n)E.error(`Could not read ${e.path}: ${e.error}`);H(n),l.sort((e,r)=>e.kind===r.kind?e.name.localeCompare(r.name):e.kind==="skills"?-1:1),w(l),D(e=>{var r;return l.find(i=>i.path===e)?e:((r=l[0])==null?void 0:r.path)??null})}},[c,u]);a.useEffect(()=>{N()},[N]),a.useEffect(()=>()=>{P.current+=1},[]);const X=a.useRef(N);X.current=N;const z=a.useRef(f);z.current=f;const G=a.useRef(o);G.current=o;const g=a.useRef(null),W=a.useRef(!1),A=a.useRef(!1),M=a.useCallback(async()=>{if(W.current){A.current=!0;return}W.current=!0;try{await X.current()}finally{W.current=!1}A.current&&(A.current=!1,M())},[]);a.useEffect(()=>()=>{g.current&&clearTimeout(g.current)},[]);const ee=a.useCallback(t=>{var r;const l=G.current,n=l?z.current.find(i=>i.path===l):null,e=l?(r=d.getState().files[l])==null?void 0:r.lastSavedAt:null;n!=null&&n.dir&&e&&Date.now()-e<we&&(t===n.dir||n.dir.startsWith(`${t}/`))||(g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,M()},Se))},[M]);fe(c?[c.skills,c.commands]:[],ee);const b=d(t=>t.files),te=d(t=>t.loadText),se=d(t=>t.setDraft),re=d(t=>t.saveText),ae=d(t=>t.revert),ne=d(t=>t.watchFile),J=d(t=>t.unwatchFile);async function le(t,l){const n=await window.api.config.readText(t.path);if(!n.exists)return;const e=ve(n.text,l);if(e===n.text)return;const r=await window.api.config.writeText(t.path,e);if(!r.ok){E.error(r.error??"failed to update skill");return}w(i=>i.map(j=>j.path===t.path?{...j,disabled:l}:j)),d.getState().files[t.path]&&d.getState().loadText(t.path,!0)}async function oe(t){if(!t.dir)return;F(null);const l=await window.api.files.delete(t.dir);if(!l.ok){E.error(l.error??"failed to remove skill");return}E.info(`Removed "${t.name}" — moved to trash`),J(t.path),w(n=>{const e=n.filter(r=>r.path!==t.path);return D(r=>{var i;return r!==t.path?r:((i=e[0])==null?void 0:i.path)??null}),e})}a.useEffect(()=>{if(o)return b[o]||te(o),ne(o),()=>J(o)},[o]);const[ie,R]=a.useState(null);if(!m)return s.jsx(T,{title:"loading…"});if(y==="library")return s.jsx(B,{toolbar:s.jsx(I,{active:y,onChange:L,installedLabel:"Installed",libraryLabel:"Library"}),children:s.jsx(be,{})});if(u==="project"&&!x)return s.jsx(B,{toolbar:s.jsxs(s.Fragment,{children:[s.jsx(I,{active:y,onChange:L}),s.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),s.jsx(Q,{scopes:["user","project"],active:u,onChange:t=>{S.current=!0,$(t)}})]}),children:s.jsx(T,{title:"no active project",hint:"open a tab in a project directory to view project skills & commands"})});const h=f.find(t=>t.path===o)??null,k=o?b[o]:null;return s.jsx(B,{toolbar:s.jsxs(s.Fragment,{children:[s.jsx(I,{active:y,onChange:L}),s.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),s.jsx(Q,{scopes:["user","project"],active:u,onChange:t=>{S.current=!0,$(t)}}),s.jsxs("span",{className:"ml-3 text-fg-faint",children:[f.length," ",f.length===1?"item":"items"]}),s.jsx("div",{className:"flex-1"}),h&&s.jsx(Y,{scope:h.scope,input:{type:h.kind==="commands"?"command":"skill",name:h.name}}),s.jsx("span",{className:"ml-2 text-fg-faint truncate",children:(h==null?void 0:h.path)??""})]}),footer:o&&k?s.jsx(ge,{dirty:k.dirty,busy:k.busy,parseError:ie,lastSavedAt:k.lastSavedAt,onSave:async()=>{R(null);const t=await re(o);t.ok||R(t.error??"save failed")},onRevert:()=>{R(null),ae(o)}}):null,children:s.jsx(me,{sidebar:s.jsxs("div",{className:"py-1",children:[s.jsx("div",{className:"px-2 pb-1",children:s.jsx("input",{value:O,onChange:t=>Z(t.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(t=>{const l=O.toLowerCase(),n=f.filter(e=>e.kind===t&&(!l||e.name.toLowerCase().includes(l)));return s.jsxs("div",{className:"mb-3",children:[s.jsx("div",{className:"px-3 py-1 text-xs uppercase tracking-wider text-fg-faint",children:t==="skills"?"Skills":"Slash Commands"}),n.length===0?s.jsx("div",{className:"px-3 py-1 text-xs text-fg-faint italic",children:"none"}):n.map(e=>{var i,j,K;const r=e.kind==="skills";return s.jsxs("div",{className:`w-full px-3 py-1 text-xs flex items-center justify-between gap-2 ${o===e.path?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[s.jsxs("button",{onClick:()=>D(e.path),className:"flex-1 min-w-0 text-left",children:[s.jsxs("div",{className:`truncate ${e.disabled?"line-through opacity-50":""}`,title:e.disabled?"Disabled — Claude will not auto-invoke this skill":void 0,children:[e.kind==="commands"?"/":"",e.name]}),e.description&&s.jsx("div",{className:"truncate text-fg-faint",children:e.description})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx(Y,{interactive:!1,scope:e.scope,input:{type:e.kind==="commands"?"command":"skill",name:e.name}}),((i=b[e.path])==null?void 0:i.dirty)&&s.jsx("span",{className:"w-1 h-1 rounded-full bg-accent"}),r&&s.jsx("span",{title:(j=b[e.path])!=null&&j.dirty?"This skill has unsaved edits — save or revert before toggling":void 0,children:s.jsx(ke,{checked:!e.disabled,disabled:!!((K=b[e.path])!=null&&K.dirty),onChange:_=>void le(e,!_)})}),e.kind==="skills"&&U===e.path&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>void oe(e),title:`Remove ${e.name} — moves the folder to trash; reinstall from the Library`,className:"text-[10px] font-semibold text-red-400 hover:text-red-300",children:"confirm"}),s.jsx("button",{onClick:()=>F(null),title:"Cancel",className:"text-[10px] text-fg-faint hover:text-fg",children:"cancel"})]}),e.kind==="skills"&&U!==e.path&&s.jsx("button",{onClick:_=>{_.stopPropagation(),F(e.path)},title:"Remove skill — moves the folder to trash; reinstall from the Library","aria-label":`Remove ${e.name}`,className:"text-fg-faint hover:text-red-400 leading-none px-0.5",children:"✕"})]})]},e.path)})]},t)})]}),detail:o&&k?s.jsx("div",{className:"h-full",children:s.jsx(xe,{path:o,value:k.draftRaw,onChange:t=>{R(null),se(o,t)}})}):f.length===0&&q.length>0?s.jsx("div",{"data-testid":"skills-list-error",children:s.jsx(T,{title:"could not list skills or commands",hint:q.map(t=>`${t.path}: ${t.error}`).join(`
|
|
2
2
|
`)})}):s.jsx(T,{title:f.length===0?"no skills or commands":"select an item"})})})}const _e=a.memo(Ce);export{_e as Skills};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aB as i,aW as g,al as e,$ as R,aT as O,a$ as _,aj as $,ak as B,aP as I,a3 as V,e as z,g as M,s as T,r as D,k as H,a8 as W,b0 as q,C as G,m as P,a7 as J}from"./index-
|
|
1
|
+
import{aB as i,aW as g,al as e,$ as R,aT as O,a$ as _,aj as $,ak as B,aP as I,a3 as V,e as z,g as M,s as T,r as D,k as H,a8 as W,b0 as q,C as G,m as P,a7 as J}from"./index-DzY_GXYY.js";import{P as A}from"./Panel-DZHiD8Ar.js";import{S as K}from"./SaveBar-mVKig6hL.js";import{f as Q,V as U}from"./Library-D-Wsxrh7.js";import"./monaco-editor-BsIlgG7c.js";import"./Button-9dIPAOBg.js";import"./listSkills-C1aWKf0T.js";const X=300;function Y({activePath:s,selectedPath:o,onSelect:f}){const[l,a]=i.useState([]),h=i.useRef(0),r=i.useRef(f);r.current=f;const k=g(n=>{var d;return s?(d=n.files[s])==null?void 0:d.diskRaw:void 0}),m=i.useRef(null);if(i.useEffect(()=>{r.current(null)},[s]),i.useEffect(()=>{if(h.current+=1,!s){m.current=null,a([]);return}const n=m.current!==s;m.current=s;let d=!1;const u=()=>{h.current+=1;const b=h.current;window.api.config.parseImports(s).then(v=>{d||h.current!==b||(v.ok?a(v.imports):(a([]),O.error(v.error||"failed to parse @-imports")))})},j=n?null:setTimeout(u,X);return n&&u(),()=>{d=!0,j&&clearTimeout(j)}},[s,k]),l.length===0||!s)return null;const x=o===s||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 · ",l.length+1]}),e.jsxs("button",{type:"button",onClick:()=>f(null),"aria-current":x,"data-testid":"referenced-file-root",className:`w-full text-left px-3 py-2 border-b border-line ${x?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg"}`,children:[e.jsx("div",{className:"text-[11.5px] font-medium truncate",children:R(s)}),e.jsx("div",{className:"text-[10px] text-fg-faint truncate",title:s,children:"this system prompt"})]}),l.map(n=>{const d=!n.ok||!n.exists,u=o===n.path;return e.jsxs("button",{type:"button",onClick:()=>f(n),"aria-current":u,"data-testid":"referenced-file-row",className:`w-full text-left px-3 py-2 border-b border-line last:border-b-0 ${u?"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:R(n.path)}),d&&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:n.path,children:n.path}),e.jsxs("div",{className:"text-[10px] text-fg-faint",children:[n.sizeBytes.toLocaleString()," bytes · ~",n.tokenEstimate.toLocaleString()," tokens"]})]},n.path)})]})}function Z({path:s,value:o,onChange:f,onSave:l,readOnly:a,defaultMode:h,headerRight:r,hideStatusBar:k}){const m=_(),x=$(s),n=B(s),d=I(s),[u,j]=i.useState(()=>a&&n?"preview":h??V(s)),[b,v]=i.useState(!0),[w,L]=i.useState(null),E=i.useRef(null),c=i.useRef(null),y=i.useCallback(t=>{E.current=t},[]),S=i.useCallback(()=>E.current,[]),C=a?n?["preview","edit"]:[]:d?["edit","preview","split"]:n?["edit","preview"]:[],p=n?u:"edit",N=e.jsx(z,{path:s,name:R(s),value:o,onChange:f,onSave:()=>l==null?void 0:l(),onReady:y,onCursor:L,readOnly:a});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:R(s)}),a&&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&&(p==="preview"||p==="split")&&e.jsx("button",{onClick:()=>v(t=>!t),"data-testid":"document-outline-toggle",className:`px-2 py-0.5 text-[10px] border border-line rounded ${b?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Toggle document outline",children:"Outline"}),C.length>0&&e.jsx("div",{className:"flex items-center ml-1 rounded border border-line overflow-hidden","data-testid":"document-mode-toggle",children:C.map(t=>e.jsx("button",{onClick:()=>j(t),className:`px-2 py-0.5 text-[10px] capitalize transition-colors ${p===t?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,children:t},t))})]}),e.jsx("div",{className:"flex-1 min-h-0",children:p==="split"&&x?e.jsxs("div",{className:"flex h-full",children:[b&&e.jsx(M,{text:o,scrollRef:c}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col border-r border-line",children:[!a&&e.jsx(T,{getEditor:S}),e.jsx("div",{className:"flex-1 min-h-0",children:N})]}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(D,{ref:c,text:o,flush:!0,wideMeasure:m.wideMeasure})})]}):p==="preview"&&x?e.jsxs("div",{className:"flex h-full",children:[b&&e.jsx(M,{text:o,scrollRef:c}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(D,{ref:c,text:o,wideMeasure:m.wideMeasure})})]}):x?e.jsxs("div",{className:"flex flex-col h-full",children:[!a&&e.jsx(T,{getEditor:S}),e.jsx("div",{className:"flex-1 min-h-0",children:N})]}):N}),!k&&e.jsx(H,{text:o,cursor:w,language:W(s)||void 0})]})}const F={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 ee(){const s=q(),[o,f]=i.useState("installed"),l=i.useMemo(()=>s?G.resolve("user",s,null):null,[s]),[a,h]=i.useState(null),r=(a==null?void 0:a.path)??l,k=!!a&&(!a.ok||!a.exists),m=g(t=>t.files),x=g(t=>t.loadText),n=g(t=>t.setDraft),d=g(t=>t.saveText),u=g(t=>t.revert),j=g(t=>t.watchFile),b=g(t=>t.unwatchFile);i.useEffect(()=>{if(l)return x(l,!0),j(l),()=>{b(l)}},[l]),i.useEffect(()=>{if(!(!r||r===l))return x(r,!0),j(r),()=>{b(r)}},[r,l]);const[v,w]=i.useState(null),L=i.useCallback(t=>{w(null),h(t)},[]);if(!s)return e.jsx(P,{title:"loading…"});if(o==="library")return e.jsx(A,{toolbar:e.jsx(U,{active:o,onChange:f,installedLabel:"Editor",libraryLabel:"Presets"}),children:e.jsx(Q,{})});const E=l?m[l]:null,c=r?m[r]:null,y=(c==null?void 0:c.draftRaw)??"",S=J(y),C=y.length,p=k,N=async()=>{if(!r)return;w(null);const t=await d(r);t.ok||w(t.error??"save failed")};return e.jsx(A,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(U,{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:[C.toLocaleString()," chars · ~",S.toLocaleString()," tokens"]})]}),footer:r&&c&&!p?e.jsx(K,{dirty:c.dirty,busy:c.busy,parseError:v,lastSavedAt:c.lastSavedAt,leading:c.exists?a?e.jsx("span",{children:"editing an imported file"}):null:e.jsx("span",{children:"file will be created on save"}),onSave:N,onRevert:()=>{w(null),u(r)}}):null,children:l&&E?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:F.title}),e.jsx("span",{className:"mx-1.5 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-dim",children:F.body}),e.jsx("span",{className:"ml-1.5 font-mono text-fg-faint",children:l})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex",children:[e.jsx(Y,{activePath:l,selectedPath:r,onSelect:L}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[p&&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(Z,{path:r,value:y,readOnly:p,defaultMode:"split",onChange:t=>{w(null),n(r,t)},onSave:()=>{N()}},r)})]})]})]}):e.jsx(P,{title:"resolving…"})})}const oe=i.memo(ee);export{oe as SystemPrompt};
|