@codexhost/cli-darwin-x64 0.19.0 → 0.20.0

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.
Files changed (56) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +24 -3
  4. package/app/console-web.js +1095 -682
  5. package/app/desktop-controller.mjs +40 -4
  6. package/app/host-runtime.mjs +1572 -1120
  7. package/app/plugins/antigravity/plugin.mjs +8753 -4274
  8. package/app/plugins/claude-code/plugin.mjs +26 -3
  9. package/app/plugins/codebuddy/plugin.mjs +41 -5
  10. package/app/plugins/codex-usage/plugin.mjs +26 -3
  11. package/app/plugins/copilot/plugin.mjs +26 -3
  12. package/app/plugins/cursor-cli/plugin.mjs +26 -3
  13. package/app/plugins/deepseek-harness/plugin.mjs +26 -3
  14. package/app/plugins/devin/plugin.mjs +25 -3
  15. package/app/plugins/grok/plugin.mjs +26 -3
  16. package/app/plugins/hermes/plugin.mjs +25 -3
  17. package/app/plugins/kimi-code/plugin.mjs +26 -3
  18. package/app/plugins/kiro-cli/plugin.mjs +26 -3
  19. package/app/plugins/omp/plugin.mjs +44 -6
  20. package/app/plugins/opencode/plugin.mjs +26 -3
  21. package/app/plugins/pi/plugin.mjs +45 -6
  22. package/app/plugins/qoder/plugin.mjs +48 -4
  23. package/app/plugins/qoder-cn/plugin.mjs +48 -4
  24. package/app/plugins/qwen-code/plugin.mjs +26 -3
  25. package/app/plugins/workbuddy/plugin.mjs +45 -8
  26. package/app/plugins/zcode/plugin.mjs +26 -3
  27. package/app/renderer-extension.js +1411 -737
  28. package/app/web/assets/index-D6-hvggd.css +1 -0
  29. package/app/web/assets/index-D85gPBbQ.js +201 -0
  30. package/app/web/assets/langs/{graphql-B8vkg11W.js → graphql-ChAeyPkT.js} +1 -1
  31. package/app/web/assets/langs/{http-DmoDEjMt.js → http-BvreBIbD.js} +1 -1
  32. package/app/web/assets/langs/{php-DJ5ovfAM.js → php-D8omCIuJ.js} +1 -1
  33. package/app/web/assets/langs/{rst-U5-R5x3p.js → rst-Do7RLLCS.js} +1 -1
  34. package/app/web/assets/langs/{ruby-VKVsnS0H.js → ruby-rH_O_vse.js} +1 -1
  35. package/app/web/assets/langs/{svelte-C20lOv9V.js → svelte-xZy73wAj.js} +1 -1
  36. package/app/web/assets/langs/{vue-z6Y-lzP-.js → vue-C4DW8agZ.js} +1 -1
  37. package/app/web/assets/{vendor-dSL872WO.js → vendor-C9g2bw8s.js} +3 -3
  38. package/app/web/codexhost-settings.js +1101 -684
  39. package/app/web/index.html +4 -3
  40. package/app/web/plugins/deepseek-ai__dsh-api-gateway/client.js +2 -2
  41. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
  42. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +8 -8
  43. package/app/web/plugins/deepseek-ai__dsh-client-connection/client.js +1 -1
  44. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +74 -69
  45. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +3 -3
  46. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +13 -13
  47. package/app/web/plugins/deepseek-ai__dsh-client-ui-session/client.js +1 -1
  48. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
  49. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +7 -7
  50. package/app/web-modules/server.mjs +138 -70
  51. package/bin/codexhost +0 -0
  52. package/libexec/codexhost-shim +0 -0
  53. package/libexec/codexhost-updater +0 -0
  54. package/package.json +1 -1
  55. package/app/web/assets/index-BNQIOOHE.css +0 -1
  56. package/app/web/assets/index-Feo4BkqN.js +0 -199
@@ -14765,13 +14765,25 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14765
14765
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
14766
14766
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
14767
14767
  var cacheHitRatePercentSchema = external_exports.number().finite().min(0).max(100);
14768
+ var usageOutputTimingSchema = external_exports.object({
14769
+ version: external_exports.literal(3).optional(),
14770
+ requestId: external_exports.string().min(1),
14771
+ turnId: external_exports.string().min(1).max(1024),
14772
+ outputTokens: nonNegativeSafeIntegerSchema,
14773
+ startedAtMs: nonNegativeSafeIntegerSchema,
14774
+ completedAtMs: nonNegativeSafeIntegerSchema
14775
+ }).strict().refine((value) => value.completedAtMs > value.startedAtMs);
14768
14776
  var usageMeasurementSchema = external_exports.object({
14777
+ version: external_exports.union([external_exports.literal(2), external_exports.literal(3)]).optional(),
14769
14778
  value: finiteNonNegativeNumberSchema,
14770
14779
  turnId: external_exports.string().min(1).max(1024),
14771
14780
  at: nonNegativeSafeIntegerSchema
14772
14781
  }).strict();
14773
14782
  var usageMeasurementsSchema = external_exports.object({
14774
- outputTokensPerSecond: usageMeasurementSchema.optional(),
14783
+ // Unversioned intervals can omit hidden thinking time; do not restore them into averages.
14784
+ outputTimings: external_exports.array(usageOutputTimingSchema).transform((values) => values.filter((value) => value.version === 3)).optional(),
14785
+ // Retain independent TTFT facts when dropping incompatible speed measurements.
14786
+ outputTokensPerSecond: usageMeasurementSchema.refine((value) => value.version === 3).optional().catch(void 0),
14775
14787
  timeToFirstOutputMs: usageMeasurementSchema.extend({ value: nonNegativeSafeIntegerSchema }).optional()
14776
14788
  }).strict();
14777
14789
  var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text) => text.length <= maximum));
@@ -14791,6 +14803,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14791
14803
  cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
14792
14804
  outputTokens: nonNegativeSafeIntegerSchema.optional(),
14793
14805
  outputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
14806
+ sessionOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
14794
14807
  apiOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
14795
14808
  reasoningOutputTokens: nonNegativeSafeIntegerSchema.optional(),
14796
14809
  totalTokens: nonNegativeSafeIntegerSchema.optional(),
@@ -15203,6 +15216,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15203
15216
  delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
15204
15217
  }).strict();
15205
15218
 
15219
+ // ../shared-contracts/dist/thread-archive-confirm.js
15220
+ var threadArchiveConfirmParamsSchema = external_exports.object({ threadId: hostThreadIdSchema }).strict();
15221
+ var threadArchiveConfirmResultSchema = external_exports.object({ confirmed: external_exports.boolean() }).strict();
15222
+
15206
15223
  // ../shared-contracts/dist/client-channel.js
15207
15224
  var CLIENT_CHANNEL_VERSION = 1;
15208
15225
  var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
@@ -15342,7 +15359,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15342
15359
  /** Current interruptible Host Turn, including command Turns omitted from client history. */
15343
15360
  activeTurnId: external_exports.string().min(1).nullable().optional(),
15344
15361
  /** Most recent explicit command in this Host process; not native conversation history. */
15345
- command: external_exports.object({ name: external_exports.string().min(1), turn: clientTurnSchema }).optional(),
15362
+ command: external_exports.object({
15363
+ name: external_exports.string().min(1),
15364
+ turn: clientTurnSchema,
15365
+ /** First ordinary Turn started after this command; its retained result is not a new event. */
15366
+ subsequentTurnId: external_exports.string().min(1).optional()
15367
+ }).optional(),
15346
15368
  thread: external_exports.object({
15347
15369
  id: external_exports.string().min(1),
15348
15370
  cwd: external_exports.string(),
@@ -15552,7 +15574,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15552
15574
  quotaUntil: external_exports.string().optional()
15553
15575
  }).strict().optional()
15554
15576
  }).strict();
15555
- var webLocalAccessRequiredDetailsSchema = external_exports.object({ url: external_exports.string() }).strict();
15556
15577
 
15557
15578
  // ../shared-contracts/dist/delegation-read.js
15558
15579
  var REMOTE_THREAD_REPLY_MAX_BYTES = 16 * 1024 * 1024;
@@ -17713,7 +17734,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17713
17734
  await Promise.all(
17714
17735
  plugins.map(async ({ id }) => {
17715
17736
  try {
17716
- const inspection = await client.inspectHarness({ harnessId: id, refresh });
17737
+ const inspection = await client.inspectHarness({
17738
+ harnessId: id,
17739
+ refresh,
17740
+ purpose: "availability"
17741
+ });
17717
17742
  availability.set(id, inspection.status);
17718
17743
  webUi.set(id, inspection.status === "ready" && inspection.webUi?.open === true);
17719
17744
  const error51 = inspection.status === "ready" ? null : inspection.error;
@@ -23470,6 +23495,7 @@ th[aria-sort] .console-usage-sort__mark {
23470
23495
  latestCacheHit: "Latest cache hit (CH)",
23471
23496
  sessionCacheHit: "Average cache hit",
23472
23497
  outputSpeed: "Output speed (TPS)",
23498
+ averageOutputSpeed: "Average output speed (TPS)",
23473
23499
  apiOutputSpeed: "API average speed",
23474
23500
  apiOutputSpeedDescription: "Output tokens / native API time, including first-token wait; not generation TPS.",
23475
23501
  timeToFirstOutput: "Time to first token (TTFT)",
@@ -23495,6 +23521,7 @@ th[aria-sort] .console-usage-sort__mark {
23495
23521
  latestCacheHit: "\u6700\u8FD1\u7F13\u5B58\u547D\u4E2D\uFF08CH\uFF09",
23496
23522
  sessionCacheHit: "\u5E73\u5747\u7F13\u5B58\u547D\u4E2D",
23497
23523
  outputSpeed: "\u8F93\u51FA\u901F\u5EA6\uFF08TPS\uFF09",
23524
+ averageOutputSpeed: "\u5E73\u5747\u8F93\u51FA\u901F\u5EA6\uFF08TPS\uFF09",
23498
23525
  apiOutputSpeed: "API \u5E73\u5747\u901F\u5EA6",
23499
23526
  apiOutputSpeedDescription: "\u8F93\u51FA Token \xF7 \u539F\u751F API \u8017\u65F6\uFF0C\u542B\u9996\u5B57\u7B49\u5F85\uFF1B\u4E0D\u662F\u751F\u6210 TPS\u3002",
23500
23527
  timeToFirstOutput: "\u9996 token\uFF08TTFT\uFF09",
@@ -27234,242 +27261,474 @@ ${detail}` : ""}`
27234
27261
  return fallback;
27235
27262
  }
27236
27263
 
27237
- // src/settings/harness-launch-controls.ts
27238
- function createHarnessLaunchControls(document2, messages, agent, settings) {
27239
- const section = document2.createElement("section");
27240
- section.className = "settings-harness-launch";
27241
- section.dataset.harnessLaunch = agent;
27242
- const label = document2.createElement("label");
27243
- label.textContent = messages.launchPathLabel;
27244
- const input = document2.createElement("input");
27245
- input.type = "text";
27246
- input.autocomplete = "off";
27247
- input.spellcheck = false;
27248
- input.placeholder = messages.locale === "zh-CN" ? "\u5E94\u7528\u5B89\u88C5\u76EE\u5F55\u7684\u7EDD\u5BF9\u8DEF\u5F84" : "Absolute installation directory";
27249
- input.setAttribute("aria-label", messages.launchPathLabel);
27250
- label.append(input);
27251
- const help = document2.createElement("p");
27252
- help.textContent = messages.locale === "zh-CN" ? "\u586B\u5199\u63D2\u4EF6\u5BF9\u5E94\u5E94\u7528\u7684\u5B89\u88C5\u76EE\u5F55\uFF1B\u6E05\u9664\u540E\u6062\u590D\u81EA\u52A8\u53D1\u73B0\u3002\u4FEE\u6539\u540E\u9700\u91CD\u542F codexhost\u3002" : "Choose the application's installation directory; clear it to restore automatic discovery. Restart codexhost after changing it.";
27253
- const actions = document2.createElement("div");
27254
- actions.className = "settings-harness-launch__actions";
27255
- const save = document2.createElement("button");
27256
- save.type = "button";
27257
- save.className = "settings-command-button";
27258
- save.textContent = messages.launchPathSave;
27259
- const reset = document2.createElement("button");
27260
- reset.type = "button";
27261
- reset.className = "settings-command-button settings-command-button--secondary";
27262
- reset.textContent = messages.launchPathReset;
27263
- const status = document2.createElement("p");
27264
- status.setAttribute("role", "status");
27265
- status.setAttribute("aria-live", "polite");
27266
- actions.append(save, reset);
27267
- section.append(label, help, actions, status);
27268
- let busy = true;
27269
- let loaded = false;
27270
- const controls = () => {
27271
- input.disabled = busy || !loaded;
27272
- save.disabled = busy || !loaded || !input.value.trim();
27273
- reset.disabled = busy || !loaded;
27274
- };
27275
- const show = (value) => {
27276
- input.value = value.path ?? "";
27277
- status.textContent = value.restartRequired ? messages.launchPathRestart : value.path ? messages.launchPathSaved : messages.launchPathAutomatic;
27278
- };
27279
- const persist = async (value) => {
27280
- if (busy || !loaded) return;
27281
- busy = true;
27282
- controls();
27283
- status.textContent = messages.launchPathSaving;
27284
- try {
27285
- show(await settings.set(value));
27286
- } catch {
27287
- status.textContent = messages.launchPathSaveError;
27288
- } finally {
27289
- busy = false;
27290
- controls();
27291
- }
27292
- };
27293
- input.addEventListener("input", controls);
27294
- save.addEventListener("click", () => {
27295
- if (input.value.trim()) void persist(input.value.trim());
27296
- });
27297
- reset.addEventListener("click", () => {
27298
- void persist(null);
27299
- });
27300
- controls();
27301
- status.textContent = messages.launchPathLoading;
27302
- void settings.get().then((value) => {
27303
- loaded = true;
27304
- show(value);
27305
- }).catch(() => {
27306
- loaded = true;
27307
- status.textContent = messages.launchPathLoadError;
27308
- }).finally(() => {
27309
- busy = false;
27310
- controls();
27311
- });
27312
- return section;
27313
- }
27314
-
27315
- // src/settings/harness-installation-guides.ts
27316
- function harnessHasInstallCommands(plugin) {
27317
- return (plugin?.installation?.commands.length ?? 0) > 0;
27264
+ // src/settings/connection-row.ts
27265
+ function connectionStatusLabel(availability, messages, hasError = false) {
27266
+ if (availability === "updating") return messages.connectionStatusUpdating;
27267
+ if (hasError && availability !== "notInstalled") return messages.connectionStatusError;
27268
+ if (availability === "ready") return messages.connectionStatusReady;
27269
+ if (availability === "checking") return messages.connectionStatusChecking;
27270
+ if (availability === "notInstalled") return messages.connectionStatusNotInstalled;
27271
+ if (availability === "unavailable" || availability === "error") {
27272
+ return availability === "error" ? messages.connectionStatusError : messages.connectionStatusUnavailable;
27273
+ }
27274
+ return availability === "installing" ? messages.connectionStatusInstalling : messages.connectionStatusUnsupported;
27318
27275
  }
27319
- function harnessInstallationGuide(plugin, locale) {
27320
- const guide = plugin?.installation;
27321
- const text = (value) => value?.[locale] ?? value?.en;
27322
- return {
27323
- url: plugin?.links?.installation ?? plugin?.links?.documentation ?? plugin?.links?.website,
27324
- commands: guide?.commands ?? [],
27325
- downloads: guide?.downloads ?? [],
27326
- before: text(guide?.before),
27327
- after: text(guide?.after)
27328
- };
27276
+ function connectionStatusTone(availability, hasError = false) {
27277
+ if (availability === "updating") return "checking";
27278
+ if (hasError && availability !== "notInstalled") return "failed";
27279
+ if (availability === "ready") return "ready";
27280
+ if (availability === "checking" || availability === "installing") return "checking";
27281
+ if (availability === "notInstalled") return "setup";
27282
+ return "failed";
27329
27283
  }
27330
-
27331
- // src/settings/harness-installation-panel.ts
27332
- function createHarnessInstallationPanel(document2, plugin, hostId2, messages, copy, installation) {
27333
- const zh = messages.locale === "zh-CN";
27334
- const guide = harnessInstallationGuide(plugin, messages.locale);
27335
- const panel = document2.createElement("div");
27336
- panel.className = "settings-harness-installation";
27337
- const paragraph = (text) => {
27338
- const p = document2.createElement("p");
27339
- p.textContent = text;
27340
- panel.append(p);
27341
- };
27342
- if (hostId2 !== "local") {
27343
- paragraph(zh ? "\u8BF7\u5728\u8FDC\u7A0B Host \u4E0A\u5B89\u88C5\u3002" : "Install on the remote Host.");
27284
+ function createConnectionIdentityIcon(document2, item, size) {
27285
+ const container = document2.createElement("span");
27286
+ container.className = item.agentSnapshot ? "settings-connection-row__mark settings-connection-row__mark--logo" : "settings-connection-row__mark";
27287
+ container.setAttribute("aria-hidden", "true");
27288
+ if (item.agentSnapshot) {
27289
+ container.append(
27290
+ createRendererAgentIcon(item.agentSnapshot.agent, size, document2, item.agentSnapshot.plugin)
27291
+ );
27292
+ } else {
27293
+ container.textContent = "CH";
27344
27294
  }
27345
- if (guide.before) paragraph(guide.before);
27346
- const install = installation && guide.commands.length > 0 ? document2.createElement("button") : null;
27347
- if (install && installation) {
27348
- install.type = "button";
27349
- install.className = "settings-command-button";
27350
- install.dataset.connectionAction = "install";
27351
- install.disabled = installation.status !== "idle";
27352
- install.textContent = installation.status === "installing" ? messages.connectionStatusInstalling : installation.status === "checking" ? messages.connectionStatusChecking : zh ? "\u4E00\u952E\u5B89\u88C5" : "Install automatically";
27353
- install.addEventListener("click", () => {
27354
- if (install.disabled) return;
27355
- install.disabled = true;
27356
- install.textContent = messages.connectionStatusInstalling;
27357
- installation.run();
27358
- });
27359
- if (guide.commands.length > 1) panel.append(install);
27295
+ return container;
27296
+ }
27297
+ function sameElementChildren(container, next) {
27298
+ if (container.children.length !== next.length) return false;
27299
+ for (let index = 0; index < next.length; index++) {
27300
+ if (container.children[index] !== next[index]) return false;
27360
27301
  }
27361
- for (const { terminal, command } of guide.commands) {
27362
- const block = document2.createElement("div");
27363
- block.className = "settings-harness-installation-command";
27364
- const label = document2.createElement("strong");
27365
- label.textContent = terminal;
27366
- const pre = document2.createElement("pre");
27367
- const code = document2.createElement("code");
27368
- code.textContent = command;
27369
- pre.append(code);
27370
- const button2 = document2.createElement("button");
27371
- button2.type = "button";
27372
- button2.className = "settings-command-button settings-command-button--secondary";
27373
- button2.dataset.connectionAction = "copy-install";
27374
- const copyLabel = zh ? "\u590D\u5236\u547D\u4EE4" : "Copy command";
27375
- button2.setAttribute("aria-label", `${copyLabel}: ${terminal}`);
27376
- button2.append(createRendererSettingsIcon("copy", 16), copyLabel);
27377
- button2.addEventListener("click", () => copy(button2, command, copyLabel));
27378
- const actions = document2.createElement("div");
27379
- actions.className = "settings-harness-installation-actions";
27380
- if (install && guide.commands.length === 1) actions.append(install);
27381
- actions.append(button2);
27382
- block.append(label, pre, actions);
27383
- panel.append(block);
27302
+ return true;
27303
+ }
27304
+ function reconcileElementChildren(container, next) {
27305
+ if (sameElementChildren(container, next)) return;
27306
+ if (typeof container.insertBefore !== "function") {
27307
+ container.replaceChildren(...next);
27308
+ return;
27384
27309
  }
27385
- for (const download2 of guide.downloads ?? []) {
27386
- const link = document2.createElement("a");
27387
- link.className = "settings-command-button settings-command-button--secondary";
27388
- link.href = download2.url;
27389
- link.target = "_blank";
27390
- link.rel = "noopener noreferrer";
27391
- link.textContent = zh ? "\u4E0B\u8F7D" : "Download";
27392
- link.setAttribute("aria-label", `${link.textContent} ${download2.label}`);
27393
- panel.append(link);
27310
+ const nextSet = new Set(next);
27311
+ for (const child of [...container.children]) {
27312
+ if (!nextSet.has(child)) child.remove();
27394
27313
  }
27395
- if (guide.after) paragraph(guide.after);
27396
- if (!plugin?.installation && guide.url) {
27397
- const link = document2.createElement("a");
27398
- link.href = guide.url;
27399
- link.target = "_blank";
27400
- link.rel = "noopener noreferrer";
27401
- link.textContent = zh ? "\u5B89\u88C5\u8BF4\u660E" : "Installation instructions";
27402
- panel.append(link);
27314
+ for (let index = 0; index < next.length; index++) {
27315
+ const desired = next[index];
27316
+ if (!desired) continue;
27317
+ const current = container.children[index] ?? null;
27318
+ if (current !== desired) {
27319
+ container.insertBefore(desired, current);
27320
+ }
27403
27321
  }
27404
- return panel;
27405
- }
27406
-
27407
- // src/settings/harness-install-store.ts
27408
- function errorMessage2(error51) {
27409
- return typeof error51 === "object" && error51 !== null && "message" in error51 && typeof error51.message === "string" ? error51.message.slice(0, 2048) : "Could not install the Harness. Check the official installation guide and retry.";
27410
27322
  }
27411
- function unknownInstallOutcome(message2) {
27412
- return /outcome is unknown|do not retry automatically|did not answer in time/i.test(message2);
27323
+ function identityIconSignature(item) {
27324
+ if (!item.agentSnapshot) return "adapter";
27325
+ const plugin = item.agentSnapshot.plugin;
27326
+ return `${item.agentSnapshot.agent}:${String(plugin?.icon ?? "")}:${String(plugin?.iconStyle ?? "")}`;
27413
27327
  }
27414
- var stores = /* @__PURE__ */ new WeakMap();
27415
- function createStore(diagnostics) {
27416
- const states2 = /* @__PURE__ */ new Map();
27417
- const listeners = /* @__PURE__ */ new Set();
27418
- const key = (host, agent) => JSON.stringify([host, agent]);
27419
- const notify2 = () => listeners.forEach((listener) => listener());
27328
+ function createConnectionRowView(document2, messages, groupable) {
27329
+ const row = document2.createElement("div");
27330
+ row.className = "settings-connection-row";
27331
+ row.setAttribute("role", "row");
27332
+ const identity2 = document2.createElement("div");
27333
+ identity2.className = "settings-connection-row__identity";
27334
+ identity2.setAttribute("role", "cell");
27335
+ let handle = null;
27336
+ if (groupable) {
27337
+ handle = document2.createElement("span");
27338
+ handle.className = "settings-connection-row__handle";
27339
+ handle.setAttribute("aria-hidden", "true");
27340
+ handle.append(createRendererSettingsIcon("grip-vertical", 15));
27341
+ identity2.append(handle);
27342
+ }
27343
+ let iconElement = null;
27344
+ let renderedIconKey = null;
27345
+ const label = document2.createElement("strong");
27346
+ const status = document2.createElement("span");
27347
+ status.className = "settings-connection-row__status";
27348
+ status.setAttribute("role", "cell");
27349
+ const action = document2.createElement("div");
27350
+ action.className = "settings-connection-row__action";
27351
+ action.setAttribute("role", "cell");
27352
+ row.append(identity2, status, action);
27353
+ let currentItem = null;
27354
+ let currentSelect = () => void 0;
27355
+ let currentGroup = null;
27356
+ let installButton = null;
27357
+ let viewErrorButton = null;
27358
+ let versionAvailableBadge = null;
27359
+ let updateButton = null;
27360
+ let groupToggleButton = null;
27361
+ let groupToggleSection = null;
27362
+ row.addEventListener("click", (event) => {
27363
+ const target2 = event.target;
27364
+ if (target2?.closest?.("a")) return;
27365
+ currentSelect();
27366
+ });
27367
+ row.addEventListener("keydown", (event) => {
27368
+ if (event.target?.closest?.("button, a")) return;
27369
+ if (event.key !== "Enter" && event.key !== " ") return;
27370
+ event.preventDefault();
27371
+ currentSelect();
27372
+ });
27373
+ if (groupable) {
27374
+ row.addEventListener("dragstart", (event) => currentGroup?.onDragStart(event));
27375
+ row.addEventListener("dragover", (event) => currentGroup?.onDragOver(event));
27376
+ row.addEventListener("dragleave", (event) => currentGroup?.onDragLeave(event));
27377
+ row.addEventListener("drop", (event) => currentGroup?.onDrop(event));
27378
+ row.addEventListener("dragend", (event) => currentGroup?.onDragEnd(event));
27379
+ }
27380
+ const setSelected = (selected) => {
27381
+ const nextSelected = String(selected);
27382
+ if (row.dataset.connectionSelected !== nextSelected) {
27383
+ row.dataset.connectionSelected = nextSelected;
27384
+ }
27385
+ const nextTabIndex = selected ? 0 : -1;
27386
+ if (row.tabIndex !== nextTabIndex) {
27387
+ row.tabIndex = nextTabIndex;
27388
+ }
27389
+ };
27420
27390
  return {
27421
- get: (host, agent) => states2.get(key(host, agent)),
27422
- clearErrors() {
27423
- for (const [id, state] of states2) if (state.status === "error") states2.delete(id);
27424
- notify2();
27425
- },
27426
- subscribe(listener) {
27427
- listeners.add(listener);
27428
- return () => {
27429
- listeners.delete(listener);
27430
- };
27431
- },
27432
- async install(host, agent) {
27433
- const id = key(host, agent);
27434
- const previous = states2.get(id);
27435
- if (!diagnostics.installation || previous && previous.status !== "error") return;
27436
- states2.set(id, { status: "installing" });
27437
- notify2();
27438
- let failure;
27439
- try {
27440
- await diagnostics.installation(host, agent, "install");
27441
- states2.set(id, { status: "checking" });
27442
- notify2();
27443
- } catch (error51) {
27444
- failure = errorMessage2(error51);
27391
+ element: row,
27392
+ setSelected,
27393
+ update(item, selected, select, group) {
27394
+ currentItem = item;
27395
+ currentSelect = select;
27396
+ currentGroup = group;
27397
+ if (row.dataset.connectionItem !== item.key) {
27398
+ row.dataset.connectionItem = item.key;
27399
+ }
27400
+ setSelected(selected);
27401
+ const nextIconKey = identityIconSignature(item);
27402
+ if (renderedIconKey !== nextIconKey || !iconElement) {
27403
+ renderedIconKey = nextIconKey;
27404
+ iconElement = createConnectionIdentityIcon(document2, item, 19);
27405
+ reconcileElementChildren(
27406
+ identity2,
27407
+ handle ? [handle, iconElement, label] : [iconElement, label]
27408
+ );
27445
27409
  }
27446
- try {
27447
- await diagnostics.refresh(host);
27448
- const refreshed = diagnostics.snapshot().hosts.find((candidate) => candidate.hostId === host)?.agents.find((candidate) => candidate.agent === agent);
27449
- if (refreshed?.availability === "ready") failure = void 0;
27450
- else if (failure && unknownInstallOutcome(failure) && refreshed && refreshed.availability !== "notInstalled") {
27451
- failure = void 0;
27410
+ if (handle && group && handle.title !== group.dragHandleTitle) {
27411
+ handle.title = group.dragHandleTitle;
27412
+ }
27413
+ if (label.textContent !== item.name) {
27414
+ label.textContent = item.name;
27415
+ }
27416
+ const tone = connectionStatusTone(item.availability, item.error !== null);
27417
+ if (status.dataset.connectionTone !== tone) {
27418
+ status.dataset.connectionTone = tone;
27419
+ }
27420
+ const statusText = item.error?.code === "authenticationRequired" ? messages.connectionLoginRequired : item.error?.code === "configurationRequired" ? messages.connectionConfigurationRequired : connectionStatusLabel(item.availability, messages, item.error !== null);
27421
+ if (status.textContent !== statusText) {
27422
+ status.textContent = statusText;
27423
+ }
27424
+ const nextActions = [];
27425
+ if (item.agentSnapshot?.availability === "notInstalled" && item.install) {
27426
+ if (!installButton) {
27427
+ const button2 = document2.createElement("button");
27428
+ button2.type = "button";
27429
+ button2.className = "settings-connection-install-link";
27430
+ button2.append(createRendererSettingsIcon("download", 17));
27431
+ button2.addEventListener("click", (event) => {
27432
+ event.stopPropagation();
27433
+ currentSelect();
27434
+ currentItem?.install?.();
27435
+ });
27436
+ installButton = button2;
27437
+ }
27438
+ installButton.disabled = item.availability === "installing" || item.availability === "checking";
27439
+ const installLabel = messages.connectionInstall;
27440
+ const ariaLabel = `${installLabel}: ${item.name}`;
27441
+ if (installButton.getAttribute("aria-label") !== ariaLabel) {
27442
+ installButton.setAttribute("aria-label", ariaLabel);
27443
+ }
27444
+ if (installButton.title !== installLabel) {
27445
+ installButton.title = installLabel;
27446
+ }
27447
+ nextActions.push(installButton);
27448
+ } else if (item.error) {
27449
+ if (!viewErrorButton) {
27450
+ const button2 = document2.createElement("button");
27451
+ button2.type = "button";
27452
+ button2.className = "settings-connection-view-error";
27453
+ button2.textContent = messages.connectionViewError;
27454
+ button2.addEventListener("click", (event) => {
27455
+ event.stopPropagation();
27456
+ currentSelect();
27457
+ });
27458
+ viewErrorButton = button2;
27459
+ }
27460
+ nextActions.push(viewErrorButton);
27461
+ }
27462
+ const version2 = item.version;
27463
+ if (version2?.state?.updateAvailable && !version2.updating) {
27464
+ if (!versionAvailableBadge) {
27465
+ const badge = document2.createElement("span");
27466
+ badge.className = "settings-connection-version-available";
27467
+ badge.textContent = messages.harnessVersionAvailable;
27468
+ versionAvailableBadge = badge;
27469
+ }
27470
+ const badgeTitle = `${messages.harnessVersionCurrent}: ${version2.state.currentVersion ?? "\u2014"}
27471
+ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages.harnessVersion)}`;
27472
+ if (versionAvailableBadge.title !== badgeTitle) {
27473
+ versionAvailableBadge.title = badgeTitle;
27474
+ }
27475
+ nextActions.push(versionAvailableBadge);
27476
+ }
27477
+ if (version2?.state?.updateAvailable && version2.state.canUpdate) {
27478
+ if (!updateButton) {
27479
+ const button2 = document2.createElement("button");
27480
+ button2.type = "button";
27481
+ button2.className = "settings-connection-install-link";
27482
+ button2.dataset.connectionAction = "update";
27483
+ button2.append(createRendererSettingsIcon("download", 17));
27484
+ button2.addEventListener("click", (event) => {
27485
+ event.stopPropagation();
27486
+ if (button2.disabled) return;
27487
+ void currentItem?.version?.update();
27488
+ currentSelect();
27489
+ });
27490
+ updateButton = button2;
27491
+ }
27492
+ updateButton.disabled = version2.updating;
27493
+ if (updateButton.title !== messages.harnessVersionUpdate) {
27494
+ updateButton.title = messages.harnessVersionUpdate;
27495
+ }
27496
+ const updateAriaLabel = `${messages.harnessVersionUpdate}: ${item.name}`;
27497
+ if (updateButton.getAttribute("aria-label") !== updateAriaLabel) {
27498
+ updateButton.setAttribute("aria-label", updateAriaLabel);
27499
+ }
27500
+ nextActions.push(updateButton);
27501
+ }
27502
+ if (group) {
27503
+ if (!groupToggleButton) {
27504
+ const button2 = document2.createElement("button");
27505
+ button2.type = "button";
27506
+ button2.className = "settings-connection-row__group-toggle";
27507
+ button2.addEventListener("click", (event) => {
27508
+ event.stopPropagation();
27509
+ currentGroup?.toggleSection();
27510
+ });
27511
+ groupToggleButton = button2;
27512
+ }
27513
+ groupToggleButton.disabled = group.disabled;
27514
+ if (groupToggleButton.title !== group.moveLabel) {
27515
+ groupToggleButton.title = group.moveLabel;
27516
+ }
27517
+ if (groupToggleButton.getAttribute("aria-label") !== group.moveLabel) {
27518
+ groupToggleButton.setAttribute("aria-label", group.moveLabel);
27519
+ }
27520
+ if (groupToggleSection !== group.section) {
27521
+ groupToggleSection = group.section;
27522
+ groupToggleButton.replaceChildren(
27523
+ createRendererSettingsIcon(
27524
+ group.section === "main" ? "chevron-down" : "chevron-up",
27525
+ 15
27526
+ )
27527
+ );
27528
+ }
27529
+ nextActions.push(groupToggleButton);
27530
+ }
27531
+ reconcileElementChildren(action, nextActions);
27532
+ if (group) {
27533
+ row.draggable = !group.disabled;
27534
+ if (row.dataset.connectionGroupSection !== group.section) {
27535
+ row.dataset.connectionGroupSection = group.section;
27452
27536
  }
27453
- } catch (error51) {
27454
- failure ??= errorMessage2(error51);
27455
27537
  }
27456
- if (failure) states2.set(id, { status: "error", error: failure });
27457
- else states2.delete(id);
27458
- notify2();
27459
27538
  }
27460
27539
  };
27461
27540
  }
27462
- function harnessInstallStore(diagnostics) {
27463
- let store = stores.get(diagnostics);
27541
+
27542
+ // src/settings/connection-updates.ts
27543
+ var sharedBatchStores = /* @__PURE__ */ new WeakMap();
27544
+ function getBatchStore(diagnostics) {
27545
+ if (!diagnostics) {
27546
+ return { batches: /* @__PURE__ */ new Map(), listeners: /* @__PURE__ */ new Set() };
27547
+ }
27548
+ let store = sharedBatchStores.get(diagnostics);
27464
27549
  if (!store) {
27465
- store = createStore(diagnostics);
27466
- stores.set(diagnostics, store);
27550
+ store = { batches: /* @__PURE__ */ new Map(), listeners: /* @__PURE__ */ new Set() };
27551
+ sharedBatchStores.set(diagnostics, store);
27467
27552
  }
27468
27553
  return store;
27469
27554
  }
27555
+ function createConnectionUpdates(document2, messages, signal, onChange, diagnostics = null) {
27556
+ const store = getBatchStore(diagnostics);
27557
+ const notify2 = () => {
27558
+ for (const listener of [...store.listeners]) listener();
27559
+ };
27560
+ if (!signal.aborted) {
27561
+ const listener = () => {
27562
+ if (!signal.aborted) onChange();
27563
+ };
27564
+ store.listeners.add(listener);
27565
+ signal.addEventListener(
27566
+ "abort",
27567
+ () => {
27568
+ store.listeners.delete(listener);
27569
+ },
27570
+ { once: true }
27571
+ );
27572
+ }
27573
+ const eligible = (panels) => panels.filter((panel) => panel.state?.updateAvailable && panel.state.canUpdate);
27574
+ const start = async (hostId2, panels) => {
27575
+ if (signal.aborted || store.batches.get(hostId2)?.running) return;
27576
+ const targets = eligible(panels);
27577
+ if (!targets.length) return;
27578
+ const batch = { running: true, total: targets.length, succeeded: 0, failed: 0 };
27579
+ store.batches.set(hostId2, batch);
27580
+ notify2();
27581
+ await Promise.all(
27582
+ targets.map(async (panel) => {
27583
+ try {
27584
+ if (await panel.update()) batch.succeeded++;
27585
+ else batch.failed++;
27586
+ } catch {
27587
+ batch.failed++;
27588
+ }
27589
+ notify2();
27590
+ })
27591
+ );
27592
+ batch.running = false;
27593
+ notify2();
27594
+ };
27595
+ return {
27596
+ createControls(hostId2, panels) {
27597
+ let currentHostId = hostId2;
27598
+ let currentPanels = panels;
27599
+ let renderedLabel = null;
27600
+ const button2 = document2.createElement("button");
27601
+ button2.type = "button";
27602
+ button2.className = "settings-command-button settings-command-button--secondary settings-connection-update-all";
27603
+ button2.dataset.connectionAction = "update-all";
27604
+ button2.title = messages.harnessUpdateAllDescription;
27605
+ button2.addEventListener("click", () => {
27606
+ if (!button2.disabled) void start(currentHostId, currentPanels);
27607
+ });
27608
+ const result = document2.createElement("p");
27609
+ result.className = "settings-connection-update-result";
27610
+ result.setAttribute("role", "status");
27611
+ const update = (nextHostId, nextPanels) => {
27612
+ currentHostId = nextHostId;
27613
+ currentPanels = nextPanels;
27614
+ const batch = store.batches.get(nextHostId);
27615
+ const count3 = eligible(nextPanels).length;
27616
+ button2.disabled = signal.aborted || Boolean(batch?.running) || !count3;
27617
+ const label = batch?.running ? `${messages.harnessUpdateAllProgress} ${batch.succeeded + batch.failed}/${batch.total}` : count3 ? `${messages.harnessUpdateAll} (${count3})` : messages.harnessUpdateAll;
27618
+ if (renderedLabel !== label) {
27619
+ renderedLabel = label;
27620
+ button2.replaceChildren(createRendererSettingsIcon("download", 15), label);
27621
+ }
27622
+ const hidden = !batch || batch.running;
27623
+ result.hidden = hidden;
27624
+ const resultText = batch && !batch.running ? messages.harnessUpdateAllResult.replace("{succeeded}", String(batch.succeeded)).replace("{failed}", String(batch.failed)) : "";
27625
+ if (result.textContent !== resultText) {
27626
+ result.textContent = resultText;
27627
+ }
27628
+ };
27629
+ update(hostId2, panels);
27630
+ return { button: button2, result, update };
27631
+ }
27632
+ };
27633
+ }
27470
27634
 
27471
27635
  // src/settings/harness-version-panel.ts
27472
- function createHarnessVersionPanel(document2, messages, signal, agent, client, onChange = () => void 0) {
27636
+ function isUnsupportedInstallationError(error51) {
27637
+ return typeof error51 === "object" && error51 !== null && "code" in error51 && (error51.code === -32601 || error51.code === -32078);
27638
+ }
27639
+ function createHarnessVersionSession(client, options) {
27640
+ let state;
27641
+ let statusKind = "checking";
27642
+ let checkPromise = null;
27643
+ let updatePromise = null;
27644
+ const listeners = /* @__PURE__ */ new Set();
27645
+ const signal = options?.signal;
27646
+ const notify2 = (pageChange) => {
27647
+ if (signal?.aborted) return;
27648
+ for (const listener of [...listeners]) listener(pageChange);
27649
+ };
27650
+ const check2 = () => {
27651
+ if (signal?.aborted || updatePromise) return Promise.resolve();
27652
+ if (checkPromise) return checkPromise;
27653
+ statusKind = "checking";
27654
+ notify2(false);
27655
+ checkPromise = (async () => {
27656
+ try {
27657
+ const result = await client.run("check");
27658
+ if (signal?.aborted || updatePromise) return;
27659
+ state = result;
27660
+ statusKind = "idle";
27661
+ } catch (error51) {
27662
+ if (signal?.aborted || updatePromise) return;
27663
+ statusKind = isUnsupportedInstallationError(error51) ? "unsupported" : "failed";
27664
+ if (state) state = { ...state, canUpdate: false };
27665
+ } finally {
27666
+ checkPromise = null;
27667
+ if (!signal?.aborted && !updatePromise) {
27668
+ notify2(true);
27669
+ }
27670
+ }
27671
+ })();
27672
+ return checkPromise;
27673
+ };
27674
+ const update = () => {
27675
+ if (updatePromise) return updatePromise;
27676
+ updatePromise = (async () => {
27677
+ if (signal?.aborted) return false;
27678
+ if (checkPromise) await checkPromise;
27679
+ if (signal?.aborted || statusKind === "unsupported" || !state?.canUpdate || !state.updateAvailable) {
27680
+ return false;
27681
+ }
27682
+ statusKind = "updating";
27683
+ notify2(true);
27684
+ try {
27685
+ const result = await client.run("update");
27686
+ if (signal?.aborted) return false;
27687
+ state = result;
27688
+ statusKind = !result.canUpdate ? "updated" : result.updateAvailable ? "failed" : "updated";
27689
+ return result.canUpdate && !result.updateAvailable;
27690
+ } catch (error51) {
27691
+ if (signal?.aborted) return false;
27692
+ statusKind = isUnsupportedInstallationError(error51) ? "unsupported" : "failed";
27693
+ if (state) state = { ...state, canUpdate: false };
27694
+ return false;
27695
+ } finally {
27696
+ updatePromise = null;
27697
+ if (!signal?.aborted) {
27698
+ notify2(true);
27699
+ }
27700
+ }
27701
+ })();
27702
+ return updatePromise;
27703
+ };
27704
+ return {
27705
+ get state() {
27706
+ return state;
27707
+ },
27708
+ get statusKind() {
27709
+ return statusKind;
27710
+ },
27711
+ get updating() {
27712
+ return statusKind === "updating";
27713
+ },
27714
+ prepareMount() {
27715
+ if (updatePromise || checkPromise) return false;
27716
+ statusKind = "checking";
27717
+ return true;
27718
+ },
27719
+ check: check2,
27720
+ update,
27721
+ subscribe(listener) {
27722
+ listeners.add(listener);
27723
+ return () => {
27724
+ listeners.delete(listener);
27725
+ };
27726
+ }
27727
+ };
27728
+ }
27729
+ function createHarnessVersionPanel(document2, messages, signal, agent, client, onChange = () => void 0, sharedSession) {
27730
+ const session = sharedSession ?? createHarnessVersionSession(client, { signal });
27731
+ const shouldScheduleCheck = session.prepareMount();
27473
27732
  const panel = document2.createElement("section");
27474
27733
  panel.className = "settings-harness-version";
27475
27734
  panel.dataset.harnessVersion = agent;
@@ -27493,15 +27752,14 @@ ${detail}` : ""}`
27493
27752
  note.textContent = messages.harnessVersionNote;
27494
27753
  actions.append(update);
27495
27754
  panel.append(heading, versions, status, actions, note);
27496
- let state;
27497
- let busy = false;
27498
- let updating = false;
27499
- let unsupported = false;
27500
- let updatePromise = null;
27501
27755
  const render = () => {
27756
+ const state = session.state;
27757
+ const statusKind = session.statusKind;
27758
+ const busy = statusKind === "checking" || statusKind === "updating";
27502
27759
  heading.textContent = state?.versionKind === "application" ? messages.harnessVersionApplicationTitle : messages.harnessVersionTitle;
27503
27760
  current.textContent = `${messages.harnessVersionCurrent}: ${state?.currentVersion ?? "\u2014"}`;
27504
27761
  latest.textContent = `${messages.harnessVersionLatest}: ${harnessVersionLabel(state, messages.harnessVersion)}`;
27762
+ status.textContent = statusKind === "checking" ? messages.harnessVersionChecking : statusKind === "updating" ? messages.harnessVersionUpdating : statusKind === "unsupported" ? messages.harnessVersionUnsupported : statusKind === "failed" ? messages.harnessVersionFailed : statusKind === "updated" ? !state?.canUpdate ? messages.harnessVersionManual : messages.harnessVersionUpdated : state && !state.canUpdate ? messages.harnessVersionManual : "";
27505
27763
  update.disabled = busy || signal.aborted || !state?.canUpdate || !state.updateAvailable;
27506
27764
  const manualUrl = !state?.canUpdate && state?.updateAvailable ? state.manualUpdateUrl : void 0;
27507
27765
  actions.replaceChildren(update);
@@ -27520,99 +27778,92 @@ ${detail}` : ""}`
27520
27778
  const detail = harnessVersionNote(state, messages.harnessVersion);
27521
27779
  note.textContent = detail ? !state?.canUpdate ? detail : `${detail} ${messages.harnessVersionNote}` : messages.harnessVersionNote;
27522
27780
  };
27523
- const run = async (action) => {
27524
- if (busy || unsupported || signal.aborted) return false;
27525
- if (action === "update" && (!state?.canUpdate || !state.updateAvailable)) return false;
27526
- busy = true;
27527
- updating = action === "update";
27528
- onChange();
27529
- status.textContent = action === "check" ? messages.harnessVersionChecking : messages.harnessVersionUpdating;
27781
+ update.addEventListener("click", () => {
27782
+ if (!signal.aborted) void session.update();
27783
+ });
27784
+ const unsubscribe = session.subscribe((pageChange) => {
27785
+ if (signal.aborted) return;
27530
27786
  render();
27531
- try {
27532
- const result = await client.run(action);
27533
- if (signal.aborted) return false;
27534
- state = result;
27535
- status.textContent = !result.canUpdate ? messages.harnessVersionManual : action === "update" ? result.updateAvailable ? messages.harnessVersionFailed : messages.harnessVersionUpdated : "";
27536
- return result.canUpdate && !result.updateAvailable;
27537
- } catch (error51) {
27538
- if (signal.aborted) return false;
27539
- unsupported = typeof error51 === "object" && error51 !== null && "code" in error51 && (error51.code === -32601 || error51.code === -32078);
27540
- status.textContent = unsupported ? messages.harnessVersionUnsupported : messages.harnessVersionFailed;
27541
- if (state) state = { ...state, canUpdate: false };
27542
- return false;
27543
- } finally {
27544
- busy = false;
27545
- updating = false;
27546
- if (!signal.aborted) {
27547
- render();
27548
- onChange();
27549
- }
27550
- }
27551
- };
27552
- const updateVersion = () => {
27553
- updatePromise ??= run("update").finally(() => {
27554
- updatePromise = null;
27555
- });
27556
- return updatePromise;
27557
- };
27558
- update.addEventListener("click", () => void updateVersion());
27787
+ if (pageChange) onChange();
27788
+ });
27559
27789
  const owner = document2.defaultView;
27560
27790
  let checkFrame = null;
27561
27791
  let checkTimer = null;
27562
27792
  signal.addEventListener(
27563
27793
  "abort",
27564
27794
  () => {
27795
+ unsubscribe();
27565
27796
  if (checkFrame !== null) owner?.cancelAnimationFrame(checkFrame);
27566
27797
  if (checkTimer !== null) owner?.clearTimeout(checkTimer);
27567
27798
  render();
27568
27799
  },
27569
27800
  { once: true }
27570
27801
  );
27571
- status.textContent = messages.harnessVersionChecking;
27572
27802
  render();
27573
- if (!signal.aborted && owner?.requestAnimationFrame) {
27574
- checkFrame = owner.requestAnimationFrame(() => {
27575
- checkFrame = null;
27576
- if (signal.aborted) return;
27577
- checkTimer = owner.setTimeout(() => {
27578
- checkTimer = null;
27579
- void run("check");
27580
- }, 0);
27581
- });
27582
- } else {
27583
- void run("check");
27803
+ if (shouldScheduleCheck && !signal.aborted) {
27804
+ if (owner?.requestAnimationFrame) {
27805
+ checkFrame = owner.requestAnimationFrame(() => {
27806
+ checkFrame = null;
27807
+ if (signal.aborted) return;
27808
+ checkTimer = owner.setTimeout(() => {
27809
+ checkTimer = null;
27810
+ if (!signal.aborted) void session.check();
27811
+ }, 0);
27812
+ });
27813
+ } else {
27814
+ void session.check();
27815
+ }
27584
27816
  }
27585
27817
  return {
27586
27818
  element: panel,
27587
27819
  get state() {
27588
- return state;
27820
+ return session.state;
27589
27821
  },
27590
27822
  get updating() {
27591
- return updating;
27823
+ return session.updating;
27592
27824
  },
27593
- update: updateVersion
27825
+ update: () => signal.aborted ? Promise.resolve(false) : session.update()
27594
27826
  };
27595
27827
  }
27596
27828
 
27597
27829
  // src/settings/connection-versions.ts
27830
+ var sessionStores = /* @__PURE__ */ new WeakMap();
27831
+ function getSessionStore(diagnostics) {
27832
+ let store = sessionStores.get(diagnostics);
27833
+ if (!store) {
27834
+ store = /* @__PURE__ */ new Map();
27835
+ sessionStores.set(diagnostics, store);
27836
+ }
27837
+ return store;
27838
+ }
27598
27839
  function createConnectionVersions(document2, messages, signal, diagnostics, onChange) {
27599
27840
  const panels = /* @__PURE__ */ new Map();
27600
27841
  const installation = diagnostics?.installation?.bind(diagnostics);
27842
+ const sessions = diagnostics ? getSessionStore(diagnostics) : null;
27843
+ const sessionKey = (hostId2, agent) => JSON.stringify([hostId2, agent]);
27601
27844
  return {
27845
+ isUpdating(hostId2, agent) {
27846
+ return Boolean(sessions?.get(sessionKey(hostId2, agent))?.updating);
27847
+ },
27602
27848
  get(hostId2, agent) {
27603
27849
  if (!installation || signal.aborted) return void 0;
27604
- const key = JSON.stringify([hostId2, agent]);
27850
+ const key = sessionKey(hostId2, agent);
27605
27851
  let panel = panels.get(key);
27606
27852
  if (!panel) {
27853
+ const run = (action) => installation(hostId2, agent, action);
27854
+ let session = sessions?.get(key);
27855
+ if (!session) {
27856
+ session = createHarnessVersionSession({ run });
27857
+ sessions?.set(key, session);
27858
+ }
27607
27859
  panel = createHarnessVersionPanel(
27608
27860
  document2,
27609
27861
  messages,
27610
27862
  signal,
27611
27863
  agent,
27612
- {
27613
- run: (action) => installation(hostId2, agent, action)
27614
- },
27615
- onChange
27864
+ { run },
27865
+ onChange,
27866
+ session
27616
27867
  );
27617
27868
  panels.set(key, panel);
27618
27869
  }
@@ -27621,79 +27872,242 @@ ${detail}` : ""}`
27621
27872
  };
27622
27873
  }
27623
27874
 
27624
- // src/settings/connection-updates.ts
27625
- function createConnectionUpdates(document2, messages, signal, onChange) {
27626
- const batches = /* @__PURE__ */ new Map();
27627
- const eligible = (panels) => panels.filter((panel) => panel.state?.updateAvailable && panel.state.canUpdate);
27628
- const start = async (hostId2, panels) => {
27629
- if (signal.aborted || batches.get(hostId2)?.running) return;
27630
- const targets = eligible(panels);
27631
- if (!targets.length) return;
27632
- const batch = { running: true, total: targets.length, succeeded: 0, failed: 0 };
27633
- batches.set(hostId2, batch);
27634
- onChange();
27635
- await Promise.all(
27636
- targets.map(async (panel) => {
27637
- try {
27638
- if (await panel.update()) batch.succeeded++;
27639
- else batch.failed++;
27640
- } catch {
27641
- batch.failed++;
27642
- }
27643
- if (!signal.aborted) onChange();
27644
- })
27645
- );
27646
- batch.running = false;
27647
- if (!signal.aborted) onChange();
27875
+ // src/settings/harness-install-store.ts
27876
+ function errorMessage2(error51) {
27877
+ return typeof error51 === "object" && error51 !== null && "message" in error51 && typeof error51.message === "string" ? error51.message.slice(0, 2048) : "Could not install the Harness. Check the official installation guide and retry.";
27878
+ }
27879
+ function unknownInstallOutcome(message2) {
27880
+ return /outcome is unknown|do not retry automatically|did not answer in time/i.test(message2);
27881
+ }
27882
+ var stores = /* @__PURE__ */ new WeakMap();
27883
+ function createStore(diagnostics) {
27884
+ const states2 = /* @__PURE__ */ new Map();
27885
+ const listeners = /* @__PURE__ */ new Set();
27886
+ const key = (host, agent) => JSON.stringify([host, agent]);
27887
+ const notify2 = () => listeners.forEach((listener) => listener());
27888
+ return {
27889
+ get: (host, agent) => states2.get(key(host, agent)),
27890
+ clearErrors() {
27891
+ for (const [id, state] of states2) if (state.status === "error") states2.delete(id);
27892
+ notify2();
27893
+ },
27894
+ subscribe(listener) {
27895
+ listeners.add(listener);
27896
+ return () => {
27897
+ listeners.delete(listener);
27898
+ };
27899
+ },
27900
+ async install(host, agent) {
27901
+ const id = key(host, agent);
27902
+ const previous = states2.get(id);
27903
+ if (!diagnostics.installation || previous && previous.status !== "error") return;
27904
+ states2.set(id, { status: "installing" });
27905
+ notify2();
27906
+ let failure;
27907
+ try {
27908
+ await diagnostics.installation(host, agent, "install");
27909
+ states2.set(id, { status: "checking" });
27910
+ notify2();
27911
+ } catch (error51) {
27912
+ failure = errorMessage2(error51);
27913
+ }
27914
+ try {
27915
+ await diagnostics.refresh(host);
27916
+ const refreshed = diagnostics.snapshot().hosts.find((candidate) => candidate.hostId === host)?.agents.find((candidate) => candidate.agent === agent);
27917
+ if (refreshed?.availability === "ready") failure = void 0;
27918
+ else if (failure && unknownInstallOutcome(failure) && refreshed && refreshed.availability !== "notInstalled") {
27919
+ failure = void 0;
27920
+ }
27921
+ } catch (error51) {
27922
+ failure ??= errorMessage2(error51);
27923
+ }
27924
+ if (failure) states2.set(id, { status: "error", error: failure });
27925
+ else states2.delete(id);
27926
+ notify2();
27927
+ }
27928
+ };
27929
+ }
27930
+ function harnessInstallStore(diagnostics) {
27931
+ let store = stores.get(diagnostics);
27932
+ if (!store) {
27933
+ store = createStore(diagnostics);
27934
+ stores.set(diagnostics, store);
27935
+ }
27936
+ return store;
27937
+ }
27938
+
27939
+ // src/settings/harness-installation-guides.ts
27940
+ function harnessHasInstallCommands(plugin) {
27941
+ return (plugin?.installation?.commands.length ?? 0) > 0;
27942
+ }
27943
+ function harnessInstallationGuide(plugin, locale) {
27944
+ const guide = plugin?.installation;
27945
+ const text = (value) => value?.[locale] ?? value?.en;
27946
+ return {
27947
+ url: plugin?.links?.installation ?? plugin?.links?.documentation ?? plugin?.links?.website,
27948
+ commands: guide?.commands ?? [],
27949
+ downloads: guide?.downloads ?? [],
27950
+ before: text(guide?.before),
27951
+ after: text(guide?.after)
27952
+ };
27953
+ }
27954
+
27955
+ // src/settings/harness-installation-panel.ts
27956
+ function createHarnessInstallationPanel(document2, plugin, hostId2, messages, copy, installation) {
27957
+ const zh = messages.locale === "zh-CN";
27958
+ const guide = harnessInstallationGuide(plugin, messages.locale);
27959
+ const panel = document2.createElement("div");
27960
+ panel.className = "settings-harness-installation";
27961
+ const paragraph = (text) => {
27962
+ const p = document2.createElement("p");
27963
+ p.textContent = text;
27964
+ panel.append(p);
27965
+ };
27966
+ if (hostId2 !== "local") {
27967
+ paragraph(zh ? "\u8BF7\u5728\u8FDC\u7A0B Host \u4E0A\u5B89\u88C5\u3002" : "Install on the remote Host.");
27968
+ }
27969
+ if (guide.before) paragraph(guide.before);
27970
+ const install = installation && guide.commands.length > 0 ? document2.createElement("button") : null;
27971
+ if (install && installation) {
27972
+ install.type = "button";
27973
+ install.className = "settings-command-button";
27974
+ install.dataset.connectionAction = "install";
27975
+ install.disabled = installation.status !== "idle";
27976
+ install.textContent = installation.status === "installing" ? messages.connectionStatusInstalling : installation.status === "checking" ? messages.connectionStatusChecking : zh ? "\u4E00\u952E\u5B89\u88C5" : "Install automatically";
27977
+ install.addEventListener("click", () => {
27978
+ if (install.disabled) return;
27979
+ install.disabled = true;
27980
+ install.textContent = messages.connectionStatusInstalling;
27981
+ installation.run();
27982
+ });
27983
+ if (guide.commands.length > 1) panel.append(install);
27984
+ }
27985
+ for (const { terminal, command } of guide.commands) {
27986
+ const block = document2.createElement("div");
27987
+ block.className = "settings-harness-installation-command";
27988
+ const label = document2.createElement("strong");
27989
+ label.textContent = terminal;
27990
+ const pre = document2.createElement("pre");
27991
+ const code = document2.createElement("code");
27992
+ code.textContent = command;
27993
+ pre.append(code);
27994
+ const button2 = document2.createElement("button");
27995
+ button2.type = "button";
27996
+ button2.className = "settings-command-button settings-command-button--secondary";
27997
+ button2.dataset.connectionAction = "copy-install";
27998
+ const copyLabel = zh ? "\u590D\u5236\u547D\u4EE4" : "Copy command";
27999
+ button2.setAttribute("aria-label", `${copyLabel}: ${terminal}`);
28000
+ button2.append(createRendererSettingsIcon("copy", 16), copyLabel);
28001
+ button2.addEventListener("click", () => copy(button2, command, copyLabel));
28002
+ const actions = document2.createElement("div");
28003
+ actions.className = "settings-harness-installation-actions";
28004
+ if (install && guide.commands.length === 1) actions.append(install);
28005
+ actions.append(button2);
28006
+ block.append(label, pre, actions);
28007
+ panel.append(block);
28008
+ }
28009
+ for (const download2 of guide.downloads ?? []) {
28010
+ const link = document2.createElement("a");
28011
+ link.className = "settings-command-button settings-command-button--secondary";
28012
+ link.href = download2.url;
28013
+ link.target = "_blank";
28014
+ link.rel = "noopener noreferrer";
28015
+ link.textContent = zh ? "\u4E0B\u8F7D" : "Download";
28016
+ link.setAttribute("aria-label", `${link.textContent} ${download2.label}`);
28017
+ panel.append(link);
28018
+ }
28019
+ if (guide.after) paragraph(guide.after);
28020
+ if (!plugin?.installation && guide.url) {
28021
+ const link = document2.createElement("a");
28022
+ link.href = guide.url;
28023
+ link.target = "_blank";
28024
+ link.rel = "noopener noreferrer";
28025
+ link.textContent = zh ? "\u5B89\u88C5\u8BF4\u660E" : "Installation instructions";
28026
+ panel.append(link);
28027
+ }
28028
+ return panel;
28029
+ }
28030
+
28031
+ // src/settings/harness-launch-controls.ts
28032
+ function createHarnessLaunchControls(document2, messages, agent, settings) {
28033
+ const section = document2.createElement("section");
28034
+ section.className = "settings-harness-launch";
28035
+ section.dataset.harnessLaunch = agent;
28036
+ const label = document2.createElement("label");
28037
+ label.textContent = messages.launchPathLabel;
28038
+ const input = document2.createElement("input");
28039
+ input.type = "text";
28040
+ input.autocomplete = "off";
28041
+ input.spellcheck = false;
28042
+ input.placeholder = messages.locale === "zh-CN" ? "\u5E94\u7528\u5B89\u88C5\u76EE\u5F55\u7684\u7EDD\u5BF9\u8DEF\u5F84" : "Absolute installation directory";
28043
+ input.setAttribute("aria-label", messages.launchPathLabel);
28044
+ label.append(input);
28045
+ const help = document2.createElement("p");
28046
+ help.textContent = messages.locale === "zh-CN" ? "\u586B\u5199\u63D2\u4EF6\u5BF9\u5E94\u5E94\u7528\u7684\u5B89\u88C5\u76EE\u5F55\uFF1B\u6E05\u9664\u540E\u6062\u590D\u81EA\u52A8\u53D1\u73B0\u3002\u4FEE\u6539\u540E\u9700\u91CD\u542F codexhost\u3002" : "Choose the application's installation directory; clear it to restore automatic discovery. Restart codexhost after changing it.";
28047
+ const actions = document2.createElement("div");
28048
+ actions.className = "settings-harness-launch__actions";
28049
+ const save = document2.createElement("button");
28050
+ save.type = "button";
28051
+ save.className = "settings-command-button";
28052
+ save.textContent = messages.launchPathSave;
28053
+ const reset = document2.createElement("button");
28054
+ reset.type = "button";
28055
+ reset.className = "settings-command-button settings-command-button--secondary";
28056
+ reset.textContent = messages.launchPathReset;
28057
+ const status = document2.createElement("p");
28058
+ status.setAttribute("role", "status");
28059
+ status.setAttribute("aria-live", "polite");
28060
+ actions.append(save, reset);
28061
+ section.append(label, help, actions, status);
28062
+ let busy = true;
28063
+ let loaded = false;
28064
+ const controls = () => {
28065
+ input.disabled = busy || !loaded;
28066
+ save.disabled = busy || !loaded || !input.value.trim();
28067
+ reset.disabled = busy || !loaded;
27648
28068
  };
27649
- return {
27650
- createControls(hostId2, panels) {
27651
- const batch = batches.get(hostId2);
27652
- const count3 = eligible(panels).length;
27653
- const button2 = document2.createElement("button");
27654
- button2.type = "button";
27655
- button2.className = "settings-command-button settings-command-button--secondary settings-connection-update-all";
27656
- button2.dataset.connectionAction = "update-all";
27657
- button2.disabled = signal.aborted || Boolean(batch?.running) || !count3;
27658
- button2.title = messages.harnessUpdateAllDescription;
27659
- const label = batch?.running ? `${messages.harnessUpdateAllProgress} ${batch.succeeded + batch.failed}/${batch.total}` : count3 ? `${messages.harnessUpdateAll} (${count3})` : messages.harnessUpdateAll;
27660
- button2.append(createRendererSettingsIcon("download", 15), label);
27661
- button2.addEventListener("click", () => {
27662
- if (!button2.disabled) void start(hostId2, panels);
27663
- });
27664
- const result = document2.createElement("p");
27665
- result.className = "settings-connection-update-result";
27666
- result.setAttribute("role", "status");
27667
- result.hidden = !batch || batch.running;
27668
- if (batch && !batch.running) {
27669
- result.textContent = messages.harnessUpdateAllResult.replace("{succeeded}", String(batch.succeeded)).replace("{failed}", String(batch.failed));
27670
- }
27671
- return { button: button2, result };
28069
+ const show = (value) => {
28070
+ input.value = value.path ?? "";
28071
+ status.textContent = value.restartRequired ? messages.launchPathRestart : value.path ? messages.launchPathSaved : messages.launchPathAutomatic;
28072
+ };
28073
+ const persist = async (value) => {
28074
+ if (busy || !loaded) return;
28075
+ busy = true;
28076
+ controls();
28077
+ status.textContent = messages.launchPathSaving;
28078
+ try {
28079
+ show(await settings.set(value));
28080
+ } catch {
28081
+ status.textContent = messages.launchPathSaveError;
28082
+ } finally {
28083
+ busy = false;
28084
+ controls();
27672
28085
  }
27673
28086
  };
28087
+ input.addEventListener("input", controls);
28088
+ save.addEventListener("click", () => {
28089
+ if (input.value.trim()) void persist(input.value.trim());
28090
+ });
28091
+ reset.addEventListener("click", () => {
28092
+ void persist(null);
28093
+ });
28094
+ controls();
28095
+ status.textContent = messages.launchPathLoading;
28096
+ void settings.get().then((value) => {
28097
+ loaded = true;
28098
+ show(value);
28099
+ }).catch(() => {
28100
+ loaded = true;
28101
+ status.textContent = messages.launchPathLoadError;
28102
+ }).finally(() => {
28103
+ busy = false;
28104
+ controls();
28105
+ });
28106
+ return section;
27674
28107
  }
27675
28108
 
27676
28109
  // src/settings/connections-page.ts
27677
28110
  var CODEXHOST_GITHUB_ISSUES_NEW_URL = "https://github.com/BytePioneer-AI/codex-host/issues/new";
27678
- function connectionStatusLabel(availability, messages, hasError = false) {
27679
- if (availability === "updating") return messages.connectionStatusUpdating;
27680
- if (hasError && availability !== "notInstalled") return messages.connectionStatusError;
27681
- if (availability === "ready") return messages.connectionStatusReady;
27682
- if (availability === "checking") return messages.connectionStatusChecking;
27683
- if (availability === "notInstalled") return messages.connectionStatusNotInstalled;
27684
- if (availability === "unavailable" || availability === "error") {
27685
- return availability === "error" ? messages.connectionStatusError : messages.connectionStatusUnavailable;
27686
- }
27687
- return availability === "installing" ? messages.connectionStatusInstalling : messages.connectionStatusUnsupported;
27688
- }
27689
- function connectionStatusTone(availability, hasError = false) {
27690
- if (availability === "updating") return "checking";
27691
- if (hasError && availability !== "notInstalled") return "failed";
27692
- if (availability === "ready") return "ready";
27693
- if (availability === "checking" || availability === "installing") return "checking";
27694
- if (availability === "notInstalled") return "setup";
27695
- return "failed";
27696
- }
27697
28111
  function diagnosticText(hostId2, item) {
27698
28112
  const error51 = item.error;
27699
28113
  return [
@@ -27789,148 +28203,21 @@ ${error51.stderrTail}`] : []
27789
28203
  tabs.addEventListener("wheel", onWheel, { passive: false });
27790
28204
  const ownerWindow = document2.defaultView;
27791
28205
  ownerWindow?.addEventListener("resize", updateButtons);
27792
- ownerWindow?.setTimeout(updateButtons, 0);
27793
- updateButtons();
27794
- return () => {
27795
- left.removeEventListener("click", onLeft);
27796
- right.removeEventListener("click", onRight);
27797
- tabs.removeEventListener("scroll", updateButtons);
27798
- tabs.removeEventListener("wheel", onWheel);
27799
- ownerWindow?.removeEventListener("resize", updateButtons);
28206
+ const refreshLayout = () => {
28207
+ ownerWindow?.setTimeout(updateButtons, 0);
28208
+ updateButtons();
28209
+ };
28210
+ refreshLayout();
28211
+ return {
28212
+ update: refreshLayout,
28213
+ dispose() {
28214
+ left.removeEventListener("click", onLeft);
28215
+ right.removeEventListener("click", onRight);
28216
+ tabs.removeEventListener("scroll", updateButtons);
28217
+ tabs.removeEventListener("wheel", onWheel);
28218
+ ownerWindow?.removeEventListener("resize", updateButtons);
28219
+ }
27800
28220
  };
27801
- }
27802
- function createConnectionIdentityIcon(document2, item, size) {
27803
- const container = document2.createElement("span");
27804
- container.className = item.agentSnapshot ? "settings-connection-row__mark settings-connection-row__mark--logo" : "settings-connection-row__mark";
27805
- container.setAttribute("aria-hidden", "true");
27806
- if (item.agentSnapshot) {
27807
- container.append(
27808
- createRendererAgentIcon(item.agentSnapshot.agent, size, document2, item.agentSnapshot.plugin)
27809
- );
27810
- } else {
27811
- container.textContent = "CH";
27812
- }
27813
- return container;
27814
- }
27815
- function createConnectionRow(document2, item, messages, selected, select, group = null) {
27816
- const row = document2.createElement("div");
27817
- row.className = "settings-connection-row";
27818
- row.dataset.connectionItem = item.key;
27819
- row.dataset.connectionSelected = String(selected);
27820
- row.tabIndex = selected ? 0 : -1;
27821
- row.setAttribute("role", "row");
27822
- const identity2 = document2.createElement("div");
27823
- identity2.className = "settings-connection-row__identity";
27824
- identity2.setAttribute("role", "cell");
27825
- if (group) {
27826
- const handle = document2.createElement("span");
27827
- handle.className = "settings-connection-row__handle";
27828
- handle.setAttribute("aria-hidden", "true");
27829
- handle.title = group.dragHandleTitle;
27830
- handle.append(createRendererSettingsIcon("grip-vertical", 15));
27831
- identity2.append(handle);
27832
- }
27833
- const label = document2.createElement("strong");
27834
- label.textContent = item.name;
27835
- identity2.append(createConnectionIdentityIcon(document2, item, 19), label);
27836
- const status = document2.createElement("span");
27837
- status.className = "settings-connection-row__status";
27838
- status.dataset.connectionTone = connectionStatusTone(item.availability, item.error !== null);
27839
- status.setAttribute("role", "cell");
27840
- status.textContent = item.error?.code === "authenticationRequired" ? messages.connectionLoginRequired : item.error?.code === "configurationRequired" ? messages.connectionConfigurationRequired : connectionStatusLabel(item.availability, messages, item.error !== null);
27841
- const version2 = item.version;
27842
- const action = document2.createElement("div");
27843
- action.className = "settings-connection-row__action";
27844
- action.setAttribute("role", "cell");
27845
- if (item.agentSnapshot?.availability === "notInstalled" && item.install) {
27846
- const install = document2.createElement("button");
27847
- install.type = "button";
27848
- install.className = "settings-connection-install-link";
27849
- install.addEventListener("click", (event) => {
27850
- event.stopPropagation();
27851
- select();
27852
- item.install?.();
27853
- });
27854
- install.disabled = item.availability === "installing" || item.availability === "checking";
27855
- const installLabel = messages.connectionInstall;
27856
- install.setAttribute("aria-label", `${installLabel}: ${item.name}`);
27857
- install.title = installLabel;
27858
- install.append(createRendererSettingsIcon("download", 17));
27859
- action.append(install);
27860
- } else if (item.error) {
27861
- const viewError = document2.createElement("button");
27862
- viewError.type = "button";
27863
- viewError.className = "settings-connection-view-error";
27864
- viewError.textContent = messages.connectionViewError;
27865
- viewError.addEventListener("click", (event) => {
27866
- event.stopPropagation();
27867
- select();
27868
- });
27869
- action.append(viewError);
27870
- }
27871
- if (version2?.state?.updateAvailable && !version2.updating) {
27872
- const available = document2.createElement("span");
27873
- available.className = "settings-connection-version-available";
27874
- available.textContent = messages.harnessVersionAvailable;
27875
- available.title = `${messages.harnessVersionCurrent}: ${version2.state.currentVersion ?? "\u2014"}
27876
- ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages.harnessVersion)}`;
27877
- action.append(available);
27878
- }
27879
- if (version2?.state?.updateAvailable && version2.state.canUpdate) {
27880
- const update = document2.createElement("button");
27881
- update.type = "button";
27882
- update.className = "settings-connection-install-link";
27883
- update.dataset.connectionAction = "update";
27884
- update.disabled = version2.updating;
27885
- update.title = messages.harnessVersionUpdate;
27886
- update.setAttribute("aria-label", `${messages.harnessVersionUpdate}: ${item.name}`);
27887
- update.append(createRendererSettingsIcon("download", 17));
27888
- update.addEventListener("click", (event) => {
27889
- event.stopPropagation();
27890
- if (update.disabled) return;
27891
- void version2.update();
27892
- select();
27893
- });
27894
- action.append(update);
27895
- }
27896
- if (group) {
27897
- const toggle = document2.createElement("button");
27898
- toggle.type = "button";
27899
- toggle.disabled = group.disabled;
27900
- toggle.className = "settings-connection-row__group-toggle";
27901
- toggle.title = group.moveLabel;
27902
- toggle.setAttribute("aria-label", group.moveLabel);
27903
- toggle.append(
27904
- createRendererSettingsIcon(group.section === "main" ? "chevron-down" : "chevron-up", 15)
27905
- );
27906
- toggle.addEventListener("click", (event) => {
27907
- event.stopPropagation();
27908
- group.toggleSection();
27909
- });
27910
- action.append(toggle);
27911
- }
27912
- row.addEventListener("click", (event) => {
27913
- const target2 = event.target;
27914
- if (target2?.closest?.("a")) return;
27915
- select();
27916
- });
27917
- row.addEventListener("keydown", (event) => {
27918
- if (event.target?.closest?.("button, a")) return;
27919
- if (event.key !== "Enter" && event.key !== " ") return;
27920
- event.preventDefault();
27921
- select();
27922
- });
27923
- if (group) {
27924
- row.draggable = !group.disabled;
27925
- row.dataset.connectionGroupSection = group.section;
27926
- row.addEventListener("dragstart", group.onDragStart);
27927
- row.addEventListener("dragover", group.onDragOver);
27928
- row.addEventListener("dragleave", group.onDragLeave);
27929
- row.addEventListener("drop", group.onDrop);
27930
- row.addEventListener("dragend", group.onDragEnd);
27931
- }
27932
- row.append(identity2, status, action);
27933
- return row;
27934
28221
  }
27935
28222
  function createInspectorHeader(document2, item, messages) {
27936
28223
  const header = document2.createElement("header");
@@ -27960,6 +28247,29 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
27960
28247
  header.append(identity2, status);
27961
28248
  return header;
27962
28249
  }
28250
+ function inspectorRenderSignature(hostId2, item, messages, diagnostics) {
28251
+ const plugin = item.agentSnapshot?.plugin;
28252
+ const notice = plugin?.notice ? plugin.notice[messages.locale] ?? plugin.notice.en : "";
28253
+ const websiteUrl = plugin?.links?.website ?? plugin?.links?.documentation ?? "";
28254
+ const hasLaunchControls = hostId2 === "local" && Boolean(item.agentSnapshot?.agent) && Boolean(plugin?.launchCommand) && Boolean(diagnostics?.getLaunchSettings && diagnostics?.setLaunchSettings);
28255
+ return JSON.stringify([
28256
+ hostId2,
28257
+ item.key,
28258
+ item.name,
28259
+ item.availability,
28260
+ item.agentSnapshot?.availability ?? null,
28261
+ String(plugin?.icon ?? ""),
28262
+ String(plugin?.iconStyle ?? ""),
28263
+ websiteUrl,
28264
+ notice,
28265
+ item.installError ?? "",
28266
+ Boolean(item.install),
28267
+ plugin?.installation ?? null,
28268
+ Boolean(item.openWebUi),
28269
+ hasLaunchControls,
28270
+ item.error ? diagnosticText(hostId2, item) : ""
28271
+ ]);
28272
+ }
27963
28273
  function renderConnectionInspector(document2, inspector, item, hostId2, messages, diagnostics, existingLaunchControls, refresh) {
27964
28274
  inspector.replaceChildren(createInspectorHeader(document2, item, messages));
27965
28275
  const body = document2.createElement("div");
@@ -28122,11 +28432,10 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28122
28432
  ];
28123
28433
  }
28124
28434
  var pendingFocusAgent = null;
28125
- function createGroupDivider(document2, messages, count3) {
28435
+ function createGroupDivider(document2) {
28126
28436
  const divider = document2.createElement("div");
28127
28437
  divider.className = "settings-connection-group-divider";
28128
28438
  divider.setAttribute("role", "presentation");
28129
- divider.textContent = `${messages.connectionGroupMoreLabel} (${count3})`;
28130
28439
  return divider;
28131
28440
  }
28132
28441
  function createGroupMoreHint(document2, messages) {
@@ -28179,11 +28488,13 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28179
28488
  context.content.append(header, syncMessage, content);
28180
28489
  let pending = false;
28181
28490
  let selectedHostId = null;
28491
+ let renderedHostId = null;
28182
28492
  let selectedItemKey = null;
28183
28493
  let launchControls = null;
28494
+ let renderedInspector = null;
28184
28495
  const hostNames = /* @__PURE__ */ new Map();
28496
+ const knownNotInstalled = /* @__PURE__ */ new Map();
28185
28497
  let latestSnapshot = null;
28186
- let disposeHostScroller = () => void 0;
28187
28498
  let disposed = false;
28188
28499
  let renderQueued = false;
28189
28500
  let renderFrame = null;
@@ -28217,7 +28528,99 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28217
28528
  scheduleRender
28218
28529
  );
28219
28530
  const installs = diagnostics ? harnessInstallStore(diagnostics) : null;
28220
- const updates = createConnectionUpdates(document2, messages, context.signal, scheduleRender);
28531
+ const updates = createConnectionUpdates(
28532
+ document2,
28533
+ messages,
28534
+ context.signal,
28535
+ scheduleRender,
28536
+ diagnostics
28537
+ );
28538
+ const panelId = "codexhost-settings-connection-host-panel";
28539
+ const empty = document2.createElement("div");
28540
+ empty.className = "settings-empty";
28541
+ empty.textContent = messages.connectionNoRuntime;
28542
+ const layout = document2.createElement("div");
28543
+ layout.className = "settings-connections-layout";
28544
+ const list = document2.createElement("section");
28545
+ list.className = "settings-connection-list";
28546
+ const hostStrip = document2.createElement("div");
28547
+ hostStrip.className = "settings-connection-host-strip";
28548
+ const scrollLeft = createHostScrollButton(document2, "left", messages);
28549
+ const tabs = document2.createElement("div");
28550
+ tabs.className = "settings-connection-host-tabs";
28551
+ tabs.setAttribute("role", "tablist");
28552
+ tabs.setAttribute("aria-label", messages.connectionHosts);
28553
+ const scrollRight = createHostScrollButton(document2, "right", messages);
28554
+ hostStrip.append(scrollLeft, tabs, scrollRight);
28555
+ const updateControls = updates.createControls("local", []);
28556
+ const hostHeader = document2.createElement("div");
28557
+ hostHeader.className = "settings-connection-host-header";
28558
+ hostHeader.append(hostStrip, updateControls.button);
28559
+ const tableHeader = document2.createElement("div");
28560
+ tableHeader.className = "settings-connection-table-header";
28561
+ tableHeader.setAttribute("role", "row");
28562
+ const componentHeading = document2.createElement("span");
28563
+ componentHeading.textContent = messages.connectionComponent;
28564
+ componentHeading.setAttribute("role", "columnheader");
28565
+ const statusHeading = document2.createElement("span");
28566
+ statusHeading.textContent = messages.connectionStatus;
28567
+ statusHeading.setAttribute("role", "columnheader");
28568
+ const actionHeading = document2.createElement("span");
28569
+ actionHeading.setAttribute("aria-hidden", "true");
28570
+ tableHeader.append(componentHeading, statusHeading, actionHeading);
28571
+ const rows = document2.createElement("div");
28572
+ rows.className = "settings-connection-rows";
28573
+ rows.id = panelId;
28574
+ rows.setAttribute("role", "rowgroup");
28575
+ list.append(hostHeader, updateControls.result, tableHeader, rows);
28576
+ const inspector = document2.createElement("aside");
28577
+ inspector.className = "settings-connection-inspector";
28578
+ inspector.setAttribute("aria-live", "polite");
28579
+ layout.append(list, inspector);
28580
+ const hostScroller = configureHostScroller(
28581
+ document2,
28582
+ hostStrip,
28583
+ tabs,
28584
+ scrollLeft,
28585
+ scrollRight
28586
+ );
28587
+ const hostTabElements = /* @__PURE__ */ new Map();
28588
+ const hostRowViews = /* @__PURE__ */ new Map();
28589
+ const groupDivider = createGroupDivider(document2);
28590
+ const moreHint = createGroupMoreHint(document2, messages);
28591
+ const moreZone = document2.createElement("div");
28592
+ moreZone.className = "settings-connection-group-more";
28593
+ moreZone.setAttribute("role", "presentation");
28594
+ const resetButton = createGroupResetButton(document2, messages, () => {
28595
+ groupPreference.resetToDefault();
28596
+ });
28597
+ let draggingAgent = null;
28598
+ let currentCatalog = [];
28599
+ let currentMainEntries = [];
28600
+ let currentMoreEntries = [];
28601
+ let currentHostRows = /* @__PURE__ */ new Map();
28602
+ const clearDropIndicators = () => {
28603
+ for (const view of currentHostRows.values()) {
28604
+ view.element.dataset.connectionDropIndicator = "";
28605
+ }
28606
+ moreZone.dataset.connectionDragOver = "false";
28607
+ };
28608
+ moreZone.addEventListener("dragover", (event) => {
28609
+ if (!draggingAgent) return;
28610
+ event.preventDefault();
28611
+ moreZone.dataset.connectionDragOver = "true";
28612
+ });
28613
+ moreZone.addEventListener("dragleave", () => {
28614
+ moreZone.dataset.connectionDragOver = "false";
28615
+ });
28616
+ moreZone.addEventListener("drop", (event) => {
28617
+ event.preventDefault();
28618
+ moreZone.dataset.connectionDragOver = "false";
28619
+ if (!draggingAgent) return;
28620
+ groupPreference.moveAgent(draggingAgent, "more", null, currentCatalog);
28621
+ draggingAgent = null;
28622
+ clearDropIndicators();
28623
+ });
28221
28624
  const runRefresh = () => {
28222
28625
  if (pending || !diagnostics) return;
28223
28626
  pending = true;
@@ -28230,6 +28633,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28230
28633
  success() {
28231
28634
  installs?.clearErrors();
28232
28635
  pending = false;
28636
+ renderedInspector = null;
28233
28637
  refresh.disabled = false;
28234
28638
  refresh.replaceChildren(
28235
28639
  createRendererSettingsIcon("diagnose", 16),
@@ -28239,6 +28643,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28239
28643
  },
28240
28644
  failure(error51) {
28241
28645
  pending = false;
28646
+ renderedInspector = null;
28242
28647
  refresh.disabled = false;
28243
28648
  refresh.replaceChildren(
28244
28649
  createRendererSettingsIcon("diagnose", 16),
@@ -28264,97 +28669,111 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28264
28669
  }
28265
28670
  });
28266
28671
  };
28672
+ const syncSelectedInspector = (hostId2, item) => {
28673
+ const currentDiagnostics = getDiagnostics();
28674
+ const signature = inspectorRenderSignature(hostId2, item, messages, currentDiagnostics);
28675
+ const versionElement = item.version?.element ?? null;
28676
+ if (renderedInspector?.signature === signature && renderedInspector.versionElement === versionElement) {
28677
+ return;
28678
+ }
28679
+ const existing = launchControls?.hostId === hostId2 && launchControls.itemKey === item.key ? launchControls.element : null;
28680
+ const element = renderConnectionInspector(
28681
+ document2,
28682
+ inspector,
28683
+ item,
28684
+ hostId2,
28685
+ messages,
28686
+ currentDiagnostics,
28687
+ existing,
28688
+ runRefresh
28689
+ );
28690
+ launchControls = { hostId: hostId2, itemKey: item.key, element };
28691
+ if (versionElement) inspector.append(versionElement);
28692
+ renderedInspector = { signature, versionElement };
28693
+ };
28267
28694
  const render = (snapshot) => {
28268
28695
  const syncStatus = groupPreference.syncStatus();
28269
28696
  const groupDisabled = syncStatus === "loading" || syncStatus === "saving";
28270
28697
  syncMessage.hidden = syncStatus === "ready";
28271
28698
  syncMessage.textContent = syncStatus === "error" ? messages.connectionGroupSyncFailed : syncStatus === "saving" ? messages.connectionGroupSaving : messages.connectionGroupLoading;
28272
28699
  latestSnapshot = snapshot;
28273
- disposeHostScroller();
28274
- disposeHostScroller = () => void 0;
28275
28700
  if (!snapshot) {
28276
- const empty = document2.createElement("div");
28277
- empty.className = "settings-empty";
28278
- empty.textContent = messages.connectionNoRuntime;
28279
- content.replaceChildren(empty);
28701
+ renderedHostId = null;
28702
+ renderedInspector = null;
28703
+ reconcileElementChildren(content, [empty]);
28280
28704
  return;
28281
28705
  }
28282
28706
  const selectedHost = (selectedHostId ? snapshot.hosts.find((host) => host.hostId === selectedHostId) : void 0) ?? snapshot.hosts.find((host) => host.active) ?? snapshot.hosts.find((host) => host.hostId === "local") ?? snapshot.hosts[0];
28283
28707
  if (!selectedHost) return;
28284
28708
  selectedHostId = selectedHost.hostId;
28285
- const layout = document2.createElement("div");
28286
- layout.className = "settings-connections-layout";
28287
- const list = document2.createElement("section");
28288
- list.className = "settings-connection-list";
28289
- const hostStrip = document2.createElement("div");
28290
- hostStrip.className = "settings-connection-host-strip";
28291
- const scrollLeft = createHostScrollButton(document2, "left", messages);
28292
- const tabs = document2.createElement("div");
28293
- tabs.className = "settings-connection-host-tabs";
28294
- tabs.setAttribute("role", "tablist");
28295
- tabs.setAttribute("aria-label", messages.connectionHosts);
28296
- const scrollRight = createHostScrollButton(document2, "right", messages);
28297
- const panelId = "codexhost-settings-connection-host-panel";
28298
- snapshot.hosts.forEach((host, index) => {
28299
- const tab = document2.createElement("button");
28300
- tab.type = "button";
28301
- tab.className = "settings-connection-host-tab";
28302
- tab.dataset.connectionHostTab = host.hostId;
28303
- tab.dataset.connectionHostActive = String(host.active);
28304
- tab.setAttribute("role", "tab");
28305
- tab.setAttribute("aria-controls", panelId);
28306
- tab.setAttribute("aria-selected", String(host.hostId === selectedHost.hostId));
28307
- tab.tabIndex = host.hostId === selectedHost.hostId ? 0 : -1;
28709
+ const layoutFirstMount = content.children[0] !== layout;
28710
+ reconcileElementChildren(content, [layout]);
28711
+ let tabsChanged = tabs.children.length !== snapshot.hosts.length;
28712
+ const nextTabs = snapshot.hosts.map((host) => {
28713
+ let tab = hostTabElements.get(host.hostId);
28714
+ if (!tab) {
28715
+ tab = document2.createElement("button");
28716
+ tab.type = "button";
28717
+ tab.className = "settings-connection-host-tab";
28718
+ tab.dataset.connectionHostTab = host.hostId;
28719
+ tab.setAttribute("role", "tab");
28720
+ tab.setAttribute("aria-controls", panelId);
28721
+ tab.addEventListener("click", () => {
28722
+ selectedHostId = host.hostId;
28723
+ render(latestSnapshot);
28724
+ });
28725
+ tab.addEventListener("keydown", (event) => {
28726
+ if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
28727
+ event.preventDefault();
28728
+ const hosts = latestSnapshot?.hosts ?? [];
28729
+ const index = hosts.findIndex((candidate) => candidate.hostId === host.hostId);
28730
+ if (index < 0) return;
28731
+ const direction = event.key === "ArrowRight" ? 1 : -1;
28732
+ const next = hosts[(index + direction + hosts.length) % hosts.length];
28733
+ if (!next) return;
28734
+ selectedHostId = next.hostId;
28735
+ render(latestSnapshot);
28736
+ hostTabElements.get(next.hostId)?.focus();
28737
+ });
28738
+ hostTabElements.set(host.hostId, tab);
28739
+ tabsChanged = true;
28740
+ }
28741
+ const isSelected = host.hostId === selectedHost.hostId;
28742
+ const activeValue = String(host.active);
28743
+ if (tab.dataset.connectionHostActive !== activeValue) {
28744
+ tab.dataset.connectionHostActive = activeValue;
28745
+ }
28746
+ const selectedValue = String(isSelected);
28747
+ if (tab.getAttribute("aria-selected") !== selectedValue) {
28748
+ tab.setAttribute("aria-selected", selectedValue);
28749
+ }
28750
+ const nextTabIndex = isSelected ? 0 : -1;
28751
+ if (tab.tabIndex !== nextTabIndex) {
28752
+ tab.tabIndex = nextTabIndex;
28753
+ }
28308
28754
  const hostName = hostNames.get(host.hostId) || connectionHostName(host.hostId, messages);
28309
- tab.textContent = hostName;
28310
- tab.title = host.active ? `${hostName} \xB7 ${messages.connectionActiveHost}` : hostName;
28311
- tab.addEventListener("click", () => {
28312
- selectedHostId = host.hostId;
28313
- render(latestSnapshot);
28314
- });
28315
- tab.addEventListener("keydown", (event) => {
28316
- if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
28317
- event.preventDefault();
28318
- const direction = event.key === "ArrowRight" ? 1 : -1;
28319
- const next = snapshot.hosts[(index + direction + snapshot.hosts.length) % snapshot.hosts.length];
28320
- if (!next) return;
28321
- selectedHostId = next.hostId;
28322
- render(latestSnapshot);
28323
- const nextTab = [
28324
- ...content.querySelectorAll("[data-connection-host-tab]")
28325
- ].find((candidate) => candidate.dataset.connectionHostTab === next.hostId);
28326
- nextTab?.focus();
28327
- });
28328
- tabs.append(tab);
28755
+ if (tab.textContent !== hostName) {
28756
+ tab.textContent = hostName;
28757
+ tabsChanged = true;
28758
+ }
28759
+ const tabTitle = host.active ? `${hostName} \xB7 ${messages.connectionActiveHost}` : hostName;
28760
+ if (tab.title !== tabTitle) {
28761
+ tab.title = tabTitle;
28762
+ }
28763
+ return tab;
28329
28764
  });
28330
- hostStrip.append(scrollLeft, tabs, scrollRight);
28331
- const tableHeader = document2.createElement("div");
28332
- tableHeader.className = "settings-connection-table-header";
28333
- tableHeader.setAttribute("role", "row");
28334
- const componentHeading = document2.createElement("span");
28335
- componentHeading.textContent = messages.connectionComponent;
28336
- componentHeading.setAttribute("role", "columnheader");
28337
- const statusHeading = document2.createElement("span");
28338
- statusHeading.textContent = messages.connectionStatus;
28339
- statusHeading.setAttribute("role", "columnheader");
28340
- const actionHeading = document2.createElement("span");
28341
- actionHeading.setAttribute("aria-hidden", "true");
28342
- tableHeader.append(componentHeading, statusHeading, actionHeading);
28343
- const rows = document2.createElement("div");
28344
- rows.className = "settings-connection-rows";
28345
- rows.id = panelId;
28346
- rows.dataset.connectionHost = selectedHost.hostId;
28347
- rows.setAttribute("role", "rowgroup");
28348
- const inspector = document2.createElement("aside");
28349
- inspector.className = "settings-connection-inspector";
28350
- inspector.setAttribute("aria-live", "polite");
28765
+ reconcileElementChildren(tabs, nextTabs);
28766
+ if (rows.dataset.connectionHost !== selectedHost.hostId) {
28767
+ rows.dataset.connectionHost = selectedHost.hostId;
28768
+ }
28351
28769
  const items = connectionItems(snapshot, selectedHost, messages, diagnostics).map(
28352
28770
  (item) => {
28353
28771
  const agent = item.agentSnapshot?.agent;
28354
28772
  if (!agent) return item;
28355
28773
  const state = installs?.get(selectedHost.hostId, agent);
28356
28774
  const availability = state?.status ?? item.availability;
28357
- const version2 = item.agentSnapshot?.availability !== "notInstalled" && availability !== "installing" && availability !== "checking" ? versions.get(selectedHost.hostId, agent) : void 0;
28775
+ const updating = versions.isUpdating(selectedHost.hostId, agent);
28776
+ const version2 = updating || item.agentSnapshot?.availability !== "notInstalled" && availability !== "installing" && availability !== "checking" ? versions.get(selectedHost.hostId, agent) : void 0;
28358
28777
  return {
28359
28778
  ...item,
28360
28779
  ...state ? { availability: state.status } : {},
@@ -28376,66 +28795,66 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28376
28795
  (item) => item.agentSnapshot?.availability === "notInstalled" || item.error !== null
28377
28796
  )?.key ?? items[0]?.key ?? null;
28378
28797
  }
28379
- const rowElements = /* @__PURE__ */ new Map();
28798
+ let hostRows = hostRowViews.get(selectedHost.hostId);
28799
+ if (!hostRows) {
28800
+ hostRows = /* @__PURE__ */ new Map();
28801
+ hostRowViews.set(selectedHost.hostId, hostRows);
28802
+ }
28803
+ currentHostRows = hostRows;
28380
28804
  const selectItem = (item) => {
28381
28805
  selectedItemKey = item.key;
28382
- for (const [key, row] of rowElements) {
28383
- const selected = key === item.key;
28384
- row.dataset.connectionSelected = String(selected);
28385
- row.tabIndex = selected ? 0 : -1;
28806
+ for (const [key, view] of currentHostRows) {
28807
+ view.setSelected(key === item.key);
28386
28808
  }
28387
- const existing = launchControls?.hostId === selectedHost.hostId && launchControls.itemKey === item.key ? launchControls.element : null;
28388
- const element = renderConnectionInspector(
28389
- document2,
28390
- inspector,
28391
- item,
28392
- selectedHost.hostId,
28393
- messages,
28394
- getDiagnostics(),
28395
- existing,
28396
- runRefresh
28397
- );
28398
- launchControls = { hostId: selectedHost.hostId, itemKey: item.key, element };
28399
- if (item.version) inspector.append(item.version.element);
28809
+ syncSelectedInspector(selectedHost.hostId, item);
28400
28810
  };
28401
- const pinnedItem = items.find((item) => item.key === "renderer-adapter");
28402
- if (pinnedItem) {
28403
- const row = createConnectionRow(
28404
- document2,
28811
+ const ensureRowView = (key, groupable) => {
28812
+ let view = hostRows.get(key);
28813
+ if (!view) {
28814
+ view = createConnectionRowView(document2, messages, groupable);
28815
+ hostRows.set(key, view);
28816
+ }
28817
+ return view;
28818
+ };
28819
+ const activeKeys = /* @__PURE__ */ new Set();
28820
+ const nextRowChildren = [];
28821
+ const pinnedItems = items.filter((item) => item.agentSnapshot === void 0);
28822
+ for (const pinnedItem of pinnedItems) {
28823
+ activeKeys.add(pinnedItem.key);
28824
+ const view = ensureRowView(pinnedItem.key, false);
28825
+ view.update(
28405
28826
  pinnedItem,
28406
- messages,
28407
28827
  pinnedItem.key === selectedItemKey,
28408
- () => selectItem(pinnedItem)
28828
+ () => selectItem(pinnedItem),
28829
+ null
28409
28830
  );
28410
- rowElements.set(pinnedItem.key, row);
28411
- rows.append(row);
28831
+ nextRowChildren.push(view.element);
28412
28832
  }
28413
28833
  const groupableItems = items.filter(
28414
28834
  (item) => item.agentSnapshot !== void 0
28415
28835
  );
28416
28836
  const agentByKey = new Map(groupableItems.map((item) => [item.key, item]));
28417
- const catalog = groupableItems.map((item) => ({ id: item.key, name: item.name }));
28418
- const preferenceOrder = groupPreference.list(
28419
- new Set(
28420
- groupableItems.filter((item) => item.agentSnapshot.availability === "notInstalled").map((item) => item.agentSnapshot.agent)
28421
- ),
28422
- catalog
28423
- ).filter((entry) => agentByKey.has(entry.agent));
28424
- const mainEntries = preferenceOrder.filter((entry) => entry.section === "main");
28425
- const moreEntries = preferenceOrder.filter((entry) => entry.section === "more");
28837
+ currentCatalog = groupableItems.map((item) => ({ id: item.key, name: item.name }));
28838
+ const notInstalledAgents = /* @__PURE__ */ new Set();
28839
+ for (const item of groupableItems) {
28840
+ const agent = item.agentSnapshot.agent;
28841
+ const stateKey = `${selectedHost.hostId}:${agent}`;
28842
+ if (item.agentSnapshot.availability !== "checking") {
28843
+ knownNotInstalled.set(stateKey, item.agentSnapshot.availability === "notInstalled");
28844
+ }
28845
+ const isNotInstalled = item.agentSnapshot.availability === "checking" ? knownNotInstalled.get(stateKey) ?? false : item.agentSnapshot.availability === "notInstalled";
28846
+ if (isNotInstalled) notInstalledAgents.add(agent);
28847
+ }
28848
+ const preferenceOrder = groupPreference.list(notInstalledAgents, currentCatalog).filter((entry) => agentByKey.has(entry.agent));
28849
+ currentMainEntries = preferenceOrder.filter((entry) => entry.section === "main");
28850
+ currentMoreEntries = preferenceOrder.filter((entry) => entry.section === "more");
28426
28851
  const nextInSection = (section, agent) => {
28427
- const list2 = section === "main" ? mainEntries : moreEntries;
28428
- const index = list2.findIndex((entry) => entry.agent === agent);
28429
- return index >= 0 ? list2[index + 1]?.agent ?? null : null;
28430
- };
28431
- let draggingAgent = null;
28432
- let moreZone = null;
28433
- const clearDropIndicators = () => {
28434
- for (const row of rowElements.values()) row.dataset.connectionDropIndicator = "";
28435
- if (moreZone) moreZone.dataset.connectionDragOver = "false";
28852
+ const sectionEntries = section === "main" ? currentMainEntries : currentMoreEntries;
28853
+ const index = sectionEntries.findIndex((entry) => entry.agent === agent);
28854
+ return index >= 0 ? sectionEntries[index + 1]?.agent ?? null : null;
28436
28855
  };
28437
28856
  const dropTargetSection = (agent, event) => {
28438
- const row = rowElements.get(agent);
28857
+ const row = currentHostRows.get(agent)?.element;
28439
28858
  const rect = row && typeof row.getBoundingClientRect === "function" ? row.getBoundingClientRect() : null;
28440
28859
  const before = rect ? event.clientY - rect.top < rect.height / 2 : true;
28441
28860
  const section = row?.dataset.connectionGroupSection ?? "main";
@@ -28447,7 +28866,12 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28447
28866
  moveLabel: section === "main" ? messages.connectionGroupMoveToMore : messages.connectionGroupMoveToMain,
28448
28867
  dragHandleTitle: messages.connectionGroupDragHandle,
28449
28868
  toggleSection() {
28450
- groupPreference.moveAgent(agent, section === "main" ? "more" : "main", null, catalog);
28869
+ groupPreference.moveAgent(
28870
+ agent,
28871
+ section === "main" ? "more" : "main",
28872
+ null,
28873
+ currentCatalog
28874
+ );
28451
28875
  },
28452
28876
  onDragStart(event) {
28453
28877
  if (groupDisabled) {
@@ -28457,127 +28881,107 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28457
28881
  draggingAgent = agent;
28458
28882
  event.dataTransfer?.setData("text/plain", agent);
28459
28883
  if (event.dataTransfer) event.dataTransfer.effectAllowed = "move";
28460
- const row = rowElements.get(agent);
28884
+ const row = currentHostRows.get(agent)?.element;
28461
28885
  if (row) row.dataset.connectionDragging = "true";
28462
28886
  },
28463
28887
  onDragOver(event) {
28464
28888
  if (!draggingAgent || draggingAgent === agent) return;
28465
28889
  event.preventDefault();
28466
- const row = rowElements.get(agent);
28890
+ const row = currentHostRows.get(agent)?.element;
28467
28891
  if (!row) return;
28468
28892
  const { before } = dropTargetSection(agent, event);
28469
28893
  clearDropIndicators();
28470
28894
  row.dataset.connectionDropIndicator = before ? "before" : "after";
28471
28895
  },
28472
28896
  onDragLeave() {
28473
- const row = rowElements.get(agent);
28897
+ const row = currentHostRows.get(agent)?.element;
28474
28898
  if (row) row.dataset.connectionDropIndicator = "";
28475
28899
  },
28476
28900
  onDrop(event) {
28477
28901
  event.preventDefault();
28478
28902
  if (!draggingAgent) return;
28479
28903
  const { beforeAgent } = dropTargetSection(agent, event);
28480
- groupPreference.moveAgent(draggingAgent, section, beforeAgent, catalog);
28904
+ groupPreference.moveAgent(draggingAgent, section, beforeAgent, currentCatalog);
28481
28905
  draggingAgent = null;
28482
28906
  clearDropIndicators();
28483
28907
  },
28484
28908
  onDragEnd() {
28485
28909
  draggingAgent = null;
28486
- const row = rowElements.get(agent);
28910
+ const row = currentHostRows.get(agent)?.element;
28487
28911
  if (row) row.dataset.connectionDragging = "false";
28488
28912
  clearDropIndicators();
28913
+ scheduleRender();
28489
28914
  }
28490
28915
  });
28491
- const appendGroupRow = (agent, section) => {
28492
- const item = agentByKey.get(agent);
28493
- if (!item) return;
28494
- const row = createConnectionRow(
28495
- document2,
28916
+ for (const entry of currentMainEntries) {
28917
+ const item = agentByKey.get(entry.agent);
28918
+ if (!item) continue;
28919
+ activeKeys.add(item.key);
28920
+ const view = ensureRowView(item.key, true);
28921
+ view.update(
28496
28922
  item,
28497
- messages,
28498
28923
  item.key === selectedItemKey,
28499
28924
  () => selectItem(item),
28500
- createGroupController(agent, section)
28925
+ createGroupController(entry.agent, "main")
28501
28926
  );
28502
- rowElements.set(item.key, row);
28503
- rows.append(row);
28504
- };
28505
- for (const entry of mainEntries) appendGroupRow(entry.agent, "main");
28927
+ nextRowChildren.push(view.element);
28928
+ }
28506
28929
  if (groupableItems.length > 0) {
28507
- rows.append(createGroupDivider(document2, messages, moreEntries.length));
28508
- const zone = document2.createElement("div");
28509
- moreZone = zone;
28510
- zone.className = "settings-connection-group-more";
28511
- zone.setAttribute("role", "presentation");
28512
- zone.addEventListener("dragover", (event) => {
28513
- if (!draggingAgent) return;
28514
- event.preventDefault();
28515
- zone.dataset.connectionDragOver = "true";
28516
- });
28517
- zone.addEventListener("dragleave", () => {
28518
- zone.dataset.connectionDragOver = "false";
28519
- });
28520
- zone.addEventListener("drop", (event) => {
28521
- event.preventDefault();
28522
- zone.dataset.connectionDragOver = "false";
28523
- if (!draggingAgent) return;
28524
- groupPreference.moveAgent(draggingAgent, "more", null, catalog);
28525
- draggingAgent = null;
28526
- clearDropIndicators();
28527
- });
28528
- if (moreEntries.length === 0) {
28529
- zone.append(createGroupMoreHint(document2, messages));
28930
+ const dividerText = `${messages.connectionGroupMoreLabel} (${currentMoreEntries.length})`;
28931
+ if (groupDivider.textContent !== dividerText) {
28932
+ groupDivider.textContent = dividerText;
28933
+ }
28934
+ nextRowChildren.push(groupDivider);
28935
+ const nextMoreChildren = [];
28936
+ if (currentMoreEntries.length === 0) {
28937
+ nextMoreChildren.push(moreHint);
28530
28938
  } else {
28531
- for (const entry of moreEntries) {
28939
+ for (const entry of currentMoreEntries) {
28532
28940
  const item = agentByKey.get(entry.agent);
28533
28941
  if (!item) continue;
28534
- const row = createConnectionRow(
28535
- document2,
28942
+ activeKeys.add(item.key);
28943
+ const view = ensureRowView(item.key, true);
28944
+ view.update(
28536
28945
  item,
28537
- messages,
28538
28946
  item.key === selectedItemKey,
28539
28947
  () => selectItem(item),
28540
28948
  createGroupController(entry.agent, "more")
28541
28949
  );
28542
- rowElements.set(item.key, row);
28543
- zone.append(row);
28950
+ nextMoreChildren.push(view.element);
28544
28951
  }
28545
28952
  }
28546
- rows.append(zone);
28547
- const reset = createGroupResetButton(document2, messages, () => {
28548
- groupPreference.resetToDefault();
28549
- });
28550
- reset.disabled = groupDisabled;
28551
- rows.append(reset);
28953
+ if (!draggingAgent || renderedHostId !== selectedHost.hostId) {
28954
+ reconcileElementChildren(moreZone, nextMoreChildren);
28955
+ }
28956
+ nextRowChildren.push(moreZone);
28957
+ resetButton.disabled = groupDisabled;
28958
+ nextRowChildren.push(resetButton);
28959
+ }
28960
+ for (const key of hostRows.keys()) {
28961
+ if (!activeKeys.has(key)) hostRows.delete(key);
28962
+ }
28963
+ if (!draggingAgent || renderedHostId !== selectedHost.hostId) {
28964
+ reconcileElementChildren(rows, nextRowChildren);
28552
28965
  }
28553
28966
  const selectedItem = items.find((item) => item.key === selectedItemKey) ?? items[0];
28554
28967
  if (selectedItem) selectItem(selectedItem);
28555
- const updateControls = updates.createControls(
28968
+ updateControls.update(
28556
28969
  selectedHost.hostId,
28557
28970
  items.flatMap((item) => item.version ? [item.version] : [])
28558
28971
  );
28559
- const hostHeader = document2.createElement("div");
28560
- hostHeader.className = "settings-connection-host-header";
28561
- hostHeader.append(hostStrip, updateControls.button);
28562
- list.append(hostHeader, updateControls.result, tableHeader, rows);
28563
- layout.append(list, inspector);
28564
- content.replaceChildren(layout);
28565
- disposeHostScroller = configureHostScroller(
28566
- document2,
28567
- hostStrip,
28568
- tabs,
28569
- scrollLeft,
28570
- scrollRight
28571
- );
28572
- const selectedTab = [...tabs.children].find(
28573
- (child) => child.getAttribute("aria-selected") === "true"
28574
- );
28575
- if (selectedTab) {
28576
- const left = selectedTab.offsetLeft;
28577
- const right = left + selectedTab.offsetWidth;
28578
- if (left < tabs.scrollLeft) tabs.scrollLeft = left;
28579
- else if (right > tabs.scrollLeft + tabs.clientWidth) {
28580
- tabs.scrollLeft = right - tabs.clientWidth;
28972
+ if (layoutFirstMount || tabsChanged) {
28973
+ hostScroller.update();
28974
+ }
28975
+ if (renderedHostId !== selectedHost.hostId) {
28976
+ renderedHostId = selectedHost.hostId;
28977
+ const selectedTab = hostTabElements.get(selectedHost.hostId);
28978
+ if (selectedTab) {
28979
+ const left = selectedTab.offsetLeft;
28980
+ const right = left + selectedTab.offsetWidth;
28981
+ if (left < tabs.scrollLeft) tabs.scrollLeft = left;
28982
+ else if (right > tabs.scrollLeft + tabs.clientWidth) {
28983
+ tabs.scrollLeft = right - tabs.clientWidth;
28984
+ }
28581
28985
  }
28582
28986
  }
28583
28987
  };
@@ -28598,7 +29002,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28598
29002
  refresh.disabled = true;
28599
29003
  return () => {
28600
29004
  cancelRender();
28601
- disposeHostScroller();
29005
+ hostScroller.dispose();
28602
29006
  unsubscribeGroup();
28603
29007
  };
28604
29008
  }
@@ -28607,7 +29011,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28607
29011
  const unsubscribeInstalls = installs?.subscribe(scheduleRender);
28608
29012
  return () => {
28609
29013
  cancelRender();
28610
- disposeHostScroller();
29014
+ hostScroller.dispose();
28611
29015
  unsubscribeInstalls?.();
28612
29016
  unsubscribe();
28613
29017
  unsubscribeGroup();
@@ -30251,9 +30655,13 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
30251
30655
  resets: "Resets",
30252
30656
  details: "Account limit details",
30253
30657
  weekly: "Weekly limit",
30658
+ weeklyShort: "Weekly",
30254
30659
  monthly: "Monthly limit",
30660
+ monthlyShort: "Monthly",
30255
30661
  fiveHour: "5-hour limit",
30662
+ fiveHourShort: "5-hour",
30256
30663
  sevenDay: "7-day limit",
30664
+ sevenDayShort: "7-day",
30257
30665
  account: "Account limit"
30258
30666
  });
30259
30667
  var CHINESE_CREDITS_MESSAGES = Object.freeze({
@@ -30261,9 +30669,13 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
30261
30669
  resets: "\u91CD\u7F6E",
30262
30670
  details: "\u8D26\u53F7\u989D\u5EA6\u8BE6\u60C5",
30263
30671
  weekly: "\u5468\u989D\u5EA6",
30672
+ weeklyShort: "\u5468\u989D\u5EA6",
30264
30673
  monthly: "\u6708\u989D\u5EA6",
30674
+ monthlyShort: "\u6708\u989D\u5EA6",
30265
30675
  fiveHour: "5 \u5C0F\u65F6\u989D\u5EA6",
30676
+ fiveHourShort: "5 \u5C0F\u65F6",
30266
30677
  sevenDay: "7 \u5929\u989D\u5EA6",
30678
+ sevenDayShort: "7 \u5929",
30267
30679
  account: "\u8D26\u53F7\u989D\u5EA6"
30268
30680
  });
30269
30681
  function formatRendererCreditsReset(value, now = /* @__PURE__ */ new Date(), locale = "en") {
@@ -33238,6 +33650,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
33238
33650
  .settings-connection-inspector {
33239
33651
  position: sticky;
33240
33652
  top: 18px;
33653
+ overflow-anchor: none;
33241
33654
  }
33242
33655
 
33243
33656
  .settings-connection-inspector__header {