@p4code/cli 0.4.19 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.mjs +170 -25
- package/dist/client/apple-touch-icon.png +0 -0
- package/dist/client/assets/DiffPanel-ByJrw-zk.js +98 -0
- package/dist/client/assets/{FilePreviewPanel-DXQsOSGG.js → FilePreviewPanel-Cu83ELuX.js} +4 -4
- package/dist/client/assets/PreviewPanel-DjGR91f5.js +2 -0
- package/dist/client/assets/{PullRequestCodeTab-CIuuBsMR.js → PullRequestCodeTab-BUVi3FWm.js} +4 -4
- package/dist/client/assets/{fileCommentAnnotations-BhUKh-pg.js → fileCommentAnnotations-BfBnLApA.js} +2 -2
- package/dist/client/assets/{index-Cj4x7ntJ.js → index-BopiBtUj.js} +246 -233
- package/dist/client/assets/{index-CSQTlXxM.css → index-X_nEJk29.css} +1 -1
- package/dist/client/assets/previewAssetResource-DZZapyaR.js +48 -0
- package/dist/client/assets/{renderFileChildren-BGOdzqzF.js → renderFileChildren-Be3rPgd3.js} +2 -2
- package/dist/client/assets/{toggle-group-BMH2uS3g.js → toggle-group-B5Gkl6L5.js} +2 -2
- package/dist/client/favicon-16x16.png +0 -0
- package/dist/client/favicon-32x32.png +0 -0
- package/dist/client/favicon.ico +0 -0
- package/dist/client/index.html +3 -3
- package/package.json +1 -1
- package/dist/client/assets/DiffPanel-DNc0AohV.js +0 -98
- package/dist/client/assets/PreviewPanel-GF4Osjrf.js +0 -2
- package/dist/client/assets/previewAssetResource-D8K82rpl.js +0 -48
package/dist/client/assets/{PullRequestCodeTab-CIuuBsMR.js → PullRequestCodeTab-BUVi3FWm.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{$ as i,Ba as a,Et as o,Fa as s,Ja as c,
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{$ as i,Ba as a,Et as o,Fa as s,Ja as c,Ma as l,Pl as u,Ur as d,Ya as f,b as p,cl as m,dl as h,dt as g,fl as _,gt as v,ht as y,il as b,ml as x,pl as S,ql as C,rl as w,uu as T,vt as E,yt as D,za as O}from"./previewAssetResource-DZZapyaR.js";import{a as k,c as A,n as j,o as M,r as N,s as ee,t as te}from"./toggle-group-B5Gkl6L5.js";import{B as P,Fr as ne,G as re,H as ie,Ir as ae,J as oe,K as se,Lr as ce,Qr as le,U as ue,V as de,W as fe,Wr as pe,X as F,Xr as me,Yr as he,_ as ge,ai as _e,ct as ve,ir as ye,it as be,lt as I,nr as xe,nt as Se,oi as Ce,ot as we,q as Te,rr as Ee,rt as De,st as Oe,ut as ke,vr as Ae}from"./index-BopiBtUj.js";var je=x(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Me=x(`message-square-off`,[[`path`,{d:`M19 19H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.7.7 0 0 1 2 21.286V5a2 2 0 0 1 1.184-1.826`,key:`1wyg69`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.656 3H20a2 2 0 0 1 2 2v11.344`,key:`mhl4k6`}]]),L=e(n(),1),Ne=new Set([`pnpm-lock.yaml`,`yarn.lock`,`package-lock.json`,`bun.lockb`,`Cargo.lock`,`go.sum`,`composer.lock`,`Gemfile.lock`]),R=new Set([`__snapshots__`,`__generated__`,`dist`,`build`,`vendor`]),z=new Set([`__tests__`,`tests`,`test`]),B=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`,`.cjs`];function Pe(e){let t=e.split(`/`),n=t.at(-1)??``;return Ne.has(n)||n.endsWith(`.snap`)||n.endsWith(`.min.js`)||n.endsWith(`.min.css`)||/\.generated\./.test(n)||t.slice(0,-1).some(e=>R.has(e))?`generated`:/\.(?:test|spec)\./.test(n)||t.slice(0,-1).some(e=>z.has(e))?`test`:`source`}function Fe(e){let t=e.lastIndexOf(`.`);return t>e.lastIndexOf(`/`)?e.slice(0,t):e}function Ie(e){return Fe(e.split(`/`).at(-1)??``)}function Le(e,t){let n=e.split(`/`).slice(0,-1);for(let e of t.split(`/`))e===`.`||e===``||(e===`..`?n.pop():n.push(e));return n.join(`/`)}var Re=/(?:\bfrom|\bimport|\brequire\s*\()\s*\(?\s*["']([^"']+)["']/g;function ze(e,t,n,r){let i=new Set;for(let a of t){Re.lastIndex=0;let t=Re.exec(a);for(;t!==null;){let o=t[1]??``,s=o.startsWith(`.`)?Le(e,o):o,c=B.find(e=>s.endsWith(e)),l=c===void 0?s:s.slice(0,-c.length),u=n.get(l)??n.get(`${l}/index`)??r.get(Ie(l));u!==void 0&&u!==e&&i.add(u),t=Re.exec(a)}}return i}function Be(e,t){let n=new Set(e),r=[],i=[...e].sort((e,t)=>e.localeCompare(t));for(;n.size>0;){let e=i.filter(e=>n.has(e)),a=e.find(e=>[...t.get(e)??[]].every(e=>!n.has(e)))??e[0];n.delete(a),r.push(a)}return r}function V(e){return(e.split(`/`).at(-1)??``).replace(/\.(?:test|spec)\..*$/,``).replace(/\.[^.]+$/,``)}function Ve(e){let t=new Map;for(let n of e)t.set(I(n),n);let n=new Map;for(let e of t.keys())n.set(e,Pe(e));let r=[...t.keys()].filter(e=>n.get(e)===`source`),i=new Map,a=new Set,o=new Map;for(let e of r){i.set(Fe(e),e);let t=Ie(e);o.has(t)&&a.add(t),o.set(t,e)}for(let e of a)o.delete(e);let s=new Map;for(let e of r){let n=t.get(e);s.set(e,ze(e,[...n.additionLines,...n.deletionLines],i,o))}let c=Be(r,s),l=new Map;c.forEach((e,t)=>{let n=Ie(e);l.has(n)||l.set(n,t)});let u=[...t.keys()].filter(e=>n.get(e)===`test`).sort((e,t)=>(l.get(V(e))??2**53-1)-(l.get(V(t))??2**53-1)||e.localeCompare(t)),d=[...t.keys()].filter(e=>n.get(e)===`generated`).sort((e,t)=>e.localeCompare(t));return[...c,...u,...d].map(e=>t.get(e))}function He(e,t){return async n=>{let r=I(n),i=n.prevName?I({...n,name:n.prevName}):r,a=await e({changeType:n.type,oldPath:i,newPath:r}),o={name:r,contents:a.newContents,cacheKey:`${t}:new:${r}`};return n.type===`rename-pure`?{oldFile:null,newFile:o}:{oldFile:{name:i,contents:a.oldContents,cacheKey:`${t}:old:${i}`},newFile:o}}}function Ue(e,t){return He(async({changeType:n,oldPath:r,newPath:i})=>{let a=await e({environmentId:t.environmentId,input:{...t.reference,...t.commit===null?{}:{commit:t.commit},changeType:n,oldPath:r,newPath:i}});if(a._tag!==`Success`)throw T(a);return a.value},t.cacheKey)}var H=r();function U(e,t,n){return!n&&(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&t.trim().length>0}var W=t();function We(e){let t=(0,H.c)(43),{kind:n,rangeLabel:r,text:a,onTextChange:o,onCancel:s,onComment:c,onDelete:u,placeholder:d,submitLabel:f,pending:p,secondaryAction:m}=e,h=d===void 0?`Add a comment…`:d,g=f===void 0?`Comment`:f,_=p===void 0?!1:p,[v,y]=(0,L.useState)(``),b=n===`draft`&&!o?v:a,x;t[0]===b?x=t[1]:(x=b.trim(),t[0]=b,t[1]=x);let S=x;if(n===`comment`){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,W.jsx)(me,{className:`mt-0.5 size-3.5 shrink-0 text-primary/70`,"aria-hidden":`true`}),t[2]=e):e=t[2];let n;t[3]===b?n=t[4]:(n=(0,W.jsx)(`p`,{className:`min-w-0 flex-1 whitespace-pre-wrap text-[13px] leading-5`,children:b}),t[3]=b,t[4]=n);let r;t[5]===u?r=t[6]:(r=u?(0,W.jsx)(l,{className:`-my-1 -mr-1 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover/comment:opacity-100 focus-visible:opacity-100 max-sm:opacity-100`,variant:`ghost`,size:`icon-xs`,"aria-label":`Delete comment`,onClick:u,children:(0,W.jsx)(ae,{className:`size-3`})}):null,t[5]=u,t[6]=r);let i;return t[7]!==n||t[8]!==r?(i=(0,W.jsxs)(`div`,{"data-diff-comment-annotation":!0,className:`group/comment flex min-w-0 items-start gap-2.5 border-s-2 border-primary/55 bg-primary/[0.045] px-3 py-2.5 font-sans text-foreground`,contentEditable:!1,onPointerDown:q,children:[e,n,r]}),t[7]=n,t[8]=r,t[9]=i):i=t[9],i}let C=`Comment on lines ${r}`,w;t[10]===o?w=t[11]:(w=e=>(o??y)(e.target.value),t[10]=o,t[11]=w);let T;t[12]!==s||t[13]!==c||t[14]!==_||t[15]!==S?(T=e=>{e.key===`Escape`&&(e.preventDefault(),s()),U(e,S,_)&&(e.preventDefault(),c(S))},t[12]=s,t[13]=c,t[14]=_,t[15]=S,t[16]=T):T=t[16];let E;t[17]!==b||t[18]!==h||t[19]!==C||t[20]!==w||t[21]!==T?(E=(0,W.jsx)(i,{autoFocus:!0,unstyled:!0,className:`relative inline-flex w-full rounded-md border border-border/50 bg-background/20 font-sans text-foreground transition-colors focus-within:border-border/70 [&_[data-slot=textarea]]:min-h-12 [&_[data-slot=textarea]]:cursor-text [&_[data-slot=textarea]]:px-2.5 [&_[data-slot=textarea]]:py-1.5 [&_[data-slot=textarea]]:font-sans [&_[data-slot=textarea]]:text-xs [&_[data-slot=textarea]]:leading-5 max-sm:[&_[data-slot=textarea]]:min-h-12`,size:`sm`,value:b,placeholder:h,"aria-label":C,onChange:w,onFocus:G,onKeyDown:T}),t[17]=b,t[18]=h,t[19]=C,t[20]=w,t[21]=T,t[22]=E):E=t[22];let D;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,W.jsx)(`span`,{className:`mr-auto text-[10px] text-muted-foreground/70`,children:`⌘/Ctrl Enter to send`}),t[23]=D):D=t[23];let O;t[24]===s?O=t[25]:(O=(0,W.jsx)(l,{className:`text-muted-foreground hover:text-foreground`,variant:`ghost`,size:`xs`,onClick:s,children:`Cancel`}),t[24]=s,t[25]=O);let k;t[26]!==m||t[27]!==S?(k=m?(0,W.jsxs)(l,{size:`xs`,variant:`outline`,disabled:!m.allowEmpty&&!S,onClick:()=>m.onAction(S),children:[m.icon,m.label]}):null,t[26]=m,t[27]=S,t[28]=k):k=t[28];let A=_||!S,j;t[29]!==c||t[30]!==S?(j=()=>c(S),t[29]=c,t[30]=S,t[31]=j):j=t[31];let M;t[32]!==g||t[33]!==A||t[34]!==j?(M=(0,W.jsx)(l,{size:`xs`,disabled:A,onClick:j,children:g}),t[32]=g,t[33]=A,t[34]=j,t[35]=M):M=t[35];let N;t[36]!==O||t[37]!==k||t[38]!==M?(N=(0,W.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1`,children:[D,O,k,M]}),t[36]=O,t[37]=k,t[38]=M,t[39]=N):N=t[39];let ee;return t[40]!==N||t[41]!==E?(ee=(0,W.jsxs)(`div`,{"data-diff-comment-annotation":!0,className:`px-3 py-2 font-sans text-foreground`,contentEditable:!1,onPointerDown:K,children:[E,N]}),t[40]=N,t[41]=E,t[42]=ee):ee=t[42],ee}function G(e){let t=e.currentTarget.value.length;e.currentTarget.setSelectionRange(t,t)}function K(e){return e.stopPropagation()}function q(e){return e.stopPropagation()}var J=`${Se}
|
|
2
2
|
:is(
|
|
3
3
|
[data-line],
|
|
4
4
|
[data-line-annotation],
|
|
@@ -243,9 +243,9 @@ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}f
|
|
|
243
243
|
transition: none;
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
|
-
`;function Ge(e){let t=(0,H.c)(18),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({options:r,viewerRef:o,className:n,unsafeCSSExtra:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s;t[6]===o?s=t[7]:(s=o?{ref:o}:{},t[6]=o,t[7]=s);let c=n?`diff-render-surface outline-none ${n}`:`diff-render-surface outline-none`,l=a?`${J}\n${a}`:J,u,d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u={diffHeaderHeight:32,hunkSeparatorHeight:24,spacing:0,paddingTop:0,paddingBottom:0},d={paddingTop:0,paddingBottom:0,gap:0},t[8]=u,t[9]=d):(u=t[8],d=t[9]);let f;t[10]!==r||t[11]!==l?(f={...r,unsafeCSS:l,itemMetrics:u,layout:d},t[10]=r,t[11]=l,t[12]=f):f=t[12];let p;return t[13]!==i||t[14]!==s||t[15]!==c||t[16]!==f?(p=(0,W.jsx)(k,{...i,...s,className:c,options:f}),t[13]=i,t[14]=s,t[15]=c,t[16]=f,t[17]=p):p=t[17],p}var Ke=`mx-3 my-2 rounded-xl border border-border/70 bg-background p-3 text-sm shadow-sm`;function qe(e){return t=>{t.key===`Escape`&&e.onCancel&&(t.preventDefault(),e.onCancel()),U(t,e.value,e.pending)&&(t.preventDefault(),e.onSubmit())}}function Je(e){let t=(0,H.c)(11),{comment:n,onRemove:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=
|
|
246
|
+
`;function Ge(e){let t=(0,H.c)(18),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({options:r,viewerRef:o,className:n,unsafeCSSExtra:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s;t[6]===o?s=t[7]:(s=o?{ref:o}:{},t[6]=o,t[7]=s);let c=n?`diff-render-surface outline-none ${n}`:`diff-render-surface outline-none`,l=a?`${J}\n${a}`:J,u,d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u={diffHeaderHeight:32,hunkSeparatorHeight:24,spacing:0,paddingTop:0,paddingBottom:0},d={paddingTop:0,paddingBottom:0,gap:0},t[8]=u,t[9]=d):(u=t[8],d=t[9]);let f;t[10]!==r||t[11]!==l?(f={...r,unsafeCSS:l,itemMetrics:u,layout:d},t[10]=r,t[11]=l,t[12]=f):f=t[12];let p;return t[13]!==i||t[14]!==s||t[15]!==c||t[16]!==f?(p=(0,W.jsx)(k,{...i,...s,className:c,options:f}),t[13]=i,t[14]=s,t[15]=c,t[16]=f,t[17]=p):p=t[17],p}var Ke=`mx-3 my-2 rounded-xl border border-border/70 bg-background p-3 text-sm shadow-sm`;function qe(e){return t=>{t.key===`Escape`&&e.onCancel&&(t.preventDefault(),e.onCancel()),U(t,e.value,e.pending)&&(t.preventDefault(),e.onSubmit())}}function Je(e){let t=(0,H.c)(11),{comment:n,onRemove:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=f(Ke,`border-dashed`),t[0]=i):i=t[0];let a,o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,W.jsx)(he,{className:`size-3.5`}),o=(0,W.jsx)(`span`,{children:`Pending — sent when you submit the review`}),t[1]=a,t[2]=o):(a=t[1],o=t[2]);let s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,W.jsx)(ae,{className:`size-3.5`}),t[3]=s):s=t[3];let c;t[4]===r?c=t[5]:(c=(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[a,o,(0,W.jsx)(l,{size:`icon-xs`,variant:`ghost`,className:`ml-auto`,"aria-label":`Discard this comment`,onClick:r,children:s})]}),t[4]=r,t[5]=c);let u;t[6]===n.body?u=t[7]:(u=(0,W.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap leading-relaxed`,children:n.body}),t[6]=n.body,t[7]=u);let d;return t[8]!==c||t[9]!==u?(d=(0,W.jsxs)(`div`,{className:i,contentEditable:!1,onPointerDown:Ye,children:[c,u]}),t[8]=c,t[9]=u,t[10]=d):d=t[10],d}function Ye(e){return e.stopPropagation()}function Xe({thread:e,workspaceRoot:t,canReply:n,canResolve:r,canReact:a,environmentId:o,reference:s,pending:c,fixPending:u,fixLabel:d=`Fix in a thread`,onFix:f,onReply:p,canEditComment:h,onEditComment:g,onToggleResolved:_,onReacted:v}){let[y,b]=(0,L.useState)(!e.isResolved),[x,S]=(0,L.useState)(!1),[C,w]=(0,L.useState)(``),[T,E]=(0,L.useState)(null),[D,O]=(0,L.useState)(!1),k=(0,L.useRef)(!1),A=async(e,t)=>{if(D)return;O(!0);let n=await g(e,t);O(!1),n&&E(null)},j=async()=>{let e=C.trim();if(!(e.length===0||c||k.current)){k.current=!0;try{await p(e)&&(w(``),S(!1))}finally{k.current=!1}}};return(0,W.jsxs)(`div`,{className:Ke,contentEditable:!1,onPointerDown:e=>e.stopPropagation(),children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[e.isResolved?(0,W.jsx)(m,{className:`size-3.5 text-emerald-600 dark:text-emerald-500`}):(0,W.jsx)(je,{className:`size-3.5`}),(0,W.jsxs)(`button`,{type:`button`,className:`hover:text-foreground`,"aria-expanded":y,onClick:()=>b(e=>!e),children:[e.isResolved?`Resolved`:`Open`,` · `,e.comments.length,` `,e.comments.length===1?`comment`:`comments`]}),e.isOutdated?(0,W.jsx)(`span`,{children:`outdated`}):null,f?(0,W.jsxs)(l,{size:`xs`,variant:`ghost`,className:`ml-auto`,disabled:c||u,onClick:f,children:[(0,W.jsx)(le,{className:`size-3`}),u?`Preparing...`:d]}):null,r?(0,W.jsx)(l,{size:`xs`,variant:`ghost`,className:f?void 0:`ml-auto`,disabled:c,onClick:_,children:e.isResolved?`Unresolve`:`Resolve`}):null]}),y?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`mt-2 space-y-3`,children:e.comments.map(e=>(0,W.jsxs)(`article`,{className:`group min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,W.jsx)(re,{actor:e.author,className:`text-foreground`}),(0,W.jsx)(`span`,{children:Ae(e.createdAt)})]}),T===e.id?(0,W.jsx)(de,{className:`mt-1`,value:e.body,cwd:t,label:`Edit comment`,saving:D,onSave:t=>void A(e.id,t),onCancel:()=>E(null)}):(0,W.jsxs)(`div`,{className:`mt-1 flex items-start gap-1`,children:[(0,W.jsx)(ie,{className:`min-w-0 flex-1 text-sm`,text:e.body,cwd:t}),h(e)?(0,W.jsx)(l,{size:`icon-xs`,variant:`ghost`,className:`shrink-0 text-muted-foreground opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100 focus-visible:opacity-100`,"aria-label":`Edit comment`,onClick:()=>E(e.id),children:(0,W.jsx)(pe,{className:`size-3`})}):null]}),(0,W.jsx)(P,{className:`mt-1.5`,reactions:e.reactions??[],canReact:a,subjectId:e.id,environmentId:o,reference:s,onRefresh:v})]},e.id))}),n?x?(0,W.jsxs)(`div`,{className:`mt-2`,children:[(0,W.jsx)(i,{autoFocus:!0,size:`sm`,value:C,placeholder:`Reply`,"aria-label":`Reply to this conversation`,onChange:e=>w(e.target.value),onKeyDown:qe({value:C,pending:c,onSubmit:()=>void j(),onCancel:()=>S(!1)})}),(0,W.jsxs)(`div`,{className:`mt-2 flex justify-end gap-2`,children:[(0,W.jsx)(l,{size:`xs`,variant:`ghost`,onClick:()=>S(!1),children:`Cancel`}),(0,W.jsx)(l,{size:`xs`,disabled:c||C.trim().length===0,onClick:()=>void j(),children:`Reply`})]})]}):(0,W.jsx)(l,{size:`xs`,variant:`ghost`,className:`mt-2 px-1`,onClick:()=>S(!0),children:`Reply`}):null]}):null]})}var Ze=0;function Qe(){return Ze+=1,`pending-review-comment-${Ze}`}function $e(e){return`${e.projectId}/${e.repository}#${e.number}`}var et=[],Y=C()(e=>({drafts:{},summaries:{},addComment:(t,n)=>e(e=>({drafts:{...e.drafts,[t]:[...e.drafts[t]??et,n]}})),removeComment:(t,n)=>e(e=>{let r=(e.drafts[t]??et).filter(e=>e.id!==n);if(r.length>0)return{drafts:{...e.drafts,[t]:r}};let{[t]:i,...a}=e.drafts;return{drafts:a}}),removeComments:(t,n)=>e(e=>{let r=new Set(n),i=(e.drafts[t]??et).filter(e=>!r.has(e.id));if(i.length>0)return{drafts:{...e.drafts,[t]:i}};let{[t]:a,...o}=e.drafts;return{drafts:o}}),clear:t=>e(e=>{let{[t]:n,...r}=e.drafts;return{drafts:r}}),setSummary:(t,n)=>e(e=>({summaries:{...e.summaries,[t]:n}})),clearSummary:(t,n)=>e(e=>{if(e.summaries[t]!==n)return e;let{[t]:r,...i}=e.summaries;return{summaries:i}})}));function tt(e){let t=(0,H.c)(2),n;return t[0]===e?n=t[1]:(n=t=>t.drafts[$e(e)]??et,t[0]=e,t[1]=n),Y(n)}var nt=[{value:`comment`,label:`Comment`,sent:`Review submitted`,icon:(0,W.jsx)(he,{className:`size-3`})},{value:`approve`,label:`Approve`,sent:`Pull request approved`,icon:(0,W.jsx)(S,{className:`size-3`})},{value:`request-changes`,label:`Request changes`,sent:`Changes requested`,icon:(0,W.jsx)(_e,{className:`size-3`})}];function rt(e){let t=(0,H.c)(13),{environmentId:n,reference:r,verdicts:a,onSubmitted:o}=e,[s,c]=(0,L.useState)(!1),u=tt(r),d=$e(r),f=Y(e=>e.summaries[d]??``),p=Y(ct),m=Y(st),h=Y(ot),_=Y(at),v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v={reportFailure:!1},t[0]=v):v=t[0];let y=D(F.submitReview,v),b;t[1]===a?b=t[2]:(b=e=>a.includes(e.value),t[1]=a,t[2]=b);let x=nt.filter(b);if(x.length===0)return null;let S=async e=>{if(s)return;let t=f,i=u;c(!0);let a=await y({environmentId:n,input:{...r,verdict:e.value,body:t,comments:i}});if(c(!1),a._tag===`Failure`){g.add({type:`error`,title:`The review could not be submitted`});return}m(d,i.map(it)),_(d,t),g.add({type:`success`,title:e.sent}),o()},C;t[3]!==f||t[4]!==u.length?(C=e=>e===`approve`||f.trim().length>0||u.length>0,t[3]=f,t[4]=u.length,t[5]=C):C=t[5];let w=C,T=u.length===0?`No line comments yet`:`${u.length} ${u.length===1?`comment`:`comments`} pending`,E;t[6]===T?E=t[7]:(E=(0,W.jsx)(`span`,{children:T}),t[6]=T,t[7]=E);let O=u.length>0?(0,W.jsx)(l,{size:`xs`,variant:`ghost`,disabled:s,onClick:()=>p(d),children:`Discard`}):null,k;t[8]!==E||t[9]!==O?(k=(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[E,O]}),t[8]=E,t[9]=O,t[10]=k):k=t[10];let A=x.map(e=>(0,W.jsx)(l,{size:`xs`,variant:e.value===`comment`?`outline`:`default`,disabled:s||!w(e.value),onClick:()=>void S(e),children:(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[e.icon,e.label]})},e.value)),j;return t[11]===A?j=t[12]:(j=(0,W.jsx)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-2`,children:A}),t[11]=A,t[12]=j),(0,W.jsxs)(`div`,{className:`px-4 py-3`,children:[k,(0,W.jsx)(i,{size:`sm`,className:`mt-2`,value:f,placeholder:`Summarize your review (optional)`,"aria-label":`Review summary`,onChange:e=>h(d,e.target.value)}),j]})}function it(e){return e.id}function at(e){return e.clearSummary}function ot(e){return e.setSummary}function st(e){return e.removeComments}function ct(e){return e.clear}function lt(e,t,n){return e.hunks.some(e=>t===`left`?n>=e.deletionStart&&n<e.deletionStart+e.deletionCount:n>=e.additionStart&&n<e.additionStart+e.additionCount)}function ut(e,t,n){let r=t!==`expanded`;return n.has(e)?!r:r}var dt=10,ft=`
|
|
247
247
|
[data-diffs-header] [data-additions-count],
|
|
248
248
|
[data-diffs-header] [data-deletions-count] {
|
|
249
249
|
display: none !important;
|
|
250
|
-
}`,pt=[];function mt(e){return e===`left`?`deletions`:`additions`}function ht(e){return e===`deletions`?`left`:`right`}function X({environmentId:e,reference:t,detail:n,selectedCommitOid:r,onSelectedCommitChange:i,pendingFinding:l,fixFindingLabel:h=`Fix in a thread`,onFixFinding:S,onAddToAgentSelection:C,onRefresh:w,refreshToken:k=0}){let{resolvedTheme:ne}=m(),ie=re(),[ae,oe]=(0,L.useState)(()=>new Set),[ue,fe]=(0,L.useState)(dt),[me,he]=(0,L.useState)(null),[ve,Ce]=(0,L.useState)(`stacked`),[I,je]=(0,L.useState)(ie.wordWrap),[Ne,R]=(0,L.useState)(null),[z,B]=(0,L.useState)(null),[Pe,Fe]=(0,L.useState)(!1),[Ie,Le]=(0,L.useState)(!1),[Re,ze]=(0,L.useState)(!1),[Be,V]=(0,L.useState)({key:``,cursor:null,slices:pt}),He=(0,L.useRef)(new Map),H=$e(t),U=r,G=U===null?H:`${H}@${U}`;(0,L.useEffect)(()=>{B(null),R(null),oe(new Set),he(null),fe(dt),Le(!1),V({key:G,cursor:null,slices:pt}),He.current.clear()},[G]);let K=Be.key===G?Be.slices:pt,q=Be.key===G?Be.cursor:null,J=o(P.diff({environmentId:e,input:{...t,...q===null?{}:{cursor:q},...U===null?{}:{commit:U}}}));(0,L.useEffect)(()=>{let e=J.data;e!==null&&V(t=>{let n=t.key===G?t.slices:pt,r={cursor:q,patch:e.patch,truncated:e.truncated,nextCursor:e.nextCursor,omittedFileStats:e.omittedFileStats??[]},i=n.findIndex(e=>e.cursor===q);if(i===-1)return{key:G,cursor:q,slices:[...n,r]};let a=n[i];return a!==void 0&&a.patch===r.patch&&a.truncated===r.truncated&&a.nextCursor===r.nextCursor&&a.omittedFileStats.length===r.omittedFileStats.length&&a.omittedFileStats.every((e,t)=>{let n=r.omittedFileStats[t];return n!==void 0&&n.path===e.path&&n.additions===e.additions&&n.deletions===e.deletions})?t:{key:G,cursor:q,slices:[...n.slice(0,i),r]}})},[q,J.data,G]);let Ke=d(P.diff({environmentId:e,input:{...t,...U===null?{}:{commit:U}}})),qe=(0,L.useRef)(k);(0,L.useEffect)(()=>{qe.current!==k&&(qe.current=k,V({key:G,cursor:null,slices:pt}),Ke())},[k,G,Ke]);let Ye=H,Ze=tt(t),et=Y(e=>e.addComment),nt=Y(e=>e.removeComment),it=D(P.replyToThread,{reportFailure:!1}),at=D(P.setThreadResolution,{reportFailure:!1}),ot=D(P.updateComment,{reportFailure:!1}),st=D(P.diffFileContents),ct=(0,L.useMemo)(()=>Ue(st,{environmentId:e,reference:t,commit:U,cacheKey:`pull-request:${H}:${n.updatedAt}:${U??`all`}`}),[U,n.updatedAt,e,st,t,H]),X=(0,L.useMemo)(()=>{let e=n.capabilities.review,t=n.viewerPermissions;return{inlineComment:e.inlineComment&&t.comment,reply:e.reply&&t.comment,resolve:e.resolve&&t.resolve,verdicts:e.verdicts.filter(e=>t.verdicts.includes(e))}},[n.capabilities.review,n.viewerPermissions]),gt=X.inlineComment&&U===null,_t=(0,L.useMemo)(()=>K.map(e=>{let t=`pull-request:${G}:${ne}:${e.cursor??`first`}:${xe(e.patch)}`,n=He.current.get(t);if(n)return n;let r=ke(e.patch,t,{compactPartialHunkOffsets:!0});return r&&He.current.set(t,r),r}),[K,ne,G]),Z=(0,L.useMemo)(()=>_t.flatMap(e=>e?.kind===`files`?Ve(e.files):[]),[_t]),Q=K.at(-1)?.nextCursor??null,vt=K.some(e=>e.truncated)||_t.some(e=>e?.kind===`raw`),yt=(0,L.useMemo)(()=>{let e=new Set;if(U!==null)return e;for(let t of Z){let r=F(t);for(let i of n.reviewThreads)i.path===r&&i.line!==null&<(t,i.side,i.line)&&e.add(i.id)}return e},[U,n.reviewThreads,Z]),$=(0,L.useMemo)(()=>Z.map(e=>{let t=Oe(e),r=F(e),i=new Map,a=(e,t)=>{let n=`${e}:${t}`,r=i.get(n);if(r)return r;let a={side:e,line:t,threads:[],pending:[],draft:!1};return i.set(n,a),a};for(let e of n.reviewThreads)e.path!==r||e.line===null||yt.has(e.id)&&a(e.side,e.line).threads.push(e);if(U===null)for(let e of Ze)e.path===r&&a(e.side,e.line).pending.push(e);z?.fileKey===t&&(a(z.side,z.line).draft=!0);let o=ut(t,me,ae),s=[...i.values()].map(e=>({side:mt(e.side),lineNumber:e.line,metadata:{threads:e.threads,pending:e.pending,draft:e.draft}}));return{id:t,type:`diff`,fileDiff:e,annotations:s,collapsed:o,version:xe(`${o?`1`:`0`}:${s.map(({side:e,lineNumber:t,metadata:n})=>`${e}:${t}:${n.draft?`d`:``}:${n.pending.map(e=>`${e.id}:${e.body}`).join(`,`)}:${n.threads.map(e=>`${e.id}:${e.isResolved?`r`:``}:${e.isOutdated?`o`:``}:${e.comments.map(e=>`${e.id}:${e.author?.login??``}:${e.createdAt}:${e.body}:${(e.reactions??[]).map(e=>`${e.content}:${e.count}:${e.viewerHasReacted?`v`:``}`).join(`,`)}`).join(`;`)}`).join(`,`)}`).join(`|`)}`)}}),[U,n.reviewThreads,z,Z,me,Ze,yt,ae]),bt=(0,L.useMemo)(()=>Te(Z),[Z]),xt=(0,L.useMemo)(()=>new Map(K.flatMap(e=>e.omittedFileStats.map(e=>[e.path,e]))),[K]),St=(0,L.useMemo)(()=>$.map(e=>e.id),[$]),Ct=(0,L.useMemo)(()=>new Set($.filter(e=>e.collapsed===!0).map(e=>e.id)),[$]),wt=N(St,Ct),[Tt,Et]=(0,L.useState)(null);(0,L.useEffect)(()=>{if(Tt===null||Q===null||Q===q||J.isPending||J.error!==null)return;let e=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&V(e=>({...e,cursor:Q}))},{rootMargin:`240px`});return e.observe(Tt),()=>e.disconnect()},[q,J.error,J.isPending,Q,Tt]);let Dt=(0,L.useCallback)(e=>oe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[]),Ot=()=>{he(N(St,Ct)?`expanded`:`folded`),oe(new Set)},kt=(0,L.useMemo)(()=>n.commits.toSorted((e,t)=>Date.parse(t.committedDate)-Date.parse(e.committedDate)),[n.commits]),At=(0,L.useCallback)((e,t)=>{if(!e||!gt)return;let n=t.item;if(n.type!==`diff`)return;let r=Z.find(e=>Oe(e)===n.id);if(!r)return;let i=F(r),a=Ae(r);B({fileKey:n.id,path:i,oldPath:a===i?null:a,line:e.end,side:ht(e.endSide??e.side),range:e})},[gt,Z]),jt=(0,L.useCallback)((e,t,r)=>{let i=Z.find(t=>Oe(t)===e.fileKey),a=i===void 0?null:f({id:`pull-request-selection:${e.fileKey}:${e.range.start}:${e.range.end}`,sectionId:`pull-request:${n.number}`,sectionTitle:`PR #${n.number} review`,filePath:e.path,fileDiff:i,range:e.range,text:t});B(null),R(null),a!==null&&r(a)},[n.number,Z]),Mt=(0,L.useCallback)(()=>Q===null?null:(0,W.jsx)(`div`,{ref:Et,className:`flex items-center justify-center gap-2 py-2 text-xs text-muted-foreground`,children:J.error===null?J.isPending?`Loading more files...`:null:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{children:`The rest of this diff could not be loaded.`}),(0,W.jsx)(u,{size:`xs`,variant:`outline`,onClick:()=>J.refresh(),children:`Retry`})]})}),[Q,J.error,J.isPending,J.refresh]),Nt=(0,L.useCallback)(e=>{let t=e.collapsed===!0;return(0,W.jsx)(`button`,{type:`button`,"aria-expanded":!t,"aria-label":t?`Expand diff`:`Collapse diff`,className:p(`mr-1 inline-flex size-5 items-center justify-center rounded text-muted-foreground transition-colors hover:text-foreground`),onClick:t=>{t.stopPropagation(),Dt(e.id)},children:t?(0,W.jsx)(g,{className:`size-4`}):(0,W.jsx)(v,{className:`size-4`})})},[Dt]),Pt=(0,L.useCallback)(e=>{if(e.type!==`diff`)return null;let t=0,n=0;for(let r of e.fileDiff.hunks)t+=r.additionLines,n+=r.deletionLines;if(t===0&&n===0){let r=xt.get(F(e.fileDiff));r&&({additions:t,deletions:n}=r)}return(0,W.jsx)(ce,{additions:t,deletions:n,className:`font-mono text-[11px]`})},[xt]),Ft=(0,L.useMemo)(()=>({diffStyle:ve===`split`?`split`:`unified`,lineDiffType:`none`,overflow:I?`wrap`:`scroll`,theme:ye(ne),themeType:ne,stickyHeaders:!0,loadDiffFiles:ct,enableGutterUtility:gt&&z===null,enableLineSelection:gt&&z===null,onGutterUtilityClick:At,onLineSelectionEnd:At}),[ve,I,ne,ct,gt,z,At]),It=(0,L.useCallback)(async(e,t)=>{if(Pe)return!1;Fe(!0);let n=await t();return Fe(!1),n._tag===`Failure`?(_.add({type:`error`,title:e}),!1):(w(),!0)},[w,Pe]),Lt=(0,L.useCallback)(r=>(0,W.jsx)(Xe,{thread:r,workspaceRoot:n.workspaceRoot,canReply:X.reply,canResolve:X.resolve,canReact:n.capabilities.reactions===!0,environmentId:e,reference:t,pending:Pe,fixPending:l===pe({kind:`thread`,thread:r}),fixLabel:h,...S?{onFix:()=>S({kind:`thread`,thread:r})}:{},onReply:n=>It(`Reply could not be posted`,()=>it({environmentId:e,input:{...t,threadId:r.id,body:n}})),canEditComment:e=>de(n,{author:e.author,kind:`review-comment`}),onEditComment:(n,r)=>It(`The comment could not be saved`,()=>ot({environmentId:e,input:{...t,commentId:n,kind:`review-comment`,body:r}})),onToggleResolved:()=>void It(`The conversation could not be updated`,()=>at({environmentId:e,input:{...t,threadId:r.id,resolved:!r.isResolved}})),onReacted:w},`${t.projectId}#${t.number}:${r.id}`),[n,e,h,w,S,l,t,it,X.reply,X.resolve,It,at,Pe,ot]),Rt=(0,L.useCallback)(e=>(0,W.jsxs)(`div`,{className:`py-1 font-sans text-foreground`,children:[e.metadata.threads.map(Lt),e.metadata.pending.map(e=>(0,W.jsx)(Je,{comment:e,onRemove:()=>nt(Ye,e.id)},e.id)),e.metadata.draft&&z?(0,W.jsx)(We,{kind:`draft`,rangeLabel:`${z.path}:${z.line}`,text:``,submitLabel:`Add to review`,...C?{secondaryAction:{label:`Add to agent`,onAction:e=>jt(z,e,t=>C({comment:t,request:e}))}}:{},onCancel:()=>{B(null),R(null)},onComment:e=>{et(Ye,{id:Qe(),path:z.path,...z.oldPath===null?{}:{oldPath:z.oldPath},line:z.line,side:z.side,body:e}),B(null),R(null)}}):null]}),[et,jt,z,C,nt,Lt,Ye]),zt=X.verdicts.length===0?null:(0,W.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 z-10`,children:Re?(0,W.jsxs)(`div`,{className:`chat-composer-glass pointer-events-auto absolute inset-x-3 bottom-3 rounded-xl border border-border/60 shadow-lg`,children:[(0,W.jsx)(u,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Close review`,className:`absolute right-2 top-2`,onClick:()=>ze(!1),children:(0,W.jsx)(T,{className:`size-3.5`})}),(0,W.jsx)(rt,{environmentId:e,reference:t,verdicts:X.verdicts,onSubmitted:()=>{w(),ze(!1)}})]}):(0,W.jsxs)(`button`,{type:`button`,className:`chat-composer-glass pointer-events-auto absolute bottom-3 right-4 flex items-center gap-1.5 rounded-full border border-border/60 px-3 py-1.5 text-xs font-medium shadow-lg`,onClick:()=>ze(!0),children:[(0,W.jsx)(ge,{className:`size-3.5`}),`Review`,Ze.length>0?(0,W.jsx)(`span`,{className:`flex size-4 items-center justify-center rounded-full bg-accent text-[10px] tabular-nums text-accent-foreground`,children:Ze.length}):null]})}),Bt=kt.find(e=>e.oid===U);(0,L.useEffect)(()=>{U!==null&&Bt===void 0&&i(null)},[U,i,Bt]);let Vt=Bt?Bt.messageHeadline:`All commits`,Ht=(0,W.jsxs)(`div`,{className:`surface-subheader justify-between gap-2 px-4 text-xs text-muted-foreground`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[kt.length>0?(0,W.jsxs)(s,{children:[(0,W.jsxs)(c,{className:`inline-flex h-6 max-w-64 items-center gap-1 rounded-md bg-accent px-2 text-xs font-medium text-accent-foreground outline-none transition-colors hover:bg-accent/80 focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Diff scope: ${Vt}`,children:[(0,W.jsx)(`span`,{className:`truncate`,children:Vt}),(0,W.jsx)(v,{className:`size-3.5 shrink-0 opacity-70`})]}),(0,W.jsxs)(a,{align:`start`,className:`w-80`,children:[(0,W.jsx)(O,{className:U===null?`bg-foreground/[0.08]`:void 0,onClick:()=>i(null),children:(0,W.jsx)(`span`,{children:`All commits`})}),kt.slice(0,ue).map(e=>(0,W.jsxs)(O,{className:e.oid===U?`bg-foreground/[0.08]`:void 0,onClick:()=>i(e.oid),children:[(0,W.jsx)(`span`,{className:`min-w-0 truncate`,title:e.messageHeadline,children:e.messageHeadline}),(0,W.jsx)(`span`,{className:`ml-auto shrink-0 font-mono text-xs text-muted-foreground`,children:e.oid.slice(0,7)})]},e.oid)),kt.length>ue?(0,W.jsx)(O,{closeOnClick:!1,onClick:()=>fe(e=>e+dt),children:(0,W.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Show more (`,kt.length-ue,` left)`]})}):null]})]}):null,(0,W.jsxs)(Ee,{children:[(0,W.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[Z.length,` `,Z.length===1?`file`:`files`,Q===null?``:`+`]}),vt?(0,W.jsxs)(b,{children:[(0,W.jsx)(E,{render:(0,W.jsx)(`span`,{className:`flex shrink-0 items-center`}),children:(0,W.jsx)(x,{"aria-label":`Some of this diff was not shown`,className:`size-3.5 text-amber-600 dark:text-amber-500`})}),(0,W.jsx)(y,{side:`bottom`,children:`The host withheld part of this diff — a binary file, or a change too large to inline.`})]}):null,U!==null&&X.inlineComment?(0,W.jsxs)(b,{children:[(0,W.jsx)(E,{render:(0,W.jsx)(`span`,{className:`flex shrink-0 items-center`}),children:(0,W.jsx)(Me,{"aria-label":`Line comments are written from the whole change`,className:`size-3.5`})}),(0,W.jsx)(y,{side:`bottom`,children:`A comment is anchored to the whole change, so switch to All commits to write one.`})]}):null]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,W.jsx)(ce,{additions:bt.additions,deletions:bt.deletions,className:`mr-1`}),St.length>0?(0,W.jsxs)(b,{children:[(0,W.jsx)(E,{render:(0,W.jsx)(u,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":wt?`Expand all files`:`Collapse all files`,onClick:Ot}),children:wt?(0,W.jsx)(we,{className:`size-3.5`}):(0,W.jsx)(A,{className:`size-3.5`})}),(0,W.jsx)(y,{side:`top`,children:wt?`Expand all files`:`Collapse all files`})]}):null,(0,W.jsxs)(j,{className:`shrink-0 gap-1`,size:`sm`,value:[ve],onValueChange:e=>{let t=e[0];(t===`stacked`||t===`split`)&&Ce(t)},children:[(0,W.jsx)(te,{"aria-label":`Stacked diff view`,value:`stacked`,variant:`ghost`,children:(0,W.jsx)(M,{className:`size-3.5`})}),(0,W.jsx)(te,{"aria-label":`Split diff view`,value:`split`,variant:`ghost`,children:(0,W.jsx)(ee,{className:`size-3.5`})})]}),(0,W.jsxs)(b,{children:[(0,W.jsx)(E,{render:(0,W.jsx)(te,{"aria-label":I?`Disable diff line wrapping`:`Enable diff line wrapping`,variant:`ghost`,size:`sm`,pressed:I,onPressedChange:e=>{je(!!e)}}),children:(0,W.jsx)(le,{className:`size-3.5`})}),(0,W.jsx)(y,{side:`top`,children:I?`Disable line wrapping`:`Enable line wrapping`})]})]})]}),Ut=e=>(0,W.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[Ht,(0,W.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`h-full overflow-auto`,children:e}),zt]})]});if(J.isPending&&K.length===0)return Ut((0,W.jsx)(se,{label:`Loading pull request diff...`}));if(J.error&&K.length===0)return Ut((0,W.jsx)(`p`,{className:`px-4 py-5 text-sm text-muted-foreground`,children:J.error}));let Wt=Q===null?_t.flatMap(e=>e?.kind===`raw`?[e]:[]):[];if(Z.length===0&&Wt.length>0)return Ut((0,W.jsx)(`div`,{className:`space-y-4 px-4 py-5`,children:Wt.map(e=>(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.reason}),(0,W.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs`,children:e.text})]},`${e.reason}:${e.text.slice(0,64)}`))}));if($.length===0&&Q===null)return Ut((0,W.jsx)(`p`,{className:`px-4 py-5 text-sm text-muted-foreground`,children:U===null?`This pull request has no file changes.`:`This commit has no file changes.`}));let Gt=n.reviewThreads.filter(e=>!yt.has(e.id)),Kt=new Map;for(let e of Gt){let t=Kt.get(e.path);t?t.push(e):Kt.set(e.path,[e])}let qt=Wt.length===0?null:(0,W.jsx)(`div`,{className:`space-y-4 border-t border-border/60 px-4 py-5`,children:Wt.map(e=>(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.reason}),(0,W.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs`,children:e.text})]},`${e.reason}:${e.text.slice(0,64)}`))});return(0,W.jsx)(_e,{children:(0,W.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[Ht,Kt.size>0?(0,W.jsxs)(Se,{className:`shrink-0 border-b border-border/60`,open:Ie,onOpenChange:Le,children:[(0,W.jsx)(`h2`,{children:(0,W.jsxs)(be,{className:`flex w-full items-center gap-1.5 px-4 py-2 text-left text-xs text-muted-foreground`,children:[(0,W.jsx)(`span`,{children:Q===null?`Conversations not on the current diff`:`Conversations not on the diff loaded so far`}),(0,W.jsx)(g,{"aria-hidden":!0,className:p(`size-3.5 transition-transform`,Ie&&`rotate-90`)}),(0,W.jsx)(`span`,{"aria-hidden":!0,className:`tabular-nums`,children:Gt.length}),(0,W.jsx)(`span`,{className:`sr-only`,children:Gt.length===1?`1 conversation`:`${Gt.length} conversations`})]})}),(0,W.jsx)(De,{children:(0,W.jsx)(`div`,{className:`max-h-64 space-y-3 overflow-auto px-4 pb-3`,children:[...Kt].map(([e,t])=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`truncate px-3 text-xs text-muted-foreground`,title:e,children:e}),(0,W.jsx)(`div`,{className:`mt-1 space-y-2`,children:t.map(e=>(0,W.jsxs)(`div`,{children:[e.line===null?null:(0,W.jsxs)(`p`,{className:`px-3 text-xs text-muted-foreground`,children:[`Line `,e.line]}),Lt(e)]},e.id))})]},e))})})]}):null,(0,W.jsxs)(`div`,{className:`relative min-h-0 flex-1`,onClickCapture:e=>{let t=e.nativeEvent.composedPath?.()??[];for(let e of t)if(e instanceof HTMLElement){if(e instanceof HTMLButtonElement||e instanceof HTMLAnchorElement)return;if(e.hasAttribute(`data-diffs-header`)){let t=e.querySelector(`[data-title]`)?.textContent?.trim();if(t===void 0||t===``)return;let n=$.find(e=>F(e.fileDiff)===t);n!==void 0&&Dt(n.id);return}}},children:[(0,W.jsx)(Ge,{className:`h-full overflow-auto [scrollbar-gutter:stable]`,items:$,selectedLines:Ne,onSelectedLinesChange:R,options:Ft,renderCodeViewFooter:Mt,renderHeaderPrefix:Nt,renderHeaderMetadata:Pt,renderAnnotation:Rt,unsafeCSSExtra:ft}),zt]}),qt]})})}export{X as PullRequestCodeTab,X as default};
|
|
251
|
-
//# sourceMappingURL=PullRequestCodeTab-
|
|
250
|
+
}`,pt=[];function mt(e){return e===`left`?`deletions`:`additions`}function ht(e){return e===`deletions`?`left`:`right`}function X({environmentId:e,reference:t,detail:n,selectedCommitOid:r,onSelectedCommitChange:i,pendingFinding:m,fixFindingLabel:x=`Fix in a thread`,onFixFinding:S,onAddToAgentSelection:C,onRefresh:T,refreshToken:k=0}){let{resolvedTheme:P}=p(),re=ne(),[ie,ae]=(0,L.useState)(()=>new Set),[le,de]=(0,L.useState)(dt),[pe,me]=(0,L.useState)(null),[_e,Se]=(0,L.useState)(`stacked`),[Ae,je]=(0,L.useState)(re.wordWrap),[Ne,R]=(0,L.useState)(null),[z,B]=(0,L.useState)(null),[Pe,Fe]=(0,L.useState)(!1),[Ie,Le]=(0,L.useState)(!1),[Re,ze]=(0,L.useState)(!1),[Be,V]=(0,L.useState)({key:``,cursor:null,slices:pt}),He=(0,L.useRef)(new Map),H=$e(t),U=r,G=U===null?H:`${H}@${U}`;(0,L.useEffect)(()=>{B(null),R(null),ae(new Set),me(null),de(dt),Le(!1),V({key:G,cursor:null,slices:pt}),He.current.clear()},[G]);let K=Be.key===G?Be.slices:pt,q=Be.key===G?Be.cursor:null,J=o(F.diff({environmentId:e,input:{...t,...q===null?{}:{cursor:q},...U===null?{}:{commit:U}}}));(0,L.useEffect)(()=>{let e=J.data;e!==null&&V(t=>{let n=t.key===G?t.slices:pt,r={cursor:q,patch:e.patch,truncated:e.truncated,nextCursor:e.nextCursor,omittedFileStats:e.omittedFileStats??[]},i=n.findIndex(e=>e.cursor===q);if(i===-1)return{key:G,cursor:q,slices:[...n,r]};let a=n[i];return a!==void 0&&a.patch===r.patch&&a.truncated===r.truncated&&a.nextCursor===r.nextCursor&&a.omittedFileStats.length===r.omittedFileStats.length&&a.omittedFileStats.every((e,t)=>{let n=r.omittedFileStats[t];return n!==void 0&&n.path===e.path&&n.additions===e.additions&&n.deletions===e.deletions})?t:{key:G,cursor:q,slices:[...n.slice(0,i),r]}})},[q,J.data,G]);let Ke=u(F.diff({environmentId:e,input:{...t,...U===null?{}:{commit:U}}})),qe=(0,L.useRef)(k);(0,L.useEffect)(()=>{qe.current!==k&&(qe.current=k,V({key:G,cursor:null,slices:pt}),Ke())},[k,G,Ke]);let Ye=H,Ze=tt(t),et=Y(e=>e.addComment),nt=Y(e=>e.removeComment),it=D(F.replyToThread,{reportFailure:!1}),at=D(F.setThreadResolution,{reportFailure:!1}),ot=D(F.updateComment,{reportFailure:!1}),st=D(F.diffFileContents),ct=(0,L.useMemo)(()=>Ue(st,{environmentId:e,reference:t,commit:U,cacheKey:`pull-request:${H}:${n.updatedAt}:${U??`all`}`}),[U,n.updatedAt,e,st,t,H]),X=(0,L.useMemo)(()=>{let e=n.capabilities.review,t=n.viewerPermissions;return{inlineComment:e.inlineComment&&t.comment,reply:e.reply&&t.comment,resolve:e.resolve&&t.resolve,verdicts:e.verdicts.filter(e=>t.verdicts.includes(e))}},[n.capabilities.review,n.viewerPermissions]),gt=X.inlineComment&&U===null,_t=(0,L.useMemo)(()=>K.map(e=>{let t=`pull-request:${G}:${P}:${e.cursor??`first`}:${be(e.patch)}`,n=He.current.get(t);if(n)return n;let r=Oe(e.patch,t,{compactPartialHunkOffsets:!0});return r&&He.current.set(t,r),r}),[K,P,G]),Z=(0,L.useMemo)(()=>_t.flatMap(e=>e?.kind===`files`?Ve(e.files):[]),[_t]),Q=K.at(-1)?.nextCursor??null,vt=K.some(e=>e.truncated)||_t.some(e=>e?.kind===`raw`),yt=(0,L.useMemo)(()=>{let e=new Set;if(U!==null)return e;for(let t of Z){let r=I(t);for(let i of n.reviewThreads)i.path===r&&i.line!==null&<(t,i.side,i.line)&&e.add(i.id)}return e},[U,n.reviewThreads,Z]),$=(0,L.useMemo)(()=>Z.map(e=>{let t=De(e),r=I(e),i=new Map,a=(e,t)=>{let n=`${e}:${t}`,r=i.get(n);if(r)return r;let a={side:e,line:t,threads:[],pending:[],draft:!1};return i.set(n,a),a};for(let e of n.reviewThreads)e.path!==r||e.line===null||yt.has(e.id)&&a(e.side,e.line).threads.push(e);if(U===null)for(let e of Ze)e.path===r&&a(e.side,e.line).pending.push(e);z?.fileKey===t&&(a(z.side,z.line).draft=!0);let o=ut(t,pe,ie),s=[...i.values()].map(e=>({side:mt(e.side),lineNumber:e.line,metadata:{threads:e.threads,pending:e.pending,draft:e.draft}}));return{id:t,type:`diff`,fileDiff:e,annotations:s,collapsed:o,version:be(`${o?`1`:`0`}:${s.map(({side:e,lineNumber:t,metadata:n})=>`${e}:${t}:${n.draft?`d`:``}:${n.pending.map(e=>`${e.id}:${e.body}`).join(`,`)}:${n.threads.map(e=>`${e.id}:${e.isResolved?`r`:``}:${e.isOutdated?`o`:``}:${e.comments.map(e=>`${e.id}:${e.author?.login??``}:${e.createdAt}:${e.body}:${(e.reactions??[]).map(e=>`${e.content}:${e.count}:${e.viewerHasReacted?`v`:``}`).join(`,`)}`).join(`;`)}`).join(`,`)}`).join(`|`)}`)}}),[U,n.reviewThreads,z,Z,pe,Ze,yt,ie]),bt=(0,L.useMemo)(()=>we(Z),[Z]),xt=(0,L.useMemo)(()=>new Map(K.flatMap(e=>e.omittedFileStats.map(e=>[e.path,e]))),[K]),St=(0,L.useMemo)(()=>$.map(e=>e.id),[$]),Ct=(0,L.useMemo)(()=>new Set($.filter(e=>e.collapsed===!0).map(e=>e.id)),[$]),wt=N(St,Ct),[Tt,Et]=(0,L.useState)(null);(0,L.useEffect)(()=>{if(Tt===null||Q===null||Q===q||J.isPending||J.error!==null)return;let e=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&V(e=>({...e,cursor:Q}))},{rootMargin:`240px`});return e.observe(Tt),()=>e.disconnect()},[q,J.error,J.isPending,Q,Tt]);let Dt=(0,L.useCallback)(e=>ae(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[]),Ot=()=>{me(N(St,Ct)?`expanded`:`folded`),ae(new Set)},kt=(0,L.useMemo)(()=>n.commits.toSorted((e,t)=>Date.parse(t.committedDate)-Date.parse(e.committedDate)),[n.commits]),At=(0,L.useCallback)((e,t)=>{if(!e||!gt)return;let n=t.item;if(n.type!==`diff`)return;let r=Z.find(e=>De(e)===n.id);if(!r)return;let i=I(r),a=ke(r);B({fileKey:n.id,path:i,oldPath:a===i?null:a,line:e.end,side:ht(e.endSide??e.side),range:e})},[gt,Z]),jt=(0,L.useCallback)((e,t,r)=>{let i=Z.find(t=>De(t)===e.fileKey),a=i===void 0?null:d({id:`pull-request-selection:${e.fileKey}:${e.range.start}:${e.range.end}`,sectionId:`pull-request:${n.number}`,sectionTitle:`PR #${n.number} review`,filePath:e.path,fileDiff:i,range:e.range,text:t});B(null),R(null),a!==null&&r(a)},[n.number,Z]),Mt=(0,L.useCallback)(()=>Q===null?null:(0,W.jsx)(`div`,{ref:Et,className:`flex items-center justify-center gap-2 py-2 text-xs text-muted-foreground`,children:J.error===null?J.isPending?`Loading more files...`:null:(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{children:`The rest of this diff could not be loaded.`}),(0,W.jsx)(l,{size:`xs`,variant:`outline`,onClick:()=>J.refresh(),children:`Retry`})]})}),[Q,J.error,J.isPending,J.refresh]),Nt=(0,L.useCallback)(e=>{let t=e.collapsed===!0;return(0,W.jsx)(`button`,{type:`button`,"aria-expanded":!t,"aria-label":t?`Expand diff`:`Collapse diff`,className:f(`mr-1 inline-flex size-5 items-center justify-center rounded text-muted-foreground transition-colors hover:text-foreground`),onClick:t=>{t.stopPropagation(),Dt(e.id)},children:t?(0,W.jsx)(h,{className:`size-4`}):(0,W.jsx)(_,{className:`size-4`})})},[Dt]),Pt=(0,L.useCallback)(e=>{if(e.type!==`diff`)return null;let t=0,n=0;for(let r of e.fileDiff.hunks)t+=r.additionLines,n+=r.deletionLines;if(t===0&&n===0){let r=xt.get(I(e.fileDiff));r&&({additions:t,deletions:n}=r)}return(0,W.jsx)(se,{additions:t,deletions:n,className:`font-mono text-[11px]`})},[xt]),Ft=(0,L.useMemo)(()=>({diffStyle:_e===`split`?`split`:`unified`,lineDiffType:`none`,overflow:Ae?`wrap`:`scroll`,theme:ve(P),themeType:P,stickyHeaders:!0,loadDiffFiles:ct,enableGutterUtility:gt&&z===null,enableLineSelection:gt&&z===null,onGutterUtilityClick:At,onLineSelectionEnd:At}),[_e,Ae,P,ct,gt,z,At]),It=(0,L.useCallback)(async(e,t)=>{if(Pe)return!1;Fe(!0);let n=await t();return Fe(!1),n._tag===`Failure`?(g.add({type:`error`,title:e}),!1):(T(),!0)},[T,Pe]),Lt=(0,L.useCallback)(r=>(0,W.jsx)(Xe,{thread:r,workspaceRoot:n.workspaceRoot,canReply:X.reply,canResolve:X.resolve,canReact:n.capabilities.reactions===!0,environmentId:e,reference:t,pending:Pe,fixPending:m===fe({kind:`thread`,thread:r}),fixLabel:x,...S?{onFix:()=>S({kind:`thread`,thread:r})}:{},onReply:n=>It(`Reply could not be posted`,()=>it({environmentId:e,input:{...t,threadId:r.id,body:n}})),canEditComment:e=>ue(n,{author:e.author,kind:`review-comment`}),onEditComment:(n,r)=>It(`The comment could not be saved`,()=>ot({environmentId:e,input:{...t,commentId:n,kind:`review-comment`,body:r}})),onToggleResolved:()=>void It(`The conversation could not be updated`,()=>at({environmentId:e,input:{...t,threadId:r.id,resolved:!r.isResolved}})),onReacted:T},`${t.projectId}#${t.number}:${r.id}`),[n,e,x,T,S,m,t,it,X.reply,X.resolve,It,at,Pe,ot]),Rt=(0,L.useCallback)(e=>(0,W.jsxs)(`div`,{className:`py-1 font-sans text-foreground`,children:[e.metadata.threads.map(Lt),e.metadata.pending.map(e=>(0,W.jsx)(Je,{comment:e,onRemove:()=>nt(Ye,e.id)},e.id)),e.metadata.draft&&z?(0,W.jsx)(We,{kind:`draft`,rangeLabel:`${z.path}:${z.line}`,text:``,submitLabel:`Add to review`,...C?{secondaryAction:{label:`Add to agent`,onAction:e=>jt(z,e,t=>C({comment:t,request:e}))}}:{},onCancel:()=>{B(null),R(null)},onComment:e=>{et(Ye,{id:Qe(),path:z.path,...z.oldPath===null?{}:{oldPath:z.oldPath},line:z.line,side:z.side,body:e}),B(null),R(null)}}):null]}),[et,jt,z,C,nt,Lt,Ye]),zt=X.verdicts.length===0?null:(0,W.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 z-10`,children:Re?(0,W.jsxs)(`div`,{className:`chat-composer-glass pointer-events-auto absolute inset-x-3 bottom-3 rounded-xl border border-border/60 shadow-lg`,children:[(0,W.jsx)(l,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Close review`,className:`absolute right-2 top-2`,onClick:()=>ze(!1),children:(0,W.jsx)(w,{className:`size-3.5`})}),(0,W.jsx)(rt,{environmentId:e,reference:t,verdicts:X.verdicts,onSubmitted:()=>{T(),ze(!1)}})]}):(0,W.jsxs)(`button`,{type:`button`,className:`chat-composer-glass pointer-events-auto absolute bottom-3 right-4 flex items-center gap-1.5 rounded-full border border-border/60 px-3 py-1.5 text-xs font-medium shadow-lg`,onClick:()=>ze(!0),children:[(0,W.jsx)(he,{className:`size-3.5`}),`Review`,Ze.length>0?(0,W.jsx)(`span`,{className:`flex size-4 items-center justify-center rounded-full bg-accent text-[10px] tabular-nums text-accent-foreground`,children:Ze.length}):null]})}),Bt=kt.find(e=>e.oid===U);(0,L.useEffect)(()=>{U!==null&&Bt===void 0&&i(null)},[U,i,Bt]);let Vt=Bt?Bt.messageHeadline:`All commits`,Ht=(0,W.jsxs)(`div`,{className:`surface-subheader justify-between gap-2 px-4 text-xs text-muted-foreground`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[kt.length>0?(0,W.jsxs)(s,{children:[(0,W.jsxs)(c,{className:`inline-flex h-6 max-w-64 items-center gap-1 rounded-md bg-accent px-2 text-xs font-medium text-accent-foreground outline-none transition-colors hover:bg-accent/80 focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Diff scope: ${Vt}`,children:[(0,W.jsx)(`span`,{className:`truncate`,children:Vt}),(0,W.jsx)(_,{className:`size-3.5 shrink-0 opacity-70`})]}),(0,W.jsxs)(a,{align:`start`,className:`w-80`,children:[(0,W.jsx)(O,{className:U===null?`bg-foreground/[0.08]`:void 0,onClick:()=>i(null),children:(0,W.jsx)(`span`,{children:`All commits`})}),kt.slice(0,le).map(e=>(0,W.jsxs)(O,{className:e.oid===U?`bg-foreground/[0.08]`:void 0,onClick:()=>i(e.oid),children:[(0,W.jsx)(`span`,{className:`min-w-0 truncate`,title:e.messageHeadline,children:e.messageHeadline}),(0,W.jsx)(`span`,{className:`ml-auto shrink-0 font-mono text-xs text-muted-foreground`,children:e.oid.slice(0,7)})]},e.oid)),kt.length>le?(0,W.jsx)(O,{closeOnClick:!1,onClick:()=>de(e=>e+dt),children:(0,W.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Show more (`,kt.length-le,` left)`]})}):null]})]}):null,(0,W.jsxs)(Te,{children:[(0,W.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[Z.length,` `,Z.length===1?`file`:`files`,Q===null?``:`+`]}),vt?(0,W.jsxs)(y,{children:[(0,W.jsx)(E,{render:(0,W.jsx)(`span`,{className:`flex shrink-0 items-center`}),children:(0,W.jsx)(b,{"aria-label":`Some of this diff was not shown`,className:`size-3.5 text-amber-600 dark:text-amber-500`})}),(0,W.jsx)(v,{side:`bottom`,children:`The host withheld part of this diff — a binary file, or a change too large to inline.`})]}):null,U!==null&&X.inlineComment?(0,W.jsxs)(y,{children:[(0,W.jsx)(E,{render:(0,W.jsx)(`span`,{className:`flex shrink-0 items-center`}),children:(0,W.jsx)(Me,{"aria-label":`Line comments are written from the whole change`,className:`size-3.5`})}),(0,W.jsx)(v,{side:`bottom`,children:`A comment is anchored to the whole change, so switch to All commits to write one.`})]}):null]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,W.jsx)(se,{additions:bt.additions,deletions:bt.deletions,className:`mr-1`}),St.length>0?(0,W.jsxs)(y,{children:[(0,W.jsx)(E,{render:(0,W.jsx)(l,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":wt?`Expand all files`:`Collapse all files`,onClick:Ot}),children:wt?(0,W.jsx)(Ce,{className:`size-3.5`}):(0,W.jsx)(A,{className:`size-3.5`})}),(0,W.jsx)(v,{side:`top`,children:wt?`Expand all files`:`Collapse all files`})]}):null,(0,W.jsxs)(j,{className:`shrink-0 gap-1`,size:`sm`,value:[_e],onValueChange:e=>{let t=e[0];(t===`stacked`||t===`split`)&&Se(t)},children:[(0,W.jsx)(te,{"aria-label":`Stacked diff view`,value:`stacked`,variant:`ghost`,children:(0,W.jsx)(M,{className:`size-3.5`})}),(0,W.jsx)(te,{"aria-label":`Split diff view`,value:`split`,variant:`ghost`,children:(0,W.jsx)(ee,{className:`size-3.5`})})]}),(0,W.jsxs)(y,{children:[(0,W.jsx)(E,{render:(0,W.jsx)(te,{"aria-label":Ae?`Disable diff line wrapping`:`Enable diff line wrapping`,variant:`ghost`,size:`sm`,pressed:Ae,onPressedChange:e=>{je(!!e)}}),children:(0,W.jsx)(ce,{className:`size-3.5`})}),(0,W.jsx)(v,{side:`top`,children:Ae?`Disable line wrapping`:`Enable line wrapping`})]})]})]}),Ut=e=>(0,W.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[Ht,(0,W.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`h-full overflow-auto`,children:e}),zt]})]});if(J.isPending&&K.length===0)return Ut((0,W.jsx)(oe,{label:`Loading pull request diff...`}));if(J.error&&K.length===0)return Ut((0,W.jsx)(`p`,{className:`px-4 py-5 text-sm text-muted-foreground`,children:J.error}));let Wt=Q===null?_t.flatMap(e=>e?.kind===`raw`?[e]:[]):[];if(Z.length===0&&Wt.length>0)return Ut((0,W.jsx)(`div`,{className:`space-y-4 px-4 py-5`,children:Wt.map(e=>(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.reason}),(0,W.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs`,children:e.text})]},`${e.reason}:${e.text.slice(0,64)}`))}));if($.length===0&&Q===null)return Ut((0,W.jsx)(`p`,{className:`px-4 py-5 text-sm text-muted-foreground`,children:U===null?`This pull request has no file changes.`:`This commit has no file changes.`}));let Gt=n.reviewThreads.filter(e=>!yt.has(e.id)),Kt=new Map;for(let e of Gt){let t=Kt.get(e.path);t?t.push(e):Kt.set(e.path,[e])}let qt=Wt.length===0?null:(0,W.jsx)(`div`,{className:`space-y-4 border-t border-border/60 px-4 py-5`,children:Wt.map(e=>(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.reason}),(0,W.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs`,children:e.text})]},`${e.reason}:${e.text.slice(0,64)}`))});return(0,W.jsx)(ge,{children:(0,W.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[Ht,Kt.size>0?(0,W.jsxs)(xe,{className:`shrink-0 border-b border-border/60`,open:Ie,onOpenChange:Le,children:[(0,W.jsx)(`h2`,{children:(0,W.jsxs)(ye,{className:`flex w-full items-center gap-1.5 px-4 py-2 text-left text-xs text-muted-foreground`,children:[(0,W.jsx)(`span`,{children:Q===null?`Conversations not on the current diff`:`Conversations not on the diff loaded so far`}),(0,W.jsx)(h,{"aria-hidden":!0,className:f(`size-3.5 transition-transform`,Ie&&`rotate-90`)}),(0,W.jsx)(`span`,{"aria-hidden":!0,className:`tabular-nums`,children:Gt.length}),(0,W.jsx)(`span`,{className:`sr-only`,children:Gt.length===1?`1 conversation`:`${Gt.length} conversations`})]})}),(0,W.jsx)(Ee,{children:(0,W.jsx)(`div`,{className:`max-h-64 space-y-3 overflow-auto px-4 pb-3`,children:[...Kt].map(([e,t])=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`truncate px-3 text-xs text-muted-foreground`,title:e,children:e}),(0,W.jsx)(`div`,{className:`mt-1 space-y-2`,children:t.map(e=>(0,W.jsxs)(`div`,{children:[e.line===null?null:(0,W.jsxs)(`p`,{className:`px-3 text-xs text-muted-foreground`,children:[`Line `,e.line]}),Lt(e)]},e.id))})]},e))})})]}):null,(0,W.jsxs)(`div`,{className:`relative min-h-0 flex-1`,onClickCapture:e=>{let t=e.nativeEvent.composedPath?.()??[];for(let e of t)if(e instanceof HTMLElement){if(e instanceof HTMLButtonElement||e instanceof HTMLAnchorElement)return;if(e.hasAttribute(`data-diffs-header`)){let t=e.querySelector(`[data-title]`)?.textContent?.trim();if(t===void 0||t===``)return;let n=$.find(e=>I(e.fileDiff)===t);n!==void 0&&Dt(n.id);return}}},children:[(0,W.jsx)(Ge,{className:`h-full overflow-auto [scrollbar-gutter:stable]`,items:$,selectedLines:Ne,onSelectedLinesChange:R,options:Ft,renderCodeViewFooter:Mt,renderHeaderPrefix:Nt,renderHeaderMetadata:Pt,renderAnnotation:Rt,unsafeCSSExtra:ft}),zt]}),qt]})})}export{X as PullRequestCodeTab,X as default};
|
|
251
|
+
//# sourceMappingURL=PullRequestCodeTab-BUVi3FWm.js.map
|
package/dist/client/assets/{fileCommentAnnotations-BhUKh-pg.js → fileCommentAnnotations-BfBnLApA.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{$ as i,Ma as a}from"./previewAssetResource-
|
|
2
|
-
//# sourceMappingURL=fileCommentAnnotations-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{$ as i,Ma as a}from"./previewAssetResource-DZZapyaR.js";import{Ir as o,Xr as s}from"./index-BopiBtUj.js";var c=r(),l=e(n(),1),u=t();function d(e){let t=(0,c.c)(44),{kind:n,rangeLabel:r,text:d,onCancel:m,onComment:h,onDelete:g}=e,[_,v]=(0,l.useState)(``);if(n===`comment`){let e,n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,u.jsx)(s,{className:`size-4 text-muted-foreground`}),n=(0,u.jsx)(`span`,{className:`text-xs font-medium`,children:`Local comment`}),t[0]=e,t[1]=n):(e=t[0],n=t[1]);let i;t[2]===r?i=t[3]:(i=(0,u.jsx)(`span`,{className:`ml-auto text-[11px] text-muted-foreground`,children:r}),t[2]=r,t[3]=i);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,u.jsx)(o,{className:`size-3.5`}),t[4]=c):c=t[4];let l;t[5]===g?l=t[6]:(l=(0,u.jsx)(a,{variant:`ghost`,size:`icon-xs`,"aria-label":`Delete comment`,onClick:g,children:c}),t[5]=g,t[6]=l);let f;t[7]!==i||t[8]!==l?(f=(0,u.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e,n,i,l]}),t[7]=i,t[8]=l,t[9]=f):f=t[9];let m;t[10]===d?m=t[11]:(m=(0,u.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-sm leading-relaxed text-foreground`,children:d}),t[10]=d,t[11]=m);let h;return t[12]!==f||t[13]!==m?(h=(0,u.jsxs)(`div`,{"data-file-comment-annotation":!0,className:`mx-3 my-2 rounded-xl border border-border/70 bg-background p-3 shadow-sm`,contentEditable:!1,onPointerDown:p,children:[f,m]}),t[12]=f,t[13]=m,t[14]=h):h=t[14],h}let y;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,u.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,u.jsx)(s,{className:`size-4 text-muted-foreground`}),(0,u.jsx)(`span`,{className:`text-sm font-medium`,children:`Local comment`})]}),t[15]=y):y=t[15];let b;t[16]===r?b=t[17]:(b=(0,u.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Comment on lines `,r]}),t[16]=r,t[17]=b);let x=`Comment on lines ${r}`,S;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>v(e.target.value),t[18]=S):S=t[18];let C;t[19]!==m||t[20]!==h||t[21]!==_?(C=e=>{e.key===`Escape`&&(e.preventDefault(),m()),(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&_.trim()&&(e.preventDefault(),h(_.trim()))},t[19]=m,t[20]=h,t[21]=_,t[22]=C):C=t[22];let w;t[23]!==x||t[24]!==C||t[25]!==_?(w=(0,u.jsx)(i,{autoFocus:!0,className:`mt-3`,size:`sm`,value:_,placeholder:`Request change`,"aria-label":x,onChange:S,onKeyDown:C}),t[23]=x,t[24]=C,t[25]=_,t[26]=w):w=t[26];let T;t[27]===m?T=t[28]:(T=(0,u.jsx)(a,{variant:`ghost`,size:`sm`,onClick:m,children:`Cancel`}),t[27]=m,t[28]=T);let E;t[29]===_?E=t[30]:(E=_.trim(),t[29]=_,t[30]=E);let D=!E,O;t[31]!==h||t[32]!==_?(O=()=>h(_.trim()),t[31]=h,t[32]=_,t[33]=O):O=t[33];let k;t[34]!==O||t[35]!==D?(k=(0,u.jsx)(a,{size:`sm`,disabled:D,onClick:O,children:`Comment`}),t[34]=O,t[35]=D,t[36]=k):k=t[36];let A;t[37]!==k||t[38]!==T?(A=(0,u.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[T,k]}),t[37]=k,t[38]=T,t[39]=A):A=t[39];let j;return t[40]!==A||t[41]!==b||t[42]!==w?(j=(0,u.jsxs)(`div`,{"data-file-comment-annotation":!0,className:`mx-3 my-2 rounded-xl border border-border/70 bg-background p-3 shadow-lg`,contentEditable:!1,onPointerDown:f,children:[y,b,w,A]}),t[40]=A,t[41]=b,t[42]=w,t[43]=j):j=t[43],j}function f(e){return e.stopPropagation()}function p(e){return e.stopPropagation()}var m=0;function h(){return m+=1,`file-comment-${Date.now()}-${m}`}function g(e){return{startLine:Math.min(e.start,e.end),endLine:Math.max(e.start,e.end)}}function _(e,t){return e===t?`L${e}`:`L${e} to L${t}`}function v(e){return e.map(e=>({...e,metadata:{entries:e.metadata.entries.map(t=>{let n=t.endLine-t.startLine;return{...t,endLine:e.lineNumber,startLine:Math.max(1,e.lineNumber-n)}})}}))}export{d as a,v as i,h as n,g as r,_ as t};
|
|
2
|
+
//# sourceMappingURL=fileCommentAnnotations-BfBnLApA.js.map
|