pierre-review 0.1.76 → 0.1.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pierre-review",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.77",
|
|
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,3 +1,3 @@
|
|
|
1
|
-
import{r as o,j as e}from"./tanstack-R-s9abdD.js";import{D as te,w as W,A as re,c as ne,d as ae,q as ie,G as ce,I as J,M as K,i as le,l as oe,k as de,C as ue,b as xe,R as Q,a as he,p as X,F as Z,r as I,E as ge,J as me,n as be,m as pe,y as fe,j as Y}from"./index-
|
|
1
|
+
import{r as o,j as e}from"./tanstack-R-s9abdD.js";import{D as te,w as W,A as re,c as ne,d as ae,q as ie,G as ce,I as J,M as K,i as le,l as oe,k as de,C as ue,b as xe,R as Q,a as he,p as X,F as Z,r as I,E as ge,J as me,n as be,m as pe,y as fe,j as Y}from"./index-CxFDrc36.js";import"./markdown-BUNN1sk6.js";import"./highlight-C8vPehS1.js";import"./vis-C3BCkP5U.js";const S="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",j="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",ye={fetching_diff:"Reading the PR",cloning:"Checking out the code",fixing:"Applying the fix",capturing:"Capturing changes",persisting:"Saving"};function je(s){var t;if(!s||s.status==="idle")return null;if(s.status==="queued")return 6;const r=s.progress;if(!r)return 10;switch(r.phase){case"fetching_diff":return 12;case"cloning":return 28;case"fixing":return Math.min(90,45+(((t=r.recentActivity)==null?void 0:t.length)??0)*3);case"capturing":return 92;case"persisting":return 96;default:return 20}}const ke={cloning:"Checking out the code",applying_fix:"Applying the fix",fetching_trunk:"Fetching the trunk",rebasing:"Rebasing onto the trunk",merging:"Merging the trunk in",resolving_conflicts:"Resolving conflicts with Claude",verifying:"Verifying the result",pushing:"Pushing"};function Ne(s){var t;if(!s||s.status==="idle")return null;if(s.status==="queued")return 6;const r=s.progress;if(!r)return 10;switch(r.phase){case"cloning":return 15;case"applying_fix":return 25;case"fetching_trunk":return 35;case"rebasing":case"merging":return 45;case"resolving_conflicts":return Math.min(90,55+(((t=r.recentActivity)==null?void 0:t.length)??0)*3);case"verifying":return 92;case"pushing":return 96;default:return 20}}function L({children:s}){return e.jsx("div",{className:"px-4 pb-1 pt-3 text-xs font-semibold uppercase tracking-wide text-gray-400",children:s})}const ve={high:"bg-green-100 text-green-700 dark:bg-green-950/40 dark:text-green-300",medium:"bg-amber-100 text-amber-700 dark:bg-amber-950/40 dark:text-amber-300",low:"bg-red-100 text-red-700 dark:bg-red-950/40 dark:text-red-300"};function z({label:s,value:r}){return r?e.jsxs("span",{className:`rounded px-1.5 py-0.5 text-[10px] font-medium uppercase ${ve[r]}`,title:s==="Fixability"?"How confident the analysis is that Pierre's agent could fix this":"How confident the analysis is about the root cause",children:[s,": ",r]}):null}function De({pr:s}){const{aiAnalysis:r,aiFix:t}=te(),n=W(x=>x.aiFixTabFocus),i=W(x=>x.consumeAiFixTabFocus),[c,m]=o.useState(null);return o.useEffect(()=>{n&&n.prId===s.id&&(n.reviewText&&m(n.reviewText),i())},[n,s.id,i]),!r&&!t?e.jsx("div",{className:"p-4 text-sm text-gray-500",children:"AI Analysis and Fix is not enabled."}):e.jsxs("div",{className:"pb-6",children:[r&&e.jsx("div",{className:"border-b border-gray-200 dark:border-gray-800",children:e.jsx(re,{pr:s})}),e.jsx(Ce,{pr:s}),r&&e.jsx(Pe,{pr:s,canFix:t}),t&&e.jsx(Re,{pr:s,seedReviewText:c,onSeedConsumed:()=>m(null)})]})}function Ce({pr:s}){const r=s.checkRuns;return r.length===0?null:e.jsxs("div",{className:"border-b border-gray-200 dark:border-gray-800",children:[e.jsx(L,{children:"CI status"}),e.jsxs("div",{className:"px-4 pb-3",children:[e.jsx(ne,{prId:s.id,checks:r}),e.jsx(ae,{prId:s.id,checks:r,viewerCanPush:s.viewerCanPush})]})]})}function Pe({pr:s,canFix:r}){const{data:t}=ie(s.id,!0),n=ce(s.id),i=J(s.id),c=o.useMemo(()=>s.checkRuns.filter(l=>l.state==="failure"||l.state==="error").map(l=>({name:l.name,jobId:l.jobId,state:l.state})),[s.checkRuns]);if(!(c.length>0||((t==null?void 0:t.hasFailures)??!1))&&!(t!=null&&t.analysis))return null;const x=(t==null?void 0:t.fixability)==="low";return e.jsxs("div",{className:"border-b border-gray-200 dark:border-gray-800",children:[e.jsx(L,{children:"CI failure analysis"}),e.jsxs("div",{className:"px-4 pb-3",children:[(t==null?void 0:t.analysis)&&(t.rootCauseConfidence||t.fixability)&&e.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-gray-400",title:"How confident the analysis is — not a severity rating",children:"Confidence"}),e.jsx(z,{label:"Root cause",value:t.rootCauseConfidence}),e.jsx(z,{label:"Fixability",value:t.fixability})]}),t!=null&&t.analysis?e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(K,{children:t.analysis})}):e.jsx("p",{className:"text-sm text-gray-500",children:"Diagnose the failing CI: likely root cause + a suggested fix, from the full logs of every failing check."}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",className:j,disabled:n.isPending||c.length===0,onClick:()=>n.mutate(c),children:n.isPending?"Analyzing…":t!=null&&t.analysis?"Re-analyze":"Analyze CI failure"}),r&&(t==null?void 0:t.analysis)&&e.jsx("button",{type:"button",className:S,disabled:i.isPending,onClick:()=>i.mutate({model:"claude-sonnet-5",seed:"ci_analysis"}),title:"Launch an agent to fix the CI failure",children:"Fix it →"}),r&&x&&(t==null?void 0:t.analysis)&&e.jsx("span",{className:"text-[11px] text-gray-500",children:"low confidence this is auto-fixable"}),n.isError&&e.jsx("span",{className:"text-[11px] text-red-500",children:D(n.error)})]})]})]})}function Re({pr:s,seedReviewText:r,onSeedConsumed:t}){var k,F,N,A;const{data:n,isLoading:i}=le(s.id,!0),[c,m]=o.useState("claude-sonnet-5"),x=J(s.id),l=oe(s.id),p=((k=n==null?void 0:n.fix)==null?void 0:k.status)??null,h=p==="running"||p==="queued"||x.isPending,{status:d}=de(s.id,h),R=(d==null?void 0:d.status)??p??"idle",f=R==="running"||R==="queued",w=r?"review":"plain",M=()=>{x.mutate({model:c,seed:w,reviewText:r??void 0},{onSuccess:()=>t()})},u=(n==null?void 0:n.fix)??null;return e.jsxs("div",{children:[e.jsx(L,{children:"AI Fix"}),e.jsxs("div",{className:"px-4",children:[(n==null?void 0:n.enabled)===!1?e.jsx("p",{className:"text-sm text-gray-500",children:"The agentic fixer is disabled."}):(n==null?void 0:n.auth)==="none"?e.jsx("p",{className:"rounded border border-amber-300 bg-amber-50 p-2 text-xs text-amber-700 dark:border-amber-700 dark:bg-amber-950/30 dark:text-amber-300",children:n.authMessage??"No Claude authentication found. Sign in to Claude or set an API key, then restart."}):e.jsxs(e.Fragment,{children:[r&&!f&&e.jsx("div",{className:"mb-2 rounded border border-blue-200 bg-blue-50 p-2 text-xs text-blue-700 dark:border-blue-800 dark:bg-blue-950/30 dark:text-blue-300",children:"Ready to generate a fix from the selected review."}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("select",{className:"rounded border border-gray-300 bg-transparent px-2 py-1 text-xs dark:border-gray-700",value:c,onChange:y=>m(y.target.value),disabled:f,children:ue.map(y=>e.jsx("option",{value:y,children:xe[y]},y))}),f?e.jsx("button",{type:"button",className:j,onClick:()=>l.mutate(),children:"Cancel"}):e.jsx("button",{type:"button",className:S,disabled:x.isPending,onClick:M,children:u?"Generate new fix":"Generate fix"}),x.isError&&e.jsx("span",{className:"text-[11px] text-red-500",children:D(x.error)})]}),f&&e.jsxs("div",{className:"mt-3",children:[e.jsx(Q,{active:!0,label:"Running AI fix",value:je(d),timeConstantSec:40}),e.jsx("div",{className:"mt-1 text-[11px] text-gray-500",children:ye[((F=d==null?void 0:d.progress)==null?void 0:F.phase)??""]??"Working…"}),((N=d==null?void 0:d.progress)==null?void 0:N.recentActivity)&&d.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:bg-gray-900",children:d.progress.recentActivity.slice(-8).join(`
|
|
2
2
|
`)})]}),!f&&u&&e.jsx(we,{pr:s,fix:u,headInfo:(n==null?void 0:n.headInfo)??null,viewerCanPush:(n==null?void 0:n.viewerCanPush)??!1}),i&&!u&&e.jsx("p",{className:"mt-3 text-xs text-gray-400",children:"Loading…"})]}),e.jsx(Fe,{history:(n==null?void 0:n.history)??[],currentFixId:((A=n==null?void 0:n.fix)==null?void 0:A.id)??null})]})]})}function we({pr:s,fix:r,headInfo:t,viewerCanPush:n}){const i=o.useMemo(()=>X(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",children:"The fix run was cancelled."});if(r.status!=="succeeded")return e.jsx(e.Fragment,{});const c=!r.patch||r.filesChanged.length===0;return e.jsxs("div",{className:"mt-3",children:[r.summary&&e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(K,{children:r.summary})}),c?e.jsx("p",{className:"mt-2 text-xs text-gray-500",children:"The agent made no changes."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-1 mt-2 text-[11px] text-gray-500",children:[r.filesChanged.length," file",r.filesChanged.length===1?"":"s"," changed"]}),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(Z,{files:i})}),e.jsx(Se,{pr:s,fix:r,headInfo:t,viewerCanPush:n})]})]})}function _({fix:s}){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:s.pushedBranch}),s.pushedPrUrl&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("a",{href:s.pushedPrUrl,target:"_blank",rel:"noreferrer",className:"underline",children:["PR #",s.pushedPrNumber]})]}),s.pushedAt&&e.jsxs(e.Fragment,{children:[" · ",I(s.pushedAt)]})]}),s.commitMessage&&e.jsx("div",{className:"mt-1 font-mono text-[11px] text-green-800 dark:text-green-300",children:s.commitMessage})]})}function Fe({history:s,currentFixId:r}){const t=s.filter(n=>n.pushedAt!=null&&n.id!==r);return t.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:"Fixes pushed via Pierre"}),e.jsx("ul",{className:"space-y-2",children:t.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:n.pushedPrUrl,target:"_blank",rel:"noreferrer",className:"underline",children:["PR #",n.pushedPrNumber]})]}),n.pushedAt&&e.jsxs(e.Fragment,{children:[" · ",I(n.pushedAt)]})]})]},n.id))})]})}function Ae({preview:s,loading:r}){if(r)return e.jsx("p",{className:"text-[11px] text-gray-400",children:"Checking against the trunk…"});if(!s||!s.available||!s.trunkSha)return null;if(!s.clean){const t=s.conflictFiles;return e.jsxs("div",{className:"rounded border border-amber-300 bg-amber-50 p-2 text-[11px] text-amber-700 dark:border-amber-700 dark:bg-amber-950/30 dark:text-amber-300",children:["⚠ Conflicts with ",e.jsx("span",{className:"font-mono",children:s.trunk}),t.length>0?e.jsxs(e.Fragment,{children:[" in ",t.length," file",t.length===1?"":"s",e.jsxs("span",{className:"text-amber-600/90 dark:text-amber-400/90",children:[": ",t.slice(0,6).join(", "),t.length>6?"…":""]})]}):null,". Resolving before you push avoids a conflicted PR."]})}return s.behindBy>0?e.jsxs("p",{className:"text-[11px] text-gray-500",children:[e.jsx("span",{className:"font-mono",children:s.trunk})," is ",s.behindBy," ","commit",s.behindBy===1?"":"s"," ahead — the fix merges cleanly."]}):e.jsxs("p",{className:"text-[11px] text-green-600 dark:text-green-400",children:["Up to date with ",e.jsx("span",{className:"font-mono",children:s.trunk})," — no conflicts."]})}function Ee({resolved:s,target:r,pushing:t,onPush:n,onRedo:i,disabled:c}){const m=o.useMemo(()=>X(s.diff),[s.diff]);return e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsxs("div",{className:"rounded border border-green-200 bg-green-50 p-2 text-[11px] text-green-700 dark:border-green-800 dark:bg-green-950/30 dark:text-green-300",children:["Rebased onto ",e.jsx("span",{className:"font-mono",children:s.trunk}),".",s.resolvedConflicts?` Claude resolved conflicts in ${s.conflictFiles.length} file${s.conflictFiles.length===1?"":"s"}${s.conflictFiles.length?`: ${s.conflictFiles.join(", ")}`:""}.`:" No conflicts."," ","Review the result below, then push."]}),e.jsxs("div",{className:"text-[11px] text-gray-500",children:[s.filesChanged.length," file",s.filesChanged.length===1?"":"s"," in the rebased result"]}),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(Z,{files:m})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",className:S,disabled:t||c,onClick:n,children:t?"Pushing…":r==="new"?"Push rebased + open PR":"Push rebased (force-with-lease)"}),e.jsx("button",{type:"button",className:j,disabled:t,onClick:i,children:"Re-rebase"})]})]})}function Se({pr:s,fix:r,headInfo:t,viewerCanPush:n}){var V,G;const i=ge(s.id),c=me(),m=be(),x=pe(),l=fe(),p=(t==null?void 0:t.canPushSameBranch)??!1,[h,d]=o.useState(p?"existing":"new"),[R,f]=o.useState((t==null?void 0:t.suggestedBranch)??""),[w,M]=o.useState(!0),[u,k]=o.useState("idle"),[F,N]=o.useState(null),A=o.useRef(!1),y=o.useRef(!1);o.useEffect(()=>{!A.current&&(t!=null&&t.suggestedBranch)&&(f(t.suggestedBranch),A.current=!0,t.canPushSameBranch||d("new"))},[t]);const g=r.pushedAt!=null,q=g&&r.pushedPrNumber==null,U=!g||q;o.useEffect(()=>{!y.current&&n&&U&&(y.current=!0,l.mutate(r.id))},[n,U,r.id]);const a=l.data??null,{status:v}=Y(s.id,r.id,"rebase",u==="rebasing"),{status:C}=Y(s.id,r.id,"push",u==="pushing");if(o.useEffect(()=>{u==="rebasing"&&v&&v.status!=="running"&&v.status!=="queued"&&(k("idle"),v.error&&N(v.error))},[u,v]),o.useEffect(()=>{u==="pushing"&&C&&C.status!=="running"&&C.status!=="queued"&&(k("idle"),C.error&&N(C.error))},[u,C]),!n)return g?e.jsx(_,{fix:r}):e.jsx("p",{className:"mt-2 text-xs text-gray-500",children:"You need write access to this repository to push this fix."});if(g&&!q)return e.jsx(_,{fix:r});const B=h==="new"&&R.trim().length===0,P=u!=="idle"||i.isPending||c.isPending,H=r.model,ee=g&&!!a&&a.available&&a.clean&&a.behindBy===0,T=E=>{N(null),i.mutate({fixId:r.id,body:{target:h,branch:h==="new"?R.trim():void 0,strategy:E,autoResolve:w,model:H}},{onSuccess:se=>{"pushedBranch"in se||k("pushing")}})},O=()=>{N(null),c.mutate({fixId:r.id,body:{autoResolve:w,model:H}},{onSuccess:()=>k("rebasing")})},b=u==="rebasing"?v:C,$=r.resolved;return e.jsxs("div",{className:"mt-3 rounded border border-gray-200 p-2 dark:border-gray-800",children:[g&&e.jsx(_,{fix:r}),e.jsx("div",{className:"mb-2 text-xs font-semibold text-gray-600 dark:text-gray-300",children:g?"Reconcile with the trunk":"Push this fix"}),!g&&r.commitMessage&&e.jsxs("div",{className:"mb-2 rounded bg-gray-50 p-2 text-[11px] dark:bg-gray-900",children:[e.jsx("span",{className:"uppercase tracking-wide text-gray-400",children:"Commit message"}),e.jsx("div",{className:"mt-0.5 font-mono text-gray-700 dark:text-gray-200",children:r.commitMessage})]}),e.jsxs("label",{className:`flex items-center gap-2 text-xs ${p?"":"opacity-40"}`,title:p?void 0:"The PR head is a fork you cannot push to — use a new branch",children:[e.jsx("input",{type:"radio",checked:h==="existing",disabled:!p||P,onChange:()=>d("existing")}),"Push to the PR branch",(t==null?void 0:t.headRef)&&e.jsxs("span",{className:"font-mono text-gray-400",children:["(",t.headRef,")"]})]}),e.jsxs("label",{className:"mt-1 flex items-center gap-2 text-xs",children:[e.jsx("input",{type:"radio",checked:h==="new",disabled:P,onChange:()=>d("new")}),"New branch + open a PR"]}),h==="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:R,disabled:P,onChange:E=>f(E.target.value),placeholder:"branch-name"}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(Ae,{preview:a,loading:l.isPending})}),e.jsx("button",{type:"button",className:j,disabled:l.isPending||P,onClick:()=>l.mutate(r.id),title:"Re-check this fix against the current trunk",children:l.isPending?"Checking…":"Re-check trunk"}),l.isError&&!l.isPending&&e.jsx("span",{className:"text-[11px] text-red-500",children:"Couldn't check the trunk — try again."})]}),u!=="idle"?e.jsxs("div",{className:"mt-2",children:[e.jsx(Q,{active:!0,label:u==="rebasing"?"Rebasing & resolving":"Pushing",value:Ne(b),timeConstantSec:40}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 text-[11px] text-gray-500",children:[e.jsx("span",{children:ke[((V=b==null?void 0:b.progress)==null?void 0:V.phase)??""]??"Working…"}),e.jsx("button",{type:"button",className:j,onClick:()=>u==="rebasing"?m.mutate(r.id):x.mutate(r.id),children:"Cancel"})]}),((G=b==null?void 0:b.progress)==null?void 0:G.recentActivity)&&b.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:bg-gray-900",children:b.progress.recentActivity.slice(-8).join(`
|
|
3
3
|
`)})]}):$?e.jsx(Ee,{resolved:$,target:h,pushing:i.isPending,disabled:B,onPush:()=>T("rebase"),onRedo:O}):ee?e.jsxs("p",{className:"mt-2 text-[11px] text-gray-500",children:["No trunk changes to reconcile — the pushed fix is up to date with"," ",e.jsx("span",{className:"font-mono",children:a==null?void 0:a.trunk}),"."]}):e.jsxs("div",{className:"mt-2 space-y-2",children:[a&&a.available&&!a.clean&&e.jsxs("div",{className:"text-[11px] text-gray-500",children:["Recommended: rebase onto"," ",e.jsx("span",{className:"font-mono",children:a.trunk})," — Claude resolves the conflicts and you review the result before it pushes."]}),e.jsxs("label",{className:"flex items-center gap-2 text-[11px] text-gray-600 dark:text-gray-300",children:[e.jsx("input",{type:"checkbox",checked:w,onChange:E=>M(E.target.checked)}),"Let Claude resolve conflicts"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("button",{type:"button",className:a&&!a.clean?S:j,disabled:P||B,onClick:O,title:"Rebase the fix onto the trunk; Claude resolves conflicts and you review before a force-with-lease push",children:["Rebase onto ",(a==null?void 0:a.trunk)??"trunk"]}),!g&&e.jsxs("button",{type:"button",className:j,disabled:P||B,onClick:()=>T("merge"),title:"Merge the trunk into the fix branch (a merge commit; never force-pushes)",children:["Merge ",(a==null?void 0:a.trunk)??"trunk"," in"]}),!g&&e.jsxs("button",{type:"button",className:!a||a.clean?S:j,disabled:P||B,onClick:()=>T("plain"),title:"Push the fix as-is (never force-pushes). If it conflicts with the trunk, the PR will show as conflicted.",children:[h==="new"?"Push + open PR":"Push",a&&!a.clean?" anyway":""]})]}),g&&e.jsxs("p",{className:"text-[11px] text-gray-400",children:["Rebasing replays the fix onto"," ",e.jsx("span",{className:"font-mono",children:(a==null?void 0:a.trunk)??"the trunk"})," ","and force-pushes (with lease) onto the PR branch — the safe way to reconcile an already-pushed fix."]}),h==="existing"&&e.jsxs("p",{className:"text-[11px] text-gray-400",children:["Rebase force-pushes (with lease) onto"," ",e.jsx("span",{className:"font-mono",children:t==null?void 0:t.headRef}),"; merge and push do not."]})]}),(F||i.isError||c.isError)&&e.jsx("div",{className:"mt-2 text-[11px] text-red-500",children:F??D(i.error??c.error)})]})}function D(s){return s instanceof he||s instanceof Error?s.message:"Something went wrong"}export{De as AiFixTab};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{e as be,r as c,j as e}from"./tanstack-R-s9abdD.js";import{f as fe,s as Ce,x as Re,o as Pe,L as Se,K as Ee,B as Ae,z as Te,v as $e,t as Ie,C as _e,b as Fe,R as Le,h as ve,g as se,e as ke,H as Me,D as re,w as Be,u as He,M as ee}from"./index-
|
|
1
|
+
import{e as be,r as c,j as e}from"./tanstack-R-s9abdD.js";import{f as fe,s as Ce,x as Re,o as Pe,L as Se,K as Ee,B as Ae,z as Te,v as $e,t as Ie,C as _e,b as Fe,R as Le,h as ve,g as se,e as ke,H as Me,D as re,w as Be,u as He,M as ee}from"./index-CxFDrc36.js";import"./markdown-BUNN1sk6.js";import"./highlight-C8vPehS1.js";import"./vis-C3BCkP5U.js";function Oe(t,s){return be({queryKey:["review-learnings",t],queryFn:()=>fe.reviewLearnings(t),enabled:s&&t!=null})}function De(t,s){return be({queryKey:["review-actions",t],queryFn:()=>fe.reviewActions(t),enabled:s&&t!=null})}function Ve({label:t,children:s}){return e.jsxs("div",{className:"flex gap-3 px-4 py-1.5 text-sm",children:[e.jsx("span",{className:"w-28 shrink-0 text-xs uppercase tracking-wide text-gray-400",children:t}),e.jsx("div",{className:"min-w-0 flex-1",children:s})]})}const Z=t=>t?t.slice(0,7):"—",z={skip:"Skipped",diff_only:"Quick",worktree:"Deep"},Ue=[{value:"auto",label:"Auto (router decides)"},{value:"diff_only",label:"Quick — diff only"},{value:"worktree",label:"Deep — full worktree"}],V=(t,s)=>`${t} ${s}${t===1?"":"s"}`;function Ge(t){const s=t.routeReason;if(!s)return;const n=`${V(s.changedFiles,"file")} · ${V(s.linesChanged,"line")} · ${V(s.dirsTouched,"dir")}`;return s.decidedBy==="user"?`You chose ${z[t.reviewMode??"worktree"]} for this run (${n}).`:s.trippedBy?`Auto chose Deep — ${n}; over the ${s.trippedBy} limit.`:`Auto chose ${z[t.reviewMode??"diff_only"]} — ${n}.`}const te={COMMENT:"Comment",REQUEST_CHANGES:"Request changes",APPROVE:"Approve"},qe={APPROVE:"bg-green-500/10 text-green-700 dark:text-green-400",REQUEST_CHANGES:"bg-red-500/10 text-red-700 dark:text-red-400",COMMENT:"bg-gray-500/10 text-gray-600 dark:text-gray-300"};function Ke({verdict:t}){return e.jsx("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-xs font-medium ${qe[t]}`,children:te[t]})}const me={blocker:0,warning:1,nit:2,question:3,praise:4},We={blocker:"bg-red-500/10 text-red-700 dark:text-red-400",warning:"bg-orange-500/10 text-orange-700 dark:text-orange-400",nit:"bg-yellow-500/10 text-yellow-700 dark:text-yellow-500",question:"bg-blue-500/10 text-blue-700 dark:text-blue-400",praise:"bg-green-500/10 text-green-700 dark:text-green-400"};function Qe(t){const s=[t.model];return t.costUsd!=null&&s.push(`${ve(t.costUsd)} cr`),t.numTurns!=null&&s.push(`${t.numTurns} turns`),t.excludedFiles.length>0&&s.push(`${t.excludedFiles.length} noise files excluded`),s.join(" · ")}const Ye={cloning:"Cloning the worktree",fetching_diff:"Fetching the diff",deciding:"Deciding scope",reviewing:"Reviewing",persisting:"Saving findings"};function ze(t){var n,a,r;if(t==null)return null;if(t.status==="queued")return 5;const s=(n=t.progress)==null?void 0:n.phase;if(s==null)return 8;switch(s){case"fetching_diff":return 15;case"deciding":return 28;case"cloning":return 42;case"reviewing":{const o=((r=(a=t.progress)==null?void 0:a.recentActivity)==null?void 0:r.length)??0;return Math.min(90,55+o*3)}case"persisting":return 95;default:return null}}function Y(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function Je({review:t}){const{inputTokens:s,outputTokens:n,cacheReadTokens:a,cacheCreationTokens:r}=t;if((s??0)+(n??0)+(a??0)+(r??0)<=0)return null;const d=[];return n!=null&&d.push({key:"out",label:"↓ out",value:n,title:"Output tokens generated (billed at the output rate — the priciest per token)"}),s!=null&&d.push({key:"in",label:"↑ in",value:s,title:"New (uncached) input tokens"}),a!=null&&d.push({key:"cr",label:"⟳ cache read",value:a,title:"Cached input tokens re-read each turn — billed at ~10% of the input rate, but the volume driver of a multi-turn run"}),r!=null&&d.push({key:"cw",label:"✎ cache write",value:r,title:"Tokens written to the prompt cache (billed at ~1.25× the input rate)"}),e.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-0.5 font-mono text-xs text-gray-500 dark:text-gray-400",children:d.map(i=>e.jsxs("span",{title:i.title,children:[i.label," ",Y(i.value)]},i.key))})}function Xe({lines:t}){const s=c.useRef(null);return c.useEffect(()=>{const n=s.current;n!=null&&(n.scrollTop=n.scrollHeight)},[t]),t.length===0?null:e.jsx("div",{ref:s,className:"mt-2 max-h-32 overflow-y-auto rounded 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((n,a)=>e.jsx("div",{className:"whitespace-pre-wrap break-words",children:n===""?" ":n},a))})}function ge(t){return t.startsWith("@@")?"text-violet-500":t.startsWith("+")?"text-green-700 dark:text-green-400":t.startsWith("-")?"text-red-700 dark:text-red-400":"text-gray-500 dark:text-gray-400"}const Q="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",L="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 Ze({hunk:t}){const[s,n]=c.useState(!1),a=t.replace(/\n$/,"").split(`
|
|
2
2
|
`),r=a.find(o=>o.startsWith("@@"))??a.at(-1)??"";return s?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:a.map((o,d)=>e.jsx("div",{className:ge(o),children:o===""?" ":o},d))}),e.jsx("button",{type:"button",onClick:()=>n(!1),className:"px-2 pb-1.5 text-[11px] text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:"⌃ Hide code"})]}):e.jsxs("button",{type:"button",onClick:()=>n(!0),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("span",{className:"shrink-0 text-gray-400",children:"▸"}),e.jsx("span",{className:`min-w-0 flex-1 truncate ${ge(r)}`,children:r===""?" ":r}),a.length>1&&e.jsxs("span",{className:"shrink-0 font-sans text-[10px] text-gray-400",children:[a.length," lines"]})]})}function et({prId:t,finding:s,editable:n,prUrl:a,repoFullName:r,headSha:o,posting:d,postError:i,onToggle:h,onReword:k,onPostComment:j}){const[g,E]=c.useState(!1),x=c.useRef(null);c.useEffect(()=>()=>{x.current!=null&&clearTimeout(x.current)},[]);const[p,N]=c.useState(!1),[S,m]=c.useState(s.editedBody??"");c.useEffect(()=>{p||m(s.editedBody??"")},[s.editedBody,p]);const b=s.editedBody!=null&&s.editedBody.trim()!=="",y=p&&S.trim()!==""&&S!==(s.editedBody??"")?S:null,A=y!=null||b,J=y??(b?s.editedBody:s.body),T=s.line!=null?`${s.path}:${s.line}`:s.path,f=s.postedAt!=null,v=s.githubCommentId!=null?s.postedCommentKind==="pr_comment"?`${a}#issuecomment-${s.githubCommentId}`:`${a}#discussion_r${s.githubCommentId}`:null,$=s.line!=null?`${a}/files#diff-${s.diffAnchorId}${s.side==="LEFT"?"L":"R"}${s.line}`:`${a}/files#diff-${s.diffAnchorId}`,U=o!=null&&s.line!=null&&s.side==="RIGHT"?`https://github.com/${r}/blob/${o}/${s.path.split("/").map(encodeURIComponent).join("/")}#L${s.line}`:null,w=v??$,C=v==null?U:null,G=n,q=()=>{let _=`${s.title}
|
|
3
3
|
|
|
4
4
|
${J}`;s.suggestion!=null&&s.suggestion!==""&&(_+=`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ClaudeReviewTab-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ClaudeReviewTab-zKtMbB1-.js","assets/tanstack-R-s9abdD.js","assets/markdown-BUNN1sk6.js","assets/highlight-C8vPehS1.js","assets/highlight-BEHUn5zE.css","assets/vis-C3BCkP5U.js","assets/vis-ziCVehMy.css","assets/AiFixTab-CMJeCtop.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{b as Xg,R as jo,e as qe,r as x,j as n,f as Be,d as Ue,a as Gm,u as Jg,c as Zg,Q as ex,P as tx}from"./tanstack-R-s9abdD.js";import{d as Uc,M as nx,r as rx,a as sx,b as ax}from"./markdown-BUNN1sk6.js";import{r as lx}from"./highlight-C8vPehS1.js";import{D as hp,T as ox}from"./vis-C3BCkP5U.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))o(i);new MutationObserver(i=>{for(const u of i)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&o(d)}).observe(document,{childList:!0,subtree:!0});function a(i){const u={};return i.integrity&&(u.integrity=i.integrity),i.referrerPolicy&&(u.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?u.credentials="include":i.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function o(i){if(i.ep)return;i.ep=!0;const u=a(i);fetch(i.href,u)}})();const ix="modulepreload",cx=function(e){return"/app/"+e},gp={},Eu=function(s,a,o){let i=Promise.resolve();if(a&&a.length>0){let d=function(g){return Promise.all(g.map(y=>Promise.resolve(y).then(b=>({status:"fulfilled",value:b}),b=>({status:"rejected",reason:b}))))};document.getElementsByTagName("link");const p=document.querySelector("meta[property=csp-nonce]"),m=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));i=d(a.map(g=>{if(g=cx(g),g in gp)return;gp[g]=!0;const y=g.endsWith(".css"),b=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${g}"]${b}`))return;const v=document.createElement("link");if(v.rel=y?"stylesheet":ix,y||(v.as="script"),v.crossOrigin="",v.href=g,m&&v.setAttribute("nonce",m),document.head.appendChild(v),y)return new Promise((N,I)=>{v.addEventListener("load",N),v.addEventListener("error",()=>I(new Error(`Unable to preload CSS for ${g}`)))})}))}function u(d){const p=new Event("vite:preloadError",{cancelable:!0});if(p.payload=d,window.dispatchEvent(p),!p.defaultPrevented)throw d}return i.then(d=>{for(const p of d||[])p.status==="rejected"&&u(p.reason);return s().catch(u)})};var No={},Kc={exports:{}},rn={},Hc={exports:{}},Wc={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* scheduler.production.min.js
|
|
@@ -37,7 +37,7 @@ ${a}`}function ln(e){const s=new Map;for(const a of e??[])s.set(a.id,a);return s
|
|
|
37
37
|
`)){const u=yv(i);if(u){a=u.oldStart,o=u.newStart,s.push({kind:"hunk",text:i});continue}const d=i[0];d==="+"?(s.push({kind:"add",text:i,newLine:o}),o+=1):d==="-"?(s.push({kind:"del",text:i,oldLine:a}),a+=1):d==="\\"?s.push({kind:"context",text:i}):(s.push({kind:"context",text:i,oldLine:a,newLine:o}),a+=1,o+=1)}return s}function bv(e){return e?e.replace(/\n$/,"").split(`
|
|
38
38
|
`).length:0}function Kp(e){let s=e.trim();return s==="/dev/null"?null:(s.startsWith('"')&&s.endsWith('"')&&(s=s.slice(1,-1)),(s.startsWith("a/")||s.startsWith("b/"))&&(s=s.slice(2)),s)}function wv(e){const s=/^diff --git a\/(.+) b\/(.+)$/.exec(e);return s?{oldPath:s[1]??null,newPath:s[2]??null}:{oldPath:null,newPath:null}}function $N(e){if(!e)return[];const s=e.replace(/\n$/,"").split(`
|
|
39
39
|
`),a=s.length,o=[];let i=0;for(;i<a&&!(s[i]??"").startsWith("diff --git ");)i++;for(;i<a;){const u=wv(s[i]??"");i++;let d="modified",p=null,m=null,g=null,y=null,b=!1;const v=[];let N=!1;for(;i<a;i++){const R=s[i]??"";if(R.startsWith("diff --git "))break;if(N){v.push(R);continue}R.startsWith("@@")?(N=!0,v.push(R)):R.startsWith("new file mode")?d="added":R.startsWith("deleted file mode")?d="removed":R.startsWith("rename from ")?(d="renamed",g=R.slice(12)):R.startsWith("rename to ")?(d="renamed",y=R.slice(10)):R.startsWith("copy from ")?(d="copied",g=R.slice(10)):R.startsWith("copy to ")?(d="copied",y=R.slice(8)):R.startsWith("Binary files ")||R.startsWith("GIT binary patch")?b=!0:R.startsWith("--- ")?p=Kp(R.slice(4)):R.startsWith("+++ ")&&(m=Kp(R.slice(4)))}const I=m||y||u.newPath||u.oldPath||p||"(unknown)",P=d==="renamed"||d==="copied"?g||p||u.oldPath:null;let E=0,w=0;for(const R of v)R.startsWith("+")&&!R.startsWith("+++")?E++:R.startsWith("-")&&!R.startsWith("---")&&w++;o.push({path:I,previousPath:P,status:d,additions:E,deletions:w,patch:b?null:v.join(`
|
|
40
|
-
`)})}return o}const kv=250,jv=400;function Nv(e){return e.patch==null||bv(e.patch)>kv||e.additions+e.deletions>jv}const Sv={added:{icon:"A",label:"added",cls:"text-green-600 dark:text-green-400"},removed:{icon:"D",label:"removed",cls:"text-red-500 dark:text-red-400"},modified:{icon:"M",label:"modified",cls:"text-amber-600 dark:text-amber-400"},renamed:{icon:"R",label:"renamed",cls:"text-sky-600 dark:text-sky-400"},copied:{icon:"C",label:"copied",cls:"text-sky-600 dark:text-sky-400"},changed:{icon:"M",label:"changed",cls:"text-amber-600 dark:text-amber-400"},unchanged:{icon:"·",label:"unchanged",cls:"text-gray-400"}};function jh(e){return e.kind==="add"&&e.newLine!=null?{line:e.newLine,side:"RIGHT"}:e.kind==="context"&&e.newLine!=null?{line:e.newLine,side:"RIGHT"}:e.kind==="del"&&e.oldLine!=null?{line:e.oldLine,side:"LEFT"}:null}function Cv(e,s){if(s==null)return null;let a=null,o=null;return e.forEach((i,u)=>{const d=jh(i);!d||d.line!==s||(d.side==="RIGHT"?a=u:o=u)}),a??o}const Rv={hunk:"bg-sky-500/5 text-sky-600 dark:text-sky-400 select-none",add:"bg-green-500/10",del:"bg-red-500/10",context:""};function Hp(e){return e==null?"":String(e)}function Iv({row:e,filePath:s,fileUrl:a,commenting:o,open:i,onOpen:u,onClose:d}){const p=o?jh(e):null,m=e.kind==="hunk"?e.text:e.text.slice(1)||" ";return n.jsxs(n.Fragment,{children:[n.jsxs("tr",{className:`group ${Rv[e.kind]}`,children:[n.jsx("td",{className:"w-9 select-none border-r border-gray-200 px-1 text-right align-top text-gray-400 dark:border-gray-800",children:e.kind==="hunk"?"":Hp(e.oldLine)}),n.jsx("td",{className:"w-9 select-none border-r border-gray-200 px-1 text-right align-top text-gray-400 dark:border-gray-800",children:e.kind==="hunk"?"":Hp(e.newLine)}),n.jsx("td",{className:"select-none px-1 align-top",children:n.jsx("div",{className:"flex w-4 justify-center",children:o&&p&&!i&&n.jsx("button",{type:"button",onClick:u,title:"Comment on this line",className:"rounded bg-blue-500 px-1 text-[10px] font-bold leading-tight text-white opacity-0 transition-opacity hover:bg-blue-600 group-hover:opacity-100",children:"+"})})}),n.jsxs("td",{className:"w-full whitespace-pre px-2 align-top",children:[e.kind!=="hunk"&&n.jsx("span",{className:"select-none text-gray-400",children:e.kind==="add"?"+":e.kind==="del"?"-":" "}),m]})]}),i&&o&&p&&n.jsx("tr",{children:n.jsx("td",{colSpan:4,className:"px-2 py-1.5",children:n.jsx(Tv,{prId:o.prId,filePath:s,fileUrl:a,line:p.line,side:p.side,onClose:d})})})]})}function Wp({thread:e,ctx:s}){const a=x.useRef(null),o=s.focusThreadId!=null&&s.focusThreadId===e.id;return x.useEffect(()=>{var i;o&&a.current&&(a.current.scrollIntoView({block:"center",behavior:"smooth"}),(i=s.onThreadShown)==null||i.call(s))},[o]),n.jsx("tr",{ref:a,children:n.jsx("td",{colSpan:4,className:"bg-gray-50 px-2 py-2 dark:bg-gray-900/40",children:n.jsx("div",{className:`rounded font-sans ${o?"ring-2 ring-amber-400/70":""}`,children:n.jsx(hl,{thread:e,usersById:s.usersById,prUrl:s.prUrl,selected:o})})})})}function Tv({prId:e,filePath:s,fileUrl:a,line:o,side:i,onClose:u}){const[d,p]=x.useState(""),[m,g]=x.useState(null),y=Py(e),b=y.error instanceof Gt?y.error.message:y.error?"Failed to post the comment.":null,v=()=>{const N=d.trim();!N||y.isPending||(g(null),y.mutate({path:s,line:o,side:i,body:N},{onSuccess:I=>{if(I.commentId===null){g({text:"Couldn't place this comment in the diff — open it on GitHub instead.",url:a,tone:"warn"});return}if(p(""),I.anchored===!1){g({text:`Posted on the nearest changed line (${I.side==="LEFT"?"old":"new"} line ${I.line}). It’ll appear in the Threads tab after the next sync.`,url:I.url,tone:"warn"});return}g({text:"Comment posted. It’ll appear in the Threads tab after the next sync.",url:I.url,tone:"ok"})}}))};return n.jsxs("div",{className:"space-y-1 rounded border border-gray-300 bg-white p-2 font-sans dark:border-gray-700 dark:bg-gray-900",children:[n.jsxs("div",{className:"text-[10px] text-gray-400",children:["Commenting on ",i==="LEFT"?"old":"new"," line ",o]}),n.jsx(ei,{prId:e,value:d,onChange:p,rows:3,autoFocus:!0,placeholder:"Add an inline review comment (markdown)…",className:"w-full rounded border border-gray-300 bg-white px-2 py-1.5 text-xs dark:border-gray-700 dark:bg-gray-950"}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("button",{type:"button",onClick:v,disabled:y.isPending||d.trim().length===0,className:"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",children:y.isPending?"Sending…":"Send"}),n.jsx("button",{type:"button",onClick:()=>{p(""),g(null),y.reset(),u()},disabled:y.isPending,className:"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",children:(m==null?void 0:m.tone)==="ok"?"Close":"Cancel"}),b&&n.jsx("span",{className:"text-[10px] text-red-500",children:b})]}),m&&n.jsxs("div",{className:m.tone==="ok"?"text-[10px] text-green-600 dark:text-green-400":"text-[10px] text-amber-600 dark:text-amber-400",children:[m.text,m.url&&n.jsxs(n.Fragment,{children:[" ",n.jsx("a",{href:m.url,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"Open on GitHub ↗"})]})]})]})}function Ev({file:e,commenting:s,threads:a,threadCtx:o}){const i=x.useMemo(()=>vv(e.patch),[e.patch]),{byRow:u,unanchored:d}=x.useMemo(()=>{const P=new Map,E=[];for(const w of a){const R=Cv(i,w.line);if(R==null)E.push(w);else{const S=P.get(R)??[];S.push(w),P.set(R,S)}}return{byRow:P,unanchored:E}},[i,a]),p=(o==null?void 0:o.focusThreadId)!=null&&a.some(P=>P.id===o.focusThreadId),[m,g]=x.useState(()=>!Nv(e)||a.length>0);x.useEffect(()=>{p&&g(!0)},[p]);const[y,b]=x.useState(null),v=Sv[e.status],N=e.previousPath?`${e.previousPath} → ${e.path}`:e.path,I=e.githubUrl??null;return n.jsxs("div",{children:[n.jsxs("div",{className:"sticky top-0 z-10 flex items-center gap-2 border-b border-gray-100 bg-white px-3 py-1.5 text-xs hover:bg-gray-50 dark:border-gray-800 dark:bg-gray-950 dark:hover:bg-gray-900",children:[n.jsxs("button",{type:"button",onClick:()=>g(P=>!P),className:"flex min-w-0 flex-1 items-center gap-2 text-left",title:m?"Collapse this file":"Expand this file",children:[n.jsx("span",{className:"w-3 shrink-0 select-none text-gray-400",children:m?"▾":"▸"}),n.jsx("span",{className:`w-3 shrink-0 select-none text-center font-mono font-bold ${v.cls}`,title:v.label,children:v.icon}),n.jsx("code",{className:"min-w-0 flex-1 truncate font-mono",children:N})]}),a.length>0&&n.jsxs("span",{className:"shrink-0 rounded bg-amber-500/15 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 dark:text-amber-300",title:`${a.length} unresolved thread${a.length===1?"":"s"} on this file`,children:[a.length," 💬"]}),n.jsxs("span",{className:"shrink-0 font-mono tabular-nums",children:[n.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",e.additions]})," ",n.jsxs("span",{className:"text-red-500 dark:text-red-400",children:["−",e.deletions]})]}),I&&n.jsx("a",{href:I,target:"_blank",rel:"noreferrer noopener",className:"shrink-0 text-blue-500 hover:underline",title:"View this file's diff on GitHub",children:"↗"})]}),m&&n.jsx("div",{className:"border-b border-gray-100 dark:border-gray-800",children:e.patch==null?n.jsxs("div",{className:"px-3 py-3 text-center text-xs text-gray-500",children:[I?n.jsxs(n.Fragment,{children:["Diff is too large or binary —"," ",n.jsx("a",{href:I,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"view on GitHub ↗"})]}):"Binary file — no textual diff.",o&&a.length>0&&n.jsx("div",{className:"mt-2 space-y-2 text-left",children:a.map(P=>n.jsx("div",{className:"font-sans",children:n.jsx(hl,{thread:P,usersById:o.usersById,prUrl:o.prUrl,selected:o.focusThreadId===P.id})},P.id))})]}):i.length===0?n.jsx("div",{className:"px-3 py-3 text-center text-xs text-gray-500",children:"No textual diff for this file."}):n.jsx("table",{className:"w-full border-collapse font-mono text-[12px] leading-[1.45]",children:n.jsxs("tbody",{children:[o&&d.map(P=>n.jsx(Wp,{thread:P,ctx:o},`u-${P.id}`)),i.map((P,E)=>{var w;return n.jsxs(x.Fragment,{children:[n.jsx(Iv,{row:P,filePath:e.path,fileUrl:I,commenting:s,open:y===E,onOpen:()=>b(E),onClose:()=>b(null)}),o&&((w=u.get(E))==null?void 0:w.map(R=>n.jsx(Wp,{thread:R,ctx:o},R.id)))]},E)})]})})})]})}function Pv({files:e,commenting:s,threadCtx:a}){const o=x.useMemo(()=>{const i=new Map;for(const u of(a==null?void 0:a.threads)??[]){const d=i.get(u.path)??[];d.push(u),i.set(u.path,d)}return i},[a==null?void 0:a.threads]);return n.jsx("div",{children:e.map(i=>n.jsx(Ev,{file:i,commenting:s??null,threads:o.get(i.path)??[],threadCtx:a??null},i.path))})}function Av({file:e}){const s=e.path.split("/"),a=s.at(-1),o=s.slice(0,-1).join("/");return n.jsxs("a",{href:e.githubUrl,target:"_blank",rel:"noreferrer noopener",className:"group flex items-center gap-3 px-4 py-1.5 text-sm hover:bg-gray-50 dark:hover:bg-gray-900",title:`${e.path} — view this file's diff on GitHub`,children:[n.jsxs("code",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:[o&&n.jsxs("span",{className:"text-gray-400",children:[o,"/"]}),n.jsx("span",{className:"font-semibold",children:a})]}),n.jsxs("span",{className:"shrink-0 font-mono text-xs tabular-nums",children:[n.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",e.additions]})," ",n.jsxs("span",{className:"text-red-500 dark:text-red-400",children:["−",e.deletions]})]}),n.jsx("span",{className:"shrink-0 text-gray-300 group-hover:text-blue-500 dark:text-gray-600",children:"↗"})]})}function Qc({pr:e,extra:s}){return n.jsxs("div",{className:"flex items-center gap-3 border-b border-gray-200 px-4 py-2 text-xs dark:border-gray-800",children:[n.jsxs("span",{className:"font-semibold text-gray-600 dark:text-gray-300",children:[e.changedFilesCount," file",e.changedFilesCount===1?"":"s"," changed"]}),n.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",e.additions.toLocaleString()]}),n.jsxs("span",{className:"text-red-500 dark:text-red-400",children:["−",e.deletions.toLocaleString()]}),s,n.jsx("a",{href:`${e.githubUrl}/files`,target:"_blank",rel:"noreferrer noopener",className:"ml-auto text-blue-500 hover:underline",children:"Files changed ↗"})]})}function $v({pr:e,focusThreadId:s,onThreadShown:a}){const{data:o,isLoading:i,isError:u}=ky(e.id),{data:d}=$n(),p=x.useMemo(()=>ln(d),[d]),m={threads:e.threads.filter(b=>!b.isResolved||b.id===s),usersById:p,prUrl:e.githubUrl,focusThreadId:s??null,onThreadShown:a};if(e.files.length===0&&e.changedFilesCount===0&&!i)return n.jsx("div",{className:"px-3 py-6 text-center text-sm text-gray-500",children:"No file changes on this PR."});if(i)return n.jsxs("div",{children:[n.jsx(Qc,{pr:e}),n.jsx("div",{className:"px-3 py-6 text-center text-sm text-gray-500",children:"Loading diff…"})]});const g=(o==null?void 0:o.files)??[];return!u&&g.length>0?n.jsxs("div",{children:[n.jsx(Qc,{pr:e,extra:m.threads.length>0?n.jsxs("span",{className:"rounded bg-amber-500/15 px-1.5 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300",children:[m.threads.length," inline thread",m.threads.length===1?"":"s"]}):void 0}),n.jsx(Pv,{files:g,commenting:{prId:e.id},threadCtx:m}),(o==null?void 0:o.truncated)&&n.jsxs("div",{className:"px-4 py-2 text-xs text-gray-400",children:["Large diff — not all files are shown."," ",n.jsx("a",{href:`${e.githubUrl}/files`,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"View all on GitHub ↗"})]})]}):n.jsxs("div",{children:[n.jsx(Qc,{pr:e}),n.jsxs("div",{className:"px-4 py-2 text-xs text-gray-400",children:[u?"The full diff couldn’t be loaded — showing the changed-file list.":"Inline diffs aren’t available for this PR — showing the changed-file list."," ",n.jsx("a",{href:`${e.githubUrl}/files`,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"View on GitHub ↗"})]}),e.files.length>0&&n.jsx("div",{className:"divide-y divide-gray-100 dark:divide-gray-800",children:e.files.map(b=>n.jsx(Av,{file:b},b.path))})]})}function Ku({prId:e,initialBody:s,autoFocus:a,onCancel:o,onDone:i}){const[u,d]=x.useState(s??""),p=Cy(e),m=p.error instanceof Gt?p.error.message:p.error?"Failed to post the comment.":null,g=()=>{const y=u.trim();!y||p.isPending||p.mutate(y,{onSuccess:()=>{d(""),i==null||i()}})};return n.jsxs("div",{className:"space-y-1.5 px-3 pb-3",children:[n.jsx(ei,{prId:e,value:u,onChange:d,rows:3,autoFocus:a,placeholder:"Add a comment to this PR (markdown, @ to mention)…",className:"w-full rounded border border-gray-300 bg-white px-2 py-1.5 text-sm dark:border-gray-700 dark:bg-gray-900"}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("button",{type:"button",onClick:g,disabled:p.isPending||u.trim().length===0,className:"whitespace-nowrap 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:p.isPending?"Commenting…":o?"Reply":"Comment"}),o&&n.jsx("button",{type:"button",onClick:()=>{p.reset(),o()},disabled:p.isPending,className:"whitespace-nowrap 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:"Cancel"}),m&&n.jsx("span",{className:"text-xs text-red-500",children:m})]})]})}const Mv=x.lazy(()=>Eu(()=>import("./ClaudeReviewTab-DIjf6gst.js"),__vite__mapDeps([0,1,2,3,4,5,6])).then(e=>({default:e.ClaudeReviewTab}))),Fv=x.lazy(()=>Eu(()=>import("./AiFixTab-Bvs2sflj.js"),__vite__mapDeps([7,1,2,3,4,5,6])).then(e=>({default:e.AiFixTab})));function Lv(e){if(!e)return null;const s=[];return e.comments>0&&s.push(`${e.comments} new comment${e.comments===1?"":"s"}`),e.reviews>0&&s.push(`${e.reviews} new review${e.reviews===1?"":"s"}`),e.commits>0&&s.push(`${e.commits} new commit${e.commits===1?"":"s"}`),s.length?s.join(" · "):null}function rl(e,s){const a=e.authorId!=null?s.get(e.authorId):void 0;return{id:e.id,number:e.number,title:e.title,repoFullName:e.repoFullName,authorLogin:(a==null?void 0:a.githubLogin)??null,authorDisplayName:(a==null?void 0:a.displayName)??null,authorAvatarUrl:(a==null?void 0:a.avatarUrl)??null}}const _v={overview:"Overview",threads:"Threads",activity:"Activity",changes:"Changes",claude_review:"Claude Review",ai_fix:"AI Analysis and Fix"};function Ov(e){var a;const s=[];s.push({key:"opened",time:e.openedAt,label:"opened this PR",actorId:e.authorId,href:e.githubUrl,event:{type:"pr_opened",refId:null}});for(const o of e.commits)s.push({key:`commit:${o.id}`,time:o.committedAt,label:"pushed a commit",actorId:o.authorId??o.committerId,detail:(a=o.message)==null?void 0:a.split(`
|
|
40
|
+
`)})}return o}const kv=250,jv=400;function Nv(e){return e.patch==null||bv(e.patch)>kv||e.additions+e.deletions>jv}const Sv={added:{icon:"A",label:"added",cls:"text-green-600 dark:text-green-400"},removed:{icon:"D",label:"removed",cls:"text-red-500 dark:text-red-400"},modified:{icon:"M",label:"modified",cls:"text-amber-600 dark:text-amber-400"},renamed:{icon:"R",label:"renamed",cls:"text-sky-600 dark:text-sky-400"},copied:{icon:"C",label:"copied",cls:"text-sky-600 dark:text-sky-400"},changed:{icon:"M",label:"changed",cls:"text-amber-600 dark:text-amber-400"},unchanged:{icon:"·",label:"unchanged",cls:"text-gray-400"}};function jh(e){return e.kind==="add"&&e.newLine!=null?{line:e.newLine,side:"RIGHT"}:e.kind==="context"&&e.newLine!=null?{line:e.newLine,side:"RIGHT"}:e.kind==="del"&&e.oldLine!=null?{line:e.oldLine,side:"LEFT"}:null}function Cv(e,s){if(s==null)return null;let a=null,o=null;return e.forEach((i,u)=>{const d=jh(i);!d||d.line!==s||(d.side==="RIGHT"?a=u:o=u)}),a??o}const Rv={hunk:"bg-sky-500/5 text-sky-600 dark:text-sky-400 select-none",add:"bg-green-500/10",del:"bg-red-500/10",context:""};function Hp(e){return e==null?"":String(e)}function Iv({row:e,filePath:s,fileUrl:a,commenting:o,open:i,onOpen:u,onClose:d}){const p=o?jh(e):null,m=e.kind==="hunk"?e.text:e.text.slice(1)||" ";return n.jsxs(n.Fragment,{children:[n.jsxs("tr",{className:`group ${Rv[e.kind]}`,children:[n.jsx("td",{className:"w-9 select-none border-r border-gray-200 px-1 text-right align-top text-gray-400 dark:border-gray-800",children:e.kind==="hunk"?"":Hp(e.oldLine)}),n.jsx("td",{className:"w-9 select-none border-r border-gray-200 px-1 text-right align-top text-gray-400 dark:border-gray-800",children:e.kind==="hunk"?"":Hp(e.newLine)}),n.jsx("td",{className:"select-none px-1 align-top",children:n.jsx("div",{className:"flex w-4 justify-center",children:o&&p&&!i&&n.jsx("button",{type:"button",onClick:u,title:"Comment on this line",className:"rounded bg-blue-500 px-1 text-[10px] font-bold leading-tight text-white opacity-0 transition-opacity hover:bg-blue-600 group-hover:opacity-100",children:"+"})})}),n.jsxs("td",{className:"w-full whitespace-pre px-2 align-top",children:[e.kind!=="hunk"&&n.jsx("span",{className:"select-none text-gray-400",children:e.kind==="add"?"+":e.kind==="del"?"-":" "}),m]})]}),i&&o&&p&&n.jsx("tr",{children:n.jsx("td",{colSpan:4,className:"px-2 py-1.5",children:n.jsx(Tv,{prId:o.prId,filePath:s,fileUrl:a,line:p.line,side:p.side,onClose:d})})})]})}function Wp({thread:e,ctx:s}){const a=x.useRef(null),o=s.focusThreadId!=null&&s.focusThreadId===e.id;return x.useEffect(()=>{var i;o&&a.current&&(a.current.scrollIntoView({block:"center",behavior:"smooth"}),(i=s.onThreadShown)==null||i.call(s))},[o]),n.jsx("tr",{ref:a,children:n.jsx("td",{colSpan:4,className:"bg-gray-50 px-2 py-2 dark:bg-gray-900/40",children:n.jsx("div",{className:`rounded font-sans ${o?"ring-2 ring-amber-400/70":""}`,children:n.jsx(hl,{thread:e,usersById:s.usersById,prUrl:s.prUrl,selected:o})})})})}function Tv({prId:e,filePath:s,fileUrl:a,line:o,side:i,onClose:u}){const[d,p]=x.useState(""),[m,g]=x.useState(null),y=Py(e),b=y.error instanceof Gt?y.error.message:y.error?"Failed to post the comment.":null,v=()=>{const N=d.trim();!N||y.isPending||(g(null),y.mutate({path:s,line:o,side:i,body:N},{onSuccess:I=>{if(I.commentId===null){g({text:"Couldn't place this comment in the diff — open it on GitHub instead.",url:a,tone:"warn"});return}if(p(""),I.anchored===!1){g({text:`Posted on the nearest changed line (${I.side==="LEFT"?"old":"new"} line ${I.line}). It’ll appear in the Threads tab after the next sync.`,url:I.url,tone:"warn"});return}g({text:"Comment posted. It’ll appear in the Threads tab after the next sync.",url:I.url,tone:"ok"})}}))};return n.jsxs("div",{className:"space-y-1 rounded border border-gray-300 bg-white p-2 font-sans dark:border-gray-700 dark:bg-gray-900",children:[n.jsxs("div",{className:"text-[10px] text-gray-400",children:["Commenting on ",i==="LEFT"?"old":"new"," line ",o]}),n.jsx(ei,{prId:e,value:d,onChange:p,rows:3,autoFocus:!0,placeholder:"Add an inline review comment (markdown)…",className:"w-full rounded border border-gray-300 bg-white px-2 py-1.5 text-xs dark:border-gray-700 dark:bg-gray-950"}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("button",{type:"button",onClick:v,disabled:y.isPending||d.trim().length===0,className:"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",children:y.isPending?"Sending…":"Send"}),n.jsx("button",{type:"button",onClick:()=>{p(""),g(null),y.reset(),u()},disabled:y.isPending,className:"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",children:(m==null?void 0:m.tone)==="ok"?"Close":"Cancel"}),b&&n.jsx("span",{className:"text-[10px] text-red-500",children:b})]}),m&&n.jsxs("div",{className:m.tone==="ok"?"text-[10px] text-green-600 dark:text-green-400":"text-[10px] text-amber-600 dark:text-amber-400",children:[m.text,m.url&&n.jsxs(n.Fragment,{children:[" ",n.jsx("a",{href:m.url,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"Open on GitHub ↗"})]})]})]})}function Ev({file:e,commenting:s,threads:a,threadCtx:o}){const i=x.useMemo(()=>vv(e.patch),[e.patch]),{byRow:u,unanchored:d}=x.useMemo(()=>{const P=new Map,E=[];for(const w of a){const R=Cv(i,w.line);if(R==null)E.push(w);else{const S=P.get(R)??[];S.push(w),P.set(R,S)}}return{byRow:P,unanchored:E}},[i,a]),p=(o==null?void 0:o.focusThreadId)!=null&&a.some(P=>P.id===o.focusThreadId),[m,g]=x.useState(()=>!Nv(e)||a.length>0);x.useEffect(()=>{p&&g(!0)},[p]);const[y,b]=x.useState(null),v=Sv[e.status],N=e.previousPath?`${e.previousPath} → ${e.path}`:e.path,I=e.githubUrl??null;return n.jsxs("div",{children:[n.jsxs("div",{className:"sticky top-0 z-10 flex items-center gap-2 border-b border-gray-100 bg-white px-3 py-1.5 text-xs hover:bg-gray-50 dark:border-gray-800 dark:bg-gray-950 dark:hover:bg-gray-900",children:[n.jsxs("button",{type:"button",onClick:()=>g(P=>!P),className:"flex min-w-0 flex-1 items-center gap-2 text-left",title:m?"Collapse this file":"Expand this file",children:[n.jsx("span",{className:"w-3 shrink-0 select-none text-gray-400",children:m?"▾":"▸"}),n.jsx("span",{className:`w-3 shrink-0 select-none text-center font-mono font-bold ${v.cls}`,title:v.label,children:v.icon}),n.jsx("code",{className:"min-w-0 flex-1 truncate font-mono",children:N})]}),a.length>0&&n.jsxs("span",{className:"shrink-0 rounded bg-amber-500/15 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 dark:text-amber-300",title:`${a.length} unresolved thread${a.length===1?"":"s"} on this file`,children:[a.length," 💬"]}),n.jsxs("span",{className:"shrink-0 font-mono tabular-nums",children:[n.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",e.additions]})," ",n.jsxs("span",{className:"text-red-500 dark:text-red-400",children:["−",e.deletions]})]}),I&&n.jsx("a",{href:I,target:"_blank",rel:"noreferrer noopener",className:"shrink-0 text-blue-500 hover:underline",title:"View this file's diff on GitHub",children:"↗"})]}),m&&n.jsx("div",{className:"border-b border-gray-100 dark:border-gray-800",children:e.patch==null?n.jsxs("div",{className:"px-3 py-3 text-center text-xs text-gray-500",children:[I?n.jsxs(n.Fragment,{children:["Diff is too large or binary —"," ",n.jsx("a",{href:I,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"view on GitHub ↗"})]}):"Binary file — no textual diff.",o&&a.length>0&&n.jsx("div",{className:"mt-2 space-y-2 text-left",children:a.map(P=>n.jsx("div",{className:"font-sans",children:n.jsx(hl,{thread:P,usersById:o.usersById,prUrl:o.prUrl,selected:o.focusThreadId===P.id})},P.id))})]}):i.length===0?n.jsx("div",{className:"px-3 py-3 text-center text-xs text-gray-500",children:"No textual diff for this file."}):n.jsx("table",{className:"w-full border-collapse font-mono text-[12px] leading-[1.45]",children:n.jsxs("tbody",{children:[o&&d.map(P=>n.jsx(Wp,{thread:P,ctx:o},`u-${P.id}`)),i.map((P,E)=>{var w;return n.jsxs(x.Fragment,{children:[n.jsx(Iv,{row:P,filePath:e.path,fileUrl:I,commenting:s,open:y===E,onOpen:()=>b(E),onClose:()=>b(null)}),o&&((w=u.get(E))==null?void 0:w.map(R=>n.jsx(Wp,{thread:R,ctx:o},R.id)))]},E)})]})})})]})}function Pv({files:e,commenting:s,threadCtx:a}){const o=x.useMemo(()=>{const i=new Map;for(const u of(a==null?void 0:a.threads)??[]){const d=i.get(u.path)??[];d.push(u),i.set(u.path,d)}return i},[a==null?void 0:a.threads]);return n.jsx("div",{children:e.map(i=>n.jsx(Ev,{file:i,commenting:s??null,threads:o.get(i.path)??[],threadCtx:a??null},i.path))})}function Av({file:e}){const s=e.path.split("/"),a=s.at(-1),o=s.slice(0,-1).join("/");return n.jsxs("a",{href:e.githubUrl,target:"_blank",rel:"noreferrer noopener",className:"group flex items-center gap-3 px-4 py-1.5 text-sm hover:bg-gray-50 dark:hover:bg-gray-900",title:`${e.path} — view this file's diff on GitHub`,children:[n.jsxs("code",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:[o&&n.jsxs("span",{className:"text-gray-400",children:[o,"/"]}),n.jsx("span",{className:"font-semibold",children:a})]}),n.jsxs("span",{className:"shrink-0 font-mono text-xs tabular-nums",children:[n.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",e.additions]})," ",n.jsxs("span",{className:"text-red-500 dark:text-red-400",children:["−",e.deletions]})]}),n.jsx("span",{className:"shrink-0 text-gray-300 group-hover:text-blue-500 dark:text-gray-600",children:"↗"})]})}function Qc({pr:e,extra:s}){return n.jsxs("div",{className:"flex items-center gap-3 border-b border-gray-200 px-4 py-2 text-xs dark:border-gray-800",children:[n.jsxs("span",{className:"font-semibold text-gray-600 dark:text-gray-300",children:[e.changedFilesCount," file",e.changedFilesCount===1?"":"s"," changed"]}),n.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",e.additions.toLocaleString()]}),n.jsxs("span",{className:"text-red-500 dark:text-red-400",children:["−",e.deletions.toLocaleString()]}),s,n.jsx("a",{href:`${e.githubUrl}/files`,target:"_blank",rel:"noreferrer noopener",className:"ml-auto text-blue-500 hover:underline",children:"Files changed ↗"})]})}function $v({pr:e,focusThreadId:s,onThreadShown:a}){const{data:o,isLoading:i,isError:u}=ky(e.id),{data:d}=$n(),p=x.useMemo(()=>ln(d),[d]),m={threads:e.threads.filter(b=>!b.isResolved||b.id===s),usersById:p,prUrl:e.githubUrl,focusThreadId:s??null,onThreadShown:a};if(e.files.length===0&&e.changedFilesCount===0&&!i)return n.jsx("div",{className:"px-3 py-6 text-center text-sm text-gray-500",children:"No file changes on this PR."});if(i)return n.jsxs("div",{children:[n.jsx(Qc,{pr:e}),n.jsx("div",{className:"px-3 py-6 text-center text-sm text-gray-500",children:"Loading diff…"})]});const g=(o==null?void 0:o.files)??[];return!u&&g.length>0?n.jsxs("div",{children:[n.jsx(Qc,{pr:e,extra:m.threads.length>0?n.jsxs("span",{className:"rounded bg-amber-500/15 px-1.5 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300",children:[m.threads.length," inline thread",m.threads.length===1?"":"s"]}):void 0}),n.jsx(Pv,{files:g,commenting:{prId:e.id},threadCtx:m}),(o==null?void 0:o.truncated)&&n.jsxs("div",{className:"px-4 py-2 text-xs text-gray-400",children:["Large diff — not all files are shown."," ",n.jsx("a",{href:`${e.githubUrl}/files`,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"View all on GitHub ↗"})]})]}):n.jsxs("div",{children:[n.jsx(Qc,{pr:e}),n.jsxs("div",{className:"px-4 py-2 text-xs text-gray-400",children:[u?"The full diff couldn’t be loaded — showing the changed-file list.":"Inline diffs aren’t available for this PR — showing the changed-file list."," ",n.jsx("a",{href:`${e.githubUrl}/files`,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"View on GitHub ↗"})]}),e.files.length>0&&n.jsx("div",{className:"divide-y divide-gray-100 dark:divide-gray-800",children:e.files.map(b=>n.jsx(Av,{file:b},b.path))})]})}function Ku({prId:e,initialBody:s,autoFocus:a,onCancel:o,onDone:i}){const[u,d]=x.useState(s??""),p=Cy(e),m=p.error instanceof Gt?p.error.message:p.error?"Failed to post the comment.":null,g=()=>{const y=u.trim();!y||p.isPending||p.mutate(y,{onSuccess:()=>{d(""),i==null||i()}})};return n.jsxs("div",{className:"space-y-1.5 px-3 pb-3",children:[n.jsx(ei,{prId:e,value:u,onChange:d,rows:3,autoFocus:a,placeholder:"Add a comment to this PR (markdown, @ to mention)…",className:"w-full rounded border border-gray-300 bg-white px-2 py-1.5 text-sm dark:border-gray-700 dark:bg-gray-900"}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("button",{type:"button",onClick:g,disabled:p.isPending||u.trim().length===0,className:"whitespace-nowrap 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:p.isPending?"Commenting…":o?"Reply":"Comment"}),o&&n.jsx("button",{type:"button",onClick:()=>{p.reset(),o()},disabled:p.isPending,className:"whitespace-nowrap 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:"Cancel"}),m&&n.jsx("span",{className:"text-xs text-red-500",children:m})]})]})}const Mv=x.lazy(()=>Eu(()=>import("./ClaudeReviewTab-zKtMbB1-.js"),__vite__mapDeps([0,1,2,3,4,5,6])).then(e=>({default:e.ClaudeReviewTab}))),Fv=x.lazy(()=>Eu(()=>import("./AiFixTab-CMJeCtop.js"),__vite__mapDeps([7,1,2,3,4,5,6])).then(e=>({default:e.AiFixTab})));function Lv(e){if(!e)return null;const s=[];return e.comments>0&&s.push(`${e.comments} new comment${e.comments===1?"":"s"}`),e.reviews>0&&s.push(`${e.reviews} new review${e.reviews===1?"":"s"}`),e.commits>0&&s.push(`${e.commits} new commit${e.commits===1?"":"s"}`),s.length?s.join(" · "):null}function rl(e,s){const a=e.authorId!=null?s.get(e.authorId):void 0;return{id:e.id,number:e.number,title:e.title,repoFullName:e.repoFullName,authorLogin:(a==null?void 0:a.githubLogin)??null,authorDisplayName:(a==null?void 0:a.displayName)??null,authorAvatarUrl:(a==null?void 0:a.avatarUrl)??null}}const _v={overview:"Overview",threads:"Threads",activity:"Activity",changes:"Changes",claude_review:"Claude Review",ai_fix:"AI Analysis and Fix"};function Ov(e){var a;const s=[];s.push({key:"opened",time:e.openedAt,label:"opened this PR",actorId:e.authorId,href:e.githubUrl,event:{type:"pr_opened",refId:null}});for(const o of e.commits)s.push({key:`commit:${o.id}`,time:o.committedAt,label:"pushed a commit",actorId:o.authorId??o.committerId,detail:(a=o.message)==null?void 0:a.split(`
|
|
41
41
|
`)[0],href:`${e.githubUrl}/commits/${o.sha}`,event:{type:"commit_pushed",refId:o.id}});for(const o of e.reviews)s.push({key:`review:${o.id}`,time:o.submittedAt,label:`reviewed (${o.state.replace("_"," ")})`,actorId:o.authorId,detail:o.body??void 0,href:o.url??e.githubUrl,event:{type:"review_submitted",refId:o.id}});for(const o of e.comments)s.push({key:`comment:${o.id}`,time:o.createdAt,label:"commented",actorId:o.authorId,detail:o.body,href:o.url??e.githubUrl,event:{type:"pr_comment",refId:o.id}});return e.mergedAt?s.push({key:"merged",time:e.mergedAt,label:"merged this PR",actorId:e.authorId,href:e.githubUrl,event:{type:"pr_merged",refId:null}}):e.closedAt&&s.push({key:"closed",time:e.closedAt,label:"closed this PR",actorId:e.authorId,href:e.githubUrl,event:{type:"pr_closed",refId:null}}),s.sort((o,i)=>i.time.localeCompare(o.time))}function Dv({pr:e,usersById:s,since:a,onClearSince:o,focusEvent:i,onConsumed:u}){const d=x.useMemo(()=>Ov(e),[e]),p=a?d.filter(v=>v.time>a):d,m=te(v=>v.showEventOnTimeline),g=x.useRef(new Map),[y,b]=x.useState(null);return x.useEffect(()=>{var N;if(!i)return;const v=d.find(I=>I.event.type===i.type&&I.event.refId===i.refId);u(),v&&((N=g.current.get(v.key))==null||N.scrollIntoView({behavior:"smooth",block:"center"}),b(v.key))},[i,d,u]),x.useEffect(()=>{if(y==null)return;const v=setTimeout(()=>b(null),1800);return()=>clearTimeout(v)},[y]),n.jsxs("ul",{className:"divide-y divide-gray-100 dark:divide-gray-800",children:[a&&n.jsxs("li",{className:"flex items-center gap-2 bg-sky-500/5 px-3 py-1.5 text-xs text-sky-600 dark:text-sky-400",children:[n.jsxs("span",{children:["Showing ",p.length," since you last looked"]}),n.jsx("button",{type:"button",onClick:o,className:"ml-auto text-gray-400 hover:text-gray-600",children:"show all"})]}),p.map(v=>{const N=v.actorId!=null?s.get(v.actorId):void 0;return n.jsxs("li",{ref:I=>{I?g.current.set(v.key,I):g.current.delete(v.key)},className:`flex items-start gap-2 px-3 py-2 text-sm ${v.key===y?"activity-flash":""}`,children:[n.jsx(ht,{user:N,size:20}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5",children:[n.jsx(sn,{user:N,fallbackId:v.actorId,repoId:e.repoId,className:"font-medium"}),n.jsx("span",{className:"text-gray-500",children:v.label}),n.jsxs("span",{className:"text-xs text-gray-400",title:Ra(v.time),children:["· ",Ra(v.time)]})]}),v.detail&&n.jsx("div",{className:"mt-0.5 truncate text-xs text-gray-500",title:v.detail,children:v.detail.split(`
|
|
42
42
|
`)[0]}),n.jsxs("div",{className:"mt-1 flex items-center gap-3 text-xs",children:[n.jsx("button",{type:"button",onClick:()=>m(e.id,v.time,v.event),className:"text-blue-500 hover:underline",title:"Show this event on the timeline",children:"Show"}),v.href&&n.jsx("a",{href:v.href,target:"_blank",rel:"noreferrer noopener",className:"text-gray-400 hover:text-blue-500",children:"Open on GitHub ↗"})]})]})]},v.key)})]})}function Bv({pr:e,usersById:s,viewedSince:a,focusCommentId:o,selectedCommentId:i,onFocusConsumed:u}){const d=x.useRef(new Map),[p,m]=x.useState(null),[g,y]=x.useState(null);if(x.useEffect(()=>{if(o==null)return;u();const v=d.current.get(o);v&&(v.scrollIntoView({behavior:"smooth",block:"center"}),m(o))},[o,u]),x.useEffect(()=>{if(p==null)return;const v=setTimeout(()=>m(null),1800);return()=>clearTimeout(v)},[p]),e.comments.length===0)return n.jsx("div",{className:"px-3 py-6 text-center text-sm text-gray-500",children:"No PR comments on this PR."});const b=[...e.comments].sort((v,N)=>v.createdAt.localeCompare(N.createdAt));return n.jsx("div",{className:"space-y-2 px-3 pb-3",children:b.map(v=>{var P;const N=v.authorId!=null?s.get(v.authorId):void 0,I=wh(v.createdAt,a);return n.jsxs("div",{ref:E=>{E?d.current.set(v.id,E):d.current.delete(v.id)},className:`rounded-md border px-2.5 py-2 ${v.id===i?"border-amber-400 bg-amber-400/5":"border-gray-200 dark:border-gray-800"} ${I?"comment-new":""} ${v.id===p?"activity-flash":""}`,children:[n.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[n.jsx(yu,{prId:e.id,at:v.createdAt,event:{type:"pr_comment",refId:v.id},title:"Show this comment on the timeline"}),n.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"·"}),n.jsx(ht,{user:N,size:18}),n.jsx(sn,{user:N,fallbackId:v.authorId,repoId:e.repoId,className:"font-semibold"}),n.jsx("span",{className:"text-gray-400",title:Ra(v.createdAt),children:St(v.createdAt)}),I&&n.jsx(bh,{})]}),n.jsx("div",{className:"mt-1 text-sm",children:n.jsx(cr,{children:v.body})}),n.jsxs("div",{className:"mt-2 flex items-center gap-3 pl-2 text-[11px]",children:[g!==v.id&&n.jsx("button",{type:"button",onClick:()=>y(v.id),className:"text-blue-500 hover:underline",children:"Reply"}),v.url&&n.jsx("a",{href:v.url,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:"↗ View comment on GitHub"})]}),g===v.id&&n.jsx("div",{className:"mt-2",children:n.jsx(Ku,{prId:e.id,initialBody:ch(v.body,((P=s.get(v.authorId??-1))==null?void 0:P.githubLogin)??null),autoFocus:!0,onCancel:()=>y(null),onDone:()=>y(null)})})]},v.id)})})}function Nh({prId:e,selectedThreadId:s}){var Pe;const{data:a,isLoading:o,error:i}=Zo(e),{data:u}=Mr(),{aiAnalysis:d,aiFix:p,claudeReview:m}=yn(),g=d||p,[y,b]=x.useState("overview"),[v,N]=x.useState(null),I=Be(),P=te(se=>se.openPrFocused),E=Oe(se=>se.openPrFocusTab),w=Oe(se=>se.openPrDetailTab),R=te(se=>se.activityFocus),S=te(se=>se.consumeActivityFocus),j=x.useMemo(()=>R&&a&&R.prId===a.id?{type:R.type,refId:R.refId}:null,[R,a]),T=te(se=>se.commentFocus),M=te(se=>se.consumeCommentFocus),D=te(se=>se.selectedCommentId),U=te(se=>se.claudeTabFocus),G=te(se=>se.consumeClaudeTabFocus),L=te(se=>se.changesThreadFocus),Y=te(se=>se.consumeChangesThreadFocus),[X,B]=x.useState(null),_=te(se=>se.aiFixTabFocus),H=T&&a&&T.prId===a.id?T.commentId:null,ee=Oe(se=>se.syncMeta);x.useEffect(()=>{s!=null&&b("threads")},[s]);const ce=te(se=>se.threadBotFilter);x.useEffect(()=>{ce!=null&&b("threads")},[ce]),x.useEffect(()=>{j&&(b("activity"),N(null))},[j]),x.useEffect(()=>{m&&U&&a&&U.prId===a.id&&(b("claude_review"),G())},[U,a,m,G]),x.useEffect(()=>{L&&a&&L.prId===a.id&&(b("changes"),B(L.threadId),Y())},[L,a,Y]),x.useEffect(()=>{g&&_&&a&&_.prId===a.id&&b("ai_fix")},[_,a,g]),x.useEffect(()=>{H!=null&&b("overview")},[H]);const C=Ue({mutationFn:se=>ge.markPrViewed(se),onSuccess:()=>{I.invalidateQueries({queryKey:["open-prs"]}),I.invalidateQueries({queryKey:["timeline"]}),I.invalidateQueries({queryKey:["my-turn"]}),I.invalidateQueries({queryKey:["me"]})}}),F=x.useRef(null);x.useEffect(()=>{a&&F.current!==a.id&&(F.current=a.id,C.mutate(a.id))},[a,C]);const K=x.useMemo(()=>ln(a==null?void 0:a.users),[a]);if(x.useEffect(()=>{a!=null&&ee(rl(a,K))},[a,K,ee]),o)return n.jsx("div",{className:"p-4 text-sm text-gray-500",children:"Loading PR…"});if(i||!a)return n.jsx("div",{className:"p-4 text-sm text-red-500",children:i?String(i):"PR not found"});const ae=qx[a.state],ne=a.authorId!=null?K.get(a.authorId):void 0;return n.jsx(mh.Provider,{value:rl(a,K),children:n.jsxs("div",{className:"flex h-full flex-col",children:[n.jsxs("div",{className:"border-b border-gray-200 px-4 py-2 pr-28 dark:border-gray-800",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"rounded px-1.5 py-0.5 text-xs font-semibold text-white",style:{backgroundColor:ae.color},children:a.isDraft?"Draft":ae.label}),n.jsxs("button",{type:"button",onClick:()=>w(rl(a,K)),className:"min-w-0 truncate text-left text-sm font-semibold hover:underline",title:"Open full-screen in its own tab",children:[n.jsxs("span",{className:"text-gray-400",children:["#",a.number]})," ",a.title]}),n.jsx("button",{type:"button",onClick:()=>w(rl(a,K)),className:"shrink-0 rounded p-0.5 text-blue-500 hover:text-blue-600",title:"Open full-screen — this PR in its own tab","aria-label":"Open this PR full-screen in its own tab",children:n.jsx(ph,{size:13})}),n.jsx("button",{type:"button",onClick:()=>P(a.id),className:"shrink-0 rounded p-0.5 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",title:"Show this PR on the timeline","aria-label":"Show this PR on the timeline",children:n.jsx(my,{size:15})}),n.jsx("button",{type:"button",onClick:()=>E(rl(a,K)),className:"shrink-0 rounded p-0.5 text-blue-500 hover:text-blue-600",title:"Focus — open this PR in its own isolated timeline tab (✕ on the tab to close)","aria-label":"Focus this PR in its own timeline tab",children:n.jsx(Xo,{size:15})}),n.jsx("a",{href:a.githubUrl,target:"_blank",rel:"noreferrer noopener",className:"shrink-0 rounded p-0.5 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",title:"Open this PR on GitHub","aria-label":"Open this PR on GitHub",children:n.jsx(hy,{size:15})}),a.isStalled&&n.jsx("span",{className:"rounded bg-orange-500/15 px-1.5 py-0.5 text-xs font-medium text-orange-500",title:"Open, no recent commits, and has open threads",children:"Stalled"}),(()=>{const se=Lv(a.newSinceLastViewed);return se?n.jsxs("button",{type:"button",onClick:()=>{b("activity"),N(a.lastViewedAt)},className:"ml-auto shrink-0 rounded bg-sky-500/15 px-1.5 py-0.5 text-xs font-medium text-sky-500 hover:bg-sky-500/25",title:"Filter activity to what's new since you last looked",children:["👁 ",se]}):null})()]}),n.jsxs("div",{className:"mt-1 flex items-center gap-2 text-xs text-gray-500",children:[n.jsx(ht,{user:ne,size:16}),n.jsx(sn,{user:ne,fallbackId:a.authorId,repoId:a.repoId}),n.jsx("span",{children:"·"}),n.jsxs("span",{className:"inline-flex items-center gap-1",children:[a.repoFullName,((Pe=u==null?void 0:u.find(se=>se.id===a.repoId))==null?void 0:Pe.inboxWatch)&&n.jsx(Bu,{size:11})]}),n.jsx("span",{children:"·"}),n.jsxs("span",{children:["opened ",St(a.openedAt)]}),a.changedFilesCount>0&&n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"·"}),n.jsxs("button",{type:"button",onClick:()=>b("changes"),className:"inline-flex shrink-0 items-center gap-1 font-medium",title:"View the files changed by this PR",children:[n.jsxs("span",{className:"text-gray-500",children:[a.changedFilesCount," file",a.changedFilesCount===1?"":"s"]}),n.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",a.additions.toLocaleString()]}),n.jsxs("span",{className:"text-red-500 dark:text-red-400",children:["−",a.deletions.toLocaleString()]})]})]})]})]}),n.jsx("div",{className:"flex gap-1 border-b border-gray-200 px-3 dark:border-gray-800",children:["overview","threads","activity","changes",...m?["claude_review"]:[],...g?["ai_fix"]:[]].map(se=>{const Z=a.checkRuns.filter(je=>je.state==="failure"||je.state==="error").length;return n.jsxs("button",{type:"button",onClick:()=>b(se),className:`-mb-px border-b-2 px-3 py-1.5 text-xs ${y===se?"border-blue-500 text-blue-500":"border-transparent text-gray-500 hover:text-gray-700"}`,children:[_v[se],se==="overview"&&Z>0&&n.jsx("span",{className:"ml-1 text-red-500",title:`${Z} failing`,children:"●"}),se==="threads"&&a.threads.length>0&&n.jsx("span",{className:"ml-1 opacity-60",title:`${a.threads.length} threads`,children:a.threads.length}),se==="changes"&&a.changedFilesCount>0&&n.jsx("span",{className:"ml-1 opacity-60",title:`${a.changedFilesCount} files changed`,children:a.changedFilesCount})]},se)})}),n.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:n.jsx(x.Suspense,{fallback:n.jsx("div",{className:"px-4 py-6 text-sm text-gray-400",children:"Loading…"}),children:y==="overview"?n.jsxs("div",{children:[n.jsx(xv,{pr:a,usersById:K}),n.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-800",children:[n.jsxs("div",{className:"px-4 pb-1 pt-2 text-xs font-semibold uppercase tracking-wide text-gray-400",children:["PR comments",a.comments.length>0&&n.jsxs("span",{className:"ml-1 font-normal opacity-70",children:["· ",a.comments.length]})]}),n.jsx(Bv,{pr:a,usersById:K,viewedSince:a.lastViewedAt,focusCommentId:H,selectedCommentId:D,onFocusConsumed:M}),n.jsx(Ku,{prId:a.id})]})]}):y==="threads"?n.jsx(Zy,{threads:a.threads,usersById:K,prUrl:a.githubUrl,prId:a.id,repoId:a.repoId,selectedThreadId:s,viewedSince:a.lastViewedAt,botFilter:ce}):y==="activity"?n.jsx(Dv,{pr:a,usersById:K,since:v,onClearSince:()=>N(null),focusEvent:j,onConsumed:S}):y==="changes"?n.jsx($v,{pr:a,focusThreadId:X,onThreadShown:()=>B(null)}):y==="ai_fix"?n.jsx(Fv,{pr:a}):n.jsx(Mv,{pr:a,usersById:K})})})]})})}const zv=["untouched","replied_unresolved","likely_addressed","resolved"],qv={open:"Open",merged:"Merged",closed:"Closed"};function Uv(e){const s=ur[e.ciStatus];return s?`<span class="pr-ci pr-ci-lead" style="background:${s.color}" title="${s.label}"></span>`:""}function Kv(e){return e?`${e.avatarUrl?`<img class="pr-avatar" src="${kt(e.avatarUrl)}" width="14" height="14" loading="lazy" alt="" />`:""}<span class="pr-author">${kt(e.label)}</span>`:""}function Hv(e,s={}){const{author:a}=s,o=e.isDraft?'<span class="pr-draft-tag">draft</span>':"";return'<div class="pr-bar-inner">'+(e.state==="open"?Uv(e):"")+`<span class="pr-num">#${e.number}</span>`+Kv(a)+`${o}<span class="pr-title">${kt(e.title)}</span></div>`}function Vp(e,s,a=""){return`<div class="pr-tt-row ${a}"><span class="pr-tt-dot" style="background:${e}"></span><span>${s}</span></div>`}function Wv(e,s={}){const{author:a,hasComments:o=!1}=s,i=[];i.push(`<div class="pr-tt-title">#${e.number} ${kt(e.title)}</div>`);const u=[];a!=null&&a.label&&u.push(kt(a.label)),u.push(qv[e.state]),e.isDraft&&u.push("draft"),e.isStalled&&u.push("stalled"),i.push(`<div class="pr-tt-meta">${u.join(" · ")}</div>`);const d=ur[e.ciStatus];d&&i.push(Vp(d.color,d.label));const p=Yo(e.mergeable,e.mergeStateStatus);p&&i.push(`<div class="pr-tt-row pr-tt-warn"><span class="pr-tt-warn-icon">⚠</span><span>merge: ${kt(p)}</span></div>`);const m=zv.filter(g=>e.threadCounts[g]>0);if(m.length>0){i.push('<div class="pr-tt-section">Review threads</div>');for(const g of m){const y=jt[g];i.push(Vp(y.color,`${y.label}: ${e.threadCounts[g]}`))}}else o&&i.push('<div class="pr-tt-row pr-tt-quiet">Has comments</div>');return`<div class="pr-tt">${i.join("")}</div>`}function Vv(e,s=!1){const a=["pr-bar",`pr-${e.state}`];return e.state==="open"?a.push("pr-emph"):a.push("pr-muted"),e.isDraft&&a.push("pr-draft"),e.isStalled&&a.push("pr-stalled"),e.reviewRequestedFromMe&&a.push("pr-myturn"),e.state==="open"&&(e.isChangesRequested?a.push("pr-changes-requested"):e.isApproved?a.push("pr-approved"):s&&a.push("pr-commented")),a.join(" ")}function Qv(){return{comments:0,reviews:0,prsOpen:0,prsMerged:0,prsClosed:0}}function Gv(e,s){const a=new Map,o=i=>{let u=a.get(i);return u||(u=Qv(),a.set(i,u)),u};for(const i of e)i.actorId!=null&&(i.type==="pr_comment"||i.type==="review_comment"?o(i.actorId).comments++:i.type==="review_submitted"&&o(i.actorId).reviews++);for(const i of s){if(i.authorId==null)continue;const u=o(i.authorId);i.state==="open"?u.prsOpen++:i.state==="merged"?u.prsMerged++:u.prsClosed++}return a}const Yv='<svg viewBox="0 0 16 16" width="11" height="11" aria-hidden="true"><path fill="#8957e5" d="M8 .8 2.2 2.9v4.2c0 3.3 2.5 6.4 5.8 7.3 3.3-.9 5.8-4 5.8-7.3V2.9L8 .8Z"/><path d="M5.2 8 7.1 9.9 10.9 6" fill="none" stroke="#fff" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>',Xv='<svg viewBox="0 0 16 16" width="11" height="11" aria-hidden="true"><rect x="2" y="9" width="3" height="5" rx="0.5" fill="currentColor"/><rect x="6.5" y="6" width="3" height="8" rx="0.5" fill="currentColor"/><rect x="11" y="3" width="3" height="11" rx="0.5" fill="currentColor"/></svg>';function Jv(e,s,a,o=!1,i,u=!1){const d=ft(e,s),p=e!=null&&e.avatarUrl?`<img class="tl-user-avatar" src="${kt(e.avatarUrl)}" width="18" height="18" loading="lazy" referrerpolicy="no-referrer" alt="" />`:`<span class="tl-user-avatar tl-user-avatar-fallback">${kt((d[0]??"?").toUpperCase())}</span>`,m=e!=null&&e.githubLogin?`<a class="tl-user-name tl-user-name-link" href="${kt(Du(e.githubLogin))}" target="_blank" rel="noreferrer noopener" title="${kt(`@${e.githubLogin} on GitHub`)}" onclick="event.stopPropagation()">${kt(d)}</a>`:`<span class="tl-user-name">${kt(d)}</span>`,g=o?`<span class="tl-merger" title="Has merge rights — has merged a PR in this repo">${Yv}</span>`:"",y=i?`<button type="button" class="tl-stats-toggle" data-stats-gid="${kt(i)}" title="Show metrics" aria-label="Show contributor metrics">${Xv}</button>`:"",b=u?"Expand row":"Collapse row";return'<div class="tl-user">'+(i?`<button type="button" class="tl-collapse-caret" data-collapse-gid="${kt(i)}" title="${kt(b)}" aria-label="${kt(b)}">${u?"▸":"▾"}</button>`:"")+p+`<span class="tl-user-main"><span class="tl-user-name-line">${m}${g}${y}</span></span></div>`}function ni(){return typeof window<"u"}function Ia(e){return Hu(e)?(e.nodeName||"").toLowerCase():"#document"}function xn(e){var s;return(e==null||(s=e.ownerDocument)==null?void 0:s.defaultView)||window}function dr(e){var s;return(s=(Hu(e)?e.ownerDocument:e.document)||window.document)==null?void 0:s.documentElement}function Hu(e){return ni()?e instanceof Node||e instanceof xn(e).Node:!1}function dt(e){return ni()?e instanceof Element||e instanceof xn(e).Element:!1}function fr(e){return ni()?e instanceof HTMLElement||e instanceof xn(e).HTMLElement:!1}function vu(e){return!ni()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof xn(e).ShadowRoot}function gl(e){const{overflow:s,overflowX:a,overflowY:o,display:i}=An(e);return/auto|scroll|overlay|hidden|clip/.test(s+o+a)&&i!=="inline"&&i!=="contents"}function Zv(e){return/^(table|td|th)$/.test(Ia(e))}function ri(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const eb=/transform|translate|scale|rotate|perspective|filter/,tb=/paint|layout|strict|content/,As=e=>!!e&&e!=="none";let Gc;function Wu(e){const s=dt(e)?An(e):e;return As(s.transform)||As(s.translate)||As(s.scale)||As(s.rotate)||As(s.perspective)||!si()&&(As(s.backdropFilter)||As(s.filter))||eb.test(s.willChange||"")||tb.test(s.contain||"")}function nb(e){let s=$r(e);for(;fr(s)&&!Ar(s);){if(Wu(s))return s;if(ri(s))return null;s=$r(s)}return null}function si(){return Gc==null&&(Gc=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Gc}function Ar(e){return/^(html|body|#document)$/.test(Ia(e))}function An(e){return xn(e).getComputedStyle(e)}function ai(e){return dt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function $r(e){if(Ia(e)==="html")return e;const s=e.assignedSlot||e.parentNode||vu(e)&&e.host||dr(e);return vu(s)?s.host:s}function Sh(e){const s=$r(e);return Ar(s)?e.ownerDocument?e.ownerDocument.body:e.body:fr(s)&&gl(s)?s:Sh(s)}function ls(e,s,a){var o;s===void 0&&(s=[]),a===void 0&&(a=!0);const i=Sh(e),u=i===((o=e.ownerDocument)==null?void 0:o.body),d=xn(i);if(u){const p=bu(d);return s.concat(d,d.visualViewport||[],gl(i)?i:[],p&&a?ls(p):[])}else return s.concat(i,ls(i,[],a))}function bu(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const Bo=Math.min,Fs=Math.max,zo=Math.round,Co=Math.floor,ir=e=>({x:e,y:e}),rb={left:"right",right:"left",bottom:"top",top:"bottom"};function Qp(e,s,a){return Fs(e,Bo(s,a))}function li(e,s){return typeof e=="function"?e(s):e}function Ds(e){return e.split("-")[0]}function oi(e){return e.split("-")[1]}function Ch(e){return e==="x"?"y":"x"}function Rh(e){return e==="y"?"height":"width"}function as(e){const s=e[0];return s==="t"||s==="b"?"y":"x"}function Ih(e){return Ch(as(e))}function sb(e,s,a){a===void 0&&(a=!1);const o=oi(e),i=Ih(e),u=Rh(i);let d=i==="x"?o===(a?"end":"start")?"right":"left":o==="start"?"bottom":"top";return s.reference[u]>s.floating[u]&&(d=qo(d)),[d,qo(d)]}function ab(e){const s=qo(e);return[wu(e),s,wu(s)]}function wu(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Gp=["left","right"],Yp=["right","left"],lb=["top","bottom"],ob=["bottom","top"];function ib(e,s,a){switch(e){case"top":case"bottom":return a?s?Yp:Gp:s?Gp:Yp;case"left":case"right":return s?lb:ob;default:return[]}}function cb(e,s,a,o){const i=oi(e);let u=ib(Ds(e),a==="start",o);return i&&(u=u.map(d=>d+"-"+i),s&&(u=u.concat(u.map(wu)))),u}function qo(e){const s=Ds(e);return rb[s]+e.slice(s.length)}function ub(e){return{top:0,right:0,bottom:0,left:0,...e}}function db(e){return typeof e!="number"?ub(e):{top:e,right:e,bottom:e,left:e}}function Uo(e){const{x:s,y:a,width:o,height:i}=e;return{width:o,height:i,top:a,left:s,right:s+o,bottom:a+i,x:s,y:a}}/*!
|
|
43
43
|
* tabbable 6.4.0
|
|
@@ -50,4 +50,4 @@ ${a}`}function ln(e){const s=new Map;for(const a of e??[])s.set(a.id,a);return s
|
|
|
50
50
|
`)),P=N.split(/[\n,]/).map(B=>B.trim()).filter(Boolean),E=u!==i.inhouseDetect||p!==i.autoTagHighConfidence||g!==i.deepDetect||b!==i.aiTiebreak||P.join(`
|
|
51
51
|
`)!==i.loginAllowlist.join(`
|
|
52
52
|
`),[w,R]=x.useState(i.tagPierreReviews),[S,j]=x.useState(i.pierreFooter),T=w!==i.tagPierreReviews||S!==i.pierreFooter,[M,D]=x.useState(i.cost),U=JSON.stringify(M)!==JSON.stringify(i.cost),G=()=>Km.find(B=>!M.some(_=>_.kind===B))??"in_house",[L,Y]=x.useState(i.slackDigest),X=L!==i.slackDigest;return n.jsxs("div",{"data-testid":"bot-settings-section",className:"space-y-4",children:[n.jsx(Oj,{}),n.jsxs(or,{title:"Detection",desc:"How we recognise automated reviewers beyond the known vendors — your own in-house AI reviewer or CI service accounts.",children:[n.jsx($s,{label:"Detect in-house / service-account reviewers",hint:"Fingerprint branded review markers and behaviour to flag your own automation.",checked:u,onChange:d}),n.jsx($s,{label:"Auto-tag high-confidence matches",hint:"Badge a reviewer automatically when detection is high-confidence (medium always asks first).",checked:p,onChange:m}),n.jsx($s,{label:"Deep detect (app attribution)",hint:"Off by default — an extra REST lookup during sync to read GitHub App attribution.",checked:g,onChange:y}),n.jsx($s,{label:"AI tie-break (opt-in)",hint:"For medium-confidence cases only, one cheap model call per reviewer to decide. Costs a little; off by default.",checked:b,onChange:v}),n.jsx(Nt,{label:"Login allowlist",hint:"One login or glob per line (e.g. acme-ci, *-bot). Always treated as automated.",children:n.jsx("textarea",{className:`${rt} min-h-[3rem] font-mono`,value:N,placeholder:`acme-ci
|
|
53
|
-
*-svc`,onChange:B=>I(B.target.value)})}),n.jsx(Pr,{dirty:E,saving:a,onClick:()=>s({bots:{inhouseDetect:u,autoTagHighConfidence:p,deepDetect:g,aiTiebreak:b,loginAllowlist:P}})})]}),n.jsxs(or,{title:"Pierre attribution",desc:"How Pierre's own Claude reviews are stamped when posted.",children:[n.jsx($s,{label:"Tag Pierre reviews",hint:"Append a hidden marker so Pierre-posted reviews are recognised as its own (verbatim vs curated).",checked:w,onChange:R}),n.jsx($s,{label:"Visible footer",hint:'Also append a visible "Reviewed with Pierre + Claude" footer to posted reviews.',checked:S,onChange:j}),n.jsx(Pr,{dirty:T,saving:a,onClick:()=>s({bots:{tagPierreReviews:w,pierreFooter:S}})})]}),n.jsx(zj,{settings:e,save:s,saving:a}),n.jsxs(or,{title:"Per-vendor cost",desc:"Optional monthly spend per reviewer, used to show cost-per-acted-on in the Bot ROI panel. Stays on your account.",children:[M.length===0?n.jsx("p",{className:"text-[11px] text-gray-400",children:"No costs entered."}):n.jsx("ul",{className:"space-y-1.5",children:M.map((B,_)=>n.jsxs("li",{className:"flex items-center gap-2",children:[n.jsx("select",{className:`${rt} w-auto`,value:B.kind,onChange:H=>D(ee=>ee.map((ce,C)=>C===_?{...ce,kind:H.target.value}:ce)),"aria-label":"Vendor",children:Km.map(H=>n.jsx("option",{value:H,children:an(H).label},H))}),n.jsx("span",{className:"text-[11px] text-gray-400",children:"$"}),n.jsx("input",{type:"number",min:0,className:`${rt} w-24`,value:B.monthlyUsd,onChange:H=>D(ee=>ee.map((ce,C)=>C===_?{...ce,monthlyUsd:Math.max(0,Number(H.target.value)||0)}:ce)),"aria-label":"Monthly USD"}),n.jsx("span",{className:"text-[11px] text-gray-400",children:"/mo"}),n.jsx("button",{type:"button",onClick:()=>D(H=>H.filter((ee,ce)=>ce!==_)),className:"ml-auto text-gray-400 hover:text-red-500","aria-label":"Remove",title:"Remove",children:"✕"})]},_))}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("button",{type:"button",onClick:()=>D(B=>[...B,{kind:G(),monthlyUsd:0}]),className:"rounded border border-gray-300 px-2 py-1 text-[11px] font-medium text-gray-600 hover:bg-gray-100 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800",children:"Add vendor cost"}),n.jsx(Pr,{dirty:U,saving:a,onClick:()=>s({bots:{cost:M}})})]})]}),o.slackDigest&&n.jsxs(or,{title:"Slack bot digest",desc:"Include a review-bot summary block in the Slack digest.",children:[n.jsx($s,{label:"Send the review-bot block",hint:"Adds a deterministic bots section (volume · acted-on · untouched) to the scheduled Slack digest.",checked:L,onChange:Y}),n.jsx(Pr,{dirty:X,saving:a,onClick:()=>s({bots:{slackDigest:L}})})]})]})}function Uj({onClose:e}){const s=yn(),a=h0(!0),o=tk(),i=d=>{o.mutate(d)};x.useEffect(()=>{const d=p=>{p.key==="Escape"&&(p.stopImmediatePropagation(),e())};return window.addEventListener("keydown",d,!0),()=>window.removeEventListener("keydown",d,!0)},[e]);const u=a.data;return n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:e,role:"presentation",children:n.jsxs("div",{className:"flex max-h-[85vh] w-[30rem] max-w-[92vw] flex-col rounded-lg border border-gray-200 bg-white shadow-xl dark:border-gray-700 dark:bg-gray-900",onClick:d=>d.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Settings",children:[n.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[n.jsx("h2",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:"Settings"}),n.jsx("button",{type:"button",onClick:e,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-200","aria-label":"Close (Esc)",title:"Close (Esc)",children:"✕"})]}),n.jsxs("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto px-4 py-3",children:[o.isError&&n.jsx("p",{className:"rounded bg-red-50 px-2 py-1 text-xs text-red-600 dark:bg-red-950 dark:text-red-300",children:o.error.message}),a.isLoading||u==null?n.jsx("p",{className:"py-6 text-center text-xs text-gray-400",children:a.isError?"Settings unavailable.":"Loading…"}):n.jsxs(n.Fragment,{children:[s.teamInsights&&n.jsx(Ej,{settings:u,save:i,saving:o.isPending}),s.teamInsights&&n.jsx(qj,{settings:u,save:i,saving:o.isPending}),s.slackDigest&&n.jsx(Pj,{settings:u,save:i,saving:o.isPending}),s.activityDigest&&n.jsx($j,{settings:u,save:i,saving:o.isPending}),s.issueLinks&&n.jsx(Fj,{settings:u,save:i,saving:o.isPending})]})]})]})})}const Kj={expired:"Your sign-in link expired. Please sign in again.",failed:"We couldn’t complete sign-in with GitHub. Please try again.",error:"Something went wrong reaching GitHub. Please try again in a moment.",unavailable:"That sign-in method isn’t enabled on this deployment."},Hm=()=>n.jsx("svg",{viewBox:"0 0 16 16",width:"18",height:"18",fill:"currentColor","aria-hidden":"true",children:n.jsx("path",{fillRule:"evenodd",d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8Z"})});function Hj(){const[e]=x.useState(()=>{const i=new URLSearchParams(window.location.search).get("auth");return i?Kj[i]??"We couldn’t complete sign-in. Please try again.":null});x.useEffect(()=>{if(!e)return;const i=new URL(window.location.href);i.searchParams.delete("auth"),window.history.replaceState({},"",i.pathname+i.search+i.hash)},[e]);const[s,a]=x.useState({oauth:!0,app:!1,appSlug:""});x.useEffect(()=>{let i=!0;return fetch("/api/auth/providers",{credentials:"include"}).then(u=>u.ok?u.json():null).then(u=>{i&&u&&a(u)}).catch(()=>{}),()=>{i=!1}},[]);const o=s.oauth&&s.app;return n.jsx("div",{className:"flex h-full min-h-screen w-full items-center justify-center bg-gray-950 px-4 text-gray-100",children:n.jsxs("div",{className:"flex w-full max-w-sm flex-col items-center rounded-2xl border border-gray-800 bg-gray-900/40 px-8 py-10 text-center shadow-xl",children:[n.jsx("span",{className:"brand-title text-4xl",title:"Pierre — a play on “PR”",children:"Pierre"}),n.jsx("p",{className:"mt-4 text-sm text-gray-400",children:"Sign in to view your team’s GitHub activity — pull requests, reviews, and what needs your attention."}),e&&n.jsx("div",{role:"alert",className:"mt-6 w-full rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs text-amber-200",children:e}),n.jsxs("div",{className:"mt-7 flex w-full flex-col gap-3",children:[s.oauth&&n.jsxs("a",{href:"/api/auth/login/oauth",className:"inline-flex w-full items-center justify-center gap-2 rounded-lg bg-blue-600 px-4 py-2.5 text-sm font-semibold text-white transition-colors hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-sky-400 focus:ring-offset-2 focus:ring-offset-gray-950",children:[n.jsx(Hm,{}),"Sign in with GitHub"]}),s.app&&n.jsxs("div",{className:"flex w-full flex-col gap-1",children:[n.jsxs("a",{href:"/api/auth/login/app",className:`inline-flex w-full items-center justify-center gap-2 rounded-lg px-4 py-2.5 text-sm font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-sky-400 focus:ring-offset-2 focus:ring-offset-gray-950 ${o?"border border-gray-700 bg-transparent text-gray-100 hover:bg-gray-800":"bg-blue-600 text-white hover:bg-blue-700"}`,children:[n.jsx(Hm,{}),"Sign in with the Pierre GitHub App"]}),n.jsx("span",{className:"px-1 text-[11px] leading-snug text-amber-500/80",children:"Scope may be limited: private org repos only appear once an org admin installs the app on your org — until then you’ll see public repos."})]})]}),o&&n.jsxs("p",{className:"mt-4 text-[11px] leading-relaxed text-gray-500",children:[n.jsx("span",{className:"text-gray-400",children:"GitHub"})," = public repositories, instant, no install. ",n.jsx("span",{className:"text-gray-400",children:"GitHub App"})," = also private repos, but only in orgs that have installed the app."]}),n.jsxs("p",{className:"mt-4 text-xs leading-relaxed text-gray-500",children:["Public repositories work either way, with no install. To watch"," ",n.jsx("strong",{className:"font-semibold text-gray-400",children:"private"})," org repos, sign in with the GitHub App and"," ",s.app&&s.appSlug?n.jsx("a",{className:"underline decoration-gray-600 underline-offset-2 hover:text-gray-300",href:`https://github.com/apps/${s.appSlug}/installations/new`,target:"_blank",rel:"noreferrer",children:"install it"}):"install it"," ","on that org (an org owner may need to approve). Revoke anytime from your GitHub settings."]})]})})}function Wj({notices:e}){if(e.length===0)return null;const s=e.map(a=>a.org).join(", ");return n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 border-b border-amber-400/50 bg-amber-400/10 px-4 py-2 text-xs text-amber-800 dark:text-amber-200",children:[n.jsxs("span",{className:"min-w-0",children:[n.jsxs("strong",{className:"font-semibold",children:["Your GitHub sign-in is no longer authorized for ",s,"."]})," ","Its pull requests, CI checks and comments can’t be synced until you re-authorize (SAML single sign-on)."]}),n.jsx("a",{href:"/api/auth/reconnect",className:"ml-auto whitespace-nowrap rounded border border-amber-500/60 px-2.5 py-0.5 font-medium hover:bg-amber-400/20",children:"Reconnect GitHub"}),n.jsx("span",{className:"w-full text-[11px] text-amber-700/80 dark:text-amber-300/70",children:"Reconnect signs you in again through SSO. If it doesn’t clear, your org may restrict third-party OAuth apps — an org owner has to approve Pierre once."})]})}function Vj({user:e,canSignOut:s,onSignOut:a,onOpenSettings:o}){const[i,u]=x.useState(!1),d=x.useRef(null),p=e.displayName??e.login;Yn(d,()=>u(!1),i),x.useEffect(()=>{if(!i)return;const g=y=>{y.key==="Escape"&&(y.stopPropagation(),u(!1))};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[i]);const m=e.avatarUrl!=null?n.jsx("img",{src:e.avatarUrl,alt:p,width:20,height:20,className:"shrink-0 rounded-full",style:{width:20,height:20}}):n.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-full bg-gray-300 text-[9px] font-semibold text-gray-700 dark:bg-gray-700 dark:text-gray-200",style:{width:20,height:20},children:p.slice(0,2).toUpperCase()});return n.jsxs("div",{ref:d,className:"relative",children:[n.jsxs("button",{type:"button",onClick:()=>u(g=>!g),"aria-haspopup":"menu","aria-expanded":i,className:`flex items-center gap-1.5 rounded px-1.5 py-0.5 text-xs font-medium text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800 ${i?"bg-gray-100 dark:bg-gray-800":""}`,title:e.displayName!=null?`Signed in as ${e.displayName} (@${e.login})`:`Signed in as ${e.login}`,children:[m,n.jsx("span",{className:"max-w-[10rem] truncate",children:p}),n.jsx("span",{"aria-hidden":"true",className:"text-[9px] text-gray-400",children:"▾"})]}),i&&n.jsxs("div",{role:"menu","aria-label":"Account menu",className:"absolute right-0 top-full z-[60] mt-1 w-52 rounded-lg border border-gray-200 bg-white py-1 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[o!=null&&n.jsxs("button",{role:"menuitem",type:"button",onClick:()=>{u(!1),o()},className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-800",children:[n.jsxs("svg",{viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[n.jsx("circle",{cx:"12",cy:"12",r:"3"}),n.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),"Settings"]}),n.jsxs("a",{role:"menuitem",href:Du(e.login),target:"_blank",rel:"noreferrer noopener",onClick:()=>u(!1),className:"flex items-center gap-2 px-3 py-1.5 text-xs text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-800",children:[n.jsx(ph,{size:13}),"Open Profile on GitHub"]}),s&&n.jsxs("button",{role:"menuitem",type:"button",onClick:()=>{u(!1),a()},className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-800",children:[n.jsxs("svg",{viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[n.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),n.jsx("polyline",{points:"16 17 21 12 16 7"}),n.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]}),"Sign Out"]})]})]})}const Qj=["7d","14d","30d","90d","custom"];function du(e,s){if(e.length!==s.length)return!1;const a=new Set(e);return s.every(o=>a.has(o))}function fu(e){if(!e)return null;const s=e.split(",").map(a=>Number.parseInt(a,10)).filter(Number.isFinite);return s.length?s:null}function Gj(){const e=new URLSearchParams(window.location.search),s={},a=e.get("preset");a&&Qj.includes(a)&&(s.preset=a),s.repoIds=fu(e.get("repos")),s.userIds=fu(e.get("users")),e.get("bots")!==null&&(s.excludeBots=e.get("bots")==="1");const o=fu(e.get("allowBots"));o&&(s.allowedBotIds=o);const i=e.get("stale");i==="0"?s.excludeStale=!1:i==="1"&&(s.excludeStale=!0),s.customFrom=e.get("from"),s.customTo=e.get("to");const u=e.get("cats");if(u){const N=new Set(cl);s.categories=u.split(",").filter(I=>N.has(I))}const d=e.get("status");if(d!==null){const N=new Set(ul);s.prStatuses=d.split(",").filter(I=>N.has(I))}const p=e.get("reviews");if(p!==null){const N=new Set(dl);s.reviewStates=p.split(",").filter(I=>N.has(I))}const m=e.get("states");if(m){const N=new Set(Pu);s.derivedStates=m.split(",").filter(I=>N.has(I))}const g=e.get("pr");g&&(s.selectedPrId=Number.parseInt(g,10));const y=e.get("thread");y&&(s.selectedThreadId=Number.parseInt(y,10));const b=e.get("strip");(b==="my_turn"||b==="needs_attention"||b==="all")&&(s.stripFilter=b);const v=e.get("activityRepo");if(v){const N=Number.parseInt(v,10);Number.isFinite(N)&&(s.activityRepoId=N)}return e.get("open")==="1"&&(s.stripCollapsed=!1),s}function Wm(e){var i,u;const s=new URLSearchParams;e.preset!=="14d"&&s.set("preset",e.preset),(i=e.repoIds)!=null&&i.length&&s.set("repos",e.repoIds.join(",")),(u=e.userIds)!=null&&u.length&&s.set("users",e.userIds.join(",")),e.excludeBots&&s.set("bots","1"),e.excludeBots&&e.allowedBotIds.length&&s.set("allowBots",e.allowedBotIds.join(",")),e.excludeStale||s.set("stale","0"),e.preset==="custom"&&e.customFrom&&s.set("from",e.customFrom),e.preset==="custom"&&e.customTo&&s.set("to",e.customTo),du(e.categories,_o)||s.set("cats",e.categories.join(",")),du(e.prStatuses,Do)||s.set("status",e.prStatuses.join(",")),du(e.reviewStates,Oo)||s.set("reviews",e.reviewStates.join(",")),e.derivedStates.length&&s.set("states",e.derivedStates.join(",")),e.selectedPrId&&s.set("pr",String(e.selectedPrId)),e.selectedThreadId&&s.set("thread",String(e.selectedThreadId)),e.stripFilter!=="all"&&s.set("strip",e.stripFilter),e.stripCollapsed||s.set("open","1"),Oe.getState().activeTab==="activity"&&(s.set("view","activity"),typeof e.activityRepoId=="number"&&s.set("activityRepo",String(e.activityRepoId)));const a=s.toString(),o=`${window.location.pathname}${a?`?${a}`:""}`;o!==window.location.pathname+window.location.search&&window.history.replaceState(null,"",o)}const b0="pierre:filterBarState";function Yj(){try{const e=localStorage.getItem(b0);if(!e)return null;const s=JSON.parse(e);return s&&typeof s=="object"?Go(s):null}catch{return null}}function Xj(e){try{localStorage.setItem(b0,JSON.stringify(gu(e)))}catch{}}function Jj(){const e=x.useRef(!1);x.useEffect(()=>{if(!e.current){if(window.location.search.length>1)te.getState().hydrate(Gj()),new URLSearchParams(window.location.search).get("view")==="activity"&&Oe.getState().setActiveTab("activity");else{const i=Gx(),u=i?Go(i.state):Yj();u&&te.getState().hydrate(u),Oe.getState().setActiveTab("activity")}e.current=!0}const s=te.subscribe(o=>{Wm(o),Xj(o)}),a=Oe.subscribe(()=>{Wm(te.getState())});return()=>{s(),a()}},[])}function Vm(e){if(!(e instanceof HTMLElement))return!1;const s=e.tagName;return s==="INPUT"||s==="TEXTAREA"||e.isContentEditable}function Zj(){const{data:e}=nh();x.useEffect(()=>{const s=a=>{var m;const{selectedPrId:o,selectPr:i,clearSelection:u}=te.getState(),d=Oe.getState(),p=d.activeTab==="timeline";if(a.key==="Escape"){Vm(a.target)?a.target.blur():p?u():d.showTimeline();return}if(!Vm(a.target)){if(a.key==="/"){a.preventDefault(),(m=document.getElementById("add-repo-input"))==null||m.focus();return}if(a.key==="i"){d.showActivity();return}if(p&&(a.key==="j"||a.key==="k")){const g=[...(e==null?void 0:e.prs)??[]].sort((N,I)=>I.openedAt.localeCompare(N.openedAt));if(g.length===0)return;const y=g.findIndex(N=>N.id===o);let b;y===-1?b=0:b=a.key==="j"?y+1:y-1,b=Math.max(0,Math.min(g.length-1,b));const v=g[b];v&&i(v.id)}}};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e])}function eN(){const e=Be();x.useEffect(()=>{let s=null;const a=()=>{const u=new Map,d=(p,m)=>{const g=u.get(p);(!g||m>g)&&u.set(p,m)};for(const[,p]of e.getQueriesData({queryKey:["timeline"]}))for(const m of(p==null?void 0:p.prs)??[])d(m.id,m.updatedAt);for(const[,p]of e.getQueriesData({queryKey:["open-prs"]}))for(const m of(p==null?void 0:p.prs)??[])d(m.id,m.updatedAt);for(const[p,m]of u){const g=e.getQueryData(["pr",p]);if(!g||g.updatedAt>=m)continue;const y=e.getQueryState(["pr",p]);if(!(y&&y.fetchStatus!=="idle")){e.invalidateQueries({queryKey:["pr",p]});for(const b of g.threads??[])e.invalidateQueries({queryKey:["thread",b.id]})}}},o=()=>{s||(s=setTimeout(()=>{s=null,a()},300))};o();const i=e.getQueryCache().subscribe(u=>{const d=u.query.queryKey[0];(d==="timeline"||d==="open-prs")&&o()});return()=>{s&&clearTimeout(s),i()}},[e])}function tN(e){const{data:s}=sh(),a=x.useRef(null);x.useEffect(()=>{if(!s)return;const o=new Set;for(const v of s.awaitingReview)o.add(`r:${v.prId}`);for(const v of s.yourPrs)o.add(`p:${v.prId}`);for(const v of s.approvedPrs??[])o.add(`a:${v.prId}`);for(const v of s.threadsAwaiting)o.add(`t:${v.threadId}`);for(const v of s.watchedRepoPrs)o.add(`w:${v.prId}`);const i=a.current;if(a.current=o,i==null||!e||typeof Notification>"u"||Notification.permission!=="granted")return;const u=[...o].filter(v=>!i.has(v));if(u.length===0)return;const d=u.filter(v=>v.startsWith("r:")).length,p=u.filter(v=>v.startsWith("t:")).length,m=u.filter(v=>v.startsWith("p:")).length,g=u.filter(v=>v.startsWith("a:")).length,y=u.filter(v=>v.startsWith("w:")).length,b=[];d&&b.push(`${d} review${d===1?"":"s"} requested`),p&&b.push(`${p} thread${p===1?"":"s"} awaiting you`),m&&b.push(`${m} of your PRs active`),g&&b.push(`${g} of your PRs approved`),y&&b.push(`${y} new in watched repos`);try{const v=new Notification(`Pierre — ${u.length} new in My Turn`,{body:b.join(" · "),tag:"pierre-my-turn"});v.onclick=()=>{window.focus(),v.close()}}catch{}},[s,e])}const pu="";function nN(e){return/^G-[A-Z0-9]{6,}$/i.test(e)&&e!=="G-XXXXXXXXXX"}let Tu=!1;function rN(){if(Tu||typeof window>"u"||!nN(pu))return;Tu=!0;const e=document.createElement("script");e.async=!0,e.src=`https://www.googletagmanager.com/gtag/js?id=${pu}`,document.head.appendChild(e),window.dataLayer=window.dataLayer||[],window.gtag=function(){window.dataLayer.push(arguments)},window.gtag("js",new Date),window.gtag("config",pu,{send_page_view:!1})}function sN(e=window.location.pathname){!Tu||!window.gtag||window.gtag("event","page_view",{page_path:e,page_location:`${window.location.origin}${e}`,page_title:document.title})}function aN(){const[e,s]=x.useState(()=>(localStorage.getItem("theme")??"dark")!=="light");return x.useEffect(()=>{document.documentElement.classList.toggle("dark",e),localStorage.setItem("theme",e?"dark":"light")},[e]),[e,()=>s(a=>!a)]}function lN(){var F,K,ae;const e=_u();Jj(),Zj(),eN();const[s,a]=aN(),[o,i]=x.useState(!1),[u,d]=x.useState(!1),p=ek(),[m,g]=x0(),y=typeof window<"u"&&"Notification"in window;tN(m&&y);const b=()=>{if(y){if(m){g(!1);return}Notification.permission==="granted"?g(!0):Notification.permission!=="denied"&&Notification.requestPermission().then(ne=>g(ne==="granted"))}},v=((F=e.data)==null?void 0:F.deploymentMode)==="cloud",N=((K=e.data)==null?void 0:K.user)??null,I=()=>{Oe.getState().clear(),ge.logout().finally(()=>window.location.assign("/"))},P=te(ne=>ne.selectedPrId),E=te(ne=>ne.selectedThreadId),w=Oe(ne=>ne.activeTab),R=Oe(ne=>ne.tabs),S=w!=="timeline"&&w!=="activity"?R.find(ne=>ne.key===w)??null:null,j=w==="activity",T=(S==null?void 0:S.kind)==="pr-detail"?S.prId:null,M=(S==null?void 0:S.kind)==="metrics-detail",D=(S==null?void 0:S.kind)==="bot-prs",U=(S==null?void 0:S.kind)==="pr-focus"?{kind:"isolate",prId:S.prId}:null,G=T!=null||j||M||D,L=P!=null&&!G,[Y,X]=s0("pierre:detailPaneHeight",384),B=x.useRef(null),_=x.useRef(null),H=x.useRef(null);x.useEffect(()=>{for(const ne of[_.current,B.current])ne&&(G?ne.setAttribute("inert",""):ne.removeAttribute("inert"))},[G]),x.useEffect(()=>{const ne=()=>Oe.getState().navigateBack();return window.addEventListener("popstate",ne),()=>window.removeEventListener("popstate",ne)},[]),x.useEffect(()=>{window.dispatchEvent(new Event("resize"))},[L]);const ee=ne=>{var Pe;H.current={startY:ne.clientY,startH:((Pe=B.current)==null?void 0:Pe.offsetHeight)??Y},ne.currentTarget.setPointerCapture(ne.pointerId)},ce=ne=>{const Pe=H.current;if(!Pe||!B.current)return;const se=window.innerHeight*.7,Z=Math.min(Math.max(Pe.startH+(Pe.startY-ne.clientY),160),se);B.current.style.height=`${Z}px`,window.dispatchEvent(new Event("resize"))},C=ne=>{!H.current||!B.current||(H.current=null,ne.currentTarget.releasePointerCapture(ne.pointerId),X(B.current.offsetHeight))};return x.useEffect(()=>{if(!v)return;const ne=()=>{ge.me().catch(()=>{})},Pe=window.setInterval(ne,180*1e3);return()=>window.clearInterval(Pe)},[v]),x.useEffect(()=>{v&&(rN(),sN())},[v]),e.error instanceof Gt&&e.error.status===401?n.jsx(Hj,{}):e.isLoading&&!e.data?n.jsx("div",{className:"flex h-full min-h-screen items-center justify-center bg-gray-950",children:n.jsx("span",{className:"brand-title text-4xl text-gray-100",children:"Pierre"})}):n.jsxs("div",{className:"flex h-full flex-col",children:[n.jsx(Wj,{notices:((ae=e.data)==null?void 0:ae.authNotices)??[]}),n.jsxs("header",{className:"flex items-center gap-3 border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[n.jsx("h1",{className:"brand-title",title:"Pierre — a play on “PR”",children:"Pierre"}),n.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[n.jsx(Sj,{}),n.jsx(Nj,{}),y&&n.jsx("button",{type:"button",onClick:b,"aria-pressed":m,className:`rounded border px-2 py-0.5 text-xs hover:border-gray-400 dark:hover:border-gray-500 ${m?"border-blue-400 text-blue-600 dark:border-blue-600 dark:text-blue-400":"border-gray-300 dark:border-gray-700"}`,title:m?"Notifications on — alerts when a new item enters your My Turn. Click to turn off.":"Turn on browser notifications for new My Turn items","aria-label":"Toggle My Turn notifications",children:n.jsxs("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:m?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[n.jsx("path",{d:"M18 8a6 6 0 0 0-12 0c0 7-3 9-3 9h18s-3-2-3-9"}),n.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})}),n.jsx("button",{type:"button",onClick:()=>i(!0),className:"rounded border border-gray-300 px-2 py-0.5 text-xs font-semibold hover:border-gray-400 dark:border-gray-700 dark:hover:border-gray-500",title:"Help — what is Pierre and how to use it","aria-label":"Help",children:"?"}),n.jsx("button",{type:"button",onClick:a,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",title:"Toggle dark mode",children:s?"☀":"☾"}),N!=null&&n.jsx(Vj,{user:N,canSignOut:v,onSignOut:I,onOpenSettings:p?()=>d(!0):null})]})]}),o&&n.jsx(Rj,{onClose:()=>i(!1)}),u&&n.jsx(Uj,{onClose:()=>d(!1)}),n.jsx(Cj,{}),n.jsx(iy,{}),n.jsx(py,{}),n.jsx(by,{}),n.jsxs("main",{className:"relative flex min-h-0 flex-1 flex-col",children:[n.jsx("section",{ref:_,className:"min-h-0 flex-1 overflow-hidden",children:U==null?n.jsx(vm,{},"board"):n.jsx(vm,{mode:U},`focus:${U.prId}`)}),L&&n.jsxs(n.Fragment,{children:[n.jsx("div",{role:"separator","aria-orientation":"horizontal","aria-label":"Resize detail pane",onPointerDown:ee,onPointerMove:ce,onPointerUp:C,title:"Drag to resize",className:"h-1 shrink-0 cursor-row-resize bg-gray-200 transition-colors hover:bg-blue-400 dark:bg-gray-800 dark:hover:bg-blue-500"}),n.jsx("section",{ref:B,style:{height:Y},className:"shrink-0 overflow-auto",children:n.jsx(fj,{})})]}),T!=null&&n.jsx("div",{"data-testid":"pinned-pr-overlay",className:"absolute inset-0 z-20 bg-white dark:bg-gray-950",children:n.jsx(Nh,{prId:T,selectedThreadId:P===T?E:null},T)}),j&&n.jsx("div",{"data-testid":"activity-overlay",className:"absolute inset-0 z-20 overflow-hidden bg-white dark:bg-gray-950",children:n.jsx(Kk,{})}),M&&n.jsx("div",{"data-testid":"metrics-overlay",className:"absolute inset-0 z-20 overflow-auto bg-white dark:bg-gray-950",children:n.jsx(ej,{})}),D&&n.jsx("div",{"data-testid":"bot-prs-overlay",className:"absolute inset-0 z-20 overflow-auto bg-white dark:bg-gray-950",children:n.jsx(dj,{})})]}),n.jsx(vj,{})]})}function di(e){return new Promise((s,a)=>{e.oncomplete=e.onsuccess=()=>s(e.result),e.onabort=e.onerror=()=>a(e.error)})}function oN(e,s){let a;const o=()=>{if(a)return a;const i=indexedDB.open(e);return i.onupgradeneeded=()=>i.result.createObjectStore(s),a=di(i),a.then(u=>{u.onclose=()=>a=void 0},()=>{}),a};return(i,u)=>o().then(d=>u(d.transaction(s,i).objectStore(s)))}let mu;function Zu(){return mu||(mu=oN("keyval-store","keyval")),mu}function iN(e,s=Zu()){return s("readonly",a=>di(a.get(e)))}function cN(e,s,a=Zu()){return a("readwrite",o=>(o.put(s,e),di(o.transaction)))}function uN(e,s=Zu()){return s("readwrite",a=>(a.delete(e),di(a.transaction)))}const dN=Zg({storage:{getItem:e=>iN(e).then(s=>s??null),setItem:(e,s)=>cN(e,s),removeItem:e=>uN(e)},key:"pierre-query-cache",throttleTime:1e3}),fN=new ex({defaultOptions:{queries:{staleTime:3e4,refetchOnWindowFocus:!1,retry:1}}});var Eo,Qm;(Qm=(Eo=navigator.storage)==null?void 0:Eo.persist)==null||Qm.call(Eo);new URLSearchParams(window.location.search).has("perf")&&Eu(()=>import("./perfProbe-Da13EhTE.js"),[]).then(e=>e.startPerfProbe());const w0=document.getElementById("root");if(!w0)throw new Error("#root not found");const pN=1e3*60*60*24*7;mx.createRoot(w0).render(n.jsx(x.StrictMode,{children:n.jsx(tx,{client:fN,persistOptions:{persister:dN,maxAge:pN,buster:"pierre-detail-v3",dehydrateOptions:{shouldDehydrateQuery:e=>{const s=e.queryKey[0];return(s==="pr"||s==="thread"||s==="pr-files")&&e.state.status==="success"}}},children:n.jsx(lN,{})})}));export{kh as A,UN as B,yN as C,yn as D,CN as E,Pv as F,jN as G,qN as H,NN as I,IN as J,zN as K,BN as L,cr as M,p0 as R,Gt as a,vN as b,uv as c,dv as d,ei as e,ge as f,Wx as g,bN as h,wN as i,PN as j,AN as k,SN as l,EN as m,TN as n,DN as o,$N as p,kN as q,St as r,MN as s,FN as t,KN as u,LN as v,te as w,_N as x,RN as y,ON as z};
|
|
53
|
+
*-svc`,onChange:B=>I(B.target.value)})}),n.jsx(Pr,{dirty:E,saving:a,onClick:()=>s({bots:{inhouseDetect:u,autoTagHighConfidence:p,deepDetect:g,aiTiebreak:b,loginAllowlist:P}})})]}),n.jsxs(or,{title:"Pierre attribution",desc:"How Pierre's own Claude reviews are stamped when posted.",children:[n.jsx($s,{label:"Tag Pierre reviews",hint:"Append a hidden marker so Pierre-posted reviews are recognised as its own (verbatim vs curated).",checked:w,onChange:R}),n.jsx($s,{label:"Visible footer",hint:'Also append a visible "Reviewed with Pierre + Claude" footer to posted reviews.',checked:S,onChange:j}),n.jsx(Pr,{dirty:T,saving:a,onClick:()=>s({bots:{tagPierreReviews:w,pierreFooter:S}})})]}),n.jsx(zj,{settings:e,save:s,saving:a}),n.jsxs(or,{title:"Per-vendor cost",desc:"Optional monthly spend per reviewer, used to show cost-per-acted-on in the Bot ROI panel. Stays on your account.",children:[M.length===0?n.jsx("p",{className:"text-[11px] text-gray-400",children:"No costs entered."}):n.jsx("ul",{className:"space-y-1.5",children:M.map((B,_)=>n.jsxs("li",{className:"flex items-center gap-2",children:[n.jsx("select",{className:`${rt} w-auto`,value:B.kind,onChange:H=>D(ee=>ee.map((ce,C)=>C===_?{...ce,kind:H.target.value}:ce)),"aria-label":"Vendor",children:Km.map(H=>n.jsx("option",{value:H,children:an(H).label},H))}),n.jsx("span",{className:"text-[11px] text-gray-400",children:"$"}),n.jsx("input",{type:"number",min:0,className:`${rt} w-24`,value:B.monthlyUsd,onChange:H=>D(ee=>ee.map((ce,C)=>C===_?{...ce,monthlyUsd:Math.max(0,Number(H.target.value)||0)}:ce)),"aria-label":"Monthly USD"}),n.jsx("span",{className:"text-[11px] text-gray-400",children:"/mo"}),n.jsx("button",{type:"button",onClick:()=>D(H=>H.filter((ee,ce)=>ce!==_)),className:"ml-auto text-gray-400 hover:text-red-500","aria-label":"Remove",title:"Remove",children:"✕"})]},_))}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("button",{type:"button",onClick:()=>D(B=>[...B,{kind:G(),monthlyUsd:0}]),className:"rounded border border-gray-300 px-2 py-1 text-[11px] font-medium text-gray-600 hover:bg-gray-100 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800",children:"Add vendor cost"}),n.jsx(Pr,{dirty:U,saving:a,onClick:()=>s({bots:{cost:M}})})]})]}),o.slackDigest&&n.jsxs(or,{title:"Slack bot digest",desc:"Include a review-bot summary block in the Slack digest.",children:[n.jsx($s,{label:"Send the review-bot block",hint:"Adds a deterministic bots section (volume · acted-on · untouched) to the scheduled Slack digest.",checked:L,onChange:Y}),n.jsx(Pr,{dirty:X,saving:a,onClick:()=>s({bots:{slackDigest:L}})})]})]})}function Uj({onClose:e}){const s=yn(),a=h0(!0),o=tk(),i=d=>{o.mutate(d)};x.useEffect(()=>{const d=p=>{p.key==="Escape"&&(p.stopImmediatePropagation(),e())};return window.addEventListener("keydown",d,!0),()=>window.removeEventListener("keydown",d,!0)},[e]);const u=a.data;return n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:e,role:"presentation",children:n.jsxs("div",{className:"flex max-h-[85vh] w-[30rem] max-w-[92vw] flex-col rounded-lg border border-gray-200 bg-white shadow-xl dark:border-gray-700 dark:bg-gray-900",onClick:d=>d.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Settings",children:[n.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[n.jsx("h2",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:"Settings"}),n.jsx("button",{type:"button",onClick:e,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-200","aria-label":"Close (Esc)",title:"Close (Esc)",children:"✕"})]}),n.jsxs("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto px-4 py-3",children:[o.isError&&n.jsx("p",{className:"rounded bg-red-50 px-2 py-1 text-xs text-red-600 dark:bg-red-950 dark:text-red-300",children:o.error.message}),a.isLoading||u==null?n.jsx("p",{className:"py-6 text-center text-xs text-gray-400",children:a.isError?"Settings unavailable.":"Loading…"}):n.jsxs(n.Fragment,{children:[s.teamInsights&&n.jsx(Ej,{settings:u,save:i,saving:o.isPending}),s.teamInsights&&n.jsx(qj,{settings:u,save:i,saving:o.isPending}),s.slackDigest&&n.jsx(Pj,{settings:u,save:i,saving:o.isPending}),s.activityDigest&&n.jsx($j,{settings:u,save:i,saving:o.isPending}),s.issueLinks&&n.jsx(Fj,{settings:u,save:i,saving:o.isPending})]})]})]})})}const Kj={expired:"Your sign-in link expired. Please sign in again.",failed:"We couldn’t complete sign-in with GitHub. Please try again.",error:"Something went wrong reaching GitHub. Please try again in a moment.",unavailable:"That sign-in method isn’t enabled on this deployment."},Hm=()=>n.jsx("svg",{viewBox:"0 0 16 16",width:"18",height:"18",fill:"currentColor","aria-hidden":"true",children:n.jsx("path",{fillRule:"evenodd",d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8Z"})});function Hj(){const[e]=x.useState(()=>{const i=new URLSearchParams(window.location.search).get("auth");return i?Kj[i]??"We couldn’t complete sign-in. Please try again.":null});x.useEffect(()=>{if(!e)return;const i=new URL(window.location.href);i.searchParams.delete("auth"),window.history.replaceState({},"",i.pathname+i.search+i.hash)},[e]);const[s,a]=x.useState({oauth:!0,app:!1,appSlug:""});x.useEffect(()=>{let i=!0;return fetch("/api/auth/providers",{credentials:"include"}).then(u=>u.ok?u.json():null).then(u=>{i&&u&&a(u)}).catch(()=>{}),()=>{i=!1}},[]);const o=s.oauth&&s.app;return n.jsx("div",{className:"flex h-full min-h-screen w-full items-center justify-center bg-gray-950 px-4 text-gray-100",children:n.jsxs("div",{className:"flex w-full max-w-sm flex-col items-center rounded-2xl border border-gray-800 bg-gray-900/40 px-8 py-10 text-center shadow-xl",children:[n.jsx("span",{className:"brand-title text-4xl",title:"Pierre — a play on “PR”",children:"Pierre"}),n.jsx("p",{className:"mt-4 text-sm text-gray-400",children:"Sign in to view your team’s GitHub activity — pull requests, reviews, and what needs your attention."}),e&&n.jsx("div",{role:"alert",className:"mt-6 w-full rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs text-amber-200",children:e}),n.jsxs("div",{className:"mt-7 flex w-full flex-col gap-3",children:[s.oauth&&n.jsxs("a",{href:"/api/auth/login/oauth",className:"inline-flex w-full items-center justify-center gap-2 rounded-lg bg-blue-600 px-4 py-2.5 text-sm font-semibold text-white transition-colors hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-sky-400 focus:ring-offset-2 focus:ring-offset-gray-950",children:[n.jsx(Hm,{}),"Sign in with GitHub"]}),s.app&&n.jsxs("div",{className:"flex w-full flex-col gap-1",children:[n.jsxs("a",{href:"/api/auth/login/app",className:`inline-flex w-full items-center justify-center gap-2 rounded-lg px-4 py-2.5 text-sm font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-sky-400 focus:ring-offset-2 focus:ring-offset-gray-950 ${o?"border border-gray-700 bg-transparent text-gray-100 hover:bg-gray-800":"bg-blue-600 text-white hover:bg-blue-700"}`,children:[n.jsx(Hm,{}),"Sign in with the Pierre GitHub App"]}),n.jsx("span",{className:"px-1 text-[11px] leading-snug text-amber-500/80",children:"Scope may be limited: private org repos only appear once an org admin installs the app on your org — until then you’ll see public repos."})]})]}),o&&n.jsxs("p",{className:"mt-4 text-[11px] leading-relaxed text-gray-500",children:[n.jsx("span",{className:"text-gray-400",children:"GitHub"})," = public repositories, instant, no install. ",n.jsx("span",{className:"text-gray-400",children:"GitHub App"})," = also private repos, but only in orgs that have installed the app."]}),n.jsxs("p",{className:"mt-4 text-xs leading-relaxed text-gray-500",children:["Public repositories work either way, with no install. To watch"," ",n.jsx("strong",{className:"font-semibold text-gray-400",children:"private"})," org repos, sign in with the GitHub App and"," ",s.app&&s.appSlug?n.jsx("a",{className:"underline decoration-gray-600 underline-offset-2 hover:text-gray-300",href:`https://github.com/apps/${s.appSlug}/installations/new`,target:"_blank",rel:"noreferrer",children:"install it"}):"install it"," ","on that org (an org owner may need to approve). Revoke anytime from your GitHub settings."]})]})})}function Wj({notices:e}){if(e.length===0)return null;const s=e.map(a=>a.org).join(", ");return n.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 border-b border-amber-400/50 bg-amber-400/10 px-4 py-2 text-xs text-amber-800 dark:text-amber-200",children:[n.jsxs("span",{className:"min-w-0",children:[n.jsxs("strong",{className:"font-semibold",children:["Your GitHub sign-in is no longer authorized for ",s,"."]})," ","Its pull requests, CI checks and comments can’t be synced until you re-authorize (SAML single sign-on)."]}),n.jsx("a",{href:"/api/auth/reconnect",className:"ml-auto whitespace-nowrap rounded border border-amber-500/60 px-2.5 py-0.5 font-medium hover:bg-amber-400/20",children:"Reconnect GitHub"}),n.jsx("span",{className:"w-full text-[11px] text-amber-700/80 dark:text-amber-300/70",children:"Reconnect signs you in again through SSO. If it doesn’t clear, your org may restrict third-party OAuth apps — an org owner has to approve Pierre once."})]})}function Vj({user:e,canSignOut:s,onSignOut:a,onOpenSettings:o}){const[i,u]=x.useState(!1),d=x.useRef(null),p=e.displayName??e.login;Yn(d,()=>u(!1),i),x.useEffect(()=>{if(!i)return;const g=y=>{y.key==="Escape"&&(y.stopPropagation(),u(!1))};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[i]);const m=e.avatarUrl!=null?n.jsx("img",{src:e.avatarUrl,alt:p,width:20,height:20,className:"shrink-0 rounded-full",style:{width:20,height:20}}):n.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-full bg-gray-300 text-[9px] font-semibold text-gray-700 dark:bg-gray-700 dark:text-gray-200",style:{width:20,height:20},children:p.slice(0,2).toUpperCase()});return n.jsxs("div",{ref:d,className:"relative",children:[n.jsxs("button",{type:"button",onClick:()=>u(g=>!g),"aria-haspopup":"menu","aria-expanded":i,className:`flex items-center gap-1.5 rounded px-1.5 py-0.5 text-xs font-medium text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800 ${i?"bg-gray-100 dark:bg-gray-800":""}`,title:e.displayName!=null?`Signed in as ${e.displayName} (@${e.login})`:`Signed in as ${e.login}`,children:[m,n.jsx("span",{className:"max-w-[10rem] truncate",children:p}),n.jsx("span",{"aria-hidden":"true",className:"text-[9px] text-gray-400",children:"▾"})]}),i&&n.jsxs("div",{role:"menu","aria-label":"Account menu",className:"absolute right-0 top-full z-[60] mt-1 w-52 rounded-lg border border-gray-200 bg-white py-1 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[o!=null&&n.jsxs("button",{role:"menuitem",type:"button",onClick:()=>{u(!1),o()},className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-800",children:[n.jsxs("svg",{viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[n.jsx("circle",{cx:"12",cy:"12",r:"3"}),n.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),"Settings"]}),n.jsxs("a",{role:"menuitem",href:Du(e.login),target:"_blank",rel:"noreferrer noopener",onClick:()=>u(!1),className:"flex items-center gap-2 px-3 py-1.5 text-xs text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-800",children:[n.jsx(ph,{size:13}),"Open Profile on GitHub"]}),s&&n.jsxs("button",{role:"menuitem",type:"button",onClick:()=>{u(!1),a()},className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-800",children:[n.jsxs("svg",{viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[n.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),n.jsx("polyline",{points:"16 17 21 12 16 7"}),n.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]}),"Sign Out"]})]})]})}const Qj=["7d","14d","30d","90d","custom"];function du(e,s){if(e.length!==s.length)return!1;const a=new Set(e);return s.every(o=>a.has(o))}function fu(e){if(!e)return null;const s=e.split(",").map(a=>Number.parseInt(a,10)).filter(Number.isFinite);return s.length?s:null}function Gj(){const e=new URLSearchParams(window.location.search),s={},a=e.get("preset");a&&Qj.includes(a)&&(s.preset=a),s.repoIds=fu(e.get("repos")),s.userIds=fu(e.get("users")),e.get("bots")!==null&&(s.excludeBots=e.get("bots")==="1");const o=fu(e.get("allowBots"));o&&(s.allowedBotIds=o);const i=e.get("stale");i==="0"?s.excludeStale=!1:i==="1"&&(s.excludeStale=!0),s.customFrom=e.get("from"),s.customTo=e.get("to");const u=e.get("cats");if(u){const N=new Set(cl);s.categories=u.split(",").filter(I=>N.has(I))}const d=e.get("status");if(d!==null){const N=new Set(ul);s.prStatuses=d.split(",").filter(I=>N.has(I))}const p=e.get("reviews");if(p!==null){const N=new Set(dl);s.reviewStates=p.split(",").filter(I=>N.has(I))}const m=e.get("states");if(m){const N=new Set(Pu);s.derivedStates=m.split(",").filter(I=>N.has(I))}const g=e.get("pr");g&&(s.selectedPrId=Number.parseInt(g,10));const y=e.get("thread");y&&(s.selectedThreadId=Number.parseInt(y,10));const b=e.get("strip");(b==="my_turn"||b==="needs_attention"||b==="all")&&(s.stripFilter=b);const v=e.get("activityRepo");if(v){const N=Number.parseInt(v,10);Number.isFinite(N)&&(s.activityRepoId=N)}return e.get("open")==="1"&&(s.stripCollapsed=!1),s}function Wm(e){var i,u;const s=new URLSearchParams;e.preset!=="14d"&&s.set("preset",e.preset),(i=e.repoIds)!=null&&i.length&&s.set("repos",e.repoIds.join(",")),(u=e.userIds)!=null&&u.length&&s.set("users",e.userIds.join(",")),e.excludeBots&&s.set("bots","1"),e.excludeBots&&e.allowedBotIds.length&&s.set("allowBots",e.allowedBotIds.join(",")),e.excludeStale||s.set("stale","0"),e.preset==="custom"&&e.customFrom&&s.set("from",e.customFrom),e.preset==="custom"&&e.customTo&&s.set("to",e.customTo),du(e.categories,_o)||s.set("cats",e.categories.join(",")),du(e.prStatuses,Do)||s.set("status",e.prStatuses.join(",")),du(e.reviewStates,Oo)||s.set("reviews",e.reviewStates.join(",")),e.derivedStates.length&&s.set("states",e.derivedStates.join(",")),e.selectedPrId&&s.set("pr",String(e.selectedPrId)),e.selectedThreadId&&s.set("thread",String(e.selectedThreadId)),e.stripFilter!=="all"&&s.set("strip",e.stripFilter),e.stripCollapsed||s.set("open","1"),Oe.getState().activeTab==="activity"&&(s.set("view","activity"),typeof e.activityRepoId=="number"&&s.set("activityRepo",String(e.activityRepoId)));const a=s.toString(),o=`${window.location.pathname}${a?`?${a}`:""}`;o!==window.location.pathname+window.location.search&&window.history.replaceState(null,"",o)}const b0="pierre:filterBarState";function Yj(){try{const e=localStorage.getItem(b0);if(!e)return null;const s=JSON.parse(e);return s&&typeof s=="object"?Go(s):null}catch{return null}}function Xj(e){try{localStorage.setItem(b0,JSON.stringify(gu(e)))}catch{}}function Jj(){const e=x.useRef(!1);x.useEffect(()=>{if(!e.current){if(window.location.search.length>1)te.getState().hydrate(Gj()),new URLSearchParams(window.location.search).get("view")==="activity"&&Oe.getState().setActiveTab("activity");else{const i=Gx(),u=i?Go(i.state):Yj();u&&te.getState().hydrate(u),Oe.getState().setActiveTab("activity")}e.current=!0}const s=te.subscribe(o=>{Wm(o),Xj(o)}),a=Oe.subscribe(()=>{Wm(te.getState())});return()=>{s(),a()}},[])}function Vm(e){if(!(e instanceof HTMLElement))return!1;const s=e.tagName;return s==="INPUT"||s==="TEXTAREA"||e.isContentEditable}function Zj(){const{data:e}=nh();x.useEffect(()=>{const s=a=>{var m;const{selectedPrId:o,selectPr:i,clearSelection:u}=te.getState(),d=Oe.getState(),p=d.activeTab==="timeline";if(a.key==="Escape"){Vm(a.target)?a.target.blur():p?u():d.showTimeline();return}if(!Vm(a.target)){if(a.key==="/"){a.preventDefault(),(m=document.getElementById("add-repo-input"))==null||m.focus();return}if(a.key==="i"){d.showActivity();return}if(p&&(a.key==="j"||a.key==="k")){const g=[...(e==null?void 0:e.prs)??[]].sort((N,I)=>I.openedAt.localeCompare(N.openedAt));if(g.length===0)return;const y=g.findIndex(N=>N.id===o);let b;y===-1?b=0:b=a.key==="j"?y+1:y-1,b=Math.max(0,Math.min(g.length-1,b));const v=g[b];v&&i(v.id)}}};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e])}function eN(){const e=Be();x.useEffect(()=>{let s=null;const a=()=>{const u=new Map,d=(p,m)=>{const g=u.get(p);(!g||m>g)&&u.set(p,m)};for(const[,p]of e.getQueriesData({queryKey:["timeline"]}))for(const m of(p==null?void 0:p.prs)??[])d(m.id,m.updatedAt);for(const[,p]of e.getQueriesData({queryKey:["open-prs"]}))for(const m of(p==null?void 0:p.prs)??[])d(m.id,m.updatedAt);for(const[p,m]of u){const g=e.getQueryData(["pr",p]);if(!g||g.updatedAt>=m)continue;const y=e.getQueryState(["pr",p]);if(!(y&&y.fetchStatus!=="idle")){e.invalidateQueries({queryKey:["pr",p]});for(const b of g.threads??[])e.invalidateQueries({queryKey:["thread",b.id]})}}},o=()=>{s||(s=setTimeout(()=>{s=null,a()},300))};o();const i=e.getQueryCache().subscribe(u=>{const d=u.query.queryKey[0];(d==="timeline"||d==="open-prs")&&o()});return()=>{s&&clearTimeout(s),i()}},[e])}function tN(e){const{data:s}=sh(),a=x.useRef(null);x.useEffect(()=>{if(!s)return;const o=new Set;for(const v of s.awaitingReview)o.add(`r:${v.prId}`);for(const v of s.yourPrs)o.add(`p:${v.prId}`);for(const v of s.approvedPrs??[])o.add(`a:${v.prId}`);for(const v of s.threadsAwaiting)o.add(`t:${v.threadId}`);for(const v of s.watchedRepoPrs)o.add(`w:${v.prId}`);const i=a.current;if(a.current=o,i==null||!e||typeof Notification>"u"||Notification.permission!=="granted")return;const u=[...o].filter(v=>!i.has(v));if(u.length===0)return;const d=u.filter(v=>v.startsWith("r:")).length,p=u.filter(v=>v.startsWith("t:")).length,m=u.filter(v=>v.startsWith("p:")).length,g=u.filter(v=>v.startsWith("a:")).length,y=u.filter(v=>v.startsWith("w:")).length,b=[];d&&b.push(`${d} review${d===1?"":"s"} requested`),p&&b.push(`${p} thread${p===1?"":"s"} awaiting you`),m&&b.push(`${m} of your PRs active`),g&&b.push(`${g} of your PRs approved`),y&&b.push(`${y} new in watched repos`);try{const v=new Notification(`Pierre — ${u.length} new in My Turn`,{body:b.join(" · "),tag:"pierre-my-turn"});v.onclick=()=>{window.focus(),v.close()}}catch{}},[s,e])}const pu="";function nN(e){return/^G-[A-Z0-9]{6,}$/i.test(e)&&e!=="G-XXXXXXXXXX"}let Tu=!1;function rN(){if(Tu||typeof window>"u"||!nN(pu))return;Tu=!0;const e=document.createElement("script");e.async=!0,e.src=`https://www.googletagmanager.com/gtag/js?id=${pu}`,document.head.appendChild(e),window.dataLayer=window.dataLayer||[],window.gtag=function(){window.dataLayer.push(arguments)},window.gtag("js",new Date),window.gtag("config",pu,{send_page_view:!1})}function sN(e=window.location.pathname){!Tu||!window.gtag||window.gtag("event","page_view",{page_path:e,page_location:`${window.location.origin}${e}`,page_title:document.title})}function aN(){const[e,s]=x.useState(()=>(localStorage.getItem("theme")??"dark")!=="light");return x.useEffect(()=>{document.documentElement.classList.toggle("dark",e),localStorage.setItem("theme",e?"dark":"light")},[e]),[e,()=>s(a=>!a)]}function lN(){var F,K,ae;const e=_u();Jj(),Zj(),eN();const[s,a]=aN(),[o,i]=x.useState(!1),[u,d]=x.useState(!1),p=ek(),[m,g]=x0(),y=typeof window<"u"&&"Notification"in window;tN(m&&y);const b=()=>{if(y){if(m){g(!1);return}Notification.permission==="granted"?g(!0):Notification.permission!=="denied"&&Notification.requestPermission().then(ne=>g(ne==="granted"))}},v=((F=e.data)==null?void 0:F.deploymentMode)==="cloud",N=((K=e.data)==null?void 0:K.user)??null,I=()=>{Oe.getState().clear(),ge.logout().finally(()=>window.location.assign("/"))},P=te(ne=>ne.selectedPrId),E=te(ne=>ne.selectedThreadId),w=Oe(ne=>ne.activeTab),R=Oe(ne=>ne.tabs),S=w!=="timeline"&&w!=="activity"?R.find(ne=>ne.key===w)??null:null,j=w==="activity",T=(S==null?void 0:S.kind)==="pr-detail"?S.prId:null,M=(S==null?void 0:S.kind)==="metrics-detail",D=(S==null?void 0:S.kind)==="bot-prs",U=(S==null?void 0:S.kind)==="pr-focus"?{kind:"isolate",prId:S.prId}:null,G=T!=null||j||M||D,L=P!=null&&!G,[Y,X]=s0("pierre:detailPaneHeight",384),B=x.useRef(null),_=x.useRef(null),H=x.useRef(null);x.useEffect(()=>{for(const ne of[_.current,B.current])ne&&(G?ne.setAttribute("inert",""):ne.removeAttribute("inert"))},[G]),x.useEffect(()=>{const ne=()=>Oe.getState().navigateBack();return window.addEventListener("popstate",ne),()=>window.removeEventListener("popstate",ne)},[]),x.useEffect(()=>{window.dispatchEvent(new Event("resize"))},[L]);const ee=ne=>{var Pe;H.current={startY:ne.clientY,startH:((Pe=B.current)==null?void 0:Pe.offsetHeight)??Y},ne.currentTarget.setPointerCapture(ne.pointerId)},ce=ne=>{const Pe=H.current;if(!Pe||!B.current)return;const se=window.innerHeight*.7,Z=Math.min(Math.max(Pe.startH+(Pe.startY-ne.clientY),160),se);B.current.style.height=`${Z}px`,window.dispatchEvent(new Event("resize"))},C=ne=>{!H.current||!B.current||(H.current=null,ne.currentTarget.releasePointerCapture(ne.pointerId),X(B.current.offsetHeight))};return x.useEffect(()=>{if(!v)return;const ne=()=>{ge.me().catch(()=>{})},Pe=window.setInterval(ne,180*1e3);return()=>window.clearInterval(Pe)},[v]),x.useEffect(()=>{v&&(rN(),sN())},[v]),e.error instanceof Gt&&e.error.status===401?n.jsx(Hj,{}):e.isLoading&&!e.data?n.jsx("div",{className:"flex h-full min-h-screen items-center justify-center bg-gray-950",children:n.jsx("span",{className:"brand-title text-4xl text-gray-100",children:"Pierre"})}):n.jsxs("div",{className:"flex h-full flex-col",children:[n.jsx(Wj,{notices:((ae=e.data)==null?void 0:ae.authNotices)??[]}),n.jsxs("header",{className:"flex items-center gap-3 border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[n.jsx("h1",{className:"brand-title",title:"Pierre — a play on “PR”",children:"Pierre"}),n.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[n.jsx(Sj,{}),n.jsx(Nj,{}),y&&n.jsx("button",{type:"button",onClick:b,"aria-pressed":m,className:`rounded border px-2 py-0.5 text-xs hover:border-gray-400 dark:hover:border-gray-500 ${m?"border-blue-400 text-blue-600 dark:border-blue-600 dark:text-blue-400":"border-gray-300 dark:border-gray-700"}`,title:m?"Notifications on — alerts when a new item enters your My Turn. Click to turn off.":"Turn on browser notifications for new My Turn items","aria-label":"Toggle My Turn notifications",children:n.jsxs("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:m?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[n.jsx("path",{d:"M18 8a6 6 0 0 0-12 0c0 7-3 9-3 9h18s-3-2-3-9"}),n.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})}),n.jsx("button",{type:"button",onClick:()=>i(!0),className:"rounded border border-gray-300 px-2 py-0.5 text-xs font-semibold hover:border-gray-400 dark:border-gray-700 dark:hover:border-gray-500",title:"Help — what is Pierre and how to use it","aria-label":"Help",children:"?"}),n.jsx("button",{type:"button",onClick:a,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",title:"Toggle dark mode",children:s?"☀":"☾"}),N!=null&&n.jsx(Vj,{user:N,canSignOut:v,onSignOut:I,onOpenSettings:p?()=>d(!0):null})]})]}),o&&n.jsx(Rj,{onClose:()=>i(!1)}),u&&n.jsx(Uj,{onClose:()=>d(!1)}),n.jsx(Cj,{}),n.jsx(iy,{}),n.jsx(py,{}),n.jsx(by,{}),n.jsxs("main",{className:"relative flex min-h-0 flex-1 flex-col",children:[n.jsx("section",{ref:_,className:"min-h-0 flex-1 overflow-hidden",children:U==null?n.jsx(vm,{},"board"):n.jsx(vm,{mode:U},`focus:${U.prId}`)}),L&&n.jsxs(n.Fragment,{children:[n.jsx("div",{role:"separator","aria-orientation":"horizontal","aria-label":"Resize detail pane",onPointerDown:ee,onPointerMove:ce,onPointerUp:C,title:"Drag to resize",className:"h-1 shrink-0 cursor-row-resize bg-gray-200 transition-colors hover:bg-blue-400 dark:bg-gray-800 dark:hover:bg-blue-500"}),n.jsx("section",{ref:B,style:{height:Y},className:"shrink-0 overflow-auto",children:n.jsx(fj,{})})]}),T!=null&&n.jsx("div",{"data-testid":"pinned-pr-overlay",className:"absolute inset-0 z-20 bg-white dark:bg-gray-950",children:n.jsx(Nh,{prId:T,selectedThreadId:P===T?E:null},T)}),j&&n.jsx("div",{"data-testid":"activity-overlay",className:"absolute inset-0 z-20 overflow-hidden bg-white dark:bg-gray-950",children:n.jsx(Kk,{})}),M&&n.jsx("div",{"data-testid":"metrics-overlay",className:"absolute inset-0 z-20 overflow-auto bg-white dark:bg-gray-950",children:n.jsx(ej,{})}),D&&n.jsx("div",{"data-testid":"bot-prs-overlay",className:"absolute inset-0 z-20 overflow-auto bg-white dark:bg-gray-950",children:n.jsx(dj,{})})]}),n.jsx(vj,{})]})}function di(e){return new Promise((s,a)=>{e.oncomplete=e.onsuccess=()=>s(e.result),e.onabort=e.onerror=()=>a(e.error)})}function oN(e,s){let a;const o=()=>{if(a)return a;const i=indexedDB.open(e);return i.onupgradeneeded=()=>i.result.createObjectStore(s),a=di(i),a.then(u=>{u.onclose=()=>a=void 0},()=>{}),a};return(i,u)=>o().then(d=>u(d.transaction(s,i).objectStore(s)))}let mu;function Zu(){return mu||(mu=oN("keyval-store","keyval")),mu}function iN(e,s=Zu()){return s("readonly",a=>di(a.get(e)))}function cN(e,s,a=Zu()){return a("readwrite",o=>(o.put(s,e),di(o.transaction)))}function uN(e,s=Zu()){return s("readwrite",a=>(a.delete(e),di(a.transaction)))}const dN=Zg({storage:{getItem:e=>iN(e).then(s=>s??null),setItem:(e,s)=>cN(e,s),removeItem:e=>uN(e)},key:"pierre-query-cache",throttleTime:1e3}),fN=new ex({defaultOptions:{queries:{staleTime:3e4,refetchOnWindowFocus:!1,retry:1}}});var Eo,Qm;(Qm=(Eo=navigator.storage)==null?void 0:Eo.persist)==null||Qm.call(Eo);new URLSearchParams(window.location.search).has("perf")&&Eu(()=>import("./perfProbe-Da13EhTE.js"),[]).then(e=>e.startPerfProbe());const w0=document.getElementById("root");if(!w0)throw new Error("#root not found");const pN=1e3*60*60*24*7;mx.createRoot(w0).render(n.jsx(x.StrictMode,{children:n.jsx(tx,{client:fN,persistOptions:{persister:dN,maxAge:pN,buster:"pierre-detail-v4",dehydrateOptions:{shouldDehydrateQuery:e=>{const s=e.queryKey[0];return(s==="pr"||s==="thread"||s==="pr-files")&&e.state.status==="success"}}},children:n.jsx(lN,{})})}));export{kh as A,UN as B,yN as C,yn as D,CN as E,Pv as F,jN as G,qN as H,NN as I,IN as J,zN as K,BN as L,cr as M,p0 as R,Gt as a,vN as b,uv as c,dv as d,ei as e,ge as f,Wx as g,bN as h,wN as i,PN as j,AN as k,SN as l,EN as m,TN as n,DN as o,$N as p,kN as q,St as r,MN as s,FN as t,KN as u,LN as v,te as w,_N as x,RN as y,ON as z};
|
package/public/index.html
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
href="https://fonts.googleapis.com/css2?family=Great+Vibes&display=swap"
|
|
21
21
|
rel="stylesheet"
|
|
22
22
|
/>
|
|
23
|
-
<script type="module" crossorigin src="/app/assets/index-
|
|
23
|
+
<script type="module" crossorigin src="/app/assets/index-CxFDrc36.js"></script>
|
|
24
24
|
<link rel="modulepreload" crossorigin href="/app/assets/tanstack-R-s9abdD.js">
|
|
25
25
|
<link rel="modulepreload" crossorigin href="/app/assets/markdown-BUNN1sk6.js">
|
|
26
26
|
<link rel="modulepreload" crossorigin href="/app/assets/highlight-C8vPehS1.js">
|