claude-code-session-manager 0.82.0 → 0.84.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentLibrary-pwlkAFb3.js → AgentLibrary-CCVIpoSz.js} +1 -1
- package/dist/assets/{DataModel-BZK9PXFD.js → DataModel-BltREYde.js} +1 -1
- package/dist/assets/{History-BVRjxJjS.js → History-BZxFkOp6.js} +2 -2
- package/dist/assets/{Hooks-CNuwHeGx.js → Hooks-Bznlfaaa.js} +1 -1
- package/dist/assets/{HostBilko-cjwNodhV.js → HostBilko-DUG5YHA_.js} +1 -1
- package/dist/assets/{Library-YPNm9W92.js → Library-Bi2Fn3w9.js} +1 -1
- package/dist/assets/{ListDetail-CY4GM1Om.js → ListDetail-4VBvXKrz.js} +1 -1
- package/dist/assets/{MarkdownEditor-BF4y2Jiz.js → MarkdownEditor-D2ft_v5j.js} +1 -1
- package/dist/assets/{McpServers-CmBdWtX_.js → McpServers-FDekKkyE.js} +1 -1
- package/dist/assets/{Memory-CvkIXNl1.js → Memory-Dkl80uj_.js} +6 -6
- package/dist/assets/{Panel-D93o-sxe.js → Panel-LurG5VfD.js} +1 -1
- package/dist/assets/{Permissions-DQipg16I.js → Permissions-D2wHBCFA.js} +1 -1
- package/dist/assets/{Plugins-B6NwzPfK.js → Plugins-CTw_wwbI.js} +2 -2
- package/dist/assets/{ProvenanceBadge-DACVJhrB.js → ProvenanceBadge-CW6HNUv6.js} +1 -1
- package/dist/assets/{SaveBar-Cg4lbChb.js → SaveBar-alDHG6cP.js} +1 -1
- package/dist/assets/{Scheduler-Dr5ZcBLe.js → Scheduler-DxiPcaiW.js} +7 -7
- package/dist/assets/{ScopeSwitcher-C-locvy0.js → ScopeSwitcher-DzFXUKLZ.js} +1 -1
- package/dist/assets/Settings-B6H3v2am.js +3 -0
- package/dist/assets/{SkillReferenceGraph-DDzuYgSK.js → SkillReferenceGraph-B8EZalpN.js} +1 -1
- package/dist/assets/{Skills-DFvhiOAQ.js → Skills-DwuHuA08.js} +2 -2
- package/dist/assets/SystemPrompt-CMMqpGYn.js +1 -0
- package/dist/assets/{TagLibrary-DruUYaAc.js → TagLibrary-C2N5C1n9.js} +1 -1
- package/dist/assets/{TiptapBody-Dr4a--42.js → TiptapBody-btlID-dQ.js} +1 -1
- package/dist/assets/{Toggle-B_EH2TFb.js → Toggle-BGOn3DZj.js} +1 -1
- package/dist/assets/{index-DApB4DHS.js → index-QLRf0epp.js} +316 -314
- package/dist/assets/{index-CYhdtisq.css → index-mnjNDpb1.css} +1 -1
- package/dist/assets/{settingsSchema-BKa-xk8g.js → settingsSchema-DA3N2Up3.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +4 -1
- package/scripts/hooks/guard-destructive-git.cjs +514 -0
- package/scripts/hooks/guard-inline-implementation.cjs +219 -0
- package/scripts/hooks/guard-prd-writes.cjs +200 -0
- package/src/main/__tests__/epicMintTelemetryTap.test.cjs +64 -0
- package/src/main/__tests__/health-delegation-chain.test.cjs +2 -1
- package/src/main/__tests__/health-queue-dispatch.test.cjs +84 -0
- package/src/main/__tests__/health-usage-poller.test.cjs +97 -0
- package/src/main/__tests__/health-worktree-cap-blocked.test.cjs +65 -0
- package/src/main/__tests__/opsErrorLogTelemetryTap.test.cjs +143 -0
- package/src/main/__tests__/pollLoop-dispatch-on-failure.test.cjs +120 -0
- package/src/main/__tests__/promptSessionTranscript.test.cjs +0 -0
- package/src/main/__tests__/queue-starvation-dispatch-driver.test.cjs +143 -0
- package/src/main/__tests__/rateLimitPollerStreak.test.cjs +79 -0
- package/src/main/__tests__/scheduleJobTransitionsTelemetryTap.test.cjs +72 -0
- package/src/main/__tests__/scheduler-inplace-salvage.test.cjs +74 -0
- package/src/main/__tests__/scheduler-job-overrun.test.cjs +58 -0
- package/src/main/__tests__/scheduler-notify-originating-tab-transcript.test.cjs +1 -0
- package/src/main/__tests__/scheduler-periodic-reverify-guard.test.cjs +134 -2
- package/src/main/__tests__/scheduler-reap-dead-running-jobs.test.cjs +33 -0
- package/src/main/__tests__/scheduler-stuck-failed-escalation.test.cjs +136 -0
- package/src/main/__tests__/telemetryClient.test.cjs +810 -0
- package/src/main/__tests__/telemetryContract.test.cjs +883 -0
- package/src/main/crashDiagnostics.cjs +29 -1
- package/src/main/health.cjs +197 -3
- package/src/main/index.cjs +65 -6
- package/src/main/ipcSchemas.cjs +19 -2
- package/src/main/lib/__tests__/crashTelemetry.test.cjs +97 -0
- package/src/main/lib/__tests__/delegationReadiness.test.cjs +302 -4
- package/src/main/lib/__tests__/fixtures/scheduler-machine.json.corrupt-1789147548 +34 -0
- package/src/main/lib/__tests__/gitWorktree.test.cjs +413 -1
- package/src/main/lib/__tests__/jobWorktreeBootLive.test.cjs +71 -0
- package/src/main/lib/__tests__/queueStoreAtomicWrite.test.cjs +88 -0
- package/src/main/lib/__tests__/queueStoreMachineStateRecovery.test.cjs +123 -0
- package/src/main/lib/__tests__/reaperHelpers.test.cjs +58 -0
- package/src/main/lib/__tests__/telemetryBacklog.test.cjs +620 -0
- package/src/main/lib/__tests__/telemetryBoot.test.cjs +125 -0
- package/src/main/lib/__tests__/telemetryConsent.test.cjs +130 -0
- package/src/main/lib/__tests__/telemetryCounters.test.cjs +57 -0
- package/src/main/lib/__tests__/telemetryCountersMetadataColumn.test.cjs +89 -0
- package/src/main/lib/crashTelemetry.cjs +37 -0
- package/src/main/lib/delegationReadiness.cjs +119 -1
- package/src/main/lib/epicMint.cjs +2 -0
- package/src/main/lib/gitWorktree.cjs +427 -17
- package/src/main/lib/jobWorktree.cjs +2 -1
- package/src/main/lib/jobWorktreeBootLive.cjs +51 -0
- package/src/main/lib/jobWorktreeTerminalOrphanLive.cjs +68 -0
- package/src/main/lib/opsErrorLog.cjs +78 -25
- package/src/main/lib/queueStore.cjs +233 -20
- package/src/main/lib/reaperHelpers.cjs +23 -1
- package/src/main/lib/scheduleJobSchema.cjs +7 -0
- package/src/main/lib/scheduleJobTransitions.cjs +12 -0
- package/src/main/lib/telemetryBacklog.cjs +601 -0
- package/src/main/lib/telemetryBoot.cjs +71 -0
- package/src/main/lib/telemetryClient.cjs +653 -0
- package/src/main/lib/telemetryConsent.cjs +34 -0
- package/src/main/lib/telemetryCounters.cjs +45 -0
- package/src/main/promptSessionTranscript.cjs +0 -0
- package/src/main/pty.cjs +2 -0
- package/src/main/scheduler.cjs +481 -33
- package/src/preload/api.d.ts +84 -4
- package/src/preload/index.cjs +9 -0
- package/dist/assets/Settings-BVrAle90.js +0 -3
- package/dist/assets/SystemPrompt-8PiTyUyL.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{N as P,ay as G,ai as x,a9 as i,Z as R,B as T,b as _}from"./index-QLRf0epp.js";import{a as E,C as B,c as L,d as S,b as I}from"./Library-Bi2Fn3w9.js";const N=e=>`${e}/.claude/session-manager/provenance.json`;function D(e){if(!e||typeof e!="object")return{};const t={};for(const[n,o]of Object.entries(e))(o==="anthropic"||o==="community"||o==="local")&&(t[n]=o);return t}const K=P((e,t)=>({overrides:{},loaded:!1,loading:!1,home:null,load:async n=>{const o=t();if(!(o.home===n&&(o.loaded||o.loading))){e({home:n,loading:!0});try{const r=await window.api.config.readJson(N(n)),d=r.exists?D(r.data):{};e(h=>({overrides:{...d,...h.overrides},loaded:!0,loading:!1}))}catch{e({loaded:!0,loading:!1})}}},setOverride:async(n,o)=>{const r={...t().overrides};o===null?delete r[n]:r[n]=o,e({overrides:r});const d=t().home;if(d)try{await window.api.config.writeJson(N(d),r)}catch{}}})),a=e=>(e??"").toLowerCase().trim(),j=new Set,$=new Set;for(const e of I){const t=e.official?j:$;t.add(a(e.id)),t.add(a(e.name))}const H=new Set(S.filter(e=>e.official).flatMap(e=>[a(e.id),a(e.name)])),J=new Set(S.filter(e=>!e.official).flatMap(e=>[a(e.id),a(e.name)])),U=new Set(L.filter(e=>e.official).flatMap(e=>[a(e.id),a(e.name)])),V=new Set(L.filter(e=>!e.official).flatMap(e=>[a(e.id),a(e.name)])),z=new Set(B.flatMap(e=>[a(e.id),a(e.name)])),Z=new Set(E.flatMap(e=>[a(e.id),a(e.name)])),q=new Set(E.map(e=>e.command.trim())),F=new Set(["security-review","pr-comments","release-notes","add-dir","code-review","simplify"]),Q=/(@anthropic-ai\/|anthropic\.com|github\.com\/anthropics)/i,W=/(^|\s)(npx|uvx|pipx|bunx|mcp-remote|deno\s+run|docker\s+run)(\s|$)/i;function X(e){return[e.command,...e.args??[],e.url,e.repository,e.homepage].filter(Boolean).join(" ").toLowerCase()}const l=e=>({provenance:"anthropic",reason:e}),y=e=>({provenance:"community",reason:e});function Y(e,t,n){switch(e){case"mcp":return j.has(t)?l("official MCP server (catalog)"):$.has(t)?y("third-party server (catalog)"):null;case"skill":case"command":return H.has(t)?l("official Anthropic skill (catalog)"):J.has(t)?y("third-party skill (catalog)"):null;case"plugin":return U.has(t)?l("official Anthropic plugin (catalog)"):V.has(t)?y("third-party plugin (catalog)"):null;case"subagent":return z.has(t)?l("bundled Anthropic subagent (catalog)"):null;case"hook":return Z.has(t)||n&&q.has(n.trim())?l("bundled hook (catalog)"):null}}function ee(e,t){return e.repository?"has a source repository":e.homepage?"has a homepage":e.url?"remote endpoint":W.test(t)?"installed from a package registry":null}function te(e){const t=a(e.name),n=X(e),o=Y(e.type,t,e.command);if(o)return o;if((e.type==="command"||e.type==="skill")&&F.has(t))return l("built-in Claude Code command");if(Q.test(n))return l("Anthropic package or repo");const r=ee(e,n);return r?y(r):{provenance:"local",reason:"no external source — assumed self-created"}}function ne(e,t,n){return`${e}:${t??"-"}:${n}`}const c={anthropic:"Anthropic",community:"Community",local:"Local"},O={anthropic:"accent",community:"warn",local:"dim"},oe=["anthropic","community","local"];function se({input:e,scope:t,interactive:n=!0,className:o=""}){const r=G(),{overrides:d,load:h,setOverride:k}=K(),[b,m]=x.useState(!1),v=x.useRef(null);x.useEffect(()=>{r&&h(r)},[r,h]),x.useEffect(()=>{if(!b)return;const s=C=>{v.current&&!v.current.contains(C.target)&&m(!1)},g=C=>{C.key==="Escape"&&m(!1)};return window.addEventListener("mousedown",s),window.addEventListener("keydown",g),()=>{window.removeEventListener("mousedown",s),window.removeEventListener("keydown",g)}},[b]);const w=ne(e.type,t??null,e.name),f=te(e),p=d[w],u=p??f.provenance,M=p?`Origin manually set to ${c[u]} — auto-detected ${c[f.provenance]} (${f.reason})`:`Auto-detected ${c[u]}: ${f.reason}`,A=i.jsxs(_,{tone:O[u],title:M,className:`${n?"cursor-pointer hover:brightness-125":""} ${o}`,children:[c[u],p&&i.jsx("span",{className:"w-1 h-1 rounded-full bg-current opacity-70","aria-hidden":!0})]});return n?i.jsxs("span",{ref:v,className:"relative inline-flex",children:[i.jsx("button",{type:"button",onClick:s=>{s.stopPropagation(),m(g=>!g)},className:"inline-flex","aria-label":`Origin: ${c[u]}. Click to change.`,children:A}),b&&i.jsxs("span",{className:`absolute ${R.dialog} top-full right-0 mt-1 min-w-[7.5rem] rounded-md border border-line bg-bg-elev shadow-lg py-1 text-left`,onClick:s=>s.stopPropagation(),children:[i.jsx("span",{className:"block px-2 pb-1 text-[10px] uppercase tracking-wide text-fg-faint",children:"Mark origin as"}),oe.map(s=>i.jsxs("button",{type:"button",onClick:()=>{k(w,s),m(!1)},className:`flex w-full items-center gap-2 px-2 py-1 text-[12px] hover:bg-bg-hi/60 ${u===s?"text-fg":"text-fg-dim"}`,children:[i.jsx("span",{className:`w-2 h-2 rounded-full border ${T[O[s]]}`,"aria-hidden":!0}),c[s],p===s&&i.jsx("span",{className:"ml-auto text-[10px] text-fg-faint",children:"set"})]},s)),i.jsx("div",{className:"my-1 border-t border-line"}),i.jsxs("button",{type:"button",onClick:()=>{k(w,null),m(!1)},disabled:!p,className:"flex w-full items-center gap-2 px-2 py-1 text-[12px] text-fg-dim hover:bg-bg-hi/60 disabled:opacity-40 disabled:hover:bg-transparent",title:`Revert to auto-detection (${c[f.provenance]})`,children:["Auto-detect",i.jsx("span",{className:"ml-auto text-[10px] text-fg-faint",children:c[f.provenance]})]})]})]}):A}export{se as P};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a9 as e,a4 as x}from"./index-QLRf0epp.js";function m({dirty:a,busy:n,parseError:t,lastSavedAt:c,onSave:i,onRevert:l,leading:d}){const s=a&&!n&&!t;return e.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-2 text-xs",children:[e.jsx("div",{className:"flex-1 min-w-0 truncate text-fg-faint",children:d}),t&&e.jsx("span",{className:"text-red-400 truncate max-w-xs",title:t,children:t}),!a&&!t&&c&&e.jsx("span",{className:"text-fg-faint",children:x(c)}),a&&!t&&e.jsx("span",{className:"text-accent",children:"unsaved"}),e.jsx("button",{onClick:l,disabled:!a||n,className:"px-2 py-0.5 border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-40 disabled:cursor-not-allowed",children:"Revert"}),e.jsx("button",{onClick:i,disabled:!s,className:`px-2.5 py-0.5 rounded border ${s?"border-accent bg-accent/15 text-accent hover:bg-accent/25":"border-line text-fg-faint opacity-50 cursor-not-allowed"}`,children:n?"Saving…":"Save"})]})}export{m as S};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a9 as e,aE as ve,ai as i,aB as Te,a as ue,Y as U,as as L,a3 as H,a5 as re,$ as z,ah as be,aC as le,am as we,an as je,a0 as Se,aH as ce,x as Le,ad as W,q as Me,L as Oe,m as Ue,k as Ne,s as ye,O as Qe,D as B,d as D,a1 as Fe,v as _e,T as Ye,ae as Pe,aw as $e,j as ae,r as Ce,i as We,aq as Ke,z as Xe,p as He,ay as Ze,av as se,w as et,C as tt,aF as st,aj as nt,y as at,aI as rt,aG as Ae,l as lt,n as he}from"./index-QLRf0epp.js";import{l as it}from"./listSkills-QORduPIk.js";import{T as ot}from"./Toggle-BGOn3DZj.js";import"./monaco-editor-BW5C4Iv1.js";function dt({options:t,active:s,onChange:n}){return e.jsx("div",{className:"inline-flex gap-1 bg-bg-hi p-1 rounded-xl shadow-[inset_0_0_0_1px] shadow-line",children:t.map(({key:a,label:d})=>{const o=s===a;return e.jsx("button",{type:"button",onClick:()=>n(a),className:`px-[18px] py-[7px] rounded-lg text-[13.5px] transition-colors ${o?"bg-bg-elev shadow-[inset_0_0_0_1px] shadow-line font-semibold text-fg":"font-medium text-fg-dim hover:text-fg"}`,children:d},a)})})}const ct=5e3;let oe=null,ne=null;async function De(t){const s=Date.now();return!(t!=null&&t.fresh)&&oe&&s-oe.at<ct?oe.result:ne||(ne=(async()=>{try{const n=await window.api.schedule.lintQueue();return oe={result:n,at:Date.now()},n}finally{ne=null}})(),ne)}function qe({options:t,value:s,onChange:n,pillPadding:a="px-3 py-1.5"}){return e.jsx("div",{className:"flex gap-1.5 flex-wrap",children:t.map(d=>{const o=d.value===s;return e.jsxs("button",{type:"button",onClick:()=>n(d.value),className:`rounded-full ${a} text-[12.5px] border transition-colors ${o?"bg-accent text-white border-accent font-semibold":"bg-bg-hi text-fg-dim border-line hover:border-fg-faint font-medium"}`,children:[d.label,d.count!==void 0&&e.jsxs("span",{children:[" ",d.count]})]},d.value)})})}const ut=5,xt=1440*60*1e3,Be="sm.scheduler.hiddenCompletedSlugs",de="sm.scheduler.focusedJobIndex",Ge="sm.scheduler.queueFilter";function pt(t,s=60){const n=t.trim();return n.length<=s?n:`${n.slice(0,s-1)}…`}const mt=["all","running","investigating","pending","completed","skipped","needs_review","failed","quarantined"];function ht(){try{const t=localStorage.getItem(Ge);if(!t)return{text:"",status:"all"};const s=JSON.parse(t);return{text:"",status:mt.includes(s.status)?s.status:"all"}}catch{return{text:"",status:"all"}}}function ft(t){try{localStorage.setItem(Ge,JSON.stringify({status:t.status}))}catch{}}function gt(t,s){if(s.status==="all"&&!s.text)return t;const n=s.text.toLowerCase();return t.filter(a=>{if(s.status!=="all"&&a.status!==s.status)return!1;if(!n)return!0;const d=be(a.cwd)??"";return a.title.toLowerCase().includes(n)||a.slug.toLowerCase().includes(n)||d.toLowerCase().includes(n)})}function bt(){try{const t=localStorage.getItem(Be);if(!t)return new Set;const s=JSON.parse(t);return Array.isArray(s)?new Set(s.filter(n=>typeof n=="string")):new Set}catch{return new Set}}function Re(t){try{localStorage.setItem(Be,JSON.stringify([...t]))}catch{}}function vt({scopeCwd:t=null,navigate:s}){const n=ve(p=>p.snapshot),a=i.useMemo(()=>!n||!t?n:{...n,jobs:n.jobs.filter(p=>p.cwd===t)},[n,t]),[d,o]=i.useState(null),[r,u]=i.useState(!1),[x,c]=i.useState(()=>Date.now()),[b,v]=i.useState(()=>bt()),[h,j]=i.useState(!1),[k,C]=i.useState(()=>ht()),[w,y]=i.useState(!1),[N,g]=i.useState("queue"),f=i.useRef(null),[A,$]=i.useState(()=>{try{return Number(localStorage.getItem(de))||0}catch{return 0}}),[G,xe]=i.useState(""),J=Te();i.useEffect(()=>(window.api.schedule.health().then(o).catch(()=>{}),window.api.schedule.onState(()=>{window.api.schedule.health().then(o).catch(()=>{})})),[]),i.useEffect(()=>{if(!J)return;c(Date.now());const p=setInterval(()=>c(Date.now()),1e3);return()=>clearInterval(p)},[J]);const M=i.useMemo(()=>{if(!a)return 15e4;const p=[];for(const S of a.jobs)if(S.status==="completed"&&S.startedAt&&S.finishedAt){const T=Date.parse(S.finishedAt)-Date.parse(S.startedAt);T>0&&p.push(T)}return p.length===0?15e4:p.reduce((S,T)=>S+T,0)/p.length},[a]),K=i.useRef(new Map);i.useEffect(()=>{if(!a)return;const p=[];for(const S of a.jobs){const T=K.current.get(S.slug);T&&T!==S.status&&p.push(`${S.title}: ${T} → ${S.status}`),K.current.set(S.slug,S.status)}p.length>0&&xe(p.join("; "))},[a]);const X=i.useMemo(()=>{var S;const p=new Map;for(const T of((S=a==null?void 0:a.lastTick)==null?void 0:S.holds)??[])p.set(T.slug,T);return p},[a==null?void 0:a.lastTick]),Z=i.useCallback(p=>{var T,ie,ke;const S=(T=f.current)==null?void 0:T.querySelectorAll("[data-job-row]");if(!(!S||S.length===0)){if(p.key==="ArrowDown"){p.preventDefault();const V=Math.min(A+1,S.length-1);$(V);try{localStorage.setItem(de,String(V))}catch{}(ie=S[V])==null||ie.focus()}else if(p.key==="ArrowUp"){p.preventDefault();const V=Math.max(A-1,0);$(V);try{localStorage.setItem(de,String(V))}catch{}(ke=S[V])==null||ke.focus()}}},[A]),pe=i.useCallback(p=>{$(p);try{localStorage.setItem(de,String(p))}catch{}},[]);if(!a)return null;if(N==="supervisor")return e.jsx(Lt,{supervisorConfig:a.config.supervisor,onSetConfig:p=>window.api.schedule.setConfig({supervisor:p}),onBack:()=>g("queue")});const{config:ee,jobs:O,paused:me,lastRunAt:q,nextReset:Q,effectiveConcurrency:R}=a;if(O.length===0)return e.jsx(Nt,{navigate:s});const F={pending:0,running:0,investigating:0,completed:0,needs_review:0,failed:0};for(const p of O)p.status in F&&F[p.status]++;const te=O.filter(p=>p.status==="running"),l=yt({snap:a,now:x,avgDurationMs:M,runningJobs:te}),m=gt(O,k),P=kt(m),{inline:I,collapsedCount:E}=St(m,b,x,h),_=Rt(I,O,P,M,l.kind,x),Y=()=>{const p=new Set(b);for(const S of O)(S.status==="completed"||S.status==="failed")&&p.add(S.slug);v(p),Re(p)},Je=async()=>{const p=O.filter(ie=>ie.status!=="running").length;if(p===0)return;const S=`Archive ${p} non-running PRD${p===1?"":"s"} and remove from the queue?
|
|
2
2
|
|
|
3
|
-
Files are moved to prds-archived/<timestamp>/ and can be restored from disk. Running jobs are kept.`;if(!window.confirm(S))return;const T=await window.api.schedule.clearQueue();T.ok||L.error(`Clear queue failed: ${T.error??"unknown error"}`)},Ve=()=>{w(new Set),Re(new Set),j(!1)},ze=I.some(p=>p.status==="completed");return e.jsxs("div",{className:"overflow-y-auto h-full",children:[e.jsx("div",{"aria-live":"polite","aria-atomic":"true",className:"sr-only",children:G}),e.jsxs("div",{className:"px-9 py-6 max-w-[1100px] mx-auto space-y-4",children:[e.jsxs("div",{className:`flex flex-wrap items-center gap-3 px-4 py-3 rounded-xl border ${kt(l.kind)}`,title:l.tooltip,children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:`w-[38px] h-[38px] rounded-xl bg-bg border border-line flex items-center justify-center shrink-0 ${St(l.kind)}`,children:e.jsx(ue,{name:"clock",size:19})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] text-fg truncate",children:$t(Ct(l.line1,a.utilization))}),l.line2&&e.jsx("div",{className:"text-[12px] text-fg-faint font-mono mt-0.5 truncate",children:l.line2})]})]}),e.jsxs("span",{className:"ml-auto font-mono text-[11.5px] text-fg-faint whitespace-nowrap",children:[(R==null?void 0:R.cap)??5," slot",((R==null?void 0:R.cap)??5)!==1?"s":""," · last batch ",U(q?Date.parse(q):null,d)]}),l.action&&e.jsx("button",{type:"button",onClick:l.action.onClick,className:"text-[12px] px-3 py-1.5 border border-line hover:border-fg-faint rounded-lg shrink-0 hover:bg-bg-hi text-fg-dim hover:text-fg",title:l.action.title,children:l.action.label})]}),c&&c.consecutiveFailures>5&&c.lastFailureKind==="meter_rate_limited"&&!me&&!v&&e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 bg-amber-400/15 border border-amber-400/30 rounded-xl",children:[e.jsx("span",{"aria-hidden":"true",children:"⚠"}),e.jsxs("span",{className:"text-[13.5px] text-amber-400/90",children:[e.jsx("strong",{className:"font-semibold",children:"Usage meter unavailable"})," — last good reading"," ",U(c.lastPollAt,d),". Firing on a conservative estimate until it recovers."]}),e.jsx("button",{type:"button",onClick:()=>y(!0),className:"ml-auto text-[12px] text-amber-400/70 hover:text-amber-400 shrink-0",title:"Dismiss this banner. The scheduler continues firing normally.",children:"Dismiss"})]}),e.jsxs("div",{className:"flex items-center gap-[18px] flex-wrap bg-bg-elev border border-line rounded-xl px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[13px] text-fg-dim",children:"Start jobs"}),e.jsxs("select",{value:ee.firePolicy??"when-available",onChange:p=>window.api.schedule.setConfig({firePolicy:p.target.value}),className:"appearance-none border border-line bg-bg-hi rounded-lg px-2.5 py-1.5 font-sans text-[13px] text-fg font-medium",title:"when-available: poll usage and fire when tokens are below threshold. on-reset: fire after each 5h reset. manual: only on Run now.",children:[e.jsx("option",{value:"when-available",children:"when available"}),e.jsx("option",{value:"on-reset",children:"only on reset"}),e.jsx("option",{value:"manual",children:"manually"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[13px] text-fg-dim",children:"Up to"}),(R==null?void 0:R.source)==="env"&&e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-amber-400/90 bg-amber-400/10 border border-amber-400/30 rounded px-1.5 py-0.5",title:"Pinned by SM_SESSION_SLOTS — unset the env var to edit",children:"env"}),e.jsx("input",{type:"number",min:0,max:10,value:(R==null?void 0:R.cap)??5,disabled:(R==null?void 0:R.source)==="env",onChange:p=>{window.api.schedule.setSessionSlots(Number(p.target.value))},className:"w-11 text-center border border-line bg-bg-hi rounded-lg py-1.5 font-mono text-[13px] text-fg disabled:opacity-50 disabled:cursor-not-allowed",title:(R==null?void 0:R.source)==="env"?"pinned by SM_SESSION_SLOTS — unset the env var to edit":"Machine-wide claude -p session slots, shared with chat runs"}),e.jsx("span",{className:"text-[13px] text-fg-dim",children:"at once"})]}),(ee.firePolicy??"when-available")==="when-available"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[13px] text-fg-dim",children:"Pause above"}),e.jsx("input",{type:"number",min:0,max:100,value:ee.utilizationThreshold??90,onChange:p=>window.api.schedule.setConfig({utilizationThreshold:Number(p.target.value)}),className:"w-11 text-center border border-line bg-bg-hi rounded-lg py-1.5 font-mono text-[13px] text-fg",title:"Fire only when 5h utilization is below this percent"}),e.jsx("span",{className:"text-[13px] text-fg-dim",children:"% of window"})]}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>window.api.schedule.forceTick().then(L.fromOutcome).catch(()=>L.error("Failed to fire batch")),disabled:F.pending===0&&F.running===0,className:"bg-accent text-white rounded-lg px-4 py-2 text-[13px] font-semibold whitespace-nowrap disabled:opacity-40 disabled:cursor-not-allowed hover:opacity-90",title:"Bypasses the billing-usage poll. Use when the meter is rate-limited or you want immediate progress.",children:"Fire next batch now"}),e.jsx("button",{type:"button",onClick:()=>window.api.schedule.rescan().then(L.fromOutcome).catch(()=>L.error("Failed to rescan")),className:"bg-bg-hi border border-line text-fg-dim hover:text-fg rounded-lg px-3.5 py-2 text-[13px] font-medium",title:"Re-scan the prds/ folder. Use when you've added or edited PRDs on disk and want the queue to reflect them immediately.",children:"Refresh"})]})]}),te.length>0&&(()=>{const p=(R==null?void 0:R.cap)??5,S=O.filter(T=>T.status==="pending").length;return e.jsxs("div",{className:"flex items-center gap-2 text-[12px] font-mono",children:[e.jsxs("span",{className:"px-2 py-0.5 rounded bg-amber-400/20 text-amber-400 shrink-0",children:[te.length,"/",p," running"]}),S>0&&e.jsxs("span",{className:"text-fg-faint",children:["+",S," ready in this group"]})]})})(),O.length>0&&e.jsx(Et,{filter:k,onChange:p=>{C(p),mt(p)}}),e.jsxs("div",{className:"bg-bg-hi border border-line rounded-2xl overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-[18px] py-3 bg-bg-elev",children:[e.jsxs("span",{className:"font-serif text-base font-semibold text-fg",children:[m.length," job",m.length!==1?"s":""]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"font-mono text-[12px] text-fg-faint",children:[F.pending,"p · ",F.running,"r · ",F.completed,"d",F.failed>0&&e.jsxs("span",{className:"text-accent",children:[" · ",F.failed,"f"]})]}),ze&&e.jsx("button",{type:"button",onClick:Y,className:"text-[12.5px] text-fg-dim hover:text-fg bg-transparent border-0 cursor-pointer font-medium",title:"Hide completed jobs from this view (queue.json unchanged — they remain in history)",children:"Clear completed"}),e.jsx("button",{type:"button",onClick:Je,disabled:O.every(p=>p.status==="running"),className:"text-[12px] text-accent border border-accent/40 hover:bg-accent/10 rounded-md px-2.5 py-1 cursor-pointer font-medium disabled:opacity-40 disabled:cursor-not-allowed",title:"Archive every non-running PRD (moved to prds-archived/<timestamp>/) and remove them from the queue. Running jobs are kept.",children:"Archive & clear queue…"})]})]}),I.length===0&&E===0&&e.jsx("div",{className:"px-[18px] py-6 text-[13px] text-fg-faint italic",children:"no matching jobs"}),e.jsx("div",{ref:f,role:"list","aria-label":"Job queue",onKeyDown:Z,children:I.map((p,S)=>e.jsx(Rt,{job:p,eta:_.get(p.slug)??null,elapsedMs:p.status==="running"&&p.startedAt?d-Date.parse(p.startedAt):null,avgDurationMs:M,listIndex:S,hold:X.get(p.slug),onFocused:pe},p.slug))}),E>0&&e.jsxs("button",{type:"button",onClick:()=>j(p=>!p),className:"w-full text-left text-[12px] text-fg-faint hover:text-fg-dim px-[18px] py-3 border-t border-line",title:h?"Re-collapse old/cleared completed":"Show all completed (incl. cleared and >24h)",children:[h?"▾":"▸"," ",E," more completed",e.jsx("span",{className:"ml-1.5 font-mono text-[11.5px] text-fg-faint",children:"· fresh & capped at 5 shown inline"}),b.size>0&&e.jsx("span",{className:"ml-2 underline",onClick:p=>{p.stopPropagation(),Ve()},children:"un-hide"})]})]}),e.jsx(Lt,{snap:a,health:c,now:d,open:r,setOpen:x}),!me&&e.jsxs("div",{className:"flex gap-2.5 bg-sage/10 border border-sage/30 rounded-xl px-3.5 py-2.5 text-[13.5px] text-fg-dim leading-relaxed",children:[e.jsx("span",{"aria-hidden":"true",children:"✓"}),e.jsxs("span",{children:[e.jsx("strong",{className:"font-semibold text-fg",children:"Nothing needed from you."})," ","Close the app if you like — jobs keep running, and History shows how each one ended."]})]}),e.jsxs("div",{className:"flex items-center justify-between text-[12px] text-fg-faint pt-1 border-t border-line",children:[e.jsxs("span",{children:[Q&&e.jsxs("span",{title:`next 5h reset: ${Q}`,children:["reset ",H(Date.parse(Q)-d)]}),q&&e.jsxs("span",{className:"ml-2",title:q,children:["last run ",H(d-Date.parse(q))," ago"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>g("supervisor"),className:"hover:text-fg-dim underline",title:"Open supervisor log and settings",children:"supervisor"}),e.jsx("button",{type:"button",onClick:()=>window.api.schedule.openFolder(),className:"hover:text-fg-dim underline",children:"folder"})]})]})]})]})}const bt=[{title:"Start a session",body:"In Sessions, pick an Agent and a Mission, describe the outcome you want, then Approve & start. Its thread writes the PRD files into that session's own folder."},{title:"Queue what it wrote",body:"The PRDs tab lists every file the session produced. Queue one, or the whole session, and they appear here."},{title:"Leave it alone",body:"Jobs start themselves inside your window, pause on rate-limit, and resume at the reset. History records how each ended."}],wt=[{term:"Session",def:"One goal, one Claude session, and the folder of PRDs written to reach it."},{term:"PRD",def:"One markdown file = one job. Authored by the session."},{term:"5-hour window",def:"Your Claude billing window, on a rolling clock."},{term:"Session pool",def:"5 slots shared with terminal and session chats."}];function vt({navigate:t}){return e.jsx("div",{className:"overflow-y-auto h-full",children:e.jsx("div",{className:"px-9 py-6 max-w-[900px] mx-auto",children:e.jsxs("div",{className:"bg-bg-hi border border-line rounded-2xl px-9 py-8",children:[e.jsx("h2",{className:"m-0 font-serif text-[25px] font-semibold text-fg",children:"Nothing to run yet — the scheduler needs a session."}),e.jsx("p",{className:"mt-2 mb-6 text-[14.5px] text-fg-dim leading-relaxed max-w-[580px]",children:"You don't write PRDs here. A session breaks its goal into numbered PRD files, and this page runs them in order. Two steps, once."}),e.jsx("div",{className:"grid grid-cols-3 gap-3.5",children:bt.map((s,n)=>{const a=n===0;return e.jsxs("div",{className:`bg-bg border rounded-xl px-4 py-4 flex flex-col gap-2 ${a?"border-accent shadow-[0_0_0_3px_rgba(184,92,52,.09)]":"border-line"}`,children:[e.jsx("span",{className:`w-6 h-6 rounded-full grid place-items-center font-mono text-[12px] font-semibold ${a?"bg-accent text-white":"bg-bg-elev text-fg-dim"}`,children:n+1}),e.jsx("h3",{className:"m-0 text-[15px] font-semibold text-fg",children:s.title}),e.jsx("p",{className:"m-0 text-[13.5px] text-fg-dim leading-relaxed",children:s.body}),a&&e.jsx("button",{type:"button",onClick:()=>t==null?void 0:t("terminal"),className:"self-start bg-accent text-white rounded-lg px-3.5 py-1.5 text-[13px] font-semibold mt-1",children:"Go to Sessions →"})]},s.title)})}),e.jsx("dl",{className:"flex mt-[22px] pt-4 border-t border-line gap-5 flex-wrap",children:wt.map(({term:s,def:n})=>e.jsxs("div",{className:"flex-1 min-w-[150px]",children:[e.jsx("dt",{className:"text-[13.5px] font-semibold text-fg mb-0.5",children:s}),e.jsx("dd",{className:"m-0 text-[12.5px] text-fg-faint leading-relaxed",children:n})]},s))})]})})})}function jt({snap:t,now:s,avgDurationMs:n,runningJobs:a}){const{config:c,jobs:o,paused:r,nextReset:x,utilization:d,effectiveConcurrency:u}=t;let b=0,w=0;for(const y of o)y.status==="pending"?b++:y.status==="completed"&&w++;const h=a.length,j=b+h,k=(u==null?void 0:u.cap)??5;if(h>0){const y=a.reduce(($,G)=>($.startedAt??"")<(G.startedAt??"")?$:G),N=y.startedAt?s-Date.parse(y.startedAt):0,g=w+h,f=w+j,A=h>1?` · ${h}/${k} parallel`:"";return{kind:"running",line1:`Running ${g}/${f}${A} · ${re(N)}`,line2:h===1?y.title:a.map($=>$.title).join(", "),tooltip:a.map($=>`${$.slug} (g${$.parallelGroup})`).join("; ")}}if(r){const y=r.resumeAt?Date.parse(r.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"}[r.reason]??`Paused — ${r.reason}`,line2:r.reason==="auth"?"Run `claude` in any terminal to refresh credentials, then Resume":y!==null&&y>0?`auto-resume ${z(Date.parse(r.resumeAt))} (in ${H(y)})`:r.resumeAt?"resuming…":"no auto-resume scheduled",tooltip:r.resumeAt??"",action:{label:"Resume",onClick:()=>window.api.schedule.resume(),title:"Clear the pause and resume queue immediately"}}}if(j===0)return{kind:"idle",line1:"No work queued",line2:null};const C=c.firePolicy??"when-available";if(C==="manual")return{kind:"manual",line1:`Manual · ${b} pending`,line2:"click Fire next batch now to fire",action:{label:"Fire next batch now",onClick:()=>window.api.schedule.forceTick().then(L.fromOutcome).catch(()=>L.error("Failed to fire batch")),title:"Bypasses the billing-usage poll. Use when the meter is rate-limited or you want immediate progress."}};if(C==="on-reset"){if(!x)return{kind:"on-reset",line1:"On-reset · waiting for billing data",line2:null};const y=Date.parse(x)+c.offsetMinutes*6e4,N=y-s;return{kind:"on-reset",line1:`On-reset · ${b} pending`,line2:N>0?`fires ${z(y)} (in ${H(N)})`:"firing now…"}}const v=c.utilizationThreshold??90;if(d==null)return{kind:"auto-soon",line1:`Auto · ${b} pending`,line2:"checking token availability…"};if(d>=v){const y=x?Date.parse(x)-s:null;return{kind:"auto-throttled",line1:`Auto · throttled (util ${d.toFixed(0)}% ≥ ${v}%)`,line2:y&&y>0?`next reset ${z(Date.parse(x))} (in ${H(y)})`:"will fire when usage drops"}}return{kind:"auto-soon",line1:`Auto · ${b} pending · util ${d.toFixed(0)}%`,line2:"fires within 2 min (poll cycle)"}}function Nt(t){const s=t.filter(a=>a.status==="running"||a.status==="pending").sort((a,c)=>a.parallelGroup-c.parallelGroup||a.slug.localeCompare(c.slug)),n=new Map;return s.forEach((a,c)=>n.set(a.slug,c)),n}function yt(t,s,n,a){if(a)return{inline:t,collapsedCount:0};const c=t.filter(u=>u.status==="completed").sort((u,b)=>{const w=u.finishedAt?Date.parse(u.finishedAt):0;return(b.finishedAt?Date.parse(b.finishedAt):0)-w}),o=new Set;let r=0;for(const u of c){if(r>=dt)break;s.has(u.slug)||u.finishedAt&&n-Date.parse(u.finishedAt)>ct||(o.add(u.slug),r++)}const x=[];let d=0;for(const u of t){if(u.status==="failed"&&s.has(u.slug)){d++;continue}if(u.status!=="completed"){x.push(u);continue}o.has(u.slug)?x.push(u):d++}return{inline:x,collapsedCount:d}}function kt(t){return t==="running"?"bg-amber-400/10 border-amber-400/25":t==="paused"?"bg-amber-500/10 border-amber-500/25":t==="auto-throttled"?"bg-amber-500/5 border-amber-500/15":"bg-bg-elev border-line"}function St(t){return t==="running"||t==="auto-soon"?"text-accent":t==="idle"?"text-sage":t==="paused"||t==="auto-throttled"?"text-butter":"text-fg-faint"}const Pt=["Running","Paused","Manual","On-reset","Auto"];function $t(t){for(const s of Pt)if(t.startsWith(s))return e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-bold",children:s}),t.slice(s.length)]});return t}function Ct(t,s){return s==null||t.includes("util")?t:`${t} · util ${Math.round(s)}%`}function At(t,s,n,a,c,o){const r=new Map;if(c==="paused"||c==="manual"||c==="auto-throttled"){for(const u of t)r.set(u.slug,null);return r}const x=s.find(u=>u.status==="running"&&u.startedAt),d=x!=null&&x.startedAt?o-Date.parse(x.startedAt):0;for(const u of t){if(u.status!=="pending"){r.set(u.slug,null);continue}const b=n.get(u.slug)??0;let w=b*a;b>0&&(w-=Math.min(a,d)),r.set(u.slug,w<=5e3?"~now":`~${re(w)}`)}return r}function Dt({job:t,eta:s,elapsedMs:n,avgDurationMs:a,listIndex:c,onFocused:o,hold:r}){const[x,d]=i.useState(!1),[u,b]=i.useState(!1),w=le(A=>A.sessions),h=i.useMemo(()=>ve(t,w),[t,w]),j=h.known&&h.epicId?w[h.epicId]:null,k=i.useCallback(A=>{je(A),window.dispatchEvent(new CustomEvent("sm:navigate",{detail:"terminal"}))},[]),C=t.status==="running",v=t.status==="failed";let y=null;C&&n!==null?y=`${Se(n)} elapsed`:t.status==="completed"&&t.startedAt&&t.finishedAt?y=`took ${re(Date.parse(t.finishedAt)-Date.parse(t.startedAt))}`:s&&(y=s);const N=t.error??null,g=v&&N?N.split(`
|
|
4
|
-
`)[0]:t.status==="needs_review"&&t.verifierVerdict?ce(t.verifierVerdict):null,f=C&&n!==null?Math.min(.99,n/a):0;return e.jsxs("div",{role:"listitem",className:"border-t border-line",children:[e.jsxs("button",{type:"button","data-job-row":!0,"data-job-index":
|
|
5
|
-
`)[0],wrap:!0})]}),t.statusHistory&&t.statusHistory.length>0&&e.jsx(B,{label:"History",children:e.jsx("div",{className:"grid gap-1",children:t.statusHistory.map((A,$)=>e.jsxs("div",{className:"font-mono text-xs leading-relaxed",children:[e.jsxs("div",{className:"text-fg",children:[A.from??"(new)"," → ",A.to,e.jsxs("span",{className:"text-fg-faint",children:[" · ",z(Date.parse(A.at))]})]}),A.reason&&e.jsx("div",{className:"text-fg-faint break-words",children:A.reason})]},$))})}),e.jsxs(B,{label:"Timing",children:[e.jsx(D,{k:"started",v:t.startedAt?z(Date.parse(t.startedAt)):"—"}),e.jsx(D,{k:"finished",v:t.finishedAt?z(Date.parse(t.finishedAt)):"—"}),e.jsx(D,{k:"duration",v:t.startedAt&&t.finishedAt?re(Date.parse(t.finishedAt)-Date.parse(t.startedAt)):C&&n!==null?Se(n):"—"})]}),e.jsxs(B,{label:"Location",children:[e.jsx(D,{k:"group",v:`${t.parallelGroup} · ${t.slug}`}),e.jsx(D,{k:"cwd",v:t.cwd??"—",wrap:!0}),e.jsx(D,{k:"session",v:h.label??h.epicId??"—",wrap:!0}),e.jsx(D,{k:"session id",v:h.epicId??"—",wrap:!0}),e.jsx(D,{k:"prompt id",v:t.sourcePromptId??"—",wrap:!0}),e.jsx(D,{k:"source tab",v:t.sourceTabId??"—",wrap:!0})]}),e.jsx(B,{label:"Actions",children:e.jsxs("div",{className:"flex flex-col gap-1.5 items-start",children:[j&&e.jsx("button",{type:"button","data-testid":"job-row-prompt-session-link",title:j.goalText,onClick:()=>k(j.id),className:"text-[13px] font-semibold text-accent hover:text-accent/80 bg-transparent border-0 cursor-pointer p-0",children:"view epic →"}),t.runId&&e.jsx("button",{type:"button",onClick:()=>b(!0),className:"text-[13px] font-semibold text-fg-dim hover:text-fg bg-transparent border-0 cursor-pointer p-0",children:"view log →"}),t.status==="quarantined"&&e.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(t.slug).then(L.fromOutcome).catch(()=>L.error("Failed to adopt PRD"))},className:"text-[13px] font-semibold text-accent hover:text-accent/80 bg-transparent border-0 cursor-pointer p-0",children:"adopt PRD →"}),t.status!=="pending"&&t.status!=="running"&&t.status!=="quarantined"&&e.jsx("button",{type:"button",onClick:()=>window.api.schedule.resetJob(t.slug),className:"text-[13px] font-semibold text-fg-dim hover:text-fg bg-transparent border-0 cursor-pointer p-0",children:"reset to pending →"})]})})]}),u&&t.runId&&e.jsx(_e,{runId:t.runId,slug:t.slug,title:t.title||t.slug,onClose:()=>b(!1)})]})}const Rt=i.memo(Dt);function Et({filter:t,onChange:s}){const n=[{label:"All",value:"all"},{label:"Running",value:"running"},{label:"Investigating",value:"investigating"},{label:"Pending",value:"pending"},{label:"Completed",value:"completed"},{label:"Skipped",value:"skipped"},{label:"Needs review",value:"needs_review"},{label:"Failed",value:"failed"},{label:"Quarantined",value:"quarantined"}];return e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-[320px]",children:[e.jsx("span",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-fg-faint inline-flex","aria-hidden":"true",children:e.jsx(ue,{name:"search",size:15})}),e.jsx("input",{type:"text",value:t.text,onChange:a=>s({...t,text:a.target.value}),placeholder:"filter jobs…",className:"w-full bg-bg-hi border border-line rounded-xl py-2 pl-9 pr-3 text-[13.5px] text-fg placeholder:text-fg-faint focus:outline-none focus:border-fg-faint","aria-label":"Filter jobs by title, slug, or project"})]}),e.jsx(qe,{options:n,value:t.status,onChange:a=>s({...t,status:a})})]})}function It({supervisorConfig:t,onSetConfig:s,onBack:n}){const[a,c]=i.useState([]),[o,r]=i.useState(()=>Date.now()),x=Te();i.useEffect(()=>{if(!x)return;window.api.supervisor.getLog().then(c).catch(()=>{}),r(Date.now());const u=setInterval(()=>r(Date.now()),5e3);return()=>clearInterval(u)},[x]);const d={enabled:(t==null?void 0:t.enabled)??!0,intervalMinutes:(t==null?void 0:t.intervalMinutes)??15,maxConcurrentProbes:(t==null?void 0:t.maxConcurrentProbes)??2,probeStaleThresholdMinutes:(t==null?void 0:t.probeStaleThresholdMinutes)??10};return e.jsxs("div",{className:"bg-bg-elev/60",children:[e.jsxs("div",{className:"px-3 py-2 flex items-center gap-2 border-b border-line",children:[e.jsx("button",{type:"button",onClick:n,className:"text-[10px] text-fg-faint hover:text-fg-dim",title:"Back to queue",children:"← queue"}),e.jsx("span",{className:"text-[11px] font-medium text-fg-dim",children:"Supervisor"}),e.jsx("button",{type:"button",onClick:()=>window.api.supervisor.getLog().then(c).catch(()=>{}),className:"ml-auto text-[10px] text-fg-faint hover:text-fg-dim underline",title:"Refresh log",children:"refresh"})]}),e.jsxs("div",{className:"px-3 py-2 space-y-1.5 border-b border-line",children:[e.jsx("div",{className:"text-[9px] text-fg-faint uppercase tracking-wider",children:"Config"}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap text-[10px] text-fg-faint",children:[e.jsxs("label",{className:"flex items-center gap-1",children:[e.jsx("input",{type:"checkbox",checked:d.enabled,onChange:u=>s({enabled:u.target.checked}),className:"cursor-pointer"}),e.jsx("span",{children:"enabled"})]}),e.jsxs("label",{className:"flex items-center gap-1",title:"How often to check for wedged jobs (minutes)",children:[e.jsx("span",{children:"interval"}),e.jsx("input",{type:"number",min:5,max:60,value:d.intervalMinutes,onChange:u=>s({intervalMinutes:Number(u.target.value)}),className:"w-10 bg-bg border border-line rounded px-1 py-0.5 font-mono"}),e.jsx("span",{children:"min"})]}),e.jsxs("label",{className:"flex items-center gap-1",title:"Max concurrent Opus probes per tick",children:[e.jsx("span",{children:"probes"}),e.jsx("input",{type:"number",min:1,max:5,value:d.maxConcurrentProbes,onChange:u=>s({maxConcurrentProbes:Number(u.target.value)}),className:"w-8 bg-bg border border-line rounded px-1 py-0.5 font-mono"})]}),e.jsxs("label",{className:"flex items-center gap-1",title:"Probe a job only if no JSONL event in this many minutes",children:[e.jsx("span",{children:"stale"}),e.jsx("input",{type:"number",min:5,max:30,value:d.probeStaleThresholdMinutes,onChange:u=>s({probeStaleThresholdMinutes:Number(u.target.value)}),className:"w-8 bg-bg border border-line rounded px-1 py-0.5 font-mono"}),e.jsx("span",{children:"min"})]})]})]}),e.jsxs("div",{className:"px-3 py-2",children:[e.jsxs("div",{className:"text-[9px] text-fg-faint uppercase tracking-wider mb-1",children:["Recent probes (last ",a.length,")"]}),a.length===0?e.jsx("div",{className:"text-[10px] text-fg-faint italic",children:"No probes yet."}):e.jsx("div",{className:"space-y-0.5 max-h-64 overflow-y-auto",children:a.map((u,b)=>e.jsx(Tt,{entry:u,now:o},`${u.ts}-${b}`))})]})]})}function Tt({entry:t,now:s}){const n=t.action!=="none",a=H(s-t.ts);return e.jsxs("div",{className:`text-[10px] px-1.5 py-1 rounded font-mono ${n?"bg-red-500/10 border border-red-500/20":"bg-bg/40"}`,title:t.reason,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsxs("span",{className:"text-fg-faint shrink-0",children:[a," ago"]}),e.jsx("span",{className:`shrink-0 px-1 rounded ${t.verdict==="stuck"?"text-red-400 bg-red-500/10":"text-green-500/70"}`,children:t.verdict}),e.jsx("span",{className:"truncate text-fg-dim",children:t.jobSlug}),n&&e.jsxs("span",{className:"shrink-0 text-red-400",children:[t.action,t.targetPid?` pid=${t.targetPid}`:""]}),t.costUsd!==null&&e.jsxs("span",{className:"shrink-0 text-fg-faint",children:["$",t.costUsd.toFixed(3)]})]}),e.jsx("div",{className:"text-fg-faint truncate mt-0.5",children:t.reason})]})}function Lt({snap:t,health:s,now:n,open:a,setOpen:c}){const[o,r]=i.useState(null),[x,d]=i.useState(!1),u=`${t.jobs.length}:${t.lastRunAt??""}`;i.useEffect(()=>{let g=!0;return d(!0),De().then(f=>{g&&r(f)}).catch(()=>{}).finally(()=>{g&&d(!1)}),()=>{g=!1}},[u]);let b=0,w=0;const h=o?o.reports.filter(g=>g.findings.length>0):[];for(const g of h)for(const f of g.findings)f.severity==="error"?b++:w++;const j=b===0&&w===0,k=o?j?`queue lint clear (${o.reports.length} scanned)`:`queue lint ${b} error${b===1?"":"s"}${w>0?`, ${w} warn${w===1?"":"s"}`:""}`:x?"scanning…":"idle",C=(s==null?void 0:s.consecutiveFailures)??0,v=s?`${C} poll failure${C===1?"":"s"} since boot`:null,y=C>0||((s==null?void 0:s.pauseReason)??null)!==null||!j,N=[v,k].filter(Boolean);return e.jsxs("div",{className:"flex flex-col gap-2 bg-bg-hi border border-line rounded-xl px-4 py-3 text-[13.5px] text-fg-dim",children:[e.jsxs("button",{type:"button",onClick:()=>c(!a),className:"flex items-center gap-2.5 w-full text-left","aria-expanded":a,title:"Scheduler poll health and queue-lint findings, in one place",children:[e.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${y?"bg-butter":"bg-sage"}`,"aria-hidden":"true"}),e.jsx("strong",{className:"text-fg font-semibold shrink-0",children:"Diagnostics"}),e.jsx("span",{className:"truncate",children:N.join(" · ")}),e.jsx("span",{className:"ml-auto text-fg-faint shrink-0","aria-hidden":"true",children:a?"▾":"▸"})]}),a&&e.jsxs("div",{className:"pl-[18px] space-y-3 font-mono text-[12px]",children:[s&&e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs("div",{children:["booted: ",U(s.bootedAt,n)]}),e.jsxs("div",{children:["last poll: ",U(s.lastPollAt,n)," · ",s.lastPollOk?"ok":"failed"]}),s.backoffNextAt!==null&&s.backoffNextAt>n&&e.jsxs("div",{children:["retry in: ",H(s.backoffNextAt-n)]}),s.nextResetCached&&e.jsxs("div",{children:["cached reset: ",z(Date.parse(s.nextResetCached))]}),s.runningJobs.length>0&&e.jsxs("div",{children:["running: ",s.runningJobs.map(g=>`${g.slug}(pid ${g.pid})`).join(", ")]})]}),o&&e.jsxs("div",{className:"space-y-1",children:[j?e.jsxs("div",{className:"text-sage",children:["✓ no issues in ",o.reports.length," PRD",o.reports.length!==1?"s":""]}):h.map(g=>e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-dim truncate",title:g.slug,children:g.slug}),g.findings.map((f,A)=>e.jsxs("div",{className:`pl-3 truncate ${f.severity==="error"?"text-accent/80":"text-butter/90"}`,title:f.snippet,children:[f.severity==="error"?"✗":"⚠"," L",f.line,": ",f.snippet]},`${g.slug}-${A}`))]},g.slug)),e.jsx("button",{type:"button",onClick:()=>{d(!0),De({fresh:!0}).then(r).catch(()=>{}).finally(()=>d(!1))},className:"text-fg-faint hover:text-fg-dim underline",children:x?"…":"rerun lint"})]})]})]})}new Set(Qe.map(t=>t.tag).filter(t=>t!=="discussion"));const Mt=["title","cwd","estimateMinutes","parallelGroup","sourcePromptId","sourceTabId","tag","agentType","dependsOn"];function Ot(t,s){return!Array.isArray(t)||!Array.isArray(s)?!1:t.length===s.length&&t.every((n,a)=>n===s[a])}function Ft(t){if(t==null)return"";if(typeof t=="boolean"||typeof t=="number")return String(t);const s=String(t);return s===""||/^(true|false|null|~)$/.test(s)||/^-?\d+(\.\d+)?$/.test(s)||/^\s|\s$/.test(s)||s.startsWith("'")||s.startsWith('"')||s.includes(`
|
|
6
|
-
`)?s.includes("'")?`"${s.replace(/"/g,'\\"')}"`:`'${s}'`:s}function
|
|
3
|
+
Files are moved to prds-archived/<timestamp>/ and can be restored from disk. Running jobs are kept.`;if(!window.confirm(S))return;const T=await window.api.schedule.clearQueue();T.ok||L.error(`Clear queue failed: ${T.error??"unknown error"}`)},Ve=()=>{v(new Set),Re(new Set),j(!1)},ze=I.some(p=>p.status==="completed");return e.jsxs("div",{className:"overflow-y-auto h-full",children:[e.jsx("div",{"aria-live":"polite","aria-atomic":"true",className:"sr-only",children:G}),e.jsxs("div",{className:"px-9 py-6 max-w-[1100px] mx-auto space-y-4",children:[e.jsxs("div",{className:`flex flex-wrap items-center gap-3 px-4 py-3 rounded-xl border ${Pt(l.kind)}`,title:l.tooltip,children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:`w-[38px] h-[38px] rounded-xl bg-bg border border-line flex items-center justify-center shrink-0 ${$t(l.kind)}`,children:e.jsx(ue,{name:"clock",size:19})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] text-fg truncate",children:At(Dt(l.line1,a.utilization))}),l.line2&&e.jsx("div",{className:"text-[12px] text-fg-faint font-mono mt-0.5 truncate",children:l.line2})]})]}),e.jsxs("span",{className:"ml-auto font-mono text-[11.5px] text-fg-faint whitespace-nowrap",children:[(R==null?void 0:R.cap)??5," slot",((R==null?void 0:R.cap)??5)!==1?"s":""," · last batch ",U(q?Date.parse(q):null,x)]}),l.action&&e.jsx("button",{type:"button",onClick:l.action.onClick,className:"text-[12px] px-3 py-1.5 border border-line hover:border-fg-faint rounded-lg shrink-0 hover:bg-bg-hi text-fg-dim hover:text-fg",title:l.action.title,children:l.action.label})]}),d&&d.consecutiveFailures>5&&d.lastFailureKind==="meter_rate_limited"&&!me&&!w&&e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 bg-amber-400/15 border border-amber-400/30 rounded-xl",children:[e.jsx("span",{"aria-hidden":"true",children:"⚠"}),e.jsxs("span",{className:"text-[13.5px] text-amber-400/90",children:[e.jsx("strong",{className:"font-semibold",children:"Usage meter unavailable"})," — last good reading"," ",U(d.lastPollAt,x),". Firing on a conservative estimate until it recovers."]}),e.jsx("button",{type:"button",onClick:()=>y(!0),className:"ml-auto text-[12px] text-amber-400/70 hover:text-amber-400 shrink-0",title:"Dismiss this banner. The scheduler continues firing normally.",children:"Dismiss"})]}),e.jsxs("div",{className:"flex items-center gap-[18px] flex-wrap bg-bg-elev border border-line rounded-xl px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[13px] text-fg-dim",children:"Start jobs"}),e.jsxs("select",{value:ee.firePolicy??"when-available",onChange:p=>window.api.schedule.setConfig({firePolicy:p.target.value}),className:"appearance-none border border-line bg-bg-hi rounded-lg px-2.5 py-1.5 font-sans text-[13px] text-fg font-medium",title:"when-available: poll usage and fire when tokens are below threshold. on-reset: fire after each 5h reset. manual: only on Run now.",children:[e.jsx("option",{value:"when-available",children:"when available"}),e.jsx("option",{value:"on-reset",children:"only on reset"}),e.jsx("option",{value:"manual",children:"manually"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[13px] text-fg-dim",children:"Up to"}),(R==null?void 0:R.source)==="env"&&e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-amber-400/90 bg-amber-400/10 border border-amber-400/30 rounded px-1.5 py-0.5",title:"Pinned by SM_SESSION_SLOTS — unset the env var to edit",children:"env"}),e.jsx("input",{type:"number",min:0,max:10,value:(R==null?void 0:R.cap)??5,disabled:(R==null?void 0:R.source)==="env",onChange:p=>{window.api.schedule.setSessionSlots(Number(p.target.value))},className:"w-11 text-center border border-line bg-bg-hi rounded-lg py-1.5 font-mono text-[13px] text-fg disabled:opacity-50 disabled:cursor-not-allowed",title:(R==null?void 0:R.source)==="env"?"pinned by SM_SESSION_SLOTS — unset the env var to edit":"Machine-wide claude -p session slots, shared with chat runs"}),e.jsx("span",{className:"text-[13px] text-fg-dim",children:"at once"})]}),(ee.firePolicy??"when-available")==="when-available"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[13px] text-fg-dim",children:"Pause above"}),e.jsx("input",{type:"number",min:0,max:100,value:ee.utilizationThreshold??90,onChange:p=>window.api.schedule.setConfig({utilizationThreshold:Number(p.target.value)}),className:"w-11 text-center border border-line bg-bg-hi rounded-lg py-1.5 font-mono text-[13px] text-fg",title:"Fire only when 5h utilization is below this percent"}),e.jsx("span",{className:"text-[13px] text-fg-dim",children:"% of window"})]}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>window.api.schedule.forceTick().then(L.fromOutcome).catch(()=>L.error("Failed to fire batch")),disabled:F.pending===0&&F.running===0,className:"bg-accent text-white rounded-lg px-4 py-2 text-[13px] font-semibold whitespace-nowrap disabled:opacity-40 disabled:cursor-not-allowed hover:opacity-90",title:"Bypasses the billing-usage poll. Use when the meter is rate-limited or you want immediate progress.",children:"Fire next batch now"}),e.jsx("button",{type:"button",onClick:()=>window.api.schedule.rescan().then(L.fromOutcome).catch(()=>L.error("Failed to rescan")),className:"bg-bg-hi border border-line text-fg-dim hover:text-fg rounded-lg px-3.5 py-2 text-[13px] font-medium",title:"Re-scan the prds/ folder. Use when you've added or edited PRDs on disk and want the queue to reflect them immediately.",children:"Refresh"})]})]}),te.length>0&&(()=>{const p=(R==null?void 0:R.cap)??5,S=O.filter(T=>T.status==="pending").length;return e.jsxs("div",{className:"flex items-center gap-2 text-[12px] font-mono",children:[e.jsxs("span",{className:"px-2 py-0.5 rounded bg-amber-400/20 text-amber-400 shrink-0",children:[te.length,"/",p," running"]}),S>0&&e.jsxs("span",{className:"text-fg-faint",children:["+",S," ready in this group"]})]})})(),O.length>0&&e.jsx(Tt,{filter:k,onChange:p=>{C(p),ft(p)}}),e.jsxs("div",{className:"bg-bg-hi border border-line rounded-2xl overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-[18px] py-3 bg-bg-elev",children:[e.jsxs("span",{className:"font-serif text-base font-semibold text-fg",children:[m.length," job",m.length!==1?"s":""]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"font-mono text-[12px] text-fg-faint",children:[F.pending,"p · ",F.running,"r · ",F.completed,"d",F.failed>0&&e.jsxs("span",{className:"text-accent",children:[" · ",F.failed,"f"]})]}),ze&&e.jsx("button",{type:"button",onClick:Y,className:"text-[12.5px] text-fg-dim hover:text-fg bg-transparent border-0 cursor-pointer font-medium",title:"Hide completed jobs from this view (queue.json unchanged — they remain in history)",children:"Clear completed"}),e.jsx("button",{type:"button",onClick:Je,disabled:O.every(p=>p.status==="running"),className:"text-[12px] text-accent border border-accent/40 hover:bg-accent/10 rounded-md px-2.5 py-1 cursor-pointer font-medium disabled:opacity-40 disabled:cursor-not-allowed",title:"Archive every non-running PRD (moved to prds-archived/<timestamp>/) and remove them from the queue. Running jobs are kept.",children:"Archive & clear queue…"})]})]}),I.length===0&&E===0&&e.jsx("div",{className:"px-[18px] py-6 text-[13px] text-fg-faint italic",children:"no matching jobs"}),e.jsx("div",{ref:f,role:"list","aria-label":"Job queue",onKeyDown:Z,children:I.map((p,S)=>e.jsx(It,{job:p,eta:_.get(p.slug)??null,elapsedMs:p.status==="running"&&p.startedAt?x-Date.parse(p.startedAt):null,avgDurationMs:M,listIndex:S,hold:X.get(p.slug),onFocused:pe},p.slug))}),E>0&&e.jsxs("button",{type:"button",onClick:()=>j(p=>!p),className:"w-full text-left text-[12px] text-fg-faint hover:text-fg-dim px-[18px] py-3 border-t border-line",title:h?"Re-collapse old/cleared completed":"Show all completed (incl. cleared and >24h)",children:[h?"▾":"▸"," ",E," more completed",e.jsx("span",{className:"ml-1.5 font-mono text-[11.5px] text-fg-faint",children:"· fresh & capped at 5 shown inline"}),b.size>0&&e.jsx("span",{className:"ml-2 underline",onClick:p=>{p.stopPropagation(),Ve()},children:"un-hide"})]})]}),e.jsx(Ot,{snap:a,health:d,now:x,open:r,setOpen:u}),!me&&e.jsxs("div",{className:"flex gap-2.5 bg-sage/10 border border-sage/30 rounded-xl px-3.5 py-2.5 text-[13.5px] text-fg-dim leading-relaxed",children:[e.jsx("span",{"aria-hidden":"true",children:"✓"}),e.jsxs("span",{children:[e.jsx("strong",{className:"font-semibold text-fg",children:"Nothing needed from you."})," ","Close the app if you like — jobs keep running, and History shows how each one ended."]})]}),e.jsxs("div",{className:"flex items-center justify-between text-[12px] text-fg-faint pt-1 border-t border-line",children:[e.jsxs("span",{children:[Q&&e.jsxs("span",{title:`next 5h reset: ${Q}`,children:["reset ",H(Date.parse(Q)-x)]}),q&&e.jsxs("span",{className:"ml-2",title:q,children:["last run ",H(x-Date.parse(q))," ago"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>g("supervisor"),className:"hover:text-fg-dim underline",title:"Open supervisor log and settings",children:"supervisor"}),e.jsx("button",{type:"button",onClick:()=>window.api.schedule.openFolder(),className:"hover:text-fg-dim underline",children:"folder"})]})]})]})]})}const wt=[{title:"Start a session",body:"In Sessions, pick an Agent and a Mission, describe the outcome you want, then Approve & start. Its thread writes the PRD files into that session's own folder."},{title:"Queue what it wrote",body:"The PRDs tab lists every file the session produced. Queue one, or the whole session, and they appear here."},{title:"Leave it alone",body:"Jobs start themselves inside your window, pause on rate-limit, and resume at the reset. History records how each ended."}],jt=[{term:"Session",def:"One goal, one Claude session, and the folder of PRDs written to reach it."},{term:"PRD",def:"One markdown file = one job. Authored by the session."},{term:"5-hour window",def:"Your Claude billing window, on a rolling clock."},{term:"Session pool",def:"5 slots shared with terminal and session chats."}];function Nt({navigate:t}){return e.jsx("div",{className:"overflow-y-auto h-full",children:e.jsx("div",{className:"px-9 py-6 max-w-[900px] mx-auto",children:e.jsxs("div",{className:"bg-bg-hi border border-line rounded-2xl px-9 py-8",children:[e.jsx("h2",{className:"m-0 font-serif text-[25px] font-semibold text-fg",children:"Nothing to run yet — the scheduler needs a session."}),e.jsx("p",{className:"mt-2 mb-6 text-[14.5px] text-fg-dim leading-relaxed max-w-[580px]",children:"You don't write PRDs here. A session breaks its goal into numbered PRD files, and this page runs them in order. Two steps, once."}),e.jsx("div",{className:"grid grid-cols-3 gap-3.5",children:wt.map((s,n)=>{const a=n===0;return e.jsxs("div",{className:`bg-bg border rounded-xl px-4 py-4 flex flex-col gap-2 ${a?"border-accent shadow-[0_0_0_3px_rgba(184,92,52,.09)]":"border-line"}`,children:[e.jsx("span",{className:`w-6 h-6 rounded-full grid place-items-center font-mono text-[12px] font-semibold ${a?"bg-accent text-white":"bg-bg-elev text-fg-dim"}`,children:n+1}),e.jsx("h3",{className:"m-0 text-[15px] font-semibold text-fg",children:s.title}),e.jsx("p",{className:"m-0 text-[13.5px] text-fg-dim leading-relaxed",children:s.body}),a&&e.jsx("button",{type:"button",onClick:()=>t==null?void 0:t("terminal"),className:"self-start bg-accent text-white rounded-lg px-3.5 py-1.5 text-[13px] font-semibold mt-1",children:"Go to Sessions →"})]},s.title)})}),e.jsx("dl",{className:"flex mt-[22px] pt-4 border-t border-line gap-5 flex-wrap",children:jt.map(({term:s,def:n})=>e.jsxs("div",{className:"flex-1 min-w-[150px]",children:[e.jsx("dt",{className:"text-[13.5px] font-semibold text-fg mb-0.5",children:s}),e.jsx("dd",{className:"m-0 text-[12.5px] text-fg-faint leading-relaxed",children:n})]},s))})]})})})}function yt({snap:t,now:s,avgDurationMs:n,runningJobs:a}){const{config:d,jobs:o,paused:r,nextReset:u,utilization:x,effectiveConcurrency:c}=t;let b=0,v=0;for(const y of o)y.status==="pending"?b++:y.status==="completed"&&v++;const h=a.length,j=b+h,k=(c==null?void 0:c.cap)??5;if(h>0){const y=a.reduce(($,G)=>($.startedAt??"")<(G.startedAt??"")?$:G),N=y.startedAt?s-Date.parse(y.startedAt):0,g=v+h,f=v+j,A=h>1?` · ${h}/${k} parallel`:"";return{kind:"running",line1:`Running ${g}/${f}${A} · ${re(N)}`,line2:h===1?y.title:a.map($=>$.title).join(", "),tooltip:a.map($=>`${$.slug} (g${$.parallelGroup})`).join("; ")}}if(r){const y=r.resumeAt?Date.parse(r.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"}[r.reason]??`Paused — ${r.reason}`,line2:r.reason==="auth"?"Run `claude` in any terminal to refresh credentials, then Resume":y!==null&&y>0?`auto-resume ${z(Date.parse(r.resumeAt))} (in ${H(y)})`:r.resumeAt?"resuming…":"no auto-resume scheduled",tooltip:r.resumeAt??"",action:{label:"Resume",onClick:()=>window.api.schedule.resume(),title:"Clear the pause and resume queue immediately"}}}if(j===0)return{kind:"idle",line1:"No work queued",line2:null};const C=d.firePolicy??"when-available";if(C==="manual")return{kind:"manual",line1:`Manual · ${b} pending`,line2:"click Fire next batch now to fire",action:{label:"Fire next batch now",onClick:()=>window.api.schedule.forceTick().then(L.fromOutcome).catch(()=>L.error("Failed to fire batch")),title:"Bypasses the billing-usage poll. Use when the meter is rate-limited or you want immediate progress."}};if(C==="on-reset"){if(!u)return{kind:"on-reset",line1:"On-reset · waiting for billing data",line2:null};const y=Date.parse(u)+d.offsetMinutes*6e4,N=y-s;return{kind:"on-reset",line1:`On-reset · ${b} pending`,line2:N>0?`fires ${z(y)} (in ${H(N)})`:"firing now…"}}const w=d.utilizationThreshold??90;if(x==null)return{kind:"auto-soon",line1:`Auto · ${b} pending`,line2:"checking token availability…"};if(x>=w){const y=u?Date.parse(u)-s:null;return{kind:"auto-throttled",line1:`Auto · throttled (util ${x.toFixed(0)}% ≥ ${w}%)`,line2:y&&y>0?`next reset ${z(Date.parse(u))} (in ${H(y)})`:"will fire when usage drops"}}return{kind:"auto-soon",line1:`Auto · ${b} pending · util ${x.toFixed(0)}%`,line2:"fires within 2 min (poll cycle)"}}function kt(t){const s=t.filter(a=>a.status==="running"||a.status==="pending").sort((a,d)=>a.parallelGroup-d.parallelGroup||a.slug.localeCompare(d.slug)),n=new Map;return s.forEach((a,d)=>n.set(a.slug,d)),n}function St(t,s,n,a){if(a)return{inline:t,collapsedCount:0};const d=t.filter(c=>c.status==="completed").sort((c,b)=>{const v=c.finishedAt?Date.parse(c.finishedAt):0;return(b.finishedAt?Date.parse(b.finishedAt):0)-v}),o=new Set;let r=0;for(const c of d){if(r>=ut)break;s.has(c.slug)||c.finishedAt&&n-Date.parse(c.finishedAt)>xt||(o.add(c.slug),r++)}const u=[];let x=0;for(const c of t){if(c.status==="failed"&&s.has(c.slug)){x++;continue}if(c.status!=="completed"){u.push(c);continue}o.has(c.slug)?u.push(c):x++}return{inline:u,collapsedCount:x}}function Pt(t){return t==="running"?"bg-amber-400/10 border-amber-400/25":t==="paused"?"bg-amber-500/10 border-amber-500/25":t==="auto-throttled"?"bg-amber-500/5 border-amber-500/15":"bg-bg-elev border-line"}function $t(t){return t==="running"||t==="auto-soon"?"text-accent":t==="idle"?"text-sage":t==="paused"||t==="auto-throttled"?"text-butter":"text-fg-faint"}const Ct=["Running","Paused","Manual","On-reset","Auto"];function At(t){for(const s of Ct)if(t.startsWith(s))return e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-bold",children:s}),t.slice(s.length)]});return t}function Dt(t,s){return s==null||t.includes("util")?t:`${t} · util ${Math.round(s)}%`}function Rt(t,s,n,a,d,o){const r=new Map;if(d==="paused"||d==="manual"||d==="auto-throttled"){for(const c of t)r.set(c.slug,null);return r}const u=s.find(c=>c.status==="running"&&c.startedAt),x=u!=null&&u.startedAt?o-Date.parse(u.startedAt):0;for(const c of t){if(c.status!=="pending"){r.set(c.slug,null);continue}const b=n.get(c.slug)??0;let v=b*a;b>0&&(v-=Math.min(a,x)),r.set(c.slug,v<=5e3?"~now":`~${re(v)}`)}return r}function Et({job:t,eta:s,elapsedMs:n,avgDurationMs:a,listIndex:d,onFocused:o,hold:r}){const[u,x]=i.useState(!1),[c,b]=i.useState(!1),v=le(A=>A.sessions),h=i.useMemo(()=>we(t,v),[t,v]),j=h.known&&h.epicId?v[h.epicId]:null,k=i.useCallback(A=>{je(A),window.dispatchEvent(new CustomEvent("sm:navigate",{detail:"terminal"}))},[]),C=t.status==="running",w=t.status==="failed";let y=null;C&&n!==null?y=`${Se(n)} elapsed`:t.status==="completed"&&t.startedAt&&t.finishedAt?y=`took ${re(Date.parse(t.finishedAt)-Date.parse(t.startedAt))}`:s&&(y=s);const N=t.error??null,g=w&&N?N.split(`
|
|
4
|
+
`)[0]:t.status==="needs_review"&&t.verifierVerdict?ce(t.verifierVerdict):null,f=C&&n!==null?Math.min(.99,n/a):0;return e.jsxs("div",{role:"listitem",className:"border-t border-line",children:[e.jsxs("button",{type:"button","data-job-row":!0,"data-job-index":d,onClick:()=>x(A=>!A),onFocus:()=>o(d),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 ${u?"bg-bg-elev/40":""}`,"aria-expanded":u,"aria-label":`${W(t.slug)?`PRD ${W(t.slug)}, `:""}${t.title}, ${t.status}${y?`, ${y}`:""}`,title:t.title,children:[e.jsx(Le,{status:t.status}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-2 text-[14.5px] font-medium text-fg leading-snug",children:[W(t.slug)&&e.jsx(Me,{n:W(t.slug)}),t.title,e.jsx(Oe,{leaked:t.leakedDescendants}),e.jsx(Ue,{count:t.leftoverCount,truncated:t.leftoverPathsTruncated,salvagePatch:t.salvagePatch})]}),g&&e.jsx("div",{className:`text-[12.5px] mt-0.5 ${w?"text-accent/80":"text-fg-faint"}`,children:g}),r&&e.jsx("div",{className:"text-[12.5px] mt-0.5 text-amber-400/90 font-mono","data-testid":"job-row-hold",children:r.dep?e.jsxs(e.Fragment,{children:["held · waiting on ",r.dep," (",r.depStatus,")"]}):e.jsxs(e.Fragment,{children:["held · ",r.reason??"launch blocked"]})}),!r&&t.status==="pending"&&t.heldReason&&e.jsxs("div",{className:"text-[12.5px] mt-0.5 text-amber-400/90 font-mono","data-testid":"job-row-held-reason",children:["held · ",t.heldReason]}),e.jsx(Ne,{epicId:h.epicId,label:h.label?pt(h.label):null,onOpen:k,testId:"job-row-prompt-session-chip",className:"mt-0.5"})]}),e.jsx(ye,{cwd:t.cwd}),e.jsxs("span",{className:"inline-flex items-center gap-2.5 font-mono text-xs text-fg-faint shrink-0",children:[e.jsx(Qe,{status:t.status,overrun:t.overrun}),y,e.jsx("span",{className:`text-fg-faint inline-flex transition-transform duration-150 ${u?"rotate-90":""}`,"aria-hidden":"true",children:e.jsx(ue,{name:"chevron",size:14})})]})]}),C&&!u&&e.jsx("div",{className:"h-1 bg-line mx-[18px] mb-3 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-accent transition-all duration-1000",style:{width:`${Math.max(4,f*100)}%`}})}),u&&e.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:[e.jsxs(B,{label:"Status",children:[e.jsx(D,{k:"result",v:t.exitCode!==null?`exit ${t.exitCode}`:"—"}),e.jsx(D,{k:"state",v:t.status.replace(/_/g," ")}),t.verifierVerdict&&e.jsx(D,{k:"verdict",v:ce(t.verifierVerdict)}),t.leakedDescendants&&t.leakedDescendants.length>0&&e.jsx(D,{k:"leaked",v:Fe(t.leakedDescendants),wrap:!0}),t.leftoverCount!=null&&t.leftoverCount>0&&e.jsx(D,{k:"uncommitted",v:`${t.leftoverCount} file${t.leftoverCount===1?"":"s"}${t.leftoverPathsTruncated?"+":""}: ${(t.leftoverPaths??[]).join(", ")}${t.salvagePatch?` — salvaged to ${t.salvagePatch}`:""}`,wrap:!0}),N&&e.jsx(D,{k:"error",v:N.split(`
|
|
5
|
+
`)[0],wrap:!0})]}),t.statusHistory&&t.statusHistory.length>0&&e.jsx(B,{label:"History",children:e.jsx("div",{className:"grid gap-1",children:t.statusHistory.map((A,$)=>e.jsxs("div",{className:"font-mono text-xs leading-relaxed",children:[e.jsxs("div",{className:"text-fg",children:[A.from??"(new)"," → ",A.to,e.jsxs("span",{className:"text-fg-faint",children:[" · ",z(Date.parse(A.at))]})]}),A.reason&&e.jsx("div",{className:"text-fg-faint break-words",children:A.reason})]},$))})}),e.jsxs(B,{label:"Timing",children:[e.jsx(D,{k:"started",v:t.startedAt?z(Date.parse(t.startedAt)):"—"}),e.jsx(D,{k:"finished",v:t.finishedAt?z(Date.parse(t.finishedAt)):"—"}),e.jsx(D,{k:"duration",v:t.startedAt&&t.finishedAt?re(Date.parse(t.finishedAt)-Date.parse(t.startedAt)):C&&n!==null?Se(n):"—"})]}),e.jsxs(B,{label:"Location",children:[e.jsx(D,{k:"group",v:`${t.parallelGroup} · ${t.slug}`}),e.jsx(D,{k:"cwd",v:t.cwd??"—",wrap:!0}),e.jsx(D,{k:"session",v:h.label??h.epicId??"—",wrap:!0}),e.jsx(D,{k:"session id",v:h.epicId??"—",wrap:!0}),e.jsx(D,{k:"prompt id",v:t.sourcePromptId??"—",wrap:!0}),e.jsx(D,{k:"source tab",v:t.sourceTabId??"—",wrap:!0})]}),e.jsx(B,{label:"Actions",children:e.jsxs("div",{className:"flex flex-col gap-1.5 items-start",children:[j&&e.jsx("button",{type:"button","data-testid":"job-row-prompt-session-link",title:j.goalText,onClick:()=>k(j.id),className:"text-[13px] font-semibold text-accent hover:text-accent/80 bg-transparent border-0 cursor-pointer p-0",children:"view epic →"}),t.runId&&e.jsx("button",{type:"button",onClick:()=>b(!0),className:"text-[13px] font-semibold text-fg-dim hover:text-fg bg-transparent border-0 cursor-pointer p-0",children:"view log →"}),t.status==="quarantined"&&e.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(t.slug).then(L.fromOutcome).catch(()=>L.error("Failed to adopt PRD"))},className:"text-[13px] font-semibold text-accent hover:text-accent/80 bg-transparent border-0 cursor-pointer p-0",children:"adopt PRD →"}),t.status!=="pending"&&t.status!=="running"&&t.status!=="quarantined"&&e.jsx("button",{type:"button",onClick:()=>window.api.schedule.resetJob(t.slug),className:"text-[13px] font-semibold text-fg-dim hover:text-fg bg-transparent border-0 cursor-pointer p-0",children:"reset to pending →"})]})})]}),c&&t.runId&&e.jsx(_e,{runId:t.runId,slug:t.slug,title:t.title||t.slug,onClose:()=>b(!1)})]})}const It=i.memo(Et);function Tt({filter:t,onChange:s}){const n=[{label:"All",value:"all"},{label:"Running",value:"running"},{label:"Investigating",value:"investigating"},{label:"Pending",value:"pending"},{label:"Completed",value:"completed"},{label:"Skipped",value:"skipped"},{label:"Needs review",value:"needs_review"},{label:"Failed",value:"failed"},{label:"Quarantined",value:"quarantined"}];return e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-[320px]",children:[e.jsx("span",{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-fg-faint inline-flex","aria-hidden":"true",children:e.jsx(ue,{name:"search",size:15})}),e.jsx("input",{type:"text",value:t.text,onChange:a=>s({...t,text:a.target.value}),placeholder:"filter jobs…",className:"w-full bg-bg-hi border border-line rounded-xl py-2 pl-9 pr-3 text-[13.5px] text-fg placeholder:text-fg-faint focus:outline-none focus:border-fg-faint","aria-label":"Filter jobs by title, slug, or project"})]}),e.jsx(qe,{options:n,value:t.status,onChange:a=>s({...t,status:a})})]})}function Lt({supervisorConfig:t,onSetConfig:s,onBack:n}){const[a,d]=i.useState([]),[o,r]=i.useState(()=>Date.now()),u=Te();i.useEffect(()=>{if(!u)return;window.api.supervisor.getLog().then(d).catch(()=>{}),r(Date.now());const c=setInterval(()=>r(Date.now()),5e3);return()=>clearInterval(c)},[u]);const x={enabled:(t==null?void 0:t.enabled)??!0,intervalMinutes:(t==null?void 0:t.intervalMinutes)??15,maxConcurrentProbes:(t==null?void 0:t.maxConcurrentProbes)??2,probeStaleThresholdMinutes:(t==null?void 0:t.probeStaleThresholdMinutes)??10};return e.jsxs("div",{className:"bg-bg-elev/60",children:[e.jsxs("div",{className:"px-3 py-2 flex items-center gap-2 border-b border-line",children:[e.jsx("button",{type:"button",onClick:n,className:"text-[10px] text-fg-faint hover:text-fg-dim",title:"Back to queue",children:"← queue"}),e.jsx("span",{className:"text-[11px] font-medium text-fg-dim",children:"Supervisor"}),e.jsx("button",{type:"button",onClick:()=>window.api.supervisor.getLog().then(d).catch(()=>{}),className:"ml-auto text-[10px] text-fg-faint hover:text-fg-dim underline",title:"Refresh log",children:"refresh"})]}),e.jsxs("div",{className:"px-3 py-2 space-y-1.5 border-b border-line",children:[e.jsx("div",{className:"text-[9px] text-fg-faint uppercase tracking-wider",children:"Config"}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap text-[10px] text-fg-faint",children:[e.jsxs("label",{className:"flex items-center gap-1",children:[e.jsx("input",{type:"checkbox",checked:x.enabled,onChange:c=>s({enabled:c.target.checked}),className:"cursor-pointer"}),e.jsx("span",{children:"enabled"})]}),e.jsxs("label",{className:"flex items-center gap-1",title:"How often to check for wedged jobs (minutes)",children:[e.jsx("span",{children:"interval"}),e.jsx("input",{type:"number",min:5,max:60,value:x.intervalMinutes,onChange:c=>s({intervalMinutes:Number(c.target.value)}),className:"w-10 bg-bg border border-line rounded px-1 py-0.5 font-mono"}),e.jsx("span",{children:"min"})]}),e.jsxs("label",{className:"flex items-center gap-1",title:"Max concurrent Opus probes per tick",children:[e.jsx("span",{children:"probes"}),e.jsx("input",{type:"number",min:1,max:5,value:x.maxConcurrentProbes,onChange:c=>s({maxConcurrentProbes:Number(c.target.value)}),className:"w-8 bg-bg border border-line rounded px-1 py-0.5 font-mono"})]}),e.jsxs("label",{className:"flex items-center gap-1",title:"Probe a job only if no JSONL event in this many minutes",children:[e.jsx("span",{children:"stale"}),e.jsx("input",{type:"number",min:5,max:30,value:x.probeStaleThresholdMinutes,onChange:c=>s({probeStaleThresholdMinutes:Number(c.target.value)}),className:"w-8 bg-bg border border-line rounded px-1 py-0.5 font-mono"}),e.jsx("span",{children:"min"})]})]})]}),e.jsxs("div",{className:"px-3 py-2",children:[e.jsxs("div",{className:"text-[9px] text-fg-faint uppercase tracking-wider mb-1",children:["Recent probes (last ",a.length,")"]}),a.length===0?e.jsx("div",{className:"text-[10px] text-fg-faint italic",children:"No probes yet."}):e.jsx("div",{className:"space-y-0.5 max-h-64 overflow-y-auto",children:a.map((c,b)=>e.jsx(Mt,{entry:c,now:o},`${c.ts}-${b}`))})]})]})}function Mt({entry:t,now:s}){const n=t.action!=="none",a=H(s-t.ts);return e.jsxs("div",{className:`text-[10px] px-1.5 py-1 rounded font-mono ${n?"bg-red-500/10 border border-red-500/20":"bg-bg/40"}`,title:t.reason,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsxs("span",{className:"text-fg-faint shrink-0",children:[a," ago"]}),e.jsx("span",{className:`shrink-0 px-1 rounded ${t.verdict==="stuck"?"text-red-400 bg-red-500/10":"text-green-500/70"}`,children:t.verdict}),e.jsx("span",{className:"truncate text-fg-dim",children:t.jobSlug}),n&&e.jsxs("span",{className:"shrink-0 text-red-400",children:[t.action,t.targetPid?` pid=${t.targetPid}`:""]}),t.costUsd!==null&&e.jsxs("span",{className:"shrink-0 text-fg-faint",children:["$",t.costUsd.toFixed(3)]})]}),e.jsx("div",{className:"text-fg-faint truncate mt-0.5",children:t.reason})]})}function Ot({snap:t,health:s,now:n,open:a,setOpen:d}){const[o,r]=i.useState(null),[u,x]=i.useState(!1),c=`${t.jobs.length}:${t.lastRunAt??""}`;i.useEffect(()=>{let g=!0;return x(!0),De().then(f=>{g&&r(f)}).catch(()=>{}).finally(()=>{g&&x(!1)}),()=>{g=!1}},[c]);let b=0,v=0;const h=o?o.reports.filter(g=>g.findings.length>0):[];for(const g of h)for(const f of g.findings)f.severity==="error"?b++:v++;const j=b===0&&v===0,k=o?j?`queue lint clear (${o.reports.length} scanned)`:`queue lint ${b} error${b===1?"":"s"}${v>0?`, ${v} warn${v===1?"":"s"}`:""}`:u?"scanning…":"idle",C=(s==null?void 0:s.consecutiveFailures)??0,w=s?`${C} poll failure${C===1?"":"s"} since boot`:null,y=C>0||((s==null?void 0:s.pauseReason)??null)!==null||!j,N=[w,k].filter(Boolean);return e.jsxs("div",{className:"flex flex-col gap-2 bg-bg-hi border border-line rounded-xl px-4 py-3 text-[13.5px] text-fg-dim",children:[e.jsxs("button",{type:"button",onClick:()=>d(!a),className:"flex items-center gap-2.5 w-full text-left","aria-expanded":a,title:"Scheduler poll health and queue-lint findings, in one place",children:[e.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${y?"bg-butter":"bg-sage"}`,"aria-hidden":"true"}),e.jsx("strong",{className:"text-fg font-semibold shrink-0",children:"Diagnostics"}),e.jsx("span",{className:"truncate",children:N.join(" · ")}),e.jsx("span",{className:"ml-auto text-fg-faint shrink-0","aria-hidden":"true",children:a?"▾":"▸"})]}),a&&e.jsxs("div",{className:"pl-[18px] space-y-3 font-mono text-[12px]",children:[s&&e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs("div",{children:["booted: ",U(s.bootedAt,n)]}),e.jsxs("div",{children:["last poll: ",U(s.lastPollAt,n)," · ",s.lastPollOk?"ok":"failed"]}),s.backoffNextAt!==null&&s.backoffNextAt>n&&e.jsxs("div",{children:["retry in: ",H(s.backoffNextAt-n)]}),s.nextResetCached&&e.jsxs("div",{children:["cached reset: ",z(Date.parse(s.nextResetCached))]}),s.runningJobs.length>0&&e.jsxs("div",{children:["running: ",s.runningJobs.map(g=>`${g.slug}(pid ${g.pid})`).join(", ")]})]}),o&&e.jsxs("div",{className:"space-y-1",children:[j?e.jsxs("div",{className:"text-sage",children:["✓ no issues in ",o.reports.length," PRD",o.reports.length!==1?"s":""]}):h.map(g=>e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-dim truncate",title:g.slug,children:g.slug}),g.findings.map((f,A)=>e.jsxs("div",{className:`pl-3 truncate ${f.severity==="error"?"text-accent/80":"text-butter/90"}`,title:f.snippet,children:[f.severity==="error"?"✗":"⚠"," L",f.line,": ",f.snippet]},`${g.slug}-${A}`))]},g.slug)),e.jsx("button",{type:"button",onClick:()=>{x(!0),De({fresh:!0}).then(r).catch(()=>{}).finally(()=>x(!1))},className:"text-fg-faint hover:text-fg-dim underline",children:u?"…":"rerun lint"})]})]})]})}new Set(Ye.map(t=>t.tag).filter(t=>t!=="discussion"));const Ft=["title","cwd","estimateMinutes","parallelGroup","sourcePromptId","sourceTabId","tag","agentType","dependsOn"];function _t(t,s){return!Array.isArray(t)||!Array.isArray(s)?!1:t.length===s.length&&t.every((n,a)=>n===s[a])}function Ht(t){if(t==null)return"";if(typeof t=="boolean"||typeof t=="number")return String(t);const s=String(t);return s===""||/^(true|false|null|~)$/.test(s)||/^-?\d+(\.\d+)?$/.test(s)||/^\s|\s$/.test(s)||s.startsWith("'")||s.startsWith('"')||s.includes(`
|
|
6
|
+
`)?s.includes("'")?`"${s.replace(/"/g,'\\"')}"`:`'${s}'`:s}function qt(t,s){var d;const n=[];for(const o of Ft){const r=t[o];if(r==null||r===""||Array.isArray(r)&&r.length===0)continue;const u=(d=t._raw)==null?void 0:d[o];if(u&&(Array.isArray(r)?_t(u.parsed,r):u.parsed===r)){n.push(u.line);continue}if(typeof r=="number"){n.push(`${o}: ${r}`);continue}if(Array.isArray(r)){n.push(`${o}: [${r.join(", ")}]`);continue}n.push(`${o}: ${Ht(r)}`)}if(t.extras)for(const o of Object.keys(t.extras)){const r=t.extras[o];!r||!r.lines.length||n.push(r.lines.join(`
|
|
7
7
|
`))}return`---
|
|
8
8
|
${n.join(`
|
|
9
9
|
`)}
|
|
10
10
|
---
|
|
11
|
-
${s}`}function fe(t){return t.filter(s=>!s.archived)}function
|
|
11
|
+
${s}`}function fe(t){return t.filter(s=>!s.archived)}function Bt(t){je(t),window.dispatchEvent(new CustomEvent("sm:navigate",{detail:"terminal"}))}function ge({label:t,tip:s,onClick:n,disabled:a,primary:d}){return e.jsx(Xe,{content:s,align:"bottom-center",children:e.jsx("button",{title:s,onClick:n,disabled:a,className:`px-2 py-0.5 text-xs rounded border disabled:opacity-40 disabled:cursor-not-allowed ${d?"text-accent border-accent/50 hover:bg-bg-hi":"text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,children:t})})}function Gt({scopeCwd:t=null}){const[s,n]=i.useState([]),[a,d]=i.useState(null),[o,r]=i.useState(null),[u,x]=i.useState(null),[c,b]=i.useState(!1),[v,h]=i.useState(!0),[j,k]=i.useState(new Set),[C,w]=i.useState(!1),[y,N]=i.useState(!1),[g,f]=i.useState(!1),[A,$]=i.useState(null);i.useEffect(()=>{let l=!0;return window.api.schedule.listPrds().then(m=>{l&&(n(fe(m)),h(!1))}).catch(m=>{l&&(h(!1),L.error(`Scheduler: failed to load PRD list — ${m instanceof Error?m.message:"unknown error"}`))}),()=>{l=!1}},[]);const G=ve(l=>l.snapshot),xe=le(l=>l.sessions);i.useEffect(()=>{G&&d(G)},[G]);const J=i.useMemo(()=>[...s].filter(l=>!t||l.cwd===t).sort((l,m)=>m.mtimeMs-l.mtimeMs||l.slug.localeCompare(m.slug)),[s,t]);i.useEffect(()=>{const l=Ke();l&&r(l);const m=P=>r(P.detail);return window.addEventListener("sm:select-prd",m),()=>window.removeEventListener("sm:select-prd",m)},[]);const M=i.useMemo(()=>(a==null?void 0:a.jobs.find(l=>l.slug===o))??null,[a,o]),K=Pe(M);function X(l){var P;const m=(P=s.find(I=>I.slug===l))==null?void 0:P.cwd;return m?`${m}/session-manager-operations/scheduler/prds/${l}.md`:null}i.useEffect(()=>{if(!o)return;const l=X(o);l&&$e.getState().openFile(l)},[o,s]);function Z(l){r(l),x(null),b(!1)}function pe(){r(null)}async function ee(){if(!o)return;if(!(M!=null&&M.runId)){x("no log available (job has not run yet)"),b(m=>!m);return}const l=await window.api.schedule.readLog(M.runId,o);x(l.ok?l.text??"":`error: ${l.error}`),b(m=>!m)}if(v)return e.jsx(ae,{title:"loading PRDs…"});const O=l=>{k(m=>{const P=new Set(m);return P.has(l)?P.delete(l):P.add(l),P})};!(J.length>0&&J.every(l=>j.has(l.slug)))&&J.some(l=>j.has(l.slug));const q=()=>k(new Set);async function Q(){try{const l=await window.api.schedule.listPrds();n(fe(l))}catch{}}async function R(){const l=`new-prd-${Date.now()}`,m=qt({title:"New PRD",cwd:"",estimateMinutes:60,parallelGroup:99},`## Task
|
|
12
12
|
|
|
13
13
|
Describe the task here.
|
|
14
|
-
`);try{const P=await window.api.schedule.writePrd(l,m);if(!P.ok){L.error(`Failed to create PRD: ${P.error}`);return}const I=await window.api.schedule.listPrds();n(fe(I)),Z(l)}catch(P){L.error(`Failed to create PRD: ${P instanceof Error?P.message:String(P)}`)}}async function F(){var l;f(!0),$(null);try{const m=[...j],P=await window.api.schedule.archivePrds(m);if(!P.ok)$(P.error??"archive failed");else{const I=((l=P.results)==null?void 0:l.filter(E=>!E.ok))??[];I.length>0&&L.warn(`Archive: ${I.length} of ${P.results.length} PRD${I.length===1?"":"s"} failed to move`),q(),v(!1),await Q()}}catch(m){$(m instanceof Error?m.message:String(m))}finally{f(!1)}}async function te(l,m){f(!0),$(null);try{const P=[];for(const E of j){const _={slug:E};l!==null&&(_.parallelGroup=l),m!==null&&(_.estimateMinutes=m),P.push(_)}const I=await window.api.schedule.retagPrds(P);if(!I.ok)$(I.error??"retag failed");else{q(),N(!1),await Q();for(const E of I.results)if(E.newSlug&&E.newSlug!==E.slug){const _=X(E.slug),Y=X(E.newSlug);_&&Y&&$e.getState().renameOpenFile(_,Y)}o&&I.results.some(E=>E.slug===o&&E.newSlug&&E.newSlug!==E.slug)&&r(null)}}catch(P){$(P instanceof Error?P.message:String(P))}finally{f(!1)}}return e.jsxs(e.Fragment,{children:[o?e.jsxs("div",{className:"h-full flex flex-col min-h-0",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-line flex-wrap shrink-0",children:[e.jsx("button",{type:"button",onClick:pe,className:"text-[11px] text-fg-faint hover:text-fg",children:"← PRDs"}),e.jsx("span",{className:"font-mono text-xs text-fg-dim truncate",children:o}),e.jsx(Ce,{status:K}),e.jsx("div",{className:"flex-1"}),e.jsx(ge,{label:"Reset",tip:"Reset failed job to pending",onClick:()=>{window.api.schedule.resetJob(o)},disabled:K!=="failed"}),e.jsx(ge,{label:"Run now",tip:"Run all pending jobs immediately",onClick:()=>{window.api.schedule.runNow()}}),e.jsx(ge,{label:u?"Hide log":"Last run log",tip:"Toggle most recent run log",onClick:ee})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Ye,{})}),u&&x!==null&&e.jsxs("div",{className:"border-t border-line max-h-64 overflow-auto bg-bg-elev",children:[e.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-2 border-b border-line sticky top-0 bg-bg-elev",children:[e.jsxs("span",{className:"text-[10px] text-fg-faint font-mono",children:["run log",M!=null&&M.runId?` — ${M.runId}`:""]}),e.jsx("button",{onClick:()=>b(!1),className:"ml-auto text-[10px] text-fg-faint hover:text-fg",children:"close"})]}),e.jsx("pre",{className:"p-3 text-[11px] font-mono text-fg-dim whitespace-pre-wrap",children:x})]})]}):e.jsxs("div",{className:"px-6 py-5 overflow-auto",children:[e.jsxs("div",{className:"flex items-start justify-between mb-5 gap-4",children:[e.jsxs("p",{className:"text-[14px] text-fg-dim leading-relaxed max-w-[560px]",children:["PRDs are the source the scheduler runs from. Each one becomes a"," ",e.jsx("code",{className:"font-mono text-[13px]",children:"claude -p"})," job when you queue it. This is where you write and edit the source — to watch a run in progress, use the Queue tab."]}),e.jsx("button",{type:"button",onClick:R,className:"shrink-0 bg-accent text-white rounded-lg px-4 py-[9px] text-[13.5px] font-semibold leading-none",children:"+ New PRD"})]}),j.size>0&&e.jsxs("div",{className:"mb-4 px-4 py-2 bg-bg border border-line rounded-lg flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-fg-dim",children:[j.size," selected"]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{type:"button",onClick:()=>v(!0),className:"text-xs px-3 py-1.5 rounded border border-line text-fg-dim hover:text-fg hover:bg-bg-hi",children:"Archive…"}),e.jsx("button",{type:"button",onClick:()=>N(!0),className:"text-xs px-3 py-1.5 rounded border border-line text-fg-dim hover:text-fg hover:bg-bg-hi",children:"Retag…"}),e.jsx("button",{type:"button",onClick:q,className:"text-xs px-3 py-1.5 rounded border border-line text-fg-dim hover:text-fg hover:bg-bg-hi",children:"Clear"})]}),J.length===0?e.jsx(ae,{title:"no PRDs found"}):e.jsx("div",{className:"grid gap-3",children:J.map(l=>{const m=a==null?void 0:a.jobs.find(Y=>Y.slug===l.slug),P=Pe(m),I=ve({epicId:l.epicId??(m==null?void 0:m.epicId)??null,sourcePromptId:l.sourcePromptId??(m==null?void 0:m.sourcePromptId)??null,sourceTabId:(m==null?void 0:m.sourceTabId)??null},xe),E=(m==null?void 0:m.status)==="running",_=(m==null?void 0:m.status)==="needs_review";return e.jsxs("div",{className:"flex items-stretch bg-bg-elev border border-line rounded-2xl overflow-hidden",children:[e.jsx("label",{className:"flex items-center px-3 cursor-pointer hover:bg-bg-hi",children:e.jsx("input",{type:"checkbox",checked:j.has(l.slug),onChange:()=>O(l.slug),className:"accent-accent w-3.5 h-3.5"})}),e.jsxs("div",{className:"flex-1 min-w-0 py-4 pr-2",children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-[5px] flex-wrap",children:[W(l.slug)&&e.jsx(Me,{n:W(l.slug)}),e.jsx("button",{type:"button",onClick:()=>Z(l.slug),className:"font-serif text-[18px] font-semibold text-fg leading-tight hover:underline text-left",children:l.title||l.slug}),e.jsx(Ce,{status:P}),(m==null?void 0:m.status)&&e.jsx("span",{className:"sr-only",children:m.status})]}),e.jsxs("div",{className:"flex items-center gap-4 font-mono text-xs text-fg-faint flex-wrap",children:[e.jsx(ye,{cwd:l.cwd}),e.jsx(Ne,{epicId:I.epicId,label:I.label,onOpen:Ht}),l.estimateMinutes!=null&&e.jsxs("span",{children:[l.estimateMinutes,"m"]}),e.jsxs("span",{children:["g",l.parallelGroup]}),e.jsxs("span",{children:["edited ",U(l.mtimeMs,Date.now())]})]}),e.jsx("button",{type:"button",onClick:()=>Z(l.slug),className:"mt-1.5 font-mono text-[11px] text-fg-faint hover:text-fg-dim leading-none",children:l.slug}),_&&e.jsxs("div",{className:"mt-3 space-y-2",children:[(m==null?void 0:m.verifierVerdict)&&e.jsxs("div",{className:"text-xs text-fg-faint",children:["verdict: ",e.jsx("span",{className:"font-mono",children:ce(m.verifierVerdict)})]}),e.jsx("button",{type:"button",onClick:()=>window.api.schedule.resetJob(l.slug),className:"text-xs px-2.5 py-1 rounded border border-line text-fg-dim hover:text-fg hover:bg-bg-hi",children:"Re-fire"})]})]}),e.jsx("div",{className:"flex flex-col gap-2 items-stretch px-[18px] py-4",children:e.jsx("button",{type:"button",onClick:()=>window.api.schedule.runNow(),disabled:E,className:"bg-fg text-bg rounded-lg px-[18px] py-2 text-[13px] font-semibold whitespace-nowrap disabled:opacity-50",children:E?"Running…":"Queue job"})})]},l.slug)})})]}),e.jsx(Bt,{open:C,count:j.size,busy:g,onClose:()=>v(!1),onConfirm:F}),e.jsx(Gt,{open:y,count:j.size,busy:g,onClose:()=>N(!1),onConfirm:te})]})}function Bt({open:t,count:s,busy:n,onClose:a,onConfirm:c}){return e.jsxs(He,{open:t,onClose:a,title:"Archive PRDs",children:[e.jsxs("p",{className:"text-xs text-fg-dim",children:["Move ",e.jsx("span",{className:"font-mono",children:s})," PRD",s===1?"":"s"," to"," ",e.jsx("span",{className:"font-mono",children:"prds-archived/<timestamp>/"}),"?"]}),e.jsx("p",{className:"text-[10px] text-fg-faint mt-2",children:"Files are renamed, never deleted. Restore manually from disk if needed."}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{type:"button",onClick:a,disabled:n,className:"px-2 py-1 text-xs border border-line rounded text-fg-dim hover:text-fg disabled:opacity-40",children:"Cancel"}),e.jsx("button",{type:"button",onClick:c,disabled:n||s===0,className:"px-2 py-1 text-xs border border-accent/60 text-accent rounded hover:bg-bg-hi disabled:opacity-40",children:n?"Archiving…":`Archive ${s}`})]})]})}function Gt({open:t,count:s,busy:n,onClose:a,onConfirm:c}){const[o,r]=i.useState(""),[x,d]=i.useState(""),[u,b]=i.useState(null);i.useEffect(()=>{t&&(r(""),d(""),b(null))},[t]);function w(){b(null);let h=null,j=null;if(o.trim()){const k=Number(o);if(!Number.isInteger(k)||k<0||k>999){b("parallelGroup must be 0–999");return}h=k}if(x.trim()){const k=Number(x);if(!Number.isInteger(k)||k<=0){b("estimateMinutes must be a positive integer");return}j=k}if(h===null&&j===null){b("set at least one field");return}c(h,j)}return e.jsxs(He,{open:t,onClose:a,title:"Retag PRDs",children:[e.jsxs("p",{className:"text-xs text-fg-dim",children:["Update ",e.jsx("span",{className:"font-mono",children:s})," PRD",s===1?"":"s",". Leave a field blank to keep its current value."]}),e.jsxs("p",{className:"text-[10px] text-fg-faint mt-2",children:["Changing parallelGroup on an ",e.jsx("span",{className:"font-mono",children:"NN-kebab"})," slug renames the file. Every change is logged to ",e.jsx("span",{className:"font-mono",children:"retag-log.jsonl"})," so it's reversible."]}),e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"w-32 text-fg-faint",children:"parallelGroup:"}),e.jsx("input",{type:"number",min:0,max:999,value:o,onChange:h=>r(h.target.value),placeholder:"(unchanged)",className:"flex-1 bg-bg border border-line rounded px-2 py-1 font-mono text-xs"})]}),e.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"w-32 text-fg-faint",children:"estimateMinutes:"}),e.jsx("input",{type:"number",min:1,value:x,onChange:h=>d(h.target.value),placeholder:"(unchanged)",className:"flex-1 bg-bg border border-line rounded px-2 py-1 font-mono text-xs"})]})]}),u&&e.jsx("div",{className:"mt-2 text-[10px] text-red-300",children:u}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{type:"button",onClick:a,disabled:n,className:"px-2 py-1 text-xs border border-line rounded text-fg-dim hover:text-fg disabled:opacity-40",children:"Cancel"}),e.jsx("button",{type:"button",onClick:w,disabled:n||s===0,className:"px-2 py-1 text-xs border border-accent/60 text-accent rounded hover:bg-bg-hi disabled:opacity-40",children:n?"Retagging…":`Retag ${s}`})]})]})}function Jt(t){je(t),window.dispatchEvent(new CustomEvent("sm:navigate",{detail:"terminal"}))}function Ee(t){return t?t.slice(0,10):""}const Vt=[{value:"all",label:"All"},{value:"completed",label:"Completed"},{value:"skipped",label:"Skipped"},{value:"failed",label:"Failed"}];function zt({scopeCwd:t=null}){const[s,n]=i.useState(null),[a,c]=i.useState(!0),[o,r]=i.useState(""),[x,d]=i.useState(""),[u,b]=i.useState(""),[w,h]=i.useState("all");i.useEffect(()=>{c(!0),window.api.schedule.getHistory().then(v=>n(v)).catch(v=>n({ok:!1,jobs:[],error:v instanceof Error?v.message:String(v)})).finally(()=>c(!1))},[]);const j=i.useMemo(()=>{if(!(s!=null&&s.jobs))return[];const v=new Set;for(const y of s.jobs){const N=be(y.cwd);N&&v.add(N)}return[...v].sort()},[s]),k=i.useMemo(()=>s!=null&&s.jobs?s.jobs.filter(v=>!(t&&v.cwd!==t||w!=="all"&&v.status!==w||o&&be(v.cwd)!==o||x&&Ee(v.finishedAt)<x||u&&Ee(v.finishedAt)>u)):[],[s,w,o,x,u,t]);if(a)return e.jsx(ae,{title:"Loading history…"});if(!(s!=null&&s.ok)||s.error)return e.jsxs("div",{className:"p-4 text-xs text-red-300",children:["Failed to load history: ",(s==null?void 0:s.error)??"unknown error"]});if(s.jobs.length===0)return e.jsx(ae,{title:"No history yet",hint:"Completed and failed jobs appear here."});const C=w!=="all"||!!o||!!x||!!u;return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-4 py-2.5 border-b border-line flex-wrap",children:[e.jsx(qe,{options:Vt,value:w,onChange:h,pillPadding:"px-3 py-1"}),e.jsx("span",{className:"w-px h-4 bg-line mx-1","aria-hidden":"true"}),j.length>0&&e.jsxs("select",{value:o,onChange:v=>r(v.target.value),className:"bg-bg-hi border border-line rounded-lg px-2 py-1 text-[12.5px] text-fg-dim max-w-[12rem] font-medium",children:[e.jsx("option",{value:"",children:"All projects"}),j.map(v=>e.jsx("option",{value:v,children:v},v))]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] text-fg-faint",children:[e.jsx("span",{children:"from"}),e.jsx("input",{type:"date",value:x,onChange:v=>d(v.target.value),className:"bg-bg-hi border border-line rounded-lg px-2 py-1 text-fg-dim font-mono text-[12px]"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] text-fg-faint",children:[e.jsx("span",{children:"to"}),e.jsx("input",{type:"date",value:u,onChange:v=>b(v.target.value),className:"bg-bg-hi border border-line rounded-lg px-2 py-1 text-fg-dim font-mono text-[12px]"})]}),e.jsxs("span",{className:"text-[12px] text-fg-faint ml-auto font-mono",children:[k.length," / ",s.jobs.length]}),C&&e.jsx("button",{type:"button",onClick:()=>{h("all"),r(""),d(""),b("")},className:"text-[12px] text-fg-faint hover:text-fg-dim underline",children:"clear"})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:k.length===0?e.jsx(ae,{title:"No matches",hint:"Try adjusting the filters."}):e.jsxs("div",{className:"mx-4 my-3 bg-bg-hi border border-line rounded-2xl overflow-hidden",children:[e.jsx("div",{className:"flex items-center px-[18px] py-3 bg-bg-elev",children:e.jsxs("span",{className:"font-serif text-base font-semibold text-fg",children:[k.length," job",k.length!==1?"s":""]})}),k.map(v=>e.jsx(Ut,{job:v},`${v.slug}-${v.finishedAt??""}`))]})})]})}function Ut({job:t}){const[s,n]=i.useState(!1),[a,c]=i.useState(!1),o=le(h=>h.sessions),r=i.useMemo(()=>ve(t,o),[t,o]),x=t.startedAt&&t.finishedAt?Date.parse(t.finishedAt)-Date.parse(t.startedAt):null,d=t.startedAt?new Date(t.startedAt).toLocaleString():"—",u=t.finishedAt?new Date(t.finishedAt).toLocaleString():"—",b=x!==null?re(x):"—",w=t.exitCode!==null?String(t.exitCode):"—";return e.jsxs("div",{className:"border-t border-line/60",children:[e.jsxs("button",{type:"button",className:`w-full text-left grid items-center gap-4 px-[18px] py-3.5 cursor-pointer transition-colors hover:bg-bg-elev ${s?"bg-bg-elev":"bg-transparent"}`,style:{gridTemplateColumns:"116px 1fr auto auto"},onClick:()=>n(h=>!h),"aria-expanded":s,children:[e.jsx(Le,{status:t.status}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-2 text-[14.5px] font-medium text-fg leading-snug text-pretty",children:[t.title,e.jsx(Oe,{leaked:t.leakedDescendants})]}),t.error&&!s&&(t.status==="failed"||t.status==="needs_review")&&e.jsx("div",{className:"text-[12.5px] mt-0.5 text-accent/80 truncate",children:t.error}),r.epicId&&e.jsx("span",{className:"flex mt-0.5",children:e.jsx(Ne,{epicId:r.epicId,label:r.label,onOpen:Jt})})]}),e.jsx(ye,{cwd:t.cwd}),e.jsxs("span",{className:"inline-flex items-center gap-2.5 font-mono text-xs text-fg-faint whitespace-nowrap",children:[b,e.jsx("span",{className:"inline-flex transition-transform duration-150",style:{transform:s?"rotate(90deg)":"none"},"aria-hidden":"true",children:"›"})]})]}),s&&e.jsxs("div",{className:"grid gap-5 px-[18px] pt-1 pb-5 bg-bg-elev",style:{gridTemplateColumns:"repeat(auto-fit, minmax(160px, 1fr))"},children:[e.jsxs(B,{label:"Status",children:[e.jsx(D,{k:"result",v:w}),e.jsx(D,{k:"state",v:t.status.replace("_"," ")}),t.verifierVerdict&&e.jsx(D,{k:"verifier",v:ce(t.verifierVerdict)}),t.leakedDescendants&&t.leakedDescendants.length>0&&e.jsx(D,{k:"leaked",v:Fe(t.leakedDescendants),wrap:!0})]}),e.jsxs(B,{label:"Timing",children:[e.jsx(D,{k:"started",v:d}),e.jsx(D,{k:"finished",v:u}),e.jsx(D,{k:"duration",v:b})]}),e.jsxs(B,{label:"Location",children:[e.jsx(D,{k:"group",v:t.parallelGroup!=null?String(t.parallelGroup):"—"}),e.jsx(D,{k:"slug",v:t.slug}),e.jsx(D,{k:"epic",v:r.label??r.epicId??"—",wrap:!0}),t.cwd&&e.jsx(D,{k:"cwd",v:t.cwd,wrap:!0})]}),e.jsx(B,{label:"Actions",children:e.jsxs("div",{className:"flex flex-col gap-2 items-start",children:[t.runId&&e.jsx("button",{type:"button",onClick:h=>{h.stopPropagation(),c(!0)},className:"text-[13px] font-semibold text-fg-dim hover:text-fg bg-transparent border-0 p-0 cursor-pointer",children:"view log →"}),t.status!=="pending"&&e.jsx("button",{type:"button",onClick:h=>{h.stopPropagation(),window.api.schedule.resetJob(t.slug)},className:"text-[13px] font-semibold text-fg-dim hover:text-fg bg-transparent border-0 p-0 cursor-pointer",children:"reset to pending →"}),t.error&&e.jsx("p",{className:"text-[12px] text-accent/90 mt-1 break-words whitespace-pre-wrap max-w-sm m-0",children:t.error})]})})]}),a&&t.runId&&e.jsx(_e,{runId:t.runId,slug:t.slug,title:t.title||t.slug,onClose:()=>c(!1)})]})}function Qt(t){return t?Object.values(t).reduce((s,n)=>s+(n??[]).reduce((a,c)=>{var o;return a+(((o=c.hooks)==null?void 0:o.length)??0)},0),0):0}function Yt(t){var s,n,a;return t?(((s=t.allow)==null?void 0:s.length)??0)+(((n=t.deny)==null?void 0:n.length)??0)+(((a=t.ask)==null?void 0:a.length)??0):0}function Wt({navigate:t}){const s=Xe(),n=se(f=>f.files),a=se(f=>f.loadJson),c=se(f=>f.loadText),o=se(f=>f.watchFile),r=se(f=>f.unwatchFile),x=s?Ze.resolve("user",s,null):null,d=s?et.resolve("user",s,null):null,u=s?`${s}/.claude.json`:null;i.useEffect(()=>{const f=[x,u].filter(Boolean);f.forEach($=>{n[$]||a($),o($)});const A=[d].filter(Boolean);return A.forEach($=>{n[$]||c($),o($)}),()=>{[...f,...A].forEach($=>r($))}},[x,d,u]);const[b,w]=i.useState(null);i.useEffect(()=>{if(!s)return;let f=!1;return(async()=>{const A=await rt(`${s}/.claude/skills`);f||w(A.length)})(),()=>{f=!0}},[s]);const h=x?n[x]:null,j=u?n[u]:null,k=d?n[d]:null,C=i.useMemo(()=>{if(!(h!=null&&h.exists)||h.parseError)return null;const f=h.diskData;return f===null||typeof f!="object"||Array.isArray(f)?{}:f},[h]),v=i.useMemo(()=>{if(!(j!=null&&j.exists)||j.parseError)return null;const f=j.diskData;return f===null||typeof f!="object"||Array.isArray(f)?{}:f},[j]),y=h?h.parseError?"invalid JSON":null:"loading…",N=j?j.parseError?"invalid JSON":null:"loading…",g=[{key:"settings",title:"Settings",summary:y??(C?`${Object.keys(C).length} top-level key${Object.keys(C).length===1?"":"s"} configured`:"not configured")},{key:"permissions",title:"Permissions",summary:y??(C?`${Yt(C.permissions)} rule(s) configured`:"not configured")},{key:"hooks",title:"Hooks",summary:y??(C?`${Qt(C.hooks)} hook(s) configured`:"not configured")},{key:"mcp",title:"MCP Servers",summary:N??(v?`${Object.keys(v.mcpServers??{}).length} MCP server(s)`:"not configured")},{key:"system-prompt",title:"System Prompt",summary:k!=null&&k.exists&&k.diskRaw.trim().length>0?`configured (${k.diskRaw.length.toLocaleString()} chars)`:"not set"},{key:"skills",title:"Skills",summary:b===null?"loading…":`${b} skill(s) installed`}];return e.jsxs("section",{className:"border border-line rounded-xl bg-bg-hi px-5 py-4",children:[e.jsx("h2",{className:"m-0 mb-1 font-serif text-[18px] font-semibold text-fg",children:"Global Controls"}),e.jsx("p",{className:"mt-0 mb-3 text-[13px] text-fg-dim leading-relaxed",children:"Machine-wide (user-scope) config state for the tabs that default to global here on Home. Read-only summary — open a card to edit."}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:g.map(f=>e.jsxs("button",{type:"button",onClick:()=>t==null?void 0:t(f.key),className:"text-left border border-line rounded-lg bg-bg px-3 py-2.5 hover:border-accent transition-colors",children:[e.jsx("div",{className:"text-[13px] font-medium text-fg",children:f.title}),e.jsx("div",{className:"mt-0.5 text-[12px] text-fg-dim",children:f.summary})]},f.key))})]})}function Kt({navigate:t}){const s=tt(),[n,a]=i.useState(!1),[c,o]=i.useState(!1);i.useEffect(()=>{let x=!0;return st().then(d=>{x&&a(d.openToHomeOnLaunch===!0)}),()=>{x=!1}},[]);const r=async x=>{a(x),o(!0);try{await nt({openToHomeOnLaunch:x})}catch{a(!x),L.error('Failed to save "Open to Home on launch" — try again.')}finally{o(!1)}};return e.jsxs("div",{className:"max-w-[760px] space-y-6",children:[e.jsx(Wt,{navigate:t}),e.jsxs("section",{className:"border border-line rounded-xl bg-bg-hi px-5 py-4",children:[e.jsx("h2",{className:"m-0 mb-1 font-serif text-[18px] font-semibold text-fg",children:"Session pool"}),e.jsxs("p",{className:"mt-0 mb-3 text-[13px] text-fg-dim leading-relaxed",children:["One machine-wide pool of concurrent Claude sessions. Scheduler jobs and Epic chat runs each request a slot before launching; work waits when the pool is full. Adjustable from 0 (pauses new launches) to 10 on the Home tab, default 5 — or pin it with"," ",e.jsx("code",{className:"font-mono text-[12px]",children:"SM_SESSION_SLOTS"})," (clamped 0–10)."]}),e.jsxs("div",{className:"flex items-center gap-2",children:[Array.from({length:(s==null?void 0:s.total)??5},(x,d)=>e.jsx("span",{className:`w-3.5 h-3.5 rounded-full border ${d<((s==null?void 0:s.inUse)??0)?"bg-accent border-accent":"bg-bg border-line"}`},d)),e.jsx("span",{className:"ml-2 font-mono text-[12.5px] text-fg-faint",children:s?`${s.inUse} / ${s.total} in use`:"loading…"})]}),s&&s.holders.length>0&&e.jsx("ul",{className:"mt-2 mb-0 pl-0 list-none space-y-0.5",children:s.holders.map((x,d)=>e.jsxs("li",{className:"font-mono text-[12px] text-fg-dim",children:[x.owner," ",e.jsxs("span",{className:"text-fg-faint",children:["since ",new Date(x.at).toLocaleTimeString()]})]},d))})]}),e.jsxs("section",{className:"border border-line rounded-xl bg-bg-hi px-5 py-4",children:[e.jsx("h2",{className:"m-0 mb-1 font-serif text-[18px] font-semibold text-fg",children:"Behavior"}),e.jsx("p",{className:"mt-0 mb-3 text-[13px] text-fg-dim leading-relaxed",children:"Cross-project app behavior, independent of any single project's config."}),e.jsx(lt,{checked:n,onChange:r,disabled:c,label:"Open to Home on launch"})]}),e.jsxs("section",{className:"border border-line rounded-xl bg-bg-hi px-5 py-4",children:[e.jsx("h2",{className:"m-0 mb-1 font-serif text-[18px] font-semibold text-fg",children:"On disk"}),e.jsxs("p",{className:"mt-0 mb-2 text-[13px] text-fg-dim leading-relaxed",children:["Global runtime state is deliberately small — everything project-scoped lives inside that project's ",e.jsx("code",{className:"font-mono text-[12px]",children:"session-manager-operations/"})," folder."]}),e.jsxs("ul",{className:"m-0 pl-0 list-none space-y-1 font-mono text-[12px] text-fg-dim",children:[e.jsxs("li",{children:["~/.claude/session-manager/scheduler-machine.json ",e.jsx("span",{className:"text-fg-faint",children:"— policy + pause state"})]}),e.jsxs("li",{children:["<project>/session-manager-operations/scheduler/state/ ",e.jsx("span",{className:"text-fg-faint",children:"— per-project queue + history"})]}),e.jsxs("li",{children:["<project>/session-manager-operations/scheduler/epics/<epic>/prds/ ",e.jsx("span",{className:"text-fg-faint",children:"— PRD sources, per session"})]})]})]})]})}const Ie="sm.schedulerTab.subView",Xt=[{key:"queue",label:"Queue"},{key:"prds",label:"PRDs"},{key:"history",label:"History"}];function Zt(t,s){const n=new Date(t),a=new Date(s);return n.getFullYear()===a.getFullYear()&&n.getMonth()===a.getMonth()&&n.getDate()===a.getDate()}function es(t,s,n){if(t==="auth")return"Scheduler paused: Claude sign-in expired or invalid. Restart the app or re-run `claude login`, then Resume.";if(t==="rate_limit"){if(s){const c=new Date(s).getTime()-n;return c>0?`Paused for rate limit — resumes in ${H(c)}`:"Paused for rate limit — resume pending"}return"Paused for rate limit"}return t==="network"?"Paused: billing endpoint unreachable for 30+ min.":t==="manual"?"Scheduler paused manually. Click Resume to restart.":`Scheduler paused (${t})`}function ts({scopeCwd:t}){const{snapshot:s}=we(),[n,a]=i.useState(()=>Date.now());if(i.useEffect(()=>{const N=setInterval(()=>a(Date.now()),3e4);return()=>clearInterval(N)},[]),!s)return null;const c=(s.jobs??[]).filter(N=>!t||N.cwd===t),o=c.filter(N=>N.status==="pending").length,r=c.filter(N=>N.status==="running").length,x=c.filter(N=>N.status==="completed"&&(N.finishedAt?Zt(N.finishedAt,n):!1)).length,d=s.nextReset?new Date(s.nextReset).getTime():null,u=d?d>n?H(d-n):"soon":"—",b=U(s.lastRunAt?new Date(s.lastRunAt).getTime():null,n),w=s.paused,h=Object.entries(s.launchBlocks??{}),j=Object.entries(s.launchMitigations??{}),k=s.pollHealth,C=k!=null&&!k.lastPollOk,y=(w==null?void 0:w.reason)==="auth"||(w==null?void 0:w.reason)==="network"?"bg-red-950/60 border-red-700/50 text-red-200":"bg-amber-950/60 border-amber-700/50 text-amber-200";return e.jsxs("div",{className:"flex flex-col gap-2",children:[w&&e.jsxs("div",{className:`flex items-center gap-3 border rounded-xl px-4 py-2.5 text-[13px] ${y}`,children:[e.jsx("span",{className:"flex-1 leading-snug",children:es(w.reason,w.resumeAt,n)}),e.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),className:"shrink-0 px-2.5 py-1 rounded border border-current/40 hover:bg-white/10 transition-colors text-[12px] font-medium",children:"Resume"})]}),h.map(([N,g])=>e.jsxs("div",{"data-testid":"launch-block-banner",className:"flex items-start gap-3 border rounded-xl px-4 py-2.5 text-[13px] bg-red-950/60 border-red-700/50 text-red-200",children:[e.jsxs("div",{className:"flex-1 leading-snug min-w-0",children:[e.jsxs("div",{className:"font-medium",children:["Launches for ",e.jsx("span",{className:"font-mono",children:N})," jobs are failing before any work starts",g.httpStatus?` (HTTP ${g.httpStatus}, ${g.kind})`:` (${g.kind})`,g.exhausted?" — held until the Claude CLI version changes or you press Retry now.":g.until?` — next automatic probe ${new Date(g.until).getTime()>n?`in ${H(new Date(g.until).getTime()-n)}`:"on the next tick"}.`:"."]}),e.jsx("div",{className:"mt-0.5 text-red-200/80",children:g.hint}),e.jsxs("div",{className:"mt-0.5 font-mono text-[12px] text-red-200/70 truncate",title:g.message,children:[g.attempts," failed probe",g.attempts===1?"":"s",g.claudeVersion?` · CLI ${g.claudeVersion}`:"",g.lastSlug?` · last: ${g.lastSlug}`:""," · ",g.message]})]}),e.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),className:"shrink-0 px-2.5 py-1 rounded border border-current/40 hover:bg-white/10 transition-colors text-[12px] font-medium",children:"Retry now"})]},`launch-block-${N}`)),j.map(([N,g])=>e.jsx("div",{"data-testid":"launch-mitigation-banner",className:"flex items-start gap-3 border rounded-xl px-4 py-2.5 text-[13px] bg-amber-950/60 border-amber-700/50 text-amber-200",children:e.jsxs("div",{className:"flex-1 leading-snug min-w-0",children:[e.jsxs("div",{className:"font-medium",children:[e.jsx("span",{className:"font-mono",children:N})," jobs are running in degraded mode"," ","(",e.jsx("span",{className:"font-mono",children:Object.entries(g.env).map(([f,A])=>`${f}=${A}`).join(" ")}),")",g.claudeVersion?` since CLI ${g.claudeVersion}`:"","."]}),e.jsx("div",{className:"mt-0.5 text-amber-200/80",children:g.hint})]})},`launch-mitigation-${N}`)),e.jsxs("div",{className:"flex items-center gap-5 flex-wrap bg-bg-hi border border-line rounded-xl px-4 py-3",children:[e.jsxs("span",{className:"inline-flex items-center gap-2 text-[13.5px] text-fg font-semibold whitespace-nowrap",children:[e.jsx("span",{className:"text-sage","aria-hidden":"true",children:e.jsx(ue,{name:"clock",size:15})}),"Window resets in ",u]}),e.jsx("span",{className:"w-px h-[18px] bg-rule shrink-0","aria-hidden":"true"}),e.jsx(he,{dotClass:"bg-fg-faint",n:o,label:"pending"}),e.jsx(he,{dotClass:"bg-accent",n:r,label:"running"}),e.jsx(he,{dotClass:"bg-sage",n:x,label:"completed today"}),s.utilization!==null&&s.utilization!==void 0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"w-px h-[18px] bg-rule shrink-0","aria-hidden":"true"}),C?e.jsxs("span",{className:"font-mono text-[12.5px] text-amber-400/70",title:"Billing poll failing — this reading may be outdated",children:[Math.round(s.utilization),"% of window used · last good reading"," ",U(k.lastPollAt,n)]}):e.jsxs("span",{className:"font-mono text-[12.5px] text-fg-faint",children:[Math.round(s.utilization),"% of window used"]})]}),e.jsxs("span",{className:"ml-auto font-mono text-[12.5px] text-fg-faint whitespace-nowrap",children:["last batch ",b]})]})]})}function ss({navigate:t}={}){var x;const[s,n]=i.useState(()=>{const d=localStorage.getItem(Ie);return d==="prds"||d==="history"||d==="machine"?d:"queue"}),a=Ae(d=>d.tabs),c=Ae(d=>d.activeTabId),o=((x=a.find(d=>d.id===c))==null?void 0:x.cwd)??null,r=o;return i.useEffect(()=>{o&&(le.getState().hydrate(o),le.getState().hydrateArchived(o))},[o]),i.useEffect(()=>{localStorage.setItem(Ie,s)},[s]),e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"shrink-0 px-9 pt-7 pb-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("div",{className:"text-xs font-bold text-fg-faint tracking-[0.8px] uppercase mb-1",children:"Workspace"}),e.jsx(at,{active:"scheduler"})]}),e.jsx("h1",{className:"m-0 font-serif text-[40px] font-semibold leading-none tracking-tight text-fg",children:"Scheduler"}),e.jsxs("p",{className:"mt-2 text-[14.5px] text-fg-dim leading-relaxed max-w-[600px]",children:["Global scheduler policy and the machine-wide session pool, plus — when a project tab is active — that project's PRDs, run as"," ",e.jsx("code",{className:"font-mono text-[13.5px]",children:"claude -p"})," ","jobs against your 5-hour window. Jobs auto-pause on rate-limit and resume on the next reset."]}),e.jsx("div",{className:"mt-[18px] mb-[22px]",children:e.jsx(ts,{scopeCwd:r})}),e.jsxs("div",{className:"flex items-center gap-3 pb-0",children:[e.jsx(it,{options:Xt,active:s,onChange:n}),e.jsxs("button",{type:"button",onClick:()=>n("machine"),"aria-pressed":s==="machine",className:`inline-flex items-center gap-1.5 px-[15px] py-2 rounded-lg text-[13.5px] transition-colors ${s==="machine"?"bg-bg-elev border border-line font-semibold text-fg":"text-fg-faint hover:text-fg-dim"}`,title:"Machine-wide config that applies to every project — not this project's live queue.",children:[e.jsx("span",{"aria-hidden":"true",children:"⚙"})," Machine"]})]}),s==="queue"&&e.jsx("p",{className:"mt-2 text-[14.5px] text-fg-dim leading-relaxed max-w-[600px]",children:"What's running right now, and what fires next."}),s==="prds"&&e.jsx("p",{className:"mt-2 text-[14.5px] text-fg-dim leading-relaxed max-w-[600px]",children:"Authored PRD source files on disk — edit, lint, archive, or queue them."}),s==="history"&&e.jsx("p",{className:"mt-2 text-[14.5px] text-fg-dim leading-relaxed max-w-[600px]",children:"The last 50 completed and failed jobs, for this project."}),s==="machine"&&e.jsx("p",{className:"mt-2 text-[14.5px] text-fg-dim leading-relaxed max-w-[600px]",children:"Machine-wide setup that applies to every project."})]}),e.jsxs("div",{className:"flex-1 min-h-0",children:[s==="queue"&&e.jsx(gt,{scopeCwd:r,navigate:t}),s==="prds"&&e.jsx(qt,{scopeCwd:r}),s==="history"&&e.jsx(zt,{scopeCwd:r}),s==="machine"&&e.jsx("div",{className:"h-full overflow-y-auto px-9 py-6",children:e.jsx(Kt,{navigate:t})})]})]})}const is=i.memo(ss);export{is as Scheduler};
|
|
14
|
+
`);try{const P=await window.api.schedule.writePrd(l,m);if(!P.ok){L.error(`Failed to create PRD: ${P.error}`);return}const I=await window.api.schedule.listPrds();n(fe(I)),Z(l)}catch(P){L.error(`Failed to create PRD: ${P instanceof Error?P.message:String(P)}`)}}async function F(){var l;f(!0),$(null);try{const m=[...j],P=await window.api.schedule.archivePrds(m);if(!P.ok)$(P.error??"archive failed");else{const I=((l=P.results)==null?void 0:l.filter(E=>!E.ok))??[];I.length>0&&L.warn(`Archive: ${I.length} of ${P.results.length} PRD${I.length===1?"":"s"} failed to move`),q(),w(!1),await Q()}}catch(m){$(m instanceof Error?m.message:String(m))}finally{f(!1)}}async function te(l,m){f(!0),$(null);try{const P=[];for(const E of j){const _={slug:E};l!==null&&(_.parallelGroup=l),m!==null&&(_.estimateMinutes=m),P.push(_)}const I=await window.api.schedule.retagPrds(P);if(!I.ok)$(I.error??"retag failed");else{q(),N(!1),await Q();for(const E of I.results)if(E.newSlug&&E.newSlug!==E.slug){const _=X(E.slug),Y=X(E.newSlug);_&&Y&&$e.getState().renameOpenFile(_,Y)}o&&I.results.some(E=>E.slug===o&&E.newSlug&&E.newSlug!==E.slug)&&r(null)}}catch(P){$(P instanceof Error?P.message:String(P))}finally{f(!1)}}return e.jsxs(e.Fragment,{children:[o?e.jsxs("div",{className:"h-full flex flex-col min-h-0",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-line flex-wrap shrink-0",children:[e.jsx("button",{type:"button",onClick:pe,className:"text-[11px] text-fg-faint hover:text-fg",children:"← PRDs"}),e.jsx("span",{className:"font-mono text-xs text-fg-dim truncate",children:o}),e.jsx(Ce,{status:K}),e.jsx("div",{className:"flex-1"}),e.jsx(ge,{label:"Reset",tip:"Reset failed job to pending",onClick:()=>{window.api.schedule.resetJob(o)},disabled:K!=="failed"}),e.jsx(ge,{label:"Run now",tip:"Run all pending jobs immediately",onClick:()=>{window.api.schedule.runNow()}}),e.jsx(ge,{label:c?"Hide log":"Last run log",tip:"Toggle most recent run log",onClick:ee})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(We,{})}),c&&u!==null&&e.jsxs("div",{className:"border-t border-line max-h-64 overflow-auto bg-bg-elev",children:[e.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-2 border-b border-line sticky top-0 bg-bg-elev",children:[e.jsxs("span",{className:"text-[10px] text-fg-faint font-mono",children:["run log",M!=null&&M.runId?` — ${M.runId}`:""]}),e.jsx("button",{onClick:()=>b(!1),className:"ml-auto text-[10px] text-fg-faint hover:text-fg",children:"close"})]}),e.jsx("pre",{className:"p-3 text-[11px] font-mono text-fg-dim whitespace-pre-wrap",children:u})]})]}):e.jsxs("div",{className:"px-6 py-5 overflow-auto",children:[e.jsxs("div",{className:"flex items-start justify-between mb-5 gap-4",children:[e.jsxs("p",{className:"text-[14px] text-fg-dim leading-relaxed max-w-[560px]",children:["PRDs are the source the scheduler runs from. Each one becomes a"," ",e.jsx("code",{className:"font-mono text-[13px]",children:"claude -p"})," job when you queue it. This is where you write and edit the source — to watch a run in progress, use the Queue tab."]}),e.jsx("button",{type:"button",onClick:R,className:"shrink-0 bg-accent text-white rounded-lg px-4 py-[9px] text-[13.5px] font-semibold leading-none",children:"+ New PRD"})]}),j.size>0&&e.jsxs("div",{className:"mb-4 px-4 py-2 bg-bg border border-line rounded-lg flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-fg-dim",children:[j.size," selected"]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{type:"button",onClick:()=>w(!0),className:"text-xs px-3 py-1.5 rounded border border-line text-fg-dim hover:text-fg hover:bg-bg-hi",children:"Archive…"}),e.jsx("button",{type:"button",onClick:()=>N(!0),className:"text-xs px-3 py-1.5 rounded border border-line text-fg-dim hover:text-fg hover:bg-bg-hi",children:"Retag…"}),e.jsx("button",{type:"button",onClick:q,className:"text-xs px-3 py-1.5 rounded border border-line text-fg-dim hover:text-fg hover:bg-bg-hi",children:"Clear"})]}),J.length===0?e.jsx(ae,{title:"no PRDs found"}):e.jsx("div",{className:"grid gap-3",children:J.map(l=>{const m=a==null?void 0:a.jobs.find(Y=>Y.slug===l.slug),P=Pe(m),I=we({epicId:l.epicId??(m==null?void 0:m.epicId)??null,sourcePromptId:l.sourcePromptId??(m==null?void 0:m.sourcePromptId)??null,sourceTabId:(m==null?void 0:m.sourceTabId)??null},xe),E=(m==null?void 0:m.status)==="running",_=(m==null?void 0:m.status)==="needs_review";return e.jsxs("div",{className:"flex items-stretch bg-bg-elev border border-line rounded-2xl overflow-hidden",children:[e.jsx("label",{className:"flex items-center px-3 cursor-pointer hover:bg-bg-hi",children:e.jsx("input",{type:"checkbox",checked:j.has(l.slug),onChange:()=>O(l.slug),className:"accent-accent w-3.5 h-3.5"})}),e.jsxs("div",{className:"flex-1 min-w-0 py-4 pr-2",children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-[5px] flex-wrap",children:[W(l.slug)&&e.jsx(Me,{n:W(l.slug)}),e.jsx("button",{type:"button",onClick:()=>Z(l.slug),className:"font-serif text-[18px] font-semibold text-fg leading-tight hover:underline text-left",children:l.title||l.slug}),e.jsx(Ce,{status:P}),(m==null?void 0:m.status)&&e.jsx("span",{className:"sr-only",children:m.status})]}),e.jsxs("div",{className:"flex items-center gap-4 font-mono text-xs text-fg-faint flex-wrap",children:[e.jsx(ye,{cwd:l.cwd}),e.jsx(Ne,{epicId:I.epicId,label:I.label,onOpen:Bt}),l.estimateMinutes!=null&&e.jsxs("span",{children:[l.estimateMinutes,"m"]}),e.jsxs("span",{children:["g",l.parallelGroup]}),e.jsxs("span",{children:["edited ",U(l.mtimeMs,Date.now())]})]}),e.jsx("button",{type:"button",onClick:()=>Z(l.slug),className:"mt-1.5 font-mono text-[11px] text-fg-faint hover:text-fg-dim leading-none",children:l.slug}),_&&e.jsxs("div",{className:"mt-3 space-y-2",children:[(m==null?void 0:m.verifierVerdict)&&e.jsxs("div",{className:"text-xs text-fg-faint",children:["verdict: ",e.jsx("span",{className:"font-mono",children:ce(m.verifierVerdict)})]}),e.jsx("button",{type:"button",onClick:()=>window.api.schedule.resetJob(l.slug),className:"text-xs px-2.5 py-1 rounded border border-line text-fg-dim hover:text-fg hover:bg-bg-hi",children:"Re-fire"})]})]}),e.jsx("div",{className:"flex flex-col gap-2 items-stretch px-[18px] py-4",children:e.jsx("button",{type:"button",onClick:()=>window.api.schedule.runNow(),disabled:E,className:"bg-fg text-bg rounded-lg px-[18px] py-2 text-[13px] font-semibold whitespace-nowrap disabled:opacity-50",children:E?"Running…":"Queue job"})})]},l.slug)})})]}),e.jsx(Jt,{open:C,count:j.size,busy:g,onClose:()=>w(!1),onConfirm:F}),e.jsx(Vt,{open:y,count:j.size,busy:g,onClose:()=>N(!1),onConfirm:te})]})}function Jt({open:t,count:s,busy:n,onClose:a,onConfirm:d}){return e.jsxs(He,{open:t,onClose:a,title:"Archive PRDs",children:[e.jsxs("p",{className:"text-xs text-fg-dim",children:["Move ",e.jsx("span",{className:"font-mono",children:s})," PRD",s===1?"":"s"," to"," ",e.jsx("span",{className:"font-mono",children:"prds-archived/<timestamp>/"}),"?"]}),e.jsx("p",{className:"text-[10px] text-fg-faint mt-2",children:"Files are renamed, never deleted. Restore manually from disk if needed."}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{type:"button",onClick:a,disabled:n,className:"px-2 py-1 text-xs border border-line rounded text-fg-dim hover:text-fg disabled:opacity-40",children:"Cancel"}),e.jsx("button",{type:"button",onClick:d,disabled:n||s===0,className:"px-2 py-1 text-xs border border-accent/60 text-accent rounded hover:bg-bg-hi disabled:opacity-40",children:n?"Archiving…":`Archive ${s}`})]})]})}function Vt({open:t,count:s,busy:n,onClose:a,onConfirm:d}){const[o,r]=i.useState(""),[u,x]=i.useState(""),[c,b]=i.useState(null);i.useEffect(()=>{t&&(r(""),x(""),b(null))},[t]);function v(){b(null);let h=null,j=null;if(o.trim()){const k=Number(o);if(!Number.isInteger(k)||k<0||k>999){b("parallelGroup must be 0–999");return}h=k}if(u.trim()){const k=Number(u);if(!Number.isInteger(k)||k<=0){b("estimateMinutes must be a positive integer");return}j=k}if(h===null&&j===null){b("set at least one field");return}d(h,j)}return e.jsxs(He,{open:t,onClose:a,title:"Retag PRDs",children:[e.jsxs("p",{className:"text-xs text-fg-dim",children:["Update ",e.jsx("span",{className:"font-mono",children:s})," PRD",s===1?"":"s",". Leave a field blank to keep its current value."]}),e.jsxs("p",{className:"text-[10px] text-fg-faint mt-2",children:["Changing parallelGroup on an ",e.jsx("span",{className:"font-mono",children:"NN-kebab"})," slug renames the file. Every change is logged to ",e.jsx("span",{className:"font-mono",children:"retag-log.jsonl"})," so it's reversible."]}),e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"w-32 text-fg-faint",children:"parallelGroup:"}),e.jsx("input",{type:"number",min:0,max:999,value:o,onChange:h=>r(h.target.value),placeholder:"(unchanged)",className:"flex-1 bg-bg border border-line rounded px-2 py-1 font-mono text-xs"})]}),e.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"w-32 text-fg-faint",children:"estimateMinutes:"}),e.jsx("input",{type:"number",min:1,value:u,onChange:h=>x(h.target.value),placeholder:"(unchanged)",className:"flex-1 bg-bg border border-line rounded px-2 py-1 font-mono text-xs"})]})]}),c&&e.jsx("div",{className:"mt-2 text-[10px] text-red-300",children:c}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx("button",{type:"button",onClick:a,disabled:n,className:"px-2 py-1 text-xs border border-line rounded text-fg-dim hover:text-fg disabled:opacity-40",children:"Cancel"}),e.jsx("button",{type:"button",onClick:v,disabled:n||s===0,className:"px-2 py-1 text-xs border border-accent/60 text-accent rounded hover:bg-bg-hi disabled:opacity-40",children:n?"Retagging…":`Retag ${s}`})]})]})}function zt(t){je(t),window.dispatchEvent(new CustomEvent("sm:navigate",{detail:"terminal"}))}function Ee(t){return t?t.slice(0,10):""}const Ut=[{value:"all",label:"All"},{value:"completed",label:"Completed"},{value:"skipped",label:"Skipped"},{value:"failed",label:"Failed"}];function Qt({scopeCwd:t=null}){const[s,n]=i.useState(null),[a,d]=i.useState(!0),[o,r]=i.useState(""),[u,x]=i.useState(""),[c,b]=i.useState(""),[v,h]=i.useState("all");i.useEffect(()=>{d(!0),window.api.schedule.getHistory().then(w=>n(w)).catch(w=>n({ok:!1,jobs:[],error:w instanceof Error?w.message:String(w)})).finally(()=>d(!1))},[]);const j=i.useMemo(()=>{if(!(s!=null&&s.jobs))return[];const w=new Set;for(const y of s.jobs){const N=be(y.cwd);N&&w.add(N)}return[...w].sort()},[s]),k=i.useMemo(()=>s!=null&&s.jobs?s.jobs.filter(w=>!(t&&w.cwd!==t||v!=="all"&&w.status!==v||o&&be(w.cwd)!==o||u&&Ee(w.finishedAt)<u||c&&Ee(w.finishedAt)>c)):[],[s,v,o,u,c,t]);if(a)return e.jsx(ae,{title:"Loading history…"});if(!(s!=null&&s.ok)||s.error)return e.jsxs("div",{className:"p-4 text-xs text-red-300",children:["Failed to load history: ",(s==null?void 0:s.error)??"unknown error"]});if(s.jobs.length===0)return e.jsx(ae,{title:"No history yet",hint:"Completed and failed jobs appear here."});const C=v!=="all"||!!o||!!u||!!c;return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-4 py-2.5 border-b border-line flex-wrap",children:[e.jsx(qe,{options:Ut,value:v,onChange:h,pillPadding:"px-3 py-1"}),e.jsx("span",{className:"w-px h-4 bg-line mx-1","aria-hidden":"true"}),j.length>0&&e.jsxs("select",{value:o,onChange:w=>r(w.target.value),className:"bg-bg-hi border border-line rounded-lg px-2 py-1 text-[12.5px] text-fg-dim max-w-[12rem] font-medium",children:[e.jsx("option",{value:"",children:"All projects"}),j.map(w=>e.jsx("option",{value:w,children:w},w))]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] text-fg-faint",children:[e.jsx("span",{children:"from"}),e.jsx("input",{type:"date",value:u,onChange:w=>x(w.target.value),className:"bg-bg-hi border border-line rounded-lg px-2 py-1 text-fg-dim font-mono text-[12px]"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] text-fg-faint",children:[e.jsx("span",{children:"to"}),e.jsx("input",{type:"date",value:c,onChange:w=>b(w.target.value),className:"bg-bg-hi border border-line rounded-lg px-2 py-1 text-fg-dim font-mono text-[12px]"})]}),e.jsxs("span",{className:"text-[12px] text-fg-faint ml-auto font-mono",children:[k.length," / ",s.jobs.length]}),C&&e.jsx("button",{type:"button",onClick:()=>{h("all"),r(""),x(""),b("")},className:"text-[12px] text-fg-faint hover:text-fg-dim underline",children:"clear"})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:k.length===0?e.jsx(ae,{title:"No matches",hint:"Try adjusting the filters."}):e.jsxs("div",{className:"mx-4 my-3 bg-bg-hi border border-line rounded-2xl overflow-hidden",children:[e.jsx("div",{className:"flex items-center px-[18px] py-3 bg-bg-elev",children:e.jsxs("span",{className:"font-serif text-base font-semibold text-fg",children:[k.length," job",k.length!==1?"s":""]})}),k.map(w=>e.jsx(Yt,{job:w},`${w.slug}-${w.finishedAt??""}`))]})})]})}function Yt({job:t}){const[s,n]=i.useState(!1),[a,d]=i.useState(!1),o=le(h=>h.sessions),r=i.useMemo(()=>we(t,o),[t,o]),u=t.startedAt&&t.finishedAt?Date.parse(t.finishedAt)-Date.parse(t.startedAt):null,x=t.startedAt?new Date(t.startedAt).toLocaleString():"—",c=t.finishedAt?new Date(t.finishedAt).toLocaleString():"—",b=u!==null?re(u):"—",v=t.exitCode!==null?String(t.exitCode):"—";return e.jsxs("div",{className:"border-t border-line/60",children:[e.jsxs("button",{type:"button",className:`w-full text-left grid items-center gap-4 px-[18px] py-3.5 cursor-pointer transition-colors hover:bg-bg-elev ${s?"bg-bg-elev":"bg-transparent"}`,style:{gridTemplateColumns:"116px 1fr auto auto"},onClick:()=>n(h=>!h),"aria-expanded":s,children:[e.jsx(Le,{status:t.status}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-2 text-[14.5px] font-medium text-fg leading-snug text-pretty",children:[t.title,e.jsx(Oe,{leaked:t.leakedDescendants})]}),t.error&&!s&&(t.status==="failed"||t.status==="needs_review")&&e.jsx("div",{className:"text-[12.5px] mt-0.5 text-accent/80 truncate",children:t.error}),r.epicId&&e.jsx("span",{className:"flex mt-0.5",children:e.jsx(Ne,{epicId:r.epicId,label:r.label,onOpen:zt})})]}),e.jsx(ye,{cwd:t.cwd}),e.jsxs("span",{className:"inline-flex items-center gap-2.5 font-mono text-xs text-fg-faint whitespace-nowrap",children:[b,e.jsx("span",{className:"inline-flex transition-transform duration-150",style:{transform:s?"rotate(90deg)":"none"},"aria-hidden":"true",children:"›"})]})]}),s&&e.jsxs("div",{className:"grid gap-5 px-[18px] pt-1 pb-5 bg-bg-elev",style:{gridTemplateColumns:"repeat(auto-fit, minmax(160px, 1fr))"},children:[e.jsxs(B,{label:"Status",children:[e.jsx(D,{k:"result",v}),e.jsx(D,{k:"state",v:t.status.replace("_"," ")}),t.verifierVerdict&&e.jsx(D,{k:"verifier",v:ce(t.verifierVerdict)}),t.leakedDescendants&&t.leakedDescendants.length>0&&e.jsx(D,{k:"leaked",v:Fe(t.leakedDescendants),wrap:!0})]}),e.jsxs(B,{label:"Timing",children:[e.jsx(D,{k:"started",v:x}),e.jsx(D,{k:"finished",v:c}),e.jsx(D,{k:"duration",v:b})]}),e.jsxs(B,{label:"Location",children:[e.jsx(D,{k:"group",v:t.parallelGroup!=null?String(t.parallelGroup):"—"}),e.jsx(D,{k:"slug",v:t.slug}),e.jsx(D,{k:"epic",v:r.label??r.epicId??"—",wrap:!0}),t.cwd&&e.jsx(D,{k:"cwd",v:t.cwd,wrap:!0})]}),e.jsx(B,{label:"Actions",children:e.jsxs("div",{className:"flex flex-col gap-2 items-start",children:[t.runId&&e.jsx("button",{type:"button",onClick:h=>{h.stopPropagation(),d(!0)},className:"text-[13px] font-semibold text-fg-dim hover:text-fg bg-transparent border-0 p-0 cursor-pointer",children:"view log →"}),t.status!=="pending"&&e.jsx("button",{type:"button",onClick:h=>{h.stopPropagation(),window.api.schedule.resetJob(t.slug)},className:"text-[13px] font-semibold text-fg-dim hover:text-fg bg-transparent border-0 p-0 cursor-pointer",children:"reset to pending →"}),t.error&&e.jsx("p",{className:"text-[12px] text-accent/90 mt-1 break-words whitespace-pre-wrap max-w-sm m-0",children:t.error})]})})]}),a&&t.runId&&e.jsx(_e,{runId:t.runId,slug:t.slug,title:t.title||t.slug,onClose:()=>d(!1)})]})}function Wt(t){return t?Object.values(t).reduce((s,n)=>s+(n??[]).reduce((a,d)=>{var o;return a+(((o=d.hooks)==null?void 0:o.length)??0)},0),0):0}function Kt(t){var s,n,a;return t?(((s=t.allow)==null?void 0:s.length)??0)+(((n=t.deny)==null?void 0:n.length)??0)+(((a=t.ask)==null?void 0:a.length)??0):0}function Xt({navigate:t}){const s=Ze(),n=se(f=>f.files),a=se(f=>f.loadJson),d=se(f=>f.loadText),o=se(f=>f.watchFile),r=se(f=>f.unwatchFile),u=s?et.resolve("user",s,null):null,x=s?tt.resolve("user",s,null):null,c=s?`${s}/.claude.json`:null;i.useEffect(()=>{const f=[u,c].filter(Boolean);f.forEach($=>{n[$]||a($),o($)});const A=[x].filter(Boolean);return A.forEach($=>{n[$]||d($),o($)}),()=>{[...f,...A].forEach($=>r($))}},[u,x,c]);const[b,v]=i.useState(null);i.useEffect(()=>{if(!s)return;let f=!1;return(async()=>{const A=await it(`${s}/.claude/skills`);f||v(A.length)})(),()=>{f=!0}},[s]);const h=u?n[u]:null,j=c?n[c]:null,k=x?n[x]:null,C=i.useMemo(()=>{if(!(h!=null&&h.exists)||h.parseError)return null;const f=h.diskData;return f===null||typeof f!="object"||Array.isArray(f)?{}:f},[h]),w=i.useMemo(()=>{if(!(j!=null&&j.exists)||j.parseError)return null;const f=j.diskData;return f===null||typeof f!="object"||Array.isArray(f)?{}:f},[j]),y=h?h.parseError?"invalid JSON":null:"loading…",N=j?j.parseError?"invalid JSON":null:"loading…",g=[{key:"settings",title:"Settings",summary:y??(C?`${Object.keys(C).length} top-level key${Object.keys(C).length===1?"":"s"} configured`:"not configured")},{key:"permissions",title:"Permissions",summary:y??(C?`${Kt(C.permissions)} rule(s) configured`:"not configured")},{key:"hooks",title:"Hooks",summary:y??(C?`${Wt(C.hooks)} hook(s) configured`:"not configured")},{key:"mcp",title:"MCP Servers",summary:N??(w?`${Object.keys(w.mcpServers??{}).length} MCP server(s)`:"not configured")},{key:"system-prompt",title:"System Prompt",summary:k!=null&&k.exists&&k.diskRaw.trim().length>0?`configured (${k.diskRaw.length.toLocaleString()} chars)`:"not set"},{key:"skills",title:"Skills",summary:b===null?"loading…":`${b} skill(s) installed`}];return e.jsxs("section",{className:"border border-line rounded-xl bg-bg-hi px-5 py-4",children:[e.jsx("h2",{className:"m-0 mb-1 font-serif text-[18px] font-semibold text-fg",children:"Global Controls"}),e.jsx("p",{className:"mt-0 mb-3 text-[13px] text-fg-dim leading-relaxed",children:"Machine-wide (user-scope) config state for the tabs that default to global here on Home. Read-only summary — open a card to edit."}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:g.map(f=>e.jsxs("button",{type:"button",onClick:()=>t==null?void 0:t(f.key),className:"text-left border border-line rounded-lg bg-bg px-3 py-2.5 hover:border-accent transition-colors",children:[e.jsx("div",{className:"text-[13px] font-medium text-fg",children:f.title}),e.jsx("div",{className:"mt-0.5 text-[12px] text-fg-dim",children:f.summary})]},f.key))})]})}function Zt({navigate:t}){const s=st(),[n,a]=i.useState(!1),[d,o]=i.useState(!1);i.useEffect(()=>{let u=!0;return nt().then(x=>{u&&a(x.openToHomeOnLaunch===!0)}),()=>{u=!1}},[]);const r=async u=>{a(u),o(!0);try{await rt({openToHomeOnLaunch:u})}catch{a(!u),L.error('Failed to save "Open to Home on launch" — try again.')}finally{o(!1)}};return e.jsxs("div",{className:"max-w-[760px] space-y-6",children:[e.jsx(Xt,{navigate:t}),e.jsxs("section",{className:"border border-line rounded-xl bg-bg-hi px-5 py-4",children:[e.jsx("h2",{className:"m-0 mb-1 font-serif text-[18px] font-semibold text-fg",children:"Session pool"}),e.jsxs("p",{className:"mt-0 mb-3 text-[13px] text-fg-dim leading-relaxed",children:["One machine-wide pool of concurrent Claude sessions. Scheduler jobs and Epic chat runs each request a slot before launching; work waits when the pool is full. Adjustable from 0 (pauses new launches) to 10 on the Home tab, default 5 — or pin it with"," ",e.jsx("code",{className:"font-mono text-[12px]",children:"SM_SESSION_SLOTS"})," (clamped 0–10)."]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(at,{total:(s==null?void 0:s.total)??5,inUse:(s==null?void 0:s.inUse)??0,size:"md"}),e.jsx("span",{className:"ml-2 font-mono text-[12.5px] text-fg-faint",children:s?`${s.inUse} / ${s.total} in use`:"loading…"})]}),s&&s.holders.length>0&&e.jsx("ul",{className:"mt-2 mb-0 pl-0 list-none space-y-0.5",children:s.holders.map((u,x)=>e.jsxs("li",{className:"font-mono text-[12px] text-fg-dim",children:[u.owner," ",e.jsxs("span",{className:"text-fg-faint",children:["since ",new Date(u.at).toLocaleTimeString()]})]},x))})]}),e.jsxs("section",{className:"border border-line rounded-xl bg-bg-hi px-5 py-4",children:[e.jsx("h2",{className:"m-0 mb-1 font-serif text-[18px] font-semibold text-fg",children:"Behavior"}),e.jsx("p",{className:"mt-0 mb-3 text-[13px] text-fg-dim leading-relaxed",children:"Cross-project app behavior, independent of any single project's config."}),e.jsx(ot,{checked:n,onChange:r,disabled:d,label:"Open to Home on launch"})]}),e.jsxs("section",{className:"border border-line rounded-xl bg-bg-hi px-5 py-4",children:[e.jsx("h2",{className:"m-0 mb-1 font-serif text-[18px] font-semibold text-fg",children:"On disk"}),e.jsxs("p",{className:"mt-0 mb-2 text-[13px] text-fg-dim leading-relaxed",children:["Global runtime state is deliberately small — everything project-scoped lives inside that project's ",e.jsx("code",{className:"font-mono text-[12px]",children:"session-manager-operations/"})," folder."]}),e.jsxs("ul",{className:"m-0 pl-0 list-none space-y-1 font-mono text-[12px] text-fg-dim",children:[e.jsxs("li",{children:["~/.claude/session-manager/scheduler-machine.json ",e.jsx("span",{className:"text-fg-faint",children:"— policy + pause state"})]}),e.jsxs("li",{children:["<project>/session-manager-operations/scheduler/state/ ",e.jsx("span",{className:"text-fg-faint",children:"— per-project queue + history"})]}),e.jsxs("li",{children:["<project>/session-manager-operations/scheduler/epics/<epic>/prds/ ",e.jsx("span",{className:"text-fg-faint",children:"— PRD sources, per session"})]})]})]})]})}const Ie="sm.schedulerTab.subView",es=[{key:"queue",label:"Queue"},{key:"prds",label:"PRDs"},{key:"history",label:"History"}];function ts(t,s){const n=new Date(t),a=new Date(s);return n.getFullYear()===a.getFullYear()&&n.getMonth()===a.getMonth()&&n.getDate()===a.getDate()}function ss(t,s,n){if(t==="auth")return"Scheduler paused: Claude sign-in expired or invalid. Restart the app or re-run `claude login`, then Resume.";if(t==="rate_limit"){if(s){const d=new Date(s).getTime()-n;return d>0?`Paused for rate limit — resumes in ${H(d)}`:"Paused for rate limit — resume pending"}return"Paused for rate limit"}return t==="network"?"Paused: billing endpoint unreachable for 30+ min.":t==="manual"?"Scheduler paused manually. Click Resume to restart.":`Scheduler paused (${t})`}function ns({scopeCwd:t}){const{snapshot:s}=ve(),[n,a]=i.useState(()=>Date.now());if(i.useEffect(()=>{const N=setInterval(()=>a(Date.now()),3e4);return()=>clearInterval(N)},[]),!s)return null;const d=(s.jobs??[]).filter(N=>!t||N.cwd===t),o=d.filter(N=>N.status==="pending").length,r=d.filter(N=>N.status==="running").length,u=d.filter(N=>N.status==="completed"&&(N.finishedAt?ts(N.finishedAt,n):!1)).length,x=s.nextReset?new Date(s.nextReset).getTime():null,c=x?x>n?H(x-n):"soon":"—",b=U(s.lastRunAt?new Date(s.lastRunAt).getTime():null,n),v=s.paused,h=Object.entries(s.launchBlocks??{}),j=Object.entries(s.launchMitigations??{}),k=s.pollHealth,C=k!=null&&!k.lastPollOk,y=(v==null?void 0:v.reason)==="auth"||(v==null?void 0:v.reason)==="network"?"bg-red-950/60 border-red-700/50 text-red-200":"bg-amber-950/60 border-amber-700/50 text-amber-200";return e.jsxs("div",{className:"flex flex-col gap-2",children:[v&&e.jsxs("div",{className:`flex items-center gap-3 border rounded-xl px-4 py-2.5 text-[13px] ${y}`,children:[e.jsx("span",{className:"flex-1 leading-snug",children:ss(v.reason,v.resumeAt,n)}),e.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),className:"shrink-0 px-2.5 py-1 rounded border border-current/40 hover:bg-white/10 transition-colors text-[12px] font-medium",children:"Resume"})]}),h.map(([N,g])=>e.jsxs("div",{"data-testid":"launch-block-banner",className:"flex items-start gap-3 border rounded-xl px-4 py-2.5 text-[13px] bg-red-950/60 border-red-700/50 text-red-200",children:[e.jsxs("div",{className:"flex-1 leading-snug min-w-0",children:[e.jsxs("div",{className:"font-medium",children:["Launches for ",e.jsx("span",{className:"font-mono",children:N})," jobs are failing before any work starts",g.httpStatus?` (HTTP ${g.httpStatus}, ${g.kind})`:` (${g.kind})`,g.exhausted?" — held until the Claude CLI version changes or you press Retry now.":g.until?` — next automatic probe ${new Date(g.until).getTime()>n?`in ${H(new Date(g.until).getTime()-n)}`:"on the next tick"}.`:"."]}),e.jsx("div",{className:"mt-0.5 text-red-200/80",children:g.hint}),e.jsxs("div",{className:"mt-0.5 font-mono text-[12px] text-red-200/70 truncate",title:g.message,children:[g.attempts," failed probe",g.attempts===1?"":"s",g.claudeVersion?` · CLI ${g.claudeVersion}`:"",g.lastSlug?` · last: ${g.lastSlug}`:""," · ",g.message]})]}),e.jsx("button",{type:"button",onClick:()=>window.api.schedule.resume(),className:"shrink-0 px-2.5 py-1 rounded border border-current/40 hover:bg-white/10 transition-colors text-[12px] font-medium",children:"Retry now"})]},`launch-block-${N}`)),j.map(([N,g])=>e.jsx("div",{"data-testid":"launch-mitigation-banner",className:"flex items-start gap-3 border rounded-xl px-4 py-2.5 text-[13px] bg-amber-950/60 border-amber-700/50 text-amber-200",children:e.jsxs("div",{className:"flex-1 leading-snug min-w-0",children:[e.jsxs("div",{className:"font-medium",children:[e.jsx("span",{className:"font-mono",children:N})," jobs are running in degraded mode"," ","(",e.jsx("span",{className:"font-mono",children:Object.entries(g.env).map(([f,A])=>`${f}=${A}`).join(" ")}),")",g.claudeVersion?` since CLI ${g.claudeVersion}`:"","."]}),e.jsx("div",{className:"mt-0.5 text-amber-200/80",children:g.hint})]})},`launch-mitigation-${N}`)),e.jsxs("div",{className:"flex items-center gap-5 flex-wrap bg-bg-hi border border-line rounded-xl px-4 py-3",children:[e.jsxs("span",{className:"inline-flex items-center gap-2 text-[13.5px] text-fg font-semibold whitespace-nowrap",children:[e.jsx("span",{className:"text-sage","aria-hidden":"true",children:e.jsx(ue,{name:"clock",size:15})}),"Window resets in ",c]}),e.jsx("span",{className:"w-px h-[18px] bg-rule shrink-0","aria-hidden":"true"}),e.jsx(he,{dotClass:"bg-fg-faint",n:o,label:"pending"}),e.jsx(he,{dotClass:"bg-accent",n:r,label:"running"}),e.jsx(he,{dotClass:"bg-sage",n:u,label:"completed today"}),s.utilization!==null&&s.utilization!==void 0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"w-px h-[18px] bg-rule shrink-0","aria-hidden":"true"}),C?e.jsxs("span",{className:"font-mono text-[12.5px] text-amber-400/70",title:"Billing poll failing — this reading may be outdated",children:[Math.round(s.utilization),"% of window used · last good reading"," ",U(k.lastPollAt,n)]}):e.jsxs("span",{className:"font-mono text-[12.5px] text-fg-faint",children:[Math.round(s.utilization),"% of window used"]})]}),e.jsxs("span",{className:"ml-auto font-mono text-[12.5px] text-fg-faint whitespace-nowrap",children:["last batch ",b]})]})]})}function as({navigate:t}={}){var u;const[s,n]=i.useState(()=>{const x=localStorage.getItem(Ie);return x==="prds"||x==="history"||x==="machine"?x:"queue"}),a=Ae(x=>x.tabs),d=Ae(x=>x.activeTabId),o=((u=a.find(x=>x.id===d))==null?void 0:u.cwd)??null,r=o;return i.useEffect(()=>{o&&(le.getState().hydrate(o),le.getState().hydrateArchived(o))},[o]),i.useEffect(()=>{localStorage.setItem(Ie,s)},[s]),e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"shrink-0 px-9 pt-7 pb-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("div",{className:"text-xs font-bold text-fg-faint tracking-[0.8px] uppercase mb-1",children:"Workspace"}),e.jsx(lt,{active:"scheduler"})]}),e.jsx("h1",{className:"m-0 font-serif text-[40px] font-semibold leading-none tracking-tight text-fg",children:"Scheduler"}),e.jsxs("p",{className:"mt-2 text-[14.5px] text-fg-dim leading-relaxed max-w-[600px]",children:["Global scheduler policy and the machine-wide session pool, plus — when a project tab is active — that project's PRDs, run as"," ",e.jsx("code",{className:"font-mono text-[13.5px]",children:"claude -p"})," ","jobs against your 5-hour window. Jobs auto-pause on rate-limit and resume on the next reset."]}),e.jsx("div",{className:"mt-[18px] mb-[22px]",children:e.jsx(ns,{scopeCwd:r})}),e.jsxs("div",{className:"flex items-center gap-3 pb-0",children:[e.jsx(dt,{options:es,active:s,onChange:n}),e.jsxs("button",{type:"button",onClick:()=>n("machine"),"aria-pressed":s==="machine",className:`inline-flex items-center gap-1.5 px-[15px] py-2 rounded-lg text-[13.5px] transition-colors ${s==="machine"?"bg-bg-elev border border-line font-semibold text-fg":"text-fg-faint hover:text-fg-dim"}`,title:"Machine-wide config that applies to every project — not this project's live queue.",children:[e.jsx("span",{"aria-hidden":"true",children:"⚙"})," Machine"]})]}),s==="queue"&&e.jsx("p",{className:"mt-2 text-[14.5px] text-fg-dim leading-relaxed max-w-[600px]",children:"What's running right now, and what fires next."}),s==="prds"&&e.jsx("p",{className:"mt-2 text-[14.5px] text-fg-dim leading-relaxed max-w-[600px]",children:"Authored PRD source files on disk — edit, lint, archive, or queue them."}),s==="history"&&e.jsx("p",{className:"mt-2 text-[14.5px] text-fg-dim leading-relaxed max-w-[600px]",children:"The last 50 completed and failed jobs, for this project."}),s==="machine"&&e.jsx("p",{className:"mt-2 text-[14.5px] text-fg-dim leading-relaxed max-w-[600px]",children:"Machine-wide setup that applies to every project."})]}),e.jsxs("div",{className:"flex-1 min-h-0",children:[s==="queue"&&e.jsx(vt,{scopeCwd:r,navigate:t}),s==="prds"&&e.jsx(Gt,{scopeCwd:r}),s==="history"&&e.jsx(Qt,{scopeCwd:r}),s==="machine"&&e.jsx("div",{className:"h-full overflow-y-auto px-9 py-6",children:e.jsx(Zt,{navigate:t})})]})]})}const ds=i.memo(as);export{ds as Scheduler};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a9 as i,S as d}from"./index-QLRf0epp.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};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{ai as d,a9 as e,S as O,a as Q,j as R,aD as X,R as ee,as as te,ay as se,aG as $,aA as ae,av as I,J as ne,V as re,w as G}from"./index-QLRf0epp.js";import{P as le}from"./Panel-LurG5VfD.js";import{S as ie}from"./ScopeSwitcher-DzFXUKLZ.js";import{S as K}from"./SaveBar-alDHG6cP.js";import{u as oe,m as ce,p as de,a as H,E as ue,s as xe}from"./settingsSchema-DA3N2Up3.js";import{T as L}from"./Toggle-BGOn3DZj.js";import"./monaco-editor-BW5C4Iv1.js";const pe=[{id:"essentials",title:"Essentials",summary:"The knobs you reach for first.",keys:["model","language","outputStyle","permissions"]},{id:"git",title:"Git & Commits",summary:"How Claude writes commits and pull requests on your behalf.",keys:["attribution","includeGitInstructions","includeCoAuthoredBy"]},{id:"memory",title:"Memory & Plans",summary:"Context Claude keeps between sessions and where it files plans.",keys:["autoMemoryEnabled","plansDirectory","claudeMdExcludes","respectGitignore"]},{id:"model",title:"Model & Reasoning",summary:"Model allow/override lists, reasoning depth, and fast-mode toggles — machine-wide, with no per-Epic override yet. An Epic's Agent persona model (Agent Library) still wins over Essentials' plain model default.",advanced:!0,keys:["availableModels","modelOverrides","effortLevel","fastMode","fastModePerSessionOptIn","alwaysThinkingEnabled"]},{id:"interface",title:"Interface",summary:"Visual polish — spinners, progress bars, motion.",keys:["spinnerTipsEnabled","spinnerTipsOverride","spinnerVerbs","terminalProgressBarEnabled","showTurnDuration","prefersReducedMotion","companyAnnouncements","statusLine","teammateMode"]},{id:"updates",title:"Updates & Cleanup",summary:"Release channel and how long transcripts stick around.",keys:["autoUpdatesChannel","cleanupPeriodDays"]},{id:"env",title:"Environment & Auth",summary:"Environment variables and auth-helper scripts.",keys:["env","apiKeyHelper","awsCredentialExport","awsAuthRefresh"]},{id:"hooks",title:"Hooks",summary:"Scripts Claude runs before/after tool use.",keys:["hooks","disableAllHooks","allowedHttpHookUrls","httpHookAllowedEnvVars"]},{id:"mcp",title:"MCP Servers",summary:"External tool providers Claude can talk to.",keys:["enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers"]},{id:"plugins",title:"Plugins",summary:"Installed plugins, marketplaces, and per-plugin configuration.",keys:["enabledPlugins","extraKnownMarketplaces","skippedPlugins","skippedMarketplaces","pluginConfigs"]},{id:"filesystem",title:"File Picker & Sandbox",summary:"How Claude browses files and the sandbox it runs in.",keys:["fileSuggestion","sandbox","worktree"]},{id:"login",title:"Login",summary:"Which login method to force on startup.",keys:["forceLoginMethod","forceLoginOrgUUID"]},{id:"feedback",title:"Feedback",summary:"Session-quality surveys.",keys:["feedbackSurveyRate"]},{id:"advanced",title:"Advanced / Enterprise",summary:"Managed-settings-only keys and enterprise allow/denylists.",advanced:!0,keys:["allowedMcpServers","deniedMcpServers","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","strictKnownMarketplaces","blockedMarketplaces","pluginTrustMessage","otelHeadersHelper","skipWebFetchPreflight"]}],me={mcp:"MCP",url:"URL",urls:"URLs",http:"HTTP",ui:"UI",id:"ID",uuid:"UUID",api:"API",aws:"AWS",otel:"OTel",json:"JSON"};function W(s){return s.replace(/^\$/,"").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").toLowerCase().split(/\s+/).filter(Boolean).map((l,n)=>{const r=me[l];return r||(n===0?l.charAt(0).toUpperCase()+l.slice(1):l)}).join(" ")}function V(s){const a=new Set,t=[];for(const n of pe){const r=n.keys.filter(i=>s.has(i));r.forEach(i=>a.add(i)),r.length!==0&&t.push({id:n.id,title:n.title,summary:n.summary,advanced:!!n.advanced,keys:r})}const l=Array.from(s).filter(n=>!a.has(n)&&n!=="$schema").sort();return l.length>0&&t.push({id:"other",title:"Other",summary:"Keys not yet grouped.",advanced:!1,keys:l}),t}function fe(s,a){return V(s).map(t=>({id:t.id,title:t.title,advanced:t.advanced,total:t.keys.length,setCount:t.keys.filter(l=>a.has(l)).length}))}const he={};function q(s,a){if(a)return{text:a,authored:!1};const t=he[s];return t?{text:t,authored:!0}:null}const ge={essentials:"star",git:"link",memory:"memory",model:"sparkle",interface:"eye",updates:"reload",env:"keys",hooks:"hooks",mcp:"mcp",plugins:"plugins",filesystem:"folder",login:"lock",feedback:"send",advanced:"shield",other:"dot"},be=["user","project","local","default"],ye={user:"user",project:"project",local:"local",default:"default"};function je({node:s,targetScope:a,onOverride:t,schema:l}){const[n,r]=d.useState(""),[i,p]=d.useState(!1),[m,v]=d.useState(!0),x=s.kind==="object"?s:null,w=x?Object.keys(x.children):[],g=l.rootKeys(),y=new Set([...w,...g]),u=d.useMemo(()=>V(y),[Array.from(y).sort().join(",")]),b=d.useMemo(()=>fe(y,new Set(w)),[Array.from(y).sort().join(","),w.join(",")]),[C,E]=d.useState(null),f=d.useRef(null),S=o=>{const j=u.find(N=>N.id===o);j!=null&&j.advanced&&!i&&p(!0),E(o)};d.useEffect(()=>{if(!C)return;E(null);const o=f.current,j=document.getElementById(`settings-group-${C}`);if(!o||!j)return;const N=j.getBoundingClientRect().top-o.getBoundingClientRect().top;o.scrollBy({top:N,behavior:"smooth"})},[C]);const k=d.useMemo(()=>u.filter(o=>i||!o.advanced).map(o=>({...o,keys:o.keys.filter(j=>{const N=(x==null?void 0:x.children[j])!==void 0;if(!m&&!N)return!1;if(!n.trim())return!0;const h=l.at([j]);return[j,W(j),(h==null?void 0:h.description)??""].join(" ").toLowerCase().includes(n.toLowerCase())})})).filter(o=>o.keys.length>0),[u,n,i,m,x,l]);return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 flex items-center gap-3 text-xs",children:[e.jsxs("span",{className:"text-fg-faint",children:["writing overrides to"," ",e.jsx("span",{className:"text-fg-dim font-medium",children:O[a].label})]}),e.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:m,onChange:o=>v(o.target.checked),className:"accent-accent"}),"show not-yet-configured"]}),e.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:o=>p(o.target.checked),className:"accent-accent"}),"show advanced"]}),e.jsx("div",{className:"flex-1"}),e.jsx("input",{value:n,onChange:o=>r(o.target.value),placeholder:"search settings…",className:"bg-bg border border-line rounded px-2 py-1 text-xs text-fg w-64"})]}),e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsx(ve,{groups:b,onJump:S}),e.jsxs("div",{ref:f,className:"flex-1 overflow-auto py-3",children:[k.map(o=>e.jsx(Ne,{id:o.id,title:o.title,summary:o.summary,advanced:o.advanced,children:o.keys.map(j=>{const N=x==null?void 0:x.children[j],h=l.at([j]);return e.jsx(we,{keyName:j,node:N,info:h,targetScope:a,onOverride:(c,T)=>t([j],c,T)},j)})},o.id)),k.length===0&&e.jsxs("div",{className:"px-6 py-12 text-center text-fg-faint text-sm",children:['no settings match "',n,'"']})]})]})]})}function ve({groups:s,onJump:a}){return e.jsx("nav",{className:"shrink-0 w-48 border-r border-line bg-bg-elev/30 overflow-y-auto py-3",children:s.map(t=>e.jsxs("button",{onClick:()=>a(t.id),className:"w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-bg-hi transition-colors",title:`jump to ${t.title}`,children:[e.jsx(Q,{name:ge[t.id]??"dot",size:15,className:"text-fg-faint shrink-0"}),e.jsx("span",{className:"flex-1 min-w-0 truncate text-xs text-fg-dim",children:t.title}),e.jsxs("span",{className:"text-[10px] text-fg-faint font-mono shrink-0",children:[t.setCount,"/",t.total]})]},t.id))})}function Ne({id:s,title:a,summary:t,advanced:l,children:n}){const[r,i]=d.useState(!0);return e.jsxs("section",{id:`settings-group-${s}`,className:"mx-4 mb-4 rounded-lg border border-line shadow-sm bg-bg-elev/50 overflow-hidden",children:[e.jsxs("header",{className:"px-4 py-3 bg-bg-elev cursor-pointer hover:bg-bg-hi flex items-center gap-3 border-b border-line",onClick:()=>i(!r),children:[e.jsx("span",{className:"text-fg-faint w-3",children:r?"▾":"▸"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-fg text-base font-semibold",children:a}),l&&e.jsx("span",{className:"text-[9px] px-1.5 py-0 rounded border border-yellow-900/40 bg-yellow-950/30 text-yellow-500/80 uppercase tracking-wide",children:"advanced"})]}),e.jsx("p",{className:"text-fg-dim text-sm mt-0.5",children:t})]})]}),r&&e.jsx("div",{className:"divide-y divide-line/60",children:n})]})}function we({keyName:s,node:a,info:t,targetScope:l,onOverride:n}){const[r,i]=d.useState(!1),[p,m]=d.useState(!1),v=W(s),x=a!==void 0,g=(a==null?void 0:a.kind)==="leaf"?a:null,y=(a==null?void 0:a.kind)==="object"||(a==null?void 0:a.kind)==="array",u=t==null?void 0:t.default,b=g&&u!==void 0&&Y(g.value,u),C=Pe({isSet:x,leafNode:g,defaultVal:u,isDefault:!!b,node:a}),E=Se(g,u),f=E.length>=2,S=!!g&&!b,k=q(s,t==null?void 0:t.description);return e.jsx("div",{className:"px-4 py-3 hover:bg-bg-elev/20",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("button",{onClick:()=>i(!r),className:"text-fg-faint hover:text-fg w-3 mt-0.5",title:r?"collapse":"expand",children:r?"▾":"▸"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-2 flex-wrap",children:[e.jsx("h3",{className:"text-fg text-sm",children:v}),e.jsx(Re,{kind:C.kind,label:C.label}),f&&e.jsxs("button",{onClick:o=>{o.stopPropagation(),r||i(!0),m(j=>!j)},className:"text-[9px] px-1.5 py-0 rounded border border-blue-900/40 bg-blue-950/30 text-blue-300/90 uppercase tracking-wide hover:bg-blue-900/40",title:"this key is defined in multiple scopes — click to expand",children:["drift · ",E.map(o=>ye[o]).join(" · ")]}),S&&g&&e.jsx("button",{onClick:o=>{o.stopPropagation(),n(void 0,g.winner)},className:"text-[9px] px-1.5 py-0 rounded border border-line bg-bg-elev text-fg-faint uppercase tracking-wide hover:text-fg hover:bg-bg-hi",title:`reset · delete from ${O[g.winner].label}`,children:"↺ reset"}),(t==null?void 0:t.deprecated)&&e.jsx("span",{className:"text-[9px] px-1 py-0 rounded border border-yellow-900/40 bg-yellow-950/30 text-yellow-500/80 uppercase tracking-wide",children:"deprecated"}),(t==null?void 0:t.required)&&!x&&e.jsx("span",{className:"text-[9px] px-1 py-0 rounded border border-red-900/40 bg-red-950/30 text-red-400/80 uppercase tracking-wide",children:"required"})]}),k&&e.jsx("p",{className:`text-fg-dim text-xs mt-0.5 leading-relaxed ${k.authored?"inline-block border-b border-dotted border-fg-faint/70 cursor-help":""}`,title:k.authored?"In-app-authored description — not from the official Claude Code schema":void 0,children:Ie(k.text)}),r&&p&&g&&e.jsx(ke,{leaf:g,defaultVal:u,onReset:o=>n(void 0,o)}),r&&e.jsx(Ce,{keyName:s,node:a,info:t,targetScope:l,onOverride:o=>n(o)})]}),e.jsx("div",{className:"shrink-0",children:!r&&e.jsx(Ae,{node:a,info:t,onSet:o=>{n(o)},disabled:y&&x})})]})})}function Se(s,a){if(!s)return[];const t=new Set;t.add(s.winner);for(const l of s.shadowed)t.add(l.scope);return a!==void 0&&t.add("default"),be.filter(l=>t.has(l))}function ke({leaf:s,defaultVal:a,onReset:t}){const l={};l[s.winner]={value:s.value,winner:!0};for(const n of s.shadowed)l[n.scope]={value:n.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(n=>{const r=l[n],i=r!==void 0;return e.jsxs("div",{className:"grid grid-cols-[5rem_1fr_auto] gap-2 px-2 py-1 items-center",children:[e.jsx("span",{className:"text-fg-faint",children:O[n].label}),e.jsx("span",{className:`font-mono truncate ${r!=null&&r.winner?"text-accent":"text-fg-dim"}`,children:i?P(r.value):e.jsx("span",{className:"text-fg-faint",children:"—"})}),i?e.jsx("button",{onClick:()=>t(n),className:"text-[9px] px-1.5 py-0 rounded border border-line text-fg-faint uppercase tracking-wide hover:text-fg hover:bg-bg-hi",title:`delete this key from ${O[n].label}`,children:"↺"}):e.jsx("span",{})]},n)}),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:a!==void 0?P(a):e.jsx("span",{className:"text-fg-faint",children:"—"})}),e.jsx("span",{})]})]})]})}function Ce({keyName:s,node:a,info:t,targetScope:l,onOverride:n}){const i=(a==null?void 0:a.kind)==="leaf"?a:null,p=q(s,t==null?void 0:t.description);return e.jsxs("div",{className:"mt-3 space-y-2 text-xs",children:[p&&e.jsx("p",{className:`text-fg-dim leading-relaxed whitespace-pre-wrap ${p.authored?"inline-block border-b border-dotted border-fg-faint/70 cursor-help":""}`,title:p.authored?"In-app-authored description — not from the official Claude Code schema":void 0,children:p.text}),e.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-fg-faint",children:[(t==null?void 0:t.type)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Type"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:Array.isArray(t.type)?t.type.join(" | "):t.type})]}),(t==null?void 0:t.default)!==void 0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Default"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:P(t.default)})]}),(t==null?void 0:t.enum)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Options"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:t.enum.map(m=>String(m)).join(" | ")})]}),i&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Current"}),e.jsxs("dd",{className:"font-mono",children:[e.jsx("span",{className:"text-fg-dim",children:P(i.value)}),e.jsxs("span",{className:"ml-2 text-fg-faint",children:["from ",O[i.winner].label]})]})]}),i&&i.shadowed.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Shadowed"}),e.jsx("dd",{className:"space-y-0.5",children:i.shadowed.map((m,v)=>e.jsxs("div",{className:"font-mono text-fg-faint line-through",children:[P(m.value)," —"," ",e.jsx("span",{className:"no-underline",children:O[m.scope].label})]},v))})]}),(a==null?void 0:a.kind)==="array"&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Accumulated"}),e.jsxs("dd",{className:"text-fg-dim",children:[a.items.length," items across all scopes"]})]})]}),e.jsx("div",{className:"pt-2 flex items-center gap-2 flex-wrap border-t border-line/60",children:e.jsx(Ee,{keyName:s,node:a,info:t,onChange:n,targetScope:l})})]})}function Ee({node:s,info:a,onChange:t,targetScope:l}){const r=(s==null?void 0:s.kind)==="leaf"?s.value:a==null?void 0:a.default,i=z(a==null?void 0:a.type);if(i==="boolean"){const p=r===!0;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-fg-faint",children:"Set to:"}),e.jsx("div",{className:"inline-flex rounded border border-line overflow-hidden",children:[{v:!0,label:"on"},{v:!1,label:"off"}].map(({v:m,label:v})=>e.jsx("button",{onClick:()=>t(m),className:`px-3 py-0.5 text-xs transition-colors ${p===m?"bg-accent text-bg":"bg-bg-elev text-fg-dim hover:bg-bg-hi hover:text-fg"}`,children:v},v))}),e.jsxs("span",{className:"text-fg-faint",children:["→ ",O[l].label]})]})}return a!=null&&a.enum?e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-fg-faint",children:"Choose:"}),a.enum.map(p=>{const m=Y(r,p);return e.jsx("button",{onClick:()=>t(p),className:`px-2 py-0.5 text-xs rounded border ${m?"bg-accent text-bg border-accent":"bg-bg-elev text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,children:String(p)},String(p))}),e.jsxs("span",{className:"text-fg-faint",children:["→ ",O[l].label]})]}):i==="integer"||i==="number"?e.jsx(Oe,{value:typeof r=="number"?r:void 0,integer:i==="integer",onCommit:t,target:O[l].label}):i==="string"?e.jsx(Te,{value:typeof r=="string"?r:"",onCommit:t,target:O[l].label}):e.jsxs("div",{className:"text-fg-faint",children:["Complex value (",i??"object/array",") — use the"," ",e.jsx("span",{className:"text-fg-dim",children:"Raw"})," tab to edit."]})}function Oe({value:s,integer:a,onCommit:t,target:l}){const[n,r]=d.useState(s!==void 0?String(s):""),i=()=>{const p=a?parseInt(n,10):parseFloat(n);Number.isNaN(p)||t(p)};return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-fg-faint",children:"Set to:"}),e.jsx("input",{type:"number",value:n,onChange:p=>r(p.target.value),onBlur:i,onKeyDown:p=>{p.key==="Enter"&&p.target.blur()},className:"w-24 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),e.jsxs("button",{onClick:i,className:"px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",l]})]})}function Te({value:s,onCommit:a,target:t}){const[l,n]=d.useState(s);return e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx("span",{className:"text-fg-faint shrink-0",children:"Set to:"}),e.jsx("input",{type:"text",value:l,onChange:r=>n(r.target.value),onKeyDown:r=>{r.key==="Enter"&&a(l)},className:"flex-1 min-w-0 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),e.jsxs("button",{onClick:()=>a(l),className:"shrink-0 px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",t]})]})}function Ae({node:s,info:a,onSet:t,disabled:l}){const n=(s==null?void 0:s.kind)==="leaf",r=z(a==null?void 0:a.type);if(l)return null;if(r==="boolean"){const i=n&&s.value===!0;return e.jsx("button",{onClick:()=>t(!i),className:`px-2.5 py-0.5 text-xs rounded border transition-colors ${i?"bg-accent/15 text-accent border-accent/40 hover:bg-accent hover:text-bg":"bg-bg-elev text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,title:"toggle",children:i?"on":"off"})}return null}function Pe({isSet:s,leafNode:a,defaultVal:t,isDefault:l,node:n}){return s?(n==null?void 0:n.kind)==="array"?{kind:"accumulated",label:`${n.items.length} items`}:(n==null?void 0:n.kind)==="object"?{kind:"set",label:"configured"}:a?l?{kind:"default",label:`= default · ${O[a.winner].label}`}:a.shadowed.length>0?{kind:"override",label:`overriding ${a.shadowed.length} scope(s)`}:{kind:"set",label:`set in ${O[a.winner].label}`}:{kind:"set",label:"configured"}:t!==void 0?{kind:"default",label:`using default: ${P(t)}`}:{kind:"unset",label:"not configured"}}function Re({kind:s,label:a}){const t={set:"bg-accent/15 text-accent border-accent/30",default:"bg-bg-hi text-fg-dim border-line",unset:"bg-bg-elev text-fg-faint border-line",override:"bg-purple-950/30 text-purple-400/80 border-purple-900/40",accumulated:"bg-blue-950/30 text-blue-400/80 border-blue-900/40"}[s];return e.jsx("span",{className:`text-[9px] px-1.5 py-0 rounded border uppercase tracking-wide ${t}`,children:a})}function z(s){if(s)return Array.isArray(s)?s.find(t=>t!=="null")??s[0]:s}function Y(s,a){return s===a?!0:typeof s!=typeof a?!1:s&&a&&typeof s=="object"?JSON.stringify(s)===JSON.stringify(a):!1}function Ie(s){const a=s.trim().split(`
|
|
2
|
+
`)[0],t=a.match(/^([^.!?]+[.!?])/);return t?t[1]:a.length>120?a.slice(0,120)+"…":a}function P(s){if(typeof s=="string")return s===""?'""':JSON.stringify(s);if(s===null)return"null";if(s===void 0)return"—";if(typeof s=="object"){const a=JSON.stringify(s);return a.length>60?a.slice(0,60)+"…":a}return String(s)}const De=1440*60*1e3;function U(s){if(!s)return"never";const a=new Date(s).getTime();return Number.isNaN(a)?"never":new Date(a).toLocaleString()}function J(s){return s?new Date(s).toLocaleString():"never"}function Me(){return e.jsxs("div",{className:"p-4 max-w-3xl space-y-8 text-sm",children:[e.jsx(Le,{}),e.jsx("hr",{className:"border-line"}),e.jsx(_e,{})]})}function Le(){const[s,a]=d.useState(null),[t,l]=d.useState(null),[n,r]=d.useState(null),[i,p]=d.useState(null),[m,v]=d.useState(!1),[x,w]=d.useState(null),[g,y]=d.useState(null);if(d.useEffect(()=>{let f=!1;return Promise.all([window.api.otel.getConfig(),window.api.otel.status(),window.api.otel.configPath()]).then(([S,k,o])=>{f||(a(S),r(S),l(k),p(o))}).catch(S=>{console.warn("[telemetry] load failed:",S==null?void 0:S.message)}),()=>{f=!0}},[]),!n||!s)return e.jsx(R,{title:"loading…"});const u=JSON.stringify(n)!==JSON.stringify(s),b=(f,S)=>{w(null),r({...n,[f]:S})},C=async()=>{v(!0),w(null);try{const f=await window.api.otel.setConfig(n);!f.ok&&f.error&&w(f.error),a(f.config),r(f.config),l(f.status),y(Date.now())}catch(f){w(f instanceof Error?f.message:String(f))}finally{v(!1)}},E=()=>{w(null),r(s)};return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-fg text-base font-medium",children:"OpenTelemetry export"}),e.jsx("p",{className:"text-fg-dim text-xs leading-relaxed",children:"When enabled, every classified transcript event (tool_use, todo_write, plan, usage, agent_spawn) is mirrored as a 0-duration OTLP/HTTP span. Point this at a local collector (Jaeger, Grafana Tempo, SigNoz, Honeycomb) for cross-session analysis."}),i&&e.jsxs("p",{className:"text-fg-faint text-[11px]",children:["stored at ",e.jsx("span",{className:"font-mono",children:i})]})]}),e.jsxs("section",{className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg",children:"Export transcripts to OTEL"}),e.jsx("div",{className:"text-fg-faint text-xs",children:"Toggle off to disable all span emission immediately."})]}),e.jsx(L,{checked:n.enabled,onChange:f=>b("enabled",f),label:n.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:n.endpoint,onChange:f=>b("endpoint",f.target.value),placeholder:"http://localhost:4318/v1/traces",className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),e.jsxs("label",{className:"block space-y-1",children:[e.jsxs("span",{className:"text-fg-dim text-xs",children:["Headers (newline-separated ",e.jsx("span",{className:"font-mono",children:"Key: Value"}),")"]}),e.jsx("textarea",{value:n.headers,onChange:f=>b("headers",f.target.value),placeholder:"x-honeycomb-team: YOUR_API_KEY",rows:3,className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),e.jsxs("label",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"Service name"}),e.jsx("input",{type:"text",value:n.serviceName,onChange:f=>b("serviceName",f.target.value),placeholder:"session-manager",className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),e.jsxs("div",{className:"flex items-start justify-between gap-3 pt-1",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg",children:"Include content (PII)"}),e.jsxs("div",{className:"text-fg-faint text-xs leading-relaxed",children:["Adds tool inputs, plan text, and agent prompts to span attributes. Off by default — matches upstream Claude Code's ",e.jsx("span",{className:"font-mono",children:"OTEL_LOG_USER_PROMPTS"})," opt-in."]})]}),e.jsx(L,{checked:n.includeContent,onChange:f=>b("includeContent",f),label:n.includeContent?"on":"off"})]})]}),t&&e.jsxs("section",{className:"border border-line rounded p-3 text-xs space-y-1",children:[e.jsx("div",{className:"text-fg-dim",children:"Runtime status"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"enabled:"})," ",e.jsx("span",{className:t.enabled?"text-accent":"text-fg-dim",children:String(t.enabled)})]}),t.error&&e.jsxs("div",{className:"text-red-400 break-words",children:[e.jsx("span",{className:"text-fg-faint",children:"error:"})," ",t.error]}),!t.error&&t.enabled&&e.jsx("div",{className:"text-fg-faint",children:"spans batched and exported in the background. Verify by enabling and pointing at a local Jaeger."})]}),e.jsxs("footer",{className:"flex items-center gap-3 pt-2 border-t border-line",children:[e.jsx("button",{onClick:C,disabled:!u||m,className:"px-3 py-1 text-xs rounded bg-accent text-bg disabled:opacity-50 disabled:cursor-not-allowed",children:m?"saving…":"Save"}),e.jsx("button",{onClick:E,disabled:!u||m,className:"px-3 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg disabled:opacity-50 disabled:cursor-not-allowed",children:"Revert"}),x&&e.jsx("span",{className:"text-red-400 text-xs",children:x}),!x&&g&&!u&&e.jsx("span",{className:"text-fg-faint text-xs",children:"saved"})]})]})}function _e(){const[s,a]=d.useState(null),[t,l]=d.useState(null),[n,r]=d.useState("Copy"),[i,p]=d.useState(!1),[m,v]=d.useState(null),[x,w]=d.useState(null),[g,y]=d.useState(null),[u,b]=d.useState(!1),C=()=>{window.api.telemetry.status().then(l).catch(h=>{console.warn("[product-telemetry] status reload failed:",h==null?void 0:h.message)})};if(d.useEffect(()=>{let h=!1;return Promise.all([window.api.telemetry.getConfig(),window.api.telemetry.status()]).then(([c,T])=>{h||(a(c),l(T))}).catch(c=>{console.warn("[product-telemetry] load failed:",c==null?void 0:c.message)}),()=>{h=!0}},[]),!s||!t)return e.jsx(R,{title:"loading…"});const E=async h=>{w(null);try{const c=await window.api.telemetry.setConfig(h);a(c.config),l(c.status)}catch(c){w(c instanceof Error?c.message:String(c))}},f=h=>{E({...s,enabled:h})},S=h=>{E({...s,enabled:h.turnOff?!1:s.enabled,noticeAckedAt:new Date().toISOString()})},k=async()=>{try{await navigator.clipboard.writeText(s.installId),r("Copied"),setTimeout(()=>r("Copy"),1500)}catch{}},o=async()=>{p(!0),v(null);try{const h=await window.api.telemetry.flushNow();v(`sent ${h.sent.length}, failed ${h.failed.length}`),C()}catch(h){v(h instanceof Error?h.message:String(h))}finally{p(!1)}},j=async()=>{if(u){b(!1);return}try{const h=await window.api.telemetry.recentRecords();y(h),b(!0)}catch(h){console.warn("[product-telemetry] recentRecords failed:",h instanceof Error?h.message:h)}},N=s.lastDailyFlushAt?new Date(s.lastDailyFlushAt).getTime()+De:null;return e.jsxs("div",{className:"space-y-5","data-testid":"product-telemetry-section",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-fg text-base font-medium",children:"Product telemetry (bilko.run)"}),e.jsxs("p",{className:"text-fg-dim text-xs leading-relaxed",children:["Anonymous, strictly non-identifying usage/error reporting that helps improve this app. On by default; switchable off in one click. See"," ",e.jsx("span",{className:"font-mono",children:"session-manager-operations/architecture/telemetry.md"})," for the full data model."]})]}),!s.noticeAckedAt&&e.jsxs("section",{"data-testid":"telemetry-first-run-notice",className:"border border-accent rounded p-3 space-y-2 text-xs",children:[e.jsx("div",{className:"text-fg font-medium",children:"This app sends anonymous product telemetry"}),e.jsx("p",{className:"text-fg-dim leading-relaxed",children:"Collected: a coarse machine profile (OS/arch/app version, no hardware id), error and warning counts, and session counts — sent on start-up, after an update, and once a day."}),e.jsx("p",{className:"text-fg-dim leading-relaxed",children:"Never collected: prompts, transcripts, file paths, project names, email, or username."}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx("button",{onClick:()=>S({turnOff:!1}),className:"px-3 py-1 rounded bg-accent text-bg",children:"OK"}),e.jsx("button",{onClick:()=>S({turnOff:!0}),className:"px-3 py-1 rounded border border-line text-fg-dim hover:text-fg",children:"Turn off"})]})]}),e.jsxs("section",{className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg",children:"Send anonymous product telemetry"}),e.jsx("div",{className:"text-fg-faint text-xs",children:"Sent on start-up, after an update, and once a day. Strictly anonymous — an install id only, never an email, name, or other identifier."})]}),e.jsx(L,{checked:s.enabled,onChange:f,label:s.enabled?"on":"off"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-fg-dim text-xs",children:"Anonymous install id"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",readOnly:!0,value:s.installId,"aria-label":"Anonymous install identifier",className:"flex-1 bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"}),e.jsx("button",{onClick:k,className:"px-2 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg",children:n})]})]}),e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("div",{className:"text-fg-faint",children:"Endpoint"}),e.jsx("div",{className:"font-mono text-fg-dim break-all",children:s.endpoint})]}),e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("div",{className:"text-fg-faint",children:"Send cadence"}),e.jsx("div",{className:"text-fg-dim",children:"on start-up, after an update, and once a day"})]}),x&&e.jsx("div",{className:"text-red-400 text-xs",children:x})]}),e.jsxs("section",{className:"border border-line rounded p-3 text-xs space-y-1.5",children:[e.jsx("div",{className:"text-fg-dim",children:"Runtime status"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"last send:"})," ",J(t.lastFlushAt)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"next daily send due:"})," ",U(N?new Date(N).toISOString():null)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"queued records:"})," ",t.pendingCount]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"de-duplicated:"})," ",t.dedupedAppends]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"evicted:"})," ",t.evictedCount]}),t.backlog&&e.jsxs("div",{className:"text-fg-faint",children:["last backlog drain (",t.backlog.reason,", ",U(t.backlog.ranAt),"):"," ",t.backlog.linesEnqueued," enqueued, ",t.backlog.linesConfirmed," confirmed,"," ",t.backlog.watermarksRewound," watermarks rewound"]}),t.lastError&&e.jsxs("div",{className:"text-red-400 break-words",children:[e.jsx("span",{className:"text-fg-faint",children:"last error:"})," ",t.lastError.message," ","(",J(t.lastError.at),")"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:o,disabled:i,className:"px-3 py-1 text-xs rounded bg-accent text-bg disabled:opacity-50 disabled:cursor-not-allowed",children:i?"sending…":"Send now"}),m&&e.jsx("span",{className:"text-fg-faint text-xs",children:m})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("button",{onClick:j,className:"px-3 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg",children:u?"Hide last records":"Inspect last records sent"}),u&&e.jsx("pre",{"data-testid":"telemetry-inspector-json",className:"bg-bg border border-line rounded p-2 text-[11px] font-mono overflow-auto max-h-96 whitespace-pre-wrap",children:JSON.stringify(g??[],null,2)})]})]})}function Fe(){const{model:s,setModel:a}=X();return e.jsxs("div",{className:"p-4 max-w-3xl space-y-5 text-sm",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-fg text-base font-medium",children:"Session Manager preferences"}),e.jsx("p",{className:"text-fg-dim text-xs leading-relaxed",children:"Native app preferences, stored locally — not part of Claude Code's own settings."})]}),e.jsx("section",{className:"border border-line rounded p-3 space-y-3",children:e.jsxs("label",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"Default model for raw sessions"}),e.jsx("select",{value:s,onChange:t=>a(t.target.value),className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs",children:ee.map(t=>e.jsx("option",{value:t,children:t.charAt(0).toUpperCase()+t.slice(1)},t))}),e.jsx("span",{className:"text-fg-faint text-[11px]",children:"Used when opening a raw interactive session without an explicit per-launch override."})]})})]})}function $e({cwd:s}){const[a,t]=d.useState(!1),[l,n]=d.useState(!1),[r,i]=d.useState(!1),[p,m]=d.useState(!1);d.useEffect(()=>{var y,u;let g=!1;return t(!1),Promise.resolve((u=(y=window.api.promptSessions)==null?void 0:y.getWorktreeDisabled)==null?void 0:u.call(y,{cwd:s})).then(b=>{g||(n((b==null?void 0:b.disabled)??!1),i((b==null?void 0:b.disabled)??!1),t(!0))},()=>{g||t(!0)}),()=>{g=!0}},[s]);const v=a&&r!==l,x=()=>{var g,y;m(!0),Promise.resolve((y=(g=window.api.promptSessions)==null?void 0:g.setWorktreeDisabled)==null?void 0:y.call(g,{cwd:s,disabled:r})).then(u=>{n((u==null?void 0:u.disabled)??r),i((u==null?void 0:u.disabled)??r)}).catch(u=>te.error(u instanceof Error?u.message:String(u))).finally(()=>m(!1))},w=()=>i(l);return e.jsxs("div",{"data-testid":"settings-epic-isolation",className:"border-b border-line bg-bg-elev px-3 py-2.5 text-[11.5px] leading-snug",children:[e.jsxs("label",{className:"flex items-start gap-2",children:[e.jsx("input",{type:"checkbox",checked:r,disabled:!a||p,onChange:g=>i(g.target.checked),"data-testid":"settings-epic-isolation-checkbox",className:"mt-0.5"}),e.jsxs("span",{children:[e.jsx("span",{className:"font-semibold text-fg",children:"Disable Epic worktree isolation for this project"}),e.jsxs("span",{className:"block text-fg-dim",children:["Off by default — each active Epic runs in its own isolated ",e.jsx("code",{children:"git worktree"})," (branch"," ",e.jsx("code",{children:"sm-epic/<id>"}),"), merged back to main at an explicit checkpoint. Turning this on makes every new Epic in this project run directly in the shared working tree instead, same as before this feature existed."]})]})]}),v&&e.jsx(K,{dirty:v,busy:p,onSave:x,onRevert:w})]})}const B={user:{title:"Global settings",body:"This is the real ~/.claude/settings.json on disk — the same file the claude CLI reads on every session it starts. Edits apply machine-wide, to every project and every session."},project:{title:"Project settings",body:"This is the real <project>/.claude/settings.json on disk, checked into git. Edits apply to every current and future session in this project, for anyone who clones it."},local:{title:"Local settings",body:"This is the real <project>/.claude/settings.local.json on disk, gitignored. Edits apply to every current and future session in this project, on this machine only."}};function Ge(){const s=se(),a=$(c=>c.tabs),t=$(c=>c.activeTabId),l=a.find(c=>c.id===t)??null,n=(l==null?void 0:l.cwd)??null,r=ae(c=>c.navFace),i=d.useRef(!1),p=d.useRef(r),[m,v]=d.useState(()=>r==="project"&&n?"project":"user"),[x,w]=d.useState("effective");d.useEffect(()=>{if(p.current!==r){if(p.current=r,i.current){i.current=!1;return}v(r==="project"&&n?"project":"user")}},[r,n]),d.useEffect(()=>{r==="project"&&(x==="telemetry"||x==="app")&&w("effective")},[r,x]);const g=c=>{i.current=!0,v(c)},y=oe(G,s,n),u=y[m]??null,b=I(c=>c.files),C=I(c=>c.setDraft),E=I(c=>c.saveJson),f=I(c=>c.revert),[S,k]=d.useState(null),o=d.useMemo(()=>ce(de(b,y)),[b,y]),j=(c,T,A)=>{var F;const D=y[A??m];if(!D)return;k(null);const _=((F=b[D])==null?void 0:F.draftRaw)??"";let M={};if(_.trim())try{M=JSON.parse(_)}catch{M={}}const Z=xe(M,c,T);C(D,JSON.stringify(Z,null,2)+`
|
|
3
|
+
`)};if(!s)return e.jsx(R,{title:"loading…"});const N=u?b[u]:null,h=c=>c!=="user"&&!n;return e.jsx(le,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(re,{options:[{key:"effective",label:"Guided"},{key:"tree",label:"Tree"},{key:"raw",label:"Raw"},...r==="home"?[{key:"telemetry",label:"Telemetry"},{key:"app",label:"Session Manager"}]:[]],active:x,onChange:w}),x!=="telemetry"&&x!=="app"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx(ie,{scopes:G.scopes,active:m,onChange:g,annotate:c=>{if(h(c))return{exists:!1};const T=y[c];if(!T)return null;const A=b[T];return{exists:(A==null?void 0:A.exists)??!1,dirty:(A==null?void 0:A.dirty)??!1}}}),e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:x==="effective"?`overrides → ${u??"—"}`:u??"—"})]}),e.jsx("div",{className:"flex-1"}),e.jsx("a",{href:"https://code.claude.com/docs/en/settings",target:"_blank",rel:"noreferrer",className:"text-fg-faint hover:text-fg-dim underline-offset-2 hover:underline",children:"schema reference ↗"})]}),footer:x!=="telemetry"&&x!=="app"&&u&&N?e.jsx(K,{dirty:N.dirty,busy:N.busy,parseError:S||N.parseError,lastSavedAt:N.lastSavedAt,leading:N.exists?null:e.jsx("span",{children:"file will be created on save"}),onSave:async()=>{k(null);const c=await E(u);c.ok||k(c.error??"save failed")},onRevert:()=>{k(null),f(u)}}):null,children:x==="telemetry"?e.jsx(Me,{}):x==="app"?e.jsx(Fe,{}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-testid":"settings-scope-note",className:"sticky top-0 z-10 border-b border-line bg-bg-elev px-3 py-2 text-[11.5px] leading-snug",children:[e.jsx("span",{className:"font-semibold text-fg",children:B[m].title}),e.jsx("span",{className:"mx-1.5 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-dim",children:B[m].body}),u&&e.jsx("span",{className:"ml-1.5 font-mono text-fg-faint",children:u})]}),m==="project"&&n&&e.jsx($e,{cwd:n}),h(m)?e.jsx(R,{title:"no active project",hint:"open a tab in a project directory to edit project or local settings"}):x==="effective"?e.jsx(je,{node:o,targetScope:m,onOverride:j,schema:H()}):x==="tree"?e.jsx(ue,{node:o,targetScope:m,onOverride:j,schema:H()}):u&&N?e.jsx(ne,{path:u,value:N.draftRaw,onChange:c=>{k(null),C(u,c)}}):e.jsx(R,{title:"resolving…"})]})})}const ze=d.memo(Ge);export{B as SETTINGS_SCOPE_NOTES,ze as Settings};
|