@cmmd-center/forge 0.13.21 → 0.13.22

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.cjs CHANGED
@@ -66232,7 +66232,7 @@ function normalizeNumberish(value) {
66232
66232
  }
66233
66233
  //#endregion
66234
66234
  //#region package.json
66235
- var version$1 = "0.13.21";
66235
+ var version$1 = "0.13.22";
66236
66236
  //#endregion
66237
66237
  //#region src/sentry.ts
66238
66238
  const SERVER_APP_NAME = "forge-server";
@@ -69595,22 +69595,52 @@ const deriveServerPaths = require_Schema$1.fn(function* (baseDir, _devUrl, _mode
69595
69595
  secretsDir: join(stateDir, "secrets")
69596
69596
  };
69597
69597
  });
69598
- const ensureServerDirectories = require_Schema$1.fn(function* (derivedPaths) {
69598
+ /**
69599
+ * Create `dir`, healing the one case a recursive mkdir cannot: a symlink whose
69600
+ * target no longer exists.
69601
+ *
69602
+ * A recursive mkdir is a no-op when the path is already a directory, but it
69603
+ * fails when the path is a DANGLING symlink, because nothing on the way down
69604
+ * resolves. bun reports that as EEXIST and node as ENOENT; either way the call
69605
+ * raises instead of recreating what the link points at.
69606
+ *
69607
+ * That shape is normal on a CMMD cloud runtime. The regenerable cache
69608
+ * directories there are symlinks onto the sprite's machine-local /tmp, which is
69609
+ * a separate device that is NOT part of the checkpointed overlay, so a wipe
69610
+ * leaves the links behind and takes their targets. Only provisioning recreated
69611
+ * them, and provisioning does not re-run on a restart, so a wiped store meant
69612
+ * the server raised at boot, exited 1, and did so again on every supervisor
69613
+ * restart for as long as the runtime existed.
69614
+ *
69615
+ * Observed live on cloud runtime 33dff4ee: /forge/caches pointed at
69616
+ * /tmp/forge-store/caches, the target was gone, and the server failed to boot
69617
+ * 974 times between 2026-09-15 and 2026-09-16. Recreating the target directory
69618
+ * by hand was the whole repair, which is what this does automatically.
69619
+ *
69620
+ * Healing is deliberately narrow. A path that is not a symlink, or a symlink
69621
+ * whose target cannot be created, re-raises the original error rather than
69622
+ * inventing a directory somewhere the caller did not ask for.
69623
+ */
69624
+ const ensureDirectory = require_Schema$1.fn(function* (dir) {
69599
69625
  const fs = yield* require_Path.FileSystem;
69626
+ const path = yield* require_Path.Path;
69627
+ yield* fs.makeDirectory(dir, { recursive: true }).pipe(require_Schema$1.catch_((error) => fs.readLink(dir).pipe(require_Schema$1.flatMap((target) => fs.makeDirectory(path.resolve(path.dirname(dir), target), { recursive: true })), require_Schema$1.mapError(() => error))));
69628
+ });
69629
+ const ensureServerDirectories = require_Schema$1.fn(function* (derivedPaths) {
69600
69630
  const path = yield* require_Path.Path;
69601
69631
  yield* require_Schema$1.all([
69602
- fs.makeDirectory(derivedPaths.stateDir, { recursive: true }),
69603
- fs.makeDirectory(derivedPaths.logsDir, { recursive: true }),
69604
- fs.makeDirectory(derivedPaths.providerLogsDir, { recursive: true }),
69605
- fs.makeDirectory(derivedPaths.terminalLogsDir, { recursive: true }),
69606
- fs.makeDirectory(derivedPaths.attachmentsDir, { recursive: true }),
69607
- fs.makeDirectory(derivedPaths.worktreesDir, { recursive: true }),
69608
- fs.makeDirectory(path.dirname(derivedPaths.keybindingsConfigPath), { recursive: true }),
69609
- fs.makeDirectory(path.dirname(derivedPaths.settingsPath), { recursive: true }),
69610
- fs.makeDirectory(derivedPaths.providerStatusCacheDir, { recursive: true }),
69611
- fs.makeDirectory(path.dirname(derivedPaths.anonymousIdPath), { recursive: true }),
69612
- fs.makeDirectory(path.dirname(derivedPaths.environmentMetadataPath), { recursive: true }),
69613
- fs.makeDirectory(path.dirname(derivedPaths.serverRuntimeStatePath), { recursive: true })
69632
+ ensureDirectory(derivedPaths.stateDir),
69633
+ ensureDirectory(derivedPaths.logsDir),
69634
+ ensureDirectory(derivedPaths.providerLogsDir),
69635
+ ensureDirectory(derivedPaths.terminalLogsDir),
69636
+ ensureDirectory(derivedPaths.attachmentsDir),
69637
+ ensureDirectory(derivedPaths.worktreesDir),
69638
+ ensureDirectory(path.dirname(derivedPaths.keybindingsConfigPath)),
69639
+ ensureDirectory(path.dirname(derivedPaths.settingsPath)),
69640
+ ensureDirectory(derivedPaths.providerStatusCacheDir),
69641
+ ensureDirectory(path.dirname(derivedPaths.anonymousIdPath)),
69642
+ ensureDirectory(path.dirname(derivedPaths.environmentMetadataPath)),
69643
+ ensureDirectory(path.dirname(derivedPaths.serverRuntimeStatePath))
69614
69644
  ], { concurrency: "unbounded" });
69615
69645
  });
69616
69646
  /**
@@ -298217,7 +298247,7 @@ function resolveBuildCommitFromEnv(env) {
298217
298247
  * environment descriptor down instead of reporting an honest "unknown".
298218
298248
  */
298219
298249
  function readBakedBuildCommit() {
298220
- return "69e84f7ffb374290143d188cb9b7312e17ee2f90";
298250
+ return "c9bc6514eb0d5f3c0eff3b12d396a11f7a96abef";
298221
298251
  }
298222
298252
  async function resolveServerBuildCommit(input) {
298223
298253
  if (isFullCommitSha(input.baked)) return input.baked;
package/dist/bin.mjs CHANGED
@@ -22,7 +22,7 @@ import { createCipheriv, createDecipheriv, createHash, createHmac, createPublicK
22
22
  import * as FS$1 from "node:fs";
23
23
  import fs, { accessSync, chmodSync, constants, createReadStream, existsSync, mkdirSync, mkdtempSync, promises, readFile, readFileSync, readdir, readdirSync, realpathSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
24
24
  import * as NodeOS from "node:os";
25
- import $U, { homedir, networkInterfaces, tmpdir } from "node:os";
25
+ import os, { homedir, networkInterfaces, tmpdir } from "node:os";
26
26
  import * as Path$1 from "node:path";
27
27
  import path, { basename, delimiter, dirname, extname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
28
28
  import { pathToFileURL } from "node:url";
@@ -50549,7 +50549,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
50549
50549
  const min = forceColor || 0;
50550
50550
  if (env.TERM === "dumb") return min;
50551
50551
  if (process$1.platform === "win32") {
50552
- const osRelease = $U.release().split(".");
50552
+ const osRelease = os.release().split(".");
50553
50553
  if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) return Number(osRelease[2]) >= 14931 ? 3 : 2;
50554
50554
  return 1;
50555
50555
  }
@@ -52992,7 +52992,7 @@ var require_ProcessDetector = /* @__PURE__ */ __commonJSMin(((exports) => {
52992
52992
  exports.processDetector = void 0;
52993
52993
  const api_1 = (init_esm$1(), __toCommonJS(esm_exports$1));
52994
52994
  const semconv_1 = require_semconv$1();
52995
- const os$3 = __require("os");
52995
+ const os$4 = __require("os");
52996
52996
  /**
52997
52997
  * ProcessDetector will be used to detect the resources related current process running
52998
52998
  * and being instrumented from the NodeJS Process module.
@@ -53014,7 +53014,7 @@ var require_ProcessDetector = /* @__PURE__ */ __commonJSMin(((exports) => {
53014
53014
  };
53015
53015
  if (process.argv.length > 1) attributes[semconv_1.ATTR_PROCESS_COMMAND] = process.argv[1];
53016
53016
  try {
53017
- const userInfo = os$3.userInfo();
53017
+ const userInfo = os$4.userInfo();
53018
53018
  attributes[semconv_1.ATTR_PROCESS_OWNER] = userInfo.username;
53019
53019
  } catch (e) {
53020
53020
  api_1.diag.debug(`error obtaining process owner: ${e}`);
@@ -65937,7 +65937,7 @@ function normalizeNumberish(value) {
65937
65937
  }
65938
65938
  //#endregion
65939
65939
  //#region package.json
65940
- var version$1 = "0.13.21";
65940
+ var version$1 = "0.13.22";
65941
65941
  //#endregion
65942
65942
  //#region src/sentry.ts
65943
65943
  const SERVER_APP_NAME = "forge-server";
@@ -69282,22 +69282,52 @@ const deriveServerPaths = fn$1(function* (baseDir, _devUrl, _mode) {
69282
69282
  secretsDir: join(stateDir, "secrets")
69283
69283
  };
69284
69284
  });
69285
- const ensureServerDirectories = fn$1(function* (derivedPaths) {
69285
+ /**
69286
+ * Create `dir`, healing the one case a recursive mkdir cannot: a symlink whose
69287
+ * target no longer exists.
69288
+ *
69289
+ * A recursive mkdir is a no-op when the path is already a directory, but it
69290
+ * fails when the path is a DANGLING symlink, because nothing on the way down
69291
+ * resolves. bun reports that as EEXIST and node as ENOENT; either way the call
69292
+ * raises instead of recreating what the link points at.
69293
+ *
69294
+ * That shape is normal on a CMMD cloud runtime. The regenerable cache
69295
+ * directories there are symlinks onto the sprite's machine-local /tmp, which is
69296
+ * a separate device that is NOT part of the checkpointed overlay, so a wipe
69297
+ * leaves the links behind and takes their targets. Only provisioning recreated
69298
+ * them, and provisioning does not re-run on a restart, so a wiped store meant
69299
+ * the server raised at boot, exited 1, and did so again on every supervisor
69300
+ * restart for as long as the runtime existed.
69301
+ *
69302
+ * Observed live on cloud runtime 33dff4ee: /forge/caches pointed at
69303
+ * /tmp/forge-store/caches, the target was gone, and the server failed to boot
69304
+ * 974 times between 2026-09-15 and 2026-09-16. Recreating the target directory
69305
+ * by hand was the whole repair, which is what this does automatically.
69306
+ *
69307
+ * Healing is deliberately narrow. A path that is not a symlink, or a symlink
69308
+ * whose target cannot be created, re-raises the original error rather than
69309
+ * inventing a directory somewhere the caller did not ask for.
69310
+ */
69311
+ const ensureDirectory = fn$1(function* (dir) {
69286
69312
  const fs = yield* FileSystem;
69313
+ const path = yield* Path$2;
69314
+ yield* fs.makeDirectory(dir, { recursive: true }).pipe(catch_((error) => fs.readLink(dir).pipe(flatMap((target) => fs.makeDirectory(path.resolve(path.dirname(dir), target), { recursive: true })), mapError(() => error))));
69315
+ });
69316
+ const ensureServerDirectories = fn$1(function* (derivedPaths) {
69287
69317
  const path = yield* Path$2;
69288
69318
  yield* all([
69289
- fs.makeDirectory(derivedPaths.stateDir, { recursive: true }),
69290
- fs.makeDirectory(derivedPaths.logsDir, { recursive: true }),
69291
- fs.makeDirectory(derivedPaths.providerLogsDir, { recursive: true }),
69292
- fs.makeDirectory(derivedPaths.terminalLogsDir, { recursive: true }),
69293
- fs.makeDirectory(derivedPaths.attachmentsDir, { recursive: true }),
69294
- fs.makeDirectory(derivedPaths.worktreesDir, { recursive: true }),
69295
- fs.makeDirectory(path.dirname(derivedPaths.keybindingsConfigPath), { recursive: true }),
69296
- fs.makeDirectory(path.dirname(derivedPaths.settingsPath), { recursive: true }),
69297
- fs.makeDirectory(derivedPaths.providerStatusCacheDir, { recursive: true }),
69298
- fs.makeDirectory(path.dirname(derivedPaths.anonymousIdPath), { recursive: true }),
69299
- fs.makeDirectory(path.dirname(derivedPaths.environmentMetadataPath), { recursive: true }),
69300
- fs.makeDirectory(path.dirname(derivedPaths.serverRuntimeStatePath), { recursive: true })
69319
+ ensureDirectory(derivedPaths.stateDir),
69320
+ ensureDirectory(derivedPaths.logsDir),
69321
+ ensureDirectory(derivedPaths.providerLogsDir),
69322
+ ensureDirectory(derivedPaths.terminalLogsDir),
69323
+ ensureDirectory(derivedPaths.attachmentsDir),
69324
+ ensureDirectory(derivedPaths.worktreesDir),
69325
+ ensureDirectory(path.dirname(derivedPaths.keybindingsConfigPath)),
69326
+ ensureDirectory(path.dirname(derivedPaths.settingsPath)),
69327
+ ensureDirectory(derivedPaths.providerStatusCacheDir),
69328
+ ensureDirectory(path.dirname(derivedPaths.anonymousIdPath)),
69329
+ ensureDirectory(path.dirname(derivedPaths.environmentMetadataPath)),
69330
+ ensureDirectory(path.dirname(derivedPaths.serverRuntimeStatePath))
69301
69331
  ], { concurrency: "unbounded" });
69302
69332
  });
69303
69333
  /**
@@ -75789,7 +75819,7 @@ var require_node_gyp_build = /* @__PURE__ */ __commonJSMin(((exports, module) =>
75789
75819
  var fs$6 = __require("fs");
75790
75820
  var path$5 = __require("path");
75791
75821
  var url$1 = __require("url");
75792
- var os$2 = __require("os");
75822
+ var os$3 = __require("os");
75793
75823
  var runtimeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
75794
75824
  var vars = process.config && process.config.variables || {};
75795
75825
  var prebuildsOnly = !!process.env.PREBUILDS_ONLY;
@@ -75797,8 +75827,8 @@ var require_node_gyp_build = /* @__PURE__ */ __commonJSMin(((exports, module) =>
75797
75827
  var abi = versions.modules;
75798
75828
  if (versions.deno || process.isBun) abi = "unsupported";
75799
75829
  var runtime = isElectron() ? "electron" : isNwjs() ? "node-webkit" : "node";
75800
- var arch = process.env.npm_config_arch || os$2.arch();
75801
- var platform = process.env.npm_config_platform || os$2.platform();
75830
+ var arch = process.env.npm_config_arch || os$3.arch();
75831
+ var platform = process.env.npm_config_platform || os$3.platform();
75802
75832
  var libc = process.env.LIBC || (isMusl(platform) ? "musl" : "glibc");
75803
75833
  var armv = process.env.ARM_VERSION || (arch === "arm64" ? "8" : vars.arm_version) || "";
75804
75834
  var uv = (versions.uv || "").split(".")[0];
@@ -93486,7 +93516,7 @@ const launchDetached = (launch) => gen(function* () {
93486
93516
  });
93487
93517
  const OpenLive = effect(Open, gen(function* () {
93488
93518
  const open = yield* tryPromise({
93489
- try: () => import("./open-D8mGyWmt.mjs"),
93519
+ try: () => import("./open-FIgTDosf.mjs"),
93490
93520
  catch: (cause) => new OpenError$1({
93491
93521
  message: "failed to load browser opener",
93492
93522
  cause
@@ -190962,7 +190992,7 @@ var Vce = {
190962
190992
  function Ve() {
190963
190993
  return Vce;
190964
190994
  }
190965
- var Us = $U.homedir(), lk = $U.tmpdir(), { env: Vc } = process$1, Yce = (e) => {
190995
+ var Us = os.homedir(), lk = os.tmpdir(), { env: Vc } = process$1, Yce = (e) => {
190966
190996
  let t = path.join(Us, "Library");
190967
190997
  return {
190968
190998
  data: path.join(t, "Application Support", e),
@@ -201162,12 +201192,12 @@ function qZ(e, t) {
201162
201192
  }
201163
201193
  return n;
201164
201194
  }
201165
- var os$1 = "https://code.claude.com/docs/en", kKe = [
201195
+ var os$2 = "https://code.claude.com/docs/en", kKe = [
201166
201196
  {
201167
201197
  matches: (e) => e.path === "permissions.defaultMode" && e.code === "invalid_value",
201168
201198
  tip: {
201169
201199
  suggestion: "Valid modes: \"acceptEdits\" (ask before file changes), \"plan\" (analysis only), \"bypassPermissions\" (auto-accept all), or \"default\" (standard behavior)",
201170
- docLink: `${os$1}/iam#permission-modes`
201200
+ docLink: `${os$2}/iam#permission-modes`
201171
201201
  }
201172
201202
  },
201173
201203
  {
@@ -201182,7 +201212,7 @@ var os$1 = "https://code.claude.com/docs/en", kKe = [
201182
201212
  matches: (e) => e.path.startsWith("env.") && e.code === "invalid_type",
201183
201213
  tip: {
201184
201214
  suggestion: "Environment variables must be strings. Wrap numbers and booleans in quotes. Example: \"DEBUG\": \"true\", \"PORT\": \"3000\"",
201185
- docLink: `${os$1}/settings#environment-variables`
201215
+ docLink: `${os$2}/settings#environment-variables`
201186
201216
  }
201187
201217
  },
201188
201218
  {
@@ -201193,14 +201223,14 @@ var os$1 = "https://code.claude.com/docs/en", kKe = [
201193
201223
  matches: (e) => e.path.startsWith("hooks.") && e.code === "invalid_key",
201194
201224
  tip: {
201195
201225
  suggestion: "Not a recognized hook event. Common events: PreToolUse, PostToolUse, UserPromptSubmit, SessionStart, SessionEnd, Stop. Check spelling and capitalization.",
201196
- docLink: `${os$1}/hooks`
201226
+ docLink: `${os$2}/hooks`
201197
201227
  }
201198
201228
  },
201199
201229
  {
201200
201230
  matches: (e) => /\.hooks\.\d+\.command$/.test(e.path) && e.code === "invalid_type" && e.received === "undefined",
201201
201231
  tip: {
201202
201232
  suggestion: "Command hooks require `command`. For exec form (no shell), set `command` to the executable and `args` to its arguments: {\"type\": \"command\", \"command\": \"echo\", \"args\": [\"hi\"]}. For shell form, set `command` to the full shell string: {\"type\": \"command\", \"command\": \"echo hi\"}.",
201203
- docLink: `${os$1}/hooks#exec-form-and-shell-form`
201233
+ docLink: `${os$2}/hooks#exec-form-and-shell-form`
201204
201234
  }
201205
201235
  },
201206
201236
  {
@@ -201215,7 +201245,7 @@ var os$1 = "https://code.claude.com/docs/en", kKe = [
201215
201245
  matches: (e) => e.code === "unrecognized_keys",
201216
201246
  tip: {
201217
201247
  suggestion: "Check for typos or refer to the documentation for valid fields",
201218
- docLink: `${os$1}/settings`
201248
+ docLink: `${os$2}/settings`
201219
201249
  }
201220
201250
  },
201221
201251
  {
@@ -201230,13 +201260,13 @@ var os$1 = "https://code.claude.com/docs/en", kKe = [
201230
201260
  matches: (e) => e.path === "permissions.additionalDirectories" && e.code === "invalid_type",
201231
201261
  tip: {
201232
201262
  suggestion: "Must be an array of directory paths. Example: [\"~/projects\", \"/tmp/workspace\"]. You can also use --add-dir flag or /add-dir command",
201233
- docLink: `${os$1}/iam#working-directories`
201263
+ docLink: `${os$2}/iam#working-directories`
201234
201264
  }
201235
201265
  }
201236
201266
  ], AKe = {
201237
- permissions: `${os$1}/iam#configuring-permissions`,
201238
- env: `${os$1}/settings#environment-variables`,
201239
- hooks: `${os$1}/hooks`
201267
+ permissions: `${os$2}/iam#configuring-permissions`,
201268
+ env: `${os$2}/settings#environment-variables`,
201269
+ hooks: `${os$2}/hooks`
201240
201270
  };
201241
201271
  function GZ(e) {
201242
201272
  let t = kKe.find((r) => r.matches(e));
@@ -268546,7 +268576,7 @@ var import_multicast_dns = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMi
268546
268576
  var dgram = __require("dgram");
268547
268577
  var thunky = require_thunky();
268548
268578
  var events = __require("events");
268549
- var os = __require("os");
268579
+ var os$1 = __require("os");
268550
268580
  var noop = function() {};
268551
268581
  module.exports = function(opts) {
268552
268582
  if (!opts) opts = {};
@@ -268677,14 +268707,14 @@ var import_multicast_dns = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMi
268677
268707
  return that;
268678
268708
  };
268679
268709
  function defaultInterface() {
268680
- var networks = os.networkInterfaces();
268710
+ var networks = os$1.networkInterfaces();
268681
268711
  var names = Object.keys(networks);
268682
268712
  for (var i = 0; i < names.length; i++) {
268683
268713
  var net = networks[names[i]];
268684
268714
  for (var j = 0; j < net.length; j++) {
268685
268715
  var iface = net[j];
268686
268716
  if (isIPv4(iface.family) && !iface.internal) {
268687
- if (os.platform() === "darwin" && names[i] === "en0") return iface.address;
268717
+ if (os$1.platform() === "darwin" && names[i] === "en0") return iface.address;
268688
268718
  return "0.0.0.0";
268689
268719
  }
268690
268720
  }
@@ -268692,7 +268722,7 @@ var import_multicast_dns = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMi
268692
268722
  return "127.0.0.1";
268693
268723
  }
268694
268724
  function allInterfaces() {
268695
- var networks = os.networkInterfaces();
268725
+ var networks = os$1.networkInterfaces();
268696
268726
  var names = Object.keys(networks);
268697
268727
  var res = [];
268698
268728
  for (var i = 0; i < names.length; i++) {
@@ -297648,7 +297678,7 @@ function resolveBuildCommitFromEnv(env) {
297648
297678
  * environment descriptor down instead of reporting an honest "unknown".
297649
297679
  */
297650
297680
  function readBakedBuildCommit() {
297651
- return "69e84f7ffb374290143d188cb9b7312e17ee2f90";
297681
+ return "c9bc6514eb0d5f3c0eff3b12d396a11f7a96abef";
297652
297682
  }
297653
297683
  async function resolveServerBuildCommit(input) {
297654
297684
  if (isFullCommitSha(input.baked)) return input.baked;
@@ -322162,7 +322192,7 @@ const connectLoginCommand = make$34("login", {
322162
322192
  })).json();
322163
322193
  },
322164
322194
  openBrowser: async (url) => {
322165
- const open = (await import("./open-D8mGyWmt.mjs")).default;
322195
+ const open = (await import("./open-FIgTDosf.mjs")).default;
322166
322196
  await open(url);
322167
322197
  return true;
322168
322198
  },
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Ha as t,Mi as n,Ua as r,Wa as i}from"./Stream-mUTFnSY9.js";import{Ba as a,Fn as o,Hc as s,Hr as c,Lc as l,Qo as u,Qr as d,Rr as f,Sr as p,Tn as m,Vc as h,Xr as g,_r as _,cs as v,d as y,fn as b,fr as x,gr as S,i as C,jn as w,l as T,m as E,n as D,qt as O,r as k,u as A,wl as j,zc as M,zr as N}from"./DiffPanelShell-CdOs97Ns.js";import{Tn as P}from"./CompositeItem-CQubmTuU.js";import{a as F,c as I,f as L,i as R,l as z,m as B,n as V,o as H,p as U,r as W,s as G,t as K}from"./Virtualizer-BS4WZy6S.js";import{Dn as q,at as J,it as ee}from"./src-DVtrA7UW.js";import{a as te,c as ne,d as re,h as ie,i as ae,l as oe,m as se,n as ce,o as Y,p as le,r as ue,s as de,t as fe,u as pe}from"./DiffPanel.logic-CaxY8ehL.js";var X=e(i(),1),me=typeof window>`u`?X.useEffect:X.useLayoutEffect;function he({fileDiff:e,options:t,editorOptions:n,lineAnnotations:r,selectedLines:i,prerenderedHTML:a,metrics:o,hasGutterRenderUtility:s,hasCustomHeader:c,disableWorkerPool:l,edit:u}){let d=V(),f=i!==void 0,p=(0,X.useContext)(C),m=A(),h=(0,X.useRef)(null),g=y(n=>{if(n!=null){if(h.current!=null)throw Error(`useFileDiffInstance: An instance should not already exist when a node is created`);d==null?h.current=new re(Z({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),l?void 0:p,!0):h.current=new pe(Z({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),d,o,l?void 0:p,!0),h.current.hydrate({fileDiff:e,fileContainer:n,lineAnnotations:r,prerenderedHTML:a})}else{if(h.current==null)throw Error(`useFileDiffInstance: A FileDiff instance should exist when unmounting`);h.current.cleanUp(),h.current=null}});return me(()=>{let{current:n}=h;if(n==null)return;let a=Z({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),o=a!==void 0&&!O(n.options,a);n.setOptions(a),n.render({forceRender:o,fileDiff:e,lineAnnotations:r}),i!==void 0&&n.setSelectedLines(i)}),me(()=>{if(u&&h.current!=null){if(m===void 0)throw Error(`FileDiff: EditContext is not attached`);let e=m(n??{});if(e==null)throw Error(`FileDiff: EditProvider.createEditor must return an editor instance`);try{return e.edit(h.current)}catch(t){throw e.cleanUp(),t}}},[u]),{ref:g,getHoveredLine:(0,X.useCallback)(()=>h.current?.getHoveredLine(),[])}}function Z({options:e,controlledSelection:t,hasCustomHeader:n,hasGutterRenderUtility:r}){return t||r||n?{...e,controlledSelection:t,renderCustomHeader:n?T:e?.renderCustomHeader,renderGutterUtility:r?T:e?.renderGutterUtility}:e}var Q=r();function ge({fileDiff:e,options:t,editorOptions:n,metrics:r,lineAnnotations:i,selectedLines:a,className:o,style:s,prerenderedHTML:c,renderAnnotation:l,renderCustomHeader:u,renderHeaderPrefix:d,renderHeaderFilenameSuffix:f,renderHeaderMetadata:p,renderGutterUtility:m,disableWorkerPool:h=!1,edit:g=!1}){let{ref:_,getHoveredLine:v}=he({fileDiff:e,options:t,editorOptions:n,metrics:r,lineAnnotations:i,selectedLines:a,prerenderedHTML:c,hasGutterRenderUtility:m!=null,hasCustomHeader:u!=null,disableWorkerPool:h,edit:g});return(0,Q.jsx)(b,{ref:_,className:o,style:s,children:W(oe({fileDiff:e,renderCustomHeader:u,renderHeaderPrefix:d,renderHeaderFilenameSuffix:f,renderHeaderMetadata:p,renderAnnotation:l,renderGutterUtility:m,lineAnnotations:i,getHoveredLine:v}),c)})}var $=t();function _e(e){return e.fromTurnCount===0?q(ee)({threadId:e.threadId,toTurnCount:e.toTurnCount}).pipe(n(e=>({kind:`fullThreadDiff`,input:e}))):q(J)({threadId:e.threadId,fromTurnCount:e.fromTurnCount,toTurnCount:e.toTurnCount}).pipe(n(e=>({kind:`turnDiff`,input:e})))}function ve(e){return e instanceof Error?e.message:typeof e==`string`?e:``}function ye(e){let t=ve(e).trim();if(t.length===0)return`Failed to load checkpoint diff.`;let n=t.toLowerCase();if(n.includes(`not a git repository`))return`Turn diffs are unavailable because this project is not a git repository.`;if(n.includes(`checkpoint unavailable for thread`)||n.includes(`checkpoint invariant violation`)){let e=t.indexOf(`:`);if(e>=0){let n=t.slice(e+1).trim();if(n.length>0)return n}}return t}function be(e){let t=ve(e).toLowerCase();return t.includes(`exceeds current turn count`)||t.includes(`checkpoint is unavailable for turn`)||t.includes(`filesystem checkpoint is unavailable`)}function xe(e){let t=_e(e);return h({queryKey:a.checkpointDiff(e),queryFn:async({signal:n})=>{if(!e.environmentId||!e.threadId||t._tag===`None`)throw Error(`Checkpoint diff is unavailable.`);let r=c(e.environmentId);try{return t.value.kind===`fullThreadDiff`?await r.orchestration.getFullThreadDiff(t.value.input,{signal:n}):await r.orchestration.getTurnDiff(t.value.input,{signal:n})}catch(e){throw Error(ye(e),{cause:e})}},enabled:(e.enabled??!0)&&!!e.environmentId&&!!e.threadId&&t._tag===`Some`,staleTime:1/0,retry:(e,t)=>be(t)?e<12:e<3,retryDelay:(e,t)=>be(t)?Math.min(5e3,250*2**(e-1)):Math.min(1e3,100*2**(e-1))})}function Se(e){if(!(!e.canScrollLeft&&!e.canScrollRight))return{maskImage:`linear-gradient(to right, ${e.canScrollLeft?`transparent 24px, black 72px`:`black`}, ${e.canScrollRight?`black calc(100% - 72px), transparent calc(100% - 24px)`:`black`})`}}function Ce(e){return e instanceof Error?e.message:e?`Failed to load checkpoint diff.`:null}function we(e){return{environmentId:e.environmentId??null,threadId:e.threadId,fromTurnCount:e.range?.fromTurnCount??null,toTurnCount:e.range?.toTurnCount??null,cacheScope:e.selectedTurnId?`turn:${e.selectedTurnId}`:e.conversationCacheScope,enabled:e.enabled}}function Te(){let e=(0,$.c)(8),t=(0,X.useRef)(null),[n,r]=(0,X.useState)(!1),[i,a]=(0,X.useState)(!1),o;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{let e=t.current;if(!e){r(!1),a(!1);return}let n=de({scrollLeft:e.scrollLeft,scrollWidth:e.scrollWidth,clientWidth:e.clientWidth});r(n.canScrollLeft),a(n.canScrollRight)},e[0]=o):o=e[0];let s=o,c;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>{t.current?.scrollBy({left:e,behavior:`smooth`})},e[1]=c):c=e[1];let l=c,u;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=e=>{let n=t.current;n&&ne({scrollWidth:n.scrollWidth,clientWidth:n.clientWidth,deltaX:e.deltaX,deltaY:e.deltaY})&&(e.preventDefault(),n.scrollBy({left:e.deltaY,behavior:`auto`}))},e[2]=u):u=e[2];let d=u,f,p;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{let e=t.current;if(!e)return;let n=window.requestAnimationFrame(s),r=()=>s();e.addEventListener(`scroll`,r,{passive:!0});let i=new ResizeObserver(()=>s());return i.observe(e),()=>{window.cancelAnimationFrame(n),e.removeEventListener(`scroll`,r),i.disconnect()}},p=[s],e[3]=f,e[4]=p):(f=e[3],p=e[4]),(0,X.useEffect)(f,p);let m;return e[5]!==n||e[6]!==i?(m={ref:t,canScrollLeft:n,canScrollRight:i,scrollBy:l,onWheel:d,remeasure:s},e[5]=n,e[6]=i,e[7]=m):m=e[7],m}function Ee(e,t){let n=(0,$.c)(5),r;n[0]===e.current?r=n[1]:(r=()=>{(e.current?.querySelector(`[data-turn-chip-selected='true']`))?.scrollIntoView({block:`nearest`,inline:`nearest`,behavior:`smooth`})},n[0]=e.current,n[1]=r);let i;n[2]!==e||n[3]!==t?(i=[e,t],n[2]=e,n[3]=t,n[4]=i):i=n[4],(0,X.useEffect)(r,i)}var De=`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Ha as t,Mi as n,Ua as r,Wa as i}from"./Stream-mUTFnSY9.js";import{Ba as a,Fn as o,Hc as s,Hr as c,Lc as l,Qo as u,Qr as d,Rr as f,Sr as p,Tn as m,Vc as h,Xr as g,_r as _,cs as v,d as y,fn as b,fr as x,gr as S,i as C,jn as w,l as T,m as E,n as D,qt as O,r as k,u as A,wl as j,zc as M,zr as N}from"./DiffPanelShell-BEZZSyhr.js";import{Tn as P}from"./CompositeItem-CQubmTuU.js";import{a as F,c as I,f as L,i as R,l as z,m as B,n as V,o as H,p as U,r as W,s as G,t as K}from"./Virtualizer-DzZ4roLU.js";import{Dn as q,at as J,it as ee}from"./src-DVtrA7UW.js";import{a as te,c as ne,d as re,h as ie,i as ae,l as oe,m as se,n as ce,o as Y,p as le,r as ue,s as de,t as fe,u as pe}from"./DiffPanel.logic-SlNrN8IK.js";var X=e(i(),1),me=typeof window>`u`?X.useEffect:X.useLayoutEffect;function he({fileDiff:e,options:t,editorOptions:n,lineAnnotations:r,selectedLines:i,prerenderedHTML:a,metrics:o,hasGutterRenderUtility:s,hasCustomHeader:c,disableWorkerPool:l,edit:u}){let d=V(),f=i!==void 0,p=(0,X.useContext)(C),m=A(),h=(0,X.useRef)(null),g=y(n=>{if(n!=null){if(h.current!=null)throw Error(`useFileDiffInstance: An instance should not already exist when a node is created`);d==null?h.current=new re(Z({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),l?void 0:p,!0):h.current=new pe(Z({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),d,o,l?void 0:p,!0),h.current.hydrate({fileDiff:e,fileContainer:n,lineAnnotations:r,prerenderedHTML:a})}else{if(h.current==null)throw Error(`useFileDiffInstance: A FileDiff instance should exist when unmounting`);h.current.cleanUp(),h.current=null}});return me(()=>{let{current:n}=h;if(n==null)return;let a=Z({controlledSelection:f,hasCustomHeader:c,hasGutterRenderUtility:s,options:t}),o=a!==void 0&&!O(n.options,a);n.setOptions(a),n.render({forceRender:o,fileDiff:e,lineAnnotations:r}),i!==void 0&&n.setSelectedLines(i)}),me(()=>{if(u&&h.current!=null){if(m===void 0)throw Error(`FileDiff: EditContext is not attached`);let e=m(n??{});if(e==null)throw Error(`FileDiff: EditProvider.createEditor must return an editor instance`);try{return e.edit(h.current)}catch(t){throw e.cleanUp(),t}}},[u]),{ref:g,getHoveredLine:(0,X.useCallback)(()=>h.current?.getHoveredLine(),[])}}function Z({options:e,controlledSelection:t,hasCustomHeader:n,hasGutterRenderUtility:r}){return t||r||n?{...e,controlledSelection:t,renderCustomHeader:n?T:e?.renderCustomHeader,renderGutterUtility:r?T:e?.renderGutterUtility}:e}var Q=r();function ge({fileDiff:e,options:t,editorOptions:n,metrics:r,lineAnnotations:i,selectedLines:a,className:o,style:s,prerenderedHTML:c,renderAnnotation:l,renderCustomHeader:u,renderHeaderPrefix:d,renderHeaderFilenameSuffix:f,renderHeaderMetadata:p,renderGutterUtility:m,disableWorkerPool:h=!1,edit:g=!1}){let{ref:_,getHoveredLine:v}=he({fileDiff:e,options:t,editorOptions:n,metrics:r,lineAnnotations:i,selectedLines:a,prerenderedHTML:c,hasGutterRenderUtility:m!=null,hasCustomHeader:u!=null,disableWorkerPool:h,edit:g});return(0,Q.jsx)(b,{ref:_,className:o,style:s,children:W(oe({fileDiff:e,renderCustomHeader:u,renderHeaderPrefix:d,renderHeaderFilenameSuffix:f,renderHeaderMetadata:p,renderAnnotation:l,renderGutterUtility:m,lineAnnotations:i,getHoveredLine:v}),c)})}var $=t();function _e(e){return e.fromTurnCount===0?q(ee)({threadId:e.threadId,toTurnCount:e.toTurnCount}).pipe(n(e=>({kind:`fullThreadDiff`,input:e}))):q(J)({threadId:e.threadId,fromTurnCount:e.fromTurnCount,toTurnCount:e.toTurnCount}).pipe(n(e=>({kind:`turnDiff`,input:e})))}function ve(e){return e instanceof Error?e.message:typeof e==`string`?e:``}function ye(e){let t=ve(e).trim();if(t.length===0)return`Failed to load checkpoint diff.`;let n=t.toLowerCase();if(n.includes(`not a git repository`))return`Turn diffs are unavailable because this project is not a git repository.`;if(n.includes(`checkpoint unavailable for thread`)||n.includes(`checkpoint invariant violation`)){let e=t.indexOf(`:`);if(e>=0){let n=t.slice(e+1).trim();if(n.length>0)return n}}return t}function be(e){let t=ve(e).toLowerCase();return t.includes(`exceeds current turn count`)||t.includes(`checkpoint is unavailable for turn`)||t.includes(`filesystem checkpoint is unavailable`)}function xe(e){let t=_e(e);return h({queryKey:a.checkpointDiff(e),queryFn:async({signal:n})=>{if(!e.environmentId||!e.threadId||t._tag===`None`)throw Error(`Checkpoint diff is unavailable.`);let r=c(e.environmentId);try{return t.value.kind===`fullThreadDiff`?await r.orchestration.getFullThreadDiff(t.value.input,{signal:n}):await r.orchestration.getTurnDiff(t.value.input,{signal:n})}catch(e){throw Error(ye(e),{cause:e})}},enabled:(e.enabled??!0)&&!!e.environmentId&&!!e.threadId&&t._tag===`Some`,staleTime:1/0,retry:(e,t)=>be(t)?e<12:e<3,retryDelay:(e,t)=>be(t)?Math.min(5e3,250*2**(e-1)):Math.min(1e3,100*2**(e-1))})}function Se(e){if(!(!e.canScrollLeft&&!e.canScrollRight))return{maskImage:`linear-gradient(to right, ${e.canScrollLeft?`transparent 24px, black 72px`:`black`}, ${e.canScrollRight?`black calc(100% - 72px), transparent calc(100% - 24px)`:`black`})`}}function Ce(e){return e instanceof Error?e.message:e?`Failed to load checkpoint diff.`:null}function we(e){return{environmentId:e.environmentId??null,threadId:e.threadId,fromTurnCount:e.range?.fromTurnCount??null,toTurnCount:e.range?.toTurnCount??null,cacheScope:e.selectedTurnId?`turn:${e.selectedTurnId}`:e.conversationCacheScope,enabled:e.enabled}}function Te(){let e=(0,$.c)(8),t=(0,X.useRef)(null),[n,r]=(0,X.useState)(!1),[i,a]=(0,X.useState)(!1),o;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{let e=t.current;if(!e){r(!1),a(!1);return}let n=de({scrollLeft:e.scrollLeft,scrollWidth:e.scrollWidth,clientWidth:e.clientWidth});r(n.canScrollLeft),a(n.canScrollRight)},e[0]=o):o=e[0];let s=o,c;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>{t.current?.scrollBy({left:e,behavior:`smooth`})},e[1]=c):c=e[1];let l=c,u;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=e=>{let n=t.current;n&&ne({scrollWidth:n.scrollWidth,clientWidth:n.clientWidth,deltaX:e.deltaX,deltaY:e.deltaY})&&(e.preventDefault(),n.scrollBy({left:e.deltaY,behavior:`auto`}))},e[2]=u):u=e[2];let d=u,f,p;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{let e=t.current;if(!e)return;let n=window.requestAnimationFrame(s),r=()=>s();e.addEventListener(`scroll`,r,{passive:!0});let i=new ResizeObserver(()=>s());return i.observe(e),()=>{window.cancelAnimationFrame(n),e.removeEventListener(`scroll`,r),i.disconnect()}},p=[s],e[3]=f,e[4]=p):(f=e[3],p=e[4]),(0,X.useEffect)(f,p);let m;return e[5]!==n||e[6]!==i?(m={ref:t,canScrollLeft:n,canScrollRight:i,scrollBy:l,onWheel:d,remeasure:s},e[5]=n,e[6]=i,e[7]=m):m=e[7],m}function Ee(e,t){let n=(0,$.c)(5),r;n[0]===e.current?r=n[1]:(r=()=>{(e.current?.querySelector(`[data-turn-chip-selected='true']`))?.scrollIntoView({block:`nearest`,inline:`nearest`,behavior:`smooth`})},n[0]=e.current,n[1]=r);let i;n[2]!==e||n[3]!==t?(i=[e,t],n[2]=e,n[3]=t,n[4]=i):i=n[4],(0,X.useEffect)(r,i)}var De=`
2
2
  [data-diffs-header],
3
3
  [data-diff],
4
4
  [data-file],
@@ -61,4 +61,4 @@ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Ha as t,Mi as n,Ua as
61
61
  text-decoration-color: currentColor;
62
62
  }
63
63
  `;function Oe(e){let t=(0,$.c)(44),{mode:n}=e,r=n===void 0?`inline`:n,{resolvedTheme:i}=S(),a=_(),[s,c]=(0,X.useState)(`stacked`),[u,d]=(0,X.useState)(a.diffWordWrap),f=(0,X.useRef)(null),h=(0,X.useRef)(!1),g=Te(),{activeCwd:v,activeThread:y,bodyState:b,diffOpen:x,inferredCheckpointTurnCountByTurnId:C,orderedTurnDiffSummaries:w,renderableFiles:T,renderablePatch:E,selectedFilePath:D,selectedTurn:O,selectedTurnId:A}=Le(i),j,P;t[0]!==x||t[1]!==a.diffWordWrap?(j=()=>{x&&!h.current&&d(a.diffWordWrap),h.current=x},P=[x,a.diffWordWrap],t[0]=x,t[1]=a.diffWordWrap,t[2]=j,t[3]=P):(j=t[2],P=t[3]),(0,X.useEffect)(j,P);let F;t[4]===D?F=t[5]:(F=()=>{!D||!f.current||Array.from(f.current.querySelectorAll(`[data-diff-file-path]`)).find(e=>e.dataset.diffFilePath===D)?.scrollIntoView({block:`nearest`})},t[4]=D,t[5]=F);let I;t[6]!==T||t[7]!==D?(I=[D,T],t[6]=T,t[7]=D,t[8]=I):I=t[8],(0,X.useEffect)(F,I);let L;t[9]===v?L=t[10]:(L=e=>{let t=p();if(!t)return;let n=v?m(e,v):e;N(t,n).catch(ke)},t[9]=v,t[10]=L);let R=L,z;t[11]===y?z=t[12]:(z=e=>{y&&o.getState().openDiff(M(l(y.environmentId,y.id)),e)},t[11]=y,t[12]=z);let B=z,V;t[13]===y?V=t[14]:(V=()=>{y&&o.getState().openDiff(M(l(y.environmentId,y.id)))},t[13]=y,t[14]=V);let H=V,U;t[15]===g.remeasure?U=t[16]:(U=()=>{let e=window.requestAnimationFrame(g.remeasure);return()=>window.cancelAnimationFrame(e)},t[15]=g.remeasure,t[16]=U);let W;t[17]!==w||t[18]!==A||t[19]!==g.remeasure?(W=[w,A,g.remeasure],t[17]=w,t[18]=A,t[19]=g.remeasure,t[20]=W):W=t[20],(0,X.useEffect)(U,W),Ee(g.ref,O?.turnId??A);let G;t[21]!==s||t[22]!==u||t[23]!==C||t[24]!==w||t[25]!==B||t[26]!==H||t[27]!==O||t[28]!==A||t[29]!==a||t[30]!==g?(G=(0,Q.jsx)(Ae,{diffRenderMode:s,diffWordWrap:u,inferredCheckpointTurnCountByTurnId:C,orderedTurnDiffSummaries:w,selectTurn:B,selectWholeConversation:H,selectedTurn:O,selectedTurnId:A,setDiffRenderMode:c,setDiffWordWrap:d,settings:a,turnStrip:g}),t[21]=s,t[22]=u,t[23]=C,t[24]=w,t[25]=B,t[26]=H,t[27]=O,t[28]=A,t[29]=a,t[30]=g,t[31]=G):G=t[31];let K=G,q;t[32]!==b||t[33]!==s||t[34]!==u||t[35]!==R||t[36]!==T||t[37]!==E||t[38]!==i?(q=(0,Q.jsx)(je,{bodyState:b,diffRenderMode:s,diffWordWrap:u,openDiffFileInEditor:R,patchViewportRef:f,renderableFiles:T,renderablePatch:E,resolvedTheme:i}),t[32]=b,t[33]=s,t[34]=u,t[35]=R,t[36]=T,t[37]=E,t[38]=i,t[39]=q):q=t[39];let J;return t[40]!==K||t[41]!==r||t[42]!==q?(J=(0,Q.jsx)(k,{mode:r,header:K,children:q}),t[40]=K,t[41]=r,t[42]=q,t[43]=J):J=t[43],J}function ke(e){console.warn(`Failed to open diff file in editor.`,e)}function Ae(e){let t=(0,$.c)(59),{diffRenderMode:n,diffWordWrap:r,inferredCheckpointTurnCountByTurnId:i,orderedTurnDiffSummaries:a,selectTurn:o,selectWholeConversation:s,selectedTurn:c,selectedTurnId:l,setDiffRenderMode:u,setDiffWordWrap:d,settings:f,turnStrip:p}=e,m,h;t[0]===p?(m=t[1],h=t[2]):(m=(0,Q.jsx)(Be,{direction:`left`,strip:p}),h=(0,Q.jsx)(Be,{direction:`right`,strip:p}),t[0]=p,t[1]=m,t[2]=h);let g=p.ref,_;t[3]!==p.canScrollLeft||t[4]!==p.canScrollRight?(_=Se({canScrollLeft:p.canScrollLeft,canScrollRight:p.canScrollRight}),t[3]=p.canScrollLeft,t[4]=p.canScrollRight,t[5]=_):_=t[5];let v=p.onWheel,y=l===null,b=l===null?`border-border bg-accent text-accent-foreground`:`border-border/70 bg-background/70 text-muted-foreground/80 hover:border-border hover:text-foreground/80`,x;t[6]===b?x=t[7]:(x=P(`rounded-md border px-2 py-1 text-left transition-colors`,b),t[6]=b,t[7]=x);let S;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Q.jsx)(`div`,{className:`text-[10px] leading-tight font-medium`,children:`All turns`}),t[8]=S):S=t[8];let C;t[9]===x?C=t[10]:(C=(0,Q.jsx)(`div`,{className:x,children:S}),t[9]=x,t[10]=C);let w;t[11]!==s||t[12]!==C||t[13]!==y?(w=(0,Q.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md`,onClick:s,"data-turn-chip-selected":y,children:C}),t[11]=s,t[12]=C,t[13]=y,t[14]=w):w=t[14];let T;if(t[15]!==i||t[16]!==a||t[17]!==o||t[18]!==c?.turnId||t[19]!==f){let e;t[21]!==i||t[22]!==o||t[23]!==c?.turnId||t[24]!==f?(e=e=>(0,Q.jsx)(Ve,{summary:e,selected:e.turnId===c?.turnId,turnCount:e.checkpointTurnCount??i[e.turnId],timestampFormat:f.timestampFormat,onSelect:o},e.turnId),t[21]=i,t[22]=o,t[23]=c?.turnId,t[24]=f,t[25]=e):e=t[25],T=a.map(e),t[15]=i,t[16]=a,t[17]=o,t[18]=c?.turnId,t[19]=f,t[20]=T}else T=t[20];let E;t[26]!==w||t[27]!==T||t[28]!==_||t[29]!==p.onWheel||t[30]!==p.ref?(E=(0,Q.jsxs)(`div`,{ref:g,className:`turn-chip-strip flex gap-1 overflow-x-auto px-8 py-0.5`,style:_,onWheel:v,children:[w,T]}),t[26]=w,t[27]=T,t[28]=_,t[29]=p.onWheel,t[30]=p.ref,t[31]=E):E=t[31];let D;t[32]!==m||t[33]!==E||t[34]!==h?(D=(0,Q.jsxs)(`div`,{className:`relative min-w-0 flex-1 [-webkit-app-region:no-drag]`,children:[m,h,E]}),t[32]=m,t[33]=E,t[34]=h,t[35]=D):D=t[35];let O;t[36]===n?O=t[37]:(O=[n],t[36]=n,t[37]=O);let k;t[38]===u?k=t[39]:(k=e=>{let t=e[0];(t===`stacked`||t===`split`)&&u(t)},t[38]=u,t[39]=k);let A;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Q.jsx)(R,{"aria-label":`Stacked diff view`,value:`stacked`,children:(0,Q.jsx)(se,{className:`size-3`})}),t[40]=A):A=t[40];let j;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,Q.jsx)(R,{"aria-label":`Split diff view`,value:`split`,children:(0,Q.jsx)(ie,{className:`size-3`})}),t[41]=j):j=t[41];let M;t[42]!==O||t[43]!==k?(M=(0,Q.jsxs)(F,{className:`shrink-0`,variant:`outline`,size:`xs`,value:O,onValueChange:k,children:[A,j]}),t[42]=O,t[43]=k,t[44]=M):M=t[44];let N=r?`Disable diff line wrapping`:`Enable diff line wrapping`,I=r?`Disable line wrapping`:`Enable line wrapping`,L;t[45]===d?L=t[46]:(L=e=>{d(!!e)},t[45]=d,t[46]=L);let z;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,Q.jsx)(le,{className:`size-3`}),t[47]=z):z=t[47];let B;t[48]!==r||t[49]!==N||t[50]!==I||t[51]!==L?(B=(0,Q.jsx)(R,{"aria-label":N,title:I,variant:`outline`,size:`xs`,pressed:r,onPressedChange:L,children:z}),t[48]=r,t[49]=N,t[50]=I,t[51]=L,t[52]=B):B=t[52];let V;t[53]!==M||t[54]!==B?(V=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 [-webkit-app-region:no-drag]`,children:[M,B]}),t[53]=M,t[54]=B,t[55]=V):V=t[55];let H;return t[56]!==D||t[57]!==V?(H=(0,Q.jsxs)(Q.Fragment,{children:[D,V]}),t[56]=D,t[57]=V,t[58]=H):H=t[58],H}function je(e){let t=(0,$.c)(18),{bodyState:n,diffRenderMode:r,diffWordWrap:i,openDiffFileInEditor:a,patchViewportRef:o,renderableFiles:s,renderablePatch:c,resolvedTheme:l}=e;if(n.kind===`no-thread`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(Ne,{children:`Select a thread to inspect turn diffs.`}),t[0]=e):e=t[0],e}if(n.kind===`not-git-repo`){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(Ne,{children:`Turn diffs are unavailable because this project is not a git repository.`}),t[1]=e):e=t[1],e}if(n.kind===`no-completed-turns`){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(Ne,{children:`No completed turns yet.`}),t[2]=e):e=t[2],e}let u;t[3]!==n.error||t[4]!==c?(u=n.error&&!c&&(0,Q.jsx)(`div`,{className:`px-3`,children:(0,Q.jsx)(`p`,{className:`mb-2 text-[11px] text-destructive-foreground`,children:n.error})}),t[3]=n.error,t[4]=c,t[5]=u):u=t[5];let d;t[6]!==n||t[7]!==r||t[8]!==i||t[9]!==a||t[10]!==s||t[11]!==c||t[12]!==l?(d=c?c.kind===`files`?(0,Q.jsx)(K,{className:`diff-render-surface h-full min-h-0 overflow-auto px-2 pb-2`,config:{overscrollSize:600,intersectionObserverMargin:1200},children:s.map(e=>{let t=Y(e),n=`${fe(e)}:${l}`;return(0,Q.jsx)(`div`,{"data-diff-file-path":t,className:`diff-render-file mb-2 rounded-md first:mt-2 last:mb-0`,onClickCapture:e=>{(e.nativeEvent.composedPath?.()??[]).some(Me)&&a(t)},children:(0,Q.jsx)(ge,{fileDiff:e,options:{diffStyle:r===`split`?`split`:`unified`,lineDiffType:`none`,overflow:i?`wrap`:`scroll`,theme:E(l),themeType:l,unsafeCSS:De}})},n)})}):(0,Q.jsx)(`div`,{className:`h-full overflow-auto p-2`,children:(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] text-muted-foreground/75`,children:c.reason}),(0,Q.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`,i?`overflow-auto whitespace-pre-wrap wrap-break-word`:`overflow-auto`),children:c.text})]})}):(0,Q.jsx)(Re,{bodyState:n}),t[6]=n,t[7]=r,t[8]=i,t[9]=a,t[10]=s,t[11]=c,t[12]=l,t[13]=d):d=t[13];let f;return t[14]!==o||t[15]!==u||t[16]!==d?(f=(0,Q.jsx)(Q.Fragment,{children:(0,Q.jsxs)(`div`,{ref:o,className:`diff-panel-viewport min-h-0 min-w-0 flex-1 overflow-hidden`,children:[u,d]})}),t[14]=o,t[15]=u,t[16]=d,t[17]=f):f=t[17],f}function Me(e){return e instanceof Element&&e.hasAttribute(`data-title`)}function Ne(e){let t=(0,$.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Q.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:n}),t[0]=n,t[1]=r),r}function Pe(){let e=(0,$.c)(19),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={strict:!1,select:Ie},e[0]=t):t=e[0];let n=j(t),r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r={strict:!1,select:Fe},e[1]=r):r=e[1];let i=B(r),a=i.rightPanel===`diff`,o=n?.threadId??null,s,c;e[2]===n?c=e[3]:(c=w(n),e[2]=n,e[3]=c),s=c;let l=v(s),u=He(l),d=l?.worktreePath,p=u?.cwd,m;e[4]!==d||e[5]!==p?(m=I({threadWorktreePath:d,projectCwd:p}),e[4]=d,e[5]=p,e[6]=m):m=e[6];let h=m,g=l?.environmentId??null,_=h??null,y;e[7]!==g||e[8]!==_?(y={environmentId:g,cwd:_},e[7]=g,e[8]=_,e[9]=y):y=e[9];let b=f(y),x;e[10]===b.data?x=e[11]:(x=z(b.data),e[10]=b.data,e[11]=x);let S=x,C;return e[12]!==h||e[13]!==l||e[14]!==o||e[15]!==a||e[16]!==i||e[17]!==S?(C={activeThread:l,activeThreadId:o,activeCwd:h,isGitRepo:S,diffSearch:i,diffOpen:a},e[12]=h,e[13]=l,e[14]=o,e[15]=a,e[16]=i,e[17]=S,e[18]=C):C=e[18],C}function Fe(e){return G(e)}function Ie(e){return g(e)}function Le(e){let{activeThread:t,activeThreadId:n,activeCwd:r,isGitRepo:i,diffSearch:a,diffOpen:o}=Pe(),{turnDiffSummaries:c,inferredCheckpointTurnCountByTurnId:l}=H(t),u=a.diffTurnId??null,d=u===null?null:a.diffFilePath??null,{activeCheckpointRange:f,conversationCacheScope:p,orderedTurnDiffSummaries:m,selectedTurn:h}=(0,X.useMemo)(()=>te({summaries:c,inferredCheckpointTurnCountByTurnId:l,selectedTurnId:u}),[l,u,c]),g=s(xe(we({environmentId:t?.environmentId,threadId:n,range:f,selectedTurnId:h?.turnId,conversationCacheScope:p,enabled:i}))),_=g.isLoading,v=Ce(g.error),y=g.data?.diff,b=typeof y==`string`&&y.trim().length===0,{emptyDiffMessage:x}=(0,X.useMemo)(()=>ae(h),[h]),S=(0,X.useMemo)(()=>ce(y,`diff-panel:${e}`),[e,y]),C=(0,X.useMemo)(()=>Ue(S),[S]);return{activeCwd:r,activeThread:t,bodyState:ue({hasActiveThread:!!t,isGitRepo:i,turnSummaryCount:m.length,checkpointDiffError:v,hasRenderablePatch:!!S,isLoadingCheckpointDiff:_,hasNoNetChanges:b,emptyDiffMessage:x}),diffOpen:o,inferredCheckpointTurnCountByTurnId:l,orderedTurnDiffSummaries:m,renderableFiles:C,renderablePatch:S,selectedFilePath:d,selectedTurn:h,selectedTurnId:u}}function Re(e){let t=(0,$.c)(4),{bodyState:n}=e;if(n.kind===`loading`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Q.jsx)(D,{label:`Loading checkpoint diff...`}),t[0]=e):e=t[0],e}let r;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Q.jsx)(L,{className:`size-7 text-muted-foreground/25`}),t[1]=r):r=t[1];let i=n.kind===`empty`?n.message:`No diff is available for this range.`,a;return t[2]===i?a=t[3]:(a=(0,Q.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 px-5 py-2 text-center`,children:[r,(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground/70`,children:i})]}),t[2]=i,t[3]=a),a}var ze=180;function Be(e){let t=(0,$.c)(14),{direction:n,strip:r}=e,i=n===`left`,a=i?r.canScrollLeft:r.canScrollRight,o=i?U:d,s=i?`left-0`:`right-0`,c=a?`border-border/70 hover:border-border hover:text-foreground`:`cursor-not-allowed border-border/40 text-muted-foreground/40`,l;t[0]!==s||t[1]!==c?(l=P(`absolute top-1/2 z-20 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded-md border bg-background/90 text-muted-foreground transition-colors`,s,c),t[0]=s,t[1]=c,t[2]=l):l=t[2];let u;t[3]!==i||t[4]!==r?(u=()=>r.scrollBy(i?-180:ze),t[3]=i,t[4]=r,t[5]=u):u=t[5];let f=!a,p=`Scroll turn list ${n}`,m;t[6]===o?m=t[7]:(m=(0,Q.jsx)(o,{className:`size-3.5`}),t[6]=o,t[7]=m);let h;return t[8]!==l||t[9]!==u||t[10]!==f||t[11]!==p||t[12]!==m?(h=(0,Q.jsx)(`button`,{type:`button`,className:l,onClick:u,disabled:f,"aria-label":p,children:m}),t[8]=l,t[9]=u,t[10]=f,t[11]=p,t[12]=m,t[13]=h):h=t[13],h}function Ve(e){let t=(0,$.c)(23),{summary:n,selected:r,turnCount:i,timestampFormat:a,onSelect:o}=e,s;t[0]!==o||t[1]!==n.turnId?(s=()=>o(n.turnId),t[0]=o,t[1]=n.turnId,t[2]=s):s=t[2];let c=n.turnId,l=r?`border-border bg-accent text-accent-foreground`:`border-border/70 bg-background/70 text-muted-foreground/80 hover:border-border hover:text-foreground/80`,u;t[3]===l?u=t[4]:(u=P(`rounded-md border px-2 py-1 text-left transition-colors`,l),t[3]=l,t[4]=u);let d=i??`?`,f;t[5]===d?f=t[6]:(f=(0,Q.jsxs)(`span`,{className:`text-[10px] leading-tight font-medium`,children:[`Turn `,d]}),t[5]=d,t[6]=f);let p;t[7]!==n.completedAt||t[8]!==a?(p=x(n.completedAt,a),t[7]=n.completedAt,t[8]=a,t[9]=p):p=t[9];let m;t[10]===p?m=t[11]:(m=(0,Q.jsx)(`span`,{className:`text-[9px] leading-tight opacity-70`,children:p}),t[10]=p,t[11]=m);let h;t[12]!==f||t[13]!==m?(h=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[f,m]}),t[12]=f,t[13]=m,t[14]=h):h=t[14];let g;t[15]!==u||t[16]!==h?(g=(0,Q.jsx)(`div`,{className:u,children:h}),t[15]=u,t[16]=h,t[17]=g):g=t[17];let _;return t[18]!==r||t[19]!==n.turnId||t[20]!==s||t[21]!==g?(_=(0,Q.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-md`,onClick:s,title:c,"data-turn-chip-selected":r,children:g}),t[18]=r,t[19]=n.turnId,t[20]=s,t[21]=g,t[22]=_):_=t[22],_}function He(e){let t=(0,$.c)(3),n=e?.environmentId,r=e?.projectId,i;return t[0]!==n||t[1]!==r?(i=e=>n&&r?u(e,{environmentId:n,projectId:r}):void 0,t[0]=n,t[1]=r,t[2]=i):i=t[2],v(i)}function Ue(e){return!e||e.kind!==`files`?[]:e.files.toSorted((e,t)=>Y(e).localeCompare(Y(t),void 0,{numeric:!0,sensitivity:`base`}))}export{Oe as default};
64
- //# sourceMappingURL=DiffPanel-B_FNg0mv.js.map
64
+ //# sourceMappingURL=DiffPanel-4dMGnRQx.js.map