limn-review 0.1.157 → 0.1.159

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.
@@ -187,11 +187,7 @@ export function outcomeOf(result) {
187
187
  const ADAPTIVE_CHEAP_MODELS = new Set(['claude-haiku-5-5']);
188
188
  const THINKING_HEADROOM = 1024;
189
189
  /** The model-dependent request shape for one cheap completion (exported for the test). */
190
- export function cheapRequestShape(model, maxTokens,
191
- // A caller's chosen effort (CompleteRequest.effort): sent as asked, with the thinking headroom.
192
- effort) {
193
- if (effort)
194
- return { maxTokens: maxTokens + THINKING_HEADROOM, effort };
190
+ export function cheapRequestShape(model, maxTokens) {
195
191
  return ADAPTIVE_CHEAP_MODELS.has(model)
196
192
  ? { maxTokens: maxTokens + THINKING_HEADROOM, effort: 'low' }
197
193
  : { maxTokens };
@@ -218,7 +214,7 @@ async function complete(req) {
218
214
  async function rawComplete(apiKey, model, opts) {
219
215
  const { default: Anthropic } = await loadAnthropicSdk();
220
216
  const client = new Anthropic({ apiKey });
221
- const shape = cheapRequestShape(model, opts.maxTokens ?? 700, opts.effort);
217
+ const shape = cheapRequestShape(model, opts.maxTokens ?? 700);
222
218
  const resp = await client.messages.create({
223
219
  model,
224
220
  max_tokens: shape.maxTokens,
@@ -252,7 +248,7 @@ async function agentComplete(model, opts, credential) {
252
248
  const prompt = opts.system
253
249
  ? `${opts.system}\n\n---\n\n${opts.prompt}`
254
250
  : opts.prompt;
255
- const shape = cheapRequestShape(model, opts.maxTokens ?? 700, opts.effort);
251
+ const shape = cheapRequestShape(model, opts.maxTokens ?? 700);
256
252
  const q = query({
257
253
  prompt,
258
254
  options: {
@@ -278,7 +278,7 @@ async function complete(req) {
278
278
  schemaPath = join(scratch, 'schema.json');
279
279
  await writeFile(schemaPath, JSON.stringify(req.outputSchema));
280
280
  }
281
- const args = buildExecArgs({ cwd, writeRoots: [], ...(req.system ? { system: req.system } : {}) }, { home, mcp: null, hook, schemaPath, model, effort: req.effort ?? CODEX_EFFORT_FOR_ROLE[role] });
281
+ const args = buildExecArgs({ cwd, writeRoots: [], ...(req.system ? { system: req.system } : {}) }, { home, mcp: null, hook, schemaPath, model, effort: CODEX_EFFORT_FOR_ROLE[role] });
282
282
  armCodexThreadSweeps(home);
283
283
  const res = await runCodexExec(args, {
284
284
  cwd,
@@ -10,7 +10,6 @@ import { buildUserPrompt, peerRef, pickReviewNonce, skipSummary, sonarHasContent
10
10
  import { pairProvidersReady, readAutoReviewProvidersForPr } from './pair.js';
11
11
  import { consolidatePair, notStartedHalf } from './pair-consolidate.js';
12
12
  import { markPairBusy } from './pair-view.js';
13
- import { checkFindings } from './finding-check.js';
14
13
  import { preflightFor } from '../../ai/run-choice.js';
15
14
  import { linkReraisedFindings, reconcileFollowUp, dropAcceptedReraises, isResolvedWithReplies, selectPriorFindings, SINCE_PATCH_CHARS, } from './follow-up.js';
16
15
  import { planThreadReview, reconcileThreads } from './threads.js';
@@ -1004,20 +1003,7 @@ async function runPipeline(item, controller, emit) {
1004
1003
  const { kept: notSettled, dropped: droppedSettled } = dropSettledReraises(notAccepted, settled);
1005
1004
  // A pair's repeats are grouped at the pair's END (pair-consolidate.ts `pairRepeatGroups`), never
1006
1005
  // dropped here: the halves run at the same time.
1007
- // THE FINDING CHECK (finding-check.ts): each blocker and warning checked again in a fresh context,
1008
- // on this run's provider and model. It can only ask one as a question, never remove it.
1009
- emit({ phase: 'checking' });
1010
- const { findings } = await checkFindings(ctx, {
1011
- accountId: item.accountId,
1012
- prId: item.prId,
1013
- owner: prCtx.owner,
1014
- name: prCtx.name,
1015
- headSha: item.headSha,
1016
- diff: prep.strippedDiff,
1017
- provider: item.provider,
1018
- model: res.ranOn?.model ?? model,
1019
- signal: controller.signal,
1020
- }, notSettled);
1006
+ const findings = notSettled;
1021
1007
  const dropped = [...droppedAccepted, ...droppedSettled];
1022
1008
  if (dropped.length > 0) {
1023
1009
  ctx.log.info(`claude review pr ${item.prId}: dropped ${dropped.length} finding(s) repeating a comment settled by a reply`);
@@ -43,7 +43,7 @@ Produce concrete, actionable findings. For each finding:
43
43
  - 'question' — something genuinely needs clarification from the author.
44
44
  - Do NOT submit a finding just to say something is good: findings are only for what the author should act on or answer. Put what is good in the summary's "Good:" line instead.
45
45
  - Be specific. Reference the actual symbol/line and say what's wrong and (briefly) what to do instead. Avoid vague "consider refactoring" comments.
46
- - Raise every real problem you find, also one you cannot fully confirm (including any a specialist reported): give it the severity it has if it is true, and say in its body what you could not confirm. Do not drop a finding only because you are unsure. After you submit, Limn checks each blocker and warning again against the code, in a separate step.
46
+ - Before you submit, check each finding once more against what you can see (the code, or the diff when that is all you have), including any a specialist reported. Drop one you cannot confirm, or ask it as a 'question'.
47
47
  - 'priorRef': only when you raise a finding from the "Previous review" section again, its ref (e.g. 'P3'). Leave it out otherwise.
48
48
 
49
49
  # Finishing
@@ -23,7 +23,7 @@
23
23
  // THE PROVIDER SEAM (ai/provider.ts): the completion itself — the ladder, the request shape, both
24
24
  // routes — is the ACTIVE PROVIDER's `complete` (Claude's lives in ai/providers/claude.ts, moved there
25
25
  // unchanged). This module keeps the one switch every caller passes through and the default model.
26
- import { getActiveProvider, getProvider } from '../ai/provider.js';
26
+ import { getActiveProvider } from '../ai/provider.js';
27
27
  import { config } from '../config.js';
28
28
  // The request shape and the route pick moved with the Claude completion; re-exported under the names
29
29
  // this module always had.
@@ -32,9 +32,6 @@ const DEFAULT_MODEL = 'claude-haiku-5-5';
32
32
  export async function cheapComplete(opts) {
33
33
  if (!config.aiEnabled)
34
34
  throw new Error('AI is switched off here.');
35
- // The named provider (a check of one run's findings), else the default.
36
- const provider = opts.provider ? getProvider(opts.provider) : getActiveProvider();
37
- const { provider: _named, ...req } = opts;
38
- return provider.complete({ ...req, model: req.model ?? DEFAULT_MODEL, role: req.role ?? 'fast' });
35
+ return getActiveProvider().complete({ ...opts, model: opts.model ?? DEFAULT_MODEL, role: opts.role ?? 'fast' });
39
36
  }
40
37
  //# sourceMappingURL=llm.js.map
@@ -43,7 +43,7 @@ export function aiUsageFeatureGroup(feature) {
43
43
  const f = feature.trim();
44
44
  // Codex records each specialist as `claude_review:<name>`; the pair merge, the replies pass and
45
45
  // Check threads are code review too.
46
- if (f === 'claude_review' || f.startsWith('claude_review:') || f === 'claude_review_merge' || f === 'claude_review_check')
46
+ if (f === 'claude_review' || f.startsWith('claude_review:') || f === 'claude_review_merge')
47
47
  return 'code';
48
48
  if (f === 'replies_check' || f === 'thread_check')
49
49
  return 'code';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "limn-review",
3
- "version": "0.1.157",
3
+ "version": "0.1.159",
4
4
  "description": "Dashboard for tracking your team's GitHub PR activity across repos. Runs on your machine with your gh login.",
5
5
  "type": "module",
6
6
  "author": "Alex Wakeman",
@@ -1,3 +1,3 @@
1
- import{d as Ie,r as p,j as e}from"./tanstack-BnbsafB1.js";import{aV as z,aU as Qe,cH as je,cO as Xe,co as Ze,cF as et,cq as Te,aO as tt,cG as U,A as Ne,aT as Se,T as ne,v as st,a4 as nt,an as ie,bp as Ee,a0 as _e,e as G,a3 as it,aR as Me,h as Be,p as at,j as rt,a as lt,C as ct,dk as ot,bU as ut,aW as dt,dc as mt,dd as ht,Y as xt,G as pt,S as ft,s as K,bC as gt,cE as bt,cD as jt,cn as Nt,bh as vt,bV as wt,az as kt,bg as yt,b5 as Rt,c3 as Le,bF as Pt,cj as $e,ck as Ct,cx as At,cM as Ft,cL as It,d5 as Tt,d6 as St,aS as Et,aP as _t,cm as Mt,cl as Bt,cy as Lt,d2 as $t,au as Ot,Z as Ut,aQ as Dt,bJ as Ht,bS as ae,V as Wt,t as Yt,K as qt,R as Gt,b$ as Oe,cW as Kt,ah as ve,u as Vt,I as zt}from"./index-DwzBL37r.js";import{r as Jt,t as Qt,S as Xt,C as Zt,T as es,F as ts,f as ss}from"./ClaudeReviewTab-3Vp06rh9.js";import"./markdown-CcoLFczy.js";import"./highlight-DIEV0qGG.js";import"./vis-C3BCkP5U.js";const ns="inline-flex h-7 items-center whitespace-nowrap rounded-ui bg-ui-raise px-2.5 text-meta font-medium text-ui-ink hover:bg-ui-hover disabled:cursor-not-allowed disabled:opacity-50 touch:h-10 touch:px-3",we="inline-flex h-7 items-center whitespace-nowrap rounded-ui bg-ui-raise px-2.5 text-meta font-medium text-ui-ink hover:bg-ui-hover disabled:cursor-not-allowed disabled:opacity-50 touch:h-10 touch:px-3",ke="inline-flex items-center rounded-ui bg-ui-raise px-1.5 py-px font-mono text-meta text-ui-ink";function is(t){return t instanceof Be||t instanceof Error?t.message:"Something went wrong"}function Ue({plan:t}){return e.jsx("ul",{className:"list-disc space-y-0.5 pl-5 text-body text-ui-ink",children:t.summary.map((s,n)=>e.jsx("li",{children:s},n))})}function ye(t,s){var n;return((n=t==null?void 0:t.find(a=>a.ref===s))==null?void 0:n.title)??null}function as({plan:t,items:s}){return e.jsxs("div",{className:"mt-2 space-y-3 text-meta text-ui-ink",children:[t.steps.length>0&&e.jsx("ol",{className:"list-decimal space-y-2 pl-5",children:t.steps.map((n,a)=>e.jsxs("li",{children:[e.jsx("div",{className:"font-medium text-ui-ink",children:n.title}),n.files.length>0&&e.jsx("div",{className:"mt-0.5 font-mono text-meta text-ui-mute",children:n.files.join(", ")}),e.jsx("p",{className:"mt-0.5 whitespace-pre-wrap",children:n.change}),n.refs.length>0&&e.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:n.refs.map(i=>e.jsx("span",{className:ke,children:i},i))})]},a))}),t.notAddressed.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"mb-1 font-semibold text-ui-mute",children:"Will not fix"}),e.jsx("ul",{className:"space-y-1",children:t.notAddressed.map(n=>e.jsxs("li",{children:[e.jsx("span",{className:ke,children:n.ref})," ",ye(s,n.ref)&&e.jsxs("span",{className:"font-medium",children:[ye(s,n.ref),": "]}),n.reason]},n.ref))})]}),t.notCovered.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"font-semibold text-ui-mute",children:"Not in the plan: "}),t.notCovered.join(", ")]})]})}function rs({pr:t,fix:s,liveStatus:n,passRunning:a,auth:i}){var w,h;const l=s.plan,o=z(s.plan??s),g=Qe((s.plan??s).provider,(s.plan??s).model),c=je(g,"plan"),m=je(g,"fix"),v=Me(c),F=Xe(t.id),u=Ze(t.id),k=et(t.id),M=Te(t.id),C=Ie({mutationKey:tt(t.id)})>0,B=U(j=>j.noteAiFixRun),[E,I]=p.useState(""),[y,D]=p.useState(!1);if(!l)return null;const R=l.plan,_=l.status==="plan_ready"&&!a,L=E.trim(),P=L.length>Ne,r=()=>{!_||C||L===""||P||F.mutate({fixId:s.id,text:L},{onSuccess:()=>I("")})},d=()=>{B({prId:t.id,repoFullName:t.repoFullName,prNumber:t.number,prTitle:t.title}),u.mutate(s.id)},f=F.error??u.error??k.error;return e.jsxs("div",{className:"mt-3 rounded-ui bg-ui-surface p-3",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1 text-meta font-semibold text-ui-ink",children:["Plan",R&&l.revision>1&&e.jsxs("span",{className:"font-normal text-ui-mute",children:["· version ",l.revision]}),l.model&&e.jsxs("span",{className:"font-normal text-ui-mute",children:["· ",Se(l.provider,l.model,l.effort)]}),e.jsxs(ne,{title:"Plan first",children:[e.jsxs("p",{children:[v," reads the code and writes a plan. It changes nothing."]}),e.jsxs("p",{children:["Tell ",v," what to change and it rewrites the plan, taking the whole conversation into account. Each message runs ",v," again."]}),e.jsxs("p",{children:["When you approve, ",v," builds the fix from this plan. You still review the diff and press Push."]})]})]}),R?e.jsxs(e.Fragment,{children:[e.jsx(Ue,{plan:R}),e.jsxs("button",{type:"button",className:"hit mt-2 inline-flex items-center gap-1 text-meta text-ui-mute hover:text-ui-ink","aria-expanded":y,onClick:()=>D(j=>!j),children:[e.jsx(st,{dir:y?"down":"right"}),"Details"]}),y&&e.jsx(as,{plan:R,items:s.reviewItems})]}):!a&&e.jsx("p",{className:"text-meta text-ui-mute",children:"No plan yet."}),s.error&&e.jsx("p",{className:"mt-2 rounded-ui bg-ui-raise p-2 text-meta text-ui-warn",children:s.error}),e.jsx(nt,{transcript:l.transcript,plannedBy:o}),a&&e.jsxs("div",{className:"mt-3",children:[e.jsx(ie,{active:!0,label:R?"Updating the plan":"Making the plan",value:Ee(n),timeConstantSec:30}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-meta text-ui-mute",children:[_e[((w=n==null?void 0:n.progress)==null?void 0:w.phase)??""]??"Working…",e.jsx("button",{type:"button",className:we,onClick:()=>M.mutate(),children:"Cancel"})]}),((h=n==null?void 0:n.progress)==null?void 0:h.recentActivity)&&n.progress.recentActivity.length>0&&e.jsx("pre",{className:"mt-1 max-h-32 overflow-auto rounded-ui bg-ui-surface p-2 text-meta leading-relaxed text-ui-mute",children:n.progress.recentActivity.slice(-8).join(`
1
+ import{d as Ie,r as p,j as e}from"./tanstack-BnbsafB1.js";import{aV as z,aU as Qe,cH as je,cO as Xe,co as Ze,cF as et,cq as Te,aO as tt,cG as U,A as Ne,aT as Se,T as ne,v as st,a4 as nt,an as ie,bp as Ee,a0 as _e,e as G,a3 as it,aR as Me,h as Be,p as at,j as rt,a as lt,C as ct,dk as ot,bU as ut,aW as dt,dc as mt,dd as ht,Y as xt,G as pt,S as ft,s as K,bC as gt,cE as bt,cD as jt,cn as Nt,bh as vt,bV as wt,az as kt,bg as yt,b5 as Rt,c3 as Le,bF as Pt,cj as $e,ck as Ct,cx as At,cM as Ft,cL as It,d5 as Tt,d6 as St,aS as Et,aP as _t,cm as Mt,cl as Bt,cy as Lt,d2 as $t,au as Ot,Z as Ut,aQ as Dt,bJ as Ht,bS as ae,V as Wt,t as Yt,K as qt,R as Gt,b$ as Oe,cW as Kt,ah as ve,u as Vt,I as zt}from"./index-DAt12j8A.js";import{r as Jt,t as Qt,S as Xt,C as Zt,T as es,F as ts,f as ss}from"./ClaudeReviewTab-VovoNLdy.js";import"./markdown-CcoLFczy.js";import"./highlight-DIEV0qGG.js";import"./vis-C3BCkP5U.js";const ns="inline-flex h-7 items-center whitespace-nowrap rounded-ui bg-ui-raise px-2.5 text-meta font-medium text-ui-ink hover:bg-ui-hover disabled:cursor-not-allowed disabled:opacity-50 touch:h-10 touch:px-3",we="inline-flex h-7 items-center whitespace-nowrap rounded-ui bg-ui-raise px-2.5 text-meta font-medium text-ui-ink hover:bg-ui-hover disabled:cursor-not-allowed disabled:opacity-50 touch:h-10 touch:px-3",ke="inline-flex items-center rounded-ui bg-ui-raise px-1.5 py-px font-mono text-meta text-ui-ink";function is(t){return t instanceof Be||t instanceof Error?t.message:"Something went wrong"}function Ue({plan:t}){return e.jsx("ul",{className:"list-disc space-y-0.5 pl-5 text-body text-ui-ink",children:t.summary.map((s,n)=>e.jsx("li",{children:s},n))})}function ye(t,s){var n;return((n=t==null?void 0:t.find(a=>a.ref===s))==null?void 0:n.title)??null}function as({plan:t,items:s}){return e.jsxs("div",{className:"mt-2 space-y-3 text-meta text-ui-ink",children:[t.steps.length>0&&e.jsx("ol",{className:"list-decimal space-y-2 pl-5",children:t.steps.map((n,a)=>e.jsxs("li",{children:[e.jsx("div",{className:"font-medium text-ui-ink",children:n.title}),n.files.length>0&&e.jsx("div",{className:"mt-0.5 font-mono text-meta text-ui-mute",children:n.files.join(", ")}),e.jsx("p",{className:"mt-0.5 whitespace-pre-wrap",children:n.change}),n.refs.length>0&&e.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:n.refs.map(i=>e.jsx("span",{className:ke,children:i},i))})]},a))}),t.notAddressed.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"mb-1 font-semibold text-ui-mute",children:"Will not fix"}),e.jsx("ul",{className:"space-y-1",children:t.notAddressed.map(n=>e.jsxs("li",{children:[e.jsx("span",{className:ke,children:n.ref})," ",ye(s,n.ref)&&e.jsxs("span",{className:"font-medium",children:[ye(s,n.ref),": "]}),n.reason]},n.ref))})]}),t.notCovered.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"font-semibold text-ui-mute",children:"Not in the plan: "}),t.notCovered.join(", ")]})]})}function rs({pr:t,fix:s,liveStatus:n,passRunning:a,auth:i}){var w,h;const l=s.plan,o=z(s.plan??s),g=Qe((s.plan??s).provider,(s.plan??s).model),c=je(g,"plan"),m=je(g,"fix"),v=Me(c),F=Xe(t.id),u=Ze(t.id),k=et(t.id),M=Te(t.id),C=Ie({mutationKey:tt(t.id)})>0,B=U(j=>j.noteAiFixRun),[E,I]=p.useState(""),[y,D]=p.useState(!1);if(!l)return null;const R=l.plan,_=l.status==="plan_ready"&&!a,L=E.trim(),P=L.length>Ne,r=()=>{!_||C||L===""||P||F.mutate({fixId:s.id,text:L},{onSuccess:()=>I("")})},d=()=>{B({prId:t.id,repoFullName:t.repoFullName,prNumber:t.number,prTitle:t.title}),u.mutate(s.id)},f=F.error??u.error??k.error;return e.jsxs("div",{className:"mt-3 rounded-ui bg-ui-surface p-3",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1 text-meta font-semibold text-ui-ink",children:["Plan",R&&l.revision>1&&e.jsxs("span",{className:"font-normal text-ui-mute",children:["· version ",l.revision]}),l.model&&e.jsxs("span",{className:"font-normal text-ui-mute",children:["· ",Se(l.provider,l.model,l.effort)]}),e.jsxs(ne,{title:"Plan first",children:[e.jsxs("p",{children:[v," reads the code and writes a plan. It changes nothing."]}),e.jsxs("p",{children:["Tell ",v," what to change and it rewrites the plan, taking the whole conversation into account. Each message runs ",v," again."]}),e.jsxs("p",{children:["When you approve, ",v," builds the fix from this plan. You still review the diff and press Push."]})]})]}),R?e.jsxs(e.Fragment,{children:[e.jsx(Ue,{plan:R}),e.jsxs("button",{type:"button",className:"hit mt-2 inline-flex items-center gap-1 text-meta text-ui-mute hover:text-ui-ink","aria-expanded":y,onClick:()=>D(j=>!j),children:[e.jsx(st,{dir:y?"down":"right"}),"Details"]}),y&&e.jsx(as,{plan:R,items:s.reviewItems})]}):!a&&e.jsx("p",{className:"text-meta text-ui-mute",children:"No plan yet."}),s.error&&e.jsx("p",{className:"mt-2 rounded-ui bg-ui-raise p-2 text-meta text-ui-warn",children:s.error}),e.jsx(nt,{transcript:l.transcript,plannedBy:o}),a&&e.jsxs("div",{className:"mt-3",children:[e.jsx(ie,{active:!0,label:R?"Updating the plan":"Making the plan",value:Ee(n),timeConstantSec:30}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-meta text-ui-mute",children:[_e[((w=n==null?void 0:n.progress)==null?void 0:w.phase)??""]??"Working…",e.jsx("button",{type:"button",className:we,onClick:()=>M.mutate(),children:"Cancel"})]}),((h=n==null?void 0:n.progress)==null?void 0:h.recentActivity)&&n.progress.recentActivity.length>0&&e.jsx("pre",{className:"mt-1 max-h-32 overflow-auto rounded-ui bg-ui-surface p-2 text-meta leading-relaxed text-ui-mute",children:n.progress.recentActivity.slice(-8).join(`
2
2
  `)})]}),_&&R&&e.jsxs("div",{className:"mt-3",children:[e.jsx(G,{kind:"plan",auth:i,meter:!1,followUp:!0,provider:c,children:e.jsx(it,{name:v,draft:E,setDraft:I,busy:C,maxChars:Ne,onSend:r})}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx(G,{kind:"fix",auth:i,followUp:!0,provider:m,children:e.jsx("button",{type:"button","data-ai-run":!0,className:ns,disabled:C,onClick:d,children:"Approve and build"})}),e.jsx("button",{type:"button",className:we,disabled:C,onClick:()=>k.mutate(s.id),children:"Discard plan"})]})]}),f!=null&&e.jsx("p",{className:"mt-1 text-meta text-ui-danger",children:is(f)})]})}function De({fix:t}){var n;const s=((n=t.plan)==null?void 0:n.status)==="approved"?t.plan.plan:null;return s?e.jsxs("div",{className:"mb-2 rounded-ui bg-ui-surface p-2",children:[e.jsx("div",{className:"mb-1 text-meta font-semibold text-ui-mute",children:"Built from your plan"}),e.jsx(Ue,{plan:s})]}):null}function ls(t,s,n){var a;return t??((s==null?void 0:s.status)==="succeeded"?s.id:((a=n.find(i=>i.status==="succeeded"))==null?void 0:a.id)??null)}function cs(t,s,n){return s==null||n==null||s===n.id?null:t!=null?"Uses the review you picked, not the latest.":n.status==="failed"?"Uses the last review that finished. The latest one failed.":n.status==="running"||n.status==="queued"?"Uses the last review that finished. A newer one is running.":"Uses the last review that finished."}const Re=ct,os=rt;function us(t){return t.kind==="finding"&&t.findingId!=null?`claude-finding-${t.findingId}`:null}function ds(t){const s=U(n=>n.openClaudeReview);return n=>{s({id:t.id,number:t.number,title:t.title,repoFullName:t.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null});const a=Date.now()+3e3,i=()=>{const l=document.getElementById(n);if(l){l.scrollIntoView({behavior:"smooth",block:"center"});return}Date.now()<a&&requestAnimationFrame(i)};requestAnimationFrame(i)}}function Pe({refId:t,item:s,onJump:n}){const a=s?`${lt[s.kind]} ${t}`:t,i=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"shrink-0",children:a}),s&&e.jsxs("span",{className:"min-w-0 truncate font-normal",children:["· ",s.title]})]}),l=s?us(s):null;return l?e.jsx("button",{type:"button",onClick:()=>n(l),"aria-label":`${a}: ${(s==null?void 0:s.title)??""}. Show in AI Review`,className:`${Re} max-w-[22rem] hover:bg-ui-hover`,children:i}):e.jsx("span",{className:`${Re} max-w-[22rem]`,children:i})}function ms(t){var s;switch(t.seed){case"review":{const n=((s=t.reviewItems)==null?void 0:s.length)??0;return`Fix from ${t.sourceReviewId==null?"the CI check":"the AI review"}${n>0?` (${n} item${n===1?"":"s"})`:""}.`}case"plain":return"Fix from your instruction.";case"comments":return"Fix from picked comments (no longer offered).";case"ci_analysis":return"Fix from the CI analysis (no longer offered).";default:return""}}function hs({pr:t,fix:s}){const n=z(s),a=ds(t),i=s.changeReport,l=new Map((s.reviewItems??[]).map(c=>[c.ref,c])),o=(s.reviewItems??[]).filter(c=>!c.included);if(!i&&o.length===0)return null;const g=l.size>0;return e.jsxs("div",{className:"mt-2 text-meta",children:[e.jsx(at,{report:i,filesChanged:s.filesChanged,by:n,refsInfo:g?e.jsx("p",{children:"Each tag is a review item the change answers. A finding tag opens it in the AI Review tab."}):null,renderRef:c=>e.jsx(Pe,{refId:c,item:l.get(c),onJump:a},c)}),o.length>0&&e.jsxs("section",{children:[e.jsxs("div",{className:os,children:["Left out",e.jsx(ne,{title:"Left out",children:e.jsxs("p",{children:["These review items did not fit in what ",n," was sent, so it never saw them."]})})]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:o.map(c=>e.jsx(Pe,{refId:c.ref,item:c,onJump:a},c.ref))})]})]})}const xs=["findings","earlier_findings","judged_threads","untouched_threads","ci_failures","sonar","style_bots","story"],ps={findings:"Claude’s findings",earlier_findings:"Earlier findings still open",judged_threads:"Threads Claude says need a fix",untouched_threads:"Unanswered threads",ci_failures:"CI failures",sonar:"SonarCloud issues",style_bots:"Style bot comments",story:"Ticket gaps"};function Ce(t,s="Claude"){return t==="findings"?`${s}’s findings`:t==="judged_threads"?`Threads ${s} says need a fix`:ps[t]}function V(t,s){return s[t.key]??t.defaultIncluded}function fs(t,s){return t.items.filter(n=>V(n,s)).map(n=>n.key)}function He(t,s){const n=new Set;let a=0;for(const i of t.items)if(V(i,s)){if(a>0&&a+i.chars>t.budgetChars){n.add(i.key);continue}a+=i.chars}return n}function gs(t,s){const n={};for(const a of t.items)n[a.key]=a.section===s;return n}const bs={blocker:"Blocker",warning:"Warning",nit:"Nit",question:"Question",praise:"Praise"},Ae={blocker:"bg-ui-danger/10 text-ui-danger",warning:"bg-ui-raise text-ui-warn",nit:"bg-ui-raise text-ui-mute"},We="whitespace-nowrap rounded-ui bg-ui-raise px-1 py-px text-meta text-ui-warn",Z=new Set;function js(t,s){return t?s!=null?`${t}:${s}`:t:null}function Ns({item:t,picked:s,cut:n,disabled:a,onToggle:i}){return e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5 pt-0.5",children:[e.jsx("label",{className:"flex cursor-pointer items-center touch:-my-3 touch:min-h-10 touch:min-w-10 touch:justify-center",children:e.jsx(K,{checked:s,disabled:a,onChange:l=>i(l.target.checked),"aria-label":`Include in the fix: ${t.label}`})}),s&&n&&e.jsx("span",{className:We,children:"Won’t fit"})]})}function vs({item:t,picked:s,cut:n,disabled:a,onToggle:i}){const l=js(t.path,t.line);return e.jsx("li",{children:e.jsxs("label",{className:`flex cursor-pointer items-start gap-2 rounded-ui border px-2 py-1.5 text-meta ${s?"border-ui-line bg-ui-sel":"border-ui-line"}`,children:[e.jsx(K,{className:"mt-0.5",checked:s,disabled:a,onChange:o=>i(o.target.checked)}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"flex flex-wrap items-center gap-1.5",children:[t.severity&&Ae[t.severity]&&e.jsx("span",{className:`rounded-ui px-1 py-px text-meta font-medium ${Ae[t.severity]}`,children:bs[t.severity]}),e.jsx("span",{className:"break-words text-ui-ink",children:t.label}),s&&n&&e.jsx("span",{className:We,children:"Won’t fit"})]}),(l||t.detail)&&e.jsxs("span",{className:"mt-0.5 block break-words text-meta text-ui-mute",children:[l&&e.jsx("span",{className:"font-mono",children:l}),l&&t.detail?" · ":"",t.detail]})]})]})})}function ws({preview:t,overrides:s,onChange:n,disabled:a,pr:i,review:l}){const o=He(t,s),g=new Map;for(const r of t.items){const d=g.get(r.section)??[];d.push(r),g.set(r.section,d)}const c=(r,d)=>{const f={...s};for(const w of r)f[w]=d;n(f)},m=l!=null&&l.id===t.sourceReviewId?l:null,v=Jt(l),F=Qt(l),u=p.useMemo(()=>m!=null?ot(m):null,[m]),k=p.useMemo(()=>new Map(((u==null?void 0:u.findings)??[]).map(r=>[r.id,r])),[u]),M=p.useMemo(()=>{var r;return new Map((((r=u==null?void 0:u.followUp)==null?void 0:r.items)??[]).map(d=>[d.priorFindingId,d]))},[u]),C=p.useMemo(()=>u!=null?ut(u):new Map,[u]),B=p.useMemo(()=>u!=null?dt(u):new Set,[u]),E=p.useMemo(()=>{var d;const r=new Set;for(const f of t.items)((d=f.card)==null?void 0:d.kind)==="story"&&r.add(f.card.ticketReviewId);return[...r].sort((f,w)=>f-w)},[t.items]),I=mt(i.id,E.length>0),y=p.useMemo(()=>{var d;const r=new Map;for(const f of((d=I.data)==null?void 0:d.tickets)??[])f.review!=null&&r.set(f.review.id,f.review);return r},[I.data]),D=p.useMemo(()=>I.data==null?[]:E.filter(r=>!y.has(r)),[I.data,E,y]),R=ht(D),_=p.useMemo(()=>{const r=new Map(y);for(const d of R)r.set(d.id,d);return r},[y,R]);if(t.items.length===0)return e.jsx("p",{className:"text-meta text-ui-mute",children:"The review found nothing to fix."});const L=(m==null?void 0:m.headSha)??i.headSha,P=r=>{var H,T;const d=V(r,s),f=o.has(r.key),w=b=>c([r.key],b),h=e.jsx(Ns,{item:r,picked:d,cut:f,disabled:a,onToggle:w}),j=r.card;switch(j==null?void 0:j.kind){case"finding":{const b=k.get(j.findingId);if(b==null)break;return e.jsx(ts,{authorName:ss(l,b),prId:i.id,finding:b,editable:!1,prUrl:i.githubUrl,repoFullName:i.repoFullName,headSha:L,posting:!1,postError:null,inChangeset:b.fileInDiff,priorStatus:C.get(b.id),alreadyPosted:B.has(b.id),actions:!1,selection:h,docReferences:(m==null?void 0:m.docReferences)??null},r.key)}case"earlier_finding":{const b=M.get(j.priorFindingId);if(b==null)break;return e.jsx(ft,{item:b,muted:!1,findingsById:k,headMoved:((H=u==null?void 0:u.followUp)==null?void 0:H.headMoved)??!1,changedPaths:Z,actions:!1,selection:h,by:v},r.key)}case"thread":return e.jsx(es,{t:j.assessment,muted:!1,actions:!1,selection:h,notCheckedNote:j.inReview?void 0:`${F} didn’t check this one.`,by:F},r.key);case"ci":return e.jsx(Zt,{f:j.item,suggestion:j.item.suggestion,changedPaths:Z,selection:h},r.key);case"sonar":return e.jsx(Xt,{issue:j.issue,selection:h},r.key);case"story":{const b=_.get(j.ticketReviewId),S=b==null?void 0:b.items.find($=>$.id===j.itemId);if(b==null||S==null)break;const N={review:b,viewedPrId:i.id,changedPaths:Z,actions:!1,selection:h};if(S.status==="missing")return e.jsx(xt,{item:S,...N},r.key);const x=(T=b.assessment)==null?void 0:T.criteria.find($=>$.ref===S.ref);if(x==null||x.status==="met")break;return e.jsx(pt,{c:x,item:S,...N},r.key)}}return e.jsx(vs,{item:r,picked:d,cut:f,disabled:a,onToggle:w},r.key)};return e.jsxs("div",{className:"space-y-3",children:[xs.filter(r=>g.has(r)).map(r=>{const d=g.get(r),f=d.filter(h=>V(h,s)).length,w=f===d.length;return e.jsxs("section",{"aria-label":Ce(r,v),children:[e.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[e.jsx("h4",{className:"text-meta font-semibold text-ui-ink",children:Ce(r,v)}),e.jsxs("span",{className:"text-meta text-ui-mute",children:[f," of ",d.length]}),e.jsx("button",{type:"button",className:"hit ml-auto text-meta text-ui-accent hover:underline disabled:opacity-50",disabled:a,onClick:()=>c(d.map(h=>h.key),!w),children:w?"Untick all":"Tick all"})]}),e.jsx("ul",{className:"space-y-1.5",children:d.map(P)})]},r)}),o.size>0&&e.jsxs("p",{className:"text-meta text-ui-warn",children:[o.size," ticked ",o.size===1?"item does":"items do"," not fit in one fix and will be left out. Untick something to make room."]})]})}const ks="inline-flex h-7 items-center whitespace-nowrap rounded-ui bg-ui-raise px-2.5 text-meta font-medium text-ui-ink hover:bg-ui-hover disabled:cursor-not-allowed disabled:opacity-50 touch:h-10 touch:px-3",Fe="inline-flex h-7 items-center whitespace-nowrap rounded-ui bg-ui-raise px-2.5 text-meta font-medium text-ui-ink hover:bg-ui-hover disabled:cursor-not-allowed disabled:opacity-50 touch:h-10 touch:px-3";function Ye(t){return{prId:t.id,repoId:t.repoId,repoFullName:t.repoFullName,prNumber:t.number,prTitle:t.title,githubUrl:t.githubUrl}}function ys(t){const s=gt({mergeable:t.mergeable,mergeStateStatus:t.mergeStateStatus,isDraft:t.isDraft,inMergeQueue:t.inMergeQueue===!0}).verdict;return bt({state:t.state,verdict:s,viewerCanPush:t.viewerCanPush})}function Rs({pr:t}){const s=jt(t.id),n=Nt(),a=vt(s),i=t.baseRefName??"the base branch";p.useEffect(()=>{wt(t.id)},[t.id]);const l=Ye(t),o=(s==null?void 0:s.phase)==="succeeded"?s.resolution:null;return e.jsxs("div",{className:"mb-3 rounded-ui bg-ui-surface p-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-body font-medium text-ui-ink",children:[e.jsx(kt,{size:13,className:"text-ai-signal"}),"This branch conflicts with ",i]}),e.jsxs("p",{className:"mt-1 text-meta text-ui-mute",children:[n," reads the code and picks a result for each conflict. You check its choices in the resolver before anything is pushed."]}),a&&s!=null?e.jsxs("div",{className:"mt-2",children:[e.jsx(ie,{active:!0,label:`Resolving conflicts with ${n}`,timeConstantSec:60}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-meta text-ui-mute",children:[yt(s.phase,n),e.jsx("button",{type:"button",className:Fe,onClick:()=>Rt(t.id),children:"Cancel"})]})]}):e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx(G,{kind:"resolve",children:e.jsx("button",{type:"button",className:ks,onClick:()=>Le(l,{providerName:n}),children:o!=null?"Run again":`Resolve merge conflicts with ${n}`})}),o!=null&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:Fe,onClick:()=>Pt(l),children:"Open the resolver"}),e.jsxs("span",{className:"text-meta text-ui-mute",children:[z(o)," decided ",o.choices.length," of ",o.decidableTotal," change",o.decidableTotal===1?"":"s","."]})]}),(s==null?void 0:s.phase)==="failed"&&s.error!=null&&e.jsx("span",{className:"text-meta text-ui-danger",children:s.error}),(s==null?void 0:s.phase)==="cancelled"&&e.jsx("span",{className:"text-meta text-ui-mute",children:"Cancelled."})]})]})}const te="inline-flex h-7 items-center whitespace-nowrap rounded-ui bg-ui-raise px-2.5 text-meta font-medium text-ui-ink hover:bg-ui-hover disabled:cursor-not-allowed disabled:opacity-50 touch:h-10 touch:px-3";function se(t){return t instanceof Be||t instanceof Error?t.message:"Something went wrong"}const ee="inline-flex h-7 items-center whitespace-nowrap rounded-ui bg-ui-raise px-2.5 text-meta font-medium text-ui-ink hover:bg-ui-hover disabled:cursor-not-allowed disabled:opacity-50 touch:h-10 touch:px-3";function Ps({children:t,info:s}){return e.jsxs("div",{className:"flex items-center gap-1.5 px-4 pb-2 pt-4 text-title text-ui-ink md:px-5",children:[e.jsx("h3",{children:t}),s]})}function Os({pr:t}){const s=$e().enabled,n=U(c=>c.aiFixTabFocus),a=U(c=>c.consumeAiFixTabFocus),[i,l]=p.useState(null),[o,g]=p.useState(null);return p.useEffect(()=>{n&&n.prId===t.id&&(n.reviewId!=null&&l(n.reviewId),n.only!=null&&g(n.only),a())},[n,t.id,a]),s?e.jsx("div",{className:"pb-6",children:e.jsx(Cs,{pr:t,handoffReviewId:i,onlySection:o,onOnlySectionApplied:()=>g(null)})}):e.jsx(e.Fragment,{})}function Cs({pr:t,handoffReviewId:s,onlySection:n,onOnlySectionApplied:a}){var oe,ue,de,me,he,xe,pe,fe,ge,be;const{data:i,isLoading:l}=Ct(t.id,!0),{data:o,isLoading:g}=At(t.id),c=(o==null?void 0:o.review)??null,m=ls(s,c,(o==null?void 0:o.history)??[]),v=cs(s,m,c),F=U(A=>A.setPrDetailTab),u=Ft("fix",zt),k=Me(u.chosen.provider),M=It().data,C=Tt(t.id),B=St(t.id),E=Te(t.id),I=$e(),y=Et(M,u.chosen.provider,"plan"),[D,R]=p.useState(!1),_=D&&y,L=U(A=>A.noteAiFixRun),P=Ie({mutationKey:_t(t.id)})>0,r=((oe=i==null?void 0:i.fix)==null?void 0:oe.status)??null,d=r==="planned",f=d&&((de=(ue=i==null?void 0:i.fix)==null?void 0:ue.plan)==null?void 0:de.status)==="planning",w=r==="running"||r==="queued"||P||f,{status:h}=Mt(t.id,w),j=(h==null?void 0:h.status)??r??"idle",H=j==="running"||j==="queued",T=H&&!d,b=d&&(f||H),S=d&&(((he=(me=i==null?void 0:i.fix)==null?void 0:me.plan)==null?void 0:he.status)==="planning"||((pe=(xe=i==null?void 0:i.fix)==null?void 0:xe.plan)==null?void 0:pe.status)==="plan_ready"),N=(i==null?void 0:i.fix)??null,x=Bt(t.id,m,(i==null?void 0:i.enabled)!==!1&&(m!=null||!g)),$=m==null&&x.data!=null&&x.data.sourceReviewId==null&&x.data.items.length>0,q=m!=null||$,Ge=Lt(m!=null&&(c==null?void 0:c.id)!==m?m:null),Ke=m!=null&&(c==null?void 0:c.id)===m?c:Ge.data??null,[J,Q]=p.useState({});p.useEffect(()=>Q({}),[m]);const[Ve,W]=p.useState(!1);p.useEffect(()=>{n==null||!x.data||(Q(gs(x.data,n)),W(!0),a())},[n,x.data,a]);const re=!S&&(Ve||!N||N.status!=="succeeded"),X=ys(t),[le,ze]=p.useState(!1),Y=$t(t.id,t.repoFullName),O=x.data?fs(x.data,J):[],ce=x.data?He(x.data,J).size:0,Je=()=>{if(!q||!x.data||O.length===0)return;const A={model:u.chosen.model,provider:u.chosen.provider,seed:"review",...m!=null?{sourceReviewId:m}:{},include:O,...Y.names.length>0?{checks:Y.names}:{}};_?B.mutate(A,{onSuccess:()=>W(!1)}):(L({prId:t.id,repoFullName:t.repoFullName,prNumber:t.number,prTitle:t.title}),C.mutate(A,{onSuccess:()=>W(!1)})),le&&X&&Le(Ye(t),{model:Dt(u.chosen.model),providerName:I.providerName})};return e.jsxs("div",{children:[e.jsx(Ps,{info:e.jsxs(ne,{title:"AI Fix",children:[e.jsxs("p",{children:[k," reads the PR's code and edits files in a private copy. It has no shell. Tick Run tests to let it run the project's own test, lint and type checks in a sandbox."]}),e.jsx("p",{children:"A fix starts from an AI review. Pick what it should work on: the review's findings, earlier findings still open, threads the review says need a fix, unanswered threads, CI failures and ticket gaps are ticked; style bot comments are not."}),e.jsx("p",{children:"With no AI review, a fix can start from a finished CI check: it works on the failures the check says this PR can fix."}),e.jsxs("p",{children:["Tick Plan first to read ",k,"'s plan, steer it and approve it before anything changes."]}),e.jsxs("p",{children:[k," reports what it changed in each file and what it left alone, and why."]}),e.jsx("p",{children:"Nothing is pushed until you press Push. An automatic fix on your own PR is pushed for you only when Push automatically is on in Settings."})]}),children:"AI Fix"}),e.jsxs("div",{className:"px-4",children:[X&&e.jsx(Rs,{pr:t}),(i==null?void 0:i.enabled)===!1?e.jsx("p",{className:"text-body text-ui-mute",children:"The agentic fixer is turned off."}):e.jsxs(e.Fragment,{children:[!T&&!S&&!q&&!g&&!x.isLoading&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-meta text-ui-mute",children:(c==null?void 0:c.status)==="running"||(c==null?void 0:c.status)==="queued"?"A fix starts from an AI review. One is running.":"A fix starts from a finished AI review."}),e.jsx("button",{type:"button",className:te,onClick:()=>F(t.id,"claude_review"),children:"Open AI Review"})]}),!T&&!S&&q&&!re&&e.jsx("button",{type:"button",className:ee,onClick:()=>W(!0),children:"New fix"}),!T&&q&&re&&e.jsxs("div",{children:[v&&e.jsx("p",{className:"mb-2 text-meta text-ui-mute",children:v}),$&&e.jsx("p",{className:"mb-2 text-meta text-ui-mute",children:"No AI review yet. This fix works on the CI check’s failures."}),x.isLoading&&e.jsx("p",{className:"text-meta text-ui-mute",children:"Loading…"}),x.isError&&m!=null&&e.jsx("p",{className:"text-meta text-ui-danger",children:se(x.error)}),x.data&&e.jsx(ws,{preview:x.data,overrides:J,onChange:Q,disabled:P,pr:t,review:Ke}),x.data&&x.data.items.length>0&&X&&e.jsxs("label",{className:"mt-3 flex cursor-pointer items-start gap-2 text-meta text-ui-ink",children:[e.jsx(K,{className:"mt-0.5",checked:le,disabled:P,onChange:A=>ze(A.target.checked)}),e.jsxs("span",{children:["Also resolve merge conflicts with ",t.baseRefName??"the base branch",e.jsx("span",{className:"block text-meta text-ui-mute",children:"You check the merge in the resolver. It lands as its own commit, apart from the fix."})]})]}),x.data&&x.data.items.length>0&&e.jsx(Ot,{state:Y,disabled:P}),x.data&&x.data.items.length>0&&e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 max-md:sticky max-md:bottom-0 max-md:z-20 max-md:-mx-4 max-md:bg-ui-surface max-md:px-4 max-md:py-3",children:[e.jsx(Ut,{state:u,onPick:u.pick,disabled:P}),y&&e.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5 text-meta text-ui-ink",children:[e.jsx(K,{checked:_,disabled:P,onChange:A=>R(A.target.checked)}),"Plan first"]}),e.jsx(G,{kind:"fix",auth:i==null?void 0:i.auth,anyProvider:!0,provider:u.chosen.provider,children:e.jsx("button",{type:"button",className:te,disabled:P||O.length===0||Y.on&&Y.query.isLoading,onClick:Je,children:_?"Make a plan":"Start fix"})}),e.jsx("span",{className:"text-meta text-ui-mute",children:O.length===0?"Nothing ticked.":`${O.length-ce} item${O.length-ce===1?"":"s"}`}),(N==null?void 0:N.status)==="succeeded"&&e.jsx("button",{type:"button",className:ee,onClick:()=>W(!1),children:"Close"})]})]}),T&&e.jsx("button",{type:"button",className:ee,onClick:()=>E.mutate(),children:"Cancel"}),(C.isError||B.isError)&&e.jsx("p",{className:"mt-1 text-meta text-ui-danger",children:se(C.error??B.error)}),N&&d&&e.jsx(rs,{pr:t,fix:N,liveStatus:h,passRunning:b,auth:i==null?void 0:i.auth}),T&&e.jsxs("div",{className:"mt-3",children:[N&&e.jsx(De,{fix:N}),e.jsx(ie,{active:!0,label:"Running AI fix",value:Ee(h),timeConstantSec:40}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-meta text-ui-mute",children:[(N==null?void 0:N.trigger)==="auto"&&e.jsx(qe,{}),_e[((fe=h==null?void 0:h.progress)==null?void 0:fe.phase)??""]??"Working…"]}),((ge=h==null?void 0:h.progress)==null?void 0:ge.recentActivity)&&h.progress.recentActivity.length>0&&e.jsx("pre",{className:"mt-1 max-h-32 overflow-auto rounded-ui bg-ui-surface p-2 text-meta leading-relaxed text-ui-mute",children:h.progress.recentActivity.slice(-8).join(`
3
3
  `)})]}),!T&&N&&!d&&e.jsx(Fs,{pr:t,fix:N,headInfo:(i==null?void 0:i.headInfo)??null,viewerCanPush:(i==null?void 0:i.viewerCanPush)??!1}),l&&!N&&e.jsx("p",{className:"mt-3 text-meta text-ui-mute",children:"Loading…"})]}),e.jsx(Ts,{history:(i==null?void 0:i.history)??[],currentFixId:((be=i==null?void 0:i.fix)==null?void 0:be.id)??null})]})]})}function qe(){return e.jsx("span",{className:"inline-flex items-center rounded-ui bg-ui-raise px-1.5 py-px text-meta font-medium text-ui-mute",children:"Auto fix"})}function As(t){return Se(t.provider,t.model,t.effort)}function Fs({pr:t,fix:s,headInfo:n,viewerCanPush:a}){var o,g,c;const i=p.useMemo(()=>Ht(s.patch),[s.patch]);if(s.status==="failed"&&((o=s.plan)==null?void 0:o.status)==="failed")return e.jsxs("div",{className:"mt-3 rounded-ui border border-ui-danger/40 bg-ui-danger/10 p-2 text-meta text-ui-danger",children:[z(s.plan??s)," could not make a plan: ",s.error??"unknown error"]});if(s.status==="cancelled"&&((g=s.plan)==null?void 0:g.status)==="discarded")return e.jsx("p",{className:"mt-3 text-meta text-ui-mute",children:"The plan was discarded."});if(s.status==="failed")return e.jsxs("div",{className:"mt-3 rounded-ui border border-ui-danger/40 bg-ui-danger/10 p-2 text-meta text-ui-danger",children:["The fix run failed: ",s.error??"unknown error"]});if(s.status==="cancelled")return e.jsx("p",{className:"mt-3 text-meta text-ui-mute",children:"The fix run was cancelled."});if(s.status!=="succeeded")return e.jsx(e.Fragment,{});const l=!s.patch||s.filesChanged.length===0;return e.jsxs("div",{className:"mt-3 border-t border-ui-line pt-3",children:[e.jsxs("p",{className:"mb-1 text-meta text-ui-mute",children:[s.trigger==="auto"&&e.jsxs(e.Fragment,{children:[e.jsx(qe,{})," "]}),ms(s)," · ",As(s),s.finishedAt&&e.jsxs(e.Fragment,{children:[" · ",ae(s.finishedAt)]})]}),s.pushedAt==null&&s.error&&e.jsx("p",{className:"mb-2 rounded-ui bg-ui-raise p-2 text-meta text-ui-warn",children:s.error}),e.jsx(De,{fix:s}),s.summary&&e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(Wt,{children:s.summary})}),e.jsx(hs,{pr:t,fix:s}),e.jsx(Yt,{checks:s.checks}),l?e.jsx("p",{className:"mt-2 text-meta text-ui-mute",children:"No files changed."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-1 mt-2 flex items-center justify-between gap-3 text-meta text-ui-mute",children:[e.jsxs("span",{children:[s.filesChanged.length," file",s.filesChanged.length===1?"":"s"," changed",!((c=s.checks)!=null&&c.ran)&&" · Not built or tested here."]}),e.jsx(qt,{})]}),e.jsx("div",{className:"overflow-hidden rounded-ui bg-ui-surface text-ui-ink",children:e.jsx(Gt,{files:i})}),e.jsx(Ss,{pr:t,fix:s,headInfo:n,viewerCanPush:a})]})]})}function Is({fix:t}){return e.jsxs("div",{className:"mb-2 rounded-ui bg-ui-raise p-2 text-meta text-ui-success",children:[e.jsxs("div",{children:["Pushed to ",e.jsx("span",{className:"font-mono",children:t.pushedBranch}),t.pushedPrUrl&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("a",{href:Oe(t.pushedPrUrl),target:"_blank",rel:"noreferrer",className:"hit underline",children:["PR #",t.pushedPrNumber]})]}),t.pushedAt&&e.jsxs(e.Fragment,{children:[" · ",ae(t.pushedAt)]})]}),t.commitMessage&&e.jsx("div",{className:"mt-1 font-mono text-meta text-ui-success",children:t.commitMessage})]})}function Ts({history:t,currentFixId:s}){const n=t.filter(a=>a.pushedAt!=null&&a.id!==s);return n.length===0?null:e.jsxs("div",{className:"mt-6",children:[e.jsx("div",{className:"mb-2 text-title text-ui-ink",children:"Earlier fixes pushed"}),e.jsx("ul",{className:"space-y-2",children:n.map(a=>e.jsxs("li",{className:"text-meta",children:[e.jsx("div",{className:"font-mono text-ui-ink",children:a.commitMessage??"(no commit message)"}),e.jsxs("div",{className:"mt-0.5 text-meta text-ui-faint",children:[a.pushedBranch&&e.jsx("span",{className:"font-mono",children:a.pushedBranch}),a.pushedPrUrl&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("a",{href:Oe(a.pushedPrUrl),target:"_blank",rel:"noreferrer",className:"hit underline",children:["PR #",a.pushedPrNumber]})]}),a.pushedAt&&e.jsxs(e.Fragment,{children:[" · ",ae(a.pushedAt)]})]})]},a.id))})]})}function Ss({pr:t,fix:s,headInfo:n,viewerCanPush:a}){const i=Kt(t.id),l=(n==null?void 0:n.canPushSameBranch)??!1,[o,g]=p.useState(l?"existing":"new"),[c,m]=p.useState((n==null?void 0:n.suggestedBranch)??""),v=p.useRef(!1);if(p.useEffect(()=>{!v.current&&(n!=null&&n.suggestedBranch)&&(m(n.suggestedBranch),v.current=!0,n.canPushSameBranch||g("new"))},[n]),s.pushedAt!=null)return e.jsx(Is,{fix:s});if(!a)return e.jsx("p",{className:"mt-2 text-meta text-ui-mute",children:"You need write access to push this fix."});const F=o==="new"&&c.trim().length===0,u=i.isPending,k=()=>{i.mutate({fixId:s.id,body:{target:o,branch:o==="new"?c.trim():void 0}})};return e.jsxs("div",{className:"mt-3 rounded-ui bg-ui-surface p-2",children:[s.commitMessage&&e.jsx("div",{className:"mb-2 rounded-ui bg-ui-surface px-2 py-1 font-mono text-meta text-ui-ink",title:"Commit message",children:s.commitMessage}),e.jsxs("label",{className:`flex items-center gap-2 text-meta ${l?"":"opacity-40"}`,title:l?void 0:"The PR head is a fork you cannot push to — use a new branch",children:[e.jsx(ve,{className:"mt-0",checked:o==="existing",disabled:!l||u,onChange:()=>g("existing")}),"Push to the PR branch",(n==null?void 0:n.headRef)&&e.jsxs("span",{className:"font-mono text-ui-faint",children:["(",n.headRef,")"]})]}),e.jsxs("label",{className:"mt-1 flex items-center gap-2 text-meta",children:[e.jsx(ve,{className:"mt-0",checked:o==="new",disabled:u,onChange:()=>g("new")}),"New branch + open a PR"]}),o==="new"&&e.jsx("input",{type:"text",className:"mt-1 w-full rounded-ui bg-ui-raise px-2 py-1 font-mono text-meta ring-1 ring-inset ring-ui-line focus:outline-none focus:ring-2 focus:ring-ui-accent touch:min-h-10",value:c,disabled:u,onChange:M=>m(M.target.value),placeholder:"branch-name"}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",className:te,disabled:u||F,onClick:k,children:u?"Pushing…":o==="new"?"Push + open PR":"Push"}),e.jsx(Vt,{checks:s.checks})]}),i.isError&&e.jsx("div",{className:"mt-2 text-meta text-ui-danger",children:se(i.error)})]})}export{Os as AiFixTab};