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