copilot-operator 0.1.47 → 0.1.50

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 (44) hide show
  1. package/dist/src/api/operator.controller.js +62 -0
  2. package/dist/src/api/operator.service.js +39 -0
  3. package/dist/src/plan/systemGuide.js +96 -16
  4. package/dist/src/session/taskExchange.js +230 -0
  5. package/dist/src/session/workspaceGit.js +212 -0
  6. package/dist/src/transport/chatSession.js +28 -4
  7. package/dist/web/404.html +2 -2
  8. package/dist/web/_next/static/chunks/534-56c68930a1a3c10f.js +1 -0
  9. package/dist/web/_next/static/chunks/549-c32dd718a1809d4d.js +1 -0
  10. package/dist/web/_next/static/chunks/867-0e5d0d5472bf185f.js +1 -0
  11. package/dist/web/_next/static/chunks/app/history/page-95bab4c1b1ff9339.js +1 -0
  12. package/dist/web/_next/static/chunks/app/layout-a1314921eeba8ad5.js +1 -0
  13. package/dist/web/_next/static/chunks/app/page-4d8f0851fe672925.js +1 -0
  14. package/dist/web/_next/static/chunks/app/sessions/view/{page-835d3533fdc63082.js → page-adb64f8ba3d8c06e.js} +1 -1
  15. package/dist/web/_next/static/css/{70ceb261074b139c.css → 4335e4ce269ba1ea.css} +1 -1
  16. package/dist/web/appearance.html +2 -2
  17. package/dist/web/appearance.txt +10 -10
  18. package/dist/web/defaults.html +2 -2
  19. package/dist/web/defaults.txt +10 -10
  20. package/dist/web/history.html +2 -2
  21. package/dist/web/history.txt +10 -10
  22. package/dist/web/import.html +2 -2
  23. package/dist/web/import.txt +10 -10
  24. package/dist/web/index.html +2 -2
  25. package/dist/web/index.txt +10 -10
  26. package/dist/web/level1.html +2 -2
  27. package/dist/web/level1.txt +10 -10
  28. package/dist/web/presets.html +2 -2
  29. package/dist/web/presets.txt +10 -10
  30. package/dist/web/sessions/view.html +2 -2
  31. package/dist/web/sessions/view.txt +10 -10
  32. package/dist/web/sessions.html +2 -2
  33. package/dist/web/sessions.txt +10 -10
  34. package/dist/web/system.html +2 -2
  35. package/dist/web/system.txt +10 -10
  36. package/package.json +3 -2
  37. package/dist/web/_next/static/chunks/549-8732dd2c1339bc5d.js +0 -1
  38. package/dist/web/_next/static/chunks/867-7fb52be342fa64e5.js +0 -1
  39. package/dist/web/_next/static/chunks/897-5a34109533c3da50.js +0 -1
  40. package/dist/web/_next/static/chunks/app/history/page-0bb537407fed5944.js +0 -1
  41. package/dist/web/_next/static/chunks/app/layout-485ce9395cb17998.js +0 -1
  42. package/dist/web/_next/static/chunks/app/page-ed6a5a2ff1b6285e.js +0 -1
  43. /package/dist/web/_next/static/{HT6yqFoDPOXChAZVDxshC → z74_FBfnnXW5IJCHTgTH2}/_buildManifest.js +0 -0
  44. /package/dist/web/_next/static/{HT6yqFoDPOXChAZVDxshC → z74_FBfnnXW5IJCHTgTH2}/_ssgManifest.js +0 -0
@@ -0,0 +1 @@
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:()=>q});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(1701),h=t(3523),m=t(3374),p=t(867),g=t(1910),x=t(5132);function j(){let{t:e}=(0,p.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)(x.s,{text:e("row.infoWhich"),className:"small"})]})]})}function k(e){let{onChange:s}=e,{t}=(0,p.kj)(),[l,i]=(0,a.useState)(null),[d,c]=(0,a.useState)(!1),[u,h]=(0,a.useState)(""),m=(0,a.useCallback)(async()=>{try{i(await r.FH.batch())}catch(e){}},[]);(0,o.z)(m,3e3);let g=async e=>{c(!0),h("");try{"pause"===e?await r.FH.pauseBatch():"resume"===e?await r.FH.resumeBatch():await r.FH.stopBatch(),await m(),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 g("resume"),title:t("batch.resumeWhy"),children:t("batch.resume")}):(0,n.jsx)("button",{disabled:d||l.stopping,onClick:()=>void g("pause"),title:t("batch.pauseWhy"),children:t("batch.pause")}),(0,n.jsx)("button",{className:"danger",disabled:d||l.stopping,onClick:()=>void g("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 v=t(3041),N=t(1035),f=t(6481),y=t(4811),w=t(7619),b=t(287),I=t(6983);let C=["queued","running","waiting-approval"],S=["blocked","failed","aborted","limit-reached"],F=e=>!!e.continuable;function H(e){let{run:s}=e,{t}=(0,p.kj)(),a=s.entries.some(h.DG),l=(0,m.c)(a),i=(0,h.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 A=(0,a.createContext)(new Map),R=(0,a.createContext)({runPanel:null,setRunPanel:()=>void 0}),T=(0,a.createContext)(()=>void 0);function P(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 q(){let{t:e}=(0,p.kj)(),s=(0,p.W3)(),[t,l]=(0,a.useState)(null),[i,d]=(0,a.useState)(""),[c,u]=(0,a.useState)(""),[h,m]=(0,a.useState)("flow"),[g,x]=(0,a.useState)(""),[j,v]=(0,a.useState)(""),[N,f]=(0,a.useState)(""),y=(0,a.useCallback)(async()=>{try{l(await r.FH.tasks()),u(new Date().toISOString()),d("")}catch(e){d(e.message)}},[]);(0,o.z)(y,6e3);let w=(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]),b=(0,a.useMemo)(()=>{let e=N.trim().toLowerCase();return(null!=t?t:[]).filter(s=>{var t,n;return(!g||s.sessionId===g)&&(!j||s.status===j)&&(!e||"".concat(s.title," ").concat(null!=(t=s.summary)?t:""," ").concat(null!=(n=s.reason)?n:""," ").concat(s.sessionName).toLowerCase().includes(e))})},[t,g,j,N]),F=(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=>S.includes(e.status)).length}},[t]),H=(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]),q=(0,a.useMemo)(()=>P(b),[b]),W=(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]),[M,D]=(0,a.useState)(null),V=(0,a.useMemo)(()=>({runPanel:M,setRunPanel:D}),[M]),[X,J]=(0,a.useState)(null),Q=b.filter(e=>"running"===e.status||"waiting-approval"===e.status),Y=b.filter(e=>"queued"===e.status),$=[...b.filter(e=>S.includes(e.status)&&"stop"===e.sessionOnFailure&&!e.sessionRunning&&Y.some(s=>s.sessionId===e.sessionId)),...Y].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}),ee=b.filter(e=>!C.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)}),es=""!==g||""!==j||""!==N.trim();return(0,n.jsx)(A.Provider,{value:W,children:(0,n.jsx)(R.Provider,{value:V,children:(0,n.jsxs)(T.Provider,{value:J,children:[(null==X?void 0:X.kind)==="fix-prompt"&&(0,n.jsx)(B,{entry:X.entry,offerRun:!0,onClose:e=>{J(null),e&&y()}}),(null==X?void 0:X.kind)==="follow-up"&&(0,n.jsx)(I.J,{sessionId:X.entry.sessionId,taskId:X.entry.taskId,title:X.entry.title,onClose:e=>{J(null),e&&y()}}),(null==X?void 0:X.kind)==="contract"&&(0,n.jsx)(z,{entry:X.entry,onChange:()=>void y(),onClose:e=>{J(null),e&&y()}}),(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 y(),children:e("reg.refresh")})]}),(0,n.jsx)("p",{className:"muted small",children:e("reg.hint")}),(0,n.jsx)(U,{sessions:w}),(0,n.jsxs)("div",{className:"counts",children:[(0,n.jsxs)("div",{className:"count",children:[(0,n.jsx)("div",{className:"n",children:F.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:F.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:F.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:F.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:F.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:g,onChange:e=>x(e.target.value),children:[(0,n.jsx)("option",{value:"",children:e("reg.allSessions")}),w.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:j,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:()=>m("flow"),children:e("reg.viewFlow")}),(0,n.jsx)("button",{type:"button","aria-pressed":"runs"===h,onClick:()=>m("runs"),children:e("reg.groupBy")}),(0,n.jsx)("button",{type:"button","aria-pressed":"list"===h,onClick:()=>m("list"),children:e("reg.viewList")})]})]}),es&&(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===b.length&&(0,n.jsx)("div",{className:"empty",children:e("reg.noMatch")})]}),"list"===h&&b.length>0&&(0,n.jsx)(K,{entries:[...Q,...Y,...ee]}),"runs"===h&&b.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")})]}),q.runs.map(e=>(0,n.jsxs)("section",{className:"panel",children:[(0,n.jsx)(_,{run:e}),(0,n.jsx)(O,{entries:e.entries,sizes:H,onChange:()=>void y()})]},e.id)),q.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)(O,{entries:q.loose,sizes:H,onChange:()=>void y()})]})]}),"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)(O,{entries:Q,sizes:H,onChange:()=>void y()})]}),b.length>0&&(0,n.jsxs)("div",{style:{marginBottom:12},children:[(0,n.jsx)(k,{onChange:()=>void y()}),b.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:b.filter(e=>e.interrupted&&!e.sessionRunning).length})]}),(0,n.jsx)(Z,{entries:b,onChange:()=>void y()})]}),b.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===ee.length?(0,n.jsx)("div",{className:"empty",children:e("reg.noPast")}):(0,n.jsx)(L,{entries:ee,sizes:H,onChange:()=>void y()})]}),b.length>0&&(0,n.jsx)("section",{className:"panel",children:(0,n.jsxs)(E,{count:$.length,children:[(0,n.jsx)("p",{className:"muted small",children:e("reg.upcomingHint")}),0===$.length?(0,n.jsx)("div",{className:"empty",children:e("reg.noUpcoming")}):(0,n.jsx)(O,{entries:$,upcoming:!0,sizes:H,onChange:()=>void y()})]})}),t&&t.length>0&&(0,n.jsx)(G,{refreshKey:c})]})]})})})}let W="cop.register.upcomingOpen";function E(e){let{count:s,children:t}=e,{t:l}=(0,p.kj)(),[i,r]=(0,a.useState)(()=>{try{let e=window.localStorage.getItem(W);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(W,String(s))}catch(e){}},children:(0,n.jsxs)("h2",{style:{display:"inline"},children:[l("reg.upcoming")," (",s,")"]})}),i&&t]})}function G(e){let{refreshKey:s}=e,{t}=(0,p.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 O(e){let{entries:s,upcoming:t=!1,sizes:l,onChange:o,picking:d}=e,{t:c}=(0,p.kj)(),u=(0,p.W3)(),k=(0,v.e)(null!=o?o:()=>void 0),N=(0,m.c)(s.some(h.DG)),[y,I]=(0,a.useState)(new Set),[H,P]=(0,a.useState)(null),{runPanel:q,setRunPanel:W}=(0,a.useContext)(R),E=(0,a.useContext)(T),G=(0,a.useContext)(A);return(0,n.jsx)(n.Fragment,{children:(0,n.jsx)("ol",{className:"flow",children:s.map(e=>{var s,a,m,p,v,A,R,T,O,_,L,B,z,U,X,Z,K,J,Q,Y,$,ee,es,et,en,ea,el;let ei=t&&1===e.queuePosition,er=e.runGroup?null!=(T=null==l?void 0:l.get(e.runGroup.id))?T: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)(M,{entry:e,twins:G.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&&S.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!=(O=e.deviations)?O:0)>0&&(0,n.jsx)("span",{className:"badge waiting-approval",title:c("reg.deviationsWhy"),children:c("reg.deviations",{n:null!=(_=e.deviations)?_:0})}),(null!=(L=e.disputes)?L:0)>0&&(0,n.jsx)("span",{className:"badge waiting-approval",title:c("reg.disputesWhy"),children:c("reg.disputes",{n:null!=(B=e.disputes)?B: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!=(z=null==(s=e.scope)?void 0:s.length)?z:0)>0&&(0,n.jsx)("span",{className:"chip",title:c("task.scopeWhy"),children:c("task.scope",{paths:(null!=(U=e.scope)?U:[]).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!=(J=e.autoRetries)?J:0})}),e.runGroup&&(0,n.jsx)("span",{className:"chip",title:c("reg.runTitle",{t:er,s:e.runGroup.sessions,when:u(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:u(e.startedAt)}):c("task.added",{t:u(e.createdAt)}),e.finishedAt?" \xb7 ".concat(c("task.finished",{t:u(e.finishedAt)})):"",void 0!==e.durationMs?" \xb7 ".concat(c("reg.took",{d:(0,r.c5)(e.durationMs)})):"",(0,h.DG)(e)?" \xb7 ".concat(c("task.runningFor",{d:(0,r.c5)((0,h.d5)(e.startedAt,void 0,N))})):"",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!=(Q=e.queuePosition)?Q: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==(m=e.attempts)?void 0:m.length)?$:0)===1?c("reg.attemptsOne",{n:null!=(es=e.attempt)?es:(null!=(ee=null==(p=e.attempts)?void 0:p.length)?ee:0)+1}):c("reg.attempts",{n:null!=(en=e.attempt)?en:(null!=(et=null==(v=e.attempts)?void 0:v.length)?et:0)+1,m:null!=(ea=null==(A=e.attempts)?void 0:A.length)?ea:0})}),(0,n.jsx)("ol",{className:"attempts",children:null==(R=e.attempts)?void 0:R.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)(f.CV,{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:u(s.startedAt)}):"",s.finishedAt?" \xb7 ".concat(c("task.finished",{t:u(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)(x.s,{text:s.summary,className:"what"})]},"".concat(null!=(t=s.runId)?t:s.attempt))})})]}),e.summary&&(0,n.jsx)(x.s,{text:e.summary,className:"what"}),e.reason&&(0,n.jsx)("p",{className:"what err",children:c("reg.stopped",{reason:e.reason})}),k.message&&k.messageTask===e.taskId&&(0,n.jsx)("p",{className:"what small",children:k.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)(D,{where:{session:e.sessionId,task:e.taskId}}),void 0!==e.changedFiles&&(0,n.jsx)(f.CV,{sessionId:e.sessionId,taskId:e.taskId,title:e.title,files:e.changedFiles}),(0,n.jsx)(j,{}),e.runId&&(0,n.jsxs)("button",{className:y.has(e.taskId)?"":"quiet","aria-expanded":y.has(e.taskId),onClick:()=>{let s;return s=e.taskId,I(e=>{let t=new Set(e);return t.has(s)?t.delete(s):t.add(s),t})},title:(0,h.DG)(e)?c("story.showLiveWhy"):c("story.why"),children:[(0,h.DG)(e)&&!y.has(e.taskId)&&(0,n.jsx)("span",{className:"dot","aria-hidden":"true"}),y.has(e.taskId)?c("story.hide"):(0,h.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&&!C.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")}),F(e)&&!e.sessionRunning&&!e.sessionInactive&&(0,n.jsx)("button",{className:H===e.taskId?"":"primary","aria-expanded":H===e.taskId,onClick:()=>P(H===e.taskId?null:e.taskId),title:c("reg.continueHereWhy"),children:c("reg.continueHere")}),!F(e)&&(0,r.Dh)(e)&&!e.sessionRunning&&!e.sessionInactive&&(0,n.jsx)("button",{className:"primary","aria-haspopup":"dialog",onClick:()=>E({kind:"follow-up",entry:e}),title:c("fup.buttonWhy"),children:c("fup.button")}),!F(e)&&("failed"===e.status||"blocked"===e.status)&&!e.sessionRunning&&!e.sessionInactive&&(0,n.jsx)("button",{className:H===e.taskId||"contract-conflict"===e.stopCode||(0,r.Dh)(e)?"":"primary","aria-expanded":H===e.taskId,onClick:()=>P(H===e.taskId?null:e.taskId),title:c("reg.rerunHereWhy"),children:c("reg.rerunHere")}),S.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:""!==k.busy,title:c("restore.why"),onClick:()=>void k.restore({sessionId:e.sessionId,taskId:e.taskId,title:e.title}),children:"restore"===k.busy?c("restore.checking"):c("restore.button")}),(0,n.jsx)("button",{className:"quiet",disabled:""!==k.busy,title:c("restart.why"),onClick:()=>void k.restartFrom({sessionId:e.sessionId,taskId:e.taskId,title:e.title}),children:"restart"===k.busy?c("restart.checking"):c("restart.button")})]})]}),H===e.taskId&&(F(e)||"failed"===e.status||"blocked"===e.status)&&!e.sessionRunning&&(0,n.jsx)(V,{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())}}),y.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 M(e){var s;let{entry:t,twins:a}=e,{t:l}=(0,p.kj)(),i=(0,p.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 D(e){let{where:s}=e,{t}=(0,p.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 _(e){var s;let{run:t}=e,{t:a}=(0,p.kj)(),l=(0,p.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=>S.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)(H,{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)(D,{where:{run:t.id}})]})]})}function L(e){let{entries:s,sizes:t,onChange:l}=e,{t:i}=(0,p.kj)(),o=(0,a.useMemo)(()=>P(s),[s]),[d,c]=(0,a.useState)(!1),[u,h]=(0,a.useState)(new Set),[m,g]=(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),y=[...u],w=async()=>{g(!0),v(""),j("");try{let e=await r.FH.downloadBundle(y.map(e=>{let[s,t]=e.split(":");return{sessionId:s,taskId:t}}));j(i("reg.bundleSaved",{name:e}))}catch(e){v(e.message)}finally{g(!1)}},b=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:m,onClick:()=>void w(),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)(_,{run:e})}),(0,n.jsx)(O,{entries:e.entries,sizes:t,onChange:l,picking:b})]},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)(O,{entries:o.loose,sizes:t,onChange:l,picking:b})]})]})}function B(e){let{entry:s,onClose:t,offerRun:l=!1}=e,{t:i}=(0,p.kj)(),[o,u]=(0,a.useState)(null),[h,m]=(0,a.useState)(""),[g,x]=(0,a.useState)(!1),[j,k]=(0,a.useState)(!1),[v,N]=(0,a.useState)([]),[f,y]=(0,a.useState)(new Set),[w,I]=(0,a.useState)(!1),[C,S]=(0,a.useState)(""),[F,H]=(0,a.useState)(""),A=(0,a.useRef)(null);(0,d.V)(A,!0),(0,a.useEffect)(()=>{let e=e=>{"Escape"!==e.key||e.defaultPrevented||g||document.querySelector('[role="alertdialog"]')||t(j)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[g,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:""),H(null!=(a=null==r?void 0:r.prompt)?a:"");let o=null!=(l=null==r?void 0:r.checks)?l:[];N(o),y(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&&m(s.message)}),()=>{e=!1}},[s.sessionId,s.taskId]);let R=async()=>{if(null!==o){x(!0),m("");try{await r.FH.rerunTask(s.sessionId,s.taskId,{prompt:o,checks:v.filter((e,s)=>f.has(s)),readOnly:w,scope:w?[]:(0,c.w)(C)},{buildOnFinished:"done"===s.status}),m(i("reg.fixPromptSaved",{title:s.title})),l?(k(!0),x(!1)):setTimeout(()=>t(!0),900)}catch(e){m(e.message),x(!1)}}};return(0,n.jsx)("div",{className:"modal-backdrop",role:"presentation",onClick:()=>t(j),children:(0,n.jsxs)("div",{ref:A,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:g}),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=>y(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:w,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:g,children:i("dialog.cancel")}),(0,n.jsx)("button",{type:"button",className:"primary",onClick:()=>void R(),disabled:g||null===o||!o.trim(),children:i("reg.fixPromptSave")})]})]})]})})}function z(e){let{entry:s,onChange:t,onClose:l}=e,{t:i}=(0,p.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 m={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:m,intro:"".concat(c," ").concat(i("runq.savedOffer")),focusFirst:!0,onClose:()=>l(!0)}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(b.y,{target:m,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 U(e){let{sessions:s}=e,{t}=(0,p.kj)();return(0,n.jsxs)("div",{className:"row",style:{margin:"14px 0 18px"},children:[(0,n.jsx)(i(),{href:"/sessions#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 V(e){let{entry:s,onClose:t}=e,{t:l}=(0,p.kj)(),i=(0,y.p)(),[o,d]=(0,a.useState)(!1),[c,h]=(0,a.useState)(""),[m,g]=(0,a.useState)(""),x=F(s),j=x?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"),k=async e=>{if("unattended"!==e||i||await (0,N.Z)(l("batch.unattendedConfirm",{n:1}))){d(!0),h("");try{var n,a;let i=await r.FH.suggestedRunName([s.sessionId]).then(e=>e.name).catch(()=>void 0),o=!1,d=await (0,u.L)({sessionIds:[s.sessionId],mode:e,start:async t=>(o||(x?await r.FH.continueTask(s.sessionId,s.taskId,m):await r.FH.rerunTask(s.sessionId,s.taskId),o=!0),await r.FH.startBatch([s.sessionId],e,"stop",void 0,void 0,i,[s.taskId],t))});if(!d.started&&!d.reply)return;let c=null!=(n=d.reply)?n:{started:!0};if(!d.started)return void h(l("batch.notStarted",{reason:null!=(a=c.reason)?a:""}));h(l("reg.continueHereStarted",{title:s.title})),t(!0)}catch(e){h(e.message)}finally{d(!1)}}};return(0,n.jsxs)("div",{className:"notice",role:"group","aria-label":l(x?"reg.continueHereTitle":"reg.rerunHereTitle",{title:s.title}),style:{marginTop:8},children:[(0,n.jsx)("strong",{children:l(x?"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(x?"reg.continueHereChat":"reg.rerunHereChat")}),(0,n.jsx)("li",{children:j}),(0,n.jsx)("li",{children:l(x?"reg.continueHereCount":"reg.rerunHereKept")}),(0,n.jsx)("li",{children:l("reg.continueHereAlone")})]}),x&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("label",{htmlFor:"continue-prompt-".concat(s.taskId),className:"small",children:l("reg.continueHerePrompt")}),(0,n.jsx)("textarea",{id:"continue-prompt-".concat(s.taskId),className:"prose",value:m,onChange:e=>g(e.target.value),style:{minHeight:90},disabled:o}),(0,n.jsx)("p",{className:"why",children:l("reg.continueHerePromptWhy")})]}),(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("button",{className:"primary",disabled:o,onClick:()=>void k("confirm"),title:l("reg.continueWhy"),children:l("reg.continueGo")}),(0,n.jsx)("button",{disabled:o,onClick:()=>void k("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 X(e){var s;let{entry:t}=e,{t:l}=(0,p.kj)(),i=(0,p.W3)(),r=(0,a.useContext)(A).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 Z(e){let{entries:s,onChange:t}=e,{t:l}=(0,p.kj)(),[i,o]=(0,a.useState)(!1),[d,c]=(0,a.useState)(""),[h,m]=(0,a.useState)(!1),[g,x]=(0,a.useState)(new Set),[j,k]=(0,a.useState)(null),v=s.filter(e=>"queued"===e.status&&!e.sessionInactive),f=s.filter(e=>S.includes(e.status)&&!e.sessionRunning&&!e.sessionInactive),w=s.some(e=>e.sessionRunning),b=f.filter(e=>"stop"===e.sessionOnFailure),I=f.filter(e=>"stop"!==e.sessionOnFailure),C=[...v,...f],H=C.filter(e=>g.has(e.taskId)),A=f.filter(e=>g.has(e.taskId)),R=v.filter(e=>g.has(e.taskId)),T=[...new Set([...H].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))],P=H.filter(e=>"stop"===e.sessionOnFailure).map(e=>({e,before:C.find(s=>s.sessionId===e.sessionId&&s.position<e.position&&!g.has(s.taskId))})).filter(e=>!!e.before),[q,W]=(0,a.useState)(""),E=b.length>0?l("reg.continueWithFailed",{f:b.length,n:v.length,s:T.length}):l("reg.continue",{n:v.length,s:T.length}),G=(0,y.p)(),O=async e=>{if("unattended"!==e||G||await (0,N.Z)(l("batch.unattendedConfirm",{n:T.length}))){o(!0),c("");try{var s,n;let a=new Set,i=await (0,u.L)({sessionIds:T,mode:e,start:async s=>{for(let e of A){let s="".concat(e.sessionId,"/").concat(e.taskId);a.has(s)||(F(e)?await r.FH.continueTask(e.sessionId,e.taskId):await r.FH.rerunTask(e.sessionId,e.taskId),a.add(s))}return await r.FH.startBatch(T,e,"stop",void 0,void 0,q.trim()||void 0,H.map(e=>e.taskId),s)}});if(!i.started&&!i.reply)return;let o=null!=(s=i.reply)?s:{started:!0};c(i.started?l("reg.continueStarted",{n:T.length}):l("batch.notStarted",{reason:null!=(n=o.reason)?n:""})),m(!1),t()}catch(e){c(e.message)}finally{o(!1)}}};return 0===v.length&&0===f.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:()=>{x(new Set(C.map(e=>e.taskId))),m(!0),c("");let e=[...new Set([...C].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=>W(e.name)).catch(()=>void 0)},title:l("reg.continueWhy"),children:E}),w&&(0,n.jsx)("span",{className:"muted small",children:l("reg.continueRunning")}),d&&(0,n.jsx)("span",{className:"small",children:d})]}),h&&!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:H.length,of:C.length})}),(0,n.jsx)("button",{className:"small",onClick:()=>x(new Set),disabled:0===H.length,children:l("reg.pickNone")}),(0,n.jsx)("button",{className:"small",onClick:()=>x(new Set(C.map(e=>e.taskId))),disabled:H.length===C.length,children:l("reg.pickAll")})]}),[{key:"chain",entries:b,intro:l("reg.continueChain"),fix:!0},{key:"loose",entries:I,intro:l("reg.continueIndependent"),fix:!0},{key:"queued",entries:v,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,x(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)(X,{entry:s}),F(s)&&(0,n.jsxs)("span",{className:"muted small",children:[" \xb7 ",l("reg.willContinue")]})]})," ",(0,n.jsx)("button",{className:"quiet small",onClick:()=>x(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:()=>k(s),title:l("reg.fixPromptHint"),children:l("reg.fixPrompt")})]})]},s.taskId))})]},e.key)),P.length>0&&(0,n.jsx)("div",{className:"notice caution small",style:{marginTop:6},children:P.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:q,onChange:e=>W(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:R.length,r:A.length,s:T.length})}),(0,n.jsxs)("div",{className:"row",style:{marginTop:8},children:[(0,n.jsx)("button",{className:"primary",disabled:i||0===T.length,onClick:()=>void O("unattended"),title:l("reg.continueUnattendedWhy"),children:l("reg.continueUnattended")}),(0,n.jsx)("button",{disabled:i||0===T.length,onClick:()=>void O("confirm"),title:l("reg.continueWhy"),children:l("reg.continueGo")}),(0,n.jsx)("button",{className:"quiet",disabled:i,onClick:()=>m(!1),children:l("dialog.cancel")})]})]}),j&&(0,n.jsx)(B,{entry:j,onClose:e=>{k(null),e&&t()}})]})}function K(e){let{entries:s}=e,{t}=(0,p.kj)(),a=(0,p.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)(X,{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,499,534,699,347,131,358],()=>e(e.s=3256)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[177],{952:()=>{},966:(e,s,a)=>{"use strict";a.d(s,{Shell:()=>f});var r=a(3365),n=a(8197),t=a.n(n),l=a(1702),i=a(8214),o=a(1521),c=a(5549),d=a(867),h=a(1035),p=a(7527),m=a(9717);function u(){let{t:e}=(0,d.kj)(),s=(0,l.usePathname)(),[a,n]=(0,o.useState)([]),[t,i]=(0,o.useState)({}),h=(0,o.useRef)({}),m=(0,o.useRef)(new Set),u=(0,o.useRef)(""),x=(0,o.useCallback)(async()=>{try{let e=await c.FH.approvals();n(e);let s=[...new Set(e.map(e=>e.sessionId).filter(e=>!(e in h.current)))],a=s.sort().join(",");if(s.length>0&&a!==u.current){for(let e of(u.current=a,await c.FH.sessions().catch(()=>[])))h.current[e.id]=e.name,"chat"===e.kind&&m.current.add(e.id);i({...h.current})}}catch(e){}},[]);(0,p.z)(x,2e3),(0,o.useEffect)(()=>{let s="copilot-operator";document.title=a.length>0?"(".concat(a.length,") ").concat(e("approval.tabTitle")," — ").concat(s):s},[a.length,e]);let j="/"===s?a.filter(e=>e.sessionId in h.current&&(!m.current.has(e.sessionId)||!!e.model||!!e.plan)):a;return 0===j.length?null:(0,r.jsxs)("section",{className:"approval-banner",role:"alert","aria-live":"assertive",children:[(0,r.jsx)("h2",{children:e("approval.waitingHere")}),(0,r.jsx)("p",{className:"small",children:e("approval.waitingHereWhy")}),j.map(e=>{var s;return(0,r.jsx)(v,{approval:e,sessionName:null!=(s=t[e.sessionId])?s:e.sessionId,onDecided:()=>void x()},e.id)})]})}function v(e){let{approval:s,sessionName:a,onDecided:n}=e,{t:l}=(0,d.kj)(),i=(0,d.W3)(),[p,m]=(0,o.useState)(!1),[u,v]=(0,o.useState)(""),j=(0,o.useRef)(!1),f=async e=>{if(!j.current&&("run-all"!==e||await (0,h.Z)(l("approval.runAllConfirm")))){j.current=!0,m(!0),v("");try{await c.FH.decide(s.id,e)}catch(e){v(e.message)}finally{j.current=!1,m(!1),n()}}};if(s.plan)return(0,r.jsx)(x,{approval:s,sessionName:a,onDecided:n});if(s.model){var k;let e=s.model;return(0,r.jsxs)("div",{className:"approval",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("strong",{children:l(e.manual?"approval.manualTitle":"approval.modelTitle")}),(0,r.jsx)(t(),{href:(0,c.aT)(s.sessionId),children:a}),(0,r.jsx)("span",{className:"muted small",children:i(s.createdAt)})]}),(0,r.jsx)("p",{children:e.manual?e.asked?l("approval.manualAsk",{model:e.asked}):l("approval.manualAskAny"):l("approval.modelAsk",{model:e.asked})}),(0,r.jsx)("p",{className:"muted small",children:l("approval.modelShown",{shown:null!=(k=e.shown)?k:"—"})}),!e.manual&&(0,r.jsx)("p",{className:"reason small",children:l("approval.modelWhy",{why:e.why,tries:e.tries})}),u&&(0,r.jsx)("p",{className:"err",role:"alert",children:u}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("button",{className:"primary",disabled:p,onClick:()=>void f("run"),children:l(e.manual?"approval.manualReady":"approval.modelChosen")}),!e.manual&&(0,r.jsx)("button",{disabled:p,onClick:()=>void f("skip"),children:l("approval.modelAsItIs")}),(0,r.jsx)("button",{className:"danger",disabled:p,onClick:()=>void f("abort"),children:l("approval.modelStop")})]})]})}return(0,r.jsxs)("div",{className:"approval",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("strong",{children:l("approval.title",{n:s.stepId})}),(0,r.jsx)(t(),{href:(0,c.aT)(s.sessionId),children:a}),(0,r.jsx)("span",{className:"muted small",children:i(s.createdAt)})]}),(0,r.jsx)("pre",{style:{margin:"8px 0"},children:s.description}),s.network&&(0,r.jsx)("p",{className:"reason small",children:l("approval.network")}),u&&(0,r.jsx)("p",{className:"err",role:"alert",children:u}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("button",{className:"primary",disabled:p,onClick:()=>void f("run"),children:l("approval.run")}),!s.network&&(0,r.jsx)("button",{disabled:p,onClick:()=>void f("run-all"),title:l("approval.runAllWhy"),children:l("approval.runAll")}),(0,r.jsx)("button",{disabled:p,onClick:()=>void f("skip"),children:l("approval.skip")}),(0,r.jsx)("button",{className:"danger",disabled:p,onClick:()=>void f("abort"),children:l("approval.abort")})]})]})}function x(e){let{approval:s,sessionName:a,onDecided:n}=e,{t:l}=(0,d.kj)(),i=(0,d.W3)(),[p,u]=(0,o.useState)(""),[v,x]=(0,o.useState)(!1),[j,f]=(0,o.useState)(""),k=(0,o.useRef)(!1),w=s.plan,b=async e=>{if(!k.current){if("revise"===e&&!p.trim())return void f(l("pm.reviseNeedsNote"));if("stop"!==e||await (0,h.Z)(l("pm.stopConfirm"))){k.current=!0,x(!0),f("");try{await c.FH.decidePlan(s.id,e,p)}catch(e){f(e.message)}finally{k.current=!1,x(!1),n()}}}};return(0,r.jsxs)("div",{className:"approval",children:[(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("strong",{children:l("pm.cardTitle",{title:w.title})}),(0,r.jsx)(t(),{href:(0,c.aT)(s.sessionId),children:a}),(0,r.jsx)("span",{className:"muted small",children:i(s.createdAt)})]}),(0,r.jsx)("p",{className:"small",children:l("pm.cardWhy")}),(0,r.jsx)(m.D,{plan:w.plan,showApproval:!1}),(0,r.jsx)("label",{htmlFor:"plan-note-".concat(s.id),children:l("pm.note")}),(0,r.jsx)("textarea",{id:"plan-note-".concat(s.id),className:"prose",value:p,onChange:e=>u(e.target.value),placeholder:l("pm.notePlaceholder"),style:{minHeight:70},disabled:v}),j&&(0,r.jsx)("p",{className:"err",role:"alert",children:j}),(0,r.jsxs)("div",{className:"row",children:[(0,r.jsx)("button",{className:"primary",disabled:v,onClick:()=>void b("approve"),children:l("pm.approve")}),(0,r.jsx)("button",{disabled:v,onClick:()=>void b("revise"),title:l("pm.reviseWhy"),children:l("pm.revise")}),(0,r.jsx)("button",{className:"danger",disabled:v,onClick:()=>void b("stop"),children:l("pm.stop")})]})]})}var j=a(3069);function f(e){let{children:s}=e;return"/"===(0,l.usePathname)()?(0,r.jsxs)("div",{className:"wb-root",children:[(0,r.jsx)(u,{}),(0,r.jsx)(j.$,{}),(0,r.jsx)("main",{id:"main",className:"wb-main",children:s})]}):(0,r.jsxs)("div",{className:"wrap",children:[(0,r.jsxs)("header",{className:"top",children:[(0,r.jsx)("h1",{children:(0,r.jsx)(t(),{href:"/",children:"copilot-operator"})}),(0,r.jsx)(i.s,{})]}),(0,r.jsx)(u,{}),(0,r.jsx)(j.$,{}),(0,r.jsx)("main",{id:"main",children:s})]})}},1702:(e,s,a)=>{"use strict";var r=a(9962);a.o(r,"usePathname")&&a.d(s,{usePathname:function(){return r.usePathname}}),a.o(r,"useRouter")&&a.d(s,{useRouter:function(){return r.useRouter}}),a.o(r,"useSearchParams")&&a.d(s,{useSearchParams:function(){return r.useSearchParams}})},7712:(e,s,a)=>{"use strict";a.d(s,{ScrollJump:()=>l});var r=a(3365),n=a(1521),t=a(867);function l(){let{t:e}=(0,t.kj)(),[s,a]=(0,n.useState)({long:!1,atTop:!0,atBottom:!1});return((0,n.useEffect)(()=>{let e=()=>{let e=document.documentElement;a({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 s=new ResizeObserver(e);return s.observe(document.body),()=>{window.removeEventListener("scroll",e),window.removeEventListener("resize",e),s.disconnect()}},[]),s.long)?(0,r.jsxs)("div",{className:"scroll-jump",children:[!s.atTop&&(0,r.jsx)("button",{type:"button","aria-label":e("scroll.top"),title:e("scroll.top"),onClick:()=>window.scrollTo({top:0,behavior:"smooth"}),children:"↑"}),!s.atBottom&&(0,r.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,s,a)=>{"use strict";a.d(s,{AppearanceProvider:()=>d,KP:()=>h});var r=a(3365),n=a(1521);let t="cop.appearance",l=["small","normal","large","huge","giant"];"\n(function () {\n try {\n var d = document.documentElement;\n var raw = localStorage.getItem('".concat(t,"');\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(l),".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 i={theme:"light",textSize:"normal",highContrast:!1,reduceMotion:!1,underlineLinks:!1,strongFocus:!1};function o(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 c=(0,n.createContext)({appearance:i,set:()=>void 0,reset:()=>void 0,loaded:!1});function d(e){let{children:s}=e,[a,d]=(0,n.useState)(i),[h,p]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let e=i;try{let s=window.localStorage.getItem(t);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":i.theme,textSize:l.includes(s.textSize)?s.textSize:i.textSize,highContrast:a(s.highContrast,i.highContrast),reduceMotion:a(s.reduceMotion,i.reduceMotion),underlineLinks:a(s.underlineLinks,i.underlineLinks),strongFocus:a(s.strongFocus,i.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){}d(e),o(e),p(!0)},[]);let m=(0,n.useCallback)(e=>{d(s=>{let a={...s,...e};o(a);try{window.localStorage.setItem(t,JSON.stringify(a))}catch(e){}return a})},[]),u=(0,n.useCallback)(()=>{d(i),o(i);try{window.localStorage.removeItem(t)}catch(e){}},[]);return(0,r.jsx)(c.Provider,{value:{appearance:a,set:m,reset:u,loaded:h},children:s})}function h(){return(0,n.useContext)(c)}},8214:(e,s,a)=>{"use strict";a.d(s,{SkipLink:()=>m,s:()=>u});var r=a(3365),n=a(1521),t=a(8197),l=a.n(t),i=a(1702),o=a(5549),c=a(7527),d=a(867);let h={sessions:(0,r.jsx)("path",{d:"M4 5h16v4H4zM4 11h16v4H4zM4 17h10v2H4z"}),workbench:(0,r.jsx)("path",{d:"M3 4h18v16H3zM9 4v16M3 15h6",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),defaults:(0,r.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,r.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,r.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,r.jsx)("path",{d:"M6 3h9l5 5v13H6zM14 3v6h6M9 13h7M9 17h7",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),presets:(0,r.jsx)("path",{d:"M5 4h14v4H5zM5 10h14v4H5zM5 16h9v4H5z",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"}),appearance:(0,r.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,r.jsx)("path",{d:"M4 5h16v10H4zM2 19h20M9 15v4M15 15v4",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"})},p=[{href:"/",label:"nav.workbench",icon:"workbench"},{href:"/sessions",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,d.kj)();return(0,r.jsx)("a",{className:"skip-link",href:"#main",children:e("a11y.skip")})}function u(){let{t:e}=(0,d.kj)(),s=(0,i.usePathname)(),a=function(){let[e,s]=(0,n.useState)(0);return(0,c.z)(()=>o.FH.activity().then(e=>s(e.sessions)).catch(()=>void 0),4e3),e}();return(0,r.jsxs)("nav",{"aria-label":e("nav.label"),children:[p.map(n=>(0,r.jsxs)(l(),{href:n.href,"aria-current":s===n.href?"page":void 0,children:[(0,r.jsx)("svg",{className:"nav-icon",viewBox:"0 0 24 24",width:"16",height:"16",fill:"currentColor","aria-hidden":"true",children:h[n.icon]}),(0,r.jsx)("span",{children:e(n.label)}),"/history"===n.href&&a>0&&(0,r.jsxs)("span",{className:"live",title:e("nav.liveTitle",{n:a}),children:[(0,r.jsx)("span",{className:"dot","aria-hidden":"true"}),e("nav.live")]})]},n.href)),(0,r.jsx)(d.c5,{})]})}},8761:(e,s,a)=>{Promise.resolve().then(a.bind(a,1035)),Promise.resolve().then(a.t.bind(a,952,23)),Promise.resolve().then(a.bind(a,8214)),Promise.resolve().then(a.bind(a,7712)),Promise.resolve().then(a.bind(a,966)),Promise.resolve().then(a.bind(a,1701)),Promise.resolve().then(a.bind(a,8078)),Promise.resolve().then(a.bind(a,867))},9717:(e,s,a)=>{"use strict";a.d(s,{D:()=>t});var r=a(3365),n=a(867);function t(e){var s,a;let{plan:t,showApproval:l=!0}=e,{t:i}=(0,n.kj)(),o=(0,n.W3)(),c=t.approved;return(0,r.jsxs)("div",{className:"plan-view",children:[(0,r.jsx)("p",{className:"small muted",children:i("pm.version",{n:t.version,at:o(t.at)})}),l&&c&&(0,r.jsxs)("p",{className:"small",children:["operator"===c.by?i("pm.approvedByOperator",{at:o(c.at)}):i("pm.approvedAuto",{at:o(c.at)}),c.why&&" ".concat(c.why),c.note&&" ".concat(i("pm.approvedNote",{note:c.note}))]}),(0,r.jsx)("h4",{children:i("pm.existing")}),(0,r.jsx)("p",{className:"pre-wrap",children:t.existing}),(0,r.jsx)("h4",{children:i("pm.approach")}),(0,r.jsx)("p",{className:"pre-wrap",children:t.approach}),(0,r.jsx)("h4",{children:i("pm.steps")}),(0,r.jsx)("ol",{children:t.steps.map((e,s)=>(0,r.jsx)("li",{className:"pre-wrap",children:e},s))}),t.files.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("h4",{children:i("pm.files")}),(0,r.jsx)("ul",{children:t.files.map(e=>(0,r.jsx)("li",{children:(0,r.jsx)("code",{children:e})},e))})]}),(0,r.jsx)("h4",{children:i("pm.verification")}),(0,r.jsx)("p",{className:"pre-wrap",children:t.verification}),t.risks&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("h4",{children:i("pm.risks")}),(0,r.jsx)("p",{className:"pre-wrap",children:t.risks})]}),(null!=(a=null==(s=t.revisions)?void 0:s.length)?a:0)>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("h4",{children:i("pm.revisions")}),(0,r.jsx)("ul",{children:t.revisions.map(e=>(0,r.jsxs)("li",{className:"small",children:[i("pm.revision",{n:e.version,at:o(e.at)})," ",(0,r.jsx)("span",{className:"pre-wrap",children:e.comment})]},e.version))})]})]})}}},e=>{e.O(0,[353,197,867,549,499,347,131,358],()=>e(e.s=8761)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{1702:(e,s,t)=>{"use strict";var a=t(9962);t.o(a,"usePathname")&&t.d(s,{usePathname:function(){return a.usePathname}}),t.o(a,"useRouter")&&t.d(s,{useRouter:function(){return a.useRouter}}),t.o(a,"useSearchParams")&&t.d(s,{useSearchParams:function(){return a.useSearchParams}})},4784:(e,s,t)=>{"use strict";t.d(s,{Yb:()=>r,u:()=>c});var a=t(3365),n=t(1521),l=t(5549),i=t(867);let c="::by-hand::";function r(e){var s,t,r;let{id:o,chosen:d,onChange:u,none:h,byHand:m,catalogue:p,disabled:b=!1,style:w}=e,{t:x}=(0,i.kj)(),j=function(e){let[s,t]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(void 0!==e)return;let s=!0;return l.FH.models().then(e=>{s&&t(e)}).catch(()=>void 0),()=>{s=!1}},[e]),void 0!==e?e:s}(p),v=null!=(s=null==j?void 0:j.options)?s:[],k=e=>e.toLowerCase().replace(/[-‐‑‒–—_]+/g," ").replace(/\s+/g," ").trim(),f=d&&d!==c?v.find(e=>k(e.name)===k(d)):void 0,g=null!=(t=null==f?void 0:f.name)?t:d,N=!!f||d===c&&void 0!==m,y=v.filter(e=>!e.group),C=new Map;for(let e of v)e.group&&C.set(e.group,[...null!=(r=C.get(e.group))?r:[],e]);return(0,a.jsxs)("select",{id:o,value:g,onChange:e=>u(e.target.value),disabled:b,style:{width:"auto",minWidth:280,...w},children:[void 0!==m&&(0,a.jsx)("option",{value:c,children:m}),void 0!==h&&(0,a.jsx)("option",{value:"",children:h}),d&&!N&&(0,a.jsx)("option",{value:d,children:x("model.notInList",{name:d})}),y.map(e=>(0,a.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(x("model.unavailable")):""]},e.name)),[...C.entries()].map(e=>{let[s,t]=e;return(0,a.jsx)("optgroup",{label:s,children:t.map(e=>(0,a.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(x("model.unavailable")):""]},e.name))},s)})]})}},5704:(e,s,t)=>{Promise.resolve().then(t.bind(t,7279))},7279:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>eh});var a=t(3365),n=t(1521),l=t(8197),i=t.n(l),c=t(5549),r=t(7527),o=t(867);function d(e){let{view:s,sessions:t,selected:n,onOpen:l,onChange:i,workspace:c,onOpenFolder:r}=e;return"files"===s?(0,a.jsx)(p,{workspace:c,onOpen:l,onOpenFolder:r}):"commits"===s?(0,a.jsx)(b,{workspace:c,sessions:t,onOpen:l,onOpenFolder:r}):(0,a.jsx)(h,{sessions:t?t.filter(e=>"chat"!==e.kind):null,selected:n,onOpen:l,onChange:i})}function u(e){let{title:s,children:t}=e;return(0,a.jsxs)("div",{className:"wb-side-head",children:[(0,a.jsx)("h2",{children:s}),(0,a.jsx)("span",{className:"grow"}),t]})}function h(e){let{sessions:s,selected:t,onOpen:l,onChange:c}=e,{t:r}=(0,o.kj)(),[d,h]=(0,n.useState)(new Set),[m,p]=(0,n.useState)(""),b=m.trim().toLowerCase();return(0,a.jsxs)("div",{className:"wb-tree",children:[(0,a.jsxs)(u,{title:r("wb.sessions"),children:[(0,a.jsx)(i(),{className:"wb-icon-btn",href:"/sessions#new-session",title:r("wb.newSession"),"aria-label":r("wb.newSession"),children:"+"}),(0,a.jsx)(i(),{className:"wb-icon-btn",href:"/import",title:r("wb.startPlan"),"aria-label":r("wb.startPlan"),children:"⇩"}),(0,a.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:c,title:r("wb.refresh"),"aria-label":r("wb.refresh"),children:"↻"})]}),(0,a.jsx)("div",{className:"wb-filter",children:(0,a.jsx)("input",{type:"search","aria-label":r("wb.filter"),placeholder:r("wb.filter"),value:m,onChange:e=>p(e.target.value)})}),s?0===s.length?(0,a.jsxs)("p",{className:"muted small wb-pad",children:[r("wb.noSessions")," ",(0,a.jsx)(i(),{href:"/import",children:r("wb.startPlan")})]}):(0,a.jsx)("ul",{className:"wb-tree-list",role:"tree","aria-label":r("wb.sessions"),children:s.map(e=>{let s=e.tasks.filter(s=>!b||s.title.toLowerCase().includes(b)||e.name.toLowerCase().includes(b));if(b&&0===s.length)return null;let n=!d.has(e.id)||!!b,i=e.tasks.filter(e=>"done"===e.status).length;return(0,a.jsxs)("li",{role:"treeitem","aria-expanded":n,"aria-selected":t.sessionId===e.id&&!t.taskId,children:[(0,a.jsxs)("div",{className:"wb-row session".concat(t.sessionId!==e.id||t.taskId?"":" sel"),children:[(0,a.jsx)("button",{type:"button",className:"wb-chev","aria-label":n?r("wb.collapse",{name:e.name}):r("wb.expand",{name:e.name}),onClick:()=>h(s=>{let t=new Set(s);return t.has(e.id)?t.delete(e.id):t.add(e.id),t}),children:n?"▾":"▸"}),(0,a.jsxs)("button",{type:"button",className:"wb-row-main",onClick:()=>l({kind:"session",sessionId:e.id}),children:[(0,a.jsx)("span",{className:"wb-row-name",children:e.name}),e.running&&(0,a.jsx)("span",{className:"wb-live",title:r("wb.running"),"aria-label":r("wb.running")}),(0,a.jsxs)("span",{className:"wb-count",children:[i,"/",e.tasks.length]})]})]}),n&&(0,a.jsx)("ul",{role:"group",children:s.map(s=>{var n;let i=e.tasks.indexOf(s)+1,c=t.taskId===s.id;return(0,a.jsx)("li",{role:"treeitem","aria-selected":c,children:(0,a.jsxs)("button",{type:"button",className:"wb-row task".concat(c?" sel":""),onClick:()=>l({kind:"task",sessionId:e.id,taskId:s.id}),title:s.title,children:[(0,a.jsx)(ed,{status:s.status}),(0,a.jsxs)("span",{className:"wb-num",children:[i,"."]}),(0,a.jsx)("span",{className:"wb-row-name",children:s.title}),(null!=(n=s.attempt)?n:1)>1&&(0,a.jsxs)("span",{className:"wb-count",children:["a",s.attempt]})]})},s.id)})})]},e.id)})}):(0,a.jsx)("p",{className:"muted small wb-pad",children:r("wb.loading")})]})}let m=(e,s)=>e.localeCompare(s,void 0,{sensitivity:"base"});function p(e){let{workspace:s,onOpen:t,onOpenFolder:l}=e,{t:i}=(0,o.kj)(),[d,h]=(0,n.useState)(null),[p,b]=(0,n.useState)(""),[w,x]=(0,n.useState)(new Set),j=()=>(null==s?void 0:s.ok)?c.FH.workspaceFiles().then(e=>{h(e.files),b("")}).catch(e=>b(e.message)):Promise.resolve();(0,n.useEffect)(()=>{h(null),j()},[null==s?void 0:s.dir,null==s?void 0:s.ok]),(0,r.z)(j,6e3,!!(null==s?void 0:s.ok));let v=(e,s)=>(0,a.jsxs)(a.Fragment,{children:[[...e.dirs.keys()].sort(m).map(t=>{let n=s?"".concat(s,"/").concat(t):t;return(0,a.jsxs)("li",{role:"treeitem","aria-expanded":w.has(n),children:[(0,a.jsxs)("button",{type:"button",className:"wb-row",onClick:()=>x(e=>{let s=new Set(e);return s.has(n)?s.delete(n):s.add(n),s}),children:[(0,a.jsx)("span",{className:"wb-chev","aria-hidden":"true",children:w.has(n)?"▾":"▸"}),(0,a.jsx)("span",{className:"wb-row-name",children:t})]}),w.has(n)&&(0,a.jsx)("ul",{role:"group",children:v(e.dirs.get(t),n)})]},"d:".concat(n))}),[...e.files].sort((e,s)=>m(e.split("/").pop(),s.split("/").pop())).map(e=>(0,a.jsx)("li",{role:"treeitem",children:(0,a.jsxs)("button",{type:"button",className:"wb-row file",onClick:()=>t({kind:"file",sessionId:"",path:e}),title:e,children:[(0,a.jsx)("span",{className:"wb-ico","aria-hidden":"true",children:"≡"}),(0,a.jsx)("span",{className:"wb-row-name",children:e.split("/").pop()})]})},"f:".concat(e)))]});return(0,a.jsxs)("div",{className:"wb-tree",children:[(0,a.jsxs)(u,{title:(null==s?void 0:s.ok)?s.name:i("wb.files"),children:[(0,a.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:l,title:i("chat.openFolder"),"aria-label":i("chat.openFolder"),children:"⋯"}),(0,a.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:()=>void j(),title:i("wb.refresh"),"aria-label":i("wb.refresh"),children:"↻"})]}),s?s.ok?p?(0,a.jsx)("p",{className:"err small wb-pad",children:p}):d?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{className:"muted small wb-pad",title:s.dir,children:s.branch?"⎇ ".concat(s.branch):s.dir}),(0,a.jsx)("ul",{className:"wb-tree-list",role:"tree","aria-label":i("wb.files"),children:v(function(e){let s={dirs:new Map,files:[]};for(let t of e){let e=t.split("/"),a=s;for(let s of e.slice(0,-1)){let e=a.dirs.get(s);e||(e={dirs:new Map,files:[]},a.dirs.set(s,e)),a=e}a.files.push(t)}return s}(d),"")})]}):(0,a.jsx)("p",{className:"muted small wb-pad",children:i("wb.loading")}):(0,a.jsxs)("div",{className:"wb-pad",children:[(0,a.jsx)("p",{className:"small",children:s.problem}),(0,a.jsx)("button",{type:"button",className:"primary",onClick:l,children:i("chat.openFolder")})]}):(0,a.jsx)("p",{className:"muted small wb-pad",children:i("wb.loading")})]})}function b(e){var s;let{workspace:t,sessions:l,onOpen:i,onOpenFolder:d}=e,{t:h}=(0,o.kj)(),m=(0,o.W3)(),[p,b]=(0,n.useState)(null),[w,x]=(0,n.useState)(""),[j,v]=(0,n.useState)(new Set),[k,f]=(0,n.useState)(""),[g,N]=(0,n.useState)(new Map),y=(0,n.useCallback)(()=>c.FH.workspaceGit().then(e=>{b(e),x("")}).catch(e=>x(e.message)),[]);(0,n.useEffect)(()=>{b(null),(null==t?void 0:t.ok)&&y()},[y,null==t?void 0:t.ok,null==t?void 0:t.dir]),(0,r.z)(y,5e3,!!(null==t?void 0:t.ok));let C=(e,s,t)=>{let n,l=e.path.lastIndexOf("/");return(0,a.jsx)("li",{children:(0,a.jsxs)("button",{type:"button",className:"wb-row wb-git-file",onClick:()=>i({kind:"diff",sessionId:"",area:s,path:e.path,...t?{commit:t}:{}}),title:"".concat(e.oldPath?"".concat(e.oldPath," → "):"").concat(e.path," \xb7 ").concat((n=e.status,h("git.status.".concat("!"===n?"conflict":n)))),children:[(0,a.jsx)("span",{className:"wb-row-name",children:e.path.slice(l+1)}),l>=0&&(0,a.jsx)("span",{className:"muted wb-git-dir",children:e.path.slice(0,l)}),(0,a.jsx)("span",{className:"grow"}),(0,a.jsx)("span",{className:"wb-git-counts",children:e.added<0?h("diff.binaryShort"):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("span",{className:"plus",children:["+",e.added]})," ",(0,a.jsxs)("span",{className:"minus",children:["−",e.removed]})]})}),(0,a.jsx)("span",{className:"wb-git-status s-".concat("!"===e.status?"conflict":e.status),"aria-hidden":"true",children:e.status})]})},"".concat(s,":").concat(null!=t?t:"",":").concat(e.path))},S=(e,s,t,n)=>(0,a.jsxs)("div",{className:"wb-git-section",children:[(0,a.jsxs)("button",{type:"button",className:"wb-git-head","aria-expanded":!j.has(e),onClick:()=>v(s=>new Set(s.has(e)?[...s].filter(s=>s!==e):[...s,e])),children:[(0,a.jsx)("span",{"aria-hidden":"true",children:j.has(e)?"▸":"▾"})," ",s,null!==t&&(0,a.jsx)("span",{className:"wb-badge",children:t})]}),!j.has(e)&&n]});return(0,a.jsxs)("div",{className:"wb-tree",children:[(0,a.jsx)(u,{title:h("git.title"),children:(0,a.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:()=>void y(),title:h("git.refresh"),"aria-label":h("git.refresh"),disabled:!(null==t?void 0:t.ok),children:"↻"})}),(null==t?void 0:t.ok)?w?(0,a.jsx)("p",{className:"err small wb-pad",children:w}):p?p.isRepo?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("p",{className:"small wb-pad wb-git-branch",children:[(0,a.jsx)("span",{"aria-hidden":"true",children:"⎇ "}),(0,a.jsx)("strong",{children:null!=(s=p.branch)?s:"HEAD"}),p.upstream&&(0,a.jsxs)("span",{className:"muted",children:[" \xb7 ",h("git.upstream",{name:p.upstream.name,ahead:p.upstream.ahead,behind:p.upstream.behind})]})]}),p.staged.length>0&&S("staged",h("git.staged"),p.staged.length,(0,a.jsx)("ul",{className:"wb-git-files",children:p.staged.map(e=>C(e,"staged"))})),S("changes",h("git.changes"),p.changes.length,0===p.changes.length?(0,a.jsx)("p",{className:"muted small wb-pad",children:h("git.noChanges")}):(0,a.jsx)("ul",{className:"wb-git-files",children:p.changes.map(e=>C(e,"changes"))})),S("commits",h("git.commits"),null,0===p.commits.length?(0,a.jsx)("p",{className:"muted small wb-pad",children:h("git.noCommits")}):(0,a.jsx)("ul",{className:"wb-commits",children:p.commits.map(e=>{let s=(e=>{for(let t of null!=l?l:[])for(let a of t.tasks){var s;let n=null==(s=a.vcs)?void 0:s.commit;if(n&&(n===e||e.startsWith(n)||n.startsWith(e)))return{sessionId:t.id,taskId:a.id,title:a.title}}return null})(e.sha),t=g.get(e.sha);return(0,a.jsxs)("li",{children:[(0,a.jsxs)("button",{type:"button",className:"wb-row","aria-expanded":k===e.sha,onClick:()=>(e=>{if(k===e)return void f("");f(e),g.has(e)||c.FH.workspaceCommit(e).then(s=>N(t=>new Map(t).set(e,s.files))).catch(s=>N(t=>new Map(t).set(e,s.message)))})(e.sha),title:e.subject,children:[(0,a.jsx)("span",{"aria-hidden":"true",children:k===e.sha?"▾":"▸"}),(0,a.jsx)("code",{children:e.short}),(0,a.jsx)("span",{className:"wb-row-name",children:e.subject})]}),(0,a.jsxs)("div",{className:"muted wb-commit-meta",children:[e.author," \xb7 ",m(e.at),s&&(0,a.jsxs)(a.Fragment,{children:[" \xb7 ",(0,a.jsx)("button",{type:"button",className:"linkish",onClick:()=>i({kind:"task",sessionId:s.sessionId,taskId:s.taskId}),children:h("wb.byTask",{title:s.title})})]})]}),k===e.sha&&(void 0===t?(0,a.jsx)("p",{className:"muted small wb-pad",children:h("wb.loading")}):"string"==typeof t?(0,a.jsx)("p",{className:"err small wb-pad",children:t}):(0,a.jsx)("ul",{className:"wb-git-files nested","aria-label":h("git.commitFiles",{sha:e.short}),children:t.map(s=>C(s,"commit",e.sha))}))]},e.sha)})})),p.moreCommits&&(0,a.jsx)("p",{className:"muted small wb-pad",children:h("git.more",{n:p.commits.length})})]}):(0,a.jsx)("p",{className:"muted small wb-pad",children:h("git.notRepo")}):(0,a.jsx)("p",{className:"muted small wb-pad",children:h("wb.loading")}):(0,a.jsxs)("div",{className:"wb-pad",children:[(0,a.jsx)("p",{className:"muted small",children:h("git.noFolder")}),(0,a.jsx)("button",{type:"button",onClick:d,children:h("chat.openFolder")})]})]})}var w=t(1035),x=t(6481),j=t(287),v=t(5132),k=t(9717);function f(e){let{session:s,task:t,focusAsk:l,onChange:i}=e,{t:r}=(0,o.kj)(),[d,u]=(0,n.useState)(""),[h,m]=(0,n.useState)(""),[p,b]=(0,n.useState)(!1),[w,x]=(0,n.useState)(!1),v=(0,n.useRef)(null),k="idle"===s.status,f="queued"===t.status||"running"===t.status||"waiting-approval"===t.status?"note":k&&"contract-conflict"!==t.stopCode?(0,c.Zm)(t)||(0,c.Dh)(t)?"continue":"done"===t.status?"newPrompt":"none":"none",g="running"===t.status||"waiting-approval"===t.status;(0,n.useEffect)(()=>{m(""),x(!1),u("")},[t.id]),(0,n.useEffect)(()=>{if(l>0){var e,s;null==(e=v.current)||e.focus(),null==(s=v.current)||s.scrollIntoView({block:"nearest"})}},[l]);let N=async()=>{if(d.trim()&&!p&&"none"!==f){b(!0),m("");try{"note"===f?(await c.FH.addTaskNote(s.id,t.id,d),m(g?r("wb.noteSentSoon"):r("wb.noteKept"))):("continue"===f?(await c.FH.continueTask(s.id,t.id,d),m(r("wb.queuedToContinue"))):(await c.FH.rerunTask(s.id,t.id,{prompt:d},{buildOnFinished:!0}),m(r("wb.queuedNewPrompt"))),x(!0)),u("")}catch(e){m(e.message)}finally{b(!1),i()}}},y="note"===f?r("wb.sendNote"):"continue"===f?r("wb.sendContinue"):"newPrompt"===f?r("wb.sendNewPrompt"):r("wb.sendNone"),C="note"===f?g?r("wb.hintNoteLive"):r("wb.hintNoteQueued"):"continue"===f?r("wb.hintContinue"):"newPrompt"===f?r("wb.hintNewPrompt"):k?r("wb.hintNone"):r("wb.hintBusy");return(0,a.jsxs)("div",{className:"wb-compose wb-task-compose",children:[w&&"queued"===t.status&&(0,a.jsx)("div",{className:"wb-inline-panel",children:(0,a.jsx)(j.f,{target:{sessionId:s.id,taskId:t.id,title:t.title},onClose:e=>{x(!1),e&&m(r("wb.started")),i()}})}),h&&(0,a.jsx)("p",{className:"small",role:"status",children:h}),(0,a.jsx)("label",{htmlFor:"wb-compose",className:"sr-only",children:y}),(0,a.jsx)("textarea",{id:"wb-compose",ref:v,value:d,onChange:e=>u(e.target.value),placeholder:"Ctrl+Enter",disabled:"none"===f||p,onKeyDown:e=>{"Enter"===e.key&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),N())}}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("span",{className:"muted small grow",children:C}),(0,a.jsx)("button",{type:"button",className:"primary",disabled:"none"===f||p||!d.trim(),onClick:()=>void N(),title:"Ctrl+Enter",children:y})]})]})}var g=t(7619);function N(e){var s,t,l,r,d,u,h,m,p,b,N,C,S,I,F,O,T,H,P,M,E,R,A,D,L,q,W,z,K;let{session:B,task:U,onChange:Z,onKerrigan:Y,onOpenFile:_}=e,{t:G}=(0,o.kj)(),J=(0,o.W3)(),[V,Q]=(0,n.useState)(""),[$,X]=(0,n.useState)(!1),[ee,es]=(0,n.useState)(!1),[et,ea]=(0,n.useState)(!1),[en,el]=(0,n.useState)(0),ei=()=>el(e=>e+1),ec=B.tasks.findIndex(e=>e.id===U.id)+1,er="running"===U.status||"waiting-approval"===U.status,eo="idle"!==B.status,eu=(0,c.Zm)(U),eh=(0,c.Dh)(U)&&!eu,em="contract-conflict"===U.stopCode,ep=!!U.startedAt,eb=null==(t=U.attempts)||null==(s=t.at(-1))?void 0:s.undone,ew=null!=(H=U.plan)?H:U.continuing?null==(l=[...null!=(T=U.attempts)?T:[]].reverse().find(e=>{var s;return null==(s=e.plan)?void 0:s.approved}))?void 0:l.plan:void 0;(0,n.useEffect)(()=>{Q(""),es(!1),ea(!1),ef(!1),eN("")},[U.id]);let ex=async function(e,s){let t=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!$){X(!0),Q("");try{await e(),s&&Q(s),t&&es(!0)}catch(e){Q(e.message)}finally{X(!1),Z()}}},ej=async()=>{await (0,w.Z)(G("wb.removeConfirm",{title:U.title}))&&await ex(()=>c.FH.deleteTask(B.id,U.id),G("wb.removed"))},ev=async()=>{await (0,w.Z)(G("wb.runAgainConfirm",{title:U.title}))&&await ex(()=>c.FH.rerunTask(B.id,U.id),G("wb.queuedAgain"),!0)},[ek,ef]=(0,n.useState)(!1),[eg,eN]=(0,n.useState)("");return(0,a.jsxs)("article",{className:"wb-task","aria-labelledby":"wb-task-".concat(U.id),children:[(0,a.jsxs)("header",{className:"wb-task-head",children:[(0,a.jsx)(ed,{status:U.status}),(0,a.jsxs)("div",{className:"grow",children:[(0,a.jsx)("h2",{id:"wb-task-".concat(U.id),children:U.title}),(0,a.jsxs)("p",{className:"muted small",children:[G("wb.taskOf",{n:ec,session:B.name,status:G("status.".concat(U.status))}),(null!=(P=U.attempt)?P:1)>1?" \xb7 ".concat(G("wb.attempt",{n:null!=(M=U.attempt)?M:1})):"",(null==(r=U.vcs)?void 0:r.branch)?" \xb7 ".concat(U.vcs.branch).concat(U.vcs.commit?" @ ".concat(U.vcs.commit.slice(0,8)):""):""]})]}),(0,a.jsx)(i(),{className:"button-link plain small",href:(0,c.aT)(B.id,U.id),children:G("wb.onSessionPage")})]}),(0,a.jsxs)("div",{className:"wb-actions",role:"toolbar","aria-label":G("wb.waysOn"),children:["queued"===U.status&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",className:"primary",disabled:$||eo,onClick:()=>es(!0),children:G("wb.runThis")}),(0,a.jsx)("button",{type:"button",onClick:ei,children:G("wb.addNote")}),(0,a.jsx)(i(),{className:"button-link",href:(0,c.aT)(B.id,U.id),children:G("wb.editTask")}),(0,a.jsx)("button",{type:"button",className:"danger",disabled:$,onClick:()=>void ej(),children:G("wb.remove")})]}),er&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",className:"primary",onClick:ei,children:G("wb.writeToChat")}),(0,a.jsx)("button",{type:"button",className:"danger",disabled:$,onClick:()=>void ex(()=>c.FH.stop(B.id),G("wb.stopping")),children:G("wb.stopSession")})]}),em&&(0,a.jsx)(i(),{className:"button-link primary",href:(0,c.aT)(B.id,U.id),children:G("wb.fixContradiction")}),eu&&!er&&(0,a.jsx)("button",{type:"button",className:"primary",disabled:$||eo,onClick:()=>void ex(()=>c.FH.continueTask(B.id,U.id),G("wb.queuedToContinue"),!0),children:G("wb.continue")}),(eh||eu)&&!em&&!er&&(0,a.jsx)("button",{type:"button",className:eh?"primary":"",disabled:eo,onClick:ei,children:G("wb.continueWithPrompt")}),"done"===U.status&&(0,a.jsx)("button",{type:"button",className:"primary",disabled:eo,onClick:ei,children:G("wb.newPrompt")}),ep&&!er&&"queued"!==U.status&&(0,a.jsx)("button",{type:"button",disabled:$||eo,onClick:()=>void ev(),children:G("wb.runAgain")}),["failed","blocked","limit-reached","aborted"].includes(U.status)&&(0,a.jsx)("button",{type:"button","aria-expanded":ek,disabled:$||eo,onClick:()=>ef(e=>!e),children:G("wb.accept")}),ep&&!er&&"queued"!==U.status&&(0,a.jsx)("button",{type:"button","aria-expanded":et,disabled:eo,onClick:()=>ea(e=>!e),children:G("wb.undo")}),(null!=(E=null==(u=U.vcs)||null==(d=u.files)?void 0:d.length)?E:0)>0&&(0,a.jsx)(x.CV,{sessionId:B.id,taskId:U.id,runId:U.runId,title:U.title,files:null!=(R=null==(m=U.vcs)||null==(h=m.files)?void 0:h.length)?R:0}),(0,a.jsx)("button",{type:"button",onClick:Y,children:G("wb.askKerrigan")})]}),V&&(0,a.jsx)("p",{className:"notice small",role:"status",children:V}),eo&&!er&&(0,a.jsx)("p",{className:"muted small",children:G("wb.sessionBusy")}),(0,a.jsx)(f,{session:B,task:U,focusAsk:en,onChange:Z}),ek&&(0,a.jsxs)("div",{className:"wb-inline-panel",role:"group","aria-label":G("wb.accept"),children:[(0,a.jsx)("label",{htmlFor:"wb-accept-".concat(U.id),children:G("wb.acceptNote")}),(0,a.jsx)("textarea",{id:"wb-accept-".concat(U.id),value:eg,onChange:e=>eN(e.target.value),style:{minHeight:60}}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("button",{type:"button",className:"primary",disabled:$,onClick:()=>void ex(()=>c.FH.acceptTask(B.id,U.id,eg),G("wb.accepted")).then(()=>ef(!1)),children:G("wb.acceptGo")}),(0,a.jsx)("button",{type:"button",className:"quiet",onClick:()=>ef(!1),children:G("dialog.cancel")})]})]}),et&&(0,a.jsx)(y,{session:B,task:U,onDone:e=>{ea(!1),Q(e),es(!0),Z()}}),ee&&"queued"===U.status&&(0,a.jsx)("div",{className:"wb-inline-panel",children:(0,a.jsx)(j.f,{target:{sessionId:B.id,taskId:U.id,title:U.title},intro:V||void 0,onClose:e=>{es(!1),e&&Q(G("wb.started")),Z()}})}),(0,a.jsxs)("section",{className:"wb-sec",children:[(0,a.jsx)("h3",{children:G("wb.result")}),U.accepted&&(0,a.jsxs)("p",{className:"notice calm small",children:[G("wb.acceptedWas",{was:G("status.".concat(U.accepted.was)),at:J(U.accepted.at)}),U.accepted.note?" ".concat(U.accepted.note):""]}),"queued"===U.status&&eb&&(0,a.jsx)("p",{className:"notice calm small",children:"this"===eb.how?G("wb.undoneThis",{commit:null!=(A=null==(p=eb.commit)?void 0:p.slice(0,8))?A:"—"}):G("wb.undoneBack")}),(null==(b=U.continuing)?void 0:b.instruction)&&"done"!==U.status&&(0,a.jsxs)("p",{className:"small",children:[(0,a.jsx)("strong",{children:G("task.continuedWith",{n:U.continuing.fromAttempt})})," ",U.continuing.instruction]}),U.summary?(0,a.jsx)(v.s,{text:U.summary}):"queued"===U.status?(0,a.jsx)("p",{className:"muted small",children:G("wb.notRunYet")}):null,U.reason&&U.reason!==U.summary&&"done"!==U.status&&(0,a.jsx)("p",{className:"reason small",children:U.reason})]}),(0,a.jsxs)("details",{className:"wb-sec",open:"queued"===U.status,children:[(0,a.jsx)("summary",{children:G("wb.prompt")}),(0,a.jsx)(v.s,{text:U.prompt})]}),ew&&(0,a.jsxs)("details",{className:"wb-sec",children:[(0,a.jsx)("summary",{children:G("wb.plan",{n:ew.version})}),(0,a.jsx)(k.D,{plan:ew})]}),(null!=(D=null==(N=U.checkResults)?void 0:N.length)?D:0)>0&&(0,a.jsxs)("section",{className:"wb-sec",children:[(0,a.jsx)("h3",{children:G("wb.checks")}),(0,a.jsx)("ul",{className:"wb-list",children:U.checkResults.map(e=>(0,a.jsxs)("li",{className:e.passed?"ok":"bad",children:[(0,a.jsx)("span",{"aria-hidden":"true",children:e.passed?"✓":"✗"})," ",(0,a.jsx)("strong",{children:e.name})," ",(0,a.jsx)("span",{className:"muted small",children:e.detail})]},e.name))})]}),U.review&&(0,a.jsxs)("section",{className:"wb-sec",children:[(0,a.jsx)("h3",{children:G("wb.review",{verdict:U.review.verdict})}),U.review.summary&&(0,a.jsx)("p",{className:"small",children:U.review.summary}),(null!=(L=null==(C=U.review.findings)?void 0:C.length)?L:0)>0&&(0,a.jsx)("ul",{className:"wb-list",children:U.review.findings.map((e,s)=>{var t;return(0,a.jsxs)("li",{className:"bad small",children:[e.id&&(0,a.jsx)("code",{children:e.id})," ",e.what,e.where?(0,a.jsxs)("span",{className:"muted",children:[" — ",e.where]}):null]},null!=(t=e.id)?t:s)})})]}),(null!=(q=null==(I=U.vcs)||null==(S=I.files)?void 0:S.length)?q:0)>0&&(0,a.jsxs)("section",{className:"wb-sec",children:[(0,a.jsx)("h3",{children:G("wb.changedFiles",{n:U.vcs.files.length})}),(0,a.jsx)("ul",{className:"wb-list",children:U.vcs.files.map(e=>(0,a.jsxs)("li",{children:[(0,a.jsx)("button",{type:"button",className:"linkish",onClick:()=>_(e.path),children:e.path})," ",(0,a.jsx)("span",{className:"muted small",children:e.added>=0?"+".concat(e.added," −").concat(e.removed):G("wb.binary")})]},e.path))})]}),(null!=(W=null==(F=U.notes)?void 0:F.length)?W:0)>0&&(0,a.jsxs)("section",{className:"wb-sec",children:[(0,a.jsx)("h3",{children:G("wb.notes")}),(0,a.jsx)("ul",{className:"wb-list",children:U.notes.map(e=>(0,a.jsxs)("li",{className:"small",children:[e.text," ",(0,a.jsxs)("span",{className:"muted",children:["— ",e.sentAt?G("wb.noteSent",{at:J(e.sentAt)}):G("wb.noteWaiting")]})]},e.id))})]}),(U.startedAt||er)&&(0,a.jsxs)("details",{className:"wb-sec",open:er,children:[(0,a.jsx)("summary",{children:G("wb.conversation")}),(0,a.jsx)(g.P,{sessionId:B.id,taskId:U.id,runId:U.runId,live:er},"".concat(U.id,":").concat(null!=(z=U.runId)?z:""))]}),(null!=(K=null==(O=U.attempts)?void 0:O.length)?K:0)>0&&(0,a.jsxs)("details",{className:"wb-sec",children:[(0,a.jsx)("summary",{children:G("wb.attempts",{n:U.attempts.length})}),(0,a.jsx)("ol",{className:"wb-list",children:U.attempts.map((e,s)=>(0,a.jsxs)("li",{className:"small",children:[(0,a.jsx)(ed,{status:e.status})," ",G("wb.attemptLine",{n:s+1,status:G("status.".concat(e.status))}),e.undone?" \xb7 ".concat("this"===e.undone.how?G("wb.undoneShortThis"):G("wb.undoneShortBack")):"",e.reason?(0,a.jsxs)("span",{className:"muted",children:[" — ",e.reason.slice(0,200)]}):null]},s))})]})]})}function y(e){var s,t,l;let{session:i,task:r,onDone:d}=e,{t:u}=(0,o.kj)(),[h,m]=(0,n.useState)(null),[p,b]=(0,n.useState)(""),[x,j]=(0,n.useState)(!1);(0,n.useEffect)(()=>{c.FH.undoPreview(i.id,r.id).then(m).catch(e=>b(e.message))},[i.id,r.id]);let v=async e=>{if(await (0,w.Z)("this"===e?u("wb.undoThisConfirm",{title:r.title}):u("wb.undoBackConfirm",{title:r.title}))){j(!0);try{let s=await c.FH.undoTask(i.id,r.id,e);d(s.message)}catch(e){b(e.message)}finally{j(!1)}}};if(p&&!h)return(0,a.jsx)("p",{className:"err small",children:p});if(!h)return(0,a.jsx)("p",{className:"muted small",children:u("wb.loading")});let k=h.this,f=h.back;return(0,a.jsxs)("div",{className:"wb-inline-panel",role:"group","aria-label":u("wb.undo"),children:[(0,a.jsxs)("div",{className:"option",children:[(0,a.jsx)("strong",{children:u("wb.undoThis")}),(0,a.jsx)("p",{className:"small",children:k.ok?k.nothing?k.nothing:k.perTask?u("wb.undoThisPerTask",{base:(null!=(s=k.baseCommit)?s:"").slice(0,8),branch:null!=(t=k.branch)?t:"—"}):u("wb.undoThisWhat",{n:k.commits.length,branch:null!=(l=k.branch)?l:"",later:k.later.length}):k.problem}),(0,a.jsx)("button",{type:"button",className:"primary",disabled:x||!k.ok,onClick:()=>void v("this"),children:u("wb.undoThisGo")})]}),(0,a.jsxs)("div",{className:"option",children:[(0,a.jsx)("strong",{children:u("wb.undoBack")}),(0,a.jsx)("p",{className:"small",children:f.ok?u("wb.undoBackWhat",{tasks:f.tasks.map(e=>"“".concat(e.title,"”")).join(", ")}):f.problem}),(0,a.jsx)("button",{type:"button",disabled:x||!f.ok,onClick:()=>void v("back"),children:u("wb.undoBackGo")})]}),p&&(0,a.jsx)("p",{className:"err small",children:p}),(0,a.jsx)("p",{className:"muted small",children:u("wb.undoKept")})]})}var C=t(1701),S=t(4811);function I(e){var s,t;let{session:l,onOpen:r,onChange:d}=e,{t:u}=(0,o.kj)(),h=(0,S.p)(),[m,p]=(0,n.useState)(""),[b,x]=(0,n.useState)(!1),j=l.tasks.filter(e=>"queued"===e.status).length,v=l.tasks.filter(e=>"done"===e.status).length,k="idle"===l.status,f=async e=>{if("unattended"!==e||h||await (0,w.Z)(u("session.unattendedConfirm"))){x(!0),p("");try{var s;let t=await (0,C.L)({sessionIds:[l.id],mode:e,start:s=>c.FH.start(l.id,e,l.planName,s)});t.started?p(u("unattended"===e?"session.startedAuto":"session.startedStep")):t.reply&&p(u("session.notStarted",{reason:null!=(s=t.reply.reason)?s:""}))}catch(e){p(e.message)}finally{x(!1),d()}}};return(0,a.jsxs)("article",{className:"wb-task","aria-labelledby":"wb-s-".concat(l.id),children:[(0,a.jsxs)("header",{className:"wb-task-head",children:[(0,a.jsx)("span",{className:"wb-ico","aria-hidden":"true",children:"▤"}),(0,a.jsxs)("div",{className:"grow",children:[(0,a.jsx)("h2",{id:"wb-s-".concat(l.id),children:l.name}),(0,a.jsxs)("p",{className:"muted small",children:[u("wb.sessionLine",{done:v,all:l.tasks.length,queued:j}),(null==(s=l.vcs)?void 0:s.enabled)?" \xb7 ".concat("per-task"===l.vcs.branchMode?u("wb.perTask"):u("wb.perSession")):" \xb7 ".concat(u("wb.noVcs")),l.modelInUse||l.model?" \xb7 ".concat(null!=(t=l.modelInUse)?t:l.model):""]})]}),(0,a.jsx)(i(),{className:"button-link plain small",href:(0,c.aT)(l.id),children:u("wb.sessionSettings")})]}),(0,a.jsxs)("div",{className:"wb-actions",role:"toolbar","aria-label":u("wb.waysOn"),children:[k?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",className:"primary",disabled:b||0===j,onClick:()=>void f("unattended"),children:u("session.run",{n:j})}),(0,a.jsx)("button",{type:"button",disabled:b||0===j,onClick:()=>void f("confirm"),children:u("session.runStep")})]}):(0,a.jsx)("button",{type:"button",className:"danger",disabled:b,onClick:()=>void c.FH.stop(l.id).then(()=>p(u("wb.stopping"))).catch(e=>p(e.message)).finally(d),children:u("wb.stopSession")}),(0,a.jsx)(i(),{className:"button-link",href:(0,c.aT)(l.id,"new-task"),children:u("wb.addTask")})]}),0===j&&k&&(0,a.jsx)("p",{className:"muted small",children:u("wb.nothingQueued")}),m&&(0,a.jsx)("p",{className:"notice small",role:"status",children:m}),(0,a.jsx)("ol",{className:"wb-list wb-session-tasks",children:l.tasks.map(e=>(0,a.jsxs)("li",{children:[(0,a.jsxs)("button",{type:"button",className:"linkish",onClick:()=>r({kind:"task",sessionId:l.id,taskId:e.id}),children:[(0,a.jsx)(ed,{status:e.status})," ",e.title]}),e.reason&&"done"!==e.status&&"queued"!==e.status?(0,a.jsxs)("span",{className:"muted small",children:[" — ",e.reason.slice(0,160)]}):null]},e.id))})]})}function F(e){var s;let{sessionId:t,path:l,taskId:i}=e,{t:r}=(0,o.kj)(),[d,u]=(0,n.useState)(null),[h,m]=(0,n.useState)("");if((0,n.useEffect)(()=>{let e=!0;return m(""),(t?c.FH.repoFile(t,l,i):c.FH.workspaceFile(l).then(e=>({...e,label:""}))).then(s=>e&&u(s)).catch(s=>e&&m(s.message)),()=>{e=!1}},[t,l,i,r]),h)return(0,a.jsx)("p",{className:"err small",children:h});if(!d)return(0,a.jsx)("p",{className:"muted small",children:r("wb.loading")});let p=(null!=(s=d.text)?s:"").split("\n");return(0,a.jsxs)("div",{className:"wb-file",children:[(0,a.jsx)("p",{className:"muted small",children:t?r("wb.fileAt",{path:d.path,ref:d.label}):r("wb.fileOnDisk",{path:d.path})}),d.binary?(0,a.jsx)("p",{className:"muted",children:r("wb.binary")}):d.tooLarge?(0,a.jsx)("p",{className:"muted",children:r("wb.tooLarge")}):(0,a.jsx)("pre",{className:"wb-code","aria-label":d.path,children:p.map((e,s)=>(0,a.jsxs)("span",{className:"wb-line",children:[(0,a.jsx)("span",{className:"wb-ln","aria-hidden":"true",children:s+1}),e,"\n"]},s))})]})}var O=t(853);function T(e){var s;let{area:t,path:l,commit:i}=e,{t:d}=(0,o.kj)(),[u,h]=(0,n.useState)(null),[m,p]=(0,n.useState)(""),[b,w]=(0,n.useState)(!1),[j,v]=(0,n.useState)(!0),[k,f]=(0,n.useState)(new Set),[g,N]=(0,n.useState)(-1),y=(0,n.useRef)(null),C=(0,n.useCallback)(()=>c.FH.workspaceGitFile(t,l,i).then(e=>{h(e),p("")}).catch(e=>p(e.message)),[t,l,i]);(0,n.useEffect)(()=>{h(null),p(""),f(new Set),N(-1),C()},[C]),(0,r.z)(C,5e3,"commit"!==t);let S=(0,n.useMemo)(()=>!u||u.binary||u.tooLarge?[]:(0,O.Qp)((0,O.Dx)(u.before),(0,O.Dx)(u.after)),[u]),I=(0,n.useMemo)(()=>(0,O.$8)(S,3,k,b),[S,k,b]),F=(0,n.useMemo)(()=>S.flatMap((e,s)=>"same"!==e.kind&&(0===s||"same"===S[s-1].kind)?[s]:[]),[S]),T=e=>{var s,t;if(0===F.length)return;let a=g<0?1===e?0:F.length-1:Math.min(F.length-1,Math.max(0,g+e));N(a),null==(t=y.current)||null==(s=t.querySelector('[data-row="'.concat(F[a],'"]')))||s.scrollIntoView({block:"center"})},H="commit"===t?(null!=i?i:"").slice(0,7):d("staged"===t?"git.index":"git.workingTree"),P=null!=(s=null==u?void 0:u.status)?s:"";return(0,a.jsxs)("div",{className:"wb-gitdiff",children:[(0,a.jsxs)("div",{className:"diff-toolbar",children:[(0,a.jsx)("strong",{className:"diff-name",children:(null==u?void 0:u.oldPath)?"".concat(u.oldPath," → ").concat(l):l}),(0,a.jsxs)("span",{className:"muted small",children:[H,P?" \xb7 ".concat(d("git.status.".concat("!"===P?"conflict":P))):""]}),(0,a.jsx)("span",{className:"grow"}),(0,a.jsx)("button",{type:"button",className:"quiet",onClick:()=>T(-1),disabled:0===F.length,children:d("diff.prevChange")}),(0,a.jsx)("button",{type:"button",className:"quiet",onClick:()=>T(1),disabled:0===F.length,children:d("diff.nextChange")}),(0,a.jsx)("span",{className:"muted small",children:F.length>0?d("diff.changeN",{i:g<0?"–":g+1,n:F.length}):""}),(0,a.jsxs)("label",{className:"option-inline",children:[(0,a.jsx)("input",{type:"checkbox",checked:b,onChange:e=>w(e.target.checked)})," ",d("diff.whole")]}),(0,a.jsxs)("label",{className:"option-inline",children:[(0,a.jsx)("input",{type:"checkbox",checked:j,onChange:e=>v(e.target.checked)})," ",d("diff.wrap")]})]}),(0,a.jsxs)("div",{className:"diff-scroll",ref:y,children:[m&&(0,a.jsx)("div",{className:"err",style:{padding:12},children:m}),!u&&!m&&(0,a.jsx)("div",{className:"muted",style:{padding:12},children:d("diff.loading")}),(null==u?void 0:u.binary)&&(0,a.jsx)("div",{className:"notice",style:{margin:12},children:d("diff.binary")}),(null==u?void 0:u.tooLarge)&&(0,a.jsx)("div",{className:"notice",style:{margin:12},children:d("diff.tooLarge")}),u&&!u.binary&&!u.tooLarge&&(0,a.jsxs)(a.Fragment,{children:[S.length>0&&0===F.length&&(0,a.jsx)("div",{className:"notice small",style:{margin:8},children:d("diff.sameText")}),(0,a.jsxs)("table",{className:"diff-table".concat(j?"":" nowrap"),children:[(0,a.jsxs)("colgroup",{children:[(0,a.jsx)("col",{className:"num"}),(0,a.jsx)("col",{}),(0,a.jsx)("col",{className:"num"}),(0,a.jsx)("col",{})]}),(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{colSpan:2,children:d("diff.before")}),(0,a.jsx)("th",{colSpan:2,children:d("diff.after")})]})}),(0,a.jsx)("tbody",{children:I.map(e=>"gap"===e.type?(0,a.jsx)("tr",{className:"diff-gap",children:(0,a.jsx)("td",{colSpan:4,children:(0,a.jsx)("button",{type:"button",className:"linkish small",onClick:()=>f(s=>new Set([...s,e.from])),children:d("diff.gap",{n:e.count})})})},"g".concat(e.from)):(0,a.jsx)(x.Q1,{row:e.row,index:e.index,current:g>=0&&F[g]===e.index},e.index))})]})]})]})]})}var H=t(7908),P=t(4784);async function M(e){try{return await navigator.clipboard.writeText(e),!0}catch(e){}try{let s=document.createElement("textarea");s.value=e,s.setAttribute("readonly",""),s.style.position="fixed",s.style.opacity="0",document.body.appendChild(s),s.select();let t=document.execCommand("copy");return s.remove(),t}catch(e){return!1}}function E(e){let{text:s,what:t,className:l=""}=e,{t:i}=(0,o.kj)(),[c,r]=(0,n.useState)(""),d=(0,n.useRef)(void 0);(0,n.useEffect)(()=>()=>window.clearTimeout(d.current),[]);let u=async()=>{r(await M(s)?"copied":"failed"),window.clearTimeout(d.current),d.current=window.setTimeout(()=>r(""),2e3)};return(0,a.jsx)("button",{type:"button",className:"quiet small copy-btn ".concat(l).trim(),onClick:()=>void u(),title:i(t),"aria-label":i(t),children:(0,a.jsx)("span",{"aria-live":"polite",children:i("copied"===c?"copy.copied":"failed"===c?"copy.failed":"copy.copy")})})}let R="cop.chat.thread",A="cop.chat.mode",D=(e,s)=>{try{s?window.localStorage.setItem(e,s):window.localStorage.removeItem(e)}catch(e){}},L=e=>{try{var s;return null!=(s=window.localStorage.getItem(e))?s:""}catch(e){return""}};function q(e){var s,t,l,i,d;let{workspace:u,composeAsk:h,onOpenFile:m,onChange:p,onOpenFolder:b,onTurn:x}=e,{t:j}=(0,o.kj)(),v=(0,S.p)(),[k,f]=(0,n.useState)([]),[g,N]=(0,n.useState)(""),[y,C]=(0,n.useState)(null),[I,F]=(0,n.useState)("confirm"),[O,T]=(0,n.useState)(""),[M,E]=(0,n.useState)(!1),[q,K]=(0,n.useState)(""),[B,U]=(0,n.useState)([]),[Z,Y]=(0,n.useState)(null),[_,G]=(0,n.useState)(""),[J,V]=(0,n.useState)(!1),Q=(0,n.useRef)(null),$=!!y&&"idle"!==y.status,X=null!=(s=null==Z?void 0:Z.defaultModel)?s:"",ee=y?!y.manualModel&&(y.model||X)?null!=(t=y.model)?t:"":P.u:"",es=_!==P.u&&(_||X)?_:P.u;(0,n.useEffect)(()=>{N(L(R));let e=L(A);"confirm"===e||"unattended"===e?F(e):c.FH.settings().then(e=>{var s;return F((null==(s=e.raw.execution)?void 0:s.mode)==="unattended"?"unattended":"confirm")}).catch(()=>void 0)},[]),(0,n.useEffect)(()=>{var e;h>0&&(null==(e=Q.current)||e.focus())},[h]),(0,n.useEffect)(()=>{c.FH.models().then(Y).catch(()=>void 0)},[]);let et=(0,n.useCallback)(()=>c.FH.chatThreads().then(f).catch(()=>void 0),[]);(0,r.z)(et,5e3);let ea=(0,n.useCallback)(()=>g?c.FH.session(g).then(e=>C("chat"===e.kind?e:null)).catch(()=>{C(null),N(""),D(R,"")}):Promise.resolve(C(null)),[g]);(0,n.useEffect)(()=>{ea()},[ea]),(0,r.z)(ea,$?1500:5e3,!!g),(0,r.z)(()=>g&&$?c.FH.approvals(g).then(U).catch(()=>void 0):Promise.resolve(U([])),1500,!!g);let en=e=>{N(e),D(R,e),K("")},el=async()=>{let e=O.trim();if(e&&!M){E(!0),K("");try{var s;let t=!g,a=t&&_===P.u,n=await c.FH.chatSend(e,g||void 0,t&&!a&&_||void 0,a);if(T(""),en(n.threadId),n.noted)return void K(j("chat.noted"));if("unattended"===I&&t&&!v&&!await (0,w.Z)(j("session.unattendedConfirm")))return void K(j("chat.notStartedYet"));let l=await c.FH.start(n.threadId,I);l.started||K(j("chat.notStarted",{reason:null!=(s=l.reason)?s:""}))}catch(e){K(e.message)}finally{E(!1),ea(),et(),p()}}},ei=async e=>{if(y&&!M&&await (0,w.Z)(j("chat.rewindConfirm",{n:y.tasks.length-y.tasks.indexOf(e)}))){E(!0),K("");try{var s;let t=await c.FH.chatRewind(y.id,e.id);T(t.text),K(j("chat.rewound")),null==(s=Q.current)||s.focus()}catch(e){K(e.message)}finally{E(!1),ea(),p()}}},ec=async e=>{if(!y)return void G(e);try{await c.FH.updateSession(y.id,e===P.u?{model:"",manualModel:!0}:{model:e,manualModel:!1}),ea()}catch(e){K(e.message)}},er=async()=>{V(!0),K(j("chat.modelsReading"));try{Y(await c.FH.refreshModels()),K(j("chat.modelsRead"))}catch(e){K(e.message)}finally{V(!1)}},eo=null==y?void 0:y.tasks.at(-1);(0,n.useEffect)(()=>{x(g?y&&eo?{sessionId:y.id,taskId:eo.id}:null:"new")},[g,null==y?void 0:y.id,null==eo?void 0:eo.id]);let{ref:ed}=(0,H.U)(!0,"".concat(null!=(l=null==y?void 0:y.tasks.length)?l:0,":").concat(null!=(i=null==eo?void 0:eo.status)?i:"",":").concat(null!=(d=null==eo?void 0:eo.iterations)?d:0));return(0,a.jsxs)("div",{className:"cs",children:[(0,a.jsxs)("div",{className:"cs-head",children:[(0,a.jsx)("label",{htmlFor:"cs-thread",className:"sr-only",children:j("chat.thread")}),(0,a.jsxs)("select",{id:"cs-thread",value:g,onChange:e=>en(e.target.value),children:[(0,a.jsx)("option",{value:"",children:j("chat.newThread")}),k.map(e=>(0,a.jsx)("option",{value:e.id,children:e.name.replace(/^chat: /,"")},e.id))]}),(0,a.jsx)("button",{type:"button",className:"cs-new",onClick:()=>{var e;en(""),C(null),null==(e=Q.current)||e.focus()},disabled:!y,title:j("chat.newChatWhy"),children:j("chat.newChat")})]}),(0,a.jsxs)("div",{className:"cs-body",ref:ed,"aria-live":"polite",children:[y?y.tasks.map(e=>(0,a.jsx)(z,{session:y,task:e,approvals:B.filter(s=>s.taskId===e.id),onOpenFile:m,onRewind:$||M?void 0:()=>void ei(e)},e.id)):(0,a.jsx)(W,{workspace:u,onPick:e=>{var s;T(e),null==(s=Q.current)||s.focus()},onOpenFolder:b}),q&&(0,a.jsx)("p",{className:"cs-system",role:"status",children:q})]}),(0,a.jsxs)("div",{className:"cs-compose",children:[(0,a.jsx)("label",{htmlFor:"cs-input",className:"sr-only",children:j("chat.input")}),(0,a.jsx)("textarea",{id:"cs-input",ref:Q,value:O,onChange:e=>T(e.target.value),placeholder:$?j("chat.placeholderRunning"):(null==u?void 0:u.ok)?j("chat.placeholder",{folder:u.name}):j("chat.placeholderNoFolder"),disabled:M||!(null==u?void 0:u.ok),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),el())}}),(0,a.jsxs)("div",{className:"cs-bar",children:[(0,a.jsx)("label",{htmlFor:"cs-model",className:"sr-only",children:j("chat.model")}),(0,a.jsx)(P.Yb,{id:"cs-model",chosen:y?ee:es,onChange:e=>void ec(e),byHand:j("chat.modelByHand"),none:(null==Z?void 0:Z.defaultModel)?j("chat.modelDefault",{model:Z.defaultModel}):void 0,catalogue:Z,disabled:$,style:{minWidth:0,maxWidth:"48%"}}),(0,a.jsx)("button",{type:"button",className:"wb-icon-btn",onClick:()=>void er(),disabled:J||$,title:j("chat.readModels"),"aria-label":j("chat.readModels"),children:"↻"})]}),(0,a.jsxs)("div",{className:"cs-bar",children:[(0,a.jsx)("label",{htmlFor:"cs-mode",className:"sr-only",children:j("chat.mode")}),(0,a.jsxs)("select",{id:"cs-mode",value:I,onChange:e=>{let s=e.target.value;F(s),D(A,s)},disabled:$,title:j("chat.modeWhy"),children:[(0,a.jsx)("option",{value:"confirm",children:j("chat.modeAsk")}),(0,a.jsx)("option",{value:"unattended",children:j("chat.modeAuto")})]}),(0,a.jsx)("span",{className:"grow"}),$&&(0,a.jsx)("button",{type:"button",className:"danger",onClick:()=>{y&&c.FH.stop(y.id).then(()=>K(j("chat.stopping"))).catch(e=>K(e.message))},children:j("chat.stop")}),(0,a.jsx)("button",{type:"button",className:"primary",disabled:M||!O.trim()||!(null==u?void 0:u.ok),onClick:()=>void el(),title:j("chat.sendWhy"),children:$?j("chat.sendNote"):j("chat.send")})]})]})]})}function W(e){var s;let{workspace:t,onPick:n,onOpenFolder:l}=e,{t:i}=(0,o.kj)();if(!t)return(0,a.jsx)("p",{className:"muted small",children:i("wb.loading")});if(!t.ok)return(0,a.jsxs)("div",{className:"cs-welcome",children:[(0,a.jsx)("p",{children:t.problem}),(0,a.jsx)("button",{type:"button",className:"primary",onClick:l,children:i("chat.openFolder")})]});let c=[i("chat.example1"),i("chat.example2"),i("chat.example3")];return(0,a.jsxs)("div",{className:"cs-welcome",children:[(0,a.jsx)("h3",{children:i("chat.welcome",{folder:t.name})}),(0,a.jsx)("p",{className:"muted small",children:i("chat.welcomeWhy",{dir:t.dir,branch:null!=(s=t.branch)?s:"—"})}),(0,a.jsx)("ul",{className:"cs-examples",children:c.map(e=>(0,a.jsx)("li",{children:(0,a.jsx)("button",{type:"button",className:"linkish",onClick:()=>n(e),children:e})},e))})]})}function z(e){var s,t,l,i;let{session:d,task:u,approvals:h,onOpenFile:m,onRewind:p}=e,{t:b}=(0,o.kj)(),[w,j]=(0,n.useState)(null),k="running"===u.status||"waiting-approval"===u.status,f=()=>u.startedAt||k?c.FH.taskStory(d.id,u.id,u.runId).then(j).catch(()=>void 0):Promise.resolve();(0,n.useEffect)(()=>{f()},[u.id,u.runId,u.status]),(0,r.z)(f,k?1500:6e4,k);let g=[],N=e=>e.forEach(e=>"review"===e.kind?N(e.entries):g.push(e));return N(null!=(l=null==w?void 0:w.entries)?l:[]),(0,a.jsxs)("section",{className:"cs-turn","aria-label":b("chat.turn",{text:u.title}),children:[(0,a.jsxs)("div",{className:"cs-user-row",children:[p&&(u.checkpoint||"queued"===u.status)&&(0,a.jsx)("button",{type:"button",className:"wb-icon-btn cs-rewind",onClick:p,title:b("chat.rewind"),"aria-label":b("chat.rewind"),children:"↶"}),(0,a.jsxs)("div",{className:"cs-user",children:[(0,a.jsx)(K,{children:(0,a.jsx)(v.s,{text:u.prompt})}),(0,a.jsx)("div",{className:"cs-copy-row",children:(0,a.jsx)(E,{text:u.prompt,what:"chat.copyMessage"})})]})]}),"queued"===u.status&&(0,a.jsx)("p",{className:"muted small cs-system",children:b("idle"===d.status?"chat.queued":"chat.waitingTurn")}),g.map((e,s)=>{var t;return"reply"===e.kind?(null==(t=e.notes)?void 0:t.trim())?(0,a.jsxs)("div",{className:"cs-bot",children:[(0,a.jsx)(v.s,{text:e.notes}),(0,a.jsx)("div",{className:"cs-copy-row",children:(0,a.jsx)(E,{text:e.notes,what:"chat.copyReply"})})]},s):null:"step"===e.kind?(0,a.jsx)(B,{step:e},s):null}),h.map(e=>(0,a.jsx)(U,{approval:e},e.id)),k&&(0,a.jsxs)("p",{className:"cs-working",role:"status",children:[(0,a.jsx)("span",{className:"wb-live","aria-hidden":"true"})," ",b("chat.working",{n:u.iterations})]}),!k&&"queued"!==u.status&&(0,a.jsxs)("div",{className:"cs-end s-".concat(u.status),children:[(0,a.jsx)(ed,{status:u.status}),(0,a.jsxs)("div",{className:"grow",children:[u.summary?(0,a.jsx)(v.s,{text:u.summary}):null,"done"!==u.status&&u.reason?(0,a.jsx)("p",{className:"small",children:u.reason}):null]}),(u.summary||u.reason)&&(0,a.jsx)(E,{text:[u.summary,"done"!==u.status?u.reason:""].filter(Boolean).join("\n\n"),what:"chat.copySummary"})]}),u.runId&&(0,a.jsx)("div",{className:"cs-exchange",children:(0,a.jsx)("a",{className:"button-link quiet small",href:c.FH.taskExchangeUrl(d.id,u.id),download:!0,title:b("chat.exchangeWhy"),children:b("chat.exchange")})}),(null!=(i=null==(t=u.vcs)||null==(s=t.files)?void 0:s.length)?i:0)>0&&!k&&(0,a.jsxs)("div",{className:"cs-files",children:[(0,a.jsx)("span",{className:"small",children:b("chat.changed",{n:u.vcs.files.length})}),u.vcs.files.slice(0,12).map(e=>(0,a.jsxs)("button",{type:"button",className:"cs-file",onClick:()=>m(e.path),title:e.path,children:[e.path.split("/").pop()," ",(0,a.jsx)("span",{className:"muted",children:e.added>=0?"+".concat(e.added," −").concat(e.removed):""})]},e.path)),(0,a.jsx)(x.CV,{sessionId:d.id,taskId:u.id,runId:u.runId,title:u.title,files:u.vcs.files.length})]})]})}function K(e){let{children:s}=e,{t}=(0,o.kj)(),l=(0,n.useRef)(null),[i,c]=(0,n.useState)(0),[r,d]=(0,n.useState)(!1),[u,h]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let e=l.current;if(!e)return;let s=()=>{let s=window.getComputedStyle(e),t=parseFloat(s.lineHeight)||1.45*parseFloat(s.fontSize),a=Math.round(3*t);c(a),d(e.scrollHeight>a+.6*t)};s();let t=new ResizeObserver(s);return t.observe(e),()=>t.disconnect()},[]);let m=r&&!u;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{ref:l,className:"cs-fold".concat(m?" folded":""),style:m?{maxHeight:i}:void 0,children:[s,m&&(0,a.jsxs)("div",{className:"cs-fold-blur","aria-hidden":"true",children:[(0,a.jsx)("span",{}),(0,a.jsx)("span",{}),(0,a.jsx)("span",{})]})]}),r&&(0,a.jsx)("button",{type:"button",className:"cs-fold-toggle","aria-expanded":u,"aria-label":t(u?"chat.foldClose":"chat.foldOpen"),title:t(u?"chat.foldClose":"chat.foldOpen"),onClick:()=>h(!u),children:u?"▴":"▾"})]})}function B(e){let{step:s}=e,{t}=(0,o.kj)(),l=!s.outcome,[i,c]=(0,n.useState)(null),r=null!=i?i:l||s.failed;return(0,a.jsxs)("div",{className:"cs-cmd".concat(s.failed?" bad":""),children:[(0,a.jsxs)("div",{className:"cs-cmd-row",children:[(0,a.jsxs)("button",{type:"button",className:"cs-cmd-head","aria-expanded":r,onClick:()=>c(!r),children:[(0,a.jsx)("span",{className:"cs-cmd-ico","aria-hidden":"true",children:l?"⟳":s.failed?"✗":"✓"}),(0,a.jsx)("code",{className:"wb-row-name",children:s.command}),(0,a.jsx)("span",{className:"muted small",children:l?t("chat.running"):void 0!==s.exitCode?t("chat.exit",{code:s.exitCode}):s.outcome})]}),(0,a.jsx)(E,{text:s.output?"$ ".concat(s.command,"\n").concat(s.output):s.command,what:"chat.copyCommand"})]}),r&&s.output&&(0,a.jsx)("pre",{className:"cs-out",children:s.output})]})}function U(e){let{approval:s}=e,{t}=(0,o.kj)(),[l,i]=(0,n.useState)(!1),r=async e=>{i(!0);try{await c.FH.decide(s.id,e)}finally{i(!1)}};return s.plan||s.model?(0,a.jsx)("p",{className:"cs-system small",children:t("chat.lookAbove")}):(0,a.jsxs)("div",{className:"cs-ask",role:"group","aria-label":t("chat.askTitle"),children:[(0,a.jsx)("p",{className:"small",children:(0,a.jsx)("strong",{children:t("chat.askTitle")})}),(0,a.jsx)("pre",{className:"cs-out",children:s.description}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("button",{type:"button",className:"primary",disabled:l,onClick:()=>void r("run"),children:t("chat.askRun")}),!s.network&&(0,a.jsx)("button",{type:"button",disabled:l,onClick:()=>void r("run-all"),children:t("chat.askRunAll")}),(0,a.jsx)("button",{type:"button",disabled:l,onClick:()=>void r("skip"),children:t("chat.askSkip")})]})]})}function Z(e){let{session:s,task:t,sessions:l,onChange:r}=e,{t:d}=(0,o.kj)(),[u,h]=(0,n.useState)(""),[m,p]=(0,n.useState)(t?"task":s?"session":"all"),[b,w]=(0,n.useState)(""),[x,j]=(0,n.useState)(""),[v,k]=(0,n.useState)(null),[f,g]=(0,n.useState)(""),[N,y]=(0,n.useState)(!1),C="task"!==m||t?"session"!==m||s?m:"all":s?"session":"all",S=async()=>{try{let e="task"===C&&s&&t?{sessionIds:[s.id],taskIds:[t.id],note:u}:"session"===C&&s?{sessionIds:[s.id],note:u}:{sessionIds:l.map(e=>e.id),note:u};return(await c.FH.kerriganReport(e)).text}catch(e){return w(e.message),null}},I=async()=>{let e=await S();if(e)try{await navigator.clipboard.writeText(e),w(d("wb.kCopied",{n:e.length}))}catch(e){w(d("wb.kCopyFailed"))}},F=async()=>{let e=await S();if(!e)return;let s=URL.createObjectURL(new Blob([e],{type:"text/plain;charset=utf-8"})),t=document.createElement("a");t.href=s,t.download="what-happened-".concat(new Date().toISOString().slice(0,16).replace(/[:T]/g,"-"),".txt"),t.click(),URL.revokeObjectURL(s),w(d("wb.kSaved"))},O=async()=>{y(!0),g("");try{k(await c.FH.checkChanges(x))}catch(e){g(e.message)}finally{y(!1)}},T=async()=>{y(!0);try{var e;let s=await c.FH.applyChanges(x);s.ok?(g(d("wb.kApplied",{n:s.applied.length})),k(null),j("")):g(null!=(e=s.problem)?e:s.check&&!s.check.ok?s.check.issues.map(e=>e.message).join(" "):"")}catch(e){g(e.message)}finally{y(!1),r()}},H=!!v&&!v.ok&&/"sessions"\s*:/.test(x)&&!/"changes"\s*:/.test(x);return(0,a.jsxs)("div",{className:"wb-kerrigan",children:[(0,a.jsxs)("section",{children:[(0,a.jsx)("h3",{children:d("wb.kTell")}),(0,a.jsx)("p",{className:"muted small",children:d("wb.kTellWhy")}),(0,a.jsxs)("fieldset",{className:"wb-scope",children:[(0,a.jsx)("legend",{className:"sr-only",children:d("wb.kScope")}),t&&(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"wb-k-scope",checked:"task"===C,onChange:()=>p("task")})," ",d("wb.kScopeTask")]}),s&&(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"wb-k-scope",checked:"session"===C,onChange:()=>p("session")})," ",d("wb.kScopeSession")]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("input",{type:"radio",name:"wb-k-scope",checked:"all"===C,onChange:()=>p("all")})," ",d("wb.kScopeAll")]})]}),(0,a.jsx)("label",{htmlFor:"wb-k-note",children:d("wb.kNote")}),(0,a.jsx)("textarea",{id:"wb-k-note",value:u,onChange:e=>h(e.target.value),placeholder:d("wb.kNotePlaceholder"),style:{minHeight:90}}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("button",{type:"button",className:"primary",onClick:()=>void I(),children:d("wb.kCopy")}),(0,a.jsx)("button",{type:"button",onClick:()=>void F(),children:d("wb.kSave")}),(0,a.jsx)(i(),{className:"button-link plain small",href:"/import",children:d("wb.kBrief")})]}),b&&(0,a.jsx)("p",{className:"small",role:"status",children:b})]}),(0,a.jsxs)("section",{children:[(0,a.jsx)("h3",{children:d("wb.kAnswer")}),(0,a.jsx)("label",{htmlFor:"wb-k-answer",children:d("wb.kPaste")}),(0,a.jsx)("textarea",{id:"wb-k-answer",value:x,onChange:e=>{j(e.target.value),k(null)},style:{minHeight:110}}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("button",{type:"button",disabled:N||!x.trim(),onClick:()=>void O(),children:d("wb.kCheck")}),(null==v?void 0:v.ok)&&(0,a.jsx)("button",{type:"button",className:"primary",disabled:N,onClick:()=>void T(),children:d("wb.kApply",{n:v.changes.length})})]}),(null==v?void 0:v.ok)&&(0,a.jsxs)(a.Fragment,{children:[v.notes&&(0,a.jsx)("p",{className:"small",children:v.notes}),(0,a.jsx)("ol",{className:"wb-list small",children:v.changes.map(e=>(0,a.jsx)("li",{children:e.says},e.index))}),v.warnings.map(e=>(0,a.jsx)("p",{className:"muted small",children:e},e))]}),v&&!v.ok&&(0,a.jsx)(a.Fragment,{children:H?(0,a.jsxs)("p",{className:"small",children:[d("wb.kIsPlan")," ",(0,a.jsx)(i(),{href:"/import",children:d("wb.kImportPage")})]}):(0,a.jsx)("ul",{className:"wb-list small",children:v.issues.map(e=>(0,a.jsxs)("li",{className:"bad",children:[e.path&&(0,a.jsx)("code",{children:e.path})," ",e.message]},"".concat(e.path).concat(e.message)))})}),f&&(0,a.jsx)("p",{className:"notice small",role:"status",children:f})]})]})}function Y(e){let{tab:s,onTab:t,session:n,task:l,sessions:i,workspace:c,composeAsk:r,onOpenFile:d,onOpenFolder:u,onTurn:h,onChange:m,onClose:p}=e,{t:b}=(0,o.kj)();return(0,a.jsxs)("div",{className:"wb-chat-inner",children:[(0,a.jsxs)("div",{className:"wb-chat-tabs",role:"tablist","aria-label":b("wb.chatPanel"),children:[(0,a.jsx)("button",{type:"button",role:"tab","aria-selected":"chat"===s,className:"chat"===s?"on":"",onClick:()=>t("chat"),children:b("wb.chatTab")}),(0,a.jsx)("button",{type:"button",role:"tab","aria-selected":"kerrigan"===s,className:"kerrigan"===s?"on":"",onClick:()=>t("kerrigan"),children:b("wb.kerriganTab")}),(0,a.jsx)("span",{className:"grow"}),(0,a.jsx)("button",{type:"button",className:"wb-icon-btn","aria-label":b("wb.toggleChat"),title:b("wb.toggleChat"),onClick:p,children:"\xd7"})]}),"kerrigan"===s?(0,a.jsx)(Z,{session:n,task:l,sessions:i,onChange:m}):(0,a.jsx)(q,{workspace:c,composeAsk:r,onOpenFile:d,onChange:m,onOpenFolder:u,onTurn:h})]})}function _(e){let{open:s,onToggle:t,tab:l,onTab:i,session:c,task:r,newChat:d=!1,onOpenTask:u}=e,{t:h}=(0,o.kj)(),m=c?function(e){let s=[];return e.tasks.forEach((t,a)=>{var n,l,i,c;let r="".concat(a+1,". ").concat(t.title),o=function(a,n){var l;let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:r;s.push({key:"".concat(e.id,"|").concat(t.id,"|a").concat(null!=(l=t.attempt)?l:1,"|").concat(a,"|").concat(n),sessionId:e.id,taskId:t.id,kind:a,text:n,where:i})};for(let e of null!=(i=t.checkResults)?i:[])e.passed||o("error","".concat(e.name,": ").concat(e.detail.slice(0,160)));if((null==(n=t.review)?void 0:n.verdict)==="fail")for(let e of null!=(c=t.review.findings)?c:[])o("error",e.what.slice(0,200),e.where?"".concat(r," \xb7 ").concat(e.where):r);["failed","blocked","limit-reached","aborted"].includes(t.status)&&t.reason&&o("warn",t.reason.slice(0,200)),(null==(l=t.vcs)?void 0:l.problem)&&o("warn",t.vcs.problem.slice(0,200))}),s}(c):[],[p,b]=(0,n.useState)(()=>new Set),[w,x]=(0,n.useState)(!1);(0,n.useEffect)(()=>b(J()),[]);let j=e=>b(function(e){let s=[...new Set([...J(),...e.filter(e=>e)])].slice(-500);try{window.localStorage.setItem(G,JSON.stringify(s))}catch(e){}return new Set(s)}(e)),v=m.filter(e=>!p.has(e.key)),k=w?m:v,f=m.length-v.length;return(0,a.jsxs)("section",{className:"wb-bottom","aria-label":h("wb.panel"),children:[(0,a.jsxs)("div",{className:"wb-bottom-tabs",role:"tablist","aria-label":h("wb.panel"),children:[["terminal","problems","output"].map(e=>(0,a.jsxs)("button",{type:"button",role:"tab","aria-selected":s&&l===e,className:s&&l===e?"on":"",onClick:()=>i(e),children:[h("terminal"===e?"wb.terminal":"problems"===e?"wb.problems":"wb.output"),"problems"===e&&v.length>0&&(0,a.jsx)("span",{className:"wb-badge",children:v.length})]},e)),(0,a.jsx)("span",{className:"grow"}),(0,a.jsx)("button",{type:"button",className:"wb-icon-btn","aria-label":h("wb.cmdPanel"),title:"".concat(h("wb.cmdPanel")," (Ctrl+J)"),onClick:t,children:s?"▾":"▴"})]}),s&&(0,a.jsx)("div",{className:"wb-bottom-body",role:"tabpanel",children:"terminal"===l?d?(0,a.jsx)("p",{className:"muted small wb-pad",children:h("wb.newChatTerminal")}):(0,a.jsx)(V,{session:c,task:r}):"problems"===l?0===m.length?(0,a.jsx)("p",{className:"muted small wb-pad",children:d?h("wb.newChatProblems"):c?h("wb.noProblems"):h("wb.pickSession")}):(0,a.jsxs)(a.Fragment,{children:[0===k.length?(0,a.jsx)("p",{className:"muted small wb-pad",children:h("wb.problemsNoneNew")}):(0,a.jsx)("ul",{className:"wb-problems",children:k.map(e=>(0,a.jsxs)("li",{className:p.has(e.key)?"seen":void 0,children:[(0,a.jsxs)("button",{type:"button",className:"wb-row",onClick:()=>u(e.sessionId,e.taskId),children:[(0,a.jsx)("span",{className:"wb-sev ".concat(e.kind),"aria-hidden":"true",children:"error"===e.kind?"✗":"⚠"}),(0,a.jsx)("span",{className:"wb-row-name",children:e.text}),(0,a.jsx)("span",{className:"muted",children:e.where})]}),!p.has(e.key)&&(0,a.jsx)("button",{type:"button",className:"quiet small wb-seen",onClick:()=>j([e.key]),title:h("wb.problemSeenWhy"),children:h("wb.problemSeen")})]},e.key))}),(v.length>1||f>0)&&(0,a.jsxs)("div",{className:"row wb-pad",children:[v.length>1&&(0,a.jsx)("button",{type:"button",className:"quiet small",onClick:()=>j(v.map(e=>e.key)),title:h("wb.problemSeenWhy"),children:h("wb.problemsAllSeen")}),f>0&&(0,a.jsx)("button",{type:"button",className:"quiet small",onClick:()=>x(!w),children:w?h("wb.problemsHideSeen"):h("wb.problemsShowSeen",{n:f})})]})]}):d?(0,a.jsx)("p",{className:"muted small wb-pad",children:h("wb.newChatOutput")}):(0,a.jsx)(Q,{session:c})})]})}let G="cop.problems.seen";function J(){try{var e;let s=JSON.parse(null!=(e=window.localStorage.getItem(G))?e:"[]");return new Set(Array.isArray(s)?s.filter(e=>"string"==typeof e):[])}catch(e){return new Set}}function V(e){var s,t;let{session:l,task:i}=e,{t:d}=(0,o.kj)(),[u,h]=(0,n.useState)(null),m=(null==i?void 0:i.status)==="running"||(null==i?void 0:i.status)==="waiting-approval",{ref:p}=(0,H.U)(!!m,null!=(s=null==u?void 0:u.entries.length)?s:0),b=()=>l&&i&&(i.startedAt||m)?c.FH.taskStory(l.id,i.id,i.runId).then(h).catch(()=>void 0):Promise.resolve();if((0,n.useEffect)(()=>{h(null),b()},[null==i?void 0:i.id,null==i?void 0:i.runId]),(0,r.z)(b,m?2e3:15e3,!!l&&!!i),!i)return(0,a.jsx)("p",{className:"muted small wb-pad",children:d("wb.pickTask")});let w=[],x=e=>e.forEach(e=>"step"===e.kind?w.push(e):"review"===e.kind?x(e.entries):void 0);return(x(null!=(t=null==u?void 0:u.entries)?t:[]),0===w.length)?(0,a.jsx)("p",{className:"muted small wb-pad",children:u?d("wb.noSteps"):d("wb.loading")}):(0,a.jsx)("div",{ref:p,className:"wb-terminal","aria-live":"off",children:w.map((e,s)=>(0,a.jsxs)("div",{className:e.failed?"bad":"",children:[(0,a.jsxs)("div",{className:"wb-cmd",children:[(0,a.jsx)("span",{"aria-hidden":"true",children:"$ "}),e.command,(0,a.jsxs)("span",{className:"muted",children:[" ",e.outcome?"".concat(e.outcome).concat(void 0!==e.exitCode?" (".concat(e.exitCode,")"):""):d("wb.runningNow")]})]}),e.output&&(0,a.jsx)("pre",{children:e.output})]},s))})}function Q(e){let{session:s}=e,{t}=(0,o.kj)(),l=(0,o.W3)(),[i,d]=(0,n.useState)([]),{ref:u}=(0,H.U)(!0,i.length),h=()=>s?c.FH.sessionEvents(s.id).then(d).catch(()=>void 0):Promise.resolve();return((0,n.useEffect)(()=>{d([]),h()},[null==s?void 0:s.id]),(0,r.z)(h,3e3,!!s),s)?(0,a.jsx)("div",{ref:u,className:"wb-terminal",children:0===i.length?(0,a.jsx)("p",{className:"muted small",children:t("wb.noEvents")}):i.map((e,s)=>{var t;return(0,a.jsxs)("div",{className:"error"===e.level?"bad":"warn"===e.level?"warnline":"",children:[(0,a.jsxs)("span",{className:"muted",children:[l(e.at)," "]}),null!=(t=e.message)?t:e.type]},s)})}):(0,a.jsx)("p",{className:"muted small wb-pad",children:t("wb.pickSession")})}var $=t(3374);function X(e){var s,t,l,i;let{sessions:d,session:u,task:h,workspace:m,onOpenTask:p}=e,{t:b}=(0,o.kj)(),w=(0,$.c)(!0,5e3),[x,j]=(0,n.useState)(""),[v,k]=(0,n.useState)(0),[f,g]=(0,n.useState)({iterations:60,minutes:240});(0,n.useEffect)(()=>{c.FH.settings().then(e=>{var s,t,a;let n=null!=(s=e.raw.limits)?s:{};g({iterations:null!=(t=n.maxIterations)?t:60,minutes:null!=(a=n.maxRunMinutes)?a:240})}).catch(()=>void 0)},[]),(0,n.useEffect)(()=>{var e;j(""),(null==u||null==(e=u.vcs)?void 0:e.enabled)&&c.FH.vcsStatus(u.id).then(e=>{var s;return j(null!=(s=e.branch)?s:"")}).catch(()=>void 0)},[null==u?void 0:u.id,null==u?void 0:u.status,null==h?void 0:h.status]),(0,r.z)(()=>c.FH.approvals().then(e=>k(e.length)).catch(()=>void 0),3e3);let N=d.find(e=>"idle"!==e.status),y=null==N?void 0:N.tasks.find(e=>"running"===e.status||"waiting-approval"===e.status),C=(null==y?void 0:y.startedAt)?Math.floor((w-Date.parse(y.startedAt))/6e4):0;return(0,a.jsxs)("footer",{className:"wb-statusbar","aria-label":b("wb.status"),children:[!(null==u||null==(s=u.vcs)?void 0:s.enabled)&&(null==m?void 0:m.ok)&&(0,a.jsxs)("span",{title:m.dir,children:[(0,a.jsx)("span",{"aria-hidden":"true",children:"⎇ "}),m.branch?"".concat(m.name," \xb7 ").concat(m.branch):m.name]}),(null==u||null==(t=u.vcs)?void 0:t.enabled)&&(0,a.jsxs)("span",{title:b("wb.branchNow"),children:[(0,a.jsx)("span",{"aria-hidden":"true",children:"⎇ "}),x||"…"]}),N&&y?(0,a.jsxs)("button",{type:"button",className:"wb-status-btn",onClick:()=>p(N.id,y.id),title:b("wb.openRunning"),children:[(0,a.jsx)("span",{className:"wb-live","aria-hidden":"true"})," ",b("wb.runningLine",{session:N.name,task:y.title,n:y.iterations,max:f.iterations,m:C,maxm:f.minutes})]}):(0,a.jsx)("span",{children:b("wb.idle")}),(0,a.jsx)("span",{className:"grow"}),v>0&&(0,a.jsx)("button",{type:"button",className:"wb-status-btn warn",onClick:()=>{var e;return null==(e=document.querySelector(".approval-banner"))?void 0:e.scrollIntoView({block:"start"})},children:b("wb.waiting",{n:v})}),u&&(0,a.jsx)("span",{title:b("wb.modelNow"),children:null!=(i=null!=(l=u.modelInUse)?l:u.model)?i:b("wb.modelDefault")})]})}var ee=t(1702);function es(e){let{commands:s,onClose:t}=e,{t:l}=(0,o.kj)(),i=(0,ee.useRouter)(),[c,r]=(0,n.useState)(""),[d,u]=(0,n.useState)(0),h=(0,n.useRef)(null);(0,n.useEffect)(()=>{var e;return null==(e=h.current)?void 0:e.focus()},[]);let m=(0,n.useMemo)(()=>{let e=c.toLowerCase().split(/\s+/).filter(Boolean);return s.filter(s=>e.every(e=>{var t;return"".concat(s.label," ").concat(null!=(t=s.hint)?t:"").toLowerCase().includes(e)})).slice(0,60)},[c,s]),p=0===m.length?-1:Math.min(d,m.length-1),b=e=>{var s;e&&(t(),e.href?i.push(e.href):null==(s=e.run)||s.call(e))};return(0,a.jsx)("div",{className:"modal-backdrop",role:"presentation",onClick:t,children:(0,a.jsxs)("div",{className:"wb-palette",role:"dialog","aria-modal":"true","aria-label":l("wb.palette"),onClick:e=>e.stopPropagation(),children:[(0,a.jsx)("input",{ref:h,type:"text",role:"combobox","aria-expanded":"true","aria-controls":"wb-palette-list","aria-activedescendant":p>=0?"wb-cmd-".concat(p):void 0,"aria-label":l("wb.palette"),placeholder:l("wb.palettePlaceholder"),value:c,onChange:e=>{r(e.target.value),u(0)},onKeyDown:e=>{"Escape"===e.key?t():"ArrowDown"===e.key?(e.preventDefault(),u(Math.min(m.length-1,p+1))):"ArrowUp"===e.key?(e.preventDefault(),u(Math.max(0,p-1))):"Enter"===e.key&&(e.preventDefault(),b(m[p]))}}),(0,a.jsxs)("ul",{id:"wb-palette-list",role:"listbox","aria-label":l("wb.palette"),children:[0===m.length&&(0,a.jsx)("li",{className:"muted small",children:l("wb.paletteNone")}),m.map((e,s)=>(0,a.jsxs)("li",{id:"wb-cmd-".concat(s),role:"option","aria-selected":s===p,className:s===p?"on":"",onMouseEnter:()=>u(s),onClick:()=>b(e),children:[(0,a.jsx)("span",{className:"wb-row-name",children:e.label}),e.hint&&(0,a.jsx)("span",{className:"muted small",children:e.hint})]},e.id))]})]})})}let et=e=>{var s;return"task"===e.kind?"t:".concat(e.taskId):"session"===e.kind?"s:".concat(e.sessionId):"diff"===e.kind?"d:".concat(e.area,":").concat(null!=(s=e.commit)?s:"",":").concat(e.path):"f:".concat(e.sessionId,":").concat(e.path)},ea={side:290,chat:420,bottom:240,sideOpen:!0,chatOpen:!0,bottomOpen:!0},en="cop.workbench.layout";function el(){return(0,a.jsx)(n.Suspense,{fallback:null,children:(0,a.jsx)(ei,{})})}function ei(){let{t:e}=(0,o.kj)(),[s,t]=(0,n.useState)(null),[l,u]=(0,n.useState)(""),[h,m]=(0,n.useState)({}),[p,b]=(0,n.useState)([]),[w,x]=(0,n.useState)(""),[j,v]=(0,n.useState)("files"),[k,f]=(0,n.useState)(null),[g,y]=(0,n.useState)(null),[C,S]=(0,n.useState)(!1),O=(0,n.useRef)(null),H=(0,n.useCallback)(e=>{y(e),"new"===e&&null!==O.current&&"new"!==O.current&&S(!0),O.current=e},[]),[P,M]=(0,n.useState)("terminal"),[E,R]=(0,n.useState)("chat"),[A,D]=(0,n.useState)(ea),[L,q]=(0,n.useState)(!1),[W,z]=(0,n.useState)(0),K=(0,n.useRef)(!1),B=(0,n.useCallback)(()=>c.FH.sessions().then(e=>{t(e),u("")}).catch(e=>u(e.message)),[]);(0,r.z)(B,3e3);let U=(0,n.useCallback)(()=>c.FH.workspace().then(f).catch(()=>void 0),[]);(0,r.z)(U,1e4);let Z=(0,n.useCallback)(async()=>{try{var e;let s=await c.FH.browseFolder((null==k?void 0:k.dir)||void 0);if(!s.ok)return;let t=await c.FH.settings();await c.FH.saveSettings({...t.raw,project:{...null!=(e=t.raw.project)?e:{},rootDir:s.path}}),await U()}catch(e){u(e.message)}},[null==k?void 0:k.dir,U]);(0,n.useEffect)(()=>{var e,s;D(function(){try{let e=window.localStorage.getItem(en);return e?{...ea,...JSON.parse(e)}:ea}catch(e){return ea}}());let t=new URLSearchParams(window.location.search),a=null!=(e=t.get("s"))?e:void 0,n=null!=(s=t.get("t"))?s:void 0;a&&m({sessionId:a,taskId:n}),K.current=!0},[]),(0,n.useEffect)(()=>{try{window.localStorage.setItem(en,JSON.stringify(A))}catch(e){}},[A]),(0,n.useEffect)(()=>{if(!K.current)return;let e=new URLSearchParams;h.sessionId&&e.set("s",h.sessionId),h.taskId&&e.set("t",h.taskId);let s=e.toString()?"/?".concat(e.toString()):"/";"".concat(window.location.pathname).concat(window.location.search)!==s&&window.history.replaceState(null,"",s)},[h]);let G=(0,n.useCallback)(e=>{b(s=>s.some(s=>et(s)===et(e))?s:[...s,e]),x(et(e)),"task"===e.kind?(m({sessionId:e.sessionId,taskId:e.taskId}),S(!1)):m(s=>({sessionId:e.sessionId,taskId:s.sessionId===e.sessionId?s.taskId:void 0}))},[]),J=(0,n.useRef)(!1);(0,n.useEffect)(()=>{if(J.current||!s||!h.sessionId)return;let e=s.find(e=>e.id===h.sessionId);e&&(J.current=!0,h.taskId&&e.tasks.some(e=>e.id===h.taskId)?G({kind:"task",sessionId:e.id,taskId:h.taskId}):G({kind:"session",sessionId:e.id}))},[s,h,G]);let V=null==s?void 0:s.find(e=>e.id===h.sessionId),Q=null==V?void 0:V.tasks.find(e=>e.id===h.taskId),$=p.find(e=>et(e)===w),ee=g&&"new"!==g?null==s?void 0:s.find(e=>e.id===g.sessionId):void 0,el=g&&"new"!==g?null==ee?void 0:ee.tasks.find(e=>e.id===g.taskId):void 0,ei=(null==$?void 0:$.kind)==="task"&&!C,eh="new"===g&&!ei,em=ei?V:eh?void 0:null!=ee?ee:C?void 0:V,ep=ei?Q:eh?void 0:ee?el:C?void 0:Q,eb=e=>D(s=>({...s,...e}));(0,n.useEffect)(()=>{let e=e=>{if(!(e.ctrlKey||e.metaKey))return;let s=e.key.toLowerCase();"k"===s||"p"===s&&e.shiftKey?(e.preventDefault(),q(!0)):"b"!==s||e.shiftKey?"j"===s?(e.preventDefault(),eb({bottomOpen:!A.bottomOpen})):"l"===s&&(e.preventDefault(),eb({chatOpen:!0}),R("chat"),z(e=>e+1)):(e.preventDefault(),eb({sideOpen:!A.sideOpen}))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[A]);let ew=(0,n.useMemo)(()=>{let t=[{id:"kerrigan",label:e("wb.cmdKerrigan"),run:()=>{eb({chatOpen:!0}),R("kerrigan")}},{id:"chat",label:e("wb.cmdChat"),hint:"Ctrl+L",run:()=>{eb({chatOpen:!0}),R("chat"),z(e=>e+1)}},{id:"side",label:e("wb.cmdSide"),hint:"Ctrl+B",run:()=>eb({sideOpen:!A.sideOpen})},{id:"panel",label:e("wb.cmdPanel"),hint:"Ctrl+J",run:()=>eb({bottomOpen:!A.bottomOpen})},{id:"files",label:e("wb.cmdFiles"),run:()=>{eb({sideOpen:!0}),v("files")}},{id:"commits",label:e("wb.cmdCommits"),run:()=>{eb({sideOpen:!0}),v("commits")}},{id:"problems",label:e("wb.cmdProblems"),run:()=>{eb({bottomOpen:!0}),M("problems")}},...[["/sessions","nav.sessions"],["/history","nav.history"],["/import","nav.import"],["/defaults","nav.defaults"],["/level1","nav.level1"],["/presets","nav.presets"],["/appearance","nav.appearance"],["/system","nav.system"]].map(s=>{let[t,a]=s;return{id:"go:".concat(t),label:e("wb.cmdGo",{page:e(a)}),href:t}})];for(let a of null!=s?s:[])t.push({id:"s:".concat(a.id),label:e("wb.cmdSession",{name:a.name}),run:()=>G({kind:"session",sessionId:a.id})}),a.tasks.forEach((s,n)=>t.push({id:"t:".concat(s.id),label:"".concat(a.name," › ").concat(n+1,". ").concat(s.title),hint:e("status.".concat(s.status)),run:()=>G({kind:"task",sessionId:a.id,taskId:s.id})}));return t},[s,e,A,G]),ex={"--wb-side":A.sideOpen?"".concat(A.side,"px"):"0px","--wb-chat":A.chatOpen?"".concat(A.chat,"px"):"0px","--wb-bottom":A.bottomOpen?"".concat(A.bottom,"px"):"34px"};return(0,a.jsxs)("div",{className:"wb",style:ex,children:[(0,a.jsxs)("header",{className:"wb-top",children:[(0,a.jsx)("span",{className:"wb-brand",children:"copilot-operator"}),(0,a.jsxs)("button",{type:"button",className:"wb-search",onClick:()=>q(!0),title:e("wb.paletteWhy"),children:[(0,a.jsx)("span",{children:e("wb.palette")}),(0,a.jsx)("kbd",{children:"Ctrl+K"})]}),(0,a.jsxs)("nav",{className:"wb-menu","aria-label":e("nav.label"),children:[(0,a.jsx)(i(),{href:"/sessions",children:e("nav.sessions")}),(0,a.jsx)(i(),{href:"/history",children:e("nav.history")}),(0,a.jsx)(i(),{href:"/import",children:e("nav.import")}),(0,a.jsx)(i(),{href:"/defaults",children:e("nav.defaults")}),(0,a.jsx)(o.c5,{})]})]}),(0,a.jsxs)("div",{className:"wb-body".concat(A.sideOpen?"":" no-side").concat(A.chatOpen?"":" no-chat"),children:[(0,a.jsx)(er,{side:j,sideOpen:A.sideOpen,onSide:e=>{e===j&&A.sideOpen?eb({sideOpen:!1}):(v(e),eb({sideOpen:!0}))},chatOpen:A.chatOpen,onChat:()=>eb({chatOpen:!A.chatOpen})}),(0,a.jsxs)("aside",{className:"wb-side","aria-label":e("wb.explorer"),hidden:!A.sideOpen,children:[l&&!s?(0,a.jsx)("p",{className:"err small",style:{padding:10},children:l}):null,(0,a.jsx)(d,{view:j,sessions:s,selected:h,onOpen:G,onChange:()=>void B(),workspace:k,onOpenFolder:()=>void Z()})]}),A.sideOpen&&(0,a.jsx)(eo,{axis:"x",label:e("wb.resize"),onDrag:e=>eb({side:ec(A.side+e,180,560)})}),(0,a.jsxs)("section",{className:"wb-center","aria-label":e("wb.editor"),children:[(0,a.jsxs)("div",{className:"wb-tabs",role:"tablist","aria-label":e("wb.openTabs"),children:[0===p.length&&(0,a.jsx)("span",{className:"muted small wb-tabs-empty",children:e("wb.noTabs")}),p.map(t=>{var n,l,i;let c=et(t),r=null==s?void 0:s.find(e=>e.id===t.sessionId),o="task"===t.kind?null==r?void 0:r.tasks.find(e=>e.id===t.taskId):void 0,d="task"===t.kind?null!=(n=null==o?void 0:o.title)?n:e("wb.goneTask"):"session"===t.kind?null!=(l=null==r?void 0:r.name)?l:e("wb.goneSession"):"diff"===t.kind?"".concat(t.path.split("/").pop()," (").concat("commit"===t.area?(null!=(i=t.commit)?i:"").slice(0,7):e("staged"===t.area?"git.index":"git.workingTree"),")"):t.path.split("/").pop();return(0,a.jsxs)("div",{className:"wb-tab".concat(c===w?" active":""),children:[(0,a.jsxs)("button",{type:"button",role:"tab","aria-selected":c===w,onClick:()=>"task"===t.kind?G(t):(x(c),m({sessionId:t.sessionId,taskId:"file"===t.kind?t.taskId:void 0})),title:"file"===t.kind||"diff"===t.kind?t.path:void 0,children:[o&&(0,a.jsx)(ed,{status:o.status}),"file"===t.kind&&(0,a.jsx)("span",{className:"wb-ico","aria-hidden":"true",children:"≡"}),"diff"===t.kind&&(0,a.jsx)("span",{className:"wb-ico","aria-hidden":"true",children:"\xb1"}),"session"===t.kind&&(0,a.jsx)("span",{className:"wb-ico","aria-hidden":"true",children:"▤"}),(0,a.jsx)("span",{className:"wb-tab-label",children:d})]}),(0,a.jsx)("button",{type:"button",className:"wb-tab-close","aria-label":e("wb.closeTab",{name:null!=d?d:""}),onClick:()=>{b(e=>{let s=e.findIndex(e=>et(e)===c),t=e.filter(e=>et(e)!==c);return c===w&&x(t[Math.max(0,s-1)]?et(t[Math.max(0,s-1)]):""),t})},children:"\xd7"})]},c)})]}),(0,a.jsx)("div",{className:"wb-editor",role:"tabpanel",children:$?"task"===$.kind?V&&Q?(0,a.jsx)(N,{session:V,task:Q,onChange:()=>void B(),onKerrigan:()=>{eb({chatOpen:!0}),R("kerrigan")},onOpenFile:e=>G({kind:"file",sessionId:V.id,path:e,taskId:Q.id})}):(0,a.jsx)("p",{className:"muted",children:e("wb.goneTask")}):"session"===$.kind?(()=>{let t=null==s?void 0:s.find(e=>e.id===$.sessionId);return t?(0,a.jsx)(I,{session:t,onOpen:G,onChange:()=>void B()}):(0,a.jsx)("p",{className:"muted",children:e("wb.goneSession")})})():"diff"===$.kind?(0,a.jsx)(T,{area:$.area,path:$.path,commit:$.commit},et($)):(0,a.jsx)(F,{sessionId:$.sessionId,path:$.path,taskId:$.taskId}):(0,a.jsx)(eu,{sessions:s,workspace:k,onOpen:G,onChat:()=>{eb({chatOpen:!0}),R("chat"),z(e=>e+1)},onKerrigan:()=>{eb({chatOpen:!0}),R("kerrigan")}})}),A.bottomOpen&&(0,a.jsx)(eo,{axis:"y",label:e("wb.resize"),onDrag:e=>eb({bottom:ec(A.bottom-e,90,700)})}),(0,a.jsx)(_,{open:A.bottomOpen,onToggle:()=>eb({bottomOpen:!A.bottomOpen}),tab:P,onTab:e=>{M(e),eb({bottomOpen:!0})},session:em,task:ep,newChat:eh,onOpenTask:(e,s)=>G({kind:"task",sessionId:e,taskId:s})})]}),A.chatOpen&&(0,a.jsx)(eo,{axis:"x",label:e("wb.resize"),onDrag:e=>eb({chat:ec(A.chat-e,300,820)})}),(0,a.jsx)("aside",{className:"wb-chat","aria-label":e("wb.chatPanel"),hidden:!A.chatOpen,children:(0,a.jsx)(Y,{tab:E,onTab:R,session:V,task:Q,sessions:(null!=s?s:[]).filter(e=>"chat"!==e.kind),workspace:k,composeAsk:W,onOpenFile:e=>G({kind:"file",sessionId:"",path:e}),onOpenFolder:()=>void Z(),onTurn:H,onChange:()=>void B(),onClose:()=>eb({chatOpen:!1})})})]}),(0,a.jsx)(X,{sessions:null!=s?s:[],session:V,task:Q,workspace:k,onOpenTask:(e,s)=>G({kind:"task",sessionId:e,taskId:s})}),L&&(0,a.jsx)(es,{commands:ew,onClose:()=>q(!1)})]})}let ec=(e,s,t)=>Math.max(s,Math.min(t,e));function er(e){let{side:s,sideOpen:t,onSide:n,chatOpen:l,onChat:c}=e,{t:r}=(0,o.kj)(),d=(e,l,i)=>(0,a.jsx)("button",{type:"button",className:"wb-act".concat(t&&s===e?" on":""),"aria-pressed":t&&s===e,"aria-label":l,title:l,onClick:()=>n(e),children:(0,a.jsx)("svg",{viewBox:"0 0 24 24",width:"22",height:"22",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i})});return(0,a.jsxs)("nav",{className:"wb-activity","aria-label":r("wb.views"),children:[d("tasks",r("wb.viewTasks"),(0,a.jsx)("path",{d:"M4 6h16M4 12h16M4 18h10"})),d("files",r("wb.viewFiles"),(0,a.jsx)("path",{d:"M4 4h6l2 2h8v14H4z"})),d("commits",r("wb.viewCommits"),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,a.jsx)("path",{d:"M12 3v6M12 15v6"})]})),(0,a.jsx)("span",{className:"grow"}),(0,a.jsx)("button",{type:"button",className:"wb-act".concat(l?" on":""),"aria-pressed":l,"aria-label":r("wb.toggleChat"),title:"".concat(r("wb.toggleChat")," (Ctrl+L)"),onClick:c,children:(0,a.jsx)("svg",{viewBox:"0 0 24 24",width:"22",height:"22",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinejoin:"round","aria-hidden":"true",children:(0,a.jsx)("path",{d:"M4 5h16v11H9l-5 4z"})})}),(0,a.jsx)(i(),{className:"wb-act",href:"/defaults","aria-label":r("nav.defaults"),title:r("nav.defaults"),children:(0,a.jsxs)("svg",{viewBox:"0 0 24 24",width:"22",height:"22",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[(0,a.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,a.jsx)("path",{d:"M12 2v3M12 19v3M2 12h3M19 12h3M5 5l2 2M17 17l2 2M5 19l2-2M17 7l2-2"})]})})]})}function eo(e){let{axis:s,label:t,onDrag:l}=e,i=(0,n.useRef)(null);return(0,a.jsx)("div",{className:"wb-split ".concat(s),role:"separator","aria-orientation":"x"===s?"vertical":"horizontal","aria-label":t,tabIndex:0,onPointerDown:e=>{i.current="x"===s?e.clientX:e.clientY,e.target.setPointerCapture(e.pointerId)},onPointerMove:e=>{if(null===i.current)return;let t="x"===s?e.clientX:e.clientY;l(t-i.current),i.current=t},onPointerUp:()=>i.current=null,onKeyDown:e=>{let t=e.shiftKey?40:12;("x"===s&&"ArrowLeft"===e.key||"y"===s&&"ArrowUp"===e.key)&&l(-t),("x"===s&&"ArrowRight"===e.key||"y"===s&&"ArrowDown"===e.key)&&l(t)}})}function ed(e){var s;let{status:t}=e,{t:n}=(0,o.kj)();return(0,a.jsx)("span",{className:"wb-status s-".concat(t),title:n("status.".concat(t)),"aria-label":n("status.".concat(t)),role:"img",children:null!=(s=({done:"✓",failed:"✗",blocked:"⊘","limit-reached":"⏸",aborted:"■",queued:"○",running:"●","waiting-approval":"◐"})[t])?s:"\xb7"})}function eu(e){let{sessions:s,workspace:t,onOpen:n,onChat:l,onKerrigan:c}=e,{t:r}=(0,o.kj)(),d=(null!=s?s:[]).filter(e=>"chat"!==e.kind),u=d.flatMap(e=>e.tasks.filter(e=>["failed","blocked","limit-reached","aborted","waiting-approval"].includes(e.status)).map(s=>({s:e,x:s}))),h=d.reduce((e,s)=>e+s.tasks.filter(e=>"queued"===e.status).length,0);return(0,a.jsxs)("div",{className:"wb-welcome",children:[(0,a.jsx)("h2",{children:(null==t?void 0:t.ok)?t.name:r("wb.welcome")}),(0,a.jsx)("p",{className:"muted",children:(null==t?void 0:t.ok)?r("wb.welcomeChat",{dir:t.dir}):r("wb.welcomeWhy")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("button",{type:"button",className:"primary",onClick:l,children:r("wb.startChat")}),(0,a.jsx)(i(),{className:"button-link",href:"/import",children:r("wb.startPlan")}),(0,a.jsx)("button",{type:"button",onClick:c,children:r("wb.askKerrigan")})]}),u.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h3",{children:r("wb.needsYou",{n:u.length})}),(0,a.jsx)("ul",{className:"wb-list",children:u.slice(0,12).map(e=>{let{s,x:t}=e;return(0,a.jsx)("li",{children:(0,a.jsxs)("button",{type:"button",className:"linkish",onClick:()=>n({kind:"task",sessionId:s.id,taskId:t.id}),children:[(0,a.jsx)(ed,{status:t.status})," ",s.name," › ",t.title]})},t.id)})})]}),h>0&&(0,a.jsx)("p",{className:"small",children:r("wb.queuedCount",{n:h})}),(0,a.jsx)("p",{className:"muted small",children:r("wb.keys")})]})}function eh(){return(0,a.jsx)(el,{})}},9717:(e,s,t)=>{"use strict";t.d(s,{D:()=>l});var a=t(3365),n=t(867);function l(e){var s,t;let{plan:l,showApproval:i=!0}=e,{t:c}=(0,n.kj)(),r=(0,n.W3)(),o=l.approved;return(0,a.jsxs)("div",{className:"plan-view",children:[(0,a.jsx)("p",{className:"small muted",children:c("pm.version",{n:l.version,at:r(l.at)})}),i&&o&&(0,a.jsxs)("p",{className:"small",children:["operator"===o.by?c("pm.approvedByOperator",{at:r(o.at)}):c("pm.approvedAuto",{at:r(o.at)}),o.why&&" ".concat(o.why),o.note&&" ".concat(c("pm.approvedNote",{note:o.note}))]}),(0,a.jsx)("h4",{children:c("pm.existing")}),(0,a.jsx)("p",{className:"pre-wrap",children:l.existing}),(0,a.jsx)("h4",{children:c("pm.approach")}),(0,a.jsx)("p",{className:"pre-wrap",children:l.approach}),(0,a.jsx)("h4",{children:c("pm.steps")}),(0,a.jsx)("ol",{children:l.steps.map((e,s)=>(0,a.jsx)("li",{className:"pre-wrap",children:e},s))}),l.files.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h4",{children:c("pm.files")}),(0,a.jsx)("ul",{children:l.files.map(e=>(0,a.jsx)("li",{children:(0,a.jsx)("code",{children:e})},e))})]}),(0,a.jsx)("h4",{children:c("pm.verification")}),(0,a.jsx)("p",{className:"pre-wrap",children:l.verification}),l.risks&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h4",{children:c("pm.risks")}),(0,a.jsx)("p",{className:"pre-wrap",children:l.risks})]}),(null!=(t=null==(s=l.revisions)?void 0:s.length)?t:0)>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h4",{children:c("pm.revisions")}),(0,a.jsx)("ul",{children:l.revisions.map(e=>(0,a.jsxs)("li",{className:"small",children:[c("pm.revision",{n:e.version,at:r(e.at)})," ",(0,a.jsx)("span",{className:"pre-wrap",children:e.comment})]},e.version))})]})]})}}},e=>{e.O(0,[197,867,549,499,534,347,131,358],()=>e(e.s=5704)),_N_E=e.O()}]);