copilot-operator 0.1.39 → 0.1.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/src/api/operator.controller.js +101 -2
  2. package/dist/src/api/operator.service.js +292 -25
  3. package/dist/src/api/server.js +7 -0
  4. package/dist/src/log/terminal.js +145 -0
  5. package/dist/src/plan/brief.js +1375 -1369
  6. package/dist/src/plan/schema.js +5 -0
  7. package/dist/src/plan/systemGuide.js +158 -16
  8. package/dist/src/session/exports.js +1 -0
  9. package/dist/src/session/startFailure.js +91 -0
  10. package/dist/src/vcs/prepareFromRemote.js +7 -20
  11. package/dist/src/vcs/remoteAuth.js +26 -1
  12. package/dist/src/vcs/runPreflight.js +31 -14
  13. package/dist/src/vcs/snapshot.js +3 -1
  14. package/dist/src/vcs/startChoice.js +295 -0
  15. package/dist/src/vcs/taskVcs.js +40 -5
  16. package/dist/web/404.html +2 -2
  17. package/dist/web/_next/static/chunks/499-28e118e33ce07935.js +1 -0
  18. package/dist/web/_next/static/chunks/549-f295c8429e83b25b.js +1 -0
  19. package/dist/web/_next/static/chunks/584-578be94a0786334b.js +1 -0
  20. package/dist/web/_next/static/chunks/867-8dc5bbb092ca2c5c.js +1 -0
  21. package/dist/web/_next/static/chunks/app/history/page-9f69ccde726c9be2.js +1 -0
  22. package/dist/web/_next/static/chunks/app/layout-73f28bc065a46ed3.js +1 -0
  23. package/dist/web/_next/static/chunks/app/page-e557d58476ae6383.js +1 -0
  24. package/dist/web/_next/static/chunks/app/sessions/view/page-0485ee7f781156ec.js +1 -0
  25. package/dist/web/_next/static/chunks/app/system/{page-5ae1f8054208e6eb.js → page-227a259e383ca2a0.js} +1 -1
  26. package/dist/web/appearance.html +2 -2
  27. package/dist/web/appearance.txt +27 -25
  28. package/dist/web/defaults.html +2 -2
  29. package/dist/web/defaults.txt +27 -25
  30. package/dist/web/history.html +2 -2
  31. package/dist/web/history.txt +27 -25
  32. package/dist/web/import.html +2 -2
  33. package/dist/web/import.txt +27 -25
  34. package/dist/web/index.html +2 -2
  35. package/dist/web/index.txt +27 -25
  36. package/dist/web/level1.html +2 -2
  37. package/dist/web/level1.txt +27 -25
  38. package/dist/web/presets.html +2 -2
  39. package/dist/web/presets.txt +27 -25
  40. package/dist/web/sessions/view.html +2 -2
  41. package/dist/web/sessions/view.txt +27 -25
  42. package/dist/web/system.html +2 -2
  43. package/dist/web/system.txt +27 -25
  44. package/package.json +158 -157
  45. package/dist/web/_next/static/chunks/549-bfde82e4a70ed1a0.js +0 -1
  46. package/dist/web/_next/static/chunks/584-eba7ffe26cf1be83.js +0 -1
  47. package/dist/web/_next/static/chunks/867-7fccf68b0840c0de.js +0 -1
  48. package/dist/web/_next/static/chunks/app/history/page-d3461384566aa332.js +0 -1
  49. package/dist/web/_next/static/chunks/app/layout-630b663626cebe4a.js +0 -1
  50. package/dist/web/_next/static/chunks/app/page-4defcfd1eb482644.js +0 -1
  51. package/dist/web/_next/static/chunks/app/sessions/view/page-945be57e397ae162.js +0 -1
  52. /package/dist/web/_next/static/{KYi1jz7Awse_66Fg8c7Ur → Y9tuV5LV-O0XyCREkeGc5}/_buildManifest.js +0 -0
  53. /package/dist/web/_next/static/{KYi1jz7Awse_66Fg8c7Ur → Y9tuV5LV-O0XyCREkeGc5}/_ssgManifest.js +0 -0
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[810],{3256:(e,s,t)=>{Promise.resolve().then(t.bind(t,4627))},4627:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>T});var n=t(3365),a=t(1521),l=t(8197),i=t.n(l),r=t(5549),o=t(7527),d=t(4969),c=t(1366),u=t(3523),h=t(3374),m=t(867),g=t(1910),p=t(5132);function x(){let{t:e}=(0,m.kj)(),[s,t]=(0,a.useState)(!1);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{type:"button",className:"info-dot","aria-expanded":s,"aria-label":e("row.info"),title:e("row.info"),onClick:()=>t(e=>!e),children:"i"}),s&&(0,n.jsxs)("div",{className:"notice info-panel",children:[(0,n.jsx)("strong",{children:e("row.infoTitle")}),(0,n.jsxs)("dl",{className:"small",children:[(0,n.jsx)("dt",{children:e("reg.openTask")}),(0,n.jsx)("dd",{children:e("row.infoOpenTask")}),(0,n.jsx)("dt",{children:e("save.log")}),(0,n.jsx)("dd",{children:e("save.why")}),(0,n.jsx)("dt",{children:e("home.col.chat")}),(0,n.jsx)("dd",{children:e("row.infoChat")})]}),(0,n.jsx)("div",{className:"small",style:{marginTop:6},children:e("row.infoExports")}),(0,n.jsxs)("dl",{className:"small",children:[(0,n.jsx)("dt",{children:e("reg.exportPlan")}),(0,n.jsx)("dd",{children:e("reg.exportPlanWhy")}),(0,n.jsx)("dt",{children:e("reg.exportDomain")}),(0,n.jsx)("dd",{children:e("reg.exportDomainWhy")}),(0,n.jsx)("dt",{children:e("reg.exportBot")}),(0,n.jsx)("dd",{children:e("reg.exportBotWhy")})]}),(0,n.jsx)(p.s,{text:e("row.infoWhich"),className:"small"})]})]})}function j(e){let{onChange:s}=e,{t}=(0,m.kj)(),[l,i]=(0,a.useState)(null),[d,c]=(0,a.useState)(!1),[u,h]=(0,a.useState)(""),g=(0,a.useCallback)(async()=>{try{i(await r.FH.batch())}catch(e){}},[]);(0,o.z)(g,3e3);let p=async e=>{c(!0),h("");try{"pause"===e?await r.FH.pauseBatch():"resume"===e?await r.FH.resumeBatch():await r.FH.stopBatch(),await g(),null==s||s()}catch(e){h(e.message)}finally{c(!1)}};return(null==l?void 0:l.running)?(0,n.jsxs)("div",{className:"row",style:{marginBottom:8},children:[l.pausing?(0,n.jsx)("button",{className:"primary",disabled:d,onClick:()=>void p("resume"),title:t("batch.resumeWhy"),children:t("batch.resume")}):(0,n.jsx)("button",{disabled:d||l.stopping,onClick:()=>void p("pause"),title:t("batch.pauseWhy"),children:t("batch.pause")}),(0,n.jsx)("button",{className:"danger",disabled:d||l.stopping,onClick:()=>void p("stop"),title:t("batch.stopWhy"),children:t("batch.stop")}),l.pausing&&!l.stopping&&(0,n.jsx)("span",{className:"muted small",children:t("batch.pausing")}),l.stopping&&(0,n.jsx)("span",{className:"muted small",children:t("batch.stopping")}),u&&(0,n.jsx)("span",{className:"err small",children:u})]}):null}var k=t(3041),v=t(1035),N=t(8934),f=t(4811),w=t(2876),b=t(287);let y=["queued","running","waiting-approval"],I=["blocked","failed","aborted","limit-reached"],C=e=>!!e.continuable;function S(e){let{run:s}=e,{t}=(0,m.kj)(),a=s.entries.some(u.DG),l=(0,h.c)(a),i=(0,u.eZ)(s,s.entries,l);return(0,n.jsx)(n.Fragment,{children:t(i.live?"reg.runRunning":"reg.runTook",{d:(0,r.c5)(i.ms)})})}let F=(0,a.createContext)(new Map),A=(0,a.createContext)({runPanel:null,setRunPanel:()=>void 0}),H=(0,a.createContext)(()=>void 0);function R(e){let s=new Map,t=[];for(let n of e){if(!n.runGroup){t.push(n);continue}let e=s.get(n.runGroup.id);e?e.entries.push(n):s.set(n.runGroup.id,{...n.runGroup,entries:[n]})}let n=[...s.values()].sort((e,s)=>Date.parse(s.startedAt)-Date.parse(e.startedAt));for(let e of n)e.entries.sort((e,s)=>{var t,n;return Date.parse(null!=(t=e.startedAt)?t:e.createdAt)-Date.parse(null!=(n=s.startedAt)?n:s.createdAt)});return{runs:n,loose:t}}function T(){let{t:e}=(0,m.kj)(),s=(0,m.W3)(),[t,l]=(0,a.useState)(null),[i,d]=(0,a.useState)(""),[c,u]=(0,a.useState)(""),[h,g]=(0,a.useState)("flow"),[p,x]=(0,a.useState)(""),[k,v]=(0,a.useState)(""),[N,f]=(0,a.useState)(""),w=(0,a.useCallback)(async()=>{try{l(await r.FH.tasks()),u(new Date().toISOString()),d("")}catch(e){d(e.message)}},[]);(0,o.z)(w,6e3);let b=(0,a.useMemo)(()=>{let e=new Map;for(let s of null!=t?t:[])e.has(s.sessionId)||e.set(s.sessionId,s.sessionName);return[...e.entries()]},[t]),C=(0,a.useMemo)(()=>{let e=N.trim().toLowerCase();return(null!=t?t:[]).filter(s=>{var t,n;return(!p||s.sessionId===p)&&(!k||s.status===k)&&(!e||"".concat(s.title," ").concat(null!=(t=s.summary)?t:""," ").concat(null!=(n=s.reason)?n:""," ").concat(s.sessionName).toLowerCase().includes(e))})},[t,p,k,N]),S=(0,a.useMemo)(()=>{let e=null!=t?t:[];return{total:e.length,done:e.filter(e=>"done"===e.status).length,running:e.filter(e=>"running"===e.status||"waiting-approval"===e.status).length,open:e.filter(e=>"queued"===e.status).length,failed:e.filter(e=>I.includes(e.status)).length}},[t]),T=(0,a.useMemo)(()=>{let e=new Map;for(let n of null!=t?t:[]){var s;n.runGroup&&e.set(n.runGroup.id,(null!=(s=e.get(n.runGroup.id))?s:0)+1)}return e},[t]),P=(0,a.useMemo)(()=>R(C),[C]),G=(0,a.useMemo)(()=>(function(e){let s=new Map;for(let n of e){var t;let e=n.title.trim().toLowerCase();s.set(e,[...null!=(t=s.get(e))?t:[],n])}let n=new Map;for(let e of s.values())for(let s of e){let t=e.filter(e=>e.sessionId!==s.sessionId);t.length>0&&n.set("".concat(s.sessionId,":").concat(s.taskId),t)}return n})(null!=t?t:[]),[t]),[O,z]=(0,a.useState)(null),U=(0,a.useMemo)(()=>({runPanel:O,setRunPanel:z}),[O]),[Z,K]=(0,a.useState)(null),Q=C.filter(e=>"running"===e.status||"waiting-approval"===e.status),J=C.filter(e=>"queued"===e.status),Y=[...C.filter(e=>I.includes(e.status)&&"stop"===e.sessionOnFailure&&!e.sessionRunning&&J.some(s=>s.sessionId===e.sessionId)),...J].sort((e,s)=>{var t,n;return(null!=(t=e.sessionRunOrder)?t:Number.MAX_SAFE_INTEGER)-(null!=(n=s.sessionRunOrder)?n:Number.MAX_SAFE_INTEGER)||e.position-s.position}),$=C.filter(e=>!y.includes(e.status)).sort((e,s)=>{var t,n,a,l;return Date.parse(null!=(n=null!=(t=s.finishedAt)?t:s.startedAt)?n:s.createdAt)-Date.parse(null!=(l=null!=(a=e.finishedAt)?a:e.startedAt)?l:e.createdAt)}),ee=""!==p||""!==k||""!==N.trim();return(0,n.jsx)(F.Provider,{value:G,children:(0,n.jsx)(A.Provider,{value:U,children:(0,n.jsxs)(H.Provider,{value:K,children:[(null==Z?void 0:Z.kind)==="fix-prompt"&&(0,n.jsx)(_,{entry:Z.entry,offerRun:!0,onClose:e=>{K(null),e&&w()}}),(null==Z?void 0:Z.kind)==="contract"&&(0,n.jsx)(B,{entry:Z.entry,onChange:()=>void w(),onClose:e=>{K(null),e&&w()}}),(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("h2",{className:"grow",style:{margin:0},children:e("reg.title")}),(0,n.jsx)("span",{className:"muted small",children:c&&e("reg.updated",{t:s(c)})}),(0,n.jsx)("button",{className:"quiet",onClick:()=>void w(),children:e("reg.refresh")})]}),(0,n.jsx)("p",{className:"muted small",children:e("reg.hint")}),(0,n.jsx)(L,{sessions:b}),(0,n.jsxs)("div",{className:"counts",children:[(0,n.jsxs)("div",{className:"count",children:[(0,n.jsx)("div",{className:"n",children:S.total}),(0,n.jsx)("div",{className:"k",children:e("reg.total")})]}),(0,n.jsxs)("div",{className:"count done",children:[(0,n.jsx)("div",{className:"n",children:S.done}),(0,n.jsx)("div",{className:"k",children:e("reg.done")})]}),(0,n.jsxs)("div",{className:"count running",children:[(0,n.jsx)("div",{className:"n",children:S.running}),(0,n.jsx)("div",{className:"k",children:e("reg.runningCount")})]}),(0,n.jsxs)("div",{className:"count queued",children:[(0,n.jsx)("div",{className:"n",children:S.open}),(0,n.jsx)("div",{className:"k",children:e("reg.open")})]}),(0,n.jsxs)("div",{className:"count failed",children:[(0,n.jsx)("div",{className:"n",children:S.failed}),(0,n.jsx)("div",{className:"k",children:e("reg.failedCount")})]})]})]}),i&&(0,n.jsx)("div",{className:"panel err",children:i}),(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsxs)("div",{className:"toolbar",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{htmlFor:"f-session",style:{margin:0},children:e("reg.filterSession")}),(0,n.jsxs)("select",{id:"f-session",value:p,onChange:e=>x(e.target.value),children:[(0,n.jsx)("option",{value:"",children:e("reg.allSessions")}),b.map(e=>{let[s,t]=e;return(0,n.jsx)("option",{value:s,children:t},s)})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{htmlFor:"f-status",style:{margin:0},children:e("reg.filterStatus")}),(0,n.jsxs)("select",{id:"f-status",value:k,onChange:e=>v(e.target.value),children:[(0,n.jsx)("option",{value:"",children:e("reg.allStatuses")}),["queued","running","waiting-approval","done","blocked","failed","aborted","limit-reached"].map(s=>(0,n.jsx)("option",{value:s,children:e("status.".concat(s))},s))]})]}),(0,n.jsxs)("div",{className:"grow",children:[(0,n.jsx)("label",{htmlFor:"f-q",style:{margin:0},children:e("reg.search")}),(0,n.jsx)("input",{id:"f-q",type:"text",value:N,onChange:e=>f(e.target.value),placeholder:e("reg.searchPlaceholder")})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{style:{margin:0},id:"view-label",children:e("reg.viewLabel")}),(0,n.jsxs)("div",{className:"segmented",role:"group","aria-labelledby":"view-label",children:[(0,n.jsx)("button",{type:"button","aria-pressed":"flow"===h,onClick:()=>g("flow"),children:e("reg.viewFlow")}),(0,n.jsx)("button",{type:"button","aria-pressed":"runs"===h,onClick:()=>g("runs"),children:e("reg.groupBy")}),(0,n.jsx)("button",{type:"button","aria-pressed":"list"===h,onClick:()=>g("list"),children:e("reg.viewList")})]})]}),ee&&(0,n.jsx)("button",{className:"quiet",onClick:()=>{x(""),v(""),f("")},children:e("reg.clear")})]}),null===t&&(0,n.jsx)("div",{className:"muted",children:e("home.loading")}),null!==t&&0===t.length&&(0,n.jsx)("div",{className:"empty",children:e("reg.none")}),null!==t&&t.length>0&&0===C.length&&(0,n.jsx)("div",{className:"empty",children:e("reg.noMatch")})]}),"list"===h&&C.length>0&&(0,n.jsx)(X,{entries:[...Q,...J,...$]}),"runs"===h&&C.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsx)("h2",{children:e("reg.runGroup")}),(0,n.jsx)("p",{className:"muted small",children:e("reg.runGroupHint")})]}),P.runs.map(e=>(0,n.jsxs)("section",{className:"panel",children:[(0,n.jsx)(M,{run:e}),(0,n.jsx)(E,{entries:e.entries,sizes:T,onChange:()=>void w()})]},e.id)),P.loose.length>0&&(0,n.jsxs)("section",{className:"panel",children:[(0,n.jsx)("h2",{children:e("reg.notInARun")}),(0,n.jsx)("p",{className:"muted small",children:e("reg.notInARunHint")}),(0,n.jsx)(E,{entries:P.loose,sizes:T,onChange:()=>void w()})]})]}),"flow"===h&&(0,n.jsxs)(n.Fragment,{children:[Q.length>0&&(0,n.jsxs)("section",{className:"panel",children:[(0,n.jsx)("h2",{children:e("reg.activeNow")}),(0,n.jsx)(E,{entries:Q,sizes:T,onChange:()=>void w()})]}),C.length>0&&(0,n.jsxs)("div",{style:{marginBottom:12},children:[(0,n.jsx)(j,{onChange:()=>void w()}),C.some(e=>e.interrupted&&!e.sessionRunning)&&(0,n.jsxs)("div",{className:"notice caution",role:"status",children:[(0,n.jsx)("strong",{children:e("reg.interruptedTitle")})," ",e("reg.interrupted",{n:C.filter(e=>e.interrupted&&!e.sessionRunning).length})]}),(0,n.jsx)(V,{entries:C,onChange:()=>void w()})]}),C.length>0&&(0,n.jsxs)("section",{className:"panel",children:[(0,n.jsx)("h2",{children:e("reg.past")}),(0,n.jsx)("p",{className:"muted small",children:e("reg.pastHint")}),0===$.length?(0,n.jsx)("div",{className:"empty",children:e("reg.noPast")}):(0,n.jsx)(D,{entries:$,sizes:T,onChange:()=>void w()})]}),C.length>0&&(0,n.jsx)("section",{className:"panel",children:(0,n.jsxs)(q,{count:Y.length,children:[(0,n.jsx)("p",{className:"muted small",children:e("reg.upcomingHint")}),0===Y.length?(0,n.jsx)("div",{className:"empty",children:e("reg.noUpcoming")}):(0,n.jsx)(E,{entries:Y,upcoming:!0,sizes:T,onChange:()=>void w()})]})}),t&&t.length>0&&(0,n.jsx)(W,{refreshKey:c})]})]})})})}let P="cop.register.upcomingOpen";function q(e){let{count:s,children:t}=e,{t:l}=(0,m.kj)(),[i,r]=(0,a.useState)(()=>{try{let e=window.localStorage.getItem(P);if("true"===e||"false"===e)return"true"===e}catch(e){}return s<=8});return(0,n.jsxs)("details",{open:i,children:[(0,n.jsx)("summary",{onClick:e=>{e.preventDefault();let s=!i;r(s);try{window.localStorage.setItem(P,String(s))}catch(e){}},children:(0,n.jsxs)("h2",{style:{display:"inline"},children:[l("reg.upcoming")," (",s,")"]})}),i&&t]})}function W(e){let{refreshKey:s}=e,{t}=(0,m.kj)(),[l,i]=(0,a.useState)(null),[o,d]=(0,a.useState)("");if((0,a.useEffect)(()=>{r.FH.metrics().then(e=>{i(e),d("")}).catch(e=>d(e.message))},[s]),!l)return o?(0,n.jsx)("div",{className:"panel err",children:o}):null;let c=e=>0===e.of?"—":"".concat(e.n," / ").concat(e.of," (").concat(Math.round(100*e.n/e.of),"%)"),u=[["metrics.tasks",e=>"".concat(e.tasks," \xb7 ").concat(t("metrics.attemptsN",{n:e.attempts}))],["metrics.firstPass",e=>c(e.firstPass)],["metrics.doneInTheEnd",e=>c(e.doneInTheEnd)],["metrics.falseCompletion",e=>c(e.falseCompletion)],["metrics.reviewRejection",e=>c(e.reviewRejection)],["metrics.repeatedCommands",e=>c(e.repeatedCommands)],["metrics.noProgress",e=>c(e.noProgress)],["metrics.scopeViolation",e=>c(e.scopeViolation)],["metrics.unrelatedDiff",e=>c(e.unrelatedDiff)],["metrics.resumed",e=>c(e.resumed)],["metrics.freshRetries",e=>String(e.freshRetries)],["metrics.manual",e=>String(e.manualInterventions)],["metrics.ended",e=>Object.entries(e.ended).map(e=>{let[s,n]=e;return"".concat(t("status.".concat(s))," ").concat(n)}).join(", ")||"—"]],h=l.rows[0];return(0,n.jsxs)("section",{className:"panel metrics",children:[(0,n.jsx)("h2",{children:t("metrics.title")}),(0,n.jsx)("p",{className:"muted small",children:t("metrics.hint")}),h&&h.withStats<h.attempts&&(0,n.jsx)("p",{className:"muted small",children:t("metrics.olderAttempts",{n:h.attempts-h.withStats})}),(0,n.jsx)("div",{className:"table-scroll",children:(0,n.jsxs)("table",{children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:t("metrics.col.measure")}),l.rows.map(e=>(0,n.jsx)("th",{children:"all"===e.group?t("metrics.col.all"):e.group},e.group))]})}),(0,n.jsx)("tbody",{children:u.map(e=>{let[s,a]=e;return(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{children:t(s)}),l.rows.map(e=>(0,n.jsx)("td",{children:a(e)},e.group))]},s)})})]})})]})}function E(e){let{entries:s,upcoming:t=!1,sizes:l,onChange:o,picking:d}=e,{t:c}=(0,m.kj)(),j=(0,m.W3)(),v=(0,k.e)(null!=o?o:()=>void 0),f=(0,h.c)(s.some(u.DG)),[S,R]=(0,a.useState)(new Set),[T,P]=(0,a.useState)(null),{runPanel:q,setRunPanel:W}=(0,a.useContext)(A),E=(0,a.useContext)(H),M=(0,a.useContext)(F);return(0,n.jsx)(n.Fragment,{children:(0,n.jsx)("ol",{className:"flow",children:s.map(e=>{var s,a,h,m,k,F,A,H,D,_,B,L,U,V,X,Z,K,Q,J,Y,$,ee,es,et,en,ea,el;let ei=t&&1===e.queuePosition,er=e.runGroup?null!=(H=null==l?void 0:l.get(e.runGroup.id))?H:1:0;return(0,n.jsxs)("li",{className:"".concat(e.status).concat(ei?" next":""),children:[(0,n.jsx)("span",{className:"flow-mark",role:"img","aria-label":c("status.".concat(e.status)),title:c("flow.markWhy",{status:c("status.".concat(e.status))})}),(0,n.jsxs)("div",{className:"head",children:[d&&(0,n.jsx)("input",{type:"checkbox",className:"pick","aria-label":e.title,checked:d.picked.has("".concat(e.sessionId,":").concat(e.taskId)),onChange:()=>d.toggle("".concat(e.sessionId,":").concat(e.taskId))}),(0,n.jsx)("strong",{children:e.title}),(0,n.jsx)("span",{className:"badge ".concat(e.status),children:c("status.".concat(e.status))}),ei&&(0,n.jsx)("span",{className:"chip",children:c("reg.next")}),(0,n.jsx)(G,{entry:e,twins:M.get("".concat(e.sessionId,":").concat(e.taskId))}),e.limit&&(0,n.jsx)("span",{className:"chip",title:c("reg.limitChipWhy"),children:c("reg.limitChip",{limit:(el=e.limit,c("limit.".concat(el.setting),{n:el.value}))})}),t&&I.includes(e.status)&&(0,n.jsx)("span",{className:"chip",title:c("reg.willRequeueFirstWhy"),children:c("reg.willRequeueFirst")}),e.sessionRunning&&(0,n.jsx)("span",{className:"chip",children:c("reg.sessionRunning")}),e.review&&"skipped"!==e.review.verdict&&(0,n.jsxs)("span",{className:"badge ".concat("pass"===e.review.verdict?"done":"fail"===e.review.verdict?"blocked":"waiting-approval"),title:e.review.stepsRun>0?c("review.ran",{n:e.review.stepsRun}):void 0,children:[c("review.verdict.".concat(e.review.verdict)),e.review.findings>0?" (".concat(e.review.findings,")"):""]}),(null!=(D=e.deviations)?D:0)>0&&(0,n.jsx)("span",{className:"badge waiting-approval",title:c("reg.deviationsWhy"),children:c("reg.deviations",{n:null!=(_=e.deviations)?_:0})}),(null!=(B=e.disputes)?B:0)>0&&(0,n.jsx)("span",{className:"badge waiting-approval",title:c("reg.disputesWhy"),children:c("reg.disputes",{n:null!=(L=e.disputes)?L:0})}),e.readOnly&&(0,n.jsx)("span",{className:"chip",title:c("reg.readOnlyWhy"),children:c("task.readOnly")}),e.stopCode&&(0,n.jsx)("span",{className:"chip",title:c("stop.why"),children:c("stop.".concat(e.stopCode))}),(null!=(U=null==(s=e.scope)?void 0:s.length)?U:0)>0&&(0,n.jsx)("span",{className:"chip",title:c("task.scopeWhy"),children:c("task.scope",{paths:(null!=(V=e.scope)?V:[]).join(", ")})}),(null!=(X=e.autoRetries)?X:0)>0&&(0,n.jsx)("span",{className:"badge ".concat("done"===e.status?"done":"blocked"===e.status?"blocked":""),title:c("reg.retriedFreshWhy"),children:"done"===e.status?c("reg.retriedFreshDone",{n:null!=(Z=e.autoRetries)?Z:0}):"blocked"===e.status?c("reg.retriedFreshStill",{n:null!=(K=e.autoRetries)?K:0}):c("reg.retriedFreshOther",{n:null!=(Q=e.autoRetries)?Q:0})}),e.runGroup&&(0,n.jsx)("span",{className:"chip",title:c("reg.runTitle",{t:er,s:e.runGroup.sessions,when:j(e.runGroup.startedAt)}),children:er>1?c("reg.runWith",{n:er-1}):c("reg.runAlone")})]}),(0,n.jsxs)("div",{className:"when",children:[(0,n.jsx)(i(),{href:(0,r.aT)(e.sessionId),children:e.sessionName})," \xb7 ",e.startedAt?c("task.started",{t:j(e.startedAt)}):c("task.added",{t:j(e.createdAt)}),e.finishedAt?" \xb7 ".concat(c("task.finished",{t:j(e.finishedAt)})):"",void 0!==e.durationMs?" \xb7 ".concat(c("reg.took",{d:(0,r.c5)(e.durationMs)})):"",(0,u.DG)(e)?" \xb7 ".concat(c("task.runningFor",{d:(0,r.c5)((0,u.d5)(e.startedAt,void 0,f))})):"",e.iterations>0?" \xb7 ".concat(c("reg.iterations",{n:e.iterations})):""]}),"queued"===e.status&&(0,n.jsx)("div",{className:"when",children:e.queuePosition&&e.queuePosition>1?c("reg.willFollow",{n:e.queuePosition-1}):e.sessionRunning?c("reg.queuePos",{n:null!=(J=e.queuePosition)?J:1}):c("reg.waitingRun")}),"blocked"===e.status&&(0,n.jsx)("p",{className:"what muted small",children:c("reg.blockedWhat")}),(null!=(Y=null==(a=e.attempts)?void 0:a.length)?Y:0)>0&&(0,n.jsxs)("details",{className:"small",style:{marginTop:6},children:[(0,n.jsx)("summary",{children:(null!=($=null==(h=e.attempts)?void 0:h.length)?$:0)===1?c("reg.attemptsOne",{n:null!=(es=e.attempt)?es:(null!=(ee=null==(m=e.attempts)?void 0:m.length)?ee:0)+1}):c("reg.attempts",{n:null!=(en=e.attempt)?en:(null!=(et=null==(k=e.attempts)?void 0:k.length)?et:0)+1,m:null!=(ea=null==(F=e.attempts)?void 0:F.length)?ea:0})}),(0,n.jsx)("ol",{className:"attempts",children:null==(A=e.attempts)?void 0:A.map(s=>{var t;return(0,n.jsxs)("li",{children:[(0,n.jsxs)("div",{className:"head",children:[(0,n.jsx)("strong",{children:c("reg.attemptN",{n:s.attempt})}),(0,n.jsx)("span",{className:"badge ".concat(s.status),children:c("status.".concat(s.status))}),s.iterations>0&&(0,n.jsx)("span",{className:"muted",children:c("reg.iterations",{n:s.iterations})}),void 0!==s.durationMs&&(0,n.jsx)("span",{className:"muted",children:c("reg.took",{d:(0,r.c5)(s.durationMs)})}),s.runId&&(0,n.jsx)(g.u,{label:c("save.attemptLog"),save:()=>r.FH.saveTaskLog(e.sessionId,e.taskId,s.runId)}),s.runId&&(0,n.jsx)(g.H,{sessionId:e.sessionId,taskId:e.taskId,attempt:s.attempt}),s.runId&&void 0!==s.changedFiles&&(0,n.jsx)(N.C,{sessionId:e.sessionId,taskId:e.taskId,runId:s.runId,title:"".concat(e.title," — ").concat(c("reg.attemptN",{n:s.attempt})),files:s.changedFiles})]}),(0,n.jsxs)("div",{className:"when",children:[s.startedAt?c("task.started",{t:j(s.startedAt)}):"",s.finishedAt?" \xb7 ".concat(c("task.finished",{t:j(s.finishedAt)})):"",s.branch?" \xb7 ".concat(s.branch):""]}),s.reason&&(0,n.jsx)("p",{className:"what err",children:c("reg.stopped",{reason:s.reason})}),s.summary&&(0,n.jsx)(p.s,{text:s.summary,className:"what"})]},"".concat(null!=(t=s.runId)?t:s.attempt))})})]}),e.summary&&(0,n.jsx)(p.s,{text:e.summary,className:"what"}),e.reason&&(0,n.jsx)("p",{className:"what err",children:c("reg.stopped",{reason:e.reason})}),v.message&&v.messageTask===e.taskId&&(0,n.jsx)("p",{className:"what small",children:v.message}),(0,n.jsxs)("div",{className:"row small",style:{marginTop:6},children:[(0,n.jsx)(i(),{href:(0,r.aT)(e.sessionId,e.taskId),children:c("reg.openTask")}),e.runId&&(0,n.jsx)(g.u,{label:c("save.log"),save:()=>r.FH.saveTaskLog(e.sessionId,e.taskId)}),e.chatUrl&&(0,n.jsx)("a",{href:e.chatUrl,target:"_blank",rel:"noreferrer",children:c("home.col.chat")}),e.startedAt&&(0,n.jsx)(O,{where:{session:e.sessionId,task:e.taskId}}),void 0!==e.changedFiles&&(0,n.jsx)(N.C,{sessionId:e.sessionId,taskId:e.taskId,title:e.title,files:e.changedFiles}),(0,n.jsx)(x,{}),e.runId&&(0,n.jsxs)("button",{className:S.has(e.taskId)?"":"quiet","aria-expanded":S.has(e.taskId),onClick:()=>{let s;return s=e.taskId,R(e=>{let t=new Set(e);return t.has(s)?t.delete(s):t.add(s),t})},title:(0,u.DG)(e)?c("story.showLiveWhy"):c("story.why"),children:[(0,u.DG)(e)&&!S.has(e.taskId)&&(0,n.jsx)("span",{className:"dot","aria-hidden":"true"}),S.has(e.taskId)?c("story.hide"):(0,u.DG)(e)?c("story.showLive"):c("story.show")]}),"queued"===e.status&&!e.sessionRunning&&!e.sessionInactive&&(0,n.jsx)("button",{className:(null==q?void 0:q.taskId)===e.taskId?"":"primary","aria-expanded":(null==q?void 0:q.taskId)===e.taskId,onClick:()=>W((null==q?void 0:q.taskId)===e.taskId?null:{taskId:e.taskId}),title:c("runq.buttonWhy"),children:c("runq.button")}),"contract-conflict"===e.stopCode&&!y.includes(e.status)&&!e.sessionRunning&&(0,n.jsx)("button",{className:"primary","aria-haspopup":"dialog",onClick:()=>E({kind:"contract",entry:e}),title:c("cfix.buttonWhy"),children:c("cfix.button")}),C(e)&&!e.sessionRunning&&!e.sessionInactive&&(0,n.jsx)("button",{className:T===e.taskId?"":"primary","aria-expanded":T===e.taskId,onClick:()=>P(T===e.taskId?null:e.taskId),title:c("reg.continueHereWhy"),children:c("reg.continueHere")}),!C(e)&&("failed"===e.status||"blocked"===e.status)&&!e.sessionRunning&&!e.sessionInactive&&(0,n.jsx)("button",{className:T===e.taskId||"contract-conflict"===e.stopCode?"":"primary","aria-expanded":T===e.taskId,onClick:()=>P(T===e.taskId?null:e.taskId),title:c("reg.rerunHereWhy"),children:c("reg.rerunHere")}),I.includes(e.status)&&!e.sessionRunning&&(0,n.jsx)("button",{className:"quiet","aria-haspopup":"dialog",onClick:()=>E({kind:"fix-prompt",entry:e}),title:c("reg.fixPromptHint"),children:c("reg.fixPrompt")}),"done"===e.status&&!e.sessionRunning&&(0,n.jsx)("button",{className:"quiet","aria-haspopup":"dialog",onClick:()=>E({kind:"fix-prompt",entry:e}),title:c("reg.newPromptHint"),children:c("reg.newPrompt")}),e.startedAt&&!e.sessionRunning&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{className:"quiet",disabled:""!==v.busy,title:c("restore.why"),onClick:()=>void v.restore({sessionId:e.sessionId,taskId:e.taskId,title:e.title}),children:"restore"===v.busy?c("restore.checking"):c("restore.button")}),(0,n.jsx)("button",{className:"quiet",disabled:""!==v.busy,title:c("restart.why"),onClick:()=>void v.restartFrom({sessionId:e.sessionId,taskId:e.taskId,title:e.title}),children:"restart"===v.busy?c("restart.checking"):c("restart.button")})]})]}),T===e.taskId&&(C(e)||"failed"===e.status||"blocked"===e.status)&&!e.sessionRunning&&(0,n.jsx)(z,{entry:e,onClose:e=>{P(null),e&&(null==o||o())}}),(null==q?void 0:q.taskId)===e.taskId&&"queued"===e.status&&(0,n.jsx)(b.f,{target:{sessionId:e.sessionId,taskId:e.taskId,title:e.title},onClose:e=>{W(null),e&&(null==o||o())}}),S.has(e.taskId)&&e.runId&&(0,n.jsx)(w.P,{sessionId:e.sessionId,taskId:e.taskId,live:"running"===e.status||"waiting-approval"===e.status})]},"".concat(e.sessionId,"-").concat(e.taskId))})})})}function G(e){var s;let{entry:t,twins:a}=e,{t:l}=(0,m.kj)(),i=(0,m.W3)();if(!a||0===a.length)return null;let r=l("twin.why",{mine:i(t.createdAt),attempt:null!=(s=t.attempt)?s:1});return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"chip twin",title:r,children:l("twin.sameTitle",{n:a.length})}),a.map(e=>{var s;return(0,n.jsx)("span",{className:"chip twin",title:r,children:l("twin.alsoIn",{session:e.sessionName,when:i(e.createdAt),status:l("status.".concat(e.status)),attempt:null!=(s=e.attempt)?s:1})},"".concat(e.sessionId,":").concat(e.taskId))})]})}function O(e){let{where:s}=e,{t}=(0,m.kj)();return(0,n.jsxs)("span",{className:"exports",title:t("reg.exportTitle"),children:[(0,n.jsxs)("span",{className:"muted",children:[t("reg.exportTitle"),":"]})," ",(0,n.jsx)("a",{href:r.FH.exportUrl("plan",s),title:t("reg.exportPlanWhy"),children:t("reg.exportPlan")})," \xb7 ",(0,n.jsx)("a",{href:r.FH.exportUrl("domain",s),title:t("reg.exportDomainWhy"),children:t("reg.exportDomain")})," \xb7 ",(0,n.jsx)("a",{href:r.FH.exportUrl("bot",s),title:t("reg.exportBotWhy"),children:t("reg.exportBot")})]})}function M(e){var s;let{run:t}=e,{t:a}=(0,m.kj)(),l=(0,m.W3)(),i=null!=(s=t.entries.map(e=>{var s;return null==(s=e.runGroup)?void 0:s.name}).find(Boolean))?s:a("reg.runUnnamed"),r=t.entries.filter(e=>"done"===e.status).length,o=t.entries.filter(e=>I.includes(e.status)).length;return(0,n.jsxs)("div",{className:"run-heading",children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("h2",{className:"grow",style:{margin:0},children:i}),(0,n.jsxs)("span",{className:"muted small",children:[a("reg.runOf",{t:t.entries.length,s:t.sessions})," \xb7 ",a("reg.runAt",{when:l(t.startedAt)})," \xb7 ",(0,n.jsx)(S,{run:t})]})]}),(0,n.jsxs)("div",{className:"row small",style:{marginTop:4},children:[(0,n.jsx)("span",{className:"badge ".concat(o>0?"failed":r===t.entries.length?"done":""),children:a("reg.runCounts",{done:r,failed:o})}),(0,n.jsx)(O,{where:{run:t.id}})]})]})}function D(e){let{entries:s,sizes:t,onChange:l}=e,{t:i}=(0,m.kj)(),o=(0,a.useMemo)(()=>R(s),[s]),[d,c]=(0,a.useState)(!1),[u,h]=(0,a.useState)(new Set),[g,p]=(0,a.useState)(!1),[x,j]=(0,a.useState)(""),[k,v]=(0,a.useState)(""),N=e=>"".concat(e.sessionId,":").concat(e.taskId),f=s.filter(e=>e.startedAt),w=[...u],b=async()=>{p(!0),v(""),j("");try{let e=await r.FH.downloadBundle(w.map(e=>{let[s,t]=e.split(":");return{sessionId:s,taskId:t}}));j(i("reg.bundleSaved",{name:e}))}catch(e){v(e.message)}finally{p(!1)}},y=d?{picked:u,toggle:e=>h(s=>{let t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})}:void 0;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"row small",style:{marginBottom:8},children:[d?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{className:"quiet",onClick:()=>{c(!1),h(new Set),j(""),v("")},children:i("reg.pickDone")}),(0,n.jsx)("button",{className:"quiet",onClick:()=>h(new Set(f.map(N))),children:i("reg.pickAll")}),(0,n.jsx)("button",{className:"quiet",onClick:()=>h(new Set),children:i("reg.pickNone")}),(0,n.jsx)("span",{className:"muted",children:u.size>0?i("reg.pickedN",{n:u.size}):i("reg.pickedNone")}),u.size>0&&(0,n.jsx)("button",{className:"primary",disabled:g,onClick:()=>void b(),title:i("reg.bundleWhy"),children:i("reg.bundle",{n:u.size})})]}):(0,n.jsx)("button",{className:"quiet",onClick:()=>c(!0),title:i("reg.pickWhy"),children:i("reg.pick")}),x&&(0,n.jsx)("span",{className:"muted",children:x}),k&&(0,n.jsx)("span",{className:"err",children:k})]}),o.runs.map((e,s)=>(0,n.jsxs)("details",{className:"run-fold",open:0===s||d,children:[(0,n.jsx)("summary",{children:(0,n.jsx)(M,{run:e})}),(0,n.jsx)(E,{entries:e.entries,sizes:t,onChange:l,picking:y})]},e.id)),o.loose.length>0&&(0,n.jsxs)("details",{className:"run-fold",open:0===o.runs.length||d,children:[(0,n.jsx)("summary",{children:(0,n.jsxs)("div",{className:"run-heading",children:[(0,n.jsx)("h2",{style:{margin:0},children:i("reg.notInARun")}),(0,n.jsx)("p",{className:"muted small",style:{margin:"4px 0 0"},children:i("reg.notInARunHint")})]})}),(0,n.jsx)(E,{entries:o.loose,sizes:t,onChange:l,picking:y})]})]})}function _(e){let{entry:s,onClose:t,offerRun:l=!1}=e,{t:i}=(0,m.kj)(),[o,u]=(0,a.useState)(null),[h,g]=(0,a.useState)(""),[p,x]=(0,a.useState)(!1),[j,k]=(0,a.useState)(!1),[v,N]=(0,a.useState)([]),[f,w]=(0,a.useState)(new Set),[y,I]=(0,a.useState)(!1),[C,S]=(0,a.useState)(""),[F,A]=(0,a.useState)(""),H=(0,a.useRef)(null);(0,d.V)(H,!0),(0,a.useEffect)(()=>{let e=e=>{"Escape"!==e.key||e.defaultPrevented||p||document.querySelector('[role="alertdialog"]')||t(j)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[p,j,t]),(0,a.useEffect)(()=>{let e=!0;return r.FH.session(s.sessionId).then(t=>{var n,a,l,i;let r=t.tasks.find(e=>e.id===s.taskId);if(!e)return;u(null!=(n=null==r?void 0:r.prompt)?n:""),A(null!=(a=null==r?void 0:r.prompt)?a:"");let o=null!=(l=null==r?void 0:r.checks)?l:[];N(o),w(new Set("done"===s.status?[]:o.map((e,s)=>s))),I(!!(null==r?void 0:r.readOnly)),S((null!=(i=null==r?void 0:r.scope)?i:[]).join("\n"))}).catch(s=>{e&&g(s.message)}),()=>{e=!1}},[s.sessionId,s.taskId]);let R=async()=>{if(null!==o){x(!0),g("");try{await r.FH.rerunTask(s.sessionId,s.taskId,{prompt:o,checks:v.filter((e,s)=>f.has(s)),readOnly:y,scope:y?[]:(0,c.w)(C)},{buildOnFinished:"done"===s.status}),g(i("reg.fixPromptSaved",{title:s.title})),l?(k(!0),x(!1)):setTimeout(()=>t(!0),900)}catch(e){g(e.message),x(!1)}}};return(0,n.jsx)("div",{className:"modal-backdrop",role:"presentation",onClick:()=>t(j),children:(0,n.jsxs)("div",{ref:H,className:"modal wide",role:"dialog","aria-modal":"true","aria-labelledby":"fix-title",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("h2",{id:"fix-title",children:i("reg.fixPromptTitle",{title:s.title})}),j?(0,n.jsx)(b.f,{target:{sessionId:s.sessionId,taskId:s.taskId,title:s.title},intro:"".concat(h," ").concat(i("runq.ask")),focusFirst:!0,onClose:()=>t(!0)}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{className:"muted small",children:i("done"===s.status?"reg.newPromptHint":"reg.fixPromptHint")}),s.reason&&(0,n.jsx)("p",{className:"what err small",children:i("reg.stopped",{reason:s.reason})}),null===o?(0,n.jsx)("p",{className:"muted small",children:h||i("reg.fixPromptLoading")}):(0,n.jsx)("textarea",{className:"prose","aria-labelledby":"fix-title",value:o,onChange:e=>u(e.target.value),style:{minHeight:260},disabled:p}),null!==o&&v.length>0&&(0,n.jsxs)("div",{style:{marginTop:10},children:[(0,n.jsx)("strong",{className:"small",children:i("reg.keepChecks")}),(0,n.jsx)("p",{className:"why",children:i("reg.keepChecksWhy")}),v.map((e,s)=>(0,n.jsx)("div",{className:"option",style:{margin:"4px 0"},children:(0,n.jsxs)("label",{children:[(0,n.jsx)("input",{type:"checkbox",checked:f.has(s),onChange:e=>w(t=>{let n=new Set(t);return e.target.checked?n.add(s):n.delete(s),n})}),(0,n.jsx)("span",{children:e.name})]})},s))]}),null!==o&&o.trim()!==F.trim()&&(0,n.jsx)("p",{className:"notice caution small",children:i("task.newIntentNote")}),null!==o&&(0,n.jsx)(c.y,{readOnly:y,scope:C,onReadOnly:I,onScope:S}),(0,n.jsxs)("div",{className:"row modal-actions",children:[h&&null!==o&&(0,n.jsx)("span",{className:"small grow",children:h}),(0,n.jsx)("button",{type:"button",className:"quiet",onClick:()=>t(!1),disabled:p,children:i("dialog.cancel")}),(0,n.jsx)("button",{type:"button",className:"primary",onClick:()=>void R(),disabled:p||null===o||!o.trim(),children:i("reg.fixPromptSave")})]})]})]})})}function B(e){let{entry:s,onChange:t,onClose:l}=e,{t:i}=(0,m.kj)(),[r,o]=(0,a.useState)(!1),[c,u]=(0,a.useState)(null),h=(0,a.useRef)(null);(0,d.V)(h,!0),(0,a.useEffect)(()=>{let e=e=>{"Escape"!==e.key||e.defaultPrevented||document.querySelector('[role="alertdialog"]')||l(r)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[r,l]);let g={sessionId:s.sessionId,taskId:s.taskId,title:s.title};return(0,n.jsx)("div",{className:"modal-backdrop",role:"presentation",onClick:()=>l(r),children:(0,n.jsxs)("div",{ref:h,className:"modal wide",role:"dialog","aria-modal":"true","aria-labelledby":"contract-title",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("h2",{id:"contract-title",children:i("cfix.button")}),s.reason&&(0,n.jsx)("p",{className:"what err small",children:i("reg.stopped",{reason:s.reason})}),null!==c?(0,n.jsx)(b.f,{target:g,intro:"".concat(c," ").concat(i("runq.savedOffer")),focusFirst:!0,onClose:()=>l(!0)}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(b.y,{target:g,onApplied:(e,s)=>{o(!0),t(),0===e&&u(s)}}),(0,n.jsx)("div",{className:"row modal-actions",children:(0,n.jsx)("button",{type:"button",className:"quiet",onClick:()=>l(r),children:i(r?"runq.later":"dialog.cancel")})})]})]})})}function L(e){let{sessions:s}=e,{t}=(0,m.kj)();return(0,n.jsxs)("div",{className:"row",style:{margin:"14px 0 18px"},children:[(0,n.jsx)(i(),{href:"/#new-session",className:"button-link",children:t("reg.newSession")}),s.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("label",{htmlFor:"new-task-session",style:{margin:0},children:[t("reg.newTask")," ",t("reg.newTaskIn")]}),(0,n.jsxs)("select",{id:"new-task-session",value:"",onChange:e=>{e.target.value&&(window.location.href=(0,r.aT)(e.target.value,"new-task"))},style:{width:"auto",minWidth:200},children:[(0,n.jsx)("option",{value:"",children:t("reg.newTaskPick")}),s.map(e=>{let[s,t]=e;return(0,n.jsx)("option",{value:s,children:t},s)})]})]})]})}function z(e){let{entry:s,onClose:t}=e,{t:l}=(0,m.kj)(),i=(0,f.p)(),[o,d]=(0,a.useState)(!1),[c,u]=(0,a.useState)(""),h=C(s),g=h?s.branch?s.commit?l("reg.continueHereCommitted",{branch:s.branch,commit:s.commit.slice(0,8)}):s.vcsProblem?l("reg.continueHereNotCommitted",{branch:s.branch,problem:s.vcsProblem}):l("reg.continueHereNothingNew",{branch:s.branch}):s.vcsProblem?l("reg.continueHereVcsInactive",{problem:s.vcsProblem}):l("reg.continueHereNoVcs"):l("reg.rerunHereBranch"),p=async e=>{if("unattended"!==e||i||await (0,v.Z)(l("batch.unattendedConfirm",{n:1}))){d(!0),u("");try{h?await r.FH.continueTask(s.sessionId,s.taskId):await r.FH.rerunTask(s.sessionId,s.taskId);let a=await r.FH.suggestedRunName([s.sessionId]).then(e=>e.name).catch(()=>void 0),i=await r.FH.startBatch([s.sessionId],e,"stop",void 0,void 0,a,[s.taskId]);if(!i.started){var n;u(l("batch.notStarted",{reason:null!=(n=i.reason)?n:""}));return}u(l("reg.continueHereStarted",{title:s.title})),t(!0)}catch(e){u(e.message)}finally{d(!1)}}};return(0,n.jsxs)("div",{className:"notice",role:"group","aria-label":l(h?"reg.continueHereTitle":"reg.rerunHereTitle",{title:s.title}),style:{marginTop:8},children:[(0,n.jsx)("strong",{children:l(h?"reg.continueHereTitle":"reg.rerunHereTitle",{title:s.title})}),s.reason&&(0,n.jsx)("p",{className:"small",children:s.reason}),(0,n.jsxs)("ul",{className:"small",children:[(0,n.jsx)("li",{children:l(h?"reg.continueHereChat":"reg.rerunHereChat")}),(0,n.jsx)("li",{children:g}),(0,n.jsx)("li",{children:l(h?"reg.continueHereCount":"reg.rerunHereKept")}),(0,n.jsx)("li",{children:l("reg.continueHereAlone")})]}),(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("button",{className:"primary",disabled:o,onClick:()=>void p("confirm"),title:l("reg.continueWhy"),children:l("reg.continueGo")}),(0,n.jsx)("button",{disabled:o,onClick:()=>void p("unattended"),title:l("reg.continueUnattendedWhy"),children:l("reg.continueUnattended")}),(0,n.jsx)("button",{className:"quiet",disabled:o,onClick:()=>t(!1),children:l("dialog.cancel")}),c&&(0,n.jsx)("span",{className:"small",children:c})]})]})}function U(e){var s;let{entry:t}=e,{t:l}=(0,m.kj)(),i=(0,m.W3)(),r=(0,a.useContext)(F).get("".concat(t.sessionId,":").concat(t.taskId));return r&&0!==r.length?(0,n.jsxs)("span",{className:"muted small",children:[" \xb7 ",l("twin.mark",{when:i(t.createdAt),attempt:null!=(s=t.attempt)?s:1})]}):null}function V(e){let{entries:s,onChange:t}=e,{t:l}=(0,m.kj)(),[i,o]=(0,a.useState)(!1),[d,c]=(0,a.useState)(""),[u,h]=(0,a.useState)(!1),[g,p]=(0,a.useState)(new Set),[x,j]=(0,a.useState)(null),k=s.filter(e=>"queued"===e.status&&!e.sessionInactive),N=s.filter(e=>I.includes(e.status)&&!e.sessionRunning&&!e.sessionInactive),w=s.some(e=>e.sessionRunning),b=N.filter(e=>"stop"===e.sessionOnFailure),y=N.filter(e=>"stop"!==e.sessionOnFailure),S=[...k,...N],F=S.filter(e=>g.has(e.taskId)),A=N.filter(e=>g.has(e.taskId)),H=k.filter(e=>g.has(e.taskId)),R=[...new Set([...F].sort((e,s)=>{var t,n;return(null!=(t=e.sessionRunOrder)?t:Number.MAX_SAFE_INTEGER)-(null!=(n=s.sessionRunOrder)?n:Number.MAX_SAFE_INTEGER)||e.position-s.position}).map(e=>e.sessionId))],T=F.filter(e=>"stop"===e.sessionOnFailure).map(e=>({e,before:S.find(s=>s.sessionId===e.sessionId&&s.position<e.position&&!g.has(s.taskId))})).filter(e=>!!e.before),[P,q]=(0,a.useState)(""),W=b.length>0?l("reg.continueWithFailed",{f:b.length,n:k.length,s:R.length}):l("reg.continue",{n:k.length,s:R.length}),E=(0,f.p)(),G=async e=>{if("unattended"!==e||E||await (0,v.Z)(l("batch.unattendedConfirm",{n:R.length}))){o(!0),c("");try{var s;for(let e of A)C(e)?await r.FH.continueTask(e.sessionId,e.taskId):await r.FH.rerunTask(e.sessionId,e.taskId);let n=await r.FH.startBatch(R,e,"stop",void 0,void 0,P.trim()||void 0,F.map(e=>e.taskId));c(n.started?l("reg.continueStarted",{n:R.length}):l("batch.notStarted",{reason:null!=(s=n.reason)?s:""})),h(!1),t()}catch(e){c(e.message)}finally{o(!1)}}};return 0===k.length&&0===N.length?null:(0,n.jsxs)("div",{style:{marginBottom:8},children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("button",{className:"primary",disabled:i||w,onClick:()=>{p(new Set(S.map(e=>e.taskId))),h(!0),c("");let e=[...new Set([...S].sort((e,s)=>{var t,n;return(null!=(t=e.sessionRunOrder)?t:Number.MAX_SAFE_INTEGER)-(null!=(n=s.sessionRunOrder)?n:Number.MAX_SAFE_INTEGER)||e.position-s.position}).map(e=>e.sessionId))];r.FH.suggestedRunName(e).then(e=>q(e.name)).catch(()=>void 0)},title:l("reg.continueWhy"),children:W}),w&&(0,n.jsx)("span",{className:"muted small",children:l("reg.continueRunning")}),d&&(0,n.jsx)("span",{className:"small",children:d})]}),u&&!w&&(0,n.jsxs)("div",{className:"notice",style:{marginTop:8},children:[(0,n.jsx)("strong",{children:l("reg.continuePanelTitle")}),(0,n.jsxs)("div",{className:"row",style:{marginTop:6},children:[(0,n.jsx)("span",{className:"small",children:l("reg.pickedCount",{n:F.length,of:S.length})}),(0,n.jsx)("button",{className:"small",onClick:()=>p(new Set),disabled:0===F.length,children:l("reg.pickNone")}),(0,n.jsx)("button",{className:"small",onClick:()=>p(new Set(S.map(e=>e.taskId))),disabled:F.length===S.length,children:l("reg.pickAll")})]}),[{key:"chain",entries:b,intro:l("reg.continueChain"),fix:!0},{key:"loose",entries:y,intro:l("reg.continueIndependent"),fix:!0},{key:"queued",entries:k,intro:l("reg.continueQueued"),fix:!1}].filter(e=>e.entries.length>0).map(e=>(0,n.jsxs)("div",{style:{marginTop:6},children:[(0,n.jsx)("div",{className:"small",children:e.intro}),(0,n.jsx)("ul",{className:"small",style:{margin:"4px 0",paddingLeft:18,listStyle:"none"},children:e.entries.map(s=>(0,n.jsxs)("li",{children:[(0,n.jsxs)("label",{className:"option-inline",children:[(0,n.jsx)("input",{type:"checkbox",checked:g.has(s.taskId),onChange:e=>{let t,n;return t=s.taskId,n=e.target.checked,p(e=>{let s=new Set(e);return n?s.add(t):s.delete(t),s})}}),(0,n.jsx)("strong",{children:s.title})," \xb7 ",s.sessionName," \xb7 ",(0,n.jsx)("span",{className:"badge ".concat(s.status),children:l("status.".concat(s.status))}),(0,n.jsx)(U,{entry:s}),C(s)&&(0,n.jsxs)("span",{className:"muted small",children:[" \xb7 ",l("reg.willContinue")]})]})," ",(0,n.jsx)("button",{className:"quiet small",onClick:()=>p(new Set([s.taskId])),title:l("reg.pickOnlyWhy"),children:l("reg.pickOnly")}),e.fix&&(0,n.jsxs)(n.Fragment,{children:[" ",(0,n.jsx)("button",{className:"quiet small",onClick:()=>j(s),title:l("reg.fixPromptHint"),children:l("reg.fixPrompt")})]})]},s.taskId))})]},e.key)),T.length>0&&(0,n.jsx)("div",{className:"notice caution small",style:{marginTop:6},children:T.map(e=>(0,n.jsx)("div",{children:l("reg.continueGap",{task:e.e.title,before:e.before.title,session:e.e.sessionName})},e.e.taskId))}),(0,n.jsxs)("div",{style:{marginTop:8},children:[(0,n.jsx)("label",{htmlFor:"continue-run-name",children:l("batch.runName")}),(0,n.jsx)("input",{id:"continue-run-name",type:"text",value:P,onChange:e=>q(e.target.value),placeholder:l("batch.runNamePlaceholder"),disabled:i}),(0,n.jsx)("p",{className:"why",children:l("reg.continueNameWhy")})]}),(0,n.jsx)("div",{className:"small",style:{marginTop:6},children:l("reg.continueSummary",{q:H.length,r:A.length,s:R.length})}),(0,n.jsxs)("div",{className:"row",style:{marginTop:8},children:[(0,n.jsx)("button",{className:"primary",disabled:i||0===R.length,onClick:()=>void G("unattended"),title:l("reg.continueUnattendedWhy"),children:l("reg.continueUnattended")}),(0,n.jsx)("button",{disabled:i||0===R.length,onClick:()=>void G("confirm"),title:l("reg.continueWhy"),children:l("reg.continueGo")}),(0,n.jsx)("button",{className:"quiet",disabled:i,onClick:()=>h(!1),children:l("dialog.cancel")})]})]}),x&&(0,n.jsx)(_,{entry:x,onClose:e=>{j(null),e&&t()}})]})}function X(e){let{entries:s}=e,{t}=(0,m.kj)(),a=(0,m.W3)();return(0,n.jsx)("div",{className:"panel",children:(0,n.jsxs)("table",{children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:t("reg.col.task")}),(0,n.jsx)("th",{children:t("reg.col.session")}),(0,n.jsx)("th",{children:t("reg.col.status")}),(0,n.jsx)("th",{children:t("reg.col.started")}),(0,n.jsx)("th",{children:t("reg.col.took")}),(0,n.jsx)("th",{children:t("reg.col.result")})]})}),(0,n.jsx)("tbody",{children:s.map(e=>{var s;return(0,n.jsxs)("tr",{children:[(0,n.jsxs)("td",{children:[(0,n.jsx)(i(),{href:(0,r.aT)(e.sessionId,e.taskId),children:e.title}),(0,n.jsx)(U,{entry:e})]}),(0,n.jsx)("td",{children:(0,n.jsx)(i(),{href:(0,r.aT)(e.sessionId),children:e.sessionName})}),(0,n.jsx)("td",{children:(0,n.jsx)("span",{className:"badge ".concat(e.status),children:t("status.".concat(e.status))})}),(0,n.jsx)("td",{className:"muted small",children:e.startedAt?a(e.startedAt):"—"}),(0,n.jsx)("td",{className:"muted small",children:(0,r.c5)(e.durationMs)||"—"}),(0,n.jsx)("td",{className:"small",children:null!=(s=e.summary)?s:e.reason?(0,n.jsx)("span",{className:"err",children:e.reason}):"—"})]},"".concat(e.sessionId,"-").concat(e.taskId))})})]})})}}},e=>{e.O(0,[197,867,549,584,347,131,358],()=>e(e.s=3256)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[177],{952:()=>{},1035:(e,t,n)=>{"use strict";n.d(t,{DialogHost:()=>c,Z:()=>d});var a=n(3365),r=n(1521),l=n(867),o=n(4969);let s=null,i=[];function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(n=>{var a;return a={kind:"confirm",message:e,...t,resolve:n},void(s?s(a):i.push(a))})}function c(e){var t,n;let{children:d}=e,{t:c}=(0,l.kj)(),[u,h]=(0,r.useState)([]),m=(0,r.useRef)(null),p=(0,r.useRef)(null);(0,r.useEffect)(()=>{if(s=e=>h(t=>[...t,e]),i.length>0){let e=i.splice(0,i.length);h(t=>[...t,...e])}return()=>{s=null}},[]);let v=u[0],f=(0,r.useCallback)(e=>{v&&(v.resolve(e),h(e=>e.slice(1)))},[v]);return(0,o.V)(p,!!v,m),(0,r.useEffect)(()=>{if(!v)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),f(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[v,f]),(0,a.jsxs)(a.Fragment,{children:[d,v&&(0,a.jsx)("div",{className:"modal-backdrop",onClick:()=>f(!1),role:"presentation",children:(0,a.jsxs)("div",{ref:p,className:"modal".concat(v.danger?" danger":""),role:"confirm"===v.kind?"alertdialog":"dialog","aria-modal":"true","aria-labelledby":"modal-title","aria-describedby":"modal-body",onClick:e=>e.stopPropagation(),children:[(0,a.jsx)("h2",{id:"modal-title",children:null!=(t=v.title)?t:c("confirm"===v.kind?"dialog.confirmTitle":"dialog.noticeTitle")}),(0,a.jsx)("div",{id:"modal-body",className:"modal-body",children:v.message}),(0,a.jsxs)("div",{className:"row modal-actions",children:["confirm"===v.kind&&(0,a.jsx)("button",{type:"button",className:"quiet",onClick:()=>f(!1),children:c("dialog.cancel")}),(0,a.jsx)("button",{ref:m,type:"button",className:v.danger?"danger":"primary",onClick:()=>f(!0),children:null!=(n=v.okLabel)?n:c("dialog.ok")})]})]})})]})}},1702:(e,t,n)=>{"use strict";var a=n(9962);n.o(a,"usePathname")&&n.d(t,{usePathname:function(){return a.usePathname}}),n.o(a,"useSearchParams")&&n.d(t,{useSearchParams:function(){return a.useSearchParams}})},4969:(e,t,n)=>{"use strict";n.d(t,{V:()=>l});var a=n(1521);let r='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function l(e,t,n){(0,a.useEffect)(()=>{var a,l;if(!t)return;let o=document.activeElement instanceof HTMLElement?document.activeElement:null,s=e.current,i=null!=(l=null!=(a=null==n?void 0:n.current)?a:null==s?void 0:s.querySelector(r))?l:null;null==i||i.focus();let d=e=>{if("Tab"!==e.key||!s)return;let t=Array.from(s.querySelectorAll(r)).filter(e=>null!==e.offsetParent);if(0===t.length)return;let n=t[0],a=t[t.length-1],l=s.contains(document.activeElement);e.shiftKey&&(document.activeElement===n||!l)?(e.preventDefault(),a.focus()):e.shiftKey||document.activeElement!==a&&l||(e.preventDefault(),n.focus())};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d),o&&document.contains(o)&&o.focus()}},[e,t,n])}},5924:(e,t,n)=>{Promise.resolve().then(n.t.bind(n,8197,23)),Promise.resolve().then(n.bind(n,6657)),Promise.resolve().then(n.bind(n,1035)),Promise.resolve().then(n.t.bind(n,952,23)),Promise.resolve().then(n.bind(n,8214)),Promise.resolve().then(n.bind(n,7712)),Promise.resolve().then(n.bind(n,8078)),Promise.resolve().then(n.bind(n,867))},6657:(e,t,n)=>{"use strict";n.d(t,{GlobalApprovals:()=>u});var a=n(3365),r=n(1521),l=n(8197),o=n.n(l),s=n(5549),i=n(867),d=n(1035),c=n(7527);function u(){let{t:e}=(0,i.kj)(),[t,n]=(0,r.useState)([]),[l,o]=(0,r.useState)({}),d=(0,r.useRef)({}),u=(0,r.useRef)(""),m=(0,r.useCallback)(async()=>{try{let e=await s.FH.approvals();n(e);let t=[...new Set(e.map(e=>e.sessionId).filter(e=>!(e in d.current)))],a=t.sort().join(",");if(t.length>0&&a!==u.current){for(let e of(u.current=a,await s.FH.sessions().catch(()=>[])))d.current[e.id]=e.name;o({...d.current})}}catch(e){}},[]);return((0,c.z)(m,2e3),(0,r.useEffect)(()=>{let n="copilot-operator";document.title=t.length>0?"(".concat(t.length,") ").concat(e("approval.tabTitle")," — ").concat(n):n},[t.length,e]),0===t.length)?null:(0,a.jsxs)("section",{className:"approval-banner",role:"alert","aria-live":"assertive",children:[(0,a.jsx)("h2",{children:e("approval.waitingHere")}),(0,a.jsx)("p",{className:"small",children:e("approval.waitingHereWhy")}),t.map(e=>{var t;return(0,a.jsx)(h,{approval:e,sessionName:null!=(t=l[e.sessionId])?t:e.sessionId,onDecided:()=>void m()},e.id)})]})}function h(e){let{approval:t,sessionName:n,onDecided:l}=e,{t:c}=(0,i.kj)(),u=(0,i.W3)(),[h,m]=(0,r.useState)(!1),[p,v]=(0,r.useState)(""),f=(0,r.useRef)(!1),k=async e=>{if(!f.current&&("run-all"!==e||await (0,d.Z)(c("approval.runAllConfirm")))){f.current=!0,m(!0),v("");try{await s.FH.decide(t.id,e)}catch(e){v(e.message)}finally{f.current=!1,m(!1),l()}}};if(t.model){var b;let e=t.model;return(0,a.jsxs)("div",{className:"approval",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("strong",{children:c(e.manual?"approval.manualTitle":"approval.modelTitle")}),(0,a.jsx)(o(),{href:(0,s.aT)(t.sessionId),children:n}),(0,a.jsx)("span",{className:"muted small",children:u(t.createdAt)})]}),(0,a.jsx)("p",{children:e.manual?e.asked?c("approval.manualAsk",{model:e.asked}):c("approval.manualAskAny"):c("approval.modelAsk",{model:e.asked})}),(0,a.jsx)("p",{className:"muted small",children:c("approval.modelShown",{shown:null!=(b=e.shown)?b:"—"})}),!e.manual&&(0,a.jsx)("p",{className:"reason small",children:c("approval.modelWhy",{why:e.why,tries:e.tries})}),p&&(0,a.jsx)("p",{className:"err",role:"alert",children:p}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("button",{className:"primary",disabled:h,onClick:()=>void k("run"),children:c(e.manual?"approval.manualReady":"approval.modelChosen")}),(0,a.jsx)("button",{disabled:h,onClick:()=>void k("skip"),children:c("approval.modelAsItIs")}),(0,a.jsx)("button",{className:"danger",disabled:h,onClick:()=>void k("abort"),children:c("approval.modelStop")})]})]})}return(0,a.jsxs)("div",{className:"approval",children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("strong",{children:c("approval.title",{n:t.stepId})}),(0,a.jsx)(o(),{href:(0,s.aT)(t.sessionId),children:n}),(0,a.jsx)("span",{className:"muted small",children:u(t.createdAt)})]}),(0,a.jsx)("pre",{style:{margin:"8px 0"},children:t.description}),t.network&&(0,a.jsx)("p",{className:"reason small",children:c("approval.network")}),p&&(0,a.jsx)("p",{className:"err",role:"alert",children:p}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("button",{className:"primary",disabled:h,onClick:()=>void k("run"),children:c("approval.run")}),!t.network&&(0,a.jsx)("button",{disabled:h,onClick:()=>void k("run-all"),title:c("approval.runAllWhy"),children:c("approval.runAll")}),(0,a.jsx)("button",{disabled:h,onClick:()=>void k("skip"),children:c("approval.skip")}),(0,a.jsx)("button",{className:"danger",disabled:h,onClick:()=>void k("abort"),children:c("approval.abort")})]})]})}},7527:(e,t,n)=>{"use strict";n.d(t,{z:()=>r});var a=n(1521);function r(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],r=(0,a.useRef)(e);r.current=e,(0,a.useEffect)(()=>{let e;if(!n)return;let a=!1,l=async()=>{try{await r.current()}catch(e){}finally{a||(e=setTimeout(()=>void l(),t))}};return l(),()=>{a=!0,e&&clearTimeout(e)}},[t,n])}},7712:(e,t,n)=>{"use strict";n.d(t,{ScrollJump:()=>o});var a=n(3365),r=n(1521),l=n(867);function o(){let{t:e}=(0,l.kj)(),[t,n]=(0,r.useState)({long:!1,atTop:!0,atBottom:!1});return((0,r.useEffect)(()=>{let e=()=>{let e=document.documentElement;n({long:e.scrollHeight>2*window.innerHeight,atTop:window.scrollY<200,atBottom:window.innerHeight+window.scrollY>=e.scrollHeight-200})};e(),window.addEventListener("scroll",e,{passive:!0}),window.addEventListener("resize",e);let t=new ResizeObserver(e);return t.observe(document.body),()=>{window.removeEventListener("scroll",e),window.removeEventListener("resize",e),t.disconnect()}},[]),t.long)?(0,a.jsxs)("div",{className:"scroll-jump",children:[!t.atTop&&(0,a.jsx)("button",{type:"button","aria-label":e("scroll.top"),title:e("scroll.top"),onClick:()=>window.scrollTo({top:0,behavior:"smooth"}),children:"↑"}),!t.atBottom&&(0,a.jsx)("button",{type:"button","aria-label":e("scroll.bottom"),title:e("scroll.bottom"),onClick:()=>window.scrollTo({top:document.documentElement.scrollHeight,behavior:"smooth"}),children:"↓"})]}):null}},8078:(e,t,n)=>{"use strict";n.d(t,{AppearanceProvider:()=>c,KP:()=>u});var a=n(3365),r=n(1521);let l="cop.appearance",o=["small","normal","large","huge","giant"];"\n(function () {\n try {\n var d = document.documentElement;\n var raw = localStorage.getItem('".concat(l,"');\n var a = raw ? JSON.parse(raw) : {};\n if (!a || typeof a !== 'object') a = {};\n d.dataset.theme = a.theme === 'dark' ? 'dark' : 'light';\n d.dataset.textsize = ").concat(JSON.stringify(o),".indexOf(a.textSize) >= 0 ? a.textSize : 'normal';\n d.dataset.contrast = a.highContrast ? 'high' : 'normal';\n d.dataset.motion = a.reduceMotion ? 'reduced' : 'normal';\n d.dataset.links = a.underlineLinks ? 'underline' : 'plain';\n d.dataset.focus = a.strongFocus ? 'strong' : 'normal';\n } catch (e) {}\n})();\n");let s={theme:"light",textSize:"normal",highContrast:!1,reduceMotion:!1,underlineLinks:!1,strongFocus:!1};function i(e){let t=document.documentElement;t.dataset.theme=e.theme,t.dataset.textsize=e.textSize,t.dataset.contrast=e.highContrast?"high":"normal",t.dataset.motion=e.reduceMotion?"reduced":"normal",t.dataset.links=e.underlineLinks?"underline":"plain",t.dataset.focus=e.strongFocus?"strong":"normal"}let d=(0,r.createContext)({appearance:s,set:()=>void 0,reset:()=>void 0,loaded:!1});function c(e){let{children:t}=e,[n,c]=(0,r.useState)(s),[u,h]=(0,r.useState)(!1);(0,r.useEffect)(()=>{let e=s;try{let t=window.localStorage.getItem(l);t?e=function(e){let t=e&&"object"==typeof e?e:{},n=(e,t)=>"boolean"==typeof e?e:t;return{theme:"dark"===t.theme?"dark":"light"===t.theme?"light":s.theme,textSize:o.includes(t.textSize)?t.textSize:s.textSize,highContrast:n(t.highContrast,s.highContrast),reduceMotion:n(t.reduceMotion,s.reduceMotion),underlineLinks:n(t.underlineLinks,s.underlineLinks),strongFocus:n(t.strongFocus,s.strongFocus)}}(JSON.parse(t)):window.matchMedia("(prefers-color-scheme: dark)").matches&&(e={...e,theme:"dark"}),window.matchMedia("(prefers-reduced-motion: reduce)").matches&&!t&&(e={...e,reduceMotion:!0})}catch(e){}c(e),i(e),h(!0)},[]);let m=(0,r.useCallback)(e=>{c(t=>{let n={...t,...e};i(n);try{window.localStorage.setItem(l,JSON.stringify(n))}catch(e){}return n})},[]),p=(0,r.useCallback)(()=>{c(s),i(s);try{window.localStorage.removeItem(l)}catch(e){}},[]);return(0,a.jsx)(d.Provider,{value:{appearance:n,set:m,reset:p,loaded:u},children:t})}function u(){return(0,r.useContext)(d)}},8214:(e,t,n)=>{"use strict";n.d(t,{Nav:()=>p,SkipLink:()=>m});var a=n(3365),r=n(1521),l=n(8197),o=n.n(l),s=n(1702),i=n(5549),d=n(7527),c=n(867);let u={sessions:(0,a.jsx)("path",{d:"M4 5h16v4H4zM4 11h16v4H4zM4 17h10v2H4z"}),defaults:(0,a.jsx)("path",{d:"M12 8a4 4 0 1 0 0 8 4 4 0 0 0 0-8zm8.5 4 1.5 1-1.6 2.8-1.8-.4a7 7 0 0 1-1.5 1.5l.4 1.8L14.7 21l-1-1.5a7 7 0 0 1-3.4 0l-1 1.5-2.8-1.6.4-1.8A7 7 0 0 1 5.4 16l-1.8.4L2 13.6 3.5 12.6V11.4L2 10.4l1.6-2.8 1.8.4A7 7 0 0 1 6.9 6.5l-.4-1.8L9.3 3l1 1.5a7 7 0 0 1 3.4 0l1-1.5 2.8 1.6-.4 1.8a7 7 0 0 1 1.5 1.5l1.8-.4L22 10.4l-1.5 1z"}),import:(0,a.jsx)("path",{d:"M12 3v10m0 0 4-4m-4 4-4-4M4 15v4a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-4",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),history:(0,a.jsx)("path",{d:"M12 3a9 9 0 1 0 8.5 6M12 7v5l3 2M3 4v5h5",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),level1:(0,a.jsx)("path",{d:"M6 3h9l5 5v13H6zM14 3v6h6M9 13h7M9 17h7",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),presets:(0,a.jsx)("path",{d:"M5 4h14v4H5zM5 10h14v4H5zM5 16h9v4H5z",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),appearance:(0,a.jsx)("path",{d:"M12 3a9 9 0 0 0 0 18c1.5 0 2-1 2-2s-1-1.5-1-2.5S14 15 15.5 15H17a4 4 0 0 0 4-4 8 8 0 0 0-9-8zM8 9a1 1 0 1 0 0 2 1 1 0 0 0 0-2zm4-3a1 1 0 1 0 0 2 1 1 0 0 0 0-2zm4 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"}),system:(0,a.jsx)("path",{d:"M4 5h16v10H4zM2 19h20M9 15v4M15 15v4",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"})},h=[{href:"/",label:"nav.sessions",icon:"sessions"},{href:"/defaults",label:"nav.defaults",icon:"defaults"},{href:"/import",label:"nav.import",icon:"import"},{href:"/history",label:"nav.history",icon:"history"},{href:"/level1",label:"nav.level1",icon:"level1"},{href:"/presets",label:"nav.presets",icon:"presets"},{href:"/appearance",label:"nav.appearance",icon:"appearance"},{href:"/system",label:"nav.system",icon:"system"}];function m(){let{t:e}=(0,c.kj)();return(0,a.jsx)("a",{className:"skip-link",href:"#main",children:e("a11y.skip")})}function p(){let{t:e}=(0,c.kj)(),t=(0,s.usePathname)(),n=function(){let[e,t]=(0,r.useState)(0);return(0,d.z)(()=>i.FH.activity().then(e=>t(e.sessions)).catch(()=>void 0),4e3),e}();return(0,a.jsxs)("nav",{"aria-label":e("nav.label"),children:[h.map(r=>(0,a.jsxs)(o(),{href:r.href,"aria-current":t===r.href?"page":void 0,children:[(0,a.jsx)("svg",{className:"nav-icon",viewBox:"0 0 24 24",width:"16",height:"16",fill:"currentColor","aria-hidden":"true",children:u[r.icon]}),(0,a.jsx)("span",{children:e(r.label)}),"/history"===r.href&&n>0&&(0,a.jsxs)("span",{className:"live",title:e("nav.liveTitle",{n:n}),children:[(0,a.jsx)("span",{className:"dot","aria-hidden":"true"}),e("nav.live")]})]},r.href)),(0,a.jsx)(c.c5,{})]})}}},e=>{e.O(0,[353,197,867,549,347,131,358],()=>e(e.s=5924)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{1035:(e,n,t)=>{"use strict";t.d(n,{DialogHost:()=>o,Z:()=>d});var l=t(3365),a=t(1521),s=t(867),i=t(4969);let r=null,c=[];function d(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(t=>{var l;return l={kind:"confirm",message:e,...n,resolve:t},void(r?r(l):c.push(l))})}function o(e){var n,t;let{children:d}=e,{t:o}=(0,s.kj)(),[h,u]=(0,a.useState)([]),m=(0,a.useRef)(null),p=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(r=e=>u(n=>[...n,e]),c.length>0){let e=c.splice(0,c.length);u(n=>[...n,...e])}return()=>{r=null}},[]);let x=h[0],j=(0,a.useCallback)(e=>{x&&(x.resolve(e),u(e=>e.slice(1)))},[x]);return(0,i.V)(p,!!x,m),(0,a.useEffect)(()=>{if(!x)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),j(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[x,j]),(0,l.jsxs)(l.Fragment,{children:[d,x&&(0,l.jsx)("div",{className:"modal-backdrop",onClick:()=>j(!1),role:"presentation",children:(0,l.jsxs)("div",{ref:p,className:"modal".concat(x.danger?" danger":""),role:"confirm"===x.kind?"alertdialog":"dialog","aria-modal":"true","aria-labelledby":"modal-title","aria-describedby":"modal-body",onClick:e=>e.stopPropagation(),children:[(0,l.jsx)("h2",{id:"modal-title",children:null!=(n=x.title)?n:o("confirm"===x.kind?"dialog.confirmTitle":"dialog.noticeTitle")}),(0,l.jsx)("div",{id:"modal-body",className:"modal-body",children:x.message}),(0,l.jsxs)("div",{className:"row modal-actions",children:["confirm"===x.kind&&(0,l.jsx)("button",{type:"button",className:"quiet",onClick:()=>j(!1),children:o("dialog.cancel")}),(0,l.jsx)("button",{ref:m,type:"button",className:x.danger?"danger":"primary",onClick:()=>j(!0),children:null!=(t=x.okLabel)?t:o("dialog.ok")})]})]})})]})}},4811:(e,n,t)=>{"use strict";t.d(n,{p:()=>s});var l=t(1521),a=t(5549);function s(){let[e,n]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{let e=!0;return a.FH.settings().then(t=>{var l;let a=null!=(l=t.raw.execution)?l:{};e&&n("unattended"===a.mode)}).catch(()=>void 0),()=>{e=!1}},[]),e}},4969:(e,n,t)=>{"use strict";t.d(n,{V:()=>s});var l=t(1521);let a='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function s(e,n,t){(0,l.useEffect)(()=>{var l,s;if(!n)return;let i=document.activeElement instanceof HTMLElement?document.activeElement:null,r=e.current,c=null!=(s=null!=(l=null==t?void 0:t.current)?l:null==r?void 0:r.querySelector(a))?s:null;null==c||c.focus();let d=e=>{if("Tab"!==e.key||!r)return;let n=Array.from(r.querySelectorAll(a)).filter(e=>null!==e.offsetParent);if(0===n.length)return;let t=n[0],l=n[n.length-1],s=r.contains(document.activeElement);e.shiftKey&&(document.activeElement===t||!s)?(e.preventDefault(),l.focus()):e.shiftKey||document.activeElement!==l&&s||(e.preventDefault(),t.focus())};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d),i&&document.contains(i)&&i.focus()}},[e,n,t])}},5704:(e,n,t)=>{Promise.resolve().then(t.bind(t,6474))},6474:(e,n,t)=>{"use strict";t.r(n),t.d(n,{default:()=>j});var l=t(3365),a=t(1521),s=t(8197),i=t.n(s),r=t(5549),c=t(7527),d=t(867),o=t(1035),h=t(4811),u=t(8848);let m={"review-inputs":"runvcs.review","snapshot-on-base":"runvcs.snapshotOnBase","snapshot-here":"runvcs.snapshotHere","use-current-branch":"runvcs.useCurrent","allow-snapshot":"runvcs.allowSnapshot"};function p(e){let{groups:n,sessionIds:t,onChange:s}=e,{t:i}=(0,d.kj)(),[r,c]=(0,a.useState)(""),o=n.filter(e=>!e.ready);return 0===o.length?r?(0,l.jsxs)("p",{className:"notice small",role:"status",children:[(0,l.jsx)("strong",{children:i("runvcs.ready")})," ",r]}):null:(0,l.jsxs)("section",{className:"notice caution","aria-labelledby":"runvcs-title",children:[(0,l.jsx)("h3",{id:"runvcs-title",style:{marginTop:0},children:i("runvcs.title")}),(0,l.jsx)("p",{className:"small",children:i("runvcs.why")}),o.map(e=>(0,l.jsx)(x,{group:e,sessionIds:t,onChange:s,onDone:c},e.repoDir))]})}function x(e){var n;let{group:t,sessionIds:s,onChange:i,onDone:c}=e,{t:o}=(0,d.kj)(),[h,u]=(0,a.useState)(!1),[p,x]=(0,a.useState)(!1),[j,g]=(0,a.useState)(!1),[v,b]=(0,a.useState)(""),[f,y]=(0,a.useState)({}),N=(e,n)=>{var t,l;return null!=(l=null!=(t=f[e])?t:n)?l:void 0},w=t.actions.find(e=>"snapshot-here"===e.id&&e.available),k=e=>(null!=e?e:"—").slice(0,8),S=async e=>{if("review-inputs"===e)return void u(e=>!e);g(!0),b("");try{var n,l,a;let d="snapshot-on-base"===e?Object.fromEntries(t.inputs.map(e=>[e.path,"include"])):Object.fromEntries(t.entries.filter(e=>N(e.path,e.choice)).map(e=>[e.path,N(e.path,e.choice)])),o=await r.FH.runVcsPrepare(s,t.repoDir,e,d);b(o.ok?null!=(n=o.result)?n:"":null!=(l=o.problem)?l:""),o.ok&&c("".concat(t.repoDir,": ").concat(null!=(a=o.result)?a:"")),i()}catch(e){b(e.message)}finally{g(!1)}};return(0,l.jsxs)("div",{className:"option",style:{overflowWrap:"anywhere"},children:[(0,l.jsx)("table",{className:"small",children:(0,l.jsxs)("tbody",{children:[(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:o("runvcs.repo")}),(0,l.jsx)("td",{children:(0,l.jsx)("code",{children:t.repoDir})})]}),(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:o("runvcs.current")}),(0,l.jsxs)("td",{children:[(0,l.jsx)("code",{children:null!=(n=t.branch)?n:"HEAD"})," @ ",(0,l.jsx)("code",{children:k(t.head)})]})]}),t.workBranch&&(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:o("runvcs.workBranch")}),(0,l.jsxs)("td",{children:[(0,l.jsx)("code",{children:t.workBranch.name})," @ ",(0,l.jsx)("code",{children:k(t.workBranch.head)})]})]}),t.baseBranch&&(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:o("runvcs.base")}),(0,l.jsxs)("td",{children:[(0,l.jsx)("code",{children:t.baseBranch})," @ ",(0,l.jsx)("code",{children:k(t.baseHead)})]})]}),(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:o("runvcs.sessions")}),(0,l.jsx)("td",{children:t.sessions.map(e=>"".concat(e.name," (").concat(o("runvcs.role.".concat(e.role)),")")).join(", ")})]}),t.inputPatterns.length>0&&(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:o("runvcs.patterns")}),(0,l.jsx)("td",{children:t.inputPatterns.map(e=>(0,l.jsx)("code",{style:{marginRight:6},children:e},e))})]})]})}),t.problem&&(0,l.jsxs)("p",{className:"small",children:[(0,l.jsx)("strong",{children:o("runvcs.problem")})," ",t.problem]}),t.inputs.length>0&&(0,l.jsx)("p",{className:"small",children:o("runvcs.inputsCount",{n:t.inputs.length})}),h&&t.inputs.length>0&&(0,l.jsx)("ul",{className:"small",style:{margin:"4px 0"},children:t.inputs.map(e=>(0,l.jsxs)("li",{children:[(0,l.jsx)("code",{children:e.path})," — ",o("vcs.snapshotKind.".concat(e.kind)),void 0!==e.size?", ".concat((0,r.zi)(e.size)):"",0===e.allowed.length&&e.reason?(0,l.jsxs)("span",{className:"err",children:[" — ",e.reason]}):null]},e.path))}),t.unrelated.length>0&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"small",children:(0,l.jsx)("strong",{children:o("runvcs.unrelated",{n:t.unrelated.length})})}),(0,l.jsx)("ul",{className:"small",style:{margin:"4px 0"},children:t.unrelated.slice(0,30).map(e=>(0,l.jsxs)("li",{children:[(0,l.jsx)("code",{children:e.path}),e.reason?" — ".concat(e.reason):""]},e.path))})]}),w&&t.entries.length>0&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"small",children:(0,l.jsx)("strong",{children:o("runvcs.choose",{n:t.entries.length})})}),(0,l.jsx)("ul",{className:"small",style:{margin:"4px 0",paddingLeft:0,listStyle:"none"},children:t.entries.map(e=>{var n;return(0,l.jsxs)("li",{style:{marginBottom:4},children:[(0,l.jsx)("code",{children:e.path})," ",(0,l.jsxs)("span",{className:"muted",children:["(",e.input?"".concat(o("vcs.snapshotInput"),", "):"",o("vcs.snapshotKind.".concat(e.kind)),void 0!==e.size?", ".concat((0,r.zi)(e.size)):"",")"]})," ",0===e.allowed.length?(0,l.jsx)("span",{className:"err",children:o("vcs.snapshotBlocked")}):(0,l.jsx)("select",{"aria-label":e.path,value:null!=(n=N(e.path,e.choice))?n:"",onChange:n=>y({...f,[e.path]:n.target.value}),disabled:j||e.allowed.length<2,children:e.allowed.map(e=>(0,l.jsx)("option",{value:e,children:o("include"===e?"vcs.snapshotInclude":"vcs.snapshotLeaveOut")},e))}),e.reason&&(0,l.jsx)("div",{className:"muted",children:e.reason})]},e.path)})})]}),p?(0,l.jsxs)("p",{className:"small muted",children:[o("runvcs.cancelled")," ",(0,l.jsx)("button",{className:"quiet",onClick:()=>x(!1),children:o("runvcs.showAgain")})]}):(0,l.jsxs)("div",{children:[t.actions.map(e=>{var n,a,s;return(0,l.jsxs)("div",{style:{marginTop:8},children:[(0,l.jsxs)("button",{className:e.recommended?"primary":void 0,onClick:()=>void S(e.id),disabled:j||!e.available,children:[o(m[e.id],{branch:null!=(n=t.baseBranch)?n:"",current:null!=(a=t.branch)?a:"HEAD"}),"review-inputs"===e.id&&h?" ✓":""]}),e.recommended&&(0,l.jsx)("span",{className:"badge done",style:{marginLeft:6},children:o("runvcs.recommended")}),(0,l.jsx)("p",{className:"why",children:e.available?e.result:"".concat(o("runvcs.notNow")," ").concat(null!=(s=e.why)?s:"")})]},e.id)}),(0,l.jsxs)("div",{style:{marginTop:8},children:[(0,l.jsx)("button",{className:"quiet",onClick:()=>x(!0),disabled:j,children:o("runvcs.cancel")}),(0,l.jsx)("p",{className:"why",children:o("runvcs.cancelWhy")})]})]}),v&&(0,l.jsx)("p",{className:"small",role:"status",children:v})]})}function j(){let{t:e}=(0,d.kj)(),n=(0,d.W3)(),[t,s]=(0,a.useState)(null),[h,u]=(0,a.useState)(null),[m,p]=(0,a.useState)([]),[x,j]=(0,a.useState)([]),[v,b]=(0,a.useState)([]),[f,y]=(0,a.useState)("stop"),[N,w]=(0,a.useState)(!1),[k,S]=(0,a.useState)(""),[C,F]=(0,a.useState)(""),[E,D]=(0,a.useState)(""),[H,T]=(0,a.useState)(null),[I,W]=(0,a.useState)(!1),B=(0,a.useCallback)(async()=>{try{let[e,n,t]=await Promise.all([r.FH.sessions(),r.FH.batch().catch(()=>null),r.FH.approvals().catch(()=>[])]);s(e),u(n),p(t),j(n=>n.filter(n=>e.some(e=>e.id===n))),T(!0),W(!1),D("")}catch(e){W(!(0,r.AV)()),T(!1),D(e.message)}},[]);(0,c.z)(B,3e3),(0,a.useEffect)(()=>{var e;let n=new URLSearchParams(window.location.search),t=(null!=(e=n.get("run"))?e:"").split(",").map(e=>e.trim()).filter(Boolean);0!==t.length&&(j(t),y("continue"===n.get("fail")?"continue":"stop"),w(!0),window.history.replaceState(null,"",window.location.pathname))},[]);let[R,O]=(0,a.useState)(!1),L=(0,a.useRef)(!1),U=async()=>{if(!L.current){L.current=!0,O(!0);try{let e=await r.FH.createSession(k||"session");S(""),window.location.href=(0,r.aT)(e.id)}catch(e){D(e.message),L.current=!1,O(!1)}}},q=async n=>{if(n.running)return void F(e("home.deleteRunning"));if(await (0,o.Z)(e("home.deleteConfirm",{name:n.name,n:n.tasks.length})))try{await r.FH.deleteSession(n.id),F(e("home.deleted",{name:n.name})),j(e=>e.filter(e=>e!==n.id)),await B()}catch(e){F(e.message)}},A=async()=>{let n=(null!=t?t:[]).filter(e=>v.includes(e.id)&&!e.running);if(0===n.length)return;let l=n.map(e=>"• ".concat(e.name," (").concat(e.tasks.length,")")).join("\n");if(!await (0,o.Z)(e("home.deleteSelectedConfirm",{n:n.length,names:l})))return;let a=0,s=[];for(let e of n)try{await r.FH.deleteSession(e.id),a+=1}catch(n){s.push("".concat(e.name,": ").concat(n.message))}F(0===s.length?e("home.deletedMany",{n:a}):e("home.deleteSomeFailed",{n:a,m:s.length,why:s.join("; ")})),j(e=>e.filter(e=>!n.some(n=>n.id===e))),b([]),await B()},P=async n=>{let l=(null!=t?t:[]).filter(e=>v.includes(e.id)&&!e.running);if(0===l.length)return;let a=[];for(let e of l)try{await r.FH.updateSession(e.id,{active:n})}catch(n){a.push("".concat(e.name,": ").concat(n.message))}F(0===a.length?e(n?"home.madeActive":"home.madeInactive",{n:l.length}):e("home.statusSomeFailed",{n:l.length-a.length,m:a.length,why:a.join("; ")})),n||j(e=>e.filter(e=>!l.some(n=>n.id===e))),b([]),await B()},M=n=>{if(n.running)return{label:e("state.running"),badge:"running"};let t=n.tasks.some(e=>"queued"===e.status||"running"===e.status);if("idle"!==n.status||t||0===n.tasks.length)return{label:e("state.".concat(n.status)),badge:""};let l=n.tasks.filter(e=>"done"!==e.status).length;return 0===l?{label:e("state.completed"),badge:"done",title:e("state.completedTitle")}:{label:e("state.ended"),badge:"failed",title:e("state.endedTitle",{n:l})}},z=async e=>{if(!t)return;let n=new Map(t.map(e=>[e.id,e]));s(e.map(e=>n.get(e)).filter(e=>!!e));try{s(await r.FH.reorderSessions(e)),D("")}catch(e){D(e.message),B()}},K=(e,n)=>{let l=(null!=t?t:[]).map(e=>e.id),a=l.indexOf(e),s=a+n;a<0||s<0||s>=l.length||([l[a],l[s]]=[l[s],l[a]],z(l))},[_,V]=(0,a.useState)(null),[Z,Q]=(0,a.useState)(null),G=(null!=t?t:[]).filter(e=>!e.running),J=G.filter(e=>v.includes(e.id));return(0,l.jsxs)(l.Fragment,{children:[I&&(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsx)("strong",{children:e("home.noToken")}),(0,l.jsx)("div",{className:"muted small",children:e("home.noTokenHint",{cmd:"npm start"})})]}),!1===H&&!I&&(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsx)("strong",{children:e("home.apiDown")}),(0,l.jsx)("div",{className:"muted small",children:e("home.apiHint",{cmd:"npm start",url:"/api"})}),E&&(0,l.jsx)("div",{className:"err",children:E})]}),(0,l.jsxs)("div",{className:"panel",id:"new-session",children:[(0,l.jsx)("h2",{children:e("home.new")}),(0,l.jsx)("p",{className:"muted small",children:e("home.newHint")}),(0,l.jsxs)("div",{className:"row",children:[(0,l.jsx)("input",{type:"text",className:"grow","aria-label":e("home.col.name"),placeholder:e("home.namePlaceholder"),value:k,onChange:e=>S(e.target.value),onKeyDown:e=>{"Enter"===e.key&&U()}}),(0,l.jsx)("button",{className:"primary",onClick:()=>void U(),disabled:R||!1===H,children:e("home.create")})]})]}),t&&t.length>0&&(0,l.jsx)(g,{sessions:t,selected:x,setSelected:j,onFailure:f,setOnFailure:y,fromPlan:N,batch:h,approvals:m,onChange:B,move:(e,n)=>{j(t=>{let l=t.indexOf(e),a=l+n;if(l<0||a<0||a>=t.length)return t;let s=[...t];return[s[l],s[a]]=[s[a],s[l]],s})}}),(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsx)("h2",{children:e("home.sessions")}),null===t&&(0,l.jsx)("div",{className:"muted",children:e("home.loading")}),t&&0===t.length&&(0,l.jsx)("div",{className:"muted",children:e("home.none")}),t&&t.length>0&&(0,l.jsxs)("div",{className:"row",style:{marginBottom:10},children:[(0,l.jsx)("strong",{className:"small",children:e("home.managed",{n:J.length})}),(0,l.jsx)("button",{onClick:()=>void P(!0),disabled:0===J.length,children:e("home.makeActive")}),(0,l.jsx)("button",{onClick:()=>void P(!1),disabled:0===J.length,children:e("home.makeInactive")}),(0,l.jsx)("button",{className:"danger",onClick:()=>void A(),disabled:0===J.length,children:e("home.deleteSelected",{n:J.length})}),(0,l.jsx)("span",{className:"muted small",children:e("home.tickForBoth")})]}),t&&t.length>0&&(0,l.jsx)("p",{className:"muted small",children:e("home.deleteWhy")}),t&&t.length>1&&(0,l.jsx)("p",{className:"muted small",children:e("home.orderWhy")}),C&&(0,l.jsx)("div",{className:"muted small",role:"status",children:C}),t&&t.length>0&&(0,l.jsxs)("table",{children:[(0,l.jsx)("thead",{children:(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:(0,l.jsx)("input",{type:"checkbox","aria-label":e("home.manageAll"),title:e("home.manageAll"),checked:G.length>0&&G.every(e=>v.includes(e.id)),onChange:e=>b(e.target.checked?G.map(e=>e.id):[]),disabled:0===G.length})}),(0,l.jsx)("th",{children:(0,l.jsx)("input",{type:"checkbox","aria-label":e("home.selectAll"),checked:t.length>0&&x.length===t.filter(e=>!1!==e.active).length,onChange:e=>j(e.target.checked?t.filter(e=>!1!==e.active).map(e=>e.id):[]),disabled:(null==h?void 0:h.running)===!0})}),(0,l.jsx)("th",{children:e("home.col.order")}),(0,l.jsx)("th",{children:e("home.col.name")}),(0,l.jsx)("th",{children:e("home.col.tasks")}),(0,l.jsx)("th",{children:e("home.col.state")}),(0,l.jsx)("th",{children:e("home.col.chat")}),(0,l.jsx)("th",{children:e("home.col.created")}),(0,l.jsx)("th",{children:(0,l.jsx)("span",{className:"visually-hidden",children:e("home.col.remove")})})]})}),(0,l.jsx)("tbody",{children:t.map((a,s)=>{let c=a.tasks.filter(e=>"done"===e.status).length,d=a.tasks.filter(e=>"queued"===e.status).length,o=[!1===a.active?"inactive":"",_===a.id?"dragging":"",Z===a.id&&_!==a.id?"drop-target":""].filter(Boolean).join(" ");return(0,l.jsxs)("tr",{className:o||void 0,draggable:!0,onDragStart:e=>{e.dataTransfer.setData("text/plain",a.id),e.dataTransfer.effectAllowed="move",V(a.id)},onDragOver:e=>{_&&(e.preventDefault(),e.dataTransfer.dropEffect="move",Z!==a.id&&Q(a.id))},onDrop:e=>{e.preventDefault();let n=e.dataTransfer.getData("text/plain")||_;V(null),Q(null),n&&((e,n)=>{let l=(null!=t?t:[]).map(e=>e.id),a=l.indexOf(e),s=l.indexOf(n);a<0||s<0||a===s||(l.splice(a,1),l.splice(s,0,e),z(l))})(n,a.id)},onDragEnd:()=>{V(null),Q(null)},children:[(0,l.jsx)("td",{children:(0,l.jsx)("input",{type:"checkbox",checked:v.includes(a.id),onChange:()=>b(e=>e.includes(a.id)?e.filter(e=>e!==a.id):[...e,a.id]),disabled:!!a.running,"aria-label":e("home.manageRow",{name:a.name}),title:a.running?e("home.manageRunning"):e("home.manageRow",{name:a.name})})}),(0,l.jsx)("td",{children:(0,l.jsx)("input",{type:"checkbox",checked:x.includes(a.id),onChange:()=>{var e;return e=a.id,void j(n=>{if(n.includes(e))return n.filter(n=>n!==e);let l=(null!=t?t:[]).map(e=>e.id);return[...n,e].sort((e,n)=>l.indexOf(e)-l.indexOf(n))})},disabled:(null==h?void 0:h.running)===!0||!1===a.active,"aria-label":a.name,title:!1===a.active?e("home.inactiveWhy"):void 0})}),(0,l.jsxs)("td",{className:"order-cell",children:[(0,l.jsx)("span",{className:"drag-handle","aria-hidden":"true",title:e("home.dragHint"),children:"⠿"}),(0,l.jsx)("button",{className:"quiet small",onClick:()=>K(a.id,-1),disabled:0===s,"aria-label":e("home.moveUp",{name:a.name}),title:e("home.moveUp",{name:a.name}),children:"↑"}),(0,l.jsx)("button",{className:"quiet small",onClick:()=>K(a.id,1),disabled:s===t.length-1,"aria-label":e("home.moveDown",{name:a.name}),title:e("home.moveDown",{name:a.name}),children:"↓"})]}),(0,l.jsx)("td",{children:(0,l.jsx)(i(),{href:(0,r.aT)(a.id),children:a.name})}),(0,l.jsxs)("td",{children:[a.tasks.length," ",(0,l.jsx)("span",{className:"muted small",children:e("home.tasksDetail",{done:c,queued:d})})]}),(0,l.jsxs)("td",{children:[(0,l.jsx)("span",{className:"badge ".concat(M(a).badge),title:M(a).title,children:M(a).label})," ",(0,l.jsx)("span",{className:"chip".concat(!1===a.active?" inactive":""),title:e(!1===a.active?"home.inactiveWhy":"home.activeWhy"),children:e(!1===a.active?"home.statusInactive":"home.statusActive")})]}),(0,l.jsx)("td",{children:a.chat?(0,l.jsx)("a",{href:a.chat.url,target:"_blank",rel:"noreferrer",children:a.chat.name}):(0,l.jsx)("span",{className:"muted",children:e("home.notOpened")})}),(0,l.jsx)("td",{className:"muted small",children:n(a.createdAt)}),(0,l.jsx)("td",{children:(0,l.jsx)("button",{className:"quiet",onClick:()=>void q(a),disabled:!!a.running,title:e("home.delete"),children:e("home.delete")})})]},a.id)})})]})]})]})}function g(e){var n,t,s,c,m,x,j;let{sessions:g,selected:v,setSelected:b,onFailure:f,setOnFailure:y,fromPlan:N,batch:w,approvals:k,onChange:S,move:C}=e,{t:F}=(0,d.kj)(),[E,D]=(0,a.useState)(""),[H,T]=(0,a.useState)(""),[I,W]=(0,a.useState)(""),[B,R]=(0,a.useState)(""),[O,L]=(0,a.useState)(""),[U,q]=(0,a.useState)(null),[A,P]=(0,a.useState)([]),[M,z]=(0,a.useState)(0);(0,a.useEffect)(()=>{r.FH.models().then(e=>{q(e),W(n=>n||e.defaultModel),R(n=>n||e.defaultReviewModel)}).catch(()=>void 0)},[]);let K=v.join(",");(0,a.useEffect)(()=>{let e=!1,n=K.split(",").filter(Boolean);if(0===n.length)return void P([]);let t=async()=>{let t=await r.FH.runVcs(n).catch(()=>[]);e||P(t)};t();let l=setInterval(()=>void t(),1e4);return()=>{e=!0,clearInterval(l)}},[K,M]);let _=new Map(g.map(e=>[e.id,e])),V=e=>e.tasks.filter(e=>"queued"===e.status).length,Z=v.map(e=>_.get(e)).filter(e=>!!e),Q=Z.filter(e=>V(e)>0&&!1!==e.active),G=Q.reduce((e,n)=>e+V(n),0),J=(null==w?void 0:w.running)===!0,X=g.some(e=>e.running),Y=A.some(e=>!e.ready),$=J||0===Q.length||X||Y,ee=X?{title:"batch.oneRunning",why:"batch.oneRunningWhy"}:0===Z.length?{title:"batch.pickFirst",why:"batch.pickFirstWhy"}:0===Q.length?{title:"batch.nothingRunnable",why:"batch.nothingRunnableWhy"}:null,en=(0,h.p)(),[et,el]=(0,a.useState)(!1),ea=(0,a.useRef)(!1),es=async e=>{if(!ea.current){ea.current=!0,el(!0);try{await e()}catch(e){T(e.message)}finally{ea.current=!1,el(!1),S()}}},ei=async e=>{("unattended"!==e||en||await (0,o.Z)(F("batch.unattendedConfirm",{n:Q.length})))&&await es(async()=>{var n;let t=await r.FH.startBatch(Q.map(e=>e.id),e,f,I||void 0,B||void 0,O.trim()||Q.map(e=>e.planName).find(Boolean)||void 0);D(""),T(t.started?"":null!=(n=t.reason)?n:"")})},er=Z.filter(e=>{var n;return(null!=(n=e.model)?n:"")!==I}).length,ec=Z.filter(e=>{var n;return(null==(n=e.review)?void 0:n.enabled)===!1}).length,ed=null!=(s=null==U?void 0:U.options)?s:[],eo=ed.filter(e=>!e.group),eh=new Map;for(let e of ed)e.group&&eh.set(e.group,[...null!=(c=eh.get(e.group))?c:[],e]);let eu=w?{done:w.sessions.filter(e=>"done"===e.state).length,failed:w.sessions.filter(e=>"failed"===e.state).length,skipped:w.sessions.filter(e=>"skipped"===e.state||"stopped"===e.state).length}:null,em=null==w?void 0:w.sessions.find(e=>"running"===e.state);return(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsx)("h2",{children:F("batch.title")}),(0,l.jsx)("p",{className:"muted small",children:F("batch.hint")}),!J&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"row",children:[(0,l.jsx)("strong",{className:"small",children:F("batch.selected",{n:Q.length,tasks:G})}),(0,l.jsx)("button",{className:"quiet",onClick:()=>b(g.filter(e=>V(e)>0).map(e=>e.id)),children:F("batch.selectQueued")}),(0,l.jsx)("button",{className:"quiet",onClick:()=>b([]),disabled:0===Z.length,children:F("batch.selectNone")})]}),N&&(0,l.jsx)("p",{className:"muted small",children:F("batch.fromPlan")}),Z.length>Q.length&&(0,l.jsx)("p",{className:"muted small",children:F("batch.notRunnable",{n:Z.length-Q.length})}),Q.length>0&&(0,l.jsx)("ol",{className:"run-order",children:Q.map((e,n)=>(0,l.jsxs)("li",{children:[(0,l.jsxs)("span",{children:[e.name," ",(0,l.jsxs)("span",{className:"muted small",children:["(",V(e),")"]})]}),(0,l.jsxs)("span",{children:[(0,l.jsx)("button",{className:"quiet",onClick:()=>C(e.id,-1),disabled:0===n,"aria-label":F("batch.moveUp",{name:e.name}),children:"↑"}),(0,l.jsx)("button",{className:"quiet",onClick:()=>C(e.id,1),disabled:n===Q.length-1,"aria-label":F("batch.moveDown",{name:e.name}),children:"↓"})]})]},e.id))}),(0,l.jsx)("label",{htmlFor:"batch-run-name",children:F("batch.runName")}),(0,l.jsx)("input",{id:"batch-run-name",type:"text",value:O,onChange:e=>L(e.target.value),placeholder:null!=(m=Q.map(e=>e.planName).find(Boolean))?m:F("batch.runNamePlaceholder")}),(0,l.jsx)("p",{className:"why",children:F("batch.runNameWhy")}),(0,l.jsx)("label",{htmlFor:"batch-model",children:F("batch.model")}),(0,l.jsxs)("div",{className:"row",children:[(0,l.jsxs)("select",{id:"batch-model",value:I,onChange:e=>W(e.target.value),style:{width:"auto",minWidth:260},children:[(0,l.jsx)("option",{value:"",children:F("batch.modelKeep")}),eo.map(e=>(0,l.jsx)("option",{value:e.name,disabled:e.disabled,children:e.name},e.name)),[...eh.entries()].map(e=>{let[n,t]=e;return(0,l.jsx)("optgroup",{label:n,children:t.map(e=>(0,l.jsx)("option",{value:e.name,disabled:e.disabled,children:e.name},e.name))},n)})]}),(null!=(x=null==U?void 0:U.options.length)?x:0)===0&&(0,l.jsx)("span",{className:"muted small",children:F("batch.modelNone")})]}),(0,l.jsx)("p",{className:"why",children:F("batch.modelWhy")}),(0,l.jsx)(u.L,{current:I,onUse:e=>W(e)}),I&&er>0&&(0,l.jsx)("p",{className:"why",style:{color:"var(--warn)"},children:F("batch.modelOverrides",{n:er})}),(0,l.jsx)("label",{htmlFor:"batch-review-model",children:F("batch.reviewModel")}),(0,l.jsx)("div",{className:"row",children:(0,l.jsxs)("select",{id:"batch-review-model",value:B,onChange:e=>R(e.target.value),style:{width:"auto",minWidth:260},children:[(0,l.jsx)("option",{value:"",children:F("batch.reviewModelKeep")}),eo.map(e=>(0,l.jsx)("option",{value:e.name,disabled:e.disabled,children:e.name},e.name)),[...eh.entries()].map(e=>{let[n,t]=e;return(0,l.jsx)("optgroup",{label:n,children:t.map(e=>(0,l.jsx)("option",{value:e.name,disabled:e.disabled,children:e.name},e.name))},n)})]})}),(0,l.jsx)("p",{className:"why",children:F("batch.reviewModelWhy")}),""!==B&&B===I&&(0,l.jsx)("p",{className:"why",style:{color:"var(--warn)"},children:F("batch.reviewSame")}),ec>0&&(0,l.jsx)("p",{className:"why",children:F("batch.reviewOffIn",{n:ec})}),(0,l.jsxs)("fieldset",{style:{border:0,padding:0,margin:"10px 0 14px"},children:[(0,l.jsx)("legend",{className:"muted small",style:{padding:0},children:F("batch.onFailure")}),(0,l.jsxs)("div",{className:"option",children:[(0,l.jsxs)("label",{children:[(0,l.jsx)("input",{type:"radio",name:"batch-fail",checked:"stop"===f,onChange:()=>y("stop")}),(0,l.jsx)("span",{children:F("batch.chain")})]}),(0,l.jsx)("p",{className:"why",children:F("batch.chainWhy")})]}),(0,l.jsxs)("div",{className:"option",children:[(0,l.jsxs)("label",{children:[(0,l.jsx)("input",{type:"radio",name:"batch-fail",checked:"continue"===f,onChange:()=>y("continue")}),(0,l.jsx)("span",{children:F("batch.independent")})]}),(0,l.jsx)("p",{className:"why",children:F("batch.independentWhy")})]})]}),ee&&(0,l.jsxs)("div",{className:"notice caution",children:[(0,l.jsx)("strong",{children:F(ee.title)}),(0,l.jsx)("div",{className:"small",style:{marginTop:4},children:F(ee.why)})]}),(0,l.jsx)(p,{groups:A,sessionIds:Q.map(e=>e.id),onChange:()=>z(e=>e+1)}),H&&(0,l.jsxs)("div",{className:"notice caution",role:"alert",children:[(0,l.jsx)("strong",{children:F("batch.notStartedTitle")}),(0,l.jsx)("div",{className:"small",style:{marginTop:4},children:H}),/execution\.isolation/.test(H)&&(0,l.jsx)("div",{className:"small",style:{marginTop:4},children:(0,l.jsx)(i(),{href:"/defaults",children:F("batch.notStartedIsolation")})})]}),!Y&&(0,l.jsxs)("div",{className:"run-choice",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("button",{className:"primary",onClick:()=>void ei("unattended"),disabled:et||$,children:F("batch.run",{n:Q.length})}),(0,l.jsx)("p",{className:"why",children:F("batch.runWhy")})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("button",{onClick:()=>void ei("confirm"),disabled:et||$,children:F("batch.runStep")}),(0,l.jsx)("p",{className:"why",children:F("batch.runStepWhy")})]})]})]}),J&&(0,l.jsxs)("div",{className:"row",children:[(null==w?void 0:w.pausing)?(0,l.jsx)("button",{className:"primary",onClick:()=>void es(async()=>{await r.FH.resumeBatch(),D("")}),disabled:et||(null==w?void 0:w.stopping),title:F("batch.resumeWhy"),children:F("batch.resume")}):(0,l.jsx)("button",{onClick:()=>void es(async()=>{await r.FH.pauseBatch(),D(F("batch.pausing"))}),disabled:et||(null==w?void 0:w.stopping),title:F("batch.pauseWhy"),children:F("batch.pause")}),(0,l.jsx)("button",{onClick:()=>void es(async()=>{await r.FH.stopBatch(),D(F("batch.stopping"))}),disabled:et||(null==w?void 0:w.stopping),title:F("batch.stopWhy"),children:F("batch.stop")}),(null==w?void 0:w.pausing)&&!(null==w?void 0:w.stopping)&&(0,l.jsx)("span",{className:"muted small",children:F("batch.pausing")}),(0,l.jsx)("span",{className:"badge",children:F("batch.modelRunning",{name:(em?(null==(n=_.get(em.sessionId))?void 0:n.modelInUse)||(null==(t=_.get(em.sessionId))?void 0:t.model):"")||F("model.default")})}),k.length>0&&(0,l.jsx)("span",{className:"badge waiting-approval",children:F("batch.waiting",{n:k.length})}),em&&(0,l.jsx)("span",{className:"small",children:F("batch.progress",{name:em.name,done:w.sessions.filter(e=>"waiting"!==e.state&&"running"!==e.state).length,total:w.sessions.length})})]}),J&&(0,l.jsx)("p",{className:"muted small",children:F("batch.hiddenWhileRunning")}),E&&(0,l.jsx)("div",{className:"muted small",role:"status",children:E}),(Z.length>0||w)&&(0,l.jsxs)("div",{className:"row",style:{marginTop:12},children:[(0,l.jsx)("a",{className:"button-link",href:r.FH.debugExportUrl(Z.length>0?Z.map(e=>e.id):(null!=(j=null==w?void 0:w.sessions)?j:[]).map(e=>e.sessionId)),children:F("batch.debug")}),(0,l.jsx)("span",{className:"muted small",children:Z.length>0?F("batch.debugSelected",{n:Z.length}):F("batch.debugLast")})]}),(Z.length>0||w)&&(0,l.jsx)("p",{className:"why",children:F("batch.debugWhy")}),w&&(0,l.jsxs)(l.Fragment,{children:[!J&&eu&&(0,l.jsx)("div",{className:"notice calm",style:{marginTop:12},children:(0,l.jsx)("strong",{children:F("batch.finished",eu)})}),(0,l.jsxs)("table",{style:{marginTop:10},children:[(0,l.jsx)("thead",{children:(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:F("batch.col.session")}),(0,l.jsx)("th",{children:F("batch.col.state")}),(0,l.jsx)("th",{children:F("batch.col.ran")}),(0,l.jsx)("th",{children:F("batch.col.why")})]})}),(0,l.jsx)("tbody",{children:w.sessions.map(e=>{var n,t;return(0,l.jsxs)("tr",{className:"batch-row ".concat(e.state),children:[(0,l.jsx)("td",{children:(0,l.jsx)(i(),{href:(0,r.aT)(e.sessionId),children:e.name})}),(0,l.jsx)("td",{children:(0,l.jsx)("span",{className:"badge ".concat("running"===(t=e.state)?"running":"done"===t?"done":"failed"===t?"failed":"stopped"===t?"aborted":""),children:F("batch.state.".concat(e.state))})}),(0,l.jsx)("td",{className:"small",children:F("batch.ranOf",{ran:e.ran,failed:e.failed})}),(0,l.jsx)("td",{className:"muted small",children:null!=(n=e.reason)?n:""})]},e.sessionId)})})]})]})]})}},7527:(e,n,t)=>{"use strict";t.d(n,{z:()=>a});var l=t(1521);function a(e,n){let t=!(arguments.length>2)||void 0===arguments[2]||arguments[2],a=(0,l.useRef)(e);a.current=e,(0,l.useEffect)(()=>{let e;if(!t)return;let l=!1,s=async()=>{try{await a.current()}catch(e){}finally{l||(e=setTimeout(()=>void s(),n))}};return s(),()=>{l=!0,e&&clearTimeout(e)}},[n,t])}},8848:(e,n,t)=>{"use strict";t.d(n,{H4:()=>d,L:()=>o,z4:()=>h});var l=t(3365),a=t(8197),s=t.n(a),i=t(1521),r=t(5549),c=t(867);function d(e){let{current:n,onUse:t}=e,{t:a}=(0,c.kj)(),[s,d]=(0,i.useState)(null);if((0,i.useEffect)(()=>{let e=!1;return r.FH.project().then(n=>{e||d(n)}).catch(()=>void 0),()=>{e=!0}},[]),!s)return null;let o=s.rootDir.trim(),h=n.trim().toLowerCase(),u=t?s.others.filter(e=>e.rootDir.trim().toLowerCase()!==h):[];return(0,l.jsx)(m,{label:o?a("proj.defaultIs",{dir:o}):a("proj.noneShort"),offer:o&&t&&h!==o.toLowerCase()?{text:a("proj.useIt"),onUse:()=>t(o)}:void 0,more:u.map(e=>({text:a("proj.otherUse",{name:e.name}),title:e.rootDir,onUse:()=>null==t?void 0:t(e.rootDir)})),link:o?a("proj.change"):a("proj.setIt"),anchor:"project"})}function o(e){let{current:n,onUse:t}=e,a=u(),{t:s}=(0,c.kj)();if(!a)return null;let i=a.defaultModel.trim();return(0,l.jsx)(m,{label:i?s("def.modelDefaultIs",{name:i}):s("def.modelNoneShort"),offer:i&&t&&n.trim()!==i?{text:s("def.modelUseIt"),onUse:()=>t(i)}:void 0,link:s(i?"proj.change":"proj.setIt"),anchor:"model"})}function h(e){let{current:n,onUse:t}=e,a=u(),{t:s}=(0,c.kj)();if(!a)return null;let i=a.defaultReviewModel.trim();return(0,l.jsx)(m,{label:i?s("def.reviewDefaultIs",{name:i}):s("def.reviewNoneShort"),offer:i&&t&&n.trim()!==i?{text:s("def.modelUseIt"),onUse:()=>t(i)}:void 0,link:s(i?"proj.change":"proj.setIt"),anchor:"review"})}function u(){let[e,n]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let e=!1;return r.FH.models().then(t=>{e||n(t)}).catch(()=>void 0),()=>{e=!0}},[]),e}function m(e){let{label:n,offer:t,more:a=[],link:i,anchor:r}=e;return(0,l.jsxs)("p",{className:"muted small",style:{marginTop:4},children:[n," ",t&&(0,l.jsxs)(l.Fragment,{children:["\xb7"," ",(0,l.jsx)("button",{type:"button",className:"linkish",onClick:t.onUse,children:t.text})," "]}),a.map(e=>(0,l.jsxs)("span",{children:["\xb7"," ",(0,l.jsx)("button",{type:"button",className:"linkish",onClick:e.onUse,title:e.title,children:e.text})," "]},e.text)),"\xb7 ",(0,l.jsx)(s(),{href:"/defaults#".concat(r),children:i})]})}}},e=>{e.O(0,[197,867,549,347,131,358],()=>e(e.s=5704)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[66],{1702:(e,s,a)=>{"use strict";var n=a(9962);a.o(n,"usePathname")&&a.d(s,{usePathname:function(){return n.usePathname}}),a.o(n,"useSearchParams")&&a.d(s,{useSearchParams:function(){return n.useSearchParams}})},1772:(e,s,a)=>{Promise.resolve().then(a.bind(a,2438))},2438:(e,s,a)=>{"use strict";a.r(s),a.d(s,{default:()=>C});var n=a(3365),t=a(1521),l=a(1702),i=a(8197),r=a.n(i),c=a(5549),d=a(867),o=a(1910),h=a(3523),u=a(3374),m=a(8078),p=a(8848),v=a(4784),x=a(2876),j=a(5132),g=a(1035),f=a(8934),y=a(4811),b=a(3041),k=a(7527),N=a(1366),w=a(8596),S=a(287);function C(){return(0,n.jsx)(t.Suspense,{fallback:null,children:(0,n.jsx)(F,{})})}function F(){var e;let{t:s}=(0,d.kj)(),a=null!=(e=(0,l.useSearchParams)().get("id"))?e:"",[i,o]=(0,t.useState)(null),[h,u]=(0,t.useState)([]),[m,p]=(0,t.useState)([]),[v,x]=(0,t.useState)(null),[j,g]=(0,t.useState)(""),[f,y]=(0,t.useState)(!1),b=(0,t.useRef)(null),N=(0,t.useRef)(0),w=(0,t.useCallback)(async()=>{if(!a)return;let e=++N.current;try{let s=await c.FH.session(a);if(e!==N.current)return;o(s),g("")}catch(s){if(e!==N.current)return;g(s.message)}},[a]),S=(0,t.useCallback)(()=>{b.current||(b.current=window.setTimeout(()=>{b.current=null,w()},400))},[w]);if((0,t.useEffect)(()=>{if(!a)return;c.FH.presets().then(p).catch(()=>void 0),c.FH.level1().then(x).catch(()=>void 0);let e=new EventSource(c.FH.streamUrl(a));return e.onopen=()=>y(!1),e.onmessage=e=>{let s;try{s=JSON.parse(e.data)}catch(e){return}"ping"!==s.type&&(u(e=>[...e.slice(-400),s]),S())},e.onerror=()=>{e.readyState===EventSource.CLOSED&&y(!0)},()=>{e.close()}},[a,S]),(0,k.z)(w,8e3,!!a),!a)return(0,n.jsx)("div",{className:"panel err",children:s("session.noId")});if(j&&!i)return(0,n.jsx)("div",{className:"panel err",children:j});if(!i)return(0,n.jsx)("div",{className:"panel muted",children:s("home.loading")});let C=i.tasks.filter(e=>"queued"===e.status).length;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"crumbs",children:[(0,n.jsx)(r(),{href:"/",children:s("session.crumb")})," / ",i.name]}),j&&(0,n.jsx)("div",{className:"panel err",role:"alert",children:s("session.stale",{err:j})}),f&&!j&&(0,n.jsx)("div",{className:"panel muted small",role:"status",children:s("session.streamClosed")}),(0,n.jsx)(I,{session:i,queued:C,onChange:w}),(0,n.jsx)(U,{tasks:i.tasks}),(0,n.jsx)(M,{session:i,onChange:w}),(0,n.jsx)(T,{level1:v,sent:i.contractSent}),(0,n.jsx)(B,{session:i,onChange:w}),(0,n.jsx)(W,{session:i,onChange:w}),(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsx)("h2",{children:s("tasks.title")}),(0,n.jsx)("p",{className:"muted small",children:s("tasks.hint")}),(0,n.jsx)(H,{session:i,onChange:w}),0===i.tasks.length&&(0,n.jsx)("div",{className:"muted",children:s("tasks.none")}),i.tasks.map((e,s)=>(0,n.jsx)(A,{session:i,task:e,index:s+1,presets:m,onChange:w},e.id))]}),(0,n.jsx)(P,{session:i}),(0,n.jsx)(D,{session:i,presets:m,onAdded:w,onPresetsChanged:()=>c.FH.presets().then(p)}),(0,n.jsx)(E,{events:h})]})}function I(e){var s;let{session:a,queued:l,onChange:i}=e,{t:r}=(0,d.kj)(),[o,h]=(0,t.useState)(""),[u,m]=(0,t.useState)("");(0,t.useEffect)(()=>{c.FH.models().then(e=>{var s;return m(null!=(s=e.defaultModel)?s:"")}).catch(()=>void 0)},[]);let[p,v]=(0,t.useState)(a.name),[x,j]=(0,t.useState)(null!=(s=a.conversationGroup)?s:"");(0,t.useEffect)(()=>v(a.name),[a.name]),(0,t.useEffect)(()=>{var e;return j(null!=(e=a.conversationGroup)?e:"")},[a.conversationGroup]);let f=(0,y.p)(),[b,k]=(0,t.useState)(!1),N=(0,t.useRef)(!1),w=async e=>{if(!N.current){N.current=!0,k(!0);try{await e()}catch(e){h(e.message)}finally{N.current=!1,k(!1),i()}}},S=async e=>{("unattended"!==e||f||await (0,g.Z)(r("session.unattendedConfirm")))&&await w(async()=>{var s;let n=await c.FH.start(a.id,e,a.planName);h(n.started?r("unattended"===e?"session.startedAuto":"session.startedStep"):r("session.notStarted",{reason:null!=(s=n.reason)?s:""}))})},C=async()=>{if(a.running)return void h(r("home.deleteRunning"));if(await (0,g.Z)(r("home.deleteConfirm",{name:a.name,n:a.tasks.length})))try{await c.FH.deleteSession(a.id),window.location.href="/"}catch(e){h(e.message)}},F=async()=>{var e;if(x.trim()!==(null!=(e=a.conversationGroup)?e:""))try{await c.FH.updateSession(a.id,{conversationGroup:x.trim()}),h(r("session.groupSaved")),i()}catch(e){h(e.message)}},I=a.running?r("state.running"):r("state.".concat(a.status));return(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("input",{type:"text",className:"grow","aria-label":r("home.col.name"),value:p,onChange:e=>v(e.target.value),onBlur:()=>void w(async()=>{p.trim()&&p!==a.name&&await c.FH.updateSession(a.id,{name:p})})}),(0,n.jsx)("span",{className:"badge ".concat(a.running?"running":""),children:I})]}),!a.running&&(0,n.jsxs)("div",{className:"run-choice",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("button",{className:"primary",onClick:()=>void S("unattended"),disabled:b||0===l,children:r("session.run",{n:l})}),(0,n.jsx)("p",{className:"why",children:r("session.runWhy")})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("button",{onClick:()=>void S("confirm"),disabled:b||0===l,children:r("session.runStep")}),(0,n.jsx)("p",{className:"why",children:r("session.runStepWhy")})]})]}),(0,n.jsxs)("div",{className:"row",style:{marginTop:10},children:[a.running&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{className:"danger",onClick:()=>void w(async()=>{await c.FH.stop(a.id),h(r("session.stopping"))}),disabled:b,children:r("session.stop")}),"unattended"===a.runMode&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"badge waiting-approval",children:r("session.modeUnattended")}),(0,n.jsx)("button",{onClick:()=>void w(async()=>{await c.FH.setRunMode(a.id,"confirm"),h(r("session.askingAgain"))}),disabled:b,children:r("session.askAgain")})]})]}),(0,n.jsx)("span",{className:"muted small",children:o}),(0,n.jsx)("span",{className:"grow"}),(0,n.jsx)("button",{className:"quiet",onClick:()=>void C(),disabled:a.running,children:r("home.delete")}),a.chat?(0,n.jsx)("a",{href:a.chat.url,target:"_blank",rel:"noreferrer",className:"small",children:r("session.openChat",{name:a.chat.name})}):(0,n.jsx)("span",{className:"muted small",children:r("session.noChat")})]}),(0,n.jsx)("label",{htmlFor:"session-group",children:r("session.group")}),(0,n.jsx)("div",{className:"row",children:(0,n.jsx)("input",{id:"session-group",type:"text",className:"grow",value:x,placeholder:r("session.groupPlaceholder"),onChange:e=>j(e.target.value),onBlur:()=>void F(),disabled:a.running})}),(0,n.jsxs)("p",{className:"why",children:[r("session.groupWhy"),a.chat&&" ".concat(r("session.groupHasChat"))]}),(0,n.jsx)("div",{className:"muted small",style:{marginTop:10},children:r("session.willUseModel",{name:(a.model&&("operator"===a.modelSource||!u)?a.model:"")||(u?r("model.followsDefault",{name:u}):r("model.default"))})})]})}function T(e){var s;let{level1:a,sent:t}=e,{t:l}=(0,d.kj)();return(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("h2",{className:"grow",style:{margin:0},children:l("l1.title")}),(0,n.jsx)("span",{className:"badge",children:l(t?"l1.sent":"l1.notSent")}),(0,n.jsx)(r(),{href:"/level1",className:"small",children:l("l1.edit")})]}),(0,n.jsxs)("p",{className:"muted small",style:{marginBottom:6},children:[l("l1.hint"),(null==a?void 0:a.customised)?" ".concat(l("l1.customised")):""]}),(0,n.jsxs)("details",{children:[(0,n.jsx)("summary",{children:l("l1.show")}),(0,n.jsx)("pre",{className:"tall",children:null!=(s=null==a?void 0:a.content)?s:"…"})]})]})}function M(e){var s,a,l,i,r;let{session:o,onChange:h}=e,{t:u}=(0,d.kj)(),m=(0,d.W3)(),[v,x]=(0,t.useState)(null),[j,f]=(0,t.useState)(!1),[y,b]=(0,t.useState)("");(0,t.useEffect)(()=>{c.FH.models().then(x).catch(()=>void 0)},[]);let k=async e=>{try{await c.FH.updateSession(o.id,{model:e}),b(e?u("model.saved",{name:e}):u("model.savedDefault")),h()}catch(e){b(e.message)}},N=async()=>{try{let e=await c.FH.setDefaultModel(C);x(s=>s?{...s,defaultModel:e.defaultModel}:s),b(e.defaultModel?u("model.defaultSaved",{name:e.defaultModel}):u("model.defaultCleared"))}catch(e){b(e.message)}},w=async()=>{if(await (0,g.Z)(u("model.refreshConfirm"))){f(!0),b(u("model.refreshing"));try{var e;let s=await c.FH.refreshModels();x(s),b(0===s.options.length?null!=(e=s.note)?e:u("model.none"):u("model.refreshed",{n:s.options.length}))}catch(e){b(e.message)}finally{f(!1)}}},S=!!o.model&&"operator"!==o.modelSource&&!!(null==v?void 0:v.defaultModel),C=S?"":null!=(s=o.model)?s:"",F=null!=(a=null==v?void 0:v.options)?a:[],I=F.some(e=>e.name===C),T=F.filter(e=>!e.group),M=new Map;for(let e of F)e.group&&M.set(e.group,[...null!=(l=M.get(e.group))?l:[],e]);return(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("h2",{className:"grow",style:{margin:0},children:u("model.title")}),o.modelInUse&&(0,n.jsx)("span",{className:"chip",children:u("model.lastUsed",{name:o.modelInUse})}),S&&(0,n.jsx)("p",{className:"muted small",children:u("model.planOutranked",{name:null!=(i=o.model)?i:""})})]}),(0,n.jsx)("p",{className:"muted small",children:u("model.hint")}),(0,n.jsxs)("div",{className:"row",children:[(0,n.jsxs)("select",{"aria-label":u("model.title"),value:C,disabled:o.running,onChange:e=>void k(e.target.value),style:{width:"auto",minWidth:260},children:[(0,n.jsx)("option",{value:"",children:(null==v?void 0:v.defaultModel)?u("model.followsDefault",{name:v.defaultModel}):u("model.default")}),C&&!I&&(0,n.jsx)("option",{value:C,children:u("model.notInList",{name:C})}),T.map(e=>(0,n.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(u("model.unavailable")):""]},e.name)),[...M.entries()].map(e=>{let[s,a]=e;return(0,n.jsx)("optgroup",{label:s,children:a.map(e=>(0,n.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(u("model.unavailable")):""]},e.name))},s)})]}),(0,n.jsx)("button",{onClick:()=>void w(),disabled:j||o.running,children:u("model.refresh")}),(0,n.jsx)("span",{className:"muted small",role:"status",children:y})]}),(0,n.jsx)(p.L,{current:C,onUse:e=>void k(e)}),(0,n.jsxs)("div",{className:"row",style:{marginTop:8},children:[(0,n.jsx)("span",{className:"muted small",children:(null==v?void 0:v.defaultModel)?u("model.defaultIs",{name:v.defaultModel}):u("model.defaultIsNone")}),(0,n.jsx)("button",{onClick:()=>void N(),disabled:C===(null!=(r=null==v?void 0:v.defaultModel)?r:""),children:C?u("model.makeDefault",{name:C}):u("model.clearDefault")})]}),(null==v?void 0:v.readAt)?(0,n.jsxs)("p",{className:"muted small",style:{marginTop:8},children:[u("model.readAt",{t:m(v.readAt),n:v.options.length}),v.current?" ".concat(u("model.chatWasOn",{name:v.current})):"",v.note?" ".concat(v.note):""]}):(0,n.jsx)("p",{className:"muted small",style:{marginTop:8},children:u("model.neverRead")}),F.length>0&&(0,n.jsxs)("details",{children:[(0,n.jsx)("summary",{children:u("model.showDetails")}),(0,n.jsx)("pre",{className:"tall",children:F.map(e=>"".concat(e.selected?"*":" "," ").concat(e.group?"".concat(e.group," > "):"").concat(e.name)+"".concat(e.disabled?" [unavailable]":"","\n ").concat(e.raw.replace(/\n/g," | "))).join("\n")})]})]})}function W(e){var s,a;let{session:l,onChange:i}=e,{t:r}=(0,d.kj)(),o=null!=(s=l.review)?s:{enabled:!0,model:""},[h,u]=(0,t.useState)(o.enabled),[m,x]=(0,t.useState)(null!=(a=o.model)?a:""),[j,g]=(0,t.useState)(""),[f,y]=(0,t.useState)(!1),[b,k]=(0,t.useState)("");(0,t.useEffect)(()=>{c.FH.models().then(e=>{var s;k(null!=(s=e.defaultReviewModel)?s:""),e.defaultReviewModel&&"operator"!==l.reviewModelSource&&x("")}).catch(()=>void 0)},[l.reviewModelSource]);let N=async()=>{y(!0),g("");try{await c.FH.updateSession(l.id,{review:{enabled:h,model:m}}),g(r("review.saved")),i()}catch(e){g(e.message)}finally{y(!1)}};return(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("h2",{className:"grow",style:{margin:0},children:r("review.title")}),(0,n.jsx)("span",{className:"badge ".concat(h?"done":""),children:h?r("review.on"):r("review.off")})]}),(0,n.jsx)("p",{className:"muted small",children:r("review.hint")}),(0,n.jsxs)("div",{className:"option",children:[(0,n.jsxs)("label",{children:[(0,n.jsx)("input",{type:"checkbox",checked:h,onChange:e=>u(e.target.checked),disabled:l.running}),(0,n.jsx)("span",{children:r("review.enable")})]}),(0,n.jsx)("p",{className:"why",children:r("review.enableWhy")})]}),(0,n.jsx)("label",{htmlFor:"review-model",children:r("review.modelField")}),(0,n.jsx)("div",{className:"row",children:(0,n.jsx)(v.Y,{id:"review-model",chosen:m,onChange:x,none:b?r("model.followsDefault",{name:b}):r("review.modelSame"),disabled:l.running||!h})}),(0,n.jsx)("p",{className:"why",children:r("review.modelWhy")}),(0,n.jsx)(p.z4,{current:m,onUse:e=>x(e)}),(0,n.jsxs)("div",{className:"row",style:{marginTop:10},children:[(0,n.jsx)("button",{className:"primary",onClick:()=>void N(),disabled:f||l.running,children:r("review.save")}),j&&(0,n.jsx)("span",{className:"muted small",children:j})]})]})}function O(e){var s;let{session:a,plan:l,onDone:i}=e,{t:r}=(0,d.kj)(),o=()=>Object.fromEntries(l.entries.filter(e=>e.choice).map(e=>[e.path,e.choice])),h=JSON.stringify(l.entries.map(e=>[e.path,e.choice])),[u,m]=(0,t.useState)(o);(0,t.useEffect)(()=>m(o()),[h]);let[p,v]=(0,t.useState)(!1),[x,j]=(0,t.useState)(""),g=l.entries.filter(e=>"include"===u[e.path]).length,f=async()=>{v(!0),j("");try{var e,s,n;let t=await c.FH.vcsSnapshot(a.id,u);j(t.ok?r("vcs.snapshotTaken",{branch:null!=(e=t.branch)?e:"",commit:(null!=(s=t.commit)?s:"").slice(0,8)}):null!=(n=t.problem)?n:""),i()}catch(e){j(e.message)}finally{v(!1)}};return(0,n.jsxs)("div",{className:"option",children:[(0,n.jsx)("p",{className:"small",children:r("vcs.snapshotList",{n:l.entries.length,branch:null!=(s=l.baselineBranch)?s:"—"})}),(0,n.jsx)("ul",{style:{margin:"4px 0",paddingLeft:0,listStyle:"none"},children:l.entries.map(e=>{var s;return(0,n.jsxs)("li",{style:{marginBottom:4,overflowWrap:"anywhere"},children:[(0,n.jsx)("code",{children:e.path})," ",(0,n.jsxs)("span",{className:"muted small",children:["(",e.input?"".concat(r("vcs.snapshotInput"),", "):"",r("vcs.snapshotKind.".concat(e.kind)),void 0!==e.size?", ".concat((0,c.zi)(e.size)):"",")"]})," ",0===e.allowed.length?(0,n.jsx)("span",{className:"err small",children:r("vcs.snapshotBlocked")}):(0,n.jsx)("select",{"aria-label":e.path,value:null!=(s=u[e.path])?s:"",onChange:s=>m({...u,[e.path]:s.target.value}),disabled:p||a.running||e.allowed.length<2,children:e.allowed.map(e=>(0,n.jsx)("option",{value:e,children:r("include"===e?"vcs.snapshotInclude":"vcs.snapshotLeaveOut")},e))}),e.reason&&(0,n.jsx)("div",{className:"muted small",children:e.reason})]},e.path)})}),(0,n.jsx)("button",{className:"primary",onClick:()=>void f(),disabled:p||a.running||!l.ok||0===g,children:r("vcs.snapshotTake")}),(0,n.jsx)("p",{className:"why",children:r("vcs.snapshotCancelWhy")}),x&&(0,n.jsx)("p",{className:"small",role:"status",children:x})]})}function B(e){var s,a,l,i,r,o,h,u,m,v,x,j,g,f,y,b,k,N,S,C,F,I,T,M,W,B,H,R,P,L,D,A,E,q,U,J;let{session:z,onChange:G}=e,{t:Z}=(0,d.kj)(),K=null!=(g=z.vcs)?g:{enabled:!0,repoDir:"",branchMode:"per-task",commitOnFinish:!0,branchPrefix:"cop/"},[_,Y]=(0,t.useState)(K.repoDir),[Q,V]=(0,t.useState)(null),[X,$]=(0,t.useState)(""),[ee,es]=(0,t.useState)(!1),ea=JSON.stringify(K),[en,et]=(0,t.useState)(null),[el,ei]=(0,t.useState)(null!=(f=K.branchName)?f:"");(0,t.useEffect)(()=>{var e;return ei(null!=(e=JSON.parse(ea).branchName)?e:"")},[ea]);let[er,ec]=(0,t.useState)(null!=(y=K.baseBranch)?y:"");(0,t.useEffect)(()=>{var e;return ec(null!=(e=JSON.parse(ea).baseBranch)?e:"")},[ea]);let[ed,eo]=(0,t.useState)((null!=(b=null==(s=K.userInputs)?void 0:s.paths)?b:[]).join("\n"));(0,t.useEffect)(()=>{var e,s;return eo((null!=(s=null==(e=JSON.parse(ea).userInputs)?void 0:e.paths)?s:[]).join("\n"))},[ea]);let[eh,eu]=(0,t.useState)((null!=(k=null==(a=K.artifacts)?void 0:a.paths)?k:[]).join("\n"));(0,t.useEffect)(()=>{var e,s;return eu((null!=(s=null==(e=JSON.parse(ea).artifacts)?void 0:e.paths)?s:[]).join("\n"))},[ea]);let em=e=>e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean),[ep,ev]=(0,t.useState)(null!=(N=K.existingBranch)?N:"");(0,t.useEffect)(()=>{var e;return ev(null!=(e=JSON.parse(ea).existingBranch)?e:"")},[ea]);let ex=null!=(S=K.startFrom)?S:"head";(0,t.useEffect)(()=>{Y(JSON.parse(ea).repoDir)},[ea]);let ej=JSON.parse(ea).repoDir||z.projectDir||"";(0,t.useEffect)(()=>{let e=!1;return ej.trim()?(c.FH.repoCheck(ej).then(s=>{var a;e||et(s.ok?null:null!=(a=s.problem)?a:null)}).catch(()=>{e||et(null)}),()=>{e=!0}):void et(null)},[ej]);let eg=(0,t.useCallback)(()=>{c.FH.vcsStatus(z.id).then(V).catch(()=>V(null))},[z.id]);(0,t.useEffect)(eg,[eg,ea]);let ef=async e=>{try{await c.FH.updateSession(z.id,{vcs:e}),$(Z("vcs.saved")),G(),eg()}catch(e){$(e.message)}},ey=async()=>{es(!0),$(Z("mirror.browsing"));try{let s=await c.FH.browseFolder(_.trim()||z.projectDir||void 0);if(s.ok)Y(s.path),await ef({repoDir:s.path});else{var e;$(s.cancelled?Z("mirror.browseCancelled"):null!=(e=s.reason)?e:"")}}catch(e){$(e.message)}finally{es(!1)}},eb=K.repoDir||z.projectDir||"",ek=""!==eb.trim()&&null===en;return(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("h2",{className:"grow",style:{margin:0},children:Z("vcs.title")}),(0,n.jsx)("span",{className:"badge ".concat(K.enabled?"done":""),children:K.enabled?Z("vcs.on"):Z("vcs.off")})]}),(0,n.jsx)("p",{className:"muted small",children:Z("vcs.hint")}),(0,n.jsx)("label",{htmlFor:"vcs-root",children:Z("vcs.repoField")}),(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("input",{id:"vcs-root",type:"text",className:"grow",value:_,onChange:e=>Y(e.target.value),onBlur:()=>_.trim()!==K.repoDir&&void ef({repoDir:_.trim()}),placeholder:z.projectDir||"C:\\Projects\\my-app",disabled:z.running}),(0,n.jsx)("button",{onClick:()=>void ey(),disabled:ee||z.running,children:Z("mirror.browse")})]}),(0,n.jsx)(p.H4,{current:_,onUse:e=>{Y(e),ef({repoDir:e})}}),en&&(0,n.jsxs)("div",{className:"notice caution",style:{marginTop:8},children:[(0,n.jsx)("strong",{children:Z("vcs.noRepo")}),(0,n.jsx)("div",{className:"small",style:{marginTop:4},children:en}),(0,n.jsx)("div",{className:"muted small",style:{marginTop:6},children:Z("vcs.noRepoHow")})]}),!en&&""!==eb.trim()&&(0,n.jsx)("p",{className:"muted small",style:{marginTop:4},children:Z("vcs.repoOk")}),""===eb.trim()&&(0,n.jsx)("p",{className:"muted small",style:{marginTop:4},children:Z("vcs.pickFirst")}),(0,n.jsxs)("div",{className:"option".concat(ek||K.enabled?"":" warned"),children:[(0,n.jsxs)("label",{children:[(0,n.jsx)("input",{type:"checkbox",checked:K.enabled,onChange:e=>void ef({enabled:e.target.checked}),disabled:z.running||!ek&&!K.enabled}),(0,n.jsx)("span",{children:Z("vcs.enable")})]}),(0,n.jsx)("p",{className:"why",children:Z("vcs.enableWhy")})]}),K.enabled&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"muted small",style:{marginTop:4},children:eb?Z("vcs.repoIs",{dir:eb}):Z("vcs.repoNone")}),eb&&!en&&(0,n.jsx)(w.E,{dir:eb}),(0,n.jsx)("h3",{children:Z("vcs.branches")}),"existing-branch"===ex&&(0,n.jsx)("p",{className:"muted small",children:Z("vcs.branchesExisting",{branch:K.existingBranch||"…"})}),(0,n.jsxs)("div",{className:"option",children:[(0,n.jsxs)("label",{children:[(0,n.jsx)("input",{type:"radio",name:"branchMode",checked:"per-task"===K.branchMode,onChange:()=>void ef({branchMode:"per-task"}),disabled:z.running}),(0,n.jsx)("span",{children:Z("vcs.perTask")})]}),(0,n.jsx)("p",{className:"why",children:Z("vcs.perTaskWhy")})]}),(0,n.jsxs)("div",{className:"option",children:[(0,n.jsxs)("label",{children:[(0,n.jsx)("input",{type:"radio",name:"branchMode",checked:"per-session"===K.branchMode,onChange:()=>void ef({branchMode:"per-session"}),disabled:z.running}),(0,n.jsx)("span",{children:Z("vcs.perSession")})]}),(0,n.jsx)("p",{className:"why",children:Z("vcs.perSessionWhy")})]}),"per-session"===K.branchMode&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("label",{htmlFor:"vcs-branch-name",children:Z("vcs.branchName")}),(0,n.jsx)("input",{id:"vcs-branch-name",type:"text",value:el,onChange:e=>ei(e.target.value),onBlur:()=>{var e;return el.trim()!==(null!=(e=K.branchName)?e:"")&&void ef({branchName:el.trim()})},placeholder:z.name,disabled:z.running}),(0,n.jsx)("p",{className:"why",children:Z("vcs.branchNameWhy")})]}),(0,n.jsx)("h3",{children:Z("vcs.startFrom")}),(0,n.jsxs)("div",{className:"option",children:[(0,n.jsxs)("label",{children:[(0,n.jsx)("input",{type:"radio",name:"startFrom",checked:"branch"===ex,onChange:()=>void ef({startFrom:"branch"}),disabled:z.running}),(0,n.jsx)("span",{children:Z("vcs.startBranch")})]}),(0,n.jsx)("p",{className:"why",children:Z("vcs.startBranchWhy")})]}),(0,n.jsxs)("div",{className:"option",children:[(0,n.jsxs)("label",{children:[(0,n.jsx)("input",{type:"radio",name:"startFrom",checked:"previous-session"===ex,onChange:()=>void ef({startFrom:"previous-session"}),disabled:z.running}),(0,n.jsx)("span",{children:Z("vcs.startPrevious")})]}),(0,n.jsx)("p",{className:"why",children:Z("vcs.startPreviousWhy")})]}),(0,n.jsxs)("div",{className:"option",children:[(0,n.jsxs)("label",{children:[(0,n.jsx)("input",{type:"radio",name:"startFrom",checked:"head"===ex,onChange:()=>void ef({startFrom:"head"}),disabled:z.running}),(0,n.jsx)("span",{children:Z("vcs.startHead")})]}),(0,n.jsx)("p",{className:"why",children:Z("vcs.startHeadWhy")})]}),(0,n.jsxs)("div",{className:"option",children:[(0,n.jsxs)("label",{children:[(0,n.jsx)("input",{type:"radio",name:"startFrom",checked:"existing-branch"===ex,onChange:()=>void ef({startFrom:"existing-branch"}),disabled:z.running}),(0,n.jsx)("span",{children:Z("vcs.startExisting")})]}),(0,n.jsx)("p",{className:"why",children:Z("vcs.startExistingWhy")})]}),"existing-branch"===ex&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("label",{htmlFor:"vcs-existing-branch",children:Z("vcs.existingBranch")}),(0,n.jsx)("input",{id:"vcs-existing-branch",type:"text",list:"vcs-local-branches",value:ep,onChange:e=>ev(e.target.value),onBlur:()=>{var e;return ep.trim()!==(null!=(e=K.existingBranch)?e:"")&&void ef({existingBranch:ep.trim()})},disabled:z.running}),(0,n.jsx)("datalist",{id:"vcs-local-branches",children:(null!=(C=null==Q?void 0:Q.branches)?C:[]).map(e=>(0,n.jsx)("option",{value:e},e))}),(0,n.jsx)("p",{className:"why",children:Z("vcs.existingBranchWhy")}),K.existingBranch&&(null==Q?void 0:Q.branches)&&!Q.branches.includes(K.existingBranch)&&(0,n.jsx)("p",{className:"err small",children:Z("vcs.existingBranchMissing",{branch:K.existingBranch})})]}),("branch"===ex||"previous-session"===ex)&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("label",{htmlFor:"vcs-base-branch",children:Z("vcs.baseBranch")}),(0,n.jsx)("input",{id:"vcs-base-branch",type:"text",value:er,onChange:e=>ec(e.target.value),onBlur:()=>{var e;return er.trim()!==(null!=(e=K.baseBranch)?e:"")&&void ef({baseBranch:er.trim()})},placeholder:"main",disabled:z.running}),(0,n.jsx)("p",{className:"why",children:Z("vcs.baseBranchWhy")})]}),z.vcsStart&&(0,n.jsxs)("p",{className:"muted small",children:["existing-branch"===z.vcsStart.kind?Z("vcs.startedExisting",{branch:null!=(F=z.vcsStart.branch)?F:"",commit:z.vcsStart.commit.slice(0,8)}):"previous-session"===z.vcsStart.kind?Z("vcs.startedPrevious",{name:null!=(I=null==(l=z.vcsStart.fromSession)?void 0:l.name)?I:"",branch:null!=(T=z.vcsStart.branch)?T:"",commit:z.vcsStart.commit.slice(0,8)}):"branch"===z.vcsStart.kind?Z("vcs.startedBranch",{branch:null!=(M=z.vcsStart.branch)?M:"",commit:z.vcsStart.commit.slice(0,8)}):"snapshot"===z.vcsStart.kind?Z("vcs.startedSnapshot",{branch:null!=(W=z.vcsStart.branch)?W:"",commit:z.vcsStart.commit.slice(0,8),from:null!=(B=null==(i=z.vcsStart.snapshot)?void 0:i.fromBranch)?B:"HEAD",n:null!=(H=null==(r=z.vcsStart.snapshot)?void 0:r.included.length)?H:0,out:null!=(R=null==(o=z.vcsStart.snapshot)?void 0:o.leftOut.length)?R:0}):Z("vcs.startedHead",{commit:z.vcsStart.commit.slice(0,8)}),z.vcsStart.note?" — ".concat(z.vcsStart.note):"",z.vcsStart.update&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("br",{}),"updated"===z.vcsStart.update.outcome?Z("vcs.updated",{branch:z.vcsStart.update.branch,remote:null!=(P=z.vcsStart.update.remote)?P:"",from:(null!=(L=z.vcsStart.update.from)?L:"").slice(0,8),to:(null!=(D=z.vcsStart.update.to)?D:"").slice(0,8)}):"up-to-date"===z.vcsStart.update.outcome?Z("vcs.upToDate",{branch:z.vcsStart.update.branch,remote:null!=(A=z.vcsStart.update.remote)?A:""}):Z("vcs.notUpdated",{branch:z.vcsStart.update.branch,why:null!=(E=z.vcsStart.update.detail)?E:z.vcsStart.update.outcome})]})]}),"head"!==ex&&(0,n.jsxs)("div",{className:"option",children:[(0,n.jsxs)("label",{children:[(0,n.jsx)("input",{type:"checkbox",checked:!1!==K.updateFromRemote,onChange:e=>void ef({updateFromRemote:e.target.checked}),disabled:z.running}),(0,n.jsx)("span",{children:Z("vcs.updateFromRemote")})]}),(0,n.jsx)("p",{className:"why",children:Z("vcs.updateFromRemoteWhy")})]}),(0,n.jsxs)("div",{className:"option",children:[(0,n.jsxs)("label",{children:[(0,n.jsx)("input",{type:"checkbox",checked:K.commitOnFinish,onChange:e=>void ef({commitOnFinish:e.target.checked}),disabled:z.running}),(0,n.jsx)("span",{children:Z("vcs.commit")})]}),(0,n.jsx)("p",{className:"why",children:Z("vcs.commitWhy")})]}),"existing-branch"!==ex&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("h3",{children:Z("vcs.dirty")}),["reject","snapshot","tracked-only-snapshot"].map(e=>{var s,a;return(0,n.jsxs)("div",{className:"option",children:[(0,n.jsxs)("label",{children:[(0,n.jsx)("input",{type:"radio",name:"vcs-dirty-".concat(z.id),checked:(null!=(a=null==(s=K.dirtyWorktree)?void 0:s.policy)?a:"reject")===e,onChange:()=>{var s;ef({dirtyWorktree:{policy:e,requireApproval:null==(s=K.dirtyWorktree)?void 0:s.requireApproval}})},disabled:z.running}),(0,n.jsx)("span",{children:Z("reject"===e?"vcs.dirtyReject":"snapshot"===e?"vcs.dirtySnapshot":"vcs.dirtyTracked")})]}),(0,n.jsx)("p",{className:"why",children:Z("reject"===e?"vcs.dirtyRejectWhy":"snapshot"===e?"vcs.dirtySnapshotWhy":"vcs.dirtyTrackedWhy")})]},e)}),(null!=(q=null==(h=K.dirtyWorktree)?void 0:h.policy)?q:"reject")!=="reject"&&(0,n.jsxs)("div",{className:"option",children:[(0,n.jsxs)("label",{children:[(0,n.jsx)("input",{type:"checkbox",checked:(null==(u=K.dirtyWorktree)?void 0:u.requireApproval)!==!1,onChange:e=>{var s,a;ef({dirtyWorktree:{policy:null!=(a=null==(s=K.dirtyWorktree)?void 0:s.policy)?a:"snapshot",requireApproval:e.target.checked}})},disabled:z.running}),(0,n.jsx)("span",{children:Z("vcs.dirtyApproval")})]}),(0,n.jsx)("p",{className:"why",children:Z("vcs.dirtyApprovalWhy")})]})]}),(0,n.jsx)("h3",{children:Z("vcs.inputs")}),(0,n.jsx)("label",{htmlFor:"vcs-inputs-".concat(z.id),children:Z("vcs.inputsField")}),(0,n.jsx)("textarea",{id:"vcs-inputs-".concat(z.id),rows:3,value:ed,onChange:e=>eo(e.target.value),onBlur:()=>{var e,s;return JSON.stringify(em(ed))!==JSON.stringify(null!=(s=null==(e=K.userInputs)?void 0:e.paths)?s:[])&&void ef({userInputs:{...K.userInputs,paths:em(ed)}})},disabled:z.running,placeholder:"rules-engine/test-data/schemas/*.yaml",spellCheck:!1}),(0,n.jsx)("p",{className:"why",children:Z("vcs.inputsWhy")}),(null!=(U=null==(m=K.userInputs)?void 0:m.paths.length)?U:0)>0&&(0,n.jsxs)("div",{className:"option",children:[(0,n.jsxs)("label",{children:[(0,n.jsx)("input",{type:"checkbox",checked:(null==(v=K.userInputs)?void 0:v.readOnly)!==!1,onChange:e=>{var s,a,n;ef({userInputs:{paths:null!=(n=null==(s=K.userInputs)?void 0:s.paths)?n:[],requireApproval:null==(a=K.userInputs)?void 0:a.requireApproval,readOnly:e.target.checked}})},disabled:z.running}),(0,n.jsx)("span",{children:Z("vcs.inputsReadOnly")})]}),(0,n.jsx)("p",{className:"why",children:Z("vcs.inputsReadOnlyWhy")})]}),(null==(x=z.vcsStart)?void 0:x.inputs)&&(0,n.jsx)("p",{className:"muted small",children:z.vcsStart.inputs.carried?Z("vcs.inputsCarried",{n:z.vcsStart.inputs.files.length,branch:z.vcsStart.inputs.carried.branch,onto:z.vcsStart.inputs.carried.onto.slice(0,8)}):Z("vcs.inputsRecorded",{n:z.vcsStart.inputs.files.length,commit:z.vcsStart.commit.slice(0,8)})}),(0,n.jsx)("h3",{children:Z("vcs.artifacts")}),(0,n.jsx)("label",{htmlFor:"vcs-artifacts-".concat(z.id),children:Z("vcs.artifactsField")}),(0,n.jsx)("textarea",{id:"vcs-artifacts-".concat(z.id),rows:2,value:eh,onChange:e=>eu(e.target.value),onBlur:()=>{var e,s;return JSON.stringify(em(eh))!==JSON.stringify(null!=(s=null==(e=K.artifacts)?void 0:e.paths)?s:[])&&void ef({artifacts:{paths:em(eh)}})},disabled:z.running,placeholder:"rules-engine/test-results/**",spellCheck:!1}),(0,n.jsx)("p",{className:"why",children:Z("vcs.artifactsWhy")}),Q&&!Q.ok&&(0,n.jsxs)("div",{className:"notice caution",role:"status",children:[(0,n.jsx)("strong",{children:Z("vcs.notReady")})," ",Q.problem]}),(null==Q||null==(j=Q.snapshot)?void 0:j.needed)&&Q.snapshot.entries.length>0&&(0,n.jsx)(O,{session:z,plan:Q.snapshot,onDone:()=>{G(),eg()}}),(null==Q?void 0:Q.ok)&&(0,n.jsx)("div",{className:"muted small",children:Z("vcs.ready",{branch:null!=(J=Q.branch)?J:"—",dir:Q.repoDir})}),(null==Q?void 0:Q.ok)&&Q.work&&Q.work.branches.length>0&&(0,n.jsxs)("div",{className:"muted small",children:["per-session"===Q.work.mode&&Q.work.complete?Z("vcs.completeOn",{branch:Q.work.complete}):Z("vcs.noSingleBranch",{n:Q.work.branches.length}),"per-task"===Q.work.mode&&(0,n.jsx)("ul",{style:{margin:"4px 0",paddingLeft:20},children:Q.work.branches.map(e=>(0,n.jsxs)("li",{children:[(0,n.jsx)("code",{children:e.branch})," — ",e.title,e.commit?"":" (".concat(Z("vcs.taskNoFiles"),")")]},e.branch))})]}),(0,n.jsx)("p",{className:"muted small",children:Z("vcs.pushIsYours")})]}),(0,n.jsx)("div",{className:"muted small",role:"status",children:X})]})}function H(e){var s;let{session:a,onChange:l}=e,{t:i}=(0,d.kj)(),[r,o]=(0,t.useState)(""),h=null!=(s=a.onFailure)?s:"stop",u=async e=>{if(e!==h)try{await c.FH.updateSession(a.id,{onFailure:e}),o(i("stop"===e?"chain.savedStop":"chain.savedContinue")),l()}catch(e){o(e.message)}};return(0,n.jsxs)("fieldset",{style:{border:0,padding:0,margin:"10px 0 14px"},children:[(0,n.jsx)("legend",{className:"muted small",style:{padding:0},children:i("chain.title")}),(0,n.jsxs)("div",{className:"option",children:[(0,n.jsxs)("label",{children:[(0,n.jsx)("input",{type:"radio",name:"chain",checked:"stop"===h,onChange:()=>void u("stop"),disabled:a.running}),(0,n.jsx)("span",{children:i("chain.stop")})]}),(0,n.jsx)("p",{className:"why",children:i("chain.stopWhy")})]}),(0,n.jsxs)("div",{className:"option",children:[(0,n.jsxs)("label",{children:[(0,n.jsx)("input",{type:"radio",name:"chain",checked:"continue"===h,onChange:()=>void u("continue"),disabled:a.running}),(0,n.jsx)("span",{children:i("chain.continue")})]}),(0,n.jsx)("p",{className:"why",children:i("chain.continueWhy")})]}),r&&(0,n.jsx)("div",{className:"muted small",role:"status",children:r}),a.running&&(0,n.jsx)("div",{className:"muted small",children:i("chain.locked")})]})}function R(e){let{value:s,onChange:a,presets:l,onPresetsChanged:i}=e,{t:r}=(0,d.kj)(),o=(0,t.useId)(),[h,u]=(0,t.useState)(""),m=async()=>{let e=prompt(r("l2.saveAsPrompt"));if(e)try{await c.FH.savePreset(e,s),u(r("l2.savedAs",{name:e})),null==i||i()}catch(e){u(e.message)}};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("label",{className:"grow",style:{margin:0},htmlFor:"".concat(o,"-text"),children:r("l2.label")}),(0,n.jsxs)("select",{value:"","aria-label":r("l2.loadPreset"),onChange:e=>{let s=l.find(s=>s.name===e.target.value);s&&a(s.content)},children:[(0,n.jsx)("option",{value:"",children:r("l2.loadPreset")}),l.map(e=>(0,n.jsx)("option",{value:e.name,children:e.name},e.name))]}),(0,n.jsx)("button",{onClick:()=>void m(),disabled:!s.trim(),children:r("l2.saveAs")})]}),(0,n.jsx)("textarea",{id:"".concat(o,"-text"),className:"prose",value:s,onChange:e=>a(e.target.value),placeholder:r("l2.placeholder"),style:{minHeight:140,marginTop:10}}),h&&(0,n.jsx)("div",{className:"muted small",children:h})]})}function P(e){let{session:s}=e,{t:a}=(0,d.kj)(),l=(0,d.W3)(),i=s.tasks.filter(e=>"queued"!==e.status),[r,o]=(0,t.useState)([]),h=r.length>0?r:i.map(e=>e.id),u=e=>(0,c.ub)("".concat(c.nC,"/sessions/").concat(s.id,"/export?variant=").concat(e)+(r.length>0?"&tasks=".concat(encodeURIComponent(r.join(","))):""));return(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsx)("h2",{children:a("export.title")}),(0,n.jsx)("p",{className:"muted small",children:a("export.hint")}),0===i.length?(0,n.jsx)("div",{className:"empty",children:a("export.nothing")}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"row",style:{marginBottom:6},children:[(0,n.jsx)("button",{className:"quiet",onClick:()=>o(i.map(e=>e.id)),children:a("export.all")}),(0,n.jsx)("button",{className:"quiet",onClick:()=>o([]),children:a("export.none")}),(0,n.jsx)("span",{className:"muted small",children:r.length>0?a("export.selected",{n:r.length}):a("export.allOf",{n:i.length})})]}),i.map(e=>{var s,t,i,c,d;return(0,n.jsx)("div",{className:"option",style:{margin:"6px 0"},children:(0,n.jsxs)("label",{children:[(0,n.jsx)("input",{type:"checkbox",checked:r.includes(e.id),onChange:()=>{let s;return s=e.id,o(e=>e.includes(s)?e.filter(e=>e!==s):[...e,s])}}),(0,n.jsxs)("span",{children:[e.title," ",(0,n.jsx)("span",{className:"badge ".concat(e.status),children:a("status.".concat(e.status))})," ",e.readOnly&&(0,n.jsx)("span",{className:"chip",children:a("task.readOnly")})," ",(null!=(t=null==(s=e.scope)?void 0:s.length)?t:0)>0&&(0,n.jsx)("span",{className:"chip",children:a("task.scope",{paths:(null!=(i=e.scope)?i:[]).join(", ")})})," ",(0,n.jsx)("span",{className:"muted small",children:l(null!=(d=null!=(c=e.finishedAt)?c:e.startedAt)?d:e.createdAt)})]})]})},e.id)}),(0,n.jsxs)("div",{className:"row",style:{marginTop:10},children:[(0,n.jsx)("a",{className:"button-link",href:u("outcome"),download:!0,children:a("export.outcome",{n:h.length})}),(0,n.jsx)("a",{className:"button-link",href:u("full"),download:!0,children:a("export.full",{n:h.length})})]}),(0,n.jsx)("p",{className:"muted small",style:{marginTop:8},children:a("export.outcomeWhy")})]})]})}function L(e){let{handoff:s}=e,{t:a}=(0,d.kj)(),t=(e,s)=>(0,n.jsxs)("div",{className:"handoff-row",children:[(0,n.jsx)("strong",{children:a(e)})," ",s]}),l=e=>(0,n.jsx)("ul",{children:e.map((e,s)=>(0,n.jsx)("li",{children:e},s))}),i=s.validation.filter(e=>e.passed).length;return(0,n.jsxs)("div",{className:"summary handoff",children:[(0,n.jsx)("strong",{children:a("handoff.title")}),t("handoff.outcome",(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"badge ".concat(s.outcome.status),children:a("status.".concat(s.outcome.status))}),s.outcome.reason?" ".concat(s.outcome.reason):""]})),t("handoff.files",0===s.changedFiles.length?(0,n.jsx)("span",{className:"muted",children:a("handoff.noFiles")}):(0,n.jsx)("code",{children:s.changedFiles.map(e=>"".concat(e.path).concat(e.added>=0?" +".concat(e.added,"/-").concat(e.removed):"")).join(", ")})),s.validation.length>0&&t("handoff.validation",(0,n.jsxs)(n.Fragment,{children:[a("handoff.passed",{n:i,of:s.validation.length}),s.review?" \xb7 ".concat(a("handoff.review",{verdict:s.review.verdict,open:s.review.open})):""]})),t("handoff.issues",0===s.knownIssues.length?(0,n.jsx)("span",{className:"muted",children:a("handoff.noIssues")}):l(s.knownIssues)),s.evidence.runId&&t("handoff.evidence",(0,n.jsx)("code",{children:s.evidence.runId})),(s.vcs.branch||s.vcs.problem)&&t("handoff.vcs",(0,n.jsxs)(n.Fragment,{children:[s.vcs.branch&&(0,n.jsx)("code",{children:s.vcs.branch}),s.vcs.commit?" @ ".concat(s.vcs.commit.slice(0,8)," \xb7 ").concat(a("handoff.notPushed")):s.vcs.branch?" \xb7 ".concat(a("handoff.noCommit")):"",s.vcs.problem?" — ".concat(s.vcs.problem):""]})),s.manual.length>0&&t("handoff.manual",l(s.manual)),s.notExecuted.length>0&&t("handoff.notRun",l(s.notExecuted))]})}function D(e){var s;let{session:a,presets:l,onAdded:i,onPresetsChanged:r}=e,{t:o}=(0,d.kj)(),h=[...a.tasks].reverse()[0],[u,m]=(0,t.useState)(""),[p,v]=(0,t.useState)(null!=(s=null==h?void 0:h.level2)?s:""),[x,j]=(0,t.useState)(""),[g,f]=(0,t.useState)(""),[y,b]=(0,t.useState)(!1),k=(0,t.useRef)(!1),N=async()=>{if(!k.current){k.current=!0,b(!0);try{await c.FH.addTask(a.id,{title:u,level2:p,prompt:x}),m(""),j(""),f(o("form.queued")),i()}catch(e){f(e.message)}finally{k.current=!1,b(!1)}}};return(0,n.jsxs)("div",{className:"panel",id:"new-task",children:[(0,n.jsx)("h2",{children:o("form.title")}),(0,n.jsx)("p",{className:"muted small",children:o("form.hint")}),(0,n.jsx)("label",{htmlFor:"new-task-title",children:o("form.titleLabel")}),(0,n.jsx)("input",{id:"new-task-title",type:"text",value:u,onChange:e=>m(e.target.value),placeholder:o("form.titlePlaceholder")}),(0,n.jsx)("div",{style:{marginTop:10},children:(0,n.jsx)(R,{value:p,onChange:v,presets:l,onPresetsChanged:r})}),(0,n.jsx)("label",{htmlFor:"new-task-prompt",children:o("form.taskLabel")}),(0,n.jsx)("textarea",{id:"new-task-prompt",className:"prose",value:x,onChange:e=>j(e.target.value),placeholder:o("form.taskPlaceholder"),style:{minHeight:140}}),(0,n.jsxs)("div",{className:"row",style:{marginTop:10},children:[(0,n.jsx)("button",{className:"primary",onClick:()=>void N(),disabled:y||!x.trim(),children:o("form.add")}),(0,n.jsx)("span",{className:"muted small",children:g})]})]})}function A(e){var s,a,l,i,r,m,p,v,y,k,w,C,F,I,T,M,W,O,B,H,P,D,A,E,U,Z,K,_,Y,Q,V,X,$,ee,es,ea,en,et,el,ei,er,ec,ed,eo,eh,eu,em,ep,ev,ex,ej,eg,ef,ey,eb,ek,eN,ew,eS,eC,eF,eI,eT,eM,eW,eO,eB,eH,eR,eP,eL,eD,eA,eE,eq,eU,eJ,ez,eG,eZ,eK,e_,eY,eQ;let{session:eV,task:eX,index:e$,presets:e0,onChange:e1}=e,{t:e2}=(0,d.kj)(),e8=(0,d.W3)(),[e4,e6]=(0,t.useState)(!1),[e3,e5]=(0,t.useState)(!1),[e7,e9]=(0,t.useState)(eX.title),[se,ss]=(0,t.useState)(eX.level2),[sa,sn]=(0,t.useState)(eX.prompt),[st,sl]=(0,t.useState)(null!=(ea=null==(s=eX.vcsPlan)?void 0:s.branch)?ea:""),[si,sr]=(0,t.useState)(null!=(en=null==(a=eX.vcsPlan)?void 0:a.commitMessage)?en:""),[sc,sd]=(0,t.useState)(null!=(et=eX.checks)?et:[]),[so,sh]=(0,t.useState)(!!eX.readOnly),[su,sm]=(0,t.useState)((null!=(el=eX.scope)?el:[]).join("\n")),sp={readOnly:so,scope:so?[]:(0,N.w)(su)},sv=(0,u.c)((0,h.DG)(eX)),[sx,sj]=(0,t.useState)(null),[sg,sf]=(0,t.useState)(""),[sy,sb]=(0,t.useState)(null),[sk,sN]=(0,t.useState)(!1),sw=async()=>{try{await c.FH.updateTask(eV.id,eX.id,{title:e7,level2:se,prompt:sa,vcsPlan:{branch:st,commitMessage:si},checks:sc,...sp}),e6(!1),e1()}catch(e){sf(e.message)}},sS="running"===eX.status||"waiting-approval"===eX.status,sC=!sS&&"queued"!==eX.status,sF=!sS&&"queued"!==eX.status,sI=!sS&&null!=(ei=null==(l=eV.vcs)?void 0:l.enabled)&&ei&&(!!(null==(i=eX.vcs)?void 0:i.baseCommit)||(null!=(er=eX.attempts)?er:[]).some(e=>{var s;return null==(s=e.vcs)?void 0:s.baseCommit})),sT=!sS&&(0,c.Zm)(eX),sM=async()=>{if(await (0,g.Z)(e2("task.continueConfirm",{title:eX.title})))try{await c.FH.continueTask(eV.id,eX.id),e1(),sb({intro:e2("runq.savedOffer")})}catch(e){sf(e.message)}},sW=async()=>{if(await (0,g.Z)(e2("task.rerunConfirm",{title:eX.title})))try{await c.FH.rerunTask(eV.id,eX.id),e1(),sb({intro:e2("runq.savedOffer")})}catch(e){sf(e.message)}},sO=async()=>{if(await (0,g.Z)(e2("task.editRanConfirm",{title:eX.title})))try{await c.FH.rerunTask(eV.id,eX.id,{title:e7,level2:se,prompt:sa,vcsPlan:{branch:st,commitMessage:si},checks:sc,...sp},{buildOnFinished:"done"===eX.status}),e6(!1),e1(),sb({intro:e2("runq.savedOffer")})}catch(e){sf(e.message)}},sB=(0,b.e)(e1),sH=async()=>{let e="queued"===eX.status?"task.deleteConfirm":"task.deleteConfirmRan";if(await (0,g.Z)(e2(e,{title:eX.title})))try{await c.FH.deleteTask(eV.id,eX.id),e1()}catch(e){sf(e.message)}},sR=async()=>{try{sj(await c.FH.taskFiles(eV.id,eX.id))}catch(e){sf(e.message)}},sP=(e,s,a)=>a.length>0&&(0,n.jsxs)("div",{children:[(0,n.jsxs)("span",{className:"muted",children:[e2(e)," "]}),a.map(e=>(0,n.jsx)("span",{style:{marginRight:10},children:(0,n.jsx)(o.u,{label:e,save:()=>c.FH.saveTaskFile(eV.id,eX.id,s,e)})},e))]});return(0,n.jsxs)("div",{className:"task ".concat(eX.status),id:eX.id,children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsxs)("h4",{className:"grow",children:[e$,". ",eX.title]}),(0,n.jsx)("span",{className:"badge ".concat(eX.status),children:e2("status.".concat(eX.status))}),eX.limit&&(0,n.jsx)("span",{className:"chip",title:e2("reg.limitChipWhy"),children:e2("reg.limitChip",{limit:e2("limit.".concat(eX.limit.setting),{n:eX.limit.value})})}),(null!=(ec=eX.attempt)?ec:1)>1&&(0,n.jsx)("span",{className:"chip",children:e2("task.attemptN",{n:null!=(ed=eX.attempt)?ed:1})}),eX.iterations>0&&(0,n.jsx)("span",{className:"muted small",children:e2("task.iterations",{n:eX.iterations})}),eX.runId&&(0,n.jsxs)("button",{className:e3?"":"quiet","aria-expanded":e3,onClick:()=>e5(e=>!e),title:(0,h.DG)(eX)?e2("story.showLiveWhy"):e2("story.why"),children:[(0,h.DG)(eX)&&!e3&&(0,n.jsx)("span",{className:"dot","aria-hidden":"true"}),e3?e2("story.hide"):(0,h.DG)(eX)?e2("story.showLive"):e2("story.show")]}),"queued"===eX.status&&!eV.running&&!1!==eV.active&&(0,n.jsx)("button",{className:sy?"":"primary","aria-expanded":!!sy,onClick:()=>{sN(!1),sb(sy?null:{})},title:e2("runq.buttonWhy"),children:e2("runq.button")}),(sk||"contract-conflict"===eX.stopCode&&!sS&&"queued"!==eX.status&&!eV.running)&&(0,n.jsx)("button",{className:sk?"":"primary","aria-expanded":sk,onClick:()=>sN(!sk),title:e2("cfix.buttonWhy"),children:e2("cfix.button")}),!sS&&(0,n.jsx)("button",{onClick:()=>{if(!e4){var e,s,a,n,t,l;e9(eX.title),ss(eX.level2),sn(eX.prompt),sl(null!=(a=null==(e=eX.vcsPlan)?void 0:e.branch)?a:""),sr(null!=(n=null==(s=eX.vcsPlan)?void 0:s.commitMessage)?n:""),sd(null!=(t=eX.checks)?t:[]),sh(!!eX.readOnly),sm((null!=(l=eX.scope)?l:[]).join("\n"))}e6(!e4)},title:e2("task.editAll"),children:e4?e2("task.cancel"):e2("task.edit")}),sT&&(0,n.jsx)("button",{className:"primary",onClick:()=>void sM(),title:e2("task.continueWhy"),children:e2("task.continue")}),sF&&(0,n.jsx)("button",{className:sT?"":"primary",onClick:()=>void sW(),title:e2("task.rerunWhy"),children:e2("task.rerun")}),sI&&(0,n.jsx)("button",{onClick:()=>void sB.restore({sessionId:eV.id,taskId:eX.id,title:eX.title}),disabled:""!==sB.busy||eV.running,title:e2("restore.why"),children:"restore"===sB.busy?e2("restore.checking"):e2("restore.button")}),sC&&(0,n.jsx)("button",{onClick:()=>void sB.restartFrom({sessionId:eV.id,taskId:eX.id,title:eX.title}),disabled:""!==sB.busy||eV.running,title:e2("restart.why"),children:"restart"===sB.busy?e2("restart.checking"):e2("restart.button")}),!sS&&(0,n.jsx)("button",{className:"danger",onClick:()=>void sH(),children:e2("task.delete")}),!e4&&(sg||sB.message)&&(0,n.jsx)("span",{className:"err",role:"alert",children:sg||sB.message})]}),(0,n.jsxs)("div",{className:"muted small",children:[eX.startedAt?e2("task.started",{t:e8(eX.startedAt)}):e2("task.added",{t:e8(eX.createdAt)}),eX.finishedAt?" \xb7 ".concat(e2("task.finished",{t:e8(eX.finishedAt)})):"",eX.startedAt&&eX.finishedAt?" \xb7 ".concat(e2("task.took",{d:(0,c.c5)((0,h.d5)(eX.startedAt,eX.finishedAt))})):"",(0,h.DG)(eX)?" \xb7 ".concat(e2("task.runningFor",{d:(0,c.c5)((0,h.d5)(eX.startedAt,void 0,sv))})):""]}),"queued"!==eX.status&&(null==(r=eV.vcs)?void 0:r.enabled)&&eX.vcs&&(0,n.jsx)("div",{className:"muted small",children:eX.vcs.problem&&!eX.vcs.branch?(0,n.jsx)("span",{className:"reason",children:e2("vcs.taskProblem",{problem:eX.vcs.problem})}):(0,n.jsxs)(n.Fragment,{children:[eX.vcs.branch&&e2("vcs.taskBranch",{branch:eX.vcs.branch}),eX.vcs.baseCommit&&" \xb7 ".concat(e2("vcs.taskBase",{commit:eX.vcs.baseCommit.slice(0,8)})),eX.vcs.commit?" \xb7 ".concat(e2("vcs.taskCommit",{commit:eX.vcs.commit.slice(0,8)})):" \xb7 ".concat(e2("vcs.taskNoFiles")),(null!=(eo=null==(m=eX.vcs.files)?void 0:m.length)?eo:0)>0&&(0,n.jsxs)("details",{style:{display:"inline"},children:[(0,n.jsxs)("summary",{style:{display:"inline",cursor:"pointer"},children:[" \xb7 ",e2("vcs.taskFiles",{n:null!=(eh=null==(p=eX.vcs.files)?void 0:p.length)?eh:0})]}),(0,n.jsx)("ul",{style:{margin:"4px 0 4px 0",paddingLeft:20},children:(null!=(eu=eX.vcs.files)?eu:[]).map(e=>(0,n.jsxs)("li",{children:[(0,n.jsx)("code",{children:e.path})," ",e.added<0||e.removed<0?e2("vcs.taskBinary"):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{style:{color:"var(--ok)"},children:["+",e.added]})," ",(0,n.jsxs)("span",{style:{color:"var(--bad)"},children:["-",e.removed]})]})]},e.path))})]}),eX.vcs.commit&&eX.vcs.baseCommit&&(0,n.jsxs)(n.Fragment,{children:[" \xb7 ",(0,n.jsx)(f.C,{sessionId:eV.id,taskId:eX.id,title:eX.title,files:null!=(em=null==(v=eX.vcs.files)?void 0:v.length)?em:0})]}),(null!=(ep=null==(y=eX.vcs.suspicious)?void 0:y.length)?ep:0)>0&&(0,n.jsxs)("div",{className:"err small",style:{marginTop:4},children:[e2("vcs.suspicious",{n:null!=(ev=null==(k=eX.vcs.suspicious)?void 0:k.length)?ev:0}),(0,n.jsx)("ul",{style:{margin:"4px 0",paddingLeft:20},children:(null!=(ex=eX.vcs.suspicious)?ex:[]).map(e=>(0,n.jsxs)("li",{children:[(0,n.jsx)("code",{children:e.path})," — ",e.reason]},e.path))})]}),(null!=(ej=null==(w=eX.scopeReverted)?void 0:w.length)?ej:0)>0&&(0,n.jsx)("div",{className:"small",style:{marginTop:4},children:e2(eX.readOnly?"task.readOnlyReverted":"task.scopeReverted",{n:null!=(eg=null==(C=eX.scopeReverted)?void 0:C.length)?eg:0,paths:(null!=(ef=eX.scopeReverted)?ef:[]).join(", ")})}),(null!=(ey=null==(F=eX.inputsRestored)?void 0:F.length)?ey:0)>0&&(0,n.jsx)("div",{className:"small",style:{marginTop:4},children:e2("task.inputsRestored",{n:null!=(eb=null==(I=eX.inputsRestored)?void 0:I.length)?eb:0,paths:(null!=(ek=eX.inputsRestored)?ek:[]).join(", ")})}),(null!=(eN=null==(T=eX.artifactsKept)?void 0:T.length)?eN:0)>0&&(0,n.jsx)("div",{className:"muted small",style:{marginTop:4,overflowWrap:"anywhere"},children:e2("task.artifactsKept",{n:null!=(ew=null==(M=eX.artifactsKept)?void 0:M.length)?ew:0,paths:(null!=(eS=eX.artifactsKept)?eS:[]).slice(0,10).map(e=>e.path).join(", ")})}),(null!=(eC=null==(W=eX.vcs.foreignCommits)?void 0:W.length)?eC:0)>0&&(0,n.jsxs)("div",{className:"err small",style:{marginTop:4},children:[e2("vcs.foreignCommits",{n:null!=(eF=null==(O=eX.vcs.foreignCommits)?void 0:O.length)?eF:0}),(0,n.jsx)("ul",{style:{margin:"4px 0",paddingLeft:20},children:(null!=(eI=eX.vcs.foreignCommits)?eI:[]).map(e=>(0,n.jsx)("li",{children:(0,n.jsx)("code",{children:e})},e))})]})]})}),"queued"===eX.status&&(null==(B=eV.vcs)?void 0:B.enabled)&&((null==(H=eX.vcsPlan)?void 0:H.branch)||(null==(P=eX.vcsPlan)?void 0:P.commitMessage))&&(0,n.jsx)("div",{className:"muted small",children:eX.vcsPlan.branch&&eX.vcsPlan.commitMessage?e2("task.gitNames",{branch:eX.vcsPlan.branch,subject:eX.vcsPlan.commitMessage.split("\n")[0]}):eX.vcsPlan.branch?e2("task.gitBranchOnly",{branch:eX.vcsPlan.branch}):e2("task.gitCommitOnly",{subject:(null!=(eT=eX.vcsPlan.commitMessage)?eT:"").split("\n")[0]})}),sk&&(0,n.jsx)(S.y,{target:{sessionId:eV.id,taskId:eX.id,title:eX.title},onApplied:(e,s)=>{e1(),0===e&&(sN(!1),sb({intro:"".concat(s," ").concat(e2("runq.savedOffer"))}))}}),sy&&"queued"===eX.status&&(0,n.jsx)(S.f,{target:{sessionId:eV.id,taskId:eX.id,title:eX.title},intro:sy.intro,checkContract:!sk,onClose:e=>{sb(null),e&&e1()}}),e3&&eX.runId&&(0,n.jsx)(x.P,{sessionId:eV.id,taskId:eX.id,live:"running"===eX.status||"waiting-approval"===eX.status}),e4?(0,n.jsxs)("div",{style:{marginTop:8},children:[(0,n.jsx)("label",{children:e2("form.titleLabel")}),(0,n.jsx)("input",{type:"text",value:e7,onChange:e=>e9(e.target.value)}),(0,n.jsx)("div",{style:{marginTop:8},children:(0,n.jsx)(R,{value:se,onChange:ss,presets:e0})}),(0,n.jsx)("label",{children:e2("form.taskLabel")}),(0,n.jsx)("textarea",{className:"prose",value:sa,onChange:e=>sn(e.target.value)}),(null==(D=eV.vcs)?void 0:D.enabled)&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("label",{htmlFor:"branch-".concat(eX.id),children:e2("task.branch")}),(0,n.jsx)("input",{id:"branch-".concat(eX.id),type:"text",value:st,onChange:e=>sl(e.target.value),placeholder:eV.vcs.branchPrefix,disabled:"per-session"===eV.vcs.branchMode}),(0,n.jsx)("p",{className:"why",children:"per-session"===eV.vcs.branchMode?e2("task.branchIgnored"):e2("task.branchWhy")}),(0,n.jsx)("label",{htmlFor:"commit-".concat(eX.id),children:e2("task.commitMessage")}),(0,n.jsx)("textarea",{id:"commit-".concat(eX.id),value:si,onChange:e=>sr(e.target.value),style:{minHeight:70}}),(0,n.jsx)("p",{className:"why",children:e2("task.commitWhy")})]}),(0,n.jsx)(q,{checks:sc,onChange:sd}),sa.trim()!==eX.prompt.trim()&&(0,n.jsx)("p",{className:"notice caution small",children:e2("task.newIntentNote")}),(0,n.jsx)(N.y,{readOnly:so,scope:su,onReadOnly:sh,onScope:sm}),(0,n.jsxs)("div",{className:"row",style:{marginTop:8},children:[(0,n.jsx)("button",{className:"primary",onClick:()=>void(sC?sO():sw()),children:sC?e2("task.saveAndRerun"):e2("task.save")}),(0,n.jsx)("span",{className:"err",children:sg})]}),sC&&(0,n.jsx)("p",{className:"muted small",children:e2("task.editRanWhy")})]}):(0,n.jsxs)(n.Fragment,{children:[(null!=(eM=null==(A=eX.checks)?void 0:A.length)?eM:0)>0&&(0,n.jsxs)("details",{className:"small",style:{margin:"6px 0"},children:[(0,n.jsxs)("summary",{children:[e2("checks.title")," — ",e2("checks.n",{n:null!=(eW=null==(E=eX.checks)?void 0:E.length)?eW:0}),(null!=(eO=null==(U=eX.checkResults)?void 0:U.length)?eO:0)>0&&" \xb7 ".concat((null!=(eB=eX.checkResults)?eB:[]).filter(e=>e.passed).length,"/").concat(null==(Z=eX.checkResults)?void 0:Z.length," ").concat(e2("checks.passed"))]}),(0,n.jsx)("ul",{style:{margin:"6px 0",paddingLeft:20},children:(null!=(eH=eX.checks)?eH:[]).map((e,s)=>{var a;let t=(null!=(a=eX.checkResults)?a:[]).find(s=>s.name===e.name);return(0,n.jsxs)("li",{children:[(0,n.jsx)("strong",{children:e.name}),(0,n.jsxs)("span",{className:"muted",children:[" — ",e2("checks.kind.".concat(e.expect)),e.value?' "'.concat(e.value,'"'):"",e.run?": ".concat(e.run):e.file?": ".concat(e.file):""]}),t&&(0,n.jsxs)("div",{className:t.passed?"muted":"reason",children:[t.passed?e2("checks.passed"):e2("checks.failed")," — ",t.detail]})]},"".concat(e.name,"-").concat(s))})})]}),(null!=(eR=null==(K=eX.reviewChecks)?void 0:K.length)?eR:0)>0&&(0,n.jsxs)("details",{className:"small",style:{margin:"6px 0"},children:[(0,n.jsx)("summary",{children:e2("checks.fromReview",{n:null!=(eP=null==(_=eX.reviewChecks)?void 0:_.length)?eP:0})}),(0,n.jsx)("p",{className:"why",children:e2("checks.fromReviewWhy")}),(0,n.jsx)("ul",{style:{margin:"6px 0",paddingLeft:20},children:(null!=(eL=eX.reviewChecks)?eL:[]).map(e=>{var s;let a=(null!=(s=eX.checkResults)?s:[]).find(s=>s.name===e.check.name);return(0,n.jsxs)("li",{children:[(0,n.jsx)("code",{children:e.findingId})," ",(0,n.jsx)("strong",{children:e.check.name}),"active"!==e.state&&(0,n.jsx)("span",{className:"chip",style:{marginLeft:6},children:e2("checks.state.".concat(e.state))}),(0,n.jsx)("div",{className:"muted",children:e.what}),a&&(0,n.jsxs)("div",{className:a.passed?"muted":"reason",children:[a.passed?e2("checks.passed"):e2("checks.failed")," — ",a.detail]})]},"".concat(e.attempt,":").concat(e.findingId,":").concat(e.check.name))})})]}),(0,n.jsx)(G,{review:eX.review}),eX.stopCode&&!(0,h.DG)(eX)&&(0,n.jsx)("p",{className:"small",children:(0,n.jsx)("span",{className:"chip",title:e2("stop.why"),children:e2("stop.".concat(eX.stopCode))})}),eX.handoff&&!(0,h.DG)(eX)&&(0,n.jsx)(L,{handoff:eX.handoff}),eX.summary&&(0,n.jsxs)("div",{className:"summary",children:[(0,n.jsx)("strong",{children:e2("task.whatWasDone")}),(0,n.jsx)(j.s,{text:eX.summary})]}),(null!=(eD=null==(Y=eX.deviations)?void 0:Y.length)?eD:0)>0&&(0,n.jsx)(J,{items:null!=(eA=eX.deviations)?eA:[]}),(null!=(eE=null==(Q=eX.disputes)?void 0:Q.length)?eE:0)>0&&(0,n.jsx)(z,{items:null!=(eq=eX.disputes)?eq:[]}),eX.environment&&(0,n.jsx)("div",{className:"muted small",style:{margin:"4px 0"},children:e2("task.ranWith",{node:eX.environment.node,npm:null!=(eU=eX.environment.npm)?eU:"—",git:null!=(eJ=eX.environment.git)?eJ:"—",pwsh:null!=(eG=null!=(ez=eX.environment.pwsh)?ez:eX.environment.powershell)?eG:"—"})}),(null!=(eZ=null==(V=eX.leftovers)?void 0:V.length)?eZ:0)>0&&(0,n.jsxs)("div",{className:"err small",style:{margin:"6px 0"},children:[e2("task.leftovers",{n:null!=(eK=null==(X=eX.leftovers)?void 0:X.length)?eK:0}),(0,n.jsx)("ul",{style:{margin:"4px 0",paddingLeft:20},children:(null!=(e_=eX.leftovers)?e_:[]).map(e=>(0,n.jsxs)("li",{children:[(0,n.jsx)("code",{children:e.name})," pid ",e.pid,e.ports.length>0?" \xb7 ".concat(e2("task.leftoverPorts",{ports:e.ports.join(", ")})):""," \xb7 ",e.by]},"".concat(e.by,"-").concat(e.pid)))})]}),eX.reason&&(0,n.jsx)("div",{className:"reason small",style:{margin:"6px 0"},children:eX.reason}),(null!=(eY=null==($=eX.attempts)?void 0:$.length)?eY:0)>0&&(0,n.jsxs)("details",{children:[(0,n.jsx)("summary",{children:e2("task.attempts",{n:null!=(eQ=null==(ee=eX.attempts)?void 0:ee.length)?eQ:0})}),null==(es=eX.attempts)?void 0:es.map((e,s)=>{var a,t,l,i;return(0,n.jsxs)("div",{className:"small",style:{margin:"8px 0 12px"},children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("strong",{children:e2("task.attemptN",{n:s+1})}),(0,n.jsx)("span",{className:"badge ".concat(e.status),children:e2("status.".concat(e.status))}),e.iterations>0&&(0,n.jsx)("span",{className:"muted",children:e2("task.iterations",{n:e.iterations})}),e.runId&&(0,n.jsx)(o.u,{label:e2("save.attemptLog"),save:()=>c.FH.saveTaskLog(eV.id,eX.id,e.runId)}),e.runId&&(0,n.jsx)(o.H,{sessionId:eV.id,taskId:eX.id,attempt:s+1}),e.runId&&(null==(a=e.vcs)?void 0:a.commit)&&e.vcs.baseCommit&&(0,n.jsx)(f.C,{sessionId:eV.id,taskId:eX.id,runId:e.runId,title:"".concat(eX.title," — ").concat(e2("task.attemptN",{n:s+1})),files:null!=(l=null==(t=e.vcs.files)?void 0:t.length)?l:0})]}),(0,n.jsxs)("div",{className:"muted",children:[e.startedAt?e2("task.started",{t:e8(e.startedAt)}):"",e.finishedAt?" \xb7 ".concat(e2("task.finished",{t:e8(e.finishedAt)})):""]}),e.summary&&(0,n.jsx)("div",{children:e.summary}),e.reason&&(0,n.jsx)("div",{className:"err",children:e.reason}),e.prompt&&e.prompt!==eX.prompt&&(0,n.jsxs)("details",{children:[(0,n.jsx)("summary",{children:e2("task.attemptText")}),(0,n.jsx)("pre",{children:e.prompt})]})]},"".concat(null!=(i=e.runId)?i:s))})]}),"queued"===eX.status?(0,n.jsxs)("div",{style:{marginTop:8},children:[(0,n.jsx)("div",{className:"muted small",children:e2("task.prompt")}),(0,n.jsx)("pre",{children:eX.prompt}),eX.level2.trim()?(0,n.jsxs)("details",{children:[(0,n.jsx)("summary",{children:e2("task.l2Show",{n:eX.level2.trim().split("\n").length})}),(0,n.jsx)("pre",{children:eX.level2})]}):(0,n.jsx)("div",{className:"muted small",children:e2("task.noL2")})]}):(0,n.jsxs)("details",{children:[(0,n.jsx)("summary",{children:e2("task.promptAndL2")}),eX.level2.trim()&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"muted small",children:e2("task.l2")}),(0,n.jsx)("pre",{children:eX.level2})]}),(0,n.jsx)("div",{className:"muted small",children:e2("task.prompt")}),(0,n.jsx)("pre",{children:eX.prompt})]}),eX.firstMessage&&(0,n.jsxs)("details",{children:[(0,n.jsx)("summary",{children:e2("task.firstMessage")}),(0,n.jsx)("pre",{className:"tall",children:eX.firstMessage})]}),eX.runId&&(0,n.jsxs)("details",{onToggle:e=>e.currentTarget.open&&void sR(),children:[(0,n.jsx)("summary",{children:e2("task.files")}),(0,n.jsx)("div",{className:"row small",style:{margin:"6px 0"},children:(0,n.jsx)(o.u,{label:e2("save.log"),save:()=>c.FH.saveTaskLog(eV.id,eX.id)})}),sx&&(0,n.jsxs)("div",{className:"small",children:[sP("task.reports","reports",sx.reports),sP("task.artifacts","artifacts",sx.artifacts),sP("task.replies","replies",sx.replies)]})]}),eX.finalReply&&(0,n.jsxs)("details",{children:[(0,n.jsx)("summary",{children:e2("task.finalReply")}),(0,n.jsx)("pre",{className:"tall",children:eX.finalReply})]})]})]})}function E(e){let{events:s}=e,{t:a}=(0,d.kj)(),{appearance:l}=(0,m.KP)(),i=(0,t.useRef)(null);return(0,t.useEffect)(()=>{!l.reduceMotion&&i.current&&(i.current.scrollTop=i.current.scrollHeight)},[s.length,l.reduceMotion]),(0,n.jsxs)("div",{className:"panel",children:[(0,n.jsx)("h2",{children:a("live.title")}),(0,n.jsxs)("div",{className:"log",ref:i,children:[0===s.length&&(0,n.jsx)("div",{className:"muted",children:a("live.none")}),s.map((e,s)=>{var a;return(0,n.jsxs)("div",{className:e.level,children:[(0,n.jsx)("span",{className:"time",children:new Date(e.at).toLocaleTimeString(void 0,{hour12:!1})}),null!=(a=e.message)?a:e.type]},s)})]})]})}function q(e){let{checks:s,onChange:a}=e,{t}=(0,d.kj)(),l=(e,n)=>a(s.map((s,a)=>e===a?{...s,...n}:s));return(0,n.jsxs)("div",{style:{marginTop:12},children:[(0,n.jsx)("label",{children:t("checks.title")}),(0,n.jsx)("p",{className:"why",style:{marginTop:0},children:t("checks.why")}),0===s.length&&(0,n.jsx)("p",{className:"muted small",children:t("checks.noneWhy")}),s.map((e,i)=>{var r,d,o,h;return(0,n.jsxs)("div",{className:"option",children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("input",{type:"text",className:"grow",value:e.name,placeholder:t("checks.namePlaceholder"),onChange:e=>l(i,{name:e.target.value}),"aria-label":t("checks.name")}),(0,n.jsx)("select",{value:e.expect,onChange:e=>l(i,{expect:e.target.value}),"aria-label":t("checks.kind"),style:{width:"auto"},children:c.FZ.map(e=>(0,n.jsx)("option",{value:e,children:t("checks.kind.".concat(e))},e))}),(0,n.jsx)("button",{className:"quiet",onClick:()=>a(s.filter((e,s)=>s!==i)),children:t("checks.remove")})]}),(0,n.jsxs)("div",{className:"row",style:{marginTop:6},children:[(0,c.rt)(e.expect)?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("input",{type:"text",className:"grow",value:null!=(r=e.run)?r:"",placeholder:t("checks.run"),onChange:e=>l(i,{run:e.target.value}),"aria-label":t("checks.run")}),(0,n.jsx)("input",{type:"text",value:null!=(d=e.cwd)?d:"",placeholder:t("checks.cwd"),onChange:e=>l(i,{cwd:e.target.value}),"aria-label":t("checks.cwd"),style:{width:220}})]}):(0,n.jsx)("input",{type:"text",className:"grow",value:null!=(o=e.file)?o:"",placeholder:t("checks.file"),onChange:e=>l(i,{file:e.target.value}),"aria-label":t("checks.file")}),(0,c.dK)(e.expect)&&(0,n.jsx)("input",{type:"text",value:null!=(h=e.value)?h:"",placeholder:"output-matches"===e.expect?t("checks.valueRegex"):t("checks.value"),onChange:e=>l(i,{value:e.target.value}),"aria-label":t("checks.value"),style:{width:240}})]})]},i)}),(0,n.jsx)("button",{onClick:()=>a([...s,{name:"",expect:"exit-zero",run:""}]),children:t("checks.add")})]})}function U(e){let{tasks:s}=e,{t:a}=(0,d.kj)(),t=(0,h.hH)(s),l=(0,u.c)(!!t&&t.tasks.some(h.DG));if(!t)return null;let i=(0,h.eZ)(t.run,t.tasks,l);return(0,n.jsx)("p",{className:"muted small",style:{margin:"4px 0 10px"},children:a(i.live?"session.runClockLive":"session.runClock",{n:i.tasks,d:(0,c.c5)(i.ms)})})}function J(e){let{items:s}=e,{t:a}=(0,d.kj)();return(0,n.jsxs)("div",{className:"summary",children:[(0,n.jsx)("strong",{children:a("task.deviations",{n:s.length})}),(0,n.jsx)("ol",{style:{margin:"6px 0",paddingLeft:20},children:s.map((e,s)=>(0,n.jsxs)("li",{style:{marginBottom:6},children:[(0,n.jsx)("div",{children:e.instruction}),(0,n.jsxs)("div",{className:"muted",children:[a("task.deviationDid"),": ",e.did]}),(0,n.jsxs)("div",{className:"muted",children:[a("task.deviationWhy"),": ",e.why]})]},s))})]})}function z(e){let{items:s}=e,{t:a}=(0,d.kj)();return(0,n.jsxs)("div",{className:"summary",children:[(0,n.jsx)("strong",{children:a("task.disputes",{n:s.length})}),(0,n.jsx)("ol",{style:{margin:"6px 0",paddingLeft:20},children:s.map((e,s)=>(0,n.jsxs)("li",{style:{marginBottom:6},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("code",{children:e.finding})," — ",e.why]}),(0,n.jsxs)("div",{className:"muted",children:[a("review.evidence"),": ",e.evidence]})]},s))})]})}function G(e){var s,a,t,l,i;let{review:r}=e,{t:c}=(0,d.kj)();if(!r)return null;if("skipped"===r.verdict)return r.skippedBecause?(0,n.jsx)("p",{className:"muted small",children:c("review.skippedWhy",{why:r.skippedBecause})}):null;let o="pass"===r.verdict?"done":"fail"===r.verdict?"blocked":"waiting-approval";return(0,n.jsxs)("div",{className:"small",style:{margin:"8px 0"},children:[(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("span",{className:"badge ".concat(o),children:c("review.verdict.".concat(r.verdict))}),r.stepsRun>0&&(0,n.jsx)("span",{className:"muted",children:c("review.ran",{n:r.stepsRun})}),r.rounds>1&&(0,n.jsx)("span",{className:"muted",children:c("review.rounds",{n:r.rounds})}),r.model&&(0,n.jsx)("span",{className:"chip",children:c("review.onModel",{model:r.model})})]}),r.problem&&(0,n.jsx)("p",{className:"reason",children:c("review.problem",{problem:r.problem})}),r.summary&&(0,n.jsx)(j.s,{text:r.summary}),(null!=(t=null==(s=r.findings)?void 0:s.length)?t:0)>0&&(0,n.jsxs)("details",{style:{marginTop:4},children:[(0,n.jsx)("summary",{children:c("review.findings",{n:null!=(l=null==(a=r.findings)?void 0:a.length)?l:0})}),(0,n.jsx)("ol",{style:{margin:"6px 0",paddingLeft:20},children:(null!=(i=r.findings)?i:[]).map((e,s)=>(0,n.jsxs)("li",{style:{marginBottom:8},children:[(0,n.jsxs)("div",{children:[e.id&&(0,n.jsx)("code",{style:{marginRight:6},children:e.id}),e.what,"task"===e.about&&(0,n.jsx)("span",{className:"chip",style:{marginLeft:6},children:c("review.aboutTask")}),e.repeated&&(0,n.jsx)("span",{className:"chip",style:{marginLeft:6},children:c("review.repeated")})]}),e.where&&(0,n.jsx)("div",{className:"muted",children:e.where}),(0,n.jsxs)("div",{className:"muted",children:[c("review.evidence"),": ",e.evidence]})]},s))})]})]})}},4784:(e,s,a)=>{"use strict";a.d(s,{Y:()=>r});var n=a(3365),t=a(1521),l=a(5549),i=a(867);function r(e){var s,a,r;let{id:c,chosen:d,onChange:o,none:h,catalogue:u,disabled:m=!1,style:p}=e,{t:v}=(0,i.kj)(),x=function(e){let[s,a]=(0,t.useState)(null);return(0,t.useEffect)(()=>{if(void 0!==e)return;let s=!0;return l.FH.models().then(e=>{s&&a(e)}).catch(()=>void 0),()=>{s=!1}},[e]),void 0!==e?e:s}(u),j=null!=(s=null==x?void 0:x.options)?s:[],g=e=>e.toLowerCase().replace(/[-‐‑‒–—_]+/g," ").replace(/\s+/g," ").trim(),f=d?j.find(e=>g(e.name)===g(d)):void 0,y=null!=(a=null==f?void 0:f.name)?a:d,b=!!f,k=j.filter(e=>!e.group),N=new Map;for(let e of j)e.group&&N.set(e.group,[...null!=(r=N.get(e.group))?r:[],e]);return(0,n.jsxs)("select",{id:c,value:y,onChange:e=>o(e.target.value),disabled:m,style:{width:"auto",minWidth:280,...p},children:[(0,n.jsx)("option",{value:"",children:h}),d&&!b&&(0,n.jsx)("option",{value:d,children:v("model.notInList",{name:d})}),k.map(e=>(0,n.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(v("model.unavailable")):""]},e.name)),[...N.entries()].map(e=>{let[s,a]=e;return(0,n.jsx)("optgroup",{label:s,children:a.map(e=>(0,n.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(v("model.unavailable")):""]},e.name))},s)})]})}},8078:(e,s,a)=>{"use strict";a.d(s,{AppearanceProvider:()=>o,KP:()=>h});var n=a(3365),t=a(1521);let l="cop.appearance",i=["small","normal","large","huge","giant"];"\n(function () {\n try {\n var d = document.documentElement;\n var raw = localStorage.getItem('".concat(l,"');\n var a = raw ? JSON.parse(raw) : {};\n if (!a || typeof a !== 'object') a = {};\n d.dataset.theme = a.theme === 'dark' ? 'dark' : 'light';\n d.dataset.textsize = ").concat(JSON.stringify(i),".indexOf(a.textSize) >= 0 ? a.textSize : 'normal';\n d.dataset.contrast = a.highContrast ? 'high' : 'normal';\n d.dataset.motion = a.reduceMotion ? 'reduced' : 'normal';\n d.dataset.links = a.underlineLinks ? 'underline' : 'plain';\n d.dataset.focus = a.strongFocus ? 'strong' : 'normal';\n } catch (e) {}\n})();\n");let r={theme:"light",textSize:"normal",highContrast:!1,reduceMotion:!1,underlineLinks:!1,strongFocus:!1};function c(e){let s=document.documentElement;s.dataset.theme=e.theme,s.dataset.textsize=e.textSize,s.dataset.contrast=e.highContrast?"high":"normal",s.dataset.motion=e.reduceMotion?"reduced":"normal",s.dataset.links=e.underlineLinks?"underline":"plain",s.dataset.focus=e.strongFocus?"strong":"normal"}let d=(0,t.createContext)({appearance:r,set:()=>void 0,reset:()=>void 0,loaded:!1});function o(e){let{children:s}=e,[a,o]=(0,t.useState)(r),[h,u]=(0,t.useState)(!1);(0,t.useEffect)(()=>{let e=r;try{let s=window.localStorage.getItem(l);s?e=function(e){let s=e&&"object"==typeof e?e:{},a=(e,s)=>"boolean"==typeof e?e:s;return{theme:"dark"===s.theme?"dark":"light"===s.theme?"light":r.theme,textSize:i.includes(s.textSize)?s.textSize:r.textSize,highContrast:a(s.highContrast,r.highContrast),reduceMotion:a(s.reduceMotion,r.reduceMotion),underlineLinks:a(s.underlineLinks,r.underlineLinks),strongFocus:a(s.strongFocus,r.strongFocus)}}(JSON.parse(s)):window.matchMedia("(prefers-color-scheme: dark)").matches&&(e={...e,theme:"dark"}),window.matchMedia("(prefers-reduced-motion: reduce)").matches&&!s&&(e={...e,reduceMotion:!0})}catch(e){}o(e),c(e),u(!0)},[]);let m=(0,t.useCallback)(e=>{o(s=>{let a={...s,...e};c(a);try{window.localStorage.setItem(l,JSON.stringify(a))}catch(e){}return a})},[]),p=(0,t.useCallback)(()=>{o(r),c(r);try{window.localStorage.removeItem(l)}catch(e){}},[]);return(0,n.jsx)(d.Provider,{value:{appearance:a,set:m,reset:p,loaded:h},children:s})}function h(){return(0,t.useContext)(d)}},8596:(e,s,a)=>{"use strict";a.d(s,{E:()=>r});var n=a(3365),t=a(1521),l=a(5549),i=a(867);function r(e){var s,a,r,c,d,o,h;let{dir:u,onDone:m}=e,{t:p}=(0,i.kj)(),v=(0,i.W3)(),[x,j]=(0,t.useState)(null),[g,f]=(0,t.useState)(""),[y,b]=(0,t.useState)(""),[k,N]=(0,t.useState)(""),[w,S]=(0,t.useState)(!1),C=e=>(null!=e?e:"—").slice(0,8),F=async e=>{b(""),N(""),f(e?"fetch":"prepare");try{j(await l.FH.preparePreview(u,e))}catch(e){b(e.message)}finally{f("")}},I=async()=>{if(null==x?void 0:x.fingerprint){b(""),f("prepare");try{var e,s;let a=await l.FH.prepareProject(u,x.fingerprint,{savedBranch:x.savedBranch,savedMainBranch:x.savedMainBranch});a.ok?(N(null!=(s=a.result)?s:""),j(null),null==m||m()):b(null!=(e=a.problem)?e:"")}catch(e){b(e.message)}finally{f("")}}},T=async e=>{try{await navigator.clipboard.writeText(e),S(!0),window.setTimeout(()=>S(!1),2500)}catch(e){b(p("plan.copyFailed"))}},M=e=>(0,n.jsxs)("ul",{style:{margin:"2px 0 6px",paddingLeft:20},children:[e.slice(0,30).map(e=>(0,n.jsx)("li",{children:(0,n.jsx)("code",{children:e})},e)),e.length>30&&(0,n.jsx)("li",{className:"muted",children:p("prep.more",{n:e.length-30})})]}),W=x&&!x.ok&&x.fetched&&!x.fetched.ok;return(0,n.jsxs)("div",{className:"prepare-folder small",style:{marginTop:8,overflowWrap:"anywhere"},children:[(0,n.jsx)("button",{type:"button",onClick:()=>void F(!0),disabled:!!g,children:p("prep.show")}),(0,n.jsx)("p",{className:"why",children:p("prep.why")}),(0,n.jsx)("p",{className:"why",children:p("prep.password")}),"fetch"===g&&(0,n.jsx)("p",{role:"status",children:p("prep.fetching")}),y&&(0,n.jsx)("p",{className:"err",role:"alert",children:y}),k&&(0,n.jsx)("p",{className:"notice",role:"status",children:k}),x&&!x.ok&&!W&&(0,n.jsx)("p",{className:"err",children:x.problem}),W&&(0,n.jsxs)("div",{className:"notice caution",style:{marginTop:8},children:[(0,n.jsxs)("p",{children:[(0,n.jsx)("strong",{children:p("prep.fetchFailed")})," ",(0,n.jsx)("code",{children:null==(s=x.fetched)?void 0:s.detail})]}),(null==(a=x.fetched)?void 0:a.auth)&&(0,n.jsx)("p",{children:p("prep.fetchAuth")}),(0,n.jsx)("div",{className:"row",children:(0,n.jsx)("button",{type:"button",onClick:()=>void F(!0),disabled:!!g,children:p("prep.retry")})}),x.fetchCommand&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{style:{marginTop:8},children:p("prep.ownTerminal")}),(0,n.jsx)("pre",{className:"sync-cmd",children:x.fetchCommand}),(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("button",{type:"button",onClick:()=>{var e;T(null!=(e=x.fetchCommand)?e:"")},children:p("prep.copyFetch")}),w&&(0,n.jsx)("span",{className:"badge done",children:p("prep.copied")}),(0,n.jsx)("button",{type:"button",onClick:()=>void F(!1),disabled:!!g,children:p("prep.useFetched")})]}),x.lastFetched&&(0,n.jsx)("p",{className:"muted",children:p("prep.lastFetched",{when:v(x.lastFetched)})})]})]}),(null==x?void 0:x.ok)&&(0,n.jsxs)("div",{className:"notice caution",style:{marginTop:8},children:[(0,n.jsx)("p",{children:p("prep.where",{target:null!=(r=x.target)?r:"",commit:C(x.targetCommit),branch:null!=(c=x.branch)?c:"HEAD",head:C(x.head)})}),!x.fetched&&(0,n.jsxs)("p",{className:"muted",children:[p("prep.notFetched")," ",x.lastFetched?p("prep.lastFetched",{when:v(x.lastFetched)}):p("prep.lastFetchedUnknown")]}),x.alreadyThere?(0,n.jsx)("p",{children:p("prep.already")}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("strong",{children:p("prep.willDo")}),(0,n.jsxs)("ol",{style:{margin:"4px 0",paddingLeft:20},children:[x.savedBranch&&(0,n.jsxs)("li",{children:[p("prep.keepChanges",{changed:x.changed.length,untracked:x.untracked.length,saved:x.savedBranch}),M([...x.changed,...x.untracked])]}),x.savedMainBranch&&(0,n.jsxs)("li",{children:[p("prep.keepMain",{n:x.mainOnlyCommits.length,branch:null!=(d=x.localBranch)?d:"",saved:x.savedMainBranch}),M(x.mainOnlyCommits)]}),(0,n.jsx)("li",{children:p("prep.moveTo",{branch:null!=(o=x.localBranch)?o:"",commit:C(x.targetCommit),target:null!=(h=x.target)?h:""})})]}),x.branchOnlyCommits.length>0&&x.branch&&(0,n.jsx)("p",{children:p("prep.branchStays",{branch:x.branch,n:x.branchOnlyCommits.length})}),(0,n.jsx)("p",{className:"muted",children:p("prep.ignored")}),(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("button",{type:"button",className:"primary",onClick:()=>void I(),disabled:!!g,children:p("prep.confirm")}),(0,n.jsx)("button",{type:"button",className:"quiet",onClick:()=>j(null),disabled:!!g,children:p("prep.cancel")})]})]})]})]})}},8848:(e,s,a)=>{"use strict";a.d(s,{H4:()=>d,L:()=>o,z4:()=>h});var n=a(3365),t=a(8197),l=a.n(t),i=a(1521),r=a(5549),c=a(867);function d(e){let{current:s,onUse:a}=e,{t}=(0,c.kj)(),[l,d]=(0,i.useState)(null);if((0,i.useEffect)(()=>{let e=!1;return r.FH.project().then(s=>{e||d(s)}).catch(()=>void 0),()=>{e=!0}},[]),!l)return null;let o=l.rootDir.trim(),h=s.trim().toLowerCase(),u=a?l.others.filter(e=>e.rootDir.trim().toLowerCase()!==h):[];return(0,n.jsx)(m,{label:o?t("proj.defaultIs",{dir:o}):t("proj.noneShort"),offer:o&&a&&h!==o.toLowerCase()?{text:t("proj.useIt"),onUse:()=>a(o)}:void 0,more:u.map(e=>({text:t("proj.otherUse",{name:e.name}),title:e.rootDir,onUse:()=>null==a?void 0:a(e.rootDir)})),link:o?t("proj.change"):t("proj.setIt"),anchor:"project"})}function o(e){let{current:s,onUse:a}=e,t=u(),{t:l}=(0,c.kj)();if(!t)return null;let i=t.defaultModel.trim();return(0,n.jsx)(m,{label:i?l("def.modelDefaultIs",{name:i}):l("def.modelNoneShort"),offer:i&&a&&s.trim()!==i?{text:l("def.modelUseIt"),onUse:()=>a(i)}:void 0,link:l(i?"proj.change":"proj.setIt"),anchor:"model"})}function h(e){let{current:s,onUse:a}=e,t=u(),{t:l}=(0,c.kj)();if(!t)return null;let i=t.defaultReviewModel.trim();return(0,n.jsx)(m,{label:i?l("def.reviewDefaultIs",{name:i}):l("def.reviewNoneShort"),offer:i&&a&&s.trim()!==i?{text:l("def.modelUseIt"),onUse:()=>a(i)}:void 0,link:l(i?"proj.change":"proj.setIt"),anchor:"review"})}function u(){let[e,s]=(0,i.useState)(null);return(0,i.useEffect)(()=>{let e=!1;return r.FH.models().then(a=>{e||s(a)}).catch(()=>void 0),()=>{e=!0}},[]),e}function m(e){let{label:s,offer:a,more:t=[],link:i,anchor:r}=e;return(0,n.jsxs)("p",{className:"muted small",style:{marginTop:4},children:[s," ",a&&(0,n.jsxs)(n.Fragment,{children:["\xb7"," ",(0,n.jsx)("button",{type:"button",className:"linkish",onClick:a.onUse,children:a.text})," "]}),t.map(e=>(0,n.jsxs)("span",{children:["\xb7"," ",(0,n.jsx)("button",{type:"button",className:"linkish",onClick:e.onUse,title:e.title,children:e.text})," "]},e.text)),"\xb7 ",(0,n.jsx)(l(),{href:"/defaults#".concat(r),children:i})]})}}},e=>{e.O(0,[197,867,549,584,347,131,358],()=>e(e.s=1772)),_N_E=e.O()}]);