claude-code-session-manager 0.76.0 → 0.78.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.
Files changed (123) hide show
  1. package/dist/assets/{AgentLibrary-CBx9l4zN.js → AgentLibrary-13pfo8uY.js} +2 -2
  2. package/dist/assets/{DataModel-Bf0EIE_t.js → DataModel-SUyQbFlg.js} +1 -1
  3. package/dist/assets/{History-CpdtWhC8.js → History-2GJMS703.js} +2 -2
  4. package/dist/assets/{Hooks-DyUbMDmg.js → Hooks-DM2nS3RT.js} +2 -2
  5. package/dist/assets/{HostBilko-By-wIpry.js → HostBilko-BLeC-lpp.js} +1 -1
  6. package/dist/assets/{Library-CQmo4QVC.js → Library-BaRkU9m0.js} +1 -1
  7. package/dist/assets/{ListDetail-BQMd6NOm.js → ListDetail-D5scjSKq.js} +1 -1
  8. package/dist/assets/{MarkdownEditor-DEp43FXX.js → MarkdownEditor-B1lgAo9T.js} +1 -1
  9. package/dist/assets/{McpServers-CLarzwqA.js → McpServers-BzyThQSM.js} +1 -1
  10. package/dist/assets/{Memory-B0sCdIy1.js → Memory-7UdaOTtl.js} +6 -6
  11. package/dist/assets/{Panel-BhWPVOCD.js → Panel-JbTMaOPq.js} +1 -1
  12. package/dist/assets/{Permissions-Ddlq8T_O.js → Permissions-UBam0bJG.js} +2 -2
  13. package/dist/assets/{Plugins-D2oA_2Jl.js → Plugins-B3gUDkeb.js} +2 -2
  14. package/dist/assets/{ProvenanceBadge-DgAgavUM.js → ProvenanceBadge-CeHOub7m.js} +1 -1
  15. package/dist/assets/SaveBar-BcvQEq6h.js +1 -0
  16. package/dist/assets/Scheduler-Dc5qiP24.js +14 -0
  17. package/dist/assets/{ScopeSwitcher-C_zWEtIl.js → ScopeSwitcher-BvGQmw4Y.js} +1 -1
  18. package/dist/assets/{Settings-2Vx3X5SI.js → Settings-C2dEFb-v.js} +1 -1
  19. package/dist/assets/{SkillReferenceGraph-BDEUjlTQ.js → SkillReferenceGraph-CIwlosBc.js} +1 -1
  20. package/dist/assets/{Skills-Cmrz_LeN.js → Skills-C0GzzVrQ.js} +2 -2
  21. package/dist/assets/{SystemPrompt-DVA1eYDP.js → SystemPrompt-mtGPK8zo.js} +1 -1
  22. package/dist/assets/TagLibrary-DX54-mpd.js +1 -0
  23. package/dist/assets/{TiptapBody-DmPc3amD.js → TiptapBody-yADC2RWE.js} +1 -1
  24. package/dist/assets/{Toggle-zfd5LJkK.js → Toggle-CRxaCYLI.js} +1 -1
  25. package/dist/assets/{index-DIjnPkRN.css → index-CYhdtisq.css} +1 -1
  26. package/dist/assets/{index-B_4PNh9T.js → index-D6ymGESc.js} +469 -469
  27. package/dist/assets/{settingsSchema-B9es6fdA.js → settingsSchema-TtMvT5Sx.js} +1 -1
  28. package/dist/index.html +2 -2
  29. package/package.json +8 -2
  30. package/plugins/session-manager-dev/skills/develop/standards.md +1 -1
  31. package/scripts/project-pages-logic/dist/logic.cjs +4709 -0
  32. package/scripts/render-project-pages/dist/renderer.cjs +18900 -0
  33. package/scripts/render-project-pages.cjs +70 -0
  34. package/scripts/scheduler-mcp-server.cjs +115 -1
  35. package/scripts/validate-project-pages-summary.cjs +62 -0
  36. package/src/main/__tests__/agentModelResolve.test.cjs +66 -0
  37. package/src/main/__tests__/health-delegation-chain.test.cjs +2 -1
  38. package/src/main/__tests__/prdAgentType.test.cjs +103 -0
  39. package/src/main/__tests__/prdCreate.test.cjs +138 -0
  40. package/src/main/__tests__/prdFrontmatterAgentType.test.cjs +117 -0
  41. package/src/main/__tests__/prdFrontmatterQuietMachine.test.cjs +108 -0
  42. package/src/main/__tests__/projectHomeAdminRoutes.test.cjs +485 -0
  43. package/src/main/__tests__/projectPages.test.cjs +73 -1
  44. package/src/main/__tests__/rcaReport.test.cjs +54 -0
  45. package/src/main/__tests__/runVerify.test.cjs +94 -0
  46. package/src/main/__tests__/scheduler-autofix-select.test.cjs +43 -0
  47. package/src/main/__tests__/scheduler-bash-timeout-env.test.cjs +103 -0
  48. package/src/main/__tests__/scheduler-effective-concurrency.test.cjs +10 -0
  49. package/src/main/__tests__/scheduler-foreign-wip-manifest.test.cjs +78 -0
  50. package/src/main/__tests__/scheduler-inplace-salvage.test.cjs +242 -0
  51. package/src/main/__tests__/scheduler-investigation-prompt.test.cjs +31 -0
  52. package/src/main/__tests__/scheduler-launch-failure.test.cjs +201 -0
  53. package/src/main/__tests__/scheduler-leftover-fields.test.cjs +52 -0
  54. package/src/main/__tests__/scheduler-looks-done.test.cjs +241 -0
  55. package/src/main/__tests__/scheduler-prd-persona-spawn.test.cjs +135 -0
  56. package/src/main/__tests__/scheduler-quiet-machine-lease.test.cjs +222 -0
  57. package/src/main/__tests__/scheduler-reap-dead-running-jobs.test.cjs +147 -0
  58. package/src/main/__tests__/scheduler-shared-tree-guard.test.cjs +212 -0
  59. package/src/main/__tests__/scheduler-worktree-cap-defer.test.cjs +194 -0
  60. package/src/main/__tests__/seedAgentPersonas.test.cjs +75 -14
  61. package/src/main/config.cjs +4 -1
  62. package/src/main/index.cjs +16 -4
  63. package/src/main/ipcSchemas.cjs +53 -0
  64. package/src/main/lib/__tests__/childWithLog.test.cjs +78 -0
  65. package/src/main/lib/__tests__/delegationReadiness.test.cjs +197 -2
  66. package/src/main/lib/__tests__/epicWorktreeMint.test.cjs +4 -2
  67. package/src/main/lib/__tests__/fixChainDepth.test.cjs +40 -0
  68. package/src/main/lib/__tests__/gitWorktree.test.cjs +277 -4
  69. package/src/main/lib/__tests__/gitWorktreeSalvageDelta.test.cjs +153 -0
  70. package/src/main/lib/__tests__/jobWorktree.test.cjs +5 -3
  71. package/src/main/lib/__tests__/landedSinceRun.test.cjs +73 -0
  72. package/src/main/lib/__tests__/launchFailure.test.cjs +220 -0
  73. package/src/main/lib/__tests__/mcpToolCatalog.test.cjs +1 -0
  74. package/src/main/lib/__tests__/opsOwnership.test.cjs +7 -0
  75. package/src/main/lib/__tests__/prdDeclaredPaths.test.cjs +82 -0
  76. package/src/main/lib/__tests__/queueHealth.test.cjs +58 -0
  77. package/src/main/lib/__tests__/quietMachineLease.test.cjs +39 -0
  78. package/src/main/lib/__tests__/reaperHelpers.test.cjs +22 -1
  79. package/src/main/lib/__tests__/schedulerBatchLaunchHold.test.cjs +125 -0
  80. package/src/main/lib/__tests__/schedulerBatchQuietMachine.test.cjs +109 -0
  81. package/src/main/lib/__tests__/schedulerMcpServerHeadlessRefusal.test.cjs +71 -0
  82. package/src/main/lib/__tests__/schedulerMcpServerProjectHome.test.cjs +350 -0
  83. package/src/main/lib/agentModelResolve.cjs +58 -0
  84. package/src/main/lib/childWithLog.cjs +40 -5
  85. package/src/main/lib/claudeBin.cjs +54 -1
  86. package/src/main/lib/definitionOfDone.cjs +3 -2
  87. package/src/main/lib/delegationReadiness.cjs +115 -9
  88. package/src/main/lib/epicWorktreeMint.cjs +5 -2
  89. package/src/main/lib/fixChainDepth.cjs +45 -0
  90. package/src/main/lib/gitWorktree.cjs +464 -19
  91. package/src/main/lib/jobWorktree.cjs +1 -0
  92. package/src/main/lib/landedSinceRun.cjs +55 -0
  93. package/src/main/lib/launchFailure.cjs +357 -0
  94. package/src/main/lib/mcpToolCatalog.cjs +87 -2
  95. package/src/main/lib/opsOwnership.cjs +12 -0
  96. package/src/main/lib/prdAgentType.cjs +84 -0
  97. package/src/main/lib/prdCreate.cjs +57 -1
  98. package/src/main/lib/prdDeclaredPaths.cjs +70 -0
  99. package/src/main/lib/prdFrontmatter.cjs +17 -3
  100. package/src/main/lib/projectHomeAdminRoutes.cjs +402 -0
  101. package/src/main/lib/projectPageSummarySchema.cjs +181 -0
  102. package/src/main/lib/queueHealth.cjs +38 -0
  103. package/src/main/lib/queueStore.cjs +9 -2
  104. package/src/main/lib/quietMachineLease.cjs +48 -0
  105. package/src/main/lib/rcaReport.cjs +53 -3
  106. package/src/main/lib/reaperHelpers.cjs +18 -1
  107. package/src/main/lib/scheduleJobSchema.cjs +31 -0
  108. package/src/main/lib/scheduleJobTransitions.cjs +6 -2
  109. package/src/main/lib/schedulerBatch.cjs +133 -29
  110. package/src/main/lib/schedulerConfig.cjs +19 -0
  111. package/src/main/projectPages.cjs +160 -2
  112. package/src/main/runVerify.cjs +50 -9
  113. package/src/main/scheduler/prdParser.cjs +18 -1
  114. package/src/main/scheduler.cjs +1371 -97
  115. package/src/main/seedAgentPersonas.cjs +62 -21
  116. package/src/main/templates/project-pages-catalog.json +741 -0
  117. package/src/main/templates/project-pages-pipeline.md +417 -0
  118. package/src/preload/api.d.ts +126 -6
  119. package/src/preload/index.cjs +8 -0
  120. package/src/seed/agents/project-home-builder.md +59 -0
  121. package/dist/assets/SaveBar-Qvc4Ek-H.js +0 -1
  122. package/dist/assets/Scheduler-BmYJvNzK.js +0 -14
  123. package/dist/assets/TagLibrary-DYJGAKZu.js +0 -1
@@ -0,0 +1,59 @@
1
+ ---
2
+ name: project-home-builder
3
+ description: Generates a project's 5 static Project Page HTML files (Home / Marketing Landing / Feature Description / Architecture Overview / Brief) by following the session-manager app's own MCP contract for the pipeline — portable to any machine with the app installed, no source-repo paths required.
4
+ tools: Read, Grep, Glob, Bash, Write, Edit
5
+ title: Project Pages — Builder
6
+ ---
7
+
8
+ You are the project-home-builder. Your whole job is to generate a project's Project Home pages by
9
+ following the exact protocol the session-manager app hands you over MCP — never by re-deriving the
10
+ pipeline from a repo you may not have, and never by inventing content.
11
+
12
+ ## Ground on the live contract, every run
13
+
14
+ 1. Call `project_home_get_contract` FIRST, before composing or reading anything else. It returns
15
+ everything you need: the operating protocol, the `ProjectPageSummary`/`ProjectPagePicks` JSON
16
+ schemas, the full component catalog for every lens (which slots exist, which variants are
17
+ available per slot, and each variant's own selection notes), the exact output paths, and the
18
+ full pipeline spec text.
19
+ 2. Follow the protocol the contract response describes. It is the single source of truth for this
20
+ run — do not fall back to a remembered or assumed version of the pipeline shape.
21
+ 3. If `project_home_get_contract` is unavailable, errors, or the MCP tools it depends on
22
+ (`project_home_validate_summary`, `project_home_render`, `project_home_status`) are not present
23
+ in this session's toolset: **report that plainly and stop.** Do not attempt to build, script, or
24
+ hand-roll any part of the pipeline yourself, and do not treat the missing contract as a coding
25
+ task for this Epic. The pipeline is owned by the session-manager app, not by the target project.
26
+
27
+ ## Hard rules
28
+
29
+ - **Never fabricate.** Every field of the summary you author must trace to something concrete about
30
+ the real project: an Epic goal, a source file/dir, a documented convention, a git log entry, or an
31
+ existing project brief. An omitted field beats an invented one, every time — no invented stats, no
32
+ invented testimonials/quotes, no invented screenshots.
33
+ - **Author the summary from real evidence.** Read the target project itself (its repo tree, its git
34
+ history, its own docs/brief, its active Epics) to build the `ProjectPageSummary` the contract's
35
+ schema describes — the contract gives you the shape, not the content.
36
+ - **Validate before you render.** Call `project_home_validate_summary` with your composed summary
37
+ and fix every returned `{field, message}` error, re-validating until it reports `valid: true`.
38
+ Don't skip straight to rendering an unvalidated summary.
39
+ - **Choose picks from the returned catalog only.** For every lens/slot the contract's catalog lists,
40
+ pick the one variant that genuinely fits this project's summary content, using the catalog's own
41
+ per-variant notes — never a variant name you assumed instead of one the catalog actually offered.
42
+ - **Respect existing picks on a regenerate.** If the project already has picks for a slot, keep them
43
+ unless this run was explicitly asked to start over — same spirit as any other pinned-content
44
+ regenerate.
45
+ - **Cost-gated, manual only.** This is a real-cost pass. Run it once per explicit "Generate" /
46
+ "Regenerate" request — never automatically, never in a loop.
47
+
48
+ ## Protocol
49
+
50
+ 1. `project_home_get_contract` — read its protocol, schemas, and catalog before anything else.
51
+ 2. Gather real evidence about the target project and compose a `ProjectPageSummary` matching the
52
+ contract's schema.
53
+ 3. `project_home_validate_summary` with that summary — fix and repeat until `valid: true`.
54
+ 4. Choose one variant per lens/slot from the contract's catalog, forming a `ProjectPagePicks` object
55
+ in the shape the contract specifies.
56
+ 5. `project_home_render` with the validated summary and the picks — this is the only write path;
57
+ it re-validates server-side and writes nothing on schema failure.
58
+ 6. `project_home_status` — confirm the expected files now exist with a fresh `generatedAt`, and
59
+ report what was generated.
@@ -1 +0,0 @@
1
- import{a4 as e,$ as x}from"./index-B_4PNh9T.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 +0,0 @@
1
- import{a4 as e,az as we,ad as l,aw as Te,a as ue,Q as V,an as L,_ as B,a0 as re,W as U,ac as be,ax as le,ah as ve,ai as je,X as ke,aC as ce,v as Le,a8 as Y,o as Me,k as Ne,q as ye,D as q,d as R,t as Oe,T as ze,a9 as Pe,ar as Ce,j as ae,p as Ae,i as Ue,al as Ve,w as Qe,n as Fe,at as We,aq as se,u as Ye,C as Ke,aA as Xe,ae as Ze,aD as et,aB as De,L as tt,l as he}from"./index-B_4PNh9T.js";import{l as st}from"./listSkills-QORduPIk.js";import{T as nt}from"./Toggle-zfd5LJkK.js";import"./monaco-editor-BW5C4Iv1.js";function at({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 i=s===a;return e.jsx("button",{type:"button",onClick:()=>n(a),className:`px-[18px] py-[7px] rounded-lg text-[13.5px] transition-colors ${i?"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 rt=5e3;let oe=null,ne=null;async function $e(t){const s=Date.now();return!(t!=null&&t.fresh)&&oe&&s-oe.at<rt?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 _e({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 i=d.value===s;return e.jsxs("button",{type:"button",onClick:()=>n(d.value),className:`rounded-full ${a} text-[12.5px] border transition-colors ${i?"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 lt=5,it=1440*60*1e3,He="sm.scheduler.hiddenCompletedSlugs",de="sm.scheduler.focusedJobIndex",qe="sm.scheduler.queueFilter";function ot(t,s=60){const n=t.trim();return n.length<=s?n:`${n.slice(0,s-1)}…`}const dt=["all","running","investigating","pending","completed","skipped","needs_review","failed","quarantined"];function ct(){try{const t=localStorage.getItem(qe);if(!t)return{text:"",status:"all"};const s=JSON.parse(t);return{text:"",status:dt.includes(s.status)?s.status:"all"}}catch{return{text:"",status:"all"}}}function ut(t){try{localStorage.setItem(qe,JSON.stringify({status:t.status}))}catch{}}function xt(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 pt(){try{const t=localStorage.getItem(He);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(He,JSON.stringify([...t]))}catch{}}function mt({scopeCwd:t=null,navigate:s}){const n=we(p=>p.snapshot),a=l.useMemo(()=>!n||!t?n:{...n,jobs:n.jobs.filter(p=>p.cwd===t)},[n,t]),[d,i]=l.useState(null),[c,x]=l.useState(!1),[o,u]=l.useState(()=>Date.now()),[b,w]=l.useState(()=>pt()),[h,v]=l.useState(!1),[N,C]=l.useState(()=>ct()),[f,j]=l.useState(!1),[D,k]=l.useState("queue"),g=l.useRef(null),[A,P]=l.useState(()=>{try{return Number(localStorage.getItem(de))||0}catch{return 0}}),[J,xe]=l.useState(""),G=Te();l.useEffect(()=>(window.api.schedule.health().then(i).catch(()=>{}),window.api.schedule.onState(()=>{window.api.schedule.health().then(i).catch(()=>{})})),[]),l.useEffect(()=>{if(!G)return;u(Date.now());const p=setInterval(()=>u(Date.now()),1e3);return()=>clearInterval(p)},[G]);const M=l.useMemo(()=>{if(!a)return 15e4;const p=[];for(const y of a.jobs)if(y.status==="completed"&&y.startedAt&&y.finishedAt){const T=Date.parse(y.finishedAt)-Date.parse(y.startedAt);T>0&&p.push(T)}return p.length===0?15e4:p.reduce((y,T)=>y+T,0)/p.length},[a]),K=l.useRef(new Map);l.useEffect(()=>{if(!a)return;const p=[];for(const y of a.jobs){const T=K.current.get(y.slug);T&&T!==y.status&&p.push(`${y.title}: ${T} → ${y.status}`),K.current.set(y.slug,y.status)}p.length>0&&xe(p.join("; "))},[a]);const X=l.useMemo(()=>{var y;const p=new Map;for(const T of((y=a==null?void 0:a.lastTick)==null?void 0:y.holds)??[])p.set(T.slug,T);return p},[a==null?void 0:a.lastTick]),Z=l.useCallback(p=>{var T,ie,Se;const y=(T=g.current)==null?void 0:T.querySelectorAll("[data-job-row]");if(!(!y||y.length===0)){if(p.key==="ArrowDown"){p.preventDefault();const z=Math.min(A+1,y.length-1);P(z);try{localStorage.setItem(de,String(z))}catch{}(ie=y[z])==null||ie.focus()}else if(p.key==="ArrowUp"){p.preventDefault();const z=Math.max(A-1,0);P(z);try{localStorage.setItem(de,String(z))}catch{}(Se=y[z])==null||Se.focus()}}},[A]),pe=l.useCallback(p=>{P(p);try{localStorage.setItem(de,String(p))}catch{}},[]);if(!a)return null;if(D==="supervisor")return e.jsx($t,{supervisorConfig:a.config.supervisor,onSetConfig:p=>window.api.schedule.setConfig({supervisor:p}),onBack:()=>k("queue")});const{config:ee,jobs:O,paused:me,lastRunAt:H,nextReset:Q,effectiveConcurrency:$}=a;if(O.length===0)return e.jsx(gt,{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"),r=bt({snap:a,now:o,avgDurationMs:M,runningJobs:te}),m=xt(O,N),S=wt(m),{inline:I,collapsedCount:E}=vt(m,b,o,h),_=Pt(I,O,S,M,r.kind,o),W=()=>{const p=new Set(b);for(const y of O)(y.status==="completed"||y.status==="failed")&&p.add(y.slug);w(p),Re(p)},Be=async()=>{const p=O.filter(ie=>ie.status!=="running").length;if(p===0)return;const y=`Archive ${p} non-running PRD${p===1?"":"s"} and remove from the queue?
2
-
3
- Files are moved to prds-archived/<timestamp>/ and can be restored from disk. Running jobs are kept.`;if(!window.confirm(y))return;const T=await window.api.schedule.clearQueue();T.ok||L.error(`Clear queue failed: ${T.error??"unknown error"}`)},Je=()=>{w(new Set),Re(new Set),v(!1)},Ge=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:J}),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 ${jt(r.kind)}`,title:r.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 ${Nt(r.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:St(kt(r.line1,a.utilization))}),r.line2&&e.jsx("div",{className:"text-[12px] text-fg-faint font-mono mt-0.5 truncate",children:r.line2})]})]}),e.jsxs("span",{className:"ml-auto font-mono text-[11.5px] text-fg-faint whitespace-nowrap",children:[($==null?void 0:$.cap)??5," slot",(($==null?void 0:$.cap)??5)!==1?"s":""," · last batch ",V(H?Date.parse(H):null,o)]}),r.action&&e.jsx("button",{type:"button",onClick:r.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:r.action.title,children:r.action.label})]}),d&&d.consecutiveFailures>5&&d.lastFailureKind==="meter_rate_limited"&&!me&&!f&&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"," ",V(d.lastPollAt,o),". Firing on a conservative estimate until it recovers."]}),e.jsx("button",{type:"button",onClick:()=>j(!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"}),($==null?void 0:$.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:($==null?void 0:$.cap)??5,disabled:($==null?void 0:$.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:($==null?void 0:$.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=($==null?void 0:$.cap)??5,y=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"]}),y>0&&e.jsxs("span",{className:"text-fg-faint",children:["+",y," ready in this group"]})]})})(),O.length>0&&e.jsx(Dt,{filter:N,onChange:p=>{C(p),ut(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"]})]}),Ge&&e.jsx("button",{type:"button",onClick:W,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:Be,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:g,role:"list","aria-label":"Job queue",onKeyDown:Z,children:I.map((p,y)=>e.jsx(At,{job:p,eta:_.get(p.slug)??null,elapsedMs:p.status==="running"&&p.startedAt?o-Date.parse(p.startedAt):null,avgDurationMs:M,listIndex:y,hold:X.get(p.slug),onFocused:pe},p.slug))}),E>0&&e.jsxs("button",{type:"button",onClick:()=>v(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(),Je()},children:"un-hide"})]})]}),e.jsx(Et,{snap:a,health:d,now:o,open:c,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 ",B(Date.parse(Q)-o)]}),H&&e.jsxs("span",{className:"ml-2",title:H,children:["last run ",B(o-Date.parse(H))," ago"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>k("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 ht=[{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."}],ft=[{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 gt({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:ht.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:ft.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 bt({snap:t,now:s,avgDurationMs:n,runningJobs:a}){const{config:d,jobs:i,paused:c,nextReset:x,utilization:o,effectiveConcurrency:u}=t;let b=0,w=0;for(const j of i)j.status==="pending"?b++:j.status==="completed"&&w++;const h=a.length,v=b+h,N=(u==null?void 0:u.cap)??5;if(h>0){const j=a.reduce((P,J)=>(P.startedAt??"")<(J.startedAt??"")?P:J),D=j.startedAt?s-Date.parse(j.startedAt):0,k=w+h,g=w+v,A=h>1?` · ${h}/${N} parallel`:"";return{kind:"running",line1:`Running ${k}/${g}${A} · ${re(D)}`,line2:h===1?j.title:a.map(P=>P.title).join(", "),tooltip:a.map(P=>`${P.slug} (g${P.parallelGroup})`).join("; ")}}if(c){const j=c.resumeAt?Date.parse(c.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"}[c.reason]??`Paused — ${c.reason}`,line2:c.reason==="auth"?"Run `claude` in any terminal to refresh credentials, then Resume":j!==null&&j>0?`auto-resume ${U(Date.parse(c.resumeAt))} (in ${B(j)})`:c.resumeAt?"resuming…":"no auto-resume scheduled",tooltip:c.resumeAt??"",action:{label:"Resume",onClick:()=>window.api.schedule.resume(),title:"Clear the pause and resume queue immediately"}}}if(v===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(!x)return{kind:"on-reset",line1:"On-reset · waiting for billing data",line2:null};const j=Date.parse(x)+d.offsetMinutes*6e4,D=j-s;return{kind:"on-reset",line1:`On-reset · ${b} pending`,line2:D>0?`fires ${U(j)} (in ${B(D)})`:"firing now…"}}const f=d.utilizationThreshold??90;if(o==null)return{kind:"auto-soon",line1:`Auto · ${b} pending`,line2:"checking token availability…"};if(o>=f){const j=x?Date.parse(x)-s:null;return{kind:"auto-throttled",line1:`Auto · throttled (util ${o.toFixed(0)}% ≥ ${f}%)`,line2:j&&j>0?`next reset ${U(Date.parse(x))} (in ${B(j)})`:"will fire when usage drops"}}return{kind:"auto-soon",line1:`Auto · ${b} pending · util ${o.toFixed(0)}%`,line2:"fires within 2 min (poll cycle)"}}function wt(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 vt(t,s,n,a){if(a)return{inline:t,collapsedCount:0};const d=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}),i=new Set;let c=0;for(const u of d){if(c>=lt)break;s.has(u.slug)||u.finishedAt&&n-Date.parse(u.finishedAt)>it||(i.add(u.slug),c++)}const x=[];let o=0;for(const u of t){if(u.status==="failed"&&s.has(u.slug)){o++;continue}if(u.status!=="completed"){x.push(u);continue}i.has(u.slug)?x.push(u):o++}return{inline:x,collapsedCount:o}}function jt(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 Nt(t){return t==="running"||t==="auto-soon"?"text-accent":t==="idle"?"text-sage":t==="paused"||t==="auto-throttled"?"text-butter":"text-fg-faint"}const yt=["Running","Paused","Manual","On-reset","Auto"];function St(t){for(const s of yt)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 kt(t,s){return s==null||t.includes("util")?t:`${t} · util ${Math.round(s)}%`}function Pt(t,s,n,a,d,i){const c=new Map;if(d==="paused"||d==="manual"||d==="auto-throttled"){for(const u of t)c.set(u.slug,null);return c}const x=s.find(u=>u.status==="running"&&u.startedAt),o=x!=null&&x.startedAt?i-Date.parse(x.startedAt):0;for(const u of t){if(u.status!=="pending"){c.set(u.slug,null);continue}const b=n.get(u.slug)??0;let w=b*a;b>0&&(w-=Math.min(a,o)),c.set(u.slug,w<=5e3?"~now":`~${re(w)}`)}return c}function Ct({job:t,eta:s,elapsedMs:n,avgDurationMs:a,listIndex:d,onFocused:i,hold:c}){const[x,o]=l.useState(!1),[u,b]=l.useState(!1),w=le(A=>A.sessions),h=l.useMemo(()=>ve(t,w),[t,w]),v=h.known&&h.epicId?w[h.epicId]:null,N=l.useCallback(A=>{je(A),window.dispatchEvent(new CustomEvent("sm:navigate",{detail:"terminal"}))},[]),C=t.status==="running",f=t.status==="failed";let j=null;C&&n!==null?j=`${ke(n)} elapsed`:t.status==="completed"&&t.startedAt&&t.finishedAt?j=`took ${re(Date.parse(t.finishedAt)-Date.parse(t.startedAt))}`:s&&(j=s);const D=t.error??null,k=f&&D?D.split(`
4
- `)[0]:t.status==="needs_review"&&t.verifierVerdict?ce(t.verifierVerdict):null,g=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:()=>o(A=>!A),onFocus:()=>i(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 ${x?"bg-bg-elev/40":""}`,"aria-expanded":x,"aria-label":`${Y(t.slug)?`PRD ${Y(t.slug)}, `:""}${t.title}, ${t.status}${j?`, ${j}`:""}`,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:[Y(t.slug)&&e.jsx(Me,{n:Y(t.slug)}),t.title]}),k&&e.jsx("div",{className:`text-[12.5px] mt-0.5 ${f?"text-accent/80":"text-fg-faint"}`,children:k}),c&&e.jsxs("div",{className:"text-[12.5px] mt-0.5 text-amber-400/90 font-mono",children:["held · waiting on ",c.dep," (",c.depStatus,")"]}),e.jsx(Ne,{epicId:h.epicId,label:h.label?ot(h.label):null,onOpen:N,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:[j,e.jsx("span",{className:`text-fg-faint inline-flex transition-transform duration-150 ${x?"rotate-90":""}`,"aria-hidden":"true",children:e.jsx(ue,{name:"chevron",size:14})})]})]}),C&&!x&&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,g*100)}%`}})}),x&&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(q,{label:"Status",children:[e.jsx(R,{k:"result",v:t.exitCode!==null?`exit ${t.exitCode}`:"—"}),e.jsx(R,{k:"state",v:t.status.replace(/_/g," ")}),t.verifierVerdict&&e.jsx(R,{k:"verdict",v:ce(t.verifierVerdict)}),D&&e.jsx(R,{k:"error",v:D.split(`
5
- `)[0],wrap:!0})]}),t.statusHistory&&t.statusHistory.length>0&&e.jsx(q,{label:"History",children:e.jsx("div",{className:"grid gap-1",children:t.statusHistory.map((A,P)=>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:[" · ",U(Date.parse(A.at))]})]}),A.reason&&e.jsx("div",{className:"text-fg-faint break-words",children:A.reason})]},P))})}),e.jsxs(q,{label:"Timing",children:[e.jsx(R,{k:"started",v:t.startedAt?U(Date.parse(t.startedAt)):"—"}),e.jsx(R,{k:"finished",v:t.finishedAt?U(Date.parse(t.finishedAt)):"—"}),e.jsx(R,{k:"duration",v:t.startedAt&&t.finishedAt?re(Date.parse(t.finishedAt)-Date.parse(t.startedAt)):C&&n!==null?ke(n):"—"})]}),e.jsxs(q,{label:"Location",children:[e.jsx(R,{k:"group",v:`${t.parallelGroup} · ${t.slug}`}),e.jsx(R,{k:"cwd",v:t.cwd??"—",wrap:!0}),e.jsx(R,{k:"session",v:h.label??h.epicId??"—",wrap:!0}),e.jsx(R,{k:"session id",v:h.epicId??"—",wrap:!0}),e.jsx(R,{k:"prompt id",v:t.sourcePromptId??"—",wrap:!0}),e.jsx(R,{k:"source tab",v:t.sourceTabId??"—",wrap:!0})]}),e.jsx(q,{label:"Actions",children:e.jsxs("div",{className:"flex flex-col gap-1.5 items-start",children:[v&&e.jsx("button",{type:"button","data-testid":"job-row-prompt-session-link",title:v.goalText,onClick:()=>N(v.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(Oe,{runId:t.runId,slug:t.slug,title:t.title||t.slug,onClose:()=>b(!1)})]})}const At=l.memo(Ct);function Dt({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(_e,{options:n,value:t.status,onChange:a=>s({...t,status:a})})]})}function $t({supervisorConfig:t,onSetConfig:s,onBack:n}){const[a,d]=l.useState([]),[i,c]=l.useState(()=>Date.now()),x=Te();l.useEffect(()=>{if(!x)return;window.api.supervisor.getLog().then(d).catch(()=>{}),c(Date.now());const u=setInterval(()=>c(Date.now()),5e3);return()=>clearInterval(u)},[x]);const o={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:o.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:o.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:o.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:o.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(Rt,{entry:u,now:i},`${u.ts}-${b}`))})]})]})}function Rt({entry:t,now:s}){const n=t.action!=="none",a=B(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 Et({snap:t,health:s,now:n,open:a,setOpen:d}){const[i,c]=l.useState(null),[x,o]=l.useState(!1),u=`${t.jobs.length}:${t.lastRunAt??""}`;l.useEffect(()=>{let k=!0;return o(!0),$e().then(g=>{k&&c(g)}).catch(()=>{}).finally(()=>{k&&o(!1)}),()=>{k=!1}},[u]);let b=0,w=0;const h=i?i.reports.filter(k=>k.findings.length>0):[];for(const k of h)for(const g of k.findings)g.severity==="error"?b++:w++;const v=b===0&&w===0,N=i?v?`queue lint clear (${i.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,f=s?`${C} poll failure${C===1?"":"s"} since boot`:null,j=C>0||((s==null?void 0:s.pauseReason)??null)!==null||!v,D=[f,N].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 ${j?"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:D.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: ",V(s.bootedAt,n)]}),e.jsxs("div",{children:["last poll: ",V(s.lastPollAt,n)," · ",s.lastPollOk?"ok":"failed"]}),s.backoffNextAt!==null&&s.backoffNextAt>n&&e.jsxs("div",{children:["retry in: ",B(s.backoffNextAt-n)]}),s.nextResetCached&&e.jsxs("div",{children:["cached reset: ",U(Date.parse(s.nextResetCached))]}),s.runningJobs.length>0&&e.jsxs("div",{children:["running: ",s.runningJobs.map(k=>`${k.slug}(pid ${k.pid})`).join(", ")]})]}),i&&e.jsxs("div",{className:"space-y-1",children:[v?e.jsxs("div",{className:"text-sage",children:["✓ no issues in ",i.reports.length," PRD",i.reports.length!==1?"s":""]}):h.map(k=>e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-dim truncate",title:k.slug,children:k.slug}),k.findings.map((g,A)=>e.jsxs("div",{className:`pl-3 truncate ${g.severity==="error"?"text-accent/80":"text-butter/90"}`,title:g.snippet,children:[g.severity==="error"?"✗":"⚠"," L",g.line,": ",g.snippet]},`${k.slug}-${A}`))]},k.slug)),e.jsx("button",{type:"button",onClick:()=>{o(!0),$e({fresh:!0}).then(c).catch(()=>{}).finally(()=>o(!1))},className:"text-fg-faint hover:text-fg-dim underline",children:x?"…":"rerun lint"})]})]})]})}new Set(ze.map(t=>t.tag).filter(t=>t!=="discussion"));const It=["title","cwd","estimateMinutes","parallelGroup","sourcePromptId","sourceTabId","tag"];function Tt(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 Lt(t,s){var d;const n=[];for(const i of It){const c=t[i];if(c==null||c==="")continue;const x=(d=t._raw)==null?void 0:d[i];if(x&&x.parsed===c){n.push(x.line);continue}if(typeof c=="number"){n.push(`${i}: ${c}`);continue}n.push(`${i}: ${Tt(c)}`)}if(t.extras)for(const i of Object.keys(t.extras)){const c=t.extras[i];!c||!c.lines.length||n.push(c.lines.join(`
7
- `))}return`---
8
- ${n.join(`
9
- `)}
10
- ---
11
- ${s}`}function fe(t){return t.filter(s=>!s.archived)}function Mt(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(Qe,{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 Ot({scopeCwd:t=null}){const[s,n]=l.useState([]),[a,d]=l.useState(null),[i,c]=l.useState(null),[x,o]=l.useState(null),[u,b]=l.useState(!1),[w,h]=l.useState(!0),[v,N]=l.useState(new Set),[C,f]=l.useState(!1),[j,D]=l.useState(!1),[k,g]=l.useState(!1),[A,P]=l.useState(null);l.useEffect(()=>{let r=!0;return window.api.schedule.listPrds().then(m=>{r&&(n(fe(m)),h(!1))}).catch(m=>{r&&(h(!1),L.error(`Scheduler: failed to load PRD list — ${m instanceof Error?m.message:"unknown error"}`))}),()=>{r=!1}},[]);const J=we(r=>r.snapshot),xe=le(r=>r.sessions);l.useEffect(()=>{J&&d(J)},[J]);const G=l.useMemo(()=>[...s].filter(r=>!t||r.cwd===t).sort((r,m)=>m.mtimeMs-r.mtimeMs||r.slug.localeCompare(m.slug)),[s,t]);l.useEffect(()=>{const r=Ve();r&&c(r);const m=S=>c(S.detail);return window.addEventListener("sm:select-prd",m),()=>window.removeEventListener("sm:select-prd",m)},[]);const M=l.useMemo(()=>(a==null?void 0:a.jobs.find(r=>r.slug===i))??null,[a,i]),K=Pe(M);function X(r){var S;const m=(S=s.find(I=>I.slug===r))==null?void 0:S.cwd;return m?`${m}/session-manager-operations/scheduler/prds/${r}.md`:null}l.useEffect(()=>{if(!i)return;const r=X(i);r&&Ce.getState().openFile(r)},[i,s]);function Z(r){c(r),o(null),b(!1)}function pe(){c(null)}async function ee(){if(!i)return;if(!(M!=null&&M.runId)){o("no log available (job has not run yet)"),b(m=>!m);return}const r=await window.api.schedule.readLog(M.runId,i);o(r.ok?r.text??"":`error: ${r.error}`),b(m=>!m)}if(w)return e.jsx(ae,{title:"loading PRDs…"});const O=r=>{N(m=>{const S=new Set(m);return S.has(r)?S.delete(r):S.add(r),S})};!(G.length>0&&G.every(r=>v.has(r.slug)))&&G.some(r=>v.has(r.slug));const H=()=>N(new Set);async function Q(){try{const r=await window.api.schedule.listPrds();n(fe(r))}catch{}}async function $(){const r=`new-prd-${Date.now()}`,m=Lt({title:"New PRD",cwd:"",estimateMinutes:60,parallelGroup:99},`## Task
12
-
13
- Describe the task here.
14
- `);try{const S=await window.api.schedule.writePrd(r,m);if(!S.ok){L.error(`Failed to create PRD: ${S.error}`);return}const I=await window.api.schedule.listPrds();n(fe(I)),Z(r)}catch(S){L.error(`Failed to create PRD: ${S instanceof Error?S.message:String(S)}`)}}async function F(){var r;g(!0),P(null);try{const m=[...v],S=await window.api.schedule.archivePrds(m);if(!S.ok)P(S.error??"archive failed");else{const I=((r=S.results)==null?void 0:r.filter(E=>!E.ok))??[];I.length>0&&L.warn(`Archive: ${I.length} of ${S.results.length} PRD${I.length===1?"":"s"} failed to move`),H(),f(!1),await Q()}}catch(m){P(m instanceof Error?m.message:String(m))}finally{g(!1)}}async function te(r,m){g(!0),P(null);try{const S=[];for(const E of v){const _={slug:E};r!==null&&(_.parallelGroup=r),m!==null&&(_.estimateMinutes=m),S.push(_)}const I=await window.api.schedule.retagPrds(S);if(!I.ok)P(I.error??"retag failed");else{H(),D(!1),await Q();for(const E of I.results)if(E.newSlug&&E.newSlug!==E.slug){const _=X(E.slug),W=X(E.newSlug);_&&W&&Ce.getState().renameOpenFile(_,W)}i&&I.results.some(E=>E.slug===i&&E.newSlug&&E.newSlug!==E.slug)&&c(null)}}catch(S){P(S instanceof Error?S.message:String(S))}finally{g(!1)}}return e.jsxs(e.Fragment,{children:[i?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:i}),e.jsx(Ae,{status:K}),e.jsx("div",{className:"flex-1"}),e.jsx(ge,{label:"Reset",tip:"Reset failed job to pending",onClick:()=>{window.api.schedule.resetJob(i)},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(Ue,{})}),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:$,className:"shrink-0 bg-accent text-white rounded-lg px-4 py-[9px] text-[13.5px] font-semibold leading-none",children:"+ New PRD"})]}),v.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:[v.size," selected"]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{type:"button",onClick:()=>f(!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:()=>D(!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:H,className:"text-xs px-3 py-1.5 rounded border border-line text-fg-dim hover:text-fg hover:bg-bg-hi",children:"Clear"})]}),G.length===0?e.jsx(ae,{title:"no PRDs found"}):e.jsx("div",{className:"grid gap-3",children:G.map(r=>{const m=a==null?void 0:a.jobs.find(W=>W.slug===r.slug),S=Pe(m),I=ve({epicId:r.epicId??(m==null?void 0:m.epicId)??null,sourcePromptId:r.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:v.has(r.slug),onChange:()=>O(r.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:[Y(r.slug)&&e.jsx(Me,{n:Y(r.slug)}),e.jsx("button",{type:"button",onClick:()=>Z(r.slug),className:"font-serif text-[18px] font-semibold text-fg leading-tight hover:underline text-left",children:r.title||r.slug}),e.jsx(Ae,{status:S}),(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:r.cwd}),e.jsx(Ne,{epicId:I.epicId,label:I.label,onOpen:Mt}),r.estimateMinutes!=null&&e.jsxs("span",{children:[r.estimateMinutes,"m"]}),e.jsxs("span",{children:["g",r.parallelGroup]}),e.jsxs("span",{children:["edited ",V(r.mtimeMs,Date.now())]})]}),e.jsx("button",{type:"button",onClick:()=>Z(r.slug),className:"mt-1.5 font-mono text-[11px] text-fg-faint hover:text-fg-dim leading-none",children:r.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(r.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"})})]},r.slug)})})]}),e.jsx(Ft,{open:C,count:v.size,busy:k,onClose:()=>f(!1),onConfirm:F}),e.jsx(_t,{open:j,count:v.size,busy:k,onClose:()=>D(!1),onConfirm:te})]})}function Ft({open:t,count:s,busy:n,onClose:a,onConfirm:d}){return e.jsxs(Fe,{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 _t({open:t,count:s,busy:n,onClose:a,onConfirm:d}){const[i,c]=l.useState(""),[x,o]=l.useState(""),[u,b]=l.useState(null);l.useEffect(()=>{t&&(c(""),o(""),b(null))},[t]);function w(){b(null);let h=null,v=null;if(i.trim()){const N=Number(i);if(!Number.isInteger(N)||N<0||N>999){b("parallelGroup must be 0–999");return}h=N}if(x.trim()){const N=Number(x);if(!Number.isInteger(N)||N<=0){b("estimateMinutes must be a positive integer");return}v=N}if(h===null&&v===null){b("set at least one field");return}d(h,v)}return e.jsxs(Fe,{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:i,onChange:h=>c(h.target.value),placeholder:"(unchanged)",className:"flex-1 bg-bg border border-line rounded px-2 py-1 font-mono text-xs"})]}),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=>o(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 Ht(t){je(t),window.dispatchEvent(new CustomEvent("sm:navigate",{detail:"terminal"}))}function Ee(t){return t?t.slice(0,10):""}const qt=[{value:"all",label:"All"},{value:"completed",label:"Completed"},{value:"skipped",label:"Skipped"},{value:"failed",label:"Failed"}];function Bt({scopeCwd:t=null}){const[s,n]=l.useState(null),[a,d]=l.useState(!0),[i,c]=l.useState(""),[x,o]=l.useState(""),[u,b]=l.useState(""),[w,h]=l.useState("all");l.useEffect(()=>{d(!0),window.api.schedule.getHistory().then(f=>n(f)).catch(f=>n({ok:!1,jobs:[],error:f instanceof Error?f.message:String(f)})).finally(()=>d(!1))},[]);const v=l.useMemo(()=>{if(!(s!=null&&s.jobs))return[];const f=new Set;for(const j of s.jobs){const D=be(j.cwd);D&&f.add(D)}return[...f].sort()},[s]),N=l.useMemo(()=>s!=null&&s.jobs?s.jobs.filter(f=>!(t&&f.cwd!==t||w!=="all"&&f.status!==w||i&&be(f.cwd)!==i||x&&Ee(f.finishedAt)<x||u&&Ee(f.finishedAt)>u)):[],[s,w,i,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"||!!i||!!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(_e,{options:qt,value:w,onChange:h,pillPadding:"px-3 py-1"}),e.jsx("span",{className:"w-px h-4 bg-line mx-1","aria-hidden":"true"}),v.length>0&&e.jsxs("select",{value:i,onChange:f=>c(f.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"}),v.map(f=>e.jsx("option",{value:f,children:f},f))]}),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:f=>o(f.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:f=>b(f.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:[N.length," / ",s.jobs.length]}),C&&e.jsx("button",{type:"button",onClick:()=>{h("all"),c(""),o(""),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:N.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:[N.length," job",N.length!==1?"s":""]})}),N.map(f=>e.jsx(Jt,{job:f},`${f.slug}-${f.finishedAt??""}`))]})})]})}function Jt({job:t}){const[s,n]=l.useState(!1),[a,d]=l.useState(!1),i=le(h=>h.sessions),c=l.useMemo(()=>ve(t,i),[t,i]),x=t.startedAt&&t.finishedAt?Date.parse(t.finishedAt)-Date.parse(t.startedAt):null,o=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.jsx("div",{className:"text-[14.5px] font-medium text-fg leading-snug text-pretty",children:t.title}),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}),c.epicId&&e.jsx("span",{className:"flex mt-0.5",children:e.jsx(Ne,{epicId:c.epicId,label:c.label,onOpen:Ht})})]}),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(q,{label:"Status",children:[e.jsx(R,{k:"result",v:w}),e.jsx(R,{k:"state",v:t.status.replace("_"," ")}),t.verifierVerdict&&e.jsx(R,{k:"verifier",v:ce(t.verifierVerdict)})]}),e.jsxs(q,{label:"Timing",children:[e.jsx(R,{k:"started",v:o}),e.jsx(R,{k:"finished",v:u}),e.jsx(R,{k:"duration",v:b})]}),e.jsxs(q,{label:"Location",children:[e.jsx(R,{k:"group",v:t.parallelGroup!=null?String(t.parallelGroup):"—"}),e.jsx(R,{k:"slug",v:t.slug}),e.jsx(R,{k:"epic",v:c.label??c.epicId??"—",wrap:!0}),t.cwd&&e.jsx(R,{k:"cwd",v:t.cwd,wrap:!0})]}),e.jsx(q,{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(Oe,{runId:t.runId,slug:t.slug,title:t.title||t.slug,onClose:()=>d(!1)})]})}function Gt(t){return t?Object.values(t).reduce((s,n)=>s+(n??[]).reduce((a,d)=>{var i;return a+(((i=d.hooks)==null?void 0:i.length)??0)},0),0):0}function zt(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 Ut({navigate:t}){const s=We(),n=se(g=>g.files),a=se(g=>g.loadJson),d=se(g=>g.loadText),i=se(g=>g.watchFile),c=se(g=>g.unwatchFile),x=s?Ye.resolve("user",s,null):null,o=s?Ke.resolve("user",s,null):null,u=s?`${s}/.claude.json`:null;l.useEffect(()=>{const g=[x,u].filter(Boolean);g.forEach(P=>{n[P]||a(P),i(P)});const A=[o].filter(Boolean);return A.forEach(P=>{n[P]||d(P),i(P)}),()=>{[...g,...A].forEach(P=>c(P))}},[x,o,u]);const[b,w]=l.useState(null);l.useEffect(()=>{if(!s)return;let g=!1;return(async()=>{const A=await st(`${s}/.claude/skills`);g||w(A.length)})(),()=>{g=!0}},[s]);const h=x?n[x]:null,v=u?n[u]:null,N=o?n[o]:null,C=l.useMemo(()=>{if(!(h!=null&&h.exists)||h.parseError)return null;const g=h.diskData;return g===null||typeof g!="object"||Array.isArray(g)?{}:g},[h]),f=l.useMemo(()=>{if(!(v!=null&&v.exists)||v.parseError)return null;const g=v.diskData;return g===null||typeof g!="object"||Array.isArray(g)?{}:g},[v]),j=h?h.parseError?"invalid JSON":null:"loading…",D=v?v.parseError?"invalid JSON":null:"loading…",k=[{key:"settings",title:"Settings",summary:j??(C?`${Object.keys(C).length} top-level key${Object.keys(C).length===1?"":"s"} configured`:"not configured")},{key:"permissions",title:"Permissions",summary:j??(C?`${zt(C.permissions)} rule(s) configured`:"not configured")},{key:"hooks",title:"Hooks",summary:j??(C?`${Gt(C.hooks)} hook(s) configured`:"not configured")},{key:"mcp",title:"MCP Servers",summary:D??(f?`${Object.keys(f.mcpServers??{}).length} MCP server(s)`:"not configured")},{key:"system-prompt",title:"System Prompt",summary:N!=null&&N.exists&&N.diskRaw.trim().length>0?`configured (${N.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:k.map(g=>e.jsxs("button",{type:"button",onClick:()=>t==null?void 0:t(g.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:g.title}),e.jsx("div",{className:"mt-0.5 text-[12px] text-fg-dim",children:g.summary})]},g.key))})]})}function Vt({navigate:t}){const s=Xe(),[n,a]=l.useState(!1),[d,i]=l.useState(!1);l.useEffect(()=>{let x=!0;return Ze().then(o=>{x&&a(o.openToHomeOnLaunch===!0)}),()=>{x=!1}},[]);const c=async x=>{a(x),i(!0);try{await et({openToHomeOnLaunch:x})}catch{a(!x),L.error('Failed to save "Open to Home on launch" — try again.')}finally{i(!1)}};return e.jsxs("div",{className:"max-w-[760px] space-y-6",children:[e.jsx(Ut,{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,o)=>e.jsx("span",{className:`w-3.5 h-3.5 rounded-full border ${o<((s==null?void 0:s.inUse)??0)?"bg-accent border-accent":"bg-bg border-line"}`},o)),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,o)=>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()]})]},o))})]}),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(nt,{checked:n,onChange:c,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",Qt=[{key:"queue",label:"Queue"},{key:"prds",label:"PRDs"},{key:"history",label:"History"}];function Wt(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 Yt(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 ${B(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 Kt({scopeCwd:t}){const{snapshot:s}=we(),[n,a]=l.useState(()=>Date.now());if(l.useEffect(()=>{const f=setInterval(()=>a(Date.now()),3e4);return()=>clearInterval(f)},[]),!s)return null;const d=(s.jobs??[]).filter(f=>!t||f.cwd===t),i=d.filter(f=>f.status==="pending").length,c=d.filter(f=>f.status==="running").length,x=d.filter(f=>f.status==="completed"&&(f.finishedAt?Wt(f.finishedAt,n):!1)).length,o=s.nextReset?new Date(s.nextReset).getTime():null,u=o?o>n?B(o-n):"soon":"—",b=V(s.lastRunAt?new Date(s.lastRunAt).getTime():null,n),w=s.paused,h=s.pollHealth,v=h!=null&&!h.lastPollOk,C=(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] ${C}`,children:[e.jsx("span",{className:"flex-1 leading-snug",children:Yt(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"})]}),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:i,label:"pending"}),e.jsx(he,{dotClass:"bg-accent",n:c,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"}),v?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"," ",V(h.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 Xt({navigate:t}={}){var x;const[s,n]=l.useState(()=>{const o=localStorage.getItem(Ie);return o==="prds"||o==="history"||o==="machine"?o:"queue"}),a=De(o=>o.tabs),d=De(o=>o.activeTabId),i=((x=a.find(o=>o.id===d))==null?void 0:x.cwd)??null,c=i;return l.useEffect(()=>{i&&(le.getState().hydrate(i),le.getState().hydrateArchived(i))},[i]),l.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(tt,{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(Kt,{scopeCwd:c})}),e.jsxs("div",{className:"flex items-center gap-3 pb-0",children:[e.jsx(at,{options:Qt,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(mt,{scopeCwd:c,navigate:t}),s==="prds"&&e.jsx(Ot,{scopeCwd:c}),s==="history"&&e.jsx(Bt,{scopeCwd:c}),s==="machine"&&e.jsx("div",{className:"h-full overflow-y-auto px-9 py-6",children:e.jsx(Vt,{navigate:t})})]})]})}const ns=l.memo(Xt);export{ns as Scheduler};
@@ -1 +0,0 @@
1
- import{ad as o,T as g,a4 as e,j as w,am as v,an as u,y}from"./index-B_4PNh9T.js";import{P as T}from"./Panel-BhWPVOCD.js";import{L as k}from"./ListDetail-BQMd6NOm.js";import"./monaco-editor-BW5C4Iv1.js";const E=new Set(g.map(a=>a.tag));function j(a){return a.filter(n=>E.has(n))}function P(){const[a,n]=o.useState(g[0].tag),[l,x]=o.useState(null),[h,m]=o.useState(!1),r=o.useRef(!0);o.useEffect(()=>()=>{r.current=!1},[]);const c=async()=>{try{const t=await window.api.agents.listPersonas();r.current&&x(t)}catch(t){if(!r.current)return;x([]),u.error(t.message||"failed to load agent personas")}};o.useEffect(()=>{c()},[]),o.useEffect(()=>window.api.agents.onChanged(()=>c()),[]);const f=g.find(t=>t.tag===a)??null,p=async(t,i)=>{try{await window.api.agents.savePersona({name:t.name,originalName:t.name,description:t.description??"",tools:t.tools,model:t.model??"inherit",color:t.color??"",tags:j([...t.tags,i]),body:t.body}),m(!1),await c()}catch(d){u.error(d.message||"failed to assign tag")}},s=async(t,i)=>{try{await window.api.agents.savePersona({name:t.name,originalName:t.name,description:t.description??"",tools:t.tools,model:t.model??"inherit",color:t.color??"",tags:j(t.tags.filter(d=>d!==i)),body:t.body}),await c()}catch(d){u.error(d.message||"failed to remove tag")}};return e.jsx(T,{toolbar:e.jsxs("span",{className:"text-fg-faint",children:[g.length," tag",g.length===1?"":"s"]}),children:e.jsx(k,{sidebar:e.jsx("div",{className:"py-1",children:g.map(t=>{const i=v(t.tag),d=a===t.tag,b=(l==null?void 0:l.filter(N=>N.tags.includes(t.tag)).length)??0;return e.jsxs("button",{onClick:()=>{n(t.tag),m(!1)},className:`w-full text-left px-3 py-1.5 text-xs flex items-center gap-2 border-l-2 ${d?"bg-bg-hi text-fg border-accent":"text-fg-dim hover:text-fg hover:bg-bg-hi border-transparent"}`,children:[e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-mono font-semibold ${i.bg} ${i.text} ${i.border?"border border-current/30":""}`,children:["#",t.tag]}),e.jsx("span",{className:"truncate",children:t.label}),b>0&&e.jsx("span",{className:"ml-auto text-[10.5px] text-fg-faint font-mono shrink-0",children:b})]},t.tag)})}),detail:f?e.jsx(S,{entry:f,personas:l,adding:h,setAdding:m,onAssign:p,onUnassign:s}):e.jsx(w,{title:"select a tag"})})})}const A=o.memo(P);function S({entry:a,personas:n,adding:l,setAdding:x,onAssign:h,onUnassign:m}){const r=v(a.tag),c=y(a.tag),f=(n==null?void 0:n.filter(s=>s.tags.includes(a.tag)))??[],p=(n==null?void 0:n.filter(s=>!s.tags.includes(a.tag)))??[];return e.jsxs("div",{className:"p-4 space-y-4 max-w-3xl",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsxs("span",{className:`px-2 py-1 rounded text-xs font-mono font-semibold ${r.bg} ${r.text} ${r.border?"border border-current/30":""}`,children:["#",a.tag]}),e.jsx("span",{className:"text-sm font-semibold text-fg",children:a.label})]}),e.jsx("div",{className:"text-xs text-fg-dim leading-relaxed",children:a.description}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"/develop eagerness"}),e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] rounded border border-line text-fg-dim font-mono",children:a.developEagerness})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"develops via"}),e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] rounded border border-line text-fg-dim font-mono",children:a.developsVia})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"agents carrying this tag"}),n===null?e.jsx("div",{className:"text-xs text-fg-faint italic",children:"loading…"}):e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[f.map(s=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 bg-bg-elev border border-line rounded px-2 py-0.5 text-[11px] font-mono text-fg-dim",children:[s.name,e.jsx("button",{onClick:()=>m(s,a.tag),title:"Remove this tag from the agent",className:"text-fg-faint hover:text-fg",children:"×"})]},s.name)),f.length===0&&!l&&e.jsx("span",{className:"text-xs text-fg-faint italic mr-1",children:"no agent carries this tag yet."}),l?p.length>0?e.jsxs("select",{autoFocus:!0,defaultValue:"",onChange:s=>{const t=n.find(i=>i.name===s.target.value);t&&h(t,a.tag)},onBlur:()=>x(!1),className:"bg-bg border border-line rounded px-2 py-0.5 text-[11px] text-fg font-mono",children:[e.jsx("option",{value:"",disabled:!0,children:"pick an agent…"}),p.map(s=>e.jsx("option",{value:s.name,children:s.name},s.name))]}):e.jsx("span",{className:"text-xs text-fg-faint italic",children:"every agent already carries this tag."}):e.jsx("button",{onClick:()=>x(!0),className:"px-2 py-0.5 rounded-full text-[11px] font-mono border border-line text-fg-faint hover:text-fg hover:bg-bg-hi",children:"+ assign agent"})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:"opening framing — sent before the human's goal"}),e.jsx("pre",{className:"text-xs text-fg-dim whitespace-pre-wrap bg-bg-elev border border-line rounded p-3 leading-relaxed font-sans",children:c.initialPromptTemplate})]})]})}export{A as TagLibrary};