@p4code/cli 0.2.5 → 0.2.6

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 CHANGED
@@ -237,7 +237,7 @@ const make$87 = () => {
237
237
  const layer$79 = Layer.sync(NetService, make$87);
238
238
  //#endregion
239
239
  //#region package.json
240
- var version = "0.2.5";
240
+ var version = "0.2.6";
241
241
  //#endregion
242
242
  //#region src/config.ts
243
243
  /**
@@ -8925,10 +8925,13 @@ var ProjectListEntriesError = class extends Schema$1.TaggedErrorClass()("Project
8925
8925
  });
8926
8926
  }
8927
8927
  };
8928
- const ProjectReadFileInput = Schema$1.Struct({
8928
+ const ProjectReadFileInput = Schema$1.Union([Schema$1.Struct({
8929
8929
  cwd: TrimmedNonEmptyString,
8930
8930
  relativePath: TrimmedNonEmptyString.check(Schema$1.isMaxLength(PROJECT_READ_FILE_PATH_MAX_LENGTH))
8931
- });
8931
+ }), Schema$1.Struct({
8932
+ cwd: TrimmedNonEmptyString,
8933
+ absolutePath: TrimmedNonEmptyString.check(Schema$1.isMaxLength(PROJECT_READ_FILE_PATH_MAX_LENGTH))
8934
+ })]);
8932
8935
  const ProjectReadFileResult = Schema$1.Struct({
8933
8936
  relativePath: TrimmedNonEmptyString,
8934
8937
  contents: Schema$1.String,
@@ -8944,6 +8947,7 @@ const ProjectReadFileResult = Schema$1.Struct({
8944
8947
  const ProjectFileFailure = Schema$1.Literals([
8945
8948
  "workspace_path_outside_root",
8946
8949
  "resolved_path_outside_root",
8950
+ "path_not_found",
8947
8951
  "path_not_file",
8948
8952
  "operation_failed"
8949
8953
  ]);
@@ -8960,6 +8964,7 @@ const ProjectFileOperation = Schema$1.Literals([
8960
8964
  var ProjectReadFileError = class extends Schema$1.TaggedErrorClass()("ProjectReadFileError", {
8961
8965
  cwd: Schema$1.optional(TrimmedNonEmptyString),
8962
8966
  relativePath: Schema$1.optional(TrimmedNonEmptyString),
8967
+ absolutePath: Schema$1.optional(TrimmedNonEmptyString),
8963
8968
  failure: Schema$1.optional(ProjectFileFailure),
8964
8969
  resolvedPath: Schema$1.optional(TrimmedNonEmptyString),
8965
8970
  resolvedWorkspaceRoot: Schema$1.optional(TrimmedNonEmptyString),
@@ -8969,9 +8974,11 @@ var ProjectReadFileError = class extends Schema$1.TaggedErrorClass()("ProjectRea
8969
8974
  cause: Schema$1.optional(Schema$1.Defect())
8970
8975
  }) {
8971
8976
  constructor(props) {
8977
+ const requestedPath = props.absolutePath ?? props.relativePath ?? "unknown";
8978
+ const message = props.failure === "workspace_path_outside_root" || props.failure === "resolved_path_outside_root" ? `File '${requestedPath}' is outside workspace root '${props.cwd}'.` : props.failure === "path_not_found" ? `File '${requestedPath}' was not found.` : `Failed to read workspace file '${requestedPath}' in '${props.cwd}'.`;
8972
8979
  super({
8973
8980
  ...props,
8974
- message: decodedProjectErrorMessage(props) ?? `Failed to read workspace file '${props.relativePath}' in '${props.cwd}'.`
8981
+ message: decodedProjectErrorMessage(props) ?? message
8975
8982
  });
8976
8983
  }
8977
8984
  };
@@ -45544,15 +45551,24 @@ const make$40 = Effect.gen(function* () {
45544
45551
  const workspacePaths = yield* WorkspacePaths;
45545
45552
  const workspaceEntries = yield* WorkspaceEntries;
45546
45553
  const readFile = Effect.fn("WorkspaceFileSystem.readFile")(function* (input) {
45547
- const target = yield* workspacePaths.resolveRelativePathWithinRoot({
45554
+ const requestedPath = "absolutePath" in input ? input.absolutePath : input.relativePath;
45555
+ const isAbsoluteRead = "absolutePath" in input;
45556
+ const target = isAbsoluteRead ? {
45557
+ absolutePath: input.absolutePath,
45558
+ relativePath: input.absolutePath
45559
+ } : yield* workspacePaths.resolveRelativePathWithinRoot({
45548
45560
  workspaceRoot: input.cwd,
45549
45561
  relativePath: input.relativePath
45550
45562
  });
45551
- const realWorkspaceRoot = yield* Effect.tryPromise({
45563
+ if (isAbsoluteRead && !path.isAbsolute(target.absolutePath)) return yield* new WorkspacePathOutsideRootError({
45564
+ workspaceRoot: input.cwd,
45565
+ relativePath: requestedPath
45566
+ });
45567
+ const realWorkspaceRoot = isAbsoluteRead ? void 0 : yield* Effect.tryPromise({
45552
45568
  try: () => NodeFSP.realpath(input.cwd),
45553
45569
  catch: (cause) => new WorkspaceFileSystemOperationError({
45554
45570
  workspaceRoot: input.cwd,
45555
- relativePath: input.relativePath,
45571
+ relativePath: requestedPath,
45556
45572
  resolvedPath: target.absolutePath,
45557
45573
  operationPath: input.cwd,
45558
45574
  operation: "realpath-workspace-root",
@@ -45563,17 +45579,17 @@ const make$40 = Effect.gen(function* () {
45563
45579
  try: () => NodeFSP.realpath(target.absolutePath),
45564
45580
  catch: (cause) => new WorkspaceFileSystemOperationError({
45565
45581
  workspaceRoot: input.cwd,
45566
- relativePath: input.relativePath,
45582
+ relativePath: requestedPath,
45567
45583
  resolvedPath: target.absolutePath,
45568
45584
  operationPath: target.absolutePath,
45569
45585
  operation: "realpath-target",
45570
45586
  cause
45571
45587
  })
45572
45588
  });
45573
- const relativeRealPath = path.relative(realWorkspaceRoot, realTargetPath);
45574
- if (relativeRealPath.startsWith(`..${path.sep}`) || relativeRealPath === ".." || path.isAbsolute(relativeRealPath)) return yield* new WorkspaceFilePathEscapeError({
45589
+ const relativeRealPath = realWorkspaceRoot ? path.relative(realWorkspaceRoot, realTargetPath) : void 0;
45590
+ if (realWorkspaceRoot && relativeRealPath !== void 0 && (relativeRealPath.startsWith(`..${path.sep}`) || relativeRealPath === ".." || path.isAbsolute(relativeRealPath))) return yield* new WorkspaceFilePathEscapeError({
45575
45591
  workspaceRoot: input.cwd,
45576
- relativePath: input.relativePath,
45592
+ relativePath: requestedPath,
45577
45593
  resolvedWorkspaceRoot: realWorkspaceRoot,
45578
45594
  resolvedPath: realTargetPath
45579
45595
  });
@@ -45581,7 +45597,7 @@ const make$40 = Effect.gen(function* () {
45581
45597
  try: () => NodeFSP.open(realTargetPath, "r"),
45582
45598
  catch: (cause) => new WorkspaceFileSystemOperationError({
45583
45599
  workspaceRoot: input.cwd,
45584
- relativePath: input.relativePath,
45600
+ relativePath: requestedPath,
45585
45601
  resolvedPath: realTargetPath,
45586
45602
  operationPath: realTargetPath,
45587
45603
  operation: "open",
@@ -45592,7 +45608,7 @@ const make$40 = Effect.gen(function* () {
45592
45608
  try: () => handle.stat(),
45593
45609
  catch: (cause) => new WorkspaceFileSystemOperationError({
45594
45610
  workspaceRoot: input.cwd,
45595
- relativePath: input.relativePath,
45611
+ relativePath: requestedPath,
45596
45612
  resolvedPath: realTargetPath,
45597
45613
  operationPath: realTargetPath,
45598
45614
  operation: "stat",
@@ -45601,7 +45617,7 @@ const make$40 = Effect.gen(function* () {
45601
45617
  });
45602
45618
  if (!stat.isFile()) return yield* new WorkspacePathNotFileError({
45603
45619
  workspaceRoot: input.cwd,
45604
- relativePath: input.relativePath,
45620
+ relativePath: requestedPath,
45605
45621
  resolvedPath: realTargetPath
45606
45622
  });
45607
45623
  const bytesToRead = Math.min(stat.size, PROJECT_READ_FILE_MAX_BYTES);
@@ -45610,7 +45626,7 @@ const make$40 = Effect.gen(function* () {
45610
45626
  try: () => handle.read(buffer, 0, bytesToRead, 0),
45611
45627
  catch: (cause) => new WorkspaceFileSystemOperationError({
45612
45628
  workspaceRoot: input.cwd,
45613
- relativePath: input.relativePath,
45629
+ relativePath: requestedPath,
45614
45630
  resolvedPath: realTargetPath,
45615
45631
  operationPath: realTargetPath,
45616
45632
  operation: "read",
@@ -45636,7 +45652,7 @@ const make$40 = Effect.gen(function* () {
45636
45652
  try: () => handle.close(),
45637
45653
  catch: (cause) => new WorkspaceFileSystemOperationError({
45638
45654
  workspaceRoot: input.cwd,
45639
- relativePath: input.relativePath,
45655
+ relativePath: requestedPath,
45640
45656
  resolvedPath: realTargetPath,
45641
45657
  operationPath: realTargetPath,
45642
45658
  operation: "close",
@@ -59017,12 +59033,17 @@ function filesystemBrowseFailureContext(error) {
59017
59033
  function projectFileFailureContext(error) {
59018
59034
  switch (error._tag) {
59019
59035
  case "WorkspacePathOutsideRootError": return { failure: "workspace_path_outside_root" };
59020
- case "WorkspaceFileSystemOperationError": return {
59021
- failure: "operation_failed",
59022
- resolvedPath: error.resolvedPath,
59023
- operation: error.operation,
59024
- operationPath: error.operationPath
59025
- };
59036
+ case "WorkspaceFileSystemOperationError":
59037
+ if (error.operation === "realpath-target" && error.cause instanceof Error && "code" in error.cause && error.cause.code === "ENOENT") return {
59038
+ failure: "path_not_found",
59039
+ resolvedPath: error.resolvedPath
59040
+ };
59041
+ return {
59042
+ failure: "operation_failed",
59043
+ resolvedPath: error.resolvedPath,
59044
+ operation: error.operation,
59045
+ operationPath: error.operationPath
59046
+ };
59026
59047
  case "WorkspaceFilePathEscapeError": return {
59027
59048
  failure: "resolved_path_outside_root",
59028
59049
  resolvedPath: error.resolvedPath,
@@ -59235,6 +59256,7 @@ const makeWsRpcLayer = (currentSession, previewAutomationBroker) => WsRpcGroup.t
59235
59256
  const serverSelfUpdate = yield* ServerSelfUpdate;
59236
59257
  const textGeneration = yield* TextGeneration;
59237
59258
  const config = yield* ServerConfig$1;
59259
+ const allowAbsoluteFileReads = config.mode === "desktop" && !isRemoteReachableHost(config.host);
59238
59260
  const lifecycleEvents = yield* ServerLifecycleEvents;
59239
59261
  const serverSettings = yield* ServerSettingsService;
59240
59262
  const hubLink = yield* HubLink;
@@ -59943,11 +59965,17 @@ const makeWsRpcLayer = (currentSession, previewAutomationBroker) => WsRpcGroup.t
59943
59965
  ...projectEntriesFailureContext(cause),
59944
59966
  cause
59945
59967
  }))), { "rpc.aggregate": "workspace" }),
59946
- [WS_METHODS.projectsReadFile]: (input) => observeRpcEffect$1(WS_METHODS.projectsReadFile, workspaceFileSystem.readFile(input).pipe(Effect.mapError((cause) => new ProjectReadFileError({
59947
- ...input,
59948
- ...projectFileFailureContext(cause),
59949
- cause
59950
- }))), { "rpc.aggregate": "workspace" }),
59968
+ [WS_METHODS.projectsReadFile]: (input) => observeRpcEffect$1(WS_METHODS.projectsReadFile, Effect.gen(function* () {
59969
+ if ("absolutePath" in input && !allowAbsoluteFileReads) return yield* new ProjectReadFileError({
59970
+ ...input,
59971
+ failure: "workspace_path_outside_root"
59972
+ });
59973
+ return yield* workspaceFileSystem.readFile(input).pipe(Effect.mapError((cause) => new ProjectReadFileError({
59974
+ ...input,
59975
+ ...projectFileFailureContext(cause),
59976
+ cause
59977
+ })));
59978
+ }), { "rpc.aggregate": "workspace" }),
59951
59979
  [WS_METHODS.projectsWriteFile]: (input) => observeRpcEffect$1(WS_METHODS.projectsWriteFile, workspaceFileSystem.writeFile(input).pipe(Effect.mapError((cause) => new ProjectWriteFileError({
59952
59980
  cwd: input.cwd,
59953
59981
  relativePath: input.relativePath,
@@ -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{$s as i,Ci as a,Di as o,Fi as s,Fn as ee,Ii as c,Li as l,Nc as te,Ni as ne,Oc as u,Oi as d,Pi as re,Qs as f,Rc as p,S as m,Sc as h,Tt as g,Zs as _,_c as ie,am as v,b as y,ct as b,ec as x,i as S,j as C,kn as ae,ol as w,u as T,v as E,wn as D,xt as oe,y as O,yi as k}from"./terminal-links-C6S74E9U.js";import{t as A}from"./arrow-right-B2X51S6S.js";import{a as se,i as j,n as M,o as ce,r as le,s as ue,t as de}from"./toggle-group-CxBIRzrW.js";import{F as fe,Gr as pe,I as me,J as he,L as N,Qr as ge,Si as _e,Ur as ve,Wr as ye,Xr as be,_ as xe,ar as Se,at as Ce,cr as we,ct as Te,dr as Ee,dt as De,fr as Oe,h as ke,hr as Ae,lr as je,lt as Me,or as Ne,ot as Pe,pr as Fe,q as Ie,qr as Le,sr as Re,st as ze,ur as Be,ut as Ve,xi as He,xr as Ue}from"./index-IyXnER5Q.js";import{a as P,n as We}from"./fileCommentAnnotations-BZ_k09XR.js";var Ge=x(`pilcrow`,[[`path`,{d:`M13 4v16`,key:`8vvj80`}],[`path`,{d:`M17 4v16`,key:`7dpous`}],[`path`,{d:`M19 4H9.5a4.5 4.5 0 0 0 0 9H13`,key:`sh4n9v`}]]),F=e(n(),1);function Ke({threadRef:e,filePath:t,activeCwd:n,openInEditor:r}){if(e){E.getState().openFile(e,t);return}r(n?S(t,n):t)}var I=r();function qe(e,t){let n=(0,I.c)(4),r=Ae(e,t),i;return n[0]!==r.data||n[1]!==r.error||n[2]!==r.isPending?(i={data:r.data,error:r.error,isPending:r.isPending},n[0]=r.data,n[1]=r.error,n[2]=r.isPending,n[3]=i):i=n[3],i}var L=t(),Je=[];function Ye(e){return(e.endSide??e.side)===`deletions`?`deletions`:`additions`}function R(e,t,n){let r=Ye(t),i=e.findIndex(e=>e.side===r&&e.lineNumber===t.end);return i<0?[...e,{side:r,lineNumber:t.end,metadata:{entries:[n]}}]:e.map((e,t)=>t===i?{...e,metadata:{entries:[...e.metadata.entries,n]}}:e)}function Xe(e){let t=(0,I.c)(50),{files:n,sectionId:r,sectionTitle:i,composerDraftTarget:a,options:o,viewerRef:s,className:c,renderHeaderPrefix:l}=e,te=D($e),ne=D(B),u;t[0]===a?u=t[1]:(u=e=>e.getComposerDraft(a)?.reviewComments??Je,t[0]=a,t[1]=u);let d=D(u),[re,f]=(0,F.useState)(null),[p,m]=(0,F.useState)(null),h;t[2]===n?h=t[3]:(h=new Map(n.map(Qe)),t[2]=n,t[3]=h);let g=h,_;if(t[4]!==p||t[5]!==n||t[6]!==d||t[7]!==r){let e;t[9]!==p||t[10]!==d||t[11]!==r?(e=e=>{let{fileDiff:t,filePath:n,fileKey:i,collapsed:a}=e,o=d.filter(e=>e.sectionId===r&&e.filePath===n&&(e.fenceLanguage??`diff`)===`diff`).reduce((e,n)=>{let r=ee(t,n);return r?R(e,r,{id:n.id,kind:`comment`,range:r,rangeLabel:n.rangeLabel,text:n.text}):e},[]),s=p?.fileKey===i?[...o,p.annotation]:o;return{id:i,type:`diff`,fileDiff:t,annotations:s,collapsed:a,version:Pe(`${a?`1`:`0`}:${s.flatMap(z).join(`:`)}`)}},t[9]=p,t[10]=d,t[11]=r,t[12]=e):e=t[12],_=n.map(e),t[4]=p,t[5]=n,t[6]=d,t[7]=r,t[8]=_}else _=t[8];let ie=_,v;t[13]!==a||t[14]!==p?.annotation||t[15]!==ne?(v=e=>{f(null),p?.annotation.metadata.entries.some(t=>t.id===e)?m(null):ne(a,e)},t[13]=a,t[14]=p?.annotation,t[15]=ne,t[16]=v):v=t[16];let y=v,b;t[17]!==te||t[18]!==a||t[19]!==p||t[20]!==g||t[21]!==r||t[22]!==i?(b=(e,t)=>{let n=p?.annotation.metadata.entries.find(t=>t.id===e),o=p?g.get(p.fileKey):void 0;if(!n||!o)return;let s=ae({id:n.id,sectionId:r,sectionTitle:i,filePath:o.filePath,fileDiff:o.fileDiff,range:n.range,text:t});s&&te(a,s),f(null),m(null)},t[17]=te,t[18]=a,t[19]=p,t[20]=g,t[21]=r,t[22]=i,t[23]=b):b=t[23];let x=b,S;t[24]!==g||t[25]!==r||t[26]!==i?(S=(e,t)=>{if(!e)return;let n=t.item;if(n.type!==`diff`)return;let a=g.get(n.id);if(!a)return;let o=We(),s=ae({id:o,sectionId:r,sectionTitle:i,filePath:a.filePath,fileDiff:a.fileDiff,range:e,text:``});s&&m({fileKey:n.id,annotation:{side:Ye(e),lineNumber:e.end,metadata:{entries:[{id:o,kind:`draft`,range:e,rangeLabel:s.rangeLabel,text:``}]}}})},t[24]=g,t[25]=r,t[26]=i,t[27]=S):S=t[27];let C=S,w=p!==null,T;t[28]===s?T=t[29]:(T=s?{ref:s}:{},t[28]=s,t[29]=T);let E;t[30]===c?E=t[31]:(E=c?{className:c}:{},t[30]=c,t[31]=E);let oe=!w,O=!w,k;t[32]!==C||t[33]!==o||t[34]!==O||t[35]!==oe?(k={...o,enableGutterUtility:oe,enableLineSelection:O,onLineSelectionEnd:C},t[32]=C,t[33]=o,t[34]=O,t[35]=oe,t[36]=k):k=t[36];let A;t[37]===l?A=t[38]:(A=e=>e.type===`diff`?l(e.fileDiff,e.id,e.collapsed===!0):null,t[37]=l,t[38]=A);let j;t[39]!==y||t[40]!==x?(j=e=>(0,L.jsx)(`div`,{className:`py-1`,children:e.metadata.entries.map(e=>(0,L.jsx)(P,{kind:e.kind,rangeLabel:e.rangeLabel,text:e.text,onCancel:()=>y(e.id),onComment:t=>x(e.id,t),onDelete:()=>y(e.id)},e.id))}),t[39]=y,t[40]=x,t[41]=j):j=t[41];let M;return t[42]!==ie||t[43]!==re||t[44]!==k||t[45]!==A||t[46]!==j||t[47]!==T||t[48]!==E?(M=(0,L.jsx)(se,{...T,...E,items:ie,selectedLines:re,onSelectedLinesChange:f,options:k,renderHeaderPrefix:A,renderAnnotation:j}),t[42]=ie,t[43]=re,t[44]=k,t[45]=A,t[46]=j,t[47]=T,t[48]=E,t[49]=M):M=t[49],M}function z(e){return e.metadata.entries.map(Ze)}function Ze(e){return`${e.id}:${e.rangeLabel}:${e.text}`}function Qe(e){return[e.fileKey,e]}function B(e){return e.removeReviewComment}function $e(e){return e.addReviewComment}function et(e){return{diffPreview:h(e,{label:`environment-data:review:diff-preview`,tag:w.reviewGetDiffPreview,staleTimeMs:5e3})}}var tt=et(g);function V(e){return e.remoteName&&e.name.startsWith(`${e.remoteName}/`)?e.name.slice(e.remoteName.length+1):e.name}function nt(e,t){let n=new Set(t),r=e.map(e=>{let r=t.filter(t=>n.has(t)&&V(t)===e.name),i=r.find(e=>e.remoteName===`origin`)??r[0]??null;return i&&n.delete(i),{id:`local:${e.name}`,label:e.name,local:e,remote:i}}),i=t.filter(e=>n.has(e)).map(e=>({id:`remote:${e.name}`,label:e.name,local:null,remote:e}));return[...r,...i]}function rt(e,t){let n=t.trim().toLocaleLowerCase();return n.length===0?e:e.filter(e=>e.label.toLocaleLowerCase().includes(n)||e.local?.name.toLocaleLowerCase().includes(n)===!0||e.remote?.name.toLocaleLowerCase().includes(n)===!0)}var H=`__automatic_base_ref__`,it=new Set,at=`
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{$s as i,Ci as a,Di as o,Fi as s,Fn as ee,Ii as c,Li as l,Nc as te,Ni as ne,Oc as u,Oi as d,Pi as re,Qs as f,Rc as p,S as m,Sc as h,Tt as g,Zs as _,_c as ie,am as v,b as y,ct as b,ec as x,i as S,j as C,kn as ae,ol as w,u as T,v as E,wn as D,xt as oe,y as O,yi as k}from"./terminal-links-Dcw5kSW5.js";import{t as A}from"./arrow-right-CB1n5rpS.js";import{a as se,i as j,n as M,o as ce,r as le,s as ue,t as de}from"./toggle-group-DngghwoH.js";import{F as fe,Gr as pe,I as me,J as he,L as N,Qr as ge,Si as _e,Ur as ve,Wr as ye,Xr as be,_ as xe,ar as Se,at as Ce,cr as we,ct as Te,dr as Ee,dt as De,fr as Oe,h as ke,hr as Ae,lr as je,lt as Me,or as Ne,ot as Pe,pr as Fe,q as Ie,qr as Le,sr as Re,st as ze,ur as Be,ut as Ve,xi as He,xr as Ue}from"./index-Cvhs37GD.js";import{a as P,n as We}from"./fileCommentAnnotations-Ckjc-0ZU.js";var Ge=x(`pilcrow`,[[`path`,{d:`M13 4v16`,key:`8vvj80`}],[`path`,{d:`M17 4v16`,key:`7dpous`}],[`path`,{d:`M19 4H9.5a4.5 4.5 0 0 0 0 9H13`,key:`sh4n9v`}]]),F=e(n(),1);function Ke({threadRef:e,filePath:t,activeCwd:n,openInEditor:r}){if(e){E.getState().openFile(e,t);return}r(n?S(t,n):t)}var I=r();function qe(e,t){let n=(0,I.c)(4),r=Ae(e,t),i;return n[0]!==r.data||n[1]!==r.error||n[2]!==r.isPending?(i={data:r.data,error:r.error,isPending:r.isPending},n[0]=r.data,n[1]=r.error,n[2]=r.isPending,n[3]=i):i=n[3],i}var L=t(),Je=[];function Ye(e){return(e.endSide??e.side)===`deletions`?`deletions`:`additions`}function R(e,t,n){let r=Ye(t),i=e.findIndex(e=>e.side===r&&e.lineNumber===t.end);return i<0?[...e,{side:r,lineNumber:t.end,metadata:{entries:[n]}}]:e.map((e,t)=>t===i?{...e,metadata:{entries:[...e.metadata.entries,n]}}:e)}function Xe(e){let t=(0,I.c)(50),{files:n,sectionId:r,sectionTitle:i,composerDraftTarget:a,options:o,viewerRef:s,className:c,renderHeaderPrefix:l}=e,te=D($e),ne=D(B),u;t[0]===a?u=t[1]:(u=e=>e.getComposerDraft(a)?.reviewComments??Je,t[0]=a,t[1]=u);let d=D(u),[re,f]=(0,F.useState)(null),[p,m]=(0,F.useState)(null),h;t[2]===n?h=t[3]:(h=new Map(n.map(Qe)),t[2]=n,t[3]=h);let g=h,_;if(t[4]!==p||t[5]!==n||t[6]!==d||t[7]!==r){let e;t[9]!==p||t[10]!==d||t[11]!==r?(e=e=>{let{fileDiff:t,filePath:n,fileKey:i,collapsed:a}=e,o=d.filter(e=>e.sectionId===r&&e.filePath===n&&(e.fenceLanguage??`diff`)===`diff`).reduce((e,n)=>{let r=ee(t,n);return r?R(e,r,{id:n.id,kind:`comment`,range:r,rangeLabel:n.rangeLabel,text:n.text}):e},[]),s=p?.fileKey===i?[...o,p.annotation]:o;return{id:i,type:`diff`,fileDiff:t,annotations:s,collapsed:a,version:Pe(`${a?`1`:`0`}:${s.flatMap(z).join(`:`)}`)}},t[9]=p,t[10]=d,t[11]=r,t[12]=e):e=t[12],_=n.map(e),t[4]=p,t[5]=n,t[6]=d,t[7]=r,t[8]=_}else _=t[8];let ie=_,v;t[13]!==a||t[14]!==p?.annotation||t[15]!==ne?(v=e=>{f(null),p?.annotation.metadata.entries.some(t=>t.id===e)?m(null):ne(a,e)},t[13]=a,t[14]=p?.annotation,t[15]=ne,t[16]=v):v=t[16];let y=v,b;t[17]!==te||t[18]!==a||t[19]!==p||t[20]!==g||t[21]!==r||t[22]!==i?(b=(e,t)=>{let n=p?.annotation.metadata.entries.find(t=>t.id===e),o=p?g.get(p.fileKey):void 0;if(!n||!o)return;let s=ae({id:n.id,sectionId:r,sectionTitle:i,filePath:o.filePath,fileDiff:o.fileDiff,range:n.range,text:t});s&&te(a,s),f(null),m(null)},t[17]=te,t[18]=a,t[19]=p,t[20]=g,t[21]=r,t[22]=i,t[23]=b):b=t[23];let x=b,S;t[24]!==g||t[25]!==r||t[26]!==i?(S=(e,t)=>{if(!e)return;let n=t.item;if(n.type!==`diff`)return;let a=g.get(n.id);if(!a)return;let o=We(),s=ae({id:o,sectionId:r,sectionTitle:i,filePath:a.filePath,fileDiff:a.fileDiff,range:e,text:``});s&&m({fileKey:n.id,annotation:{side:Ye(e),lineNumber:e.end,metadata:{entries:[{id:o,kind:`draft`,range:e,rangeLabel:s.rangeLabel,text:``}]}}})},t[24]=g,t[25]=r,t[26]=i,t[27]=S):S=t[27];let C=S,w=p!==null,T;t[28]===s?T=t[29]:(T=s?{ref:s}:{},t[28]=s,t[29]=T);let E;t[30]===c?E=t[31]:(E=c?{className:c}:{},t[30]=c,t[31]=E);let oe=!w,O=!w,k;t[32]!==C||t[33]!==o||t[34]!==O||t[35]!==oe?(k={...o,enableGutterUtility:oe,enableLineSelection:O,onLineSelectionEnd:C},t[32]=C,t[33]=o,t[34]=O,t[35]=oe,t[36]=k):k=t[36];let A;t[37]===l?A=t[38]:(A=e=>e.type===`diff`?l(e.fileDiff,e.id,e.collapsed===!0):null,t[37]=l,t[38]=A);let j;t[39]!==y||t[40]!==x?(j=e=>(0,L.jsx)(`div`,{className:`py-1`,children:e.metadata.entries.map(e=>(0,L.jsx)(P,{kind:e.kind,rangeLabel:e.rangeLabel,text:e.text,onCancel:()=>y(e.id),onComment:t=>x(e.id,t),onDelete:()=>y(e.id)},e.id))}),t[39]=y,t[40]=x,t[41]=j):j=t[41];let M;return t[42]!==ie||t[43]!==re||t[44]!==k||t[45]!==A||t[46]!==j||t[47]!==T||t[48]!==E?(M=(0,L.jsx)(se,{...T,...E,items:ie,selectedLines:re,onSelectedLinesChange:f,options:k,renderHeaderPrefix:A,renderAnnotation:j}),t[42]=ie,t[43]=re,t[44]=k,t[45]=A,t[46]=j,t[47]=T,t[48]=E,t[49]=M):M=t[49],M}function z(e){return e.metadata.entries.map(Ze)}function Ze(e){return`${e.id}:${e.rangeLabel}:${e.text}`}function Qe(e){return[e.fileKey,e]}function B(e){return e.removeReviewComment}function $e(e){return e.addReviewComment}function et(e){return{diffPreview:h(e,{label:`environment-data:review:diff-preview`,tag:w.reviewGetDiffPreview,staleTimeMs:5e3})}}var tt=et(g);function V(e){return e.remoteName&&e.name.startsWith(`${e.remoteName}/`)?e.name.slice(e.remoteName.length+1):e.name}function nt(e,t){let n=new Set(t),r=e.map(e=>{let r=t.filter(t=>n.has(t)&&V(t)===e.name),i=r.find(e=>e.remoteName===`origin`)??r[0]??null;return i&&n.delete(i),{id:`local:${e.name}`,label:e.name,local:e,remote:i}}),i=t.filter(e=>n.has(e)).map(e=>({id:`remote:${e.name}`,label:e.name,local:null,remote:e}));return[...r,...i]}function rt(e,t){let n=t.trim().toLocaleLowerCase();return n.length===0?e:e.filter(e=>e.label.toLocaleLowerCase().includes(n)||e.local?.name.toLocaleLowerCase().includes(n)===!0||e.remote?.name.toLocaleLowerCase().includes(n)===!0)}var H=`__automatic_base_ref__`,it=new Set,at=`
2
2
  [data-diffs-header],
3
3
  [data-diff],
4
4
  [data-file],
@@ -95,4 +95,4 @@ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}f
95
95
  text-decoration-color: currentColor;
96
96
  }
97
97
  `;function U({mode:e=`inline`,composerDraftTarget:t,initialGitScope:n}){let{resolvedTheme:r}=T(),ee=Le(),[h]=(0,F.useState)(n),[g,x]=(0,F.useState)(`stacked`),[S,ae]=(0,F.useState)(ee.wordWrap),[w,E]=(0,F.useState)(ee.diffIgnoreWhitespace),[D,se]=(0,F.useState)(``),[xe,Ae]=(0,F.useState)(()=>({scopeKey:null,fileKeys:it})),Pe=(0,F.useRef)(null),P=v({strict:!1,select:e=>b(e)}),We=P?.threadId??null,I=pe(P),Je=I?.projectId??null,Ye=ye(I&&Je?{environmentId:I.environmentId,projectId:Je}:null),R=I?.worktreePath??Ye?.workspaceRoot,z=ie(oe.configValueAtom(I?.environmentId??null)),Ze=Fe(I?.environmentId??null,z?.availableEditors??[]),Qe=C(I!=null&&R!=null?ve.status({environmentId:I.environmentId,input:{cwd:R}}):null),B=N(e=>me(e.byThreadKey,P,h===`unstaged`)),$e=Qe.data?.isRepo??!0,{turnDiffSummaries:et,inferredCheckpointTurnCountByTurnId:V}=fe(I),U=(0,F.useMemo)(()=>[...et].toSorted((e,t)=>{let n=e.checkpointTurnCount??V[e.turnId]??0,r=t.checkpointTurnCount??V[t.turnId]??0;return n===r?t.completedAt.localeCompare(e.completedAt):r-n}),[V,et]);(0,F.useEffect)(()=>{!P||B.kind!==`turn`||N.getState().reconcileTurnSelection(P,U.map(e=>e.turnId))},[B,U,P]);let W=B.kind===`turn`?B.turnId:null,G=B.kind===`unstaged`?`unstaged`:`branch`,K=B.kind===`branch`?B.baseRef:null,ot=B.kind===`turn`?B.filePath:null,st=B.kind===`turn`?B.revealRequestId:0,q=W===null?void 0:U.find(e=>e.turnId===W)??U[0],J=q&&(q.checkpointTurnCount??V[q.turnId]),ct=U[0],lt=W===null?G===`unstaged`?`Working tree`:`Branch changes`:q?.turnId===ct?.turnId?`Latest turn`:`Turn ${J??`?`}`,ut=q?`turn:${q.turnId}`:G,Y=P?`${P.environmentId}:${P.threadId}:${ut}`:null,dt=xe.scopeKey===Y?xe.fileKeys:it,ft=q?`Turn ${J??`?`}`:G===`unstaged`?`Working tree`:`Branch changes`,pt=(0,F.useMemo)(()=>typeof J==`number`?{fromTurnCount:Math.max(0,J-1),toTurnCount:J}:null,[J]),mt=qe({environmentId:I?.environmentId??null,threadId:We,fromTurnCount:pt?.fromTurnCount??null,toTurnCount:pt?.toTurnCount??null,ignoreWhitespace:w,cacheScope:q?`turn:${q.turnId}`:null},{enabled:$e&&q!==void 0}),ht=C(W===null&&I&&R?tt.diffPreview({environmentId:I.environmentId,input:{cwd:R,...K?{baseRef:K}:{},ignoreWhitespace:w}}):null),gt=W===null&&ht.error?.includes(`configured workspace root`)===!0&&z?.cwd!==void 0&&z.cwd!==R,_t=C(gt&&I&&z?tt.diffPreview({environmentId:I.environmentId,input:{cwd:z.cwd,...K?{baseRef:K}:{},ignoreWhitespace:w}}):null),X=gt?_t:ht,Z=X.data?.sources.find(e=>e.kind===(G===`unstaged`?`working-tree`:`branch-range`)),vt=C(W===null&&G===`branch`&&I&&X.data?.cwd?ve.listRefs({environmentId:I.environmentId,input:{cwd:X.data.cwd,includeMatchingRemoteRefs:!0,refKind:`local`,...D.trim().length>0?{query:D.trim()}:{},limit:100}}):null),yt=C(W===null&&G===`branch`&&I&&X.data?.cwd?ve.listRefs({environmentId:I.environmentId,input:{cwd:X.data.cwd,includeMatchingRemoteRefs:!0,refKind:`remote`,...D.trim().length>0?{query:D.trim()}:{},limit:100}}):null),bt=nt(vt.data?.refs.filter(e=>e.name!==Z?.headRef)??[],yt.data?.refs??[]),xt=rt(bt,D),St=e=>K&&K===e.remote?.name?K:e.local?.name??e.remote?.name??e.id,Ct=[H,...bt.map(St)],wt=[...D.trim().length===0?[H]:[],...xt.map(St)],Tt=Z?.diff,Et=q?mt.data?.diff:Tt,Dt=!q&&Z?.truncated===!0,Ot=q?mt.isPending:X.isPending,kt=q?mt.error:X.error,At=typeof Et==`string`&&Et.trim().length===0,Q=(0,F.useMemo)(()=>Me(Et,`diff-panel:${r}`,{compactPartialHunkOffsets:W===null}),[r,Et,W]),jt=(0,F.useMemo)(()=>!Q||Q.kind!==`files`?[]:Q.files.toSorted((e,t)=>De(e).localeCompare(De(t),void 0,{numeric:!0,sensitivity:`base`})),[Q]),$=(0,F.useMemo)(()=>jt.map(e=>{let t=Ce(e);return{fileDiff:e,filePath:De(e),fileKey:t,collapsed:dt.has(t)}}),[dt,jt]),Mt=(0,F.useMemo)(()=>$.map(e=>e.fileKey),[$]),Nt=le(Mt,dt),Pt=(0,F.useMemo)(()=>Te(jt),[jt]);(0,F.useEffect)(()=>{if(!ot)return;let e=$.find(e=>e.filePath===ot);e&&Pe.current?.scrollTo({type:`item`,id:e.fileKey,align:`start`})},[$,ot,st]);let Ft=(0,F.useCallback)(e=>{Ke({threadRef:P,filePath:e,activeCwd:R,openInEditor:e=>{(async()=>{let t=await Ze(e);t._tag===`Failure`&&!u(t)&&console.warn(`Failed to open diff file in editor.`,{operation:`open-diff-file`,...P?{environmentId:P.environmentId,threadId:P.threadId}:{},...p(te(t))})})()}})},[R,Ze,P]),It=(0,F.useCallback)(e=>{Ae(t=>{let n=new Set(t.scopeKey===Y?t.fileKeys:[]);return n.has(e)?n.delete(e):n.add(e),{scopeKey:Y,fileKeys:n}})},[Y]),Lt=(0,F.useCallback)(()=>{Ae(e=>{let t=e.scopeKey===Y?e.fileKeys:it;return{scopeKey:Y,fileKeys:j(Mt,t)}})},[Y,Mt]),Rt=e=>{P&&N.getState().selectTurn(P,e)},zt=e=>{P&&N.getState().selectGitScope(P,e)},Bt=e=>{P&&N.getState().selectBranchBaseRef(P,e)};return(0,L.jsx)(he,{mode:e,header:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3 [-webkit-app-region:no-drag]`,children:[(0,L.jsxs)(a,{children:[(0,L.jsxs)(c,{className:`inline-flex h-6 max-w-full items-center gap-1 rounded-md bg-muted/70 px-2 text-xs font-medium text-foreground outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Diff scope: ${lt}`,children:[(0,L.jsx)(`span`,{className:`truncate`,children:lt}),(0,L.jsx)(f,{className:`size-3.5 shrink-0 text-muted-foreground`})]}),(0,L.jsxs)(d,{align:`start`,className:`w-60`,children:[(0,L.jsx)(o,{className:W===null&&G===`unstaged`?`bg-foreground/[0.08]`:void 0,onClick:()=>zt(`unstaged`),children:(0,L.jsx)(`span`,{children:`Working tree`})}),(0,L.jsx)(o,{className:W===null&&G===`branch`?`bg-foreground/[0.08]`:void 0,onClick:()=>zt(`branch`),children:(0,L.jsx)(`span`,{children:`Branch changes`})}),(0,L.jsx)(o,{className:W!==null&&q?.turnId===ct?.turnId?`bg-foreground/[0.08]`:void 0,onClick:()=>{ct&&Rt(ct.turnId)},children:(0,L.jsx)(`span`,{children:`Latest turn`})}),(0,L.jsxs)(ne,{children:[(0,L.jsx)(s,{children:`Turn`}),(0,L.jsx)(re,{className:`w-64`,children:U.map(e=>{let t=e.checkpointTurnCount??V[e.turnId]??`?`;return(0,L.jsxs)(o,{className:e.turnId===q?.turnId?`bg-foreground/[0.08]`:void 0,onClick:()=>Rt(e.turnId),children:[(0,L.jsxs)(`span`,{children:[`Turn `,t]}),(0,L.jsx)(`span`,{className:`ml-auto text-xs tabular-nums text-muted-foreground`,children:Ue(e.completedAt,ee.timestampFormat)})]},e.turnId)})})]})]})]}),W===null&&G===`branch`&&Z?.baseRef&&(0,L.jsxs)(`div`,{className:`flex min-w-0 max-w-full items-center gap-2 overflow-hidden text-xs text-muted-foreground`,title:`${Z.headRef??`HEAD`} → ${Z.baseRef}`,"aria-label":`Comparing ${Z.headRef??`HEAD`} against ${Z.baseRef}`,children:[(0,L.jsx)(`span`,{className:`min-w-0 max-w-48 truncate`,children:Z.headRef??`HEAD`}),(0,L.jsx)(A,{className:`size-3.5 shrink-0 opacity-70`}),(0,L.jsxs)(Ne,{items:Ct,filteredItems:wt,value:K??H,onOpenChange:e=>{e||se(``)},onValueChange:e=>{e&&Bt(e===H?null:e)},children:[(0,L.jsxs)(Oe,{className:`inline-flex min-w-0 max-w-48 items-center gap-1 overflow-hidden rounded-md px-1.5 py-1 outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Change comparison target. Currently ${Z.baseRef}`,children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:Z.baseRef}),(0,L.jsx)(f,{className:`size-3.5 shrink-0 opacity-70`})]}),(0,L.jsxs)(Ee,{align:`start`,className:`w-72 min-w-0 max-w-[calc(100vw-1rem)] overflow-hidden [&>[data-slot=combobox-popup]]:min-w-0 [&>[data-slot=combobox-popup]]:overflow-hidden`,children:[(0,L.jsx)(`div`,{className:`min-w-0 shrink-0 px-3 pt-2.5`,children:(0,L.jsxs)(`div`,{className:`relative -translate-y-px border-b border-border/70 pb-1.5 transition-colors focus-within:border-ring`,children:[(0,L.jsx)(ge,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1.5 left-0 size-4 shrink-0 text-muted-foreground/55`}),(0,L.jsx)(we,{className:`[&_input]:h-6.5 [&_input]:ps-5 [&_input]:font-sans [&_input]:leading-6.5`,inputClassName:`rounded-none bg-transparent text-sm`,placeholder:`Search refs...`,showTrigger:!1,size:`sm`,unstyled:!0,value:D,onChange:e=>se(e.target.value)})]})}),(0,L.jsxs)(`div`,{className:`grid shrink-0 grid-cols-[1rem_minmax(0,1fr)] items-center gap-2 border-b border-border/70 ps-3 pe-6.5 pt-2 pb-1.5 font-medium text-[10px] text-muted-foreground uppercase tracking-wide`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`}),(0,L.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_2rem] items-center`,children:[(0,L.jsx)(`span`,{children:`Branch`}),(0,L.jsx)(`span`,{className:`text-right`,children:`Remote`})]})]}),(0,L.jsx)(Re,{children:`No matching refs.`}),(0,L.jsxs)(Be,{className:`max-h-64 min-w-0 overflow-x-hidden`,children:[(0,L.jsx)(je,{className:`h-8 w-full min-w-0 grid-cols-[1rem_minmax(0,1fr)] py-0`,contentClassName:`w-full min-w-0 overflow-hidden`,value:H,children:(0,L.jsx)(`span`,{className:`block min-w-0 truncate`,children:`Automatic`})}),bt.map(e=>{let t=St(e),n=e.local!==null&&e.remote!==null,r=e.remote?.name===t;return(0,L.jsx)(je,{className:`h-8 w-full min-w-0 grid-cols-[1rem_minmax(0,1fr)] py-0`,contentClassName:`w-full min-w-0 overflow-hidden`,value:t,children:(0,L.jsxs)(`div`,{className:`grid w-full min-w-0 grid-cols-[minmax(0,1fr)_2rem] items-center overflow-hidden`,children:[(0,L.jsx)(`span`,{className:`block min-w-0 truncate pe-2`,children:e.label}),n?(0,L.jsx)(`div`,{className:`flex justify-end`,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,L.jsx)(Se,{"aria-label":`Use remote version of ${e.label}`,checked:r,className:`[--thumb-size:--spacing(3)]`,onCheckedChange:t=>{let n=t?e.remote?.name:e.local?.name;n&&Bt(n)}})}):e.remote?(0,L.jsx)(`span`,{className:`flex justify-end text-muted-foreground`,title:`Remote only`,children:(0,L.jsx)(i,{"aria-hidden":`true`,className:`size-3`})}):null]})},e.id)})]})]})]})]})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 [-webkit-app-region:no-drag]`,children:[$.length>0&&(0,L.jsx)(ke,{additions:Pt.additions,deletions:Pt.deletions,className:`mr-1 text-[11px]`,layout:`inline`}),$.length>0&&(0,L.jsxs)(O,{children:[(0,L.jsx)(m,{render:(0,L.jsx)(k,{type:`button`,size:`icon-xs`,variant:`outline`,"aria-label":Nt?`Expand all files`:`Collapse all files`,onClick:Lt}),children:Nt?(0,L.jsx)(He,{className:`size-3`}):(0,L.jsx)(_e,{className:`size-3`})}),(0,L.jsx)(y,{side:`top`,children:Nt?`Expand all files`:`Collapse all files`})]}),(0,L.jsxs)(M,{className:`shrink-0`,variant:`outline`,size:`xs`,value:[g],onValueChange:e=>{let t=e[0];(t===`stacked`||t===`split`)&&x(t)},children:[(0,L.jsx)(de,{"aria-label":`Stacked diff view`,value:`stacked`,children:(0,L.jsx)(ce,{className:`size-3`})}),(0,L.jsx)(de,{"aria-label":`Split diff view`,value:`split`,children:(0,L.jsx)(ue,{className:`size-3`})})]}),(0,L.jsxs)(O,{children:[(0,L.jsx)(m,{render:(0,L.jsx)(de,{"aria-label":S?`Disable diff line wrapping`:`Enable diff line wrapping`,variant:`outline`,size:`xs`,pressed:S,onPressedChange:e=>{ae(!!e)}}),children:(0,L.jsx)(be,{className:`size-3`})}),(0,L.jsx)(y,{side:`top`,children:S?`Disable line wrapping`:`Enable line wrapping`})]}),(0,L.jsxs)(O,{children:[(0,L.jsx)(m,{render:(0,L.jsx)(de,{"aria-label":w?`Show whitespace changes`:`Hide whitespace changes`,variant:`outline`,size:`xs`,pressed:w,onPressedChange:e=>{E(!!e)}}),children:(0,L.jsx)(Ge,{className:`size-3`})}),(0,L.jsx)(y,{side:`top`,children:w?`Show whitespace changes`:`Hide whitespace changes`})]})]})]}),children:I?$e?W!==null&&U.length===0?(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`No completed turns yet.`}):(0,L.jsx)(L.Fragment,{children:(0,L.jsxs)(`div`,{className:`diff-panel-viewport flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[Dt&&(0,L.jsx)(`p`,{className:`shrink-0 border-b border-border/70 bg-muted/40 px-3 py-1.5 text-[11px] text-muted-foreground`,children:`This diff was truncated because it exceeded the preview limit. The changes shown are incomplete.`}),kt&&!Q&&(0,L.jsx)(`div`,{className:`px-3`,children:(0,L.jsx)(`p`,{className:`mb-2 text-[11px] text-red-500/80`,children:kt})}),Q?Q.kind===`files`?(0,L.jsx)(`div`,{className:`min-h-0 flex-1`,onClickCapture:e=>{let t=(e.nativeEvent.composedPath?.()??[]).find(e=>e instanceof HTMLElement&&e.hasAttribute(`data-title`))?.textContent?.trim();t&&Ft(t)},children:(0,L.jsx)(Xe,{viewerRef:Pe,className:`diff-render-surface h-full min-h-0 overflow-auto`,files:$,sectionId:ut,sectionTitle:ft,composerDraftTarget:t,renderHeaderPrefix:(e,t,n)=>{let r=De(e);return(0,L.jsxs)(O,{children:[(0,L.jsx)(m,{render:(0,L.jsx)(`button`,{type:`button`,className:l(`inline-flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-sm border-0 bg-transparent p-0 transition-colors hover:bg-foreground/10 focus-visible:outline-hidden`,ze(e)),"aria-label":n?`Expand ${r}`:`Collapse ${r}`,"aria-expanded":!n,onClick:e=>{e.stopPropagation(),It(t)}}),children:n?(0,L.jsx)(_,{className:`size-4`}):(0,L.jsx)(f,{className:`size-4`})}),(0,L.jsx)(y,{side:`top`,children:n?`Expand diff`:`Collapse diff`})]})},options:{diffStyle:g===`split`?`split`:`unified`,lineDiffType:`none`,overflow:S?`wrap`:`scroll`,theme:Ve(r),themeType:r,unsafeCSS:at,stickyHeaders:!0,itemMetrics:{diffHeaderHeight:33},layout:{paddingTop:0,paddingBottom:8,gap:8}}},Y??ut)}):(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-2`,children:(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(`p`,{className:`text-[11px] text-muted-foreground/75`,children:Q.reason}),(0,L.jsx)(`pre`,{className:l(`max-h-[72vh] rounded-md border border-border/70 bg-background/70 p-3 font-mono text-[11px] leading-relaxed text-muted-foreground/90`,S?`overflow-auto whitespace-pre-wrap wrap-break-word`:`overflow-auto`),children:Q.text})]})}):Ot?(0,L.jsx)(Ie,{label:q?`Loading checkpoint diff...`:G===`unstaged`?`Loading working tree diff...`:`Loading branch diff...`}):(0,L.jsx)(`div`,{className:`flex h-full items-center justify-center px-3 py-2 text-xs text-muted-foreground/70`,children:(0,L.jsx)(`p`,{children:At?`No net changes in this selection.`:`No patch available for this selection.`})})]})}):(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`Turn diffs are unavailable because this project is not a git repository.`}):(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`Select a thread to inspect turn diffs.`})})}export{xe as DiffWorkerPoolProvider,U as default};
98
- //# sourceMappingURL=DiffPanel-Do6aSu0E.js.map
98
+ //# sourceMappingURL=DiffPanel-BooVz7M0.js.map