@p4code/cli 0.5.15 → 0.5.16

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
@@ -265,7 +265,7 @@ const make$120 = () => {
265
265
  const layer$122 = Layer.sync(NetService, make$120);
266
266
  //#endregion
267
267
  //#region package.json
268
- var version$1 = "0.5.15";
268
+ var version$1 = "0.5.16";
269
269
  //#endregion
270
270
  //#region src/config.ts
271
271
  /**
@@ -12960,8 +12960,10 @@ const ThreadEvidenceActivityOutcome = Schema$1.Literals([
12960
12960
  * Server clock around one review, never the supervisor's own account of it.
12961
12961
  *
12962
12962
  * `readAt` is when the evidence-read row was recorded and `closedAt` when the
12963
- * row that closes the review was: the report for a reported review, the turn
12964
- * boundary for an unreported one.
12963
+ * row that closes the review was: the report for a reported review, the
12964
+ * completed supervisor turn for an unreported one. A supervisor turn that
12965
+ * failed or was interrupted closes nothing, so its read keeps no timing until
12966
+ * some later turn reports on it.
12965
12967
  */
12966
12968
  const ThreadEvidenceReportTiming = Schema$1.Struct({
12967
12969
  readAt: IsoDateTime,
@@ -41635,12 +41637,82 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
41635
41637
  FROM projection_thread_activities
41636
41638
  WHERE activity_id = ${activityId}
41637
41639
  LIMIT 1
41640
+ `
41641
+ });
41642
+ const TurnStartRow = Schema$1.Struct({
41643
+ threadId: ThreadId,
41644
+ messageId: Schema$1.NullOr(Schema$1.String),
41645
+ startedAt: Schema$1.NullOr(Schema$1.String)
41646
+ });
41647
+ /**
41648
+ * The message a turn was started from, by the table's own key.
41649
+ *
41650
+ * Thread and turn together, because the unique key is the pair: a turn id is
41651
+ * provider-supplied for some providers, and matching on it alone would let
41652
+ * one provider's collision answer for another thread.
41653
+ */
41654
+ const getTurnStartRow = SqlSchema.findOneOption({
41655
+ Request: Schema$1.Struct({
41656
+ threadId: ThreadId,
41657
+ turnId: TurnId
41658
+ }),
41659
+ Result: TurnStartRow,
41660
+ execute: (input) => sql`
41661
+ SELECT
41662
+ thread_id AS "threadId",
41663
+ pending_message_id AS "messageId",
41664
+ started_at AS "startedAt"
41665
+ FROM projection_turns
41666
+ WHERE thread_id = ${input.threadId}
41667
+ AND turn_id = ${input.turnId}
41668
+ LIMIT 1
41669
+ `
41670
+ });
41671
+ /** The turn a thread's session is running, by the session projection's own row. */
41672
+ const getActiveTurnIdRow = SqlSchema.findOneOption({
41673
+ Request: ThreadId,
41674
+ Result: Schema$1.Struct({ activeTurnId: Schema$1.NullOr(Schema$1.String) }),
41675
+ execute: (threadId) => sql`
41676
+ SELECT active_turn_id AS "activeTurnId"
41677
+ FROM projection_thread_sessions
41678
+ WHERE thread_id = ${threadId}
41679
+ LIMIT 1
41680
+ `
41681
+ });
41682
+ const ThreadMessageStampRow = Schema$1.Struct({
41683
+ messageId: Schema$1.String,
41684
+ createdAt: Schema$1.String
41685
+ });
41686
+ /**
41687
+ * The newest message on a thread whose id starts with a prefix.
41688
+ *
41689
+ * The server names the messages it sends itself, so asking by id prefix asks
41690
+ * what the server last sent - a question no turn row can be talked out of by
41691
+ * whichever turn happened to adopt a pending start.
41692
+ */
41693
+ const getLatestThreadMessageWithIdPrefixRow = SqlSchema.findOneOption({
41694
+ Request: Schema$1.Struct({
41695
+ threadId: ThreadId,
41696
+ idPrefix: Schema$1.String
41697
+ }),
41698
+ Result: ThreadMessageStampRow,
41699
+ execute: (input) => sql`
41700
+ SELECT
41701
+ message_id AS "messageId",
41702
+ created_at AS "createdAt"
41703
+ FROM projection_thread_messages
41704
+ WHERE thread_id = ${input.threadId}
41705
+ AND message_id LIKE ${`${input.idPrefix}%`} ESCAPE '\\'
41706
+ ORDER BY created_at DESC, message_id DESC
41707
+ LIMIT 1
41638
41708
  `
41639
41709
  });
41640
41710
  const LatestEvidenceReadRow = Schema$1.Struct({
41641
41711
  watchedThreadId: ThreadId,
41642
41712
  afterSequence: Schema$1.NullOr(Schema$1.Number),
41643
41713
  throughSequence: Schema$1.Number,
41714
+ /** The supervisor turn that recorded the read, absent on rows written before it was stamped. */
41715
+ turnId: Schema$1.NullOr(Schema$1.String),
41644
41716
  readAt: Schema$1.String,
41645
41717
  hasReport: Schema$1.Number
41646
41718
  });
@@ -41659,6 +41731,7 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
41659
41731
  json_extract(reads.payload_json, '$.watchedThreadId') AS "watchedThreadId",
41660
41732
  json_extract(reads.payload_json, '$.afterSequence') AS "afterSequence",
41661
41733
  json_extract(reads.payload_json, '$.throughSequence') AS "throughSequence",
41734
+ json_extract(reads.payload_json, '$.turnId') AS "turnId",
41662
41735
  reads.created_at AS "readAt",
41663
41736
  EXISTS (
41664
41737
  SELECT 1
@@ -43467,10 +43540,20 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
43467
43540
  });
43468
43541
  const getLatestThreadContextWindow = (threadId) => getLatestContextWindowRow(threadId).pipe(Effect.mapError(toPersistenceSqlOrDecodeError$1("ProjectionSnapshotQuery.getLatestThreadContextWindow:query", "ProjectionSnapshotQuery.getLatestThreadContextWindow:decodeRow")));
43469
43542
  const getEvidenceReadContext = (activityId) => getEvidenceReadContextRow(activityId).pipe(Effect.mapError(toPersistenceSqlOrDecodeError$1("ProjectionSnapshotQuery.getEvidenceReadContext:query", "ProjectionSnapshotQuery.getEvidenceReadContext:decodeRow")));
43543
+ const getTurnStart = (threadId, turnId) => getTurnStartRow({
43544
+ threadId,
43545
+ turnId
43546
+ }).pipe(Effect.mapError(toPersistenceSqlOrDecodeError$1("ProjectionSnapshotQuery.getTurnStart:query", "ProjectionSnapshotQuery.getTurnStart:decodeRow")));
43547
+ const getActiveTurnId = (threadId) => getActiveTurnIdRow(threadId).pipe(Effect.map(Option.flatMap((row) => Option.fromNullable(row.activeTurnId))), Effect.mapError(toPersistenceSqlOrDecodeError$1("ProjectionSnapshotQuery.getActiveTurnId:query", "ProjectionSnapshotQuery.getActiveTurnId:decodeRow")));
43548
+ const getLatestThreadMessageWithIdPrefix = (threadId, idPrefix) => getLatestThreadMessageWithIdPrefixRow({
43549
+ threadId,
43550
+ idPrefix
43551
+ }).pipe(Effect.mapError(toPersistenceSqlOrDecodeError$1("ProjectionSnapshotQuery.getLatestThreadMessageWithIdPrefix:query", "ProjectionSnapshotQuery.getLatestThreadMessageWithIdPrefix:decodeRow")));
43470
43552
  const getLatestEvidenceRead = (threadId) => getLatestEvidenceReadRow(threadId).pipe(Effect.map(Option.map((row) => ({
43471
43553
  watchedThreadId: row.watchedThreadId,
43472
43554
  afterSequence: row.afterSequence,
43473
43555
  throughSequence: row.throughSequence,
43556
+ turnId: row.turnId,
43474
43557
  readAt: row.readAt,
43475
43558
  hasReport: row.hasReport !== 0
43476
43559
  }))), Effect.mapError(toPersistenceSqlOrDecodeError$1("ProjectionSnapshotQuery.getLatestEvidenceRead:query", "ProjectionSnapshotQuery.getLatestEvidenceRead:decodeRow")));
@@ -43698,6 +43781,9 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
43698
43781
  getThreadPairById,
43699
43782
  getActiveThreadPairs,
43700
43783
  getLatestEvidenceRead,
43784
+ getTurnStart,
43785
+ getLatestThreadMessageWithIdPrefix,
43786
+ getActiveTurnId,
43701
43787
  getThreadShellById,
43702
43788
  getThreadDetailById,
43703
43789
  getHandoffContext,
@@ -134323,6 +134409,7 @@ const recordEvidenceRead = Effect.fn("mcp.watch.recordEvidenceRead")(function* (
134323
134409
  onNone: () => afterSequence,
134324
134410
  onSome: (row) => row.afterSequence ?? afterSequence
134325
134411
  });
134412
+ const activeTurnId = yield* projections.getActiveTurnId(readerThreadId).pipe(Effect.orElseSucceed(() => Option.none()), Effect.map(Option.getOrNull));
134326
134413
  const usedTokensAtRead = opened ? Option.getOrNull(Option.map(recorded, (row) => row.usedTokensAtRead)) : yield* projections.getLatestThreadContextWindow(readerThreadId).pipe(Effect.map(Option.map((row) => row.usedTokens)), Effect.orElseSucceed(() => Option.none()), Effect.map(Option.getOrNull));
134327
134414
  yield* engine.dispatch({
134328
134415
  type: "thread.activity.append",
@@ -134343,6 +134430,7 @@ const recordEvidenceRead = Effect.fn("mcp.watch.recordEvidenceRead")(function* (
134343
134430
  nextAfterSequence: page.nextAfterSequence,
134344
134431
  hasMore: page.hasMore,
134345
134432
  scannedEvents: page.scannedEvents,
134433
+ ...activeTurnId === null ? {} : { turnId: activeTurnId },
134346
134434
  ...usedTokensAtRead === null ? {} : { usedTokensAtRead }
134347
134435
  }
134348
134436
  }
@@ -140039,21 +140127,8 @@ const make$3 = Effect.gen(function* () {
140039
140127
  yield* processReview(pair, completion, turn);
140040
140128
  }
140041
140129
  });
140042
- /**
140043
- * Closes a supervisor turn that read the builder's evidence and ended without
140044
- * reporting on it.
140045
- *
140046
- * The row it writes is keyed exactly like the supervisor's own report, so a
140047
- * later report replaces it rather than doubling it, and it carries the same
140048
- * server-measured context and timing. Without it, a review that was never
140049
- * reported is indistinguishable in stored history from one that was never
140050
- * attempted.
140051
- */
140052
- const recordUnreportedEvidence = Effect.fn("FusionWatcherReactor.recordUnreportedEvidence")(function* (pair, completion) {
140053
- const read = yield* projectionSnapshotQuery.getLatestEvidenceRead(pair.watcherThreadId).pipe(Effect.orElseSucceed(() => Option.none()));
140054
- if (Option.isNone(read)) return;
140055
- const latest = read.value;
140056
- if (latest.hasReport || latest.watchedThreadId !== pair.implementerThreadId) return;
140130
+ /** Writes the row, once the caller has established the turn owed one. */
140131
+ const stampUnreported = Effect.fn("FusionWatcherReactor.stampUnreported")(function* (pair, completion, latest) {
140057
140132
  const { context, timing } = yield* correlateEvidence({
140058
140133
  readerThreadId: pair.watcherThreadId,
140059
140134
  readActivityId: evidenceReadActivityId(latest.watchedThreadId, latest.throughSequence),
@@ -140086,6 +140161,39 @@ const make$3 = Effect.gen(function* () {
140086
140161
  }
140087
140162
  });
140088
140163
  });
140164
+ /**
140165
+ * Closes a supervisor turn that read the builder's evidence and ended without
140166
+ * reporting on it.
140167
+ *
140168
+ * The row it writes is keyed exactly like the supervisor's own report, so a
140169
+ * later report replaces it rather than doubling it, and it carries the same
140170
+ * server-measured context and timing. Without it, a review that was never
140171
+ * reported is indistinguishable in stored history from one that was never
140172
+ * attempted.
140173
+ */
140174
+ const recordUnreportedEvidence = Effect.fn("FusionWatcherReactor.recordUnreportedEvidence")(function* (pair, completion, input) {
140175
+ const read = yield* projectionSnapshotQuery.getLatestEvidenceRead(pair.watcherThreadId).pipe(Effect.orElseSucceed(() => Option.none()));
140176
+ if (Option.isNone(read)) return;
140177
+ const latest = read.value;
140178
+ if (latest.hasReport || latest.watchedThreadId !== pair.implementerThreadId) return;
140179
+ if (completion.payload.turnId === null) return;
140180
+ const turn = yield* projectionSnapshotQuery.getTurnStart(pair.watcherThreadId, completion.payload.turnId).pipe(Effect.orElseSucceed(() => Option.none()));
140181
+ if (Option.isNone(turn)) return;
140182
+ const started = turn.value;
140183
+ if (started.threadId !== pair.watcherThreadId) return;
140184
+ const readAt = Date.parse(latest.readAt);
140185
+ if (latest.turnId === null) {
140186
+ if (input.replayed) return;
140187
+ if (started.startedAt !== null && readAt < Date.parse(started.startedAt)) return;
140188
+ if (readAt > Date.parse(completion.occurredAt)) return;
140189
+ } else if (latest.turnId !== completion.payload.turnId) return;
140190
+ const wakeAt = (prefix) => projectionSnapshotQuery.getLatestThreadMessageWithIdPrefix(pair.watcherThreadId, prefix).pipe(Effect.map(Option.flatMap((wake) => {
140191
+ const sentAt = Date.parse(wake.createdAt);
140192
+ return Number.isNaN(sentAt) || sentAt > readAt ? Option.none() : Option.some(sentAt);
140193
+ })), Effect.orElseSucceed(() => Option.none()));
140194
+ if (!(started.messageId === null ? yield* Effect.map(Effect.all([wakeAt("fusion-review:"), wakeAt("fusion-gate:")]), ([review, gate]) => Option.isSome(review) && (Option.isNone(gate) || gate.value < review.value)) : started.messageId.startsWith("fusion-review:"))) return;
140195
+ yield* stampUnreported(pair, completion, latest);
140196
+ });
140089
140197
  const processCompletion = Effect.fn("FusionWatcherReactor.processCompletion")(function* (event) {
140090
140198
  const activePairs = ((yield* projectionSnapshotQuery.getCommandReadModel()).threadPairs ?? []).filter((pair) => pair.detachedAt === null);
140091
140199
  const failedPair = activePairs.find((pair) => pair.implementerThreadId === event.payload.threadId || pair.watcherThreadId === event.payload.threadId);
@@ -140101,7 +140209,7 @@ const make$3 = Effect.gen(function* () {
140101
140209
  }
140102
140210
  if (event.payload.state !== "completed") return;
140103
140211
  const watcherPair = activePairs.find((pair) => pair.watcherThreadId === event.payload.threadId);
140104
- if (watcherPair !== void 0) yield* recordUnreportedEvidence(watcherPair, event).pipe(Effect.catchCause((cause) => Effect.logWarning("could not record an unreported Fusion evidence read", {
140212
+ if (watcherPair !== void 0) yield* recordUnreportedEvidence(watcherPair, event, { replayed: event.sequence <= liveEventsAfterSequence }).pipe(Effect.catchCause((cause) => Effect.logWarning("could not record an unreported Fusion evidence read", {
140105
140213
  pairId: watcherPair.id,
140106
140214
  cause: Cause.pretty(cause)
140107
140215
  })));
@@ -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{$l as i,Ba as a,Et as o,Fa as s,Ga as c,Il as l,Ja as ee,Ka as te,Ma as u,Rr as d,Ur as ne,Uu as f,Ya as p,Yr as re,_n as m,au as h,b as ie,dl as g,fl as _,gt as v,gu as ae,h as y,ht as b,ml as x,pl as oe,qa as S,st as C,uu as se,vt as w,xn as T,za as E}from"./previewAssetResource-CKOao7Zb.js";import{a as D,c as O,i as k,n as A,o as j,r as M,s as ce,t as N}from"./toggle-group-hqQeP7ri.js";import{A as le,Fr as ue,J as de,Lr as fe,M as P,Mr as pe,Nr as me,Rr as he,Y as ge,_ as _e,_r as ve,at as ye,cr as be,ct as xe,dr as Se,fr as Ce,h as we,hr as Te,it as Ee,j as De,jr as Oe,k as ke,lr as Ae,lt as je,oi as Me,or as Ne,ot as Pe,pr as Fe,rt as Ie,si as Le,sr as Re,st as ze,ur as Be,yr as Ve}from"./index-CL8KBlld.js";import{a as He,n as Ue}from"./fileCommentAnnotations-CoOCi5GC.js";var We=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 Ge({threadRef:e,filePath:t,activeCwd:n,openInEditor:r,openFileSurface:i}){if(e){if(i){i(t);return}C.getState().openFile(e,t);return}r(n?y(t,n):t)}var I=r();function Ke(e,t){let n=(0,I.c)(4),r=Te(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(),qe=[];function Je(e){return(e.endSide??e.side)===`deletions`?`deletions`:`additions`}function R(e,t,n){let r=Je(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 Ye(e){let t=(0,I.c)(50),{files:n,sectionId:r,sectionTitle:i,composerDraftTarget:a,options:o,viewerRef:s,className:c,renderHeaderPrefix:l}=e,ee=d(Qe),te=d(B),u;t[0]===a?u=t[1]:(u=e=>e.getComposerDraft(a)?.reviewComments??qe,t[0]=a,t[1]=u);let f=d(u),[p,m]=(0,F.useState)(null),[h,ie]=(0,F.useState)(null),g;t[2]===n?g=t[3]:(g=new Map(n.map(Ze)),t[2]=n,t[3]=g);let _=g,v;if(t[4]!==h||t[5]!==n||t[6]!==f||t[7]!==r){let e;t[9]!==h||t[10]!==f||t[11]!==r?(e=e=>{let{fileDiff:t,filePath:n,fileKey:i,collapsed:a}=e,o=f.filter(e=>e.sectionId===r&&e.filePath===n&&(e.fenceLanguage??`diff`)===`diff`).reduce((e,n)=>{let r=re(t,n);return r?R(e,r,{id:n.id,kind:`comment`,range:r,rangeLabel:n.rangeLabel,text:n.text}):e},[]),s=h?.fileKey===i?[...o,h.annotation]:o;return{id:i,type:`diff`,fileDiff:t,annotations:s,collapsed:a,version:Ee(`${a?`1`:`0`}:${s.flatMap(z).join(`:`)}`)}},t[9]=h,t[10]=f,t[11]=r,t[12]=e):e=t[12],v=n.map(e),t[4]=h,t[5]=n,t[6]=f,t[7]=r,t[8]=v}else v=t[8];let ae=v,y;t[13]!==a||t[14]!==h?.annotation||t[15]!==te?(y=e=>{m(null),h?.annotation.metadata.entries.some(t=>t.id===e)?ie(null):te(a,e)},t[13]=a,t[14]=h?.annotation,t[15]=te,t[16]=y):y=t[16];let b=y,x;t[17]!==ee||t[18]!==a||t[19]!==h||t[20]!==_||t[21]!==r||t[22]!==i?(x=(e,t)=>{let n=h?.annotation.metadata.entries.find(t=>t.id===e),o=h?_.get(h.fileKey):void 0;if(!n||!o)return;let s=ne({id:n.id,sectionId:r,sectionTitle:i,filePath:o.filePath,fileDiff:o.fileDiff,range:n.range,text:t});s&&ee(a,s),m(null),ie(null)},t[17]=ee,t[18]=a,t[19]=h,t[20]=_,t[21]=r,t[22]=i,t[23]=x):x=t[23];let oe=x,S;t[24]!==_||t[25]!==r||t[26]!==i?(S=(e,t)=>{if(!e)return;let n=t.item;if(n.type!==`diff`)return;let a=_.get(n.id);if(!a)return;let o=Ue(),s=ne({id:o,sectionId:r,sectionTitle:i,filePath:a.filePath,fileDiff:a.fileDiff,range:e,text:``});s&&ie({fileKey:n.id,annotation:{side:Je(e),lineNumber:e.end,metadata:{entries:[{id:o,kind:`draft`,range:e,rangeLabel:s.rangeLabel,text:``}]}}})},t[24]=_,t[25]=r,t[26]=i,t[27]=S):S=t[27];let C=S,se=h!==null,w;t[28]===s?w=t[29]:(w=s?{ref:s}:{},t[28]=s,t[29]=w);let T;t[30]===c?T=t[31]:(T=c?{className:c}:{},t[30]=c,t[31]=T);let E=!se,O=!se,k;t[32]!==C||t[33]!==o||t[34]!==O||t[35]!==E?(k={...o,enableGutterUtility:E,enableLineSelection:O,onLineSelectionEnd:C},t[32]=C,t[33]=o,t[34]=O,t[35]=E,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]!==b||t[40]!==oe?(j=e=>(0,L.jsx)(`div`,{className:`py-1`,children:e.metadata.entries.map(e=>(0,L.jsx)(He,{kind:e.kind,rangeLabel:e.rangeLabel,text:e.text,onCancel:()=>b(e.id),onComment:t=>oe(e.id,t),onDelete:()=>b(e.id)},e.id))}),t[39]=b,t[40]=oe,t[41]=j):j=t[41];let M;return t[42]!==ae||t[43]!==p||t[44]!==k||t[45]!==A||t[46]!==j||t[47]!==w||t[48]!==T?(M=(0,L.jsx)(D,{...w,...T,items:ae,selectedLines:p,onSelectedLinesChange:m,options:k,renderHeaderPrefix:A,renderAnnotation:j}),t[42]=ae,t[43]=p,t[44]=k,t[45]=A,t[46]=j,t[47]=w,t[48]=T,t[49]=M):M=t[49],M}function z(e){return e.metadata.entries.map(Xe)}function Xe(e){return`${e.id}:${e.rangeLabel}:${e.text}`}function Ze(e){return[e.fileKey,e]}function B(e){return e.removeReviewComment}function Qe(e){return e.addReviewComment}function $e(e){return{diffPreview:i(e,{label:`environment-data:review:diff-preview`,tag:f.reviewGetDiffPreview,staleTimeMs:5e3})}}var et=$e(T);function V(e){return e.remoteName&&e.name.startsWith(`${e.remoteName}/`)?e.name.slice(e.remoteName.length+1):e.name}function tt(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 nt(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__`,rt=new Set,it=`
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{$l as i,Ba as a,Et as o,Fa as s,Ga as c,Il as l,Ja as ee,Ka as te,Ma as u,Rr as d,Ur as ne,Uu as f,Ya as p,Yr as re,_n as m,au as h,b as ie,dl as g,fl as _,gt as v,gu as ae,h as y,ht as b,ml as x,pl as oe,qa as S,st as C,uu as se,vt as w,xn as T,za as E}from"./previewAssetResource-CKOao7Zb.js";import{a as D,c as O,i as k,n as A,o as j,r as M,s as ce,t as N}from"./toggle-group-NIaLKwkg.js";import{A as le,Fr as ue,J as de,Lr as fe,M as P,Mr as pe,Nr as me,Rr as he,Y as ge,_ as _e,_r as ve,at as ye,cr as be,ct as xe,dr as Se,fr as Ce,h as we,hr as Te,it as Ee,j as De,jr as Oe,k as ke,lr as Ae,lt as je,oi as Me,or as Ne,ot as Pe,pr as Fe,rt as Ie,si as Le,sr as Re,st as ze,ur as Be,yr as Ve}from"./index-DwVt0vnY.js";import{a as He,n as Ue}from"./fileCommentAnnotations-T78XG7k8.js";var We=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 Ge({threadRef:e,filePath:t,activeCwd:n,openInEditor:r,openFileSurface:i}){if(e){if(i){i(t);return}C.getState().openFile(e,t);return}r(n?y(t,n):t)}var I=r();function Ke(e,t){let n=(0,I.c)(4),r=Te(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(),qe=[];function Je(e){return(e.endSide??e.side)===`deletions`?`deletions`:`additions`}function R(e,t,n){let r=Je(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 Ye(e){let t=(0,I.c)(50),{files:n,sectionId:r,sectionTitle:i,composerDraftTarget:a,options:o,viewerRef:s,className:c,renderHeaderPrefix:l}=e,ee=d(Qe),te=d(B),u;t[0]===a?u=t[1]:(u=e=>e.getComposerDraft(a)?.reviewComments??qe,t[0]=a,t[1]=u);let f=d(u),[p,m]=(0,F.useState)(null),[h,ie]=(0,F.useState)(null),g;t[2]===n?g=t[3]:(g=new Map(n.map(Ze)),t[2]=n,t[3]=g);let _=g,v;if(t[4]!==h||t[5]!==n||t[6]!==f||t[7]!==r){let e;t[9]!==h||t[10]!==f||t[11]!==r?(e=e=>{let{fileDiff:t,filePath:n,fileKey:i,collapsed:a}=e,o=f.filter(e=>e.sectionId===r&&e.filePath===n&&(e.fenceLanguage??`diff`)===`diff`).reduce((e,n)=>{let r=re(t,n);return r?R(e,r,{id:n.id,kind:`comment`,range:r,rangeLabel:n.rangeLabel,text:n.text}):e},[]),s=h?.fileKey===i?[...o,h.annotation]:o;return{id:i,type:`diff`,fileDiff:t,annotations:s,collapsed:a,version:Ee(`${a?`1`:`0`}:${s.flatMap(z).join(`:`)}`)}},t[9]=h,t[10]=f,t[11]=r,t[12]=e):e=t[12],v=n.map(e),t[4]=h,t[5]=n,t[6]=f,t[7]=r,t[8]=v}else v=t[8];let ae=v,y;t[13]!==a||t[14]!==h?.annotation||t[15]!==te?(y=e=>{m(null),h?.annotation.metadata.entries.some(t=>t.id===e)?ie(null):te(a,e)},t[13]=a,t[14]=h?.annotation,t[15]=te,t[16]=y):y=t[16];let b=y,x;t[17]!==ee||t[18]!==a||t[19]!==h||t[20]!==_||t[21]!==r||t[22]!==i?(x=(e,t)=>{let n=h?.annotation.metadata.entries.find(t=>t.id===e),o=h?_.get(h.fileKey):void 0;if(!n||!o)return;let s=ne({id:n.id,sectionId:r,sectionTitle:i,filePath:o.filePath,fileDiff:o.fileDiff,range:n.range,text:t});s&&ee(a,s),m(null),ie(null)},t[17]=ee,t[18]=a,t[19]=h,t[20]=_,t[21]=r,t[22]=i,t[23]=x):x=t[23];let oe=x,S;t[24]!==_||t[25]!==r||t[26]!==i?(S=(e,t)=>{if(!e)return;let n=t.item;if(n.type!==`diff`)return;let a=_.get(n.id);if(!a)return;let o=Ue(),s=ne({id:o,sectionId:r,sectionTitle:i,filePath:a.filePath,fileDiff:a.fileDiff,range:e,text:``});s&&ie({fileKey:n.id,annotation:{side:Je(e),lineNumber:e.end,metadata:{entries:[{id:o,kind:`draft`,range:e,rangeLabel:s.rangeLabel,text:``}]}}})},t[24]=_,t[25]=r,t[26]=i,t[27]=S):S=t[27];let C=S,se=h!==null,w;t[28]===s?w=t[29]:(w=s?{ref:s}:{},t[28]=s,t[29]=w);let T;t[30]===c?T=t[31]:(T=c?{className:c}:{},t[30]=c,t[31]=T);let E=!se,O=!se,k;t[32]!==C||t[33]!==o||t[34]!==O||t[35]!==E?(k={...o,enableGutterUtility:E,enableLineSelection:O,onLineSelectionEnd:C},t[32]=C,t[33]=o,t[34]=O,t[35]=E,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]!==b||t[40]!==oe?(j=e=>(0,L.jsx)(`div`,{className:`py-1`,children:e.metadata.entries.map(e=>(0,L.jsx)(He,{kind:e.kind,rangeLabel:e.rangeLabel,text:e.text,onCancel:()=>b(e.id),onComment:t=>oe(e.id,t),onDelete:()=>b(e.id)},e.id))}),t[39]=b,t[40]=oe,t[41]=j):j=t[41];let M;return t[42]!==ae||t[43]!==p||t[44]!==k||t[45]!==A||t[46]!==j||t[47]!==w||t[48]!==T?(M=(0,L.jsx)(D,{...w,...T,items:ae,selectedLines:p,onSelectedLinesChange:m,options:k,renderHeaderPrefix:A,renderAnnotation:j}),t[42]=ae,t[43]=p,t[44]=k,t[45]=A,t[46]=j,t[47]=w,t[48]=T,t[49]=M):M=t[49],M}function z(e){return e.metadata.entries.map(Xe)}function Xe(e){return`${e.id}:${e.rangeLabel}:${e.text}`}function Ze(e){return[e.fileKey,e]}function B(e){return e.removeReviewComment}function Qe(e){return e.addReviewComment}function $e(e){return{diffPreview:i(e,{label:`environment-data:review:diff-preview`,tag:f.reviewGetDiffPreview,staleTimeMs:5e3})}}var et=$e(T);function V(e){return e.remoteName&&e.name.startsWith(`${e.remoteName}/`)?e.name.slice(e.remoteName.length+1):e.name}function tt(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 nt(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__`,rt=new Set,it=`
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,threadRef:r}){let{resolvedTheme:i}=ie(),d=ue(),[ne]=(0,F.useState)(n),[f,re]=(0,F.useState)(`stacked`),[y,x]=(0,F.useState)(d.wordWrap),[C,T]=(0,F.useState)(d.diffIgnoreWhitespace),[D,_e]=(0,F.useState)(``),[Te,Ee]=(0,F.useState)(()=>({scopeKey:null,fileKeys:rt})),He=(0,F.useRef)(null),Ue=r.threadId,I=me(r),qe=I?.projectId??null,Je=pe(I&&qe?{environmentId:I.environmentId,projectId:qe}:null),R=I?.worktreePath??Je?.workspaceRoot,z=l(m.configValueAtom(I?.environmentId??null)),Xe=ve(I?.environmentId??null,z?.availableEditors??[]),Ze=o(I!=null&&R!=null?Oe.status({environmentId:I.environmentId,input:{cwd:R}}):null),B=P(e=>De(e.byThreadKey,r,ne===`unstaged`)),Qe=Ze.data?.isRepo??!0,{turnDiffSummaries:$e,inferredCheckpointTurnCountByTurnId:V}=le(I),U=(0,F.useMemo)(()=>[...$e].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,$e]);(0,F.useEffect)(()=>{B.kind===`turn`&&P.getState().reconcileTurnSelection(r,U.map(e=>e.turnId))},[B,U,r]);let W=B.kind===`turn`?B.turnId:null,G=B.kind===`unstaged`?`unstaged`:`branch`,K=B.kind===`branch`?B.baseRef:null,at=B.kind===`turn`?B.filePath:null,ot=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]),st=U[0],ct=W===null?G===`unstaged`?`Working tree`:`Branch changes`:q?.turnId===st?.turnId?`Latest turn`:`Turn ${J??`?`}`,lt=q?`turn:${q.turnId}`:G,Y=`${r.environmentId}:${r.threadId}:${lt}`,ut=Te.scopeKey===Y?Te.fileKeys:rt,dt=q?`Turn ${J??`?`}`:G===`unstaged`?`Working tree`:`Branch changes`,ft=(0,F.useMemo)(()=>typeof J==`number`?{fromTurnCount:Math.max(0,J-1),toTurnCount:J}:null,[J]),pt=Ke({environmentId:I?.environmentId??null,threadId:Ue,fromTurnCount:ft?.fromTurnCount??null,toTurnCount:ft?.toTurnCount??null,ignoreWhitespace:C,cacheScope:q?`turn:${q.turnId}`:null},{enabled:Qe&&q!==void 0}),mt=o(W===null&&I&&R?et.diffPreview({environmentId:I.environmentId,input:{cwd:R,...K?{baseRef:K}:{},ignoreWhitespace:C}}):null),ht=W===null&&mt.error?.includes(`configured workspace root`)===!0&&z?.cwd!==void 0&&z.cwd!==R,gt=o(ht&&I&&z?et.diffPreview({environmentId:I.environmentId,input:{cwd:z.cwd,...K?{baseRef:K}:{},ignoreWhitespace:C}}):null),X=ht?gt:mt,Z=X.data?.sources.find(e=>e.kind===(G===`unstaged`?`working-tree`:`branch-range`)),_t=o(W===null&&G===`branch`&&I&&X.data?.cwd?Oe.listRefs({environmentId:I.environmentId,input:{cwd:X.data.cwd,includeMatchingRemoteRefs:!0,refKind:`local`,...D.trim().length>0?{query:D.trim()}:{},limit:100}}):null),vt=o(W===null&&G===`branch`&&I&&X.data?.cwd?Oe.listRefs({environmentId:I.environmentId,input:{cwd:X.data.cwd,includeMatchingRemoteRefs:!0,refKind:`remote`,...D.trim().length>0?{query:D.trim()}:{},limit:100}}):null),yt=tt(_t.data?.refs.filter(e=>e.name!==Z?.headRef)??[],vt.data?.refs??[]),bt=nt(yt,D),xt=e=>K&&K===e.remote?.name?K:e.local?.name??e.remote?.name??e.id,St=[H,...yt.map(xt)],Ct=[...D.trim().length===0?[H]:[],...bt.map(xt)],wt=Z?.diff,Tt=q?pt.data?.diff:wt,Et=!q&&Z?.truncated===!0,Dt=q?pt.isPending:X.isPending,Ot=q?pt.error:X.error,kt=typeof Tt==`string`&&Tt.trim().length===0,Q=(0,F.useMemo)(()=>ze(Tt,`diff-panel:${i}`,{compactPartialHunkOffsets:W===null}),[i,Tt,W]),At=(0,F.useMemo)(()=>!Q||Q.kind!==`files`?[]:Q.files.toSorted((e,t)=>je(e).localeCompare(je(t),void 0,{numeric:!0,sensitivity:`base`})),[Q]),$=(0,F.useMemo)(()=>At.map(e=>{let t=Ie(e);return{fileDiff:e,filePath:je(e),fileKey:t,collapsed:ut.has(t)}}),[ut,At]),jt=(0,F.useMemo)(()=>$.map(e=>e.fileKey),[$]),Mt=M(jt,ut),Nt=(0,F.useMemo)(()=>Pe(At),[At]);(0,F.useEffect)(()=>{if(!at)return;let e=$.find(e=>e.filePath===at);e&&He.current?.scrollTo({type:`item`,id:e.fileKey,align:`start`})},[$,at,ot]);let Pt=ke({threadRef:r,workspaceRoot:R??null}),Ft=(0,F.useCallback)(e=>{Ge({threadRef:r,filePath:e,activeCwd:R,openFileSurface:Pt,openInEditor:e=>{(async()=>{let t=await Xe(e);t._tag===`Failure`&&!h(t)&&console.warn(`Failed to open diff file in editor.`,{operation:`open-diff-file`,environmentId:r.environmentId,threadId:r.threadId,...ae(se(t))})})()}})},[R,Pt,Xe,r]),It=(0,F.useCallback)(e=>{Ee(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)(()=>{Ee(e=>{let t=e.scopeKey===Y?e.fileKeys:rt;return{scopeKey:Y,fileKeys:k(jt,t)}})},[Y,jt]),Rt=e=>{P.getState().selectTurn(r,e)},zt=e=>{P.getState().selectGitScope(r,e)},Bt=e=>{P.getState().selectBranchBaseRef(r,e)};return(0,L.jsx)(ge,{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)(s,{children:[(0,L.jsxs)(ee,{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: ${ct}`,children:[(0,L.jsx)(`span`,{className:`truncate`,children:ct}),(0,L.jsx)(_,{className:`size-3.5 shrink-0 text-muted-foreground`})]}),(0,L.jsxs)(a,{align:`start`,className:`w-60`,children:[(0,L.jsx)(E,{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)(E,{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)(E,{className:W!==null&&q?.turnId===st?.turnId?`bg-foreground/[0.08]`:void 0,onClick:()=>{st&&Rt(st.turnId)},children:(0,L.jsx)(`span`,{children:`Latest turn`})}),(0,L.jsxs)(c,{children:[(0,L.jsx)(S,{children:`Turn`}),(0,L.jsx)(te,{className:`w-64`,children:U.map(e=>{let t=e.checkpointTurnCount??V[e.turnId]??`?`;return(0,L.jsxs)(E,{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:Ve(e.completedAt,d.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)(Le,{className:`size-3.5 shrink-0 opacity-70`}),(0,L.jsxs)(Ne,{items:St,filteredItems:Ct,value:K??H,onOpenChange:e=>{e||_e(``)},onValueChange:e=>{e&&Bt(e===H?null:e)},children:[(0,L.jsxs)(Ce,{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)(_,{className:`size-3.5 shrink-0 opacity-70`})]}),(0,L.jsxs)(Se,{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)(he,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1.5 left-0 size-4 shrink-0 text-muted-foreground/55`}),(0,L.jsx)(be,{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=>_e(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)(Ae,{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`})}),yt.map(e=>{let t=xt(e),n=e.local!==null&&e.remote!==null,r=e.remote?.name===t;return(0,L.jsx)(Ae,{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)(Fe,{"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)(oe,{"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)(we,{additions:Nt.additions,deletions:Nt.deletions,className:`mr-1 text-[11px]`,layout:`inline`}),$.length>0&&(0,L.jsxs)(b,{children:[(0,L.jsx)(w,{render:(0,L.jsx)(u,{type:`button`,size:`icon-xs`,variant:`outline`,"aria-label":Mt?`Expand all files`:`Collapse all files`,onClick:Lt}),children:Mt?(0,L.jsx)(Me,{className:`size-3`}):(0,L.jsx)(O,{className:`size-3`})}),(0,L.jsx)(v,{side:`top`,children:Mt?`Expand all files`:`Collapse all files`})]}),(0,L.jsxs)(A,{className:`shrink-0`,variant:`outline`,size:`xs`,value:[f],onValueChange:e=>{let t=e[0];(t===`stacked`||t===`split`)&&re(t)},children:[(0,L.jsx)(N,{"aria-label":`Stacked diff view`,value:`stacked`,children:(0,L.jsx)(j,{className:`size-3`})}),(0,L.jsx)(N,{"aria-label":`Split diff view`,value:`split`,children:(0,L.jsx)(ce,{className:`size-3`})})]}),(0,L.jsxs)(b,{children:[(0,L.jsx)(w,{render:(0,L.jsx)(N,{"aria-label":y?`Disable diff line wrapping`:`Enable diff line wrapping`,variant:`outline`,size:`xs`,pressed:y,onPressedChange:e=>{x(!!e)}}),children:(0,L.jsx)(fe,{className:`size-3`})}),(0,L.jsx)(v,{side:`top`,children:y?`Disable line wrapping`:`Enable line wrapping`})]}),(0,L.jsxs)(b,{children:[(0,L.jsx)(w,{render:(0,L.jsx)(N,{"aria-label":C?`Show whitespace changes`:`Hide whitespace changes`,variant:`outline`,size:`xs`,pressed:C,onPressedChange:e=>{T(!!e)}}),children:(0,L.jsx)(We,{className:`size-3`})}),(0,L.jsx)(v,{side:`top`,children:C?`Show whitespace changes`:`Hide whitespace changes`})]})]})]}),children:I?Qe?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:[Et&&(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.`}),Ot&&!Q&&(0,L.jsx)(`div`,{className:`px-3`,children:(0,L.jsx)(`p`,{className:`mb-2 text-[11px] text-red-500/80`,children:Ot})}),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)(Ye,{viewerRef:He,className:`diff-render-surface h-full min-h-0 overflow-auto`,files:$,sectionId:lt,sectionTitle:dt,composerDraftTarget:t,renderHeaderPrefix:(e,t,n)=>{let r=je(e);return(0,L.jsxs)(b,{children:[(0,L.jsx)(w,{render:(0,L.jsx)(`button`,{type:`button`,className:p(`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`,ye(e)),"aria-label":n?`Expand ${r}`:`Collapse ${r}`,"aria-expanded":!n,onClick:e=>{e.stopPropagation(),It(t)}}),children:n?(0,L.jsx)(g,{className:`size-4`}):(0,L.jsx)(_,{className:`size-4`})}),(0,L.jsx)(v,{side:`top`,children:n?`Expand diff`:`Collapse diff`})]})},options:{diffStyle:f===`split`?`split`:`unified`,lineDiffType:`none`,overflow:y?`wrap`:`scroll`,theme:xe(i),themeType:i,unsafeCSS:it,stickyHeaders:!0,itemMetrics:{diffHeaderHeight:33},layout:{paddingTop:0,paddingBottom:8,gap:8}}},Y??lt)}):(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:p(`max-h-[72vh] rounded-md border border-border/70 bg-background/70 p-3 font-mono text-[11px] leading-relaxed text-muted-foreground/90`,y?`overflow-auto whitespace-pre-wrap wrap-break-word`:`overflow-auto`),children:Q.text})]})}):Dt?(0,L.jsx)(de,{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:kt?`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{_e as DiffWorkerPoolProvider,U as default};
98
- //# sourceMappingURL=DiffPanel-BnLuM3jo.js.map
98
+ //# sourceMappingURL=DiffPanel-D67u97Q2.js.map