@p4code/cli 0.6.35 → 0.6.37

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
@@ -263,7 +263,7 @@ const make$123 = () => {
263
263
  const layer$124 = Layer.sync(NetService, make$123);
264
264
  //#endregion
265
265
  //#region package.json
266
- var version$1 = "0.6.35";
266
+ var version$1 = "0.6.37";
267
267
  //#endregion
268
268
  //#region ../../packages/shared/src/serverInstance.ts
269
269
  /**
@@ -7908,6 +7908,24 @@ const ServerProviderResetCredits = Schema$1.Struct({
7908
7908
  /** Pins hub redemption to the displayed credit, including retries from another client. */
7909
7909
  nextCreditId: Schema$1.optional(TrimmedNonEmptyString)
7910
7910
  });
7911
+ /** Paid usage is separate from quota windows and banked reset credits. */
7912
+ const ServerProviderSpendingCredits = Schema$1.Union([Schema$1.Struct({
7913
+ kind: Schema$1.Literal("credits"),
7914
+ hasCredits: Schema$1.Boolean,
7915
+ unlimited: Schema$1.Boolean,
7916
+ balance: Schema$1.optional(Schema$1.String.check(Schema$1.isPattern(/^\d+(?:\.\d+)?$/)))
7917
+ }), Schema$1.Struct({
7918
+ kind: Schema$1.Literal("extraUsage"),
7919
+ enabled: Schema$1.Boolean,
7920
+ currency: Schema$1.optional(Schema$1.String.check(Schema$1.isPattern(/^[A-Z]{3}$/))),
7921
+ /** Claude reports monetary amounts in minor currency units, not a wallet balance. */
7922
+ usedMinor: Schema$1.optional(Schema$1.Number.check(Schema$1.isFinite(), Schema$1.isGreaterThanOrEqualTo(0))),
7923
+ limitMinor: Schema$1.optional(Schema$1.Number.check(Schema$1.isFinite(), Schema$1.isGreaterThanOrEqualTo(0))),
7924
+ usedPercent: Schema$1.optional(Schema$1.Number.check(Schema$1.isBetween({
7925
+ minimum: 0,
7926
+ maximum: 100
7927
+ })))
7928
+ })]);
7911
7929
  /**
7912
7930
  * What the provider answered when asked to redeem a reset credit. `reset` is
7913
7931
  * the only answer that cleared anything; the others are the provider saying no.
@@ -7966,6 +7984,7 @@ const ServerProviderUsageLimits = Schema$1.Struct({
7966
7984
  checkedAt: IsoDateTime,
7967
7985
  windows: ForwardCompatibleArray(ServerProviderUsageWindow),
7968
7986
  resetCredits: Schema$1.optional(ServerProviderResetCredits),
7987
+ spendingCredits: Schema$1.optional(ServerProviderSpendingCredits),
7969
7988
  unavailable: Schema$1.optional(Schema$1.Struct({
7970
7989
  reason: Schema$1.Literals(["unsupported", "probeFailed"]),
7971
7990
  message: Schema$1.optional(TrimmedNonEmptyString)
@@ -7977,7 +7996,10 @@ const ServerProviderUsageLimits = Schema$1.Struct({
7977
7996
  * a time and Codex documents its notification as a partial. Windows merge by
7978
7997
  * `id` onto the instance's published snapshot; omitted windows are unchanged.
7979
7998
  */
7980
- const ProviderUsageLimitsUpdate = Schema$1.Struct({ windows: Schema$1.Array(ServerProviderUsageWindow) });
7999
+ const ProviderUsageLimitsUpdate = Schema$1.Struct({
8000
+ windows: Schema$1.Array(ServerProviderUsageWindow),
8001
+ spendingCredits: Schema$1.optional(Schema$1.NullOr(ServerProviderSpendingCredits))
8002
+ });
7981
8003
  var UsageLimitSourceError = class extends Schema$1.TaggedErrorClass()("UsageLimitSourceError", { detail: Schema$1.String }) {};
7982
8004
  /**
7983
8005
  * One account a usage-limit source reports on. `driver` is the provider the
@@ -65632,9 +65654,10 @@ function makeUnavailableUsageLimits(input) {
65632
65654
  */
65633
65655
  function applyUsageLimitsUpdate(input) {
65634
65656
  const { previous, update } = input;
65635
- if (update.windows.length === 0 || previous?.unavailable?.reason === "unsupported") return previous;
65657
+ if (update.windows.length === 0 && update.spendingCredits === void 0 || previous?.unavailable?.reason === "unsupported") return previous;
65636
65658
  const merged = new Map(previous?.windows.map((window) => [window.id, window]));
65637
- let changed = false;
65659
+ const spendingCredits = update.spendingCredits === void 0 ? previous?.spendingCredits : update.spendingCredits ?? void 0;
65660
+ let changed = spendingCredits !== previous?.spendingCredits && JSON.stringify(spendingCredits) !== JSON.stringify(previous?.spendingCredits);
65638
65661
  for (const window of update.windows) {
65639
65662
  const existing = merged.get(window.id);
65640
65663
  const next = {
@@ -65654,7 +65677,8 @@ function applyUsageLimitsUpdate(input) {
65654
65677
  checkedAt: input.checkedAt,
65655
65678
  windows: merged.values()
65656
65679
  }),
65657
- ...previous?.resetCredits !== void 0 ? { resetCredits: previous.resetCredits } : {}
65680
+ ...previous?.resetCredits !== void 0 ? { resetCredits: previous.resetCredits } : {},
65681
+ ...spendingCredits !== void 0 ? { spendingCredits } : {}
65658
65682
  };
65659
65683
  }
65660
65684
  function usageWindowEquals(a, b) {
@@ -67876,6 +67900,17 @@ function claudeUsageResponseToLimits(input) {
67876
67900
  names: { overageIncluded: void 0 }
67877
67901
  };
67878
67902
  const windows = [];
67903
+ const extra = response.rate_limits.extra_usage;
67904
+ const nonNegative = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : void 0;
67905
+ const currency = extra?.currency?.toUpperCase();
67906
+ const paidCredits = extra ? {
67907
+ kind: "extraUsage",
67908
+ enabled: extra.is_enabled,
67909
+ ...currency && /^[A-Z]{3}$/.test(currency) ? { currency } : {},
67910
+ ...nonNegative(extra.used_credits) !== void 0 ? { usedMinor: extra.used_credits } : {},
67911
+ ...nonNegative(extra.monthly_limit) !== void 0 ? { limitMinor: extra.monthly_limit } : {},
67912
+ ...nonNegative(extra.utilization) !== void 0 ? { usedPercent: clampPercent(extra.utilization) } : {}
67913
+ } : void 0;
67879
67914
  for (const id of Object.keys(WINDOWS)) {
67880
67915
  const window = response.rate_limits[id];
67881
67916
  if (!window || typeof window.utilization !== "number") continue;
@@ -67888,10 +67923,13 @@ function claudeUsageResponseToLimits(input) {
67888
67923
  overageIncluded ??= entry.display_name;
67889
67924
  }
67890
67925
  return {
67891
- limits: makeUsageLimits({
67892
- checkedAt,
67893
- windows
67894
- }),
67926
+ limits: {
67927
+ ...makeUsageLimits({
67928
+ checkedAt,
67929
+ windows
67930
+ }),
67931
+ ...paidCredits ? { spendingCredits: paidCredits } : {}
67932
+ },
67895
67933
  names: { overageIncluded }
67896
67934
  };
67897
67935
  }
@@ -69168,10 +69206,8 @@ const acknowledgedClaudeModel = (envelope) => {
69168
69206
  const ClaudeResultEnvelope = Schema$1.Struct({ result: Schema$1.String });
69169
69207
  const USAGE_LIMIT_LINE = /^.+:\s+\d+(?:\.\d+)?%\s+used/mu;
69170
69208
  /**
69171
- * When the CLI cannot resolve the account behind its config directory it does
69172
- * not fail: it prints the session's own cost summary — all zeroes for a
69173
- * one-shot run — in place of the account's limits. Only a report that carries a
69174
- * limit line is the report that was asked for.
69209
+ * The CLI may return session costs for API or proxy accounts. That alone does
69210
+ * not establish a login failure. Only a report with limit lines is an account report.
69175
69211
  */
69176
69212
  function isClaudeUsageReport(report) {
69177
69213
  return USAGE_LIMIT_LINE.test(report);
@@ -69481,10 +69517,13 @@ const makeClaudeTextGeneration = Effect.fn("makeClaudeTextGeneration")(function*
69481
69517
  detail: "Claude CLI returned unexpected output format.",
69482
69518
  cause
69483
69519
  })) }))).result.trim();
69484
- if (!isClaudeUsageReport(report)) return yield* new TextGenerationError({
69485
- operation,
69486
- detail: "Claude CLI answered with its session cost summary instead of the account report. That means it could not read the subscription behind its config directory - run `claude /login` for this instance's CLAUDE_CONFIG_DIR and try again."
69487
- });
69520
+ if (!isClaudeUsageReport(report)) {
69521
+ const baseUrl = claudeEnvironment.ANTHROPIC_BASE_URL?.trim();
69522
+ return yield* new TextGenerationError({
69523
+ operation,
69524
+ detail: baseUrl && !/^https:\/\/api\.anthropic\.com\/?$/i.test(baseUrl) ? "This Claude instance uses a custom API endpoint. The CLI did not report subscription limits. For pooled accounts, open Subscription limits > Manage usage sources and configure the proxy's management URL and management key." : "Claude CLI did not return subscription limits. API-key accounts do not report subscription allowances here. If this instance should use a subscription, check its login and CLAUDE_CONFIG_DIR."
69525
+ });
69526
+ }
69488
69527
  return { report };
69489
69528
  })
69490
69529
  };
@@ -91120,6 +91159,17 @@ const codexSessionAppServerArgs = (appServerArgs, launchArgs) => {
91120
91159
  };
91121
91160
  //#endregion
91122
91161
  //#region src/provider/Layers/codexUsageLimits.ts
91162
+ function spendingCredits(snapshot) {
91163
+ const credits = snapshot.credits;
91164
+ if (!credits) return void 0;
91165
+ const balance = credits.balance?.trim();
91166
+ return {
91167
+ kind: "credits",
91168
+ hasCredits: credits.hasCredits,
91169
+ unlimited: credits.unlimited,
91170
+ ...balance && /^\d+(?:\.\d+)?$/.test(balance) ? { balance } : {}
91171
+ };
91172
+ }
91123
91173
  const SESSION_MINS = 300;
91124
91174
  const WEEK_MINS = 10080;
91125
91175
  const MONTH_MINS = 720 * 60;
@@ -91181,18 +91231,25 @@ function codexResetCreditsToContract(summary) {
91181
91231
  }
91182
91232
  function codexRateLimitsToLimits(input) {
91183
91233
  const resetCredits = codexResetCreditsToContract(input.resetCredits);
91184
- const windows = codexRateLimitsToWindows(input.rateLimitsByLimitId?.codex ?? input.snapshot);
91234
+ const snapshot = input.rateLimitsByLimitId?.codex ?? input.snapshot;
91235
+ const windows = codexRateLimitsToWindows(snapshot);
91236
+ const paidCredits = spendingCredits(snapshot);
91185
91237
  return {
91186
91238
  ...makeUsageLimits({
91187
91239
  checkedAt: input.checkedAt,
91188
91240
  windows
91189
91241
  }),
91190
- ...resetCredits ? { resetCredits } : {}
91242
+ ...resetCredits ? { resetCredits } : {},
91243
+ ...paidCredits ? { spendingCredits: paidCredits } : {}
91191
91244
  };
91192
91245
  }
91193
91246
  function codexRateLimitsToUpdate(snapshot) {
91247
+ if (snapshot.limitId && snapshot.limitId !== "codex") return void 0;
91194
91248
  const windows = codexRateLimitsToWindows(snapshot);
91195
- return windows.length > 0 ? { windows } : void 0;
91249
+ return windows.length > 0 || snapshot.credits !== void 0 ? {
91250
+ windows,
91251
+ ...snapshot.credits !== void 0 ? { spendingCredits: spendingCredits(snapshot) ?? null } : {}
91252
+ } : void 0;
91196
91253
  }
91197
91254
  /**
91198
91255
  * A bounded, client-safe reason for a failed `account/rateLimits/read`. The
@@ -102737,7 +102794,7 @@ async function readManagementJson(config, path, body, signal) {
102737
102794
  });
102738
102795
  if (!response.ok || !response.body) {
102739
102796
  await response.body?.cancel();
102740
- throw new Error("Usage source request failed");
102797
+ throw new UsageLimitSourceError({ detail: response.status === 401 || response.status === 403 ? `The usage source rejected its management key (HTTP ${response.status}). Update the management key in Manage usage sources; a provider API key cannot replace it.` : `The usage source management request failed (HTTP ${response.status}). Check the source URL and management API availability.` });
102741
102798
  }
102742
102799
  const reader = response.body.getReader();
102743
102800
  const chunks = [];
@@ -102758,6 +102815,7 @@ async function readManagementJson(config, path, body, signal) {
102758
102815
  }
102759
102816
  //#endregion
102760
102817
  //#region src/usage/cliproxyApi.ts
102818
+ const isUsageLimitSourceError$1 = Schema$1.is(UsageLimitSourceError);
102761
102819
  const MAX_SOURCE_ACCOUNTS = 128;
102762
102820
  const ACCOUNT_READ_CONCURRENCY = 4;
102763
102821
  const AuthFile = Schema$1.Struct({
@@ -102783,6 +102841,11 @@ const CodexWindow = Schema$1.Struct({
102783
102841
  });
102784
102842
  const CodexUsage = Schema$1.Struct({
102785
102843
  plan_type: Schema$1.optional(Schema$1.String),
102844
+ credits: Schema$1.optional(Schema$1.NullOr(Schema$1.Struct({
102845
+ has_credits: Schema$1.Boolean,
102846
+ unlimited: Schema$1.Boolean,
102847
+ balance: Schema$1.optional(Schema$1.NullOr(Schema$1.Union([Schema$1.String, Schema$1.Number])))
102848
+ })).pipe(Schema$1.catchDecoding(() => Effect.succeedSome(null)))),
102786
102849
  rate_limit: Schema$1.NullOr(Schema$1.Struct({
102787
102850
  primary_window: Schema$1.optional(Schema$1.NullOr(CodexWindow)),
102788
102851
  secondary_window: Schema$1.optional(Schema$1.NullOr(CodexWindow))
@@ -102793,6 +102856,13 @@ const ClaudeWindow = Schema$1.Struct({
102793
102856
  resets_at: Schema$1.NullOr(Schema$1.String)
102794
102857
  });
102795
102858
  const ClaudeUsage = Schema$1.Struct({
102859
+ extra_usage: Schema$1.optional(Schema$1.NullOr(Schema$1.Struct({
102860
+ is_enabled: Schema$1.Boolean,
102861
+ monthly_limit: Schema$1.NullOr(Schema$1.Number),
102862
+ used_credits: Schema$1.NullOr(Schema$1.Number),
102863
+ utilization: Schema$1.NullOr(Schema$1.Number),
102864
+ currency: Schema$1.optional(Schema$1.NullOr(Schema$1.String))
102865
+ })).pipe(Schema$1.catchDecoding(() => Effect.succeedSome(null)))),
102796
102866
  five_hour: Schema$1.optional(Schema$1.NullOr(ClaudeWindow)),
102797
102867
  seven_day: Schema$1.optional(Schema$1.NullOr(ClaudeWindow)),
102798
102868
  limits: Schema$1.optional(Schema$1.Array(Schema$1.Struct({
@@ -102819,8 +102889,8 @@ const CREDIT_URL = `${CODEX_BASE}/rate-limit-reset-credits`;
102819
102889
  const makeCliproxyApi = Effect.gen(function* () {
102820
102890
  const management = (config, path, body) => Effect.tryPromise({
102821
102891
  try: (signal) => readManagementJson(config, path, body, signal),
102822
- catch: () => new UsageLimitSourceError({ detail: "The usage source management request failed." })
102823
- }).pipe(Effect.timeout("15 seconds"), Effect.mapError(() => new UsageLimitSourceError({ detail: "The usage source management request failed." })));
102892
+ catch: (cause) => isUsageLimitSourceError$1(cause) ? cause : new UsageLimitSourceError({ detail: "Could not reach the usage source management API. Check the source URL and connection." })
102893
+ }).pipe(Effect.timeout("15 seconds"), Effect.mapError((cause) => isUsageLimitSourceError$1(cause) ? cause : new UsageLimitSourceError({ detail: "The usage source management request timed out." })));
102824
102894
  const authFiles = Effect.fn("CliproxyApi.authFiles")(function* (config) {
102825
102895
  const response = yield* management(config, "auth-files");
102826
102896
  return (yield* decodeAuthFiles(response)).files;
@@ -102879,7 +102949,14 @@ const makeCliproxyApi = Effect.gen(function* () {
102879
102949
  rate_limits: {
102880
102950
  five_hour: usage.five_hour ?? null,
102881
102951
  seven_day: usage.seven_day ?? null,
102882
- model_scoped
102952
+ model_scoped,
102953
+ ...usage.extra_usage ? { extra_usage: {
102954
+ is_enabled: usage.extra_usage.is_enabled,
102955
+ monthly_limit: usage.extra_usage.monthly_limit,
102956
+ used_credits: usage.extra_usage.used_credits,
102957
+ utilization: usage.extra_usage.utilization,
102958
+ ...usage.extra_usage.currency !== void 0 ? { currency: usage.extra_usage.currency } : {}
102959
+ } } : {}
102883
102960
  }
102884
102961
  }
102885
102962
  }).limits
@@ -102903,7 +102980,12 @@ const makeCliproxyApi = Effect.gen(function* () {
102903
102980
  snapshot: {
102904
102981
  planType: usage.plan_type ?? null,
102905
102982
  primary: toWindow(usage.rate_limit?.primary_window),
102906
- secondary: toWindow(usage.rate_limit?.secondary_window)
102983
+ secondary: toWindow(usage.rate_limit?.secondary_window),
102984
+ credits: usage.credits ? {
102985
+ hasCredits: usage.credits.has_credits,
102986
+ unlimited: usage.credits.unlimited,
102987
+ balance: usage.credits.balance == null ? null : String(usage.credits.balance)
102988
+ } : null
102907
102989
  }
102908
102990
  }),
102909
102991
  ...available ? { resetCredits: {
@@ -102925,12 +103007,13 @@ const makeCliproxyApi = Effect.gen(function* () {
102925
103007
  })));
102926
103008
  });
102927
103009
  return { readAccounts: Effect.fn("CliproxyApi.readAccounts")(function* (config) {
102928
- const accounts = yield* authFiles(config).pipe(Effect.mapError(() => new UsageLimitSourceError({ detail: "The hub could not list accounts." })));
103010
+ const accounts = yield* authFiles(config).pipe(Effect.mapError((cause) => isUsageLimitSourceError$1(cause) ? cause : new UsageLimitSourceError({ detail: "The usage source returned an unsupported account list." })));
102929
103011
  return yield* Effect.forEach(accounts.filter((account) => !account.disabled && (account.provider === "codex" || account.provider === "claude")), (account) => readAccount(config, account), { concurrency: ACCOUNT_READ_CONCURRENCY });
102930
103012
  }) };
102931
103013
  });
102932
103014
  //#endregion
102933
103015
  //#region src/usage/UsageLimitSources.ts
103016
+ const isUsageLimitSourceError = Schema$1.is(UsageLimitSourceError);
102934
103017
  const REFRESH_INTERVAL = "5 minutes";
102935
103018
  const SOURCE_READ_TIMEOUT = "30 seconds";
102936
103019
  const SOURCE_CONCURRENCY = 4;
@@ -102959,10 +103042,10 @@ const makeWithReader = (api) => Effect.gen(function* () {
102959
103042
  return yield* api.readAccounts(config).pipe(Effect.timeout(SOURCE_READ_TIMEOUT), Effect.map((accounts) => ({
102960
103043
  ...base,
102961
103044
  accounts
102962
- })), Effect.orElseSucceed(() => ({
103045
+ })), Effect.catch((cause) => Effect.succeed({
102963
103046
  ...base,
102964
103047
  accounts: [],
102965
- error: "Could not read this usage source."
103048
+ error: isUsageLimitSourceError(cause) ? cause.detail : "The usage source request timed out. Try refreshing again."
102966
103049
  })));
102967
103050
  });
102968
103051
  const refresh = Effect.gen(function* () {
@@ -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{$r as i,Fa as a,Gu as o,Ha as s,Hr as c,Ja as l,Ot as u,Qa as d,Ra as ee,Rl as te,Ua as f,Xa as p,Ya as ne,Za as re,_t as m,b as ie,bt as h,fu as g,gl as _,h as v,hl as y,lt as b,ml as x,pl as ae,qr as oe,su as S,tu as C,vt as w,vu as T,wn as E,yn as se}from"./previewAssetResource-BvtVhg5M.js";import{a as D,c as ce,i as O,n as k,o as A,r as j,s as le,t as M}from"./toggle-group-Cd6Qv7Ia.js";import{F as N,Lr as ue,M as de,N as fe,P as pe,Q as me,Rr as he,Sr as ge,Ur as _e,Vr as ve,Wr as ye,Z as be,_r as xe,b as Se,cr as Ce,dr as we,dt as Te,fi as Ee,fr as De,ft as Oe,hr as ke,ht as P,lr as Ae,lt as je,mt as Me,or as Ne,pi as Pe,pr as Fe,pt as Ie,sr as Le,ur as Re,ut as ze,v as Be,zr as Ve}from"./index-DN7NbwKL.js";import{a as He,n as Ue}from"./fileCommentAnnotations-JIW1Jp89.js";var We=_(`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}b.getState().openFile(e,t);return}r(n?v(t,n):t)}var I=r();function Ke(e,t){let n=(0,I.c)(4),r=ke(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:a,composerDraftTarget:o,options:s,viewerRef:l,className:u,renderHeaderPrefix:d}=e,ee=c(Qe),te=c(B),f;t[0]===o?f=t[1]:(f=e=>e.getComposerDraft(o)?.reviewComments??qe,t[0]=o,t[1]=f);let p=c(f),[ne,re]=(0,F.useState)(null),[m,ie]=(0,F.useState)(null),h;t[2]===n?h=t[3]:(h=new Map(n.map(Ze)),t[2]=n,t[3]=h);let g=h,_;if(t[4]!==m||t[5]!==n||t[6]!==p||t[7]!==r){let e;t[9]!==m||t[10]!==p||t[11]!==r?(e=e=>{let{fileDiff:t,filePath:n,fileKey:a,collapsed:o}=e,s=p.filter(e=>e.sectionId===r&&e.filePath===n&&(e.fenceLanguage??`diff`)===`diff`).reduce((e,n)=>{let r=i(t,n);return r?R(e,r,{id:n.id,kind:`comment`,range:r,rangeLabel:n.rangeLabel,text:n.text}):e},[]),c=m?.fileKey===a?[...s,m.annotation]:s;return{id:a,type:`diff`,fileDiff:t,annotations:c,collapsed:o,version:ze(`${o?`1`:`0`}:${c.flatMap(z).join(`:`)}`)}},t[9]=m,t[10]=p,t[11]=r,t[12]=e):e=t[12],_=n.map(e),t[4]=m,t[5]=n,t[6]=p,t[7]=r,t[8]=_}else _=t[8];let v=_,y;t[13]!==o||t[14]!==m?.annotation||t[15]!==te?(y=e=>{re(null),m?.annotation.metadata.entries.some(t=>t.id===e)?ie(null):te(o,e)},t[13]=o,t[14]=m?.annotation,t[15]=te,t[16]=y):y=t[16];let b=y,x;t[17]!==ee||t[18]!==o||t[19]!==m||t[20]!==g||t[21]!==r||t[22]!==a?(x=(e,t)=>{let n=m?.annotation.metadata.entries.find(t=>t.id===e),i=m?g.get(m.fileKey):void 0;if(!n||!i)return;let s=oe({id:n.id,sectionId:r,sectionTitle:a,filePath:i.filePath,fileDiff:i.fileDiff,range:n.range,text:t});s&&ee(o,s),re(null),ie(null)},t[17]=ee,t[18]=o,t[19]=m,t[20]=g,t[21]=r,t[22]=a,t[23]=x):x=t[23];let ae=x,S;t[24]!==g||t[25]!==r||t[26]!==a?(S=(e,t)=>{if(!e)return;let n=t.item;if(n.type!==`diff`)return;let i=g.get(n.id);if(!i)return;let o=Ue(),s=oe({id:o,sectionId:r,sectionTitle:a,filePath:i.filePath,fileDiff:i.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]=g,t[25]=r,t[26]=a,t[27]=S):S=t[27];let C=S,w=m!==null,T;t[28]===l?T=t[29]:(T=l?{ref:l}:{},t[28]=l,t[29]=T);let E;t[30]===u?E=t[31]:(E=u?{className:u}:{},t[30]=u,t[31]=E);let se=!w,ce=!w,O;t[32]!==C||t[33]!==s||t[34]!==ce||t[35]!==se?(O={...s,enableGutterUtility:se,enableLineSelection:ce,onLineSelectionEnd:C},t[32]=C,t[33]=s,t[34]=ce,t[35]=se,t[36]=O):O=t[36];let k;t[37]===d?k=t[38]:(k=e=>e.type===`diff`?d(e.fileDiff,e.id,e.collapsed===!0):null,t[37]=d,t[38]=k);let A;t[39]!==b||t[40]!==ae?(A=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=>ae(e.id,t),onDelete:()=>b(e.id)},e.id))}),t[39]=b,t[40]=ae,t[41]=A):A=t[41];let j;return t[42]!==v||t[43]!==ne||t[44]!==O||t[45]!==k||t[46]!==A||t[47]!==T||t[48]!==E?(j=(0,L.jsx)(D,{...T,...E,items:v,selectedLines:ne,onSelectedLinesChange:re,options:O,renderHeaderPrefix:k,renderAnnotation:A}),t[42]=v,t[43]=ne,t[44]=O,t[45]=k,t[46]=A,t[47]=T,t[48]=E,t[49]=j):j=t[49],j}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:C(e,{label:`environment-data:review:diff-preview`,tag:o.reviewGetDiffPreview,staleTimeMs:5e3})}}var et=$e(E);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{$r as i,Fa as a,Gu as o,Ha as s,Hr as c,Ja as l,Ot as u,Qa as d,Ra as ee,Rl as te,Ua as f,Xa as p,Ya as ne,Za as re,_t as m,b as ie,bt as h,fu as g,gl as _,h as v,hl as y,lt as b,ml as x,pl as ae,qr as oe,su as S,tu as C,vt as w,vu as T,wn as E,yn as se}from"./previewAssetResource-DtOxXvhD.js";import{a as D,c as ce,i as O,n as k,o as A,r as j,s as le,t as M}from"./toggle-group-CTJXu0-J.js";import{F as N,Lr as ue,M as de,N as fe,P as pe,Q as me,Rr as he,Sr as ge,Ur as _e,Vr as ve,Wr as ye,Z as be,_r as xe,b as Se,cr as Ce,dr as we,dt as Te,fi as Ee,fr as De,ft as Oe,hr as ke,ht as P,lr as Ae,lt as je,mt as Me,or as Ne,pi as Pe,pr as Fe,pt as Ie,sr as Le,ur as Re,ut as ze,v as Be,zr as Ve}from"./index-ShkvHTe4.js";import{a as He,n as Ue}from"./fileCommentAnnotations-DvOcJqBW.js";var We=_(`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}b.getState().openFile(e,t);return}r(n?v(t,n):t)}var I=r();function Ke(e,t){let n=(0,I.c)(4),r=ke(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:a,composerDraftTarget:o,options:s,viewerRef:l,className:u,renderHeaderPrefix:d}=e,ee=c(Qe),te=c(B),f;t[0]===o?f=t[1]:(f=e=>e.getComposerDraft(o)?.reviewComments??qe,t[0]=o,t[1]=f);let p=c(f),[ne,re]=(0,F.useState)(null),[m,ie]=(0,F.useState)(null),h;t[2]===n?h=t[3]:(h=new Map(n.map(Ze)),t[2]=n,t[3]=h);let g=h,_;if(t[4]!==m||t[5]!==n||t[6]!==p||t[7]!==r){let e;t[9]!==m||t[10]!==p||t[11]!==r?(e=e=>{let{fileDiff:t,filePath:n,fileKey:a,collapsed:o}=e,s=p.filter(e=>e.sectionId===r&&e.filePath===n&&(e.fenceLanguage??`diff`)===`diff`).reduce((e,n)=>{let r=i(t,n);return r?R(e,r,{id:n.id,kind:`comment`,range:r,rangeLabel:n.rangeLabel,text:n.text}):e},[]),c=m?.fileKey===a?[...s,m.annotation]:s;return{id:a,type:`diff`,fileDiff:t,annotations:c,collapsed:o,version:ze(`${o?`1`:`0`}:${c.flatMap(z).join(`:`)}`)}},t[9]=m,t[10]=p,t[11]=r,t[12]=e):e=t[12],_=n.map(e),t[4]=m,t[5]=n,t[6]=p,t[7]=r,t[8]=_}else _=t[8];let v=_,y;t[13]!==o||t[14]!==m?.annotation||t[15]!==te?(y=e=>{re(null),m?.annotation.metadata.entries.some(t=>t.id===e)?ie(null):te(o,e)},t[13]=o,t[14]=m?.annotation,t[15]=te,t[16]=y):y=t[16];let b=y,x;t[17]!==ee||t[18]!==o||t[19]!==m||t[20]!==g||t[21]!==r||t[22]!==a?(x=(e,t)=>{let n=m?.annotation.metadata.entries.find(t=>t.id===e),i=m?g.get(m.fileKey):void 0;if(!n||!i)return;let s=oe({id:n.id,sectionId:r,sectionTitle:a,filePath:i.filePath,fileDiff:i.fileDiff,range:n.range,text:t});s&&ee(o,s),re(null),ie(null)},t[17]=ee,t[18]=o,t[19]=m,t[20]=g,t[21]=r,t[22]=a,t[23]=x):x=t[23];let ae=x,S;t[24]!==g||t[25]!==r||t[26]!==a?(S=(e,t)=>{if(!e)return;let n=t.item;if(n.type!==`diff`)return;let i=g.get(n.id);if(!i)return;let o=Ue(),s=oe({id:o,sectionId:r,sectionTitle:a,filePath:i.filePath,fileDiff:i.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]=g,t[25]=r,t[26]=a,t[27]=S):S=t[27];let C=S,w=m!==null,T;t[28]===l?T=t[29]:(T=l?{ref:l}:{},t[28]=l,t[29]=T);let E;t[30]===u?E=t[31]:(E=u?{className:u}:{},t[30]=u,t[31]=E);let se=!w,ce=!w,O;t[32]!==C||t[33]!==s||t[34]!==ce||t[35]!==se?(O={...s,enableGutterUtility:se,enableLineSelection:ce,onLineSelectionEnd:C},t[32]=C,t[33]=s,t[34]=ce,t[35]=se,t[36]=O):O=t[36];let k;t[37]===d?k=t[38]:(k=e=>e.type===`diff`?d(e.fileDiff,e.id,e.collapsed===!0):null,t[37]=d,t[38]=k);let A;t[39]!==b||t[40]!==ae?(A=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=>ae(e.id,t),onDelete:()=>b(e.id)},e.id))}),t[39]=b,t[40]=ae,t[41]=A):A=t[41];let j;return t[42]!==v||t[43]!==ne||t[44]!==O||t[45]!==k||t[46]!==A||t[47]!==T||t[48]!==E?(j=(0,L.jsx)(D,{...T,...E,items:v,selectedLines:ne,onSelectedLinesChange:re,options:O,renderHeaderPrefix:k,renderAnnotation:A}),t[42]=v,t[43]=ne,t[44]=O,t[45]=k,t[46]=A,t[47]=T,t[48]=E,t[49]=j):j=t[49],j}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:C(e,{label:`environment-data:review:diff-preview`,tag:o.reviewGetDiffPreview,staleTimeMs:5e3})}}var et=$e(E);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(),o=ve(),[c]=(0,F.useState)(n),[_,v]=(0,F.useState)(`stacked`),[b,oe]=(0,F.useState)(o.wordWrap),[C,E]=(0,F.useState)(o.diffIgnoreWhitespace),[D,Se]=(0,F.useState)(``),[ke,ze]=(0,F.useState)(()=>({scopeKey:null,fileKeys:rt})),He=(0,F.useRef)(null),Ue=r.threadId,I=Ve(r),qe=I?.projectId??null,Je=he(I&&qe?{environmentId:I.environmentId,projectId:qe}:null),R=I?.worktreePath??Je?.workspaceRoot,z=te(se.configValueAtom(I?.environmentId??null)),Xe=xe(I?.environmentId??null,z?.availableEditors??[]),Ze=u(I!=null&&R!=null?ue.status({environmentId:I.environmentId,input:{cwd:R}}):null),B=N(e=>pe(e.byThreadKey,r,c===`unstaged`)),Qe=Ze.data?.isRepo??!0,{turnDiffSummaries:$e,inferredCheckpointTurnCountByTurnId:V}=fe(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`&&N.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=ke.scopeKey===Y?ke.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=u(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=u(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=u(W===null&&G===`branch`&&I&&X.data?.cwd?ue.listRefs({environmentId:I.environmentId,input:{cwd:X.data.cwd,includeMatchingRemoteRefs:!0,refKind:`local`,...D.trim().length>0?{query:D.trim()}:{},limit:100}}):null),vt=u(W===null&&G===`branch`&&I&&X.data?.cwd?ue.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)(()=>Ie(Tt,`diff-panel:${i}`,{compactPartialHunkOffsets:W===null}),[i,Tt,W]),At=(0,F.useMemo)(()=>!Q||Q.kind!==`files`?[]:Q.files.toSorted((e,t)=>P(e).localeCompare(P(t),void 0,{numeric:!0,sensitivity:`base`})),[Q]),$=(0,F.useMemo)(()=>At.map(e=>{let t=je(e);return{fileDiff:e,filePath:P(e),fileKey:t,collapsed:ut.has(t)}}),[ut,At]),jt=(0,F.useMemo)(()=>$.map(e=>e.fileKey),[$]),Mt=j(jt,ut),Nt=(0,F.useMemo)(()=>Oe(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=de({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`&&!S(t)&&console.warn(`Failed to open diff file in editor.`,{operation:`open-diff-file`,environmentId:r.environmentId,threadId:r.threadId,...T(g(t))})})()}})},[R,Pt,Xe,r]),It=(0,F.useCallback)(e=>{ze(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)(()=>{ze(e=>{let t=e.scopeKey===Y?e.fileKeys:rt;return{scopeKey:Y,fileKeys:O(jt,t)}})},[Y,jt]),Rt=e=>{N.getState().selectTurn(r,e)},zt=e=>{N.getState().selectGitScope(r,e)},Bt=e=>{N.getState().selectBranchBaseRef(r,e)};return(0,L.jsx)(me,{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)(ee,{children:[(0,L.jsxs)(re,{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)(x,{className:`size-3.5 shrink-0 text-muted-foreground`})]}),(0,L.jsxs)(f,{align:`start`,className:`w-60`,children:[(0,L.jsx)(s,{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)(s,{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)(s,{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)(l,{children:[(0,L.jsx)(p,{children:`Turn`}),(0,L.jsx)(ne,{className:`w-64`,children:U.map(e=>{let t=e.checkpointTurnCount??V[e.turnId]??`?`;return(0,L.jsxs)(s,{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:ge(e.completedAt,o.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)(Pe,{className:`size-3.5 shrink-0 opacity-70`}),(0,L.jsxs)(Ne,{items:St,filteredItems:Ct,value:K??H,onOpenChange:e=>{e||Se(``)},onValueChange:e=>{e&&Bt(e===H?null:e)},children:[(0,L.jsxs)(De,{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)(x,{className:`size-3.5 shrink-0 opacity-70`})]}),(0,L.jsxs)(we,{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)(ye,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1.5 left-0 size-4 shrink-0 text-muted-foreground/55`}),(0,L.jsx)(Ce,{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)(Le,{children:`No matching refs.`}),(0,L.jsxs)(Re,{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)(y,{"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)(Be,{additions:Nt.additions,deletions:Nt.deletions,className:`mr-1 text-[11px]`,layout:`inline`}),$.length>0&&(0,L.jsxs)(m,{children:[(0,L.jsx)(h,{render:(0,L.jsx)(a,{type:`button`,size:`icon-xs`,variant:`outline`,"aria-label":Mt?`Expand all files`:`Collapse all files`,onClick:Lt}),children:Mt?(0,L.jsx)(Ee,{className:`size-3`}):(0,L.jsx)(ce,{className:`size-3`})}),(0,L.jsx)(w,{side:`top`,children:Mt?`Expand all files`:`Collapse all files`})]}),(0,L.jsxs)(k,{className:`shrink-0`,variant:`outline`,size:`xs`,value:[_],onValueChange:e=>{let t=e[0];(t===`stacked`||t===`split`)&&v(t)},children:[(0,L.jsx)(M,{"aria-label":`Stacked diff view`,value:`stacked`,children:(0,L.jsx)(A,{className:`size-3`})}),(0,L.jsx)(M,{"aria-label":`Split diff view`,value:`split`,children:(0,L.jsx)(le,{className:`size-3`})})]}),(0,L.jsxs)(m,{children:[(0,L.jsx)(h,{render:(0,L.jsx)(M,{"aria-label":b?`Disable diff line wrapping`:`Enable diff line wrapping`,variant:`outline`,size:`xs`,pressed:b,onPressedChange:e=>{oe(!!e)}}),children:(0,L.jsx)(_e,{className:`size-3`})}),(0,L.jsx)(w,{side:`top`,children:b?`Disable line wrapping`:`Enable line wrapping`})]}),(0,L.jsxs)(m,{children:[(0,L.jsx)(h,{render:(0,L.jsx)(M,{"aria-label":C?`Show whitespace changes`:`Hide whitespace changes`,variant:`outline`,size:`xs`,pressed:C,onPressedChange:e=>{E(!!e)}}),children:(0,L.jsx)(We,{className:`size-3`})}),(0,L.jsx)(w,{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=P(e);return(0,L.jsxs)(m,{children:[(0,L.jsx)(h,{render:(0,L.jsx)(`button`,{type:`button`,className:d(`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`,Te(e)),"aria-label":n?`Expand ${r}`:`Collapse ${r}`,"aria-expanded":!n,onClick:e=>{e.stopPropagation(),It(t)}}),children:n?(0,L.jsx)(ae,{className:`size-4`}):(0,L.jsx)(x,{className:`size-4`})}),(0,L.jsx)(w,{side:`top`,children:n?`Expand diff`:`Collapse diff`})]})},options:{diffStyle:_===`split`?`split`:`unified`,lineDiffType:`none`,overflow:b?`wrap`:`scroll`,theme:Me(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:d(`max-h-[72vh] rounded-md border border-border/70 bg-background/70 p-3 font-mono text-[11px] leading-relaxed text-muted-foreground/90`,b?`overflow-auto whitespace-pre-wrap wrap-break-word`:`overflow-auto`),children:Q.text})]})}):Dt?(0,L.jsx)(be,{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{Se as DiffWorkerPoolProvider,U as default};
98
- //# sourceMappingURL=DiffPanel-DHWQZCoU.js.map
98
+ //# sourceMappingURL=DiffPanel-DRPGUwdK.js.map