ensemble-review 1.0.37 → 1.0.39

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.
@@ -0,0 +1,76 @@
1
+ // ---------------------------------------------------------------------------
2
+ // THE ENSEMBLE MARK — one banded quarter-circle in the ember run.
3
+ //
4
+ // The ONE definition of the logo. Three consumers draw it from here:
5
+ // · apps/frontend Wordmark.tsx (the app's header and sign-in gate)
6
+ // · scripts/make-favicons.mjs (every favicon, the app icons and the
7
+ // landing's transparent /mark.svg, which
8
+ // the landing header shows)
9
+ // The landing shares no runtime code with the app, so it takes the mark as that
10
+ // generated file rather than importing this module.
11
+ //
12
+ // The geometry is the landing's arc (apps/landing/src/components/arcs/geometry.ts)
13
+ // redrawn for a 16-unit box: the centre sits at the bottom-left, the bands bulge
14
+ // up and to the right, each thicker than the one inside it, and ONE linear run
15
+ // goes from the pole (the top) to the diameter (the right end). The colours are
16
+ // that file's EMBER run (red → orange → amber → yellow): a narrow, warm range,
17
+ // not the whole spectrum, so the mark reads as one colour family even at 16px.
18
+ // Keep the two in step.
19
+ //
20
+ // Only erasable TypeScript here: the favicon script imports this file with Node's
21
+ // type stripping.
22
+ // ---------------------------------------------------------------------------
23
+ export const BRAND_RUN = [
24
+ '#f80e0f', // red
25
+ '#ff6a00', // orange
26
+ '#fe9c00', // amber
27
+ '#ffcf00', // yellow
28
+ ];
29
+ /** The page ground the opaque icons sit on (the landing's --bg). */
30
+ export const BRAND_GROUND = '#0f1012';
31
+ const r2 = (n) => Math.round(n * 100) / 100;
32
+ /**
33
+ * The mark in a 16 × 16 box. `bands` trades detail for legibility: 3 for a 16px
34
+ * tab icon, 4 for the app header, 6 or more for large icons.
35
+ */
36
+ export function brandMark(bands = 4) {
37
+ const cx = 2;
38
+ const cy = 14;
39
+ const R = 12;
40
+ const n = Math.max(2, Math.round(bands));
41
+ const inner = R * 0.22;
42
+ const tIn = R * (n <= 3 ? 0.12 : 0.07);
43
+ const tOut = R * (n <= 3 ? 0.2 : 0.16);
44
+ const pitch = (R - inner) / (n - 1);
45
+ const out = [];
46
+ for (let i = 0; i < n; i++) {
47
+ const k = i / (n - 1);
48
+ const t = tIn + (tOut - tIn) * k;
49
+ // centre line, with the rim band's outer edge landing on R
50
+ const r = Math.max(inner + i * pitch - (i === n - 1 ? t / 2 : 0), t / 2);
51
+ out.push({ d: `M${r2(cx)} ${r2(cy - r)}A${r2(r)} ${r2(r)} 0 0 1 ${r2(cx + r)} ${r2(cy)}`, width: r2(t) });
52
+ }
53
+ const last = BRAND_RUN.length - 1;
54
+ return {
55
+ viewBox: '0 0 16 16',
56
+ line: [r2(cx + 0.15 * R), r2(cy - R), r2(cx + 0.55 * R), cy],
57
+ stops: BRAND_RUN.map((color, i) => ({ offset: r2(i / last), color })),
58
+ bands: out,
59
+ };
60
+ }
61
+ /** The mark as a standalone SVG document; `ground` paints an opaque square behind it. */
62
+ export function brandMarkSvg(bands = 4, ground, id = 'ensemble-mark') {
63
+ const m = brandMark(bands);
64
+ const [x1, y1, x2, y2] = m.line;
65
+ return [
66
+ `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${m.viewBox}">`,
67
+ ground ? `<rect width="16" height="16" fill="${ground}"/>` : '',
68
+ `<defs><linearGradient id="${id}" gradientUnits="userSpaceOnUse" x1="${x1}" y1="${y1}" x2="${x2}" y2="${y2}">`,
69
+ ...m.stops.map((s) => `<stop offset="${s.offset}" stop-color="${s.color}"/>`),
70
+ `</linearGradient></defs>`,
71
+ `<g fill="none" stroke="url(#${id})">`,
72
+ ...m.bands.map((b) => `<path d="${b.d}" stroke-width="${b.width}"/>`),
73
+ `</g></svg>`,
74
+ '',
75
+ ].join('');
76
+ }
@@ -1,5 +1,6 @@
1
1
  export * from './types.js';
2
2
  export * from './product.js';
3
+ export * from './brand-mark.js';
3
4
  export * from './conflicts.js';
4
5
  export * from './conflict-fold.js';
5
6
  export * from './pending-rules.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ensemble-review",
3
- "version": "1.0.37",
3
+ "version": "1.0.39",
4
4
  "description": "Dashboard for tracking your team's GitHub PR activity across repos. Runs on your machine with your gh login.",
5
5
  "type": "module",
6
6
  "author": "Alex Wakeman",
@@ -100,7 +100,7 @@
100
100
  "CODEX_VERSION": "0.164.0"
101
101
  },
102
102
  "repository": "ghcr.io/alexwakeman/limn-sandbox",
103
- "tag": "1.0.37",
104
- "digest": "sha256:2645ccce85edee7e3757445c1cbb588e5d6a9c9ed1744c2224c7b9f35349ec45"
103
+ "tag": "1.0.39",
104
+ "digest": "sha256:16bfcd4e08cad1b926e7daf96894526dad15af0b544e686fe2c862d6fca8359f"
105
105
  }
106
106
  }
Binary file
@@ -1 +1 @@
1
- import{j as e,r as x,d as Ee}from"./tanstack-5qsxxaLe.js";import{H as se,i as _e,d as Me,c as $e,I as U,aa as I,A as ge,C as Be,Z as Le,a1 as Oe,as as De,Y as We,J as Ue,ap as He,aq as ze,q as Ye,L as qe,m as Ke,v as Ve,j as Ge,T as Xe,p as Je,o as Qe,O as Ze,f as H,l as je,a2 as be,a3 as et,a7 as tt,ag as st,y as nt,af as it,am as at,ao as rt,z as lt,ae as ot,x as ct,ad as ut,U as dt,a0 as ht,a4 as mt,a8 as xt,al as ft,P as pt,S as gt,r as jt,a as bt,a6 as we,b as wt,E as Ne,u as Nt,$ as kt,V as ke,X as ne,M as vt,g as yt,n as Rt,F as ve,_ as ye,ab as Pt,ak as St,an as Ft,ac as Ct,w as It,a9 as Tt,B as J,s as At,G as Et,e as _t,W as Mt,ai as $t,R as ce,h as Bt,D as Lt}from"./index-BrjUDY3j.js";import"./markdown-I_JLLVAZ.js";import"./highlight-CIIZLa6Z.js";import"./vis-C3BCkP5U.js";function Ot(t){return t==null?!1:t.live?t.phase!=="discarded"&&t.phase!=="failed":t.phase==="built"&&t.resumable}function Dt(t){return(t==null?void 0:t.live)===!0}function Wt(t,s){switch(t.phase){case"booting":return"Setting up the sandbox.";case"ready":return"The plan is ready. Talk to the agent, then press Start fix.";case"chatting":return t.mode==="chat"?"The agent is making a plan.":"The agent is answering.";case"planning":case"revising":return"The agent is making a plan.";case"plan_ready":return"The plan is ready. Talk to the agent, then press Start fix.";case"building":return"The agent is fixing and testing.";case"built":return t.live?"Fixed. Review the changes and push them, or ask for more.":s?"An automatic fix. The sandbox is closed and the changes are kept: push them, or resume.":"The sandbox is closed. The changes are kept: push them, or resume.";case"pushed":return"Pushed.";case"discarded":return"Discarded.";case"failed":return"The session failed."}}function Ut(t,s){if(t.repoId===s.prRepoId){const a=s.filesChanged>0?`${s.filesChanged} file${s.filesChanged===1?"":"s"} changed`:null,i=s.merge;return{status:s.pushed?"Pushed":i!=null&&i.status==="valid"?a!=null?`${i.baseRef} merged · ${a}`:`${i.baseRef} merged`:i!=null&&(i.status==="invalid"||i.status==="missing")?"Merge not valid":a??"No changes yet",note:s.headRef!=null?`Pushes to ${s.headRef}`:"Pushes to the PR branch"}}const n=s.leftOut.find(a=>a.repoId===t.repoId);return n!=null&&n.files.length>0?{status:`${n.files.length} file${n.files.length===1?"":"s"} left out`,note:"Read only. Edits here are left out."}:{status:"Read only",note:null}}function Ht(t,s){return`Edits in ${t.fullName} are left out. AI Fix pushes only ${s}.`}function zt(t){return t.error==null||t.error===""?null:t.session==null||t.error.startsWith("Automatic push failed")?"warn":"note"}const ue=t=>(t??"").slice(0,7);function Yt(t){return t.merge!=null?t.merge.status==="valid":(t.patch??"")!==""&&t.filesChanged.length>0}function qt(t,s){const n=t.conflictedFiles.length;switch(t.status){case"valid":{const a=s!=null&&s!==""?` (${ue(s)})`:"",i=n===0?"":n===1?" No conflict markers are left in the file that was in conflict.":` No conflict markers are left in the ${n} files that were in conflict.`;return{tone:"ok",text:`Ensemble checked the merge commit. Its parents are the PR head${a} and ${t.baseRef} (${ue(t.baseSha)}).${i}`}}case"invalid":case"missing":return{tone:"bad",text:`Nothing will be pushed: ${t.reason??"the merge did not pass Ensemble’s check."}`};case"pending":return{tone:"pending",text:`The merge of ${t.baseRef} is not finished.`}}}function Kt(t,s){return t==null||s.phase!=="built"||t.status!=="invalid"&&t.status!=="missing"?null:"The merge did not pass Ensemble’s check, so nothing can be pushed. Ask for more, or discard."}const de="inline-flex items-center rounded-ui bg-ui-raise px-1.5 py-px font-mono text-meta text-ui-ink";function Re({plan:t}){return e.jsx("ul",{className:"list-disc space-y-0.5 pl-5 text-body text-ui-ink",children:t.summary.map((s,n)=>e.jsx("li",{children:s},n))})}function he(t,s){var n;return((n=t==null?void 0:t.find(a=>a.ref===s))==null?void 0:n.title)??null}function Vt({plan:t,items:s}){return e.jsxs("div",{className:"mt-2 space-y-3 text-meta text-ui-ink",children:[t.steps.length>0&&e.jsx("ol",{className:"list-decimal space-y-2 pl-5",children:t.steps.map((n,a)=>e.jsxs("li",{children:[e.jsx("div",{className:"font-medium text-ui-ink",children:n.title}),n.files.length>0&&e.jsx("div",{className:"mt-0.5 font-mono text-meta text-ui-mute",children:n.files.join(", ")}),e.jsx("p",{className:"mt-0.5 whitespace-pre-wrap",children:n.change}),n.refs.length>0&&e.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:n.refs.map(i=>e.jsx("span",{className:de,children:i},i))})]},a))}),t.notAddressed.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"mb-1 font-semibold text-ui-mute",children:"Will not fix"}),e.jsx("ul",{className:"space-y-1",children:t.notAddressed.map(n=>e.jsxs("li",{children:[e.jsx("span",{className:de,children:n.ref})," ",he(s,n.ref)&&e.jsxs("span",{className:"font-medium",children:[he(s,n.ref),": "]}),n.reason]},n.ref))})]}),t.notCovered.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"font-semibold text-ui-mute",children:"Not in the plan: "}),t.notCovered.join(", ")]})]})}function Gt({fix:t}){const[s,n]=x.useState(!1),a=t.plan;if(a==null||a.plan==null||a.status==="approved")return null;const i=a.plan,l=se(a.model!=null?a:t);return e.jsxs("div",{"data-testid":"ai-fix-plan-history",className:"mt-3 rounded-ui bg-ui-surface p-2",children:[e.jsxs("div",{className:"mb-1 text-meta font-semibold text-ui-mute",children:["The plan ",l," made"]}),e.jsx(Re,{plan:i}),e.jsxs("button",{type:"button",className:"hit mt-1 inline-flex items-center gap-1 text-meta text-ui-mute hover:text-ui-ink","aria-expanded":s,onClick:()=>n(o=>!o),children:[e.jsx(_e,{dir:s?"down":"right"}),s?"Hide the details":"Show the details"]}),s&&e.jsx(Vt,{plan:i,items:t.reviewItems}),s&&a.transcript.length>0&&e.jsx("ul",{className:"mt-3 space-y-1.5 border-t border-ui-line pt-2 text-meta",children:a.transcript.map((o,f)=>e.jsxs("li",{className:"whitespace-pre-wrap text-ui-ink",children:[e.jsxs("span",{className:"font-semibold",children:[o.role==="reader"?"You":l,": "]}),o.text]},f))})]})}function Xt({fix:t}){var n;const s=((n=t.plan)==null?void 0:n.status)==="approved"?t.plan.plan:null;return s?e.jsxs("div",{className:"mb-2 rounded-ui bg-ui-surface p-2",children:[e.jsx("div",{className:"mb-1 text-meta font-semibold text-ui-mute",children:"Built from your plan"}),e.jsx(Re,{plan:s})]}):null}function Jt(t,s,n){var a;return t??((s==null?void 0:s.status)==="succeeded"?s.id:((a=n.find(i=>i.status==="succeeded"))==null?void 0:a.id)??null)}function Qt(t,s,n){return s==null||n==null||s===n.id?null:t!=null?"Uses the review you picked, not the latest.":n.status==="failed"?"Uses the last review that finished. The latest one failed.":n.status==="running"||n.status==="queued"?"Uses the last review that finished. A newer one is running.":"Uses the last review that finished."}const me=Be,Zt=$e;function es(t){return t.kind==="finding"&&t.findingId!=null?`claude-finding-${t.findingId}`:null}function ts(t){const s=I(n=>n.openClaudeReview);return n=>{s({id:t.id,number:t.number,title:t.title,repoFullName:t.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null});const a=Date.now()+3e3,i=()=>{const l=document.getElementById(n);if(l){l.scrollIntoView({behavior:"smooth",block:"center"});return}Date.now()<a&&requestAnimationFrame(i)};requestAnimationFrame(i)}}function xe({refId:t,item:s,onJump:n}){const a=s?`${ge[s.kind]} ${t}`:t,i=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"shrink-0",children:a}),s&&e.jsxs("span",{className:"min-w-0 truncate font-normal",children:["· ",s.title]})]}),l=s?es(s):null;return l?e.jsx("button",{type:"button",onClick:()=>n(l),"aria-label":`${a}: ${(s==null?void 0:s.title)??""}. Show in AI Review`,className:`${me} max-w-[22rem] hover:bg-ui-hover`,children:i}):e.jsx("span",{className:`${me} max-w-[22rem]`,children:i})}function Pe(t){var s;switch(t.seed){case"review":{const n=((s=t.reviewItems)==null?void 0:s.length)??0;return`Fix from ${t.sourceReviewId==null?"the CI check":"the AI review"}${n>0?` (${n} item${n===1?"":"s"})`:""}.`}case"plain":return"Fix from your instruction.";case"comments":return"Fix from picked comments (no longer offered).";case"ci_analysis":return"Fix from the CI analysis (no longer offered).";default:return""}}function ss({pr:t,fix:s}){const n=se(s),a=ts(t),i=s.changeReport,l=new Map((s.reviewItems??[]).map(c=>[c.ref,c])),o=(s.reviewItems??[]).filter(c=>!c.included);if(!i&&o.length===0)return null;const f=l.size>0;return e.jsxs("div",{className:"mt-2 text-meta",children:[e.jsx(Me,{report:i,filesChanged:s.filesChanged,by:n,refsInfo:f?e.jsx("p",{children:"Each tag is a review item the change answers. A finding tag opens it in the AI Review tab."}):null,renderRef:c=>e.jsx(xe,{refId:c,item:l.get(c),onJump:a},c)}),o.length>0&&e.jsxs("section",{children:[e.jsxs("div",{className:Zt,children:["Left out",e.jsx(U,{title:"Left out",children:e.jsxs("p",{children:["These review items did not fit in what ",n," was sent, so it never saw them."]})})]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:o.map(c=>e.jsx(xe,{refId:c.ref,item:c,onJump:a},c.ref))})]})]})}const ns=["conflicts","findings","earlier_findings","judged_threads","untouched_threads","ci_failures","sonar","style_bots","story"],is={conflicts:"Merge conflicts",findings:"Claude’s findings",earlier_findings:"Earlier findings still open",judged_threads:"Threads Claude says need a fix",untouched_threads:"Unanswered threads",ci_failures:"CI failures",sonar:"SonarCloud issues",style_bots:"Style bot comments",story:"Ticket gaps"};function fe(t,s="Claude"){return t==="findings"?`${s}’s findings`:t==="judged_threads"?`Threads ${s} says need a fix`:is[t]}function z(t,s){return s[t.key]??t.defaultIncluded}function as(t,s){return t.items.filter(n=>z(n,s)).map(n=>n.key)}function Se(t,s){const n=new Set;let a=0;for(const i of t.items)if(z(i,s)){if(a>0&&a+i.chars>t.budgetChars){n.add(i.key);continue}a+=i.chars}return n}function rs(t,s){const n={};for(const a of t.items)n[a.key]=a.section===s;return n}const ls={blocker:"Blocker",warning:"Warning",nit:"Nit",question:"Question",praise:"Praise"},pe={blocker:"bg-ui-danger/10 text-ui-danger",warning:"bg-ui-raise text-ui-warn",nit:"bg-ui-raise text-ui-mute"},Fe="whitespace-nowrap rounded-ui bg-ui-raise px-1 py-px text-meta text-ui-warn",Q=new Set;function os(t,s){return t?s!=null?`${t}:${s}`:t:null}function cs({item:t,picked:s,cut:n,disabled:a,onToggle:i}){return e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5 pt-0.5",children:[e.jsx("label",{className:"flex cursor-pointer items-center touch:-my-3 touch:min-h-10 touch:min-w-10 touch:justify-center",children:e.jsx(H,{checked:s,disabled:a,onChange:l=>i(l.target.checked),"aria-label":`Include in the fix: ${t.label}`})}),s&&n&&e.jsx("span",{className:Fe,children:"Won’t fit"})]})}function us({item:t,picked:s,cut:n,disabled:a,onToggle:i}){const l=os(t.path,t.line);return e.jsx("li",{children:e.jsxs("label",{className:`flex cursor-pointer items-start gap-2 rounded-ui border px-2 py-1.5 text-meta ${s?"border-ui-line bg-ui-sel":"border-ui-line"}`,children:[e.jsx(H,{className:"mt-0.5",checked:s,disabled:a,onChange:o=>i(o.target.checked)}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"flex flex-wrap items-center gap-1.5",children:[t.severity&&pe[t.severity]&&e.jsx("span",{className:`rounded-ui px-1 py-px text-meta font-medium ${pe[t.severity]}`,children:ls[t.severity]}),t.section==="conflicts"&&e.jsx(je,{size:12,className:"shrink-0 text-ui-mute"}),e.jsx("span",{className:"break-words text-ui-ink",children:t.label}),s&&n&&e.jsx("span",{className:Fe,children:"Won’t fit"})]}),(l||t.detail)&&e.jsxs("span",{className:"mt-0.5 block break-words text-meta text-ui-mute",children:[l&&e.jsx("span",{className:"font-mono",children:l}),l&&t.detail?" · ":"",t.detail]})]})]})})}function ds({preview:t,overrides:s,onChange:n,disabled:a,pr:i,review:l}){const o=Se(t,s),f=new Map;for(const r of t.items){const h=f.get(r.section)??[];h.push(r),f.set(r.section,h)}const c=(r,h)=>{const j={...s};for(const k of r)j[k]=h;n(j)},u=l!=null&&l.id===t.sourceReviewId?l:null,b=Le(l),y=Oe(l),d=x.useMemo(()=>u!=null?De(u):null,[u]),w=x.useMemo(()=>new Map(((d==null?void 0:d.findings)??[]).map(r=>[r.id,r])),[d]),R=x.useMemo(()=>{var r;return new Map((((r=d==null?void 0:d.followUp)==null?void 0:r.items)??[]).map(h=>[h.priorFindingId,h]))},[d]),F=x.useMemo(()=>d!=null?We(d):new Map,[d]),C=x.useMemo(()=>d!=null?Ue(d):new Set,[d]),T=x.useMemo(()=>{var h;const r=new Set;for(const j of t.items)((h=j.card)==null?void 0:h.kind)==="story"&&r.add(j.card.ticketReviewId);return[...r].sort((j,k)=>j-k)},[t.items]),A=He(i.id,T.length>0),E=x.useMemo(()=>{var h;const r=new Map;for(const j of((h=A.data)==null?void 0:h.tickets)??[])j.review!=null&&r.set(j.review.id,j.review);return r},[A.data]),$=x.useMemo(()=>A.data==null?[]:T.filter(r=>!E.has(r)),[A.data,T,E]),B=ze($),Y=x.useMemo(()=>{const r=new Map(E);for(const h of B)r.set(h.id,h);return r},[E,B]);if(t.items.length===0)return e.jsx("p",{className:"text-meta text-ui-mute",children:"The review found nothing to fix."});const q=(u==null?void 0:u.headSha)??i.headSha,P=r=>{var W,_;const h=z(r,s),j=o.has(r.key),k=p=>c([r.key],p),g=e.jsx(cs,{item:r,picked:h,cut:j,disabled:a,onToggle:k}),N=r.card;switch(N==null?void 0:N.kind){case"finding":{const p=w.get(N.findingId);if(p==null)break;return e.jsx(Qe,{authorName:Ze(l,p),prId:i.id,finding:p,editable:!1,prUrl:i.githubUrl,repoFullName:i.repoFullName,headSha:q,posting:!1,postError:null,inChangeset:p.fileInDiff,priorStatus:F.get(p.id),alreadyPosted:C.has(p.id),actions:!1,selection:g,docReferences:(u==null?void 0:u.docReferences)??null},r.key)}case"earlier_finding":{const p=R.get(N.priorFindingId);if(p==null)break;return e.jsx(Je,{item:p,muted:!1,findingsById:w,headMoved:((W=d==null?void 0:d.followUp)==null?void 0:W.headMoved)??!1,changedPaths:Q,actions:!1,selection:g,by:b},r.key)}case"thread":return e.jsx(Xe,{t:N.assessment,muted:!1,actions:!1,selection:g,notCheckedNote:N.inReview?void 0:`${y} didn’t check this one.`,by:y},r.key);case"ci":return e.jsx(Ge,{f:N.item,suggestion:N.item.suggestion,changedPaths:Q,selection:g},r.key);case"sonar":return e.jsx(Ve,{issue:N.issue,selection:g},r.key);case"story":{const p=Y.get(N.ticketReviewId),m=p==null?void 0:p.items.find(O=>O.id===N.itemId);if(p==null||m==null)break;const L={review:p,viewedPrId:i.id,changedPaths:Q,actions:!1,selection:g};if(m.status==="missing")return e.jsx(Ye,{item:m,...L},r.key);const S=(_=p.assessment)==null?void 0:_.criteria.find(O=>O.ref===m.ref);if(S==null||qe(S.status))break;return e.jsx(Ke,{c:S,item:m,...L},r.key)}}return e.jsx(us,{item:r,picked:h,cut:j,disabled:a,onToggle:k},r.key)};return e.jsxs("div",{className:"space-y-3",children:[ns.filter(r=>f.has(r)).map(r=>{const h=f.get(r),j=h.filter(g=>z(g,s)).length,k=j===h.length;return e.jsxs("section",{"aria-label":fe(r,b),children:[e.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[e.jsx("h4",{className:"text-meta font-semibold text-ui-ink",children:fe(r,b)}),e.jsxs("span",{className:"text-meta text-ui-mute",children:[j," of ",h.length]}),e.jsx("button",{type:"button",className:"hit ml-auto text-meta text-ui-accent hover:underline disabled:opacity-50",disabled:a,onClick:()=>c(h.map(g=>g.key),!k),children:k?"Untick all":"Tick all"})]}),e.jsx("ul",{className:"space-y-1.5",children:h.map(P)})]},r)}),o.size>0&&e.jsxs("p",{className:"text-meta text-ui-warn",children:[o.size," ticked ",o.size===1?"item does":"items do"," not fit in one fix and will be left out. Untick something to make room."]})]})}const hs="limn.aiFix.pushWhenDone",Z="inline-flex h-7 items-center whitespace-nowrap rounded-ui bg-ui-raise px-2.5 text-meta font-medium text-ui-ink hover:bg-ui-hover disabled:cursor-not-allowed disabled:opacity-50 touch:h-10 touch:px-3";function ee(t){return t instanceof wt||t instanceof Error?t.message:"Something went wrong"}const te="inline-flex h-7 items-center whitespace-nowrap rounded-ui bg-ui-raise px-2.5 text-meta font-medium text-ui-ink hover:bg-ui-hover disabled:cursor-not-allowed disabled:opacity-50 touch:h-10 touch:px-3";function ms({children:t,info:s}){return e.jsxs("div",{className:"flex items-center gap-1.5 px-4 pb-2 pt-4 text-title text-ui-ink md:px-5",children:[e.jsx("h3",{children:t}),s]})}function Es({pr:t}){const s=be().enabled,n=I(c=>c.aiFixTabFocus),a=I(c=>c.consumeAiFixTabFocus),[i,l]=x.useState(null),[o,f]=x.useState(null);return x.useEffect(()=>{n&&n.prId===t.id&&(n.reviewId!=null&&l(n.reviewId),n.only!=null&&f(n.only),a())},[n,t.id,a]),s?e.jsx("div",{className:"pb-6",children:e.jsx(xs,{pr:t,handoffReviewId:i,onlySection:o,onOnlySectionApplied:()=>f(null)})}):e.jsx(e.Fragment,{})}function xs({pr:t,handoffReviewId:s,onlySection:n,onOnlySectionApplied:a}){var re,le,oe;const{data:i,isLoading:l}=et(t.id,!0),{data:o,isLoading:f}=tt(t.id),c=(o==null?void 0:o.review)??null,u=Jt(s,c,(o==null?void 0:o.history)??[]),b=Qt(s,u,c),y=I(v=>v.setPrDetailTab),d=st("fix",Lt),w=nt(d.chosen.provider),R=it().data,F=at(t.id),C=rt(t.id);be();const T=lt(R,d.chosen.provider,"plan"),[A,E]=x.useState(!1),$=A&&T,[B,Y]=ot(hs,!0),q=I(v=>v.noteAiFixRun),P=Ee({mutationKey:ct(t.id)})>0,r=(i==null?void 0:i.fix)??null,h=(r==null?void 0:r.session)??null,j=(h==null?void 0:h.live)===!0,k=ut(t.id,(r==null?void 0:r.id)??null,j),g=h!=null?dt(h,j||k.done?k.session:null):null,N=r!=null&&g!=null&&Ot(g),W=g!=null&&ht(g),_=(i==null?void 0:i.waiting)??null,p=Dt(g)||P||_!=null,m=mt(t.id,u,(i==null?void 0:i.enabled)!==!1&&(u!=null||!f)),L=u==null&&m.data!=null&&m.data.sourceReviewId==null&&m.data.items.length>0,S=u!=null||L,O=xt(u!=null&&(c==null?void 0:c.id)!==u?u:null),Ie=u!=null&&(c==null?void 0:c.id)===u?c:O.data??null,[K,V]=x.useState({});x.useEffect(()=>V({}),[u]);const[Te,D]=x.useState(!1);x.useEffect(()=>{n==null||!m.data||(V(rs(m.data,n)),D(!0),a())},[n,m.data,a]);const G=!p&&(Te||!r||r.status!=="succeeded"),X=ft(G&&S),ie=X.data!=null&&!X.data.available,M=m.data?as(m.data,K):[],ae=m.data?Se(m.data,K).size:0,Ae=()=>{if(!S||!m.data||M.length===0)return;const v={model:d.chosen.model,provider:d.chosen.provider,seed:"review",...u!=null?{sourceReviewId:u}:{},include:M,pushWhenDone:B};$?C.mutate(v,{onSuccess:()=>D(!1)}):(q({prId:t.id,repoFullName:t.repoFullName,prNumber:t.number,prTitle:t.title}),F.mutate(v,{onSuccess:()=>D(!1)}))};return e.jsxs("div",{children:[e.jsx(ms,{info:e.jsxs(U,{title:"AI Fix",children:[e.jsxs("p",{children:[w," reads the PR's code and fixes it in a sandbox on this computer. The sandbox holds every repository in the workspace; the PR's repository is at the PR's latest commit. There"," ",w," can run the project's own tests, lint and type checks, and start the services you picked for integration tests."]}),e.jsx("p",{children:"A fix starts from an AI review. Pick what it should work on: the review's findings, earlier findings still open, threads the review says need a fix, unanswered threads, CI failures and ticket gaps are ticked; style bot comments are not."}),e.jsx("p",{children:"With no AI review, a fix can start from a finished CI check: it works on the failures the check says this PR can fix."}),e.jsxs("p",{children:["When the PR conflicts with its base branch, Resolve merge conflicts is ticked too. ",w," ","merges the base first and resolves each conflict, then fixes the other items on top. Ensemble checks the merge commit before Push. You can still resolve conflicts by hand with Resolve conflicts."]}),e.jsxs("p",{children:["Start fix starts at once. Watch it work, press Stop, or ask for more in the same session. Tick Plan first to read and discuss ",w,"'s plan before anything changes, then press Start fix."]}),e.jsxs("p",{children:[w," reports what it changed in each file and what it left alone, and why."]}),e.jsx("p",{children:"Only the PR's repository is pushed, to the PR's own branch. Edits in other repositories are shown and left out. Nothing is pushed until you press Push. An automatic fix on your own PR is pushed for you only when Push automatically is on in Settings."})]}),children:"AI Fix"}),e.jsxs("div",{className:"px-4",children:[(i==null?void 0:i.enabled)===!1?e.jsx("p",{className:"text-body text-ui-mute",children:"The agentic fixer is turned off."}):e.jsxs(e.Fragment,{children:[_!=null&&e.jsx(Ss,{prId:t.id,line:pt(_)}),!p&&!S&&!f&&!m.isLoading&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-meta text-ui-mute",children:(c==null?void 0:c.status)==="running"||(c==null?void 0:c.status)==="queued"?"A fix starts from an AI review. One is running.":"A fix starts from a finished AI review."}),e.jsx("button",{type:"button",className:Z,onClick:()=>y(t.id,"claude_review"),children:"Open AI Review"})]}),!p&&S&&!G&&e.jsx("button",{type:"button",className:te,onClick:()=>D(!0),children:"New fix"}),S&&G&&e.jsxs("div",{children:[b&&e.jsx("p",{className:"mb-2 text-meta text-ui-mute",children:b}),L&&((re=m.data)==null?void 0:re.items.some(v=>v.section==="ci_failures"))&&e.jsx("p",{className:"mb-2 text-meta text-ui-mute",children:"No AI review yet. This fix works on the CI check’s failures."}),m.isLoading&&e.jsx("p",{className:"text-meta text-ui-mute",children:"Loading…"}),m.isError&&u!=null&&e.jsx("p",{className:"text-meta text-ui-danger",children:ee(m.error)}),m.data&&e.jsx(ds,{preview:m.data,overrides:K,onChange:V,disabled:P,pr:t,review:Ie}),m.data&&m.data.items.length>0&&ie&&e.jsx("div",{className:"mt-3","data-testid":"ai-fix-no-runtime",children:e.jsx(gt,{status:X.data,loading:!1,testId:"ai-fix-runtime-line"})}),m.data&&m.data.items.length>0&&!ie&&e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 max-md:sticky max-md:bottom-0 max-md:z-20 max-md:-mx-4 max-md:bg-ui-surface max-md:px-4 max-md:py-3",children:[e.jsx(jt,{state:d,onPick:d.pick,disabled:P}),T&&e.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5 text-meta text-ui-ink",children:[e.jsx(H,{checked:$,disabled:P,onChange:v=>E(v.target.checked)}),"Plan first"]}),e.jsxs("label",{"data-testid":"ai-fix-push-when-done",className:"flex cursor-pointer items-center gap-1.5 text-meta text-ui-ink",children:[e.jsx(H,{checked:B,disabled:P,onChange:v=>Y(v.target.checked)}),"Push when done",e.jsxs(U,{title:"Push when done",children:[e.jsx("p",{children:"When the fix finishes on your own pull request, Ensemble pushes it to the pull request's branch. You do not press Push."}),e.jsx("p",{className:"mt-2",children:"It waits for your press instead when the agent says something is not fixed, its report does not cover every item, or the pull request is someone else's. The session says which."}),e.jsx("p",{className:"mt-2",children:"A push ends the session, so untick this to keep talking to the agent first."})]})]}),e.jsx(bt,{kind:"fix",auth:i==null?void 0:i.auth,anyProvider:!0,provider:d.chosen.provider,children:e.jsx("button",{type:"button",className:Z,"data-ai-fix-action":"start",disabled:P||M.length===0,onClick:Ae,children:P?"Starting…":$?"Make a plan":"Start fix"})}),e.jsx("span",{className:"text-meta text-ui-mute",children:M.length===0?"Nothing ticked.":`${M.length-ae} item${M.length-ae===1?"":"s"}`}),(r==null?void 0:r.status)==="succeeded"&&e.jsx("button",{type:"button",className:te,onClick:()=>D(!1),children:"Close"})]})]}),(F.isError||C.isError)&&e.jsx("p",{className:"mt-1 text-meta text-ui-danger",children:ee(F.error??C.error)}),N&&r!=null&&g!=null&&e.jsx(gs,{pr:t,fix:r,session:g,partials:k.partials,headRef:((le=i==null?void 0:i.headInfo)==null?void 0:le.headRef)??t.headRefName??null}),r&&!W&&(g==null?void 0:g.phase)!=="booting"&&e.jsx(ks,{pr:t,fix:r,headInfo:(i==null?void 0:i.headInfo)??null,viewerCanPush:(i==null?void 0:i.viewerCanPush)??!1}),l&&!r&&e.jsx("p",{className:"mt-3 text-meta text-ui-mute",children:"Loading…"})]}),e.jsx(Rs,{history:(i==null?void 0:i.history)??[],currentFixId:((oe=i==null?void 0:i.fix)==null?void 0:oe.id)??null})]})]})}const fs={startBuild:"Start fix",startBuildTitle:"The agent changes the code and runs the checks. The words in the box go with it.",readerBuildLabel:"You · Build turn",empty:"The agent has read the items to fix and the repositories.",chatPlaceholder:"Ask about the plan, or say what to change in it.",buildPlaceholder:"Ask for more. It is a build turn: the agent may edit and test.",resumeNote:"Resume starts a new sandbox with this fix. The agent does not remember the conversation.",gate:{chat:"plan",build:"fix"}};function ps(t,s,n,a){return{busyKey:It(t),useSend(){const i=Ct(t);return{run:(l,o)=>i.mutate({fixId:s,text:l},{onSuccess:o}),pending:i.isPending,error:i.error,succeeded:i.isSuccess}},useStartBuild(){const i=Ft(t);return{run:(l,o)=>(a(),i.mutate({fixId:s,text:l},{onSuccess:o})),pending:i.isPending,error:i.error,succeeded:i.isSuccess}},useStop(){const i=we(t);return{run:(l,o)=>i.mutate(void 0,{onSuccess:o}),pending:i.isPending,error:i.error,succeeded:i.isSuccess}},useResume(){const i=St(t);return{run:(l,o)=>i.mutate(s,{onSuccess:o}),pending:i.isPending,error:i.error,succeeded:i.isSuccess}},useAllow(){const i=Pt(t,n);return{run:(l,o)=>i.mutate({fixId:s,body:l},{onSuccess:o}),pending:i.isPending,error:i.error,succeeded:i.isSuccess}}}}function gs({pr:t,fix:s,session:n,partials:a,headRef:i}){const l=I(b=>b.workspaceId),o=I(b=>b.noteAiFixRun),f=x.useMemo(()=>ps(t.id,s.id,l,()=>o({prId:t.id,repoFullName:t.repoFullName,prNumber:t.number,prTitle:t.title})),[t.id,t.repoFullName,t.number,t.title,s.id,l,o]),c=s.leftOut??[],u=b=>Ut(b,{prRepoId:t.repoId,headRef:i,filesChanged:s.filesChanged.length,pushed:s.pushedAt!=null,leftOut:c,merge:s.merge??null});return e.jsxs("div",{"data-testid":"ai-fix-session",className:"mt-3",children:[e.jsxs("p",{"data-testid":"ai-fix-session-status",className:"flex flex-wrap items-center gap-2 text-meta text-ui-mute",children:[s.trigger==="auto"&&e.jsx(Ce,{}),e.jsx("span",{children:Kt(s.merge,n)??Wt(n,s.unattended===!0)}),n.model!=null&&e.jsxs("span",{children:["· ",Ne(n.provider,n.model,n.effort)]})]}),e.jsx(Nt,{session:n,partials:a,actions:f,words:fs,provider:ws(s),testPrefix:"fix-session",actionAttr:"data-ai-fix-action",railTop:e.jsx(js,{pr:t,fix:s}),repoStatus:u,composerExtra:kt(n)&&n.phase!=="pushed"?e.jsx(bs,{prId:t.id,fixId:s.id,live:n.live}):null})]})}function js({pr:t,fix:s}){const n=(s.reviewItems??[]).filter(a=>a.included);return e.jsxs(At,{title:"What to fix",testId:"fix-session-items",children:[s.seed==="plain"?e.jsx("p",{className:"text-meta text-ui-mute",children:"Your instruction."}):n.length===0?e.jsx("p",{className:"text-meta text-ui-mute",children:Pe(s)}):e.jsx("ul",{className:"space-y-1 text-meta text-ui-ink",children:n.map(a=>e.jsxs("li",{className:"break-words",children:[e.jsx("span",{className:"font-mono text-ui-mute",children:a.ref})," ",e.jsx("span",{className:"text-ui-mute",children:ge[a.kind]})," ",a.title,a.path!=null&&e.jsxs("span",{className:"block break-all font-mono text-ui-mute",children:[a.path,a.line!=null&&`:${a.line}`]})]},a.ref))}),e.jsxs("p",{className:"mt-1.5 text-meta text-ui-mute",children:["Pushes only to ",e.jsx("span",{className:"font-mono",children:t.repoFullName}),"."]})]})}function bs({prId:t,fixId:s,live:n}){const a=Tt(t),[i,l]=x.useState(!1);return i?e.jsxs("span",{className:"flex items-center gap-1.5 text-meta text-ui-ink",children:[e.jsx("span",{children:n?"Stop the agent and remove the sandbox? Nothing is pushed.":"Drop this fix? Nothing is pushed."}),e.jsx(J,{size:"sm",variant:"secondary","data-ai-fix-action":"discard-confirm",disabled:a.isPending,onClick:()=>a.mutate(s,{onSettled:()=>l(!1)}),children:"Discard"}),e.jsx(J,{size:"sm",variant:"ghost",onClick:()=>l(!1),children:"Keep"})]}):e.jsx(J,{size:"sm",variant:"ghost","data-ai-fix-action":"discard",onClick:()=>l(!0),children:"Discard"})}function Ce(){return e.jsx("span",{className:"inline-flex items-center rounded-ui bg-ui-raise px-1.5 py-px text-meta font-medium text-ui-mute",children:"Auto fix"})}function ws(t){return Et(t.provider,t.model)}function Ns(t){return Ne(t.provider,t.model,t.effort)}function ks({pr:t,fix:s,headInfo:n,viewerCanPush:a}){var b,y,d;const i=x.useMemo(()=>ke(s.patch),[s.patch]),l=s.merge??null;if(s.status==="failed"&&((b=s.plan)==null?void 0:b.status)==="failed")return e.jsxs("div",{className:"mt-3 rounded-ui border border-ui-danger/40 bg-ui-danger/10 p-2 text-meta text-ui-danger",children:[se(s.plan??s)," could not make a plan: ",s.error??"unknown error"]});if(s.status==="cancelled"&&((y=s.plan)==null?void 0:y.status)==="discarded")return e.jsx("p",{className:"mt-3 text-meta text-ui-mute",children:"The plan was discarded."});if(s.status==="failed")return e.jsxs("div",{className:"mt-3 rounded-ui border border-ui-danger/40 bg-ui-danger/10 p-2 text-meta text-ui-danger",children:["The fix run failed: ",s.error??"unknown error"]});if(s.status==="cancelled")return e.jsx("p",{className:"mt-3 text-meta text-ui-mute",children:s.session!=null?"The fix was stopped or discarded. Nothing was pushed.":"The fix run was cancelled."});if(s.status!=="succeeded")return e.jsx(e.Fragment,{});const o=!s.patch||s.filesChanged.length===0,f=Yt(s),c=zt(s),u=(s.leftOut??[]).filter(w=>w.files.length>0);return e.jsxs("div",{className:"mt-3 border-t border-ui-line pt-3",children:[e.jsxs("p",{className:"mb-1 text-meta text-ui-mute",children:[s.trigger==="auto"&&e.jsxs(e.Fragment,{children:[e.jsx(Ce,{})," "]}),Pe(s)," · ",Ns(s),s.finishedAt&&e.jsxs(e.Fragment,{children:[" · ",ne(s.finishedAt)]})]}),s.pushedAt==null&&c==="warn"&&e.jsx("p",{className:"mb-2 rounded-ui bg-ui-raise p-2 text-meta text-ui-warn",children:s.error}),s.pushedAt==null&&c==="note"&&((d=s.session)==null?void 0:d.resumable)!==!0&&e.jsx("p",{className:"mb-2 text-meta text-ui-mute",children:s.error}),e.jsx(Xt,{fix:s}),e.jsx(Gt,{fix:s}),s.summary&&e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(vt,{children:s.summary})}),e.jsx(ss,{pr:t,fix:s}),u.length>0&&e.jsx("ul",{"data-testid":"ai-fix-left-out",className:"mt-2 space-y-0.5 text-meta text-ui-mute",children:u.map(w=>e.jsxs("li",{children:[Ht(w,t.repoFullName)," ",e.jsxs("span",{className:"font-mono",children:[w.files.slice(0,5).join(", "),w.files.length>5?`, and ${w.files.length-5} more`:""]})]},w.repoId))}),e.jsx(yt,{checks:s.checks}),l!=null&&e.jsx(vs,{merge:l,headSha:s.baseSha}),o?e.jsx("p",{className:"mt-2 text-meta text-ui-mute",children:l!=null?"No other changes on top of the merge.":"No files changed."}):e.jsxs("div",{"data-testid":"ai-fix-changes",children:[e.jsxs("div",{className:"mb-1 mt-2 flex items-center justify-between gap-3 text-meta text-ui-mute",children:[e.jsxs("span",{children:[l!=null&&e.jsx("span",{className:"font-semibold text-ui-ink",children:"Fixes on top of the merge · "}),s.filesChanged.length," file",s.filesChanged.length===1?"":"s"," changed"]}),e.jsx(Rt,{})]}),e.jsx("div",{className:"overflow-hidden rounded-ui bg-ui-surface text-ui-ink",children:e.jsx(ve,{files:i})})]}),f&&e.jsx(Ps,{pr:t,fix:s,headInfo:n,viewerCanPush:a})]})}function vs({merge:t,headSha:s}){const n=x.useMemo(()=>ke(t.resolutionDiff),[t.resolutionDiff]),a=qt(t,s),i=t.conflictedFiles.length;return e.jsxs("div",{"data-testid":"ai-fix-merge","data-merge-status":t.status,className:"mt-2",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1.5 text-meta font-semibold text-ui-ink",children:[e.jsx(je,{size:12}),"Merge of ",e.jsx("span",{className:"font-mono",children:t.baseRef}),e.jsxs(U,{title:"How the conflicts were resolved",children:[e.jsxs("p",{children:["The agent merged ",t.baseRef," into the PR in the sandbox and made a merge commit. Ensemble then checked it: the merge commit's parents must be the PR head and the ",t.baseRef," commit Ensemble picked, no conflict markers may be left in the files that were in conflict, and every other change must sit on top of the merge."]}),e.jsx("p",{children:"The diff below compares the merge commit with git's own merge, conflict markers and all. Each hunk shows how one conflict was settled. Check for lines that are doubled or dropped."}),e.jsx("p",{children:"Push sends the merge commit and the fixes on top to the PR's branch. A merge that fails the check sends nothing."})]})]}),e.jsxs("p",{"data-testid":"ai-fix-merge-check",className:`flex items-start gap-1.5 text-meta ${a.tone==="ok"?"text-ui-success":a.tone==="bad"?"text-ui-danger":"text-ui-mute"}`,children:[a.tone==="ok"?e.jsx(_t,{size:12,className:"mt-0.5 shrink-0"}):a.tone==="bad"?e.jsx(Mt,{size:12,className:"mt-0.5 shrink-0"}):null,e.jsx("span",{children:a.text})]}),i>0&&e.jsxs("p",{className:"mt-0.5 break-words text-meta text-ui-mute",children:["In conflict: ",e.jsx("span",{className:"font-mono",children:t.conflictedFiles.slice(0,8).join(", ")}),i>8?`, and ${i-8} more`:""]}),n.length>0?e.jsxs("div",{"data-testid":"ai-fix-resolution",className:"mt-2",children:[e.jsxs("div",{className:"mb-1 text-meta text-ui-mute",children:[e.jsx("span",{className:"font-semibold text-ui-ink",children:"How the conflicts were resolved"})," · ",n.length," file",n.length===1?"":"s"]}),e.jsx("div",{className:"overflow-hidden rounded-ui bg-ui-surface text-ui-ink",children:e.jsx(ve,{files:n})})]}):t.status==="valid"&&i>0&&e.jsx("p",{className:"mt-1 text-meta text-ui-mute",children:"The merge commit matches git's own merge outside the conflicts."})]})}function ys({fix:t}){return e.jsxs("div",{className:"mb-2 rounded-ui bg-ui-raise p-2 text-meta text-ui-success",children:[e.jsxs("div",{children:["Pushed to ",e.jsx("span",{className:"font-mono",children:t.pushedBranch}),t.pushedPrUrl&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("a",{href:ye(t.pushedPrUrl),target:"_blank",rel:"noreferrer",className:"hit underline",children:["PR #",t.pushedPrNumber]})]}),t.pushedAt&&e.jsxs(e.Fragment,{children:[" · ",ne(t.pushedAt)]})]}),t.commitMessage&&e.jsx("div",{className:"mt-1 font-mono text-meta text-ui-success",children:t.commitMessage})]})}function Rs({history:t,currentFixId:s}){const n=t.filter(a=>a.pushedAt!=null&&a.id!==s);return n.length===0?null:e.jsxs("div",{className:"mt-6",children:[e.jsx("div",{className:"mb-2 text-title text-ui-ink",children:"Earlier fixes pushed"}),e.jsx("ul",{className:"space-y-2",children:n.map(a=>e.jsxs("li",{className:"text-meta",children:[e.jsx("div",{className:"font-mono text-ui-ink",children:a.commitMessage??"(no commit message)"}),e.jsxs("div",{className:"mt-0.5 text-meta text-ui-faint",children:[a.pushedBranch&&e.jsx("span",{className:"font-mono",children:a.pushedBranch}),a.pushedPrUrl&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("a",{href:ye(a.pushedPrUrl),target:"_blank",rel:"noreferrer",className:"hit underline",children:["PR #",a.pushedPrNumber]})]}),a.pushedAt&&e.jsxs(e.Fragment,{children:[" · ",ne(a.pushedAt)]})]})]},a.id))})]})}function Ps({pr:t,fix:s,headInfo:n,viewerCanPush:a}){const i=$t(t.id),l=(n==null?void 0:n.canPushSameBranch)??!1,o=s.merge!=null,[f,c]=x.useState(l?"existing":"new"),[u,b]=x.useState((n==null?void 0:n.suggestedBranch)??""),y=x.useRef(!1);if(x.useEffect(()=>{!y.current&&(n!=null&&n.suggestedBranch)&&(b(n.suggestedBranch),y.current=!0,!n.canPushSameBranch&&!o&&c("new"))},[n,o]),s.pushedAt!=null)return e.jsx(ys,{fix:s});if(!a)return e.jsx("p",{className:"mt-2 text-meta text-ui-mute",children:"You need write access to push this fix."});if(o&&!l)return e.jsx("p",{className:"mt-2 text-meta text-ui-mute",children:"A fix with a merge pushes only to the PR's own branch, and you can't push to it."});const d=o?"existing":f,w=d==="new"&&u.trim().length===0,R=i.isPending,F=()=>{i.mutate({fixId:s.id,body:{target:d,branch:f==="new"&&!o?u.trim():void 0}})};return e.jsxs("div",{className:"mt-3 rounded-ui bg-ui-surface p-2",children:[s.commitMessage&&e.jsx("div",{className:"mb-2 rounded-ui bg-ui-surface px-2 py-1 font-mono text-meta text-ui-ink",title:"Commit message",children:s.commitMessage}),e.jsxs("label",{className:`flex items-center gap-2 text-meta ${l?"":"opacity-40"}`,title:l?void 0:"The PR head is a fork you cannot push to — use a new branch",children:[e.jsx(ce,{className:"mt-0",checked:d==="existing",disabled:!l||R,onChange:()=>c("existing")}),"Push to the PR branch",(n==null?void 0:n.headRef)&&e.jsxs("span",{className:"font-mono text-ui-faint",children:["(",n.headRef,")"]})]}),!o&&e.jsxs("label",{className:"mt-1 flex items-center gap-2 text-meta",children:[e.jsx(ce,{className:"mt-0",checked:f==="new",disabled:R,onChange:()=>c("new")}),"New branch + open a PR"]}),f==="new"&&!o&&e.jsx("input",{type:"text",className:"mt-1 w-full rounded-ui bg-ui-raise px-2 py-1 font-mono text-meta ring-1 ring-inset ring-ui-line focus:outline-none focus:ring-2 focus:ring-ui-accent touch:min-h-10",value:u,disabled:R,onChange:C=>b(C.target.value),placeholder:"branch-name"}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",className:Z,disabled:R||w,onClick:F,children:R?"Pushing…":d==="new"?"Push + open PR":"Push"}),e.jsx(Bt,{checks:s.checks})]}),i.isError&&e.jsx("div",{className:"mt-2 text-meta text-ui-danger",children:ee(i.error)})]})}function Ss({prId:t,line:s}){const n=we(t);return e.jsxs("div",{"data-testid":"ai-fix-waiting",className:"mb-3 flex flex-wrap items-center gap-2 rounded-ui bg-ui-raise px-3 py-2 text-meta text-ui-ink",children:[e.jsx("span",{children:s}),e.jsx("button",{type:"button",className:te,disabled:n.isPending,onClick:()=>n.mutate(),children:"Cancel"})]})}export{Es as AiFixTab};
1
+ import{j as e,r as x,d as Ee}from"./tanstack-5qsxxaLe.js";import{H as se,i as _e,d as Me,c as $e,I as U,aa as I,A as ge,C as Be,Z as Le,a1 as Oe,as as De,Y as We,J as Ue,ap as He,aq as ze,q as Ye,L as qe,m as Ke,v as Ve,j as Ge,T as Xe,p as Je,o as Qe,O as Ze,f as H,l as je,a2 as be,a3 as et,a7 as tt,ag as st,y as nt,af as it,am as at,ao as rt,z as lt,ae as ot,x as ct,ad as ut,U as dt,a0 as ht,a4 as mt,a8 as xt,al as ft,P as pt,S as gt,r as jt,a as bt,a6 as we,b as wt,E as Ne,u as Nt,$ as kt,V as ke,X as ne,M as vt,g as yt,n as Rt,F as ve,_ as ye,ab as Pt,ak as St,an as Ft,ac as Ct,w as It,a9 as Tt,B as J,s as At,G as Et,e as _t,W as Mt,ai as $t,R as ce,h as Bt,D as Lt}from"./index-Bhnig73n.js";import"./markdown-I_JLLVAZ.js";import"./highlight-CIIZLa6Z.js";import"./vis-C3BCkP5U.js";function Ot(t){return t==null?!1:t.live?t.phase!=="discarded"&&t.phase!=="failed":t.phase==="built"&&t.resumable}function Dt(t){return(t==null?void 0:t.live)===!0}function Wt(t,s){switch(t.phase){case"booting":return"Setting up the sandbox.";case"ready":return"The plan is ready. Talk to the agent, then press Start fix.";case"chatting":return t.mode==="chat"?"The agent is making a plan.":"The agent is answering.";case"planning":case"revising":return"The agent is making a plan.";case"plan_ready":return"The plan is ready. Talk to the agent, then press Start fix.";case"building":return"The agent is fixing and testing.";case"built":return t.live?"Fixed. Review the changes and push them, or ask for more.":s?"An automatic fix. The sandbox is closed and the changes are kept: push them, or resume.":"The sandbox is closed. The changes are kept: push them, or resume.";case"pushed":return"Pushed.";case"discarded":return"Discarded.";case"failed":return"The session failed."}}function Ut(t,s){if(t.repoId===s.prRepoId){const a=s.filesChanged>0?`${s.filesChanged} file${s.filesChanged===1?"":"s"} changed`:null,i=s.merge;return{status:s.pushed?"Pushed":i!=null&&i.status==="valid"?a!=null?`${i.baseRef} merged · ${a}`:`${i.baseRef} merged`:i!=null&&(i.status==="invalid"||i.status==="missing")?"Merge not valid":a??"No changes yet",note:s.headRef!=null?`Pushes to ${s.headRef}`:"Pushes to the PR branch"}}const n=s.leftOut.find(a=>a.repoId===t.repoId);return n!=null&&n.files.length>0?{status:`${n.files.length} file${n.files.length===1?"":"s"} left out`,note:"Read only. Edits here are left out."}:{status:"Read only",note:null}}function Ht(t,s){return`Edits in ${t.fullName} are left out. AI Fix pushes only ${s}.`}function zt(t){return t.error==null||t.error===""?null:t.session==null||t.error.startsWith("Automatic push failed")?"warn":"note"}const ue=t=>(t??"").slice(0,7);function Yt(t){return t.merge!=null?t.merge.status==="valid":(t.patch??"")!==""&&t.filesChanged.length>0}function qt(t,s){const n=t.conflictedFiles.length;switch(t.status){case"valid":{const a=s!=null&&s!==""?` (${ue(s)})`:"",i=n===0?"":n===1?" No conflict markers are left in the file that was in conflict.":` No conflict markers are left in the ${n} files that were in conflict.`;return{tone:"ok",text:`Ensemble checked the merge commit. Its parents are the PR head${a} and ${t.baseRef} (${ue(t.baseSha)}).${i}`}}case"invalid":case"missing":return{tone:"bad",text:`Nothing will be pushed: ${t.reason??"the merge did not pass Ensemble’s check."}`};case"pending":return{tone:"pending",text:`The merge of ${t.baseRef} is not finished.`}}}function Kt(t,s){return t==null||s.phase!=="built"||t.status!=="invalid"&&t.status!=="missing"?null:"The merge did not pass Ensemble’s check, so nothing can be pushed. Ask for more, or discard."}const de="inline-flex items-center rounded-ui bg-ui-raise px-1.5 py-px font-mono text-meta text-ui-ink";function Re({plan:t}){return e.jsx("ul",{className:"list-disc space-y-0.5 pl-5 text-body text-ui-ink",children:t.summary.map((s,n)=>e.jsx("li",{children:s},n))})}function he(t,s){var n;return((n=t==null?void 0:t.find(a=>a.ref===s))==null?void 0:n.title)??null}function Vt({plan:t,items:s}){return e.jsxs("div",{className:"mt-2 space-y-3 text-meta text-ui-ink",children:[t.steps.length>0&&e.jsx("ol",{className:"list-decimal space-y-2 pl-5",children:t.steps.map((n,a)=>e.jsxs("li",{children:[e.jsx("div",{className:"font-medium text-ui-ink",children:n.title}),n.files.length>0&&e.jsx("div",{className:"mt-0.5 font-mono text-meta text-ui-mute",children:n.files.join(", ")}),e.jsx("p",{className:"mt-0.5 whitespace-pre-wrap",children:n.change}),n.refs.length>0&&e.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:n.refs.map(i=>e.jsx("span",{className:de,children:i},i))})]},a))}),t.notAddressed.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"mb-1 font-semibold text-ui-mute",children:"Will not fix"}),e.jsx("ul",{className:"space-y-1",children:t.notAddressed.map(n=>e.jsxs("li",{children:[e.jsx("span",{className:de,children:n.ref})," ",he(s,n.ref)&&e.jsxs("span",{className:"font-medium",children:[he(s,n.ref),": "]}),n.reason]},n.ref))})]}),t.notCovered.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"font-semibold text-ui-mute",children:"Not in the plan: "}),t.notCovered.join(", ")]})]})}function Gt({fix:t}){const[s,n]=x.useState(!1),a=t.plan;if(a==null||a.plan==null||a.status==="approved")return null;const i=a.plan,l=se(a.model!=null?a:t);return e.jsxs("div",{"data-testid":"ai-fix-plan-history",className:"mt-3 rounded-ui bg-ui-surface p-2",children:[e.jsxs("div",{className:"mb-1 text-meta font-semibold text-ui-mute",children:["The plan ",l," made"]}),e.jsx(Re,{plan:i}),e.jsxs("button",{type:"button",className:"hit mt-1 inline-flex items-center gap-1 text-meta text-ui-mute hover:text-ui-ink","aria-expanded":s,onClick:()=>n(o=>!o),children:[e.jsx(_e,{dir:s?"down":"right"}),s?"Hide the details":"Show the details"]}),s&&e.jsx(Vt,{plan:i,items:t.reviewItems}),s&&a.transcript.length>0&&e.jsx("ul",{className:"mt-3 space-y-1.5 border-t border-ui-line pt-2 text-meta",children:a.transcript.map((o,f)=>e.jsxs("li",{className:"whitespace-pre-wrap text-ui-ink",children:[e.jsxs("span",{className:"font-semibold",children:[o.role==="reader"?"You":l,": "]}),o.text]},f))})]})}function Xt({fix:t}){var n;const s=((n=t.plan)==null?void 0:n.status)==="approved"?t.plan.plan:null;return s?e.jsxs("div",{className:"mb-2 rounded-ui bg-ui-surface p-2",children:[e.jsx("div",{className:"mb-1 text-meta font-semibold text-ui-mute",children:"Built from your plan"}),e.jsx(Re,{plan:s})]}):null}function Jt(t,s,n){var a;return t??((s==null?void 0:s.status)==="succeeded"?s.id:((a=n.find(i=>i.status==="succeeded"))==null?void 0:a.id)??null)}function Qt(t,s,n){return s==null||n==null||s===n.id?null:t!=null?"Uses the review you picked, not the latest.":n.status==="failed"?"Uses the last review that finished. The latest one failed.":n.status==="running"||n.status==="queued"?"Uses the last review that finished. A newer one is running.":"Uses the last review that finished."}const me=Be,Zt=$e;function es(t){return t.kind==="finding"&&t.findingId!=null?`claude-finding-${t.findingId}`:null}function ts(t){const s=I(n=>n.openClaudeReview);return n=>{s({id:t.id,number:t.number,title:t.title,repoFullName:t.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null});const a=Date.now()+3e3,i=()=>{const l=document.getElementById(n);if(l){l.scrollIntoView({behavior:"smooth",block:"center"});return}Date.now()<a&&requestAnimationFrame(i)};requestAnimationFrame(i)}}function xe({refId:t,item:s,onJump:n}){const a=s?`${ge[s.kind]} ${t}`:t,i=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"shrink-0",children:a}),s&&e.jsxs("span",{className:"min-w-0 truncate font-normal",children:["· ",s.title]})]}),l=s?es(s):null;return l?e.jsx("button",{type:"button",onClick:()=>n(l),"aria-label":`${a}: ${(s==null?void 0:s.title)??""}. Show in AI Review`,className:`${me} max-w-[22rem] hover:bg-ui-hover`,children:i}):e.jsx("span",{className:`${me} max-w-[22rem]`,children:i})}function Pe(t){var s;switch(t.seed){case"review":{const n=((s=t.reviewItems)==null?void 0:s.length)??0;return`Fix from ${t.sourceReviewId==null?"the CI check":"the AI review"}${n>0?` (${n} item${n===1?"":"s"})`:""}.`}case"plain":return"Fix from your instruction.";case"comments":return"Fix from picked comments (no longer offered).";case"ci_analysis":return"Fix from the CI analysis (no longer offered).";default:return""}}function ss({pr:t,fix:s}){const n=se(s),a=ts(t),i=s.changeReport,l=new Map((s.reviewItems??[]).map(c=>[c.ref,c])),o=(s.reviewItems??[]).filter(c=>!c.included);if(!i&&o.length===0)return null;const f=l.size>0;return e.jsxs("div",{className:"mt-2 text-meta",children:[e.jsx(Me,{report:i,filesChanged:s.filesChanged,by:n,refsInfo:f?e.jsx("p",{children:"Each tag is a review item the change answers. A finding tag opens it in the AI Review tab."}):null,renderRef:c=>e.jsx(xe,{refId:c,item:l.get(c),onJump:a},c)}),o.length>0&&e.jsxs("section",{children:[e.jsxs("div",{className:Zt,children:["Left out",e.jsx(U,{title:"Left out",children:e.jsxs("p",{children:["These review items did not fit in what ",n," was sent, so it never saw them."]})})]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:o.map(c=>e.jsx(xe,{refId:c.ref,item:c,onJump:a},c.ref))})]})]})}const ns=["conflicts","findings","earlier_findings","judged_threads","untouched_threads","ci_failures","sonar","style_bots","story"],is={conflicts:"Merge conflicts",findings:"Claude’s findings",earlier_findings:"Earlier findings still open",judged_threads:"Threads Claude says need a fix",untouched_threads:"Unanswered threads",ci_failures:"CI failures",sonar:"SonarCloud issues",style_bots:"Style bot comments",story:"Ticket gaps"};function fe(t,s="Claude"){return t==="findings"?`${s}’s findings`:t==="judged_threads"?`Threads ${s} says need a fix`:is[t]}function z(t,s){return s[t.key]??t.defaultIncluded}function as(t,s){return t.items.filter(n=>z(n,s)).map(n=>n.key)}function Se(t,s){const n=new Set;let a=0;for(const i of t.items)if(z(i,s)){if(a>0&&a+i.chars>t.budgetChars){n.add(i.key);continue}a+=i.chars}return n}function rs(t,s){const n={};for(const a of t.items)n[a.key]=a.section===s;return n}const ls={blocker:"Blocker",warning:"Warning",nit:"Nit",question:"Question",praise:"Praise"},pe={blocker:"bg-ui-danger/10 text-ui-danger",warning:"bg-ui-raise text-ui-warn",nit:"bg-ui-raise text-ui-mute"},Fe="whitespace-nowrap rounded-ui bg-ui-raise px-1 py-px text-meta text-ui-warn",Q=new Set;function os(t,s){return t?s!=null?`${t}:${s}`:t:null}function cs({item:t,picked:s,cut:n,disabled:a,onToggle:i}){return e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5 pt-0.5",children:[e.jsx("label",{className:"flex cursor-pointer items-center touch:-my-3 touch:min-h-10 touch:min-w-10 touch:justify-center",children:e.jsx(H,{checked:s,disabled:a,onChange:l=>i(l.target.checked),"aria-label":`Include in the fix: ${t.label}`})}),s&&n&&e.jsx("span",{className:Fe,children:"Won’t fit"})]})}function us({item:t,picked:s,cut:n,disabled:a,onToggle:i}){const l=os(t.path,t.line);return e.jsx("li",{children:e.jsxs("label",{className:`flex cursor-pointer items-start gap-2 rounded-ui border px-2 py-1.5 text-meta ${s?"border-ui-line bg-ui-sel":"border-ui-line"}`,children:[e.jsx(H,{className:"mt-0.5",checked:s,disabled:a,onChange:o=>i(o.target.checked)}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"flex flex-wrap items-center gap-1.5",children:[t.severity&&pe[t.severity]&&e.jsx("span",{className:`rounded-ui px-1 py-px text-meta font-medium ${pe[t.severity]}`,children:ls[t.severity]}),t.section==="conflicts"&&e.jsx(je,{size:12,className:"shrink-0 text-ui-mute"}),e.jsx("span",{className:"break-words text-ui-ink",children:t.label}),s&&n&&e.jsx("span",{className:Fe,children:"Won’t fit"})]}),(l||t.detail)&&e.jsxs("span",{className:"mt-0.5 block break-words text-meta text-ui-mute",children:[l&&e.jsx("span",{className:"font-mono",children:l}),l&&t.detail?" · ":"",t.detail]})]})]})})}function ds({preview:t,overrides:s,onChange:n,disabled:a,pr:i,review:l}){const o=Se(t,s),f=new Map;for(const r of t.items){const h=f.get(r.section)??[];h.push(r),f.set(r.section,h)}const c=(r,h)=>{const j={...s};for(const k of r)j[k]=h;n(j)},u=l!=null&&l.id===t.sourceReviewId?l:null,b=Le(l),y=Oe(l),d=x.useMemo(()=>u!=null?De(u):null,[u]),w=x.useMemo(()=>new Map(((d==null?void 0:d.findings)??[]).map(r=>[r.id,r])),[d]),R=x.useMemo(()=>{var r;return new Map((((r=d==null?void 0:d.followUp)==null?void 0:r.items)??[]).map(h=>[h.priorFindingId,h]))},[d]),F=x.useMemo(()=>d!=null?We(d):new Map,[d]),C=x.useMemo(()=>d!=null?Ue(d):new Set,[d]),T=x.useMemo(()=>{var h;const r=new Set;for(const j of t.items)((h=j.card)==null?void 0:h.kind)==="story"&&r.add(j.card.ticketReviewId);return[...r].sort((j,k)=>j-k)},[t.items]),A=He(i.id,T.length>0),E=x.useMemo(()=>{var h;const r=new Map;for(const j of((h=A.data)==null?void 0:h.tickets)??[])j.review!=null&&r.set(j.review.id,j.review);return r},[A.data]),$=x.useMemo(()=>A.data==null?[]:T.filter(r=>!E.has(r)),[A.data,T,E]),B=ze($),Y=x.useMemo(()=>{const r=new Map(E);for(const h of B)r.set(h.id,h);return r},[E,B]);if(t.items.length===0)return e.jsx("p",{className:"text-meta text-ui-mute",children:"The review found nothing to fix."});const q=(u==null?void 0:u.headSha)??i.headSha,P=r=>{var W,_;const h=z(r,s),j=o.has(r.key),k=p=>c([r.key],p),g=e.jsx(cs,{item:r,picked:h,cut:j,disabled:a,onToggle:k}),N=r.card;switch(N==null?void 0:N.kind){case"finding":{const p=w.get(N.findingId);if(p==null)break;return e.jsx(Qe,{authorName:Ze(l,p),prId:i.id,finding:p,editable:!1,prUrl:i.githubUrl,repoFullName:i.repoFullName,headSha:q,posting:!1,postError:null,inChangeset:p.fileInDiff,priorStatus:F.get(p.id),alreadyPosted:C.has(p.id),actions:!1,selection:g,docReferences:(u==null?void 0:u.docReferences)??null},r.key)}case"earlier_finding":{const p=R.get(N.priorFindingId);if(p==null)break;return e.jsx(Je,{item:p,muted:!1,findingsById:w,headMoved:((W=d==null?void 0:d.followUp)==null?void 0:W.headMoved)??!1,changedPaths:Q,actions:!1,selection:g,by:b},r.key)}case"thread":return e.jsx(Xe,{t:N.assessment,muted:!1,actions:!1,selection:g,notCheckedNote:N.inReview?void 0:`${y} didn’t check this one.`,by:y},r.key);case"ci":return e.jsx(Ge,{f:N.item,suggestion:N.item.suggestion,changedPaths:Q,selection:g},r.key);case"sonar":return e.jsx(Ve,{issue:N.issue,selection:g},r.key);case"story":{const p=Y.get(N.ticketReviewId),m=p==null?void 0:p.items.find(O=>O.id===N.itemId);if(p==null||m==null)break;const L={review:p,viewedPrId:i.id,changedPaths:Q,actions:!1,selection:g};if(m.status==="missing")return e.jsx(Ye,{item:m,...L},r.key);const S=(_=p.assessment)==null?void 0:_.criteria.find(O=>O.ref===m.ref);if(S==null||qe(S.status))break;return e.jsx(Ke,{c:S,item:m,...L},r.key)}}return e.jsx(us,{item:r,picked:h,cut:j,disabled:a,onToggle:k},r.key)};return e.jsxs("div",{className:"space-y-3",children:[ns.filter(r=>f.has(r)).map(r=>{const h=f.get(r),j=h.filter(g=>z(g,s)).length,k=j===h.length;return e.jsxs("section",{"aria-label":fe(r,b),children:[e.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[e.jsx("h4",{className:"text-meta font-semibold text-ui-ink",children:fe(r,b)}),e.jsxs("span",{className:"text-meta text-ui-mute",children:[j," of ",h.length]}),e.jsx("button",{type:"button",className:"hit ml-auto text-meta text-ui-accent hover:underline disabled:opacity-50",disabled:a,onClick:()=>c(h.map(g=>g.key),!k),children:k?"Untick all":"Tick all"})]}),e.jsx("ul",{className:"space-y-1.5",children:h.map(P)})]},r)}),o.size>0&&e.jsxs("p",{className:"text-meta text-ui-warn",children:[o.size," ticked ",o.size===1?"item does":"items do"," not fit in one fix and will be left out. Untick something to make room."]})]})}const hs="limn.aiFix.pushWhenDone",Z="inline-flex h-7 items-center whitespace-nowrap rounded-ui bg-ui-raise px-2.5 text-meta font-medium text-ui-ink hover:bg-ui-hover disabled:cursor-not-allowed disabled:opacity-50 touch:h-10 touch:px-3";function ee(t){return t instanceof wt||t instanceof Error?t.message:"Something went wrong"}const te="inline-flex h-7 items-center whitespace-nowrap rounded-ui bg-ui-raise px-2.5 text-meta font-medium text-ui-ink hover:bg-ui-hover disabled:cursor-not-allowed disabled:opacity-50 touch:h-10 touch:px-3";function ms({children:t,info:s}){return e.jsxs("div",{className:"flex items-center gap-1.5 px-4 pb-2 pt-4 text-title text-ui-ink md:px-5",children:[e.jsx("h3",{children:t}),s]})}function Es({pr:t}){const s=be().enabled,n=I(c=>c.aiFixTabFocus),a=I(c=>c.consumeAiFixTabFocus),[i,l]=x.useState(null),[o,f]=x.useState(null);return x.useEffect(()=>{n&&n.prId===t.id&&(n.reviewId!=null&&l(n.reviewId),n.only!=null&&f(n.only),a())},[n,t.id,a]),s?e.jsx("div",{className:"pb-6",children:e.jsx(xs,{pr:t,handoffReviewId:i,onlySection:o,onOnlySectionApplied:()=>f(null)})}):e.jsx(e.Fragment,{})}function xs({pr:t,handoffReviewId:s,onlySection:n,onOnlySectionApplied:a}){var re,le,oe;const{data:i,isLoading:l}=et(t.id,!0),{data:o,isLoading:f}=tt(t.id),c=(o==null?void 0:o.review)??null,u=Jt(s,c,(o==null?void 0:o.history)??[]),b=Qt(s,u,c),y=I(v=>v.setPrDetailTab),d=st("fix",Lt),w=nt(d.chosen.provider),R=it().data,F=at(t.id),C=rt(t.id);be();const T=lt(R,d.chosen.provider,"plan"),[A,E]=x.useState(!1),$=A&&T,[B,Y]=ot(hs,!0),q=I(v=>v.noteAiFixRun),P=Ee({mutationKey:ct(t.id)})>0,r=(i==null?void 0:i.fix)??null,h=(r==null?void 0:r.session)??null,j=(h==null?void 0:h.live)===!0,k=ut(t.id,(r==null?void 0:r.id)??null,j),g=h!=null?dt(h,j||k.done?k.session:null):null,N=r!=null&&g!=null&&Ot(g),W=g!=null&&ht(g),_=(i==null?void 0:i.waiting)??null,p=Dt(g)||P||_!=null,m=mt(t.id,u,(i==null?void 0:i.enabled)!==!1&&(u!=null||!f)),L=u==null&&m.data!=null&&m.data.sourceReviewId==null&&m.data.items.length>0,S=u!=null||L,O=xt(u!=null&&(c==null?void 0:c.id)!==u?u:null),Ie=u!=null&&(c==null?void 0:c.id)===u?c:O.data??null,[K,V]=x.useState({});x.useEffect(()=>V({}),[u]);const[Te,D]=x.useState(!1);x.useEffect(()=>{n==null||!m.data||(V(rs(m.data,n)),D(!0),a())},[n,m.data,a]);const G=!p&&(Te||!r||r.status!=="succeeded"),X=ft(G&&S),ie=X.data!=null&&!X.data.available,M=m.data?as(m.data,K):[],ae=m.data?Se(m.data,K).size:0,Ae=()=>{if(!S||!m.data||M.length===0)return;const v={model:d.chosen.model,provider:d.chosen.provider,seed:"review",...u!=null?{sourceReviewId:u}:{},include:M,pushWhenDone:B};$?C.mutate(v,{onSuccess:()=>D(!1)}):(q({prId:t.id,repoFullName:t.repoFullName,prNumber:t.number,prTitle:t.title}),F.mutate(v,{onSuccess:()=>D(!1)}))};return e.jsxs("div",{children:[e.jsx(ms,{info:e.jsxs(U,{title:"AI Fix",children:[e.jsxs("p",{children:[w," reads the PR's code and fixes it in a sandbox on this computer. The sandbox holds every repository in the workspace; the PR's repository is at the PR's latest commit. There"," ",w," can run the project's own tests, lint and type checks, and start the services you picked for integration tests."]}),e.jsx("p",{children:"A fix starts from an AI review. Pick what it should work on: the review's findings, earlier findings still open, threads the review says need a fix, unanswered threads, CI failures and ticket gaps are ticked; style bot comments are not."}),e.jsx("p",{children:"With no AI review, a fix can start from a finished CI check: it works on the failures the check says this PR can fix."}),e.jsxs("p",{children:["When the PR conflicts with its base branch, Resolve merge conflicts is ticked too. ",w," ","merges the base first and resolves each conflict, then fixes the other items on top. Ensemble checks the merge commit before Push. You can still resolve conflicts by hand with Resolve conflicts."]}),e.jsxs("p",{children:["Start fix starts at once. Watch it work, press Stop, or ask for more in the same session. Tick Plan first to read and discuss ",w,"'s plan before anything changes, then press Start fix."]}),e.jsxs("p",{children:[w," reports what it changed in each file and what it left alone, and why."]}),e.jsx("p",{children:"Only the PR's repository is pushed, to the PR's own branch. Edits in other repositories are shown and left out. Nothing is pushed until you press Push. An automatic fix on your own PR is pushed for you only when Push automatically is on in Settings."})]}),children:"AI Fix"}),e.jsxs("div",{className:"px-4",children:[(i==null?void 0:i.enabled)===!1?e.jsx("p",{className:"text-body text-ui-mute",children:"The agentic fixer is turned off."}):e.jsxs(e.Fragment,{children:[_!=null&&e.jsx(Ss,{prId:t.id,line:pt(_)}),!p&&!S&&!f&&!m.isLoading&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-meta text-ui-mute",children:(c==null?void 0:c.status)==="running"||(c==null?void 0:c.status)==="queued"?"A fix starts from an AI review. One is running.":"A fix starts from a finished AI review."}),e.jsx("button",{type:"button",className:Z,onClick:()=>y(t.id,"claude_review"),children:"Open AI Review"})]}),!p&&S&&!G&&e.jsx("button",{type:"button",className:te,onClick:()=>D(!0),children:"New fix"}),S&&G&&e.jsxs("div",{children:[b&&e.jsx("p",{className:"mb-2 text-meta text-ui-mute",children:b}),L&&((re=m.data)==null?void 0:re.items.some(v=>v.section==="ci_failures"))&&e.jsx("p",{className:"mb-2 text-meta text-ui-mute",children:"No AI review yet. This fix works on the CI check’s failures."}),m.isLoading&&e.jsx("p",{className:"text-meta text-ui-mute",children:"Loading…"}),m.isError&&u!=null&&e.jsx("p",{className:"text-meta text-ui-danger",children:ee(m.error)}),m.data&&e.jsx(ds,{preview:m.data,overrides:K,onChange:V,disabled:P,pr:t,review:Ie}),m.data&&m.data.items.length>0&&ie&&e.jsx("div",{className:"mt-3","data-testid":"ai-fix-no-runtime",children:e.jsx(gt,{status:X.data,loading:!1,testId:"ai-fix-runtime-line"})}),m.data&&m.data.items.length>0&&!ie&&e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 max-md:sticky max-md:bottom-0 max-md:z-20 max-md:-mx-4 max-md:bg-ui-surface max-md:px-4 max-md:py-3",children:[e.jsx(jt,{state:d,onPick:d.pick,disabled:P}),T&&e.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5 text-meta text-ui-ink",children:[e.jsx(H,{checked:$,disabled:P,onChange:v=>E(v.target.checked)}),"Plan first"]}),e.jsxs("label",{"data-testid":"ai-fix-push-when-done",className:"flex cursor-pointer items-center gap-1.5 text-meta text-ui-ink",children:[e.jsx(H,{checked:B,disabled:P,onChange:v=>Y(v.target.checked)}),"Push when done",e.jsxs(U,{title:"Push when done",children:[e.jsx("p",{children:"When the fix finishes on your own pull request, Ensemble pushes it to the pull request's branch. You do not press Push."}),e.jsx("p",{className:"mt-2",children:"It waits for your press instead when the agent says something is not fixed, its report does not cover every item, or the pull request is someone else's. The session says which."}),e.jsx("p",{className:"mt-2",children:"A push ends the session, so untick this to keep talking to the agent first."})]})]}),e.jsx(bt,{kind:"fix",auth:i==null?void 0:i.auth,anyProvider:!0,provider:d.chosen.provider,children:e.jsx("button",{type:"button",className:Z,"data-ai-fix-action":"start",disabled:P||M.length===0,onClick:Ae,children:P?"Starting…":$?"Make a plan":"Start fix"})}),e.jsx("span",{className:"text-meta text-ui-mute",children:M.length===0?"Nothing ticked.":`${M.length-ae} item${M.length-ae===1?"":"s"}`}),(r==null?void 0:r.status)==="succeeded"&&e.jsx("button",{type:"button",className:te,onClick:()=>D(!1),children:"Close"})]})]}),(F.isError||C.isError)&&e.jsx("p",{className:"mt-1 text-meta text-ui-danger",children:ee(F.error??C.error)}),N&&r!=null&&g!=null&&e.jsx(gs,{pr:t,fix:r,session:g,partials:k.partials,headRef:((le=i==null?void 0:i.headInfo)==null?void 0:le.headRef)??t.headRefName??null}),r&&!W&&(g==null?void 0:g.phase)!=="booting"&&e.jsx(ks,{pr:t,fix:r,headInfo:(i==null?void 0:i.headInfo)??null,viewerCanPush:(i==null?void 0:i.viewerCanPush)??!1}),l&&!r&&e.jsx("p",{className:"mt-3 text-meta text-ui-mute",children:"Loading…"})]}),e.jsx(Rs,{history:(i==null?void 0:i.history)??[],currentFixId:((oe=i==null?void 0:i.fix)==null?void 0:oe.id)??null})]})]})}const fs={startBuild:"Start fix",startBuildTitle:"The agent changes the code and runs the checks. The words in the box go with it.",readerBuildLabel:"You · Build turn",empty:"The agent has read the items to fix and the repositories.",chatPlaceholder:"Ask about the plan, or say what to change in it.",buildPlaceholder:"Ask for more. It is a build turn: the agent may edit and test.",resumeNote:"Resume starts a new sandbox with this fix. The agent does not remember the conversation.",gate:{chat:"plan",build:"fix"}};function ps(t,s,n,a){return{busyKey:It(t),useSend(){const i=Ct(t);return{run:(l,o)=>i.mutate({fixId:s,text:l},{onSuccess:o}),pending:i.isPending,error:i.error,succeeded:i.isSuccess}},useStartBuild(){const i=Ft(t);return{run:(l,o)=>(a(),i.mutate({fixId:s,text:l},{onSuccess:o})),pending:i.isPending,error:i.error,succeeded:i.isSuccess}},useStop(){const i=we(t);return{run:(l,o)=>i.mutate(void 0,{onSuccess:o}),pending:i.isPending,error:i.error,succeeded:i.isSuccess}},useResume(){const i=St(t);return{run:(l,o)=>i.mutate(s,{onSuccess:o}),pending:i.isPending,error:i.error,succeeded:i.isSuccess}},useAllow(){const i=Pt(t,n);return{run:(l,o)=>i.mutate({fixId:s,body:l},{onSuccess:o}),pending:i.isPending,error:i.error,succeeded:i.isSuccess}}}}function gs({pr:t,fix:s,session:n,partials:a,headRef:i}){const l=I(b=>b.workspaceId),o=I(b=>b.noteAiFixRun),f=x.useMemo(()=>ps(t.id,s.id,l,()=>o({prId:t.id,repoFullName:t.repoFullName,prNumber:t.number,prTitle:t.title})),[t.id,t.repoFullName,t.number,t.title,s.id,l,o]),c=s.leftOut??[],u=b=>Ut(b,{prRepoId:t.repoId,headRef:i,filesChanged:s.filesChanged.length,pushed:s.pushedAt!=null,leftOut:c,merge:s.merge??null});return e.jsxs("div",{"data-testid":"ai-fix-session",className:"mt-3",children:[e.jsxs("p",{"data-testid":"ai-fix-session-status",className:"flex flex-wrap items-center gap-2 text-meta text-ui-mute",children:[s.trigger==="auto"&&e.jsx(Ce,{}),e.jsx("span",{children:Kt(s.merge,n)??Wt(n,s.unattended===!0)}),n.model!=null&&e.jsxs("span",{children:["· ",Ne(n.provider,n.model,n.effort)]})]}),e.jsx(Nt,{session:n,partials:a,actions:f,words:fs,provider:ws(s),testPrefix:"fix-session",actionAttr:"data-ai-fix-action",railTop:e.jsx(js,{pr:t,fix:s}),repoStatus:u,composerExtra:kt(n)&&n.phase!=="pushed"?e.jsx(bs,{prId:t.id,fixId:s.id,live:n.live}):null})]})}function js({pr:t,fix:s}){const n=(s.reviewItems??[]).filter(a=>a.included);return e.jsxs(At,{title:"What to fix",testId:"fix-session-items",children:[s.seed==="plain"?e.jsx("p",{className:"text-meta text-ui-mute",children:"Your instruction."}):n.length===0?e.jsx("p",{className:"text-meta text-ui-mute",children:Pe(s)}):e.jsx("ul",{className:"space-y-1 text-meta text-ui-ink",children:n.map(a=>e.jsxs("li",{className:"break-words",children:[e.jsx("span",{className:"font-mono text-ui-mute",children:a.ref})," ",e.jsx("span",{className:"text-ui-mute",children:ge[a.kind]})," ",a.title,a.path!=null&&e.jsxs("span",{className:"block break-all font-mono text-ui-mute",children:[a.path,a.line!=null&&`:${a.line}`]})]},a.ref))}),e.jsxs("p",{className:"mt-1.5 text-meta text-ui-mute",children:["Pushes only to ",e.jsx("span",{className:"font-mono",children:t.repoFullName}),"."]})]})}function bs({prId:t,fixId:s,live:n}){const a=Tt(t),[i,l]=x.useState(!1);return i?e.jsxs("span",{className:"flex items-center gap-1.5 text-meta text-ui-ink",children:[e.jsx("span",{children:n?"Stop the agent and remove the sandbox? Nothing is pushed.":"Drop this fix? Nothing is pushed."}),e.jsx(J,{size:"sm",variant:"secondary","data-ai-fix-action":"discard-confirm",disabled:a.isPending,onClick:()=>a.mutate(s,{onSettled:()=>l(!1)}),children:"Discard"}),e.jsx(J,{size:"sm",variant:"ghost",onClick:()=>l(!1),children:"Keep"})]}):e.jsx(J,{size:"sm",variant:"ghost","data-ai-fix-action":"discard",onClick:()=>l(!0),children:"Discard"})}function Ce(){return e.jsx("span",{className:"inline-flex items-center rounded-ui bg-ui-raise px-1.5 py-px text-meta font-medium text-ui-mute",children:"Auto fix"})}function ws(t){return Et(t.provider,t.model)}function Ns(t){return Ne(t.provider,t.model,t.effort)}function ks({pr:t,fix:s,headInfo:n,viewerCanPush:a}){var b,y,d;const i=x.useMemo(()=>ke(s.patch),[s.patch]),l=s.merge??null;if(s.status==="failed"&&((b=s.plan)==null?void 0:b.status)==="failed")return e.jsxs("div",{className:"mt-3 rounded-ui border border-ui-danger/40 bg-ui-danger/10 p-2 text-meta text-ui-danger",children:[se(s.plan??s)," could not make a plan: ",s.error??"unknown error"]});if(s.status==="cancelled"&&((y=s.plan)==null?void 0:y.status)==="discarded")return e.jsx("p",{className:"mt-3 text-meta text-ui-mute",children:"The plan was discarded."});if(s.status==="failed")return e.jsxs("div",{className:"mt-3 rounded-ui border border-ui-danger/40 bg-ui-danger/10 p-2 text-meta text-ui-danger",children:["The fix run failed: ",s.error??"unknown error"]});if(s.status==="cancelled")return e.jsx("p",{className:"mt-3 text-meta text-ui-mute",children:s.session!=null?"The fix was stopped or discarded. Nothing was pushed.":"The fix run was cancelled."});if(s.status!=="succeeded")return e.jsx(e.Fragment,{});const o=!s.patch||s.filesChanged.length===0,f=Yt(s),c=zt(s),u=(s.leftOut??[]).filter(w=>w.files.length>0);return e.jsxs("div",{className:"mt-3 border-t border-ui-line pt-3",children:[e.jsxs("p",{className:"mb-1 text-meta text-ui-mute",children:[s.trigger==="auto"&&e.jsxs(e.Fragment,{children:[e.jsx(Ce,{})," "]}),Pe(s)," · ",Ns(s),s.finishedAt&&e.jsxs(e.Fragment,{children:[" · ",ne(s.finishedAt)]})]}),s.pushedAt==null&&c==="warn"&&e.jsx("p",{className:"mb-2 rounded-ui bg-ui-raise p-2 text-meta text-ui-warn",children:s.error}),s.pushedAt==null&&c==="note"&&((d=s.session)==null?void 0:d.resumable)!==!0&&e.jsx("p",{className:"mb-2 text-meta text-ui-mute",children:s.error}),e.jsx(Xt,{fix:s}),e.jsx(Gt,{fix:s}),s.summary&&e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(vt,{children:s.summary})}),e.jsx(ss,{pr:t,fix:s}),u.length>0&&e.jsx("ul",{"data-testid":"ai-fix-left-out",className:"mt-2 space-y-0.5 text-meta text-ui-mute",children:u.map(w=>e.jsxs("li",{children:[Ht(w,t.repoFullName)," ",e.jsxs("span",{className:"font-mono",children:[w.files.slice(0,5).join(", "),w.files.length>5?`, and ${w.files.length-5} more`:""]})]},w.repoId))}),e.jsx(yt,{checks:s.checks}),l!=null&&e.jsx(vs,{merge:l,headSha:s.baseSha}),o?e.jsx("p",{className:"mt-2 text-meta text-ui-mute",children:l!=null?"No other changes on top of the merge.":"No files changed."}):e.jsxs("div",{"data-testid":"ai-fix-changes",children:[e.jsxs("div",{className:"mb-1 mt-2 flex items-center justify-between gap-3 text-meta text-ui-mute",children:[e.jsxs("span",{children:[l!=null&&e.jsx("span",{className:"font-semibold text-ui-ink",children:"Fixes on top of the merge · "}),s.filesChanged.length," file",s.filesChanged.length===1?"":"s"," changed"]}),e.jsx(Rt,{})]}),e.jsx("div",{className:"overflow-hidden rounded-ui bg-ui-surface text-ui-ink",children:e.jsx(ve,{files:i})})]}),f&&e.jsx(Ps,{pr:t,fix:s,headInfo:n,viewerCanPush:a})]})}function vs({merge:t,headSha:s}){const n=x.useMemo(()=>ke(t.resolutionDiff),[t.resolutionDiff]),a=qt(t,s),i=t.conflictedFiles.length;return e.jsxs("div",{"data-testid":"ai-fix-merge","data-merge-status":t.status,className:"mt-2",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1.5 text-meta font-semibold text-ui-ink",children:[e.jsx(je,{size:12}),"Merge of ",e.jsx("span",{className:"font-mono",children:t.baseRef}),e.jsxs(U,{title:"How the conflicts were resolved",children:[e.jsxs("p",{children:["The agent merged ",t.baseRef," into the PR in the sandbox and made a merge commit. Ensemble then checked it: the merge commit's parents must be the PR head and the ",t.baseRef," commit Ensemble picked, no conflict markers may be left in the files that were in conflict, and every other change must sit on top of the merge."]}),e.jsx("p",{children:"The diff below compares the merge commit with git's own merge, conflict markers and all. Each hunk shows how one conflict was settled. Check for lines that are doubled or dropped."}),e.jsx("p",{children:"Push sends the merge commit and the fixes on top to the PR's branch. A merge that fails the check sends nothing."})]})]}),e.jsxs("p",{"data-testid":"ai-fix-merge-check",className:`flex items-start gap-1.5 text-meta ${a.tone==="ok"?"text-ui-success":a.tone==="bad"?"text-ui-danger":"text-ui-mute"}`,children:[a.tone==="ok"?e.jsx(_t,{size:12,className:"mt-0.5 shrink-0"}):a.tone==="bad"?e.jsx(Mt,{size:12,className:"mt-0.5 shrink-0"}):null,e.jsx("span",{children:a.text})]}),i>0&&e.jsxs("p",{className:"mt-0.5 break-words text-meta text-ui-mute",children:["In conflict: ",e.jsx("span",{className:"font-mono",children:t.conflictedFiles.slice(0,8).join(", ")}),i>8?`, and ${i-8} more`:""]}),n.length>0?e.jsxs("div",{"data-testid":"ai-fix-resolution",className:"mt-2",children:[e.jsxs("div",{className:"mb-1 text-meta text-ui-mute",children:[e.jsx("span",{className:"font-semibold text-ui-ink",children:"How the conflicts were resolved"})," · ",n.length," file",n.length===1?"":"s"]}),e.jsx("div",{className:"overflow-hidden rounded-ui bg-ui-surface text-ui-ink",children:e.jsx(ve,{files:n})})]}):t.status==="valid"&&i>0&&e.jsx("p",{className:"mt-1 text-meta text-ui-mute",children:"The merge commit matches git's own merge outside the conflicts."})]})}function ys({fix:t}){return e.jsxs("div",{className:"mb-2 rounded-ui bg-ui-raise p-2 text-meta text-ui-success",children:[e.jsxs("div",{children:["Pushed to ",e.jsx("span",{className:"font-mono",children:t.pushedBranch}),t.pushedPrUrl&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("a",{href:ye(t.pushedPrUrl),target:"_blank",rel:"noreferrer",className:"hit underline",children:["PR #",t.pushedPrNumber]})]}),t.pushedAt&&e.jsxs(e.Fragment,{children:[" · ",ne(t.pushedAt)]})]}),t.commitMessage&&e.jsx("div",{className:"mt-1 font-mono text-meta text-ui-success",children:t.commitMessage})]})}function Rs({history:t,currentFixId:s}){const n=t.filter(a=>a.pushedAt!=null&&a.id!==s);return n.length===0?null:e.jsxs("div",{className:"mt-6",children:[e.jsx("div",{className:"mb-2 text-title text-ui-ink",children:"Earlier fixes pushed"}),e.jsx("ul",{className:"space-y-2",children:n.map(a=>e.jsxs("li",{className:"text-meta",children:[e.jsx("div",{className:"font-mono text-ui-ink",children:a.commitMessage??"(no commit message)"}),e.jsxs("div",{className:"mt-0.5 text-meta text-ui-faint",children:[a.pushedBranch&&e.jsx("span",{className:"font-mono",children:a.pushedBranch}),a.pushedPrUrl&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("a",{href:ye(a.pushedPrUrl),target:"_blank",rel:"noreferrer",className:"hit underline",children:["PR #",a.pushedPrNumber]})]}),a.pushedAt&&e.jsxs(e.Fragment,{children:[" · ",ne(a.pushedAt)]})]})]},a.id))})]})}function Ps({pr:t,fix:s,headInfo:n,viewerCanPush:a}){const i=$t(t.id),l=(n==null?void 0:n.canPushSameBranch)??!1,o=s.merge!=null,[f,c]=x.useState(l?"existing":"new"),[u,b]=x.useState((n==null?void 0:n.suggestedBranch)??""),y=x.useRef(!1);if(x.useEffect(()=>{!y.current&&(n!=null&&n.suggestedBranch)&&(b(n.suggestedBranch),y.current=!0,!n.canPushSameBranch&&!o&&c("new"))},[n,o]),s.pushedAt!=null)return e.jsx(ys,{fix:s});if(!a)return e.jsx("p",{className:"mt-2 text-meta text-ui-mute",children:"You need write access to push this fix."});if(o&&!l)return e.jsx("p",{className:"mt-2 text-meta text-ui-mute",children:"A fix with a merge pushes only to the PR's own branch, and you can't push to it."});const d=o?"existing":f,w=d==="new"&&u.trim().length===0,R=i.isPending,F=()=>{i.mutate({fixId:s.id,body:{target:d,branch:f==="new"&&!o?u.trim():void 0}})};return e.jsxs("div",{className:"mt-3 rounded-ui bg-ui-surface p-2",children:[s.commitMessage&&e.jsx("div",{className:"mb-2 rounded-ui bg-ui-surface px-2 py-1 font-mono text-meta text-ui-ink",title:"Commit message",children:s.commitMessage}),e.jsxs("label",{className:`flex items-center gap-2 text-meta ${l?"":"opacity-40"}`,title:l?void 0:"The PR head is a fork you cannot push to — use a new branch",children:[e.jsx(ce,{className:"mt-0",checked:d==="existing",disabled:!l||R,onChange:()=>c("existing")}),"Push to the PR branch",(n==null?void 0:n.headRef)&&e.jsxs("span",{className:"font-mono text-ui-faint",children:["(",n.headRef,")"]})]}),!o&&e.jsxs("label",{className:"mt-1 flex items-center gap-2 text-meta",children:[e.jsx(ce,{className:"mt-0",checked:f==="new",disabled:R,onChange:()=>c("new")}),"New branch + open a PR"]}),f==="new"&&!o&&e.jsx("input",{type:"text",className:"mt-1 w-full rounded-ui bg-ui-raise px-2 py-1 font-mono text-meta ring-1 ring-inset ring-ui-line focus:outline-none focus:ring-2 focus:ring-ui-accent touch:min-h-10",value:u,disabled:R,onChange:C=>b(C.target.value),placeholder:"branch-name"}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",className:Z,disabled:R||w,onClick:F,children:R?"Pushing…":d==="new"?"Push + open PR":"Push"}),e.jsx(Bt,{checks:s.checks})]}),i.isError&&e.jsx("div",{className:"mt-2 text-meta text-ui-danger",children:ee(i.error)})]})}function Ss({prId:t,line:s}){const n=we(t);return e.jsxs("div",{"data-testid":"ai-fix-waiting",className:"mb-3 flex flex-wrap items-center gap-2 rounded-ui bg-ui-raise px-3 py-2 text-meta text-ui-ink",children:[e.jsx("span",{children:s}),e.jsx("button",{type:"button",className:te,disabled:n.isPending,onClick:()=>n.mutate(),children:"Cancel"})]})}export{Es as AiFixTab};
@@ -1 +1 @@
1
- import{r as w,j as s}from"./tanstack-5qsxxaLe.js";import{ah as j,aj as y,a5 as N,I as g,K as b,ar as k,X as v,W as f,t as C,k as T,N as x,Q as $}from"./index-BrjUDY3j.js";import"./markdown-I_JLLVAZ.js";import"./highlight-CIIZLa6Z.js";import"./vis-C3BCkP5U.js";function h(e){return e==null?"—":$(e)}function B(e){const t=[];for(const i of e){const a=v(i.at),n=t[t.length-1];if(n&&n.label===a){n.to=i.at,n.count+=1,i.kind==="review"?n.reviews+=1:n.comments+=1;continue}t.push({from:i.at,to:i.at,label:a,count:1,reviews:i.kind==="review"?1:0,comments:i.kind==="review"?0:1})}return t}function I(e){const t=[];return e.reviews>0&&t.push(`${e.reviews} review${e.reviews===1?"":"s"}`),e.comments>0&&t.push(`${e.comments} comment${e.comments===1?"":"s"}`),t.join(", ")}const P=40;function d({label:e,value:t,tone:i}){return s.jsxs("div",{children:[s.jsx("div",{className:"text-meta font-semibold text-ui-mute",children:e}),s.jsx("div",{className:`text-body font-semibold ${i==="warn"?"text-ui-danger":"text-ui-ink"}`,children:t})]})}function R({bot:e,color:t}){const i=b(e.kind),a=e.ttfrAnomaly,n=e.typicalTtfrHours==null,u=e.typicalFollowups!=null&&e.followupCount>=e.typicalFollowups+2,c=B(e.touches),r=c.slice(0,P),l=e.touches.length-r.reduce((o,p)=>o+p.count,0),m=n?"building baseline":a?`slower than typical — usually ${h(e.typicalTtfrHours)}`:`within typical (${h(e.typicalTtfrHours)})`;return s.jsxs("div",{className:"space-y-2 rounded-ui border border-ui-line p-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-body font-semibold text-ui-ink",children:[s.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{background:t},"aria-hidden":!0}),e.label]}),s.jsx("span",{className:"rounded-ui px-1.5 py-0.5 text-meta font-medium",style:{...k(i.color),background:`${i.color}1a`},children:i.label}),e.firstTouchAt&&s.jsxs("span",{className:"text-meta text-ui-mute",children:["first touch ",v(e.firstTouchAt)]}),a&&s.jsxs("span",{className:"rounded-ui bg-ui-danger/10 px-1.5 py-0.5 text-meta font-semibold text-ui-danger",children:[s.jsx(f,{size:11,className:"inline-block align-[-0.1em]"})," slower than usual"]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4",children:[s.jsx(d,{label:"Time to first review",value:h(e.ttfrHours),tone:a?"warn":"default"}),s.jsx(d,{label:"Follow-ups",value:String(e.followupCount),tone:u?"warn":"default"}),s.jsx(d,{label:"Comments",value:String(e.commentCount)}),s.jsx(d,{label:"Touches",value:String(e.touchCount)})]}),s.jsxs("div",{className:"text-meta text-ui-mute",children:[s.jsxs("span",{className:a?"font-medium text-ui-danger":"",children:[!n&&a&&s.jsx(f,{size:11,className:"mr-1 inline-block align-[-0.1em]"}),m]}),e.ttfrBasis&&!n&&s.jsxs("span",{children:[" · from ",e.ttfrBasis==="ready"?"ready-for-review":"opened"]}),e.typicalFollowups!=null&&s.jsxs("span",{children:[" · ",e.followupCount," follow-up",e.followupCount===1?"":"s"," vs ",e.typicalFollowups," typical",u?" (more than usual)":""]}),!n&&s.jsxs("span",{children:[" · baseline: ",e.baselinePrs," PRs"]})]}),c.length>0&&s.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[r.map((o,p)=>s.jsxs("span",{className:"inline-flex items-center gap-1 rounded-ui bg-ui-raise px-1.5 py-0.5 text-meta text-ui-mute",title:`${o.count>1?`${I(o)} · `:""}${o.from===o.to?x(o.from):`${x(o.from)} – ${x(o.to)}`}`,children:[o.reviews>0&&s.jsx(C,{size:11}),o.comments>0&&s.jsx(T,{size:11}),o.count>1&&s.jsxs("span",{className:"font-medium",children:["×",o.count]}),o.label]},p)),l>0&&s.jsxs("span",{className:"text-meta text-ui-mute",children:["+",l," more touches"]})]})]})}function S({pr:e}){const{data:t,isLoading:i,isError:a}=j(e.id,!0),{data:n}=y(),u=w.useMemo(()=>{var l;return((l=(n??[]).find(m=>m.id===e.repoId))==null?void 0:l.workspaceId)??null},[n,e.repoId]),c=N(u),r=(t==null?void 0:t.bots)??[];return s.jsxs("div",{className:"space-y-3 p-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(g,{title:"Bot activity",children:[s.jsx("p",{children:"How each review bot behaved on this pull request, compared with its own usual over the last 84 days. No AI is involved."}),s.jsx("p",{children:"A touch is one review or one comment, so a review submitted with three inline comments counts as four."})]}),s.jsx("span",{className:"text-meta text-ui-mute",children:"Each bot against its own usual"})]}),i?s.jsx("div",{className:"h-24 animate-pulse rounded-ui bg-ui-surface"}):a?s.jsx("div",{className:"text-body text-ui-danger",children:"Couldn’t load bot behaviour for this PR."}):r.length===0?s.jsx("div",{className:"rounded-ui border border-dashed border-ui-line p-6 text-center text-body text-ui-mute",children:"No automated-reviewer activity on this PR."}):r.map(l=>s.jsx(R,{bot:l,color:c({login:l.login,kind:l.kind})},l.key))]})}export{S as PrBotBehaviourTab};
1
+ import{r as w,j as s}from"./tanstack-5qsxxaLe.js";import{ah as j,aj as y,a5 as N,I as g,K as b,ar as k,X as v,W as f,t as C,k as T,N as x,Q as $}from"./index-Bhnig73n.js";import"./markdown-I_JLLVAZ.js";import"./highlight-CIIZLa6Z.js";import"./vis-C3BCkP5U.js";function h(e){return e==null?"—":$(e)}function B(e){const t=[];for(const i of e){const a=v(i.at),n=t[t.length-1];if(n&&n.label===a){n.to=i.at,n.count+=1,i.kind==="review"?n.reviews+=1:n.comments+=1;continue}t.push({from:i.at,to:i.at,label:a,count:1,reviews:i.kind==="review"?1:0,comments:i.kind==="review"?0:1})}return t}function I(e){const t=[];return e.reviews>0&&t.push(`${e.reviews} review${e.reviews===1?"":"s"}`),e.comments>0&&t.push(`${e.comments} comment${e.comments===1?"":"s"}`),t.join(", ")}const P=40;function d({label:e,value:t,tone:i}){return s.jsxs("div",{children:[s.jsx("div",{className:"text-meta font-semibold text-ui-mute",children:e}),s.jsx("div",{className:`text-body font-semibold ${i==="warn"?"text-ui-danger":"text-ui-ink"}`,children:t})]})}function R({bot:e,color:t}){const i=b(e.kind),a=e.ttfrAnomaly,n=e.typicalTtfrHours==null,u=e.typicalFollowups!=null&&e.followupCount>=e.typicalFollowups+2,c=B(e.touches),r=c.slice(0,P),l=e.touches.length-r.reduce((o,p)=>o+p.count,0),m=n?"building baseline":a?`slower than typical — usually ${h(e.typicalTtfrHours)}`:`within typical (${h(e.typicalTtfrHours)})`;return s.jsxs("div",{className:"space-y-2 rounded-ui border border-ui-line p-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-body font-semibold text-ui-ink",children:[s.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{background:t},"aria-hidden":!0}),e.label]}),s.jsx("span",{className:"rounded-ui px-1.5 py-0.5 text-meta font-medium",style:{...k(i.color),background:`${i.color}1a`},children:i.label}),e.firstTouchAt&&s.jsxs("span",{className:"text-meta text-ui-mute",children:["first touch ",v(e.firstTouchAt)]}),a&&s.jsxs("span",{className:"rounded-ui bg-ui-danger/10 px-1.5 py-0.5 text-meta font-semibold text-ui-danger",children:[s.jsx(f,{size:11,className:"inline-block align-[-0.1em]"})," slower than usual"]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4",children:[s.jsx(d,{label:"Time to first review",value:h(e.ttfrHours),tone:a?"warn":"default"}),s.jsx(d,{label:"Follow-ups",value:String(e.followupCount),tone:u?"warn":"default"}),s.jsx(d,{label:"Comments",value:String(e.commentCount)}),s.jsx(d,{label:"Touches",value:String(e.touchCount)})]}),s.jsxs("div",{className:"text-meta text-ui-mute",children:[s.jsxs("span",{className:a?"font-medium text-ui-danger":"",children:[!n&&a&&s.jsx(f,{size:11,className:"mr-1 inline-block align-[-0.1em]"}),m]}),e.ttfrBasis&&!n&&s.jsxs("span",{children:[" · from ",e.ttfrBasis==="ready"?"ready-for-review":"opened"]}),e.typicalFollowups!=null&&s.jsxs("span",{children:[" · ",e.followupCount," follow-up",e.followupCount===1?"":"s"," vs ",e.typicalFollowups," typical",u?" (more than usual)":""]}),!n&&s.jsxs("span",{children:[" · baseline: ",e.baselinePrs," PRs"]})]}),c.length>0&&s.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[r.map((o,p)=>s.jsxs("span",{className:"inline-flex items-center gap-1 rounded-ui bg-ui-raise px-1.5 py-0.5 text-meta text-ui-mute",title:`${o.count>1?`${I(o)} · `:""}${o.from===o.to?x(o.from):`${x(o.from)} – ${x(o.to)}`}`,children:[o.reviews>0&&s.jsx(C,{size:11}),o.comments>0&&s.jsx(T,{size:11}),o.count>1&&s.jsxs("span",{className:"font-medium",children:["×",o.count]}),o.label]},p)),l>0&&s.jsxs("span",{className:"text-meta text-ui-mute",children:["+",l," more touches"]})]})]})}function S({pr:e}){const{data:t,isLoading:i,isError:a}=j(e.id,!0),{data:n}=y(),u=w.useMemo(()=>{var l;return((l=(n??[]).find(m=>m.id===e.repoId))==null?void 0:l.workspaceId)??null},[n,e.repoId]),c=N(u),r=(t==null?void 0:t.bots)??[];return s.jsxs("div",{className:"space-y-3 p-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(g,{title:"Bot activity",children:[s.jsx("p",{children:"How each review bot behaved on this pull request, compared with its own usual over the last 84 days. No AI is involved."}),s.jsx("p",{children:"A touch is one review or one comment, so a review submitted with three inline comments counts as four."})]}),s.jsx("span",{className:"text-meta text-ui-mute",children:"Each bot against its own usual"})]}),i?s.jsx("div",{className:"h-24 animate-pulse rounded-ui bg-ui-surface"}):a?s.jsx("div",{className:"text-body text-ui-danger",children:"Couldn’t load bot behaviour for this PR."}):r.length===0?s.jsx("div",{className:"rounded-ui border border-dashed border-ui-line p-6 text-center text-body text-ui-mute",children:"No automated-reviewer activity on this PR."}):r.map(l=>s.jsx(R,{bot:l,color:c({login:l.login,kind:l.kind})},l.key))]})}export{S as PrBotBehaviourTab};