claude-code-session-manager 0.140.0 → 0.141.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/{AppSettings-CMFEM68R.js → AppSettings-DExeJhqQ.js} +1 -1
- package/dist/assets/{History--JwsFnbn.js → History-DJMiuXyK.js} +1 -1
- package/dist/assets/{HomeClaudeConfig-ijEXs--3.js → HomeClaudeConfig-CTp2tkZ4.js} +2 -2
- package/dist/assets/{Panel-CALyU0pe.js → Panel-Bf1Cf8UL.js} +1 -1
- package/dist/assets/{ProjectClaudeConfig-sdlA-fUb.js → ProjectClaudeConfig-BWPpypf9.js} +1 -1
- package/dist/assets/{Scheduler-YT3j8SUa.js → Scheduler-cyr61UAC.js} +1 -1
- package/dist/assets/{SkillReferenceGraph-CxAuwhNN.js → SkillReferenceGraph-Ba4TkX2C.js} +1 -1
- package/dist/assets/{Skills-DtRzghn5.js → Skills-C1v91GEO.js} +1 -1
- package/dist/assets/{TiptapBody-DApeu7x8.js → TiptapBody-BrcWVpiW.js} +1 -1
- package/dist/assets/{ViewTabs-B7qLXRAH.js → ViewTabs-DXhOWFG0.js} +1 -1
- package/dist/assets/{VoiceButton-DtStfv1H.js → VoiceButton-qivnDV6K.js} +1 -1
- package/dist/assets/{historyTotals-ydfnwepc.js → historyTotals-CMCPTKqC.js} +1 -1
- package/dist/assets/{index-CtxruO1L.js → index-B2TQz3nd.js} +3 -3
- package/dist/index.html +1 -1
- package/dist-web/app.js +1 -1
- package/package.json +1 -1
- package/plugins/session-manager-dev/skills/builder/SKILL.md +4 -2
- package/plugins/session-manager-dev/skills/develop/SKILL.md +3 -0
- package/scripts/scheduler-mcp-server.cjs +5 -0
- package/src/main/build-info.json +4 -4
- package/src/main/ipcSchemas.cjs +10 -0
- package/src/main/lib/mcpToolCatalog.cjs +11 -2
- package/src/main/lib/prd/prdCreate.cjs +27 -1
- package/src/main/lib/prd/prdFrontmatter.cjs +28 -3
- package/src/main/lib/scheduler/preflightCheck.cjs +97 -0
- package/src/main/lib/scheduler/reviewNotice.cjs +39 -0
- package/src/main/scheduler/prdParser.cjs +16 -1
- package/src/main/scheduler/reviewLadder.cjs +36 -3
- package/src/main/scheduler/starvation.cjs +69 -0
- package/src/main/scheduler.cjs +335 -25
- package/src/main/templates/PRD_AUTHORING.md +9 -1
package/dist/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Claude Session Manager</title>
|
|
7
|
-
<script type="module" crossorigin src="./assets/index-
|
|
7
|
+
<script type="module" crossorigin src="./assets/index-B2TQz3nd.js"></script>
|
|
8
8
|
<link rel="modulepreload" crossorigin href="./assets/monaco-editor-BsIlgG7c.js">
|
|
9
9
|
<link rel="stylesheet" crossorigin href="./assets/monaco-editor-Cu5D__1H.css">
|
|
10
10
|
<link rel="stylesheet" crossorigin href="./assets/index-DKXdXfka.css">
|
package/dist-web/app.js
CHANGED
|
@@ -77,7 +77,7 @@ ${i}`],o=(s.images??[]).filter(l=>l.path).map(l=>l.path);o.length>0&&r.push(["Cu
|
|
|
77
77
|
|
|
78
78
|
`);return HV({title:`[Customer ${s.tag}] ${s.title}`,goal:a,tag:jOe[s.tag],agentName:"architect",agentDescription:iQe,...n?{agentBody:n.text,agentPath:n.path}:{}})}function rQe({it:s}){const e=s.images,[n,i]=T.useState({});T.useEffect(()=>{let a=!1;return i({}),(e??[]).forEach((l,c)=>{if(!l.path)return;const d=u=>{a||i(h=>({...h,[c]:u}))};Promise.resolve().then(()=>window.api.customerFeedback.inboxImage({id:s.id,index:c})).then(u=>d(u&&u.ok?{status:"ok",dataUrl:u.dataUrl}:{status:"error"}),()=>d({status:"error"}))}),()=>{a=!0}},[s.id,e]);const r=e??[];if(r.length===0)return null;const o=r.filter(a=>!a.path).length;return p.jsxs("div",{className:"grid gap-1","data-testid":"customer-feedback-inbox-images",children:[p.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.map((a,l)=>{if(!a.path)return null;const c=n[l]??{status:"loading"};return c.status==="ok"?p.jsx("img",{src:c.dataUrl,alt:`Customer image ${l+1}`,className:"max-h-24 max-w-[8rem] rounded border border-line object-contain"},l):p.jsx("div",{className:"flex h-16 w-24 items-center justify-center rounded border border-line px-1 text-center text-[11px] text-fg-dim","data-testid":c.status==="error"?"customer-feedback-inbox-image-error":void 0,children:c.status==="error"?"Could not load image":"Loading…"},l)})}),o>0&&p.jsxs("div",{className:"text-[11.5px] text-fg-dim",children:[o," image(s) not downloaded yet. Pull to retry."]})]})}function oQe({it:s,projectCwd:e}){const n=uo(v=>v.setInboxStatus),i=uo(v=>v.linkEpic),r=cn(v=>v.createPromptSession),[o,a]=T.useState(!1),[l,c]=T.useState(""),[d,u]=T.useState(!1),h=s.body.length>p0e,f=h&&!o?`${s.body.slice(0,p0e)}…`:s.body,g=s.epicId!=null,m=d||g||!e,_=g?"An Epic is already linked to this feedback":e?"Create a proposed Epic from this feedback":"No owner project is configured for this inbox",b=async()=>{if(!(m||!e)){u(!0);try{const{goalText:v,openingPrompt:x,sections:w}=await sQe(s,e),y=await r(e,v,jOe[s.tag],void 0,"architect",x,w);await i(s.id,y.id),await n(s.id,"in_progress")}catch(v){pe.error(v instanceof Error?v.message:String(v))}finally{u(!1)}}};return p.jsxs("div",{className:"rounded-lg border border-line bg-bg px-3 py-2 grid gap-1.5","data-testid":"customer-feedback-inbox-item",children:[p.jsxs("div",{className:"flex items-start justify-between gap-2",children:[p.jsx("div",{className:"min-w-0 text-[13px] font-semibold text-fg break-words",children:s.title}),p.jsx("span",{className:"shrink-0 rounded border border-line px-1.5 py-0.5 text-[11px] font-semibold text-fg-dim",children:eQe[s.status]})]}),p.jsxs("div",{className:"font-mono text-[11px] text-fg-dim",children:[tQe[s.tag]," · ",new Date(BQ(s.receivedAt)).toLocaleDateString()," · v",s.clientVersion??"?"," ·"," ",s.clientPlatform??"?"]}),p.jsx("div",{className:"text-[12.5px] text-fg whitespace-pre-wrap break-words",children:f}),p.jsx(rQe,{it:s}),h&&p.jsx("button",{type:"button",onClick:()=>a(v=>!v),className:"justify-self-start text-[11.5px] font-semibold text-accent",children:o?"Show less":"Show more"}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("select",{value:s.status,onChange:v=>void n(s.id,v.target.value,l.trim()||void 0),className:"rounded-md border border-line bg-bg px-2 py-1 text-[12px] text-fg","aria-label":"Status","data-testid":"customer-feedback-inbox-status",children:OOe.map(v=>p.jsx("option",{value:v.value,children:v.label},v.value))}),p.jsx("input",{type:"text",value:l,onChange:v=>c(v.target.value),placeholder:"Note (optional)",maxLength:500,className:"min-w-0 flex-1 rounded-md border border-line bg-bg px-2 py-1 text-[12px] text-fg","aria-label":"Status note"}),p.jsx("button",{type:"button",onClick:()=>void b(),disabled:m,title:_,className:"rounded-md bg-accent px-2.5 py-1 text-[12px] font-semibold text-white disabled:opacity-50","data-testid":"customer-feedback-inbox-open-epic",children:g?"Epic linked":"Open as Epic"})]})]})}function aQe(){const s=uo(a=>{var l;return((l=a.ownerInfo)==null?void 0:l.ownerMode)??!1}),e=uo(a=>{var l;return((l=a.ownerInfo)==null?void 0:l.projectCwd)??null}),n=uo(a=>a.inbox),i=uo(a=>a.inboxLoading),r=uo(a=>a.pullInbox),o=T.useMemo(()=>[...n].sort((a,l)=>BQ(l.receivedAt)-BQ(a.receivedAt)),[n]);return T.useEffect(()=>{s&&r()},[s,r]),s?p.jsxs("section",{className:"shrink-0 max-h-[50%] overflow-auto border-t border-line px-5 py-4 grid gap-2 content-start","data-testid":"customer-feedback-inbox",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"m-0 font-mono text-[11px] uppercase tracking-[0.08em] text-fg-dim",children:"Customer inbox"}),p.jsx("button",{type:"button",onClick:()=>void r(),disabled:i,className:"rounded-md border border-line bg-bg px-2.5 py-1 text-[12px] font-semibold text-fg-dim hover:bg-bg-elev disabled:opacity-50","data-testid":"customer-feedback-inbox-refresh",children:i?"Refreshing…":"Refresh"})]}),o.length===0?p.jsx("p",{className:"m-0 text-[12.5px] text-fg-dim",children:"No customer feedback yet."}):o.map(a=>p.jsx(oQe,{it:a,projectCwd:e},a.id))]}):null}function $V(s){return s===0?"0 B":s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}const g0e=[137,80,78,71,13,10,26,10];function lQe(s){if(s.length<24)return null;for(let n=0;n<g0e.length;n++)if(s[n]!==g0e[n])return null;const e=new DataView(s.buffer,s.byteOffset,s.byteLength);return{width:e.getUint32(16),height:e.getUint32(20)}}const m0e=2;function hue(){const[s,e]=T.useState([]),n=T.useRef([]),i=T.useRef(!0),r=d=>{n.current=d,e(d)};T.useEffect(()=>(i.current=!0,()=>{i.current=!1;for(const d of n.current)d.url&&URL.revokeObjectURL(d.url);n.current=[]}),[]);const o=d=>{const u=Array.from(d);if(!u.length)return;const h=u.map(f=>{const g=f.path||"";return{id:Math.random().toString(36).slice(2),name:f.name||"pasted-image.png",size:$V(f.size),url:f.type.startsWith("image/")?URL.createObjectURL(f):null,path:g||f.name||"pasted-image.png",hasRealPath:!!g,file:f}});r([...n.current,...h]);for(const f of h)f.hasRealPath||f.file.type!=="image/png"||a(f)},a=async d=>{let u;try{u=lQe(new Uint8Array(await d.file.slice(0,24).arrayBuffer()))}catch{return}!u||u.width>m0e||u.height>m0e||!i.current||!n.current.some(h=>h.id===d.id)||(l(d.id),pe.warn(`The pasted image is only ${u.width}×${u.height} px — your screenshot did not reach the clipboard, so it was not attached. Copy it again and paste.`))},l=d=>{const u=n.current.find(h=>h.id===d);u!=null&&u.url&&URL.revokeObjectURL(u.url),r(n.current.filter(h=>h.id!==d))};return{items:s,add:o,remove:l,clear:()=>{for(const d of n.current)d.url&&URL.revokeObjectURL(d.url);r([])}}}function HQ(s,e){var i;const n=(i=s.clipboardData)==null?void 0:i.files;return!n||n.length===0?!1:(s.preventDefault(),e.add(n),!0)}async function cQe(s){const e=await s.arrayBuffer(),n=new Uint8Array(e);let i="";for(let r=0;r<n.length;r++)i+=String.fromCharCode(n[r]);return btoa(i)}async function FOe(s,e){const n=[];for(const i of s){if(i.hasRealPath){n.push(i.path);continue}try{const r=`${e}/session-manager-operations/prompt-sessions/attachments/${i.id}-${i.name}`,o=await cQe(i.file),a=await window.api.files.saveBinary(r,o,"epics");a.ok?n.push(r):pe.error(`Failed to save attachment "${i.name}": ${a.error??"unknown error"}`)}catch(r){const o=r instanceof Error?r.message:String(r);pe.error(`Failed to save attachment "${i.name}": ${o}`)}}return n}function BOe({att:s,testId:e,className:n="",size:i=17}){const r=T.useRef(null),o="Attach files — or paste a screenshot (⌘V) or drop files onto the prompt";return p.jsxs(p.Fragment,{children:[p.jsx("button",{type:"button","data-testid":e,onClick:()=>{var a;return(a=r.current)==null?void 0:a.click()},"aria-label":o,title:o,className:n,children:p.jsx(Ci,{name:"paperclip",size:i})}),p.jsx("input",{ref:r,"data-testid":e?`${e}-input`:void 0,type:"file",multiple:!0,className:"hidden",onChange:a=>{a.target.files&&s.add(a.target.files),a.target.value=""}})]})}function HOe({att:s,testId:e}){return s.items.length===0?null:p.jsx("div",{"data-testid":e,className:"mt-2 flex flex-wrap gap-2",children:s.items.map(n=>p.jsxs("span",{className:"inline-flex max-w-[240px] items-center gap-2 rounded-[9px] border border-line bg-bg-hi py-1 pl-2 pr-2.5",children:[n.url?p.jsx("img",{src:n.url,alt:"",className:"h-6 w-[30px] rounded object-cover border border-rule"}):p.jsx("span",{className:"text-accent","aria-hidden":"true",children:p.jsx(Ci,{name:"file",size:14})}),p.jsx("span",{className:"truncate font-mono text-[11px] text-fg-dim",children:n.name}),p.jsx("span",{className:"shrink-0 font-mono text-[10px] text-fg-faint",children:n.size}),p.jsx("button",{type:"button",onClick:()=>s.remove(n.id),title:"Remove",className:"shrink-0 text-fg-faint hover:text-fg",children:"×"})]},n.id))})}const dQe={open:"Open",in_progress:"In progress",resolved:"Resolved",wontfix:"Won't fix"},uQe=[{tag:"bug",label:"Bug"},{tag:"feature",label:"Feature"},{tag:"discussion",label:"Discussion"}],hQe={bug:"Bug",feature:"Feature",discussion:"Discussion"},_0e="Send this to Session Manager as feedback, with any screenshots I attached.",b0e=120,fQe=4e3,u4=5,pQe=25*1024*1024,v0e=["image/png","image/jpeg","image/webp","image/gif"];function gQe(s){return new Promise((e,n)=>{const i=new FileReader;i.onload=()=>e(String(i.result)),i.onerror=()=>n(i.error??new Error(`could not read ${s.name||"image"}`)),i.readAsDataURL(s)})}function mQe(){const s=uo(I=>I.panelOpen),e=uo(I=>I.draft),n=uo(I=>I.items),i=uo(I=>I.submitting),r=uo(I=>I.closePanel),o=uo(I=>I.setDraft),a=uo(I=>I.submit),l=uo(I=>I.load),c=uo(I=>I.loadOwnerInfo),d=uo(I=>I.refreshStatus),u=uo(I=>I.markSeen),h=uo(I=>{var A;return((A=I.ownerInfo)==null?void 0:A.ownerMode)===!0}),f=rs(I=>I.show),[g,m]=T.useState(!1),[_,b]=T.useState(!1),v=hue(),x=T.useRef(null),w=T.useMemo(()=>[...n].sort((I,A)=>A.submittedAt-I.submittedAt),[n]);if(T.useEffect(()=>{if(!s){m(!1);return}const I=requestAnimationFrame(()=>m(!0));return()=>cancelAnimationFrame(I)},[s]),T.useEffect(()=>{if(!s)return;let I=!1;return(async()=>(await Promise.all([l(),c(),d()]),I||await u()))(),()=>{I=!0}},[s,l,c,d,u]),T.useEffect(()=>{if(b(!1),!s)return;let I=!1;return(async()=>{var A,j,F,P;try{const H=await((F=(j=(A=window.api)==null?void 0:A.app)==null?void 0:j.seedStatus)==null?void 0:F.call(j));I||b(((P=H==null?void 0:H["scheduler-mcp"])==null?void 0:P.status)==="done")}catch{}})(),()=>{I=!0}},[s]),T.useEffect(()=>{if(!s)return;const I=A=>{A.key==="Escape"&&(A.stopPropagation(),r())};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[s,r]),!s)return null;const y=e.title.trim()===""||e.body.trim()==="",S=I=>{const A=I?Array.from(I):[];if(A.length===0)return;const j=[];for(const F of A){const P=F.name||"pasted image";if(!v0e.includes(F.type))f("error",`${P} is not a PNG, JPEG, WebP or GIF image.`);else if(F.size>pQe)f("error",`${P} is over 25 MB.`);else if(v.items.length+j.length>=u4){f("error",`You can attach up to ${u4} images.`);break}else j.push(F)}j.length&&v.add(j)},E=async()=>{let I;try{I=await Promise.all(v.items.map(async A=>({dataUrl:await gQe(A.file)})))}catch(A){f("error",`Could not read an image: ${A instanceof Error?A.message:String(A)}`);return}await a(I)&&v.clear()},L=async()=>{await gc(_0e)?f("info","Copied — paste it into your session."):f("error","Could not copy to the clipboard.")},N=p.jsxs("div",{className:`fixed inset-0 ${xi.dialog}`,"data-testid":"customer-feedback-root",children:[p.jsx("div",{className:`absolute inset-0 bg-black/50 transition-opacity duration-[220ms] ${g?"opacity-100":"opacity-0"}`,onClick:I=>{I.target===I.currentTarget&&r()},"data-testid":"customer-feedback-backdrop"}),p.jsxs("aside",{role:"dialog","aria-modal":"true","aria-label":"Send feedback",className:`absolute left-0 top-0 h-full w-full max-w-[480px] border-r border-line bg-bg-elev text-fg shadow-xl flex flex-col transition-transform duration-[220ms] ${g?"translate-x-0":"-translate-x-full"}`,style:{transitionTimingFunction:"cubic-bezier(.32,.72,.28,1)"},"data-testid":"customer-feedback-panel",children:[p.jsxs("header",{className:"px-5 py-4 border-b border-line flex items-center justify-between gap-3 shrink-0",children:[p.jsx("h2",{className:"m-0 font-serif text-[18px] font-semibold text-fg",children:"Feedback"}),p.jsx("button",{onClick:r,className:"shrink-0 rounded-md border border-line bg-bg px-2.5 py-1 text-[12px] font-semibold text-fg-dim hover:bg-bg-elev","aria-label":"Close","data-testid":"customer-feedback-close",children:"Close"})]}),p.jsxs("div",{className:"flex-1 min-h-0 overflow-auto px-5 py-4 grid gap-5 content-start",children:[p.jsxs("form",{className:"grid gap-3",onSubmit:I=>{I.preventDefault(),!y&&!i&&E()},onPaste:I=>{var j;const A=(j=I.clipboardData)==null?void 0:j.files;!A||A.length===0||(I.preventDefault(),S(A))},onDragOver:I=>{var A,j;(j=(A=I.dataTransfer)==null?void 0:A.types)!=null&&j.includes("Files")&&I.preventDefault()},onDrop:I=>{var j;const A=(j=I.dataTransfer)==null?void 0:j.files;!A||A.length===0||(I.preventDefault(),S(A))},"data-testid":"customer-feedback-form",children:[_&&p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsxs("p",{className:"m-0 flex-1 text-[12.5px] text-fg-dim","data-testid":"customer-feedback-session-hint",children:['Already talking about this in a session? Ask it: "',_0e,`" It uses what the session already knows, so you don't retype it, and the item shows up here.`]}),p.jsx("button",{type:"button",className:"shrink-0 text-[12.5px] font-semibold text-accent hover:underline","aria-label":"Copy the phrase to ask your session","data-testid":"customer-feedback-session-hint-copy",onClick:()=>void L(),children:"Copy"})]}),p.jsxs("label",{className:"grid gap-1",children:[p.jsxs("span",{className:"flex justify-between font-mono text-[11px] uppercase tracking-[0.05em] text-fg-dim",children:[p.jsx("span",{children:"Goal"}),p.jsxs("span",{children:[e.title.length,"/",b0e]})]}),p.jsx("input",{value:e.title,maxLength:b0e,onChange:I=>o({title:I.target.value}),className:"rounded-md border border-line bg-bg px-2.5 py-1.5 text-[13px] text-fg","data-testid":"customer-feedback-title"})]}),p.jsxs("label",{className:"grid gap-1",children:[p.jsx("span",{className:"font-mono text-[11px] uppercase tracking-[0.05em] text-fg-dim",children:"Description"}),p.jsx("textarea",{value:e.body,maxLength:fQe,rows:6,onChange:I=>o({body:I.target.value}),className:"rounded-md border border-line bg-bg px-2.5 py-1.5 text-[13px] text-fg resize-y","data-testid":"customer-feedback-body"})]}),p.jsxs("div",{className:"grid gap-2",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("button",{type:"button",onClick:()=>{var I;return(I=x.current)==null?void 0:I.click()},disabled:v.items.length>=u4,className:"rounded-md border border-line bg-bg px-2.5 py-1 text-[12px] font-semibold text-fg-dim hover:bg-bg-elev disabled:opacity-50",title:"Add images — or paste a screenshot or drop images onto the form","data-testid":"customer-feedback-add-images",children:"Add images"}),p.jsxs("span",{className:"font-mono text-[11px] text-fg-dim",children:[v.items.length,"/",u4," images"]}),p.jsx("input",{ref:x,type:"file",multiple:!0,accept:v0e.join(","),className:"hidden",onChange:I=>{S(I.target.files),I.target.value=""},"data-testid":"customer-feedback-images-input"})]}),v.items.length>0&&p.jsx("div",{className:"flex flex-wrap gap-2",children:v.items.map(I=>p.jsxs("div",{className:"relative h-16 w-16 overflow-hidden rounded-md border border-line bg-bg","data-testid":"customer-feedback-image",children:[I.url&&p.jsx("img",{src:I.url,alt:I.name,className:"h-full w-full object-cover"}),p.jsx("button",{type:"button",onClick:()=>v.remove(I.id),"aria-label":`Remove ${I.name}`,title:"Remove",className:"absolute right-0.5 top-0.5 rounded bg-black/60 px-1 text-[11px] leading-4 text-white hover:bg-black/80","data-testid":"customer-feedback-image-remove",children:"×"})]},I.id))})]}),p.jsx("div",{className:"flex gap-2",role:"group","aria-label":"Feedback type",children:uQe.map(({tag:I,label:A})=>p.jsx("button",{type:"button","aria-pressed":e.tag===I,onClick:()=>o({tag:I}),className:`rounded-md border border-line px-3 py-1 text-[12px] font-semibold ${e.tag===I?"bg-accent text-white":"bg-bg text-fg-dim hover:bg-bg-elev"}`,"data-testid":`customer-feedback-tag-${I}`,children:A},I))}),p.jsx("p",{className:"m-0 text-[11.5px] text-fg-dim",children:"Your feedback, including any screenshots, is sent to bilko.run. Please don't include secrets, keys or passwords."}),p.jsx("button",{type:"submit",disabled:y||i,className:"rounded-md bg-accent px-3 py-1.5 text-[13px] font-semibold text-white disabled:opacity-50","data-testid":"customer-feedback-submit",children:i?"Sending…":"Submit"})]}),p.jsxs("p",{className:"m-0 text-[12.5px] text-fg-dim","data-testid":"customer-feedback-free-hour",children:["Rather talk it through?"," ",p.jsx("button",{type:"button",className:"font-semibold text-accent hover:underline","data-testid":"customer-feedback-free-hour-link",onClick:MOe,children:"Book a free hour with Bilko"})]}),p.jsxs("section",{className:"grid gap-2","data-testid":"customer-feedback-list",children:[p.jsx("h3",{className:"m-0 font-mono text-[11px] uppercase tracking-[0.08em] text-fg-dim",children:"Your feedback"}),w.length===0?p.jsx("p",{className:"m-0 text-[12.5px] text-fg-dim",children:"No feedback yet — what you send will show up here."}):w.map(I=>p.jsxs("div",{className:"rounded-lg border border-line bg-bg px-3 py-2 grid gap-1","data-testid":"customer-feedback-item",children:[p.jsxs("div",{className:"flex items-start justify-between gap-2",children:[p.jsx("div",{className:"min-w-0 text-[13px] font-semibold text-fg break-words",children:I.title}),p.jsx("span",{className:"shrink-0 rounded border border-line px-1.5 py-0.5 text-[11px] font-semibold text-fg-dim","data-testid":"customer-feedback-status",children:dQe[I.status]})]}),p.jsxs("div",{className:"font-mono text-[11px] text-fg-dim",children:[hQe[I.tag]," · ",new Date(I.submittedAt).toLocaleDateString()]}),I.statusNote&&p.jsx("div",{className:"text-[12px] text-fg-dim break-words",children:I.statusNote})]},I.id))]})]}),h&&p.jsx(aQe,{})]})]});return typeof document<"u"&&document.body?G0.createPortal(N,document.body):N}function VD({content:s,children:e,align:n="bottom-right"}){const[i,r]=T.useState(!1),o=n==="bottom-right"?"top-full mt-1 right-0":"top-full mt-1 left-1/2 -translate-x-1/2";return p.jsxs("span",{className:"relative inline-flex",onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),onFocus:()=>r(!0),onBlur:()=>r(!1),children:[e,i&&p.jsx("span",{role:"tooltip",className:`absolute ${xi.dialog} ${o} px-2 py-1 text-[10px] leading-snug text-fg bg-bg-elev border border-line rounded shadow-lg max-w-[18rem] whitespace-normal pointer-events-none`,children:s})]})}const _Qe=3e4,x0e="Thank you for using the product — feedback is much appreciated. For convenience, ask your agent to send it via the Feedback MCP, directly from any session.";function bQe(){const s=Ft(L=>L.tabs),e=Ft(L=>L.activeTabId),n=Ft(L=>L.closeTab),i=Ft(L=>L.setActive),r=Ft(L=>L.reorderTab),o=gR(L=>L.watchers),a=di(L=>L.openPanel),l=di(L=>L.openProjectPanel),c=di(L=>L.setEpicsWorkspaceOpen),d=di(L=>L.navFace==="home"),u=uo(L=>L.items),h=uo(L=>L.panelOpen),f=uo(L=>L.togglePanel),g=uo(L=>L.load),m=JJe(u)>0;T.useEffect(()=>{g()},[g]);const[_,b]=T.useState(()=>Date.now()),v=uue();T.useEffect(()=>{if(!v)return;b(Date.now());const L=window.setInterval(()=>b(Date.now()),1e3);return()=>window.clearInterval(L)},[v]);const x=L=>{for(const N of Object.values(o))if(N.tabId===L&&N.lastLineAt&&_-N.lastLineAt<_Qe)return!0;return!1},{getTabDragProps:w,isDragging:y,containerRef:S}=ZJe({tabCount:s.length,onReorder:r,onActivate:L=>{const N=s[L];N&&(i(N.id),c(!1),l("terminal"))}}),E=["#6f7d52","#b85c34","#a39079","#7a8466","#5b4a36"];return p.jsxs("div",{className:"h-12 bg-bg-elev border-b border-line flex items-end px-3 gap-0 shrink-0 relative","data-testid":"tour-tabbar",children:[p.jsxs("button",{onClick:()=>a("overview"),title:"This machine — home","aria-current":d?"true":void 0,"data-testid":"tabbar-machine-home",className:`flex items-center gap-2 px-3.5 py-1.5 mb-1 rounded-full text-[13px] shrink-0 transition-colors ${d?"bg-accent text-bg font-semibold shadow-sm":"text-fg-dim hover:text-fg hover:bg-bg-hi/40"}`,children:[p.jsx(Ci,{name:"home",className:"w-[15px] h-[15px]"}),p.jsx("span",{children:"Home"})]}),p.jsx("span",{className:"w-px self-stretch my-1.5 bg-line"}),p.jsx("div",{ref:S,className:`flex items-end gap-0.5 overflow-x-auto no-scrollbar min-w-0 flex-1 select-none ${y?"cursor-grabbing":""}`,children:s.map((L,N)=>{const I=L.id===e,A=w(N),j=E[N%E.length];return p.jsxs("div",{...A,style:A.style,className:`group flex items-center gap-2 px-3.5 pt-1.5 pb-2 rounded-t-[10px] text-[13px] shrink-0 transition-colors ${y?"":"cursor-grab"} ${I?"bg-bg text-fg font-medium relative z-10 -mb-px border border-accent shadow-[inset_0_2px_0_theme(colors.accent.DEFAULT)]":"text-fg-dim hover:text-fg hover:bg-bg-hi/40"}`,title:L.cwd,"aria-current":I?"true":void 0,children:[p.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:j,boxShadow:"inset 0 0 0 0.5px rgba(0,0,0,0.15)",opacity:L.status==="spawning"?.55:1}}),p.jsx("span",{className:"truncate max-w-[200px]",children:L.label}),L.status==="spawning"&&p.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-butter animate-pulse",title:"spawning"}),x(L.id)&&p.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent animate-pulse",title:"watcher emitted a line in the last 30s","data-testid":"tab-watcher-dot"}),p.jsx("button",{onClick:F=>{F.stopPropagation(),n(L.id)},className:"text-fg-faint opacity-0 group-hover:opacity-100 hover:text-fg ml-1 leading-none",title:"Close session","aria-label":`Close ${L.label}`,children:"×"})]},L.id)})}),p.jsx("span",{className:"w-px self-stretch my-1.5 bg-line"}),p.jsx(VD,{content:x0e,children:p.jsxs("button",{onClick:f,title:x0e,"aria-label":"Send feedback","aria-expanded":h,"data-testid":"tabbar-customer-feedback",className:"relative flex items-center px-3.5 py-1.5 mb-1 rounded-full text-[13px] font-mono shrink-0 transition-colors text-fg-dim hover:text-fg hover:bg-bg-hi/40",children:["Feedback",m&&p.jsx("span",{className:"absolute top-1 right-1.5 w-1.5 h-1.5 rounded-full bg-accent","data-testid":"customer-feedback-unseen-dot"})]})}),p.jsx(mQe,{})]})}function vQe(...s){}function xQe(s){return Promise.reject(new Error("Not available in the web version"))}const wQe=new Set,yQe=new Set;function CQe(){for(const s of wQe)try{s()}catch{}}function WQ(){for(const s of yQe)try{s()}catch{}}function SQe(s){return s.replace(/```[\s\S]*?```/g,"").replace(/`([^`]+)`/g,"$1").replace(/^#{1,6}\s+/gm,"").replace(/\*{1,3}([^*]+)\*{1,3}/g,"$1").replace(/_{1,3}([^_]+)_{1,3}/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/^[-*_]{3,}\s*$/gm,"").replace(/^>\s?/gm,"").replace(/^[\s]*[-*+]\s/gm,"").replace(/^[\s]*\d+\.\s/gm,"").trim()}function kQe(s){if(!window.speechSynthesis)return;const e=SQe(s);if(!e)return;const n=new SpeechSynthesisUtterance(e);n.rate=1,n.pitch=1,n.onstart=()=>{performance.now(),CQe()},n.onend=()=>{!window.speechSynthesis.speaking&&!window.speechSynthesis.pending&&WQ()},n.onerror=i=>{i.error!=="canceled"&&!window.speechSynthesis.speaking&&!window.speechSynthesis.pending&&WQ()},window.speechSynthesis.speak(n)}function EQe(){window.speechSynthesis&&(window.speechSynthesis.cancel(),WQ())}function h4(s,e,n,i,r){var a,l;try{(l=(a=window.api)==null?void 0:a.logs)==null||l.write(s,e,n,i,r)}catch{}const o=e==="error"?console.error:e==="warn"?console.warn:console.log;i!==void 0?o(`[${s}]`,n,i):o(`[${s}]`,n)}const ei={debug:(s,e,n)=>h4(s,"debug",e,n),info:(s,e,n)=>h4(s,"info",e,n),warn:(s,e,n)=>h4(s,"warn",e,n),error:(s,e,n,i)=>h4(s,"error",e,n,i)};function w0e(){nn.getState().submitCountdownStartAt!==null&&nn.setState({submitCountdownStartAt:null})}let y0e=null;const f4=1e4;let mR=null;function dK(){mR&&(clearTimeout(mR),mR=null)}let o6=null,a6=null;function p4(){o6=null,a6&&(a6(),a6=null)}const LQe=1500,NQe=9e4;let rI=0,l6=null,$Q=-1;function oI(){l6&&(clearTimeout(l6),l6=null,$Q=-1)}const DQe=1800*1e3;let _R=null;function TQe(){_R&&(clearTimeout(_R),_R=null)}const nn=ir((s,e)=>{function n(){TQe(),_R=setTimeout(()=>{if(_R=null,e().isRecording||y0e){n();return}ei.info("voice","model idle timeout: releasing worker"),oI(),rI++,s({modelStatus:"idle",loadingProgress:0,error:null,errorKind:null})},DQe)}return{isRecording:!1,externalRecording:!1,ttsEnabled:!1,autoSubmit:!0,submitDelayMs:8e3,submitCountdownStartAt:null,lastTranscript:"",lastPartial:"",statusPill:"idle",partialsEnabled:!0,error:null,errorKind:null,modelStatus:"idle",loadingProgress:0,permissionState:"unknown",lastBargeInAt:null,hotkeyState:"idle",levelMeterEnabled:!0,turnDetectorState:"disabled",turnDetectorMode:"off",wizardArmed:!1,wizardOpen:!1,initModel:()=>{if(e().modelStatus!=="idle")return;ei.info("voice","initModel: kicking off preload"),s({modelStatus:"loading",error:null,errorKind:null,loadingProgress:0});const i=++rI,r=()=>{i===rI&&(oI(),$Q=i,l6=setTimeout(()=>{$Q===i&&e().modelStatus==="loading"&&(ei.warn("voice","mic.gate.timeout: no progress within 90s"),s({modelStatus:"error",error:"Model load timed out",errorKind:"timeout"}))},NQe))};r(),vQe((o,a)=>{i===rI&&(o==="ready"?(oI(),ei.info("voice","modelStatus -> ready"),s({modelStatus:"ready",loadingProgress:100,errorKind:null}),!e().isRecording&&!y0e&&n()):o==="error"?(oI(),ei.error("voice","modelStatus -> error",{msg:a}),s({modelStatus:"error",error:a,errorKind:"load"})):(r(),s({modelStatus:"loading"})))},o=>{i===rI&&(r(),s({loadingProgress:Math.round(o)}))})},resetAndRetryModel:()=>{ei.info("voice","mic.gate.retry"),oI(),s({modelStatus:"idle",error:null,errorKind:null,loadingProgress:0}),e().initModel()},startRecording:(i,r)=>{if(!e().isRecording){s({error:"Microphone or Web Worker not available",errorKind:"recording"});return}},stopRecording:()=>{},restartWithDevice:async()=>{e().isRecording},setExternalRecording:i=>s({externalRecording:i}),toggleTTS:()=>{const i=!e().ttsEnabled;s({ttsEnabled:i}),Promise.resolve().then(()=>{var r,o,a;return(a=(o=(r=window.api)==null?void 0:r.voice)==null?void 0:o.setTtsEnabled)==null?void 0:a.call(o,i)}).catch(r=>{ei.warn("voice","setTtsEnabled failed",{error:r instanceof Error?r.message:String(r)})})},setAutoSubmit:i=>s({autoSubmit:i}),setSubmitDelayMs:i=>s({submitDelayMs:Math.max(500,Math.min(13e3,Math.floor(i)))}),cancelSubmit:()=>w0e(),setPartialsEnabled:i=>{e().partialsEnabled!==i&&(s({partialsEnabled:i}),i||s({lastPartial:""}))},clearError:()=>s({error:null,errorKind:null}),setPermissionState:i=>{e().permissionState!==i&&(ei.info("voice","mic.gate.permission_changed",{from:e().permissionState,to:i}),s({permissionState:i}))},setLevelMeterEnabled:i=>{e().levelMeterEnabled!==i&&s({levelMeterEnabled:i})},setTurnDetectorRuntimeState:i=>{e().turnDetectorState!==i&&(s({turnDetectorState:i}),i==="load_failed"?ei.warn("voice-turn","voice-turn.load_failed"):i==="runtime_error"?ei.warn("voice-turn","voice-turn.runtime_error"):i==="disabled"&&ei.info("voice-turn","voice-turn.fallback_to_vad"))},setWizardArmed:i=>{e().wizardArmed!==i&&s({wizardArmed:i})},openWizard:()=>{e().wizardOpen||s({wizardOpen:!0})},closeWizard:()=>{e().wizardOpen&&s({wizardOpen:!1})},armHotkey:({phase:i,source:r,mode:o,tabId:a})=>{const l=e(),{canRecord:c,reason:d}=P8();if(i==="down"){if(d==="error"||d==="load-timeout"){l.resetAndRetryModel(),ei.info("voice-hotkey","down.retry",{source:r,reason:d});return}if(!c&&d!=="loading"){ei.warn("voice-hotkey","miss-model-loading",{modelStatus:l.modelStatus,reason:d});return}if(l.hotkeyState==="recording"||l.isRecording){(o==="toggle"||r==="global")&&(s({hotkeyState:"stopping"}),dK(),mR=setTimeout(()=>{e().hotkeyState==="stopping"&&(ei.warn("voice-hotkey","drain-timeout",{durationMs:f4}),s({hotkeyState:"aborted"}),setTimeout(()=>{e().hotkeyState==="aborted"&&s({hotkeyState:"idle"})},0))},f4),l.stopRecording());return}if(d==="loading"){l.hotkeyState!=="armed"&&(s({hotkeyState:"armed"}),ei.info("voice-hotkey","armed",{source:r,modelStatus:l.modelStatus})),p4(),o6={tabId:a,source:r,mode:o},a6=nn.subscribe((u,h)=>{if(o6&&u.modelStatus==="ready"&&h.modelStatus!=="ready"&&u.hotkeyState==="armed"){const f=o6;if(p4(),!f.tabId){ei.warn("voice-hotkey","armed-promote-no-tab",{source:f.source}),s({hotkeyState:"idle"});return}ei.info("voice-hotkey","armed-promote",f),s({hotkeyState:"recording"}),nn.getState().startRecording(f.tabId)}});return}if(!a){ei.warn("voice-hotkey","no-active-tab",{source:r});return}ei.info("voice-hotkey","start",{source:r,mode:o,tabId:a}),l.startRecording(a),e().isRecording?s({hotkeyState:"recording"}):(ei.warn("voice-hotkey","start: recording did not engage",{errorKind:e().errorKind}),s({hotkeyState:"idle"}));return}if(!(o!=="hold"||r==="global")){if(l.hotkeyState==="armed"){p4(),ei.info("voice-hotkey","miss-model-loading-armed-up"),s({hotkeyState:"idle"});return}l.hotkeyState==="recording"&&(s({hotkeyState:"stopping"}),dK(),mR=setTimeout(()=>{e().hotkeyState==="stopping"&&(ei.warn("voice-hotkey","drain-timeout",{durationMs:f4}),s({hotkeyState:"aborted"}),setTimeout(()=>{e().hotkeyState==="aborted"&&s({hotkeyState:"idle"})},0))},f4),l.stopRecording())}},destroyHotkey:()=>{const i=e();if(p4(),w0e(),i.hotkeyState==="recording"){ei.warn("voice-hotkey","destroyed-mid-recording"),s({hotkeyState:"destroyed"});try{i.stopRecording()}catch{}}else(i.hotkeyState==="armed"||i.hotkeyState==="stopping")&&(dK(),s({hotkeyState:"destroyed"}))}}}),IQe=s=>({isRecording:s.isRecording,statusPill:s.statusPill,lastPartial:s.lastPartial,lastTranscript:s.lastTranscript,submitCountdownStartAt:s.submitCountdownStartAt}),P8=s=>({canRecord:!1,reason:"unsupported"});typeof window<"u"&&Promise.resolve().then(()=>{var s,e,n;return(n=(e=(s=window.api)==null?void 0:s.voice)==null?void 0:e.getTtsEnabled)==null?void 0:n.call(e)}).then(s=>{typeof s=="boolean"&&nn.setState({ttsEnabled:s})}).catch(s=>{ei.warn("voice","getTtsEnabled failed",{error:s instanceof Error?s.message:String(s)})});if(typeof window<"u"){const s=window;s.__voice=nn,s.__transcripts=[]}const iM=6e4,RQe=3e5,AQe=.25,MQe=5e3,RN=ir(()=>({data:null,refreshing:!1}));let C0e=!1,c6=null,uK=iM,g4=!1,u_=null;function PQe(s,e){if(s.kind==="ok")return{delayMs:iM,nextBackoffMs:iM};const n=Math.min(e*2,RQe),i=n*AQe;let r=n+(Math.random()*2-1)*i;const o=s.kind==="meter_rate_limited"?s.retryAfterMs:void 0;return typeof o=="number"&&Number.isFinite(o)&&o>r&&(r=o),{delayMs:r,nextBackoffMs:n}}function S0e(){return nue(window.api.billing.fetch(),MQe,"billing.fetch")}function k0e(s){RN.setState({data:s,refreshing:!1})}async function fue(){RN.setState({refreshing:!0});let s=iM;try{const e=await S0e();u_&&(u_.cancel(),u_=null),k0e(e);const{delayMs:n,nextBackoffMs:i}=PQe(e,uK);uK=i,s=n}catch(e){uK=iM,RN.setState({refreshing:!1});const n=fOe({error:e,retry:S0e,onRetrySuccess:i=>{u_=null,k0e(i)},onStillFailing:i=>{u_=null,g4||(g4=!0,pe.warn(`Billing usage fetch: ${i}`))}});if(n)u_=n;else if(!g4){g4=!0;const i=e instanceof Error?e.message:String(e);pe.warn(`Billing usage fetch failed: ${i}`)}}c6=setTimeout(fue,s)}function OQe(){C0e||(C0e=!0,fue())}function WOe(s){return s?s.kind==="ok"||s.kind==="ok-stale"?s.data:(s.kind==="auth"||s.kind==="meter_rate_limited")&&s.cached?s.cached:null:null}function $Oe(){c6!==null&&(clearTimeout(c6),c6=null),u_&&(u_.cancel(),u_=null),fue()}function S0(s){if(!s||s==="—"||s==="unknown")return s;const e=/\[(\dm)\]/.exec(s),n=/(opus|sonnet|haiku|fable)[-_](\d+)[-_.]?(\d+)?/i.exec(s);if(!n)return s;const i=n[1].charAt(0).toUpperCase()+n[1].slice(1).toLowerCase(),r=n[3]?`${n[2]}.${n[3]}`:n[2];return e?`${i} ${r} ${e[1]}`:`${i} ${r}`}function Id(s){const e=/(opus|sonnet|haiku|fable)/i.exec(s);return e?e[1].toLowerCase():null}const m4=new Map,jQe=3e4;function pue(s){const[e,n]=T.useState(()=>{var i;return s?((i=m4.get(s))==null?void 0:i.value)??null:null});return T.useEffect(()=>{if(!s){n(null);return}let i=!1;return(async()=>{const o=m4.get(s);if(o&&Date.now()-o.ts<jQe){i||n(o.value);return}try{const a=await window.api.app.gitBranch(s);if(i)return;m4.set(s,{value:a,ts:Date.now()}),n(a)}catch{if(i)return;m4.set(s,{value:null,ts:Date.now()}),n(null)}})(),()=>{i=!0}},[s]),e}const FQe="~/.claude/session-manager/ui-chrome-prefs.json",VOe=Qg(FQe),BQe=180,HQe=480,VQ=252,yw={sidebarWidth:VQ,sidebarCollapsed:!1,collapsedGroups:[],learningPanelCollapsed:!1,tourCompletedAt:null,density:"roomy"};function zQ(s){return Math.min(HQe,Math.max(BQe,s))}let ix=null,d6={};function WQe(s){const e=()=>{const n=s(),i={sidebarWidth:n.sidebarWidth,sidebarCollapsed:n.sidebarCollapsed,collapsedGroups:n.collapsedGroups,learningPanelCollapsed:n.learningPanelCollapsed,tourCompletedAt:n.tourCompletedAt,density:n.density};VOe.patch(i).catch(()=>{})};s().hydrated||!ix?e():ix.then(e)}function Fk(s,e,n){s(n),!e().hydrated&&ix&&Object.assign(d6,n),WQe(e)}const Fo=ir((s,e)=>({...yw,hydrated:!1,hydrate:()=>e().hydrated?Promise.resolve():ix||(ix=(async()=>{try{const n=await VOe.read();if(Object.keys(n).length>0){s({sidebarWidth:typeof n.sidebarWidth=="number"?zQ(n.sidebarWidth):yw.sidebarWidth,sidebarCollapsed:n.sidebarCollapsed??yw.sidebarCollapsed,collapsedGroups:Array.isArray(n.collapsedGroups)?n.collapsedGroups:yw.collapsedGroups,learningPanelCollapsed:n.learningPanelCollapsed??yw.learningPanelCollapsed,tourCompletedAt:typeof n.tourCompletedAt=="number"?n.tourCompletedAt:yw.tourCompletedAt,density:n.density==="compact"?"compact":yw.density,...d6,hydrated:!0});return}}catch{}s({...d6,hydrated:!0})})().finally(()=>{ix=null,d6={}}),ix),setSidebarWidth:n=>Fk(s,e,{sidebarWidth:zQ(n)}),setSidebarCollapsed:n=>Fk(s,e,{sidebarCollapsed:n}),setCollapsedGroups:n=>Fk(s,e,{collapsedGroups:n}),setLearningPanelCollapsed:n=>Fk(s,e,{learningPanelCollapsed:n}),setTourCompletedAt:n=>Fk(s,e,{tourCompletedAt:n}),setDensity:n=>Fk(s,e,{density:n})})),$Qe=52;function VQe(s){return new Set(s.filter(e=>e==="Workspace"||e==="Claude Code"||e==="Session Manager"))}function zQe(){const s=Ft(n=>{var i;return((i=n.tabs.find(r=>r.id===n.activeTabId))==null?void 0:i.cwd)??null});return{scheduler:Aa(n=>{var i;return(((i=n.snapshot)==null?void 0:i.jobs)??[]).some(r=>r.status==="running"&&(!s||r.cwd===s))})}}function UQe({active:s,onNavigate:e,onNewSession:n}){const i=Fo(P=>P.hydrated),r=Fo(P=>P.hydrate);T.useEffect(()=>{i||r()},[i,r]);const o=Fo(P=>P.collapsedGroups),a=Fo(P=>P.setCollapsedGroups),l=T.useMemo(()=>VQe(o),[o]),c=T.useCallback(P=>{const H=new Set(l);H.has(P)?H.delete(P):H.add(P),a(Array.from(H))},[l,a]),d=Fo(P=>P.sidebarCollapsed),u=Fo(P=>P.setSidebarCollapsed),h=T.useCallback(()=>{u(!d)},[d,u]),f=Ft(P=>P.tabs),g=Ft(P=>P.activeTabId),m=f.find(P=>P.id===g)??null,_=zQe(),b=di(P=>P.navFace),v=FJe(b),x=v.filter(P=>P.group==="Workspace"),w=v.filter(P=>P.group==="Claude Code"),y=v.filter(P=>P.group==="Session Manager"),S=b==="home"&&!d,E=Fo(P=>P.sidebarWidth),L=Fo(P=>P.setSidebarWidth),[N,I]=T.useState(E),A=T.useRef(N);A.current=N,T.useEffect(()=>{I(E)},[E]);const j=T.useCallback(P=>{P.preventDefault();const H=P.clientX,B=A.current;let U=B;const Z=M=>{U=zQ(B+(M.clientX-H)),I(U)},Y=()=>{window.removeEventListener("pointermove",Z),window.removeEventListener("pointerup",Y),document.body.style.cursor="",document.body.style.userSelect="",L(U)};window.addEventListener("pointermove",Z),window.addEventListener("pointerup",Y),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[L]),F=T.useCallback(()=>{I(VQ),L(VQ)},[L]);return p.jsxs("aside",{className:"shrink-0 bg-bg-elev border-r border-line flex flex-col relative transition-[width] duration-150",style:{width:d?$Qe:N},"data-testid":"tour-leftnav","aria-label":"Primary navigation",children:[p.jsx(GQe,{tab:m,navFace:b,onNewSession:n,rail:d,onToggleRail:h}),p.jsx("div",{className:"flex-1 min-h-0 overflow-auto pb-3",style:{paddingInline:d?"4px":"8px"},children:S?p.jsxs(p.Fragment,{children:[p.jsx(hK,{label:"Workspace",desc:lK.Workspace,collapsed:l.has("Workspace"),count:x.length,onToggle:()=>c("Workspace")}),!l.has("Workspace")&&x.map(P=>p.jsx(_4,{item:P,active:s===P.key,live:P.liveKind?_[P.liveKind]:!1,onClick:()=>e(P.key),rail:!1},P.key)),p.jsx(hK,{label:"Claude Code",desc:lK["Claude Code"],collapsed:l.has("Claude Code"),count:w.length,onToggle:()=>c("Claude Code")}),!l.has("Claude Code")&&w.map(P=>p.jsx(_4,{item:P,active:s===P.key,live:!1,onClick:()=>e(P.key),rail:!1},P.key)),p.jsx(hK,{label:"Session Manager",desc:lK["Session Manager"],collapsed:l.has("Session Manager"),count:y.length,onToggle:()=>c("Session Manager")}),!l.has("Session Manager")&&y.map(P=>p.jsx(_4,{item:P,active:s===P.key,live:!1,onClick:()=>e(P.key),rail:!1},P.key))]}):p.jsx("div",{className:"pt-2",children:v.map(P=>p.jsx(_4,{item:P,active:s===P.key,live:P.liveKind?_[P.liveKind]:!1,onClick:()=>e(P.key),rail:d},P.key))})}),p.jsx(qQe,{rail:d,navFace:b}),!d&&p.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",title:"Drag to resize · double-click to reset",onPointerDown:j,onDoubleClick:F,className:"absolute top-0 right-0 h-full w-1.5 translate-x-1/2 z-10 cursor-col-resize hover:bg-accent/40 active:bg-accent/60 transition-colors"})]})}function GQe({tab:s,navFace:e,onNewSession:n,rail:i,onToggleRail:r}){const o=(s==null?void 0:s.label)??"no session",a=pue((s==null?void 0:s.cwd)??null);return i?p.jsxs("div",{className:"flex flex-col items-center gap-1.5 pt-2 pb-2 border-b border-rule",children:[p.jsx("button",{onClick:n,"data-testid":"tour-new-session",title:"Open / Start Project",className:"w-9 h-9 rounded-md bg-bg-hi border border-line text-fg hover:bg-bg-hi/80 hover:border-accent/40 transition-colors flex items-center justify-center",children:p.jsx(Ci,{name:"plus",size:15,stroke:1.8})}),p.jsx("button",{onClick:r,title:"Expand sidebar","data-testid":"sidebar-rail-toggle",className:"w-9 h-9 rounded-md text-fg-faint hover:text-fg hover:bg-bg-hi/50 transition-colors flex items-center justify-center",children:p.jsx("span",{style:{display:"inline-flex",transform:"rotate(0deg)"},children:p.jsx(Ci,{name:"chevron",size:15,stroke:1.8})})})]}):e==="home"?p.jsxs("div",{className:"px-[18px] pt-[14px] pb-[10px] border-b border-rule",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("div",{className:"text-[11px] font-semibold tracking-[0.06em] text-fg-faint uppercase",children:"Session Manager"}),p.jsx("button",{onClick:r,title:"Collapse sidebar","data-testid":"sidebar-rail-toggle",className:"w-6 h-6 rounded-md text-fg-faint hover:text-fg hover:bg-bg-hi/50 transition-colors flex items-center justify-center",children:p.jsx("span",{style:{display:"inline-flex",transform:"rotate(180deg)"},children:p.jsx(Ci,{name:"chevron",size:13,stroke:1.8})})})]}),p.jsx("div",{className:"mt-3 flex items-stretch gap-1.5",children:p.jsxs("button",{onClick:n,"data-testid":"tour-new-session",className:"flex-1 px-3 py-1.5 rounded-md bg-bg-hi border border-line text-fg text-[12.5px] font-medium hover:bg-bg-hi/80 hover:border-accent/40 transition-colors flex items-center justify-center gap-1.5",children:[p.jsx(Ci,{name:"plus",size:13,stroke:1.8}),"Open / Start Project"]})})]}):p.jsxs("div",{className:"px-[18px] pt-[14px] pb-[10px] border-b border-rule",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("div",{className:"text-[11px] font-semibold tracking-[0.06em] text-fg-faint uppercase",children:"Project"}),p.jsx("button",{onClick:r,title:"Collapse sidebar","data-testid":"sidebar-rail-toggle",className:"w-6 h-6 rounded-md text-fg-faint hover:text-fg hover:bg-bg-hi/50 transition-colors flex items-center justify-center",children:p.jsx("span",{style:{display:"inline-flex",transform:"rotate(180deg)"},children:p.jsx(Ci,{name:"chevron",size:13,stroke:1.8})})})]}),p.jsxs("div",{className:"flex items-baseline gap-2 mt-1",children:[p.jsx("span",{className:"self-center w-2 h-2 rounded-full bg-sage"}),p.jsx("span",{className:"font-serif text-[18px] font-medium text-fg truncate",title:(s==null?void 0:s.cwd)??"",children:o})]}),p.jsx("div",{className:"text-[12px] text-fg-faint font-mono mt-0.5 truncate",children:a?`⌥${a}`:s?s.cwd:"—"}),p.jsx("div",{className:"mt-3 flex items-stretch gap-1.5",children:p.jsxs("button",{onClick:n,"data-testid":"tour-new-session",className:"flex-1 px-3 py-1.5 rounded-md bg-bg-hi border border-line text-fg text-[12.5px] font-medium hover:bg-bg-hi/80 hover:border-accent/40 transition-colors flex items-center justify-center gap-1.5",children:[p.jsx(Ci,{name:"plus",size:13,stroke:1.8}),"Open / Start Project"]})})]})}function hK({label:s,desc:e,collapsed:n,count:i,onToggle:r}){return p.jsxs("div",{className:"px-3 pt-3.5 pb-1.5",children:[p.jsxs("button",{onClick:r,"aria-expanded":!n,title:n?`Expand ${s}`:`Collapse ${s}`,className:"group w-full flex items-center gap-1.5 font-serif italic text-[11px] font-bold tracking-[0.07em] uppercase text-fg-faint hover:text-fg-dim transition-colors text-left",children:[p.jsx("span",{"aria-hidden":!0,className:"inline-block w-2 text-[9px] not-italic transition-transform",style:{transform:n?"rotate(-90deg)":"rotate(0deg)"},children:"▾"}),p.jsx("span",{className:"flex-1",children:s}),n&&p.jsx("span",{className:"not-italic text-[10px] font-mono text-fg-faint/70 normal-case tracking-normal",children:i})]}),!n&&p.jsx("p",{className:"mt-0.5 pl-3.5 text-[11px] leading-[1.35] text-fg-faint/80 normal-case tracking-normal font-sans not-italic line-clamp-2",children:e})]})}function _4({item:s,active:e,live:n,onClick:i,rail:r}){return p.jsxs("button",{onClick:i,title:s.hint,"data-testid":s.key==="scheduler"?"tour-scheduler":s.key==="terminal"?"tour-sessions":void 0,className:`relative w-full flex items-center rounded-[10px] text-left mb-0.5 transition-colors ${r?"justify-center px-0 py-[9px]":"gap-3 px-3.5 py-[9px] text-[14px]"} ${e?"bg-bg-hi text-fg font-semibold border border-line":"text-fg-dim hover:bg-bg-hi/50 hover:text-fg border border-transparent"}`,children:[e&&p.jsx("span",{"aria-hidden":!0,className:`absolute top-2 bottom-2 w-[3px] rounded-sm bg-accent ${r?"-left-[4px]":"-left-[10px]"}`}),p.jsx("span",{className:`inline-flex ${e?"text-accent":"text-fg-faint"}`,children:p.jsx(Ci,{name:s.icon,size:17,stroke:1.6})}),!r&&p.jsxs("span",{className:"flex-1 min-w-0",children:[p.jsx("span",{className:"block truncate",children:s.label}),s.hint&&p.jsx("span",{className:"block text-[11px] leading-[1.3] text-fg-faint/80 font-normal truncate",children:s.hint})]}),!r&&n&&p.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-accent animate-pulse",title:"live activity"}),r&&n&&p.jsx("span",{className:"absolute top-1.5 right-1.5 w-1.5 h-1.5 rounded-full bg-accent animate-pulse",title:"live activity"})]})}function qQe({rail:s,navFace:e}){const n=nn(c=>c.isRecording),i=Ft(c=>c.tabs),r=Ft(c=>c.activeTabId),o=i.find(c=>c.id===r)??null,[a,l]=T.useState(null);return T.useEffect(()=>{let c=!1;if(!(o!=null&&o.presetId)){l(null);return}return cOe(o.presetId).then(d=>{c||l((d==null?void 0:d.model)??null)}).catch(()=>{c||l(null)}),()=>{c=!0}},[o==null?void 0:o.presetId]),s?p.jsx("div",{className:"py-2.5 border-t border-rule flex justify-center",children:p.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${n?"bg-red-500 animate-pulse":"bg-sage"}`,title:n?"recording":"idle"})}):p.jsxs("div",{className:"px-3.5 py-2.5 border-t border-rule flex items-center gap-2 text-[11.5px] text-fg-dim font-mono",children:[p.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${n?"bg-red-500 animate-pulse":"bg-sage"}`,title:n?"recording":"idle"}),(n||e==="project")&&p.jsx("span",{className:"truncate",title:a??"",children:n?"recording…":a?`Claude · ${S0(a)}`:"Claude Code"})]})}function KQe(s,e,n){return e?s.map(i=>i.id===e?{...i,lastActivityAt:n}:i):s}function YQe(s,e,n){return{tabId:s,sessionUuid:n,cwd:e,path:null,todos:[],lastToolUses:[],plans:[],agents:[],usage:{inputTokens:0,outputTokens:0},lastEventAt:0,activityRing:[],activitySeq:0}}function XQe(s,e,n){const i=Date.now(),r={...s,lastEventAt:n!=null&&n.replay?s.lastEventAt:i},o=[],a=(l,c)=>l.length>c?l.slice(0,c-1)+"…":l;switch(e.kind){case"todo_write":{const l=Array.isArray(e.data)?e.data:[];r.todos=l,n!=null&&n.replay||o.push({id:0,kind:"todo-update",at:i,label:`Todos · ${l.length} item${l.length!==1?"s":""}`});break}case"tool_use":{const l=e.data,c=l.input,d={};for(const u of["command","file_path","pattern","url","query","subagent_type","description"])c&&u in c&&(d[u]=c[u]);if(r.lastToolUses=[{id:l.id,name:l.name,input:d,at:i},...s.lastToolUses].slice(0,50),!(n!=null&&n.replay)){const u=l.input,h=["Edit","Write","NotebookEdit"].includes(l.name),f=typeof(u==null?void 0:u.file_path)=="string"?u.file_path:void 0,g=typeof(u==null?void 0:u.command)=="string"?u.command:void 0,m=f?f.split("/").pop()??f:g?a(g,28):"";o.push({id:0,kind:"tool-use",at:i,label:m?`${l.name} · ${m}`:l.name,target:f??g,toolName:l.name}),h&&f&&o.push({id:0,kind:"file-edit",at:i,label:`${l.name} · ${a(f.split("/").pop()??f,34)}`,target:f,toolName:l.name})}break}case"plan":{const l=e.data,c=typeof l=="string"?l:(l==null?void 0:l.plan)??JSON.stringify(l);r.plans=[{at:i,content:c??""},...s.plans].slice(0,50),n!=null&&n.replay||o.push({id:0,kind:"plan-revision",at:i,label:"Plan revised"});break}case"agent_spawn":{const l=e.data;r.agents=[{id:l==null?void 0:l.toolUseId,at:i,subagentType:l==null?void 0:l.subagent_type,description:l==null?void 0:l.description,lastActivityAt:i},...s.agents].slice(0,50),n!=null&&n.replay||o.push({id:0,kind:"agent-spawn",at:i,label:l!=null&&l.subagent_type?`Agent: ${a(l.subagent_type,32)}`:"Agent spawned"});break}case"usage":{const l=e.data,c=(s.usage.inputTokens||0)+(s.usage.outputTokens||0),d=l.input_tokens??l.inputTokens??0,u=l.output_tokens??l.outputTokens??0,h=c+d+u;r.usage={inputTokens:(s.usage.inputTokens||0)+d,outputTokens:(s.usage.outputTokens||0)+u,cacheCreationInputTokens:(s.usage.cacheCreationInputTokens||0)+(l.cache_creation_input_tokens??l.cacheCreationInputTokens??0),cacheReadInputTokens:(s.usage.cacheReadInputTokens||0)+(l.cache_read_input_tokens??l.cacheReadInputTokens??0)},!(n!=null&&n.replay)&&Math.floor(h/1e3)>Math.floor(c/1e3)&&o.push({id:0,kind:"usage-tick",at:i,label:`${Math.floor(h/1e3)}k tokens`});break}case"tool_result":{const l=e.data;r.agents=KQe(s.agents,l==null?void 0:l.toolUseId,i);break}}return{next:r,newActivity:o}}const u6=ir((s,e)=>({tabs:{},refs:{},unsubs:{},subscribe:(n,i,r)=>{const o={...e().refs};if(o[n]=(o[n]??0)+1,s({refs:o}),o[n]>1)return;s({tabs:{...e().tabs,[n]:YQe(n,i,r)}});const a=window.api.transcripts.onEvent(n,l=>e().ingestBatch(n,l));s({unsubs:{...e().unsubs,[n]:a}}),window.api.transcripts.subscribe({tabId:n,cwd:i,sessionUuid:r}).then(async l=>{const c=e().tabs[n];if(!c)return;if(!l.ok){const{toast:u}=await $n(async()=>{const{toast:h}=await Promise.resolve().then(()=>uOe);return{toast:h}},void 0,import.meta.url);u.error(`Live view unavailable: ${l.error??"subscribe failed"}`),s({tabs:{...e().tabs,[n]:{...c,path:null}}});return}s({tabs:{...e().tabs,[n]:{...c,path:l.path}}});const d=await window.api.transcripts.buffer(n);e().ingestBatch(n,d,{replay:!0})}).catch(l=>console.error("[live] transcripts.subscribe failed:",n,l))},unsubscribe:n=>{const i={...e().refs};if(!i[n])return;if(i[n]--,i[n]>0){s({refs:i});return}delete i[n];const r=e().unsubs[n];r==null||r();const o={...e().unsubs};delete o[n];const a={...e().tabs};delete a[n],window.api.transcripts.unsubscribe(n),s({refs:i,unsubs:o,tabs:a})},ingest:(n,i,r)=>{e().ingestBatch(n,[i],r)},ingestBatch:(n,i,r)=>{const o=e().tabs[n];if(!o||i.length===0)return;let a=o,l=[];for(const c of i){const{next:d,newActivity:u}=XQe(a,c,r);a=d,l=l.concat(u)}if(l.length>0){let c=o.activitySeq;const d=l.map(u=>({...u,id:++c}));a={...a,activitySeq:c,activityRing:[...o.activityRing,...d].slice(-32)}}s({tabs:{...e().tabs,[n]:a}})}}));function ZQe(s){const e=u6(r=>r.subscribe),n=u6(r=>r.unsubscribe),i=u6(r=>s?r.tabs[s.id]:void 0);return T.useEffect(()=>{if(s)return e(s.id,s.cwd,s.sessionId),()=>n(s.id)},[s==null?void 0:s.id,s==null?void 0:s.cwd,s==null?void 0:s.sessionId,e,n]),i}function zOe(s){if(!s)return null;const e=new Date(s);if(Number.isNaN(e.getTime()))return null;const n=e.getTime()-Date.now();if(n<=0)return{rel:"now",abs:""};const i=Math.floor(n/864e5),r=Math.floor(n%864e5/36e5),o=Math.floor(n%36e5/6e4),a=i>0?`${i}d ${r}h`:r>0?`${r}h ${o}m`:`${o}m`,l=i>=1?e.toLocaleString("en-US",{timeZone:"America/Los_Angeles",weekday:"short",hour:"numeric",minute:"2-digit"}):e.toLocaleTimeString("en-US",{timeZone:"America/Los_Angeles",hour:"numeric",minute:"2-digit"});return{rel:a,abs:`${l} PT`}}function UQ(s){return!s||typeof s.utilization!="number"||Number.isNaN(s.utilization)?null:Math.round(s.utilization)}function E0e(s,e){const n=UQ(e);if(n==null)return`${s} — usage unavailable`;const i=zOe((e==null?void 0:e.resets_at)??null),r=i?` · resets in ${i.rel}${i.abs?` (${i.abs})`:""}`:"";return`${s} · ${n}% used${r} — click to open Home`}function JQe(s,e){return s?s==="session"||s==="five_hour"?"Session · 5h":s==="weekly_all"?"Weekly · all models":s==="weekly_scoped"?"Weekly · scoped":s:null}const UOe=T.createContext(null);function QQe({panelId:s,children:e}){return p.jsx(UOe.Provider,{value:s,children:e})}function q0(s){const e=T.useContext(UOe),n=s??e;return di(i=>n==null||i.focusedPanelId===n)}function gue(s){const e=q0(s),n=T.useRef(e);return n.current=e,n}const eet=5e3;let hy=null;const GQ=new Set;let fK=0,bR=null;function tet(){GQ.forEach(s=>s())}async function O8(){try{hy=await window.api.schedule.sessionSlots(),tet()}catch{}}const net=0,iet=10;async function set(s){hy||await O8();const e=hy?hy.min:net,n=hy?hy.max:iet,i=Math.min(n,Math.max(e,Math.round(s)));await window.api.schedule.setSessionSlots(i),await O8()}function ret(){bR==null&&(O8(),bR=setInterval(()=>{O8()},eet))}function oet(){bR!=null&&(clearInterval(bR),bR=null)}function WO(s){const e=q0(s),[,n]=T.useState(0);return T.useEffect(()=>{const i=()=>n(r=>r+1);return GQ.add(i),()=>{GQ.delete(i)}},[]),T.useEffect(()=>{if(e)return fK+=1,ret(),()=>{fK-=1,fK<=0&&oet()}},[e]),hy}let EE=null;const qQ=new Set;let pK=0,h6=null,KQ=!1;const aet=360*60*1e3;let f6=null;function L0e(s){EE=s.check||!(EE!=null&&EE.check)?s:{...s,check:EE.check},qQ.forEach(e=>e())}function cet(){if(KQ)return;KQ=!0,h6=window.api.updater.onStatus(L0e);const s=()=>{window.api.updater.status().then(L0e).catch(()=>{})};s(),f6=setInterval(s,aet)}function det(){KQ=!1,f6!=null&&(clearInterval(f6),f6=null),h6&&(h6(),h6=null)}function GOe(){const[,s]=T.useState(0);return T.useEffect(()=>{const e=()=>s(n=>n+1);return qQ.add(e),pK+=1,cet(),()=>{qQ.delete(e),pK-=1,pK<=0&&det()}},[]),EE}function qOe({total:s,inUse:e,size:n}){const i=Math.min(Math.max(e,0),s),r=n==="md"?"w-3.5 h-3.5 rounded-full border":"w-2 h-2 rounded-full border";return p.jsx(p.Fragment,{children:Array.from({length:s},(o,a)=>p.jsx("span",{"data-testid":"slot-dot","data-filled":a<i?"true":"false",className:`${r} ${a<i?"bg-accent border-accent":"bg-bg border-line"}`},a))})}function uet({onNavigate:s}){const e=Ft(B=>B.tabs),n=Ft(B=>B.activeTabId),i=e.find(B=>B.id===n)??null,r=ZQe(i),o=(r==null?void 0:r.lastEventAt)??0,a=RN(B=>B.data),l=Aa(B=>{var U;return((U=B.snapshot)==null?void 0:U.paused)??null}),c=pue((i==null?void 0:i.cwd)??null),d=WO(),u=GOe(),h=(u==null?void 0:u.check)??null,f=rs(B=>B.show),[,g]=T.useState(0);T.useEffect(()=>{const B=setInterval(()=>g(U=>U+1),6e4);return()=>clearInterval(B)},[]);const m=async()=>{const B=(u==null?void 0:u.latest)??"";try{const U=await window.api.updater.install(!1),Z=(U==null?void 0:U.status)??await window.api.updater.status();(Z==null?void 0:Z.state)==="deferred"&&f("info",`Update v${B} will install when ${Z.busyReason??"running jobs"} finish`)}catch(U){f("error",U instanceof Error?U.message:String(U))}},_=(r==null?void 0:r.todos)??[],[b,v]=T.useState(!1),x=T.useRef(null);T.useEffect(()=>{if(!b)return;const B=U=>{x.current&&!x.current.contains(U.target)&&v(!1)};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[b]),T.useEffect(()=>{_.length===0&&v(!1)},[_.length]);const w=WOe(a),y=(w==null?void 0:w.usage.five_hour)??null,S=(w==null?void 0:w.usage.seven_day)??null,E=UQ(y),L=UQ(S),N=(a==null?void 0:a.kind)==="ok"||(a==null?void 0:a.kind)==="ok-stale",I=o>0?pet(Date.now()-o):"—",A=(d==null?void 0:d.total)??5,j=d?Math.min(Math.max(d.inUse,0),d.total):0,F=d?`${j} / ${A}`:`— / ${A}`,P=d&&d.holders.length>0?`
|
|
79
79
|
`+d.holders.slice(0,5).map(B=>B.owner).join(`
|
|
80
|
-
`):"",H=`${F} Claude sessions running${P}`;return p.jsxs("div",{className:"h-[30px] shrink-0 bg-bg-elev border-t border-line flex items-center gap-4 px-[18px] font-mono text-[11.5px] text-fg-dim","data-testid":"tour-statusbar",children:[p.jsxs("button",{onClick:()=>s==null?void 0:s("settings"),className:"flex items-center gap-1.5 hover:text-fg transition-colors",title:N?"Connected to Anthropic":"Disconnected",children:[p.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${N?"bg-sage":"bg-fg-faint"}`}),p.jsx("span",{children:N?"connected":"offline"})]}),p.jsxs("button",{onClick:()=>s==null?void 0:s("overview"),className:"hover:text-fg transition-colors",title:E0e("Session (5h window)",y),"data-testid":"footer-usage-session",children:["session ",p.jsx("span",{className:"text-fg",children:E!=null?`${E}%`:"—"})]}),p.jsxs("button",{onClick:()=>s==null?void 0:s("overview"),className:"hover:text-fg transition-colors",title:E0e("Weekly window (all models)",S),"data-testid":"footer-usage-weekly",children:["weekly ",p.jsx("span",{className:"text-fg",children:L!=null?`${L}%`:"—"})]}),l&&p.jsxs("button",{onClick:()=>s==null?void 0:s("scheduler"),title:"Scheduler is paused — click to open Scheduler",className:`flex items-center gap-1 px-1.5 py-0.5 rounded border font-mono text-[10.5px] transition-colors ${l.reason==="auth"||l.reason==="network"?"border-red-700/60 text-red-300 hover:bg-red-900/20":"border-amber-700/60 text-amber-300 hover:bg-amber-900/20"}`,children:[p.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current opacity-80"}),"Scheduler paused · ",l.reason]}),i&&p.jsxs("span",{className:"text-fg-faint",title:i.cwd,children:[i.label,c&&p.jsxs("span",{className:"text-fg-dim",children:[" · ⌥",c]})]}),p.jsxs("span",{className:"text-fg-faint",children:["last activity: ",p.jsx("span",{className:"text-fg-dim",children:I})]}),_.length>0&&p.jsx(het,{ref:x,todos:_,open:b,onToggle:()=>v(B=>!B)}),p.jsx("span",{className:"flex-1"}),p.jsx("button",{onClick:()=>s==null?void 0:s("overview"),className:"flex items-center gap-1 hover:text-fg transition-colors",title:H,"data-testid":"footer-active-sessions",children:d&&d.total===0?p.jsx("span",{className:"text-fg-faint",children:"pool paused"}):p.jsx(qOe,{total:A,inUse:(d==null?void 0:d.inUse)??0,size:"sm"})}),(u==null?void 0:u.state)==="ready"?p.jsxs("button",{type:"button",className:"text-amber-300 hover:underline",title:"A new version is downloaded. Click to restart and install — running jobs are waited for first.","data-testid":"footer-version",onClick:()=>{m()},children:["Update ready — restart to install v",u.latest]}):(u==null?void 0:u.state)==="deferred"?p.jsxs("span",{className:"text-amber-300",title:`Waiting for ${u.busyReason??"running jobs"} to finish before restarting`,"data-testid":"footer-version",children:["v",u.latest," installs when idle"]}):(u==null?void 0:u.state)==="downloading"?p.jsxs("span",{className:"text-fg-dim","data-testid":"footer-version",children:["Downloading v",u.latest,"…"]}):h!=null&&h.behind&&h.latest&&h.channel==="installer"?p.jsxs("button",{type:"button",className:"text-amber-300 hover:underline",title:`v${h.current} → v${h.latest}`,"data-testid":"footer-version",onClick:()=>{const B=h.downloadUrl;B&&window.api.shell.open({as:"external",url:B}).catch(()=>{f("error",`Couldn't open URL: ${B}`)})},children:["Download v",h.latest]}):h!=null&&h.behind&&h.latest?p.jsxs("span",{className:"text-amber-300",title:"A newer version is published — update the app. A stale npx cache can pin an old version.","data-testid":"footer-version",children:["v",h.current," → v",h.latest]}):p.jsxs("span",{className:"text-fg-dim","data-testid":"footer-version",children:["v",(h==null?void 0:h.current)??"0.140.0"]})]})}const het=T.forwardRef(function({todos:e,open:n,onToggle:i},r){const o={completed:e.filter(a=>a.status==="completed").length,in_progress:e.filter(a=>a.status==="in_progress").length,pending:e.filter(a=>a.status==="pending").length};return p.jsxs("div",{ref:r,className:"relative",children:[p.jsxs("button",{onClick:i,className:"flex items-center gap-1.5 hover:text-fg transition-colors",title:"Live to-dos for this session","data-testid":"footer-todos",children:[p.jsxs("span",{className:"text-green-400",children:["✓",o.completed]}),p.jsxs("span",{className:"text-accent",children:["●",o.in_progress]}),p.jsxs("span",{className:"text-fg-dim",children:["○",o.pending]}),p.jsxs("span",{className:"text-fg-faint",children:["todos ",n?"▾":"▴"]})]}),n&&p.jsx("div",{className:`absolute bottom-full left-0 mb-1.5 w-80 max-h-72 overflow-auto bg-bg-elev border border-line rounded shadow-xl p-2 ${xi.dialog}`,"data-testid":"footer-todos-popover",children:p.jsx("ul",{className:"space-y-0.5",children:e.map((a,l)=>p.jsxs("li",{className:`flex items-start gap-2 py-1 px-1.5 rounded ${a.status==="in_progress"?"bg-bg-hi":""}`,children:[p.jsx(fet,{status:a.status}),p.jsx("span",{className:a.status==="completed"?"text-fg-faint line-through":a.status==="in_progress"?"text-fg":"text-fg-dim",children:a.status==="in_progress"&&a.activeForm?a.activeForm:a.content})]},l))})})]})});function fet({status:s}){return s==="completed"?p.jsx("span",{className:"text-green-400 w-3 shrink-0",children:"✓"}):s==="in_progress"?p.jsx("span",{className:"w-3 shrink-0",children:p.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-accent animate-pulse"})}):p.jsx("span",{className:"text-fg-faint w-3 shrink-0",children:"○"})}function pet(s){const e=Math.max(0,Math.floor(s/1e3));if(e<60)return`${e}s ago`;const n=Math.floor(e/60);return n<60?`${n}m ago`:`${Math.floor(n/60)}h ago`}function get({onClose:s,onSent:e}){const n=Ft(L=>L.tabs),[i,r]=T.useState(""),[o,a]=T.useState(()=>Object.fromEntries(n.map(L=>[L.id,!0]))),[l,c]=T.useState(!1),[d,u]=T.useState({}),h=T.useRef(null),f=T.useRef(e);T.useEffect(()=>{f.current=e},[e]),T.useEffect(()=>{a(L=>{const N={};for(const I of n)N[I.id]=L[I.id]??!0;return N})},[n]),T.useEffect(()=>{var L;(L=h.current)==null||L.focus()},[]),T.useEffect(()=>window.api.pty.onWriteError(N=>{u(I=>N.tabId in I?{...I,[N.tabId]:"skipped"}:I)}),[]),T.useEffect(()=>{if(Object.keys(d).length===0)return;const L=Object.values(d).filter(I=>I==="sent").length,N=window.setTimeout(()=>f.current(L),1500);return()=>window.clearTimeout(N)},[d]);const g=n.filter(L=>o[L.id]).map(L=>L.id),m=g.length,_=Object.keys(d).length>0,b=i.length>0&&m>0&&!l&&!_,v=()=>{if(!b)return;c(!0);const L=Ft.getState().tabs,N=new Set(L.map(A=>A.id)),I={};for(const A of g)N.has(A)?(window.api.pty.write({tabId:A,data:i+"\r"}),I[A]="sent"):I[A]="skipped";u(I),c(!1)},x=L=>{if(L.key==="Escape"){L.preventDefault(),L.stopPropagation(),s();return}L.key==="Enter"&&(L.metaKey||L.ctrlKey)&&(L.preventDefault(),v())},w=n.length>0&&n.every(L=>o[L.id]),y=()=>{const L=!w;a(Object.fromEntries(n.map(N=>[N.id,L])))},S=Object.values(d).some(L=>L==="skipped"),E=_?S?"Sent (some skipped)":"Sent":`Send to ${m} tab${m===1?"":"s"}`;return p.jsxs("div",{className:"border-b border-line bg-bg-elev px-4 py-3 flex flex-col gap-2 shrink-0",onKeyDown:x,"data-testid":"broadcast-bar",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("div",{className:"text-xs text-fg-dim uppercase tracking-wider",children:"Broadcast"}),p.jsx("div",{className:"text-[10px] text-fg-faint",children:"Esc to close · Cmd/Ctrl+Enter to send"})]}),p.jsx("textarea",{ref:h,value:i,onChange:L=>r(L.target.value),rows:3,placeholder:"Prompt to broadcast…",className:"w-full bg-bg border border-line rounded px-2 py-1.5 text-xs text-fg font-mono resize-y focus:outline-none focus:border-fg-faint"}),p.jsxs("div",{className:"flex flex-col gap-1",children:[p.jsxs("label",{className:"flex items-center gap-2 text-[11px] text-fg-dim cursor-pointer select-none",children:[p.jsx("input",{type:"checkbox",checked:w,onChange:y,className:"accent-accent"}),p.jsxs("span",{children:["All tabs (",m,"/",n.length,")"]})]}),p.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-1 max-h-24 overflow-y-auto pl-4",children:n.map(L=>p.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-fg-dim cursor-pointer select-none",children:[p.jsx("input",{type:"checkbox",checked:!!o[L.id],onChange:N=>a(I=>({...I,[L.id]:N.target.checked})),className:"accent-accent"}),p.jsx("span",{className:"truncate max-w-[12rem]",children:L.label}),d[L.id]==="sent"&&p.jsx("span",{"data-testid":"broadcast-row-sent",className:"text-[10px] text-green-500",children:"✓"}),d[L.id]==="skipped"&&p.jsx("span",{"data-testid":"broadcast-row-skipped",className:"text-[10px] text-red-400",children:"×"})]},L.id))})]}),p.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[p.jsx("button",{onClick:s,className:"px-2 py-0.5 text-[10px] text-fg-faint hover:text-fg border border-line hover:border-fg-faint rounded transition-colors",children:"Cancel"}),p.jsx("button",{onClick:v,disabled:!b,className:"px-2 py-0.5 text-[10px] text-fg border border-accent-muted hover:border-accent rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:E})]})]})}function met({tabId:s,cwd:e,onClose:n}){const i=gR(m=>m.watchersForTab(s)),r=gR(m=>m.add),o=gR(m=>m.remove),a=T.useRef(null),[l,c]=T.useState(""),[d,u]=T.useState(""),[h,f]=T.useState(!1);T.useEffect(()=>{const m=_=>{_.key==="Escape"&&n()};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[n]),T.useEffect(()=>{const m=_=>{a.current&&!a.current.contains(_.target)&&n()};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[n]);const g=async()=>{const m=d.trim();if(!m||h)return;f(!0);const _=await r({tabId:s,label:l.trim(),command:m,cwd:e});f(!1),_&&(c(""),u(""))};return p.jsxs("div",{ref:a,className:"absolute right-2 top-full mt-1 z-30 w-[420px] max-w-[calc(100vw-1rem)] bg-bg-elev border border-line rounded shadow-lg p-3 text-xs",role:"dialog","aria-label":"Watchers","data-testid":"watchers-popover",children:[p.jsxs("div",{className:"flex items-center mb-2",children:[p.jsx("span",{className:"text-fg-dim uppercase tracking-wider",children:"Watchers"}),p.jsxs("span",{className:"text-fg-faint ml-2",children:[i.length," active"]}),p.jsx("div",{className:"flex-1"}),p.jsx("button",{onClick:n,className:"text-fg-faint hover:text-fg",title:"Close",children:"×"})]}),p.jsxs("div",{className:"flex flex-col gap-1.5 mb-3",children:[p.jsx("input",{value:l,onChange:m=>c(m.target.value),placeholder:"label (optional)",className:"bg-bg border border-line rounded px-2 py-1 text-fg placeholder:text-fg-faint focus:outline-none focus:border-fg-faint"}),p.jsxs("div",{className:"flex gap-1.5",children:[p.jsx("input",{value:d,onChange:m=>u(m.target.value),onKeyDown:m=>{m.key==="Enter"&&g()},placeholder:"shell command — e.g. npm test --watch",className:"flex-1 bg-bg border border-line rounded px-2 py-1 text-fg placeholder:text-fg-faint focus:outline-none focus:border-fg-faint font-mono","data-testid":"watcher-command-input"}),p.jsx("button",{onClick:g,disabled:!d.trim()||h,className:"px-2 py-1 border border-line rounded text-fg-dim hover:text-fg hover:border-fg-faint disabled:opacity-40 disabled:cursor-not-allowed","data-testid":"watcher-add",children:"Add"})]}),p.jsxs("span",{className:"text-fg-faint",children:["cwd: ",p.jsx("span",{className:"font-mono",children:e})]})]}),i.length===0?p.jsx("div",{className:"text-fg-faint italic py-2",children:"no watchers — add one above"}):p.jsx("ul",{className:"flex flex-col gap-2 max-h-64 overflow-y-auto",children:i.map(m=>{const _=m.lines[m.lines.length-1];return p.jsxs("li",{className:"border border-line rounded p-2 bg-bg",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("span",{className:"font-medium text-fg truncate",children:m.label}),p.jsxs("span",{className:"text-fg-faint",children:[m.lineCount," line",m.lineCount===1?"":"s"]}),p.jsx("div",{className:"flex-1"}),p.jsx("button",{onClick:()=>o(m.watcherId),className:"text-fg-faint hover:text-red-400",title:"Stop watcher","data-testid":`watcher-remove-${m.watcherId}`,children:"stop"})]}),p.jsx("div",{className:"text-fg-faint font-mono text-[10px] truncate mt-0.5",title:m.command,children:m.command}),p.jsx("div",{className:"text-fg-dim font-mono text-[10px] truncate mt-1",title:(_==null?void 0:_.line)??"",children:_?_.line:p.jsx("span",{className:"italic text-fg-faint",children:"waiting for output…"})})]},m.watcherId)})})]})}/**
|
|
80
|
+
`):"",H=`${F} Claude sessions running${P}`;return p.jsxs("div",{className:"h-[30px] shrink-0 bg-bg-elev border-t border-line flex items-center gap-4 px-[18px] font-mono text-[11.5px] text-fg-dim","data-testid":"tour-statusbar",children:[p.jsxs("button",{onClick:()=>s==null?void 0:s("settings"),className:"flex items-center gap-1.5 hover:text-fg transition-colors",title:N?"Connected to Anthropic":"Disconnected",children:[p.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${N?"bg-sage":"bg-fg-faint"}`}),p.jsx("span",{children:N?"connected":"offline"})]}),p.jsxs("button",{onClick:()=>s==null?void 0:s("overview"),className:"hover:text-fg transition-colors",title:E0e("Session (5h window)",y),"data-testid":"footer-usage-session",children:["session ",p.jsx("span",{className:"text-fg",children:E!=null?`${E}%`:"—"})]}),p.jsxs("button",{onClick:()=>s==null?void 0:s("overview"),className:"hover:text-fg transition-colors",title:E0e("Weekly window (all models)",S),"data-testid":"footer-usage-weekly",children:["weekly ",p.jsx("span",{className:"text-fg",children:L!=null?`${L}%`:"—"})]}),l&&p.jsxs("button",{onClick:()=>s==null?void 0:s("scheduler"),title:"Scheduler is paused — click to open Scheduler",className:`flex items-center gap-1 px-1.5 py-0.5 rounded border font-mono text-[10.5px] transition-colors ${l.reason==="auth"||l.reason==="network"?"border-red-700/60 text-red-300 hover:bg-red-900/20":"border-amber-700/60 text-amber-300 hover:bg-amber-900/20"}`,children:[p.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current opacity-80"}),"Scheduler paused · ",l.reason]}),i&&p.jsxs("span",{className:"text-fg-faint",title:i.cwd,children:[i.label,c&&p.jsxs("span",{className:"text-fg-dim",children:[" · ⌥",c]})]}),p.jsxs("span",{className:"text-fg-faint",children:["last activity: ",p.jsx("span",{className:"text-fg-dim",children:I})]}),_.length>0&&p.jsx(het,{ref:x,todos:_,open:b,onToggle:()=>v(B=>!B)}),p.jsx("span",{className:"flex-1"}),p.jsx("button",{onClick:()=>s==null?void 0:s("overview"),className:"flex items-center gap-1 hover:text-fg transition-colors",title:H,"data-testid":"footer-active-sessions",children:d&&d.total===0?p.jsx("span",{className:"text-fg-faint",children:"pool paused"}):p.jsx(qOe,{total:A,inUse:(d==null?void 0:d.inUse)??0,size:"sm"})}),(u==null?void 0:u.state)==="ready"?p.jsxs("button",{type:"button",className:"text-amber-300 hover:underline",title:"A new version is downloaded. Click to restart and install — running jobs are waited for first.","data-testid":"footer-version",onClick:()=>{m()},children:["Update ready — restart to install v",u.latest]}):(u==null?void 0:u.state)==="deferred"?p.jsxs("span",{className:"text-amber-300",title:`Waiting for ${u.busyReason??"running jobs"} to finish before restarting`,"data-testid":"footer-version",children:["v",u.latest," installs when idle"]}):(u==null?void 0:u.state)==="downloading"?p.jsxs("span",{className:"text-fg-dim","data-testid":"footer-version",children:["Downloading v",u.latest,"…"]}):h!=null&&h.behind&&h.latest&&h.channel==="installer"?p.jsxs("button",{type:"button",className:"text-amber-300 hover:underline",title:`v${h.current} → v${h.latest}`,"data-testid":"footer-version",onClick:()=>{const B=h.downloadUrl;B&&window.api.shell.open({as:"external",url:B}).catch(()=>{f("error",`Couldn't open URL: ${B}`)})},children:["Download v",h.latest]}):h!=null&&h.behind&&h.latest?p.jsxs("span",{className:"text-amber-300",title:"A newer version is published — update the app. A stale npx cache can pin an old version.","data-testid":"footer-version",children:["v",h.current," → v",h.latest]}):p.jsxs("span",{className:"text-fg-dim","data-testid":"footer-version",children:["v",(h==null?void 0:h.current)??"0.141.0"]})]})}const het=T.forwardRef(function({todos:e,open:n,onToggle:i},r){const o={completed:e.filter(a=>a.status==="completed").length,in_progress:e.filter(a=>a.status==="in_progress").length,pending:e.filter(a=>a.status==="pending").length};return p.jsxs("div",{ref:r,className:"relative",children:[p.jsxs("button",{onClick:i,className:"flex items-center gap-1.5 hover:text-fg transition-colors",title:"Live to-dos for this session","data-testid":"footer-todos",children:[p.jsxs("span",{className:"text-green-400",children:["✓",o.completed]}),p.jsxs("span",{className:"text-accent",children:["●",o.in_progress]}),p.jsxs("span",{className:"text-fg-dim",children:["○",o.pending]}),p.jsxs("span",{className:"text-fg-faint",children:["todos ",n?"▾":"▴"]})]}),n&&p.jsx("div",{className:`absolute bottom-full left-0 mb-1.5 w-80 max-h-72 overflow-auto bg-bg-elev border border-line rounded shadow-xl p-2 ${xi.dialog}`,"data-testid":"footer-todos-popover",children:p.jsx("ul",{className:"space-y-0.5",children:e.map((a,l)=>p.jsxs("li",{className:`flex items-start gap-2 py-1 px-1.5 rounded ${a.status==="in_progress"?"bg-bg-hi":""}`,children:[p.jsx(fet,{status:a.status}),p.jsx("span",{className:a.status==="completed"?"text-fg-faint line-through":a.status==="in_progress"?"text-fg":"text-fg-dim",children:a.status==="in_progress"&&a.activeForm?a.activeForm:a.content})]},l))})})]})});function fet({status:s}){return s==="completed"?p.jsx("span",{className:"text-green-400 w-3 shrink-0",children:"✓"}):s==="in_progress"?p.jsx("span",{className:"w-3 shrink-0",children:p.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-accent animate-pulse"})}):p.jsx("span",{className:"text-fg-faint w-3 shrink-0",children:"○"})}function pet(s){const e=Math.max(0,Math.floor(s/1e3));if(e<60)return`${e}s ago`;const n=Math.floor(e/60);return n<60?`${n}m ago`:`${Math.floor(n/60)}h ago`}function get({onClose:s,onSent:e}){const n=Ft(L=>L.tabs),[i,r]=T.useState(""),[o,a]=T.useState(()=>Object.fromEntries(n.map(L=>[L.id,!0]))),[l,c]=T.useState(!1),[d,u]=T.useState({}),h=T.useRef(null),f=T.useRef(e);T.useEffect(()=>{f.current=e},[e]),T.useEffect(()=>{a(L=>{const N={};for(const I of n)N[I.id]=L[I.id]??!0;return N})},[n]),T.useEffect(()=>{var L;(L=h.current)==null||L.focus()},[]),T.useEffect(()=>window.api.pty.onWriteError(N=>{u(I=>N.tabId in I?{...I,[N.tabId]:"skipped"}:I)}),[]),T.useEffect(()=>{if(Object.keys(d).length===0)return;const L=Object.values(d).filter(I=>I==="sent").length,N=window.setTimeout(()=>f.current(L),1500);return()=>window.clearTimeout(N)},[d]);const g=n.filter(L=>o[L.id]).map(L=>L.id),m=g.length,_=Object.keys(d).length>0,b=i.length>0&&m>0&&!l&&!_,v=()=>{if(!b)return;c(!0);const L=Ft.getState().tabs,N=new Set(L.map(A=>A.id)),I={};for(const A of g)N.has(A)?(window.api.pty.write({tabId:A,data:i+"\r"}),I[A]="sent"):I[A]="skipped";u(I),c(!1)},x=L=>{if(L.key==="Escape"){L.preventDefault(),L.stopPropagation(),s();return}L.key==="Enter"&&(L.metaKey||L.ctrlKey)&&(L.preventDefault(),v())},w=n.length>0&&n.every(L=>o[L.id]),y=()=>{const L=!w;a(Object.fromEntries(n.map(N=>[N.id,L])))},S=Object.values(d).some(L=>L==="skipped"),E=_?S?"Sent (some skipped)":"Sent":`Send to ${m} tab${m===1?"":"s"}`;return p.jsxs("div",{className:"border-b border-line bg-bg-elev px-4 py-3 flex flex-col gap-2 shrink-0",onKeyDown:x,"data-testid":"broadcast-bar",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("div",{className:"text-xs text-fg-dim uppercase tracking-wider",children:"Broadcast"}),p.jsx("div",{className:"text-[10px] text-fg-faint",children:"Esc to close · Cmd/Ctrl+Enter to send"})]}),p.jsx("textarea",{ref:h,value:i,onChange:L=>r(L.target.value),rows:3,placeholder:"Prompt to broadcast…",className:"w-full bg-bg border border-line rounded px-2 py-1.5 text-xs text-fg font-mono resize-y focus:outline-none focus:border-fg-faint"}),p.jsxs("div",{className:"flex flex-col gap-1",children:[p.jsxs("label",{className:"flex items-center gap-2 text-[11px] text-fg-dim cursor-pointer select-none",children:[p.jsx("input",{type:"checkbox",checked:w,onChange:y,className:"accent-accent"}),p.jsxs("span",{children:["All tabs (",m,"/",n.length,")"]})]}),p.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-1 max-h-24 overflow-y-auto pl-4",children:n.map(L=>p.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-fg-dim cursor-pointer select-none",children:[p.jsx("input",{type:"checkbox",checked:!!o[L.id],onChange:N=>a(I=>({...I,[L.id]:N.target.checked})),className:"accent-accent"}),p.jsx("span",{className:"truncate max-w-[12rem]",children:L.label}),d[L.id]==="sent"&&p.jsx("span",{"data-testid":"broadcast-row-sent",className:"text-[10px] text-green-500",children:"✓"}),d[L.id]==="skipped"&&p.jsx("span",{"data-testid":"broadcast-row-skipped",className:"text-[10px] text-red-400",children:"×"})]},L.id))})]}),p.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[p.jsx("button",{onClick:s,className:"px-2 py-0.5 text-[10px] text-fg-faint hover:text-fg border border-line hover:border-fg-faint rounded transition-colors",children:"Cancel"}),p.jsx("button",{onClick:v,disabled:!b,className:"px-2 py-0.5 text-[10px] text-fg border border-accent-muted hover:border-accent rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:E})]})]})}function met({tabId:s,cwd:e,onClose:n}){const i=gR(m=>m.watchersForTab(s)),r=gR(m=>m.add),o=gR(m=>m.remove),a=T.useRef(null),[l,c]=T.useState(""),[d,u]=T.useState(""),[h,f]=T.useState(!1);T.useEffect(()=>{const m=_=>{_.key==="Escape"&&n()};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[n]),T.useEffect(()=>{const m=_=>{a.current&&!a.current.contains(_.target)&&n()};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[n]);const g=async()=>{const m=d.trim();if(!m||h)return;f(!0);const _=await r({tabId:s,label:l.trim(),command:m,cwd:e});f(!1),_&&(c(""),u(""))};return p.jsxs("div",{ref:a,className:"absolute right-2 top-full mt-1 z-30 w-[420px] max-w-[calc(100vw-1rem)] bg-bg-elev border border-line rounded shadow-lg p-3 text-xs",role:"dialog","aria-label":"Watchers","data-testid":"watchers-popover",children:[p.jsxs("div",{className:"flex items-center mb-2",children:[p.jsx("span",{className:"text-fg-dim uppercase tracking-wider",children:"Watchers"}),p.jsxs("span",{className:"text-fg-faint ml-2",children:[i.length," active"]}),p.jsx("div",{className:"flex-1"}),p.jsx("button",{onClick:n,className:"text-fg-faint hover:text-fg",title:"Close",children:"×"})]}),p.jsxs("div",{className:"flex flex-col gap-1.5 mb-3",children:[p.jsx("input",{value:l,onChange:m=>c(m.target.value),placeholder:"label (optional)",className:"bg-bg border border-line rounded px-2 py-1 text-fg placeholder:text-fg-faint focus:outline-none focus:border-fg-faint"}),p.jsxs("div",{className:"flex gap-1.5",children:[p.jsx("input",{value:d,onChange:m=>u(m.target.value),onKeyDown:m=>{m.key==="Enter"&&g()},placeholder:"shell command — e.g. npm test --watch",className:"flex-1 bg-bg border border-line rounded px-2 py-1 text-fg placeholder:text-fg-faint focus:outline-none focus:border-fg-faint font-mono","data-testid":"watcher-command-input"}),p.jsx("button",{onClick:g,disabled:!d.trim()||h,className:"px-2 py-1 border border-line rounded text-fg-dim hover:text-fg hover:border-fg-faint disabled:opacity-40 disabled:cursor-not-allowed","data-testid":"watcher-add",children:"Add"})]}),p.jsxs("span",{className:"text-fg-faint",children:["cwd: ",p.jsx("span",{className:"font-mono",children:e})]})]}),i.length===0?p.jsx("div",{className:"text-fg-faint italic py-2",children:"no watchers — add one above"}):p.jsx("ul",{className:"flex flex-col gap-2 max-h-64 overflow-y-auto",children:i.map(m=>{const _=m.lines[m.lines.length-1];return p.jsxs("li",{className:"border border-line rounded p-2 bg-bg",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx("span",{className:"font-medium text-fg truncate",children:m.label}),p.jsxs("span",{className:"text-fg-faint",children:[m.lineCount," line",m.lineCount===1?"":"s"]}),p.jsx("div",{className:"flex-1"}),p.jsx("button",{onClick:()=>o(m.watcherId),className:"text-fg-faint hover:text-red-400",title:"Stop watcher","data-testid":`watcher-remove-${m.watcherId}`,children:"stop"})]}),p.jsx("div",{className:"text-fg-faint font-mono text-[10px] truncate mt-0.5",title:m.command,children:m.command}),p.jsx("div",{className:"text-fg-dim font-mono text-[10px] truncate mt-1",title:(_==null?void 0:_.line)??"",children:_?_.line:p.jsx("span",{className:"italic text-fg-faint",children:"waiting for output…"})})]},m.watcherId)})})]})}/**
|
|
81
81
|
* dockview-core
|
|
82
82
|
* @version 6.6.1
|
|
83
83
|
* @link https://github.com/mathuo/dockview
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-code-session-manager",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.141.0",
|
|
4
4
|
"description": "Free desktop app for Claude Code: run many sessions, each in its own git worktree; queue work that runs headless within your usage limits; agents drive it through an MCP server and skills.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/main/index.cjs",
|
|
@@ -39,7 +39,8 @@ to walk back once published.
|
|
|
39
39
|
|
|
40
40
|
## 3. Gate and publish preflight
|
|
41
41
|
|
|
42
|
-
Run each name in `build-target.json`'s `gates` as `timeout 300 npm run <gate
|
|
42
|
+
Run each name in `build-target.json`'s `gates` as `timeout <gateTimeoutSeconds[gate] or 300> npm run <gate>`
|
|
43
|
+
(default 300 when `gateTimeoutSeconds` has no entry for that gate), in order,
|
|
43
44
|
against `HEAD`, with no `--skip` flags. With no `gates` entry, run the pre-commit checks the
|
|
44
45
|
project's `CLAUDE.md` or README requires; with none documented, say so in the report. Any
|
|
45
46
|
failure → stop: report the command and its real output, and that no bump, tag or publish
|
|
@@ -94,7 +95,8 @@ have no `release.yml`) always use steps 5-11:
|
|
|
94
95
|
5. `mkdir -p "$HOME/.cache/sm-publish" && git worktree add "$HOME/.cache/sm-publish/v<version>" v<version>`
|
|
95
96
|
— never under `/tmp` or `os.tmpdir()`: some test suites (this repo's included) treat those
|
|
96
97
|
paths as fixtures and fail there.
|
|
97
|
-
6. In the worktree: `npm ci`, then the gates again (step 3
|
|
98
|
+
6. In the worktree: `npm ci`, then the gates again (step 3: `timeout <gateTimeoutSeconds[gate] or 300>
|
|
99
|
+
npm run <gate>`, default 300 when a gate has no entry), then the project's build. Check
|
|
98
100
|
every `files` entry in `package.json` exists before publishing; stop on any failure.
|
|
99
101
|
A cold `test:unit` in a fresh publish worktree can time out under load; rerun the failed files, then the full suite, before calling the gate red — never publish on the partial rerun.
|
|
100
102
|
7. `npm publish` from inside the worktree, so `prepublishOnly` builds there too.
|
|
@@ -265,6 +265,9 @@ Rules:
|
|
|
265
265
|
to decide. Why: a second miss on the same criterion means the plan is wrong, and another
|
|
266
266
|
wave would repeat it. A Not validated list means validate exactly those PRDs here. All
|
|
267
267
|
`VERIFIED` with nothing open means Done: write the final report.
|
|
268
|
+
3. **A `PRECONDITION HOLD` notice** is not a park and not a fix-wave trigger. Do nothing — no
|
|
269
|
+
reset, no edit, no fix PRD; the scheduler re-checks the preflight on its own. State the
|
|
270
|
+
missing precondition in the report. Why: only a person can supply it.
|
|
268
271
|
4. **Done** = the latest validator marked every PRD `VERIFIED`, including each PRD an earlier
|
|
269
272
|
validator refuted, no Critical or Important finding is open, and its record exists in the main checkout's
|
|
270
273
|
`session-manager-operations/plan-records/<epic-id>/`.
|
|
@@ -418,6 +418,10 @@ const CREATE_PRD_ITEM_SCHEMA = {
|
|
|
418
418
|
type: 'array', items: { type: 'string' }, maxItems: 20,
|
|
419
419
|
description: 'Optional: the tool-risk rules this PRD is cleared to call although they are marked irreversible, money or public in ~/.claude/tool-risk.json or <project>/.claude/tool-risk.json. Same syntax as the marks (mcp__server__tool, mcp__server__*, Bash(prefix:*)). At most 20.',
|
|
420
420
|
},
|
|
421
|
+
preflight: {
|
|
422
|
+
type: 'string', maxLength: 500,
|
|
423
|
+
description: 'Optional: a read-only, shell-free command in gate syntax, at most 60 s, that must exit 0 before the PRD runs; the scheduler holds the PRD and re-checks it on a backoff while it fails.',
|
|
424
|
+
},
|
|
421
425
|
quietMachine: {
|
|
422
426
|
type: 'boolean',
|
|
423
427
|
description: 'Optional: set true only when this PRD\'s acceptance criteria are wall-clock/timing measurements (frame time, performance fences) that CPU contention from concurrent jobs would invalidate. The scheduler dispatches it only once zero other jobs are running machine-wide, and holds every other job off the whole slot pool for its run — a whole-machine exclusive lease, not a per-project one. If the machine never goes quiet within the configured wait window (default 30 minutes), it dispatches anyway and is marked degraded. Opt-in only; omit for ordinary PRDs.',
|
|
@@ -604,6 +608,7 @@ const TOOLS = [
|
|
|
604
608
|
dependsOn: { type: 'array', items: { type: 'string' }, description: 'Optional: replaces the dependsOn list; an explicit empty array CLEARS it — see scheduler_create_prd' },
|
|
605
609
|
disposition: { type: 'string', enum: ['append', 'new-head'], description: 'Optional: patches the recorded wave-authoring decision — see scheduler_create_prd' },
|
|
606
610
|
riskTools: { type: 'array', items: { type: 'string' }, maxItems: 20, description: 'Optional: replaces the PRD\'s riskTools — the tool-risk rules it is cleared to call although marked in tool-risk.json. Same rule syntax as scheduler_create_prd\'s riskTools (mcp__server__tool, mcp__server__*, Bash(prefix:*)). At most 20; an explicit empty array clears it.' },
|
|
611
|
+
preflight: { type: 'string', maxLength: 500, description: 'Optional: replaces the PRD\'s preflight — a read-only, shell-free command in gate syntax, at most 60 s, that must exit 0 before the PRD runs; the scheduler holds the PRD and re-checks it on a backoff while it fails.' },
|
|
607
612
|
},
|
|
608
613
|
},
|
|
609
614
|
body: { type: 'string', description: 'Optional: full replacement body (everything after the frontmatter). Cannot be combined with gate/files/acceptanceCriteria.' },
|
package/src/main/build-info.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
3
|
-
"gitSha": "
|
|
4
|
-
"gitShortSha": "
|
|
2
|
+
"version": "0.141.0",
|
|
3
|
+
"gitSha": "0db73892da43176f003e4495092dfb8283045331",
|
|
4
|
+
"gitShortSha": "0db73892",
|
|
5
5
|
"gitBranch": "HEAD",
|
|
6
|
-
"builtAt": "2026-11-
|
|
6
|
+
"builtAt": "2026-11-23T02:26:13.633Z",
|
|
7
7
|
"dirty": false
|
|
8
8
|
}
|
package/src/main/ipcSchemas.cjs
CHANGED
|
@@ -440,6 +440,10 @@ const MAX_DEPENDS_ON = 100;
|
|
|
440
440
|
// The rule grammar (toolRiskMarks.parseRule), de-dup and cap are re-checked by
|
|
441
441
|
// prdCreate.cjs's normalizeRiskTools on both paths.
|
|
442
442
|
const RiskToolsSchema = z.array(z.string().min(1).max(200)).max(20);
|
|
443
|
+
// A PRD's optional preflight command — shared by schedulerCreatePrd (hence
|
|
444
|
+
// every adminCreatePrds entry) and adminPrdFrontmatterPatch. One gate-syntax
|
|
445
|
+
// command; its grammar is re-checked by the PRD library, not here.
|
|
446
|
+
const PreflightSchema = z.string().max(500);
|
|
443
447
|
// Wave-authoring decision (scheduler wave-disposition PRD), shared between
|
|
444
448
|
// schedulerCreatePrd (authoring time) and adminPrdFrontmatterPatch (the
|
|
445
449
|
// after-the-fact change path) so both can never disagree on what a valid
|
|
@@ -489,6 +493,10 @@ const schedulerCreatePrd = z.object({
|
|
|
489
493
|
// Tool-risk rule strings this PRD is cleared to call (toolRiskMarks.parseRule
|
|
490
494
|
// grammar, re-checked + de-duplicated in prdCreate.cjs; written as `riskTools`).
|
|
491
495
|
riskTools: RiskToolsSchema.optional(),
|
|
496
|
+
// Read-only, shell-free precondition command in gate syntax (PRD
|
|
497
|
+
// preflight-api-schemas). Passed through unchanged; prdCreate.cjs owns the
|
|
498
|
+
// grammar check and writes it as `preflight` frontmatter.
|
|
499
|
+
preflight: PreflightSchema.optional(),
|
|
492
500
|
// An EXISTING Epic's promptSessionId (PRD 748) — NOT a PromptTicket.id.
|
|
493
501
|
// ensureEpic() (epicMint.cjs) joins the Epic whose active-index.json
|
|
494
502
|
// sessions key literally equals this value; the renderer only ever sends
|
|
@@ -717,6 +725,8 @@ const adminPrdFrontmatterPatch = z.object({
|
|
|
717
725
|
// re-checks a non-empty list with normalizeRiskTools; an explicit `[]`
|
|
718
726
|
// removes the key from the PRD file.
|
|
719
727
|
riskTools: RiskToolsSchema.optional(),
|
|
728
|
+
// Patchable after creation too, same shape as create (see PreflightSchema).
|
|
729
|
+
preflight: PreflightSchema.optional(),
|
|
720
730
|
});
|
|
721
731
|
|
|
722
732
|
const adminUpdatePrd = z.object({
|
|
@@ -114,6 +114,9 @@ const MCP_TOOL_CATALOG = [
|
|
|
114
114
|
+ 'no path may contain "..". '
|
|
115
115
|
+ '`riskTools` (optional, up to 20) names the tool-risk rules this PRD is cleared to call although they are '
|
|
116
116
|
+ 'marked irreversible, money or public in a tool-risk.json, in the same syntax as the marks. '
|
|
117
|
+
+ '`preflight` (optional, at most 500 characters) is a read-only, shell-free command in gate syntax, '
|
|
118
|
+
+ 'at most 60 s, that must exit 0 before the PRD runs; the scheduler holds the PRD and re-checks it on a '
|
|
119
|
+
+ 'backoff while it fails. '
|
|
117
120
|
+ 'A bare slug already used by a PRD in ANOTHER Epic is refused as a cross-Epic duplicate (the error names '
|
|
118
121
|
+ 'the exact NN slugs); add them to dependsOn, or call again with allowDuplicateOf: [those NN slugs] for a '
|
|
119
122
|
+ 'deliberate duplicate. '
|
|
@@ -162,7 +165,10 @@ const MCP_TOOL_CATALOG = [
|
|
|
162
165
|
+ 'next reconcile pass. All entries must resolve to the same project and Epic; top-level cwd, sourcePromptId '
|
|
163
166
|
+ 'and origin fields are forwarded the same way as scheduler_create_prd. An entry whose bare slug already '
|
|
164
167
|
+ 'exists in another Epic fails the batch as a cross-Epic duplicate; give that entry dependsOn on the named NN '
|
|
165
|
-
+ 'slugs, or allowDuplicateOf: [those NN slugs] for a deliberate duplicate, and call again.'
|
|
168
|
+
+ 'slugs, or allowDuplicateOf: [those NN slugs] for a deliberate duplicate, and call again. '
|
|
169
|
+
+ 'Each entry also takes `preflight` (optional, at most 500 characters): a read-only, shell-free command in gate syntax, '
|
|
170
|
+
+ 'at most 60 s, that must exit 0 before the PRD runs; the scheduler holds the PRD and re-checks it on a '
|
|
171
|
+
+ 'backoff while it fails.',
|
|
166
172
|
summary: 'Queue a whole plan of PRDs in one all-or-nothing call.',
|
|
167
173
|
whenToUse: 'Use to queue a whole plan at once, validate PRD included: dependsOn may name other entries of the same call by bare slug (earlier or later), so a chain needs no ordering of calls.',
|
|
168
174
|
whenNotToUse: 'Do not use for a single PRD — use scheduler_create_prd. Not callable from inside a headless scheduled job (same refusal as scheduler_create_prd). If the app is not running, stop and ask the human to start it; never hand-write PRD files.',
|
|
@@ -218,7 +224,10 @@ const MCP_TOOL_CATALOG = [
|
|
|
218
224
|
+ 'sourcePromptId, sourceTabId, tag, dependsOn) may be patched; unrecognized keys round-trip unchanged. '
|
|
219
225
|
+ 'Patching dependsOn to a non-empty array replaces it wholesale (validated against existing PRD slugs, '
|
|
220
226
|
+ 'same resolver scheduler_create_prd uses); patching it to an explicit empty array CLEARS the dependency — '
|
|
221
|
-
+ 'the safe way to fix a wrong dependsOn without archiving (which marks the PRD completed and wrongly frees its dependents).'
|
|
227
|
+
+ 'the safe way to fix a wrong dependsOn without archiving (which marks the PRD completed and wrongly frees its dependents). '
|
|
228
|
+
+ '`preflight` (optional, at most 500 characters) is patchable too: a read-only, shell-free command in gate syntax, '
|
|
229
|
+
+ 'at most 60 s, that must exit 0 before the PRD runs; the scheduler holds the PRD and re-checks it on a '
|
|
230
|
+
+ 'backoff while it fails.',
|
|
222
231
|
summary: 'Edit a PRD that has not run yet or has stopped.',
|
|
223
232
|
whenToUse: 'Use to fix a PRD\'s spec before it runs, or to fix a parked (needs_review or failed) or skipped PRD before you reset it with scheduler_reset_job.',
|
|
224
233
|
whenNotToUse: 'Do not use on a running or completed job. Do not reset first and edit second: the reset job can start before the edit lands.',
|
|
@@ -34,10 +34,25 @@ const { isFixPlanSlug } = require('../scheduler/fixPlanSlug.cjs');
|
|
|
34
34
|
const { isIncomplete, resolveChainTerminals, isValidPlanId, mintPlanId, resolveInheritedPlanId } = require('./prdDisposition.cjs');
|
|
35
35
|
const { splitFrontmatter, PRD_EFFORT_LEVELS, formatQuotedInlineList } = require('./prdFrontmatter.cjs');
|
|
36
36
|
const { parseRule: parseToolRiskRule } = require('../claude/toolRiskMarks.cjs');
|
|
37
|
+
const { normalizePreflight } = require('../scheduler/preflightCheck.cjs');
|
|
37
38
|
|
|
38
39
|
// Cap on riskTools entries — mirrors ipcSchemas.cjs RiskToolsSchema.
|
|
39
40
|
const RISK_TOOLS_MAX = 20;
|
|
40
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Validate + normalize a `preflight` value — wraps preflightCheck's
|
|
44
|
+
* normalizePreflight (which throws) into the { ok, value | error } shape the
|
|
45
|
+
* other field checks return, so createPrd and the update path share one check.
|
|
46
|
+
* value is null when the input is empty/absent (no frontmatter key).
|
|
47
|
+
*/
|
|
48
|
+
function normalizePreflightField(value) {
|
|
49
|
+
try {
|
|
50
|
+
return { ok: true, value: normalizePreflight(value) };
|
|
51
|
+
} catch (e) {
|
|
52
|
+
return { ok: false, error: e && e.message ? e.message : String(e) };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
41
56
|
/**
|
|
42
57
|
* Validate + normalize a `riskTools` value — the ONE check shared by
|
|
43
58
|
* createPrd and scheduler.cjs's updatePrd so create and update can never
|
|
@@ -119,7 +134,7 @@ function isValidMacroId(id) {
|
|
|
119
134
|
function buildPrdBody(input) {
|
|
120
135
|
const {
|
|
121
136
|
title, cwd, estimateMinutes, goal, acceptanceCriteria,
|
|
122
|
-
implementationNotes, outOfScope, sourcePromptId, sourceTabId, tag, agentType, dependsOn, quietMachine, disposition, deliverable, artifactPaths, planId, macroId, effort, riskTools,
|
|
137
|
+
implementationNotes, outOfScope, sourcePromptId, sourceTabId, tag, agentType, dependsOn, quietMachine, disposition, deliverable, artifactPaths, planId, macroId, effort, riskTools, preflight,
|
|
123
138
|
gate, files, budgetExempt, fixes,
|
|
124
139
|
} = input;
|
|
125
140
|
|
|
@@ -180,6 +195,9 @@ function buildPrdBody(input) {
|
|
|
180
195
|
if (PRD_EFFORT_LEVELS.includes(effort)) fmLines.push(`effort: ${effort}`);
|
|
181
196
|
// Risky tools this PRD is cleared to call — validated + de-duplicated by createPrd().
|
|
182
197
|
if (Array.isArray(riskTools) && riskTools.length) fmLines.push(`riskTools: ${formatQuotedInlineList(riskTools)}`);
|
|
198
|
+
// Precondition command — validated by createPrd() via normalizePreflightField.
|
|
199
|
+
// JSON-string form, matching prdFrontmatter.cjs's serializer.
|
|
200
|
+
if (typeof preflight === 'string' && preflight) fmLines.push(`preflight: ${JSON.stringify(preflight)}`);
|
|
183
201
|
if (quietMachine === true) fmLines.push('quietMachine: true');
|
|
184
202
|
// Budget exemption is for a sweep validator that cannot be split further;
|
|
185
203
|
// every other caller's budgetExempt is ignored.
|
|
@@ -659,6 +677,13 @@ async function createPrdInner(input, remote, ctl, opts = {}) {
|
|
|
659
677
|
if (!rt.ok) return { ok: false, applied: false, status: 400, error: rt.error };
|
|
660
678
|
input = { ...input, riskTools: rt.value };
|
|
661
679
|
}
|
|
680
|
+
// preflight: one-line precondition command (preflightCheck.normalizePreflight).
|
|
681
|
+
// Refused before NN allocation; an empty value writes no key.
|
|
682
|
+
if (input.preflight !== undefined) {
|
|
683
|
+
const pf = normalizePreflightField(input.preflight);
|
|
684
|
+
if (!pf.ok) return { ok: false, applied: false, status: 400, error: pf.error };
|
|
685
|
+
input = { ...input, preflight: pf.value || undefined };
|
|
686
|
+
}
|
|
662
687
|
|
|
663
688
|
// Fake-heading guard (gate-and-files-in-PRD-body unit): a caller-supplied
|
|
664
689
|
// free-text field that itself contains a "# Gate" or "# Files" heading line
|
|
@@ -1317,6 +1342,7 @@ module.exports = {
|
|
|
1317
1342
|
createPrd,
|
|
1318
1343
|
createPrdBatch,
|
|
1319
1344
|
normalizeRiskTools,
|
|
1345
|
+
normalizePreflightField,
|
|
1320
1346
|
RISK_TOOLS_MAX,
|
|
1321
1347
|
findCrossEpicDuplicates,
|
|
1322
1348
|
validateFixesShape,
|
|
@@ -80,8 +80,8 @@ function splitFrontmatter(raw) {
|
|
|
80
80
|
* { prd, missKind, reason } — see parseFixes.
|
|
81
81
|
*/
|
|
82
82
|
|
|
83
|
-
const RECOGNIZED_KEYS = new Set(['title', 'cwd', 'estimateMinutes', 'parallelGroup', 'sourcePromptId', 'sourceTabId', 'tag', 'agentType', 'createdVia', 'issuedAt', 'dependsOn', 'fixes', 'quietMachine', 'disposition', 'planId', 'deliverable', 'artifactPaths', 'macroId', 'effort', 'riskTools']);
|
|
84
|
-
const EMIT_ORDER = ['title', 'cwd', 'estimateMinutes', 'parallelGroup', 'sourcePromptId', 'sourceTabId', 'tag', 'agentType', 'createdVia', 'issuedAt', 'dependsOn', 'fixes', 'quietMachine', 'disposition', 'planId', 'deliverable', 'artifactPaths', 'macroId', 'effort', 'riskTools'];
|
|
83
|
+
const RECOGNIZED_KEYS = new Set(['title', 'cwd', 'estimateMinutes', 'parallelGroup', 'sourcePromptId', 'sourceTabId', 'tag', 'agentType', 'createdVia', 'issuedAt', 'dependsOn', 'fixes', 'quietMachine', 'disposition', 'planId', 'deliverable', 'artifactPaths', 'macroId', 'effort', 'riskTools', 'preflight']);
|
|
84
|
+
const EMIT_ORDER = ['title', 'cwd', 'estimateMinutes', 'parallelGroup', 'sourcePromptId', 'sourceTabId', 'tag', 'agentType', 'createdVia', 'issuedAt', 'dependsOn', 'fixes', 'quietMachine', 'disposition', 'planId', 'deliverable', 'artifactPaths', 'macroId', 'effort', 'riskTools', 'preflight'];
|
|
85
85
|
// Mirrors modelCatalog.cjs CATALOG_FLOOR.effortLevels. A closed set so the
|
|
86
86
|
// value is always safe as a frontmatter line and as a --effort argv token.
|
|
87
87
|
const PRD_EFFORT_LEVELS = Object.freeze(['low', 'medium', 'high', 'xhigh', 'max']);
|
|
@@ -309,9 +309,29 @@ function applyKey(fm, key, after) {
|
|
|
309
309
|
if (list) fm.riskTools = list;
|
|
310
310
|
return;
|
|
311
311
|
}
|
|
312
|
+
case 'preflight': {
|
|
313
|
+
// One-line precondition command (preflightCheck.cjs). Written as a JSON
|
|
314
|
+
// string so quotes/`#` inside a command survive; a bare hand-written
|
|
315
|
+
// value is read as-is.
|
|
316
|
+
const s = parsePreflightValue(after);
|
|
317
|
+
if (s) fm.preflight = s;
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
312
320
|
}
|
|
313
321
|
}
|
|
314
322
|
|
|
323
|
+
function parsePreflightValue(raw) {
|
|
324
|
+
const t = String(raw ?? '').trim();
|
|
325
|
+
if (t.startsWith('"')) {
|
|
326
|
+
try {
|
|
327
|
+
const j = JSON.parse(t);
|
|
328
|
+
if (typeof j === 'string') return j.trim() || null;
|
|
329
|
+
} catch { /* fall through to the bare form */ }
|
|
330
|
+
}
|
|
331
|
+
const s = t.length >= 2 && t.startsWith("'") && t.endsWith("'") ? t.slice(1, -1) : t;
|
|
332
|
+
return s.trim() || null;
|
|
333
|
+
}
|
|
334
|
+
|
|
315
335
|
/** Parse a full PRD file into { frontmatter, body }, same shape as the TS module. */
|
|
316
336
|
function parsePrdFile(text) {
|
|
317
337
|
const m = text.match(FRONTMATTER_RE);
|
|
@@ -344,7 +364,7 @@ function parsePrdFile(text) {
|
|
|
344
364
|
|
|
345
365
|
if (RECOGNIZED_KEYS.has(key)) {
|
|
346
366
|
applyKey(fm, key, after);
|
|
347
|
-
if (key === 'dependsOn' || key === 'artifactPaths' || key === 'fixes' || key === 'riskTools') {
|
|
367
|
+
if (key === 'dependsOn' || key === 'artifactPaths' || key === 'fixes' || key === 'riskTools' || key === 'preflight') {
|
|
348
368
|
if (fm[key]) {
|
|
349
369
|
if (!fm._raw) fm._raw = {};
|
|
350
370
|
fm._raw[key] = { line, parsed: fm[key] };
|
|
@@ -410,6 +430,10 @@ function serializePrdFile(fm, body) {
|
|
|
410
430
|
out.push(`${key}: ${formatQuotedInlineList(v)}`);
|
|
411
431
|
continue;
|
|
412
432
|
}
|
|
433
|
+
if (key === 'preflight') {
|
|
434
|
+
out.push(`${key}: ${JSON.stringify(String(v))}`);
|
|
435
|
+
continue;
|
|
436
|
+
}
|
|
413
437
|
if (Array.isArray(v)) {
|
|
414
438
|
out.push(`${key}: [${v.join(', ')}]`);
|
|
415
439
|
continue;
|
|
@@ -430,6 +454,7 @@ function serializePrdFile(fm, body) {
|
|
|
430
454
|
|
|
431
455
|
module.exports = {
|
|
432
456
|
splitFrontmatter,
|
|
457
|
+
parsePreflightValue,
|
|
433
458
|
parsePrdFile,
|
|
434
459
|
serializePrdFile,
|
|
435
460
|
parseInlineList,
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* preflightCheck — the optional PRD precondition command (`preflight`).
|
|
4
|
+
*
|
|
5
|
+
* A PRD whose work needs an external precondition a person controls (a store
|
|
6
|
+
* agreement, billing, DNS, OAuth consent) declares one cheap, read-only
|
|
7
|
+
* command. The scheduler holds the job while it exits non-zero and resumes it
|
|
8
|
+
* once it exits 0. This module is the pure-plus-runner core; wiring lives in
|
|
9
|
+
* the scheduler.
|
|
10
|
+
*
|
|
11
|
+
* No second gate grammar: a preflight is validated by prdGateFiles'
|
|
12
|
+
* validateGate (as a one-entry gate) and run by definitionOfDone's
|
|
13
|
+
* runIsolatedSequence — the same no-shell tokenizer + spawner the gate shadow
|
|
14
|
+
* uses. The read-only contract is not enforced beyond that validator.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const { validateGate } = require('../prd/prdGateFiles.cjs');
|
|
18
|
+
const { parseChain, isNoneGate, runIsolatedSequence } = require('./definitionOfDone.cjs');
|
|
19
|
+
|
|
20
|
+
const PREFLIGHT_MAX_CHARS = 500;
|
|
21
|
+
const OUTPUT_TAIL_CHARS = 500;
|
|
22
|
+
const DEFAULT_TIMEOUT_MS = 60_000;
|
|
23
|
+
const MIN_MS = 60 * 1000;
|
|
24
|
+
const DELAY_LADDER_MS = [10 * MIN_MS, 20 * MIN_MS, 40 * MIN_MS, 60 * MIN_MS];
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @param {unknown} value
|
|
28
|
+
* @returns {string|null} trimmed command, or null when empty/absent.
|
|
29
|
+
* @throws {Error} for a multi-line, over-long or gate-invalid value.
|
|
30
|
+
*/
|
|
31
|
+
function normalizePreflight(value) {
|
|
32
|
+
if (value === undefined || value === null) return null;
|
|
33
|
+
if (typeof value !== 'string') throw new Error('preflight must be a string command.');
|
|
34
|
+
const cmd = value.trim();
|
|
35
|
+
if (!cmd) return null;
|
|
36
|
+
if (/[\r\n]/.test(cmd)) throw new Error('preflight must be one line (no newline).');
|
|
37
|
+
if (cmd.length > PREFLIGHT_MAX_CHARS) {
|
|
38
|
+
throw new Error(`preflight must be at most ${PREFLIGHT_MAX_CHARS} chars (got ${cmd.length}).`);
|
|
39
|
+
}
|
|
40
|
+
if (isNoneGate(cmd)) throw new Error('preflight "none" is not a command — omit preflight instead.');
|
|
41
|
+
const v = validateGate([cmd]);
|
|
42
|
+
if (!v.ok) throw new Error(`preflight is not a valid command: ${v.error.replace(/^gate /, '')}`);
|
|
43
|
+
return cmd;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Re-check delay for the Nth failed check: 10, 20, 40, then 60 minutes. */
|
|
47
|
+
function preflightDelayMs(attempt) {
|
|
48
|
+
const n = Number.isFinite(attempt) && attempt >= 1 ? Math.floor(attempt) : 1;
|
|
49
|
+
return DELAY_LADDER_MS[Math.min(n, DELAY_LADDER_MS.length) - 1];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Run the preflight command once, without a shell.
|
|
54
|
+
* Every step's timeout is capped at timeoutMs.
|
|
55
|
+
*
|
|
56
|
+
* @returns {Promise<{ok:boolean, exitCode:number|null, timedOut:boolean, outputTail:string}>}
|
|
57
|
+
*/
|
|
58
|
+
async function runPreflight({ command, cwd, timeoutMs = DEFAULT_TIMEOUT_MS } = {}) {
|
|
59
|
+
const steps = typeof command === 'string' ? parseChain(command.trim()) : [];
|
|
60
|
+
if (!steps.length) {
|
|
61
|
+
return { ok: false, exitCode: null, timedOut: false, outputTail: 'preflight command could not be parsed' };
|
|
62
|
+
}
|
|
63
|
+
const sequence = steps.map((s) => ({ ...s, timeoutMs: Math.min(s.timeoutMs, timeoutMs) }));
|
|
64
|
+
const r = await runIsolatedSequence(sequence, { cwd });
|
|
65
|
+
const results = Array.isArray(r.results) ? r.results : [];
|
|
66
|
+
const last = results[results.length - 1];
|
|
67
|
+
const combined = results.map((x) => x.outputTail || '').join('');
|
|
68
|
+
const timedOut = results.some((x) => x.timedOut === true);
|
|
69
|
+
return {
|
|
70
|
+
ok: r.status === 'green' && !timedOut,
|
|
71
|
+
exitCode: last && typeof last.code === 'number' ? last.code : null,
|
|
72
|
+
timedOut,
|
|
73
|
+
outputTail: combined.slice(-OUTPUT_TAIL_CHARS),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Next hold state after a failed preflight check.
|
|
79
|
+
*
|
|
80
|
+
* @param {object|null|undefined} prev previous hold (or none)
|
|
81
|
+
* @param {{exitCode:number|null, outputTail:string}} result runPreflight result
|
|
82
|
+
* @param {number} now epoch ms
|
|
83
|
+
* @param {string} failText the person-facing "what to do" text
|
|
84
|
+
*/
|
|
85
|
+
function armPreflightHold(prev, result, now, failText) {
|
|
86
|
+
const attempts = prev && Number.isFinite(prev.attempts) ? prev.attempts + 1 : 1;
|
|
87
|
+
return {
|
|
88
|
+
since: prev && prev.since ? prev.since : new Date(now).toISOString(),
|
|
89
|
+
attempts,
|
|
90
|
+
nextAt: new Date(now + preflightDelayMs(attempts)).toISOString(),
|
|
91
|
+
lastExit: result && typeof result.exitCode === 'number' ? result.exitCode : null,
|
|
92
|
+
lastOutputTail: result && typeof result.outputTail === 'string' ? result.outputTail : '',
|
|
93
|
+
failText,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
module.exports = { normalizePreflight, preflightDelayMs, runPreflight, armPreflightHold };
|