import{n as e,s as t}from"./rolldown-runtime-Czos8NxU.js";import{Bt as n,El as r,Ft as i,Pt as a,Rt as o,Tl as s,Xs as c,bt as l,cl as u,gt as d,mn as f,tc as p,ul as m,vl as h,zt as g}from"./app-initial~app-main~worktree-init-v2-page~appgen-settings-page~page~appgen-publication-ter~fzo5ij6p-BKVLyD1q.js";import{Bo as _,Gc as ee,Lx as v,Ly as te,Ob as y,Rc as b,Rx as ne,Ry as x,Wy as S,Yy as C,Zy as re,b_ as ie,bl as ae,kb as oe,x_ as w,yl as T,zo as E}from"./app-initial~app-main~onboarding-page-CNHnOMz8.js";import{$h as se,Ar as ce,Da as le,Ea as ue,F_ as D,Gd as O,I_ as k,P as de,R as A,Sh as fe,Sx as j,V_ as M,Yn as N,as as P,fv as F,na as I,pv as L,qd as pe,ts as me,ua as R,wx as z,yx as B}from"./app-initial~app-main~new-thread-panel-page-BZHGOlMi.js";import{$ as V,L as H,Q as U,Z as W,dt as G,et as K,gt as he,z as q}from"./app-initial~app-main~worktree-init-v2-page~remote-conversation-page~pull-requests-page~new-~djgpfzje-C7Uyb8hp.js";import{M as J,N as ge}from"./app-initial~app-main~worktree-init-v2-page~remote-conversation-page~pull-requests-page~new-~mam8fk3d-QYu6Tutl.js";import{Y,Z as _e}from"./app-initial~app-main~remote-conversation-page~new-thread-panel-page~appgen-library-page~hot~djo67r4n-DfdeaLvo.js";import{c as ve,s as X}from"./app-initial~app-main~local-conversation-page-CVMYzWpY.js";import{n as ye,t as be}from"./use-git-recent-branches-BlqbwMky.js";var xe,Se=e((()=>{xe=`# Review Guidelines

You are acting as a reviewer for a proposed code change made by another engineer.

Review the change and respond in normal Markdown. Do not return JSON, XML, a findings object, or any structured review schema.

When feedback should be attached directly to a changed line, emit one \`::code-comment{...}\` directive for that issue. The directive creates an inline code comment in the review UI; keep the visible response as normal Markdown. Emit no directives when there are no actionable inline comments.

Required \`code-comment\` attributes: \`title\`, \`body\`, and \`file\`. Optional attributes: \`start\`, \`end\`, and \`priority\`. Use the shortest useful line range. \`file\` should be an absolute path or include the workspace folder segment.

Focus on discrete, actionable issues the original author would likely fix if they knew about them. Prefer no issues over speculative or low-signal feedback.

General guidelines for whether to call out an issue:

1. It meaningfully impacts correctness, performance, security, or maintainability.
2. It is discrete and actionable.
3. It was introduced by the change under review.
4. The author would likely fix it once aware.
5. It does not rely on unstated assumptions about intent.
6. It identifies the affected behavior clearly rather than speculating broadly.

When you call out an issue, include the relevant file and line or function in prose, explain the scenario where it matters, and keep the explanation concise. Use priority labels such as \`[P1]\` or \`[P2]\` only when helpful to communicate severity.

If there are no actionable issues, say that directly and briefly.
`}));function Ce({reviewInstructions:e,requestMessage:t}){return[D,xe.trim(),e.trim(),k,t].join(`
`)}async function we({context:e,hostId:t,intl:n}){if(e.mode===`uncommitted`)return{diffFilter:`unstaged`,prompt:Ce({reviewInstructions:Oe,requestMessage:n.formatMessage({id:`quickAction.request.codeReview.uncommitted`,defaultMessage:`Please review my uncommitted changes`,description:`User message used when reviewing uncommitted changes`})}),baseBranch:null};let r=await d(`git-merge-base`,{source:`review_model`,params:{gitRoot:e.gitRoot,baseBranch:e.baseBranch,hostId:t}});if(!r.mergeBaseSha)throw Error(`Failed to resolve a merge base between HEAD and ${e.baseBranch}.`);let i=n.formatMessage({id:`quickAction.request.codeReview.branches`,defaultMessage:`Please review changes on {from} against {to}`,description:`User message used when reviewing against a selected base branch`},{from:e.sourceBranch,to:e.baseBranch});return{diffFilter:`branch`,prompt:Ce({reviewInstructions:De.replaceAll(`{baseBranch}`,e.baseBranch).replaceAll(`{mergeBaseSha}`,r.mergeBaseSha.trim()),requestMessage:i}),baseBranch:e.baseBranch}}function Te(e){let t=(0,Ee.c)(13),{hostId:n,onError:r,onSuccess:a}=e,s=p(o),c=z(),l=A(n),u;t[0]!==n||t[1]!==l||t[2]!==c||t[3]!==s?(u=async e=>{let{context:t,conversationId:r,delivery:i}=e,{gitRoot:a,cwd:o}=t,u=await we({context:t,hostId:n,intl:c}),d=r==null?null:s.get(ce,r);if(i===`inline`&&r!=null&&d===n){if(l==null)throw Error(`Code review host is unavailable`);return await L(`start-turn-for-host`,{hostId:l.getHostId(),conversationId:r,params:{cwd:o,input:[{type:`text`,text:u.prompt,text_elements:[]}],approvalsReviewer:`user`,collaborationMode:null,inheritThreadSettings:!1,serviceTier:await w(s,n,null)}}),{delivery:`inline`,diffFilter:u.diffFilter,baseBranch:u.baseBranch}}let f=await L(`start-conversation`,{hostId:n,input:[{type:`text`,text:u.prompt,text_elements:[]}],cwd:o,workspaceRoots:[a],collaborationMode:null,serviceTier:await w(s,n,null),approvalsReviewer:`user`});return{baseBranch:u.baseBranch,conversationId:f,delivery:`detached`,diffFilter:u.diffFilter}},t[0]=n,t[1]=l,t[2]=c,t[3]=s,t[4]=u):u=t[4];let d;t[5]===a?d=t[6]:(d=e=>{a(e)},t[5]=a,t[6]=d);let f;t[7]===r?f=t[8]:(f=e=>{i.error(`Failed to start quick review conversation`,{safe:{},sensitive:{error:e}}),r(e)},t[7]=r,t[8]=f);let h;return t[9]!==u||t[10]!==d||t[11]!==f?(h={mutationFn:u,onSuccess:d,onError:f},t[9]=u,t[10]=d,t[11]=f,t[12]=h):h=t[12],m(h)}var Ee,De,Oe,ke=e((()=>{Ee=s(),u(),c(),B(),de(),N(),F(),ie(),Se(),M(),g(),a(),l(),De="Review the code changes against the base branch '{baseBranch}'. The merge base commit for this comparison is {mergeBaseSha}. Run `git diff {mergeBaseSha}` to inspect the changes relative to {baseBranch}. Provide concise, actionable feedback in a normal Markdown response.",Oe=`Review the current code changes (staged, unstaged, and untracked files) and provide concise, actionable feedback in a normal Markdown response.`}));function Ae(e,t,n,r){let i=(0,je.c)(2),a;return i[0]===n?a=i[1]:(a=e=>{let{root:t}=e;return{operationSource:n,root:t}},i[0]=n,i[1]=a),R(e,t,`base-branch`,a,n,r)}var je,Me=e((()=>{je=s(),I()}));function Ne({currentBranch:e,defaultTargetBranch:t,recentBranches:n}){let r=[],i=[t??Pe],a=new Set;return e&&a.add(e),n!=null&&i.push(...n),i.forEach(e=>{!e||a.has(e)||(r.push(e),a.add(e))}),r}var Pe,Fe=e((()=>{Pe=`main`}));function Ie(e){let t=(0,Z.c)(24),{onSelectUnstaged:n,onSelectBaseBranch:r,isSubmitting:i,isLoadingBaseBranch:a,requiresXcodeLicense:o,isRetryingGit:s,onRetryGit:c}=e,l=z();if(o){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(E,{className:`icon-xs shrink-0 text-token-charts-red`}),t[0]=e):e=t[0];let n;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(`span`,{className:`font-medium text-token-foreground`,children:(0,Q.jsx)(j,{id:`composer.reviewMode.xcodeLicenseRequired.title`,defaultMessage:`Review the Xcode license to use Git`,description:`Title shown when Git cannot run until the user accepts the Xcode license`})}),t[1]=n):n=t[1];let r;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[n,(0,Q.jsx)(`span`,{className:`text-token-description-foreground`,children:(0,Q.jsx)(j,{id:`composer.reviewMode.xcodeLicenseRequired.detail`,defaultMessage:`In your terminal, run <command>sudo xcodebuild -license</command>, follow the prompts, and try again.`,description:`Instructions shown when Git cannot run until the user accepts the Xcode license`,values:{command:Le}})})]}),t[2]=r):r=t[2];let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsx)(j,{id:`composer.reviewMode.xcodeLicenseRequired.retry`,defaultMessage:`Try again`,description:`Button label for retrying Git after accepting the Xcode license`}),t[3]=i):i=t[3];let a;return t[4]!==s||t[5]!==c?(a=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-sm`,role:`alert`,children:[e,r,(0,Q.jsx)(W,{className:`shrink-0`,loading:s,onClick:c,size:`composerSm`,children:i})]}),t[4]=s,t[5]=c,t[6]=a):a=t[6],a}let u;t[7]===l?u=t[8]:(u=l.formatMessage({id:`composer.reviewMode.option.baseBranch.simple`,defaultMessage:`Review against a base branch`,description:`Button label for reviewing against a base branch`}),t[7]=l,t[8]=u);let d=i||a,f=a?V:void 0,p;t[9]!==r||t[10]!==u||t[11]!==d||t[12]!==f?(p=(0,Q.jsx)(X,{value:`base-branch`,title:u,onSelect:r,disabled:d,RightIcon:f}),t[9]=r,t[10]=u,t[11]=d,t[12]=f,t[13]=p):p=t[13];let m;t[14]===l?m=t[15]:(m=l.formatMessage({id:`composer.reviewMode.option.unstaged.simple`,defaultMessage:`Review uncommitted changes`,description:`Button label for reviewing unstaged changes`}),t[14]=l,t[15]=m);let h=i?V:void 0,g;t[16]!==i||t[17]!==n||t[18]!==m||t[19]!==h?(g=(0,Q.jsx)(X,{value:`unstaged`,title:m,onSelect:n,disabled:i,RightIcon:h}),t[16]=i,t[17]=n,t[18]=m,t[19]=h,t[20]=g):g=t[20];let _;return t[21]!==p||t[22]!==g?(_=(0,Q.jsxs)(Q.Fragment,{children:[p,g]}),t[21]=p,t[22]=g,t[23]=_):_=t[23],_}function Le(e){return(0,Q.jsx)(`code`,{className:`font-mono`,children:e},`command`)}function Re(e){let t=(0,Z.c)(10),{onSelect:n,branchLines:r,isLoading:i,isError:a,refetchBranchOverview:o,submittingBranchName:s}=e,c=s!=null,l;t[0]!==r||t[1]!==a||t[2]!==i||t[3]!==c||t[4]!==n||t[5]!==o||t[6]!==s?(l=i?(0,Q.jsx)(`div`,{className:`flex items-center justify-center gap-2 py-4 text-xs text-token-foreground/70`,children:(0,Q.jsx)(V,{className:`size-3`})}):a?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 py-2`,children:[(0,Q.jsx)(`span`,{className:`text-center text-xs text-token-foreground/70`,children:(0,Q.jsx)(j,{id:`composer.reviewMode.branches.error`,defaultMessage:`Unable to load branches`,description:`Error message when branch list could not be loaded`})}),(0,Q.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-token-text-link-foreground`,onClick:o,children:(0,Q.jsx)(j,{id:`composer.reviewMode.branches.retry`,defaultMessage:`Retry`,description:`Retry button for branch list error`})})]}):r.map(e=>(0,Q.jsx)(X,{value:e.label,title:e.label,onSelect:n,disabled:c,RightIcon:s===e.key?V:void 0},e.key)),t[0]=r,t[1]=a,t[2]=i,t[3]=c,t[4]=n,t[5]=o,t[6]=s,t[7]=l):l=t[7];let u;return t[8]===l?u=t[9]:(u=(0,Q.jsx)(Q.Fragment,{children:l}),t[8]=l,t[9]=u),u}var Z,Q,ze=e((()=>{Z=s(),B(),U(),K(),_(),ve(),Q=h()}));function Be(e){let t=(0,He.c)(63),{conversationId:n,onItemsChanged:r,onClose:a,cwd:o,hostConfig:s}=e,c=p(me),l=z(),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u={status:`choose-target`},t[0]=u):u=t[0];let[d,m]=(0,Ue.useState)(u),h=ge(),g;t[1]===s.id?g=t[2]:(g={hostId:s.id,source:`review_mode_content`},t[1]=s.id,t[2]=g);let{gitRoot:_}=_e(o,g),{data:v,error:y,isFetching:b,isLoading:x,refetch:C}=ae(_,s,`review_mode_content`),{data:ie,isLoading:w,isError:T,refetch:E}=Ae(_,s,`review_mode_content`),{data:se,isLoading:ce,isError:ue,refetch:D}=ye(_,s,`review_mode_content`),O=te(ie??null),k=he(f.reviewDelivery),de=Ne({currentBranch:v,defaultTargetBranch:O,recentBranches:se}),A=w||ce,j=T||ue,M;t[3]!==E||t[4]!==D?(M=()=>{Promise.all([E(),D()])},t[3]=E,t[4]=D,t[5]=M):M=t[5];let N=M,P;t[6]!==l||t[7]!==c?(P=e=>{i.error(`Failed to start code review`,{safe:{},sensitive:{error:e}}),c.get(q).danger(l.formatMessage({id:`composer.reviewMode.quickReviewError`,defaultMessage:`Failed to start code review.`,description:`Toast shown when quick review action fails`}))},t[6]=l,t[7]=c,t[8]=P):P=t[8];let F;t[9]!==n||t[10]!==h||t[11]!==c?(F=e=>{if(re(c,e.diffFilter),e.delivery===`detached`){S(c,e.conversationId,e.baseBranch),h(e.conversationId);return}S(c,n,e.baseBranch);let t=c.get(oe.activeTab$)?.tabId;ee(c,!t?.startsWith(`sidechat:`)),c.set(ne,!1)},t[9]=n,t[10]=h,t[11]=c,t[12]=F):F=t[12];let I;t[13]!==s.id||t[14]!==P||t[15]!==F?(I={hostId:s.id,onError:P,onSuccess:F},t[13]=s.id,t[14]=P,t[15]=F,t[16]=I):I=t[16];let{mutate:L,isPending:R,variables:B}=Te(I),V=R&&B?.context.mode===`base-branch`?B.context.baseBranch:null,H;t[17]!==n||t[18]!==v||t[19]!==o||t[20]!==_||t[21]!==l||t[22]!==R||t[23]!==a||t[24]!==r||t[25]!==k||t[26]!==c||t[27]!==L?(H=e=>{if(!R){if(!_){c.get(q).danger(l.formatMessage({id:`composer.reviewMode.gitRoot.error`,defaultMessage:`Git root not found`,description:`Toast shown when git root not found`}));return}if(e===`base-branch`){pe(c,fe,{target:`base_branch`}),m({status:`choose-base`}),r();return}pe(c,fe,{target:`unstaged`}),L({conversationId:n,context:{mode:`uncommitted`,sourceBranch:v??`HEAD`,gitRoot:_,cwd:o},delivery:k??`inline`},{onSuccess:a})}},t[17]=n,t[18]=v,t[19]=o,t[20]=_,t[21]=l,t[22]=R,t[23]=a,t[24]=r,t[25]=k,t[26]=c,t[27]=L,t[28]=H):H=t[28];let U=H,W;t[29]!==n||t[30]!==v||t[31]!==o||t[32]!==_||t[33]!==l||t[34]!==R||t[35]!==a||t[36]!==k||t[37]!==c||t[38]!==L?(W=e=>{if(!R){if(!_){c.get(q).danger(l.formatMessage({id:`composer.reviewMode.gitRoot.error`,defaultMessage:`Git root not found`,description:`Toast shown when git root not found`}));return}L({conversationId:n,context:{mode:`base-branch`,sourceBranch:v??`HEAD`,baseBranch:e,gitRoot:_,cwd:o},delivery:k??`inline`},{onSuccess:a})}},t[29]=n,t[30]=v,t[31]=o,t[32]=_,t[33]=l,t[34]=R,t[35]=a,t[36]=k,t[37]=c,t[38]=L,t[39]=W):W=t[39];let G=W;if(d.status===`choose-target`){let e,n;t[40]===U?(e=t[41],n=t[42]):(n=()=>U(`unstaged`),e=()=>U(`base-branch`),t[40]=U,t[41]=e,t[42]=n);let r;t[43]===y?r=t[44]:(r=le(y),t[43]=y,t[44]=r);let i;t[45]===C?i=t[46]:(i=()=>{C()},t[45]=C,t[46]=i);let a;return t[47]!==b||t[48]!==x||t[49]!==R||t[50]!==e||t[51]!==r||t[52]!==i||t[53]!==n?(a=(0,$.jsx)(Ie,{onSelectUnstaged:n,onSelectBaseBranch:e,isSubmitting:R,isLoadingBaseBranch:x,requiresXcodeLicense:r,isRetryingGit:b,onRetryGit:i}),t[47]=b,t[48]=x,t[49]=R,t[50]=e,t[51]=r,t[52]=i,t[53]=n,t[54]=a):a=t[54],a}let K=Re,J=de.map(Ve),Y;return t[55]!==K||t[56]!==G||t[57]!==j||t[58]!==A||t[59]!==N||t[60]!==V||t[61]!==J?(Y=(0,$.jsx)(K,{onSelect:G,branchLines:J,isLoading:A,isError:j,refetchBranchOverview:N,submittingBranchName:V}),t[55]=K,t[56]=G,t[57]=j,t[58]=A,t[59]=N,t[60]=V,t[61]=J,t[62]=Y):Y=t[62],Y}function Ve(e){return{key:e,label:e}}var He,Ue,$;e((()=>{He=s(),se(),c(),n(),Ue=t(r(),1),B(),ke(),v(),y(),H(),ue(),Me(),T(),be(),O(),C(),x(),P(),G(),b(),Y(),a(),J(),Fe(),ze(),$=h()}))();export{Be as ReviewModeContent};
//# sourceMappingURL=review-mode-content-CKAFHiEI.js.map