limn-review 0.1.185 → 0.1.187
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/db/migrations/0169_approved_merged_since.sql +6 -0
- package/dist/db/migrations/meta/_journal.json +7 -0
- package/dist/db/queries.js +11 -2
- package/dist/db/schema.sqlite.js +4 -0
- package/package.json +1 -1
- package/public/assets/{AiFixTab-Bgm-Ja8b.js → AiFixTab-DcfRKyaR.js} +1 -1
- package/public/assets/{ClaudeReviewTab-Di50zOZT.js → ClaudeReviewTab-tgm-D75c.js} +1 -1
- package/public/assets/{PrBotBehaviourTab-GP2FO_VM.js → PrBotBehaviourTab-B8tT__IA.js} +1 -1
- package/public/assets/{index-CICgf03S.css → index-Ci8T4vWi.css} +1 -1
- package/public/assets/{index-C5bt1sKw.js → index-De8TkiUU.js} +51 -51
- package/public/index.html +2 -2
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
-- MY TURN "Merged after your Limn approved" counts only merges from the moment the card type
|
|
2
|
+
-- reached this install — an upgrade must not drop every recent approved-then-merged PR on My Turn.
|
|
3
|
+
-- NULL (an account created later) reads as that account's own `created_at`.
|
|
4
|
+
ALTER TABLE `accounts` ADD `approved_merged_since` integer;
|
|
5
|
+
--> statement-breakpoint
|
|
6
|
+
UPDATE `accounts` SET `approved_merged_since` = unixepoch();
|
|
@@ -1184,6 +1184,13 @@
|
|
|
1184
1184
|
"when": 1792224079016,
|
|
1185
1185
|
"tag": "0168_ai_review_seen_per_run",
|
|
1186
1186
|
"breakpoints": true
|
|
1187
|
+
},
|
|
1188
|
+
{
|
|
1189
|
+
"idx": 169,
|
|
1190
|
+
"version": "6",
|
|
1191
|
+
"when": 1792310479016,
|
|
1192
|
+
"tag": "0169_approved_merged_since",
|
|
1193
|
+
"breakpoints": true
|
|
1187
1194
|
}
|
|
1188
1195
|
]
|
|
1189
1196
|
}
|
package/dist/db/queries.js
CHANGED
|
@@ -8354,7 +8354,8 @@ repoIds) {
|
|
|
8354
8354
|
/**
|
|
8355
8355
|
* MERGED AFTER YOUR LIMN APPROVED IT — the My Turn `ai_approved_merged` section's seeds (docs/BACKEND.md
|
|
8356
8356
|
* § My Turn). One item per merged PR in scope, merged within `APPROVED_MERGED_DAYS` of `now` and at or
|
|
8357
|
-
* after the repo's onboarding floor (`passesFloor`)
|
|
8357
|
+
* after the repo's onboarding floor (`passesFloor`) AND the account's `approvedMergedSince` (going forward
|
|
8358
|
+
* only — never retrospective), where:
|
|
8358
8359
|
* • an OWN run's auto-post LANDED a review SENT as APPROVE (`auto_post.githubReviewId` set,
|
|
8359
8360
|
* `verdict.submitted = 'APPROVE'`) before the merge — a pair's one review is recorded on both
|
|
8360
8361
|
* halves, so the earliest record wins;
|
|
@@ -8364,7 +8365,15 @@ repoIds) {
|
|
|
8364
8365
|
* DB only, account-scoped. The dismissal filter is applied by `getMyTurn`.
|
|
8365
8366
|
*/
|
|
8366
8367
|
export async function getApprovedThenMerged(accountId, repoIds, now, passesFloor) {
|
|
8367
|
-
|
|
8368
|
+
// ⚠ GOING FORWARD ONLY: no merge before the card type reached this account counts
|
|
8369
|
+
// (`accounts.approvedMergedSince`, NULL = the account's own `createdAt`).
|
|
8370
|
+
const [acct] = await db
|
|
8371
|
+
.select({ since: schema.accounts.approvedMergedSince, createdAt: schema.accounts.createdAt })
|
|
8372
|
+
.from(schema.accounts)
|
|
8373
|
+
.where(eq(schema.accounts.id, accountId))
|
|
8374
|
+
.execute();
|
|
8375
|
+
const sinceMs = (acct?.since ?? acct?.createdAt)?.getTime() ?? now;
|
|
8376
|
+
const from = new Date(Math.max(now - APPROVED_MERGED_DAYS * 86_400_000, sinceMs));
|
|
8368
8377
|
const rows = await db
|
|
8369
8378
|
.select({
|
|
8370
8379
|
reviewId: claudeReviews.id,
|
package/dist/db/schema.sqlite.js
CHANGED
|
@@ -63,6 +63,10 @@ export const accounts = sqliteTable('accounts', {
|
|
|
63
63
|
// a positive integer the user typed (the route rejects anything else), so a reader that sees
|
|
64
64
|
// null knows the user never expressed an opinion, rather than guessing at a sentinel.
|
|
65
65
|
largePrCodeLocThreshold: integer('large_pr_code_loc_threshold'),
|
|
66
|
+
// MY TURN "Merged after your Limn approved" starts HERE, never retrospectively: only merges at or
|
|
67
|
+
// after this moment make a card. Migration 0169 stamps existing accounts with the upgrade time;
|
|
68
|
+
// NULL (an account created later) reads as the account's own `createdAt`.
|
|
69
|
+
approvedMergedSince: integer('approved_merged_since', { mode: 'timestamp' }),
|
|
66
70
|
// BLAST RADIUS reading settings: `{sensitivity, surfacesOff[], overrides?}` — the dial, the
|
|
67
71
|
// per-account surface opt-out, and (stored, honoured, no UI in v1) numeric overrides. Same
|
|
68
72
|
// ACCOUNT grain and same two-state rule as the threshold above: NULL means the user has never
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as Ie,r as x,j as e}from"./tanstack-BnbsafB1.js";import{aY as G,aX as Qe,cV as be,d0 as Ze,cC as es,cT as ss,cE as Se,aR as ts,cU as O,A as Ne,aW as Te,W as ne,y as ns,a7 as is,an as ie,bw as Ee,a3 as _e,e as Me,f as q,a6 as as,aU as Be,i as Le,s as rs,k as ls,a as cs,C as os,dz as us,c2 as ds,aZ as ms,dr as hs,ds as xs,$ as ps,J as fs,V as gs,v as K,bL as js,cS as bs,cR as Ns,cB as vs,bo as ws,c3 as ks,az as ys,bn as Rs,bc as Ps,cd as Ue,bO as Cs,cx as $e,cy as As,cL as Fs,c_ as Is,cZ as Ss,dj as Ts,dk as Es,aV as _s,aS as Ms,cA as Bs,cz as Ls,cM as Us,dg as $s,au as Os,a0 as Ds,aT as Hs,bS as Ws,c0 as ae,X as Ys,w as zs,N as qs,U as Ks,c8 as Oe,d8 as Vs,aj as ve,x as Gs,L as Xs}from"./index-C5bt1sKw.js";import{r as Js,t as Qs,S as Zs,C as et,T as st,F as tt,f as nt}from"./ClaudeReviewTab-Di50zOZT.js";import"./markdown-CcoLFczy.js";import"./highlight-DIEV0qGG.js";import"./vis-C3BCkP5U.js";const it="inline-flex h-7 items-center whitespace-nowrap rounded-ui bg-ui-raise px-2.5 text-meta font-medium text-ui-ink hover:bg-ui-hover disabled:cursor-not-allowed disabled:opacity-50 touch:h-10 touch:px-3",we="inline-flex h-7 items-center whitespace-nowrap rounded-ui bg-ui-raise px-2.5 text-meta font-medium text-ui-ink hover:bg-ui-hover disabled:cursor-not-allowed disabled:opacity-50 touch:h-10 touch:px-3",ke="inline-flex items-center rounded-ui bg-ui-raise px-1.5 py-px font-mono text-meta text-ui-ink";function at(s){return s instanceof Le||s instanceof Error?s.message:"Something went wrong"}function De({plan:s}){return e.jsx("ul",{className:"list-disc space-y-0.5 pl-5 text-body text-ui-ink",children:s.summary.map((t,n)=>e.jsx("li",{children:t},n))})}function ye(s,t){var n;return((n=s==null?void 0:s.find(a=>a.ref===t))==null?void 0:n.title)??null}function rt({plan:s,items:t}){return e.jsxs("div",{className:"mt-2 space-y-3 text-meta text-ui-ink",children:[s.steps.length>0&&e.jsx("ol",{className:"list-decimal space-y-2 pl-5",children:s.steps.map((n,a)=>e.jsxs("li",{children:[e.jsx("div",{className:"font-medium text-ui-ink",children:n.title}),n.files.length>0&&e.jsx("div",{className:"mt-0.5 font-mono text-meta text-ui-mute",children:n.files.join(", ")}),e.jsx("p",{className:"mt-0.5 whitespace-pre-wrap",children:n.change}),n.refs.length>0&&e.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:n.refs.map(i=>e.jsx("span",{className:ke,children:i},i))})]},a))}),s.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:s.notAddressed.map(n=>e.jsxs("li",{children:[e.jsx("span",{className:ke,children:n.ref})," ",ye(t,n.ref)&&e.jsxs("span",{className:"font-medium",children:[ye(t,n.ref),": "]}),n.reason]},n.ref))})]}),s.notCovered.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"font-semibold text-ui-mute",children:"Not in the plan: "}),s.notCovered.join(", ")]})]})}function lt({pr:s,fix:t,liveStatus:n,passRunning:a,auth:i}){var w,p;const l=t.plan,o=G(t.plan??t),g=Qe((t.plan??t).provider,(t.plan??t).model),c=be(g,"plan"),m=be(g,"fix"),v=Be(c),F=Ze(s.id),u=es(s.id),k=ss(s.id),M=Se(s.id),C=Ie({mutationKey:ts(s.id)})>0,B=O(N=>N.noteAiFixRun),[E,I]=x.useState(""),[y,D]=x.useState(!1);if(!l)return null;const R=l.plan,_=l.status==="plan_ready"&&!a,L=E.trim(),P=L.length>Ne,r=()=>{!_||C||L===""||P||F.mutate({fixId:t.id,text:L},{onSuccess:()=>I("")})},d=()=>{B({prId:s.id,repoFullName:s.repoFullName,prNumber:s.number,prTitle:s.title}),u.mutate(t.id)},f=F.error??u.error??k.error;return e.jsxs("div",{className:"mt-3 rounded-ui bg-ui-surface p-3",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1 text-meta font-semibold text-ui-ink",children:["Plan",R&&l.revision>1&&e.jsxs("span",{className:"font-normal text-ui-mute",children:["· version ",l.revision]}),l.model&&e.jsxs("span",{className:"font-normal text-ui-mute",children:["· ",Te(l.provider,l.model,l.effort)]}),e.jsxs(ne,{title:"Plan first",children:[e.jsxs("p",{children:[v," reads the code and writes a plan. It changes nothing."]}),e.jsxs("p",{children:["Tell ",v," what to change and it rewrites the plan, taking the whole conversation into account. Each message runs ",v," again."]}),e.jsxs("p",{children:["When you approve, ",v," builds the fix from this plan. You still review the diff and press Push."]})]})]}),R?e.jsxs(e.Fragment,{children:[e.jsx(De,{plan:R}),e.jsxs("button",{type:"button",className:"hit mt-2 inline-flex items-center gap-1 text-meta text-ui-mute hover:text-ui-ink","aria-expanded":y,onClick:()=>D(N=>!N),children:[e.jsx(ns,{dir:y?"down":"right"}),"Details"]}),y&&e.jsx(rt,{plan:R,items:t.reviewItems})]}):!a&&e.jsx("p",{className:"text-meta text-ui-mute",children:"No plan yet."}),t.error&&e.jsx("p",{className:"mt-2 rounded-ui bg-ui-raise p-2 text-meta text-ui-warn",children:t.error}),e.jsx(is,{transcript:l.transcript,plannedBy:o}),a&&e.jsxs("div",{className:"mt-3",children:[e.jsx(ie,{active:!0,label:R?"Updating the plan":"Making the plan",value:Ee(n),timeConstantSec:30}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-meta text-ui-mute",children:[_e[((w=n==null?void 0:n.progress)==null?void 0:w.phase)??""]??"Working…",e.jsx("button",{type:"button",className:we,onClick:()=>M.mutate(),children:"Cancel"})]}),e.jsx(Me,{lines:(p=n==null?void 0:n.progress)==null?void 0:p.recentActivity,className:"mt-1"})]}),_&&R&&e.jsxs("div",{className:"mt-3",children:[e.jsx(q,{kind:"plan",auth:i,meter:!1,followUp:!0,provider:c,children:e.jsx(as,{name:v,draft:E,setDraft:I,busy:C,maxChars:Ne,onSend:r})}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx(q,{kind:"fix",auth:i,followUp:!0,provider:m,children:e.jsx("button",{type:"button","data-ai-run":!0,className:it,disabled:C,onClick:d,children:"Approve and build"})}),e.jsx("button",{type:"button",className:we,disabled:C,onClick:()=>k.mutate(t.id),children:"Discard plan"})]})]}),f!=null&&e.jsx("p",{className:"mt-1 text-meta text-ui-danger",children:at(f)})]})}function He({fix:s}){var n;const t=((n=s.plan)==null?void 0:n.status)==="approved"?s.plan.plan:null;return t?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(De,{plan:t})]}):null}function ct(s,t,n){var a;return s??((t==null?void 0:t.status)==="succeeded"?t.id:((a=n.find(i=>i.status==="succeeded"))==null?void 0:a.id)??null)}function ot(s,t,n){return t==null||n==null||t===n.id?null:s!=null?"Uses the review you picked, not the latest.":n.status==="failed"?"Uses the last review that finished. The latest one failed.":n.status==="running"||n.status==="queued"?"Uses the last review that finished. A newer one is running.":"Uses the last review that finished."}const Re=os,ut=ls;function dt(s){return s.kind==="finding"&&s.findingId!=null?`claude-finding-${s.findingId}`:null}function mt(s){const t=O(n=>n.openClaudeReview);return n=>{t({id:s.id,number:s.number,title:s.title,repoFullName:s.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null});const a=Date.now()+3e3,i=()=>{const l=document.getElementById(n);if(l){l.scrollIntoView({behavior:"smooth",block:"center"});return}Date.now()<a&&requestAnimationFrame(i)};requestAnimationFrame(i)}}function Pe({refId:s,item:t,onJump:n}){const a=t?`${cs[t.kind]} ${s}`:s,i=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"shrink-0",children:a}),t&&e.jsxs("span",{className:"min-w-0 truncate font-normal",children:["· ",t.title]})]}),l=t?dt(t):null;return l?e.jsx("button",{type:"button",onClick:()=>n(l),"aria-label":`${a}: ${(t==null?void 0:t.title)??""}. Show in AI Review`,className:`${Re} max-w-[22rem] hover:bg-ui-hover`,children:i}):e.jsx("span",{className:`${Re} max-w-[22rem]`,children:i})}function ht(s){var t;switch(s.seed){case"review":{const n=((t=s.reviewItems)==null?void 0:t.length)??0;return`Fix from ${s.sourceReviewId==null?"the CI check":"the AI review"}${n>0?` (${n} item${n===1?"":"s"})`:""}.`}case"plain":return"Fix from your instruction.";case"comments":return"Fix from picked comments (no longer offered).";case"ci_analysis":return"Fix from the CI analysis (no longer offered).";default:return""}}function xt({pr:s,fix:t}){const n=G(t),a=mt(s),i=t.changeReport,l=new Map((t.reviewItems??[]).map(c=>[c.ref,c])),o=(t.reviewItems??[]).filter(c=>!c.included);if(!i&&o.length===0)return null;const g=l.size>0;return e.jsxs("div",{className:"mt-2 text-meta",children:[e.jsx(rs,{report:i,filesChanged:t.filesChanged,by:n,refsInfo:g?e.jsx("p",{children:"Each tag is a review item the change answers. A finding tag opens it in the AI Review tab."}):null,renderRef:c=>e.jsx(Pe,{refId:c,item:l.get(c),onJump:a},c)}),o.length>0&&e.jsxs("section",{children:[e.jsxs("div",{className:ut,children:["Left out",e.jsx(ne,{title:"Left out",children:e.jsxs("p",{children:["These review items did not fit in what ",n," was sent, so it never saw them."]})})]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:o.map(c=>e.jsx(Pe,{refId:c.ref,item:c,onJump:a},c.ref))})]})]})}const pt=["findings","earlier_findings","judged_threads","untouched_threads","ci_failures","sonar","style_bots","story"],ft={findings:"Claude’s findings",earlier_findings:"Earlier findings still open",judged_threads:"Threads Claude says need a fix",untouched_threads:"Unanswered threads",ci_failures:"CI failures",sonar:"SonarCloud issues",style_bots:"Style bot comments",story:"Ticket gaps"};function Ce(s,t="Claude"){return s==="findings"?`${t}’s findings`:s==="judged_threads"?`Threads ${t} says need a fix`:ft[s]}function V(s,t){return t[s.key]??s.defaultIncluded}function gt(s,t){return s.items.filter(n=>V(n,t)).map(n=>n.key)}function We(s,t){const n=new Set;let a=0;for(const i of s.items)if(V(i,t)){if(a>0&&a+i.chars>s.budgetChars){n.add(i.key);continue}a+=i.chars}return n}function jt(s,t){const n={};for(const a of s.items)n[a.key]=a.section===t;return n}const bt={blocker:"Blocker",warning:"Warning",nit:"Nit",question:"Question",praise:"Praise"},Ae={blocker:"bg-ui-danger/10 text-ui-danger",warning:"bg-ui-raise text-ui-warn",nit:"bg-ui-raise text-ui-mute"},Ye="whitespace-nowrap rounded-ui bg-ui-raise px-1 py-px text-meta text-ui-warn",Z=new Set;function Nt(s,t){return s?t!=null?`${s}:${t}`:s:null}function vt({item:s,picked:t,cut:n,disabled:a,onToggle:i}){return e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5 pt-0.5",children:[e.jsx("label",{className:"flex cursor-pointer items-center touch:-my-3 touch:min-h-10 touch:min-w-10 touch:justify-center",children:e.jsx(K,{checked:t,disabled:a,onChange:l=>i(l.target.checked),"aria-label":`Include in the fix: ${s.label}`})}),t&&n&&e.jsx("span",{className:Ye,children:"Won’t fit"})]})}function wt({item:s,picked:t,cut:n,disabled:a,onToggle:i}){const l=Nt(s.path,s.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 ${t?"border-ui-line bg-ui-sel":"border-ui-line"}`,children:[e.jsx(K,{className:"mt-0.5",checked:t,disabled:a,onChange:o=>i(o.target.checked)}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"flex flex-wrap items-center gap-1.5",children:[s.severity&&Ae[s.severity]&&e.jsx("span",{className:`rounded-ui px-1 py-px text-meta font-medium ${Ae[s.severity]}`,children:bt[s.severity]}),e.jsx("span",{className:"break-words text-ui-ink",children:s.label}),t&&n&&e.jsx("span",{className:Ye,children:"Won’t fit"})]}),(l||s.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&&s.detail?" · ":"",s.detail]})]})]})})}function kt({preview:s,overrides:t,onChange:n,disabled:a,pr:i,review:l}){const o=We(s,t),g=new Map;for(const r of s.items){const d=g.get(r.section)??[];d.push(r),g.set(r.section,d)}const c=(r,d)=>{const f={...t};for(const w of r)f[w]=d;n(f)},m=l!=null&&l.id===s.sourceReviewId?l:null,v=Js(l),F=Qs(l),u=x.useMemo(()=>m!=null?us(m):null,[m]),k=x.useMemo(()=>new Map(((u==null?void 0:u.findings)??[]).map(r=>[r.id,r])),[u]),M=x.useMemo(()=>{var r;return new Map((((r=u==null?void 0:u.followUp)==null?void 0:r.items)??[]).map(d=>[d.priorFindingId,d]))},[u]),C=x.useMemo(()=>u!=null?ds(u):new Map,[u]),B=x.useMemo(()=>u!=null?ms(u):new Set,[u]),E=x.useMemo(()=>{var d;const r=new Set;for(const f of s.items)((d=f.card)==null?void 0:d.kind)==="story"&&r.add(f.card.ticketReviewId);return[...r].sort((f,w)=>f-w)},[s.items]),I=hs(i.id,E.length>0),y=x.useMemo(()=>{var d;const r=new Map;for(const f of((d=I.data)==null?void 0:d.tickets)??[])f.review!=null&&r.set(f.review.id,f.review);return r},[I.data]),D=x.useMemo(()=>I.data==null?[]:E.filter(r=>!y.has(r)),[I.data,E,y]),R=xs(D),_=x.useMemo(()=>{const r=new Map(y);for(const d of R)r.set(d.id,d);return r},[y,R]);if(s.items.length===0)return e.jsx("p",{className:"text-meta text-ui-mute",children:"The review found nothing to fix."});const L=(m==null?void 0:m.headSha)??i.headSha,P=r=>{var H,S;const d=V(r,t),f=o.has(r.key),w=b=>c([r.key],b),p=e.jsx(vt,{item:r,picked:d,cut:f,disabled:a,onToggle:w}),N=r.card;switch(N==null?void 0:N.kind){case"finding":{const b=k.get(N.findingId);if(b==null)break;return e.jsx(tt,{authorName:nt(l,b),prId:i.id,finding:b,editable:!1,prUrl:i.githubUrl,repoFullName:i.repoFullName,headSha:L,posting:!1,postError:null,inChangeset:b.fileInDiff,priorStatus:C.get(b.id),alreadyPosted:B.has(b.id),actions:!1,selection:p,docReferences:(m==null?void 0:m.docReferences)??null},r.key)}case"earlier_finding":{const b=M.get(N.priorFindingId);if(b==null)break;return e.jsx(gs,{item:b,muted:!1,findingsById:k,headMoved:((H=u==null?void 0:u.followUp)==null?void 0:H.headMoved)??!1,changedPaths:Z,actions:!1,selection:p,by:v},r.key)}case"thread":return e.jsx(st,{t:N.assessment,muted:!1,actions:!1,selection:p,notCheckedNote:N.inReview?void 0:`${F} didn’t check this one.`,by:F},r.key);case"ci":return e.jsx(et,{f:N.item,suggestion:N.item.suggestion,changedPaths:Z,selection:p},r.key);case"sonar":return e.jsx(Zs,{issue:N.issue,selection:p},r.key);case"story":{const b=_.get(N.ticketReviewId),T=b==null?void 0:b.items.find(U=>U.id===N.itemId);if(b==null||T==null)break;const j={review:b,viewedPrId:i.id,changedPaths:Z,actions:!1,selection:p};if(T.status==="missing")return e.jsx(ps,{item:T,...j},r.key);const h=(S=b.assessment)==null?void 0:S.criteria.find(U=>U.ref===T.ref);if(h==null||h.status==="met")break;return e.jsx(fs,{c:h,item:T,...j},r.key)}}return e.jsx(wt,{item:r,picked:d,cut:f,disabled:a,onToggle:w},r.key)};return e.jsxs("div",{className:"space-y-3",children:[pt.filter(r=>g.has(r)).map(r=>{const d=g.get(r),f=d.filter(p=>V(p,t)).length,w=f===d.length;return e.jsxs("section",{"aria-label":Ce(r,v),children:[e.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[e.jsx("h4",{className:"text-meta font-semibold text-ui-ink",children:Ce(r,v)}),e.jsxs("span",{className:"text-meta text-ui-mute",children:[f," of ",d.length]}),e.jsx("button",{type:"button",className:"hit ml-auto text-meta text-ui-accent hover:underline disabled:opacity-50",disabled:a,onClick:()=>c(d.map(p=>p.key),!w),children:w?"Untick all":"Tick all"})]}),e.jsx("ul",{className:"space-y-1.5",children:d.map(P)})]},r)}),o.size>0&&e.jsxs("p",{className:"text-meta text-ui-warn",children:[o.size," ticked ",o.size===1?"item does":"items do"," not fit in one fix and will be left out. Untick something to make room."]})]})}const 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",Fe="inline-flex h-7 items-center whitespace-nowrap rounded-ui bg-ui-raise px-2.5 text-meta font-medium text-ui-ink hover:bg-ui-hover disabled:cursor-not-allowed disabled:opacity-50 touch:h-10 touch:px-3";function ze(s){return{prId:s.id,repoId:s.repoId,repoFullName:s.repoFullName,prNumber:s.number,prTitle:s.title,githubUrl:s.githubUrl}}function Rt(s){const t=js({mergeable:s.mergeable,mergeStateStatus:s.mergeStateStatus,isDraft:s.isDraft,inMergeQueue:s.inMergeQueue===!0}).verdict;return bs({state:s.state,verdict:t,viewerCanPush:s.viewerCanPush})}function Pt({pr:s}){const t=Ns(s.id),n=vs(),a=ws(t),i=s.baseRefName??"the base branch";x.useEffect(()=>{ks(s.id)},[s.id]);const l=ze(s),o=(t==null?void 0:t.phase)==="succeeded"?t.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(ys,{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&&t!=null?e.jsxs("div",{className:"mt-2",children:[e.jsx(ie,{active:!0,label:`Resolving conflicts with ${n}`,timeConstantSec:60}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-meta text-ui-mute",children:[Rs(t.phase,n),e.jsx("button",{type:"button",className:Fe,onClick:()=>Ps(s.id),children:"Cancel"})]})]}):e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx(q,{kind:"resolve",children:e.jsx("button",{type:"button",className:yt,onClick:()=>Ue(l,{providerName:n}),children:o!=null?"Run again":`Resolve merge conflicts with ${n}`})}),o!=null&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:Fe,onClick:()=>Cs(l),children:"Open the resolver"}),e.jsxs("span",{className:"text-meta text-ui-mute",children:[G(o)," decided ",o.choices.length," of ",o.decidableTotal," change",o.decidableTotal===1?"":"s","."]})]}),(t==null?void 0:t.phase)==="failed"&&t.error!=null&&e.jsx("span",{className:"text-meta text-ui-danger",children:t.error}),(t==null?void 0:t.phase)==="cancelled"&&e.jsx("span",{className:"text-meta text-ui-mute",children:"Cancelled."})]})]})}const se="inline-flex h-7 items-center whitespace-nowrap rounded-ui bg-ui-raise px-2.5 text-meta font-medium text-ui-ink hover:bg-ui-hover disabled:cursor-not-allowed disabled:opacity-50 touch:h-10 touch:px-3";function te(s){return s instanceof Le||s instanceof Error?s.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 Ct({children:s,info:t}){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:s}),t]})}function Ot({pr:s}){const t=$e().enabled,n=O(c=>c.aiFixTabFocus),a=O(c=>c.consumeAiFixTabFocus),[i,l]=x.useState(null),[o,g]=x.useState(null);return x.useEffect(()=>{n&&n.prId===s.id&&(n.reviewId!=null&&l(n.reviewId),n.only!=null&&g(n.only),a())},[n,s.id,a]),t?e.jsx("div",{className:"pb-6",children:e.jsx(At,{pr:s,handoffReviewId:i,onlySection:o,onOnlySectionApplied:()=>g(null)})}):e.jsx(e.Fragment,{})}function At({pr:s,handoffReviewId:t,onlySection:n,onOnlySectionApplied:a}){var oe,ue,de,me,he,xe,pe,fe,ge,je;const{data:i,isLoading:l}=As(s.id,!0),{data:o,isLoading:g}=Fs(s.id),c=(o==null?void 0:o.review)??null,m=ct(t,c,(o==null?void 0:o.history)??[]),v=ot(t,m,c),F=O(A=>A.setPrDetailTab),u=Is("fix",Xs),k=Be(u.chosen.provider),M=Ss().data,C=Ts(s.id),B=Es(s.id),E=Se(s.id),I=$e(),y=_s(M,u.chosen.provider,"plan"),[D,R]=x.useState(!1),_=D&&y,L=O(A=>A.noteAiFixRun),P=Ie({mutationKey:Ms(s.id)})>0,r=((oe=i==null?void 0:i.fix)==null?void 0:oe.status)??null,d=r==="planned",f=d&&((de=(ue=i==null?void 0:i.fix)==null?void 0:ue.plan)==null?void 0:de.status)==="planning",w=r==="running"||r==="queued"||P||f,{status:p}=Bs(s.id,w),N=(p==null?void 0:p.status)??r??"idle",H=N==="running"||N==="queued",S=H&&!d,b=d&&(f||H),T=d&&(((he=(me=i==null?void 0:i.fix)==null?void 0:me.plan)==null?void 0:he.status)==="planning"||((pe=(xe=i==null?void 0:i.fix)==null?void 0:xe.plan)==null?void 0:pe.status)==="plan_ready"),j=(i==null?void 0:i.fix)??null,h=Ls(s.id,m,(i==null?void 0:i.enabled)!==!1&&(m!=null||!g)),U=m==null&&h.data!=null&&h.data.sourceReviewId==null&&h.data.items.length>0,z=m!=null||U,Ke=Us(m!=null&&(c==null?void 0:c.id)!==m?m:null),Ve=m!=null&&(c==null?void 0:c.id)===m?c:Ke.data??null,[X,J]=x.useState({});x.useEffect(()=>J({}),[m]);const[Ge,W]=x.useState(!1);x.useEffect(()=>{n==null||!h.data||(J(jt(h.data,n)),W(!0),a())},[n,h.data,a]);const re=!T&&(Ge||!j||j.status!=="succeeded"),Q=Rt(s),[le,Xe]=x.useState(!1),Y=$s(s.id,s.repoFullName),$=h.data?gt(h.data,X):[],ce=h.data?We(h.data,X).size:0,Je=()=>{if(!z||!h.data||$.length===0)return;const A={model:u.chosen.model,provider:u.chosen.provider,seed:"review",...m!=null?{sourceReviewId:m}:{},include:$,...Y.names.length>0?{checks:Y.names}:{}};_?B.mutate(A,{onSuccess:()=>W(!1)}):(L({prId:s.id,repoFullName:s.repoFullName,prNumber:s.number,prTitle:s.title}),C.mutate(A,{onSuccess:()=>W(!1)})),le&&Q&&Ue(ze(s),{model:Hs(u.chosen.model),providerName:I.providerName})};return e.jsxs("div",{children:[e.jsx(Ct,{info:e.jsxs(ne,{title:"AI Fix",children:[e.jsxs("p",{children:[k," reads the PR's code and edits files in a private copy. It has no shell. Tick Run tests to let it run the project's own test, lint and type checks in a sandbox."]}),e.jsx("p",{children:"A fix starts from an AI review. Pick what it should work on: the review's findings, earlier findings still open, threads the review says need a fix, unanswered threads, CI failures and ticket gaps are ticked; style bot comments are not."}),e.jsx("p",{children:"With no AI review, a fix can start from a finished CI check: it works on the failures the check says this PR can fix."}),e.jsxs("p",{children:["Tick Plan first to read ",k,"'s plan, steer it and approve it before anything changes."]}),e.jsxs("p",{children:[k," reports what it changed in each file and what it left alone, and why."]}),e.jsx("p",{children:"Nothing is pushed until you press Push. An automatic fix on your own PR is pushed for you only when Push automatically is on in Settings."})]}),children:"AI Fix"}),e.jsxs("div",{className:"px-4",children:[Q&&e.jsx(Pt,{pr:s}),(i==null?void 0:i.enabled)===!1?e.jsx("p",{className:"text-body text-ui-mute",children:"The agentic fixer is turned off."}):e.jsxs(e.Fragment,{children:[!S&&!T&&!z&&!g&&!h.isLoading&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-meta text-ui-mute",children:(c==null?void 0:c.status)==="running"||(c==null?void 0:c.status)==="queued"?"A fix starts from an AI review. One is running.":"A fix starts from a finished AI review."}),e.jsx("button",{type:"button",className:se,onClick:()=>F(s.id,"claude_review"),children:"Open AI Review"})]}),!S&&!T&&z&&!re&&e.jsx("button",{type:"button",className:ee,onClick:()=>W(!0),children:"New fix"}),!S&&z&&re&&e.jsxs("div",{children:[v&&e.jsx("p",{className:"mb-2 text-meta text-ui-mute",children:v}),U&&e.jsx("p",{className:"mb-2 text-meta text-ui-mute",children:"No AI review yet. This fix works on the CI check’s failures."}),h.isLoading&&e.jsx("p",{className:"text-meta text-ui-mute",children:"Loading…"}),h.isError&&m!=null&&e.jsx("p",{className:"text-meta text-ui-danger",children:te(h.error)}),h.data&&e.jsx(kt,{preview:h.data,overrides:X,onChange:J,disabled:P,pr:s,review:Ve}),h.data&&h.data.items.length>0&&Q&&e.jsxs("label",{className:"mt-3 flex cursor-pointer items-start gap-2 text-meta text-ui-ink",children:[e.jsx(K,{className:"mt-0.5",checked:le,disabled:P,onChange:A=>Xe(A.target.checked)}),e.jsxs("span",{children:["Also resolve merge conflicts with ",s.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."})]})]}),h.data&&h.data.items.length>0&&e.jsx(Os,{state:Y,disabled:P}),h.data&&h.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(Ds,{state:u,onPick:u.pick,disabled:P}),y&&e.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5 text-meta text-ui-ink",children:[e.jsx(K,{checked:_,disabled:P,onChange:A=>R(A.target.checked)}),"Plan first"]}),e.jsx(q,{kind:"fix",auth:i==null?void 0:i.auth,anyProvider:!0,provider:u.chosen.provider,children:e.jsx("button",{type:"button",className:se,disabled:P||$.length===0||Y.on&&Y.query.isLoading,onClick:Je,children:_?"Make a plan":"Start fix"})}),e.jsx("span",{className:"text-meta text-ui-mute",children:$.length===0?"Nothing ticked.":`${$.length-ce} item${$.length-ce===1?"":"s"}`}),(j==null?void 0:j.status)==="succeeded"&&e.jsx("button",{type:"button",className:ee,onClick:()=>W(!1),children:"Close"})]})]}),S&&e.jsx("button",{type:"button",className:ee,onClick:()=>E.mutate(),children:"Cancel"}),(C.isError||B.isError)&&e.jsx("p",{className:"mt-1 text-meta text-ui-danger",children:te(C.error??B.error)}),j&&d&&e.jsx(lt,{pr:s,fix:j,liveStatus:p,passRunning:b,auth:i==null?void 0:i.auth}),S&&e.jsxs("div",{className:"mt-3",children:[j&&e.jsx(He,{fix:j}),e.jsx(ie,{active:!0,label:"Running AI fix",value:Ee(p),timeConstantSec:40}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-meta text-ui-mute",children:[(j==null?void 0:j.trigger)==="auto"&&e.jsx(qe,{}),_e[((fe=p==null?void 0:p.progress)==null?void 0:fe.phase)??""]??"Working…"]}),e.jsx(Me,{lines:(ge=p==null?void 0:p.progress)==null?void 0:ge.recentActivity,runKey:(j==null?void 0:j.id)??null,className:"mt-1"})]}),!S&&j&&!d&&e.jsx(It,{pr:s,fix:j,headInfo:(i==null?void 0:i.headInfo)??null,viewerCanPush:(i==null?void 0:i.viewerCanPush)??!1}),l&&!j&&e.jsx("p",{className:"mt-3 text-meta text-ui-mute",children:"Loading…"})]}),e.jsx(Tt,{history:(i==null?void 0:i.history)??[],currentFixId:((je=i==null?void 0:i.fix)==null?void 0:je.id)??null})]})]})}function qe(){return e.jsx("span",{className:"inline-flex items-center rounded-ui bg-ui-raise px-1.5 py-px text-meta font-medium text-ui-mute",children:"Auto fix"})}function Ft(s){return Te(s.provider,s.model,s.effort)}function It({pr:s,fix:t,headInfo:n,viewerCanPush:a}){var o,g,c;const i=x.useMemo(()=>Ws(t.patch),[t.patch]);if(t.status==="failed"&&((o=t.plan)==null?void 0:o.status)==="failed")return e.jsxs("div",{className:"mt-3 rounded-ui border border-ui-danger/40 bg-ui-danger/10 p-2 text-meta text-ui-danger",children:[G(t.plan??t)," could not make a plan: ",t.error??"unknown error"]});if(t.status==="cancelled"&&((g=t.plan)==null?void 0:g.status)==="discarded")return e.jsx("p",{className:"mt-3 text-meta text-ui-mute",children:"The plan was discarded."});if(t.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: ",t.error??"unknown error"]});if(t.status==="cancelled")return e.jsx("p",{className:"mt-3 text-meta text-ui-mute",children:"The fix run was cancelled."});if(t.status!=="succeeded")return e.jsx(e.Fragment,{});const l=!t.patch||t.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:[t.trigger==="auto"&&e.jsxs(e.Fragment,{children:[e.jsx(qe,{})," "]}),ht(t)," · ",Ft(t),t.finishedAt&&e.jsxs(e.Fragment,{children:[" · ",ae(t.finishedAt)]})]}),t.pushedAt==null&&t.error&&e.jsx("p",{className:"mb-2 rounded-ui bg-ui-raise p-2 text-meta text-ui-warn",children:t.error}),e.jsx(He,{fix:t}),t.summary&&e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(Ys,{children:t.summary})}),e.jsx(xt,{pr:s,fix:t}),e.jsx(zs,{checks:t.checks}),l?e.jsx("p",{className:"mt-2 text-meta text-ui-mute",children:"No files changed."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-1 mt-2 flex items-center justify-between gap-3 text-meta text-ui-mute",children:[e.jsxs("span",{children:[t.filesChanged.length," file",t.filesChanged.length===1?"":"s"," changed",!((c=t.checks)!=null&&c.ran)&&" · Not built or tested here."]}),e.jsx(qs,{})]}),e.jsx("div",{className:"overflow-hidden rounded-ui bg-ui-surface text-ui-ink",children:e.jsx(Ks,{files:i})}),e.jsx(Et,{pr:s,fix:t,headInfo:n,viewerCanPush:a})]})]})}function St({fix:s}){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:s.pushedBranch}),s.pushedPrUrl&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("a",{href:Oe(s.pushedPrUrl),target:"_blank",rel:"noreferrer",className:"hit underline",children:["PR #",s.pushedPrNumber]})]}),s.pushedAt&&e.jsxs(e.Fragment,{children:[" · ",ae(s.pushedAt)]})]}),s.commitMessage&&e.jsx("div",{className:"mt-1 font-mono text-meta text-ui-success",children:s.commitMessage})]})}function Tt({history:s,currentFixId:t}){const n=s.filter(a=>a.pushedAt!=null&&a.id!==t);return n.length===0?null:e.jsxs("div",{className:"mt-6",children:[e.jsx("div",{className:"mb-2 text-title text-ui-ink",children:"Earlier fixes pushed"}),e.jsx("ul",{className:"space-y-2",children:n.map(a=>e.jsxs("li",{className:"text-meta",children:[e.jsx("div",{className:"font-mono text-ui-ink",children:a.commitMessage??"(no commit message)"}),e.jsxs("div",{className:"mt-0.5 text-meta text-ui-faint",children:[a.pushedBranch&&e.jsx("span",{className:"font-mono",children:a.pushedBranch}),a.pushedPrUrl&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("a",{href:Oe(a.pushedPrUrl),target:"_blank",rel:"noreferrer",className:"hit underline",children:["PR #",a.pushedPrNumber]})]}),a.pushedAt&&e.jsxs(e.Fragment,{children:[" · ",ae(a.pushedAt)]})]})]},a.id))})]})}function Et({pr:s,fix:t,headInfo:n,viewerCanPush:a}){const i=Vs(s.id),l=(n==null?void 0:n.canPushSameBranch)??!1,[o,g]=x.useState(l?"existing":"new"),[c,m]=x.useState((n==null?void 0:n.suggestedBranch)??""),v=x.useRef(!1);if(x.useEffect(()=>{!v.current&&(n!=null&&n.suggestedBranch)&&(m(n.suggestedBranch),v.current=!0,n.canPushSameBranch||g("new"))},[n]),t.pushedAt!=null)return e.jsx(St,{fix:t});if(!a)return e.jsx("p",{className:"mt-2 text-meta text-ui-mute",children:"You need write access to push this fix."});const F=o==="new"&&c.trim().length===0,u=i.isPending,k=()=>{i.mutate({fixId:t.id,body:{target:o,branch:o==="new"?c.trim():void 0}})};return e.jsxs("div",{className:"mt-3 rounded-ui bg-ui-surface p-2",children:[t.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:t.commitMessage}),e.jsxs("label",{className:`flex items-center gap-2 text-meta ${l?"":"opacity-40"}`,title:l?void 0:"The PR head is a fork you cannot push to — use a new branch",children:[e.jsx(ve,{className:"mt-0",checked:o==="existing",disabled:!l||u,onChange:()=>g("existing")}),"Push to the PR branch",(n==null?void 0:n.headRef)&&e.jsxs("span",{className:"font-mono text-ui-faint",children:["(",n.headRef,")"]})]}),e.jsxs("label",{className:"mt-1 flex items-center gap-2 text-meta",children:[e.jsx(ve,{className:"mt-0",checked:o==="new",disabled:u,onChange:()=>g("new")}),"New branch + open a PR"]}),o==="new"&&e.jsx("input",{type:"text",className:"mt-1 w-full rounded-ui bg-ui-raise px-2 py-1 font-mono text-meta ring-1 ring-inset ring-ui-line focus:outline-none focus:ring-2 focus:ring-ui-accent touch:min-h-10",value:c,disabled:u,onChange:M=>m(M.target.value),placeholder:"branch-name"}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",className:se,disabled:u||F,onClick:k,children:u?"Pushing…":o==="new"?"Push + open PR":"Push"}),e.jsx(Gs,{checks:t.checks})]}),i.isError&&e.jsx("div",{className:"mt-2 text-meta text-ui-danger",children:te(i.error)})]})}export{Ot as AiFixTab};
|
|
1
|
+
import{d as Ie,r as x,j as e}from"./tanstack-BnbsafB1.js";import{aY as G,aX as Qe,cV as be,d0 as Ze,cC as es,cT as ss,cE as Se,aR as ts,cU as O,A as Ne,aW as Te,W as ne,y as ns,a7 as is,an as ie,bw as Ee,a3 as _e,e as Me,f as q,a6 as as,aU as Be,i as Le,s as rs,k as ls,a as cs,C as os,dz as us,c2 as ds,aZ as ms,dr as hs,ds as xs,$ as ps,J as fs,V as gs,v as K,bL as js,cS as bs,cR as Ns,cB as vs,bo as ws,c3 as ks,az as ys,bn as Rs,bc as Ps,cd as Ue,bO as Cs,cx as $e,cy as As,cL as Fs,c_ as Is,cZ as Ss,dj as Ts,dk as Es,aV as _s,aS as Ms,cA as Bs,cz as Ls,cM as Us,dg as $s,au as Os,a0 as Ds,aT as Hs,bS as Ws,c0 as ae,X as Ys,w as zs,N as qs,U as Ks,c8 as Oe,d8 as Vs,aj as ve,x as Gs,L as Xs}from"./index-De8TkiUU.js";import{r as Js,t as Qs,S as Zs,C as et,T as st,F as tt,f as nt}from"./ClaudeReviewTab-tgm-D75c.js";import"./markdown-CcoLFczy.js";import"./highlight-DIEV0qGG.js";import"./vis-C3BCkP5U.js";const it="inline-flex h-7 items-center whitespace-nowrap rounded-ui bg-ui-raise px-2.5 text-meta font-medium text-ui-ink hover:bg-ui-hover disabled:cursor-not-allowed disabled:opacity-50 touch:h-10 touch:px-3",we="inline-flex h-7 items-center whitespace-nowrap rounded-ui bg-ui-raise px-2.5 text-meta font-medium text-ui-ink hover:bg-ui-hover disabled:cursor-not-allowed disabled:opacity-50 touch:h-10 touch:px-3",ke="inline-flex items-center rounded-ui bg-ui-raise px-1.5 py-px font-mono text-meta text-ui-ink";function at(s){return s instanceof Le||s instanceof Error?s.message:"Something went wrong"}function De({plan:s}){return e.jsx("ul",{className:"list-disc space-y-0.5 pl-5 text-body text-ui-ink",children:s.summary.map((t,n)=>e.jsx("li",{children:t},n))})}function ye(s,t){var n;return((n=s==null?void 0:s.find(a=>a.ref===t))==null?void 0:n.title)??null}function rt({plan:s,items:t}){return e.jsxs("div",{className:"mt-2 space-y-3 text-meta text-ui-ink",children:[s.steps.length>0&&e.jsx("ol",{className:"list-decimal space-y-2 pl-5",children:s.steps.map((n,a)=>e.jsxs("li",{children:[e.jsx("div",{className:"font-medium text-ui-ink",children:n.title}),n.files.length>0&&e.jsx("div",{className:"mt-0.5 font-mono text-meta text-ui-mute",children:n.files.join(", ")}),e.jsx("p",{className:"mt-0.5 whitespace-pre-wrap",children:n.change}),n.refs.length>0&&e.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:n.refs.map(i=>e.jsx("span",{className:ke,children:i},i))})]},a))}),s.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:s.notAddressed.map(n=>e.jsxs("li",{children:[e.jsx("span",{className:ke,children:n.ref})," ",ye(t,n.ref)&&e.jsxs("span",{className:"font-medium",children:[ye(t,n.ref),": "]}),n.reason]},n.ref))})]}),s.notCovered.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"font-semibold text-ui-mute",children:"Not in the plan: "}),s.notCovered.join(", ")]})]})}function lt({pr:s,fix:t,liveStatus:n,passRunning:a,auth:i}){var w,p;const l=t.plan,o=G(t.plan??t),g=Qe((t.plan??t).provider,(t.plan??t).model),c=be(g,"plan"),m=be(g,"fix"),v=Be(c),F=Ze(s.id),u=es(s.id),k=ss(s.id),M=Se(s.id),C=Ie({mutationKey:ts(s.id)})>0,B=O(N=>N.noteAiFixRun),[E,I]=x.useState(""),[y,D]=x.useState(!1);if(!l)return null;const R=l.plan,_=l.status==="plan_ready"&&!a,L=E.trim(),P=L.length>Ne,r=()=>{!_||C||L===""||P||F.mutate({fixId:t.id,text:L},{onSuccess:()=>I("")})},d=()=>{B({prId:s.id,repoFullName:s.repoFullName,prNumber:s.number,prTitle:s.title}),u.mutate(t.id)},f=F.error??u.error??k.error;return e.jsxs("div",{className:"mt-3 rounded-ui bg-ui-surface p-3",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1 text-meta font-semibold text-ui-ink",children:["Plan",R&&l.revision>1&&e.jsxs("span",{className:"font-normal text-ui-mute",children:["· version ",l.revision]}),l.model&&e.jsxs("span",{className:"font-normal text-ui-mute",children:["· ",Te(l.provider,l.model,l.effort)]}),e.jsxs(ne,{title:"Plan first",children:[e.jsxs("p",{children:[v," reads the code and writes a plan. It changes nothing."]}),e.jsxs("p",{children:["Tell ",v," what to change and it rewrites the plan, taking the whole conversation into account. Each message runs ",v," again."]}),e.jsxs("p",{children:["When you approve, ",v," builds the fix from this plan. You still review the diff and press Push."]})]})]}),R?e.jsxs(e.Fragment,{children:[e.jsx(De,{plan:R}),e.jsxs("button",{type:"button",className:"hit mt-2 inline-flex items-center gap-1 text-meta text-ui-mute hover:text-ui-ink","aria-expanded":y,onClick:()=>D(N=>!N),children:[e.jsx(ns,{dir:y?"down":"right"}),"Details"]}),y&&e.jsx(rt,{plan:R,items:t.reviewItems})]}):!a&&e.jsx("p",{className:"text-meta text-ui-mute",children:"No plan yet."}),t.error&&e.jsx("p",{className:"mt-2 rounded-ui bg-ui-raise p-2 text-meta text-ui-warn",children:t.error}),e.jsx(is,{transcript:l.transcript,plannedBy:o}),a&&e.jsxs("div",{className:"mt-3",children:[e.jsx(ie,{active:!0,label:R?"Updating the plan":"Making the plan",value:Ee(n),timeConstantSec:30}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-meta text-ui-mute",children:[_e[((w=n==null?void 0:n.progress)==null?void 0:w.phase)??""]??"Working…",e.jsx("button",{type:"button",className:we,onClick:()=>M.mutate(),children:"Cancel"})]}),e.jsx(Me,{lines:(p=n==null?void 0:n.progress)==null?void 0:p.recentActivity,className:"mt-1"})]}),_&&R&&e.jsxs("div",{className:"mt-3",children:[e.jsx(q,{kind:"plan",auth:i,meter:!1,followUp:!0,provider:c,children:e.jsx(as,{name:v,draft:E,setDraft:I,busy:C,maxChars:Ne,onSend:r})}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx(q,{kind:"fix",auth:i,followUp:!0,provider:m,children:e.jsx("button",{type:"button","data-ai-run":!0,className:it,disabled:C,onClick:d,children:"Approve and build"})}),e.jsx("button",{type:"button",className:we,disabled:C,onClick:()=>k.mutate(t.id),children:"Discard plan"})]})]}),f!=null&&e.jsx("p",{className:"mt-1 text-meta text-ui-danger",children:at(f)})]})}function He({fix:s}){var n;const t=((n=s.plan)==null?void 0:n.status)==="approved"?s.plan.plan:null;return t?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(De,{plan:t})]}):null}function ct(s,t,n){var a;return s??((t==null?void 0:t.status)==="succeeded"?t.id:((a=n.find(i=>i.status==="succeeded"))==null?void 0:a.id)??null)}function ot(s,t,n){return t==null||n==null||t===n.id?null:s!=null?"Uses the review you picked, not the latest.":n.status==="failed"?"Uses the last review that finished. The latest one failed.":n.status==="running"||n.status==="queued"?"Uses the last review that finished. A newer one is running.":"Uses the last review that finished."}const Re=os,ut=ls;function dt(s){return s.kind==="finding"&&s.findingId!=null?`claude-finding-${s.findingId}`:null}function mt(s){const t=O(n=>n.openClaudeReview);return n=>{t({id:s.id,number:s.number,title:s.title,repoFullName:s.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null});const a=Date.now()+3e3,i=()=>{const l=document.getElementById(n);if(l){l.scrollIntoView({behavior:"smooth",block:"center"});return}Date.now()<a&&requestAnimationFrame(i)};requestAnimationFrame(i)}}function Pe({refId:s,item:t,onJump:n}){const a=t?`${cs[t.kind]} ${s}`:s,i=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"shrink-0",children:a}),t&&e.jsxs("span",{className:"min-w-0 truncate font-normal",children:["· ",t.title]})]}),l=t?dt(t):null;return l?e.jsx("button",{type:"button",onClick:()=>n(l),"aria-label":`${a}: ${(t==null?void 0:t.title)??""}. Show in AI Review`,className:`${Re} max-w-[22rem] hover:bg-ui-hover`,children:i}):e.jsx("span",{className:`${Re} max-w-[22rem]`,children:i})}function ht(s){var t;switch(s.seed){case"review":{const n=((t=s.reviewItems)==null?void 0:t.length)??0;return`Fix from ${s.sourceReviewId==null?"the CI check":"the AI review"}${n>0?` (${n} item${n===1?"":"s"})`:""}.`}case"plain":return"Fix from your instruction.";case"comments":return"Fix from picked comments (no longer offered).";case"ci_analysis":return"Fix from the CI analysis (no longer offered).";default:return""}}function xt({pr:s,fix:t}){const n=G(t),a=mt(s),i=t.changeReport,l=new Map((t.reviewItems??[]).map(c=>[c.ref,c])),o=(t.reviewItems??[]).filter(c=>!c.included);if(!i&&o.length===0)return null;const g=l.size>0;return e.jsxs("div",{className:"mt-2 text-meta",children:[e.jsx(rs,{report:i,filesChanged:t.filesChanged,by:n,refsInfo:g?e.jsx("p",{children:"Each tag is a review item the change answers. A finding tag opens it in the AI Review tab."}):null,renderRef:c=>e.jsx(Pe,{refId:c,item:l.get(c),onJump:a},c)}),o.length>0&&e.jsxs("section",{children:[e.jsxs("div",{className:ut,children:["Left out",e.jsx(ne,{title:"Left out",children:e.jsxs("p",{children:["These review items did not fit in what ",n," was sent, so it never saw them."]})})]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:o.map(c=>e.jsx(Pe,{refId:c.ref,item:c,onJump:a},c.ref))})]})]})}const pt=["findings","earlier_findings","judged_threads","untouched_threads","ci_failures","sonar","style_bots","story"],ft={findings:"Claude’s findings",earlier_findings:"Earlier findings still open",judged_threads:"Threads Claude says need a fix",untouched_threads:"Unanswered threads",ci_failures:"CI failures",sonar:"SonarCloud issues",style_bots:"Style bot comments",story:"Ticket gaps"};function Ce(s,t="Claude"){return s==="findings"?`${t}’s findings`:s==="judged_threads"?`Threads ${t} says need a fix`:ft[s]}function V(s,t){return t[s.key]??s.defaultIncluded}function gt(s,t){return s.items.filter(n=>V(n,t)).map(n=>n.key)}function We(s,t){const n=new Set;let a=0;for(const i of s.items)if(V(i,t)){if(a>0&&a+i.chars>s.budgetChars){n.add(i.key);continue}a+=i.chars}return n}function jt(s,t){const n={};for(const a of s.items)n[a.key]=a.section===t;return n}const bt={blocker:"Blocker",warning:"Warning",nit:"Nit",question:"Question",praise:"Praise"},Ae={blocker:"bg-ui-danger/10 text-ui-danger",warning:"bg-ui-raise text-ui-warn",nit:"bg-ui-raise text-ui-mute"},Ye="whitespace-nowrap rounded-ui bg-ui-raise px-1 py-px text-meta text-ui-warn",Z=new Set;function Nt(s,t){return s?t!=null?`${s}:${t}`:s:null}function vt({item:s,picked:t,cut:n,disabled:a,onToggle:i}){return e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5 pt-0.5",children:[e.jsx("label",{className:"flex cursor-pointer items-center touch:-my-3 touch:min-h-10 touch:min-w-10 touch:justify-center",children:e.jsx(K,{checked:t,disabled:a,onChange:l=>i(l.target.checked),"aria-label":`Include in the fix: ${s.label}`})}),t&&n&&e.jsx("span",{className:Ye,children:"Won’t fit"})]})}function wt({item:s,picked:t,cut:n,disabled:a,onToggle:i}){const l=Nt(s.path,s.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 ${t?"border-ui-line bg-ui-sel":"border-ui-line"}`,children:[e.jsx(K,{className:"mt-0.5",checked:t,disabled:a,onChange:o=>i(o.target.checked)}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"flex flex-wrap items-center gap-1.5",children:[s.severity&&Ae[s.severity]&&e.jsx("span",{className:`rounded-ui px-1 py-px text-meta font-medium ${Ae[s.severity]}`,children:bt[s.severity]}),e.jsx("span",{className:"break-words text-ui-ink",children:s.label}),t&&n&&e.jsx("span",{className:Ye,children:"Won’t fit"})]}),(l||s.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&&s.detail?" · ":"",s.detail]})]})]})})}function kt({preview:s,overrides:t,onChange:n,disabled:a,pr:i,review:l}){const o=We(s,t),g=new Map;for(const r of s.items){const d=g.get(r.section)??[];d.push(r),g.set(r.section,d)}const c=(r,d)=>{const f={...t};for(const w of r)f[w]=d;n(f)},m=l!=null&&l.id===s.sourceReviewId?l:null,v=Js(l),F=Qs(l),u=x.useMemo(()=>m!=null?us(m):null,[m]),k=x.useMemo(()=>new Map(((u==null?void 0:u.findings)??[]).map(r=>[r.id,r])),[u]),M=x.useMemo(()=>{var r;return new Map((((r=u==null?void 0:u.followUp)==null?void 0:r.items)??[]).map(d=>[d.priorFindingId,d]))},[u]),C=x.useMemo(()=>u!=null?ds(u):new Map,[u]),B=x.useMemo(()=>u!=null?ms(u):new Set,[u]),E=x.useMemo(()=>{var d;const r=new Set;for(const f of s.items)((d=f.card)==null?void 0:d.kind)==="story"&&r.add(f.card.ticketReviewId);return[...r].sort((f,w)=>f-w)},[s.items]),I=hs(i.id,E.length>0),y=x.useMemo(()=>{var d;const r=new Map;for(const f of((d=I.data)==null?void 0:d.tickets)??[])f.review!=null&&r.set(f.review.id,f.review);return r},[I.data]),D=x.useMemo(()=>I.data==null?[]:E.filter(r=>!y.has(r)),[I.data,E,y]),R=xs(D),_=x.useMemo(()=>{const r=new Map(y);for(const d of R)r.set(d.id,d);return r},[y,R]);if(s.items.length===0)return e.jsx("p",{className:"text-meta text-ui-mute",children:"The review found nothing to fix."});const L=(m==null?void 0:m.headSha)??i.headSha,P=r=>{var H,S;const d=V(r,t),f=o.has(r.key),w=b=>c([r.key],b),p=e.jsx(vt,{item:r,picked:d,cut:f,disabled:a,onToggle:w}),N=r.card;switch(N==null?void 0:N.kind){case"finding":{const b=k.get(N.findingId);if(b==null)break;return e.jsx(tt,{authorName:nt(l,b),prId:i.id,finding:b,editable:!1,prUrl:i.githubUrl,repoFullName:i.repoFullName,headSha:L,posting:!1,postError:null,inChangeset:b.fileInDiff,priorStatus:C.get(b.id),alreadyPosted:B.has(b.id),actions:!1,selection:p,docReferences:(m==null?void 0:m.docReferences)??null},r.key)}case"earlier_finding":{const b=M.get(N.priorFindingId);if(b==null)break;return e.jsx(gs,{item:b,muted:!1,findingsById:k,headMoved:((H=u==null?void 0:u.followUp)==null?void 0:H.headMoved)??!1,changedPaths:Z,actions:!1,selection:p,by:v},r.key)}case"thread":return e.jsx(st,{t:N.assessment,muted:!1,actions:!1,selection:p,notCheckedNote:N.inReview?void 0:`${F} didn’t check this one.`,by:F},r.key);case"ci":return e.jsx(et,{f:N.item,suggestion:N.item.suggestion,changedPaths:Z,selection:p},r.key);case"sonar":return e.jsx(Zs,{issue:N.issue,selection:p},r.key);case"story":{const b=_.get(N.ticketReviewId),T=b==null?void 0:b.items.find(U=>U.id===N.itemId);if(b==null||T==null)break;const j={review:b,viewedPrId:i.id,changedPaths:Z,actions:!1,selection:p};if(T.status==="missing")return e.jsx(ps,{item:T,...j},r.key);const h=(S=b.assessment)==null?void 0:S.criteria.find(U=>U.ref===T.ref);if(h==null||h.status==="met")break;return e.jsx(fs,{c:h,item:T,...j},r.key)}}return e.jsx(wt,{item:r,picked:d,cut:f,disabled:a,onToggle:w},r.key)};return e.jsxs("div",{className:"space-y-3",children:[pt.filter(r=>g.has(r)).map(r=>{const d=g.get(r),f=d.filter(p=>V(p,t)).length,w=f===d.length;return e.jsxs("section",{"aria-label":Ce(r,v),children:[e.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[e.jsx("h4",{className:"text-meta font-semibold text-ui-ink",children:Ce(r,v)}),e.jsxs("span",{className:"text-meta text-ui-mute",children:[f," of ",d.length]}),e.jsx("button",{type:"button",className:"hit ml-auto text-meta text-ui-accent hover:underline disabled:opacity-50",disabled:a,onClick:()=>c(d.map(p=>p.key),!w),children:w?"Untick all":"Tick all"})]}),e.jsx("ul",{className:"space-y-1.5",children:d.map(P)})]},r)}),o.size>0&&e.jsxs("p",{className:"text-meta text-ui-warn",children:[o.size," ticked ",o.size===1?"item does":"items do"," not fit in one fix and will be left out. Untick something to make room."]})]})}const 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",Fe="inline-flex h-7 items-center whitespace-nowrap rounded-ui bg-ui-raise px-2.5 text-meta font-medium text-ui-ink hover:bg-ui-hover disabled:cursor-not-allowed disabled:opacity-50 touch:h-10 touch:px-3";function ze(s){return{prId:s.id,repoId:s.repoId,repoFullName:s.repoFullName,prNumber:s.number,prTitle:s.title,githubUrl:s.githubUrl}}function Rt(s){const t=js({mergeable:s.mergeable,mergeStateStatus:s.mergeStateStatus,isDraft:s.isDraft,inMergeQueue:s.inMergeQueue===!0}).verdict;return bs({state:s.state,verdict:t,viewerCanPush:s.viewerCanPush})}function Pt({pr:s}){const t=Ns(s.id),n=vs(),a=ws(t),i=s.baseRefName??"the base branch";x.useEffect(()=>{ks(s.id)},[s.id]);const l=ze(s),o=(t==null?void 0:t.phase)==="succeeded"?t.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(ys,{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&&t!=null?e.jsxs("div",{className:"mt-2",children:[e.jsx(ie,{active:!0,label:`Resolving conflicts with ${n}`,timeConstantSec:60}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-meta text-ui-mute",children:[Rs(t.phase,n),e.jsx("button",{type:"button",className:Fe,onClick:()=>Ps(s.id),children:"Cancel"})]})]}):e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx(q,{kind:"resolve",children:e.jsx("button",{type:"button",className:yt,onClick:()=>Ue(l,{providerName:n}),children:o!=null?"Run again":`Resolve merge conflicts with ${n}`})}),o!=null&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:Fe,onClick:()=>Cs(l),children:"Open the resolver"}),e.jsxs("span",{className:"text-meta text-ui-mute",children:[G(o)," decided ",o.choices.length," of ",o.decidableTotal," change",o.decidableTotal===1?"":"s","."]})]}),(t==null?void 0:t.phase)==="failed"&&t.error!=null&&e.jsx("span",{className:"text-meta text-ui-danger",children:t.error}),(t==null?void 0:t.phase)==="cancelled"&&e.jsx("span",{className:"text-meta text-ui-mute",children:"Cancelled."})]})]})}const se="inline-flex h-7 items-center whitespace-nowrap rounded-ui bg-ui-raise px-2.5 text-meta font-medium text-ui-ink hover:bg-ui-hover disabled:cursor-not-allowed disabled:opacity-50 touch:h-10 touch:px-3";function te(s){return s instanceof Le||s instanceof Error?s.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 Ct({children:s,info:t}){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:s}),t]})}function Ot({pr:s}){const t=$e().enabled,n=O(c=>c.aiFixTabFocus),a=O(c=>c.consumeAiFixTabFocus),[i,l]=x.useState(null),[o,g]=x.useState(null);return x.useEffect(()=>{n&&n.prId===s.id&&(n.reviewId!=null&&l(n.reviewId),n.only!=null&&g(n.only),a())},[n,s.id,a]),t?e.jsx("div",{className:"pb-6",children:e.jsx(At,{pr:s,handoffReviewId:i,onlySection:o,onOnlySectionApplied:()=>g(null)})}):e.jsx(e.Fragment,{})}function At({pr:s,handoffReviewId:t,onlySection:n,onOnlySectionApplied:a}){var oe,ue,de,me,he,xe,pe,fe,ge,je;const{data:i,isLoading:l}=As(s.id,!0),{data:o,isLoading:g}=Fs(s.id),c=(o==null?void 0:o.review)??null,m=ct(t,c,(o==null?void 0:o.history)??[]),v=ot(t,m,c),F=O(A=>A.setPrDetailTab),u=Is("fix",Xs),k=Be(u.chosen.provider),M=Ss().data,C=Ts(s.id),B=Es(s.id),E=Se(s.id),I=$e(),y=_s(M,u.chosen.provider,"plan"),[D,R]=x.useState(!1),_=D&&y,L=O(A=>A.noteAiFixRun),P=Ie({mutationKey:Ms(s.id)})>0,r=((oe=i==null?void 0:i.fix)==null?void 0:oe.status)??null,d=r==="planned",f=d&&((de=(ue=i==null?void 0:i.fix)==null?void 0:ue.plan)==null?void 0:de.status)==="planning",w=r==="running"||r==="queued"||P||f,{status:p}=Bs(s.id,w),N=(p==null?void 0:p.status)??r??"idle",H=N==="running"||N==="queued",S=H&&!d,b=d&&(f||H),T=d&&(((he=(me=i==null?void 0:i.fix)==null?void 0:me.plan)==null?void 0:he.status)==="planning"||((pe=(xe=i==null?void 0:i.fix)==null?void 0:xe.plan)==null?void 0:pe.status)==="plan_ready"),j=(i==null?void 0:i.fix)??null,h=Ls(s.id,m,(i==null?void 0:i.enabled)!==!1&&(m!=null||!g)),U=m==null&&h.data!=null&&h.data.sourceReviewId==null&&h.data.items.length>0,z=m!=null||U,Ke=Us(m!=null&&(c==null?void 0:c.id)!==m?m:null),Ve=m!=null&&(c==null?void 0:c.id)===m?c:Ke.data??null,[X,J]=x.useState({});x.useEffect(()=>J({}),[m]);const[Ge,W]=x.useState(!1);x.useEffect(()=>{n==null||!h.data||(J(jt(h.data,n)),W(!0),a())},[n,h.data,a]);const re=!T&&(Ge||!j||j.status!=="succeeded"),Q=Rt(s),[le,Xe]=x.useState(!1),Y=$s(s.id,s.repoFullName),$=h.data?gt(h.data,X):[],ce=h.data?We(h.data,X).size:0,Je=()=>{if(!z||!h.data||$.length===0)return;const A={model:u.chosen.model,provider:u.chosen.provider,seed:"review",...m!=null?{sourceReviewId:m}:{},include:$,...Y.names.length>0?{checks:Y.names}:{}};_?B.mutate(A,{onSuccess:()=>W(!1)}):(L({prId:s.id,repoFullName:s.repoFullName,prNumber:s.number,prTitle:s.title}),C.mutate(A,{onSuccess:()=>W(!1)})),le&&Q&&Ue(ze(s),{model:Hs(u.chosen.model),providerName:I.providerName})};return e.jsxs("div",{children:[e.jsx(Ct,{info:e.jsxs(ne,{title:"AI Fix",children:[e.jsxs("p",{children:[k," reads the PR's code and edits files in a private copy. It has no shell. Tick Run tests to let it run the project's own test, lint and type checks in a sandbox."]}),e.jsx("p",{children:"A fix starts from an AI review. Pick what it should work on: the review's findings, earlier findings still open, threads the review says need a fix, unanswered threads, CI failures and ticket gaps are ticked; style bot comments are not."}),e.jsx("p",{children:"With no AI review, a fix can start from a finished CI check: it works on the failures the check says this PR can fix."}),e.jsxs("p",{children:["Tick Plan first to read ",k,"'s plan, steer it and approve it before anything changes."]}),e.jsxs("p",{children:[k," reports what it changed in each file and what it left alone, and why."]}),e.jsx("p",{children:"Nothing is pushed until you press Push. An automatic fix on your own PR is pushed for you only when Push automatically is on in Settings."})]}),children:"AI Fix"}),e.jsxs("div",{className:"px-4",children:[Q&&e.jsx(Pt,{pr:s}),(i==null?void 0:i.enabled)===!1?e.jsx("p",{className:"text-body text-ui-mute",children:"The agentic fixer is turned off."}):e.jsxs(e.Fragment,{children:[!S&&!T&&!z&&!g&&!h.isLoading&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-meta text-ui-mute",children:(c==null?void 0:c.status)==="running"||(c==null?void 0:c.status)==="queued"?"A fix starts from an AI review. One is running.":"A fix starts from a finished AI review."}),e.jsx("button",{type:"button",className:se,onClick:()=>F(s.id,"claude_review"),children:"Open AI Review"})]}),!S&&!T&&z&&!re&&e.jsx("button",{type:"button",className:ee,onClick:()=>W(!0),children:"New fix"}),!S&&z&&re&&e.jsxs("div",{children:[v&&e.jsx("p",{className:"mb-2 text-meta text-ui-mute",children:v}),U&&e.jsx("p",{className:"mb-2 text-meta text-ui-mute",children:"No AI review yet. This fix works on the CI check’s failures."}),h.isLoading&&e.jsx("p",{className:"text-meta text-ui-mute",children:"Loading…"}),h.isError&&m!=null&&e.jsx("p",{className:"text-meta text-ui-danger",children:te(h.error)}),h.data&&e.jsx(kt,{preview:h.data,overrides:X,onChange:J,disabled:P,pr:s,review:Ve}),h.data&&h.data.items.length>0&&Q&&e.jsxs("label",{className:"mt-3 flex cursor-pointer items-start gap-2 text-meta text-ui-ink",children:[e.jsx(K,{className:"mt-0.5",checked:le,disabled:P,onChange:A=>Xe(A.target.checked)}),e.jsxs("span",{children:["Also resolve merge conflicts with ",s.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."})]})]}),h.data&&h.data.items.length>0&&e.jsx(Os,{state:Y,disabled:P}),h.data&&h.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(Ds,{state:u,onPick:u.pick,disabled:P}),y&&e.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5 text-meta text-ui-ink",children:[e.jsx(K,{checked:_,disabled:P,onChange:A=>R(A.target.checked)}),"Plan first"]}),e.jsx(q,{kind:"fix",auth:i==null?void 0:i.auth,anyProvider:!0,provider:u.chosen.provider,children:e.jsx("button",{type:"button",className:se,disabled:P||$.length===0||Y.on&&Y.query.isLoading,onClick:Je,children:_?"Make a plan":"Start fix"})}),e.jsx("span",{className:"text-meta text-ui-mute",children:$.length===0?"Nothing ticked.":`${$.length-ce} item${$.length-ce===1?"":"s"}`}),(j==null?void 0:j.status)==="succeeded"&&e.jsx("button",{type:"button",className:ee,onClick:()=>W(!1),children:"Close"})]})]}),S&&e.jsx("button",{type:"button",className:ee,onClick:()=>E.mutate(),children:"Cancel"}),(C.isError||B.isError)&&e.jsx("p",{className:"mt-1 text-meta text-ui-danger",children:te(C.error??B.error)}),j&&d&&e.jsx(lt,{pr:s,fix:j,liveStatus:p,passRunning:b,auth:i==null?void 0:i.auth}),S&&e.jsxs("div",{className:"mt-3",children:[j&&e.jsx(He,{fix:j}),e.jsx(ie,{active:!0,label:"Running AI fix",value:Ee(p),timeConstantSec:40}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-meta text-ui-mute",children:[(j==null?void 0:j.trigger)==="auto"&&e.jsx(qe,{}),_e[((fe=p==null?void 0:p.progress)==null?void 0:fe.phase)??""]??"Working…"]}),e.jsx(Me,{lines:(ge=p==null?void 0:p.progress)==null?void 0:ge.recentActivity,runKey:(j==null?void 0:j.id)??null,className:"mt-1"})]}),!S&&j&&!d&&e.jsx(It,{pr:s,fix:j,headInfo:(i==null?void 0:i.headInfo)??null,viewerCanPush:(i==null?void 0:i.viewerCanPush)??!1}),l&&!j&&e.jsx("p",{className:"mt-3 text-meta text-ui-mute",children:"Loading…"})]}),e.jsx(Tt,{history:(i==null?void 0:i.history)??[],currentFixId:((je=i==null?void 0:i.fix)==null?void 0:je.id)??null})]})]})}function qe(){return e.jsx("span",{className:"inline-flex items-center rounded-ui bg-ui-raise px-1.5 py-px text-meta font-medium text-ui-mute",children:"Auto fix"})}function Ft(s){return Te(s.provider,s.model,s.effort)}function It({pr:s,fix:t,headInfo:n,viewerCanPush:a}){var o,g,c;const i=x.useMemo(()=>Ws(t.patch),[t.patch]);if(t.status==="failed"&&((o=t.plan)==null?void 0:o.status)==="failed")return e.jsxs("div",{className:"mt-3 rounded-ui border border-ui-danger/40 bg-ui-danger/10 p-2 text-meta text-ui-danger",children:[G(t.plan??t)," could not make a plan: ",t.error??"unknown error"]});if(t.status==="cancelled"&&((g=t.plan)==null?void 0:g.status)==="discarded")return e.jsx("p",{className:"mt-3 text-meta text-ui-mute",children:"The plan was discarded."});if(t.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: ",t.error??"unknown error"]});if(t.status==="cancelled")return e.jsx("p",{className:"mt-3 text-meta text-ui-mute",children:"The fix run was cancelled."});if(t.status!=="succeeded")return e.jsx(e.Fragment,{});const l=!t.patch||t.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:[t.trigger==="auto"&&e.jsxs(e.Fragment,{children:[e.jsx(qe,{})," "]}),ht(t)," · ",Ft(t),t.finishedAt&&e.jsxs(e.Fragment,{children:[" · ",ae(t.finishedAt)]})]}),t.pushedAt==null&&t.error&&e.jsx("p",{className:"mb-2 rounded-ui bg-ui-raise p-2 text-meta text-ui-warn",children:t.error}),e.jsx(He,{fix:t}),t.summary&&e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(Ys,{children:t.summary})}),e.jsx(xt,{pr:s,fix:t}),e.jsx(zs,{checks:t.checks}),l?e.jsx("p",{className:"mt-2 text-meta text-ui-mute",children:"No files changed."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-1 mt-2 flex items-center justify-between gap-3 text-meta text-ui-mute",children:[e.jsxs("span",{children:[t.filesChanged.length," file",t.filesChanged.length===1?"":"s"," changed",!((c=t.checks)!=null&&c.ran)&&" · Not built or tested here."]}),e.jsx(qs,{})]}),e.jsx("div",{className:"overflow-hidden rounded-ui bg-ui-surface text-ui-ink",children:e.jsx(Ks,{files:i})}),e.jsx(Et,{pr:s,fix:t,headInfo:n,viewerCanPush:a})]})]})}function St({fix:s}){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:s.pushedBranch}),s.pushedPrUrl&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("a",{href:Oe(s.pushedPrUrl),target:"_blank",rel:"noreferrer",className:"hit underline",children:["PR #",s.pushedPrNumber]})]}),s.pushedAt&&e.jsxs(e.Fragment,{children:[" · ",ae(s.pushedAt)]})]}),s.commitMessage&&e.jsx("div",{className:"mt-1 font-mono text-meta text-ui-success",children:s.commitMessage})]})}function Tt({history:s,currentFixId:t}){const n=s.filter(a=>a.pushedAt!=null&&a.id!==t);return n.length===0?null:e.jsxs("div",{className:"mt-6",children:[e.jsx("div",{className:"mb-2 text-title text-ui-ink",children:"Earlier fixes pushed"}),e.jsx("ul",{className:"space-y-2",children:n.map(a=>e.jsxs("li",{className:"text-meta",children:[e.jsx("div",{className:"font-mono text-ui-ink",children:a.commitMessage??"(no commit message)"}),e.jsxs("div",{className:"mt-0.5 text-meta text-ui-faint",children:[a.pushedBranch&&e.jsx("span",{className:"font-mono",children:a.pushedBranch}),a.pushedPrUrl&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("a",{href:Oe(a.pushedPrUrl),target:"_blank",rel:"noreferrer",className:"hit underline",children:["PR #",a.pushedPrNumber]})]}),a.pushedAt&&e.jsxs(e.Fragment,{children:[" · ",ae(a.pushedAt)]})]})]},a.id))})]})}function Et({pr:s,fix:t,headInfo:n,viewerCanPush:a}){const i=Vs(s.id),l=(n==null?void 0:n.canPushSameBranch)??!1,[o,g]=x.useState(l?"existing":"new"),[c,m]=x.useState((n==null?void 0:n.suggestedBranch)??""),v=x.useRef(!1);if(x.useEffect(()=>{!v.current&&(n!=null&&n.suggestedBranch)&&(m(n.suggestedBranch),v.current=!0,n.canPushSameBranch||g("new"))},[n]),t.pushedAt!=null)return e.jsx(St,{fix:t});if(!a)return e.jsx("p",{className:"mt-2 text-meta text-ui-mute",children:"You need write access to push this fix."});const F=o==="new"&&c.trim().length===0,u=i.isPending,k=()=>{i.mutate({fixId:t.id,body:{target:o,branch:o==="new"?c.trim():void 0}})};return e.jsxs("div",{className:"mt-3 rounded-ui bg-ui-surface p-2",children:[t.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:t.commitMessage}),e.jsxs("label",{className:`flex items-center gap-2 text-meta ${l?"":"opacity-40"}`,title:l?void 0:"The PR head is a fork you cannot push to — use a new branch",children:[e.jsx(ve,{className:"mt-0",checked:o==="existing",disabled:!l||u,onChange:()=>g("existing")}),"Push to the PR branch",(n==null?void 0:n.headRef)&&e.jsxs("span",{className:"font-mono text-ui-faint",children:["(",n.headRef,")"]})]}),e.jsxs("label",{className:"mt-1 flex items-center gap-2 text-meta",children:[e.jsx(ve,{className:"mt-0",checked:o==="new",disabled:u,onChange:()=>g("new")}),"New branch + open a PR"]}),o==="new"&&e.jsx("input",{type:"text",className:"mt-1 w-full rounded-ui bg-ui-raise px-2 py-1 font-mono text-meta ring-1 ring-inset ring-ui-line focus:outline-none focus:ring-2 focus:ring-ui-accent touch:min-h-10",value:c,disabled:u,onChange:M=>m(M.target.value),placeholder:"branch-name"}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",className:se,disabled:u||F,onClick:k,children:u?"Pushing…":o==="new"?"Push + open PR":"Push"}),e.jsx(Gs,{checks:t.checks})]}),i.isError&&e.jsx("div",{className:"mt-2 text-meta text-ui-danger",children:te(i.error)})]})}export{Ot as AiFixTab};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as t,r as f,k as Fs,e as Ln,d as ds}from"./tanstack-BnbsafB1.js";import{c0 as Ms,bN as ft,b9 as gt,b4 as bt,b5 as jt,a2 as et,aY as De,aU as we,cm as lt,q as Bs,c as Ue,ca as $e,bY as Fn,bG as Mn,ar as Q,aM as Hs,aO as Os,ah as J,bs as Ds,W as te,br as le,S as ce,af as Pe,y as me,aw as Ge,aI as Us,cZ as Bn,b1 as Hn,cB as Rt,bU as On,cq as Dn,cp as Un,ad as ke,bD as Gn,c8 as he,b0 as Gs,bm as Wn,bl as Vn,p as zn,aC as ms,o as Kn,co as qn,aD as Yn,B as Qn,R as We,ai as se,aa as ue,cr as Xn,I as Jn,db as Zn,i as ei,h as Ws,f as xe,a5 as ti,cQ as si,cn as ni,cj as ii,ci as li,ag as Ct,cx as Ne,cH as Vs,di as ai,cJ as ri,cK as oi,cI as ci,bj as qe,cU as zs,bk as ui,bf as di,an as It,bh as mi,m as hi,bi as xi,X as ye,bg as pi,az as Ks,j as Ee,be as fi,as as Ve,g as qs,l as gi,t as Ae,aP as St,d6 as bi,da as ji,d2 as vi,d7 as yi,cY as wi,b_ as ne,b$ as at,G as ki,cc as Ni,aH as hs,bT as Ri,dr as $t,dm as Ci,dp as Ii,dq as Si,dn as $i,cs as Pi,bM as Ei,bp as Ai,bF as Ys,ch as Qs,aF as _i,aE as Ti,K as Li,bZ as Fi,aA as Xs,cu as Mi,aG as Bi,aL as Hi,dl as Js,F as Oi,bW as Zs,ct as Di,cg as Ui,bd as Gi,cv as Wi,dw as Vi,E as zi,bE as Ki,c$ as qi,aB as Yi,J as Qi,_ as Xi,a1 as Ji,P as Zi,a9 as el,bq as tl,ce as sl,bK as nl,cL as il,dd as ll,cW as al,cO as rl,cF as ol,du as cl,dt as ul,d3 as dl,d1 as ml,bu as hl,cP as xl,df as en,cM as pl,aX as Pt,ab as fl,ak as gl,al as Se,a0 as bl,Z as jl,r as vl,d as yl,b3 as xs,bC as wl,bR as kl,am as tn,aQ as Nl,e as Rl,c4 as Cl,b6 as ps,cl as Il,b2 as Sl,Y as sn,ax as $l,bz as Pl,dz as El,bJ as Al,bV as _l,cb as Tl,c2 as Ll,aZ as Fl,by as Ml,c9 as Bl,cG as Hl,d9 as Ol,bI as nn,a_ as Dl,aK as Et,bP as Ul,T as ln,D as Gl,u as Wl,cf as fs,Q as Vl,z as zl,ao as Kl,bt as ql,ae as vt,av as an,n as Yl,aJ as gs,bv as Ql,ck as Xl,a$ as Jl,ac as bs,b as ht,bX as js,c1 as Zl,b7 as vs,O as ea,ay as ta,c5 as sa,cN as na,c6 as ia,aq as la,c7 as aa,d4 as ra,at as oa,a8 as ca,cw as ua,dc as da,dv as ma,de as ha,b8 as xa,dy as pa,dh as fa,bQ as ga,aW as ba,aN as ja,cX as va,bB as ys,bA as ya,bH as wa,dA as rn,bb as ka,a4 as Na,M as Ra}from"./index-
|
|
1
|
+
import{j as t,r as f,k as Fs,e as Ln,d as ds}from"./tanstack-BnbsafB1.js";import{c0 as Ms,bN as ft,b9 as gt,b4 as bt,b5 as jt,a2 as et,aY as De,aU as we,cm as lt,q as Bs,c as Ue,ca as $e,bY as Fn,bG as Mn,ar as Q,aM as Hs,aO as Os,ah as J,bs as Ds,W as te,br as le,S as ce,af as Pe,y as me,aw as Ge,aI as Us,cZ as Bn,b1 as Hn,cB as Rt,bU as On,cq as Dn,cp as Un,ad as ke,bD as Gn,c8 as he,b0 as Gs,bm as Wn,bl as Vn,p as zn,aC as ms,o as Kn,co as qn,aD as Yn,B as Qn,R as We,ai as se,aa as ue,cr as Xn,I as Jn,db as Zn,i as ei,h as Ws,f as xe,a5 as ti,cQ as si,cn as ni,cj as ii,ci as li,ag as Ct,cx as Ne,cH as Vs,di as ai,cJ as ri,cK as oi,cI as ci,bj as qe,cU as zs,bk as ui,bf as di,an as It,bh as mi,m as hi,bi as xi,X as ye,bg as pi,az as Ks,j as Ee,be as fi,as as Ve,g as qs,l as gi,t as Ae,aP as St,d6 as bi,da as ji,d2 as vi,d7 as yi,cY as wi,b_ as ne,b$ as at,G as ki,cc as Ni,aH as hs,bT as Ri,dr as $t,dm as Ci,dp as Ii,dq as Si,dn as $i,cs as Pi,bM as Ei,bp as Ai,bF as Ys,ch as Qs,aF as _i,aE as Ti,K as Li,bZ as Fi,aA as Xs,cu as Mi,aG as Bi,aL as Hi,dl as Js,F as Oi,bW as Zs,ct as Di,cg as Ui,bd as Gi,cv as Wi,dw as Vi,E as zi,bE as Ki,c$ as qi,aB as Yi,J as Qi,_ as Xi,a1 as Ji,P as Zi,a9 as el,bq as tl,ce as sl,bK as nl,cL as il,dd as ll,cW as al,cO as rl,cF as ol,du as cl,dt as ul,d3 as dl,d1 as ml,bu as hl,cP as xl,df as en,cM as pl,aX as Pt,ab as fl,ak as gl,al as Se,a0 as bl,Z as jl,r as vl,d as yl,b3 as xs,bC as wl,bR as kl,am as tn,aQ as Nl,e as Rl,c4 as Cl,b6 as ps,cl as Il,b2 as Sl,Y as sn,ax as $l,bz as Pl,dz as El,bJ as Al,bV as _l,cb as Tl,c2 as Ll,aZ as Fl,by as Ml,c9 as Bl,cG as Hl,d9 as Ol,bI as nn,a_ as Dl,aK as Et,bP as Ul,T as ln,D as Gl,u as Wl,cf as fs,Q as Vl,z as zl,ao as Kl,bt as ql,ae as vt,av as an,n as Yl,aJ as gs,bv as Ql,ck as Xl,a$ as Jl,ac as bs,b as ht,bX as js,c1 as Zl,b7 as vs,O as ea,ay as ta,c5 as sa,cN as na,c6 as ia,aq as la,c7 as aa,d4 as ra,at as oa,a8 as ca,cw as ua,dc as da,dv as ma,de as ha,b8 as xa,dy as pa,dh as fa,bQ as ga,aW as ba,aN as ja,cX as va,bB as ys,bA as ya,bH as wa,dA as rn,bb as ka,a4 as Na,M as Ra}from"./index-De8TkiUU.js";const Ca="https://sonarcloud.io",Ia={blocker:"Blocker",critical:"Critical",major:"Major",minor:"Minor",info:"Info"},Sa={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 At(e){return Sa[e]??e.replace(/^new_/,"").replace(/_/g," ").replace(/^./,s=>s.toUpperCase())}const on=e=>/_rating$/.test(e),$a=e=>/(coverage|density|hotspots_reviewed)$/.test(e);function yt(e,s){const n=Number(s);return Number.isFinite(n)?on(e)?"ABCDE"[Math.round(n)-1]??s:$a(e)?`${Math.round(n*10)/10}%`:String(n):s}function Pa(e){const s=At(e.metric),n=e.actual!=null?yt(e.metric,e.actual):null,l=e.threshold!=null?yt(e.metric,e.threshold):null,o=n!=null?`${s} is ${n}.`:`${s} fails.`;if(l==null)return o;const c=on(e.metric)?`${l} or better`:e.comparator==="LT"?`at least ${l}`:e.comparator==="GT"?`at most ${l}`:l;return`${o} The quality gate needs ${c}.`}function Ea(e){return((e==null?void 0:e.conditions)??[]).filter(s=>s.status==="ERROR"||s.status==="WARN")}const cn=e=>/coverage|uncovered_lines|lines_to_cover/.test(e),Aa=e=>/duplicat/.test(e);function _a(e){return cn(e)||Aa(e)}function Ta(e,s){return Ea(e).filter(n=>_a(n.metric)).map(n=>{const l=cn(n.metric),o=n.files??[],c=o.length>0?`
|
|
2
2
|
|
|
3
3
|
Files with the most ${l?"uncovered":"duplicated"} new lines:
|
|
4
4
|
${o.map(r=>`- ${r.path}: ${r.lines} ${r.lines===1?"line":"lines"}`).join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as w,j as s}from"./tanstack-BnbsafB1.js";import{d5 as j,dc as y,cD as N,W as b,ba as g,dx as k,c0 as v,aP as f,ap as C,H as T,bs as x,bx as $}from"./index-
|
|
1
|
+
import{r as w,j as s}from"./tanstack-BnbsafB1.js";import{d5 as j,dc as y,cD as N,W as b,ba as g,dx as k,c0 as v,aP as f,ap as C,H as T,bs as x,bx as $}from"./index-De8TkiUU.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};
|