copilot-operator 0.1.42 → 0.1.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/api/operator.controller.js +185 -0
- package/dist/src/api/operator.service.js +421 -3
- package/dist/src/api/server.js +16 -0
- package/dist/src/cli.js +12 -0
- package/dist/src/config/schema.js +10 -0
- package/dist/src/orchestrator/taskRunner.js +109 -38
- package/dist/src/plan/brief.js +57 -20
- package/dist/src/plan/changes.js +217 -0
- package/dist/src/plan/schema.js +1 -1
- package/dist/src/plan/systemGuide.js +733 -12
- package/dist/src/session/compose.js +15 -1
- package/dist/src/session/model.js +1 -1
- package/dist/src/session/store.js +60 -0
- package/dist/src/session/workspace.js +71 -0
- package/dist/src/vcs/taskVcs.js +110 -1
- package/dist/web/404.html +2 -2
- package/dist/web/_next/static/BX8Nw248DTY9xAfUu2pOH/_buildManifest.js +1 -0
- package/dist/web/_next/static/chunks/499-751e0be9d4f86e2d.js +1 -0
- package/dist/web/_next/static/chunks/549-1fe42544e4b72942.js +1 -0
- package/dist/web/_next/static/chunks/699-9d031f8c145a0465.js +1 -0
- package/dist/web/_next/static/chunks/867-0f0f8c3bd37be31e.js +1 -0
- package/dist/web/_next/static/chunks/897-5a34109533c3da50.js +1 -0
- package/dist/web/_next/static/chunks/app/defaults/page-56134fbb8cc7554f.js +1 -0
- package/dist/web/_next/static/chunks/app/history/{page-47973539ceff81d6.js → page-0bb537407fed5944.js} +1 -1
- package/dist/web/_next/static/chunks/app/import/{page-999d6cd958989723.js → page-8ef75fc08638e75f.js} +1 -1
- package/dist/web/_next/static/chunks/app/layout-12f138ee04d33c1e.js +1 -0
- package/dist/web/_next/static/chunks/app/page-09c6e2d42098f8d4.js +1 -0
- package/dist/web/_next/static/chunks/app/{page-e557d58476ae6383.js → sessions/page-28376d2e4a9b4738.js} +1 -1
- package/dist/web/_next/static/chunks/app/sessions/view/page-afc235a9171535d8.js +1 -0
- package/dist/web/_next/static/css/{0e55721108c300f2.css → eaec9cc6fe8aceb7.css} +1 -1
- package/dist/web/appearance.html +2 -2
- package/dist/web/appearance.txt +25 -28
- package/dist/web/defaults.html +2 -2
- package/dist/web/defaults.txt +25 -28
- package/dist/web/history.html +2 -2
- package/dist/web/history.txt +25 -28
- package/dist/web/import.html +2 -2
- package/dist/web/import.txt +25 -28
- package/dist/web/index.html +2 -2
- package/dist/web/index.txt +25 -28
- package/dist/web/level1.html +2 -2
- package/dist/web/level1.txt +25 -28
- package/dist/web/presets.html +3 -3
- package/dist/web/presets.txt +25 -28
- package/dist/web/sessions/view.html +2 -2
- package/dist/web/sessions/view.txt +25 -28
- package/dist/web/sessions.html +16 -0
- package/dist/web/sessions.txt +26 -0
- package/dist/web/system.html +2 -2
- package/dist/web/system.txt +25 -28
- package/package.json +5 -2
- package/dist/web/_next/static/chunks/204-db82ca47ff211e21.js +0 -1
- package/dist/web/_next/static/chunks/499-39b2c00bda3656f0.js +0 -1
- package/dist/web/_next/static/chunks/549-348b0a1404407e5a.js +0 -1
- package/dist/web/_next/static/chunks/867-7d86a692260006f1.js +0 -1
- package/dist/web/_next/static/chunks/app/defaults/page-a25c40436fc312db.js +0 -1
- package/dist/web/_next/static/chunks/app/layout-6ee612d25e78b246.js +0 -1
- package/dist/web/_next/static/chunks/app/sessions/view/page-872d8b9fe8eedbbf.js +0 -1
- package/dist/web/_next/static/lDmqS7pWU_B_Ac5idPvdS/_buildManifest.js +0 -1
- /package/dist/web/_next/static/{lDmqS7pWU_B_Ac5idPvdS → BX8Nw248DTY9xAfUu2pOH}/_ssgManifest.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[897],{287:(e,t,s)=>{s.d(t,{y:()=>h,f:()=>u});var n=s(3365),l=s(1521),a=s(5549),i=s(867),r=s(7527),c=s(1035),d=s(1701),o=s(4811);function u(e){var t,s,u;let{target:f,intro:m,initial:p="one",focusFirst:x=!1,checkContract:g=!0,onClose:j}=e,{t:y}=(0,i.kj)(),k=(0,o.p)(),[v,b]=(0,l.useState)(null),[N,w]=(0,l.useState)(p),[S,C]=(0,l.useState)(!1),[q,I]=(0,l.useState)(""),[F,R]=(0,l.useState)(!1),E=(0,l.useRef)(null),L=(0,l.useRef)(null),T=(0,l.useRef)(null),M=(0,l.useId)(),H=()=>a.FH.session(f.sessionId).then(b).catch(e=>I(e.message));(0,l.useEffect)(()=>{H(),g&&a.FH.contractCheck(f.sessionId,f.taskId).then(e=>R(e.conflicts.length>0)).catch(()=>void 0)},[f.sessionId,f.taskId]),(0,r.z)(H,3e3,!!(null==v?void 0:v.running));let O=null!==v;if((0,l.useEffect)(()=>{var e,t,s;if(!O||(null==(t=E.current)||null==(e=t.scrollIntoView)||e.call(t,{block:"nearest"}),!x))return;let n=L.current;n&&!n.disabled?n.focus():null==(s=T.current)||s.focus()},[O,x]),!v)return(0,n.jsx)("div",{className:"notice calm",style:{marginTop:8},children:(0,n.jsx)("span",{className:"small",children:q||y("runq.loading")})});let W=function(e,t){let s=e.tasks.findIndex(e=>e.id===t),n=s>=0?e.tasks[s]:void 0,l=s>=0?e.tasks.slice(0,s):[],a=s>=0?e.tasks.slice(s+1):[],i="continue"!==e.onFailure,r=-1;return a.forEach((e,t)=>{"queued"===e.status&&(r=t)}),{task:n,followingQueued:a.filter(e=>"queued"===e.status),laterRan:a.filter(e=>"queued"!==e.status),earlierRan:l.filter(e=>"queued"!==e.status),chain:i,chainGap:i?l.find(e=>"done"!==e.status):void 0,chainGapLater:i&&r>0?a.slice(0,r).find(e=>"queued"!==e.status&&"done"!==e.status):void 0}}(v,f.taskId),D=(null==(t=W.task)?void 0:t.status)==="queued",G="following"===N?[W.task,...W.followingQueued]:W.task?[W.task]:[],Q=v.running?y("runq.sessionRunning"):!1===v.active?y("runq.sessionInactive"):"",P=async e=>{if("unattended"!==e||k||await (0,c.Z)(y("batch.unattendedConfirm",{n:1}))){C(!0),I(""),R(!1);try{var t,s;let n=await a.FH.suggestedRunName([f.sessionId]).then(e=>e.name).catch(()=>void 0),l=await (0,d.L)({sessionIds:[f.sessionId],mode:e,start:t=>a.FH.startBatch([f.sessionId],e,"stop",void 0,void 0,n,G.map(e=>e.id),t)});if(!l.started&&!l.reply)return;let i=null!=(t=l.reply)?t:{started:!0};if(!l.started){I(y("batch.notStarted",{reason:null!=(s=i.reason)?s:""}));let e=await a.FH.contractCheck(f.sessionId,f.taskId).catch(()=>({conflicts:[]}));R(e.conflicts.length>0);return}I(y("runq.started",{n:G.length})),j(!0)}catch(e){I(e.message)}finally{C(!1)}}},A=y("runq.title",{title:f.title});return(0,n.jsxs)("div",{ref:E,className:"notice calm",role:"group","aria-label":A,style:{marginTop:8},children:[m&&(0,n.jsx)("p",{className:"small",style:{marginTop:0},children:m}),(0,n.jsx)("strong",{children:A}),D?(0,n.jsxs)(n.Fragment,{children:[W.followingQueued.length>0&&(0,n.jsxs)("div",{className:"small",role:"radiogroup","aria-label":A,style:{marginTop:6},children:[(0,n.jsxs)("label",{className:"option-inline",children:[(0,n.jsx)("input",{type:"radio",name:"runq-".concat(M),checked:"one"===N,onChange:()=>w("one"),disabled:S}),y("runq.onlyThis")]}),(0,n.jsxs)("label",{className:"option-inline",title:y("runq.followingWhy"),children:[(0,n.jsx)("input",{type:"radio",name:"runq-".concat(M),checked:"following"===N,onChange:()=>w("following"),disabled:S}),y("runq.following",{n:W.followingQueued.length,session:v.name})]})]}),(0,n.jsx)("div",{className:"small",style:{marginTop:6},children:y("runq.willRun")}),(0,n.jsx)("ol",{className:"small",style:{margin:"4px 0",paddingLeft:22},children:G.map(e=>(0,n.jsx)("li",{children:e.title},e.id))}),(0,n.jsxs)("ul",{className:"small",style:{margin:"4px 0",paddingLeft:18},children:[W.chain&&G.length>1&&(0,n.jsx)("li",{children:y("runq.chainStops")}),W.earlierRan.length>0&&(0,n.jsx)("li",{children:y("runq.untouched",{n:W.earlierRan.length})}),W.laterRan.length>0&&(0,n.jsx)("li",{children:y("runq.laterRan",{list:W.laterRan.map(e=>'"'.concat(e.title,'"')).join(", ")})}),"one"===N&&W.followingQueued.length>0&&(0,n.jsx)("li",{children:y("runq.restWait",{n:W.followingQueued.length})})]}),W.chainGap&&(0,n.jsx)("div",{className:"notice caution small",style:{marginTop:6},children:y("runq.chainGap",{before:W.chainGap.title,status:y("status.".concat(W.chainGap.status))})}),"following"===N&&W.chainGapLater&&(0,n.jsx)("div",{className:"notice caution small",style:{marginTop:6},children:y("runq.chainGapLater",{between:W.chainGapLater.title,status:y("status.".concat(W.chainGapLater.status))})}),Q&&(0,n.jsx)("p",{className:"small",children:Q})]}):(0,n.jsx)("p",{className:"small",children:y("runq.notQueued",{status:y("status.".concat(null!=(u=null==(s=W.task)?void 0:s.status)?u:"queued"))})}),(0,n.jsxs)("div",{className:"row",style:{marginTop:8},children:[D&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{ref:L,className:"primary",disabled:S||!!Q,onClick:()=>void P("confirm"),title:y("runq.goWhy"),children:y("runq.go")}),(0,n.jsx)("button",{disabled:S||!!Q,onClick:()=>void P("unattended"),title:y("runq.unattendedWhy"),children:y("runq.unattended")})]}),(0,n.jsx)("button",{ref:T,className:"quiet",disabled:S,onClick:()=>j(!1),children:m?y("runq.later"):y("dialog.cancel")}),q&&(0,n.jsx)("span",{className:"small",role:"status",children:q})]}),F&&(0,n.jsx)(h,{target:f,onApplied:(e,t)=>{H(),0===e&&(R(!1),I(t))}})]})}function h(e){let{target:t,onApplied:s}=e,{t:r}=(0,i.kj)(),[c,d]=(0,l.useState)(null),[o,u]=(0,l.useState)([]),[h,f]=(0,l.useState)(!1),[m,p]=(0,l.useState)(""),[x,g]=(0,l.useState)(null),[j,y]=(0,l.useState)(null),k=(0,l.useId)();(0,l.useEffect)(()=>{d(null),Promise.all([a.FH.contractCheck(t.sessionId,t.taskId),a.FH.session(t.sessionId)]).then(e=>{var s;let[n,l]=e,a=l.tasks.find(e=>e.id===t.taskId);d(n.conflicts),u(n.conflicts.map(e=>e.fixes.length>0?0:-1)),g(null!=(s=null==a?void 0:a.status)?s:null),y(a?{readOnly:a.readOnly,scope:a.scope,checks:a.checks}:null)}).catch(e=>p(e.message))},[t.sessionId,t.taskId]);let v=async()=>{if(c){f(!0),p("");try{let e=await a.FH.applyContractFix(t.sessionId,t.taskId,o,c.map(e=>e.text)),n=r("cfix.applied",{list:(j?function(e,t,s){var n,l,a,i;let r=[];!!t.readOnly!=!!s.readOnly&&r.push(e(s.readOnly?"cfix.chReadOnlyOn":"cfix.chReadOnlyOff"));let c=(null!=(n=t.scope)?n:[]).join(", "),d=(null!=(l=s.scope)?l:[]).join(", ");c!==d&&r.push(d?e("cfix.chScope",{paths:d}):e("cfix.chScopeRemoved"));let o=new Set((null!=(a=s.checks)?a:[]).map(e=>e.name));for(let s of null!=(i=t.checks)?i:[])o.has(s.name)||r.push(e("cfix.chDropped",{check:s.name}));return r.join("; ")}(r,j,e.task):e.applied.join("; "))||r("cfix.chNothing")});p(n+(e.remaining.length>0?" ".concat(r("cfix.remaining",{n:e.remaining.length})):"")),d(e.remaining),u(e.remaining.map(e=>e.fixes.length>0?0:-1)),g("queued"),y({readOnly:e.task.readOnly,scope:e.task.scope,checks:e.task.checks}),s(e.remaining.length,n)}catch(e){p(e.message)}finally{f(!1)}}},b=r("cfix.title",{title:t.title});return(0,n.jsxs)("div",{className:"notice caution",role:"group","aria-label":b,style:{marginTop:8},children:[(0,n.jsx)("strong",{children:b}),(0,n.jsx)("p",{className:"why",children:r("cfix.why")}),null===c?(0,n.jsx)("p",{className:"small",children:m||r("cfix.loading")}):0===c.length?(0,n.jsx)("p",{className:"small",role:"status",children:m||r("cfix.none")}):(0,n.jsxs)(n.Fragment,{children:[c.map((e,t)=>(0,n.jsxs)("fieldset",{className:"small",style:{margin:"8px 0",border:0,padding:0},children:[(0,n.jsx)("legend",{style:{fontWeight:600},children:e.text}),e.fixes.map((e,s)=>(0,n.jsxs)("label",{className:"option-inline",style:{display:"block"},children:[(0,n.jsx)("input",{type:"radio",name:"cfix-".concat(k,"-").concat(t),checked:o[t]===s,onChange:()=>u(e=>e.map((e,n)=>n===t?s:e)),disabled:h}),"add-to-scope"===e.kind?r("cfix.addToScope",{path:e.path}):"not-read-only"===e.kind?e.scope.length>0?r("cfix.notReadOnly",{paths:e.scope.join(", ")}):r("cfix.notReadOnlyAll"):"drop-scope"===e.kind?r("cfix.dropScope"):r("cfix.dropCheck",{check:e.check}),0===s&&(0,n.jsxs)("span",{className:"muted",children:[" ",r("cfix.minimal")]})]},s)),(0,n.jsxs)("label",{className:"option-inline",style:{display:"block"},children:[(0,n.jsx)("input",{type:"radio",name:"cfix-".concat(k,"-").concat(t),checked:-1===o[t],onChange:()=>u(e=>e.map((e,s)=>s===t?-1:e)),disabled:h}),e.fixes.length>0?r("cfix.leave"):r("cfix.noFix")]})]},t)),(0,n.jsxs)("div",{className:"row",children:[(0,n.jsx)("button",{className:"primary",disabled:h||o.every(e=>-1===e),onClick:()=>void v(),children:"queued"===x?r("cfix.applyQueued"):r("cfix.apply")}),m&&(0,n.jsx)("span",{className:"small",role:"status",children:m})]})]})]})}},3374:(e,t,s)=>{s.d(t,{c:()=>l});var n=s(1521);function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3,[s,l]=(0,n.useState)(()=>Date.now());return(0,n.useEffect)(()=>{if(!e)return;l(Date.now());let s=window.setInterval(()=>l(Date.now()),t);return()=>window.clearInterval(s)},[e,t]),s}},4811:(e,t,s)=>{s.d(t,{p:()=>a});var n=s(1521),l=s(5549);function a(){let[e,t]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{let e=!0;return l.FH.settings().then(s=>{var n;let l=null!=(n=s.raw.execution)?n:{};e&&t("unattended"===l.mode)}).catch(()=>void 0),()=>{e=!1}},[]),e}},5132:(e,t,s)=>{s.d(t,{s:()=>r});var n=s(3365),l=s(1521);function a(e,t){let s,l=[],a=/(`[^`\n]+`)|(\*\*[^*\n]+\*\*)|(\*[^*\n]+\*)/g,i=0,r=0;for(;null!==(s=a.exec(e));){s.index>i&&l.push(e.slice(i,s.index));let a=s[0],c="".concat(t,"-i").concat(r+=1);a.startsWith("`")?l.push((0,n.jsx)("code",{children:a.slice(1,-1)},c)):a.startsWith("**")?l.push((0,n.jsx)("strong",{children:a.slice(2,-2)},c)):l.push((0,n.jsx)("em",{children:a.slice(1,-1)},c)),i=s.index+a.length}return i<e.length&&l.push(e.slice(i)),l}function i(e){let t=/^\s*[-*•]\s+(.*)$/.exec(e);if(t)return t[1];let s=/^\s*\d+[.)]\s+(.*)$/.exec(e);return s?s[1]:null}function r(e){let{text:t,className:s}=e,r=[],c=t.replace(/\r\n/g,"\n").split("\n"),d=0,o=0;for(;d<c.length;){let e=c[d];if(e.trim().startsWith("```")){let e=[];for(d+=1;d<c.length&&!c[d].trim().startsWith("```");)e.push(c[d++]);d+=1,e.length>0&&r.push((0,n.jsx)("pre",{children:e.join("\n")},"b".concat(o+=1)));continue}if(null!==i(e)){let e=[];for(;d<c.length&&null!==i(c[d]);)e.push(i(c[d++]));r.push((0,n.jsx)("ul",{children:e.map((e,t)=>(0,n.jsx)("li",{children:a(e,"b".concat(o,"-").concat(t))},t))},"b".concat(o+=1)));continue}if(""===e.trim()){d+=1;continue}let t=[];for(;d<c.length&&""!==c[d].trim()&&null===i(c[d])&&!c[d].trim().startsWith("```");)t.push(c[d++]);let s=o+=1;r.push((0,n.jsx)("p",{children:t.map((e,t)=>(0,n.jsxs)(l.Fragment,{children:[t>0&&(0,n.jsx)("br",{}),a(e,"b".concat(s,"-").concat(t))]},t))},"b".concat(s)))}return(0,n.jsx)("div",{className:"rich ".concat(null!=s?s:""),children:r})}},7619:(e,t,s)=>{s.d(t,{P:()=>o});var n=s(3365),l=s(1521),a=s(5549),i=s(867),r=s(7908),c=s(5132);function d(e){let{text:t,follow:s}=e,{ref:l}=(0,r.U)(s,t);return(0,n.jsx)("pre",{ref:l,className:"story-out".concat(s?" terminal":""),children:t})}function o(e){let{sessionId:t,taskId:s,runId:o,live:h}=e,{t:f}=(0,i.kj)(),[m,p]=(0,l.useState)(null),[x,g]=(0,l.useState)(""),[j,y]=(0,l.useState)(!0),[k,v]=(0,l.useState)(!0),[b,N]=(0,l.useState)(new Set),[w,S]=(0,l.useState)(new Set),[C,q]=(0,l.useState)(new Set),I=!!(null==m?void 0:m.live),F=(0,l.useRef)(0);F.current+=1;let R=(0,r.U)(I,F.current),E=(0,l.useRef)(null),L=(0,l.useRef)(!1);if((0,l.useEffect)(()=>{if(!m)return;let e=[],t=(s,n)=>s.forEach((s,l)=>{let a="".concat(n).concat(l);"review"===s.kind?t(s.entries,"".concat(a,"-")):"step"!==s.kind||s.outcome||e.push(a)});t(m.entries,"e"),e.some(e=>!w.has(e))&&S(t=>new Set([...t,...e])),m.live&&!L.current&&E.current&&(L.current=!0,E.current.scrollIntoView({block:"nearest",behavior:"smooth"}))},[m,w]),(0,l.useEffect)(()=>{let e,n=!0,l=async()=>{try{let i=await a.FH.taskStory(t,s,o);if(!n)return;p(i),g(""),(i.live||h)&&(e=setTimeout(l,2e3))}catch(t){if(!n)return;g(t.message),h&&(e=setTimeout(l,2e3))}};return l(),()=>{n=!1,e&&clearTimeout(e)}},[t,s,o,h]),x&&!m)return(0,n.jsx)("div",{className:"err small",children:x});if(!m)return(0,n.jsx)("div",{className:"muted small",children:f("story.loading")});let T=e=>b.has(e)||w.has(e)&&!C.has(e),M=e=>{let t=T(e);N(s=>{let n=new Set(s);return t?n.delete(e):n.add(e),n}),q(s=>{let n=new Set(s);return t?n.add(e):n.delete(e),n})},H=(e,t)=>{if(!("review"===e.kind?j||k:"step"===e.kind?k:j))return null;if("review"===e.kind)return(0,n.jsxs)("li",{className:"story-review",children:[(0,n.jsxs)("div",{className:"story-head",children:[(0,n.jsx)(u,{at:e.at}),(0,n.jsx)("span",{className:"chip",children:f("story.review",{n:e.round})})]}),(0,n.jsx)("ol",{className:"story",children:e.entries.map((e,s)=>H(e,"".concat(t,"-").concat(s)))})]},t);if("step"===e.kind){let s=T(t),l=!e.outcome&&m.live;return(0,n.jsxs)("li",{className:"story-step".concat(e.failed?" failed":""),children:[(0,n.jsxs)("div",{className:"story-head",children:[(0,n.jsx)(u,{at:e.at}),(0,n.jsx)("span",{className:"chip",children:f("story.step",{it:e.iteration,id:e.id})}),e.outcome&&(0,n.jsxs)("span",{className:"badge ".concat(e.failed?"failed":"done"),children:[e.outcome,void 0!==e.exitCode?" \xb7 exit ".concat(e.exitCode):"",void 0!==e.durationMs?" \xb7 ".concat((0,a.c5)(e.durationMs)):""]}),!e.outcome&&(0,n.jsx)("span",{className:"badge running",children:f("story.running")}),e.failed&&(0,n.jsx)("span",{className:"badge failed",children:f("story.failedHere")})]}),(0,n.jsx)("pre",{className:"story-cmd",children:e.command}),e.output&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{type:"button",className:"linkish small",onClick:()=>M(t),children:s?f("story.hideOutput"):f("story.showOutput",{n:e.output.length})}),s&&(0,n.jsx)(d,{text:e.output,follow:l})]})]},t)}let s=b.has(t),l="sent"===e.kind?f("story.bot"):f("story.chat"),i="reply"===e.kind&&("blocked"===e.status||"failed"===e.status);return(0,n.jsxs)("li",{className:"story-msg ".concat(e.kind).concat(i?" failed":""),children:[(0,n.jsxs)("div",{className:"story-head",children:[(0,n.jsx)(u,{at:e.at}),(0,n.jsx)("strong",{children:l}),(0,n.jsx)("span",{className:"muted small",children:e.label}),"reply"===e.kind&&e.status&&(0,n.jsx)("span",{className:"badge ".concat(i?"failed":"done"===e.status?"done":""),children:e.status})]}),"reply"===e.kind&&e.notes&&(0,n.jsx)("p",{className:"story-notes",children:e.notes}),(0,n.jsx)("button",{type:"button",className:"linkish small",onClick:()=>M(t),children:s?f("story.hideText"):f("story.showText",{n:e.text.length})}),s&&(0,n.jsx)("pre",{className:"story-out",children:e.text})]},t)},O=m.close,W=O&&"done"!==O.status;return(0,n.jsxs)("div",{className:"story-box",ref:E,children:[(0,n.jsxs)("div",{className:"row small",style:{marginBottom:6},children:[(0,n.jsxs)("label",{className:"option-inline",children:[(0,n.jsx)("input",{type:"checkbox",checked:j,onChange:e=>y(e.target.checked)})," ",f("story.showChat")]}),(0,n.jsxs)("label",{className:"option-inline",children:[(0,n.jsx)("input",{type:"checkbox",checked:k,onChange:e=>v(e.target.checked)})," ",f("story.showCommands")]}),m.live&&(0,n.jsxs)("span",{className:"live",children:[(0,n.jsx)("span",{className:"dot","aria-hidden":"true"})," ",f("story.live")]}),m.live&&!R.following&&(0,n.jsx)("button",{type:"button",className:"quiet small",onClick:R.follow,title:f("story.followWhy"),children:f("story.follow")}),x&&(0,n.jsx)("span",{className:"err",children:x})]}),(0,n.jsxs)("div",{className:"story-fixed",children:[(0,n.jsx)("strong",{children:f("story.prompt")}),(0,n.jsx)("pre",{className:"story-out always",children:m.prompt})]}),(0,n.jsx)("div",{ref:R.ref,className:"story-scroll".concat(m.live?" live":""),children:(0,n.jsx)("ol",{className:"story",children:m.entries.map((e,t)=>H(e,"e".concat(t)))})}),O?(0,n.jsxs)("div",{className:"story-fixed close".concat(W?" failed":""),children:[(0,n.jsx)("strong",{children:W?f("story.endedBadly",{status:O.status}):f("story.ended")}),O.reason&&(0,n.jsx)("p",{className:"err small",children:O.reason}),O.summary&&(0,n.jsx)(c.s,{text:O.summary,className:"what"}),O.checks&&O.checks.length>0&&(0,n.jsx)("ul",{className:"small",style:{margin:"6px 0 0",paddingLeft:18},children:O.checks.map((e,t)=>(0,n.jsxs)("li",{className:e.passed?"":"err",children:[e.passed?"✓":"✗"," ",e.name,!e.passed&&e.detail?" — ".concat(e.detail):""]},t))})]}):(0,n.jsx)("div",{className:"story-fixed muted small",children:f("story.notEnded")})]})}function u(e){let{at:t}=e,s=(0,i.W3)(),{locale:l}=(0,i.kj)();if(!t)return null;let a=new Date(t),r="bg"===l?"bg-BG":void 0,c=a.toLocaleTimeString(r,{hour12:!1}),d=new Date().toDateString()===a.toDateString();return(0,n.jsx)("time",{className:"story-when",dateTime:t,title:s(t),children:d?c:"".concat(a.toLocaleDateString(r)," ").concat(c)})}},7908:(e,t,s)=>{s.d(t,{U:()=>l});var n=s(1521);function l(e,t){let[s,l]=(0,n.useState)(null),a=(0,n.useRef)(!0),[i,r]=(0,n.useState)(!0),c=(0,n.useCallback)(e=>l(e),[]);return(0,n.useLayoutEffect)(()=>{if(!s)return;let e=()=>{let e=s.scrollHeight-s.scrollTop-s.clientHeight<=24;a.current=e,r(e)};return s.addEventListener("scroll",e,{passive:!0}),()=>s.removeEventListener("scroll",e)},[s]),(0,n.useLayoutEffect)(()=>{s&&e&&a.current&&(s.scrollTop=s.scrollHeight)},[s,e,t]),{ref:c,following:i,follow:(0,n.useCallback)(()=>{a.current=!0,r(!0),s&&(s.scrollTop=s.scrollHeight)},[s])}}},8934:(e,t,s)=>{s.d(t,{C:()=>d});var n=s(3365),l=s(1521),a=s(5549),i=s(4969),r=s(867);function c(e){if(null===e||""===e)return[];let t=e.split(/\r?\n/);return""===t[t.length-1]&&t.pop(),t}function d(e){let{sessionId:t,taskId:s,runId:a,title:i,files:c}=e,{t:d}=(0,r.kj)(),[u,h]=(0,l.useState)(!1);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{type:"button",className:"linkish",onClick:()=>h(!0),title:d("diff.openWhy"),children:d("diff.open",{n:c})}),u&&(0,n.jsx)(o,{sessionId:t,taskId:s,runId:a,title:i,onClose:()=>h(!1)})]})}function o(e){var t,s,d,o,h,f,m;let{sessionId:p,taskId:x,runId:g,title:j,onClose:y}=e,{t:k}=(0,r.kj)(),[v,b]=(0,l.useState)(null),[N,w]=(0,l.useState)(""),[S,C]=(0,l.useState)(0),[q,I]=(0,l.useState)(new Map),[F,R]=(0,l.useState)(!1),[E,L]=(0,l.useState)(!0),[T,M]=(0,l.useState)(new Map),[H,O]=(0,l.useState)(-1),W=(0,l.useRef)(null),D=(0,l.useRef)(null),G=(0,l.useRef)(null);(0,i.V)(D,!0,G),(0,l.useEffect)(()=>{a.FH.taskChanges(p,x,g).then(b).catch(e=>w(e.message))},[p,x,g]);let Q=null!=(d=null==v?void 0:v.files)?d:[],P=Q[S];(0,l.useEffect)(()=>{!P||q.has(P.path)||a.FH.taskChangeFile(p,x,P.path,g).then(e=>I(t=>new Map(t).set(P.path,e))).catch(e=>I(t=>new Map(t).set(P.path,e.message)))},[P,q,p,x,g]);let A=P?q.get(P.path):void 0,B=(0,l.useMemo)(()=>!A||"string"==typeof A||A.binary||A.tooLarge?[]:function(e,t){let s=function(e,t){let s=0;for(;s<e.length&&s<t.length&&e[s]===t[s];)s+=1;let n=e.length,l=t.length;for(;n>s&&l>s&&e[n-1]===t[l-1];)n-=1,l-=1;let a=[];for(let e=0;e<s;e+=1)a.push({kind:"same",a:e,b:e});for(let i of function(e,t){let s=e.length,n=t.length;if(0===s)return t.map((e,t)=>({kind:"add",b:t}));if(0===n)return e.map((e,t)=>({kind:"del",a:t}));let l=s+n,a=l+1,i=new Int32Array(2*l+3),r=[];for(let c=0;c<=Math.min(l,2e3);c+=1){r.push(i.slice(a-c-1,a+c+2));for(let l=-c;l<=c;l+=2){let d=l===-c||l!==c&&i[a+l-1]<i[a+l+1]?i[a+l+1]:i[a+l-1]+1,o=d-l;for(;d<s&&o<n&&e[d]===t[o];)d+=1,o+=1;if(i[a+l]=d,d>=s&&o>=n)return function(e,t,s,n){let l=[],a=t.length,i=s.length;for(let t=n;t>0;t-=1){let s=e[t],n=e=>s[e+t+1],r=a-i,c=r===-t||r!==t&&n(r-1)<n(r+1)?r+1:r-1,d=n(c),o=d-c;for(;a>d&&i>o;)a-=1,i-=1,l.push({kind:"same",a:a,b:i});a===d?l.push({kind:"add",b:o}):l.push({kind:"del",a:d}),a=d,i=o}for(;a>0&&i>0;)a-=1,i-=1,l.push({kind:"same",a:a,b:i});return l.reverse()}(r,e,t,c)}}return[...e.map((e,t)=>({kind:"del",a:t})),...t.map((e,t)=>({kind:"add",b:t}))]}(e.slice(s,n),t.slice(s,l)))a.push({kind:i.kind,...void 0!==i.a?{a:i.a+s}:{},...void 0!==i.b?{b:i.b+s}:{}});for(let t=0;n+t<e.length;t+=1)a.push({kind:"same",a:n+t,b:l+t});return a}(e,t),n=[];for(let l=0;l<s.length;){let a=s[l];if("same"===a.kind){n.push({kind:"same",left:{no:a.a+1,text:e[a.a]},right:{no:a.b+1,text:t[a.b]}}),l+=1;continue}let i=[],r=[];for(;l<s.length&&"same"!==s[l].kind;){let e=s[l];"del"===e.kind?i.push(e.a):r.push(e.b),l+=1}let c=Math.max(i.length,r.length);for(let s=0;s<c;s+=1){let l=i[s],a=r[s];n.push({kind:void 0!==l&&void 0!==a?"change":void 0!==l?"del":"add",...void 0!==l?{left:{no:l+1,text:e[l]}}:{},...void 0!==a?{right:{no:a+1,text:t[a]}}:{}})}}return n}(c(A.before),c(A.after)),[A]),V=P&&T.get(P.path)||new Set,_=(0,l.useMemo)(()=>(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Set,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(n)return e.map((e,t)=>({type:"row",row:e,index:t}));let l=[];for(let n=0;n<e.length;){if("same"!==e[n].kind){l.push({type:"row",row:e[n],index:n}),n+=1;continue}let a=n;for(;a<e.length&&"same"===e[a].kind;)a+=1;let i=0===n?0:t,r=a===e.length?0:t,c=a-n-i-r;if(c>1&&!s.has(n+i)){for(let t=n;t<n+i;t+=1)l.push({type:"row",row:e[t],index:t});l.push({type:"gap",from:n+i,count:c});for(let t=a-r;t<a;t+=1)l.push({type:"row",row:e[t],index:t})}else for(let t=n;t<a;t+=1)l.push({type:"row",row:e[t],index:t});n=a}return l})(B,3,V,F),[B,V,F]),K=(0,l.useMemo)(()=>B.flatMap((e,t)=>"same"!==e.kind&&(0===t||"same"===B[t-1].kind)?[t]:[]),[B]);(0,l.useEffect)(()=>{O(-1),W.current&&(W.current.scrollTop=0)},[S]);let U=(0,l.useCallback)(e=>{var t;if(0===K.length)return;let s=H<0?1===e?0:K.length-1:Math.min(K.length-1,Math.max(0,H+e));O(s);let n=null==(t=W.current)?void 0:t.querySelector('[data-row="'.concat(K[s],'"]'));null==n||n.scrollIntoView({block:"center"})},[H,K]),$=(0,l.useCallback)(e=>C(t=>Math.min(Math.max(0,t+e),Math.max(0,Q.length-1))),[Q.length]);(0,l.useEffect)(()=>{let e=e=>{if(!e.ctrlKey&&!e.metaKey&&!e.altKey){if("Escape"===e.key)y();else if("n"===e.key)U(1);else if("p"===e.key)U(-1);else if("]"===e.key)$(1);else{if("["!==e.key)return;$(-1)}e.preventDefault()}};window.addEventListener("keydown",e);let t=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",e),document.body.style.overflow=t}},[U,$,y]);let z=Q.reduce((e,t)=>({added:e.added+Math.max(0,t.added),removed:e.removed+Math.max(0,t.removed)}),{added:0,removed:0});return(0,n.jsxs)("div",{ref:D,className:"diff-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"diff-title",children:[(0,n.jsxs)("div",{className:"diff-head",children:[(0,n.jsx)("h2",{id:"diff-title",children:k("diff.title",{title:j})}),(null==v?void 0:v.ok)&&(0,n.jsxs)("span",{className:"muted small",children:[v.branch?"".concat(v.branch," \xb7 "):"",null==(t=v.base)?void 0:t.slice(0,8)," → ",null==(s=v.commit)?void 0:s.slice(0,8)," \xb7 ",k("diff.summary",{n:Q.length,a:z.added,r:z.removed})]}),(0,n.jsx)("span",{className:"grow"}),(0,n.jsx)("span",{className:"muted small",children:k("diff.keys")}),(0,n.jsx)("button",{ref:G,type:"button",onClick:y,children:k("diff.close")})]}),N&&(0,n.jsx)("div",{className:"err",style:{padding:12},children:N}),!v&&!N&&(0,n.jsx)("div",{className:"muted",style:{padding:12},children:k("diff.loading")}),v&&!v.ok&&(0,n.jsx)("div",{className:"notice caution",style:{margin:12},children:v.problem}),(null==v?void 0:v.ok)&&0===Q.length&&(0,n.jsx)("div",{className:"notice",style:{margin:12},children:k("diff.nothing")}),(null==v?void 0:v.ok)&&Q.length>0&&(0,n.jsxs)("div",{className:"diff-body",children:[(0,n.jsx)("nav",{className:"diff-files","aria-label":k("diff.files"),children:Q.map((e,t)=>{let s=e.path.lastIndexOf("/");return(0,n.jsxs)("button",{type:"button",className:"diff-file".concat(t===S?" on":""),onClick:()=>C(t),title:e.oldPath?"".concat(e.oldPath," → ").concat(e.path):e.path,children:[(0,n.jsx)("span",{className:"diff-status s-".concat(e.status),children:e.status}),(0,n.jsxs)("span",{className:"diff-path",children:[s>=0&&(0,n.jsx)("span",{className:"muted",children:e.path.slice(0,s+1)}),(0,n.jsx)("strong",{children:e.path.slice(s+1)})]}),(0,n.jsx)("span",{className:"diff-counts",children:e.added<0?k("diff.binaryShort"):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{className:"plus",children:["+",e.added]})," ",(0,n.jsxs)("span",{className:"minus",children:["−",e.removed]})]})})]},e.path)})}),(0,n.jsxs)("div",{className:"diff-main",children:[P&&(0,n.jsxs)("div",{className:"diff-toolbar",children:[(0,n.jsx)("strong",{className:"diff-name",children:P.oldPath?"".concat(P.oldPath," → ").concat(P.path):P.path}),(0,n.jsx)("span",{className:"muted small",children:"A"===P.status?k("diff.added"):"D"===P.status?k("diff.deleted"):"R"===P.status?k("diff.renamed"):""}),(0,n.jsx)("span",{className:"grow"}),(0,n.jsx)("button",{type:"button",className:"quiet",onClick:()=>U(-1),disabled:0===K.length,children:k("diff.prevChange")}),(0,n.jsx)("button",{type:"button",className:"quiet",onClick:()=>U(1),disabled:0===K.length,children:k("diff.nextChange")}),(0,n.jsx)("span",{className:"muted small",children:K.length>0?k("diff.changeN",{i:H<0?"–":H+1,n:K.length}):""}),(0,n.jsx)("button",{type:"button",className:"quiet",onClick:()=>$(-1),disabled:0===S,children:k("diff.prevFile")}),(0,n.jsx)("button",{type:"button",className:"quiet",onClick:()=>$(1),disabled:S>=Q.length-1,children:k("diff.nextFile")}),(0,n.jsxs)("label",{className:"option-inline",children:[(0,n.jsx)("input",{type:"checkbox",checked:F,onChange:e=>R(e.target.checked)})," ",k("diff.whole")]}),(0,n.jsxs)("label",{className:"option-inline",children:[(0,n.jsx)("input",{type:"checkbox",checked:E,onChange:e=>L(e.target.checked)})," ",k("diff.wrap")]})]}),(0,n.jsxs)("div",{className:"diff-scroll",ref:W,children:[void 0===A&&(0,n.jsx)("div",{className:"muted",style:{padding:12},children:k("diff.loading")}),"string"==typeof A&&(0,n.jsx)("div",{className:"err",style:{padding:12},children:A}),A&&"string"!=typeof A&&A.binary&&(0,n.jsx)("div",{className:"notice",style:{margin:12},children:k("diff.binary")}),A&&"string"!=typeof A&&A.tooLarge&&(0,n.jsx)("div",{className:"notice",style:{margin:12},children:k("diff.tooLarge")}),A&&"string"!=typeof A&&!A.binary&&!A.tooLarge&&(0,n.jsxs)(n.Fragment,{children:[(null!=(o=A.before)?o:"").includes("\r\n")!==(null!=(h=A.after)?h:"").includes("\r\n")&&null!==A.before&&null!==A.after&&(0,n.jsx)("div",{className:"notice small",style:{margin:8},children:k("diff.eol",{from:(null!=(f=A.before)?f:"").includes("\r\n")?"CRLF":"LF",to:(null!=(m=A.after)?m:"").includes("\r\n")?"CRLF":"LF"})}),B.length>0&&0===K.length&&(0,n.jsx)("div",{className:"notice small",style:{margin:8},children:k("diff.sameText")}),(0,n.jsxs)("table",{className:"diff-table".concat(E?"":" nowrap"),children:[(0,n.jsxs)("colgroup",{children:[(0,n.jsx)("col",{className:"num"}),(0,n.jsx)("col",{}),(0,n.jsx)("col",{className:"num"}),(0,n.jsx)("col",{})]}),(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{colSpan:2,children:k("diff.before")}),(0,n.jsx)("th",{colSpan:2,children:k("diff.after")})]})}),(0,n.jsx)("tbody",{children:_.map(e=>"gap"===e.type?(0,n.jsx)("tr",{className:"diff-gap",children:(0,n.jsx)("td",{colSpan:4,children:(0,n.jsx)("button",{type:"button",className:"linkish small",onClick:()=>{var t;return t=e.from,void(P&&M(e=>{var s;return new Map(e).set(P.path,new Set([...null!=(s=e.get(P.path))?s:[],t]))}))},children:k("diff.gap",{n:e.count})})})},"g".concat(e.from)):(0,n.jsx)(u,{row:e.row,index:e.index,current:H>=0&&K[H]===e.index},e.index))})]})]})]})]})]})]})}function u(e){var t,s,a,i;let{row:r,index:c,current:d}=e,o="change"===r.kind?function(e,t){let s=0;for(;s<e.length&&s<t.length&&e[s]===t[s];)s+=1;let n=e.length,l=t.length;for(;n>s&&l>s&&e[n-1]===t[l-1];)n-=1,l-=1;return{start:s,leftEnd:n,rightEnd:l}}(r.left.text,r.right.text):null,u=e=>{let t=r[e];if(!t)return null;if(!o)return t.text;let s="left"===e?o.leftEnd:o.rightEnd;return(0,n.jsxs)(l.Fragment,{children:[t.text.slice(0,o.start),(0,n.jsx)("mark",{children:t.text.slice(o.start,s)}),t.text.slice(s)]})};return(0,n.jsxs)("tr",{className:"diff-row ".concat(r.kind).concat(d?" current":""),"data-row":c,children:[(0,n.jsx)("td",{className:"num",children:null!=(a=null==(t=r.left)?void 0:t.no)?a:""}),(0,n.jsx)("td",{className:"code l".concat(r.left?"":" empty"),children:u("left")}),(0,n.jsx)("td",{className:"num",children:null!=(i=null==(s=r.right)?void 0:s.no)?i:""}),(0,n.jsx)("td",{className:"code r".concat(r.right?"":" empty"),children:u("right")})]})}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[189],{1035:(e,l,t)=>{"use strict";t.d(l,{DialogHost:()=>c,Z:()=>d});var a=t(3365),n=t(1521),s=t(867),r=t(4969);let i=null,o=[];function d(e){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(t=>{var a;return a={kind:"confirm",message:e,...l,resolve:t},void(i?i(a):o.push(a))})}function c(e){var l,t;let{children:d}=e,{t:c}=(0,s.kj)(),[u,m]=(0,n.useState)([]),h=(0,n.useRef)(null),p=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(i=e=>m(l=>[...l,e]),o.length>0){let e=o.splice(0,o.length);m(l=>[...l,...e])}return()=>{i=null}},[]);let x=u[0],j=(0,n.useCallback)(e=>{x&&(x.resolve(e),m(e=>e.slice(1)))},[x]);return(0,r.V)(p,!!x,h),(0,n.useEffect)(()=>{if(!x)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),j(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[x,j]),(0,a.jsxs)(a.Fragment,{children:[d,x&&(0,a.jsx)("div",{className:"modal-backdrop",onClick:()=>j(!1),role:"presentation",children:(0,a.jsxs)("div",{ref:p,className:"modal".concat(x.danger?" danger":""),role:"confirm"===x.kind?"alertdialog":"dialog","aria-modal":"true","aria-labelledby":"modal-title","aria-describedby":"modal-body",onClick:e=>e.stopPropagation(),children:[(0,a.jsx)("h2",{id:"modal-title",children:null!=(l=x.title)?l:c("confirm"===x.kind?"dialog.confirmTitle":"dialog.noticeTitle")}),(0,a.jsx)("div",{id:"modal-body",className:"modal-body",children:x.message}),(0,a.jsxs)("div",{className:"row modal-actions",children:["confirm"===x.kind&&(0,a.jsx)("button",{type:"button",className:"quiet",onClick:()=>j(!1),children:c("dialog.cancel")}),(0,a.jsx)("button",{ref:h,type:"button",className:x.danger?"danger":"primary",onClick:()=>j(!0),children:null!=(t=x.okLabel)?t:c("dialog.ok")})]})]})})]})}},1896:(e,l,t)=>{Promise.resolve().then(t.bind(t,3197))},3197:(e,l,t)=>{"use strict";t.r(l),t.d(l,{default:()=>m});var a=t(3365),n=t(1521),s=t(8596),r=t(8197),i=t.n(r),o=t(5549),d=t(867),c=t(1035),u=t(4784);function m(){let{t:e}=(0,d.kj)(),[l,t]=(0,n.useState)(null),[s,r]=(0,n.useState)(!1),[i,u]=(0,n.useState)("");(0,n.useEffect)(()=>{o.FH.models().then(t).catch(()=>void 0)},[]);let m=async()=>{if(await (0,c.Z)(e("model.refreshConfirm"))){r(!0),u(e("model.refreshing"));try{var l;let a=await o.FH.models().then(()=>o.FH.refreshModels());t(a),u(0===a.options.length?null!=(l=a.note)?l:e("model.none"):e("model.refreshed",{n:a.options.length}))}catch(e){u(e.message)}finally{r(!1)}}},h={catalogue:l,setCatalogue:t,refreshModels:m,refreshing:s,refreshMsg:i};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"panel",children:[(0,a.jsx)("h2",{children:e("def.title")}),(0,a.jsx)("p",{className:"muted small",children:e("def.intro")}),(0,a.jsx)("p",{className:"why",children:e("def.autoSave")})]}),(0,a.jsx)(v,{}),(0,a.jsx)(y,{}),(0,a.jsx)(b,{...h}),(0,a.jsx)(N,{...h}),(0,a.jsx)(g,{})]})}function h(e){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:900,t=(0,n.useRef)(null),a=(0,n.useRef)(null),s=(0,n.useRef)(e);return s.current=e,(0,n.useEffect)(()=>()=>{t.current&&clearTimeout(t.current),a.current&&s.current(a.current.value)},[]),e=>{t.current&&clearTimeout(t.current),a.current={value:e},t.current=setTimeout(()=>{a.current=null,s.current(e)},l)}}function p(e){let{id:l,value:t,min:s,max:r,onChange:i,disabled:o}=e,[d,c]=(0,n.useState)(String(t));return(0,n.useEffect)(()=>c(e=>x(e)===t?e:String(t)),[t]),(0,a.jsx)("input",{id:l,type:"number",min:s,max:r,step:1,value:d,onChange:e=>{c(e.target.value);let l=x(e.target.value);null!==l&&l>=s&&l<=r&&i(l)},onBlur:()=>{let e=x(d),l=null===e?t:Math.max(s,Math.min(r,e));c(String(l)),l!==t&&i(l)},style:{width:"9ch"},disabled:o})}function x(e){if(""===e.trim())return null;let l=Number(e);return Number.isInteger(l)?l:null}function j(e){let{msg:l,onSave:t}=e,{t:n}=(0,d.kj)();return(0,a.jsxs)("div",{className:"row",style:{marginTop:6},children:[t&&(0,a.jsx)("button",{className:"quiet",onClick:t,title:n("def.saveAnywayWhy"),children:n("def.saveAnyway")}),(0,a.jsx)("span",{className:"muted small",role:"status",children:l||n("def.savedAutomatically")})]})}function v(){var e;let{t:l}=(0,d.kj)(),[t,s]=(0,n.useState)(null),[r,i]=(0,n.useState)(""),[c,u]=(0,n.useState)(""),[m,p]=(0,n.useState)(""),[x,v]=(0,n.useState)(""),[g,y]=(0,n.useState)(!1),[b,w]=(0,n.useState)(""),[N,k]=(0,n.useState)(""),C=(0,n.useCallback)(async()=>{try{let e=await o.FH.project();s(e),i(e.rootDir),u(e.name),v("")}catch(e){v(e.message)}},[]);(0,n.useEffect)(()=>{C()},[C]);let S=async(e,l)=>{y(!0),p("");try{let t=await o.FH.setProject(e);return s(t),i(t.rootDir),p(l(t)),v(""),!0}catch(e){return v(e.message),!1}finally{y(!1)}},F=e=>S({rootDir:e},e=>e.rootDir?l("proj.saved",{dir:e.rootDir}):l("proj.cleared")),R=e=>S({name:e},()=>l("proj.nameSaved")),M=h(F),T=h(R),E=async(e,l)=>{y(!0);try{var t;let a=await o.FH.browseFolder(l.trim()||void 0);a.ok?e(a.path):a.cancelled||v(null!=(t=a.reason)?t:"")}catch(e){v(e.message)}finally{y(!1)}},D=null!=(e=null==t?void 0:t.others)?e:[],B=e=>e.map(e=>({name:e.name,rootDir:e.rootDir})),A=async()=>{await S({others:[...B(D),{name:b.trim(),rootDir:N.trim()}]},e=>l("proj.othersSaved",{n:e.others.length}))&&(w(""),k(""))};return(0,a.jsxs)("div",{className:"panel",id:"project",children:[(0,a.jsx)("h2",{children:l("proj.title")}),(0,a.jsx)("p",{className:"muted small",children:l("proj.intro")}),x&&(0,a.jsx)("div",{className:"err",children:x}),(0,a.jsx)("p",{className:"muted small",children:l("proj.listIntro")}),(0,a.jsx)(f,{name:c,dir:r,repoOk:!!(null==t?void 0:t.repoOk),repoProblem:null==t?void 0:t.repoProblem,isDefault:!0,busy:g,onNameInput:e=>{u(e),T(e)},onName:e=>void R(e),onDirInput:e=>{i(e),M(e)},onDir:e=>void F(e),onBrowse:()=>void E(e=>void F(e),r),onRemove:(null==t?void 0:t.rootDir)?()=>void F(""):void 0,removeLabel:l("proj.clear")}),(0,a.jsx)(j,{msg:m}),t&&!t.rootDir&&(0,a.jsx)("p",{className:"muted small",style:{marginTop:8},children:l("proj.none")}),D.map((e,t)=>(0,a.jsx)(f,{name:e.name,dir:e.rootDir,repoOk:e.repoOk,repoProblem:e.repoProblem,busy:g,onName:t=>void S({others:B(D.map(l=>l.name===e.name?{...l,name:t}:l))},()=>l("proj.nameSaved")),onDir:t=>void S({others:B(D.map(l=>l.name===e.name?{...l,rootDir:t}:l))},()=>l("proj.othersSaved",{n:D.length})),onBrowse:()=>void E(t=>void S({others:B(D.map(l=>l.name===e.name?{...l,rootDir:t}:l))},()=>l("proj.othersSaved",{n:D.length})),e.rootDir),onRemove:()=>{let t;t=e.name,S({others:B(D.filter(e=>e.name!==t))},e=>l("proj.othersSaved",{n:e.others.length}))},removeLabel:l("proj.otherRemove")},"other-".concat(t))),(0,a.jsx)("h3",{id:"others",children:l("proj.addTitle")}),(0,a.jsx)("p",{className:"muted small",children:l("proj.othersIntro")}),(0,a.jsxs)("div",{className:"row",style:{marginTop:8},children:[(0,a.jsx)("input",{type:"text","aria-label":l("proj.entryName"),value:b,onChange:e=>w(e.target.value),placeholder:l("proj.entryName"),disabled:g,style:{width:160}}),(0,a.jsx)("input",{type:"text",className:"grow","aria-label":l("proj.entryDir"),value:N,onChange:e=>k(e.target.value),placeholder:"C:\\Projects\\my-app-tests",disabled:g}),(0,a.jsx)("button",{onClick:()=>void E(e=>k(e),N),disabled:g,children:l("mirror.browse")}),(0,a.jsx)("button",{className:"primary",onClick:()=>void A(),disabled:g||!b.trim()||!N.trim(),children:l("proj.otherAdd")})]}),(0,a.jsx)("h3",{children:l("proj.affects")}),(0,a.jsxs)("ul",{className:"muted small",style:{margin:0,paddingLeft:20},children:[(0,a.jsx)("li",{children:l("proj.affectsNew")}),(0,a.jsx)("li",{children:l("proj.affectsExisting")}),(0,a.jsx)("li",{children:l("proj.affectsPlan")}),(0,a.jsx)("li",{children:l("proj.affectsNever")})]})]})}function f(e){var l;let{name:t,dir:r,repoOk:i,repoProblem:o,isDefault:c=!1,busy:u,onNameInput:m,onName:h,onDirInput:p,onDir:x,onBrowse:j,onRemove:v,removeLabel:f}=e,{t:g}=(0,d.kj)(),y=(0,n.useId)(),[b,w]=(0,n.useState)(t),[N,k]=(0,n.useState)(r);return(0,n.useEffect)(()=>w(t),[t]),(0,n.useEffect)(()=>k(r),[r]),(0,a.jsxs)("div",{className:"panel inner",style:{marginTop:10},children:[(0,a.jsxs)("div",{className:"row",children:[(0,a.jsxs)("div",{style:{width:"min(200px, 100%)"},children:[(0,a.jsx)("label",{htmlFor:"".concat(y,"-name"),children:g("proj.entryName")}),(0,a.jsx)("input",{id:"".concat(y,"-name"),type:"text",value:b,onChange:e=>{w(e.target.value),null==m||m(e.target.value)},onBlur:()=>{(b!==t||m)&&h(b)},placeholder:r?null!=(l=r.replace(/[\/]+$/,"").split(/[\/]/).pop())?l:"":g("proj.namePlaceholder")})]}),(0,a.jsxs)("div",{className:"grow",children:[(0,a.jsx)("label",{htmlFor:"".concat(y,"-dir"),children:g("proj.entryDir")}),(0,a.jsx)("input",{id:"".concat(y,"-dir"),type:"text",value:N,onChange:e=>{k(e.target.value),null==p||p(e.target.value)},onBlur:()=>{(N!==r||p)&&x(N)},placeholder:"C:\\Projects\\my-app"})]}),(0,a.jsx)("button",{onClick:j,disabled:u,children:g("mirror.browse")}),v&&(0,a.jsx)("button",{className:"quiet",onClick:v,disabled:u,children:f})]}),(0,a.jsxs)("div",{className:"row small",style:{marginTop:6},children:[c&&(0,a.jsx)("span",{className:"chip",title:g("proj.isDefaultWhy"),children:g("proj.isDefault")}),r&&(0,a.jsx)("span",{className:"badge ".concat(i?"done":""),title:i?g("proj.isRepo"):o,children:g(i?"proj.otherRepo":"proj.otherNotRepo")}),r&&!i&&(0,a.jsx)("span",{className:"muted",children:o||g("proj.notRepoWhy")})]}),r&&i&&(0,a.jsx)(s.E,{dir:r})]})}function g(){let{t:e}=(0,d.kj)(),[l,t]=(0,n.useState)(null),s=(0,n.useRef)(null),r=(0,n.useRef)(Promise.resolve()),[i,c]=(0,n.useState)(2),[u,m]=(0,n.useState)(3),[x,v]=(0,n.useState)(2),[f,g]=(0,n.useState)(2),[y,b]=(0,n.useState)(60),[w,N]=(0,n.useState)(240),[k,C]=(0,n.useState)(900),[S,F]=(0,n.useState)("none"),[R,M]=(0,n.useState)("confirm"),[T,E]=(0,n.useState)("ask"),[D,B]=(0,n.useState)("off"),[A,H]=(0,n.useState)(""),[I,W]=(0,n.useState)("");(0,n.useEffect)(()=>{o.FH.settings().then(e=>{var l,a,n,r,i,o,d;s.current=e.raw,t(e.raw);let u=null!=(l=e.raw.limits)?l:{};m("number"==typeof u.autoContinue?u.autoContinue:3),c("number"==typeof u.retryBlockedInFreshChat?u.retryBlockedInFreshChat:2),v("number"==typeof u.minApproachesBeforeBlocked?u.minApproachesBeforeBlocked:2),g("number"==typeof u.maxReviewRounds?u.maxReviewRounds:2),b("number"==typeof u.maxIterations?u.maxIterations:60),N("number"==typeof u.maxRunMinutes?u.maxRunMinutes:240);let h=null!=(a=e.raw.copilot)?a:{};C("number"==typeof h.replyTimeoutSec?h.replyTimeoutSec:900);let p=null!=(n=e.raw.execution)?n:{};F(null!=(r=p.isolation)?r:"none"),M(null!=(i=p.mode)?i:"confirm"),E(null!=(o=p.networkFetch)?o:"ask"),B(null!=(d=p.planMode)?d:"off")}).catch(e=>W(e.message))},[]);let P=(l,a,n)=>{let i=async()=>{var r;if(!s.current)return;let i=await o.FH.settings().then(e=>e.raw).catch(()=>s.current),d={...i,[l]:{...null!=(r=i[l])?r:{},[a]:n}};H("");try{await o.FH.saveSettings(d),s.current=d,t(d),H(e("exec.saved")),W("")}catch(e){W(e.message)}},d=r.current.then(i);return r.current=d.catch(()=>void 0),d},L=h(e=>P("limits","retryBlockedInFreshChat",e)),O=h(e=>P("limits","autoContinue",e)),q=h(e=>P("limits","minApproachesBeforeBlocked",e)),U=h(e=>P("limits","maxReviewRounds",e)),_=h(e=>P("limits","maxIterations",e)),V=h(e=>P("limits","maxRunMinutes",e)),Y=h(e=>P("copilot","replyTimeoutSec",e)),K=(e,l)=>P("execution",e,l);return(0,a.jsxs)("div",{className:"panel",id:"execution",children:[(0,a.jsx)("h2",{children:e("exec.title")}),(0,a.jsx)("p",{className:"muted small",children:e("exec.intro")}),I&&(0,a.jsx)("div",{className:"err",children:I}),(0,a.jsx)("label",{htmlFor:"auto-continue",children:e("exec.autoContinue")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)(p,{id:"auto-continue",value:u,min:0,max:20,onChange:e=>{m(e),O(e)},disabled:!l}),(0,a.jsx)("span",{className:"muted small",children:e("exec.autoContinueUnit")})]}),(0,a.jsx)("p",{className:"why",children:e("exec.autoContinueWhy")}),(0,a.jsx)("label",{htmlFor:"min-approaches",children:e("exec.minApproaches")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)(p,{id:"min-approaches",value:x,min:2,max:20,onChange:e=>{v(e),q(e)},disabled:!l}),(0,a.jsx)("span",{className:"muted small",children:e("exec.minApproachesUnit")})]}),(0,a.jsx)("p",{className:"why",children:e("exec.minApproachesWhy")}),(0,a.jsx)("label",{htmlFor:"max-review-rounds",children:e("exec.maxReviewRounds")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)(p,{id:"max-review-rounds",value:f,min:1,max:6,onChange:e=>{g(e),U(e)},disabled:!l}),(0,a.jsx)("span",{className:"muted small",children:e("exec.maxReviewRoundsUnit")})]}),(0,a.jsx)("p",{className:"why",children:e("exec.maxReviewRoundsWhy")}),(0,a.jsx)("label",{htmlFor:"retry-blocked",children:e("exec.retryBlocked")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)(p,{id:"retry-blocked",value:i,min:0,max:5,onChange:e=>{c(e),L(e)},disabled:!l}),(0,a.jsx)("span",{className:"muted small",children:e("exec.retryBlockedTimes")})]}),(0,a.jsx)("p",{className:"why",children:e("exec.retryBlockedWhy")}),(0,a.jsx)("label",{htmlFor:"max-iterations",children:e("exec.maxIterations")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)(p,{id:"max-iterations",value:y,min:5,max:200,onChange:e=>{b(e),_(e)},disabled:!l}),(0,a.jsx)("span",{className:"muted small",children:e("exec.maxIterationsUnit")})]}),(0,a.jsx)("p",{className:"why",children:e("exec.maxIterationsWhy")}),(0,a.jsx)("label",{htmlFor:"max-minutes",children:e("exec.maxRunMinutes")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)(p,{id:"max-minutes",value:w,min:10,max:1440,onChange:e=>{N(e),V(e)},disabled:!l}),(0,a.jsx)("span",{className:"muted small",children:e("exec.maxRunMinutesUnit")})]}),(0,a.jsx)("p",{className:"why",children:e("exec.maxRunMinutesWhy")}),(0,a.jsx)("label",{htmlFor:"reply-timeout",children:e("exec.replyTimeout")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)(p,{id:"reply-timeout",value:k,min:60,max:10800,onChange:e=>{C(e),Y(e)},disabled:!l}),(0,a.jsx)("span",{className:"muted small",children:e("exec.replyTimeoutUnit")})]}),(0,a.jsx)("p",{className:"why",children:e("exec.replyTimeoutWhy")}),(0,a.jsx)("label",{htmlFor:"isolation",children:e("exec.isolation")}),(0,a.jsxs)("select",{id:"isolation",value:S,onChange:e=>{let l=e.target.value;F(l),K("isolation",l)},disabled:!l,children:[(0,a.jsx)("option",{value:"none",children:e("exec.isolationNone")}),(0,a.jsx)("option",{value:"none-accepted",children:e("exec.isolationNoneAccepted")}),(0,a.jsx)("option",{value:"separate-account",children:e("exec.isolationAccount")}),(0,a.jsx)("option",{value:"sandbox",children:e("exec.isolationSandbox")}),(0,a.jsx)("option",{value:"vm",children:e("exec.isolationVm")})]}),(0,a.jsx)("p",{className:"why",children:e("exec.isolationWhy")}),(0,a.jsx)("label",{htmlFor:"start-mode",children:e("exec.startMode")}),(0,a.jsxs)("select",{id:"start-mode",value:R,onChange:e=>{let l=e.target.value;M(l),K("mode",l)},disabled:!l,children:[(0,a.jsx)("option",{value:"confirm",children:e("exec.startModeAsk")}),(0,a.jsx)("option",{value:"unattended",children:e("exec.startModeAuto")})]}),(0,a.jsx)("p",{className:"why",children:e("exec.startModeWhy")}),(0,a.jsx)("label",{htmlFor:"network-fetch",children:e("exec.networkFetch")}),(0,a.jsxs)("select",{id:"network-fetch",value:T,onChange:e=>{let l=e.target.value;E(l),K("networkFetch",l)},disabled:!l,children:[(0,a.jsx)("option",{value:"ask",children:e("exec.networkFetchAsk")}),(0,a.jsx)("option",{value:"refuse",children:e("exec.networkFetchRefuse")}),(0,a.jsx)("option",{value:"run",children:e("exec.networkFetchRun")})]}),(0,a.jsx)("p",{className:"why",children:e("exec.networkFetchWhy")}),(0,a.jsx)("label",{htmlFor:"plan-mode",children:e("pm.setting")}),(0,a.jsxs)("select",{id:"plan-mode",value:D,onChange:e=>{let l=e.target.value;B(l),K("planMode",l)},disabled:!l,children:[(0,a.jsx)("option",{value:"off",children:e("pm.off")}),(0,a.jsx)("option",{value:"auto",children:e("pm.auto")}),(0,a.jsx)("option",{value:"approve",children:e("pm.approveMode")})]}),(0,a.jsx)(j,{msg:A}),(0,a.jsx)("p",{className:"why",children:e("pm.settingWhy")})]})}function y(){let{t:e}=(0,d.kj)(),[l,t]=(0,n.useState)(""),[s,r]=(0,n.useState)(!1),[i,c]=(0,n.useState)(""),[u,m]=(0,n.useState)(""),h=async()=>{r(!0),m(""),c(e("login.waiting"));try{let e=await o.FH.login(l);e.ok?c(e.message):(c(""),m(e.message))}catch(e){c(""),m(e.message)}finally{r(!1)}};return(0,a.jsxs)("div",{className:"panel",id:"login",children:[(0,a.jsx)("h2",{children:e("login.title")}),(0,a.jsx)("p",{className:"muted small",children:e("login.intro")}),u&&(0,a.jsx)("div",{className:"err",children:u}),(0,a.jsx)("label",{htmlFor:"login-account",children:e("login.account")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("input",{id:"login-account",type:"email",className:"grow",value:l,onChange:e=>t(e.target.value),placeholder:"name@company.com",disabled:s}),(0,a.jsx)("button",{className:"primary",onClick:()=>void h(),disabled:s,children:s?e("login.busy"):e("login.button")})]}),(0,a.jsx)("p",{className:"why",children:e("login.accountWhy")}),i&&(0,a.jsx)("div",{className:"small",role:"status",children:i})]})}function b(e){var l;let{catalogue:t,setCatalogue:s,refreshModels:r,refreshing:i,refreshMsg:c}=e,{t:m}=(0,d.kj)(),h=(0,d.W3)(),[p,x]=(0,n.useState)(""),[v,f]=(0,n.useState)(""),[g,y]=(0,n.useState)(!1),b=null!=(l=null==t?void 0:t.defaultModel)?l:"",N=async e=>{y(!0),x("");try{let l=await o.FH.setDefaultModel(e);t&&s({...t,defaultModel:l.defaultModel}),x(l.defaultModel?m("def.modelSaved",{name:l.defaultModel}):m("def.modelCleared")),f("")}catch(e){f(e.message)}finally{y(!1)}};return(0,a.jsxs)("div",{className:"panel",id:"model",children:[(0,a.jsx)("h2",{children:m("def.modelTitle")}),(0,a.jsx)("p",{className:"muted small",children:m("def.modelIntro")}),v&&(0,a.jsx)("div",{className:"err",children:v}),(0,a.jsx)("label",{htmlFor:"default-model",children:m("def.modelField")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)(u.Y,{id:"default-model",chosen:b,onChange:e=>void N(e),none:m("def.modelNone"),catalogue:t,disabled:g||i}),(0,a.jsx)("button",{className:"quiet",onClick:()=>void N(""),disabled:g||!b,children:m("proj.clear")}),(0,a.jsx)("button",{onClick:()=>void r(),disabled:g||i,children:m("model.refresh")})]}),(0,a.jsx)(j,{msg:p||c}),(0,a.jsx)("p",{className:"muted small",style:{marginTop:8},children:(null==t?void 0:t.readAt)?m("model.readAt",{t:h(t.readAt),n:t.options.length}):m("model.neverRead")}),(0,a.jsx)(w,{}),(0,a.jsx)("h3",{children:m("proj.affects")}),(0,a.jsxs)("ul",{className:"muted small",style:{margin:0,paddingLeft:20},children:[(0,a.jsx)("li",{children:m("def.modelAffectsNew")}),(0,a.jsx)("li",{children:m("def.modelAffectsExisting")}),(0,a.jsx)("li",{children:m("def.modelAffectsBatch")})]})]})}function w(){let{t:e}=(0,d.kj)(),[l,t]=(0,n.useState)(null),[s,r]=(0,n.useState)("");(0,n.useEffect)(()=>{o.FH.settings().then(e=>{var l;return t((null==(l=e.raw.copilot)?void 0:l.manualModel)===!0)}).catch(e=>r(e.message))},[]);let i=async e=>{t(e);try{var l;let t=await o.FH.settings();await o.FH.saveSettings({...t.raw,copilot:{...null!=(l=t.raw.copilot)?l:{},manualModel:e}}),r("")}catch(e){r(e.message)}};return(0,a.jsxs)("div",{style:{marginTop:12},children:[(0,a.jsxs)("label",{className:"row",style:{gap:8,alignItems:"center"},children:[(0,a.jsx)("input",{id:"manual-model",type:"checkbox",checked:!0===l,disabled:null===l,onChange:e=>void i(e.target.checked)}),(0,a.jsx)("span",{children:e("def.manualModel")})]}),(0,a.jsx)("p",{className:"why",children:e("def.manualModelWhy")}),s&&(0,a.jsx)("div",{className:"err",children:s})]})}function N(e){var l,t;let{catalogue:s,setCatalogue:r,refreshModels:c,refreshing:m,refreshMsg:h}=e,{t:p}=(0,d.kj)(),[x,v]=(0,n.useState)(""),[f,g]=(0,n.useState)(""),[y,b]=(0,n.useState)(!1),w=null!=(l=null==s?void 0:s.defaultReviewModel)?l:"",N=async e=>{b(!0),v("");try{let l=await o.FH.setDefaultReviewModel(e);s&&r({...s,defaultReviewModel:l.defaultReviewModel}),v(l.defaultReviewModel?p("def.reviewSaved",{name:l.defaultReviewModel}):p("def.reviewCleared")),g("")}catch(e){g(e.message)}finally{b(!1)}},k=""!==w&&w===(null!=(t=null==s?void 0:s.defaultModel)?t:"");return(0,a.jsxs)("div",{className:"panel",id:"review",children:[(0,a.jsx)("h2",{children:p("def.reviewTitle")}),(0,a.jsx)("p",{className:"muted small",children:p("def.reviewIntro")}),f&&(0,a.jsx)("div",{className:"err",children:f}),(0,a.jsx)("label",{htmlFor:"default-review-model",children:p("def.reviewField")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)(u.Y,{id:"default-review-model",chosen:w,onChange:e=>void N(e),none:p("def.reviewNone"),catalogue:s,disabled:y||m}),(0,a.jsx)("button",{className:"quiet",onClick:()=>void N(""),disabled:y||!w,children:p("proj.clear")}),(0,a.jsx)("button",{onClick:()=>void c(),disabled:y||m,children:p("model.refresh")})]}),k&&(0,a.jsx)("p",{className:"why",style:{color:"var(--warn)"},children:p("def.reviewSame")}),(0,a.jsx)(j,{msg:x||h}),(0,a.jsx)("h3",{children:p("proj.affects")}),(0,a.jsxs)("ul",{className:"muted small",style:{margin:0,paddingLeft:20},children:[(0,a.jsx)("li",{children:p("def.reviewAffectsNew")}),(0,a.jsx)("li",{children:p("def.reviewAffectsExisting")}),(0,a.jsx)("li",{children:p("def.reviewAffectsBatch")})]}),(0,a.jsxs)("div",{className:"row",style:{marginTop:12},children:[(0,a.jsx)(i(),{href:"/sessions",className:"button-link plain",children:p("proj.toSessions")}),(0,a.jsx)(i(),{href:"/import",className:"button-link quiet",children:p("proj.toImport")})]})]})}},4784:(e,l,t)=>{"use strict";t.d(l,{Y:()=>i});var a=t(3365),n=t(1521),s=t(5549),r=t(867);function i(e){var l,t,i;let{id:o,chosen:d,onChange:c,none:u,catalogue:m,disabled:h=!1,style:p}=e,{t:x}=(0,r.kj)(),j=function(e){let[l,t]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(void 0!==e)return;let l=!0;return s.FH.models().then(e=>{l&&t(e)}).catch(()=>void 0),()=>{l=!1}},[e]),void 0!==e?e:l}(m),v=null!=(l=null==j?void 0:j.options)?l:[],f=e=>e.toLowerCase().replace(/[-‐‑‒–—_]+/g," ").replace(/\s+/g," ").trim(),g=d?v.find(e=>f(e.name)===f(d)):void 0,y=null!=(t=null==g?void 0:g.name)?t:d,b=!!g,w=v.filter(e=>!e.group),N=new Map;for(let e of v)e.group&&N.set(e.group,[...null!=(i=N.get(e.group))?i:[],e]);return(0,a.jsxs)("select",{id:o,value:y,onChange:e=>c(e.target.value),disabled:h,style:{width:"auto",minWidth:280,...p},children:[(0,a.jsx)("option",{value:"",children:u}),d&&!b&&(0,a.jsx)("option",{value:d,children:x("model.notInList",{name:d})}),w.map(e=>(0,a.jsxs)("option",{value:e.name,disabled:e.disabled,children:[e.name,e.disabled?" — ".concat(x("model.unavailable")):""]},e.name)),[...N.entries()].map(e=>{let[l,t]=e;return(0,a.jsx)("optgroup",{label:l,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))},l)})]})}},4969:(e,l,t)=>{"use strict";t.d(l,{V:()=>s});var a=t(1521);let n='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function s(e,l,t){(0,a.useEffect)(()=>{var a,s;if(!l)return;let r=document.activeElement instanceof HTMLElement?document.activeElement:null,i=e.current,o=null!=(s=null!=(a=null==t?void 0:t.current)?a:null==i?void 0:i.querySelector(n))?s:null;null==o||o.focus();let d=e=>{if("Tab"!==e.key||!i)return;let l=Array.from(i.querySelectorAll(n)).filter(e=>null!==e.offsetParent);if(0===l.length)return;let t=l[0],a=l[l.length-1],s=i.contains(document.activeElement);e.shiftKey&&(document.activeElement===t||!s)?(e.preventDefault(),a.focus()):e.shiftKey||document.activeElement!==a&&s||(e.preventDefault(),t.focus())};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d),r&&document.contains(r)&&r.focus()}},[e,l,t])}},8596:(e,l,t)=>{"use strict";t.d(l,{E:()=>i});var a=t(3365),n=t(1521),s=t(5549),r=t(867);function i(e){var l,t,i,o,d,c,u;let{dir:m,onDone:h}=e,{t:p}=(0,r.kj)(),x=(0,r.W3)(),[j,v]=(0,n.useState)(null),[f,g]=(0,n.useState)(""),[y,b]=(0,n.useState)(""),[w,N]=(0,n.useState)(""),[k,C]=(0,n.useState)(!1),S=e=>(null!=e?e:"—").slice(0,8),F=async e=>{b(""),N(""),g(e?"fetch":"prepare");try{v(await s.FH.preparePreview(m,e))}catch(e){b(e.message)}finally{g("")}},R=async()=>{if(null==j?void 0:j.fingerprint){b(""),g("prepare");try{var e,l;let t=await s.FH.prepareProject(m,j.fingerprint,{savedBranch:j.savedBranch,savedMainBranch:j.savedMainBranch});t.ok?(N(null!=(l=t.result)?l:""),v(null),null==h||h()):b(null!=(e=t.problem)?e:"")}catch(e){b(e.message)}finally{g("")}}},M=async e=>{try{await navigator.clipboard.writeText(e),C(!0),window.setTimeout(()=>C(!1),2500)}catch(e){b(p("plan.copyFailed"))}},T=e=>(0,a.jsxs)("ul",{style:{margin:"2px 0 6px",paddingLeft:20},children:[e.slice(0,30).map(e=>(0,a.jsx)("li",{children:(0,a.jsx)("code",{children:e})},e)),e.length>30&&(0,a.jsx)("li",{className:"muted",children:p("prep.more",{n:e.length-30})})]}),E=j&&!j.ok&&j.fetched&&!j.fetched.ok;return(0,a.jsxs)("div",{className:"prepare-folder small",style:{marginTop:8,overflowWrap:"anywhere"},children:[(0,a.jsx)("button",{type:"button",onClick:()=>void F(!0),disabled:!!f,children:p("prep.show")}),(0,a.jsx)("p",{className:"why",children:p("prep.why")}),(0,a.jsx)("p",{className:"why",children:p("prep.password")}),"fetch"===f&&(0,a.jsx)("p",{role:"status",children:p("prep.fetching")}),y&&(0,a.jsx)("p",{className:"err",role:"alert",children:y}),w&&(0,a.jsx)("p",{className:"notice",role:"status",children:w}),j&&!j.ok&&!E&&(0,a.jsx)("p",{className:"err",children:j.problem}),E&&(0,a.jsxs)("div",{className:"notice caution",style:{marginTop:8},children:[(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:p("prep.fetchFailed")})," ",(0,a.jsx)("code",{children:null==(l=j.fetched)?void 0:l.detail})]}),(null==(t=j.fetched)?void 0:t.auth)&&(0,a.jsx)("p",{children:p("prep.fetchAuth")}),(0,a.jsx)("div",{className:"row",children:(0,a.jsx)("button",{type:"button",onClick:()=>void F(!0),disabled:!!f,children:p("prep.retry")})}),j.fetchCommand&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{style:{marginTop:8},children:p("prep.ownTerminal")}),(0,a.jsx)("pre",{className:"sync-cmd",children:j.fetchCommand}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("button",{type:"button",onClick:()=>{var e;M(null!=(e=j.fetchCommand)?e:"")},children:p("prep.copyFetch")}),k&&(0,a.jsx)("span",{className:"badge done",children:p("prep.copied")}),(0,a.jsx)("button",{type:"button",onClick:()=>void F(!1),disabled:!!f,children:p("prep.useFetched")})]}),j.lastFetched&&(0,a.jsx)("p",{className:"muted",children:p("prep.lastFetched",{when:x(j.lastFetched)})})]})]}),(null==j?void 0:j.ok)&&(0,a.jsxs)("div",{className:"notice caution",style:{marginTop:8},children:[(0,a.jsx)("p",{children:p("prep.where",{target:null!=(i=j.target)?i:"",commit:S(j.targetCommit),branch:null!=(o=j.branch)?o:"HEAD",head:S(j.head)})}),!j.fetched&&(0,a.jsxs)("p",{className:"muted",children:[p("prep.notFetched")," ",j.lastFetched?p("prep.lastFetched",{when:x(j.lastFetched)}):p("prep.lastFetchedUnknown")]}),j.alreadyThere?(0,a.jsx)("p",{children:p("prep.already")}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("strong",{children:p("prep.willDo")}),(0,a.jsxs)("ol",{style:{margin:"4px 0",paddingLeft:20},children:[j.savedBranch&&(0,a.jsxs)("li",{children:[p("prep.keepChanges",{changed:j.changed.length,untracked:j.untracked.length,saved:j.savedBranch}),T([...j.changed,...j.untracked])]}),j.savedMainBranch&&(0,a.jsxs)("li",{children:[p("prep.keepMain",{n:j.mainOnlyCommits.length,branch:null!=(d=j.localBranch)?d:"",saved:j.savedMainBranch}),T(j.mainOnlyCommits)]}),(0,a.jsx)("li",{children:p("prep.moveTo",{branch:null!=(c=j.localBranch)?c:"",commit:S(j.targetCommit),target:null!=(u=j.target)?u:""})})]}),j.branchOnlyCommits.length>0&&j.branch&&(0,a.jsx)("p",{children:p("prep.branchStays",{branch:j.branch,n:j.branchOnlyCommits.length})}),(0,a.jsx)("p",{className:"muted",children:p("prep.ignored")}),(0,a.jsxs)("div",{className:"row",children:[(0,a.jsx)("button",{type:"button",className:"primary",onClick:()=>void R(),disabled:!!f,children:p("prep.confirm")}),(0,a.jsx)("button",{type:"button",className:"quiet",onClick:()=>v(null),disabled:!!f,children:p("prep.cancel")})]})]})]})]})}}},e=>{e.O(0,[197,867,549,347,131,358],()=>e(e.s=1896)),_N_E=e.O()}]);
|
|
@@ -1 +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(8934),y=t(4811),w=t(2876),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.C,{sessionId:e.sessionId,taskId:e.taskId,runId:s.runId,title:"".concat(e.title," — ").concat(c("reg.attemptN",{n:s.attempt})),files:s.changedFiles})]}),(0,n.jsxs)("div",{className:"when",children:[s.startedAt?c("task.started",{t: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.C,{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:"/#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,204,347,131,358],()=>e(e.s=3256)),_N_E=e.O()}]);
|
|
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(8934),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.C,{sessionId:e.sessionId,taskId:e.taskId,runId:s.runId,title:"".concat(e.title," — ").concat(c("reg.attemptN",{n:s.attempt})),files:s.changedFiles})]}),(0,n.jsxs)("div",{className:"when",children:[s.startedAt?c("task.started",{t: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.C,{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,897,699,347,131,358],()=>e(e.s=3256)),_N_E=e.O()}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[322],{1035:(e,a,n)=>{"use strict";n.d(a,{DialogHost:()=>d,Z:()=>o});var l=n(3365),s=n(1521),t=n(867),i=n(4969);let r=null,c=[];function o(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(n=>{var l;return l={kind:"confirm",message:e,...a,resolve:n},void(r?r(l):c.push(l))})}function d(e){var a,n;let{children:o}=e,{t:d}=(0,t.kj)(),[m,p]=(0,s.useState)([]),u=(0,s.useRef)(null),h=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(r=e=>p(a=>[...a,e]),c.length>0){let e=c.splice(0,c.length);p(a=>[...a,...e])}return()=>{r=null}},[]);let x=m[0],j=(0,s.useCallback)(e=>{x&&(x.resolve(e),p(e=>e.slice(1)))},[x]);return(0,i.V)(h,!!x,u),(0,s.useEffect)(()=>{if(!x)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),j(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[x,j]),(0,l.jsxs)(l.Fragment,{children:[o,x&&(0,l.jsx)("div",{className:"modal-backdrop",onClick:()=>j(!1),role:"presentation",children:(0,l.jsxs)("div",{ref:h,className:"modal".concat(x.danger?" danger":""),role:"confirm"===x.kind?"alertdialog":"dialog","aria-modal":"true","aria-labelledby":"modal-title","aria-describedby":"modal-body",onClick:e=>e.stopPropagation(),children:[(0,l.jsx)("h2",{id:"modal-title",children:null!=(a=x.title)?a:d("confirm"===x.kind?"dialog.confirmTitle":"dialog.noticeTitle")}),(0,l.jsx)("div",{id:"modal-body",className:"modal-body",children:x.message}),(0,l.jsxs)("div",{className:"row modal-actions",children:["confirm"===x.kind&&(0,l.jsx)("button",{type:"button",className:"quiet",onClick:()=>j(!1),children:d("dialog.cancel")}),(0,l.jsx)("button",{ref:u,type:"button",className:x.danger?"danger":"primary",onClick:()=>j(!0),children:null!=(n=x.okLabel)?n:d("dialog.ok")})]})]})})]})}},4969:(e,a,n)=>{"use strict";n.d(a,{V:()=>t});var l=n(1521);let s='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function t(e,a,n){(0,l.useEffect)(()=>{var l,t;if(!a)return;let i=document.activeElement instanceof HTMLElement?document.activeElement:null,r=e.current,c=null!=(t=null!=(l=null==n?void 0:n.current)?l:null==r?void 0:r.querySelector(s))?t:null;null==c||c.focus();let o=e=>{if("Tab"!==e.key||!r)return;let a=Array.from(r.querySelectorAll(s)).filter(e=>null!==e.offsetParent);if(0===a.length)return;let n=a[0],l=a[a.length-1],t=r.contains(document.activeElement);e.shiftKey&&(document.activeElement===n||!t)?(e.preventDefault(),l.focus()):e.shiftKey||document.activeElement!==l&&t||(e.preventDefault(),n.focus())};return document.addEventListener("keydown",o),()=>{document.removeEventListener("keydown",o),i&&document.contains(i)&&i.focus()}},[e,a,n])}},5515:(e,a,n)=>{Promise.resolve().then(n.bind(n,9262))},9262:(e,a,n)=>{"use strict";n.r(a),n.d(a,{default:()=>d});var l=n(3365),s=n(1521),t=n(8197),i=n.n(t),r=n(5549),c=n(1035),o=n(867);function d(){var e,a;let{t:n,locale:t}=(0,o.kj)(),d=(0,o.W3)(),[m,u]=(0,s.useState)(""),[h,x]=(0,s.useState)(""),[j,v]=(0,s.useState)(!1),[f,g]=(0,s.useState)(""),[y,b]=(0,s.useState)(""),[k,N]=(0,s.useState)(0),[w,C]=(0,s.useState)(""),[S,T]=(0,s.useState)(!1),[E,H]=(0,s.useState)(null),[F,L]=(0,s.useState)(""),[P,D]=(0,s.useState)(""),R=(0,s.useRef)(null),[A,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{let e=!1;return r.FH.planBrief(t).then(a=>{e||(u(a.text),x(a.software),b(""))}).catch(a=>{e||b(a.message)}),()=>{e=!0}},[t,k]);let O=(0,s.useCallback)(async(e,a)=>{try{await navigator.clipboard.writeText(a),g(e),window.setTimeout(()=>g(""),2500)}catch(e){D(n("plan.copyFailed"))}},[n]),W=(0,s.useCallback)(async e=>{if(e.size>2097152)return void D(n("plan.fileTooBig",{size:"".concat(Math.round(e.size/1024)," KB")}));try{C(await e.text()),H(null),B(null),D("")}catch(e){D(n("plan.fileError",{reason:e.message}))}},[n]),q=async()=>{L("check"),D("");try{H(await r.FH.checkPlan(w))}catch(e){D(e.message)}finally{L("")}},Z=async()=>{var e;let a=null!=E?E:await r.FH.checkPlan(w).catch(()=>null),l=a&&!a.ok?[]:null!=(e=null==a?void 0:a.duplicates)?e:[];if(l.length>0){let e=l.map(e=>"• ".concat(e.name," (").concat(e.tasks,")")).join("\n");if(!await (0,c.Z)(n("plan.duplicateConfirm",{names:e})))return}L("import"),D("");try{let e=await r.FH.importPlan(w);e.ok?(B(e),H({ok:!0,warnings:e.result.warnings,summary:e.summary,duplicates:e.duplicates}),C("")):(B(null),H(e.check))}catch(e){D(e.message)}finally{L("")}},_=(E&&!E.ok?E.issues:[]).map(e=>e.path?"- ".concat(e.path,": ").concat(e.message):"- ".concat(e.message)).join("\n");return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsx)("h2",{children:n("plan.title")}),(0,l.jsx)("p",{className:"muted small",children:n("plan.intro")})]}),(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsx)("h2",{children:n("plan.step1")}),(0,l.jsx)("p",{className:"muted small",children:n("plan.step1Hint")}),(0,l.jsx)("h3",{children:n("plan.briefAsks")}),(0,l.jsx)("p",{className:"why",children:n("plan.briefAsksWhy")}),m.length>116e3&&(0,l.jsx)("div",{className:"notice caution",role:"status",style:{marginTop:12},children:n("plan.briefTooLong",{n:m.length.toLocaleString(),limit:116e3.toLocaleString()})}),(0,l.jsxs)("div",{className:"row",style:{marginTop:12},children:[(0,l.jsx)("button",{className:m.length>116e3?"":"primary",onClick:()=>void O("brief",m),disabled:!m,children:n("plan.copyBrief")}),(0,l.jsx)("button",{className:m.length>116e3?"primary":"",onClick:()=>(function(e,a){let n=URL.createObjectURL(new Blob([e],{type:"text/plain;charset=utf-8"})),l=document.createElement("a");l.href=n,l.download="copilot-operator-brief.".concat(a,".txt"),document.body.appendChild(l),l.click(),l.remove(),window.setTimeout(()=>URL.revokeObjectURL(n),1e4)})(m,t),disabled:!m,children:n("plan.saveBrief")}),"brief"===f&&(0,l.jsx)("span",{className:"badge done",children:n("plan.copied")}),(0,l.jsx)("span",{className:"muted small",children:n("plan.briefLang")})]}),m.length>116e3&&(0,l.jsxs)("div",{className:"row",style:{marginTop:8},children:[(0,l.jsx)("button",{onClick:()=>void O("briefNote",n("plan.briefFileMessage")),children:n("plan.copyBriefNote")}),"briefNote"===f&&(0,l.jsx)("span",{className:"badge done",children:n("plan.copied")}),(0,l.jsx)("span",{className:"muted small",children:n("plan.briefFileMessage")})]}),y&&(0,l.jsx)("div",{className:"err",children:y}),(0,l.jsx)("h3",{style:{marginTop:16},children:n("plan.persona")}),(0,l.jsx)("p",{className:"why",children:n("plan.personaWhy")}),(0,l.jsxs)("details",{style:{marginTop:8},open:j,onToggle:e=>v(e.target.open),children:[(0,l.jsx)("summary",{children:n("plan.softwarePart")}),(0,l.jsx)("textarea",{readOnly:!0,"aria-label":n("plan.softwarePart"),value:h,style:{minHeight:380,marginTop:10}})]}),(0,l.jsx)(p,{kind:"organisation",onSaved:()=>N(e=>e+1)}),(0,l.jsx)(p,{kind:"persona",onSaved:()=>N(e=>e+1)}),(0,l.jsx)(p,{kind:"work",onSaved:()=>N(e=>e+1)})]}),(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsx)("h2",{children:n("plan.step2")}),(0,l.jsx)("p",{className:"muted small",children:n("plan.step2Hint")}),(0,l.jsxs)("div",{className:"dropzone".concat(S?" active":""),onDragOver:e=>{e.preventDefault(),T(!0)},onDragLeave:()=>T(!1),onDrop:e=>{var a;e.preventDefault(),T(!1);let n=null==(a=e.dataTransfer.files)?void 0:a[0];n&&W(n)},children:[(0,l.jsx)("textarea",{className:"grow","aria-label":n("plan.placeholder"),placeholder:n("plan.placeholder"),value:w,onChange:e=>{C(e.target.value),H(null),B(null)},style:{minHeight:220,width:"100%"}}),(0,l.jsx)("p",{className:"muted small",children:S?n("plan.dropActive"):n("plan.drop")})]}),(0,l.jsxs)("div",{className:"row",style:{marginTop:10},children:[(0,l.jsx)("button",{onClick:()=>{var e;return null==(e=R.current)?void 0:e.click()},children:n("plan.browse")}),(0,l.jsx)("input",{ref:R,type:"file",accept:".json,application/json,text/plain",style:{display:"none"},onChange:e=>{var a;let n=null==(a=e.target.files)?void 0:a[0];n&&W(n),e.target.value=""}}),(0,l.jsx)("button",{onClick:()=>void q(),disabled:!w.trim()||""!==F,children:"check"===F?n("plan.checking"):n("plan.check")}),(0,l.jsx)("button",{className:"primary",onClick:()=>void Z(),disabled:!w.trim()||""!==F,children:"import"===F?n("plan.importing"):n("plan.import")}),(0,l.jsx)("button",{className:"quiet",onClick:()=>{C(""),H(null),B(null),D("")},disabled:!w&&!E,children:n("plan.clear")})]}),P&&(0,l.jsx)("div",{className:"err",children:P}),A&&""===w.trim()&&(0,l.jsx)("p",{className:"why",children:n("plan.cleared")})]}),E&&!E.ok&&(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsx)("div",{className:"notice",children:(0,l.jsx)("strong",{children:n("plan.invalid")})}),(0,l.jsx)("h3",{children:n("plan.issues")}),(0,l.jsx)("p",{className:"muted small",children:n("plan.issuesHint")}),(0,l.jsx)("pre",{children:_}),(0,l.jsxs)("div",{className:"row",children:[(0,l.jsx)("button",{onClick:()=>void O("issues",_),children:n("plan.copyIssues")}),"issues"===f&&(0,l.jsx)("span",{className:"badge done",children:n("plan.copied")})]})]}),(null!=(e=null==E?void 0:E.duplicates.length)?e:0)>0&&(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsxs)("div",{className:"notice caution",children:[(0,l.jsx)("strong",{children:n("plan.duplicates")}),(0,l.jsx)("ul",{children:(null!=(a=null==E?void 0:E.duplicates)?a:[]).map(e=>(0,l.jsx)("li",{children:(0,l.jsx)(i(),{href:(0,r.aT)(e.sessionId),children:n("plan.duplicateRow",{name:e.name,tasks:e.tasks,when:d(e.createdAt)})})},e.sessionId))})]}),(0,l.jsx)("p",{className:"muted small",children:n("plan.duplicatesHint")})]}),(null==E?void 0:E.ok)&&(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsx)("div",{className:"notice calm",children:(0,l.jsx)("strong",{children:A?n("plan.imported",{sessions:A.result.sessions.length,tasks:A.result.taskCount}):n("plan.valid",{sessions:E.summary.sessions.length,tasks:E.summary.taskCount})})}),E.summary.plan&&(0,l.jsx)("p",{children:E.summary.plan}),(0,l.jsxs)("p",{className:"muted small",children:[n("plan.col.planFail"),":"," ","continue"===E.summary.onFailure?n("batch.independent"):n("batch.chain")]}),(0,l.jsx)("h3",{children:n("plan.preview")}),(0,l.jsxs)("table",{children:[(0,l.jsx)("thead",{children:(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:n("plan.col.session")}),(0,l.jsx)("th",{children:n("plan.col.tasks")}),(0,l.jsx)("th",{children:n("plan.col.chain")}),(0,l.jsx)("th",{children:n("plan.col.repo")})]})}),(0,l.jsx)("tbody",{children:E.summary.sessions.map((e,a)=>{let s=null==A?void 0:A.result.sessions[a];return(0,l.jsxs)("tr",{children:[(0,l.jsx)("td",{children:s?(0,l.jsx)(i(),{href:(0,r.aT)(s.id),children:e.name}):e.name}),(0,l.jsxs)("td",{className:"small",children:[e.tasks.length,(0,l.jsx)("div",{className:"muted small",children:e.tasks.join(", ")})]}),(0,l.jsx)("td",{className:"small",children:"continue"===e.onFailure?n("chain.continue"):n("chain.stop")}),(0,l.jsx)("td",{className:"small muted",children:e.repoDir||n("plan.noRepo")})]},"".concat(e.name,"-").concat(a))})})]}),E.summary.notes&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("h3",{children:n("plan.notes")}),(0,l.jsx)("p",{className:"muted small",style:{whiteSpace:"pre-wrap"},children:E.summary.notes})]}),E.warnings.length>0&&(0,l.jsxs)("div",{className:"notice caution",children:[(0,l.jsx)("strong",{children:n("plan.warnings")}),(0,l.jsx)("ul",{children:E.warnings.map(e=>(0,l.jsx)("li",{children:e},e))})]})]}),A&&(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsx)("h2",{children:n("plan.step3")}),(0,l.jsx)("p",{className:"muted small",children:n("plan.step3Hint")}),(0,l.jsxs)("div",{className:"row",children:[(0,l.jsx)(i(),{href:"/?run=".concat(encodeURIComponent(A.result.sessions.map(e=>e.id).join(",")),"&fail=").concat(A.summary.onFailure),className:"button-link",children:n("plan.runThese")}),(0,l.jsx)(i(),{href:"/",className:"button-link plain",children:n("plan.toSessions")})]})]})]})}function m(e){var a,n;let{current:t,onLoad:i}=e,{t:d}=(0,o.kj)(),[m,p]=(0,s.useState)([]),[u,h]=(0,s.useState)(""),[x,j]=(0,s.useState)(""),v=(0,s.useCallback)(async()=>{try{p(await r.FH.personas())}catch(e){j(e.message)}},[]);(0,s.useEffect)(()=>{v()},[v]);let f=null!=(n=null==(a=m.find(e=>e.content===t))?void 0:a.name)?n:"",g=async e=>{let a=m.find(a=>a.name===e);a&&(!t.trim()||f||await (0,c.Z)(d("plan.personaReplaceConfirm",{name:e})))&&(i(a.content),h(a.name),j(d("plan.personaLoaded",{name:a.name})))},y=async()=>{let e=u.trim();if(e&&t.trim()&&(!m.some(a=>a.name===e)||await (0,c.Z)(d("plan.personaOverwriteConfirm",{name:e}))))try{let a=await r.FH.savePersona(e,t);h(a.name),j(d("plan.personaSavedAs",{name:a.name})),await v()}catch(e){j(e.message)}},b=async()=>{if(f&&await (0,c.Z)(d("plan.personaDeleteConfirm",{name:f})))try{await r.FH.deletePersona(f),j(d("plan.personaDeleted",{name:f})),await v()}catch(e){j(e.message)}};return(0,l.jsxs)("div",{className:"option",style:{marginBottom:8},children:[(0,l.jsx)("label",{htmlFor:"persona-shelf",children:d("plan.personaSaved")}),(0,l.jsxs)("div",{className:"row",children:[(0,l.jsxs)("select",{id:"persona-shelf",value:f,onChange:e=>void g(e.target.value),style:{width:"auto",minWidth:260},children:[(0,l.jsx)("option",{value:"",children:0===m.length?d("plan.personaNone"):d("plan.personaPick")}),m.map(e=>(0,l.jsx)("option",{value:e.name,children:e.name},e.name))]}),(0,l.jsx)("button",{className:"quiet",onClick:()=>void b(),disabled:!f,children:d("plan.personaDelete")})]}),(0,l.jsxs)("div",{className:"row",style:{marginTop:6},children:[(0,l.jsx)("input",{type:"text",value:u,onChange:e=>h(e.target.value),placeholder:d("plan.personaNamePlaceholder"),"aria-label":d("plan.personaNamePlaceholder"),style:{maxWidth:360}}),(0,l.jsx)("button",{onClick:()=>void y(),disabled:!u.trim()||!t.trim(),children:d("plan.personaSaveAs")}),(0,l.jsx)("span",{className:"muted small",role:"status",children:x})]}),(0,l.jsx)("p",{className:"why",children:d("plan.personaSavedWhy")})]})}function p(e){let{kind:a,onSaved:n}=e,{t,locale:i}=(0,o.kj)(),[d,p]=(0,s.useState)(""),[u,h]=(0,s.useState)(""),[x,j]=(0,s.useState)(""),[v,f]=(0,s.useState)(!1),[g,y]=(0,s.useState)(""),b=(0,s.useRef)(null);(0,s.useEffect)(()=>{let e=!1;return r.FH.context(a,i).then(a=>{e||(p(a.content),h(a.content),j(a.example),f(a.customised))}).catch(e=>y(e.message)),()=>{e=!0}},[a,i]);let k=async e=>{try{await r.FH.setContext(a,e),h(e),f(""!==e.trim()),y(t("plan.ctxSaved")),n()}catch(e){y(e.message)}},N=async()=>{if(await (0,c.Z)(t("plan.ctxClearConfirm")))try{let e=await r.FH.resetContext(a,i);p(e.content),h(e.content),f(e.customised),y(t("plan.ctxCleared")),n()}catch(e){y(e.message)}},w="organisation"===a?t("plan.orgPart"):"persona"===a?t("plan.personaPart"):t("plan.workPart"),C="organisation"===a?t("plan.orgHint"):"persona"===a?t("plan.personaHint"):t("plan.workHint");return(0,l.jsxs)("details",{style:{marginTop:8},open:!0,children:[(0,l.jsxs)("summary",{children:[w," ",(0,l.jsxs)("span",{className:"muted small",children:["— ",v?t("plan.ctxWritten"):t("plan.ctxEmpty")]})]}),(0,l.jsx)("p",{className:"muted small",style:{marginTop:8},children:C}),"persona"===a&&(0,l.jsx)(m,{current:d,onLoad:e=>{p(e),k(e)}}),(0,l.jsx)("textarea",{"aria-label":w,value:d,onChange:e=>{var a;p(e.target.value),a=e.target.value,b.current&&clearTimeout(b.current),b.current=setTimeout(()=>void k(a),900)},onBlur:()=>d!==u&&void k(d),placeholder:x,style:{minHeight:220}}),(0,l.jsxs)("div",{className:"row",style:{marginTop:6},children:[(0,l.jsx)("button",{className:"quiet",onClick:()=>void N(),disabled:!v,children:t("plan.ctxClear")}),(0,l.jsx)("span",{className:"muted small",role:"status",children:g||t("def.savedAutomatically")})]})]})}}},e=>{e.O(0,[197,867,549,347,131,358],()=>e(e.s=5515)),_N_E=e.O()}]);
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[322],{1035:(e,a,n)=>{"use strict";n.d(a,{DialogHost:()=>d,Z:()=>o});var l=n(3365),s=n(1521),t=n(867),i=n(4969);let r=null,c=[];function o(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(n=>{var l;return l={kind:"confirm",message:e,...a,resolve:n},void(r?r(l):c.push(l))})}function d(e){var a,n;let{children:o}=e,{t:d}=(0,t.kj)(),[m,p]=(0,s.useState)([]),u=(0,s.useRef)(null),h=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(r=e=>p(a=>[...a,e]),c.length>0){let e=c.splice(0,c.length);p(a=>[...a,...e])}return()=>{r=null}},[]);let x=m[0],j=(0,s.useCallback)(e=>{x&&(x.resolve(e),p(e=>e.slice(1)))},[x]);return(0,i.V)(h,!!x,u),(0,s.useEffect)(()=>{if(!x)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),j(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[x,j]),(0,l.jsxs)(l.Fragment,{children:[o,x&&(0,l.jsx)("div",{className:"modal-backdrop",onClick:()=>j(!1),role:"presentation",children:(0,l.jsxs)("div",{ref:h,className:"modal".concat(x.danger?" danger":""),role:"confirm"===x.kind?"alertdialog":"dialog","aria-modal":"true","aria-labelledby":"modal-title","aria-describedby":"modal-body",onClick:e=>e.stopPropagation(),children:[(0,l.jsx)("h2",{id:"modal-title",children:null!=(a=x.title)?a:d("confirm"===x.kind?"dialog.confirmTitle":"dialog.noticeTitle")}),(0,l.jsx)("div",{id:"modal-body",className:"modal-body",children:x.message}),(0,l.jsxs)("div",{className:"row modal-actions",children:["confirm"===x.kind&&(0,l.jsx)("button",{type:"button",className:"quiet",onClick:()=>j(!1),children:d("dialog.cancel")}),(0,l.jsx)("button",{ref:u,type:"button",className:x.danger?"danger":"primary",onClick:()=>j(!0),children:null!=(n=x.okLabel)?n:d("dialog.ok")})]})]})})]})}},4969:(e,a,n)=>{"use strict";n.d(a,{V:()=>t});var l=n(1521);let s='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function t(e,a,n){(0,l.useEffect)(()=>{var l,t;if(!a)return;let i=document.activeElement instanceof HTMLElement?document.activeElement:null,r=e.current,c=null!=(t=null!=(l=null==n?void 0:n.current)?l:null==r?void 0:r.querySelector(s))?t:null;null==c||c.focus();let o=e=>{if("Tab"!==e.key||!r)return;let a=Array.from(r.querySelectorAll(s)).filter(e=>null!==e.offsetParent);if(0===a.length)return;let n=a[0],l=a[a.length-1],t=r.contains(document.activeElement);e.shiftKey&&(document.activeElement===n||!t)?(e.preventDefault(),l.focus()):e.shiftKey||document.activeElement!==l&&t||(e.preventDefault(),n.focus())};return document.addEventListener("keydown",o),()=>{document.removeEventListener("keydown",o),i&&document.contains(i)&&i.focus()}},[e,a,n])}},5515:(e,a,n)=>{Promise.resolve().then(n.bind(n,9262))},9262:(e,a,n)=>{"use strict";n.r(a),n.d(a,{default:()=>d});var l=n(3365),s=n(1521),t=n(8197),i=n.n(t),r=n(5549),c=n(1035),o=n(867);function d(){var e,a;let{t:n,locale:t}=(0,o.kj)(),d=(0,o.W3)(),[m,u]=(0,s.useState)(""),[h,x]=(0,s.useState)(""),[j,v]=(0,s.useState)(!1),[f,g]=(0,s.useState)(""),[y,b]=(0,s.useState)(""),[k,N]=(0,s.useState)(0),[w,C]=(0,s.useState)(""),[S,T]=(0,s.useState)(!1),[E,H]=(0,s.useState)(null),[F,L]=(0,s.useState)(""),[P,D]=(0,s.useState)(""),R=(0,s.useRef)(null),[A,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{let e=!1;return r.FH.planBrief(t).then(a=>{e||(u(a.text),x(a.software),b(""))}).catch(a=>{e||b(a.message)}),()=>{e=!0}},[t,k]);let O=(0,s.useCallback)(async(e,a)=>{try{await navigator.clipboard.writeText(a),g(e),window.setTimeout(()=>g(""),2500)}catch(e){D(n("plan.copyFailed"))}},[n]),W=(0,s.useCallback)(async e=>{if(e.size>2097152)return void D(n("plan.fileTooBig",{size:"".concat(Math.round(e.size/1024)," KB")}));try{C(await e.text()),H(null),B(null),D("")}catch(e){D(n("plan.fileError",{reason:e.message}))}},[n]),q=async()=>{L("check"),D("");try{H(await r.FH.checkPlan(w))}catch(e){D(e.message)}finally{L("")}},Z=async()=>{var e;let a=null!=E?E:await r.FH.checkPlan(w).catch(()=>null),l=a&&!a.ok?[]:null!=(e=null==a?void 0:a.duplicates)?e:[];if(l.length>0){let e=l.map(e=>"• ".concat(e.name," (").concat(e.tasks,")")).join("\n");if(!await (0,c.Z)(n("plan.duplicateConfirm",{names:e})))return}L("import"),D("");try{let e=await r.FH.importPlan(w);e.ok?(B(e),H({ok:!0,warnings:e.result.warnings,summary:e.summary,duplicates:e.duplicates}),C("")):(B(null),H(e.check))}catch(e){D(e.message)}finally{L("")}},_=(E&&!E.ok?E.issues:[]).map(e=>e.path?"- ".concat(e.path,": ").concat(e.message):"- ".concat(e.message)).join("\n");return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsx)("h2",{children:n("plan.title")}),(0,l.jsx)("p",{className:"muted small",children:n("plan.intro")})]}),(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsx)("h2",{children:n("plan.step1")}),(0,l.jsx)("p",{className:"muted small",children:n("plan.step1Hint")}),(0,l.jsx)("h3",{children:n("plan.briefAsks")}),(0,l.jsx)("p",{className:"why",children:n("plan.briefAsksWhy")}),m.length>116e3&&(0,l.jsx)("div",{className:"notice caution",role:"status",style:{marginTop:12},children:n("plan.briefTooLong",{n:m.length.toLocaleString(),limit:116e3.toLocaleString()})}),(0,l.jsxs)("div",{className:"row",style:{marginTop:12},children:[(0,l.jsx)("button",{className:m.length>116e3?"":"primary",onClick:()=>void O("brief",m),disabled:!m,children:n("plan.copyBrief")}),(0,l.jsx)("button",{className:m.length>116e3?"primary":"",onClick:()=>(function(e,a){let n=URL.createObjectURL(new Blob([e],{type:"text/plain;charset=utf-8"})),l=document.createElement("a");l.href=n,l.download="copilot-operator-brief.".concat(a,".txt"),document.body.appendChild(l),l.click(),l.remove(),window.setTimeout(()=>URL.revokeObjectURL(n),1e4)})(m,t),disabled:!m,children:n("plan.saveBrief")}),"brief"===f&&(0,l.jsx)("span",{className:"badge done",children:n("plan.copied")}),(0,l.jsx)("span",{className:"muted small",children:n("plan.briefLang")})]}),m.length>116e3&&(0,l.jsxs)("div",{className:"row",style:{marginTop:8},children:[(0,l.jsx)("button",{onClick:()=>void O("briefNote",n("plan.briefFileMessage")),children:n("plan.copyBriefNote")}),"briefNote"===f&&(0,l.jsx)("span",{className:"badge done",children:n("plan.copied")}),(0,l.jsx)("span",{className:"muted small",children:n("plan.briefFileMessage")})]}),y&&(0,l.jsx)("div",{className:"err",children:y}),(0,l.jsx)("h3",{style:{marginTop:16},children:n("plan.persona")}),(0,l.jsx)("p",{className:"why",children:n("plan.personaWhy")}),(0,l.jsxs)("details",{style:{marginTop:8},open:j,onToggle:e=>v(e.target.open),children:[(0,l.jsx)("summary",{children:n("plan.softwarePart")}),(0,l.jsx)("textarea",{readOnly:!0,"aria-label":n("plan.softwarePart"),value:h,style:{minHeight:380,marginTop:10}})]}),(0,l.jsx)(p,{kind:"organisation",onSaved:()=>N(e=>e+1)}),(0,l.jsx)(p,{kind:"persona",onSaved:()=>N(e=>e+1)}),(0,l.jsx)(p,{kind:"work",onSaved:()=>N(e=>e+1)})]}),(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsx)("h2",{children:n("plan.step2")}),(0,l.jsx)("p",{className:"muted small",children:n("plan.step2Hint")}),(0,l.jsxs)("div",{className:"dropzone".concat(S?" active":""),onDragOver:e=>{e.preventDefault(),T(!0)},onDragLeave:()=>T(!1),onDrop:e=>{var a;e.preventDefault(),T(!1);let n=null==(a=e.dataTransfer.files)?void 0:a[0];n&&W(n)},children:[(0,l.jsx)("textarea",{className:"grow","aria-label":n("plan.placeholder"),placeholder:n("plan.placeholder"),value:w,onChange:e=>{C(e.target.value),H(null),B(null)},style:{minHeight:220,width:"100%"}}),(0,l.jsx)("p",{className:"muted small",children:S?n("plan.dropActive"):n("plan.drop")})]}),(0,l.jsxs)("div",{className:"row",style:{marginTop:10},children:[(0,l.jsx)("button",{onClick:()=>{var e;return null==(e=R.current)?void 0:e.click()},children:n("plan.browse")}),(0,l.jsx)("input",{ref:R,type:"file",accept:".json,application/json,text/plain",style:{display:"none"},onChange:e=>{var a;let n=null==(a=e.target.files)?void 0:a[0];n&&W(n),e.target.value=""}}),(0,l.jsx)("button",{onClick:()=>void q(),disabled:!w.trim()||""!==F,children:"check"===F?n("plan.checking"):n("plan.check")}),(0,l.jsx)("button",{className:"primary",onClick:()=>void Z(),disabled:!w.trim()||""!==F,children:"import"===F?n("plan.importing"):n("plan.import")}),(0,l.jsx)("button",{className:"quiet",onClick:()=>{C(""),H(null),B(null),D("")},disabled:!w&&!E,children:n("plan.clear")})]}),P&&(0,l.jsx)("div",{className:"err",children:P}),A&&""===w.trim()&&(0,l.jsx)("p",{className:"why",children:n("plan.cleared")})]}),E&&!E.ok&&(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsx)("div",{className:"notice",children:(0,l.jsx)("strong",{children:n("plan.invalid")})}),(0,l.jsx)("h3",{children:n("plan.issues")}),(0,l.jsx)("p",{className:"muted small",children:n("plan.issuesHint")}),(0,l.jsx)("pre",{children:_}),(0,l.jsxs)("div",{className:"row",children:[(0,l.jsx)("button",{onClick:()=>void O("issues",_),children:n("plan.copyIssues")}),"issues"===f&&(0,l.jsx)("span",{className:"badge done",children:n("plan.copied")})]})]}),(null!=(e=null==E?void 0:E.duplicates.length)?e:0)>0&&(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsxs)("div",{className:"notice caution",children:[(0,l.jsx)("strong",{children:n("plan.duplicates")}),(0,l.jsx)("ul",{children:(null!=(a=null==E?void 0:E.duplicates)?a:[]).map(e=>(0,l.jsx)("li",{children:(0,l.jsx)(i(),{href:(0,r.aT)(e.sessionId),children:n("plan.duplicateRow",{name:e.name,tasks:e.tasks,when:d(e.createdAt)})})},e.sessionId))})]}),(0,l.jsx)("p",{className:"muted small",children:n("plan.duplicatesHint")})]}),(null==E?void 0:E.ok)&&(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsx)("div",{className:"notice calm",children:(0,l.jsx)("strong",{children:A?n("plan.imported",{sessions:A.result.sessions.length,tasks:A.result.taskCount}):n("plan.valid",{sessions:E.summary.sessions.length,tasks:E.summary.taskCount})})}),E.summary.plan&&(0,l.jsx)("p",{children:E.summary.plan}),(0,l.jsxs)("p",{className:"muted small",children:[n("plan.col.planFail"),":"," ","continue"===E.summary.onFailure?n("batch.independent"):n("batch.chain")]}),(0,l.jsx)("h3",{children:n("plan.preview")}),(0,l.jsxs)("table",{children:[(0,l.jsx)("thead",{children:(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:n("plan.col.session")}),(0,l.jsx)("th",{children:n("plan.col.tasks")}),(0,l.jsx)("th",{children:n("plan.col.chain")}),(0,l.jsx)("th",{children:n("plan.col.repo")})]})}),(0,l.jsx)("tbody",{children:E.summary.sessions.map((e,a)=>{let s=null==A?void 0:A.result.sessions[a];return(0,l.jsxs)("tr",{children:[(0,l.jsx)("td",{children:s?(0,l.jsx)(i(),{href:(0,r.aT)(s.id),children:e.name}):e.name}),(0,l.jsxs)("td",{className:"small",children:[e.tasks.length,(0,l.jsx)("div",{className:"muted small",children:e.tasks.join(", ")})]}),(0,l.jsx)("td",{className:"small",children:"continue"===e.onFailure?n("chain.continue"):n("chain.stop")}),(0,l.jsx)("td",{className:"small muted",children:e.repoDir||n("plan.noRepo")})]},"".concat(e.name,"-").concat(a))})})]}),E.summary.notes&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("h3",{children:n("plan.notes")}),(0,l.jsx)("p",{className:"muted small",style:{whiteSpace:"pre-wrap"},children:E.summary.notes})]}),E.warnings.length>0&&(0,l.jsxs)("div",{className:"notice caution",children:[(0,l.jsx)("strong",{children:n("plan.warnings")}),(0,l.jsx)("ul",{children:E.warnings.map(e=>(0,l.jsx)("li",{children:e},e))})]})]}),A&&(0,l.jsxs)("div",{className:"panel",children:[(0,l.jsx)("h2",{children:n("plan.step3")}),(0,l.jsx)("p",{className:"muted small",children:n("plan.step3Hint")}),(0,l.jsxs)("div",{className:"row",children:[(0,l.jsx)(i(),{href:"/sessions?run=".concat(encodeURIComponent(A.result.sessions.map(e=>e.id).join(",")),"&fail=").concat(A.summary.onFailure),className:"button-link",children:n("plan.runThese")}),(0,l.jsx)(i(),{href:"/sessions",className:"button-link plain",children:n("plan.toSessions")})]})]})]})}function m(e){var a,n;let{current:t,onLoad:i}=e,{t:d}=(0,o.kj)(),[m,p]=(0,s.useState)([]),[u,h]=(0,s.useState)(""),[x,j]=(0,s.useState)(""),v=(0,s.useCallback)(async()=>{try{p(await r.FH.personas())}catch(e){j(e.message)}},[]);(0,s.useEffect)(()=>{v()},[v]);let f=null!=(n=null==(a=m.find(e=>e.content===t))?void 0:a.name)?n:"",g=async e=>{let a=m.find(a=>a.name===e);a&&(!t.trim()||f||await (0,c.Z)(d("plan.personaReplaceConfirm",{name:e})))&&(i(a.content),h(a.name),j(d("plan.personaLoaded",{name:a.name})))},y=async()=>{let e=u.trim();if(e&&t.trim()&&(!m.some(a=>a.name===e)||await (0,c.Z)(d("plan.personaOverwriteConfirm",{name:e}))))try{let a=await r.FH.savePersona(e,t);h(a.name),j(d("plan.personaSavedAs",{name:a.name})),await v()}catch(e){j(e.message)}},b=async()=>{if(f&&await (0,c.Z)(d("plan.personaDeleteConfirm",{name:f})))try{await r.FH.deletePersona(f),j(d("plan.personaDeleted",{name:f})),await v()}catch(e){j(e.message)}};return(0,l.jsxs)("div",{className:"option",style:{marginBottom:8},children:[(0,l.jsx)("label",{htmlFor:"persona-shelf",children:d("plan.personaSaved")}),(0,l.jsxs)("div",{className:"row",children:[(0,l.jsxs)("select",{id:"persona-shelf",value:f,onChange:e=>void g(e.target.value),style:{width:"auto",minWidth:260},children:[(0,l.jsx)("option",{value:"",children:0===m.length?d("plan.personaNone"):d("plan.personaPick")}),m.map(e=>(0,l.jsx)("option",{value:e.name,children:e.name},e.name))]}),(0,l.jsx)("button",{className:"quiet",onClick:()=>void b(),disabled:!f,children:d("plan.personaDelete")})]}),(0,l.jsxs)("div",{className:"row",style:{marginTop:6},children:[(0,l.jsx)("input",{type:"text",value:u,onChange:e=>h(e.target.value),placeholder:d("plan.personaNamePlaceholder"),"aria-label":d("plan.personaNamePlaceholder"),style:{maxWidth:360}}),(0,l.jsx)("button",{onClick:()=>void y(),disabled:!u.trim()||!t.trim(),children:d("plan.personaSaveAs")}),(0,l.jsx)("span",{className:"muted small",role:"status",children:x})]}),(0,l.jsx)("p",{className:"why",children:d("plan.personaSavedWhy")})]})}function p(e){let{kind:a,onSaved:n}=e,{t,locale:i}=(0,o.kj)(),[d,p]=(0,s.useState)(""),[u,h]=(0,s.useState)(""),[x,j]=(0,s.useState)(""),[v,f]=(0,s.useState)(!1),[g,y]=(0,s.useState)(""),b=(0,s.useRef)(null);(0,s.useEffect)(()=>{let e=!1;return r.FH.context(a,i).then(a=>{e||(p(a.content),h(a.content),j(a.example),f(a.customised))}).catch(e=>y(e.message)),()=>{e=!0}},[a,i]);let k=async e=>{try{await r.FH.setContext(a,e),h(e),f(""!==e.trim()),y(t("plan.ctxSaved")),n()}catch(e){y(e.message)}},N=async()=>{if(await (0,c.Z)(t("plan.ctxClearConfirm")))try{let e=await r.FH.resetContext(a,i);p(e.content),h(e.content),f(e.customised),y(t("plan.ctxCleared")),n()}catch(e){y(e.message)}},w="organisation"===a?t("plan.orgPart"):"persona"===a?t("plan.personaPart"):t("plan.workPart"),C="organisation"===a?t("plan.orgHint"):"persona"===a?t("plan.personaHint"):t("plan.workHint");return(0,l.jsxs)("details",{style:{marginTop:8},open:!0,children:[(0,l.jsxs)("summary",{children:[w," ",(0,l.jsxs)("span",{className:"muted small",children:["— ",v?t("plan.ctxWritten"):t("plan.ctxEmpty")]})]}),(0,l.jsx)("p",{className:"muted small",style:{marginTop:8},children:C}),"persona"===a&&(0,l.jsx)(m,{current:d,onLoad:e=>{p(e),k(e)}}),(0,l.jsx)("textarea",{"aria-label":w,value:d,onChange:e=>{var a;p(e.target.value),a=e.target.value,b.current&&clearTimeout(b.current),b.current=setTimeout(()=>void k(a),900)},onBlur:()=>d!==u&&void k(d),placeholder:x,style:{minHeight:220}}),(0,l.jsxs)("div",{className:"row",style:{marginTop:6},children:[(0,l.jsx)("button",{className:"quiet",onClick:()=>void N(),disabled:!v,children:t("plan.ctxClear")}),(0,l.jsx)("span",{className:"muted small",role:"status",children:g||t("def.savedAutomatically")})]})]})}}},e=>{e.O(0,[197,867,549,347,131,358],()=>e(e.s=5515)),_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)):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")}),(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()}]);
|