limn-review 0.1.162 → 0.1.164

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "limn-review",
3
- "version": "0.1.162",
3
+ "version": "0.1.164",
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",
@@ -1,3 +1,3 @@
1
- import{d as Ie,r as p,j as e}from"./tanstack-BnbsafB1.js";import{aV as z,aU as Qe,cH as je,cO as Xe,co as Ze,cF as et,cq as Te,aO as tt,cG as U,A as Ne,aT as Se,T as ne,v as st,a4 as nt,an as ie,bp as Ee,a0 as _e,e as G,a3 as it,aR as Me,h as Be,p as at,j as rt,a as lt,C as ct,dk as ot,bU as ut,aW as dt,dc as mt,dd as ht,Y as xt,G as pt,S as ft,s as K,bC as gt,cE as bt,cD as jt,cn as Nt,bh as vt,bV as wt,az as kt,bg as yt,b5 as Rt,c3 as Le,bF as Pt,cj as $e,ck as Ct,cx as At,cM as Ft,cL as It,d5 as Tt,d6 as St,aS as Et,aP as _t,cm as Mt,cl as Bt,cy as Lt,d2 as $t,au as Ot,Z as Ut,aQ as Dt,bJ as Ht,bS as ae,V as Wt,t as Yt,K as qt,R as Gt,b$ as Oe,cW as Kt,ah as ve,u as Vt,I as zt}from"./index-Bk94ZJq7.js";import{r as Jt,t as Qt,S as Xt,C as Zt,T as es,F as ts,f as ss}from"./ClaudeReviewTab-D5UZntQn.js";import"./markdown-CcoLFczy.js";import"./highlight-DIEV0qGG.js";import"./vis-C3BCkP5U.js";const ns="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",we="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",ke="inline-flex items-center rounded-ui bg-ui-raise px-1.5 py-px font-mono text-meta text-ui-ink";function is(t){return t instanceof Be||t instanceof Error?t.message:"Something went wrong"}function Ue({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 ye(t,s){var n;return((n=t==null?void 0:t.find(a=>a.ref===s))==null?void 0:n.title)??null}function as({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:ke,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:ke,children:n.ref})," ",ye(s,n.ref)&&e.jsxs("span",{className:"font-medium",children:[ye(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 rs({pr:t,fix:s,liveStatus:n,passRunning:a,auth:i}){var w,h;const l=s.plan,o=z(s.plan??s),g=Qe((s.plan??s).provider,(s.plan??s).model),c=je(g,"plan"),m=je(g,"fix"),v=Me(c),F=Xe(t.id),u=Ze(t.id),k=et(t.id),M=Te(t.id),C=Ie({mutationKey:tt(t.id)})>0,B=U(j=>j.noteAiFixRun),[E,I]=p.useState(""),[y,D]=p.useState(!1);if(!l)return null;const R=l.plan,_=l.status==="plan_ready"&&!a,L=E.trim(),P=L.length>Ne,r=()=>{!_||C||L===""||P||F.mutate({fixId:s.id,text:L},{onSuccess:()=>I("")})},d=()=>{B({prId:t.id,repoFullName:t.repoFullName,prNumber:t.number,prTitle:t.title}),u.mutate(s.id)},f=F.error??u.error??k.error;return e.jsxs("div",{className:"mt-3 rounded-ui bg-ui-surface p-3",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1 text-meta font-semibold text-ui-ink",children:["Plan",R&&l.revision>1&&e.jsxs("span",{className:"font-normal text-ui-mute",children:["· version ",l.revision]}),l.model&&e.jsxs("span",{className:"font-normal text-ui-mute",children:["· ",Se(l.provider,l.model,l.effort)]}),e.jsxs(ne,{title:"Plan first",children:[e.jsxs("p",{children:[v," reads the code and writes a plan. It changes nothing."]}),e.jsxs("p",{children:["Tell ",v," what to change and it rewrites the plan, taking the whole conversation into account. Each message runs ",v," again."]}),e.jsxs("p",{children:["When you approve, ",v," builds the fix from this plan. You still review the diff and press Push."]})]})]}),R?e.jsxs(e.Fragment,{children:[e.jsx(Ue,{plan:R}),e.jsxs("button",{type:"button",className:"hit mt-2 inline-flex items-center gap-1 text-meta text-ui-mute hover:text-ui-ink","aria-expanded":y,onClick:()=>D(j=>!j),children:[e.jsx(st,{dir:y?"down":"right"}),"Details"]}),y&&e.jsx(as,{plan:R,items:s.reviewItems})]}):!a&&e.jsx("p",{className:"text-meta text-ui-mute",children:"No plan yet."}),s.error&&e.jsx("p",{className:"mt-2 rounded-ui bg-ui-raise p-2 text-meta text-ui-warn",children:s.error}),e.jsx(nt,{transcript:l.transcript,plannedBy:o}),a&&e.jsxs("div",{className:"mt-3",children:[e.jsx(ie,{active:!0,label:R?"Updating the plan":"Making the plan",value:Ee(n),timeConstantSec:30}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-meta text-ui-mute",children:[_e[((w=n==null?void 0:n.progress)==null?void 0:w.phase)??""]??"Working…",e.jsx("button",{type:"button",className:we,onClick:()=>M.mutate(),children:"Cancel"})]}),((h=n==null?void 0:n.progress)==null?void 0:h.recentActivity)&&n.progress.recentActivity.length>0&&e.jsx("pre",{className:"mt-1 max-h-32 overflow-auto rounded-ui bg-ui-surface p-2 text-meta leading-relaxed text-ui-mute",children:n.progress.recentActivity.slice(-8).join(`
2
- `)})]}),_&&R&&e.jsxs("div",{className:"mt-3",children:[e.jsx(G,{kind:"plan",auth:i,meter:!1,followUp:!0,provider:c,children:e.jsx(it,{name:v,draft:E,setDraft:I,busy:C,maxChars:Ne,onSend:r})}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx(G,{kind:"fix",auth:i,followUp:!0,provider:m,children:e.jsx("button",{type:"button","data-ai-run":!0,className:ns,disabled:C,onClick:d,children:"Approve and build"})}),e.jsx("button",{type:"button",className:we,disabled:C,onClick:()=>k.mutate(s.id),children:"Discard plan"})]})]}),f!=null&&e.jsx("p",{className:"mt-1 text-meta text-ui-danger",children:is(f)})]})}function De({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(Ue,{plan:s})]}):null}function ls(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 cs(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 Re=ct,os=rt;function us(t){return t.kind==="finding"&&t.findingId!=null?`claude-finding-${t.findingId}`:null}function ds(t){const s=U(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 Pe({refId:t,item:s,onJump:n}){const a=s?`${lt[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?us(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:`${Re} max-w-[22rem] hover:bg-ui-hover`,children:i}):e.jsx("span",{className:`${Re} max-w-[22rem]`,children:i})}function ms(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 hs({pr:t,fix:s}){const n=z(s),a=ds(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 g=l.size>0;return e.jsxs("div",{className:"mt-2 text-meta",children:[e.jsx(at,{report:i,filesChanged:s.filesChanged,by:n,refsInfo:g?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(Pe,{refId:c,item:l.get(c),onJump:a},c)}),o.length>0&&e.jsxs("section",{children:[e.jsxs("div",{className:os,children:["Left out",e.jsx(ne,{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(Pe,{refId:c.ref,item:c,onJump:a},c.ref))})]})]})}const xs=["findings","earlier_findings","judged_threads","untouched_threads","ci_failures","sonar","style_bots","story"],ps={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 Ce(t,s="Claude"){return t==="findings"?`${s}’s findings`:t==="judged_threads"?`Threads ${s} says need a fix`:ps[t]}function V(t,s){return s[t.key]??t.defaultIncluded}function fs(t,s){return t.items.filter(n=>V(n,s)).map(n=>n.key)}function He(t,s){const n=new Set;let a=0;for(const i of t.items)if(V(i,s)){if(a>0&&a+i.chars>t.budgetChars){n.add(i.key);continue}a+=i.chars}return n}function gs(t,s){const n={};for(const a of t.items)n[a.key]=a.section===s;return n}const bs={blocker:"Blocker",warning:"Warning",nit:"Nit",question:"Question",praise:"Praise"},Ae={blocker:"bg-ui-danger/10 text-ui-danger",warning:"bg-ui-raise text-ui-warn",nit:"bg-ui-raise text-ui-mute"},We="whitespace-nowrap rounded-ui bg-ui-raise px-1 py-px text-meta text-ui-warn",Z=new Set;function js(t,s){return t?s!=null?`${t}:${s}`:t:null}function Ns({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(K,{checked:s,disabled:a,onChange:l=>i(l.target.checked),"aria-label":`Include in the fix: ${t.label}`})}),s&&n&&e.jsx("span",{className:We,children:"Won’t fit"})]})}function vs({item:t,picked:s,cut:n,disabled:a,onToggle:i}){const l=js(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(K,{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&&Ae[t.severity]&&e.jsx("span",{className:`rounded-ui px-1 py-px text-meta font-medium ${Ae[t.severity]}`,children:bs[t.severity]}),e.jsx("span",{className:"break-words text-ui-ink",children:t.label}),s&&n&&e.jsx("span",{className:We,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 ws({preview:t,overrides:s,onChange:n,disabled:a,pr:i,review:l}){const o=He(t,s),g=new Map;for(const r of t.items){const d=g.get(r.section)??[];d.push(r),g.set(r.section,d)}const c=(r,d)=>{const f={...s};for(const w of r)f[w]=d;n(f)},m=l!=null&&l.id===t.sourceReviewId?l:null,v=Jt(l),F=Qt(l),u=p.useMemo(()=>m!=null?ot(m):null,[m]),k=p.useMemo(()=>new Map(((u==null?void 0:u.findings)??[]).map(r=>[r.id,r])),[u]),M=p.useMemo(()=>{var r;return new Map((((r=u==null?void 0:u.followUp)==null?void 0:r.items)??[]).map(d=>[d.priorFindingId,d]))},[u]),C=p.useMemo(()=>u!=null?ut(u):new Map,[u]),B=p.useMemo(()=>u!=null?dt(u):new Set,[u]),E=p.useMemo(()=>{var d;const r=new Set;for(const f of t.items)((d=f.card)==null?void 0:d.kind)==="story"&&r.add(f.card.ticketReviewId);return[...r].sort((f,w)=>f-w)},[t.items]),I=mt(i.id,E.length>0),y=p.useMemo(()=>{var d;const r=new Map;for(const f of((d=I.data)==null?void 0:d.tickets)??[])f.review!=null&&r.set(f.review.id,f.review);return r},[I.data]),D=p.useMemo(()=>I.data==null?[]:E.filter(r=>!y.has(r)),[I.data,E,y]),R=ht(D),_=p.useMemo(()=>{const r=new Map(y);for(const d of R)r.set(d.id,d);return r},[y,R]);if(t.items.length===0)return e.jsx("p",{className:"text-meta text-ui-mute",children:"The review found nothing to fix."});const L=(m==null?void 0:m.headSha)??i.headSha,P=r=>{var H,T;const d=V(r,s),f=o.has(r.key),w=b=>c([r.key],b),h=e.jsx(Ns,{item:r,picked:d,cut:f,disabled:a,onToggle:w}),j=r.card;switch(j==null?void 0:j.kind){case"finding":{const b=k.get(j.findingId);if(b==null)break;return e.jsx(ts,{authorName:ss(l,b),prId:i.id,finding:b,editable:!1,prUrl:i.githubUrl,repoFullName:i.repoFullName,headSha:L,posting:!1,postError:null,inChangeset:b.fileInDiff,priorStatus:C.get(b.id),alreadyPosted:B.has(b.id),actions:!1,selection:h,docReferences:(m==null?void 0:m.docReferences)??null},r.key)}case"earlier_finding":{const b=M.get(j.priorFindingId);if(b==null)break;return e.jsx(ft,{item:b,muted:!1,findingsById:k,headMoved:((H=u==null?void 0:u.followUp)==null?void 0:H.headMoved)??!1,changedPaths:Z,actions:!1,selection:h,by:v},r.key)}case"thread":return e.jsx(es,{t:j.assessment,muted:!1,actions:!1,selection:h,notCheckedNote:j.inReview?void 0:`${F} didn’t check this one.`,by:F},r.key);case"ci":return e.jsx(Zt,{f:j.item,suggestion:j.item.suggestion,changedPaths:Z,selection:h},r.key);case"sonar":return e.jsx(Xt,{issue:j.issue,selection:h},r.key);case"story":{const b=_.get(j.ticketReviewId),S=b==null?void 0:b.items.find($=>$.id===j.itemId);if(b==null||S==null)break;const N={review:b,viewedPrId:i.id,changedPaths:Z,actions:!1,selection:h};if(S.status==="missing")return e.jsx(xt,{item:S,...N},r.key);const x=(T=b.assessment)==null?void 0:T.criteria.find($=>$.ref===S.ref);if(x==null||x.status==="met")break;return e.jsx(pt,{c:x,item:S,...N},r.key)}}return e.jsx(vs,{item:r,picked:d,cut:f,disabled:a,onToggle:w},r.key)};return e.jsxs("div",{className:"space-y-3",children:[xs.filter(r=>g.has(r)).map(r=>{const d=g.get(r),f=d.filter(h=>V(h,s)).length,w=f===d.length;return e.jsxs("section",{"aria-label":Ce(r,v),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:Ce(r,v)}),e.jsxs("span",{className:"text-meta text-ui-mute",children:[f," of ",d.length]}),e.jsx("button",{type:"button",className:"hit ml-auto text-meta text-ui-accent hover:underline disabled:opacity-50",disabled:a,onClick:()=>c(d.map(h=>h.key),!w),children:w?"Untick all":"Tick all"})]}),e.jsx("ul",{className:"space-y-1.5",children:d.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 ks="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",Fe="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 Ye(t){return{prId:t.id,repoId:t.repoId,repoFullName:t.repoFullName,prNumber:t.number,prTitle:t.title,githubUrl:t.githubUrl}}function ys(t){const s=gt({mergeable:t.mergeable,mergeStateStatus:t.mergeStateStatus,isDraft:t.isDraft,inMergeQueue:t.inMergeQueue===!0}).verdict;return bt({state:t.state,verdict:s,viewerCanPush:t.viewerCanPush})}function Rs({pr:t}){const s=jt(t.id),n=Nt(),a=vt(s),i=t.baseRefName??"the base branch";p.useEffect(()=>{wt(t.id)},[t.id]);const l=Ye(t),o=(s==null?void 0:s.phase)==="succeeded"?s.resolution:null;return e.jsxs("div",{className:"mb-3 rounded-ui bg-ui-surface p-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-body font-medium text-ui-ink",children:[e.jsx(kt,{size:13,className:"text-ai-signal"}),"This branch conflicts with ",i]}),e.jsxs("p",{className:"mt-1 text-meta text-ui-mute",children:[n," reads the code and picks a result for each conflict. You check its choices in the resolver before anything is pushed."]}),a&&s!=null?e.jsxs("div",{className:"mt-2",children:[e.jsx(ie,{active:!0,label:`Resolving conflicts with ${n}`,timeConstantSec:60}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-meta text-ui-mute",children:[yt(s.phase,n),e.jsx("button",{type:"button",className:Fe,onClick:()=>Rt(t.id),children:"Cancel"})]})]}):e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx(G,{kind:"resolve",children:e.jsx("button",{type:"button",className:ks,onClick:()=>Le(l,{providerName:n}),children:o!=null?"Run again":`Resolve merge conflicts with ${n}`})}),o!=null&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:Fe,onClick:()=>Pt(l),children:"Open the resolver"}),e.jsxs("span",{className:"text-meta text-ui-mute",children:[z(o)," decided ",o.choices.length," of ",o.decidableTotal," change",o.decidableTotal===1?"":"s","."]})]}),(s==null?void 0:s.phase)==="failed"&&s.error!=null&&e.jsx("span",{className:"text-meta text-ui-danger",children:s.error}),(s==null?void 0:s.phase)==="cancelled"&&e.jsx("span",{className:"text-meta text-ui-mute",children:"Cancelled."})]})]})}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 se(t){return t instanceof Be||t instanceof Error?t.message:"Something went wrong"}const ee="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 Ps({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 Os({pr:t}){const s=$e().enabled,n=U(c=>c.aiFixTabFocus),a=U(c=>c.consumeAiFixTabFocus),[i,l]=p.useState(null),[o,g]=p.useState(null);return p.useEffect(()=>{n&&n.prId===t.id&&(n.reviewId!=null&&l(n.reviewId),n.only!=null&&g(n.only),a())},[n,t.id,a]),s?e.jsx("div",{className:"pb-6",children:e.jsx(Cs,{pr:t,handoffReviewId:i,onlySection:o,onOnlySectionApplied:()=>g(null)})}):e.jsx(e.Fragment,{})}function Cs({pr:t,handoffReviewId:s,onlySection:n,onOnlySectionApplied:a}){var oe,ue,de,me,he,xe,pe,fe,ge,be;const{data:i,isLoading:l}=Ct(t.id,!0),{data:o,isLoading:g}=At(t.id),c=(o==null?void 0:o.review)??null,m=ls(s,c,(o==null?void 0:o.history)??[]),v=cs(s,m,c),F=U(A=>A.setPrDetailTab),u=Ft("fix",zt),k=Me(u.chosen.provider),M=It().data,C=Tt(t.id),B=St(t.id),E=Te(t.id),I=$e(),y=Et(M,u.chosen.provider,"plan"),[D,R]=p.useState(!1),_=D&&y,L=U(A=>A.noteAiFixRun),P=Ie({mutationKey:_t(t.id)})>0,r=((oe=i==null?void 0:i.fix)==null?void 0:oe.status)??null,d=r==="planned",f=d&&((de=(ue=i==null?void 0:i.fix)==null?void 0:ue.plan)==null?void 0:de.status)==="planning",w=r==="running"||r==="queued"||P||f,{status:h}=Mt(t.id,w),j=(h==null?void 0:h.status)??r??"idle",H=j==="running"||j==="queued",T=H&&!d,b=d&&(f||H),S=d&&(((he=(me=i==null?void 0:i.fix)==null?void 0:me.plan)==null?void 0:he.status)==="planning"||((pe=(xe=i==null?void 0:i.fix)==null?void 0:xe.plan)==null?void 0:pe.status)==="plan_ready"),N=(i==null?void 0:i.fix)??null,x=Bt(t.id,m,(i==null?void 0:i.enabled)!==!1&&(m!=null||!g)),$=m==null&&x.data!=null&&x.data.sourceReviewId==null&&x.data.items.length>0,q=m!=null||$,Ge=Lt(m!=null&&(c==null?void 0:c.id)!==m?m:null),Ke=m!=null&&(c==null?void 0:c.id)===m?c:Ge.data??null,[J,Q]=p.useState({});p.useEffect(()=>Q({}),[m]);const[Ve,W]=p.useState(!1);p.useEffect(()=>{n==null||!x.data||(Q(gs(x.data,n)),W(!0),a())},[n,x.data,a]);const re=!S&&(Ve||!N||N.status!=="succeeded"),X=ys(t),[le,ze]=p.useState(!1),Y=$t(t.id,t.repoFullName),O=x.data?fs(x.data,J):[],ce=x.data?He(x.data,J).size:0,Je=()=>{if(!q||!x.data||O.length===0)return;const A={model:u.chosen.model,provider:u.chosen.provider,seed:"review",...m!=null?{sourceReviewId:m}:{},include:O,...Y.names.length>0?{checks:Y.names}:{}};_?B.mutate(A,{onSuccess:()=>W(!1)}):(L({prId:t.id,repoFullName:t.repoFullName,prNumber:t.number,prTitle:t.title}),C.mutate(A,{onSuccess:()=>W(!1)})),le&&X&&Le(Ye(t),{model:Dt(u.chosen.model),providerName:I.providerName})};return e.jsxs("div",{children:[e.jsx(Ps,{info:e.jsxs(ne,{title:"AI Fix",children:[e.jsxs("p",{children:[k," reads the PR's code and edits files in a private copy. It has no shell. Tick Run tests to let it run the project's own test, lint and type checks in a sandbox."]}),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:["Tick Plan first to read ",k,"'s plan, steer it and approve it before anything changes."]}),e.jsxs("p",{children:[k," reports what it changed in each file and what it left alone, and why."]}),e.jsx("p",{children:"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:[X&&e.jsx(Rs,{pr:t}),(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:[!T&&!S&&!q&&!g&&!x.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:te,onClick:()=>F(t.id,"claude_review"),children:"Open AI Review"})]}),!T&&!S&&q&&!re&&e.jsx("button",{type:"button",className:ee,onClick:()=>W(!0),children:"New fix"}),!T&&q&&re&&e.jsxs("div",{children:[v&&e.jsx("p",{className:"mb-2 text-meta text-ui-mute",children:v}),$&&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."}),x.isLoading&&e.jsx("p",{className:"text-meta text-ui-mute",children:"Loading…"}),x.isError&&m!=null&&e.jsx("p",{className:"text-meta text-ui-danger",children:se(x.error)}),x.data&&e.jsx(ws,{preview:x.data,overrides:J,onChange:Q,disabled:P,pr:t,review:Ke}),x.data&&x.data.items.length>0&&X&&e.jsxs("label",{className:"mt-3 flex cursor-pointer items-start gap-2 text-meta text-ui-ink",children:[e.jsx(K,{className:"mt-0.5",checked:le,disabled:P,onChange:A=>ze(A.target.checked)}),e.jsxs("span",{children:["Also resolve merge conflicts with ",t.baseRefName??"the base branch",e.jsx("span",{className:"block text-meta text-ui-mute",children:"You check the merge in the resolver. It lands as its own commit, apart from the fix."})]})]}),x.data&&x.data.items.length>0&&e.jsx(Ot,{state:Y,disabled:P}),x.data&&x.data.items.length>0&&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(Ut,{state:u,onPick:u.pick,disabled:P}),y&&e.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5 text-meta text-ui-ink",children:[e.jsx(K,{checked:_,disabled:P,onChange:A=>R(A.target.checked)}),"Plan first"]}),e.jsx(G,{kind:"fix",auth:i==null?void 0:i.auth,anyProvider:!0,provider:u.chosen.provider,children:e.jsx("button",{type:"button",className:te,disabled:P||O.length===0||Y.on&&Y.query.isLoading,onClick:Je,children:_?"Make a plan":"Start fix"})}),e.jsx("span",{className:"text-meta text-ui-mute",children:O.length===0?"Nothing ticked.":`${O.length-ce} item${O.length-ce===1?"":"s"}`}),(N==null?void 0:N.status)==="succeeded"&&e.jsx("button",{type:"button",className:ee,onClick:()=>W(!1),children:"Close"})]})]}),T&&e.jsx("button",{type:"button",className:ee,onClick:()=>E.mutate(),children:"Cancel"}),(C.isError||B.isError)&&e.jsx("p",{className:"mt-1 text-meta text-ui-danger",children:se(C.error??B.error)}),N&&d&&e.jsx(rs,{pr:t,fix:N,liveStatus:h,passRunning:b,auth:i==null?void 0:i.auth}),T&&e.jsxs("div",{className:"mt-3",children:[N&&e.jsx(De,{fix:N}),e.jsx(ie,{active:!0,label:"Running AI fix",value:Ee(h),timeConstantSec:40}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-meta text-ui-mute",children:[(N==null?void 0:N.trigger)==="auto"&&e.jsx(qe,{}),_e[((fe=h==null?void 0:h.progress)==null?void 0:fe.phase)??""]??"Working…"]}),((ge=h==null?void 0:h.progress)==null?void 0:ge.recentActivity)&&h.progress.recentActivity.length>0&&e.jsx("pre",{className:"mt-1 max-h-32 overflow-auto rounded-ui bg-ui-surface p-2 text-meta leading-relaxed text-ui-mute",children:h.progress.recentActivity.slice(-8).join(`
3
- `)})]}),!T&&N&&!d&&e.jsx(Fs,{pr:t,fix:N,headInfo:(i==null?void 0:i.headInfo)??null,viewerCanPush:(i==null?void 0:i.viewerCanPush)??!1}),l&&!N&&e.jsx("p",{className:"mt-3 text-meta text-ui-mute",children:"Loading…"})]}),e.jsx(Ts,{history:(i==null?void 0:i.history)??[],currentFixId:((be=i==null?void 0:i.fix)==null?void 0:be.id)??null})]})]})}function qe(){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 As(t){return Se(t.provider,t.model,t.effort)}function Fs({pr:t,fix:s,headInfo:n,viewerCanPush:a}){var o,g,c;const i=p.useMemo(()=>Ht(s.patch),[s.patch]);if(s.status==="failed"&&((o=s.plan)==null?void 0:o.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:[z(s.plan??s)," could not make a plan: ",s.error??"unknown error"]});if(s.status==="cancelled"&&((g=s.plan)==null?void 0:g.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:"The fix run was cancelled."});if(s.status!=="succeeded")return e.jsx(e.Fragment,{});const l=!s.patch||s.filesChanged.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(qe,{})," "]}),ms(s)," · ",As(s),s.finishedAt&&e.jsxs(e.Fragment,{children:[" · ",ae(s.finishedAt)]})]}),s.pushedAt==null&&s.error&&e.jsx("p",{className:"mb-2 rounded-ui bg-ui-raise p-2 text-meta text-ui-warn",children:s.error}),e.jsx(De,{fix:s}),s.summary&&e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(Wt,{children:s.summary})}),e.jsx(hs,{pr:t,fix:s}),e.jsx(Yt,{checks:s.checks}),l?e.jsx("p",{className:"mt-2 text-meta text-ui-mute",children:"No files changed."}):e.jsxs(e.Fragment,{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:[s.filesChanged.length," file",s.filesChanged.length===1?"":"s"," changed",!((c=s.checks)!=null&&c.ran)&&" · Not built or tested here."]}),e.jsx(qt,{})]}),e.jsx("div",{className:"overflow-hidden rounded-ui bg-ui-surface text-ui-ink",children:e.jsx(Gt,{files:i})}),e.jsx(Ss,{pr:t,fix:s,headInfo:n,viewerCanPush:a})]})]})}function Is({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:Oe(t.pushedPrUrl),target:"_blank",rel:"noreferrer",className:"hit underline",children:["PR #",t.pushedPrNumber]})]}),t.pushedAt&&e.jsxs(e.Fragment,{children:[" · ",ae(t.pushedAt)]})]}),t.commitMessage&&e.jsx("div",{className:"mt-1 font-mono text-meta text-ui-success",children:t.commitMessage})]})}function Ts({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:Oe(a.pushedPrUrl),target:"_blank",rel:"noreferrer",className:"hit underline",children:["PR #",a.pushedPrNumber]})]}),a.pushedAt&&e.jsxs(e.Fragment,{children:[" · ",ae(a.pushedAt)]})]})]},a.id))})]})}function Ss({pr:t,fix:s,headInfo:n,viewerCanPush:a}){const i=Kt(t.id),l=(n==null?void 0:n.canPushSameBranch)??!1,[o,g]=p.useState(l?"existing":"new"),[c,m]=p.useState((n==null?void 0:n.suggestedBranch)??""),v=p.useRef(!1);if(p.useEffect(()=>{!v.current&&(n!=null&&n.suggestedBranch)&&(m(n.suggestedBranch),v.current=!0,n.canPushSameBranch||g("new"))},[n]),s.pushedAt!=null)return e.jsx(Is,{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."});const F=o==="new"&&c.trim().length===0,u=i.isPending,k=()=>{i.mutate({fixId:s.id,body:{target:o,branch:o==="new"?c.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(ve,{className:"mt-0",checked:o==="existing",disabled:!l||u,onChange:()=>g("existing")}),"Push to the PR branch",(n==null?void 0:n.headRef)&&e.jsxs("span",{className:"font-mono text-ui-faint",children:["(",n.headRef,")"]})]}),e.jsxs("label",{className:"mt-1 flex items-center gap-2 text-meta",children:[e.jsx(ve,{className:"mt-0",checked:o==="new",disabled:u,onChange:()=>g("new")}),"New branch + open a PR"]}),o==="new"&&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:c,disabled:u,onChange:M=>m(M.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:te,disabled:u||F,onClick:k,children:u?"Pushing…":o==="new"?"Push + open PR":"Push"}),e.jsx(Vt,{checks:s.checks})]}),i.isError&&e.jsx("div",{className:"mt-2 text-meta text-ui-danger",children:se(i.error)})]})}export{Os as AiFixTab};
1
+ import{d as Ie,r as p,j as e}from"./tanstack-BnbsafB1.js";import{aU as z,aT as Xe,cG as je,cN as Je,cn as Ze,cE as et,cp as Te,aN as tt,cF as O,A as Ne,aS as Se,T as ne,v as st,a4 as nt,am as ie,bo as Ee,a0 as _e,e as q,a3 as it,aQ as Me,h as Be,p as at,j as rt,a as lt,C as ct,dj as ot,bT as ut,aV as dt,db as mt,dc as ht,Y as xt,G as pt,S as ft,s as G,bB as gt,cD as bt,cC as jt,cm as Nt,bg as vt,bU as wt,ay as kt,bf as yt,b4 as Rt,c2 as Le,bE as Pt,ci as Ue,cj as Ct,cw as At,cL as Ft,cK as It,d4 as Tt,d5 as St,aR as Et,aO as _t,cl as Mt,ck as Bt,cx as Lt,d1 as Ut,at as $t,Z as Ot,aP as Dt,bI as Ht,bR as ae,V as Yt,t as Wt,K as Kt,R as qt,b_ as $e,cV as Gt,ah as ve,u as Vt,I as zt}from"./index-DWLpcq8D.js";import{r as Qt,t as Xt,S as Jt,C as Zt,T as es,F as ts,f as ss}from"./ClaudeReviewTab-BK6Iz-IB.js";import"./markdown-CcoLFczy.js";import"./highlight-DIEV0qGG.js";import"./vis-C3BCkP5U.js";const ns="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",we="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",ke="inline-flex items-center rounded-ui bg-ui-raise px-1.5 py-px font-mono text-meta text-ui-ink";function is(t){return t instanceof Be||t instanceof Error?t.message:"Something went wrong"}function Oe({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 ye(t,s){var n;return((n=t==null?void 0:t.find(a=>a.ref===s))==null?void 0:n.title)??null}function as({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:ke,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:ke,children:n.ref})," ",ye(s,n.ref)&&e.jsxs("span",{className:"font-medium",children:[ye(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 rs({pr:t,fix:s,liveStatus:n,passRunning:a,auth:i}){var w,h;const l=s.plan,o=z(s.plan??s),g=Xe((s.plan??s).provider,(s.plan??s).model),c=je(g,"plan"),m=je(g,"fix"),v=Me(c),F=Je(t.id),u=Ze(t.id),k=et(t.id),M=Te(t.id),C=Ie({mutationKey:tt(t.id)})>0,B=O(j=>j.noteAiFixRun),[E,I]=p.useState(""),[y,D]=p.useState(!1);if(!l)return null;const R=l.plan,_=l.status==="plan_ready"&&!a,L=E.trim(),P=L.length>Ne,r=()=>{!_||C||L===""||P||F.mutate({fixId:s.id,text:L},{onSuccess:()=>I("")})},d=()=>{B({prId:t.id,repoFullName:t.repoFullName,prNumber:t.number,prTitle:t.title}),u.mutate(s.id)},f=F.error??u.error??k.error;return e.jsxs("div",{className:"mt-3 rounded-ui bg-ui-surface p-3",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1 text-meta font-semibold text-ui-ink",children:["Plan",R&&l.revision>1&&e.jsxs("span",{className:"font-normal text-ui-mute",children:["· version ",l.revision]}),l.model&&e.jsxs("span",{className:"font-normal text-ui-mute",children:["· ",Se(l.provider,l.model,l.effort)]}),e.jsxs(ne,{title:"Plan first",children:[e.jsxs("p",{children:[v," reads the code and writes a plan. It changes nothing."]}),e.jsxs("p",{children:["Tell ",v," what to change and it rewrites the plan, taking the whole conversation into account. Each message runs ",v," again."]}),e.jsxs("p",{children:["When you approve, ",v," builds the fix from this plan. You still review the diff and press Push."]})]})]}),R?e.jsxs(e.Fragment,{children:[e.jsx(Oe,{plan:R}),e.jsxs("button",{type:"button",className:"hit mt-2 inline-flex items-center gap-1 text-meta text-ui-mute hover:text-ui-ink","aria-expanded":y,onClick:()=>D(j=>!j),children:[e.jsx(st,{dir:y?"down":"right"}),"Details"]}),y&&e.jsx(as,{plan:R,items:s.reviewItems})]}):!a&&e.jsx("p",{className:"text-meta text-ui-mute",children:"No plan yet."}),s.error&&e.jsx("p",{className:"mt-2 rounded-ui bg-ui-raise p-2 text-meta text-ui-warn",children:s.error}),e.jsx(nt,{transcript:l.transcript,plannedBy:o}),a&&e.jsxs("div",{className:"mt-3",children:[e.jsx(ie,{active:!0,label:R?"Updating the plan":"Making the plan",value:Ee(n),timeConstantSec:30}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-meta text-ui-mute",children:[_e[((w=n==null?void 0:n.progress)==null?void 0:w.phase)??""]??"Working…",e.jsx("button",{type:"button",className:we,onClick:()=>M.mutate(),children:"Cancel"})]}),((h=n==null?void 0:n.progress)==null?void 0:h.recentActivity)&&n.progress.recentActivity.length>0&&e.jsx("pre",{className:"mt-1 max-h-32 overflow-auto rounded-ui bg-ui-surface p-2 text-meta leading-relaxed text-ui-mute",children:n.progress.recentActivity.slice(-8).join(`
2
+ `)})]}),_&&R&&e.jsxs("div",{className:"mt-3",children:[e.jsx(q,{kind:"plan",auth:i,meter:!1,followUp:!0,provider:c,children:e.jsx(it,{name:v,draft:E,setDraft:I,busy:C,maxChars:Ne,onSend:r})}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx(q,{kind:"fix",auth:i,followUp:!0,provider:m,children:e.jsx("button",{type:"button","data-ai-run":!0,className:ns,disabled:C,onClick:d,children:"Approve and build"})}),e.jsx("button",{type:"button",className:we,disabled:C,onClick:()=>k.mutate(s.id),children:"Discard plan"})]})]}),f!=null&&e.jsx("p",{className:"mt-1 text-meta text-ui-danger",children:is(f)})]})}function De({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(Oe,{plan:s})]}):null}function ls(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 cs(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 Re=ct,os=rt;function us(t){return t.kind==="finding"&&t.findingId!=null?`claude-finding-${t.findingId}`:null}function ds(t){const s=O(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 Pe({refId:t,item:s,onJump:n}){const a=s?`${lt[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?us(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:`${Re} max-w-[22rem] hover:bg-ui-hover`,children:i}):e.jsx("span",{className:`${Re} max-w-[22rem]`,children:i})}function ms(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 hs({pr:t,fix:s}){const n=z(s),a=ds(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 g=l.size>0;return e.jsxs("div",{className:"mt-2 text-meta",children:[e.jsx(at,{report:i,filesChanged:s.filesChanged,by:n,refsInfo:g?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(Pe,{refId:c,item:l.get(c),onJump:a},c)}),o.length>0&&e.jsxs("section",{children:[e.jsxs("div",{className:os,children:["Left out",e.jsx(ne,{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(Pe,{refId:c.ref,item:c,onJump:a},c.ref))})]})]})}const xs=["findings","earlier_findings","judged_threads","untouched_threads","ci_failures","sonar","style_bots","story"],ps={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 Ce(t,s="Claude"){return t==="findings"?`${s}’s findings`:t==="judged_threads"?`Threads ${s} says need a fix`:ps[t]}function V(t,s){return s[t.key]??t.defaultIncluded}function fs(t,s){return t.items.filter(n=>V(n,s)).map(n=>n.key)}function He(t,s){const n=new Set;let a=0;for(const i of t.items)if(V(i,s)){if(a>0&&a+i.chars>t.budgetChars){n.add(i.key);continue}a+=i.chars}return n}function gs(t,s){const n={};for(const a of t.items)n[a.key]=a.section===s;return n}const bs={blocker:"Blocker",warning:"Warning",nit:"Nit",question:"Question",praise:"Praise"},Ae={blocker:"bg-ui-danger/10 text-ui-danger",warning:"bg-ui-raise text-ui-warn",nit:"bg-ui-raise text-ui-mute"},Ye="whitespace-nowrap rounded-ui bg-ui-raise px-1 py-px text-meta text-ui-warn",Z=new Set;function js(t,s){return t?s!=null?`${t}:${s}`:t:null}function Ns({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(G,{checked:s,disabled:a,onChange:l=>i(l.target.checked),"aria-label":`Include in the fix: ${t.label}`})}),s&&n&&e.jsx("span",{className:Ye,children:"Won’t fit"})]})}function vs({item:t,picked:s,cut:n,disabled:a,onToggle:i}){const l=js(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(G,{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&&Ae[t.severity]&&e.jsx("span",{className:`rounded-ui px-1 py-px text-meta font-medium ${Ae[t.severity]}`,children:bs[t.severity]}),e.jsx("span",{className:"break-words text-ui-ink",children:t.label}),s&&n&&e.jsx("span",{className:Ye,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 ws({preview:t,overrides:s,onChange:n,disabled:a,pr:i,review:l}){const o=He(t,s),g=new Map;for(const r of t.items){const d=g.get(r.section)??[];d.push(r),g.set(r.section,d)}const c=(r,d)=>{const f={...s};for(const w of r)f[w]=d;n(f)},m=l!=null&&l.id===t.sourceReviewId?l:null,v=Qt(l),F=Xt(l),u=p.useMemo(()=>m!=null?ot(m):null,[m]),k=p.useMemo(()=>new Map(((u==null?void 0:u.findings)??[]).map(r=>[r.id,r])),[u]),M=p.useMemo(()=>{var r;return new Map((((r=u==null?void 0:u.followUp)==null?void 0:r.items)??[]).map(d=>[d.priorFindingId,d]))},[u]),C=p.useMemo(()=>u!=null?ut(u):new Map,[u]),B=p.useMemo(()=>u!=null?dt(u):new Set,[u]),E=p.useMemo(()=>{var d;const r=new Set;for(const f of t.items)((d=f.card)==null?void 0:d.kind)==="story"&&r.add(f.card.ticketReviewId);return[...r].sort((f,w)=>f-w)},[t.items]),I=mt(i.id,E.length>0),y=p.useMemo(()=>{var d;const r=new Map;for(const f of((d=I.data)==null?void 0:d.tickets)??[])f.review!=null&&r.set(f.review.id,f.review);return r},[I.data]),D=p.useMemo(()=>I.data==null?[]:E.filter(r=>!y.has(r)),[I.data,E,y]),R=ht(D),_=p.useMemo(()=>{const r=new Map(y);for(const d of R)r.set(d.id,d);return r},[y,R]);if(t.items.length===0)return e.jsx("p",{className:"text-meta text-ui-mute",children:"The review found nothing to fix."});const L=(m==null?void 0:m.headSha)??i.headSha,P=r=>{var H,T;const d=V(r,s),f=o.has(r.key),w=b=>c([r.key],b),h=e.jsx(Ns,{item:r,picked:d,cut:f,disabled:a,onToggle:w}),j=r.card;switch(j==null?void 0:j.kind){case"finding":{const b=k.get(j.findingId);if(b==null)break;return e.jsx(ts,{authorName:ss(l,b),prId:i.id,finding:b,editable:!1,prUrl:i.githubUrl,repoFullName:i.repoFullName,headSha:L,posting:!1,postError:null,inChangeset:b.fileInDiff,priorStatus:C.get(b.id),alreadyPosted:B.has(b.id),actions:!1,selection:h,docReferences:(m==null?void 0:m.docReferences)??null},r.key)}case"earlier_finding":{const b=M.get(j.priorFindingId);if(b==null)break;return e.jsx(ft,{item:b,muted:!1,findingsById:k,headMoved:((H=u==null?void 0:u.followUp)==null?void 0:H.headMoved)??!1,changedPaths:Z,actions:!1,selection:h,by:v},r.key)}case"thread":return e.jsx(es,{t:j.assessment,muted:!1,actions:!1,selection:h,notCheckedNote:j.inReview?void 0:`${F} didn’t check this one.`,by:F},r.key);case"ci":return e.jsx(Zt,{f:j.item,suggestion:j.item.suggestion,changedPaths:Z,selection:h},r.key);case"sonar":return e.jsx(Jt,{issue:j.issue,selection:h},r.key);case"story":{const b=_.get(j.ticketReviewId),S=b==null?void 0:b.items.find(U=>U.id===j.itemId);if(b==null||S==null)break;const N={review:b,viewedPrId:i.id,changedPaths:Z,actions:!1,selection:h};if(S.status==="missing")return e.jsx(xt,{item:S,...N},r.key);const x=(T=b.assessment)==null?void 0:T.criteria.find(U=>U.ref===S.ref);if(x==null||x.status==="met")break;return e.jsx(pt,{c:x,item:S,...N},r.key)}}return e.jsx(vs,{item:r,picked:d,cut:f,disabled:a,onToggle:w},r.key)};return e.jsxs("div",{className:"space-y-3",children:[xs.filter(r=>g.has(r)).map(r=>{const d=g.get(r),f=d.filter(h=>V(h,s)).length,w=f===d.length;return e.jsxs("section",{"aria-label":Ce(r,v),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:Ce(r,v)}),e.jsxs("span",{className:"text-meta text-ui-mute",children:[f," of ",d.length]}),e.jsx("button",{type:"button",className:"hit ml-auto text-meta text-ui-accent hover:underline disabled:opacity-50",disabled:a,onClick:()=>c(d.map(h=>h.key),!w),children:w?"Untick all":"Tick all"})]}),e.jsx("ul",{className:"space-y-1.5",children:d.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 ks="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",Fe="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 We(t){return{prId:t.id,repoId:t.repoId,repoFullName:t.repoFullName,prNumber:t.number,prTitle:t.title,githubUrl:t.githubUrl}}function ys(t){const s=gt({mergeable:t.mergeable,mergeStateStatus:t.mergeStateStatus,isDraft:t.isDraft,inMergeQueue:t.inMergeQueue===!0}).verdict;return bt({state:t.state,verdict:s,viewerCanPush:t.viewerCanPush})}function Rs({pr:t}){const s=jt(t.id),n=Nt(),a=vt(s),i=t.baseRefName??"the base branch";p.useEffect(()=>{wt(t.id)},[t.id]);const l=We(t),o=(s==null?void 0:s.phase)==="succeeded"?s.resolution:null;return e.jsxs("div",{className:"mb-3 rounded-ui bg-ui-surface p-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-body font-medium text-ui-ink",children:[e.jsx(kt,{size:13,className:"text-ai-signal"}),"This branch conflicts with ",i]}),e.jsxs("p",{className:"mt-1 text-meta text-ui-mute",children:[n," reads the code and picks a result for each conflict. You check its choices in the resolver before anything is pushed."]}),a&&s!=null?e.jsxs("div",{className:"mt-2",children:[e.jsx(ie,{active:!0,label:`Resolving conflicts with ${n}`,timeConstantSec:60}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-meta text-ui-mute",children:[yt(s.phase,n),e.jsx("button",{type:"button",className:Fe,onClick:()=>Rt(t.id),children:"Cancel"})]})]}):e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx(q,{kind:"resolve",children:e.jsx("button",{type:"button",className:ks,onClick:()=>Le(l,{providerName:n}),children:o!=null?"Run again":`Resolve merge conflicts with ${n}`})}),o!=null&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:Fe,onClick:()=>Pt(l),children:"Open the resolver"}),e.jsxs("span",{className:"text-meta text-ui-mute",children:[z(o)," decided ",o.choices.length," of ",o.decidableTotal," change",o.decidableTotal===1?"":"s","."]})]}),(s==null?void 0:s.phase)==="failed"&&s.error!=null&&e.jsx("span",{className:"text-meta text-ui-danger",children:s.error}),(s==null?void 0:s.phase)==="cancelled"&&e.jsx("span",{className:"text-meta text-ui-mute",children:"Cancelled."})]})]})}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 se(t){return t instanceof Be||t instanceof Error?t.message:"Something went wrong"}const ee="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 Ps({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 $s({pr:t}){const s=Ue().enabled,n=O(c=>c.aiFixTabFocus),a=O(c=>c.consumeAiFixTabFocus),[i,l]=p.useState(null),[o,g]=p.useState(null);return p.useEffect(()=>{n&&n.prId===t.id&&(n.reviewId!=null&&l(n.reviewId),n.only!=null&&g(n.only),a())},[n,t.id,a]),s?e.jsx("div",{className:"pb-6",children:e.jsx(Cs,{pr:t,handoffReviewId:i,onlySection:o,onOnlySectionApplied:()=>g(null)})}):e.jsx(e.Fragment,{})}function Cs({pr:t,handoffReviewId:s,onlySection:n,onOnlySectionApplied:a}){var oe,ue,de,me,he,xe,pe,fe,ge,be;const{data:i,isLoading:l}=Ct(t.id,!0),{data:o,isLoading:g}=At(t.id),c=(o==null?void 0:o.review)??null,m=ls(s,c,(o==null?void 0:o.history)??[]),v=cs(s,m,c),F=O(A=>A.setPrDetailTab),u=Ft("fix",zt),k=Me(u.chosen.provider),M=It().data,C=Tt(t.id),B=St(t.id),E=Te(t.id),I=Ue(),y=Et(M,u.chosen.provider,"plan"),[D,R]=p.useState(!1),_=D&&y,L=O(A=>A.noteAiFixRun),P=Ie({mutationKey:_t(t.id)})>0,r=((oe=i==null?void 0:i.fix)==null?void 0:oe.status)??null,d=r==="planned",f=d&&((de=(ue=i==null?void 0:i.fix)==null?void 0:ue.plan)==null?void 0:de.status)==="planning",w=r==="running"||r==="queued"||P||f,{status:h}=Mt(t.id,w),j=(h==null?void 0:h.status)??r??"idle",H=j==="running"||j==="queued",T=H&&!d,b=d&&(f||H),S=d&&(((he=(me=i==null?void 0:i.fix)==null?void 0:me.plan)==null?void 0:he.status)==="planning"||((pe=(xe=i==null?void 0:i.fix)==null?void 0:xe.plan)==null?void 0:pe.status)==="plan_ready"),N=(i==null?void 0:i.fix)??null,x=Bt(t.id,m,(i==null?void 0:i.enabled)!==!1&&(m!=null||!g)),U=m==null&&x.data!=null&&x.data.sourceReviewId==null&&x.data.items.length>0,K=m!=null||U,qe=Lt(m!=null&&(c==null?void 0:c.id)!==m?m:null),Ge=m!=null&&(c==null?void 0:c.id)===m?c:qe.data??null,[Q,X]=p.useState({});p.useEffect(()=>X({}),[m]);const[Ve,Y]=p.useState(!1);p.useEffect(()=>{n==null||!x.data||(X(gs(x.data,n)),Y(!0),a())},[n,x.data,a]);const re=!S&&(Ve||!N||N.status!=="succeeded"),J=ys(t),[le,ze]=p.useState(!1),W=Ut(t.id,t.repoFullName),$=x.data?fs(x.data,Q):[],ce=x.data?He(x.data,Q).size:0,Qe=()=>{if(!K||!x.data||$.length===0)return;const A={model:u.chosen.model,provider:u.chosen.provider,seed:"review",...m!=null?{sourceReviewId:m}:{},include:$,...W.names.length>0?{checks:W.names}:{}};_?B.mutate(A,{onSuccess:()=>Y(!1)}):(L({prId:t.id,repoFullName:t.repoFullName,prNumber:t.number,prTitle:t.title}),C.mutate(A,{onSuccess:()=>Y(!1)})),le&&J&&Le(We(t),{model:Dt(u.chosen.model),providerName:I.providerName})};return e.jsxs("div",{children:[e.jsx(Ps,{info:e.jsxs(ne,{title:"AI Fix",children:[e.jsxs("p",{children:[k," reads the PR's code and edits files in a private copy. It has no shell. Tick Run tests to let it run the project's own test, lint and type checks in a sandbox."]}),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:["Tick Plan first to read ",k,"'s plan, steer it and approve it before anything changes."]}),e.jsxs("p",{children:[k," reports what it changed in each file and what it left alone, and why."]}),e.jsx("p",{children:"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:[J&&e.jsx(Rs,{pr:t}),(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:[!T&&!S&&!K&&!g&&!x.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:te,onClick:()=>F(t.id,"claude_review"),children:"Open AI Review"})]}),!T&&!S&&K&&!re&&e.jsx("button",{type:"button",className:ee,onClick:()=>Y(!0),children:"New fix"}),!T&&K&&re&&e.jsxs("div",{children:[v&&e.jsx("p",{className:"mb-2 text-meta text-ui-mute",children:v}),U&&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."}),x.isLoading&&e.jsx("p",{className:"text-meta text-ui-mute",children:"Loading…"}),x.isError&&m!=null&&e.jsx("p",{className:"text-meta text-ui-danger",children:se(x.error)}),x.data&&e.jsx(ws,{preview:x.data,overrides:Q,onChange:X,disabled:P,pr:t,review:Ge}),x.data&&x.data.items.length>0&&J&&e.jsxs("label",{className:"mt-3 flex cursor-pointer items-start gap-2 text-meta text-ui-ink",children:[e.jsx(G,{className:"mt-0.5",checked:le,disabled:P,onChange:A=>ze(A.target.checked)}),e.jsxs("span",{children:["Also resolve merge conflicts with ",t.baseRefName??"the base branch",e.jsx("span",{className:"block text-meta text-ui-mute",children:"You check the merge in the resolver. It lands as its own commit, apart from the fix."})]})]}),x.data&&x.data.items.length>0&&e.jsx($t,{state:W,disabled:P}),x.data&&x.data.items.length>0&&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(Ot,{state:u,onPick:u.pick,disabled:P}),y&&e.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5 text-meta text-ui-ink",children:[e.jsx(G,{checked:_,disabled:P,onChange:A=>R(A.target.checked)}),"Plan first"]}),e.jsx(q,{kind:"fix",auth:i==null?void 0:i.auth,anyProvider:!0,provider:u.chosen.provider,children:e.jsx("button",{type:"button",className:te,disabled:P||$.length===0||W.on&&W.query.isLoading,onClick:Qe,children:_?"Make a plan":"Start fix"})}),e.jsx("span",{className:"text-meta text-ui-mute",children:$.length===0?"Nothing ticked.":`${$.length-ce} item${$.length-ce===1?"":"s"}`}),(N==null?void 0:N.status)==="succeeded"&&e.jsx("button",{type:"button",className:ee,onClick:()=>Y(!1),children:"Close"})]})]}),T&&e.jsx("button",{type:"button",className:ee,onClick:()=>E.mutate(),children:"Cancel"}),(C.isError||B.isError)&&e.jsx("p",{className:"mt-1 text-meta text-ui-danger",children:se(C.error??B.error)}),N&&d&&e.jsx(rs,{pr:t,fix:N,liveStatus:h,passRunning:b,auth:i==null?void 0:i.auth}),T&&e.jsxs("div",{className:"mt-3",children:[N&&e.jsx(De,{fix:N}),e.jsx(ie,{active:!0,label:"Running AI fix",value:Ee(h),timeConstantSec:40}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-meta text-ui-mute",children:[(N==null?void 0:N.trigger)==="auto"&&e.jsx(Ke,{}),_e[((fe=h==null?void 0:h.progress)==null?void 0:fe.phase)??""]??"Working…"]}),((ge=h==null?void 0:h.progress)==null?void 0:ge.recentActivity)&&h.progress.recentActivity.length>0&&e.jsx("pre",{className:"mt-1 max-h-32 overflow-auto rounded-ui bg-ui-surface p-2 text-meta leading-relaxed text-ui-mute",children:h.progress.recentActivity.slice(-8).join(`
3
+ `)})]}),!T&&N&&!d&&e.jsx(Fs,{pr:t,fix:N,headInfo:(i==null?void 0:i.headInfo)??null,viewerCanPush:(i==null?void 0:i.viewerCanPush)??!1}),l&&!N&&e.jsx("p",{className:"mt-3 text-meta text-ui-mute",children:"Loading…"})]}),e.jsx(Ts,{history:(i==null?void 0:i.history)??[],currentFixId:((be=i==null?void 0:i.fix)==null?void 0:be.id)??null})]})]})}function Ke(){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 As(t){return Se(t.provider,t.model,t.effort)}function Fs({pr:t,fix:s,headInfo:n,viewerCanPush:a}){var o,g,c;const i=p.useMemo(()=>Ht(s.patch),[s.patch]);if(s.status==="failed"&&((o=s.plan)==null?void 0:o.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:[z(s.plan??s)," could not make a plan: ",s.error??"unknown error"]});if(s.status==="cancelled"&&((g=s.plan)==null?void 0:g.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:"The fix run was cancelled."});if(s.status!=="succeeded")return e.jsx(e.Fragment,{});const l=!s.patch||s.filesChanged.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(Ke,{})," "]}),ms(s)," · ",As(s),s.finishedAt&&e.jsxs(e.Fragment,{children:[" · ",ae(s.finishedAt)]})]}),s.pushedAt==null&&s.error&&e.jsx("p",{className:"mb-2 rounded-ui bg-ui-raise p-2 text-meta text-ui-warn",children:s.error}),e.jsx(De,{fix:s}),s.summary&&e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(Yt,{children:s.summary})}),e.jsx(hs,{pr:t,fix:s}),e.jsx(Wt,{checks:s.checks}),l?e.jsx("p",{className:"mt-2 text-meta text-ui-mute",children:"No files changed."}):e.jsxs(e.Fragment,{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:[s.filesChanged.length," file",s.filesChanged.length===1?"":"s"," changed",!((c=s.checks)!=null&&c.ran)&&" · Not built or tested here."]}),e.jsx(Kt,{})]}),e.jsx("div",{className:"overflow-hidden rounded-ui bg-ui-surface text-ui-ink",children:e.jsx(qt,{files:i})}),e.jsx(Ss,{pr:t,fix:s,headInfo:n,viewerCanPush:a})]})]})}function Is({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:$e(t.pushedPrUrl),target:"_blank",rel:"noreferrer",className:"hit underline",children:["PR #",t.pushedPrNumber]})]}),t.pushedAt&&e.jsxs(e.Fragment,{children:[" · ",ae(t.pushedAt)]})]}),t.commitMessage&&e.jsx("div",{className:"mt-1 font-mono text-meta text-ui-success",children:t.commitMessage})]})}function Ts({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:$e(a.pushedPrUrl),target:"_blank",rel:"noreferrer",className:"hit underline",children:["PR #",a.pushedPrNumber]})]}),a.pushedAt&&e.jsxs(e.Fragment,{children:[" · ",ae(a.pushedAt)]})]})]},a.id))})]})}function Ss({pr:t,fix:s,headInfo:n,viewerCanPush:a}){const i=Gt(t.id),l=(n==null?void 0:n.canPushSameBranch)??!1,[o,g]=p.useState(l?"existing":"new"),[c,m]=p.useState((n==null?void 0:n.suggestedBranch)??""),v=p.useRef(!1);if(p.useEffect(()=>{!v.current&&(n!=null&&n.suggestedBranch)&&(m(n.suggestedBranch),v.current=!0,n.canPushSameBranch||g("new"))},[n]),s.pushedAt!=null)return e.jsx(Is,{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."});const F=o==="new"&&c.trim().length===0,u=i.isPending,k=()=>{i.mutate({fixId:s.id,body:{target:o,branch:o==="new"?c.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(ve,{className:"mt-0",checked:o==="existing",disabled:!l||u,onChange:()=>g("existing")}),"Push to the PR branch",(n==null?void 0:n.headRef)&&e.jsxs("span",{className:"font-mono text-ui-faint",children:["(",n.headRef,")"]})]}),e.jsxs("label",{className:"mt-1 flex items-center gap-2 text-meta",children:[e.jsx(ve,{className:"mt-0",checked:o==="new",disabled:u,onChange:()=>g("new")}),"New branch + open a PR"]}),o==="new"&&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:c,disabled:u,onChange:M=>m(M.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:te,disabled:u||F,onClick:k,children:u?"Pushing…":o==="new"?"Push + open PR":"Push"}),e.jsx(Vt,{checks:s.checks})]}),i.isError&&e.jsx("div",{className:"mt-2 text-meta text-ui-danger",children:se(i.error)})]})}export{$s as AiFixTab};
@@ -0,0 +1,20 @@
1
+ import{j as e,r as f,d as Bt,k as Qs}from"./tanstack-BnbsafB1.js";import{bR as os,bD as et,b1 as tt,aY as st,aZ as nt,$ as cs,aS as us,c as ve,aU as We,aQ as Ve,bX as ds,aw as ms,cm as ct,bK as Xs,cb as Js,ca as Zs,aq as ee,ad as it,v as ye,T as te,ab as ue,bv as en,b_ as ae,aW as hs,be as tn,bd as sn,o as nn,aB as Ht,n as an,c9 as ln,aC as rn,B as on,O as Ie,ag as q,a8 as ne,cc as cn,F as un,cY as dn,h as mn,g as xs,e as le,a2 as hn,cB as xn,c8 as pn,c7 as fn,ae as ut,ci as de,cs as ps,d3 as gn,cu as bn,cv as jn,ct as vn,bb as Te,cF as fs,bc as yn,b7 as kn,am as dt,b9 as Nn,l as wn,ba as Cn,af as J,V as ce,b8 as Rn,ay as gs,i as ke,b6 as $n,ar as Pe,f as bs,k as Sn,q as Se,aL as mt,cT as In,cX as Pn,cP as En,av as ht,cU as _n,cJ as An,a5 as Tn,bP as Q,bQ as ze,D as Ln,c1 as Fn,aG as Ot,bJ as Mn,db as xt,d7 as Bn,d9 as Hn,da as On,d8 as Dn,cd as Un,bC as Gn,bh as Wn,bx as js,c6 as vs,U as Vn,aE as zn,aD as qn,H as Kn,bO as Yn,az as ys,cf as Qn,aF as Xn,aH as Jn,d6 as ks,z as Zn,bM as Ns,ce as ei,c5 as ti,b5 as si,cg as ni,dg as ii,y as ai,bw as li,cM as ri,aA as oi,G as ci,X as ui,_ as di,M as mi,a7 as hi,bi as xi,c3 as pi,bA as fi,cw as gi,c_ as bi,cH as ji,cz as vi,cq as yi,de as ki,dd as Ni,cQ as wi,cO as Ci,bm as Ri,cA as $i,d0 as ws,cx as Si,aT as Cs,a9 as Ii,ai as Pi,aj as je,ak as Ei,Z as _i,bj as Be,P as He,d as Ai,aX as Dt,bu as Ti,bH as Li,al as Rs,aM as Fi,a_ as Ut,W as $s,br as Mi,dj as Bi,bz as Hi,bL as Oi,c0 as Di,bT as Ui,aV as Gi,bq as Wi,b$ as Vi,cr as zi,cW as qi,bF as Ki,bW as Yi,Q as Ss,x as Qi,r as Xi,c4 as Ji,N as Zi,w as ea,an as ta,bl as sa,ac as at,au as Is,m as na,bn as ia,aa as Gt,b as Xe,bN as Wt,bS as aa,a$ as Vt,L as la,ax as ra,bV as oa,cy as ca,bY as ua,ap as da,bZ as ma,cR as ha,as as xa,a6 as pa,ch as fa,cZ as ga,df as ba,c$ as ja,b0 as va,di as ya,bG as ka,d2 as Na,aJ as wa,aI as Ca,aK as Ra,cI as $a,bt as zt,bs as Sa,by as Ia,dk as Ps,b3 as Pa,a1 as Ea,J as _a}from"./index-DWLpcq8D.js";const Aa="https://sonarcloud.io",Ta={blocker:"Blocker",critical:"Critical",major:"Major",minor:"Minor",info:"Info"},La={new_coverage:"Coverage on new code",coverage:"Coverage",new_line_coverage:"Line coverage on new code",line_coverage:"Line coverage",new_branch_coverage:"Branch coverage on new code",branch_coverage:"Branch coverage",new_uncovered_lines:"Uncovered new lines",uncovered_lines:"Uncovered lines",new_lines_to_cover:"New lines to cover",new_duplicated_lines_density:"Duplicated lines on new code",duplicated_lines_density:"Duplicated lines",new_duplicated_lines:"Duplicated new lines",duplicated_lines:"Duplicated lines",new_lines:"New lines",new_reliability_rating:"Reliability rating on new code",new_security_rating:"Security rating on new code",new_maintainability_rating:"Maintainability rating on new code",new_security_review_rating:"Security review rating on new code",new_security_hotspots_reviewed:"Security hotspots reviewed",new_violations:"Issues on new code",new_bugs:"Bugs on new code",new_vulnerabilities:"Vulnerabilities on new code",new_code_smells:"Code smells on new code"};function pt(t){return La[t]??t.replace(/^new_/,"").replace(/_/g," ").replace(/^./,s=>s.toUpperCase())}const Es=t=>/_rating$/.test(t),Fa=t=>/(coverage|density|hotspots_reviewed)$/.test(t);function lt(t,s){const n=Number(s);return Number.isFinite(n)?Es(t)?"ABCDE"[Math.round(n)-1]??s:Fa(t)?`${Math.round(n*10)/10}%`:String(n):s}function Ma(t){const s=pt(t.metric),n=t.actual!=null?lt(t.metric,t.actual):null,l=t.threshold!=null?lt(t.metric,t.threshold):null,r=n!=null?`${s} is ${n}.`:`${s} fails.`;if(l==null)return r;const o=Es(t.metric)?`${l} or better`:t.comparator==="LT"?`at least ${l}`:t.comparator==="GT"?`at most ${l}`:l;return`${r} The quality gate needs ${o}.`}function Ba(t){return((t==null?void 0:t.conditions)??[]).filter(s=>s.status==="ERROR"||s.status==="WARN")}const _s=t=>/coverage|uncovered_lines|lines_to_cover/.test(t),Ha=t=>/duplicat/.test(t);function Oa(t){return _s(t)||Ha(t)}function Da(t,s){return Ba(t).filter(n=>Oa(n.metric)).map(n=>{const l=_s(n.metric),r=n.files??[],o=r.length>0?`
2
+
3
+ Files with the most ${l?"uncovered":"duplicated"} new lines:
4
+ ${r.map(c=>`- ${c.path}: ${c.lines} ${c.lines===1?"line":"lines"}`).join(`
5
+ `)}`:"",a=l?`Write tests that run the new and changed lines SonarCloud reports as not covered, then let CI measure coverage again.${o}`:`Move the repeated new code into one shared function or module and call it from each place.${o}`;return{key:`gate:${n.metric}`,kind:"gate",rule:n.metric,ruleName:pt(n.metric),severity:n.status==="ERROR"?"critical":"major",type:"QUALITY_GATE",message:Ma(n),path:null,line:null,endLine:null,effort:null,tags:[],securityCategory:null,whyIsThisAnIssue:null,howToFix:a,code:[],url:s??Aa}})}const qe="Replies checked";function Ua(t){return t!=null&&t.live==null&&t.unjudged>0}function Ga(t){return t>1?`Check ${t} replies`:"Check replies"}function Wa(t){const s=[];return t.accepted>0&&s.push(`${t.accepted} accepted`),t.disputed>0&&s.push(`${t.disputed} still open`),t.notChecked>0&&s.push(`${t.notChecked} not checked`),s.length>0?`${s.join(", ")}.`:null}function Va(t,s="Claude"){if(t==null)return null;if(t.status==="failed"){const c=t.error!=null&&t.error.trim()!==""?t.error.trim():null;return c?`Replies check failed: ${c}`:"Replies check failed."}if(t.status!=="succeeded")return null;const n=t.finishedAt??t.createdAt,l=Wa(t),r=`${qe} ${os(n)}${l?`: ${l}`:"."}`,o=et(t),a=t.trigger==="auto"?tt(t.autoPost,s)??o??st(t.autoPost,s)??nt(t.autoPost):t.verdict==="APPROVE"?"Would approve.":t.verdict==="REQUEST_CHANGES"?"Would request changes.":o;return a?`${r} ${a}`:r}const rt=t=>t==="queued"||t==="running";function za(t){const{shown:s,latest:n,previousLatestId:l,history:r}=t;if(n==null)return s;if(l!=null&&n.id!==l&&n.trigger!=="auto")return n.id;const a=c=>c===n.id||r.some(i=>i.id===c);if(s!=null&&a(s))return s;if(n.trigger==="auto"&&rt(n.status)){const c=r.find(i=>i.id!==n.id&&!rt(i.status));if(c)return c.id}return n.id}const qa={queued:"Queued",running:"Running",succeeded:"Finished",failed:"Failed",cancelled:"Cancelled"};function qt(t){return qa[t]??t}const Kt=t=>t?t.slice(0,7):"—";function Ka(t){var s;return t.some(n=>rt(n.status))?t.every(n=>n.status==="queued")?"queued":"running":t.some(n=>n.status==="succeeded")?"succeeded":((s=t[0])==null?void 0:s.status)??"failed"}function As(t,s,n){const l=[],r=new Map;for(const a of t){if(a.pair==null)continue;const c=r.get(a.pair.pairId)??[];c.push(a),r.set(a.pair.pairId,c)}const o=new Set;for(const a of t){if(a.pair!=null){if(o.has(a.pair.pairId))continue;o.add(a.pair.pairId);const x=r.get(a.pair.pairId)??[a],d=x[0],u=Ka(x),m=[cs,Kt(d.headSha),n(d.finishedAt??d.createdAt)];u!=="succeeded"&&m.push(qt(u)),d.trigger==="auto"&&m.push(ve);const p=x.map(j=>j.id);l.push({id:d.id,runIds:p,label:m.join(" · ")+(s!=null&&p.includes(s)?" (latest)":"")});continue}const i=[a.kind==="replies"?qe:a.reviewMode==="skip"?"Skipped (nothing to review)":us(a.provider,a.model,a.effort),Kt(a.headSha),n(a.finishedAt??a.createdAt)];a.status!=="succeeded"&&i.push(qt(a.status)),a.trigger==="auto"&&i.push(ve),l.push({id:a.id,runIds:[a.id],label:i.join(" · ")+(a.id===s?" (latest)":"")})}return l}function Ts(t,s){var n;return s==null?null:((n=t.find(l=>l.runIds.includes(s)))==null?void 0:n.id)??s}function Re(t){return(t==null?void 0:t.pair)!=null?cs:We(t)}function Ya(t,s){var l,r;const n=(r=(l=t==null?void 0:t.pair)==null?void 0:l.halves)==null?void 0:r.find(o=>o.reviewId===s.reviewId);return n!=null?Ve(n.provider):We(t)}function Qa(t){return We(t)}function Xa({history:t,shownId:s,latestId:n,onShow:l}){const r=As(t,n,ds);if(r.length<2)return null;const o=Ts(r,s??n)??r[0].id;return e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 text-meta text-ui-mute",children:[e.jsx("span",{"aria-hidden":!0,children:"Showing"}),e.jsx(ms,{label:"Showing",value:String(o),onChange:a=>l(Number(a)),options:r.map(a=>({value:String(a.id),label:a.label})),className:"max-w-full"})]})}function Ja(t,s){return s&&t.postedAt==null&&t.earlierPost==null&&!t.included}function Ls(t,s){return t.filter(n=>n.severity!=="praise"&&!Ja(n,s))}const Za={blocker:"Blocker",warning:"Warning",nit:"Nit",question:"Question",praise:"Praise"};function el(t){const s=[`### ${Za[t.severity]}: ${t.title}`];t.path===""?s.push("Whole PR"):s.push(`\`${t.line!=null?`${t.path}:${t.line}`:t.path}\``);const n=t.editedBody!=null&&t.editedBody.trim()!==""?t.editedBody:t.body;return n.trim()!==""&&s.push(n.trim()),t.suggestion!=null&&t.suggestion.trim()!==""&&s.push(`\`\`\`suggestion
6
+ ${t.suggestion}
7
+ \`\`\``),s.join(`
8
+
9
+ `)}function tl(t,s){return Ls(t,s).map(el).join(`
10
+
11
+ ---
12
+
13
+ `)}function sl(t,s){return t<=0?null:t>=s?"Copy all":`Copy ${t}`}const $e=ue,X="text-ui-mute";function Yt({t,muted:s,onOpenThread:n,actions:l=!0,selection:r=null,notCheckedNote:o,by:a}){const[c,i]=f.useState(!1),[x,d]=f.useState(!1),u=f.useId(),m=en(t),p=ae(t.url),j=hs(t.path,t.line),k=f.useRef(null),[b,g]=f.useState(!1);f.useLayoutEffect(()=>{const $=k.current;$!=null&&!c&&g($.scrollHeight>$.clientHeight+1)},[t.excerpt,c]);const I=t.validity!=="not_checked"||t.addressed!=="not_checked",P=tn(t.validity),h=sn(t.addressed,t.resolved===!0),L=t.reason!=null&&t.reason.trim()!==""?t.reason.trim():null,N=t.explanation!=null&&t.explanation!==""?t.explanation:null,[E,w]=f.useState(!1);return e.jsxs("li",{className:"rounded-ui bg-ui-surface px-3 py-2.5 text-body ",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r,P!=null&&e.jsx("span",{className:`${$e} ${Ht[t.validity]}`,children:nn[P]}),I&&h!=null&&e.jsx("span",{className:`${$e} ${t.resolved===!0?"bg-ui-raise text-ui-success":ln(t)}`,children:an[h]}),!I&&e.jsx("span",{className:`${$e} ${Ht.not_checked}`,children:rn.not_checked}),t.authorLogin!=null&&e.jsxs("span",{className:s?"text-ui-mute":"font-medium",children:["@",t.authorLogin]}),t.authorIsBot&&e.jsxs("span",{className:`${$e} gap-1 bg-ui-raise text-ui-mute`,children:[e.jsx(on,{size:12}),"Bot"]}),t.carried&&e.jsxs("span",{className:`text-meta ${X}`,children:["Unchanged since ",e.jsx("span",{className:"font-mono",children:t.assessedAtHead.slice(0,7)})]}),p!=null&&e.jsxs("a",{href:p,target:"_blank",rel:"noreferrer noopener",className:"hit ml-auto inline-flex items-center gap-1 text-meta text-ui-ink hover:underline",children:["GitHub",e.jsx(Ie,{size:11})]})]}),e.jsxs("div",{className:"mt-0.5",children:[n!=null?e.jsx("button",{type:"button",onClick:()=>n(t.threadId),className:"hit break-all text-left font-mono text-meta text-ui-ink hover:underline",children:j}):e.jsx("span",{className:`break-all font-mono text-meta ${X}`,children:j}),t.commentCount>1&&e.jsxs("span",{className:`ml-2 text-meta ${X}`,children:[t.commentCount," comments"]})]}),t.excerpt!==""&&e.jsxs("div",{className:"mt-1",children:[e.jsx("p",{ref:k,className:`${q} ${c?"":"line-clamp-3"}`,children:e.jsx(ne,{text:t.excerpt})}),(b||c)&&e.jsx("button",{type:"button",onClick:()=>i($=>!$),"aria-expanded":c,className:`text-meta ${X} hover:text-ui-ink`,children:c?"Less":"More"})]}),L!=null?e.jsxs("div",{className:"mt-1",children:[e.jsx("p",{className:q,children:e.jsx(ne,{text:L})}),N!=null&&N!==L&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>w($=>!$),"aria-expanded":E,className:`text-meta ${X} hover:text-ui-ink`,children:E?"Less":"More"}),E&&e.jsx("p",{className:`mt-0.5 ${q}`,children:e.jsx(ne,{text:N})})]})]}):N!=null?e.jsx("p",{className:`mt-1 ${q}`,children:e.jsx(ne,{text:N})}):I?null:e.jsx("p",{className:`mt-1 text-meta ${X}`,children:o??cn(t,a)}),t.draftReply!=null&&t.draftReply!==""&&e.jsxs("div",{className:"mt-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("button",{type:"button",onClick:()=>d($=>!$),"aria-expanded":x,"aria-controls":u,className:`inline-flex items-center gap-1 text-meta ${X} hover:text-ui-ink`,children:[e.jsx(ye,{dir:x?"down":"right",size:11}),"Suggested reply"]}),l&&e.jsx(un,{text:t.draftReply,what:"suggested reply"})]}),x&&e.jsx("p",{id:u,className:`mt-0.5 rounded-ui bg-ui-raise px-2 py-1 ${q}`,children:t.draftReply})]})]})}function nl({items:t,counts:s,onOpenThread:n,actions:l,by:r}){const[o,a]=f.useState(!1),c=ct(),i=r??c,x=f.useMemo(()=>Xs(t??[]),[t]);if(t==null)return null;const d=Js(s??Zs(t));return e.jsx(ee,{title:"Review threads",section:"threads",actions:l,pills:d.map(u=>e.jsx("span",{className:`${$e} ${u.cls}`,children:u.label},u.key)),info:e.jsxs(te,{title:"Review threads",children:[e.jsxs("p",{children:["Comments from people and other review bots. ",i," checks each one against the code: does the comment hold up, and where does the code stand. Each carries a one-line reason; More opens the longer one."]}),e.jsx("p",{className:"mt-2",children:"“Generate fix from this review” includes the ones still to fix."})]}),children:t.length===0?e.jsx("p",{className:`text-meta ${X}`,children:"No other review threads."}):e.jsxs(e.Fragment,{children:[x.shown.length>0&&e.jsx("ul",{className:it,children:x.shown.map(u=>e.jsx(Yt,{t:u,muted:!1,onOpenThread:n,by:r},u.threadId))}),x.more.length>0&&e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>a(u=>!u),"aria-expanded":o,className:`inline-flex items-center gap-1 text-meta ${X} hover:text-ui-ink`,children:[e.jsx(ye,{dir:o?"down":"right",size:11}),o?"Show fewer":`Show ${x.more.length} more`]}),o&&e.jsx("ul",{className:`mt-1.5 ${it}`,children:x.more.map(u=>e.jsx(Yt,{t:u,muted:!0,onOpenThread:n,by:r},u.threadId))})]})]})})}const il={nothing_to_check:"Every reply already has a judgement.",review_in_progress:"A review is running. It checks the replies itself.",no_review:"There is no review to follow up yet."};function al({prId:t,state:s,onShow:n}){const{start:l,cancel:r}=dn(t),o=ct();if(s==null)return null;const a=s.latest,c=Va(a,o),i=Ua(s);if(s.live==null&&!i&&c==null)return null;const x=l.data,d=(x==null?void 0:x.outcome)==="refused"?il[x.reason]:null,u=l.error instanceof mn?l.error.message:l.error?"The check could not start.":null;return e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-meta",children:[s.live!=null?e.jsx(xs,{stage:s.live==="queued"?"Waiting for a free slot":"Checking replies",since:(a==null?void 0:a.createdAt)??null,children:e.jsx("button",{type:"button",onClick:()=>r.mutate(),disabled:r.isPending,className:"hit rounded-ui px-1 text-meta text-ui-mute underline decoration-dotted underline-offset-2 hover:text-ui-ink disabled:opacity-50",children:"Cancel"})}):e.jsxs(e.Fragment,{children:[c!=null&&e.jsx("span",{className:"text-ui-ink",children:c}),c!=null&&a!=null&&a.status==="succeeded"&&e.jsx("button",{type:"button",onClick:()=>n(a.reviewId),className:"hit rounded-ui px-1 text-meta text-ui-mute underline decoration-dotted underline-offset-2 hover:text-ui-ink",children:"Show"}),i&&e.jsx(le,{kind:"thread_check",children:e.jsxs("button",{type:"button",onClick:()=>l.mutate(),disabled:l.isPending,className:"hit inline-flex items-center gap-1 rounded-ui border border-ai-border bg-ai-surface-2 px-2 py-0.5 text-meta font-medium text-ai-ink hover:bg-ai-surface disabled:opacity-50",children:[e.jsx(hn,{size:12,className:"text-ai-signal"}),l.isPending?"Starting…":Ga(s.unjudged)]})})]}),e.jsxs(te,{title:"Replies to the review",children:[e.jsxs("p",{children:["When someone replies to one of the review’s comments on GitHub, ",o," can check just the replies, without a new commit or a full review."]}),e.jsx("p",{children:"It accepts a reply that holds up (the comment then counts as settled) or pushes back once. A pass you start here posts nothing: use Post reply on each one."}),e.jsx("p",{children:"With auto review on, it runs by itself a few minutes after the replies stop. With auto-posting on, it posts the replies, and may approve or request changes when the replies change the outcome."})]}),d!=null&&e.jsx("span",{className:"text-ui-mute",children:d}),u!=null&&e.jsx("span",{className:"text-ui-danger",children:u})]})}function ll({prId:t,data:s}){var d,u;const n=xn(t),[l,r]=f.useState(!1),o=pn(s==null?void 0:s.teamClaimSkip),a=((d=s==null?void 0:s.review)==null?void 0:d.trigger)==="auto"?fn(s.review.teamClaim):null,c=(s==null?void 0:s.teamClaimPending)??null;if(o==null&&a==null&&c==null)return null;const i=c!=null&&c.mine&&o==null?"Your auto review didn’t finish. Limn releases its pending GitHub line on its own.":null,x=n.data&&!n.data.ok?n.data.message??"Couldn’t clear it.":null;return e.jsxs("div",{className:"mt-2 space-y-1 text-meta text-ui-mute",children:[o!=null&&e.jsx("div",{children:o}),o==null&&a!=null&&i==null&&e.jsx("div",{children:a}),i!=null&&e.jsx("div",{children:i}),c!=null&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[l&&!c.mine?e.jsxs(e.Fragment,{children:[e.jsxs("span",{children:["@",c.login," is reviewing this now. Clear anyway?"]}),e.jsx("button",{type:"button",onClick:()=>{r(!1),n.mutate(c.provider)},disabled:n.isPending,className:"hit bg-ui-raise rounded-ui px-2 py-0.5 text-meta hover:bg-ui-hover disabled:opacity-50",children:"Clear anyway"}),e.jsx("button",{type:"button",onClick:()=>r(!1),className:"hit bg-ui-raise rounded-ui px-2 py-0.5 text-meta hover:bg-ui-hover",children:"Cancel"})]}):e.jsx("button",{type:"button",onClick:()=>c.mine?n.mutate(c.provider):r(!0),disabled:n.isPending,title:`Replace the pending ${Ve(c.provider)} line with “Cleared by you”, so any Limn can review this commit.`,className:"hit bg-ui-raise rounded-ui px-2 py-0.5 text-meta hover:bg-ui-hover disabled:opacity-50",children:n.isPending?"Clearing…":"Clear"}),(x!=null||n.isError)&&e.jsx("span",{className:"text-ui-danger",children:x??((u=n.error)==null?void 0:u.message)??"Couldn’t clear it."})]})]})}const Fs="bg-ui-danger/10 text-ui-danger",Qt="bg-ui-raise text-ui-warn",De="bg-ui-raise text-ui-mute",rl={code:"Code",test:"Test",flaky_or_infra:"Flaky or infra",config:"Config",unclear:"Unclear"},Xt={code:Fs,test:Qt,config:Qt,flaky_or_infra:De,unclear:De},ol=t=>t.status==="diagnosed"&&t.fixableInPr===!0;function Jt(t){const s=n=>ol(n)?0:n.status==="diagnosed"?1:2;return t.map((n,l)=>({f:n,i:l})).sort((n,l)=>s(n.f)-s(l.f)||n.i-l.i).map(n=>n.f)}function cl(t){let s=0,n=0,l=0;for(const o of t)o.status!=="diagnosed"?l+=1:o.fixableInPr===!0?s+=1:n+=1;return[{key:"fixable",label:`${s} fixable here`,cls:Fs,n:s},{key:"notFixable",label:`${n} not from this change`,cls:De,n},{key:"notChecked",label:`${l} not checked`,cls:De,n:l}].filter(o=>o.n>0).map(({key:o,label:a,cls:c})=>({key:o,label:a,cls:c}))}function ul(t,s="Claude"){switch(t){case"no_log":return"No log available: this check does not run on GitHub Actions.";case"log_unavailable":return"Its log couldn't be read.";case"over_cap":return`Not sent to ${s}: too many failing checks.`;case"not_reported":return`${s} didn't report on this one.`;default:return"Not checked."}}function dl(t){return`${t} failing ${t===1?"check":"checks"}`}const Zt=ue,oe="text-ui-mute";function ml({path:t,line:s,changedPaths:n,onOpenInChanges:l}){const r=hs(t,s);return l!=null&&n.has(t)?e.jsx("button",{type:"button",onClick:()=>l(t,s,"RIGHT"),className:"hit break-all text-left font-mono text-meta text-ui-ink hover:underline",children:r}):e.jsx("span",{className:`break-all font-mono text-meta ${oe}`,children:r})}function es({f:t,suggestion:s=null,changedPaths:n,onOpenInChanges:l,selection:r=null,by:o}){const[a,c]=f.useState(!1),i=f.useId(),x=ae(t.url),d=t.status==="diagnosed",u=d&&t.fixableInPr===!0;return e.jsxs("li",{className:"rounded-ui border px-3 py-2 text-body border-ui-line",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r,d&&t.category!=null?e.jsx("span",{className:`${Zt} ${Xt[t.category]}`,children:rl[t.category]}):e.jsx("span",{className:`${Zt} ${Xt.unclear}`,children:"Not checked"}),e.jsx("span",{className:`break-all ${ut}`,children:t.checkName}),d&&typeof t.confidence=="number"&&e.jsxs("span",{className:`text-meta ${oe}`,children:["Confidence ",t.confidence,"%"]}),t.step!=null&&e.jsxs("span",{className:`break-all text-meta ${oe}`,children:["Step: ",t.step]}),d&&t.fixableInPr===!1&&e.jsx("span",{className:`text-meta ${oe}`,children:"Not from this change"}),t.carried&&e.jsxs("span",{className:`text-meta ${oe}`,children:["Unchanged since ",e.jsx("span",{className:"font-mono",children:t.assessedAtHead.slice(0,7)})]}),x!=null&&e.jsxs("a",{href:x,target:"_blank",rel:"noreferrer noopener",className:"hit ml-auto inline-flex items-center gap-1 text-meta text-ui-ink hover:underline",children:["Details",e.jsx(Ie,{size:11})]})]}),d?e.jsxs(e.Fragment,{children:[t.cause!=null&&e.jsx("p",{className:`mt-1 ${q}`,children:e.jsx(ne,{text:t.cause})}),s!=null&&s!==""&&e.jsxs("p",{className:`mt-1 ${q}`,children:[e.jsx("span",{className:"font-medium",children:"Fix: "}),e.jsx(ne,{text:s})]}),t.explanation!=null&&t.explanation!==""&&e.jsxs("div",{className:"mt-0.5",children:[e.jsxs("button",{type:"button",onClick:()=>c(m=>!m),"aria-expanded":a,"aria-controls":i,className:`inline-flex items-center gap-1 text-meta ${oe} hover:text-ui-ink`,children:[e.jsx(ye,{dir:a?"down":"right",size:11}),"Why"]}),a&&e.jsx("p",{id:i,className:`mt-0.5 ${q}`,children:e.jsx(ne,{text:t.explanation})})]}),t.relatedFiles.length>0&&e.jsx("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5",children:t.relatedFiles.map(m=>e.jsx(ml,{path:m.path,line:m.line,changedPaths:n,onOpenInChanges:l},`${m.path}:${m.line??""}`))})]}):e.jsx("p",{className:`mt-1 text-meta ${oe}`,children:ul(t.notCheckedReason,o)})]})}const Le="text-ui-mute",Fe="text-ui-danger",hl="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",xl="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 pl({currency:t}){return e.jsxs("span",{className:`${ue} ${Sn[t.tone]}`,title:t.title,children:[t.tone==="current"?e.jsx(Se,{size:11}):t.tone==="stale"?e.jsx(mt,{size:11}):e.jsx("span",{"aria-hidden":!0,className:"h-1.5 w-1.5 animate-pulse rounded-full bg-ui-accent-fill"}),t.label]})}function ts({pr:t,legacy:s=null,changedPaths:n,onOpenInChanges:l}){var D,U;const r=de(),{data:o,isLoading:a,isError:c}=ps(t.id,r.enabled),i=gn(t.id),x=bn(t.id),d=(o==null?void 0:o.state)??null,u=(o==null?void 0:o.review)??null,m=(d==null?void 0:d.status)==="running",p=jn((d==null?void 0:d.runningRunId)??null,m),j=(u==null?void 0:u.status)==="succeeded"?u:null,{data:k}=vn(j==null&&(d==null?void 0:d.latestRunId)!=null&&Te(d.headSha,t.headSha)?d.latestRunId:null),b=j??((k==null?void 0:k.status)==="succeeded"?k:null),g=b!=null&&Te(b.headSha,t.headSha)?b:null,I=s!=null&&Te(s.headSha,t.headSha)?s.ciFailures:null,P=f.useMemo(()=>Jt((g==null?void 0:g.items)??[]),[g]),h=f.useMemo(()=>Jt(I??[]),[I]),L=fs(_=>_.openAiFixForCi);if(!r.enabled||a)return null;const N=m?null:(d==null?void 0:d.refused)??null,E=!m&&(u==null?void 0:u.status)==="failed"&&u.refused==null&&Te(u.headSha,t.headSha)?u.error??"The check failed.":null,w=c?"offer":yn({hasCurrentRun:g!=null||N!=null||E!=null,running:m,legacyFailures:I,prCiStatus:t.ciStatus});if(w==="hidden")return null;const $=d!=null&&(g!=null||m)?kn(d):null,M=w==="legacy"?h:P,B=cl(M);return e.jsxs(ee,{title:"CI check",section:"ci",pills:e.jsxs(e.Fragment,{children:[$!=null&&e.jsx(pl,{currency:$}),g!=null&&e.jsx(Pe,{at:g.completedAt}),g!=null&&e.jsx(bs,{provider:g.provider,model:g.model}),(g==null?void 0:g.trigger)==="auto"&&e.jsx("span",{className:"rounded-ui bg-ui-raise px-1.5 py-0.5 text-meta text-ui-mute",children:ve}),M.length>0&&e.jsx("span",{className:`text-meta ${Le}`,children:dl(M.length)}),B.map(_=>e.jsx("span",{className:`${ue} ${_.cls}`,children:_.label},_.key))]}),info:e.jsxs(te,{title:"CI check",children:[e.jsxs("p",{children:[r.providerName," reads each failing GitHub Actions job’s log, picks out the error lines, reads the code, and says why it failed, how sure it is, and whether this PR can fix it."]}),e.jsx("p",{className:"mt-2",children:"Checks outside GitHub Actions have no log to read, so they are listed only."}),e.jsx("p",{className:"mt-2",children:"When auto review is on, a check that fails is looked at on its own."}),e.jsxs("p",{className:"mt-2",children:["When auto-posting is on, the causes ",r.providerName," is more than 50% sure of are posted to the PR as one comment, once for each set of failing checks."]})]}),actions:m?null:e.jsx(le,{kind:"ci_review",children:e.jsx("button",{type:"button",disabled:x,onClick:()=>i.mutate(),className:(d==null?void 0:d.status)==="stale"?xl:hl,children:$n(g!=null,x)})}),children:[e.jsx("div",{className:"empty:hidden",children:e.jsx(dt,{active:m,label:"Checking CI",value:Nn(p.progress),timeConstantSec:30})}),m&&e.jsxs("p",{className:`text-meta ${Le}`,children:[p.progress!=null?wn[p.progress.phase]:"Starting","…"]}),i.isError&&e.jsx("p",{className:`text-meta ${Fe}`,children:i.error.message||"Could not start the check."}),c&&e.jsx("p",{className:`text-meta ${Fe}`,children:"Could not load the CI check."}),N!=null&&e.jsx("p",{className:`text-meta ${Le}`,children:Cn(N)}),E!=null&&e.jsx("p",{className:`text-meta ${Fe}`,children:E}),w==="legacy"&&e.jsx("p",{className:J,children:"From an earlier AI review of this commit."}),w==="ci"&&(g==null?void 0:g.summary)!=null&&g.summary!==""&&e.jsx(ce,{prRefs:!0,children:g.summary}),w==="ci"&&((D=g==null?void 0:g.autoPost)==null?void 0:D.status)==="posted"&&e.jsx("p",{className:J,children:"Posted to the PR automatically."}),w==="ci"&&((U=g==null?void 0:g.autoPost)==null?void 0:U.status)==="failed"&&e.jsxs("p",{className:`text-meta ${Fe}`,children:["Couldn’t post automatically",g.autoPost.error?`: ${g.autoPost.error}`:"."]}),M.length>0&&e.jsx("ul",{className:"space-y-1.5",children:w==="legacy"?h.map(_=>e.jsx(es,{f:_,changedPaths:n,onOpenInChanges:l},`${_.checkName}:${_.jobId??""}`)):P.map(_=>e.jsx(es,{f:_,suggestion:_.suggestion,changedPaths:n,onOpenInChanges:l,by:We(g)},_.id))}),w==="ci"&&g!=null&&!m&&Rn(P)>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>L(t.id),className:"inline-flex h-7 items-center gap-1.5 whitespace-nowrap rounded-ui bg-ui-raise px-2.5 text-meta font-medium text-ui-ink hover:bg-ui-hover touch:h-10 touch:px-3",children:[e.jsx(gs,{size:12,className:"text-ai-signal"}),"Fix with AI",e.jsx(ke,{dir:"right",size:11})]}),e.jsx(te,{title:"Fix the failing CI",children:e.jsxs("p",{children:["Opens AI Fix with the failures this PR can fix ticked. ",r.providerName," edits the code in a private copy. Nothing changes until you press Start fix, and nothing is pushed until you press Push."]})})]}),w!=="legacy"&&g==null&&!m&&N==null&&E==null&&e.jsx("p",{className:`text-meta ${Le}`,children:"Not checked yet."})]})}const Ce="text-ui-mute",ot={blocker:"bg-ui-danger/10 text-ui-danger",critical:"bg-ui-danger/10 text-ui-danger",major:"bg-ui-raise text-ui-warn",minor:"bg-ui-raise text-ui-warn",info:"bg-ui-raise text-ui-mute"},fl={BUG:"Bug",VULNERABILITY:"Vulnerability",CODE_SMELL:"Code smell",SECURITY_HOTSPOT:"Security hotspot",QUALITY_GATE:"Quality gate"},gl="inline-flex h-7 items-center whitespace-nowrap rounded-ui bg-ui-raise px-2 text-meta text-ui-ink hover:bg-ui-hover disabled:cursor-not-allowed disabled:opacity-40 touch:h-10 touch:px-3";function bl(t){return t.path?t.line==null?t.path:t.endLine!=null&&t.endLine!==t.line?`${t.path}:${t.line}-${t.endLine}`:`${t.path}:${t.line}`:null}function jl({issue:t,changedPaths:s,onOpenInChanges:n,selection:l=null}){const[r,o]=f.useState(!1),a=f.useId(),c=ae(t.url),i=bl(t),x=t.type?fl[t.type]??t.type:null,d=t.howToFix??t.whyIsThisAnIssue;return e.jsxs("li",{className:"rounded-ui border border-ui-line px-3 py-2 text-body",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[l,e.jsx("span",{className:`${ue} ${ot[t.severity]}`,children:Ta[t.severity]}),x!=null&&e.jsx("span",{className:`text-meta ${Ce}`,children:x}),e.jsx("span",{className:`break-all text-meta ${Ce}`,children:t.ruleName??t.rule}),t.effort!=null&&e.jsxs("span",{className:`text-meta ${Ce}`,children:[t.effort," to fix"]}),c!=null&&e.jsxs("a",{href:c,target:"_blank",rel:"noreferrer noopener",className:"hit ml-auto inline-flex items-center gap-1 text-meta text-ui-ink hover:underline",children:["SonarCloud",e.jsx(Ie,{size:11})]})]}),e.jsx("p",{className:`mt-1 ${ut} ${q}`,children:t.message}),i!=null&&(n!=null&&t.path!=null&&(s!=null&&s.has(t.path))?e.jsx("button",{type:"button",onClick:()=>n(t.path,t.line,"RIGHT"),className:"hit mt-0.5 break-all text-left font-mono text-meta text-ui-ink hover:underline",children:i}):e.jsx("div",{className:`mt-0.5 break-all font-mono text-meta ${Ce}`,children:i})),t.code.length>0&&e.jsx("pre",{className:"mt-1 overflow-x-auto rounded-ui bg-ui-surface px-2 py-1 font-mono text-meta leading-snug",children:t.code.map(u=>e.jsxs("div",{className:u.flagged?"bg-ui-raise text-ui-ink":"text-ui-mute",children:[e.jsx("span",{className:"mr-2 inline-block w-8 select-none text-right text-ui-mute",children:u.line}),u.code]},u.line))}),d!=null&&e.jsxs("div",{className:"mt-1",children:[e.jsxs("button",{type:"button",onClick:()=>o(u=>!u),"aria-expanded":r,"aria-controls":a,className:`inline-flex items-center gap-1 text-meta ${Ce} hover:text-ui-ink`,children:[e.jsx(ye,{dir:r?"down":"right",size:11}),t.howToFix!=null?"How to fix":"Why it matters"]}),r&&e.jsx("p",{id:a,className:`mt-0.5 ${q}`,children:d})]})]})}function vl(t){const s=t.qualityGate;if(!s||s.status==="NONE")return null;const n=s.status==="OK"?"bg-ui-raise text-ui-success":s.status==="WARN"?ot.major:ot.blocker,l=s.status==="OK"?"Quality gate passed":s.status==="WARN"?"Quality gate warning":"Quality gate failed";return e.jsx("span",{className:`${ue} ${n}`,children:l})}function ss(t){var n;const s=((n=t.qualityGate)==null?void 0:n.measures)??[];return s.length===0?null:`New code: ${s.map(l=>`${pt(l.metric).replace(/ on new code$/,"")} ${lt(l.metric,l.value)}`).join(" · ")}`}function yl(t){const s=t.totalIssues+t.totalHotspots;return t.issues.length<s?`${t.issues.length} of ${s} issues`:`${s} ${s===1?"issue":"issues"}`}function kl(t,s){const n=t.post;if(!n)return null;if(n.status==="posting")return"Posting to GitHub…";if(n.status==="failed")return`Posting failed: ${n.error??"GitHub refused it."}`;const l=n.trigger==="auto"?"Posted automatically":"Posted",r=s===!1?" It’ll show up here shortly.":"";if(n.inline!=null){const a=[];return n.inline.length>0&&a.push(`${n.inline.length} on the changed lines`),a.push(`${n.summaryCount??0} in the summary${n.truncated?" (the rest did not fit)":""}`),(n.alreadyCount??0)>0&&a.push(`${n.alreadyCount} already there from an earlier commit`),`${l} to GitHub: ${a.join(", ")}.${r}`}const o=n.truncated?` (${n.issueCount} issues fitted in one comment)`:"";return`${l} to GitHub${o}.${r}`}function Nl({prId:t,headSha:s,canPost:n,changedPaths:l,onOpenInChanges:r}){var b,g;const o=In(t,s),a=Pn(t,s),c=En(t,s),i=Bt({mutationKey:["pr-sonar-post",t,s??"head"]})>0,x=Bt({mutationKey:["pr-sonar-refresh",t,s??"head"]})>0,d=o.data,u=(d==null?void 0:d.snapshot)??null;if(!d||!d.configured&&u==null)return null;const m=n&&u!=null&&u.state==="ok"&&u.post==null&&(u.issues.length>0||((b=u.qualityGate)==null?void 0:b.status)==="ERROR"),p=((g=c.data)==null?void 0:g.visible)??null,j=u?kl(u,p):null,k=(u==null?void 0:u.state)==="ok"?Da(u.qualityGate,u.dashboardUrl):[];return e.jsxs(ee,{title:"SonarCloud",section:"sonar",pills:(u==null?void 0:u.state)==="ok"?e.jsxs(e.Fragment,{children:[vl(u),e.jsx(ht,{children:yl(u)})]}):void 0,info:e.jsx(te,{title:"SonarCloud",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{children:"Limn reads this commit’s SonarCloud analysis: open issues, security hotspots to review, the quality gate with the files behind a coverage or duplication shortfall, and each rule’s advice on how to fix it."}),e.jsx("p",{children:"Only an analysis of this exact commit is used. Until SonarCloud has analysed it, nothing shows."}),e.jsx("p",{children:"The 50 most severe are kept. AI Review sees them as evidence and AI Fix can take them on."}),e.jsx("p",{children:"“Post SonarCloud findings” adds one review to the PR, once per commit: a comment on each issue that sits on a changed line, and a summary with everything else. An issue already commented on for an earlier commit is only named in the summary."})]})}),actions:e.jsxs(e.Fragment,{children:[(u==null?void 0:u.dashboardUrl)!=null&&ae(u.dashboardUrl)!=null&&e.jsxs("a",{href:ae(u.dashboardUrl),target:"_blank",rel:"noreferrer noopener",className:"hit inline-flex items-center gap-1 text-meta text-ui-ink hover:underline",children:["Open in SonarCloud",e.jsx(Ie,{size:11})]}),d.configured&&e.jsx("button",{type:"button",className:gl,disabled:x,onClick:()=>a.mutate(),children:x?"Reading…":"Refresh"}),m&&e.jsx("button",{type:"button",className:"hit rounded-ui bg-ui-accent-fill disabled:bg-ui-raise disabled:text-ui-ink px-2 py-0.5 text-meta font-medium text-ui-on-accent hover:bg-ui-accent-fill disabled:cursor-not-allowed disabled:opacity-50",disabled:i,onClick:()=>c.mutate(),children:i?"Posting…":"Post SonarCloud findings"})]}),children:[u==null?e.jsx("p",{className:J,children:"Not read for this commit yet."}):u.state!=="ok"?e.jsx("p",{className:J,children:u.message??"SonarCloud could not be read."}):e.jsxs(e.Fragment,{children:[ss(u)!=null&&e.jsx("p",{className:J,children:ss(u)}),k.length+u.issues.length===0?e.jsx("p",{className:J,children:"No open issues on this commit."}):e.jsx("ul",{className:"space-y-2",children:[...k,...u.issues].map(I=>e.jsx(jl,{issue:I,changedPaths:l,onOpenInChanges:r},I.key))})]}),j!=null&&e.jsx("p",{className:J,children:j}),a.isError&&e.jsx("p",{className:"text-meta text-ui-danger",children:a.error.message}),c.isError&&e.jsx("p",{className:"text-meta text-ui-danger",children:c.error.message})]})}function ns(t,s,n,l){const r=t??(s==null?void 0:s.prId)??null;if(r!=null)return r===n?"this":"other";const o=(s==null?void 0:s.repoId)??null;return o!=null?o===l?"this":"other":"none"}function wl(t,s,n){var d,u;const l=new Map(s.map(m=>[m.ref,m])),r=new Map(t.missing.map(m=>[m.ref,m])),o=[];let a=0,c=0;for(const m of t.criteria){if(m.deliveredBy.includes(n.id)){o.push(m);continue}if(m.status==="met"){a+=1;continue}ns((d=l.get(m.ref))==null?void 0:d.ownerPrId,m.expectedIn,n.id,n.repoId)==="other"?c+=1:o.push(m)}const i=[];for(const m of s){if(m.status!=="missing")continue;ns(m.ownerPrId,(u=r.get(m.ref))==null?void 0:u.expectedIn,n.id,n.repoId)==="other"?c+=1:i.push(m)}const x=t.notRequested.filter(m=>m.prId===n.id);return{criteria:o,missing:i,notRequested:x,metElsewhere:a,todoElsewhere:c}}function Cl(t,s){if(t==null||t.length===0)return[];const n=new Set([...s.criteria.map(l=>l.ref),...s.missing.map(l=>l.ref)].map(l=>l.toLowerCase()));return n.size===0?[]:t.filter(l=>(l.about??"").toLowerCase().split(/[^a-z0-9]+/).some(r=>r!==""&&n.has(r)))}function Rl(t,s){var n;return((n=t.find(l=>l.prId===s))==null?void 0:n.card)??null}function $l(t){const s=[],n=t.metElsewhere,l=t.todoElsewhere;return n>0&&s.push(n===1?"1 more criterion is met by another PR.":`${n} more criteria are met by other PRs.`),l>0&&s.push(l===1?"1 more is still to do in another PR.":`${l} more are still to do in other PRs.`),s.length>0?s.join(" "):null}function Sl(t){return!t.trackerOn||t.ident.startsWith("manual:")||t.ticketKey==null||t.ticketKey.trim()===""?!1:t.prOpen||t.members.some(s=>s.state==="open")}const Ue="text-ui-mute",Ge="text-ui-danger",Il="inline-flex h-7 items-center whitespace-nowrap rounded-ui bg-ui-raise px-2 text-meta text-ui-ink hover:bg-ui-hover disabled:opacity-50 touch:h-10 touch:px-3",Pl="inline-flex h-7 items-center whitespace-nowrap rounded-ui bg-ui-raise px-2 text-meta text-ui-ink hover:bg-ui-hover disabled:opacity-50 touch:h-10 touch:px-3",is="text-meta text-ui-ink hover:underline disabled:opacity-50",Ms="inline-block h-3 w-3 shrink-0 animate-spin rounded-full border-2 border-ui-line border-t-ui-line",Bs=new Set(["found","linked","already"]),El=t=>t.result!=null&&Bs.has(t.result.status);function _l(t){if(Mn(t).kind==="invalid")return{ref:t,status:"invalid",key:null,ident:null,title:null,url:null,message:"Not a ticket link or key."}}function Al({prId:t,startOpen:s,manualShown:n,onInputManually:l}){var _;const r=f.useId(),o=f.useRef(null),[a,c]=f.useState(s),[i,x]=f.useState(""),[d,u]=f.useState([]),m=f.useRef(d),p=v=>{m.current=v,u(v)},[j,k]=f.useState(null),b=_n(t),g=An(t),I=f.useRef(!0);f.useEffect(()=>(I.current=!0,()=>{I.current=!1}),[]);const P=v=>{const C=new Map(v.map(R=>[Q(R.ref),R]));p(m.current.map(R=>{const H=C.get(Q(R.ref));return H!=null?{...R,result:H}:R}))},h=v=>{const C=new Set(m.current.map(F=>Q(F.ref))),R=Fn(v).filter(F=>!C.has(Q(F)));if(R.length===0)return;const H=Ot-m.current.length,G=R.slice(0,Math.max(0,H));if(k(R.length>G.length?`Up to ${Ot} tickets at a time.`:null),G.length===0)return;const z=G.map(F=>({ref:F,result:_l(F)}));p([...m.current,...z]);const T=z.filter(F=>F.result==null).map(F=>F.ref);T.length!==0&&b.mutate(T,{onSuccess:F=>{I.current&&P(F)},onError:F=>{if(!I.current)return;const O=F.message||"Could not read the tickets.";P(T.map(S=>({ref:S,status:"failed",key:null,ident:null,title:null,url:null,message:O})))}})},L=()=>{i.trim()!==""&&(h(i),x(""))},N=v=>{v.key==="Enter"||v.key===","?(v.preventDefault(),L()):v.key==="Backspace"&&i===""&&m.current.length>0&&p(m.current.slice(0,-1))},E=v=>{const C=v.clipboardData.getData("text");/[\s,;]/.test(C.trim())&&(v.preventDefault(),h(`${i} ${C}`),x(""))},w=v=>{var C;p(m.current.filter((R,H)=>H!==v)),(C=o.current)==null||C.focus()},$=d.filter(El),M=d.some(v=>v.result==null),B=$.length,D=(((_=g.data)==null?void 0:_.runs)??[]).filter(v=>v.refused!=null&&v.ticketReviewId==null),U=()=>{const v=$.map(C=>C.ref);g.mutate(v,{onSuccess:({results:C,startFailed:R})=>{if(!I.current)return;const H=T=>T.ident!=null?R[T.ident]:void 0,G=new Set(C.filter(T=>(T.status==="linked"||T.status==="already")&&H(T)==null).map(T=>Q(T.ref))),z=new Map(C.map(T=>[Q(T.ref),T]));p(m.current.filter(T=>!G.has(Q(T.ref))).map(T=>{const F=z.get(Q(T.ref)),O=F!=null?H(F):void 0;return{...T,result:F??T.result,startError:O}}))}})};return a?e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsx("label",{htmlFor:r,className:"block text-meta font-medium text-ui-ink",children:"Add tickets"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 rounded-ui border border-ui-line px-2 py-1.5 focus-within:border-ui-accent/50",children:[d.length>0&&e.jsx("ul",{className:"contents","aria-label":"Tickets to add",children:d.map((v,C)=>e.jsx(Tl,{chip:v,onRemove:()=>w(C)},Q(v.ref)))}),e.jsx("input",{id:r,ref:o,type:"text",value:i,onChange:v=>x(v.target.value),onKeyDown:N,onPaste:E,onBlur:L,disabled:g.isPending,placeholder:d.length===0?"Paste ticket links or keys, like PROJ-123":"Add another",className:"min-w-[12rem] flex-1 bg-transparent py-0.5 text-meta text-ui-ink outline-none placeholder:text-ui-mute"})]}),j!=null&&e.jsx("p",{className:`text-meta ${Ue}`,children:j}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[B>0&&e.jsx(le,{kind:"ticket_review",children:e.jsx("button",{type:"button",disabled:M||g.isPending,onClick:U,className:Pl,children:g.isPending?"Starting…":B===1?"Check this ticket":`Check ${B} tickets`})}),M&&e.jsxs("span",{role:"status",className:`inline-flex items-center gap-1.5 text-meta ${Ue}`,children:[e.jsx("span",{className:Ms,"aria-hidden":"true"}),"Reading…"]}),!n&&e.jsx("button",{type:"button",onClick:l,className:Il,children:"Input manually"}),g.isError&&e.jsx("span",{className:`text-meta ${Ge}`,children:g.error.message||"Could not start the check."})]}),D.map(v=>e.jsx("p",{className:`text-meta ${Ge}`,children:ze(v.refused)},v.ident))]}):e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>{c(!0),requestAnimationFrame(()=>{var v;return(v=o.current)==null?void 0:v.focus()})},className:`inline-flex items-center gap-1 ${is}`,children:[e.jsx(Tn,{size:11}),"Add ticket"]}),!n&&e.jsx("button",{type:"button",onClick:l,className:is,children:"Input manually"})]})}function Tl({chip:t,onRemove:s}){const n=t.result,l=n!=null&&Bs.has(n.status),r=(n==null?void 0:n.key)??t.ref,o=l?ae(n.url):void 0;return e.jsxs("li",{className:`inline-flex max-w-full items-start gap-1 rounded-full border px-2 py-0.5 text-meta ${n==null||l?"border-ui-line text-ui-ink":"border-ui-danger/40 text-ui-ink"}`,children:[e.jsx("span",{className:"mt-px shrink-0","aria-hidden":"true",children:n==null?e.jsx("span",{className:Ms}):l?e.jsx(Se,{size:12,className:"text-ui-success"}):e.jsx(mt,{size:12,className:"text-ui-danger"})}),e.jsxs("span",{className:"min-w-0 break-words",children:[o!=null?e.jsx("a",{href:o,target:"_blank",rel:"noreferrer noopener",className:"hit font-mono hover:underline",children:r}):e.jsx("span",{className:"font-mono",children:r}),n==null&&e.jsx("span",{className:Ue,children:" reading…"}),l&&n.title!=null&&n.title!==""&&e.jsxs("span",{children:[" ",n.title]}),(n==null?void 0:n.status)==="already"&&e.jsx("span",{className:Ue,children:" (already on this PR)"}),n!=null&&!l&&n.message!=null&&e.jsxs("span",{className:Ge,children:[" ",n.message]}),t.startError!=null&&e.jsxs("span",{className:Ge,children:[" Added, but the check did not start: ",t.startError]})]}),e.jsx("button",{type:"button",onClick:s,"aria-label":`Remove ${r}`,className:"hit mt-px shrink-0 rounded-full p-0.5 text-ui-mute hover:bg-ui-hover hover:text-ui-ink",children:e.jsx(Ln,{size:10})})]})}const Ll=ue,Z="text-ui-mute",ie="text-ui-danger",Hs="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",Os="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",as=xi();function Fl({review:t,pr:s,ident:n,ticketKey:l,ticketTitle:r,changedPaths:o,onOpenInChanges:a}){const c=t.assessment,i=f.useMemo(()=>c!=null?wl(c,t.items,{id:s.id,repoId:s.repoId}):null,[c,t.items,s.id,s.repoId]),x=f.useMemo(()=>li(t.items),[t.items]),d=Rl(t.members,s.id),u=ri();if(i==null)return e.jsx("p",{className:`text-meta ${Z}`,children:"No result stored."});const m={review:t,viewedPrId:s.id,changedPaths:o,onOpenInChanges:a},p=$l(i),j=i.criteria.length===0&&i.missing.length===0&&i.notRequested.length===0;return e.jsxs("div",{className:"space-y-3",children:[j&&e.jsx("p",{className:`text-meta ${Z}`,children:"No criteria are this PR’s."}),e.jsx(oi,{review:t,viewedPrId:s.id,onlyThisPr:!0}),i.criteria.length>0&&e.jsx("ul",{className:"space-y-1.5",children:i.criteria.map(k=>e.jsx(ci,{c:k,item:x.get(k.ref),...m},k.ref))}),e.jsx(ui,{items:i.missing,...m}),e.jsx(di,{items:i.notRequested,...m}),e.jsx(mi,{references:Cl(c==null?void 0:c.references,i)}),d!=null&&e.jsx(hi,{card:d}),e.jsxs("p",{className:`text-meta ${Z}`,children:[p!=null&&e.jsxs(e.Fragment,{children:[p," "]}),e.jsx("button",{type:"button",onClick:()=>u({ident:n,key:l,title:r}),className:"hit text-ui-ink hover:underline text-link-phone",children:"See the whole ticket"})]})]})}function Ml({entry:t,pr:s,changedPaths:n,onOpenInChanges:l}){var B,D;const{ident:r,state:o,review:a}=t,c=Bn(r),i=Hn(r),x=o.status==="running",d=On(o.runningRunId,x),u=(a==null?void 0:a.status)==="succeeded"?a:null,{data:m}=Dn(u==null&&o.latestRunId!=null?o.latestRunId:null),p=u??((m==null?void 0:m.status)==="succeeded"?m:null),j=(p==null?void 0:p.members)??(a==null?void 0:a.members)??[],b=Un(o,U=>{const _=j.find(v=>v.prId===U);return _!=null?fi(_):null}),g=Gn(o),I=Wn(o.counts),h=((D=(B=c.data)==null?void 0:B.runs.find(U=>U.ident===r))==null?void 0:D.refused)??null??((a==null?void 0:a.status)==="failed"?a.refused:null),L=(a==null?void 0:a.status)==="failed"&&a.refused==null?a.error??"The check failed.":null,N=t.ticketTitle??(a==null?void 0:a.ticketTitle)??null,E=(p==null?void 0:p.ticket)??(a==null?void 0:a.ticket)??null,w=js(s.tickets,t.ticketKey),$=vs(w,[E]),M=Sl({ident:r,ticketKey:t.ticketKey,trackerOn:s.tickets!=null,prOpen:s.state==="open",members:j});return e.jsxs("div",{"aria-label":`Ticket ${t.ticketKey??N??""}`,className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsxs("h4",{className:"flex min-w-0 flex-wrap items-baseline gap-x-2",children:[t.ticketKey!=null&&($!=null?e.jsx(Vn,{ticketKey:t.ticketKey,url:$}):e.jsx("span",{className:"font-mono text-body font-semibold text-ui-ink",children:t.ticketKey})),N!=null&&N!==""&&e.jsx("span",{className:"min-w-0 break-words text-body font-semibold text-ui-ink",children:N})]}),o.alignment!=null&&e.jsx("span",{className:`${Ll} ${qn[o.alignment]}`,children:zn[o.alignment]}),!M&&I!=null&&e.jsx("span",{className:`text-meta ${Z}`,children:I}),b!=null&&e.jsx(Kn,{currency:b}),g!=null&&e.jsx("span",{className:`text-meta ${Z}`,title:g.title,"data-testid":"ticket-new-comments",children:g.label}),p!=null&&e.jsx(Pe,{at:p.completedAt}),p!=null&&e.jsx(bs,{provider:p.provider,model:p.model}),e.jsx("span",{className:"ml-auto",children:!x&&e.jsx(le,{kind:"ticket_review",children:e.jsx("button",{type:"button",disabled:i,onClick:()=>c.mutate(Yn(s.id,r,p??a)),className:o.status==="stale"?Os:Hs,children:i?"Starting…":p==null?"Check":"Re-check"})})})]}),e.jsx(ys,{prId:s.id,jiraRef:w,stored:[E],url:$}),e.jsx("div",{className:"empty:hidden",children:e.jsx(dt,{active:x,label:"Checking the story",value:Qn(d.progress),timeConstantSec:30})}),x&&e.jsxs("p",{className:`text-meta ${Z}`,children:[d.progress!=null?Xn[d.progress.phase]:"Starting","…"]}),c.isError&&e.jsx("p",{className:`text-meta ${ie}`,children:c.error.message||"Could not start the check."}),h!=null&&e.jsx("p",{className:`text-meta ${ie}`,children:ze(h)}),L!=null&&e.jsx("p",{className:`text-meta ${ie}`,children:L}),p!=null?M&&t.ticketKey!=null?e.jsx(Fl,{review:p,pr:s,ident:r,ticketKey:t.ticketKey,ticketTitle:N,changedPaths:n,onOpenInChanges:l}):e.jsx(Jn,{review:p,viewedPrId:s.id,changedPaths:n,onOpenInChanges:l}):!x&&h==null&&L==null&&e.jsx("p",{className:`text-meta ${Z}`,children:"Not checked yet."})]})}function Bl({entry:t,legacy:s,pr:n,known:l,changedPaths:r,onOpenInChanges:o}){var m;const a=ks(n.id),{ticket:c}=t,i=js(n.tickets,c.key),x=vs(i,[c]),d=c.title!=null&&c.title.trim()!=="",u=(((m=a.data)==null?void 0:m.runs)??[]).filter(p=>p.refused!=null&&p.ticketReviewId==null);return e.jsx(Zn,{entry:t,label:c.key??(d?null:ti(c,t.index)),findingIds:s.findingIds,findingsById:s.findingsById,renderFinding:s.renderFinding,changedPaths:r,onOpenInChanges:o,aside:e.jsxs("span",{className:"ml-auto inline-flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:`text-meta ${Z}`,children:"Checked on this PR only"}),e.jsx(Pe,{at:s.finishedAt}),e.jsx(le,{kind:"ticket_review",children:e.jsx("button",{type:"button",disabled:a.isPending,onClick:()=>a.mutate(Ns([ei(c)],l)),className:Hs,children:a.isPending?"Starting…":"Check"})}),a.isError&&e.jsx("span",{className:`text-meta ${ie}`,children:a.error.message||"Could not start the check."}),u.map(p=>e.jsx("span",{className:`text-meta ${ie}`,children:ze(p.refused)},p.ident))]}),below:e.jsx(ys,{prId:n.id,jiraRef:i,stored:[c],url:x})})}function Hl({pr:t,entries:s}){var I,P;const[n,l]=f.useState(()=>as.get(t.id)??[]),r=h=>{as.set(t.id,h),l(h)},o=f.useMemo(()=>si(n),[n]),a=f.useMemo(()=>Ns(ni(o)??[],s),[o,s]),c=a.idents.length+a.pasted.length,i=ks(t.id),{data:x}=ii(),d=((I=x==null?void 0:x.find(h=>h.repoIds.includes(t.repoId)))==null?void 0:I.name)??null,u=(((P=i.data)==null?void 0:P.runs)??[]).filter(h=>h.refused!=null&&h.ticketReviewId==null),m=f.useMemo(()=>{const h=new Set(s.map(L=>{var N;return(N=L.ticketKey)==null?void 0:N.trim().toUpperCase()}).filter(Boolean));return(t.tickets??[]).filter(L=>!h.has(L.key.trim().toUpperCase()))},[s,t.tickets]),[p,j]=f.useState(!1),k=t.ticketsAddable??t.tickets!=null,b=!k||p||n.length>0,g=()=>{r(pi(n)),j(!0)};return e.jsxs("div",{children:[k&&e.jsx(Al,{prId:t.id,startOpen:s.length===0,manualShown:b,onInputManually:g},t.id),b&&e.jsx(ai,{autoPullReady:!1,value:n,onChange:r,check:o,prId:t.id,tickets:m,prWorkspaceName:d,defaultOpen:p,onClose:()=>j(!1)},t.id),c>0&&e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx(le,{kind:"ticket_review",children:e.jsx("button",{type:"button",disabled:!o.ok||i.isPending,onClick:()=>i.mutate(a),className:Os,children:i.isPending?"Starting…":c===1?"Check this story":`Check ${c} stories`})}),i.isError&&e.jsx("span",{className:`text-meta ${ie}`,children:i.error.message||"Could not start the check."})]}),u.map(h=>e.jsx("p",{className:`mt-1 text-meta ${ie}`,children:ze(h.refused)},h.ident))]})}function ls({pr:t,changedPaths:s,onOpenInChanges:n,legacy:l=null}){const r=de(),{data:o,isLoading:a,isError:c}=xt(t.id,r.enabled);if(!r.enabled)return null;const i=(o==null?void 0:o.tickets)??[],x=(l==null?void 0:l.entries)??[],d=i.length+x.length;return e.jsxs(ee,{title:"Story check",section:"stories",pills:d>0?e.jsx(ht,{children:`${d} ${d===1?"ticket":"tickets"}`}):null,info:e.jsxs(te,{title:"Story check",children:[e.jsxs("p",{children:[r.providerName," checks each ticket’s acceptance criteria against every open or merged PR that names it, together. A criterion done in another PR counts as met."]}),e.jsx("p",{className:"mt-2",children:"When auto review is on, a ticket is checked again on its own once one of its PRs is pushed, joins or leaves. Nothing is posted until you press Post: the gaps that belong on a PR go to it as one comment."}),e.jsx("p",{className:"mt-2",children:"A story marked “Checked on this PR only” was judged by an earlier PR review against this PR alone. Its unmet items are that review’s findings. Check runs the ticket check."})]}),children:[a&&e.jsx("p",{className:`text-meta ${Z}`,children:"Loading…"}),c&&e.jsx("p",{className:`text-meta ${ie}`,children:"Could not load the story checks."}),d>0&&e.jsxs("div",{className:"divide-y divide-ui-line",children:[i.map(u=>e.jsx("div",{className:"py-4 first:pt-0 last:pb-0",children:e.jsx(Ml,{entry:u,pr:t,changedPaths:s,onOpenInChanges:n})},u.ident)),l!=null&&x.map(u=>e.jsx("div",{className:"py-4 first:pt-0 last:pb-0",children:e.jsx(Bl,{entry:u,legacy:l,pr:t,known:i,changedPaths:s,onOpenInChanges:n})},`legacy-${u.index}`))]}),e.jsx(Hl,{pr:t,entries:i},t.id)]})}const Ol=t=>t?t.slice(0,7):"—",ft={skip:"Skipped",diff_only:"Quick",worktree:"Deep"},Ds={COMMENT:"Comment",REQUEST_CHANGES:"Request changes",APPROVE:"Approve"};function gt({verdict:t}){return e.jsxs("span",{className:`${wa} ${Ca[t]}`,children:[e.jsx(Ra,{verdict:t,size:13}),Ds[t]]})}const Dl=["blocker","warning","nit","question"],Ul={pass:"Claude and Codex each reviewed this commit. A quick pass merged the two: findings making the same point were kept once, and the verdict was worked out from what is left.",code:"Claude and Codex each reviewed this commit. Their findings are listed together and their summaries joined.",single:"Only one of the two reviews finished, so this is that review."};function rs(t,s){var o;const n=[Ol(t.headSha)],l=(o=t.pair)==null?void 0:o.halves;if(l!=null&&l.length>0){n.push(ka(l));for(const a of l){const c=s(a.costUsd,a.provider);c!=null&&n.push(`${Ve(a.provider)} ${c}`)}return n.join(" · ")}t.reviewMode!=="skip"&&n.push(us(t.provider,t.model,t.effort));const r=s(t.costUsd,Cs(t.provider,t.model));return r!=null&&n.push(r),n.join(" · ")}function Us(t,s){var n,l;return oa({reviewedHeadSha:t.headSha,currentHeadSha:((n=t.head)==null?void 0:n.currentHeadSha)??s,commitsSince:((l=t.head)==null?void 0:l.commitsSince)??null})}function Gs({currency:t}){return e.jsxs("span",{className:"inline-flex items-center gap-1 py-0.5 text-meta font-medium text-ui-mute",title:t.title,children:[t.tone==="current"?e.jsx(Se,{size:12,className:"text-ui-faint"}):e.jsx(mt,{size:12,className:"text-ui-warn"}),t.label,t.tone==="current"&&e.jsxs("span",{className:"font-mono",children:["· ",t.sha]})]})}const Gl={cloning:"Cloning the worktree",fetching_diff:"Fetching the diff",deciding:"Deciding scope",reviewing:"Reviewing",persisting:"Saving findings",merging:"Merging the two reviews…"};function Wl(t){var n,l,r;if(t==null)return null;if(t.status==="queued")return 5;const s=(n=t.progress)==null?void 0:n.phase;if(s==null)return 8;switch(s){case"fetching_diff":return 15;case"deciding":return 28;case"cloning":return 42;case"reviewing":{const o=((r=(l=t.progress)==null?void 0:l.recentActivity)==null?void 0:r.length)??0;return Math.min(90,55+o*3)}case"persisting":return 95;default:return null}}function Oe(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function Vl({review:t}){const{inputTokens:s,outputTokens:n,cacheReadTokens:l,cacheCreationTokens:r}=t;if((s??0)+(n??0)+(l??0)+(r??0)<=0)return null;const a=[];return n!=null&&a.push({key:"out",icon:e.jsx(ke,{dir:"down",size:11}),label:"out",value:n,title:"Output tokens generated (billed at the output rate — the priciest per token)"}),s!=null&&a.push({key:"in",icon:e.jsx(ke,{dir:"up",size:11}),label:"in",value:s,title:"New (uncached) input tokens"}),l!=null&&a.push({key:"cr",icon:e.jsx(Rs,{size:11}),label:"cache read",value:l,title:"Cached input tokens re-read each turn — billed at ~10% of the input rate, but the volume driver of a multi-turn run"}),r!=null&&a.push({key:"cw",icon:e.jsx(Ea,{size:11}),label:"cache write",value:r,title:"Tokens written to the prompt cache (billed at ~1.25× the input rate)"}),e.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-0.5 font-mono text-meta text-ui-mute",children:a.map(c=>e.jsxs("span",{title:c.title,className:"inline-flex items-center gap-1",children:[c.icon,e.jsxs("span",{children:[c.label," ",Oe(c.value)]})]},c.key))})}function zl({lines:t}){const s=f.useRef(null);return f.useEffect(()=>{const n=s.current;n!=null&&(n.scrollTop=n.scrollHeight)},[t]),t.length===0?null:e.jsx("div",{ref:s,className:"mt-2 max-h-32 overflow-y-auto rounded-ui bg-ui-surface px-2 py-1.5 font-mono text-meta leading-snug text-ui-mute",children:t.map((n,l)=>e.jsx("div",{className:"whitespace-pre-wrap break-words",children:n===""?" ":n},l))})}function Je(t,s=!1){return t.startsWith("@@")?"font-medium text-ui-mute":t.startsWith("+")?s?"":"text-ui-success":t.startsWith("-")?s?"":"text-ui-danger":"text-ui-mute"}const Me="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",se="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 ql({preview:t}){const s=ya(t.body),n=(l,r)=>`${l} ${r}${l===1?"":"s"}`;return e.jsxs("div",{className:"space-y-2 rounded-ui bg-ui-surface px-3 py-2 text-body",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(gt,{verdict:t.event}),e.jsxs("span",{className:J,children:[n(t.comments.length,"inline comment"),t.prComments.length>0?` · ${n(t.prComments.length,"PR comment")}`:""]})]}),s!==""?e.jsx(ce,{children:s}):e.jsx("p",{className:J,children:"No summary."}),t.comments.length>0&&e.jsx("ul",{className:"space-y-2",children:t.comments.map((l,r)=>e.jsxs("li",{className:`${at} bg-ui-surface`,children:[e.jsxs("div",{className:"mb-1 break-all font-mono text-meta text-ui-mute",children:[l.path,":",l.line]}),e.jsx(ce,{children:l.body})]},`${l.path}:${l.line}:${r}`))}),t.prComments.length>0&&e.jsx("ul",{className:"space-y-2",children:t.prComments.map(l=>e.jsxs("li",{className:`${at} bg-ui-surface`,children:[e.jsxs("div",{className:"mb-1 text-meta text-ui-mute",children:["PR comment",l.path!==""?e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"break-all font-mono",children:l.path})]}):null]}),e.jsx(ce,{children:l.body})]},l.findingId))})]})}function Kl({findings:t,editable:s}){const[n,l]=f.useState(null),r=f.useRef(null);f.useEffect(()=>()=>{r.current!=null&&clearTimeout(r.current)},[]);const o=Ls(t,s).length,a=sl(o,t.length);if(a==null)return null;const c=()=>{Ps(tl(t,s)).then(i=>{i&&(l(o),r.current!=null&&clearTimeout(r.current),r.current=setTimeout(()=>l(null),1500))})};return e.jsx("button",{type:"button",onClick:c,className:se,children:n!=null?`Copied ${n}`:a})}function Yl({hunk:t,path:s}){var u;const[n,l]=f.useState(!1),r=$a(t,s),o=t.replace(/\n$/,"").split(`
14
+ `),a=o.findIndex(m=>m.startsWith("@@")),c=a>=0?a:o.length-1,i=o[c]??"",x=(r==null?void 0:r[c])??null,d=((u=o[0])==null?void 0:u.startsWith("@@"))===!0;return n?e.jsxs("div",{className:"mt-1 rounded-ui bg-ui-surface",children:[e.jsx("pre",{className:"overflow-x-auto px-2 py-1.5 font-mono text-meta leading-snug",children:o.map((m,p)=>p===0&&d?e.jsx("button",{type:"button",onClick:()=>{var j;((j=window.getSelection())==null?void 0:j.isCollapsed)!==!1&&l(!1)},"aria-expanded":!0,"aria-label":"Hide code",title:"Hide code",className:`block w-full whitespace-pre text-left hover:bg-ui-hover ${Je(m)}`,children:m===""?" ":m},p):e.jsx("div",{className:Je(m,(r==null?void 0:r[p])!=null),children:(r==null?void 0:r[p])!=null?e.jsxs(e.Fragment,{children:[zt(m),e.jsx("span",{className:"code-hl",dangerouslySetInnerHTML:{__html:r[p]}})]}):m===""?" ":m},p))}),e.jsxs("button",{type:"button",onClick:()=>l(!1),"aria-expanded":!0,className:"hit inline-flex items-center gap-1 px-2 pb-1.5 text-meta text-ui-faint hover:text-ui-mute",children:[e.jsx(ye,{dir:"up",size:11}),"Hide code"]})]}):e.jsxs("button",{type:"button",onClick:()=>l(!0),"aria-expanded":!1,title:"Show the code hunk",className:"hit mt-1 flex w-full items-center gap-2 overflow-hidden rounded-ui bg-ui-surface px-2 py-1.5 text-left font-mono text-meta",children:[e.jsx(ye,{dir:"right",className:"shrink-0 text-ui-faint"}),e.jsx("span",{className:`min-w-0 flex-1 truncate ${Je(i,x!=null)}`,children:x!=null?e.jsxs(e.Fragment,{children:[zt(i),e.jsx("span",{className:"code-hl",dangerouslySetInnerHTML:{__html:x}})]}):i===""?" ":i}),o.length>1&&e.jsxs("span",{className:"shrink-0 font-sans text-meta text-ui-mute",children:[o.length," lines"]})]})}function Ql({suggestion:t,path:s}){const n=f.useMemo(()=>s==null||s===""?null:Sa(t,Ia(s)),[t,s]);return e.jsx("pre",{className:"mt-1 overflow-x-auto rounded-ui bg-ui-raise px-2 py-1.5 font-mono text-meta",children:n!=null?e.jsx("code",{className:"code-hl",dangerouslySetInnerHTML:{__html:n}}):e.jsx("code",{children:t})})}function Ws({prId:t,finding:s,editable:n,prUrl:l,repoFullName:r,headSha:o,posting:a,postError:c,inChangeset:i,priorStatus:x,alreadyPosted:d=!1,storyLabel:u=null,onOpenInChanges:m,onToggle:p,onReword:j,onPostComment:k,onPostReminder:b,actions:g=!0,selection:I=null,docReferences:P=null,authorName:h="Claude"}){var be;const[L,N]=f.useState(!1),E=f.useRef(null);f.useEffect(()=>()=>{E.current!=null&&clearTimeout(E.current)},[]);const[w,$]=f.useState(!1),[M,B]=f.useState(s.editedBody??"");f.useEffect(()=>{w||B(s.editedBody??"")},[s.editedBody,w]);const D=s.editedBody!=null&&s.editedBody.trim()!=="",U=w&&M.trim()!==""&&M!==(s.editedBody??"")?M:null,_=s.line!=null?`${s.path}:${s.line}`:s.path,v=s.path==="",C=sa(s),R=C!=null,H=(C==null?void 0:C.githubCommentId)!=null?C.postedCommentKind==="pr_comment"?`${l}#issuecomment-${C.githubCommentId}`:`${l}#discussion_r${C.githubCommentId}`:null,G=s.line!=null?`${l}/files#diff-${s.diffAnchorId}${s.side==="LEFT"?"L":"R"}${s.line}`:`${l}/files#diff-${s.diffAnchorId}`,z=o!=null&&s.line!=null&&s.side==="RIGHT"?`https://github.com/${r}/blob/${o}/${s.path.split("/").map(encodeURIComponent).join("/")}#L${s.line}`:null,T=i&&m!=null,F=H??G,O=H==null?z:null,S=n&&!R,K=Pa(C,n),y=s.reminder!=null?s.reminder.postedCommentKind==="pr_comment"?`${l}#issuecomment-${s.reminder.githubCommentId}`:`${l}#discussion_r${s.reminder.githubCommentId}`:null,Ee=()=>{let re=s.body.trim()!==""?`**${s.title}**
15
+
16
+ ${s.body}`:`**${s.title}**`;s.suggestion!=null&&s.suggestion.trim()!==""&&(re+=`
17
+
18
+ \`\`\`suggestion
19
+ ${s.suggestion}
20
+ \`\`\``),Ps(re).then(Qe=>{Qe&&(N(!0),E.current!=null&&clearTimeout(E.current),E.current=setTimeout(()=>N(!1),1500))})},Ke=()=>{j==null||j(M).catch(()=>{}),$(!1)},me=()=>{j==null||j("").catch(()=>{}),B(""),$(!1)},[he,xe]=f.useState(!1),Ye=async()=>{xe(!0);try{await(b==null?void 0:b())}catch{}finally{xe(!1)}},pe=async()=>{xe(!0);try{U!=null&&(await(j==null?void 0:j(U)),$(!1)),await(k==null?void 0:k())}catch{}finally{xe(!1)}},fe=a||he,_e=!s.anchored&&!s.fileInDiff,Ae=n&&!R,V=Ae&&!s.included,[Y,ge]=f.useState(!1),Ne=V&&!Y;return e.jsxs("li",{id:`claude-finding-${s.id}`,className:`${at} ${V?"opacity-50":""}`,children:[e.jsxs("div",{className:"flex items-start gap-2",children:[I,e.jsx("span",{className:`mt-0.5 inline-flex shrink-0 items-center rounded-ui px-1.5 py-0.5 text-meta font-semibold capitalize ${Is[s.severity]}`,children:s.severity}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:ut,children:e.jsx(ne,{text:s.title})}),s.lens!=null&&e.jsx("span",{className:"rounded-ui bg-ui-raise px-1.5 py-0.5 text-meta text-ui-mute",children:na[s.lens]}),s.source!=null&&e.jsx("span",{className:"rounded-ui bg-ui-raise px-1.5 py-0.5 text-meta text-ui-mute","data-finding-source":s.source,children:ia(s.source)}),u!=null&&e.jsx("span",{className:"rounded-ui bg-ui-sel px-1.5 py-0.5 text-meta text-ui-accent",children:u}),x!=null&&e.jsx("span",{className:`rounded-ui px-1.5 py-0.5 text-meta font-medium ${Gt[x].cls}`,title:"Raised in the previous review",children:Gt[x].label}),d&&!R&&e.jsx("span",{className:`rounded-ui px-1.5 py-0.5 text-meta font-medium ${Xe.cls}`,title:Xe.title,children:Xe.label}),R&&(H!=null?e.jsxs("a",{href:ae(H),target:"_blank",rel:"noreferrer noopener",className:"hit inline-flex items-center gap-1 rounded-ui bg-ui-raise px-1.5 py-0.5 text-meta text-ui-success hover:underline",title:"View this comment on GitHub",children:[Wt(C),e.jsx(Se,{size:11})]}):e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-ui bg-ui-raise px-1.5 py-0.5 text-meta text-ui-success",children:[Wt(C),e.jsx(Se,{size:11})]})),y!=null&&e.jsx("a",{href:ae(y),target:"_blank",rel:"noreferrer noopener",className:"hit inline-flex items-center gap-1 rounded-ui bg-ui-raise px-1.5 py-0.5 text-meta text-ui-success hover:underline",title:"View the reminder on GitHub",children:aa(s.reminder)}),Vt(s.autoResolve)!=null&&e.jsx("span",{className:`rounded-ui px-1.5 py-0.5 text-meta ${((be=s.autoResolve)==null?void 0:be.status)==="failed"?"bg-ui-raise text-ui-warn":"bg-ui-raise text-ui-success"}`,children:Vt(s.autoResolve)}),D&&!R&&e.jsx("span",{className:"rounded-ui bg-ui-sel px-1.5 py-0.5 text-meta text-ui-accent",children:"Your wording"}),!s.anchored&&!R&&(v?e.jsx("span",{className:"rounded-ui bg-ui-raise px-1.5 py-0.5 text-meta text-ui-mute",title:"Posts as a PR comment",children:"PR comment"}):s.fileInDiff?e.jsx("span",{className:"rounded-ui bg-ui-raise px-1.5 py-0.5 text-meta text-ui-mute",title:"Posts on the file's first change",children:"Line not in diff"}):e.jsx("span",{className:"rounded-ui bg-ui-raise px-1.5 py-0.5 text-meta text-ui-warn",title:"Posts as a PR comment",children:"File not in diff"})),V&&e.jsx("span",{className:"rounded-ui bg-ui-raise px-1.5 py-0.5 text-meta text-ui-mute",children:"Ignored"})]}),!Ne&&e.jsxs(e.Fragment,{children:[e.jsx(la,{citations:s.docCitations,references:P}),!v&&e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-2 font-mono text-meta",children:[T?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>m(s.path,s.line,s.side,s.threadId??void 0),className:"hit text-left text-ui-ink hover:underline",title:s.threadId!=null?"Show this comment in the Changes tab":s.line!=null?"Show this line in the Changes tab":"Show this file in the Changes tab",children:_}),e.jsx("a",{href:G,target:"_blank",rel:"noreferrer noopener","aria-label":s.line!=null?`Open ${s.path} line ${s.line} in the PR diff on GitHub`:`Open ${s.path} in the PR diff on GitHub`,title:"Open this line in the PR diff on GitHub",className:"hit shrink-0 text-ui-faint hover:text-ui-mute",children:e.jsx(Ie,{size:11})})]}):e.jsx("a",{href:F,target:"_blank",rel:"noreferrer noopener",className:"hit text-ui-ink hover:underline",title:H!=null?"Open this posted comment on GitHub":s.line!=null?"Open this line in the PR diff on GitHub":"Open this file in the PR diff on GitHub",children:_}),O!=null&&e.jsx("a",{href:O,target:"_blank",rel:"noreferrer noopener",className:"hit font-sans text-meta text-ui-mute hover:text-ui-ink hover:underline",title:"Open the file at the reviewed commit",children:"view file"})]}),s.diffHunk!=null&&s.diffHunk!==""&&e.jsx(Yl,{hunk:s.diffHunk,path:s.path}),s.body.trim()!==""&&e.jsx("div",{className:"mt-1",children:e.jsx(ce,{prRefs:!0,children:s.body})}),s.suggestion!=null&&s.suggestion!==""&&e.jsx(Ql,{suggestion:s.suggestion,path:s.path}),D&&!w&&e.jsxs("div",{className:"mt-1.5 rounded-ui bg-ui-sel px-2 py-1",children:[e.jsx("div",{className:"text-meta font-medium text-ui-accent",children:"Your wording"}),e.jsx(ce,{children:s.editedBody})]}),n&&!R&&w&&e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsx($s,{prId:t,value:M,onChange:B,rows:4,placeholder:"Your wording (markdown)",className:"w-full rounded-ui bg-ui-surface px-2 py-1.5 font-mono text-meta"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:Ke,className:Me,children:"Save"}),e.jsx("button",{type:"button",onClick:()=>{$(!1),B(s.editedBody??"")},className:se,children:"Cancel"}),D&&e.jsxs("button",{type:"button",onClick:me,className:`${se} text-ui-mute`,children:["Use ",h,"'s text"]})]})]})]})]})]}),g&&e.jsx("div",{className:"mt-2.5 flex flex-wrap items-center gap-2",children:V?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>ge(re=>!re),className:se,children:Y?"Collapse":"Show"}),e.jsx("button",{type:"button",onClick:()=>p==null?void 0:p(!0),title:"Re-include this finding in the review",className:Me,children:"Un-ignore"}),Y&&e.jsx("button",{type:"button",onClick:Ee,className:se,children:L?"Copied":"Copy"})]}):e.jsxs(e.Fragment,{children:[S&&e.jsx("button",{type:"button",onClick:pe,disabled:fe,className:Me,children:fe?"Posting…":_e?"Post as PR comment":"Post as comment"}),K&&e.jsx("button",{type:"button",onClick:Ye,disabled:fe,className:se,title:"Post it again on GitHub, marked as a reminder that links the first comment",children:fe?"Posting…":"Post reminder"}),n&&!R&&!w&&e.jsx("button",{type:"button",onClick:()=>{B(s.editedBody??""),$(!0)},className:Me,children:D?"Edit wording":"Reword"}),e.jsx("button",{type:"button",onClick:Ee,className:se,children:L?"Copied":"Copy"}),e.jsx(ra,{prId:t,reviewId:s.reviewId,pinRef:{kind:"finding",findingId:s.id},label:`${s.severity.charAt(0).toUpperCase()}${s.severity.slice(1)} · ${s.title}`}),Ae&&e.jsx("button",{type:"button",onClick:()=>p==null?void 0:p(!1),title:"Set aside — exclude this finding from the submitted review",className:se,children:"Ignore"}),c!=null&&e.jsx("span",{className:"ml-auto text-meta text-ui-danger",children:c})]})})]})}function Vs({review:t,editable:s,prUrl:n,repoFullName:l,prHeadSha:r,postingFindingId:o,postErrorFindingId:a,postErrorMessage:c,changedPaths:i,onOpenInChanges:x,onOpenThread:d,onToggleFinding:u,onRewordFinding:m,onPostFinding:p,storyCheck:j,ciCheck:k,currentThreads:b=null,checkThreadsPrId:g=null}){var F,O;const I=ws(),P=Re(t),h=f.useMemo(()=>Bi(t),[t]),L=de(),{data:N}=xt(h.prId,L.enabled),E=f.useMemo(()=>L.enabled?Hi(h.tickets??[],(N==null?void 0:N.tickets)??[]):[],[L.enabled,h.tickets,N]),w=f.useMemo(()=>Oi(h.findings,E),[h.findings,E]),$=Di(h.findings.filter(S=>!w.placed.has(S.id))),M=Ui(h),B=Gi(h),D=Wi(h.followUp),U=f.useMemo(()=>Vi(h),[h]),_=h.headSha??r,v=h.status==="succeeded"&&h.reviewMode!=="skip"?h.id:null,C=zi(t),R=Us(h,r),H=w.ids,G=qi("review"),z=(S,K)=>e.jsx(Ws,{authorName:Ya(t,S),prId:h.prId,finding:S,editable:s,prUrl:n,repoFullName:l,headSha:_,posting:o===S.id,postError:a===S.id?c:null,inChangeset:i.size>0?i.has(S.path):S.fileInDiff,priorStatus:M.get(S.id),alreadyPosted:B.has(S.id),storyLabel:K,docReferences:h.docReferences,onOpenInChanges:x,onToggle:y=>u(S.id,y),onReword:y=>m(S.id,y),onPostComment:()=>p(S.id),onPostReminder:()=>p(S.id,{reminder:!0})},S.id),T=(S,K,y)=>`${S} ${S===1?K:y}`;return e.jsxs(e.Fragment,{children:[e.jsx(je,{slot:"status",children:e.jsx(Jl,{review:h,title:t.pair!=null?`${P} review`:`${P}'s review`,currency:R,meta:rs(h,I)})}),e.jsx(je,{slot:"counts",children:e.jsx(er,{findings:$,storyFindings:w.placed.size,threads:(b!=null?b.counts:h.threadAssessmentCounts)??null})}),e.jsxs(ee,{title:t.pair!=null?`${P} review`:`${P}'s review`,section:"review",pills:G?null:e.jsxs(e.Fragment,{children:[h.verdict!=null&&e.jsx(gt,{verdict:h.verdict}),R!=null&&e.jsx(Gs,{currency:R}),e.jsx(Pe,{at:h.finishedAt}),h.trigger==="auto"&&e.jsx("span",{className:"text-meta text-ui-mute",children:ve}),h.fresh===!0&&e.jsx("span",{className:"text-meta text-ui-mute",children:Ss}),h.kind==="replies"&&e.jsx("span",{className:"text-meta text-ui-mute",children:qe}),h.reviewMode!=null&&e.jsxs("span",{className:"text-meta text-ui-mute",children:[ft[h.reviewMode]," review"]})]}),info:e.jsx(te,{title:t.pair!=null?"This review":"This run",children:e.jsxs("div",{className:"space-y-2",children:[((F=t.pair)==null?void 0:F.how)!=null&&e.jsx("p",{children:Ul[t.pair.how]}),e.jsx(Vl,{review:h}),h.numTurns!=null&&e.jsxs("p",{children:[h.numTurns," turns."]}),h.diffCapped&&e.jsx("p",{children:"The diff was too large to send whole, so it was cut to fit."}),h.excludedFiles.length>0&&e.jsxs("p",{children:["Left out as noise: ",h.excludedFiles.length," file",h.excludedFiles.length===1?"":"s"," (lockfiles, generated code)."]})]})}),children:[!G&&e.jsx("div",{className:"text-meta text-ui-mute",children:rs(h,I)}),et(t)!=null&&e.jsx("div",{className:"text-meta text-ui-ink","data-not-approved":!0,children:et(t)}),((O=h.pair)==null?void 0:O.failedHalf)!=null&&e.jsx("div",{className:"text-meta text-ui-mute","data-pair-failed-half":!0,children:Ki(h.pair.failedHalf)}),h.alsoRead!=null&&h.alsoRead.length>0&&e.jsxs("div",{className:"text-meta text-ui-mute",children:["Also read: ",h.alsoRead.map(Yi).join(", ")]}),D!=null&&e.jsx("div",{className:"font-medium",children:D}),h.summary!=null&&h.summary!==""&&e.jsx("div",{className:G?"reading-measure":void 0,children:e.jsx(ce,{prRefs:!0,children:h.summary})})]}),(h.followUp!=null||U.length>0)&&e.jsx(Qi,{followUp:h.followUp??null,settledEarlier:U,findings:h.findings,changedPaths:i,onOpenInChanges:x,prId:h.prId,reviewId:h.id,by:P}),e.jsx(nl,{items:b!=null?b.items:h.threadAssessments,counts:b!=null?b.counts:h.threadAssessmentCounts,onOpenThread:d,actions:g!=null?e.jsx(Xi,{prId:g}):void 0,by:b==null?Qa(t):void 0}),e.jsx(ee,{title:"Findings",section:"findings",pills:e.jsxs(e.Fragment,{children:[e.jsx(ht,{children:T($.length,"finding","findings")}),e.jsx(Kl,{findings:$,editable:s}),w.placed.size>0&&e.jsxs("span",{className:"text-meta text-ui-mute",children:[w.placed.size," more under Story check"]})]}),children:$.length>0?e.jsx("ul",{className:it,children:$.map(S=>z(S,S.story!=null?Ji(S.story,h.tickets):null))}):e.jsx("div",{className:"text-meta text-ui-mute",children:w.placed.size>0?"None outside Story check.":"No line-level findings."})}),j({entries:E,findingIds:H,findingsById:w.byId,renderFinding:z,finishedAt:h.finishedAt}),k,e.jsx(Nl,{prId:h.prId,headSha:_,canPost:L.enabled,changedPaths:i,onOpenInChanges:x}),e.jsx(Zi,{references:h.docReferences,by:P}),e.jsx(ea,{prId:h.prId,reviewFinishedAt:h.finishedAt??null,onOpenInChanges:x}),v!=null&&e.jsx(ta,{reviewId:v,prId:h.prId,reviewProvider:C})]})}const zs=["status","run","counts","nav","actions","post"],qs=[{id:"review",label:"Summary"},{id:"previous",label:"Previous review"},{id:"threads",label:"Review threads"},{id:"findings",label:"Findings"},{id:"stories",label:"Story check"},{id:"ci",label:"CI check"},{id:"sonar",label:"SonarCloud"},{id:"refs",label:"Reference docs"},{id:"design",label:"Design"},{id:"chat",label:"Review chat"}],Xl={name:"review",slots:zs,sections:qs,sectionAttr:"data-review-section",startSection:null,railLabel:"Review facts and actions",narrowClassName:"max-w-[61.5rem]",wideClassName:"relative z-10 bg-ui-bg"};function Jl({review:t,title:s,currency:n,meta:l}){return e.jsxs("div",{className:"space-y-1.5","data-testid":"review-rail-status",children:[e.jsx("p",{className:"text-meta text-ui-mute",children:s}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.verdict!=null&&e.jsx(gt,{verdict:t.verdict}),n!=null&&e.jsx(Gs,{currency:n})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-meta text-ui-mute",children:[e.jsx(Pe,{at:t.finishedAt}),t.trigger==="auto"&&e.jsx("span",{children:ve}),t.fresh===!0&&e.jsx("span",{children:Ss}),t.kind==="replies"&&e.jsx("span",{children:qe}),t.reviewMode!=null&&e.jsxs("span",{children:[ft[t.reviewMode]," review"]})]}),e.jsx("p",{className:"break-words text-meta text-ui-mute",children:l})]})}const Zl={blocker:["blocker","blockers"],warning:["warning","warnings"],nit:["nit","nits"],question:["question","questions"],praise:["praise","praise"]};function er({findings:t,storyFindings:s,threads:n}){const l=Na(),r=Dl.map(c=>({sev:c,n:t.filter(i=>i.severity===c).length})).filter(c=>c.n>0),o=(n==null?void 0:n.validUnaddressed)??0,a=(c,i,x,d)=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>l==null?void 0:l(i),className:Be("hit -mx-1.5 flex w-[calc(100%+0.75rem)] items-center gap-2 rounded-ui px-1.5 py-0.5 text-left text-body text-ui-ink hover:bg-ui-hover",He),children:[e.jsx("span",{className:"min-w-0 flex-1",children:x}),e.jsx("span",{className:"tabular-nums text-ui-mute",children:d})]})},c);return e.jsxs("div",{"data-testid":"review-rail-counts",children:[e.jsx("p",{className:"mb-1 text-meta text-ui-mute",children:"In this review"}),e.jsxs("ul",{className:"space-y-0.5",children:[r.length===0&&s===0?e.jsx("li",{className:"text-body text-ui-mute",children:"No line-level findings"}):r.map(({sev:c,n:i})=>a(c,"findings",e.jsx("span",{className:`inline-flex rounded-ui px-1.5 py-0.5 text-meta font-semibold capitalize ${Is[c]}`,children:Zl[c][i===1?0:1]}),i)),s>0&&a("story","stories","Under Story check",s),n!=null&&n.total>0&&a("threads","threads","Threads to fix",o)]})]})}function tr({pr:t,review:s,children:n}){var j,k;const l=de(),r=xt(t.id,l.enabled),o=r.data,a=ps(t.id,l.enabled),c=(j=a.data)==null?void 0:j.review,i=(s==null?void 0:s.status)==="succeeded"&&s.reviewMode!=="skip"?s.id:null,x=ca(i??-1,null,!1),d=i!=null?(k=x.data)==null?void 0:k.messages:void 0,u=f.useMemo(()=>{var g;const b=[{prId:t.id,repoFullName:t.repoFullName,number:t.number,title:t.title}];for(const I of(o==null?void 0:o.tickets)??[])for(const P of((g=I.review)==null?void 0:g.members)??[])b.push({prId:P.prId,repoFullName:P.repo,number:P.number,title:P.title});return b},[t.id,t.repoFullName,t.number,t.title,o]),m=f.useMemo(()=>[...ua(s,((o==null?void 0:o.tickets)??[]).map(b=>b.review)),...(d??[]).filter(b=>b.role==="assistant"&&b.content.includes("#")).map(b=>b.content),...c!=null?[c.summary,...c.items.flatMap(b=>[b.cause,b.explanation,b.suggestion])].filter(b=>b!=null&&b.includes("#")):[]],[s,o,d,c]),p=(!l.enabled||r.data!==void 0||r.isError)&&(!l.enabled||a.data!==void 0||a.isError)&&(i==null||x.data!==void 0||x.isError);return e.jsx(da,{currentPrId:t.id,currentRepoFullName:t.repoFullName,known:u,texts:m,ready:p,children:n})}function sr({prId:t,review:s}){const n=fs(r=>r.openAiFixFromReview),l=ct();return e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>n(t,s.id),className:"inline-flex h-7 items-center gap-1.5 whitespace-nowrap rounded-ui bg-ui-raise px-2.5 text-meta font-medium text-ui-ink hover:bg-ui-hover touch:h-10 touch:px-3",children:[e.jsx(gs,{size:12,className:"text-ai-signal"}),"Generate fix from this review",e.jsx(ke,{dir:"right",size:11})]}),e.jsx(te,{title:"Generate a fix",children:e.jsxs("p",{children:["Opens AI Fix with this review picked. ",l," edits the code to address the findings and threads still to fix. Nothing is pushed until you press the button there."]})})]})}function Ze({label:t,children:s}){return e.jsxs("div",{className:"flex flex-col gap-1 sm:flex-row sm:gap-3",children:[e.jsx("span",{className:"shrink-0 text-meta text-ui-faint sm:w-20 sm:pt-1",children:t}),e.jsx("div",{className:"min-w-0 flex-1",children:s})]})}function nr({pr:t,usersById:s,fixReview:n}){const l=de().enabled,r=ma(t),o=ha(t),a=l&&(n==null?void 0:n.status)==="succeeded";return!r&&!o&&!a?null:e.jsxs(ee,{title:"Reviews and actions",children:[r&&e.jsx(Ze,{label:"Reviews",children:e.jsx(xa,{pr:t,usersById:s})}),o&&e.jsx(Ze,{label:"Actions",children:e.jsx(pa,{pr:t})}),a&&n!=null&&e.jsx(Ze,{label:"Fix",children:e.jsx(sr,{prId:t.id,review:n})})]})}function ir({pr:t,usersById:s,onOpenInChanges:n,onOpenThread:l,oneColumn:r=!1}){var jt,vt,yt,kt,Nt,wt,Ct,Rt,$t,St,It,Pt,Et,_t,At,Tt,Lt,Ft,Mt;const o=de(),{data:a,isLoading:c}=gi(t.id),i=(a==null?void 0:a.review)??null,x=Qs(),d=f.useMemo(()=>{const A=new Set;for(const we of t.files)A.add(we.path);const W=x.getQueryData(["pr-files",t.id]);for(const we of(W==null?void 0:W.files)??[])A.add(we.path),we.previousPath&&A.add(we.previousPath);return A},[t.files,t.id,x]),u=bi(_a),[m,p]=f.useState(!1),[j,k]=f.useState(""),[b,g]=f.useState("COMMENT"),[I,P]=f.useState(null),h=f.useRef(null),[L,N]=f.useState(null),[E,w]=f.useState(null),[$,M]=f.useState(!1),B=ji(t.id),D=vi(t.id),U=yi(t.id),_=ki(t.id),v=Ni(t.id),C=wi(t.id),R=Ci(t.id),H=R.isPending?((jt=R.variables)==null?void 0:jt.findingId)??null:null,G=R.isError?((vt=R.variables)==null?void 0:vt.findingId)??null:null,z=R.isError?((yt=R.error)==null?void 0:yt.message)??"Failed to post comment":null,T=f.useRef(null);f.useEffect(()=>{if(i==null){T.current=null;return}T.current!==i.id&&(T.current=i.id,k(i.userBody??""),g(i.userVerdict??"COMMENT"),N(null),w(null),M(!1))},[i]);const F=a==null?void 0:a.history;f.useEffect(()=>{const A=i!=null?{id:i.id,status:i.status,trigger:i.trigger}:null;P(W=>za({shown:W,latest:A,previousLatestId:h.current,history:F??[]})),A!=null&&(h.current=A.id)},[i==null?void 0:i.id,i==null?void 0:i.status,i==null?void 0:i.trigger,F]);const O=(i==null?void 0:i.status)==="running"||(i==null?void 0:i.status)==="queued",S=(a==null?void 0:a.autoReview)??(O&&(i==null?void 0:i.trigger)==="auto"?"running":null),K=Ri(a),{status:y}=$i(t.id,O),Ee=ws(),Ke=As((a==null?void 0:a.history)??[],(i==null?void 0:i.id)??null,ds),me=Ts(Ke,I),he=me==null||me===(i==null?void 0:i.id),{data:xe}=Si(he?null:me);if(c)return e.jsx("div",{className:"px-4 py-3 text-body text-ui-faint",children:"Loading…"});if(!o.enabled||(a==null?void 0:a.enabled)===!1)return e.jsx(e.Fragment,{});const Ye=(i==null?void 0:i.status)==="succeeded"&&i.headSha===t.headSha,pe=(i==null?void 0:i.status)==="succeeded"?Us(i,t.headSha):null,fe=(pe==null?void 0:pe.tone)==="behind"?pe.label:null,_e=()=>{fa(),p(!1),N(null),w(null),B.mutate(u.pair?{model:u.chosen.model,pair:!0}:{model:u.chosen.model,provider:u.chosen.provider})},Ae=()=>{Ye?p(!0):_e()},V=he?i:xe??null,Y=he&&i!=null,ge=((kt=y==null?void 0:y.progress)==null?void 0:kt.phase)??null,Ne=i!=null&&(i.status==="running"||i.status==="queued")?i:null,be=((Nt=y==null?void 0:y.pair)==null?void 0:Nt.provider)??(Ne?Cs(Ne.provider,Ne.model):u.chosen.provider),re=Ee((Ct=(wt=y==null?void 0:y.progress)==null?void 0:wt.usage)==null?void 0:Ct.estCostUsd,be),Qe=ge!=null?Gl[ge]??ge:"Starting…",bt=A=>{i!=null&&_.mutateAsync({reviewId:i.id,userBody:j}).then(A,()=>{})},Ks=()=>{i!=null&&(w(null),N(null),bt(()=>C.mutate({reviewId:i.id,userVerdict:b,dryRun:!0},{onSuccess:A=>N(A)})))},Ys=()=>{i!=null&&(M(!1),bt(()=>C.mutate({reviewId:i.id,userVerdict:b},{onSuccess:A=>w(A)})))};return e.jsx(tr,{pr:t,review:V,children:e.jsx(Ii,{children:e.jsx("div",{className:"px-5 py-2 max-md:px-3",children:e.jsx(Pi,{config:Xl,oneColumn:r,children:e.jsxs("div",{className:"space-y-7",children:[e.jsx(je,{slot:"actions",inline:!0,children:e.jsx(nr,{pr:t,usersById:s,fixReview:Y?i:null})}),e.jsx(je,{slot:"nav",children:e.jsx(Ei,{})}),e.jsx(je,{slot:"run",inline:!0,children:e.jsxs(ee,{title:"Run a review",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(_i,{state:u,onPick:u.pick,disabled:O||D}),e.jsx(le,{kind:"review",auth:a==null?void 0:a.auth,anyProvider:!0,provider:u.chosen.provider,children:e.jsx("button",{type:"button",onClick:Ae,disabled:O||D||S!=null,className:Be("inline-flex h-8 items-center rounded-ui px-3 text-body font-medium touch:h-11 touch:px-4 disabled:cursor-not-allowed disabled:opacity-50",i==null||fe!=null?"bg-ui-accent-fill text-ui-on-accent hover:brightness-110":"bg-ui-raise text-ui-ink hover:bg-ui-hover",He),children:i==null?"Run review":"Re-review"})}),S!=null&&e.jsx("span",{className:"text-meta text-ui-mute",children:S==="running"?"Auto review running":"Auto review queued"}),S==null&&(a==null?void 0:a.autoReviewWaiting)!=null&&e.jsx("span",{className:"text-meta text-ui-mute",children:Ai[a.autoReviewWaiting]})]}),m&&e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 rounded-ui bg-ui-surface px-3 py-2 text-body text-ui-ink",children:[e.jsx("span",{children:"This commit is already reviewed."}),e.jsx("button",{type:"button",onClick:_e,disabled:S!=null,className:Be("inline-flex h-7 items-center rounded-ui bg-ui-raise px-2 text-meta font-medium hover:bg-ui-hover disabled:opacity-50 touch:h-10",He),children:"Run anyway"}),e.jsx("button",{type:"button",onClick:()=>p(!1),className:Be("inline-flex h-7 items-center rounded-ui px-2 text-meta text-ui-mute hover:bg-ui-hover hover:text-ui-ink touch:h-10",He),children:"Cancel"})]}),he&&Dt(a==null?void 0:a.autoFix)!=null&&e.jsx("div",{className:"mt-2 text-meta text-ui-mute",children:Dt(a==null?void 0:a.autoFix)}),e.jsx(ll,{prId:t.id,data:a}),B.isError&&!Ti(B.error)&&e.jsx("div",{className:"mt-2 text-meta text-ui-danger",children:((Rt=B.error)==null?void 0:Rt.message)??"Failed to start review."})]}),e.jsx("div",{className:"empty:hidden",children:e.jsx(dt,{active:O,label:Li(Ve(be),(($t=y==null?void 0:y.pair)==null?void 0:$t.role)??null,ge,((St=y==null?void 0:y.pair)==null?void 0:St.both)===!0),value:Wl(y),timeConstantSec:30})}),O&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-body",children:[e.jsx(xs,{stage:Qe,since:i!=null&&(y==null?void 0:y.reviewId)===i.id?i.createdAt:null,className:"text-body"}),(i==null?void 0:i.trigger)==="auto"&&e.jsx("span",{className:"text-meta text-ui-mute",children:ve}),((It=y==null?void 0:y.progress)==null?void 0:It.reviewMode)!=null&&e.jsxs("span",{className:"rounded-ui bg-ui-sel px-1.5 py-0.5 text-meta font-medium text-ui-accent",title:"The review depth chosen for this run",children:[ft[y.progress.reviewMode]," review"]}),((Pt=y==null?void 0:y.progress)==null?void 0:Pt.message)!=null&&e.jsx("span",{className:"text-meta text-ui-faint",children:y.progress.message}),e.jsx("button",{type:"button",onClick:()=>U.mutate(),disabled:U.isPending,className:"ml-auto 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",children:U.isPending?"Stopping…":"Stop"})]}),((Et=y==null?void 0:y.progress)==null?void 0:Et.usage)&&e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5 font-mono text-meta text-ui-mute",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",title:"Output tokens generated so far",children:[e.jsx(ke,{dir:"down",size:11}),Oe(y.progress.usage.outputTokens)," out"]}),e.jsxs("span",{className:"inline-flex items-center gap-1",title:"New (uncached) input tokens billed so far",children:[e.jsx(ke,{dir:"up",size:11}),Oe(y.progress.usage.inputTokens)," in"]}),e.jsxs("span",{className:"inline-flex items-center gap-1",title:"Cached input tokens read so far (billed at ~10% of input)",children:[e.jsx(Rs,{size:11}),Oe(y.progress.usage.cacheReadTokens)," cache"]}),e.jsx("span",{className:"font-semibold text-ui-mute",title:`Estimated so far, on ${Fi(be)}. Limn charges nothing. The figure recorded when the run finishes is authoritative.`,children:re!=null&&`~${re}`})]}),e.jsx(zl,{lines:((_t=y==null?void 0:y.progress)==null?void 0:_t.recentActivity)??[]})]}),!O&&K!=null&&e.jsx(ar,{repoId:t.repoId,prId:t.id,error:K.error,held:S!=null,retry:K.retry}),!O&&(i==null?void 0:i.status)==="failed"&&i.trigger!=="auto"&&e.jsx("div",{children:e.jsx("div",{className:"rounded-ui border border-ui-danger/40 bg-ui-danger/10 px-3 py-2 text-body text-ui-danger",children:i.error??"The review failed."})}),!O&&(i==null?void 0:i.status)==="cancelled"&&e.jsx("div",{className:"text-body text-ui-mute",children:"Review cancelled."}),a!=null&&e.jsx(al,{prId:t.id,state:a.repliesCheck,onShow:A=>{P(A),N(null),w(null)}}),a!=null&&a.history.length>1&&e.jsx(Xa,{history:a.history,shownId:me??(i==null?void 0:i.id)??null,latestId:(i==null?void 0:i.id)??null,onShow:A=>{P(A),N(null),w(null)}})]})}),V!=null&&V.status==="succeeded"&&e.jsx(Vs,{review:V,editable:Y,currentThreads:Y&&(a==null?void 0:a.currentThreadAssessments)!==void 0?{items:a.currentThreadAssessments,counts:a.currentThreadAssessmentCounts??null}:null,checkThreadsPrId:Y?t.id:null,prUrl:t.githubUrl,repoFullName:t.repoFullName,prHeadSha:t.headSha,postingFindingId:H,postErrorFindingId:G,postErrorMessage:z,changedPaths:d,onOpenInChanges:n,onOpenThread:l,onToggleFinding:(A,W)=>v.mutate({findingId:A,included:W}),onRewordFinding:(A,W)=>v.mutateAsync({findingId:A,editedBody:W}),onPostFinding:(A,W)=>R.mutateAsync({findingId:A,reminder:W==null?void 0:W.reminder}),storyCheck:A=>e.jsx(ls,{pr:t,changedPaths:d,onOpenInChanges:n,legacy:A}),ciCheck:e.jsx(ts,{pr:t,legacy:V,changedPaths:d,onOpenInChanges:n})}),!(V!=null&&V.status==="succeeded")&&e.jsxs(e.Fragment,{children:[e.jsx(ls,{pr:t,changedPaths:d,onOpenInChanges:n}),e.jsx(ts,{pr:t,changedPaths:d,onOpenInChanges:n})]}),Y&&i!=null&&i.status==="succeeded"&&i.reviewMode!=="skip"&&e.jsx(je,{slot:"post",inline:!0,children:e.jsxs(ee,{title:"Post to GitHub",pills:i.postedAt!=null?e.jsx("span",{className:"text-meta text-ui-mute",children:((At=i.autoPost)==null?void 0:At.status)==="posted"||((Tt=i.autoPost)==null?void 0:Tt.status)==="partial"?`Posted automatically · ${os(i.autoPost.at)}`:`Posted ${Mi(i.postedAt)}`}):null,info:e.jsx(te,{title:"Post to GitHub",children:e.jsx("p",{children:"Posts one review: your summary as its top-level comment, with your verdict. Every finding above that you have not ignored or already posted goes with it, including a story marked “Checked on this PR only”. Other Story check items are posted on their own."})}),children:[e.jsx("div",{className:"text-meta font-medium text-ui-ink",children:"Summary"}),nt(i.autoPost)!=null&&e.jsx("p",{className:"text-meta text-ui-warn",children:nt(i.autoPost)}),Ut(i.autoPost)!=null&&e.jsx("p",{className:"text-meta text-ui-mute",children:Ut(i.autoPost)}),tt(i.autoPost,Re(i))!=null&&e.jsx("p",{className:"text-meta text-ui-mute",children:tt(i.autoPost,Re(i))}),st(i.autoPost,Re(i))!=null&&e.jsx("p",{className:((Ft=(Lt=i.autoPost)==null?void 0:Lt.liftedBlock)==null?void 0:Ft.how)==="dismiss_failed"?"text-meta text-ui-warn":"text-meta text-ui-mute",children:st(i.autoPost,Re(i))}),e.jsx($s,{prId:t.id,value:j,onChange:A=>{k(A),N(null)},onBlur:()=>_.mutate({reviewId:i.id,userBody:j}),rows:6,placeholder:"Summary (markdown, @ to mention). Optional.",className:"w-full rounded-ui bg-ui-surface px-2 py-1.5 font-mono text-body"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>_.mutate({reviewId:i.id,userBody:j}),disabled:_.isPending,title:"Saves the draft. Nothing is posted yet.",className:"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",children:"Save draft"}),e.jsx(ms,{label:"Verdict",value:b,onChange:A=>{g(A),N(null),_.mutate({reviewId:i.id,userVerdict:A})},options:[{value:"COMMENT",label:"Comment"},{value:"REQUEST_CHANGES",label:"Request changes"},{value:"APPROVE",label:"Approve"}]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",onClick:Ks,disabled:C.isPending,className:"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",children:"Preview"}),$?e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsxs("span",{className:"text-meta text-ui-mute",children:["Post as ",e.jsx("strong",{children:Ds[b]}),"?"]}),e.jsx("button",{type:"button",onClick:Ys,disabled:C.isPending,className:"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",children:"Confirm post"}),e.jsx("button",{type:"button",onClick:()=>M(!1),className:"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",children:"Cancel"})]}):e.jsx("button",{type:"button",onClick:()=>M(!0),disabled:C.isPending,className:"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",children:"Post to GitHub"}),C.isPending&&e.jsx("span",{className:"text-meta text-ui-mute",children:"Posting…"})]}),L!=null&&e.jsx(ql,{preview:L}),E!=null&&e.jsxs("div",{className:"rounded-ui bg-ui-raise px-3 py-2 text-body text-ui-success",children:[e.jsxs("div",{children:["Posted review #",E.postedReviewId??"?"," ·"," ",E.postedCommentCount," inline comment",E.postedCommentCount===1?"":"s"]}),E.prCommentCount>0&&e.jsxs("div",{className:"mt-1 text-meta",children:["Plus ",E.prCommentCount," PR comment",E.prCommentCount===1?"":"s","."]})]}),C.isError&&e.jsx("div",{className:"text-meta text-ui-danger",children:((Mt=C.error)==null?void 0:Mt.message)??"Failed to post review to GitHub."})]})})]})})})})})}function ar({repoId:t,prId:s,error:n,held:l,retry:r}){var j;const o=de(),{data:a}=ga(),c=((j=a==null?void 0:a.find(k=>k.id===t))==null?void 0:j.workspaceId)??null,{data:i}=ba(o.enabled,c),x=ja(c),[d,u]=f.useState(null),m=(n??"no reason was given").replace(/\s+/g," ").trim(),p=r&&o.enabled&&!l&&(i==null?void 0:i.workspaceId)===c&&(i==null?void 0:i.autoReview.enabled)===!0;return e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-body",children:[e.jsxs("span",{className:"min-w-0 flex-1 truncate text-ui-danger",title:m,children:["Auto review failed: ",m]}),p&&e.jsx(le,{kind:"review",meter:!1,children:e.jsx("button",{type:"button",onClick:()=>{u(null),x.mutate({prId:s},{onSuccess:k=>u(va(k,!0)),onError:k=>u((k==null?void 0:k.message)??"Could not retry.")})},disabled:x.isPending,className:"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",children:x.isPending?"Retrying…":"Retry"})}),d!=null&&e.jsx("span",{role:"status",className:"text-meta text-ui-mute",children:d})]})}const or=Object.freeze(Object.defineProperty({__proto__:null,ClaudeReviewTab:ir,ClaudesReview:Vs,FindingRow:Ws,REVIEW_RAIL_SLOTS:zs,REVIEW_SECTIONS:qs},Symbol.toStringTag,{value:"Module"}));export{es as C,Ws as F,jl as S,Yt as T,or as a,Ya as f,Re as r,Qa as t};
@@ -1 +1 @@
1
- import{r as w,j as s}from"./tanstack-BnbsafB1.js";import{cT as j,c_ as y,cp as N,T as b,b3 as g,di as k,bS as v,aM as f,ap as T,E as C,bl as x,bq as $}from"./index-Bk94ZJq7.js";import"./markdown-CcoLFczy.js";import"./highlight-DIEV0qGG.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=g(e.kind),a=e.ttfrAnomaly,n=e.typicalTtfrHours==null,c=e.typicalFollowups!=null&&e.followupCount>=e.typicalFollowups+2,u=B(e.touches),r=u.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:c?"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",c?" (more than usual)":""]}),!n&&s.jsxs("span",{children:[" · baseline: ",e.baselinePrs," PRs"]})]}),u.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(T,{size:11}),o.comments>0&&s.jsx(C,{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 z({pr:e}){const{data:t,isLoading:i,isError:a}=j(e.id,!0),{data:n}=y(),c=w.useMemo(()=>{var l;return((l=(n??[]).find(m=>m.id===e.repoId))==null?void 0:l.workspaceId)??null},[n,e.repoId]),u=N(c),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(b,{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:u({login:l.login,kind:l.kind})},l.key))]})}export{z as PrBotBehaviourTab};
1
+ import{r as w,j as s}from"./tanstack-BnbsafB1.js";import{cS as j,cZ as y,co as N,T as b,b2 as g,dh as k,bR as v,aL as f,ao as T,E as C,bk as x,bp as $}from"./index-DWLpcq8D.js";import"./markdown-CcoLFczy.js";import"./highlight-DIEV0qGG.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=g(e.kind),a=e.ttfrAnomaly,n=e.typicalTtfrHours==null,c=e.typicalFollowups!=null&&e.followupCount>=e.typicalFollowups+2,u=B(e.touches),r=u.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:c?"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",c?" (more than usual)":""]}),!n&&s.jsxs("span",{children:[" · baseline: ",e.baselinePrs," PRs"]})]}),u.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(T,{size:11}),o.comments>0&&s.jsx(C,{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 z({pr:e}){const{data:t,isLoading:i,isError:a}=j(e.id,!0),{data:n}=y(),c=w.useMemo(()=>{var l;return((l=(n??[]).find(m=>m.id===e.repoId))==null?void 0:l.workspaceId)??null},[n,e.repoId]),u=N(c),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(b,{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:u({login:l.login,kind:l.kind})},l.key))]})}export{z as PrBotBehaviourTab};