claude-code-session-manager 0.89.0 → 0.91.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-tuj-j1kQ.js → AgentLibrary-zkgdnCnG.js} +1 -1
- package/dist/assets/DataModel-CNFdqxrR.js +1 -0
- package/dist/assets/{History-DylcasUk.js → History-C-qijfXz.js} +2 -2
- package/dist/assets/{Hooks--2xoag9a.js → Hooks-DGxt1nBd.js} +3 -3
- package/dist/assets/{HostBilko-oaw8paAh.js → HostBilko-sIYTK-m9.js} +1 -1
- package/dist/assets/{Library-DzKA09Iy.js → Library-51Jx0oGl.js} +1 -1
- package/dist/assets/{ListDetail-CEdcO80v.js → ListDetail-ByNJU-ie.js} +1 -1
- package/dist/assets/MarkdownEditor-Wwcpe9O1.js +1 -0
- package/dist/assets/{McpServers-BB7ayW7W.js → McpServers-Bs5xPbTG.js} +2 -2
- package/dist/assets/{Memory-BOdYvrL4.js → Memory-BsHGInmd.js} +6 -6
- package/dist/assets/{Panel-Yf3SxsRv.js → Panel-ilEDcV0m.js} +1 -1
- package/dist/assets/{Permissions-BYCpHNy5.js → Permissions-Djgc3TFk.js} +3 -3
- package/dist/assets/{Plugins-B0lXiYqV.js → Plugins-BBojr1mt.js} +2 -2
- package/dist/assets/{ProvenanceBadge-T7x8LWcV.js → ProvenanceBadge-Cz1VLnXb.js} +1 -1
- package/dist/assets/{SaveBar-BdVb4DbR.js → SaveBar-Cj0wz84u.js} +1 -1
- package/dist/assets/Scheduler-D4Ekm93R.js +16 -0
- package/dist/assets/{ScopeSwitcher-WVhmNsL5.js → ScopeSwitcher-DA5MqWli.js} +1 -1
- package/dist/assets/{Settings-Bt4dVsl6.js → Settings-B1Kfgjvl.js} +2 -2
- package/dist/assets/{SkillReferenceGraph-R-0YykV8.js → SkillReferenceGraph-Dew-1uMy.js} +1 -1
- package/dist/assets/{Skills-DXV_LdJP.js → Skills-DzuhnXy9.js} +2 -2
- package/dist/assets/SystemPrompt-CNcCwEev.js +1 -0
- package/dist/assets/{TagLibrary-B9OuqU6M.js → TagLibrary-D0plTZgP.js} +1 -1
- package/dist/assets/{TiptapBody-HKKmB0AE.js → TiptapBody-BlmUt7SR.js} +1 -1
- package/dist/assets/{Toggle-CBggPonH.js → Toggle-yTfx2R-e.js} +1 -1
- package/dist/assets/{index-BHTX4OTc.css → index-CRPJslSA.css} +1 -1
- package/dist/assets/{index-BcJqLDiY.js → index-ju-h7BFf.js} +444 -444
- package/dist/assets/{settingsSchema-BYE9DVw_.js → settingsSchema-BkcnLBYk.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/scripts/README.md +1 -0
- package/src/main/__tests__/bilkoHost-integration.test.cjs +22 -9
- package/src/main/__tests__/chatRunner-session-flag-retry.test.cjs +159 -0
- package/src/main/__tests__/health-delegation-chain.test.cjs +3 -1
- package/src/main/__tests__/pollLoop-dispatch-on-failure.test.cjs +16 -4
- package/src/main/__tests__/projectHomeAdminRoutes.test.cjs +12 -0
- package/src/main/__tests__/scheduler-default-eligible-heal.test.cjs +10 -3
- package/src/main/__tests__/scheduler-looks-done.test.cjs +9 -2
- package/src/main/__tests__/scheduler-needs-review-autoresolve.test.cjs +14 -6
- package/src/main/__tests__/scheduler-shard-quarantine.test.cjs +2 -2
- package/src/main/__tests__/scheduler-stranded-autofix-park.test.cjs +8 -1
- package/src/main/__tests__/transcripts-paged-reads.test.cjs +4 -2
- package/src/main/__tests__/transcripts-worktree-epic-path.test.cjs +154 -0
- package/src/main/__tests__/usageSingleFlight.test.cjs +3 -1
- package/src/main/bilkoHost.cjs +6 -7
- package/src/main/build-info.json +4 -4
- package/src/main/chatRunner.cjs +108 -45
- package/src/main/health.cjs +20 -3
- package/src/main/index.cjs +1 -1
- package/src/main/ipcSchemas.cjs +3 -0
- package/src/main/lib/__tests__/epicSpawnCwd.test.cjs +34 -0
- package/src/main/lib/__tests__/epicSpawnPlan.test.cjs +117 -0
- package/src/main/lib/__tests__/epicTranscriptPath.test.cjs +163 -0
- package/src/main/lib/__tests__/localAdminHttp.test.cjs +5 -1
- package/src/main/lib/__tests__/schedulerPathsWorktree.test.cjs +40 -1
- package/src/main/lib/__tests__/telemetryCountersMetadataColumn.test.cjs +8 -5
- package/src/main/lib/effectiveModelInfo.cjs +3 -3
- package/src/main/lib/epicDelegationStats.cjs +3 -2
- package/src/main/lib/epicSpawnCwd.cjs +36 -5
- package/src/main/lib/epicSpawnPlan.cjs +119 -0
- package/src/main/lib/epicTranscriptDiagnostic.cjs +79 -0
- package/src/main/lib/epicTranscriptPath.cjs +184 -0
- package/src/main/lib/gitWorktree.cjs +1 -1
- package/src/main/lib/mcpToolCatalog.cjs +6 -1
- package/src/main/lib/prdCreate.cjs +27 -1
- package/src/main/lib/prdFrontmatter.cjs +16 -5
- package/src/main/lib/rcaReport.cjs +27 -3
- package/src/main/lib/schedulerPaths.cjs +27 -4
- package/src/main/lib/telemetryClient.cjs +11 -4
- package/src/main/lib/terminalRunOutcome.cjs +1 -0
- package/src/main/pty.cjs +1 -1
- package/src/main/runVerify.cjs +89 -1
- package/src/main/scheduler.cjs +17 -4
- package/src/main/templates/PRD_AUTHORING.md +11 -0
- package/src/main/transcripts.cjs +28 -7
- package/src/preload/api.d.ts +4 -2
- package/src/preload/index.cjs +1 -0
- package/dist/assets/DataModel-DOim5SXW.js +0 -1
- package/dist/assets/MarkdownEditor-BMyo0F7s.js +0 -1
- package/dist/assets/Scheduler-DlOCWioV.js +0 -14
- package/dist/assets/SystemPrompt-DiQRo_WF.js +0 -1
package/src/main/transcripts.cjs
CHANGED
|
@@ -38,9 +38,22 @@ function attachWindow(w) {
|
|
|
38
38
|
|
|
39
39
|
const { encodeCwd } = require('./lib/encodeCwd.cjs');
|
|
40
40
|
const { classifyLine } = require('./lib/classifyTranscriptLine.cjs');
|
|
41
|
+
const { resolveEpicTranscriptPath } = require('./lib/epicTranscriptPath.cjs');
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Where the CLI's JSONL for this session lives. Epic sessions run in a
|
|
45
|
+
* worktree, so the resolver checks the worktree encoding as well as the
|
|
46
|
+
* project one; a non-Epic tab resolves to the plain project-encoded path.
|
|
47
|
+
* Sync + absolute always (falls back to the plain path on invalid input).
|
|
48
|
+
*/
|
|
49
|
+
function resolveTranscript(cwd, sessionUuid) {
|
|
50
|
+
const r = resolveEpicTranscriptPath({ cwd, claudeSessionId: sessionUuid });
|
|
51
|
+
const filePath = r.path || path.join(os.homedir(), '.claude', 'projects', encodeCwd(cwd), `${sessionUuid}.jsonl`);
|
|
52
|
+
return { filePath, existsAnywhere: !!r.existsAnywhere };
|
|
53
|
+
}
|
|
41
54
|
|
|
42
55
|
function transcriptPath(cwd, sessionUuid) {
|
|
43
|
-
return
|
|
56
|
+
return resolveTranscript(cwd, sessionUuid).filePath;
|
|
44
57
|
}
|
|
45
58
|
|
|
46
59
|
// Cap bytes read per readDelta pass. Bounds memory on first attach to a very
|
|
@@ -191,8 +204,11 @@ async function readPage(sub, startLine, endLine) {
|
|
|
191
204
|
const from = Math.max(0, Math.min(startLine, total - 1));
|
|
192
205
|
const to = Math.max(0, Math.min(endLine, total - 1));
|
|
193
206
|
if (total === 0 || from > to) return { events: [], totalLines: total };
|
|
194
|
-
|
|
195
|
-
|
|
207
|
+
// Snapshot the entries synchronously: the awaits below can interleave with a
|
|
208
|
+
// rotation/truncation rebuild that shrinks sub.lineIndex, so never re-index it after.
|
|
209
|
+
const entries = sub.lineIndex.slice(from, to + 1);
|
|
210
|
+
const first = entries[0];
|
|
211
|
+
const last = entries[entries.length - 1];
|
|
196
212
|
const spanOffset = first.byteOffset;
|
|
197
213
|
const spanLength = last.byteOffset + last.byteLength - spanOffset;
|
|
198
214
|
const events = [];
|
|
@@ -202,7 +218,7 @@ async function readPage(sub, startLine, endLine) {
|
|
|
202
218
|
const buf = Buffer.alloc(spanLength);
|
|
203
219
|
await fd.read(buf, 0, spanLength, spanOffset);
|
|
204
220
|
for (let lineNo = from; lineNo <= to; lineNo++) {
|
|
205
|
-
const entry =
|
|
221
|
+
const entry = entries[lineNo - from];
|
|
206
222
|
const relOffset = entry.byteOffset - spanOffset;
|
|
207
223
|
const text = buf.toString('utf8', relOffset, relOffset + entry.byteLength);
|
|
208
224
|
let obj;
|
|
@@ -361,9 +377,14 @@ async function subscribe({ tabId, cwd, sessionUuid }) {
|
|
|
361
377
|
});
|
|
362
378
|
return { ok: false, path: null, error: 'too many active subscriptions' };
|
|
363
379
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
380
|
+
// Known limitation: filePath is latched here and never re-resolved. Fine
|
|
381
|
+
// because nothing relocates a transcript under an open subscription.
|
|
382
|
+
const { filePath, existsAnywhere } = resolveTranscript(cwd, sessionUuid);
|
|
383
|
+
// Only create the dir when no transcript exists anywhere (it is the dir the
|
|
384
|
+
// CLI is about to write); otherwise we'd mint empty project dirs it never made.
|
|
385
|
+
if (!existsAnywhere) {
|
|
386
|
+
await fsp.mkdir(path.dirname(filePath), { recursive: true }).catch(() => {});
|
|
387
|
+
}
|
|
367
388
|
const sub = {
|
|
368
389
|
tabId,
|
|
369
390
|
cwd,
|
package/src/preload/api.d.ts
CHANGED
|
@@ -200,8 +200,8 @@ export interface McpStatusResult {
|
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
/** One session-manager-scheduler MCP tool's catalog entry (src/main/lib/mcpToolCatalog.cjs) —
|
|
203
|
-
* the same data GET /admin/mcp/catalog serves, read in-process for
|
|
204
|
-
*
|
|
203
|
+
* the same data GET /admin/mcp/catalog serves, read in-process for the Dashboard's
|
|
204
|
+
* HomeAgentTools section. */
|
|
205
205
|
export interface McpToolCatalogEntry {
|
|
206
206
|
name: string;
|
|
207
207
|
group: 'scheduler' | 'chat' | 'feedback' | 'help';
|
|
@@ -1780,6 +1780,8 @@ export interface SessionManagerAPI {
|
|
|
1780
1780
|
total: number; inUse: number; holders: { owner: string; at: string }[];
|
|
1781
1781
|
min: number; max: number; default: number; envOverride: boolean;
|
|
1782
1782
|
}>;
|
|
1783
|
+
/** Resolved base dir of managed Epic/job worktrees (SM_WORKTREE_ROOT, else the persistent per-user state dir). */
|
|
1784
|
+
worktreeBase: () => Promise<string>;
|
|
1783
1785
|
/** Set the slot pool's user cap (Home tab), [0, 10]; 0 pauses new launches. Ignored if SM_SESSION_SLOTS is set. */
|
|
1784
1786
|
setSessionSlots: (cap: number) => Promise<{
|
|
1785
1787
|
total: number; inUse: number; holders: { owner: string; at: string }[];
|
package/src/preload/index.cjs
CHANGED
|
@@ -231,6 +231,7 @@ contextBridge.exposeInMainWorld('api', {
|
|
|
231
231
|
schedule: {
|
|
232
232
|
state: () => ipcRenderer.invoke('schedule:state'),
|
|
233
233
|
sessionSlots: () => ipcRenderer.invoke('schedule:session-slots'),
|
|
234
|
+
worktreeBase: () => ipcRenderer.invoke('schedule:worktree-base'),
|
|
234
235
|
setSessionSlots: (cap) => ipcRenderer.invoke('schedule:set-session-slots', { cap }),
|
|
235
236
|
setConfig: (partial) => ipcRenderer.invoke('schedule:set-config', partial),
|
|
236
237
|
resetJob: (slug) => ipcRenderer.invoke('schedule:reset-job', { slug }),
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{al as d,f as j,ab as $,U as g,aa as e,j as N,V as E,ad as S,W as b,an as T,b as p,I as D,g as v,E as R}from"./index-BcJqLDiY.js";import{P as V}from"./Panel-Yf3SxsRv.js";import"./monaco-editor-BW5C4Iv1.js";const C=[{key:"diagram",label:"Diagram"},{key:"tables",label:"Tables"}];function G(){const[s,t]=d.useState("diagram"),[a,i]=d.useState(null),[l,n]=d.useState(()=>new Set),c=d.useMemo(()=>j.filter(r=>!l.has(r.group)),[l]),m=d.useMemo(()=>$(c),[c]),o=r=>{n(x=>{const h=new Set(x);return h.has(r)?h.delete(r):h.add(r),h}),i(null)},u=a?g(a):null,y=r=>c.some(x=>x.id===r);return e.jsx(V,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(E,{options:C,active:s,onChange:t}),e.jsx(M,{hiddenGroups:l,onToggle:o}),e.jsxs("span",{className:"ml-auto text-fg-faint",children:[j.length," entities"]})]}),children:s==="diagram"?e.jsxs("div",{className:"h-full flex",children:[e.jsx("div",{className:"flex-1 min-w-0 overflow-auto",children:e.jsx(O,{layout:m,selectedId:a,onSelect:r=>i(x=>x===r?null:r)})}),e.jsx("div",{className:"w-96 shrink-0 border-l border-line overflow-y-auto",children:u?e.jsx(F,{entity:u,onSelectRelated:r=>y(r)?i(r):void 0}):e.jsx(N,{title:"select an entity",hint:"click a box in the diagram to see its storage, fields, and relations"})})]}):e.jsx(P,{})})}const L=d.memo(G);function M({hiddenGroups:s,onToggle:t}){return e.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:v.map(a=>{const i=s.has(a.id);return e.jsxs("button",{onClick:()=>t(a.id),title:`${a.blurb} (${a.realm})`,className:`flex items-center gap-1 px-1.5 py-0.5 rounded border text-[10.5px] ${i?"border-line text-fg-faint opacity-50":"border-line text-fg-dim hover:text-fg"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${a.tone.dot}`}),a.label,e.jsx("span",{className:"text-fg-faint",children:a.realm})]},a.id)})})}function O({layout:s,selectedId:t,onSelect:a}){const i=d.useMemo(()=>t?new Set(S(t)):null,[t]),l=n=>!!t&&(n.relation.from===t||n.relation.to===t);return s.boxes.length===0?e.jsx(N,{title:"no entities in view",hint:"toggle a group in the legend to show its entities"}):e.jsxs("div",{className:"relative p-4",style:{width:s.width+32,height:s.height+32},children:[e.jsxs("svg",{width:s.width,height:s.height,className:"absolute left-4 top-4 overflow-visible",children:[s.edges.map(n=>{const c=l(n);return e.jsx("path",{"data-testid":`erd-edge-${n.relation.from}-${n.relation.to}`,d:n.d,fill:"none",className:c?"stroke-accent":"stroke-line",strokeWidth:c?2:1,opacity:t&&!c?.25:1},`${n.relation.from}-${n.relation.to}-${n.relation.label}`)}),s.edges.map(n=>l(n)?e.jsx("text",{x:n.mx,y:n.my,textAnchor:"middle",className:"fill-fg-dim text-[10px]",children:n.relation.label},`label-${n.relation.from}-${n.relation.to}-${n.relation.label}`):null)]}),s.boxes.map(n=>e.jsx(_,{box:n,selected:n.id===t,dimmed:!!t&&n.id!==t&&!(i!=null&&i.has(n.id)),onClick:()=>a(n.id)},n.id))]})}function _({box:s,selected:t,dimmed:a,onClick:i}){const l=g(s.id),n=b(s.group),c=l.fields.slice(0,R),m=l.fields.length-c.length;return e.jsxs("button",{type:"button","data-testid":`erd-box-${s.id}`,onClick:i,className:`absolute text-left rounded border overflow-hidden bg-bg-hi ${t?"border-accent ring-1 ring-accent":"border-line"} ${a?"opacity-30":""}`,style:{left:s.x,top:s.y,width:s.w,height:s.h},children:[e.jsxs("div",{className:"px-2 py-1 border-b border-line flex items-center gap-1.5",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${n.tone.dot}`}),e.jsx("span",{className:"text-[11px] font-semibold text-fg truncate",children:l.name})]}),l.aka&&e.jsx("div",{className:"px-2 pt-0.5 text-[9.5px] text-fg-faint truncate",children:l.aka}),e.jsxs("div",{className:"px-2 py-0.5",children:[c.map(o=>e.jsxs("div",{className:"text-[9.5px] font-mono text-fg-dim truncate flex items-center gap-1",children:[o.key&&e.jsx("span",{className:"text-fg-faint",children:o.key}),e.jsx("span",{className:"truncate",children:o.name})]},o.name)),m>0&&e.jsxs("div",{className:"text-[9.5px] text-fg-faint italic",children:["+",m," more"]})]})]})}function w({fields:s}){return e.jsxs("table",{className:"w-full text-[11px] font-mono",children:[e.jsx("thead",{className:"text-fg-faint uppercase tracking-wide text-[9.5px]",children:e.jsxs("tr",{className:"border-b border-line",children:[e.jsx("th",{className:"text-left font-normal px-2 py-1",children:"name"}),e.jsx("th",{className:"text-left font-normal px-2 py-1",children:"type"}),e.jsx("th",{className:"text-left font-normal px-2 py-1",children:"key"}),e.jsx("th",{className:"text-left font-normal px-2 py-1",children:"note"})]})}),e.jsx("tbody",{children:s.map(t=>e.jsxs("tr",{className:"border-b border-line/50",children:[e.jsxs("td",{className:"px-2 py-1 text-fg",children:[t.name,t.optional&&e.jsx("span",{className:"text-fg-faint",children:"?"})]}),e.jsx("td",{className:"px-2 py-1 text-fg-dim",children:t.type}),e.jsx("td",{className:"px-2 py-1",children:t.key&&e.jsxs(p,{tone:t.key==="pk"?"accent":"dim",children:[t.key,t.ref?` → ${t.ref}`:""]})}),e.jsx("td",{className:"px-2 py-1 text-fg-faint",children:t.note})]},t.name))})]})}function k({entity:s}){return e.jsxs("div",{className:"space-y-1 text-[11px]",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-faint w-20 shrink-0",children:"path"}),e.jsx("span",{className:"font-mono text-fg-dim break-all",children:s.store.path})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-faint w-20 shrink-0",children:"format"}),e.jsx("span",{className:"font-mono text-fg-dim",children:s.store.format})]}),s.store.writer&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-faint w-20 shrink-0",children:"writer"}),e.jsxs(p,{tone:"accent",children:["single-writer: ",s.store.writer]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-faint w-20 shrink-0",children:"definedIn"}),e.jsx("span",{className:"font-mono text-fg-dim break-all",children:s.store.definedIn})]})]})}function F({entity:s,onSelectRelated:t}){const a=b(s.group),i=T(s.id);return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${a.tone.dot}`}),e.jsx("span",{className:"text-sm font-semibold text-fg",children:s.name})]}),s.aka&&e.jsx("div",{className:"text-[10.5px] text-fg-faint",children:s.aka}),e.jsx(p,{tone:"dim",className:"mt-1",children:a.label})]}),e.jsx("div",{className:"text-xs text-fg-dim leading-relaxed",children:s.summary}),e.jsxs("div",{children:[e.jsx(f,{children:"storage"}),e.jsx(k,{entity:s})]}),e.jsxs("div",{children:[e.jsx(f,{children:"fields"}),e.jsx(w,{fields:s.fields})]}),s.notes&&s.notes.length>0&&e.jsxs("div",{children:[e.jsx(f,{children:"notes"}),e.jsx("ul",{className:"list-disc pl-4 space-y-0.5 text-xs text-fg-dim",children:s.notes.map(l=>e.jsx("li",{children:l},l))})]}),e.jsxs("div",{children:[e.jsx(f,{children:"relations"}),i.length===0?e.jsx("div",{className:"text-xs text-fg-faint italic",children:"no relations"}):e.jsx("ul",{className:"space-y-1",children:i.map(l=>{const n=l.from===s.id?l.to:l.from,c=g(n);return e.jsxs("li",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx("span",{className:"font-mono text-fg-faint w-10 shrink-0",children:D(l.cardinality)}),e.jsx("span",{className:"text-fg-dim",children:l.label}),l.via&&e.jsxs("span",{className:"font-mono text-[10px] text-fg-faint",children:["via ",l.via]}),e.jsx("button",{type:"button",onClick:()=>t(n),className:"ml-auto text-accent hover:underline font-mono",children:c.name})]},`${l.from}-${l.to}-${l.label}`)})})]})]})}function f({children:s}){return e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1 font-mono",children:s})}function P(){return e.jsx("div",{className:"p-4 space-y-6",children:v.map(s=>{const t=j.filter(a=>a.group===s.id);return t.length===0?null:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${s.tone.dot}`}),e.jsx("span",{className:"text-xs font-semibold text-fg",children:s.label}),e.jsx("span",{className:"text-[10.5px] text-fg-faint",children:s.realm})]}),e.jsx("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-3",children:t.map(a=>e.jsxs("div",{className:"border border-line rounded bg-bg-hi p-3 space-y-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-fg",children:a.name}),a.aka&&e.jsx("span",{className:"text-[10.5px] text-fg-faint",children:a.aka})]}),e.jsx(p,{tone:"dim",className:"mt-1",children:s.label})]}),e.jsx("div",{className:"text-xs text-fg-dim leading-relaxed",children:a.summary}),e.jsx(k,{entity:a}),e.jsx(w,{fields:a.fields}),a.notes&&a.notes.length>0&&e.jsx("ul",{className:"list-disc pl-4 space-y-0.5 text-xs text-fg-dim",children:a.notes.map(i=>e.jsx("li",{children:i},i))})]},a.id))})]},s.id)})})}export{L as DataModel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aa as i,F as r}from"./index-BcJqLDiY.js";function l({value:e,onChange:a,path:n,readOnly:o}){return i.jsx(r,{path:`file://${n}`,defaultLanguage:"markdown",value:e,onChange:t=>a(t??""),theme:"vs-dark",options:{minimap:{enabled:!1},fontSize:13,fontFamily:"JetBrains Mono, ui-monospace, Menlo, monospace",lineNumbers:"on",renderLineHighlight:"line",scrollBeyondLastLine:!1,tabSize:2,wordWrap:"on",readOnly:o,automaticLayout:!0}})}export{l as M};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import{aa as e,al as c,a3 as q,Y as G,ap as ge,aI as $e,aF as Fe,aG as le,a as pe,aw as _,a5 as xe,$ as ee,ak as Se,ar as Ce,a0 as De,aL as fe,x as Be,ag as ae,q as He,L as qe,m as at,k as Pe,s as Ae,O as lt,D as J,d as D,a1 as Je,v as Ge,T as it,ah as Re,aA as Ie,j as ue,r as Ee,i as rt,au as ot,z as dt,p as Ve,aC as ct,az as de,w as ut,C as xt,aJ as pt,am as mt,y as ht,aM as ft,aK as Me,l as gt,n as je}from"./index-BcJqLDiY.js";import{l as bt}from"./listSkills-QORduPIk.js";import{T as wt}from"./Toggle-CBggPonH.js";import"./monaco-editor-BW5C4Iv1.js";function vt({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 l=s===a;return e.jsx("button",{type:"button",onClick:()=>n(a),className:`px-[18px] py-[7px] rounded-lg text-[13.5px] transition-colors ${l?"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 jt=15e3,Nt={paused:"bg-amber-950/60 border-amber-700/50 text-amber-200","launch-blocked":"bg-red-950/60 border-red-700/50 text-red-200",blocked:"bg-red-950/60 border-red-700/50 text-red-200",stalled:"bg-amber-950/60 border-amber-700/50 text-amber-200",saturated:"bg-bg-hi border-line text-fg-dim",idle:"bg-bg-hi border-line text-fg-dim",running:"bg-bg-hi border-line text-fg-dim"};function yt(t,s){var n;switch(t.kind){case"paused":return`paused: scheduler is paused (${t.reason??"manual"})`;case"launch-blocked":return`launch-blocked: ${t.agentType} jobs can't launch${(n=t.block)!=null&&n.kind?` (${t.block.kind})`:""}`;case"idle":return"idle: 0 pending";case"saturated":{const a=s!=null?`, oldest ${q(s)}`:"";return`saturated: ${t.totalSlots??"?"} slot(s) busy${a}`}case"blocked":{const a=t.blockedChains.length;return`blocked: ${t.pending} pending, ${t.dispatchable} dispatchable — ${a} chain${a===1?"":"s"} stuck behind a failed/skipped dependency`}case"stalled":return`stalled: no dispatch attempt in ${t.idleMs!=null?q(t.idleMs):"?"} with ${t.dispatchable} dispatchable`;case"running":default:return`running: ${t.runningCount} in flight, ${t.pending} pending`}}function Z({label:t,value:s,title:n}){return e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[12.5px] text-fg-faint whitespace-nowrap",title:n,children:[t," ",e.jsx("strong",{className:"text-fg font-mono text-[12.5px]",children:s})]})}function kt({scopeCwd:t}){const[s,n]=c.useState(null),[a,d]=c.useState(()=>Date.now());if(c.useEffect(()=>{let o=!0;const u=()=>{window.api.schedule.queueHealth(t).then(p=>{o&&n(p)})};u();const r=setInterval(u,jt);return()=>{o=!1,clearInterval(r)}},[t]),c.useEffect(()=>{const o=setInterval(()=>d(Date.now()),3e4);return()=>clearInterval(o)},[]),!s)return null;if(s.unknown)return e.jsxs("div",{"data-testid":"queue-health-header","data-verdict-kind":"unknown",className:"flex items-center gap-3 border rounded-xl px-4 py-2.5 text-[13px] bg-bg-hi border-line text-fg-faint",children:["Queue health: unknown — ",s.reason??"state unavailable"]});const l=s.verdict,i=s.slots;return e.jsxs("div",{"data-testid":"queue-health-header","data-verdict-kind":l.kind,className:`flex flex-col gap-2 border rounded-xl px-4 py-2.5 text-[13px] ${Nt[l.kind]}`,children:[e.jsx("div",{className:"font-medium",children:yt(l,s.oldestRunningAgeMs??null)}),e.jsxs("div",{className:"flex items-center gap-4 flex-wrap text-fg-dim",children:[e.jsx(Z,{label:"slots",value:`${i.inUse}/${i.total}`,title:`Machine-wide session pool (${i.source==="env"?"SM_SESSION_SLOTS override":"Home tab cap"}), not scoped to this project`}),e.jsx(Z,{label:"oldest running",value:s.oldestRunningAgeMs!=null?q(s.oldestRunningAgeMs):"—",title:"Across every project on this machine"}),e.jsx(Z,{label:"pending",value:String(l.pending)}),e.jsx(Z,{label:"dispatchable",value:String(l.dispatchable),title:"Pending rows whose dependsOn chain is fully satisfied right now"}),e.jsx(Z,{label:"needs_review",value:String(l.needsReviewCount)}),e.jsx(Z,{label:"last batch fired",value:G(s.lastRunAt?Date.parse(s.lastRunAt):null,a),title:"lastRunAt — only advances when tickQueue actually launches a job"}),e.jsx(Z,{label:"last dispatch attempt",value:G(s.lastDispatchAttemptAt?Date.parse(s.lastDispatchAttemptAt):null,a),title:"lastDispatchAttemptAt — advances every time the driver evaluates the queue, whether or not it launched anything"})]})]})}const St=5e3;let he=null,ce=null;async function Oe(t){const s=Date.now();return!(t!=null&&t.fresh)&&he&&s-he.at<St?he.result:ce||(ce=(async()=>{try{const n=await window.api.schedule.lintQueue();return he={result:n,at:Date.now()},n}finally{ce=null}})(),ce)}function ze({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 l=d.value===s;return e.jsxs("button",{type:"button",onClick:()=>n(d.value),className:`rounded-full ${a} text-[12.5px] border transition-colors ${l?"bg-accent text-white border-accent font-semibold":"bg-bg-hi text-fg-dim border-line hover:border-fg-faint font-medium"}`,children:[d.label,d.count!==void 0&&e.jsxs("span",{children:[" ",d.count]})]},d.value)})})}function $t(t){const s=new Map(t.map(i=>[i.slug,i])),n=new Map,a=new Set,d=[];function l(i){n.set(i,1),d.push(i);const o=s.get(i);for(const u of(o==null?void 0:o.dependsOn)??[]){if(!s.has(u))continue;const r=n.get(u);if(r===1){const p=d.indexOf(u);for(let m=p;m<d.length;m++)a.add(d[m])}else r===void 0&&l(u)}d.pop(),n.set(i,2)}for(const i of t)n.has(i.slug)||l(i.slug);return a}function Ct(t,s){return(t.dependsOn??[]).map(n=>{const a=s.get(n);return a?{slug:n,status:a.status,missing:!1,needsReview:a.status==="needs_review"}:{slug:n,status:null,missing:!0,needsReview:!1}})}function Pt(t,s,n){const a=new Set(t.map(r=>r.slug)),d=new Set;for(const r of t)for(const p of r.dependsOn??[])a.has(p)&&d.add(p);const l=new Map,i=[];for(const r of t){const p=n.has(r.slug)?void 0:(r.dependsOn??[]).find(m=>a.has(m)&&!n.has(m));p?(l.has(p)||l.set(p,[]),l.get(p).push(r)):i.push(r)}const o=(r,p)=>r.slug.localeCompare(p.slug);i.sort(o);for(const r of l.values())r.sort(o);function u(r,p,m){const g=Ct(r,s),v=n.has(r.slug);m.add(r.slug);const j=v?[]:(l.get(r.slug)??[]).filter(k=>!m.has(k.slug)).map(k=>u(k,p+1,m));return m.delete(r.slug),{row:r,depth:p,children:j,blockers:g,blocked:g.some(k=>!k.missing&&k.status!=="completed"),hasNeedsReviewBlocker:g.some(k=>k.needsReview),hasMissingDep:g.some(k=>k.missing),cycle:v,parallelEligible:(r.dependsOn??[]).length===0&&!d.has(r.slug)}}return i.map(r=>u(r,0,new Set))}function At(t,s,n){const a=new Map((n??t).map(r=>[r.slug,r])),d=$t(t),l=[],i=new Map,o=new Map;for(const r of t){const p=ge(r,s),m=p.epicId??"__none__";i.has(m)||(l.push(m),i.set(m,[]),o.set(m,{epicId:p.epicId,label:p.known&&p.label?p.label:p.epicId?`Epic ${p.epicId.slice(0,12)}…`:"No Epic",known:p.known})),i.get(m).push(r)}const u=l.map(r=>{const p=o.get(r),m=i.get(r),g=Pt(m,a,d),v={};for(const j of m){const k=j.status??"unknown";v[k]=(v[k]??0)+1}return{epicId:p.epicId,label:p.label,known:p.known,nodes:g,counts:v,total:m.length}});return u.sort((r,p)=>r.epicId===null?1:p.epicId===null?-1:r.known!==p.known?r.known?-1:1:r.label.localeCompare(p.label)),u}function Ue(t){const s=[],n=a=>{s.push(a);for(const d of a.children)n(d)};for(const a of t)n(a);return s}const Dt=5,Rt=1440*60*1e3,Qe="sm.scheduler.hiddenCompletedSlugs",Ne="sm.scheduler.focusedJobIndex",Ye="sm.scheduler.queueFilter";function We(t,s=60){const n=t.trim();return n.length<=s?n:`${n.slice(0,s-1)}…`}const It=["all","running","investigating","pending","completed","skipped","needs_review","failed","quarantined"];function Et(){try{const t=localStorage.getItem(Ye);if(!t)return{text:"",status:"all"};const s=JSON.parse(t);return{text:"",status:It.includes(s.status)?s.status:"all"}}catch{return{text:"",status:"all"}}}function Mt(t){try{localStorage.setItem(Ye,JSON.stringify({status:t.status}))}catch{}}function Ot(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=Se(a.cwd)??"";return a.title.toLowerCase().includes(n)||a.slug.toLowerCase().includes(n)||d.toLowerCase().includes(n)})}function Tt(){try{const t=localStorage.getItem(Qe);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 Te(t){try{localStorage.setItem(Qe,JSON.stringify([...t]))}catch{}}function Lt({scopeCwd:t=null,navigate:s}){const n=$e(h=>h.snapshot),a=c.useMemo(()=>!n||!t?n:{...n,jobs:n.jobs.filter(h=>h.cwd===t)},[n,t]),[d,l]=c.useState(null),[i,o]=c.useState(!1),[u,r]=c.useState(()=>Date.now()),[p,m]=c.useState(()=>Tt()),[g,v]=c.useState(!1),[j,k]=c.useState(()=>Et()),[N,$]=c.useState(!1),[S,b]=c.useState("queue"),w=c.useRef(null),[O,P]=c.useState(()=>{try{return Number(localStorage.getItem(Ne))||0}catch{return 0}}),[A,W]=c.useState(""),V=Fe();c.useEffect(()=>(window.api.schedule.health().then(l).catch(()=>{}),window.api.schedule.onState(()=>{window.api.schedule.health().then(l).catch(()=>{})})),[]),c.useEffect(()=>{if(!V)return;r(Date.now());const h=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(h)},[V]);const B=c.useMemo(()=>{if(!a)return 15e4;const h=[];for(const C of a.jobs)if(C.status==="completed"&&C.startedAt&&C.finishedAt){const I=Date.parse(C.finishedAt)-Date.parse(C.startedAt);I>0&&h.push(I)}return h.length===0?15e4:h.reduce((C,I)=>C+I,0)/h.length},[a]),ie=c.useRef(new Map);c.useEffect(()=>{if(!a)return;const h=[];for(const C of a.jobs){const I=ie.current.get(C.slug);I&&I!==C.status&&h.push(`${C.title}: ${I} → ${C.status}`),ie.current.set(C.slug,C.status)}h.length>0&&W(h.join("; "))},[a]);const re=c.useMemo(()=>{var C;const h=new Map;for(const I of((C=a==null?void 0:a.lastTick)==null?void 0:C.holds)??[])h.set(I.slug,I);return h},[a==null?void 0:a.lastTick]),te=le(h=>h.sessions),be=c.useMemo(()=>a?At(a.jobs,te,n==null?void 0:n.jobs):[],[a,te,n]),we=c.useCallback(h=>{var ne;const C=(ne=w.current)==null?void 0:ne.querySelectorAll("[data-job-row]");if(!C||C.length===0)return;const I=Array.from(C),T=I.findIndex(L=>L.dataset.jobIndex===String(O)),U=L=>{const X=I[L];if(!X)return;const Q=Number(X.dataset.jobIndex);P(Q);try{localStorage.setItem(Ne,String(Q))}catch{}X.focus()};h.key==="ArrowDown"?(h.preventDefault(),U(T===-1?0:Math.min(T+1,I.length-1))):h.key==="ArrowUp"&&(h.preventDefault(),U(T===-1?I.length-1:Math.max(T-1,0)))},[O]),ve=c.useCallback(h=>{P(h);try{localStorage.setItem(Ne,String(h))}catch{}},[]);if(!a)return null;if(S==="supervisor")return e.jsx(rs,{supervisorConfig:a.config.supervisor,onSetConfig:h=>window.api.schedule.setConfig({supervisor:h}),onBack:()=>b("queue")});const{config:me,jobs:F,paused:se,lastRunAt:K,nextReset:oe,effectiveConcurrency:R}=a;if(F.length===0)return e.jsx(Bt,{navigate:s});const x={pending:0,running:0,investigating:0,completed:0,needs_review:0,failed:0};for(const h of F)h.status in x&&x[h.status]++;const f=F.filter(h=>h.status==="running"),y=Ht({snap:a,now:u,avgDurationMs:B,runningJobs:f}),E=Ot(F,j),M=qt(E),{inline:H,collapsedCount:z}=Jt(E,p,u,g),Ke=Yt(H,F,M,B,y.kind,u),Xe=()=>{const h=new Set(p);for(const C of F)(C.status==="completed"||C.status==="failed")&&h.add(C.slug);m(h),Te(h)},Ze=async()=>{const h=F.filter(T=>T.status!=="running").length;if(h===0)return;const C=`Archive ${h} non-running PRD${h===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(C))return;const I=await window.api.schedule.clearQueue();I.ok||_.error(`Clear queue failed: ${I.error??"unknown error"}`)},et=()=>{m(new Set),Te(new Set),v(!1)},tt=H.some(h=>h.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:A}),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 ${Gt(y.kind)}`,title:y.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 ${Vt(y.kind)}`,children:e.jsx(pe,{name:"clock",size:19})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] text-fg truncate",children:Ut(Qt(y.line1,a.utilization))}),y.line2&&e.jsx("div",{className:"text-[12px] text-fg-faint font-mono mt-0.5 truncate",children:y.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 ",G(K?Date.parse(K):null,u)]}),!se&&e.jsx("button",{type:"button",onClick:()=>window.api.schedule.pause(),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:"Stop NEW dispatch. Running jobs are not killed.",children:"Pause"}),y.action&&e.jsx("button",{type:"button",onClick:y.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:y.action.title,children:y.action.label})]}),d&&d.consecutiveFailures>5&&d.lastFailureKind==="meter_rate_limited"&&!se&&!N&&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"," ",G(d.lastPollAt,u),". Firing on a conservative estimate until it recovers."]}),e.jsx("button",{type:"button",onClick:()=>$(!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:me.firePolicy??"when-available",onChange:h=>window.api.schedule.setConfig({firePolicy:h.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:h=>{window.api.schedule.setSessionSlots(Number(h.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"})]}),(me.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:me.utilizationThreshold??90,onChange:h=>window.api.schedule.setConfig({utilizationThreshold:Number(h.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(_.fromOutcome).catch(()=>_.error("Failed to fire batch")),disabled:x.pending===0&&x.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(_.fromOutcome).catch(()=>_.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"})]})]}),f.length>0&&(()=>{const h=(R==null?void 0:R.cap)??5,C=F.filter(I=>I.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:[f.length,"/",h," running"]}),C>0&&e.jsxs("span",{className:"text-fg-faint",children:["+",C," ready in this group"]})]})})(),F.length>0&&e.jsx(is,{filter:j,onChange:h=>{k(h),Mt(h)}}),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:[E.length," job",E.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:[x.pending,"p · ",x.running,"r · ",x.completed,"d",x.failed>0&&e.jsxs("span",{className:"text-accent",children:[" · ",x.failed,"f"]})]}),tt&&e.jsx("button",{type:"button",onClick:Xe,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:Ze,disabled:F.every(h=>h.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…"})]})]}),H.length===0&&z===0&&e.jsx("div",{className:"px-[18px] py-6 text-[13px] text-fg-faint italic",children:"no matching jobs"}),e.jsx("div",{ref:w,role:"list","aria-label":"Job queue",onKeyDown:we,children:(()=>{const h=new Set(H.map(T=>T.slug));let C=0;return be.map(T=>{const U=T.nodes.map(L=>({rootSlug:L.row.slug,label:L.row.title||L.row.slug,terminals:Wt(L)})),ne=T.nodes.map(L=>{const X=Ue([L]).filter(Q=>h.has(Q.row.slug)).map(Q=>({node:Q,listIndex:C++}));return{headRootSlug:L.row.slug,rows:X}}).filter(L=>L.rows.length>0);return{section:T,heads:ne,headChoices:U}}).filter(T=>T.heads.length>0).map(({section:T,heads:U,headChoices:ne})=>e.jsx(Kt,{section:T,children:U.map(({headRootSlug:L,rows:X},Q)=>e.jsxs("div",{"data-testid":"backlog-head-group",children:[U.length>1&&e.jsxs("div",{className:"px-[18px] pt-2.5 pb-1 text-[11px] font-mono uppercase tracking-wide text-fg-faint bg-bg-elev/30 border-t border-line/60","data-testid":"backlog-head-label",children:["Plan ",Q+1," of ",U.length]}),X.map(({node:Y,listIndex:st})=>e.jsx(as,{job:Y.row,backlog:Y,eta:Ke.get(Y.row.slug)??null,elapsedMs:Y.row.status==="running"&&Y.row.startedAt?u-Date.parse(Y.row.startedAt):null,avgDurationMs:B,listIndex:st,hold:re.get(Y.row.slug),onFocused:ve,headChoices:ne.filter(nt=>nt.rootSlug!==L)},Y.row.slug))]},L))},T.epicId??"__none__"))})()}),z>0&&e.jsxs("button",{type:"button",onClick:()=>v(h=>!h),className:"w-full text-left text-[12px] text-fg-faint hover:text-fg-dim px-[18px] py-3 border-t border-line",title:g?"Re-collapse old/cleared completed":"Show all completed (incl. cleared and >24h)",children:[g?"▾":"▸"," ",z," more completed",e.jsx("span",{className:"ml-1.5 font-mono text-[11.5px] text-fg-faint",children:"· fresh & capped at 5 shown inline"}),p.size>0&&e.jsx("span",{className:"ml-2 underline",onClick:h=>{h.stopPropagation(),et()},children:"un-hide"})]})]}),e.jsx(ds,{snap:a,health:d,now:u,open:i,setOpen:o}),!se&&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:[oe&&e.jsxs("span",{title:`next 5h reset: ${oe}`,children:["reset ",q(Date.parse(oe)-u)]}),K&&e.jsxs("span",{className:"ml-2",title:K,children:["last run ",q(u-Date.parse(K))," ago"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>b("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 _t=[{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 Bt({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:_t.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 Ht({snap:t,now:s,avgDurationMs:n,runningJobs:a}){const{config:d,jobs:l,paused:i,nextReset:o,utilization:u,effectiveConcurrency:r}=t;let p=0,m=0;for(const $ of l)$.status==="pending"?p++:$.status==="completed"&&m++;const g=a.length,v=p+g,j=(r==null?void 0:r.cap)??5;if(g>0){const $=a.reduce((P,A)=>(P.startedAt??"")<(A.startedAt??"")?P:A),S=$.startedAt?s-Date.parse($.startedAt):0,b=m+g,w=m+v,O=g>1?` · ${g}/${j} parallel`:"";return{kind:"running",line1:`Running ${b}/${w}${O} · ${xe(S)}`,line2:g===1?$.title:a.map(P=>P.title).join(", "),tooltip:a.map(P=>`${P.slug} (g${P.parallelGroup})`).join("; ")}}if(i){const $=i.resumeAt?Date.parse(i.resumeAt)-s:null;return{kind:"paused",line1:{rate_limit:"Paused — tokens exhausted",auth:"Paused — authentication failed",network:"Paused — network unreachable",reset_failure:"Paused — billing data unavailable",manual:"Paused — manual (you paused the queue)"}[i.reason]??`Paused — ${i.reason}`,line2:i.reason==="auth"?"Run `claude` in any terminal to refresh credentials, then Resume":$!==null&&$>0?`auto-resume ${ee(Date.parse(i.resumeAt))} (in ${q($)})`:i.resumeAt?"resuming…":"no auto-resume scheduled",tooltip:i.resumeAt??"",action:{label:"Resume",onClick:()=>window.api.schedule.resume(),title:"Clear the pause and resume queue immediately"}}}if(v===0)return{kind:"idle",line1:"No work queued",line2:null};const k=d.firePolicy??"when-available";if(k==="manual")return{kind:"manual",line1:`Manual · ${p} pending`,line2:"click Fire next batch now to fire",action:{label:"Fire next batch now",onClick:()=>window.api.schedule.forceTick().then(_.fromOutcome).catch(()=>_.error("Failed to fire batch")),title:"Bypasses the billing-usage poll. Use when the meter is rate-limited or you want immediate progress."}};if(k==="on-reset"){if(!o)return{kind:"on-reset",line1:"On-reset · waiting for billing data",line2:null};const $=Date.parse(o)+d.offsetMinutes*6e4,S=$-s;return{kind:"on-reset",line1:`On-reset · ${p} pending`,line2:S>0?`fires ${ee($)} (in ${q(S)})`:"firing now…"}}const N=d.utilizationThreshold??90;if(u==null)return{kind:"auto-soon",line1:`Auto · ${p} pending`,line2:"checking token availability…"};if(u>=N){const $=o?Date.parse(o)-s:null;return{kind:"auto-throttled",line1:`Auto · throttled (util ${u.toFixed(0)}% ≥ ${N}%)`,line2:$&&$>0?`next reset ${ee(Date.parse(o))} (in ${q($)})`:"will fire when usage drops"}}return{kind:"auto-soon",line1:`Auto · ${p} pending · util ${u.toFixed(0)}%`,line2:"fires within 2 min (poll cycle)"}}function qt(t){const s=new Map(t.map(l=>[l.slug,l])),n=l=>(l.dependsOn??[]).filter(i=>{var o;return((o=s.get(i))==null?void 0:o.status)!=="completed"}).length,a=t.filter(l=>l.status==="running"||l.status==="pending").sort((l,i)=>n(l)-n(i)||l.slug.localeCompare(i.slug)),d=new Map;return a.forEach((l,i)=>d.set(l.slug,i)),d}function Jt(t,s,n,a){if(a)return{inline:t,collapsedCount:0};const d=t.filter(r=>r.status==="completed").sort((r,p)=>{const m=r.finishedAt?Date.parse(r.finishedAt):0;return(p.finishedAt?Date.parse(p.finishedAt):0)-m}),l=new Set;let i=0;for(const r of d){if(i>=Dt)break;s.has(r.slug)||r.finishedAt&&n-Date.parse(r.finishedAt)>Rt||(l.add(r.slug),i++)}const o=[];let u=0;for(const r of t){if(r.status==="failed"&&s.has(r.slug)){u++;continue}if(r.status!=="completed"){o.push(r);continue}l.has(r.slug)?o.push(r):u++}return{inline:o,collapsedCount:u}}function Gt(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 Vt(t){return t==="running"||t==="auto-soon"?"text-accent":t==="idle"?"text-sage":t==="paused"||t==="auto-throttled"?"text-butter":"text-fg-faint"}const zt=["Running","Paused","Manual","On-reset","Auto"];function Ut(t){for(const s of zt)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 Qt(t,s){return s==null||t.includes("util")?t:`${t} · util ${Math.round(s)}%`}function Yt(t,s,n,a,d,l){const i=new Map;if(d==="paused"||d==="manual"||d==="auto-throttled"){for(const r of t)i.set(r.slug,null);return i}const o=s.find(r=>r.status==="running"&&r.startedAt),u=o!=null&&o.startedAt?l-Date.parse(o.startedAt):0;for(const r of t){if(r.status!=="pending"){i.set(r.slug,null);continue}const p=n.get(r.slug)??0;let m=p*a;p>0&&(m-=Math.min(a,u)),i.set(r.slug,m<=5e3?"~now":`~${xe(m)}`)}return i}function Wt(t){return Ue([t]).filter(s=>s.children.length===0).map(s=>s.row.slug)}function Kt({section:t,children:s}){const[n,a]=c.useState(!0),d=Object.entries(t.counts).map(([l,i])=>`${i} ${l.replace(/_/g," ")}`).join(" · ");return e.jsxs("div",{className:"border-t border-line","data-testid":"backlog-epic-section","data-epic-id":t.epicId??"",children:[e.jsxs("button",{type:"button",onClick:()=>a(l=>!l),className:"w-full flex items-center gap-2.5 px-[18px] py-2.5 bg-bg-elev/60 hover:bg-bg-elev text-left","aria-expanded":n,title:t.label,children:[e.jsx("span",{className:`text-fg-faint inline-flex shrink-0 transition-transform duration-150 ${n?"rotate-90":""}`,"aria-hidden":"true",children:e.jsx(pe,{name:"chevron",size:12})}),e.jsx("span",{className:"font-serif text-[14.5px] font-semibold text-fg truncate","data-testid":"backlog-epic-label",children:t.label}),e.jsxs("span",{className:"font-mono text-[11px] text-fg-faint shrink-0",children:[t.total," PRD",t.total===1?"":"s"]}),e.jsx("span",{className:"font-mono text-[11px] text-fg-faint truncate",children:d})]}),n&&s]})}const Xt=[],Zt=[],es={depth:0,blockers:Xt,blocked:!1,hasNeedsReviewBlocker:!1,hasMissingDep:!1,cycle:!1,parallelEligible:!1};function ts(t){return t.missing?`${t.slug} (missing)`:t.needsReview?`${t.slug} (needs review)`:`${t.slug} (${(t.status??"unknown").replace(/_/g," ")})`}function ss(t){return t.missing?"text-accent":t.needsReview?"text-butter font-semibold":t.status==="completed"?"text-sage":"text-amber-400/90"}function ns({job:t,eta:s,elapsedMs:n,avgDurationMs:a,listIndex:d,onFocused:l,hold:i,backlog:o=es,headChoices:u=Zt}){const[r,p]=c.useState(!1),[m,g]=c.useState(!1),v=le(A=>A.sessions),j=c.useMemo(()=>ge(t,v),[t,v]),k=j.known&&j.epicId?v[j.epicId]:null,N=c.useCallback(A=>{Ce(A),window.dispatchEvent(new CustomEvent("sm:navigate",{detail:"terminal"}))},[]),$=t.status==="running",S=t.status==="failed";let b=null;$&&n!==null?b=`${De(n)} elapsed`:t.status==="completed"&&t.startedAt&&t.finishedAt?b=`took ${xe(Date.parse(t.finishedAt)-Date.parse(t.startedAt))}`:s&&(b=s);const w=t.error??null,O=S&&w?w.split(`
|
|
4
|
-
`)[0]:t.status==="needs_review"&&t.verifierVerdict?fe(t.verifierVerdict):null,P=$&&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,"data-depth":o.depth,onClick:()=>p(A=>!A),onFocus:()=>l(d),style:o.depth>0?{paddingLeft:18+o.depth*20}:void 0,className:`w-full text-left grid grid-cols-[116px_1fr_auto_auto] items-center gap-4 px-[18px] py-3.5 hover:bg-bg/40 focus:outline-none focus:ring-1 focus:ring-accent focus:ring-inset ${r?"bg-bg-elev/40":""}`,"aria-expanded":r,"aria-label":`${ae(t.slug)?`PRD ${ae(t.slug)}, `:""}${t.title}, ${t.status}${b?`, ${b}`:""}`,title:t.title,children:[e.jsx(Be,{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:[ae(t.slug)&&e.jsx(He,{n:ae(t.slug)}),t.title,e.jsx(qe,{leaked:t.leakedDescendants}),e.jsx(at,{count:t.leftoverCount,truncated:t.leftoverPathsTruncated,salvagePatch:t.salvagePatch}),o.parallelEligible&&e.jsx("span",{"data-testid":"job-row-parallel-eligible",title:"No dependsOn, and nothing in this Epic depends on it — can run any time a slot is free",className:"text-[10px] font-semibold uppercase tracking-wide text-sage/90 bg-sage/10 border border-sage/30 rounded px-1.5 py-0.5",children:"parallel"})]}),o.cycle&&e.jsxs("div",{className:"text-[12.5px] mt-0.5 text-accent font-mono","data-testid":"job-row-cycle-warning",children:["⚠ dependsOn cycle — ",o.blockers.map(A=>A.slug).join(" ↔ ")||"self-referencing"]}),!o.cycle&&o.blockers.length>0&&e.jsxs("div",{className:"text-[12.5px] mt-0.5 font-mono","data-testid":"job-row-blockers",children:[e.jsx("span",{className:o.blocked||o.hasMissingDep?"text-amber-400/90":"text-fg-faint",children:o.blocked||o.hasMissingDep?"blocked by ":"depends on "}),o.blockers.map((A,W)=>e.jsxs("span",{className:ss(A),children:[W>0&&", ",ts(A)]},A.slug))]}),O&&e.jsx("div",{className:`text-[12.5px] mt-0.5 ${S?"text-accent/80":"text-fg-faint"}`,children:O}),i&&e.jsx("div",{className:"text-[12.5px] mt-0.5 text-amber-400/90 font-mono","data-testid":"job-row-hold",children:i.dep?e.jsxs(e.Fragment,{children:["held · waiting on ",i.dep," (",i.depStatus,")"]}):e.jsxs(e.Fragment,{children:["held · ",i.reason??"launch blocked"]})}),!i&&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(Pe,{epicId:j.epicId,label:j.label?We(j.label):null,onOpen:N,testId:"job-row-prompt-session-chip",className:"mt-0.5"})]}),e.jsx(Ae,{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(lt,{status:t.status,overrun:t.overrun}),b,e.jsx("span",{className:`text-fg-faint inline-flex transition-transform duration-150 ${r?"rotate-90":""}`,"aria-hidden":"true",children:e.jsx(pe,{name:"chevron",size:14})})]})]}),$&&!r&&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,P*100)}%`}})}),r&&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(J,{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:fe(t.verifierVerdict)}),t.leakedDescendants&&t.leakedDescendants.length>0&&e.jsx(D,{k:"leaked",v:Je(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}),w&&e.jsx(D,{k:"error",v:w.split(`
|
|
5
|
-
`)[0],wrap:!0})]}),t.statusHistory&&t.statusHistory.length>0&&e.jsx(J,{label:"History",children:e.jsx("div",{className:"grid gap-1",children:t.statusHistory.map((A,W)=>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:[" · ",ee(Date.parse(A.at))]})]}),A.reason&&e.jsx("div",{className:"text-fg-faint break-words",children:A.reason})]},W))})}),e.jsxs(J,{label:"Timing",children:[e.jsx(D,{k:"started",v:t.startedAt?ee(Date.parse(t.startedAt)):"—"}),e.jsx(D,{k:"finished",v:t.finishedAt?ee(Date.parse(t.finishedAt)):"—"}),e.jsx(D,{k:"duration",v:t.startedAt&&t.finishedAt?xe(Date.parse(t.finishedAt)-Date.parse(t.startedAt)):$&&n!==null?De(n):"—"})]}),e.jsxs(J,{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:j.label??j.epicId??"—",wrap:!0}),e.jsx(D,{k:"session id",v:j.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(J,{label:"Actions",children:e.jsxs("div",{className:"flex flex-col gap-1.5 items-start",children:[k&&e.jsx("button",{type:"button","data-testid":"job-row-prompt-session-link",title:k.goalText,onClick:()=>N(k.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:()=>g(!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(_.fromOutcome).catch(()=>_.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 →"}),t.disposition&&(t.status==="pending"||t.status==="quarantined")&&e.jsx(ls,{job:t,headChoices:u})]})})]}),m&&t.runId&&e.jsx(Ge,{runId:t.runId,slug:t.slug,title:t.title||t.slug,onClose:()=>g(!1)})]})}const as=c.memo(ns);function ls({job:t,headChoices:s}){const[n,a]=c.useState(!1),d=c.useCallback((l,i)=>{a(!0),window.api.schedule.setPrdDisposition({slug:t.slug,cwd:t.cwd??void 0,disposition:l,dependsOn:i}).then(_.fromOutcome).catch(()=>_.error("Failed to change disposition")).finally(()=>a(!1))},[t.slug,t.cwd]);return t.disposition!=="append"&&s.length===0?null:e.jsxs("select",{"data-testid":"job-row-disposition-control",disabled:n,value:"",onChange:l=>{const i=l.target.value;if(i==="__new-head__")d("new-head");else if(i){const o=s.find(u=>u.rootSlug===i);o&&d("append",o.terminals)}},className:"text-[13px] font-semibold text-fg-dim hover:text-fg bg-transparent border border-line/60 rounded px-1.5 py-0.5 cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",title:"Change this wave's relationship to the rest of the Epic's plan",children:[e.jsx("option",{value:"",disabled:!0,children:"change disposition…"}),t.disposition==="append"&&e.jsx("option",{value:"__new-head__",children:"promote to new head"}),s.map(l=>e.jsxs("option",{value:l.rootSlug,children:["attach behind: ",We(l.label,40)]},l.rootSlug))]})}function is({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(pe,{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(ze,{options:n,value:t.status,onChange:a=>s({...t,status:a})})]})}function rs({supervisorConfig:t,onSetConfig:s,onBack:n}){const[a,d]=c.useState([]),[l,i]=c.useState(()=>Date.now()),o=Fe();c.useEffect(()=>{if(!o)return;window.api.supervisor.getLog().then(d).catch(()=>{}),i(Date.now());const r=setInterval(()=>i(Date.now()),5e3);return()=>clearInterval(r)},[o]);const u={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:u.enabled,onChange:r=>s({enabled:r.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:u.intervalMinutes,onChange:r=>s({intervalMinutes:Number(r.target.value)}),className:"w-10 bg-bg border border-line rounded px-1 py-0.5 font-mono"}),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:u.maxConcurrentProbes,onChange:r=>s({maxConcurrentProbes:Number(r.target.value)}),className:"w-8 bg-bg border border-line rounded px-1 py-0.5 font-mono"})]}),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:u.probeStaleThresholdMinutes,onChange:r=>s({probeStaleThresholdMinutes:Number(r.target.value)}),className:"w-8 bg-bg border border-line rounded px-1 py-0.5 font-mono"}),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((r,p)=>e.jsx(os,{entry:r,now:l},`${r.ts}-${p}`))})]})]})}function os({entry:t,now:s}){const n=t.action!=="none",a=q(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 ds({snap:t,health:s,now:n,open:a,setOpen:d}){const[l,i]=c.useState(null),[o,u]=c.useState(!1),r=`${t.jobs.length}:${t.lastRunAt??""}`;c.useEffect(()=>{let b=!0;return u(!0),Oe().then(w=>{b&&i(w)}).catch(()=>{}).finally(()=>{b&&u(!1)}),()=>{b=!1}},[r]);let p=0,m=0;const g=l?l.reports.filter(b=>b.findings.length>0):[];for(const b of g)for(const w of b.findings)w.severity==="error"?p++:m++;const v=p===0&&m===0,j=l?v?`queue lint clear (${l.reports.length} scanned)`:`queue lint ${p} error${p===1?"":"s"}${m>0?`, ${m} warn${m===1?"":"s"}`:""}`:o?"scanning…":"idle",k=(s==null?void 0:s.consecutiveFailures)??0,N=s?`${k} poll failure${k===1?"":"s"} since boot`:null,$=k>0||((s==null?void 0:s.pauseReason)??null)!==null||!v,S=[N,j].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 ${$?"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:S.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: ",G(s.bootedAt,n)]}),e.jsxs("div",{children:["last poll: ",G(s.lastPollAt,n)," · ",s.lastPollOk?"ok":"failed"]}),s.backoffNextAt!==null&&s.backoffNextAt>n&&e.jsxs("div",{children:["retry in: ",q(s.backoffNextAt-n)]}),s.nextResetCached&&e.jsxs("div",{children:["cached reset: ",ee(Date.parse(s.nextResetCached))]}),s.runningJobs.length>0&&e.jsxs("div",{children:["running: ",s.runningJobs.map(b=>`${b.slug}(pid ${b.pid})`).join(", ")]})]}),l&&e.jsxs("div",{className:"space-y-1",children:[v?e.jsxs("div",{className:"text-sage",children:["✓ no issues in ",l.reports.length," PRD",l.reports.length!==1?"s":""]}):g.map(b=>e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-dim truncate",title:b.slug,children:b.slug}),b.findings.map((w,O)=>e.jsxs("div",{className:`pl-3 truncate ${w.severity==="error"?"text-accent/80":"text-butter/90"}`,title:w.snippet,children:[w.severity==="error"?"✗":"⚠"," L",w.line,": ",w.snippet]},`${b.slug}-${O}`))]},b.slug)),e.jsx("button",{type:"button",onClick:()=>{u(!0),Oe({fresh:!0}).then(i).catch(()=>{}).finally(()=>u(!1))},className:"text-fg-faint hover:text-fg-dim underline",children:o?"…":"rerun lint"})]})]})]})}new Set(it.map(t=>t.tag).filter(t=>t!=="discussion"));const cs=["title","cwd","estimateMinutes","parallelGroup","sourcePromptId","sourceTabId","tag","agentType","dependsOn","disposition"];function us(t,s){return!Array.isArray(t)||!Array.isArray(s)?!1:t.length===s.length&&t.every((n,a)=>n===s[a])}function xs(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 ps(t,s){var d;const n=[];for(const l of cs){const i=t[l];if(i==null||i===""||Array.isArray(i)&&i.length===0)continue;const o=(d=t._raw)==null?void 0:d[l];if(o&&(Array.isArray(i)?us(o.parsed,i):o.parsed===i)){n.push(o.line);continue}if(typeof i=="number"){n.push(`${l}: ${i}`);continue}if(Array.isArray(i)){n.push(`${l}: [${i.join(", ")}]`);continue}n.push(`${l}: ${xs(i)}`)}if(t.extras)for(const l of Object.keys(t.extras)){const i=t.extras[l];!i||!i.lines.length||n.push(i.lines.join(`
|
|
7
|
-
`))}return`---
|
|
8
|
-
${n.join(`
|
|
9
|
-
`)}
|
|
10
|
-
---
|
|
11
|
-
${s}`}function ye(t){return t.filter(s=>!s.archived)}function ms(t){Ce(t),window.dispatchEvent(new CustomEvent("sm:navigate",{detail:"terminal"}))}function ke({label:t,tip:s,onClick:n,disabled:a,primary:d}){return e.jsx(dt,{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 hs({scopeCwd:t=null}){const[s,n]=c.useState([]),[a,d]=c.useState(null),[l,i]=c.useState(null),[o,u]=c.useState(null),[r,p]=c.useState(!1),[m,g]=c.useState(!0),[v,j]=c.useState(new Set),[k,N]=c.useState(!1),[$,S]=c.useState(!1),[b,w]=c.useState(!1),[O,P]=c.useState(null);c.useEffect(()=>{let x=!0;return window.api.schedule.listPrds().then(f=>{x&&(n(ye(f)),g(!1))}).catch(f=>{x&&(g(!1),_.error(`Scheduler: failed to load PRD list — ${f instanceof Error?f.message:"unknown error"}`))}),()=>{x=!1}},[]);const A=$e(x=>x.snapshot),W=le(x=>x.sessions);c.useEffect(()=>{A&&d(A)},[A]);const V=c.useMemo(()=>[...s].filter(x=>!t||x.cwd===t).sort((x,f)=>f.mtimeMs-x.mtimeMs||x.slug.localeCompare(f.slug)),[s,t]);c.useEffect(()=>{const x=ot();x&&i(x);const f=y=>i(y.detail);return window.addEventListener("sm:select-prd",f),()=>window.removeEventListener("sm:select-prd",f)},[]);const B=c.useMemo(()=>(a==null?void 0:a.jobs.find(x=>x.slug===l))??null,[a,l]),ie=Re(B);function re(x){var y;const f=(y=s.find(E=>E.slug===x))==null?void 0:y.cwd;return f?`${f}/session-manager-operations/scheduler/prds/${x}.md`:null}c.useEffect(()=>{if(!l)return;const x=re(l);x&&Ie.getState().openFile(x)},[l,s]);function te(x){i(x),u(null),p(!1)}function be(){i(null)}async function we(){if(!l)return;if(!(B!=null&&B.runId)){u("no log available (job has not run yet)"),p(f=>!f);return}const x=await window.api.schedule.readLog(B.runId,l);u(x.ok?x.text??"":`error: ${x.error}`),p(f=>!f)}if(m)return e.jsx(ue,{title:"loading PRDs…"});const ve=x=>{j(f=>{const y=new Set(f);return y.has(x)?y.delete(x):y.add(x),y})};!(V.length>0&&V.every(x=>v.has(x.slug)))&&V.some(x=>v.has(x.slug));const F=()=>j(new Set);async function se(){try{const x=await window.api.schedule.listPrds();n(ye(x))}catch{}}async function K(){const x=`new-prd-${Date.now()}`,f=ps({title:"New PRD",cwd:"",estimateMinutes:60,parallelGroup:99},`## Task
|
|
12
|
-
|
|
13
|
-
Describe the task here.
|
|
14
|
-
`);try{const y=await window.api.schedule.writePrd(x,f);if(!y.ok){_.error(`Failed to create PRD: ${y.error}`);return}const E=await window.api.schedule.listPrds();n(ye(E)),te(x)}catch(y){_.error(`Failed to create PRD: ${y instanceof Error?y.message:String(y)}`)}}async function oe(){var x;w(!0),P(null);try{const f=[...v],y=await window.api.schedule.archivePrds(f);if(!y.ok)P(y.error??"archive failed");else{const E=((x=y.results)==null?void 0:x.filter(M=>!M.ok))??[];E.length>0&&_.warn(`Archive: ${E.length} of ${y.results.length} PRD${E.length===1?"":"s"} failed to move`),F(),N(!1),await se()}}catch(f){P(f instanceof Error?f.message:String(f))}finally{w(!1)}}async function R(x,f){w(!0),P(null);try{const y=[];for(const M of v){const H={slug:M};x!==null&&(H.parallelGroup=x),f!==null&&(H.estimateMinutes=f),y.push(H)}const E=await window.api.schedule.retagPrds(y);if(!E.ok)P(E.error??"retag failed");else{F(),S(!1),await se();for(const M of E.results)if(M.newSlug&&M.newSlug!==M.slug){const H=re(M.slug),z=re(M.newSlug);H&&z&&Ie.getState().renameOpenFile(H,z)}l&&E.results.some(M=>M.slug===l&&M.newSlug&&M.newSlug!==M.slug)&&i(null)}}catch(y){P(y instanceof Error?y.message:String(y))}finally{w(!1)}}return e.jsxs(e.Fragment,{children:[l?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:be,className:"text-[11px] text-fg-faint hover:text-fg",children:"← PRDs"}),e.jsx("span",{className:"font-mono text-xs text-fg-dim truncate",children:l}),e.jsx(Ee,{status:ie}),e.jsx("div",{className:"flex-1"}),e.jsx(ke,{label:"Reset",tip:"Reset failed job to pending",onClick:()=>{window.api.schedule.resetJob(l)},disabled:ie!=="failed"}),e.jsx(ke,{label:"Run now",tip:"Run all pending jobs immediately",onClick:()=>{window.api.schedule.runNow()}}),e.jsx(ke,{label:r?"Hide log":"Last run log",tip:"Toggle most recent run log",onClick:we})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(rt,{})}),r&&o!==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",B!=null&&B.runId?` — ${B.runId}`:""]}),e.jsx("button",{onClick:()=>p(!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:o})]})]}):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:K,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:()=>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:"Archive…"}),e.jsx("button",{type:"button",onClick:()=>S(!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:F,className:"text-xs px-3 py-1.5 rounded border border-line text-fg-dim hover:text-fg hover:bg-bg-hi",children:"Clear"})]}),V.length===0?e.jsx(ue,{title:"no PRDs found"}):e.jsx("div",{className:"grid gap-3",children:V.map(x=>{const f=a==null?void 0:a.jobs.find(z=>z.slug===x.slug),y=Re(f),E=ge({epicId:x.epicId??(f==null?void 0:f.epicId)??null,sourcePromptId:x.sourcePromptId??(f==null?void 0:f.sourcePromptId)??null,sourceTabId:(f==null?void 0:f.sourceTabId)??null},W),M=(f==null?void 0:f.status)==="running",H=(f==null?void 0:f.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(x.slug),onChange:()=>ve(x.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:[ae(x.slug)&&e.jsx(He,{n:ae(x.slug)}),e.jsx("button",{type:"button",onClick:()=>te(x.slug),className:"font-serif text-[18px] font-semibold text-fg leading-tight hover:underline text-left",children:x.title||x.slug}),e.jsx(Ee,{status:y}),(f==null?void 0:f.status)&&e.jsx("span",{className:"sr-only",children:f.status})]}),e.jsxs("div",{className:"flex items-center gap-4 font-mono text-xs text-fg-faint flex-wrap",children:[e.jsx(Ae,{cwd:x.cwd}),e.jsx(Pe,{epicId:E.epicId,label:E.label,onOpen:ms}),x.estimateMinutes!=null&&e.jsxs("span",{children:[x.estimateMinutes,"m"]}),e.jsxs("span",{className:"opacity-60",title:"parallelGroup — a unique-per-PRD display hint, never an ordering barrier. dependsOn is the real ordering primitive.",children:["g",x.parallelGroup]}),x.dependsOn&&x.dependsOn.length>0&&e.jsxs("span",{title:`depends on: ${x.dependsOn.join(", ")}`,children:["⛓ ",x.dependsOn.length," dep",x.dependsOn.length===1?"":"s"]}),e.jsxs("span",{children:["edited ",G(x.mtimeMs,Date.now())]})]}),e.jsx("button",{type:"button",onClick:()=>te(x.slug),className:"mt-1.5 font-mono text-[11px] text-fg-faint hover:text-fg-dim leading-none",children:x.slug}),H&&e.jsxs("div",{className:"mt-3 space-y-2",children:[(f==null?void 0:f.verifierVerdict)&&e.jsxs("div",{className:"text-xs text-fg-faint",children:["verdict: ",e.jsx("span",{className:"font-mono",children:fe(f.verifierVerdict)})]}),e.jsx("button",{type:"button",onClick:()=>window.api.schedule.resetJob(x.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:M,className:"bg-fg text-bg rounded-lg px-[18px] py-2 text-[13px] font-semibold whitespace-nowrap disabled:opacity-50",children:M?"Running…":"Queue job"})})]},x.slug)})})]}),e.jsx(fs,{open:k,count:v.size,busy:b,onClose:()=>N(!1),onConfirm:oe}),e.jsx(gs,{open:$,count:v.size,busy:b,onClose:()=>S(!1),onConfirm:R})]})}function fs({open:t,count:s,busy:n,onClose:a,onConfirm:d}){return e.jsxs(Ve,{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 gs({open:t,count:s,busy:n,onClose:a,onConfirm:d}){const[l,i]=c.useState(""),[o,u]=c.useState(""),[r,p]=c.useState(null);c.useEffect(()=>{t&&(i(""),u(""),p(null))},[t]);function m(){p(null);let g=null,v=null;if(l.trim()){const j=Number(l);if(!Number.isInteger(j)||j<0||j>999){p("parallelGroup must be 0–999");return}g=j}if(o.trim()){const j=Number(o);if(!Number.isInteger(j)||j<=0){p("estimateMinutes must be a positive integer");return}v=j}if(g===null&&v===null){p("set at least one field");return}d(g,v)}return e.jsxs(Ve,{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:l,onChange:g=>i(g.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:o,onChange:g=>u(g.target.value),placeholder:"(unchanged)",className:"flex-1 bg-bg border border-line rounded px-2 py-1 font-mono text-xs"})]})]}),r&&e.jsx("div",{className:"mt-2 text-[10px] text-red-300",children:r}),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:m,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 bs(t){Ce(t),window.dispatchEvent(new CustomEvent("sm:navigate",{detail:"terminal"}))}function Le(t){return t?t.slice(0,10):""}const ws=[{value:"all",label:"All"},{value:"completed",label:"Completed"},{value:"skipped",label:"Skipped"},{value:"failed",label:"Failed"}];function vs({scopeCwd:t=null}){const[s,n]=c.useState(null),[a,d]=c.useState(!0),[l,i]=c.useState(""),[o,u]=c.useState(""),[r,p]=c.useState(""),[m,g]=c.useState("all");c.useEffect(()=>{d(!0),window.api.schedule.getHistory().then(N=>n(N)).catch(N=>n({ok:!1,jobs:[],error:N instanceof Error?N.message:String(N)})).finally(()=>d(!1))},[]);const v=c.useMemo(()=>{if(!(s!=null&&s.jobs))return[];const N=new Set;for(const $ of s.jobs){const S=Se($.cwd);S&&N.add(S)}return[...N].sort()},[s]),j=c.useMemo(()=>s!=null&&s.jobs?s.jobs.filter(N=>!(t&&N.cwd!==t||m!=="all"&&N.status!==m||l&&Se(N.cwd)!==l||o&&Le(N.finishedAt)<o||r&&Le(N.finishedAt)>r)):[],[s,m,l,o,r,t]);if(a)return e.jsx(ue,{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(ue,{title:"No history yet",hint:"Completed and failed jobs appear here."});const k=m!=="all"||!!l||!!o||!!r;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(ze,{options:ws,value:m,onChange:g,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:l,onChange:N=>i(N.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(N=>e.jsx("option",{value:N,children:N},N))]}),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:o,onChange:N=>u(N.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:r,onChange:N=>p(N.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:[j.length," / ",s.jobs.length]}),k&&e.jsx("button",{type:"button",onClick:()=>{g("all"),i(""),u(""),p("")},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:j.length===0?e.jsx(ue,{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:[j.length," job",j.length!==1?"s":""]})}),j.map(N=>e.jsx(js,{job:N},`${N.slug}-${N.finishedAt??""}`))]})})]})}function js({job:t}){const[s,n]=c.useState(!1),[a,d]=c.useState(!1),l=le(g=>g.sessions),i=c.useMemo(()=>ge(t,l),[t,l]),o=t.startedAt&&t.finishedAt?Date.parse(t.finishedAt)-Date.parse(t.startedAt):null,u=t.startedAt?new Date(t.startedAt).toLocaleString():"—",r=t.finishedAt?new Date(t.finishedAt).toLocaleString():"—",p=o!==null?xe(o):"—",m=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(g=>!g),"aria-expanded":s,children:[e.jsx(Be,{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(qe,{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}),i.epicId&&e.jsx("span",{className:"flex mt-0.5",children:e.jsx(Pe,{epicId:i.epicId,label:i.label,onOpen:bs})})]}),e.jsx(Ae,{cwd:t.cwd}),e.jsxs("span",{className:"inline-flex items-center gap-2.5 font-mono text-xs text-fg-faint whitespace-nowrap",children:[p,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(J,{label:"Status",children:[e.jsx(D,{k:"result",v:m}),e.jsx(D,{k:"state",v:t.status.replace("_"," ")}),t.verifierVerdict&&e.jsx(D,{k:"verifier",v:fe(t.verifierVerdict)}),t.leakedDescendants&&t.leakedDescendants.length>0&&e.jsx(D,{k:"leaked",v:Je(t.leakedDescendants),wrap:!0})]}),e.jsxs(J,{label:"Timing",children:[e.jsx(D,{k:"started",v:u}),e.jsx(D,{k:"finished",v:r}),e.jsx(D,{k:"duration",v:p})]}),e.jsxs(J,{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:i.label??i.epicId??"—",wrap:!0}),t.cwd&&e.jsx(D,{k:"cwd",v:t.cwd,wrap:!0})]}),e.jsx(J,{label:"Actions",children:e.jsxs("div",{className:"flex flex-col gap-2 items-start",children:[t.runId&&e.jsx("button",{type:"button",onClick:g=>{g.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:g=>{g.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(Ge,{runId:t.runId,slug:t.slug,title:t.title||t.slug,onClose:()=>d(!1)})]})}function Ns(t){return t?Object.values(t).reduce((s,n)=>s+(n??[]).reduce((a,d)=>{var l;return a+(((l=d.hooks)==null?void 0:l.length)??0)},0),0):0}function ys(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 ks({navigate:t}){const s=ct(),n=de(w=>w.files),a=de(w=>w.loadJson),d=de(w=>w.loadText),l=de(w=>w.watchFile),i=de(w=>w.unwatchFile),o=s?ut.resolve("user",s,null):null,u=s?xt.resolve("user",s,null):null,r=s?`${s}/.claude.json`:null;c.useEffect(()=>{const w=[o,r].filter(Boolean);w.forEach(P=>{n[P]||a(P),l(P)});const O=[u].filter(Boolean);return O.forEach(P=>{n[P]||d(P),l(P)}),()=>{[...w,...O].forEach(P=>i(P))}},[o,u,r]);const[p,m]=c.useState(null);c.useEffect(()=>{if(!s)return;let w=!1;return(async()=>{const O=await bt(`${s}/.claude/skills`);w||m(O.length)})(),()=>{w=!0}},[s]);const g=o?n[o]:null,v=r?n[r]:null,j=u?n[u]:null,k=c.useMemo(()=>{if(!(g!=null&&g.exists)||g.parseError)return null;const w=g.diskData;return w===null||typeof w!="object"||Array.isArray(w)?{}:w},[g]),N=c.useMemo(()=>{if(!(v!=null&&v.exists)||v.parseError)return null;const w=v.diskData;return w===null||typeof w!="object"||Array.isArray(w)?{}:w},[v]),$=g?g.parseError?"invalid JSON":null:"loading…",S=v?v.parseError?"invalid JSON":null:"loading…",b=[{key:"settings",title:"Settings",summary:$??(k?`${Object.keys(k).length} top-level key${Object.keys(k).length===1?"":"s"} configured`:"not configured")},{key:"permissions",title:"Permissions",summary:$??(k?`${ys(k.permissions)} rule(s) configured`:"not configured")},{key:"hooks",title:"Hooks",summary:$??(k?`${Ns(k.hooks)} hook(s) configured`:"not configured")},{key:"mcp",title:"MCP Servers",summary:S??(N?`${Object.keys(N.mcpServers??{}).length} MCP server(s)`:"not configured")},{key:"system-prompt",title:"System Prompt",summary:j!=null&&j.exists&&j.diskRaw.trim().length>0?`configured (${j.diskRaw.length.toLocaleString()} chars)`:"not set"},{key:"skills",title:"Skills",summary:p===null?"loading…":`${p} 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:b.map(w=>e.jsxs("button",{type:"button",onClick:()=>t==null?void 0:t(w.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:w.title}),e.jsx("div",{className:"mt-0.5 text-[12px] text-fg-dim",children:w.summary})]},w.key))})]})}function Ss({navigate:t}){const s=pt(),[n,a]=c.useState(!1),[d,l]=c.useState(!1);c.useEffect(()=>{let o=!0;return mt().then(u=>{o&&a(u.openToHomeOnLaunch===!0)}),()=>{o=!1}},[]);const i=async o=>{a(o),l(!0);try{await ft({openToHomeOnLaunch:o})}catch{a(!o),_.error('Failed to save "Open to Home on launch" — try again.')}finally{l(!1)}};return e.jsxs("div",{className:"max-w-[760px] space-y-6",children:[e.jsx(ks,{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(ht,{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((o,u)=>e.jsxs("li",{className:"font-mono text-[12px] text-fg-dim",children:[o.owner," ",e.jsxs("span",{className:"text-fg-faint",children:["since ",new Date(o.at).toLocaleTimeString()]})]},u))})]}),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(wt,{checked:n,onChange:i,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 _e="sm.schedulerTab.subView",$s=[{key:"queue",label:"Queue"},{key:"prds",label:"PRDs"},{key:"history",label:"History"}];function Cs(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 Ps(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 ${q(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 — no new jobs start; running jobs continue. Click Resume to restart.":`Scheduler paused (${t})`}function As({scopeCwd:t}){const{snapshot:s}=$e(),[n,a]=c.useState(()=>Date.now());if(c.useEffect(()=>{const S=setInterval(()=>a(Date.now()),3e4);return()=>clearInterval(S)},[]),!s)return null;const d=(s.jobs??[]).filter(S=>!t||S.cwd===t),l=d.filter(S=>S.status==="pending").length,i=d.filter(S=>S.status==="running").length,o=d.filter(S=>S.status==="completed"&&(S.finishedAt?Cs(S.finishedAt,n):!1)).length,u=s.nextReset?new Date(s.nextReset).getTime():null,r=u?u>n?q(u-n):"soon":"—",p=G(s.lastRunAt?new Date(s.lastRunAt).getTime():null,n),m=s.paused,g=Object.entries(s.launchBlocks??{}),v=Object.entries(s.launchMitigations??{}),j=s.pollHealth,k=j!=null&&!j.lastPollOk,$=(m==null?void 0:m.reason)==="auth"||(m==null?void 0:m.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:[!m&&e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button",onClick:()=>window.api.schedule.pause(),title:"Stop NEW dispatch. Running jobs are not killed.",className:"px-2.5 py-1 rounded border border-line hover:bg-white/10 transition-colors text-[12px] font-medium text-fg-dim hover:text-fg",children:"Pause"})}),m&&e.jsxs("div",{className:`flex items-center gap-3 border rounded-xl px-4 py-2.5 text-[13px] ${$}`,children:[e.jsx("span",{className:"flex-1 leading-snug",children:Ps(m.reason,m.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"})]}),g.map(([S,b])=>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:S})," jobs are failing before any work starts",b.httpStatus?` (HTTP ${b.httpStatus}, ${b.kind})`:` (${b.kind})`,b.exhausted?" — held until the Claude CLI version changes or you press Retry now.":b.until?` — next automatic probe ${new Date(b.until).getTime()>n?`in ${q(new Date(b.until).getTime()-n)}`:"on the next tick"}.`:"."]}),e.jsx("div",{className:"mt-0.5 text-red-200/80",children:b.hint}),e.jsxs("div",{className:"mt-0.5 font-mono text-[12px] text-red-200/70 truncate",title:b.message,children:[b.attempts," failed probe",b.attempts===1?"":"s",b.claudeVersion?` · CLI ${b.claudeVersion}`:"",b.lastSlug?` · last: ${b.lastSlug}`:""," · ",b.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-${S}`)),v.map(([S,b])=>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:S})," jobs are running in degraded mode"," ","(",e.jsx("span",{className:"font-mono",children:Object.entries(b.env).map(([w,O])=>`${w}=${O}`).join(" ")}),")",b.claudeVersion?` since CLI ${b.claudeVersion}`:"","."]}),e.jsx("div",{className:"mt-0.5 text-amber-200/80",children:b.hint})]})},`launch-mitigation-${S}`)),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(pe,{name:"clock",size:15})}),"Window resets in ",r]}),e.jsx("span",{className:"w-px h-[18px] bg-rule shrink-0","aria-hidden":"true"}),e.jsx(je,{dotClass:"bg-fg-faint",n:l,label:"pending"}),e.jsx(je,{dotClass:"bg-accent",n:i,label:"running"}),e.jsx(je,{dotClass:"bg-sage",n:o,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"}),k?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"," ",G(j.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 ",p]})]})]})}function Ds({navigate:t}={}){var o;const[s,n]=c.useState(()=>{const u=localStorage.getItem(_e);return u==="prds"||u==="history"||u==="machine"?u:"queue"}),a=Me(u=>u.tabs),d=Me(u=>u.activeTabId),l=((o=a.find(u=>u.id===d))==null?void 0:o.cwd)??null,i=l;return c.useEffect(()=>{l&&(le.getState().hydrate(l),le.getState().hydrateArchived(l))},[l]),c.useEffect(()=>{localStorage.setItem(_e,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(gt,{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-[14px]",children:e.jsx(kt,{scopeCwd:i})}),e.jsx("div",{className:"mb-[22px]",children:e.jsx(As,{scopeCwd:i})}),e.jsxs("div",{className:"flex items-center gap-3 pb-0",children:[e.jsx(vt,{options:$s,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(Lt,{scopeCwd:i,navigate:t}),s==="prds"&&e.jsx(hs,{scopeCwd:i}),s==="history"&&e.jsx(vs,{scopeCwd:i}),s==="machine"&&e.jsx("div",{className:"h-full overflow-y-auto px-9 py-6",children:e.jsx(Ss,{navigate:t})})]})]})}const Os=c.memo(Ds);export{Os as Scheduler};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{al as l,aw as O,aa as e,aB as $,a8 as I,a9 as V,as as _,Q as z,c as H,e as L,o as M,M as D,h as Q,X,aC as q,C as G,az as h,j as P}from"./index-BcJqLDiY.js";import{P as T}from"./Panel-Yf3SxsRv.js";import{S as J}from"./SaveBar-BdVb4DbR.js";import{f as K,V as A}from"./Library-DzKA09Iy.js";import"./monaco-editor-BW5C4Iv1.js";function F(t){return t.split("/").pop()||t}function W({activePath:t,selectedPath:o,onSelect:f}){const[n,i]=l.useState([]),m=l.useRef(0),r=l.useRef(f);if(r.current=f,l.useEffect(()=>{if(m.current+=1,r.current(null),!t){i([]);return}const a=m.current;let x=!1;return window.api.config.parseImports(t).then(c=>{x||m.current!==a||(c.ok?i(c.imports):(i([]),O.error(c.error||"failed to parse @-imports")))}),()=>{x=!0}},[t]),n.length===0||!t)return null;const b=o===t||o===null;return e.jsxs("div",{className:"w-64 shrink-0 border-r border-line bg-bg-elev overflow-auto","data-testid":"referenced-files-rail",children:[e.jsxs("div",{className:"px-3 py-2 text-[10px] uppercase tracking-wide text-fg-faint border-b border-line",children:["Documents · ",n.length+1]}),e.jsxs("button",{type:"button",onClick:()=>f(null),"aria-current":b,"data-testid":"referenced-file-root",className:`w-full text-left px-3 py-2 border-b border-line ${b?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg"}`,children:[e.jsx("div",{className:"text-[11.5px] font-medium truncate",children:F(t)}),e.jsx("div",{className:"text-[10px] text-fg-faint truncate",title:t,children:"this system prompt"})]}),n.map(a=>{const x=!a.ok||!a.exists,c=o===a.path;return e.jsxs("button",{type:"button",onClick:()=>f(a),"aria-current":c,"data-testid":"referenced-file-row",className:`w-full text-left px-3 py-2 border-b border-line last:border-b-0 ${c?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[11.5px] font-medium truncate flex-1",children:F(a.path)}),x&&e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded text-[9px] uppercase tracking-wide text-amber-400/90 border border-amber-400/30","data-testid":"referenced-file-missing",children:"missing"})]}),e.jsx("div",{className:"text-[10px] text-fg-faint truncate",title:a.path,children:a.path}),e.jsxs("div",{className:"text-[10px] text-fg-faint",children:[a.sizeBytes.toLocaleString()," bytes · ~",a.tokenEstimate.toLocaleString()," tokens"]})]},a.path)})]})}function U(t){return t.split("/").filter(Boolean).pop()||t}function Y({path:t,value:o,onChange:f,onSave:n,readOnly:i,defaultMode:m,headerRight:r,hideStatusBar:b}){const a=$(),x=I(t),c=V(t),S=_(t),[E,w]=l.useState(()=>i&&c?"preview":m??z(t)),[g,C]=l.useState(!0),[p,R]=l.useState(null),N=l.useRef(null),d=l.useRef(null),v=l.useCallback(s=>{N.current=s},[]),y=l.useCallback(()=>N.current,[]),k=i?c?["preview","edit"]:[]:S?["edit","preview","split"]:c?["edit","preview"]:[],u=c?E:"edit",j=e.jsx(H,{path:t,name:U(t),value:o,onChange:f,onSave:()=>n==null?void 0:n(),onReady:v,onCursor:R,readOnly:i});return e.jsxs("div",{className:"flex flex-col h-full min-h-0","data-testid":"document-editor-pane",children:[e.jsxs("div",{className:"flex items-center gap-1 px-2 h-7 shrink-0 border-b border-line bg-bg-elev",children:[e.jsx("span",{className:"text-[11px] font-medium text-fg truncate",children:U(t)}),i&&e.jsx("span",{className:"ml-1 px-1.5 py-0.5 rounded text-[9px] uppercase tracking-wide text-fg-faint border border-line",children:"read-only"}),e.jsx("div",{className:"flex-1"}),r,x&&(u==="preview"||u==="split")&&e.jsx("button",{onClick:()=>C(s=>!s),"data-testid":"document-outline-toggle",className:`px-2 py-0.5 text-[10px] border border-line rounded ${g?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Toggle document outline",children:"Outline"}),k.length>0&&e.jsx("div",{className:"flex items-center ml-1 rounded border border-line overflow-hidden","data-testid":"document-mode-toggle",children:k.map(s=>e.jsx("button",{onClick:()=>w(s),className:`px-2 py-0.5 text-[10px] capitalize transition-colors ${u===s?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,children:s},s))})]}),e.jsx("div",{className:"flex-1 min-h-0",children:u==="split"&&x?e.jsxs("div",{className:"flex h-full",children:[g&&e.jsx(L,{text:o,scrollRef:d}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col border-r border-line",children:[!i&&e.jsx(M,{getEditor:y}),e.jsx("div",{className:"flex-1 min-h-0",children:j})]}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(D,{ref:d,text:o,flush:!0,wideMeasure:a.wideMeasure})})]}):u==="preview"&&x?e.jsxs("div",{className:"flex h-full",children:[g&&e.jsx(L,{text:o,scrollRef:d}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(D,{ref:d,text:o,wideMeasure:a.wideMeasure})})]}):x?e.jsxs("div",{className:"flex flex-col h-full",children:[!i&&e.jsx(M,{getEditor:y}),e.jsx("div",{className:"flex-1 min-h-0",children:j})]}):j}),!b&&e.jsx(Q,{text:o,cursor:p,language:X(t)||void 0})]})}const B={title:"User system prompt",body:"This is the real ~/.claude/CLAUDE.md on disk — the instructions the claude CLI loads into every session it starts on this machine, in every project. A project's own CLAUDE.md / CLAUDE.local.md are read from that project's directory when a session launches there; they are not edited here."};function Z(t){return Math.round(t.length/4)}function ee(){const t=q(),[o,f]=l.useState("installed"),n=l.useMemo(()=>t?G.resolve("user",t,null):null,[t]),[i,m]=l.useState(null),r=(i==null?void 0:i.path)??n,b=!!i&&(!i.ok||!i.exists),a=h(s=>s.files),x=h(s=>s.loadText),c=h(s=>s.setDraft),S=h(s=>s.saveText),E=h(s=>s.revert),w=h(s=>s.watchFile),g=h(s=>s.unwatchFile);l.useEffect(()=>{if(n)return x(n,!0),w(n),()=>{g(n)}},[n]),l.useEffect(()=>{if(!(!r||r===n))return x(r,!0),w(r),()=>{g(r)}},[r,n]);const[C,p]=l.useState(null),R=l.useCallback(s=>{p(null),m(s)},[]);if(!t)return e.jsx(P,{title:"loading…"});if(o==="library")return e.jsx(T,{toolbar:e.jsx(A,{active:o,onChange:f,installedLabel:"Editor",libraryLabel:"Presets"}),children:e.jsx(K,{})});const N=n?a[n]:null,d=r?a[r]:null,v=(d==null?void 0:d.draftRaw)??"",y=Z(v),k=v.length,u=b,j=async()=>{if(!r)return;p(null);const s=await S(r);s.ok||p(s.error??"save failed")};return e.jsx(T,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(A,{active:o,onChange:f,installedLabel:"Editor",libraryLabel:"Presets"}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-dim",children:"User scope"}),e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:r??"—"}),e.jsx("div",{className:"flex-1"}),e.jsxs("span",{className:"text-fg-faint",children:[k.toLocaleString()," chars · ~",y.toLocaleString()," tokens"]})]}),footer:r&&d&&!u?e.jsx(J,{dirty:d.dirty,busy:d.busy,parseError:C,lastSavedAt:d.lastSavedAt,leading:d.exists?i?e.jsx("span",{children:"editing an imported file"}):null:e.jsx("span",{children:"file will be created on save"}),onSave:j,onRevert:()=>{p(null),E(r)}}):null,children:n&&N?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{"data-testid":"system-prompt-scope-note",className:"shrink-0 border-b border-line bg-bg-elev px-3 py-2 text-[11.5px] leading-snug",children:[e.jsx("span",{className:"font-semibold text-fg",children:B.title}),e.jsx("span",{className:"mx-1.5 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-dim",children:B.body}),e.jsx("span",{className:"ml-1.5 font-mono text-fg-faint",children:n})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex",children:[e.jsx(W,{activePath:n,selectedPath:r,onSelect:R}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[u&&e.jsx("div",{"data-testid":"system-prompt-missing-note",className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 text-[11px] text-amber-400/90",children:"This import does not resolve to a readable file — the CLI will skip it."}),r&&e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Y,{path:r,value:v,readOnly:u,defaultMode:"split",onChange:s=>{p(null),c(r,s)},onSave:()=>{j()}},r)})]})]})]}):e.jsx(P,{title:"resolving…"})})}const ie=l.memo(ee);export{ie as SystemPrompt};
|