limn-review 0.1.123 → 0.1.124
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/api/plugins/rate-limit.js +17 -0
- package/dist/pro/bind.js +2 -0
- package/dist/shared/claude-review.js +7 -1
- package/dist/shared/types.js +9 -0
- package/dist/sync/repo-synced-hooks.js +22 -0
- package/dist/sync/sync-manager.js +7 -0
- package/package.json +1 -1
- package/public/assets/{AiFixTab-CQP6PT5u.js → AiFixTab-h2ls6ngx.js} +2 -2
- package/public/assets/ClaudeReviewTab-B54Zk88j.js +8 -0
- package/public/assets/{PrBotBehaviourTab-CCnFrWbC.js → PrBotBehaviourTab-B0GQ1qk8.js} +1 -1
- package/public/assets/index-CiUiKrBE.css +1 -0
- package/public/assets/index-SG17YBlJ.js +74 -0
- package/public/index.html +2 -2
- package/public/assets/ClaudeReviewTab-DQJ-58ZA.js +0 -8
- package/public/assets/index-BDnYs6zg.js +0 -73
- package/public/assets/index-mCuI--RC.css +0 -1
|
@@ -419,6 +419,23 @@ function tierFor(method, path) {
|
|
|
419
419
|
if (!mutating && /^\/api\/pro\/prs\/[^/]+\/jira-ticket$/.test(path)) {
|
|
420
420
|
return [TIERS.search, TIERS.read];
|
|
421
421
|
}
|
|
422
|
+
// The story panel's two writes on a STORED ticket (plugin 0038): `POST …/jira-ticket/refresh` reads
|
|
423
|
+
// that ticket from Jira again now, and `PUT …/jira-ticket/ac-field` saves the criteria field for
|
|
424
|
+
// its issue type and re-reads it — one upstream call each, the customer's quota. Spelled by exact
|
|
425
|
+
// verb + path: without these lines the catch-all parks a mutating /api/pro/ route on `ai`.
|
|
426
|
+
if (method === 'POST' && /^\/api\/pro\/prs\/[^/]+\/jira-ticket\/refresh$/.test(path)) {
|
|
427
|
+
return [TIERS.search, TIERS.read];
|
|
428
|
+
}
|
|
429
|
+
if (method === 'PUT' && /^\/api\/pro\/prs\/[^/]+\/jira-ticket\/ac-field$/.test(path)) {
|
|
430
|
+
return [TIERS.search, TIERS.read];
|
|
431
|
+
}
|
|
432
|
+
// POST /api/pro/ticket-links — the Open PRs cards' ticket row, ONE request per board: DB-only
|
|
433
|
+
// detection plus the STORED ticket rows (plugin 0038); a detected ticket with no row kicks the
|
|
434
|
+
// background worker, which spends the customer's Jira quota — so `search`, not `read`. A POST
|
|
435
|
+
// only because it carries a list of PR ids; it writes nothing itself. Without this line the catch-all would tier it
|
|
436
|
+
// on the verb and park a read on the 20/min `ai` bucket.
|
|
437
|
+
if (path === '/api/pro/ticket-links')
|
|
438
|
+
return [TIERS.search, TIERS.read];
|
|
422
439
|
// ---- AI generation ----
|
|
423
440
|
// ⚠ RE-DECIDED, not inherited: `POST /api/pro/prs/:id/annotations/run` now spends GITHUB quota
|
|
424
441
|
// as well as model tokens — one PR_DETAIL_QUERY per uncached PR for the anchor hunks
|
package/dist/pro/bind.js
CHANGED
|
@@ -34,6 +34,7 @@ import { makeConflictSeam } from '../conflict/seam.js';
|
|
|
34
34
|
import { registerAgenticProviders } from '../review/plugin-providers.js';
|
|
35
35
|
import { registerScheduledJob } from '../sync/scheduled-jobs.js';
|
|
36
36
|
import { registerPrDetailEnricher } from '../pr/detail-enricher.js';
|
|
37
|
+
import { registerRepoSyncedHook } from '../sync/repo-synced-hooks.js';
|
|
37
38
|
import { cheapComplete } from '../review/llm.js';
|
|
38
39
|
import { detectClaudeAuth } from '../review/auth.js';
|
|
39
40
|
import { getAccessToken, getAccountById } from '../auth/account.js';
|
|
@@ -249,6 +250,7 @@ export async function bindProPlugin(app) {
|
|
|
249
250
|
registerAgenticProviders,
|
|
250
251
|
registerScheduledJob,
|
|
251
252
|
registerPrDetailEnricher,
|
|
253
|
+
registerRepoSyncedHook,
|
|
252
254
|
// AI Fix infra (per-account, cloud-ready). The host owns the security-sensitive
|
|
253
255
|
// clone/agent/push machinery; the plugin only drives it with prompts/model.
|
|
254
256
|
github: {
|
|
@@ -96,7 +96,13 @@ export function checkClaudeReviewTickets(raw) {
|
|
|
96
96
|
for (let i = 0; i < list.length; i += 1) {
|
|
97
97
|
const one = checkClaudeReviewTicket(list[i]);
|
|
98
98
|
if (!one.ok) {
|
|
99
|
-
|
|
99
|
+
// Named as every other surface names it: the Jira key, else "Story N" where N counts the
|
|
100
|
+
// stories that will be STORED (blank entries are dropped below, so a raw position would
|
|
101
|
+
// disagree with the panel's tabs and the run's results).
|
|
102
|
+
const raw = list[i];
|
|
103
|
+
const key = raw?.source === 'jira' && typeof raw.key === 'string' ? raw.key.trim() : '';
|
|
104
|
+
const name = storyName({ key: TICKET_KEY_RE.test(key) ? key : null }, tickets.length);
|
|
105
|
+
const message = list.length > 1 ? `${name}: ${one.message}` : one.message;
|
|
100
106
|
return { ok: false, index: i, field: one.field, message };
|
|
101
107
|
}
|
|
102
108
|
if (one.ticket)
|
package/dist/shared/types.js
CHANGED
|
@@ -589,6 +589,15 @@ export const BLAST_HIGH_SURFACES = [
|
|
|
589
589
|
// every send, so this is a spend bound, not a UI nicety. `cap` and `configuredCount` ride the GET
|
|
590
590
|
// so the UI can warn BEFORE the Save rather than explaining a refusal after it.
|
|
591
591
|
export const SLACK_TARGET_WORKSPACE_CAP = 12;
|
|
592
|
+
// ── The Open PRs cards' ticket row (Pro, `issueLinks`) ─────────────────────────────────────────
|
|
593
|
+
// `POST /api/pro/ticket-links` — ONE request for every listed card (never one per card). The
|
|
594
|
+
// server runs the SAME detection the PR-detail chips use (title + head branch, against the PR's
|
|
595
|
+
// own workspace tracker settings) and, for a Jira workspace with a saved token, adds each ticket's
|
|
596
|
+
// title, status and assignee from the STORED rows (plugin 0038) — the route makes NO Jira call; a
|
|
597
|
+
// ticket not read yet kicks the background worker. Over `TICKET_LINKS_MAX_PRS` ids is a 400, never
|
|
598
|
+
// a silent truncation. (`TICKET_LINKS_TITLE_LOOKUPS` is now the worker's per-kick bound.)
|
|
599
|
+
export const TICKET_LINKS_MAX_PRS = 1000;
|
|
600
|
+
export const TICKET_LINKS_TITLE_LOOKUPS = 40;
|
|
592
601
|
// The OFFERED list: what the picker shows and what `POST /api/prs/:id/claude-review` accepts.
|
|
593
602
|
// A real runtime value, read by the SPA AND the plugin's route schema (shared is vendored into
|
|
594
603
|
// the release, so both halves read this one spelling). DEFAULT FIRST: Opus 5.5 is the most
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const hooks = [];
|
|
2
|
+
export function registerRepoSyncedHook(handler) {
|
|
3
|
+
hooks.push(handler);
|
|
4
|
+
}
|
|
5
|
+
export function notifyRepoSynced(args, log) {
|
|
6
|
+
for (const h of hooks) {
|
|
7
|
+
try {
|
|
8
|
+
const r = h(args);
|
|
9
|
+
if (r != null && typeof r.then === 'function') {
|
|
10
|
+
r.catch((err) => log.warn(`repo-synced hook failed (non-fatal): ${err instanceof Error ? err.message : String(err)}`));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
catch (err) {
|
|
14
|
+
log.warn(`repo-synced hook failed (non-fatal): ${err instanceof Error ? err.message : String(err)}`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/** Test hook. */
|
|
19
|
+
export function _resetRepoSyncedHooksForTest() {
|
|
20
|
+
hooks.length = 0;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=repo-synced-hooks.js.map
|
|
@@ -6,6 +6,7 @@ import { syncRepo } from './sync-repo.js';
|
|
|
6
6
|
import { backoffMsFor, decideIncrementalWalk, isDue, noteAttempt, noteWalkFailure, noteWalkSuccess, recordFullWalk, } from './adaptive.js';
|
|
7
7
|
import { isSeverityApiConfigured } from '../ml/severity-client.js';
|
|
8
8
|
import { runMlEnrichmentTick } from './ml-enrichment.js';
|
|
9
|
+
import { notifyRepoSynced } from './repo-synced-hooks.js';
|
|
9
10
|
import { deleteMlLabelsForRepo } from '../db/ml-labels.js';
|
|
10
11
|
const { repos, syncState, accounts } = schema;
|
|
11
12
|
// In-memory record of which repos are mid-sync (status isn't persisted as
|
|
@@ -420,6 +421,12 @@ export async function runSyncForRepo(repoId, log, opts = {}) {
|
|
|
420
421
|
catch (err) {
|
|
421
422
|
log.warn(`commit headline backfill ${repo.owner}/${repo.name} failed (non-fatal): ${err instanceof Error ? err.message : err}`);
|
|
422
423
|
}
|
|
424
|
+
// "A PR WAS RECEIVED": the plugin's Jira ticket worker reads the tickets new and changed PRs
|
|
425
|
+
// name (sync/repo-synced-hooks.ts). A fire-and-forget KICK — it never holds this repo's slot
|
|
426
|
+
// and never fails the sync; inert with no plugin.
|
|
427
|
+
if (!walk.cancelled && !cancelRequested.has(repoId)) {
|
|
428
|
+
notifyRepoSynced({ accountId: repo.accountId, repoId }, log);
|
|
429
|
+
}
|
|
423
430
|
// The UNSETTLED-PR BACKSTOP (sync/unsettled-prs.ts): re-read merge state stored unknown and
|
|
424
431
|
// CI stuck `pending` — GitHub finishing either never bumps `updatedAt`, so the walk's own
|
|
425
432
|
// `since` window can never see it again. FIRE-AND-FORGET (never holds this repo's slot),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "limn-review",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.124",
|
|
4
4
|
"description": "Dashboard for tracking your team's GitHub PR activity across repos — local (SQLite + gh) or self-hosted multi-tenant cloud (Postgres + GitHub App).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Alex Wakeman",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as e,r as m,d as V}from"./tanstack-5qsxxaLe.js";import{I as R,
|
|
2
|
-
`)})]}),!p&&b&&e.jsx(Fe,{pr:t,fix:b,headInfo:(s==null?void 0:s.headInfo)??null,viewerCanPush:(s==null?void 0:s.viewerCanPush)??!1}),n&&!b&&e.jsx("p",{className:"mt-3 text-xs text-gray-500 dark:text-gray-400",children:"Loading…"})]}),e.jsx(Ae,{history:(s==null?void 0:s.history)??[],currentFixId:((B=s==null?void 0:s.fix)==null?void 0:B.id)??null})]})]})}function
|
|
1
|
+
import{j as e,r as m,d as V}from"./tanstack-5qsxxaLe.js";import{I as R,b7 as N,a as G,aZ as X,e as Y,g as z,o as Z,q as Q,a_ as ee,b3 as se,D as te,bf as re,b1 as ne,$ as ae,a$ as ie,A as D,l as le,m as de,f as U,J as ce,af as oe,P as xe,h as ue,ay as he,aF as E,M as me,v as ge,x as pe,aK as O,bd as be}from"./index-SG17YBlJ.js";import"./markdown-I_JLLVAZ.js";import"./highlight-CIIZLa6Z.js";import"./vis-C3BCkP5U.js";const $="inline-flex max-w-full items-center gap-1 rounded px-1.5 py-0.5 text-[11px] font-medium bg-gray-500/10 text-gray-700 dark:text-gray-200",f="mb-1 mt-3 flex items-center gap-1 text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400";function ye(t){return t.kind==="finding"&&t.findingId!=null?`claude-finding-${t.findingId}`:null}function je(t){const r=N(s=>s.openClaudeReview);return s=>{r({id:t.id,number:t.number,title:t.title,repoFullName:t.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null});const n=Date.now()+3e3,l=()=>{const i=document.getElementById(s);if(i){i.scrollIntoView({behavior:"smooth",block:"center"});return}Date.now()<n&&requestAnimationFrame(l)};requestAnimationFrame(l)}}function v({refId:t,item:r,onJump:s}){const n=r?`${G[r.kind]} ${t}`:t,l=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"shrink-0",children:n}),r&&e.jsxs("span",{className:"min-w-0 truncate font-normal",children:["· ",r.title]})]}),i=r?ye(r):null;return i?e.jsx("button",{type:"button",onClick:()=>s(i),"aria-label":`${n}: ${(r==null?void 0:r.title)??""}. Show in Claude Review`,className:`${$} max-w-[22rem] hover:bg-gray-500/20`,children:l}):e.jsx("span",{className:`${$} max-w-[22rem]`,children:l})}function fe(t){var r;switch(t.seed){case"review":{const s=((r=t.reviewItems)==null?void 0:r.length)??0;return`Fix from the Claude review${s>0?` (${s} item${s===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 ve({pr:t,fix:r}){const s=je(t),n=r.changeReport,l=new Map((r.reviewItems??[]).map(a=>[a.ref,a])),i=(r.reviewItems??[]).filter(a=>!a.included);if(!n&&i.length===0)return null;const d=new Set((n==null?void 0:n.changes.map(a=>a.path))??[]),g=r.filesChanged.filter(a=>!d.has(a)),u=l.size>0;return e.jsxs("div",{className:"mt-2 text-xs",children:[n&&(n.changes.length>0||g.length>0)&&e.jsxs("section",{children:[e.jsxs("div",{className:f,children:["Changes",e.jsxs(R,{title:"Changes",children:[e.jsx("p",{children:"What Claude says it changed in each file, and why."}),u&&e.jsx("p",{children:"Each tag is a review item the change answers. A finding tag opens it in the Claude Review tab."}),e.jsx("p",{children:"The diff below is what actually changed."})]})]}),e.jsxs("ul",{className:"space-y-2",children:[n.changes.map(a=>e.jsxs("li",{children:[e.jsx("div",{className:"break-all font-mono text-gray-800 dark:text-gray-100",children:a.path}),a.summary&&e.jsx("p",{className:"mt-0.5 text-gray-700 dark:text-gray-300",children:a.summary}),a.refs.length>0&&e.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:a.refs.map(h=>e.jsx(v,{refId:h,item:l.get(h),onJump:s},h))})]},a.path)),g.map(a=>e.jsxs("li",{children:[e.jsx("div",{className:"break-all font-mono text-gray-800 dark:text-gray-100",children:a}),e.jsx("p",{className:"mt-0.5 text-gray-500 dark:text-gray-400",children:"No summary reported."})]},a))]})]}),n&&n.unaddressed.length>0&&e.jsxs("section",{children:[e.jsx("div",{className:f,children:"Not addressed"}),e.jsx("ul",{className:"space-y-1.5",children:n.unaddressed.map(a=>e.jsxs("li",{children:[e.jsx(v,{refId:a.ref,item:l.get(a.ref),onJump:s}),e.jsx("p",{className:"mt-0.5 text-gray-700 dark:text-gray-300",children:a.reason})]},a.ref))})]}),n&&n.notReported.length>0&&e.jsxs("section",{children:[e.jsx("div",{className:f,children:"No report"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:n.notReported.map(a=>e.jsx(v,{refId:a,item:l.get(a),onJump:s},a))})]}),i.length>0&&e.jsxs("section",{children:[e.jsxs("div",{className:f,children:["Left out",e.jsx(R,{title:"Left out",children:e.jsx("p",{children:"These review items did not fit in what Claude was sent, so it never saw them."})})]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:i.map(a=>e.jsx(v,{refId:a.ref,item:a,onJump:s},a.ref))})]})]})}const P="whitespace-nowrap rounded border border-blue-400 px-2.5 py-1 text-xs text-blue-600 hover:bg-blue-50 disabled:opacity-50 dark:border-blue-600 dark:text-blue-400 dark:hover:bg-blue-900/30";function K(t){return t instanceof ue||t instanceof Error?t.message:"Something went wrong"}const Ne="whitespace-nowrap rounded border border-gray-300 px-2.5 py-1 text-xs hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500";function W({children:t,info:r}){return e.jsxs("div",{className:"flex items-center gap-1 px-4 pb-1 pt-3 text-xs font-semibold uppercase tracking-wide text-gray-400",children:[t,r]})}function _e({pr:t}){const r=X().enabled,s=N(d=>d.aiFixTabFocus),n=N(d=>d.consumeAiFixTabFocus),[l,i]=m.useState(null);return m.useEffect(()=>{s&&s.prId===t.id&&(s.reviewId!=null&&i(s.reviewId),n())},[s,t.id,n]),r?e.jsxs("div",{className:"pb-6",children:[e.jsx("div",{className:"border-b border-gray-200 empty:hidden dark:border-gray-800",children:e.jsx(z,{pr:t})}),e.jsx(we,{pr:t}),e.jsx(ke,{pr:t,handoffReviewId:l})]}):e.jsx("div",{className:"p-4",children:e.jsx(Y,{})})}function we({pr:t}){const r=t.checkRuns;return r.length===0?null:e.jsxs("div",{className:"border-b border-gray-200 dark:border-gray-800",children:[e.jsx(W,{children:"CI status"}),e.jsxs("div",{className:"px-4 pb-3",children:[e.jsx(Z,{prId:t.id,prGithubUrl:t.githubUrl,checks:r}),e.jsx(Q,{prId:t.id,checks:r,viewerCanPush:t.viewerCanPush})]})]})}function ke({pr:t,handoffReviewId:r}){var _,L,M,B;const{data:s,isLoading:n}=ee(t.id,!0),{data:l}=se(t.id),i=(l==null?void 0:l.review)??null,d=r??((i==null?void 0:i.status)==="succeeded"?i.id:null),g=r!=null&&i!=null&&r!==i.id,[u,a]=m.useState(te),[h,y]=m.useState(""),x=re(t.id),w=ne(t.id),k=N(c=>c.noteAiFixRun),F=V({mutationKey:ae(t.id)})>0,C=((_=s==null?void 0:s.fix)==null?void 0:_.status)??null,J=C==="running"||C==="queued"||F,{status:o}=ie(t.id,J),S=(o==null?void 0:o.status)??C??"idle",p=S==="running"||S==="queued",I=()=>k({prId:t.id,repoFullName:t.repoFullName,prNumber:t.number,prTitle:t.title}),q=()=>{d!=null&&(I(),x.mutate({model:u,seed:"review",sourceReviewId:d}))},j=h.trim(),A=j.length>D,T=()=>{j===""||A||(I(),x.mutate({model:u,seed:"plain",instruction:j},{onSuccess:()=>y("")}))},b=(s==null?void 0:s.fix)??null;return e.jsxs("div",{children:[e.jsx(W,{info:e.jsxs(R,{title:"AI Fix",children:[e.jsx("p",{children:"Claude reads the PR's code and edits files in a private copy. It has no shell, so it installs, builds and tests nothing."}),e.jsx("p",{children:"Fix from review works through everything the Claude review found except praise: findings you have not ignored, earlier findings still open, other reviewers' threads that still need a fix, user-story gaps and CI failures the review says this PR can fix. Or type your own instruction."}),e.jsx("p",{children:"Claude 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."})]}),children:"AI Fix"}),e.jsxs("div",{className:"px-4",children:[(s==null?void 0:s.enabled)===!1?e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"The agentic fixer is turned off."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("select",{"aria-label":"Model",className:"rounded border border-gray-300 bg-transparent px-2 py-1 text-xs dark:border-gray-700",value:u,onChange:c=>a(c.target.value),disabled:p,children:le.map(c=>e.jsx("option",{value:c,children:de[c]},c))}),p?e.jsx("button",{type:"button",className:Ne,onClick:()=>w.mutate(),children:"Cancel"}):d!=null&&e.jsx(U,{auth:s==null?void 0:s.auth,children:e.jsx("button",{type:"button",className:P,disabled:F,onClick:q,children:"Fix from review"})}),!p&&g&&e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Uses the review you picked, not the latest."})]}),!p&&e.jsxs("div",{className:"mt-2",children:[e.jsx("textarea",{"aria-label":"What to fix",className:"w-full rounded border border-gray-300 bg-transparent px-2 py-1 text-xs dark:border-gray-700",rows:2,value:h,placeholder:"Or say what to fix…",onChange:c=>y(c.target.value),onKeyDown:c=>{c.key==="Enter"&&(c.metaKey||c.ctrlKey)&&T()}}),j!==""&&e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[e.jsx(U,{auth:s==null?void 0:s.auth,children:e.jsx("button",{type:"button",className:P,disabled:F||A,onClick:T,children:"Fix"})}),A&&e.jsxs("span",{className:"text-[11px] text-red-600 dark:text-red-400",children:["Keep it under ",D.toLocaleString("en-US")," characters."]})]})]}),x.isError&&e.jsx("p",{className:"mt-1 text-[11px] text-red-600 dark:text-red-400",children:K(x.error)}),p&&e.jsxs("div",{className:"mt-3",children:[e.jsx(ce,{active:!0,label:"Running AI fix",value:oe(o),timeConstantSec:40}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400",children:[(b==null?void 0:b.trigger)==="auto"&&e.jsx(H,{}),xe[((L=o==null?void 0:o.progress)==null?void 0:L.phase)??""]??"Working…"]}),((M=o==null?void 0:o.progress)==null?void 0:M.recentActivity)&&o.progress.recentActivity.length>0&&e.jsx("pre",{className:"mt-1 max-h-32 overflow-auto rounded bg-gray-50 p-2 text-[11px] leading-relaxed text-gray-500 dark:text-gray-400 dark:bg-gray-900",children:o.progress.recentActivity.slice(-8).join(`
|
|
2
|
+
`)})]}),!p&&b&&e.jsx(Fe,{pr:t,fix:b,headInfo:(s==null?void 0:s.headInfo)??null,viewerCanPush:(s==null?void 0:s.viewerCanPush)??!1}),n&&!b&&e.jsx("p",{className:"mt-3 text-xs text-gray-500 dark:text-gray-400",children:"Loading…"})]}),e.jsx(Ae,{history:(s==null?void 0:s.history)??[],currentFixId:((B=s==null?void 0:s.fix)==null?void 0:B.id)??null})]})]})}function H(){return e.jsx("span",{className:"inline-flex items-center rounded bg-gray-500/10 px-1.5 py-px text-[11px] font-medium text-gray-600 dark:text-gray-300",children:"Auto fix"})}function Fe({pr:t,fix:r,headInfo:s,viewerCanPush:n}){const l=m.useMemo(()=>he(r.patch),[r.patch]);if(r.status==="failed")return e.jsxs("div",{className:"mt-3 rounded border border-red-200 bg-red-50 p-2 text-xs text-red-700 dark:border-red-800 dark:bg-red-950/30 dark:text-red-300",children:["The fix run failed: ",r.error??"unknown error"]});if(r.status==="cancelled")return e.jsx("p",{className:"mt-3 text-xs text-gray-500 dark:text-gray-400",children:"The fix run was cancelled."});if(r.status!=="succeeded")return e.jsx(e.Fragment,{});const i=!r.patch||r.filesChanged.length===0;return e.jsxs("div",{className:"mt-3 border-t border-gray-200 pt-3 dark:border-gray-800",children:[e.jsxs("p",{className:"mb-1 text-xs text-gray-500 dark:text-gray-400",children:[r.trigger==="auto"&&e.jsxs(e.Fragment,{children:[e.jsx(H,{})," "]}),fe(r),r.finishedAt&&e.jsxs(e.Fragment,{children:[" · ",E(r.finishedAt)]})]}),r.summary&&e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(me,{children:r.summary})}),e.jsx(ve,{pr:t,fix:r}),i?e.jsx("p",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",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-xs text-gray-500 dark:text-gray-400",children:[e.jsxs("span",{children:[r.filesChanged.length," file",r.filesChanged.length===1?"":"s"," changed · Not built or tested here."]}),e.jsx(ge,{})]}),e.jsx("div",{className:"overflow-hidden rounded border border-gray-200 text-gray-800 dark:border-gray-800 dark:text-gray-200",children:e.jsx(pe,{files:l})}),e.jsx(Re,{pr:t,fix:r,headInfo:s,viewerCanPush:n})]})]})}function Ce({fix:t}){return e.jsxs("div",{className:"mb-2 rounded border border-green-200 bg-green-50 p-2 text-xs text-green-700 dark:border-green-800 dark:bg-green-950/30 dark:text-green-300",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:O(t.pushedPrUrl),target:"_blank",rel:"noreferrer",className:"underline",children:["PR #",t.pushedPrNumber]})]}),t.pushedAt&&e.jsxs(e.Fragment,{children:[" · ",E(t.pushedAt)]})]}),t.commitMessage&&e.jsx("div",{className:"mt-1 font-mono text-[11px] text-green-800 dark:text-green-300",children:t.commitMessage})]})}function Ae({history:t,currentFixId:r}){const s=t.filter(n=>n.pushedAt!=null&&n.id!==r);return s.length===0?null:e.jsxs("div",{className:"mt-4 border-t border-gray-200 pt-3 dark:border-gray-800",children:[e.jsx("div",{className:"mb-1.5 text-xs font-semibold uppercase tracking-wide text-gray-400",children:"Earlier fixes pushed"}),e.jsx("ul",{className:"space-y-2",children:s.map(n=>e.jsxs("li",{className:"text-xs",children:[e.jsx("div",{className:"font-mono text-gray-700 dark:text-gray-200",children:n.commitMessage??"(no commit message)"}),e.jsxs("div",{className:"mt-0.5 text-[11px] text-gray-400",children:[n.pushedBranch&&e.jsx("span",{className:"font-mono",children:n.pushedBranch}),n.pushedPrUrl&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("a",{href:O(n.pushedPrUrl),target:"_blank",rel:"noreferrer",className:"underline",children:["PR #",n.pushedPrNumber]})]}),n.pushedAt&&e.jsxs(e.Fragment,{children:[" · ",E(n.pushedAt)]})]})]},n.id))})]})}function Re({pr:t,fix:r,headInfo:s,viewerCanPush:n}){const l=be(t.id),i=(s==null?void 0:s.canPushSameBranch)??!1,[d,g]=m.useState(i?"existing":"new"),[u,a]=m.useState((s==null?void 0:s.suggestedBranch)??""),h=m.useRef(!1);if(m.useEffect(()=>{!h.current&&(s!=null&&s.suggestedBranch)&&(a(s.suggestedBranch),h.current=!0,s.canPushSameBranch||g("new"))},[s]),r.pushedAt!=null)return e.jsx(Ce,{fix:r});if(!n)return e.jsx("p",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:"You need write access to push this fix."});const y=d==="new"&&u.trim().length===0,x=l.isPending,w=()=>{l.mutate({fixId:r.id,body:{target:d,branch:d==="new"?u.trim():void 0}})};return e.jsxs("div",{className:"mt-3 rounded border border-gray-200 p-2 dark:border-gray-800",children:[r.commitMessage&&e.jsx("div",{className:"mb-2 rounded bg-gray-50 px-2 py-1 font-mono text-xs text-gray-700 dark:bg-gray-900 dark:text-gray-200",title:"Commit message",children:r.commitMessage}),e.jsxs("label",{className:`flex items-center gap-2 text-xs ${i?"":"opacity-40"}`,title:i?void 0:"The PR head is a fork you cannot push to — use a new branch",children:[e.jsx("input",{type:"radio",checked:d==="existing",disabled:!i||x,onChange:()=>g("existing")}),"Push to the PR branch",(s==null?void 0:s.headRef)&&e.jsxs("span",{className:"font-mono text-gray-400",children:["(",s.headRef,")"]})]}),e.jsxs("label",{className:"mt-1 flex items-center gap-2 text-xs",children:[e.jsx("input",{type:"radio",checked:d==="new",disabled:x,onChange:()=>g("new")}),"New branch + open a PR"]}),d==="new"&&e.jsx("input",{type:"text",className:"mt-1 w-full rounded border border-gray-300 bg-transparent px-2 py-1 font-mono text-xs dark:border-gray-700",value:u,disabled:x,onChange:k=>a(k.target.value),placeholder:"branch-name"}),e.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:e.jsx("button",{type:"button",className:P,disabled:x||y,onClick:w,children:x?"Pushing…":d==="new"?"Push + open PR":"Push"})}),l.isError&&e.jsx("div",{className:"mt-2 text-[11px] text-red-500",children:K(l.error)})]})}export{_e as AiFixTab};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{j as e,i as Dt,l as et,e as Bt,d as Ut,f as Ot,r as u}from"./tanstack-5qsxxaLe.js";import{a2 as xe,s as Gt,p as ie,j as dt,M as ve,f as Rt,ab as zt,aK as Me,E as De,a8 as Kt,ae as Vt,aX as Wt,aV as qt,k as ct,ar as Jt,a4 as Qt,I as he,aP as Yt,ao as fe,r as Xt,G as Zt,Z as es,H as tt,a9 as ts,aC as ss,as as Ae,aE as _e,at as Ge,aw as rs,aD as ze,aG as as,_ as ns,aq as ls,Y as is,az as os,F as St,w as $t,aU as ds,Q as cs,O as us,aN as ut,aO as xt,ad as xs,ah as hs,S as It,ax as ms,n as $e,V as ps,U as gs,av as ys,a6 as bs,a1 as st,aA as fs,aS as ks,aR as js,ap as Ns,N as ht,L as mt,T as vs,aQ as ws,B as Cs,aT as Rs,t as Ss,aZ as Et,b3 as $s,u as Is,aI as pt,a7 as Es,bi as Ts,b8 as As,b5 as _s,b2 as Fs,bh as Ps,bg as Ls,bb as Hs,ba as Ms,b6 as Ds,b4 as Bs,e as Us,l as Os,m as Qe,d as Gs,a3 as gt,an as zs,J as Ks,c as Ye,i as Ie,ak as Tt,aj as yt,y as At,aa as Vs,aJ as Ws,aY as qs,aW as Js,aB as Qs,aL as Ys,aH as Xs,a0 as Zs,ai as er,aM as tr,b7 as sr,X as rr,W as ar,C as nr,R as bt,b as Ke,b9 as lr,am as ft,al as ir,au as or,bk as dr,z as cr}from"./index-SG17YBlJ.js";import"./markdown-I_JLLVAZ.js";import"./highlight-CIIZLa6Z.js";import"./vis-C3BCkP5U.js";function ne({title:t,pills:s,info:a,actions:n,children:i}){const l=i!=null&&i!==!1;return e.jsxs("section",{"aria-label":t,className:"rounded-lg border border-gray-300 bg-white dark:border-gray-700 dark:bg-gray-950",children:[e.jsxs("header",{className:`flex flex-wrap items-center gap-x-2 gap-y-1 bg-gray-50 px-3 py-2 dark:bg-gray-900 ${l?"rounded-t-lg border-b border-gray-200 dark:border-gray-800":"rounded-lg"}`,children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:t}),s,a,n!=null&&e.jsx("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:n})]}),l&&e.jsx("div",{className:"space-y-2 px-3 py-3 text-sm",children:i})]})}function kt({children:t}){return e.jsx("span",{className:"inline-flex shrink-0 items-center rounded bg-gray-500/10 px-1.5 py-0.5 text-[11px] font-medium text-gray-700 dark:text-gray-300",children:t})}const _t=(t,s)=>["claude-review-chat",t,s??"review"],rt=t=>["claude-review-chat-ask",t];function ur(t,s,a){return Dt({queryKey:_t(t,s),queryFn:()=>xe.claudeReviewChat(t,s),staleTime:3e4,refetchInterval:n=>{var i;return(i=n.state.data)!=null&&i.answering?4e3:!1}})}function xr(t){return Ut({mutationKey:rt(t)})>0}function hr(t,s){const n=Ot({filters:{mutationKey:rt(t),status:"pending"},select:i=>i.state.variables}).find(i=>((i==null?void 0:i.findingId)??null)===s);return(n==null?void 0:n.question)??null}function mr(t){const s=et();return Bt({mutationKey:rt(t),mutationFn:a=>xe.askClaudeReviewChat(t,a),onSuccess:(a,n)=>{const i=_t(t,n.findingId??null);s.setQueryData(i,l=>l&&{...l,messages:[...l.messages.filter(d=>!a.messages.some(r=>r.id===d.id)),...a.messages],headMoved:a.headMoved,answering:!1}),s.invalidateQueries({queryKey:i}),s.invalidateQueries({queryKey:["ai-usage"]})}})}const pr="Answers are about the reviewed commit; the PR has moved on.",gr="whitespace-nowrap rounded border border-blue-400 px-2 py-0.5 text-xs text-blue-600 hover:bg-blue-50 disabled:opacity-50 dark:border-blue-600 dark:text-blue-400 dark:hover:bg-blue-900/30";function yr({reviewId:t,findingId:s}){var S,L,_;const a=ur(t,s),n=mr(t),i=xr(t),l=hr(t,s),[d,r]=u.useState(""),[h,b]=u.useState(null),j=((S=a.data)==null?void 0:S.messages)??[],C=((L=a.data)==null?void 0:L.answering)===!0&&!i,m=d.trim().length>dt,N=d.trim()!==""&&!m&&!i&&!C,f=()=>{if(!N)return;const v=d.trim();b(null),n.mutate({question:v,findingId:s},{onSuccess:()=>r(A=>A.trim()===v?"":A),onError:A=>b(A.message)})};return e.jsxs("div",{className:"mt-2 space-y-2 rounded border border-gray-200 bg-gray-50/60 p-2 dark:border-gray-800 dark:bg-gray-900/40",children:[((_=a.data)==null?void 0:_.headMoved)&&e.jsx("div",{className:"text-xs text-amber-700 dark:text-amber-400",children:pr}),a.isLoading&&e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Loading…"}),a.isError&&e.jsx("div",{className:"text-xs text-red-600 dark:text-red-400",children:"Could not load this conversation."}),j.length>0&&e.jsx("ol",{className:"space-y-2",children:j.map(v=>e.jsxs("li",{className:"text-sm",children:[e.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:v.role==="user"?"You":"Claude"}),v.role==="user"?e.jsx("div",{className:"whitespace-pre-wrap",children:v.content}):e.jsx(ve,{children:v.content})]},v.id))}),l!=null&&e.jsxs("div",{className:"text-sm",children:[e.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"You"}),e.jsx("div",{className:"whitespace-pre-wrap",children:l})]}),(l!=null||C)&&e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Claude is answering…"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("textarea",{value:d,onChange:v=>r(v.target.value),onKeyDown:v=>{v.key==="Enter"&&(v.metaKey||v.ctrlKey)&&(v.preventDefault(),f())},rows:2,placeholder:s!=null?"Ask about this finding":"Ask about this review","aria-label":s!=null?"Question about this finding":"Question about this review",className:"w-full resize-y rounded border border-gray-300 bg-white px-2 py-1 text-sm dark:border-gray-700 dark:bg-gray-950"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Rt,{children:e.jsx("button",{type:"button",onClick:f,disabled:!N,className:gr,children:i?"Answering…":"Ask"})}),i&&l==null&&e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Answering another question…"}),m&&e.jsxs("span",{className:"text-xs text-red-600 dark:text-red-400",children:["Keep it under ",dt.toLocaleString("en-US")," characters."]}),h!=null&&e.jsx("span",{className:"text-xs text-red-600 dark:text-red-400",children:h})]})]})]})}function br({reviewId:t}){const[s,a]=u.useState(!1);return e.jsx(ne,{title:"Review chat",actions:e.jsxs("button",{type:"button",onClick:()=>a(n=>!n),"aria-expanded":s,className:"inline-flex items-center gap-1.5 text-sm font-medium text-blue-600 hover:underline dark:text-blue-400",children:[e.jsx(Gt,{size:13}),s?"Hide":"Ask Claude about this review",e.jsx(ie,{dir:s?"down":"right",size:12})]}),children:s&&e.jsx(yr,{reviewId:t,findingId:null})})}const fr="text-gray-500 dark:text-gray-400";function kr({ticketKey:t,url:s}){const a=s!=null?Me(s):void 0;return a==null||a===""?e.jsx("span",{className:"font-mono text-xs font-semibold",children:t}):e.jsxs("a",{href:a,target:"_blank",rel:"noreferrer noopener",className:"inline-flex items-center gap-1 font-mono text-xs font-semibold text-blue-600 hover:underline dark:text-blue-400",children:[t,e.jsx(De,{size:11})]})}function jr({draft:t,actions:s,fieldControl:a}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[t.key!=null&&e.jsx("span",{className:"pt-0.5",children:e.jsx(kr,{ticketKey:t.key,url:t.url})}),e.jsx("span",{className:"min-w-0 flex-1 break-words text-sm font-medium",children:t.title}),s]}),a,t.description.trim()!==""&&e.jsx("div",{className:"max-h-56 overflow-y-auto text-xs",children:e.jsx(ve,{children:t.description})}),e.jsxs("div",{children:[!zt(t.acceptanceCriteria)&&e.jsx("div",{className:`text-xs font-medium ${fr}`,children:"Acceptance criteria"}),t.acceptanceCriteria.trim()!==""?e.jsx("div",{className:"max-h-56 overflow-y-auto text-xs",children:e.jsx(ve,{children:t.acceptanceCriteria})}):e.jsx("p",{className:"text-xs text-gray-700 dark:text-gray-300",children:"None taken from this ticket."})]})]})}const Nr={blocker:"Blocker",warning:"Warning",nit:"Nit",question:"Question",praise:"Praise"},vr=["not_addressed","partly_addressed","not_checked","addressed","no_longer_applies"],Ee="inline-flex shrink-0 items-center rounded px-1.5 py-0.5 text-[11px] font-medium",$="text-gray-500 dark:text-gray-400",Ne="text-red-600 dark:text-red-400",Ve="whitespace-nowrap rounded border border-gray-300 px-2 py-0.5 text-xs hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",Pe="mt-0.5 w-full rounded border border-gray-300 bg-white px-2 py-1 text-sm dark:border-gray-700 dark:bg-gray-900";function Te({path:t,line:s,side:a,inChangeset:n,onOpenInChanges:i}){const l=st(t,s);return n&&i!=null?e.jsx("button",{type:"button",onClick:()=>i(t,s,a),className:"break-all text-left font-mono text-xs text-blue-600 hover:underline dark:text-blue-400",children:l}):e.jsx("span",{className:`break-all font-mono text-xs ${$}`,children:l})}function We({id:t,label:s,field:a,value:n,error:i,children:l}){const d=xs(a,n);return e.jsxs("div",{children:[e.jsx("label",{htmlFor:t,className:"text-xs font-medium text-gray-700 dark:text-gray-200",children:s}),l,d!=null&&e.jsx("div",{className:`mt-0.5 text-xs ${d.over?Ne:$}`,children:d.text}),i!=null&&e.jsx("p",{id:`${t}-error`,className:`mt-0.5 text-xs ${Ne}`,children:i})]})}function wr({value:t,onChange:s,errorFor:a}){const n=u.useId(),i={title:`${n}-title`,description:`${n}-description`,acceptanceCriteria:`${n}-criteria`},l=(r,h)=>s({...t,[r]:h}),d=r=>a(r)!=null?`${i[r]}-error`:void 0;return e.jsxs("div",{className:"space-y-2",children:[e.jsx(We,{id:i.title,label:"Title",field:"title",value:t.title,error:a("title"),children:e.jsx("input",{id:i.title,type:"text",value:t.title,onChange:r=>l("title",r.target.value),"aria-invalid":a("title")!=null,"aria-describedby":d("title"),className:Pe})}),e.jsx(We,{id:i.description,label:"Description",field:"description",value:t.description,error:a("description"),children:e.jsx("textarea",{id:i.description,rows:3,value:t.description,onChange:r=>l("description",r.target.value),"aria-invalid":a("description")!=null,"aria-describedby":d("description"),className:Pe})}),e.jsx(We,{id:i.acceptanceCriteria,label:"Acceptance criteria",field:"acceptanceCriteria",value:t.acceptanceCriteria,error:a("acceptanceCriteria"),children:e.jsx("textarea",{id:i.acceptanceCriteria,rows:4,value:t.acceptanceCriteria,onChange:r=>l("acceptanceCriteria",r.target.value),"aria-invalid":a("acceptanceCriteria")!=null,"aria-describedby":d("acceptanceCriteria"),className:Pe})})]})}function Cr(t,s){return t.key!=null&&t.key!==""?t.key:`Story ${s+1}`}const ke=ts(),Rr=6e4,Sr="rounded p-0.5 text-gray-500 hover:bg-gray-200 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-100",$r="whitespace-nowrap rounded border border-blue-400 px-2 py-0.5 text-xs font-medium text-blue-700 hover:bg-blue-50 disabled:opacity-50 dark:border-blue-600 dark:text-blue-300 dark:hover:bg-blue-900/30",Ir="text-xs text-blue-700 hover:underline disabled:opacity-50 dark:text-blue-300",Er="inline-block h-3 w-3 shrink-0 animate-spin rounded-full border-2 border-gray-300 border-t-blue-500 dark:border-gray-600 dark:border-t-blue-400";function Tr({value:t,onChange:s,check:a,prId:n,tickets:i,prWorkspaceName:l,autoPullReady:d}){const r=et(),[h,b]=u.useState(!1),j=u.useId(),C=u.useId(),[m,N]=u.useState(0),f=Kt(m,t.length),[S,L]=u.useState({}),_=u.useRef(S),v=o=>{_.current=o,L(o)},[A,U]=u.useState([]),[O,E]=u.useState(null),[D,H]=u.useState(null),q=u.useRef([]),p=u.useRef(t);p.current=t;const I=u.useRef(!0);u.useEffect(()=>(I.current=!0,()=>{I.current=!1}),[]);const w=u.useMemo(()=>Vt(i),[i]),X=Wt(i),P=A.length>0,Z=qt(t,a),we=t.length>=ct,G=Jt(w,t).keys,V=o=>w.find(c=>c.key===o)??null,ee=o=>["jira-ticket",n,o],le=o=>r.fetchQuery({queryKey:ee(o),queryFn:()=>xe.jiraTicket(n,o),staleTime:Rr}),oe=async(o,c)=>{const y=await le(o),x=ys(bs(),c,y);if(x==null)return y;try{const k=await xe.setJiraAcField(n,o,x);return r.setQueryData(ee(o),k),k}catch{return y}},ue=async(o,c)=>{if(o.length===0)return;U(o),E(null);const y=await ss(o,F=>{var W;return oe(F,((W=V(F))==null?void 0:W.url)??"")});if(!I.current){c&&ke.clearAutoPull(n);return}const x=[],k={..._.current};for(const{key:F,details:W}of y.ok){const Q=V(F);if(Q==null)continue;const re=Ae(Q.url),K=_e(W);x.push(Ge(Q,W,K)),k[F]={details:W,site:re,chosen:K}}const M=rs(p.current,x);M.added.length+M.refreshed.length>0&&s(M.drafts),M.selected!=null&&N(M.selected),v(k),E(ze(y.failed,M.overCap)),U([])},B=async(o,c,y)=>{const x=V(o);if(x==null)return null;U([o]),E(null);try{const k=await c();if(r.setQueryData(ee(o),k),!I.current)return k;const M=Ae(x.url),F=y??_e(k),W=Ge(x,k,F),Q=p.current,re=Q.findIndex(K=>fe(K)&&K.key===o);return re>=0&&s(Q.map((K,be)=>be===re?W:K)),v({..._.current,[o]:{details:k,site:M,chosen:F}}),k}catch(k){return I.current&&E(ze([{key:o,message:k instanceof Error?k.message:String(k)}],[])),null}finally{I.current&&U([])}},J=async(o,c)=>{if(c==null)return;const y=p.current.filter(x=>fe(x)&&x.key!=null&&x.key!==o&&x.issueTypeId===c);for(const x of y){const k=x.key,M=V(k);if(M!=null)try{await r.invalidateQueries({queryKey:ee(k)});const F=await le(k);if(!I.current)return;const W=Ge(M,F,_e(F)),Q=p.current,re=Q.findIndex(K=>fe(K)&&K.key===k);re>=0&&s(Q.map((K,be)=>be===re?W:K)),v({..._.current,[k]:{details:F,site:Ae(M.url),chosen:_e(F)}})}catch{}}},me=o=>{const c=o.key;c!=null&&B(c,()=>xe.refreshJiraTicket(n,c))},Ce=(o,c)=>{var y;if(H(null),c===""){const x=(y=_.current[o])==null?void 0:y.details;x!=null&&B(o,async()=>x,"");return}B(o,()=>xe.setJiraAcField(n,o,c)).then(x=>{var k;return J(o,(k=x==null?void 0:x.issueType)==null?void 0:k.id)})},pe=o=>{const c=o.key;c!=null&&(H(null),B(c,()=>xe.setJiraAcField(n,c,null)).then(y=>{var x;return J(c,(x=y==null?void 0:y.issueType)==null?void 0:x.id)}))},te=async o=>{var x;const c=o.key;if(c==null)return;if(D===c){H(null);return}if(H(c),_.current[c]!=null)return;const y=V(c);if(y!=null)try{const k=await le(c);if(!I.current)return;v({..._.current,[c]:{details:k,site:Ae(y.url),chosen:((x=o.acField)==null?void 0:x.id)??""}})}catch(k){I.current&&(H(null),E(ze([{key:c,message:k instanceof Error?k.message:String(k)}],[])))}},z=o=>{const c=o.filter(fe).map(x=>x.key).filter(x=>x!=null);if(c.length===0)return;ke.noteRemoved(n,c);const y={..._.current};for(const x of c)delete y[x];v(y),D!=null&&c.includes(D)&&H(null)},se=o=>{const c=p.current[o];if(c==null)return;z([c]);const y=as(p.current,o,f);s(y.drafts),N(y.selected),requestAnimationFrame(()=>{var x;return(x=q.current[y.selected])==null?void 0:x.focus()})},R=()=>{const o=p.current.length;o!==0&&window.confirm(`Remove ${o===1?"the story":`all ${o} stories`} from this review?`)&&(z(p.current),s([]),N(0),E(null))},Y=()=>{const o=ns(p.current);o!=null&&(s(o.drafts),N(o.selected),b(!0))},ge=o=>{ke.unremove(n,o),b(!0),ue(o,!1)},Be=(o,c)=>s(p.current.map((y,x)=>x===o?c:y)),ye=o=>c=>!a.ok&&a.index===o&&a.field===c?a.message:null;u.useEffect(()=>{if(!d||A.length>0)return;const o=w.map(y=>y.key);if(!ke.shouldAutoPull(n,o))return;const c=Qt(ke,n,w,p.current);ke.noteAutoPull(n,o),c.length!==0&&(b(!0),ue(c,!0))},[d,n,w]);const Ue=(o,c)=>{var k;const y=t.length;let x=null;if(o.key==="ArrowRight")x=(c+1)%y;else if(o.key==="ArrowLeft")x=(c-1+y)%y;else if(o.key==="Home")x=0;else if(o.key==="End")x=y-1;else if(o.key==="Delete"){o.preventDefault(),se(c);return}x!=null&&(o.preventDefault(),N(x),(k=q.current[x])==null||k.focus())},T=t[f],Oe=G.length===1?`Pull ${G[0]} from Jira`:`Pull all from Jira (${G.length})`;return e.jsxs("div",{className:"mt-2 rounded border border-gray-200 dark:border-gray-800",children:[e.jsxs("div",{className:"flex items-center gap-2 pr-2",children:[e.jsxs("button",{type:"button",onClick:()=>b(o=>!o),"aria-expanded":h,"aria-controls":j,className:"flex flex-1 items-center gap-1.5 px-2 py-1.5 text-left text-xs font-medium text-gray-700 dark:text-gray-200",children:[e.jsx(ie,{dir:h?"down":"right",className:"shrink-0"}),e.jsx("span",{children:"User stories (optional)"}),Z!==""&&e.jsx("span",{className:`font-normal ${a.ok?$:Ne}`,children:Z}),P&&!h&&e.jsx("span",{className:`font-normal ${$}`,children:"· pulling from Jira…"})]}),G.length>0&&!P&&e.jsx("button",{type:"button",onClick:()=>ge(G),className:$r,children:Oe}),e.jsxs(he,{title:"User stories",children:[e.jsxs("p",{children:["Claude checks the change against each story and lists what is missing or was not asked for. Up to ",ct," per review."]}),e.jsx("p",{className:"mt-2",children:"Jira tickets named on the pull request are added when you open this tab, as Limn last read them from Jira. Refresh reads one again. A story you remove is not added again unless you ask."})]})]}),h&&e.jsxs("div",{id:j,className:"border-t border-gray-200 px-2 pb-2 pt-1.5 dark:border-gray-800",children:[G.length>1&&!P&&e.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-1",children:[e.jsx("span",{className:`text-xs ${$}`,children:"Or pull one:"}),G.map(o=>e.jsx("button",{type:"button",onClick:()=>ge([o]),"aria-label":`Pull ${o} from Jira`,className:`${Ve} font-mono`,children:o},o))]}),w.length===0&&X.length>0&&e.jsxs("p",{className:`mb-1.5 text-xs ${$}`,children:["To pull ",X.map(o=>o.key).join(", "),", add a Jira API token in Settings for the"," ",l!=null?`${l} workspace`:"workspace this repository is in","."]}),e.jsxs("div",{className:"flex flex-wrap items-end gap-x-1 gap-y-1 border-b border-gray-200 dark:border-gray-800",children:[e.jsx("div",{role:"tablist","aria-label":"User stories",className:"flex min-w-0 flex-wrap items-end gap-1",children:t.map((o,c)=>{const y=Yt(t,c),x=c===f,k=!a.ok&&a.index===c,M=fe(o)&&o.key!=null;return e.jsxs("div",{role:"presentation",className:`-mb-px flex items-center rounded-t border ${x?"border-gray-200 border-b-white bg-white dark:border-gray-800 dark:border-b-gray-950 dark:bg-gray-950":"border-transparent hover:bg-gray-100 dark:hover:bg-gray-900"}`,children:[e.jsxs("button",{type:"button",role:"tab",id:`${C}-tab-${c}`,ref:F=>{q.current[c]=F},"aria-selected":x,"aria-controls":`${C}-panel`,tabIndex:x?0:-1,onClick:()=>N(c),onKeyDown:F=>Ue(F,c),className:`py-1 pl-2 pr-1 text-xs font-medium ${M?"font-mono":""} ${k?Ne:x?"text-gray-900 dark:text-gray-100":$}`,children:[y,k&&e.jsx("span",{className:"sr-only",children:" (needs a fix)"})]}),e.jsx("button",{type:"button",onClick:()=>se(c),"aria-label":`Remove ${y}`,title:`Remove ${y}`,tabIndex:x?0:-1,className:`mr-1 ${Sr}`,children:e.jsx(Xt,{size:10})})]},M?`jira-${o.key}`:`typed-${c}`)})}),P&&e.jsxs("span",{role:"status",className:`flex items-center gap-1.5 px-2 py-1 text-xs ${$}`,children:[e.jsx("span",{className:Er,"aria-hidden":"true"}),"Pulling ",A.join(", "),"…"]}),!we&&e.jsxs("button",{type:"button",onClick:Y,className:"flex items-center gap-1 px-2 py-1 text-xs text-blue-700 hover:underline dark:text-blue-300",children:[e.jsx(Zt,{size:11}),"Add story"]}),t.length>1&&e.jsx("button",{type:"button",onClick:R,className:`ml-auto px-1 py-1 text-xs ${$} hover:underline`,children:"Clear all"})]}),O!=null&&e.jsx("p",{className:`mt-1.5 text-xs ${Ne}`,children:O}),!a.ok&&a.index!==f&&e.jsx("p",{className:`mt-1.5 text-xs ${Ne}`,children:a.message}),T!=null&&e.jsx("div",{role:"tabpanel",id:`${C}-panel`,"aria-labelledby":`${C}-tab-${f}`,tabIndex:0,className:"pt-2 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500",children:fe(T)?e.jsx(jr,{draft:T,actions:T.key!=null&&V(T.key)!=null?e.jsxs("button",{type:"button",onClick:()=>me(T),disabled:P,className:`${Ve} inline-flex items-center gap-1`,children:[e.jsx(tt,{size:11,className:P&&A.includes(T.key)?"animate-spin":void 0}),"Refresh"]}):void 0,fieldControl:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-xs",children:[e.jsx("span",{className:$,children:"Criteria from:"}),e.jsx("span",{className:"font-medium text-gray-800 dark:text-gray-200",children:es(T)}),T.key!=null&&V(T.key)!=null&&e.jsx("button",{type:"button",onClick:()=>void te(T),disabled:P,"aria-expanded":D===T.key,className:Ir,children:"Change"})]}),D!=null&&D===T.key&&(S[T.key]!=null?e.jsxs("div",{className:"rounded border border-gray-200 p-2 dark:border-gray-800",children:[e.jsx(Ar,{fetched:S[T.key],onChoose:o=>Ce(T.key,o)}),e.jsx("button",{type:"button",onClick:()=>pe(T),disabled:P,className:`mt-1.5 ${Ve}`,children:"Reset to default"})]}):e.jsxs("p",{className:`text-xs ${$}`,children:["Reading ",T.key,"…"]}))]})}):e.jsx(wr,{value:T,onChange:o=>Be(f,o),errorFor:ye(f)},`typed-${f}`)})]})]})}function Ar({fetched:t,onChoose:s}){const a=u.useId(),{details:n,chosen:i}=t,l=ls(n,i);return n.candidates.length===0?l!=null?e.jsx("p",{className:`text-xs ${$}`,children:l}):null:e.jsxs("div",{children:[e.jsxs("label",{htmlFor:a,className:"text-xs font-medium text-gray-700 dark:text-gray-200",children:["Take the criteria from",n.issueType!=null&&e.jsxs("span",{className:`font-normal ${$}`,children:[" (",n.issueType.name,")"]})]}),e.jsxs("select",{id:a,value:i,onChange:d=>s(d.target.value),className:Pe,children:[e.jsx("option",{value:"",children:"None of these"}),n.candidates.map(d=>e.jsx("option",{value:d.id,children:is(d)},d.id))]}),n.omittedCandidates>0&&e.jsxs("p",{className:`mt-0.5 text-xs ${$}`,children:[n.omittedCandidates," more ",n.omittedCandidates===1?"field":"fields"," with text not listed."]}),l!=null&&e.jsx("p",{className:`mt-0.5 text-xs ${$}`,children:l})]})}function _r({c:t,changedPaths:s,onOpenInChanges:a}){return t.status==="met"?e.jsxs("li",{className:"flex items-baseline gap-2 px-1 text-xs",children:[e.jsx("span",{className:"shrink-0 self-center text-green-700 dark:text-green-400","aria-label":"Met",children:e.jsx($e,{size:12})}),e.jsx("span",{className:`shrink-0 font-mono ${$}`,children:t.ref}),e.jsxs("span",{className:"min-w-0 break-words text-gray-800 dark:text-gray-200",children:[t.text,t.path!=null&&t.path!==""&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:$,"aria-hidden":"true",children:" · "}),e.jsx(Te,{path:t.path,line:t.line,side:"RIGHT",inChangeset:s.has(t.path),onOpenInChanges:a})]})]})]}):e.jsxs("li",{className:"rounded border border-gray-200 px-3 py-2 dark:border-gray-800",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`${Ee} ${gs[t.status]}`,children:ps[t.status]}),e.jsx("span",{className:`shrink-0 font-mono text-xs leading-5 ${$}`,children:t.ref}),e.jsx("span",{className:"min-w-0 flex-1 whitespace-pre-wrap break-words text-sm font-medium",children:t.text})]}),t.path!=null&&t.path!==""&&e.jsx("div",{className:"mt-0.5",children:e.jsx(Te,{path:t.path,line:t.line,side:"RIGHT",inChangeset:s.has(t.path),onOpenInChanges:a})}),t.explanation!=null&&t.explanation!==""&&e.jsxs("p",{className:"mt-1 whitespace-pre-wrap break-words text-xs text-gray-700 dark:text-gray-300",children:[e.jsx("span",{className:"font-medium",children:"Claude: "}),t.explanation]})]})}function Fr({g:t,changedPaths:s,onOpenInChanges:a}){return e.jsxs("li",{className:"rounded border border-gray-200 px-3 py-2 dark:border-gray-800",children:[e.jsx("div",{className:"whitespace-pre-wrap break-words text-sm font-medium",children:t.title}),t.path!=null&&t.path!==""&&e.jsx("div",{className:"mt-0.5",children:e.jsx(Te,{path:t.path,line:t.line,side:"RIGHT",inChangeset:s.has(t.path),onOpenInChanges:a})}),t.explanation!=null&&t.explanation!==""&&e.jsx("p",{className:"mt-1 whitespace-pre-wrap break-words text-xs text-gray-700 dark:text-gray-300",children:t.explanation})]})}function jt({children:t}){return e.jsx("h5",{className:"text-xs font-semibold text-gray-700 dark:text-gray-200",children:t})}function Pr({entry:t,label:s,findingIds:a,findingsById:n,renderFinding:i,changedPaths:l,onOpenInChanges:d}){const{ticket:r,assessment:h}=t,b=ds(h),j=m=>m!=null?n.get(m)??null:null,C={changedPaths:l,onOpenInChanges:d};return e.jsxs("div",{"aria-label":`User story ${s??r.title??""}`,className:"space-y-3",children:[e.jsxs("h4",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[s!=null&&e.jsx("span",{className:`text-sm font-semibold text-gray-900 dark:text-gray-100 ${r.key!=null?"font-mono":""}`,children:s}),r.title!=null&&r.title!==""&&e.jsx("span",{className:"min-w-0 break-words text-sm font-medium text-gray-900 dark:text-gray-100",children:r.title}),h!=null&&e.jsx("span",{className:`${Ee} ${us[h.alignment]}`,children:cs[h.alignment]}),b!=null&&e.jsx("span",{className:`text-xs font-normal ${$}`,children:b.replace(/\.$/,"")})]}),h==null?e.jsx("p",{className:`text-xs ${$}`,children:"Not checked in this run."}):e.jsxs(e.Fragment,{children:[h.summary!=null&&h.summary!==""&&e.jsxs("p",{className:"whitespace-pre-wrap break-words text-xs text-gray-700 dark:text-gray-300",children:[e.jsx("span",{className:"font-medium",children:"Claude: "}),h.summary]}),h.criteria.length>0&&e.jsx("ul",{className:"space-y-1.5",children:h.criteria.map(m=>{const f=m.status==="not_met"||m.status==="partly_met"?j(ut(a,t.index,{ref:m.ref})):null;return f!=null&&(m.status==="not_met"||m.status==="partly_met")?e.jsx(u.Fragment,{children:i(f,xt(m.ref,m.status))},m.ref):e.jsx(_r,{c:m,...C},m.ref)})}),h.missing.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(jt,{children:`Not done (${h.missing.length})`}),e.jsx("ul",{className:"space-y-1.5",children:h.missing.map((m,N)=>{var S;const f=j(ut(a,t.index,{missingIndex:N}));return f!=null?e.jsx(u.Fragment,{children:i(f,xt(((S=f.story)==null?void 0:S.ref)??"",null))},N):e.jsx(Fr,{g:m,...C},N)})})]}),h.notRequested.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(jt,{children:`Not asked for (${h.notRequested.length})`}),e.jsx("ul",{className:"space-y-1.5 border-l-2 border-gray-200 pl-3 dark:border-gray-700",children:h.notRequested.map((m,N)=>e.jsxs("li",{className:"text-xs",children:[e.jsx("span",{className:"break-words font-medium text-gray-800 dark:text-gray-200",children:m.title}),m.path!=null&&m.path!==""&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:$,"aria-hidden":"true",children:" · "}),e.jsx(Te,{path:m.path,line:m.line,side:"RIGHT",inChangeset:l.has(m.path),onOpenInChanges:d})]}),m.explanation!=null&&m.explanation!==""&&e.jsx("p",{className:"whitespace-pre-wrap break-words text-gray-700 dark:text-gray-300",children:m.explanation})]},N))})]})]})]})}function Nt({item:t,muted:s,findingsById:a,headMoved:n,changedPaths:i,onOpenInChanges:l}){const d=hs(t,a,n,i),r=t.status==="not_addressed"||t.status==="partly_addressed"?"border-amber-300 dark:border-amber-700/60":"border-gray-200 dark:border-gray-800",h=t.reraisedFindingId!=null&&a.has(t.reraisedFindingId)?t.reraisedFindingId:null;return e.jsxs("li",{className:`rounded border px-3 py-2 text-sm ${r}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:`${Ee} ${St[t.status]}`,children:$t[t.status]}),e.jsx("span",{className:`${Ee} ${It[t.severity]}`,children:Nr[t.severity]}),e.jsx("span",{className:`min-w-0 break-words ${s?"text-gray-600 dark:text-gray-400":"font-medium"}`,children:t.title}),t.carried&&e.jsx("span",{className:`text-xs ${$}`,children:"from an earlier review"})]}),e.jsx("div",{className:"mt-0.5",children:e.jsx(Te,{path:d.path,line:d.line,side:d.side,inChangeset:d.inChangeset,onOpenInChanges:l})}),t.explanation!=null&&t.explanation!==""?e.jsxs("p",{className:"mt-1 whitespace-pre-wrap break-words text-xs text-gray-700 dark:text-gray-300",children:[e.jsx("span",{className:"font-medium",children:"Claude: "}),t.explanation]}):t.status==="not_checked"?e.jsx("p",{className:`mt-1 text-xs ${$}`,children:ms(t)}):null,h!=null&&e.jsxs("button",{type:"button",onClick:()=>{var b;return(b=document.getElementById(`claude-finding-${h}`))==null?void 0:b.scrollIntoView({block:"center",behavior:"smooth"})},className:"mt-1 inline-flex items-center gap-1 text-xs text-blue-600 hover:underline dark:text-blue-400",children:["Raised again below",e.jsx(ie,{dir:"down",size:11})]})]})}function Lr({followUp:t,findings:s,changedPaths:a,onOpenInChanges:n}){const[i,l]=u.useState(!1),d=u.useMemo(()=>new Map(s.map(j=>[j.id,j])),[s]),{open:r,closed:h}=u.useMemo(()=>os(t.items),[t.items]);if(t.items.length===0)return null;const b={findingsById:d,headMoved:t.headMoved,changedPaths:a,onOpenInChanges:n};return e.jsxs(ne,{title:"Previous review",pills:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`font-mono text-xs ${$}`,title:t.priorHeadSha,children:t.priorHeadSha.slice(0,7)}),vr.map(j=>{const C=t.items.filter(m=>m.status===j).length;return C>0?e.jsxs("span",{className:`${Ee} ${St[j]}`,children:[C," ",$t[j].toLowerCase()]},j):null})]}),children:[r.length>0&&e.jsx("ul",{className:"space-y-1.5",children:r.map(j=>e.jsx(Nt,{item:j,muted:!1,...b},j.priorFindingId))}),h.length>0&&e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>l(j=>!j),"aria-expanded":i,className:`inline-flex items-center gap-1 text-xs ${$} hover:text-gray-700 dark:hover:text-gray-200`,children:[e.jsx(ie,{dir:i?"down":"right",size:11}),"Addressed or no longer applies (",h.length,")"]}),i&&e.jsx("ul",{className:"mt-1.5 space-y-1.5",children:h.map(j=>e.jsx(Nt,{item:j,muted:!0,...b},j.priorFindingId))})]})]})}const Se="inline-flex shrink-0 items-center rounded px-1.5 py-0.5 text-[11px] font-medium",de="text-gray-500 dark:text-gray-400";function vt({t,muted:s,onOpenThread:a}){const[n,i]=u.useState(!1),[l,d]=u.useState(!1),r=u.useId(),h=Ns(t),b=Me(t.url),j=st(t.path,t.line),C=u.useRef(null),[m,N]=u.useState(!1);u.useLayoutEffect(()=>{const S=C.current;S!=null&&!n&&N(S.scrollHeight>S.clientHeight+1)},[t.excerpt,n]);const f=t.validity!=="not_checked"||t.addressed!=="not_checked";return e.jsxs("li",{className:`rounded border px-3 py-2 text-sm ${h?"border-amber-300 dark:border-amber-700/60":"border-gray-200 dark:border-gray-800"}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.validity!=="not_checked"&&e.jsx("span",{className:`${Se} ${mt[t.validity]}`,children:ht[t.validity]}),t.addressed!=="not_checked"&&e.jsx("span",{className:`${Se} ${ws(t)}`,children:vs[t.addressed]}),!f&&e.jsx("span",{className:`${Se} ${mt.not_checked}`,children:ht.not_checked}),t.authorLogin!=null&&e.jsxs("span",{className:s?"text-gray-600 dark:text-gray-400":"font-medium",children:["@",t.authorLogin]}),t.authorIsBot&&e.jsxs("span",{className:`${Se} gap-1 bg-gray-500/10 text-gray-600 dark:text-gray-300`,children:[e.jsx(Cs,{size:12}),"Bot"]}),t.carried&&e.jsxs("span",{className:`text-xs ${de}`,children:["Unchanged since ",e.jsx("span",{className:"font-mono",children:t.assessedAtHead.slice(0,7)})]}),b!=null&&e.jsxs("a",{href:b,target:"_blank",rel:"noreferrer noopener",className:"ml-auto inline-flex items-center gap-1 text-xs text-blue-600 hover:underline dark:text-blue-400",children:["GitHub",e.jsx(De,{size:11})]})]}),e.jsxs("div",{className:"mt-0.5",children:[a!=null?e.jsx("button",{type:"button",onClick:()=>a(t.threadId),className:"break-all text-left font-mono text-xs text-blue-600 hover:underline dark:text-blue-400",children:j}):e.jsx("span",{className:`break-all font-mono text-xs ${de}`,children:j}),t.commentCount>1&&e.jsxs("span",{className:`ml-2 text-xs ${de}`,children:[t.commentCount," comments"]})]}),t.excerpt!==""&&e.jsxs("div",{className:"mt-1",children:[e.jsx("p",{ref:C,className:`whitespace-pre-wrap break-words text-xs text-gray-700 dark:text-gray-300 ${n?"":"line-clamp-3"}`,children:t.excerpt}),(m||n)&&e.jsx("button",{type:"button",onClick:()=>i(S=>!S),"aria-expanded":n,className:`text-xs ${de} hover:text-gray-700 dark:hover:text-gray-200`,children:n?"Less":"More"})]}),t.explanation!=null&&t.explanation!==""?e.jsxs("p",{className:"mt-1 whitespace-pre-wrap break-words text-xs text-gray-700 dark:text-gray-300",children:[e.jsx("span",{className:"font-medium",children:"Claude: "}),t.explanation]}):f?null:e.jsx("p",{className:`mt-1 text-xs ${de}`,children:Rs(t)}),t.draftReply!=null&&t.draftReply!==""&&e.jsxs("div",{className:"mt-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("button",{type:"button",onClick:()=>d(S=>!S),"aria-expanded":l,"aria-controls":r,className:`inline-flex items-center gap-1 text-xs ${de} hover:text-gray-700 dark:hover:text-gray-200`,children:[e.jsx(ie,{dir:l?"down":"right",size:11}),"Suggested reply"]}),e.jsx(Ss,{text:t.draftReply,what:"suggested reply"})]}),l&&e.jsx("p",{id:r,className:"mt-0.5 whitespace-pre-wrap break-words rounded bg-gray-500/5 px-2 py-1 text-xs text-gray-700 dark:text-gray-300",children:t.draftReply})]})]})}function Hr({items:t,counts:s,onOpenThread:a}){const[n,i]=u.useState(!1),l=u.useMemo(()=>fs(t??[]),[t]);if(t==null)return null;const d=ks(s??js(t));return e.jsx(ne,{title:"Review threads",pills:d.map(r=>e.jsx("span",{className:`${Se} ${r.cls}`,children:r.label},r.key)),info:e.jsxs(he,{title:"Review threads",children:[e.jsx("p",{children:"Open comments from people and other review bots. Claude checks each one against the code: is it right, and has it been dealt with."}),e.jsx("p",{className:"mt-2",children:"“Generate fix from this review” includes the ones still to fix."})]}),children:t.length===0?e.jsx("p",{className:`text-xs ${de}`,children:"No other review threads."}):e.jsxs(e.Fragment,{children:[l.shown.length>0&&e.jsx("ul",{className:"space-y-1.5",children:l.shown.map(r=>e.jsx(vt,{t:r,muted:!1,onOpenThread:a},r.threadId))}),l.more.length>0&&e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>i(r=>!r),"aria-expanded":n,className:`inline-flex items-center gap-1 text-xs ${de} hover:text-gray-700 dark:hover:text-gray-200`,children:[e.jsx(ie,{dir:n?"down":"right",size:11}),n?"Show fewer":`Show ${l.more.length} more`]}),n&&e.jsx("ul",{className:"mt-1.5 space-y-1.5",children:l.more.map(r=>e.jsx(vt,{t:r,muted:!0,onOpenThread:a},r.threadId))})]})]})})}const Ft="bg-red-500/10 text-red-700 dark:text-red-400",wt="bg-orange-500/10 text-orange-700 dark:text-orange-400",Mr="bg-green-500/10 text-green-700 dark:text-green-400",He="bg-gray-500/10 text-gray-600 dark:text-gray-300",Dr={code:"Code",test:"Test",flaky_or_infra:"Flaky or infra",config:"Config",unclear:"Unclear"},Ct={code:Ft,test:wt,config:wt,flaky_or_infra:He,unclear:He};function Pt(t){var n;const s=t.ciFailures;if(s==null)return"hidden";if(s.length>0)return"list";const a=(n=t.ciState)==null?void 0:n.state;return a==="passing"?"passing":a==="pending"?"pending":"hidden"}const Br=t=>t.status==="diagnosed"&&t.fixableInPr===!0;function Ur(t){const s=a=>Br(a)?0:a.status==="diagnosed"?1:2;return t.map((a,n)=>({f:a,i:n})).sort((a,n)=>s(a.f)-s(n.f)||a.i-n.i).map(a=>a.f)}function Or(t){let s=0,a=0,n=0;for(const l of t)l.status!=="diagnosed"?n+=1:l.fixableInPr===!0?s+=1:a+=1;return[{key:"fixable",label:`${s} fixable here`,cls:Ft,n:s},{key:"notFixable",label:`${a} not from this change`,cls:He,n:a},{key:"notChecked",label:`${n} not checked`,cls:He,n}].filter(l=>l.n>0).map(({key:l,label:d,cls:r})=>({key:l,label:d,cls:r}))}const Gr=Mr;function zr(t){switch(t){case"no_log":return"No log available: this check does not run on GitHub Actions.";case"log_unavailable":return"Its log couldn't be read.";case"over_cap":return"Not sent to Claude: too many failing checks.";case"not_reported":return"Claude didn't report on this one.";default:return"Not checked."}}function Kr(t){return`${t} failing ${t===1?"check":"checks"}`}const Xe="inline-flex shrink-0 items-center rounded px-1.5 py-0.5 text-[11px] font-medium",ce="text-gray-500 dark:text-gray-400";function Vr({path:t,line:s,changedPaths:a,onOpenInChanges:n}){const i=st(t,s);return n!=null&&a.has(t)?e.jsx("button",{type:"button",onClick:()=>n(t,s,"RIGHT"),className:"break-all text-left font-mono text-xs text-blue-600 hover:underline dark:text-blue-400",children:i}):e.jsx("span",{className:`break-all font-mono text-xs ${ce}`,children:i})}function Wr({f:t,changedPaths:s,onOpenInChanges:a}){const[n,i]=u.useState(!1),l=u.useId(),d=Me(t.url),r=t.status==="diagnosed",h=r&&t.fixableInPr===!0;return e.jsxs("li",{className:`rounded border px-3 py-2 text-sm ${h?"border-amber-300 dark:border-amber-700/60":"border-gray-200 dark:border-gray-800"}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r&&t.category!=null?e.jsx("span",{className:`${Xe} ${Ct[t.category]}`,children:Dr[t.category]}):e.jsx("span",{className:`${Xe} ${Ct.unclear}`,children:"Not checked"}),e.jsx("span",{className:"break-all font-medium",children:t.checkName}),t.step!=null&&e.jsxs("span",{className:`break-all text-xs ${ce}`,children:["Step: ",t.step]}),r&&t.fixableInPr===!1&&e.jsx("span",{className:`text-xs ${ce}`,children:"Not from this change"}),t.carried&&e.jsxs("span",{className:`text-xs ${ce}`,children:["Unchanged since ",e.jsx("span",{className:"font-mono",children:t.assessedAtHead.slice(0,7)})]}),d!=null&&e.jsxs("a",{href:d,target:"_blank",rel:"noreferrer noopener",className:"ml-auto inline-flex items-center gap-1 text-xs text-blue-600 hover:underline dark:text-blue-400",children:["Details",e.jsx(De,{size:11})]})]}),r?e.jsxs(e.Fragment,{children:[t.cause!=null&&e.jsxs("p",{className:"mt-1 whitespace-pre-wrap break-words text-xs text-gray-700 dark:text-gray-300",children:[e.jsx("span",{className:"font-medium",children:"Claude: "}),t.cause]}),t.explanation!=null&&t.explanation!==""&&e.jsxs("div",{className:"mt-0.5",children:[e.jsxs("button",{type:"button",onClick:()=>i(b=>!b),"aria-expanded":n,"aria-controls":l,className:`inline-flex items-center gap-1 text-xs ${ce} hover:text-gray-700 dark:hover:text-gray-200`,children:[e.jsx(ie,{dir:n?"down":"right",size:11}),"Why"]}),n&&e.jsx("p",{id:l,className:"mt-0.5 whitespace-pre-wrap break-words text-xs text-gray-700 dark:text-gray-300",children:t.explanation})]}),t.relatedFiles.length>0&&e.jsx("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5",children:t.relatedFiles.map(b=>e.jsx(Vr,{path:b.path,line:b.line,changedPaths:s,onOpenInChanges:a},`${b.path}:${b.line??""}`))})]}):e.jsx("p",{className:`mt-1 text-xs ${ce}`,children:zr(t.notCheckedReason)})]})}function qr({review:t}){const s=Pt(t);return s==="passing"?e.jsxs("span",{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-xs ${Gr}`,children:[e.jsx($e,{size:12}),"CI passing"]}):s==="pending"?e.jsx("span",{className:`text-xs ${ce}`,children:"CI was still running when Claude reviewed."}):null}function Jr({review:t,changedPaths:s,onOpenInChanges:a}){const n=Pt(t),i=u.useMemo(()=>Ur(t.ciFailures??[]),[t.ciFailures]);if(n!=="list")return null;const l=Or(i);return e.jsx(ne,{title:"CI failures",pills:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`text-xs ${ce}`,children:Kr(i.length)}),l.map(d=>e.jsx("span",{className:`${Xe} ${d.cls}`,children:d.label},d.key))]}),info:e.jsxs(he,{title:"CI failures",children:[e.jsx("p",{children:"Checks that failed on the reviewed commit. Claude reads the end of each GitHub Actions log and the code, and says why it failed."}),e.jsx("p",{className:"mt-2",children:"Checks outside GitHub Actions have no log to read, so they are listed only."})]}),children:e.jsx("ul",{className:"space-y-1.5",children:i.map(d=>e.jsx(Wr,{f:d,changedPaths:s,onOpenInChanges:a},`${d.checkName}:${d.jobId??""}`))})})}const Lt=t=>t?t.slice(0,7):"—",Ht={skip:"Skipped",diff_only:"Quick",worktree:"Deep"},Ze={COMMENT:"Comment",REQUEST_CHANGES:"Request changes",APPROVE:"Approve"};function Qr({verdict:t}){return e.jsx("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-xs font-medium ${ar[t]}`,children:Ze[t]})}function Yr(t){const s=Qe[t.model]??t.model,a=[Lt(t.headSha),s];return t.costUsd!=null&&a.push(Tt(t.costUsd)),a.join(" · ")}function Mt(t,s){var a,n;return Ws({reviewedHeadSha:t.headSha,currentHeadSha:((a=t.head)==null?void 0:a.currentHeadSha)??s,commitsSince:((n=t.head)==null?void 0:n.commitsSince)??null})}function Xr({currency:t}){return e.jsxs("span",{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-xs font-medium ${t.className}`,title:t.title,children:[t.tone==="current"?e.jsx($e,{size:12}):e.jsx(rr,{size:12}),t.label,t.tone==="current"&&e.jsxs("span",{className:"font-mono",children:["· ",t.sha]})]})}const Zr={cloning:"Cloning the worktree",fetching_diff:"Fetching the diff",deciding:"Deciding scope",reviewing:"Reviewing",persisting:"Saving findings"};function ea(t){var a,n,i;if(t==null)return null;if(t.status==="queued")return 5;const s=(a=t.progress)==null?void 0:a.phase;if(s==null)return 8;switch(s){case"fetching_diff":return 15;case"deciding":return 28;case"cloning":return 42;case"reviewing":{const l=((i=(n=t.progress)==null?void 0:n.recentActivity)==null?void 0:i.length)??0;return Math.min(90,55+l*3)}case"persisting":return 95;default:return null}}function Le(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function ta({review:t}){const{inputTokens:s,outputTokens:a,cacheReadTokens:n,cacheCreationTokens:i}=t;if((s??0)+(a??0)+(n??0)+(i??0)<=0)return null;const d=[];return a!=null&&d.push({key:"out",icon:e.jsx(Ie,{dir:"down",size:11}),label:"out",value:a,title:"Output tokens generated (billed at the output rate — the priciest per token)"}),s!=null&&d.push({key:"in",icon:e.jsx(Ie,{dir:"up",size:11}),label:"in",value:s,title:"New (uncached) input tokens"}),n!=null&&d.push({key:"cr",icon:e.jsx(tt,{size:11}),label:"cache read",value:n,title:"Cached input tokens re-read each turn — billed at ~10% of the input rate, but the volume driver of a multi-turn run"}),i!=null&&d.push({key:"cw",icon:e.jsx(cr,{size:11}),label:"cache write",value:i,title:"Tokens written to the prompt cache (billed at ~1.25× the input rate)"}),e.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-0.5 font-mono text-xs text-gray-500 dark:text-gray-400",children:d.map(r=>e.jsxs("span",{title:r.title,className:"inline-flex items-center gap-1",children:[r.icon,e.jsxs("span",{children:[r.label," ",Le(r.value)]})]},r.key))})}function sa({lines:t}){const s=u.useRef(null);return u.useEffect(()=>{const a=s.current;a!=null&&(a.scrollTop=a.scrollHeight)},[t]),t.length===0?null:e.jsx("div",{ref:s,className:"mt-2 max-h-32 overflow-y-auto rounded border border-gray-100 bg-gray-50 px-2 py-1.5 font-mono text-[11px] leading-snug text-gray-500 dark:border-gray-800 dark:bg-gray-900/60 dark:text-gray-400",children:t.map((a,n)=>e.jsx("div",{className:"whitespace-pre-wrap break-words",children:a===""?" ":a},n))})}function qe(t,s=!1){return t.startsWith("@@")?"font-medium text-gray-600 dark:text-gray-300":t.startsWith("+")?s?"":"text-green-700 dark:text-green-400":t.startsWith("-")?s?"":"text-red-700 dark:text-red-400":"text-gray-500 dark:text-gray-400"}const Fe="whitespace-nowrap rounded border border-blue-400 px-2 py-0.5 text-xs text-blue-600 hover:bg-blue-50 disabled:opacity-50 dark:border-blue-600 dark:text-blue-400 dark:hover:bg-blue-900/30",je="whitespace-nowrap rounded border border-gray-300 px-2 py-0.5 text-xs hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500";function ra({hunk:t,path:s}){var C;const[a,n]=u.useState(!1),i=lr(t,s),l=t.replace(/\n$/,"").split(`
|
|
2
|
+
`),d=l.findIndex(m=>m.startsWith("@@")),r=d>=0?d:l.length-1,h=l[r]??"",b=(i==null?void 0:i[r])??null,j=((C=l[0])==null?void 0:C.startsWith("@@"))===!0;return a?e.jsxs("div",{className:"mt-1 rounded bg-gray-50 dark:bg-gray-900/60",children:[e.jsx("pre",{className:"overflow-x-auto px-2 py-1.5 font-mono text-xs leading-snug",children:l.map((m,N)=>N===0&&j?e.jsx("button",{type:"button",onClick:()=>{var f;((f=window.getSelection())==null?void 0:f.isCollapsed)!==!1&&n(!1)},"aria-expanded":!0,"aria-label":"Hide code",title:"Hide code",className:`block w-full whitespace-pre text-left hover:bg-gray-200/70 dark:hover:bg-gray-800/70 ${qe(m)}`,children:m===""?" ":m},N):e.jsx("div",{className:qe(m,(i==null?void 0:i[N])!=null),children:(i==null?void 0:i[N])!=null?e.jsxs(e.Fragment,{children:[ft(m),e.jsx("span",{className:"code-hl",dangerouslySetInnerHTML:{__html:i[N]}})]}):m===""?" ":m},N))}),e.jsxs("button",{type:"button",onClick:()=>n(!1),"aria-expanded":!0,className:"inline-flex items-center gap-1 px-2 pb-1.5 text-[11px] text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:[e.jsx(ie,{dir:"up",size:11}),"Hide code"]})]}):e.jsxs("button",{type:"button",onClick:()=>n(!0),"aria-expanded":!1,title:"Show the code hunk",className:"mt-1 flex w-full items-center gap-2 overflow-hidden rounded bg-gray-50 px-2 py-1.5 text-left font-mono text-xs dark:bg-gray-900/60",children:[e.jsx(ie,{dir:"right",className:"shrink-0 text-gray-400"}),e.jsx("span",{className:`min-w-0 flex-1 truncate ${qe(h,b!=null)}`,children:b!=null?e.jsxs(e.Fragment,{children:[ft(h),e.jsx("span",{className:"code-hl",dangerouslySetInnerHTML:{__html:b}})]}):h===""?" ":h}),l.length>1&&e.jsxs("span",{className:"shrink-0 font-sans text-[11px] text-gray-500 dark:text-gray-400",children:[l.length," lines"]})]})}function aa({suggestion:t,path:s}){const a=u.useMemo(()=>s==null||s===""?null:ir(t,or(s)),[t,s]);return e.jsx("pre",{className:"mt-1 overflow-x-auto rounded bg-gray-100 px-2 py-1.5 font-mono text-xs dark:bg-gray-800",children:a!=null?e.jsx("code",{className:"code-hl",dangerouslySetInnerHTML:{__html:a}}):e.jsx("code",{children:t})})}function na({prId:t,finding:s,editable:a,prUrl:n,repoFullName:i,headSha:l,posting:d,postError:r,inChangeset:h,priorStatus:b,alreadyPosted:j=!1,storyLabel:C=null,onOpenInChanges:m,onToggle:N,onReword:f,onPostComment:S}){const[L,_]=u.useState(!1),v=u.useRef(null);u.useEffect(()=>()=>{v.current!=null&&clearTimeout(v.current)},[]);const[A,U]=u.useState(!1),[O,E]=u.useState(s.editedBody??"");u.useEffect(()=>{A||E(s.editedBody??"")},[s.editedBody,A]);const D=s.editedBody!=null&&s.editedBody.trim()!=="",H=A&&O.trim()!==""&&O!==(s.editedBody??"")?O:null,q=s.line!=null?`${s.path}:${s.line}`:s.path,p=s.path==="",I=s.postedAt!=null,w=s.githubCommentId!=null?s.postedCommentKind==="pr_comment"?`${n}#issuecomment-${s.githubCommentId}`:`${n}#discussion_r${s.githubCommentId}`:null,X=s.line!=null?`${n}/files#diff-${s.diffAnchorId}${s.side==="LEFT"?"L":"R"}${s.line}`:`${n}/files#diff-${s.diffAnchorId}`,P=l!=null&&s.line!=null&&s.side==="RIGHT"?`https://github.com/${i}/blob/${l}/${s.path.split("/").map(encodeURIComponent).join("/")}#L${s.line}`:null,Z=h&&m!=null,we=w??X,G=w==null?P:null,V=a&&!I,ee=()=>{let Y=s.body.trim()!==""?`**${s.title}**
|
|
3
|
+
|
|
4
|
+
${s.body}`:`**${s.title}**`;s.suggestion!=null&&s.suggestion.trim()!==""&&(Y+=`
|
|
5
|
+
|
|
6
|
+
\`\`\`suggestion
|
|
7
|
+
${s.suggestion}
|
|
8
|
+
\`\`\``),dr(Y).then(ge=>{ge&&(_(!0),v.current!=null&&clearTimeout(v.current),v.current=setTimeout(()=>_(!1),1500))})},le=()=>{f(O).catch(()=>{}),U(!1)},oe=()=>{f("").catch(()=>{}),E(""),U(!1)},[ue,B]=u.useState(!1),J=async()=>{B(!0);try{H!=null&&(await f(H),U(!1)),await S()}catch{}finally{B(!1)}},me=d||ue,Ce=!s.anchored&&!s.fileInDiff,pe=a&&!I,te=pe&&!s.included,[z,se]=u.useState(!1),R=te&&!z;return e.jsxs("li",{id:`claude-finding-${s.id}`,className:`rounded border border-gray-100 px-3 py-2 text-sm dark:border-gray-800 ${te?"opacity-50":""}`,children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`mt-0.5 inline-flex shrink-0 items-center rounded px-1.5 py-0.5 text-[11px] font-semibold capitalize ${It[s.severity]}`,children:s.severity}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-semibold",children:s.title}),s.lens!=null&&e.jsx("span",{className:"rounded bg-gray-500/10 px-1.5 py-0.5 text-[11px] text-gray-600 dark:text-gray-300",children:nr[s.lens]}),C!=null&&e.jsx("span",{className:"rounded bg-sky-500/10 px-1.5 py-0.5 text-[11px] text-sky-700 dark:text-sky-300",children:C}),b!=null&&e.jsx("span",{className:`rounded px-1.5 py-0.5 text-[11px] font-medium ${bt[b].cls}`,title:"Raised in the previous review",children:bt[b].label}),j&&e.jsx("span",{className:`rounded px-1.5 py-0.5 text-[11px] font-medium ${Ke.cls}`,title:Ke.title,children:Ke.label}),I&&(w!=null?e.jsxs("a",{href:Me(w),target:"_blank",rel:"noreferrer noopener",className:"inline-flex items-center gap-1 rounded bg-green-500/10 px-1.5 py-0.5 text-[11px] text-green-700 hover:underline dark:text-green-400",title:"View this comment on GitHub",children:["Posted",e.jsx($e,{size:11})]}):e.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-green-500/10 px-1.5 py-0.5 text-[11px] text-green-700 dark:text-green-400",children:["Posted",e.jsx($e,{size:11})]})),D&&!I&&e.jsx("span",{className:"rounded bg-blue-500/10 px-1.5 py-0.5 text-[11px] text-blue-600 dark:text-blue-400",children:"Your wording"}),!s.anchored&&!I&&(p?e.jsx("span",{className:"rounded bg-gray-500/10 px-1.5 py-0.5 text-[11px] text-gray-600 dark:text-gray-300",title:"Posts as a PR comment",children:"PR comment"}):s.fileInDiff?e.jsx("span",{className:"rounded bg-gray-500/10 px-1.5 py-0.5 text-[11px] text-gray-600 dark:text-gray-300",title:"Posts on the file's first change",children:"Line not in diff"}):e.jsx("span",{className:"rounded bg-amber-500/10 px-1.5 py-0.5 text-[11px] text-amber-700 dark:text-amber-400",title:"Posts as a PR comment",children:"File not in diff"})),te&&e.jsx("span",{className:"rounded bg-gray-500/10 px-1.5 py-0.5 text-[11px] text-gray-600 dark:text-gray-300",children:"Ignored"})]}),!R&&e.jsxs(e.Fragment,{children:[!p&&e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-2 font-mono text-xs",children:[Z?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>m(s.path,s.line,s.side),className:"text-left text-blue-600 hover:underline dark:text-blue-400",title:s.line!=null?"Show this line in the Changes tab":"Show this file in the Changes tab",children:q}),e.jsx("a",{href:X,target:"_blank",rel:"noreferrer noopener","aria-label":s.line!=null?`Open ${s.path} line ${s.line} in the PR diff on GitHub`:`Open ${s.path} in the PR diff on GitHub`,title:"Open this line in the PR diff on GitHub",className:"shrink-0 text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:e.jsx(De,{size:11})})]}):e.jsx("a",{href:we,target:"_blank",rel:"noreferrer noopener",className:"text-blue-600 hover:underline dark:text-blue-400",title:w!=null?"Open this posted comment on GitHub":s.line!=null?"Open this line in the PR diff on GitHub":"Open this file in the PR diff on GitHub",children:q}),G!=null&&e.jsx("a",{href:G,target:"_blank",rel:"noreferrer noopener",className:"font-sans text-[11px] text-gray-500 hover:text-gray-700 hover:underline dark:text-gray-400 dark:hover:text-gray-200",title:"Open the file at the reviewed commit",children:"view file"})]}),s.diffHunk!=null&&s.diffHunk!==""&&e.jsx(ra,{hunk:s.diffHunk,path:s.path}),s.body.trim()!==""&&e.jsx("div",{className:"mt-1",children:e.jsx(ve,{children:s.body})}),s.suggestion!=null&&s.suggestion!==""&&e.jsx(aa,{suggestion:s.suggestion,path:s.path}),D&&!A&&e.jsxs("div",{className:"mt-1.5 rounded border border-blue-200 bg-blue-50/50 px-2 py-1 dark:border-blue-900/50 dark:bg-blue-900/10",children:[e.jsx("div",{className:"text-[11px] font-medium text-blue-700 dark:text-blue-400",children:"Your wording"}),e.jsx(ve,{children:s.editedBody})]}),a&&!I&&A&&e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsx(At,{prId:t,value:O,onChange:E,rows:4,placeholder:"Your wording (markdown)",className:"w-full rounded border border-gray-300 bg-white px-2 py-1.5 font-mono text-xs dark:border-gray-700 dark:bg-gray-900"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:le,className:Fe,children:"Save"}),e.jsx("button",{type:"button",onClick:()=>{U(!1),E(s.editedBody??"")},className:je,children:"Cancel"}),D&&e.jsx("button",{type:"button",onClick:oe,className:`${je} text-gray-500 dark:text-gray-400`,children:"Use Claude's text"})]})]})]})]})]}),e.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-2 border-t border-gray-100 pt-2 dark:border-gray-800",children:te?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>se(Y=>!Y),className:je,children:z?"Collapse":"Show"}),e.jsx("button",{type:"button",onClick:()=>N(!0),title:"Re-include this finding in the review",className:Fe,children:"Un-ignore"}),z&&e.jsx("button",{type:"button",onClick:ee,className:je,children:L?"Copied":"Copy"})]}):e.jsxs(e.Fragment,{children:[V&&e.jsx("button",{type:"button",onClick:J,disabled:me,className:Fe,children:me?"Posting…":Ce?"Post as PR comment":"Post as comment"}),a&&!I&&!A&&e.jsx("button",{type:"button",onClick:()=>{E(s.editedBody??""),U(!0)},className:Fe,children:D?"Edit wording":"Reword"}),e.jsx("button",{type:"button",onClick:ee,className:je,children:L?"Copied":"Copy"}),pe&&e.jsx("button",{type:"button",onClick:()=>N(!1),title:"Set aside — exclude this finding from the submitted review",className:je,children:"Ignore"}),r!=null&&e.jsx("span",{className:"ml-auto text-xs text-red-500",children:r})]})})]})}function la({review:t,editable:s,prUrl:a,repoFullName:n,prHeadSha:i,postingFindingId:l,postErrorFindingId:d,postErrorMessage:r,changedPaths:h,onOpenInChanges:b,onOpenThread:j,onToggleFinding:C,onRewordFinding:m,onPostFinding:N}){const f=u.useMemo(()=>Qs(t.findings,t.tickets),[t.findings,t.tickets]),S=Ys(t.findings.filter(p=>!f.placed.has(p.id))),L=Xs(t),_=Zs(t),v=er(t.followUp),A=t.headSha??i,U=t.status==="succeeded"&&t.reviewMode!=="skip"?t.id:null,O=Mt(t,i),E=t.tickets??[],D=f.ids,H=(p,I)=>e.jsx(na,{prId:t.prId,finding:p,editable:s,prUrl:a,repoFullName:n,headSha:A,posting:l===p.id,postError:d===p.id?r:null,inChangeset:h.size>0?h.has(p.path):p.fileInDiff,priorStatus:L.get(p.id),alreadyPosted:_.has(p.id),storyLabel:I,onOpenInChanges:b,onToggle:w=>C(p.id,w),onReword:w=>m(p.id,w),onPostComment:()=>N(p.id)},p.id),q=(p,I,w)=>`${p} ${p===1?I:w}`;return e.jsxs(e.Fragment,{children:[e.jsxs(ne,{title:"Claude's review",pills:e.jsxs(e.Fragment,{children:[O!=null&&e.jsx(Xr,{currency:O}),t.verdict!=null&&e.jsx(Qr,{verdict:t.verdict}),t.trigger==="auto"&&e.jsx("span",{className:"rounded bg-gray-500/10 px-1.5 py-0.5 text-xs text-gray-600 dark:text-gray-300",children:Ye}),t.reviewMode!=null&&e.jsxs("span",{className:"rounded bg-gray-500/10 px-1.5 py-0.5 text-xs text-gray-600 dark:text-gray-300",children:[Ht[t.reviewMode]," review"]}),e.jsx(qr,{review:t})]}),info:e.jsx(he,{title:"This run",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(ta,{review:t}),t.numTurns!=null&&e.jsxs("p",{children:[t.numTurns," turns."]}),t.diffCapped&&e.jsx("p",{children:"The diff was too large to send whole, so it was cut to fit."}),t.excludedFiles.length>0&&e.jsxs("p",{children:["Left out as noise: ",t.excludedFiles.length," file",t.excludedFiles.length===1?"":"s"," (lockfiles, generated code)."]})]})}),children:[e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:Yr(t)}),v!=null&&e.jsx("div",{className:"font-medium",children:v}),t.summary!=null&&t.summary!==""&&e.jsx(ve,{children:t.summary})]}),e.jsx(Jr,{review:t,changedPaths:h,onOpenInChanges:b}),t.followUp!=null&&e.jsx(Lr,{followUp:t.followUp,findings:t.findings,changedPaths:h,onOpenInChanges:b}),e.jsx(Hr,{items:t.threadAssessments,counts:t.threadAssessmentCounts,onOpenThread:j}),E.length>0&&e.jsx(ne,{title:E.length===1?"User story":"User stories",pills:f.placed.size>0?e.jsx(kt,{children:q(f.placed.size,"finding","findings")}):null,info:e.jsxs(he,{title:"User stories",children:[e.jsx("p",{children:"Each criterion that is not met or only partly met, and each thing asked for but not done, is a finding. Post, reword or ignore it here, like any other finding."}),e.jsx("p",{className:"mt-2",children:"Met criteria and changes nobody asked for are listed for reference."})]}),children:e.jsx("div",{className:"divide-y divide-gray-200 dark:divide-gray-800",children:E.map(p=>e.jsx("div",{className:"py-4 first:pt-0 last:pb-0",children:e.jsx(Pr,{entry:p,label:E.length===1&&p.ticket.key==null?null:Cr(p.ticket,p.index),findingIds:D,findingsById:f.byId,renderFinding:H,changedPaths:h,onOpenInChanges:b})},p.index))})}),e.jsx(ne,{title:"Findings",pills:e.jsxs(e.Fragment,{children:[e.jsx(kt,{children:q(S.length,"finding","findings")}),f.placed.size>0&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[f.placed.size," more under ",E.length===1?"User story":"User stories"]})]}),children:S.length>0?e.jsx("ul",{className:"space-y-2",children:S.map(p=>H(p,p.story!=null?tr(p.story,t.tickets):null))}):e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:f.placed.size>0?"None outside the user stories.":"No line-level findings."})}),U!=null&&e.jsx(br,{reviewId:U})]})}function ia({prId:t,review:s}){const a=Et().enabled,n=sr(i=>i.openAiFixFromReview);return!a||(s==null?void 0:s.status)!=="succeeded"?null:e.jsx(ne,{title:"Generate a fix",info:e.jsx(he,{title:"Generate a fix",children:e.jsx("p",{children:"Opens AI Fix with this review picked. Claude edits the code to address the findings and threads still to fix. Nothing is pushed until you press the button there."})}),actions:e.jsxs("button",{type:"button",onClick:()=>n(t,s.id),className:"inline-flex items-center gap-1 whitespace-nowrap rounded border border-ai-border px-2.5 py-1 text-xs text-ai-signal hover:border-ai-signal/60 hover:bg-ai-surface-2",children:["Generate fix from this review",e.jsx(Ie,{dir:"right",size:11})]})})}const Je=Vs();function ha({pr:t,usersById:s,onOpenInChanges:a,onOpenThread:n}){var F,W,Q,re,K,be,at,nt,lt,it,ot;const i=Et(),{data:l,isLoading:d}=$s(t.id),r=(l==null?void 0:l.review)??null,h=et(),b=u.useMemo(()=>{const g=new Set;for(const Re of t.files)g.add(Re.path);const ae=h.getQueryData(["pr-files",t.id]);for(const Re of(ae==null?void 0:ae.files)??[])g.add(Re.path),Re.previousPath&&g.add(Re.previousPath);return g},[t.files,t.id,h]),[j,C]=u.useState(Is),[m,N]=u.useState(()=>pt(Je.get(t.id),r)),f=u.useRef(null);u.useEffect(()=>{const g=`${t.id}:${(r==null?void 0:r.id)??"none"}`;f.current!==g&&(f.current=g,N(pt(Je.get(t.id),r)))},[t.id,r]);const S=g=>{Je.set(t.id,g),N(g)},L=u.useMemo(()=>Es(m),[m]),{data:_}=Ts(),v=((F=_==null?void 0:_.find(g=>g.repoIds.includes(t.repoId)))==null?void 0:F.name)??null,A=L.ok?void 0:`Fix the user story first: ${L.message}`,[U,O]=u.useState(!1),[E,D]=u.useState(""),[H,q]=u.useState("COMMENT"),[p,I]=u.useState(null),[w,X]=u.useState(null),[P,Z]=u.useState(null),[we,G]=u.useState(!1),V=As(t.id),ee=_s(t.id),le=Fs(t.id),oe=Ps(t.id),ue=Ls(t.id),B=Hs(t.id),J=Ms(t.id),me=J.isPending?((W=J.variables)==null?void 0:W.findingId)??null:null,Ce=J.isError?((Q=J.variables)==null?void 0:Q.findingId)??null:null,pe=J.isError?((re=J.error)==null?void 0:re.message)??"Failed to post comment":null,te=u.useRef(null);u.useEffect(()=>{if(r==null){te.current=null;return}te.current!==r.id&&(te.current=r.id,D(r.userBody??""),q(r.userVerdict??"COMMENT"),I(r.id),X(null),Z(null),G(!1))},[r]);const z=(r==null?void 0:r.status)==="running"||(r==null?void 0:r.status)==="queued",se=(l==null?void 0:l.autoReview)??(z&&(r==null?void 0:r.trigger)==="auto"?"running":null),{status:R}=Ds(t.id,z),Y=p==null||p===(r==null?void 0:r.id),{data:ge}=Bs(Y?null:p);if(d)return e.jsx("div",{className:"px-4 py-3 text-sm text-gray-400",children:"Loading…"});if(!i.enabled||(l==null?void 0:l.enabled)===!1)return e.jsx("div",{className:"px-4 py-3",children:e.jsx(Us,{})});const Be=(r==null?void 0:r.status)==="succeeded"&&r.headSha===t.headSha,ye=(r==null?void 0:r.status)==="succeeded"?Mt(r,t.headSha):null,Ue=(ye==null?void 0:ye.tone)==="behind"?ye.label:null,T=()=>{L.ok&&(qs(),O(!1),X(null),Z(null),V.mutate({model:j,tickets:Js(L)}))},Oe=()=>{Be?O(!0):T()},o=Y?r:ge??null,c=Y&&r!=null,y=((K=R==null?void 0:R.progress)==null?void 0:K.phase)??null,x=y!=null?Zr[y]??y:"Starting…",k=()=>{r!=null&&(Z(null),B.mutate({reviewId:r.id,userVerdict:H,dryRun:!0},{onSuccess:g=>X(g)}))},M=()=>{r!=null&&(G(!1),B.mutate({reviewId:r.id,userVerdict:H},{onSuccess:g=>Z(g)}))};return e.jsxs("div",{className:"space-y-3 px-4 py-3",children:[e.jsxs(ne,{title:"Run a review",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("select",{value:j,onChange:g=>C(g.target.value),disabled:z||ee,"aria-label":"Model",className:"rounded border border-gray-300 bg-white px-2 py-1 text-sm dark:border-gray-700 dark:bg-gray-900",children:Os.map(g=>e.jsx("option",{value:g,children:Qe[g]},g))}),e.jsx(Rt,{auth:l==null?void 0:l.auth,children:e.jsx("button",{type:"button",onClick:Oe,disabled:z||ee||se!=null||!L.ok,title:A,className:Ue!=null?"rounded border border-blue-400 px-2 py-1 text-sm text-blue-600 hover:bg-blue-50 disabled:opacity-50 dark:border-blue-600 dark:text-blue-400 dark:hover:bg-blue-900/30":"rounded border border-gray-300 px-2 py-1 text-sm hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:r==null?"Run review":"Re-review"})}),se!=null&&e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:se==="running"?"Auto review running":"Auto review queued"}),se==null&&(l==null?void 0:l.autoReviewWaiting)!=null&&e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:Gs[l.autoReviewWaiting]})]}),e.jsx(Tr,{autoPullReady:!d,value:m,onChange:S,check:L,prId:t.id,tickets:t.tickets,prWorkspaceName:v},t.id),U&&e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 rounded border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-800 dark:border-amber-700/60 dark:bg-amber-900/20 dark:text-amber-300",children:[e.jsx("span",{children:"This commit is already reviewed."}),e.jsx("button",{type:"button",onClick:T,disabled:!L.ok||se!=null,title:A,className:"rounded border border-amber-400 px-2 py-0.5 text-xs hover:bg-amber-100 disabled:opacity-50 dark:border-amber-600 dark:hover:bg-amber-900/40",children:"Run anyway"}),e.jsx("button",{type:"button",onClick:()=>O(!1),className:"rounded border border-gray-300 px-2 py-0.5 text-xs hover:border-gray-400 dark:border-gray-700 dark:hover:border-gray-500",children:"Cancel"})]}),Y&>(l==null?void 0:l.autoFix)!=null&&e.jsx("div",{className:"mt-2 text-xs text-gray-600 dark:text-gray-400",children:gt(l==null?void 0:l.autoFix)}),V.isError&&!zs(V.error)&&e.jsx("div",{className:"mt-2 text-xs text-red-600 dark:text-red-400",children:((be=V.error)==null?void 0:be.message)??"Failed to start review."})]}),e.jsx("div",{className:"empty:hidden",children:e.jsx(Ks,{active:z,label:"Running Claude review",value:ea(R),timeConstantSec:30})}),z&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[e.jsx("span",{className:"inline-block h-3 w-3 animate-spin rounded-full border-2 border-gray-300 border-t-blue-500"}),e.jsxs("span",{children:[x,"…"]}),(r==null?void 0:r.trigger)==="auto"&&e.jsx("span",{className:"rounded bg-gray-500/10 px-1.5 py-0.5 text-xs text-gray-500 dark:text-gray-400",children:Ye}),((at=R==null?void 0:R.progress)==null?void 0:at.reviewMode)!=null&&e.jsxs("span",{className:"rounded bg-blue-500/10 px-1.5 py-0.5 text-xs font-medium text-blue-700 dark:text-blue-400",title:"The review depth chosen for this run",children:[Ht[R.progress.reviewMode]," review"]}),((nt=R==null?void 0:R.progress)==null?void 0:nt.message)!=null&&e.jsx("span",{className:"text-xs text-gray-400",children:R.progress.message}),e.jsx("button",{type:"button",onClick:()=>le.mutate(),disabled:le.isPending,className:"ml-auto rounded border border-gray-300 px-2 py-0.5 text-xs hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:le.isPending?"Stopping…":"Stop"})]}),((lt=R==null?void 0:R.progress)==null?void 0:lt.usage)&&e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5 font-mono text-xs text-gray-500 dark:text-gray-400",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",title:"Output tokens generated so far",children:[e.jsx(Ie,{dir:"down",size:11}),Le(R.progress.usage.outputTokens)," out"]}),e.jsxs("span",{className:"inline-flex items-center gap-1",title:"New (uncached) input tokens billed so far",children:[e.jsx(Ie,{dir:"up",size:11}),Le(R.progress.usage.inputTokens)," in"]}),e.jsxs("span",{className:"inline-flex items-center gap-1",title:"Cached input tokens read so far (billed at ~10% of input)",children:[e.jsx(tt,{size:11}),Le(R.progress.usage.cacheReadTokens)," cache"]}),e.jsxs("span",{className:"font-semibold text-gray-600 dark:text-gray-300",title:"Estimated cost so far, on your own Claude Code or Anthropic API key. Limn charges nothing. The figure recorded when the run finishes is authoritative.",children:["~",Tt(R.progress.usage.estCostUsd)]})]}),e.jsx(sa,{lines:((it=R==null?void 0:R.progress)==null?void 0:it.recentActivity)??[]})]}),!z&&(r==null?void 0:r.status)==="failed"&&e.jsx("div",{children:e.jsx("div",{className:"rounded border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-700/60 dark:bg-red-900/20 dark:text-red-400",children:r.error??"The review failed."})}),!z&&(r==null?void 0:r.status)==="cancelled"&&e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Review cancelled."}),l!=null&&l.history.length>1&&e.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-xs text-gray-500 dark:text-gray-400",children:["Showing",e.jsx("select",{value:p??(r==null?void 0:r.id)??"",onChange:g=>{I(Number(g.target.value)),X(null),Z(null)},className:"rounded border border-gray-300 bg-white px-2 py-1 text-sm text-gray-900 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-100",children:l.history.map(g=>e.jsxs("option",{value:g.id,children:[Lt(g.headSha)," ·"," ",Qe[g.model]??g.model," ·"," ",g.status," ·"," ",yt(g.createdAt),g.trigger==="auto"?` · ${Ye}`:"",g.id===(r==null?void 0:r.id)?" (latest)":""]},g.id))})]})]}),o!=null&&o.status==="succeeded"&&e.jsx(la,{review:o,editable:c,prUrl:t.githubUrl,repoFullName:t.repoFullName,prHeadSha:t.headSha,postingFindingId:me,postErrorFindingId:Ce,postErrorMessage:pe,changedPaths:b,onOpenInChanges:a,onOpenThread:n,onToggleFinding:(g,ae)=>ue.mutate({findingId:g,included:ae}),onRewordFinding:(g,ae)=>ue.mutateAsync({findingId:g,editedBody:ae}),onPostFinding:g=>J.mutateAsync({findingId:g})}),c&&r!=null&&r.status==="succeeded"&&r.reviewMode!=="skip"&&e.jsxs(ne,{title:"Post to GitHub",pills:r.postedAt!=null?e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Posted ",yt(r.postedAt)]}):null,info:e.jsx(he,{title:"Post to GitHub",children:e.jsx("p",{children:"Posts one review: your summary as its top-level comment, with your verdict. Every finding above that you have not ignored or already posted goes with it, story findings included."})}),children:[e.jsx("div",{className:"text-xs font-medium text-gray-700 dark:text-gray-300",children:"Summary"}),e.jsx(At,{prId:t.id,value:E,onChange:D,onBlur:()=>oe.mutate({reviewId:r.id,userBody:E}),rows:6,placeholder:"Summary (markdown, @ to mention). Optional.",className:"w-full rounded border border-gray-300 bg-white px-2 py-1.5 font-mono text-sm dark:border-gray-700 dark:bg-gray-900"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>oe.mutate({reviewId:r.id,userBody:E}),disabled:oe.isPending,title:"Saves the draft. Nothing is posted yet.",className:"rounded border border-gray-300 px-2 py-0.5 text-sm hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:"Save draft"}),e.jsxs("select",{"aria-label":"Verdict",value:H,onChange:g=>{const ae=g.target.value;q(ae),oe.mutate({reviewId:r.id,userVerdict:ae})},className:"rounded border border-gray-300 bg-white px-2 py-1 text-sm dark:border-gray-700 dark:bg-gray-900",children:[e.jsx("option",{value:"COMMENT",children:"Comment"}),e.jsx("option",{value:"REQUEST_CHANGES",children:"Request changes"}),e.jsx("option",{value:"APPROVE",children:"Approve"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",onClick:k,disabled:B.isPending,className:"rounded border border-gray-300 px-2 py-0.5 text-sm hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:"Preview"}),we?e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Post as ",e.jsx("strong",{children:Ze[H]}),"?"]}),e.jsx("button",{type:"button",onClick:M,disabled:B.isPending,className:"rounded border border-blue-400 px-2 py-0.5 text-xs text-blue-600 hover:bg-blue-50 disabled:opacity-50 dark:border-blue-600 dark:text-blue-400 dark:hover:bg-blue-900/30",children:"Confirm post"}),e.jsx("button",{type:"button",onClick:()=>G(!1),className:"rounded border border-gray-300 px-2 py-0.5 text-xs hover:border-gray-400 dark:border-gray-700 dark:hover:border-gray-500",children:"Cancel"})]}):e.jsx("button",{type:"button",onClick:()=>G(!0),disabled:B.isPending,className:"rounded border border-blue-400 px-2 py-0.5 text-sm text-blue-600 hover:bg-blue-50 disabled:opacity-50 dark:border-blue-600 dark:text-blue-400 dark:hover:bg-blue-900/30",children:"Post to GitHub"}),B.isPending&&e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Posting…"})]}),w!=null&&e.jsxs("div",{className:"rounded border border-gray-200 bg-gray-50 px-3 py-2 text-sm dark:border-gray-700 dark:bg-gray-800/50",children:[e.jsxs("div",{children:["Will post ",e.jsx("strong",{children:w.comments.length})," inline comment",w.comments.length===1?"":"s"," as"," ",e.jsx("strong",{children:Ze[w.event]}),"."]}),w.prComments.length>0&&e.jsxs("div",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:["Plus ",e.jsx("strong",{children:w.prComments.length})," PR comment",w.prComments.length===1?"":"s",":"," ",w.prComments.map(g=>g.path!==""?g.path:"the whole change").join(", ")]})]}),P!=null&&e.jsxs("div",{className:"rounded border border-green-300 bg-green-50 px-3 py-2 text-sm text-green-700 dark:border-green-700/60 dark:bg-green-900/20 dark:text-green-400",children:[e.jsxs("div",{children:["Posted review #",P.postedReviewId??"?"," ·"," ",P.postedCommentCount," inline comment",P.postedCommentCount===1?"":"s"]}),P.prCommentCount>0&&e.jsxs("div",{className:"mt-1 text-xs",children:["Plus ",P.prCommentCount," PR comment",P.prCommentCount===1?"":"s","."]})]}),B.isError&&e.jsx("div",{className:"text-xs text-red-600 dark:text-red-400",children:((ot=B.error)==null?void 0:ot.message)??"Failed to post review to GitHub."})]}),c&&e.jsx(ia,{prId:t.id,review:r})]})}export{ha as ClaudeReviewTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as g,j as s}from"./tanstack-5qsxxaLe.js";import{
|
|
1
|
+
import{r as g,j as s}from"./tanstack-5qsxxaLe.js";import{bc as v,be as w,b0 as j,a5 as k,bj as N,aF as y,X as f,K as b,s as T,ac as p,ag as C}from"./index-SG17YBlJ.js";import"./markdown-I_JLLVAZ.js";import"./highlight-CIIZLa6Z.js";import"./vis-C3BCkP5U.js";function h(e){return e==null?"—":C(e)}function $(e){const t=[];for(const r of e){const o=y(r.at),a=t[t.length-1];if(a&&a.label===o){a.to=r.at,a.count+=1,r.kind==="review"?a.reviews+=1:a.comments+=1;continue}t.push({from:r.at,to:r.at,label:o,count:1,reviews:r.kind==="review"?1:0,comments:r.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 u({label:e,value:t,tone:r}){return s.jsxs("div",{children:[s.jsx("div",{className:"text-[11px] font-semibold text-gray-500 dark:text-gray-400",children:e}),s.jsx("div",{className:`text-sm font-semibold ${r==="warn"?"text-red-600 dark:text-red-400":"text-gray-800 dark:text-gray-100"}`,children:t})]})}function B({bot:e,color:t}){const r=k(e.kind),o=e.ttfrAnomaly,a=e.typicalTtfrHours==null,c=e.typicalFollowups!=null&&e.followupCount>=e.typicalFollowups+2,d=$(e.touches),i=d.slice(0,P),l=e.touches.length-i.reduce((n,x)=>n+x.count,0),m=a?"building baseline":o?`slower than typical — usually ${h(e.typicalTtfrHours)}`:`within typical (${h(e.typicalTtfrHours)})`;return s.jsxs("div",{className:"space-y-2 rounded-lg border border-gray-200 p-3 dark:border-gray-800",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-sm font-semibold text-gray-800 dark:text-gray-100",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 px-1.5 py-0.5 text-[11px] font-medium",style:{...N(r.color),background:`${r.color}1a`},children:r.label}),e.firstTouchAt&&s.jsxs("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:["first touch ",y(e.firstTouchAt)]}),o&&s.jsxs("span",{className:"rounded bg-red-500/10 px-1.5 py-0.5 text-[11px] font-semibold text-red-600 dark:text-red-400",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(u,{label:"Time to first review",value:h(e.ttfrHours),tone:o?"warn":"default"}),s.jsx(u,{label:"Follow-ups",value:String(e.followupCount),tone:c?"warn":"default"}),s.jsx(u,{label:"Comments",value:String(e.commentCount)}),s.jsx(u,{label:"Touches",value:String(e.touchCount)})]}),s.jsxs("div",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:[s.jsxs("span",{className:o?"font-medium text-red-600 dark:text-red-400":"",children:[!a&&o&&s.jsx(f,{size:11,className:"mr-1 inline-block align-[-0.1em]"}),m]}),e.ttfrBasis&&!a&&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)":""]}),!a&&s.jsxs("span",{children:[" · baseline: ",e.baselinePrs," PRs"]})]}),d.length>0&&s.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[i.map((n,x)=>s.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-gray-500/10 px-1.5 py-0.5 text-[11px] text-gray-600 dark:text-gray-300",title:`${n.count>1?`${I(n)} · `:""}${n.from===n.to?p(n.from):`${p(n.from)} – ${p(n.to)}`}`,children:[n.reviews>0&&s.jsx(b,{size:11}),n.comments>0&&s.jsx(T,{size:11}),n.count>1&&s.jsxs("span",{className:"font-medium",children:["×",n.count]}),n.label]},x)),l>0&&s.jsxs("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:["+",l," more touches"]})]})]})}function z({pr:e}){const{data:t,isLoading:r,isError:o}=v(e.id,!0),{data:a}=w(),c=g.useMemo(()=>{var l;return((l=(a??[]).find(m=>m.id===e.repoId))==null?void 0:l.workspaceId)??null},[a,e.repoId]),d=j(c),i=(t==null?void 0:t.bots)??[];return s.jsxs("div",{className:"space-y-3 p-4",children:[s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:s.jsxs("span",{className:"text-[12px] text-gray-500 dark:text-gray-400",children:["How each review bot behaved on THIS PR vs its ",s.jsx("span",{className:"font-medium",children:"own"})," ","typical (84-day baseline). Deterministic, no AI. A touch is one review or one comment, so a review submitted with three inline comments counts as four."]})}),r?s.jsx("div",{className:"h-24 animate-pulse rounded-lg border border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900/40"}):o?s.jsx("div",{className:"text-sm text-red-500",children:"Couldn’t load bot behaviour for this PR."}):i.length===0?s.jsx("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-500 dark:border-gray-700 dark:text-gray-400",children:"No automated-reviewer activity on this PR."}):i.map(l=>s.jsx(B,{bot:l,color:d({login:l.login,kind:l.kind})},l.key))]})}export{z as PrBotBehaviourTab};
|