@codexhost/cli-darwin-x64 0.19.0 → 0.21.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 (63) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +45 -4
  4. package/app/console-web.js +1124 -684
  5. package/app/desktop-controller.mjs +197 -50
  6. package/app/host-runtime.mjs +36192 -29254
  7. package/app/plugins/antigravity/assets/icon.svg +1 -1
  8. package/app/plugins/antigravity/plugin.mjs +8863 -4094
  9. package/app/plugins/claude-code/plugin.mjs +173 -26
  10. package/app/plugins/codebuddy/plugin.mjs +71 -6
  11. package/app/plugins/codex-usage/plugin.mjs +56 -4
  12. package/app/plugins/copilot/plugin.mjs +48 -4
  13. package/app/plugins/cursor-cli/plugin.mjs +48 -4
  14. package/app/plugins/deepseek-harness/plugin.mjs +73 -9
  15. package/app/plugins/devin/plugin.mjs +47 -4
  16. package/app/plugins/grok/plugin.mjs +84 -13
  17. package/app/plugins/hermes/plugin.mjs +47 -4
  18. package/app/plugins/kimi-code/plugin.mjs +73 -14
  19. package/app/plugins/kiro-cli/plugin.mjs +48 -4
  20. package/app/plugins/omp/plugin.mjs +74 -7
  21. package/app/plugins/opencode/plugin.mjs +74 -13
  22. package/app/plugins/pi/plugin.mjs +75 -7
  23. package/app/plugins/qoder/plugin.mjs +85 -5
  24. package/app/plugins/qoder-cn/plugin.mjs +85 -5
  25. package/app/plugins/qwen-code/plugin.mjs +48 -4
  26. package/app/plugins/workbuddy/plugin.mjs +75 -9
  27. package/app/plugins/zcode/plugin.mjs +56 -4
  28. package/app/renderer-extension.js +1431 -737
  29. package/app/web/assets/index-BdmZfTRW.js +201 -0
  30. package/app/web/assets/index-DJW4bmyx.css +1 -0
  31. package/app/web/assets/langs/{graphql-B8vkg11W.js → graphql-ChAeyPkT.js} +1 -1
  32. package/app/web/assets/langs/{http-DmoDEjMt.js → http-BvreBIbD.js} +1 -1
  33. package/app/web/assets/langs/{php-DJ5ovfAM.js → php-D8omCIuJ.js} +1 -1
  34. package/app/web/assets/langs/{rst-U5-R5x3p.js → rst-Do7RLLCS.js} +1 -1
  35. package/app/web/assets/langs/{ruby-VKVsnS0H.js → ruby-rH_O_vse.js} +1 -1
  36. package/app/web/assets/langs/{svelte-C20lOv9V.js → svelte-xZy73wAj.js} +1 -1
  37. package/app/web/assets/langs/{vue-z6Y-lzP-.js → vue-C4DW8agZ.js} +1 -1
  38. package/app/web/assets/{vendor-dSL872WO.js → vendor-C9g2bw8s.js} +3 -3
  39. package/app/web/codexhost-settings.js +1130 -686
  40. package/app/web/index.html +4 -3
  41. package/app/web/plugins/deepseek-ai__dsh-api-gateway/client.js +2 -2
  42. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
  43. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +8 -8
  44. package/app/web/plugins/deepseek-ai__dsh-client-connection/client.js +1 -1
  45. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +74 -69
  46. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +7 -7
  47. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +27 -27
  48. package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
  49. package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
  50. package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +1 -1
  51. package/app/web/plugins/deepseek-ai__dsh-client-ui-session/client.js +1 -1
  52. package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
  53. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar/client.js +1 -1
  54. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +9 -9
  55. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
  56. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +7 -7
  57. package/app/web-modules/server.mjs +1144 -731
  58. package/bin/codexhost +0 -0
  59. package/libexec/codexhost-shim +0 -0
  60. package/libexec/codexhost-updater +0 -0
  61. package/package.json +1 -1
  62. package/app/web/assets/index-BNQIOOHE.css +0 -1
  63. 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.union([external_exports.literal(3), external_exports.literal(4)]).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), external_exports.literal(4)]).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
+ // Older 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 === 4)).optional(),
14785
+ // Retain independent TTFT facts when dropping incompatible speed measurements.
14786
+ outputTokensPerSecond: usageMeasurementSchema.refine((value) => value.version === 4).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;
@@ -15233,6 +15250,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15233
15250
  cursor: clientChannelCursorSchema,
15234
15251
  cwd: external_exports.string().optional()
15235
15252
  }),
15253
+ external_exports.object({
15254
+ type: external_exports.literal("harness-inspection-changed"),
15255
+ cursor: clientChannelCursorSchema,
15256
+ harnessId: external_exports.string().min(1)
15257
+ }),
15236
15258
  external_exports.object({ type: external_exports.literal("display-settings-changed"), cursor: clientChannelCursorSchema }),
15237
15259
  external_exports.object({
15238
15260
  type: external_exports.literal("preferences-changed"),
@@ -15304,6 +15326,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15304
15326
  var clientTurnSchema = external_exports.object({
15305
15327
  id: external_exports.string().min(1),
15306
15328
  status: external_exports.string().min(1),
15329
+ /** Native history has no terminal evidence; Desktop's status vocabulary cannot express this. */
15330
+ codexhostTurnOutcome: external_exports.object({ status: external_exports.literal("unknown"), reason: external_exports.string() }).optional(),
15307
15331
  items: external_exports.array(external_exports.object({ id: external_exports.string().min(1), type: external_exports.string().min(1) }).passthrough()),
15308
15332
  /** Original file operations, independent of the cumulative Desktop fileChange card.
15309
15333
  * Insert before the named non-file Item; null appends at the end of the Turn.
@@ -15342,7 +15366,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15342
15366
  /** Current interruptible Host Turn, including command Turns omitted from client history. */
15343
15367
  activeTurnId: external_exports.string().min(1).nullable().optional(),
15344
15368
  /** 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(),
15369
+ command: external_exports.object({
15370
+ name: external_exports.string().min(1),
15371
+ turn: clientTurnSchema,
15372
+ /** First ordinary Turn started after this command; its retained result is not a new event. */
15373
+ subsequentTurnId: external_exports.string().min(1).optional()
15374
+ }).optional(),
15346
15375
  thread: external_exports.object({
15347
15376
  id: external_exports.string().min(1),
15348
15377
  cwd: external_exports.string(),
@@ -15552,7 +15581,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15552
15581
  quotaUntil: external_exports.string().optional()
15553
15582
  }).strict().optional()
15554
15583
  }).strict();
15555
- var webLocalAccessRequiredDetailsSchema = external_exports.object({ url: external_exports.string() }).strict();
15556
15584
 
15557
15585
  // ../shared-contracts/dist/delegation-read.js
15558
15586
  var REMOTE_THREAD_REPLY_MAX_BYTES = 16 * 1024 * 1024;
@@ -16566,6 +16594,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16566
16594
  "completed",
16567
16595
  "failed",
16568
16596
  "interrupted",
16597
+ "needsInput",
16569
16598
  "timedOut",
16570
16599
  "unreadable",
16571
16600
  "notFound"
@@ -16615,13 +16644,25 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16615
16644
  var thread = { ...target, threadId: identity };
16616
16645
  var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
16617
16646
  external_exports.strictObject({ kind: external_exports.literal("hosts") }),
16647
+ external_exports.strictObject({ kind: external_exports.literal("status"), ...thread }),
16618
16648
  external_exports.strictObject({
16619
16649
  kind: external_exports.literal("list"),
16620
16650
  ...target,
16621
16651
  cursor: external_exports.string().nullable(),
16622
16652
  archived: external_exports.boolean()
16623
16653
  }),
16624
- external_exports.strictObject({ kind: external_exports.literal("read"), ...thread }),
16654
+ external_exports.strictObject({
16655
+ kind: external_exports.literal("read"),
16656
+ ...thread,
16657
+ page: external_exports.strictObject({
16658
+ cursor: external_exports.string().min(1).max(8192).nullable(),
16659
+ epoch: identity.optional(),
16660
+ sortDirection: external_exports.enum(["asc", "desc"]).optional(),
16661
+ limit: external_exports.number().int().min(1).max(20).optional()
16662
+ }).refine((page) => page.cursor === null || page.epoch !== void 0, {
16663
+ message: "A history continuation requires its connection epoch"
16664
+ }).optional()
16665
+ }),
16625
16666
  external_exports.strictObject({
16626
16667
  kind: external_exports.literal("configure"),
16627
16668
  ...thread,
@@ -17691,11 +17732,18 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17691
17732
  const webUi = /* @__PURE__ */ new Map();
17692
17733
  const listeners = /* @__PURE__ */ new Set();
17693
17734
  let pending = null;
17735
+ let queuedRefresh = null;
17694
17736
  const publish = () => {
17695
17737
  for (const listener of [...listeners]) listener();
17696
17738
  };
17697
17739
  const inspectAll = (refresh) => {
17698
- if (pending) return pending;
17740
+ if (pending) {
17741
+ if (!refresh) return pending;
17742
+ queuedRefresh ??= pending.then(() => inspectAll(true)).finally(() => {
17743
+ queuedRefresh = null;
17744
+ });
17745
+ return queuedRefresh;
17746
+ }
17699
17747
  pending = Promise.resolve().then(async () => {
17700
17748
  try {
17701
17749
  if (!client.listHarnessPlugins)
@@ -17713,7 +17761,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17713
17761
  await Promise.all(
17714
17762
  plugins.map(async ({ id }) => {
17715
17763
  try {
17716
- const inspection = await client.inspectHarness({ harnessId: id, refresh });
17764
+ const inspection = await client.inspectHarness({
17765
+ harnessId: id,
17766
+ refresh,
17767
+ purpose: "availability"
17768
+ });
17717
17769
  availability.set(id, inspection.status);
17718
17770
  webUi.set(id, inspection.status === "ready" && inspection.webUi?.open === true);
17719
17771
  const error51 = inspection.status === "ready" ? null : inspection.error;
@@ -23470,6 +23522,7 @@ th[aria-sort] .console-usage-sort__mark {
23470
23522
  latestCacheHit: "Latest cache hit (CH)",
23471
23523
  sessionCacheHit: "Average cache hit",
23472
23524
  outputSpeed: "Output speed (TPS)",
23525
+ averageOutputSpeed: "Average output speed (TPS)",
23473
23526
  apiOutputSpeed: "API average speed",
23474
23527
  apiOutputSpeedDescription: "Output tokens / native API time, including first-token wait; not generation TPS.",
23475
23528
  timeToFirstOutput: "Time to first token (TTFT)",
@@ -23495,6 +23548,7 @@ th[aria-sort] .console-usage-sort__mark {
23495
23548
  latestCacheHit: "\u6700\u8FD1\u7F13\u5B58\u547D\u4E2D\uFF08CH\uFF09",
23496
23549
  sessionCacheHit: "\u5E73\u5747\u7F13\u5B58\u547D\u4E2D",
23497
23550
  outputSpeed: "\u8F93\u51FA\u901F\u5EA6\uFF08TPS\uFF09",
23551
+ averageOutputSpeed: "\u5E73\u5747\u8F93\u51FA\u901F\u5EA6\uFF08TPS\uFF09",
23498
23552
  apiOutputSpeed: "API \u5E73\u5747\u901F\u5EA6",
23499
23553
  apiOutputSpeedDescription: "\u8F93\u51FA Token \xF7 \u539F\u751F API \u8017\u65F6\uFF0C\u542B\u9996\u5B57\u7B49\u5F85\uFF1B\u4E0D\u662F\u751F\u6210 TPS\u3002",
23500
23554
  timeToFirstOutput: "\u9996 token\uFF08TTFT\uFF09",
@@ -27234,242 +27288,474 @@ ${detail}` : ""}`
27234
27288
  return fallback;
27235
27289
  }
27236
27290
 
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;
27291
+ // src/settings/connection-row.ts
27292
+ function connectionStatusLabel(availability, messages, hasError = false) {
27293
+ if (availability === "updating") return messages.connectionStatusUpdating;
27294
+ if (hasError && availability !== "notInstalled") return messages.connectionStatusError;
27295
+ if (availability === "ready") return messages.connectionStatusReady;
27296
+ if (availability === "checking") return messages.connectionStatusChecking;
27297
+ if (availability === "notInstalled") return messages.connectionStatusNotInstalled;
27298
+ if (availability === "unavailable" || availability === "error") {
27299
+ return availability === "error" ? messages.connectionStatusError : messages.connectionStatusUnavailable;
27300
+ }
27301
+ return availability === "installing" ? messages.connectionStatusInstalling : messages.connectionStatusUnsupported;
27318
27302
  }
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
- };
27303
+ function connectionStatusTone(availability, hasError = false) {
27304
+ if (availability === "updating") return "checking";
27305
+ if (hasError && availability !== "notInstalled") return "failed";
27306
+ if (availability === "ready") return "ready";
27307
+ if (availability === "checking" || availability === "installing") return "checking";
27308
+ if (availability === "notInstalled") return "setup";
27309
+ return "failed";
27329
27310
  }
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.");
27311
+ function createConnectionIdentityIcon(document2, item, size) {
27312
+ const container = document2.createElement("span");
27313
+ container.className = item.agentSnapshot ? "settings-connection-row__mark settings-connection-row__mark--logo" : "settings-connection-row__mark";
27314
+ container.setAttribute("aria-hidden", "true");
27315
+ if (item.agentSnapshot) {
27316
+ container.append(
27317
+ createRendererAgentIcon(item.agentSnapshot.agent, size, document2, item.agentSnapshot.plugin)
27318
+ );
27319
+ } else {
27320
+ container.textContent = "CH";
27344
27321
  }
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);
27322
+ return container;
27323
+ }
27324
+ function sameElementChildren(container, next) {
27325
+ if (container.children.length !== next.length) return false;
27326
+ for (let index = 0; index < next.length; index++) {
27327
+ if (container.children[index] !== next[index]) return false;
27360
27328
  }
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);
27329
+ return true;
27330
+ }
27331
+ function reconcileElementChildren(container, next) {
27332
+ if (sameElementChildren(container, next)) return;
27333
+ if (typeof container.insertBefore !== "function") {
27334
+ container.replaceChildren(...next);
27335
+ return;
27384
27336
  }
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);
27337
+ const nextSet = new Set(next);
27338
+ for (const child of [...container.children]) {
27339
+ if (!nextSet.has(child)) child.remove();
27394
27340
  }
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);
27341
+ for (let index = 0; index < next.length; index++) {
27342
+ const desired = next[index];
27343
+ if (!desired) continue;
27344
+ const current = container.children[index] ?? null;
27345
+ if (current !== desired) {
27346
+ container.insertBefore(desired, current);
27347
+ }
27403
27348
  }
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
27349
  }
27411
- function unknownInstallOutcome(message2) {
27412
- return /outcome is unknown|do not retry automatically|did not answer in time/i.test(message2);
27350
+ function identityIconSignature(item) {
27351
+ if (!item.agentSnapshot) return "adapter";
27352
+ const plugin = item.agentSnapshot.plugin;
27353
+ return `${item.agentSnapshot.agent}:${String(plugin?.icon ?? "")}:${String(plugin?.iconStyle ?? "")}`;
27413
27354
  }
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());
27355
+ function createConnectionRowView(document2, messages, groupable) {
27356
+ const row = document2.createElement("div");
27357
+ row.className = "settings-connection-row";
27358
+ row.setAttribute("role", "row");
27359
+ const identity2 = document2.createElement("div");
27360
+ identity2.className = "settings-connection-row__identity";
27361
+ identity2.setAttribute("role", "cell");
27362
+ let handle = null;
27363
+ if (groupable) {
27364
+ handle = document2.createElement("span");
27365
+ handle.className = "settings-connection-row__handle";
27366
+ handle.setAttribute("aria-hidden", "true");
27367
+ handle.append(createRendererSettingsIcon("grip-vertical", 15));
27368
+ identity2.append(handle);
27369
+ }
27370
+ let iconElement = null;
27371
+ let renderedIconKey = null;
27372
+ const label = document2.createElement("strong");
27373
+ const status = document2.createElement("span");
27374
+ status.className = "settings-connection-row__status";
27375
+ status.setAttribute("role", "cell");
27376
+ const action = document2.createElement("div");
27377
+ action.className = "settings-connection-row__action";
27378
+ action.setAttribute("role", "cell");
27379
+ row.append(identity2, status, action);
27380
+ let currentItem = null;
27381
+ let currentSelect = () => void 0;
27382
+ let currentGroup = null;
27383
+ let installButton = null;
27384
+ let viewErrorButton = null;
27385
+ let versionAvailableBadge = null;
27386
+ let updateButton = null;
27387
+ let groupToggleButton = null;
27388
+ let groupToggleSection = null;
27389
+ row.addEventListener("click", (event) => {
27390
+ const target2 = event.target;
27391
+ if (target2?.closest?.("a")) return;
27392
+ currentSelect();
27393
+ });
27394
+ row.addEventListener("keydown", (event) => {
27395
+ if (event.target?.closest?.("button, a")) return;
27396
+ if (event.key !== "Enter" && event.key !== " ") return;
27397
+ event.preventDefault();
27398
+ currentSelect();
27399
+ });
27400
+ if (groupable) {
27401
+ row.addEventListener("dragstart", (event) => currentGroup?.onDragStart(event));
27402
+ row.addEventListener("dragover", (event) => currentGroup?.onDragOver(event));
27403
+ row.addEventListener("dragleave", (event) => currentGroup?.onDragLeave(event));
27404
+ row.addEventListener("drop", (event) => currentGroup?.onDrop(event));
27405
+ row.addEventListener("dragend", (event) => currentGroup?.onDragEnd(event));
27406
+ }
27407
+ const setSelected = (selected) => {
27408
+ const nextSelected = String(selected);
27409
+ if (row.dataset.connectionSelected !== nextSelected) {
27410
+ row.dataset.connectionSelected = nextSelected;
27411
+ }
27412
+ const nextTabIndex = selected ? 0 : -1;
27413
+ if (row.tabIndex !== nextTabIndex) {
27414
+ row.tabIndex = nextTabIndex;
27415
+ }
27416
+ };
27420
27417
  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);
27418
+ element: row,
27419
+ setSelected,
27420
+ update(item, selected, select, group) {
27421
+ currentItem = item;
27422
+ currentSelect = select;
27423
+ currentGroup = group;
27424
+ if (row.dataset.connectionItem !== item.key) {
27425
+ row.dataset.connectionItem = item.key;
27426
+ }
27427
+ setSelected(selected);
27428
+ const nextIconKey = identityIconSignature(item);
27429
+ if (renderedIconKey !== nextIconKey || !iconElement) {
27430
+ renderedIconKey = nextIconKey;
27431
+ iconElement = createConnectionIdentityIcon(document2, item, 19);
27432
+ reconcileElementChildren(
27433
+ identity2,
27434
+ handle ? [handle, iconElement, label] : [iconElement, label]
27435
+ );
27445
27436
  }
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;
27437
+ if (handle && group && handle.title !== group.dragHandleTitle) {
27438
+ handle.title = group.dragHandleTitle;
27439
+ }
27440
+ if (label.textContent !== item.name) {
27441
+ label.textContent = item.name;
27442
+ }
27443
+ const tone = connectionStatusTone(item.availability, item.error !== null);
27444
+ if (status.dataset.connectionTone !== tone) {
27445
+ status.dataset.connectionTone = tone;
27446
+ }
27447
+ const statusText = item.error?.code === "authenticationRequired" ? messages.connectionLoginRequired : item.error?.code === "configurationRequired" ? messages.connectionConfigurationRequired : connectionStatusLabel(item.availability, messages, item.error !== null);
27448
+ if (status.textContent !== statusText) {
27449
+ status.textContent = statusText;
27450
+ }
27451
+ const nextActions = [];
27452
+ if (item.agentSnapshot?.availability === "notInstalled" && item.install) {
27453
+ if (!installButton) {
27454
+ const button2 = document2.createElement("button");
27455
+ button2.type = "button";
27456
+ button2.className = "settings-connection-install-link";
27457
+ button2.append(createRendererSettingsIcon("download", 17));
27458
+ button2.addEventListener("click", (event) => {
27459
+ event.stopPropagation();
27460
+ currentSelect();
27461
+ currentItem?.install?.();
27462
+ });
27463
+ installButton = button2;
27464
+ }
27465
+ installButton.disabled = item.availability === "installing" || item.availability === "checking";
27466
+ const installLabel = messages.connectionInstall;
27467
+ const ariaLabel = `${installLabel}: ${item.name}`;
27468
+ if (installButton.getAttribute("aria-label") !== ariaLabel) {
27469
+ installButton.setAttribute("aria-label", ariaLabel);
27470
+ }
27471
+ if (installButton.title !== installLabel) {
27472
+ installButton.title = installLabel;
27473
+ }
27474
+ nextActions.push(installButton);
27475
+ } else if (item.error) {
27476
+ if (!viewErrorButton) {
27477
+ const button2 = document2.createElement("button");
27478
+ button2.type = "button";
27479
+ button2.className = "settings-connection-view-error";
27480
+ button2.textContent = messages.connectionViewError;
27481
+ button2.addEventListener("click", (event) => {
27482
+ event.stopPropagation();
27483
+ currentSelect();
27484
+ });
27485
+ viewErrorButton = button2;
27486
+ }
27487
+ nextActions.push(viewErrorButton);
27488
+ }
27489
+ const version2 = item.version;
27490
+ if (version2?.state?.updateAvailable && !version2.updating) {
27491
+ if (!versionAvailableBadge) {
27492
+ const badge = document2.createElement("span");
27493
+ badge.className = "settings-connection-version-available";
27494
+ badge.textContent = messages.harnessVersionAvailable;
27495
+ versionAvailableBadge = badge;
27496
+ }
27497
+ const badgeTitle = `${messages.harnessVersionCurrent}: ${version2.state.currentVersion ?? "\u2014"}
27498
+ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages.harnessVersion)}`;
27499
+ if (versionAvailableBadge.title !== badgeTitle) {
27500
+ versionAvailableBadge.title = badgeTitle;
27501
+ }
27502
+ nextActions.push(versionAvailableBadge);
27503
+ }
27504
+ if (version2?.state?.updateAvailable && version2.state.canUpdate) {
27505
+ if (!updateButton) {
27506
+ const button2 = document2.createElement("button");
27507
+ button2.type = "button";
27508
+ button2.className = "settings-connection-install-link";
27509
+ button2.dataset.connectionAction = "update";
27510
+ button2.append(createRendererSettingsIcon("download", 17));
27511
+ button2.addEventListener("click", (event) => {
27512
+ event.stopPropagation();
27513
+ if (button2.disabled) return;
27514
+ void currentItem?.version?.update();
27515
+ currentSelect();
27516
+ });
27517
+ updateButton = button2;
27518
+ }
27519
+ updateButton.disabled = version2.updating;
27520
+ if (updateButton.title !== messages.harnessVersionUpdate) {
27521
+ updateButton.title = messages.harnessVersionUpdate;
27522
+ }
27523
+ const updateAriaLabel = `${messages.harnessVersionUpdate}: ${item.name}`;
27524
+ if (updateButton.getAttribute("aria-label") !== updateAriaLabel) {
27525
+ updateButton.setAttribute("aria-label", updateAriaLabel);
27526
+ }
27527
+ nextActions.push(updateButton);
27528
+ }
27529
+ if (group) {
27530
+ if (!groupToggleButton) {
27531
+ const button2 = document2.createElement("button");
27532
+ button2.type = "button";
27533
+ button2.className = "settings-connection-row__group-toggle";
27534
+ button2.addEventListener("click", (event) => {
27535
+ event.stopPropagation();
27536
+ currentGroup?.toggleSection();
27537
+ });
27538
+ groupToggleButton = button2;
27539
+ }
27540
+ groupToggleButton.disabled = group.disabled;
27541
+ if (groupToggleButton.title !== group.moveLabel) {
27542
+ groupToggleButton.title = group.moveLabel;
27543
+ }
27544
+ if (groupToggleButton.getAttribute("aria-label") !== group.moveLabel) {
27545
+ groupToggleButton.setAttribute("aria-label", group.moveLabel);
27546
+ }
27547
+ if (groupToggleSection !== group.section) {
27548
+ groupToggleSection = group.section;
27549
+ groupToggleButton.replaceChildren(
27550
+ createRendererSettingsIcon(
27551
+ group.section === "main" ? "chevron-down" : "chevron-up",
27552
+ 15
27553
+ )
27554
+ );
27555
+ }
27556
+ nextActions.push(groupToggleButton);
27557
+ }
27558
+ reconcileElementChildren(action, nextActions);
27559
+ if (group) {
27560
+ row.draggable = !group.disabled;
27561
+ if (row.dataset.connectionGroupSection !== group.section) {
27562
+ row.dataset.connectionGroupSection = group.section;
27452
27563
  }
27453
- } catch (error51) {
27454
- failure ??= errorMessage2(error51);
27455
27564
  }
27456
- if (failure) states2.set(id, { status: "error", error: failure });
27457
- else states2.delete(id);
27458
- notify2();
27459
27565
  }
27460
27566
  };
27461
27567
  }
27462
- function harnessInstallStore(diagnostics) {
27463
- let store = stores.get(diagnostics);
27568
+
27569
+ // src/settings/connection-updates.ts
27570
+ var sharedBatchStores = /* @__PURE__ */ new WeakMap();
27571
+ function getBatchStore(diagnostics) {
27572
+ if (!diagnostics) {
27573
+ return { batches: /* @__PURE__ */ new Map(), listeners: /* @__PURE__ */ new Set() };
27574
+ }
27575
+ let store = sharedBatchStores.get(diagnostics);
27464
27576
  if (!store) {
27465
- store = createStore(diagnostics);
27466
- stores.set(diagnostics, store);
27577
+ store = { batches: /* @__PURE__ */ new Map(), listeners: /* @__PURE__ */ new Set() };
27578
+ sharedBatchStores.set(diagnostics, store);
27467
27579
  }
27468
27580
  return store;
27469
27581
  }
27582
+ function createConnectionUpdates(document2, messages, signal, onChange, diagnostics = null) {
27583
+ const store = getBatchStore(diagnostics);
27584
+ const notify2 = () => {
27585
+ for (const listener of [...store.listeners]) listener();
27586
+ };
27587
+ if (!signal.aborted) {
27588
+ const listener = () => {
27589
+ if (!signal.aborted) onChange();
27590
+ };
27591
+ store.listeners.add(listener);
27592
+ signal.addEventListener(
27593
+ "abort",
27594
+ () => {
27595
+ store.listeners.delete(listener);
27596
+ },
27597
+ { once: true }
27598
+ );
27599
+ }
27600
+ const eligible = (panels) => panels.filter((panel) => panel.state?.updateAvailable && panel.state.canUpdate);
27601
+ const start = async (hostId2, panels) => {
27602
+ if (signal.aborted || store.batches.get(hostId2)?.running) return;
27603
+ const targets = eligible(panels);
27604
+ if (!targets.length) return;
27605
+ const batch = { running: true, total: targets.length, succeeded: 0, failed: 0 };
27606
+ store.batches.set(hostId2, batch);
27607
+ notify2();
27608
+ await Promise.all(
27609
+ targets.map(async (panel) => {
27610
+ try {
27611
+ if (await panel.update()) batch.succeeded++;
27612
+ else batch.failed++;
27613
+ } catch {
27614
+ batch.failed++;
27615
+ }
27616
+ notify2();
27617
+ })
27618
+ );
27619
+ batch.running = false;
27620
+ notify2();
27621
+ };
27622
+ return {
27623
+ createControls(hostId2, panels) {
27624
+ let currentHostId = hostId2;
27625
+ let currentPanels = panels;
27626
+ let renderedLabel = null;
27627
+ const button2 = document2.createElement("button");
27628
+ button2.type = "button";
27629
+ button2.className = "settings-command-button settings-command-button--secondary settings-connection-update-all";
27630
+ button2.dataset.connectionAction = "update-all";
27631
+ button2.title = messages.harnessUpdateAllDescription;
27632
+ button2.addEventListener("click", () => {
27633
+ if (!button2.disabled) void start(currentHostId, currentPanels);
27634
+ });
27635
+ const result = document2.createElement("p");
27636
+ result.className = "settings-connection-update-result";
27637
+ result.setAttribute("role", "status");
27638
+ const update = (nextHostId, nextPanels) => {
27639
+ currentHostId = nextHostId;
27640
+ currentPanels = nextPanels;
27641
+ const batch = store.batches.get(nextHostId);
27642
+ const count3 = eligible(nextPanels).length;
27643
+ button2.disabled = signal.aborted || Boolean(batch?.running) || !count3;
27644
+ const label = batch?.running ? `${messages.harnessUpdateAllProgress} ${batch.succeeded + batch.failed}/${batch.total}` : count3 ? `${messages.harnessUpdateAll} (${count3})` : messages.harnessUpdateAll;
27645
+ if (renderedLabel !== label) {
27646
+ renderedLabel = label;
27647
+ button2.replaceChildren(createRendererSettingsIcon("download", 15), label);
27648
+ }
27649
+ const hidden = !batch || batch.running;
27650
+ result.hidden = hidden;
27651
+ const resultText = batch && !batch.running ? messages.harnessUpdateAllResult.replace("{succeeded}", String(batch.succeeded)).replace("{failed}", String(batch.failed)) : "";
27652
+ if (result.textContent !== resultText) {
27653
+ result.textContent = resultText;
27654
+ }
27655
+ };
27656
+ update(hostId2, panels);
27657
+ return { button: button2, result, update };
27658
+ }
27659
+ };
27660
+ }
27470
27661
 
27471
27662
  // src/settings/harness-version-panel.ts
27472
- function createHarnessVersionPanel(document2, messages, signal, agent, client, onChange = () => void 0) {
27663
+ function isUnsupportedInstallationError(error51) {
27664
+ return typeof error51 === "object" && error51 !== null && "code" in error51 && (error51.code === -32601 || error51.code === -32078);
27665
+ }
27666
+ function createHarnessVersionSession(client, options) {
27667
+ let state;
27668
+ let statusKind = "checking";
27669
+ let checkPromise = null;
27670
+ let updatePromise = null;
27671
+ const listeners = /* @__PURE__ */ new Set();
27672
+ const signal = options?.signal;
27673
+ const notify2 = (pageChange) => {
27674
+ if (signal?.aborted) return;
27675
+ for (const listener of [...listeners]) listener(pageChange);
27676
+ };
27677
+ const check2 = () => {
27678
+ if (signal?.aborted || updatePromise) return Promise.resolve();
27679
+ if (checkPromise) return checkPromise;
27680
+ statusKind = "checking";
27681
+ notify2(false);
27682
+ checkPromise = (async () => {
27683
+ try {
27684
+ const result = await client.run("check");
27685
+ if (signal?.aborted || updatePromise) return;
27686
+ state = result;
27687
+ statusKind = "idle";
27688
+ } catch (error51) {
27689
+ if (signal?.aborted || updatePromise) return;
27690
+ statusKind = isUnsupportedInstallationError(error51) ? "unsupported" : "failed";
27691
+ if (state) state = { ...state, canUpdate: false };
27692
+ } finally {
27693
+ checkPromise = null;
27694
+ if (!signal?.aborted && !updatePromise) {
27695
+ notify2(true);
27696
+ }
27697
+ }
27698
+ })();
27699
+ return checkPromise;
27700
+ };
27701
+ const update = () => {
27702
+ if (updatePromise) return updatePromise;
27703
+ updatePromise = (async () => {
27704
+ if (signal?.aborted) return false;
27705
+ if (checkPromise) await checkPromise;
27706
+ if (signal?.aborted || statusKind === "unsupported" || !state?.canUpdate || !state.updateAvailable) {
27707
+ return false;
27708
+ }
27709
+ statusKind = "updating";
27710
+ notify2(true);
27711
+ try {
27712
+ const result = await client.run("update");
27713
+ if (signal?.aborted) return false;
27714
+ state = result;
27715
+ statusKind = !result.canUpdate ? "updated" : result.updateAvailable ? "failed" : "updated";
27716
+ return result.canUpdate && !result.updateAvailable;
27717
+ } catch (error51) {
27718
+ if (signal?.aborted) return false;
27719
+ statusKind = isUnsupportedInstallationError(error51) ? "unsupported" : "failed";
27720
+ if (state) state = { ...state, canUpdate: false };
27721
+ return false;
27722
+ } finally {
27723
+ updatePromise = null;
27724
+ if (!signal?.aborted) {
27725
+ notify2(true);
27726
+ }
27727
+ }
27728
+ })();
27729
+ return updatePromise;
27730
+ };
27731
+ return {
27732
+ get state() {
27733
+ return state;
27734
+ },
27735
+ get statusKind() {
27736
+ return statusKind;
27737
+ },
27738
+ get updating() {
27739
+ return statusKind === "updating";
27740
+ },
27741
+ prepareMount() {
27742
+ if (updatePromise || checkPromise) return false;
27743
+ statusKind = "checking";
27744
+ return true;
27745
+ },
27746
+ check: check2,
27747
+ update,
27748
+ subscribe(listener) {
27749
+ listeners.add(listener);
27750
+ return () => {
27751
+ listeners.delete(listener);
27752
+ };
27753
+ }
27754
+ };
27755
+ }
27756
+ function createHarnessVersionPanel(document2, messages, signal, agent, client, onChange = () => void 0, sharedSession) {
27757
+ const session = sharedSession ?? createHarnessVersionSession(client, { signal });
27758
+ const shouldScheduleCheck = session.prepareMount();
27473
27759
  const panel = document2.createElement("section");
27474
27760
  panel.className = "settings-harness-version";
27475
27761
  panel.dataset.harnessVersion = agent;
@@ -27493,15 +27779,14 @@ ${detail}` : ""}`
27493
27779
  note.textContent = messages.harnessVersionNote;
27494
27780
  actions.append(update);
27495
27781
  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
27782
  const render = () => {
27783
+ const state = session.state;
27784
+ const statusKind = session.statusKind;
27785
+ const busy = statusKind === "checking" || statusKind === "updating";
27502
27786
  heading.textContent = state?.versionKind === "application" ? messages.harnessVersionApplicationTitle : messages.harnessVersionTitle;
27503
27787
  current.textContent = `${messages.harnessVersionCurrent}: ${state?.currentVersion ?? "\u2014"}`;
27504
27788
  latest.textContent = `${messages.harnessVersionLatest}: ${harnessVersionLabel(state, messages.harnessVersion)}`;
27789
+ 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
27790
  update.disabled = busy || signal.aborted || !state?.canUpdate || !state.updateAvailable;
27506
27791
  const manualUrl = !state?.canUpdate && state?.updateAvailable ? state.manualUpdateUrl : void 0;
27507
27792
  actions.replaceChildren(update);
@@ -27520,99 +27805,92 @@ ${detail}` : ""}`
27520
27805
  const detail = harnessVersionNote(state, messages.harnessVersion);
27521
27806
  note.textContent = detail ? !state?.canUpdate ? detail : `${detail} ${messages.harnessVersionNote}` : messages.harnessVersionNote;
27522
27807
  };
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;
27808
+ update.addEventListener("click", () => {
27809
+ if (!signal.aborted) void session.update();
27810
+ });
27811
+ const unsubscribe = session.subscribe((pageChange) => {
27812
+ if (signal.aborted) return;
27530
27813
  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());
27814
+ if (pageChange) onChange();
27815
+ });
27559
27816
  const owner = document2.defaultView;
27560
27817
  let checkFrame = null;
27561
27818
  let checkTimer = null;
27562
27819
  signal.addEventListener(
27563
27820
  "abort",
27564
27821
  () => {
27822
+ unsubscribe();
27565
27823
  if (checkFrame !== null) owner?.cancelAnimationFrame(checkFrame);
27566
27824
  if (checkTimer !== null) owner?.clearTimeout(checkTimer);
27567
27825
  render();
27568
27826
  },
27569
27827
  { once: true }
27570
27828
  );
27571
- status.textContent = messages.harnessVersionChecking;
27572
27829
  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");
27830
+ if (shouldScheduleCheck && !signal.aborted) {
27831
+ if (owner?.requestAnimationFrame) {
27832
+ checkFrame = owner.requestAnimationFrame(() => {
27833
+ checkFrame = null;
27834
+ if (signal.aborted) return;
27835
+ checkTimer = owner.setTimeout(() => {
27836
+ checkTimer = null;
27837
+ if (!signal.aborted) void session.check();
27838
+ }, 0);
27839
+ });
27840
+ } else {
27841
+ void session.check();
27842
+ }
27584
27843
  }
27585
27844
  return {
27586
27845
  element: panel,
27587
27846
  get state() {
27588
- return state;
27847
+ return session.state;
27589
27848
  },
27590
27849
  get updating() {
27591
- return updating;
27850
+ return session.updating;
27592
27851
  },
27593
- update: updateVersion
27852
+ update: () => signal.aborted ? Promise.resolve(false) : session.update()
27594
27853
  };
27595
27854
  }
27596
27855
 
27597
27856
  // src/settings/connection-versions.ts
27857
+ var sessionStores = /* @__PURE__ */ new WeakMap();
27858
+ function getSessionStore(diagnostics) {
27859
+ let store = sessionStores.get(diagnostics);
27860
+ if (!store) {
27861
+ store = /* @__PURE__ */ new Map();
27862
+ sessionStores.set(diagnostics, store);
27863
+ }
27864
+ return store;
27865
+ }
27598
27866
  function createConnectionVersions(document2, messages, signal, diagnostics, onChange) {
27599
27867
  const panels = /* @__PURE__ */ new Map();
27600
27868
  const installation = diagnostics?.installation?.bind(diagnostics);
27869
+ const sessions = diagnostics ? getSessionStore(diagnostics) : null;
27870
+ const sessionKey = (hostId2, agent) => JSON.stringify([hostId2, agent]);
27601
27871
  return {
27872
+ isUpdating(hostId2, agent) {
27873
+ return Boolean(sessions?.get(sessionKey(hostId2, agent))?.updating);
27874
+ },
27602
27875
  get(hostId2, agent) {
27603
27876
  if (!installation || signal.aborted) return void 0;
27604
- const key = JSON.stringify([hostId2, agent]);
27877
+ const key = sessionKey(hostId2, agent);
27605
27878
  let panel = panels.get(key);
27606
27879
  if (!panel) {
27880
+ const run = (action) => installation(hostId2, agent, action);
27881
+ let session = sessions?.get(key);
27882
+ if (!session) {
27883
+ session = createHarnessVersionSession({ run });
27884
+ sessions?.set(key, session);
27885
+ }
27607
27886
  panel = createHarnessVersionPanel(
27608
27887
  document2,
27609
27888
  messages,
27610
27889
  signal,
27611
27890
  agent,
27612
- {
27613
- run: (action) => installation(hostId2, agent, action)
27614
- },
27615
- onChange
27891
+ { run },
27892
+ onChange,
27893
+ session
27616
27894
  );
27617
27895
  panels.set(key, panel);
27618
27896
  }
@@ -27621,79 +27899,242 @@ ${detail}` : ""}`
27621
27899
  };
27622
27900
  }
27623
27901
 
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();
27902
+ // src/settings/harness-install-store.ts
27903
+ function errorMessage2(error51) {
27904
+ 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.";
27905
+ }
27906
+ function unknownInstallOutcome(message2) {
27907
+ return /outcome is unknown|do not retry automatically|did not answer in time/i.test(message2);
27908
+ }
27909
+ var stores = /* @__PURE__ */ new WeakMap();
27910
+ function createStore(diagnostics) {
27911
+ const states2 = /* @__PURE__ */ new Map();
27912
+ const listeners = /* @__PURE__ */ new Set();
27913
+ const key = (host, agent) => JSON.stringify([host, agent]);
27914
+ const notify2 = () => listeners.forEach((listener) => listener());
27915
+ return {
27916
+ get: (host, agent) => states2.get(key(host, agent)),
27917
+ clearErrors() {
27918
+ for (const [id, state] of states2) if (state.status === "error") states2.delete(id);
27919
+ notify2();
27920
+ },
27921
+ subscribe(listener) {
27922
+ listeners.add(listener);
27923
+ return () => {
27924
+ listeners.delete(listener);
27925
+ };
27926
+ },
27927
+ async install(host, agent) {
27928
+ const id = key(host, agent);
27929
+ const previous = states2.get(id);
27930
+ if (!diagnostics.installation || previous && previous.status !== "error") return;
27931
+ states2.set(id, { status: "installing" });
27932
+ notify2();
27933
+ let failure;
27934
+ try {
27935
+ await diagnostics.installation(host, agent, "install");
27936
+ states2.set(id, { status: "checking" });
27937
+ notify2();
27938
+ } catch (error51) {
27939
+ failure = errorMessage2(error51);
27940
+ }
27941
+ try {
27942
+ await diagnostics.refresh(host);
27943
+ const refreshed = diagnostics.snapshot().hosts.find((candidate) => candidate.hostId === host)?.agents.find((candidate) => candidate.agent === agent);
27944
+ if (refreshed?.availability === "ready") failure = void 0;
27945
+ else if (failure && unknownInstallOutcome(failure) && refreshed && refreshed.availability !== "notInstalled") {
27946
+ failure = void 0;
27947
+ }
27948
+ } catch (error51) {
27949
+ failure ??= errorMessage2(error51);
27950
+ }
27951
+ if (failure) states2.set(id, { status: "error", error: failure });
27952
+ else states2.delete(id);
27953
+ notify2();
27954
+ }
27955
+ };
27956
+ }
27957
+ function harnessInstallStore(diagnostics) {
27958
+ let store = stores.get(diagnostics);
27959
+ if (!store) {
27960
+ store = createStore(diagnostics);
27961
+ stores.set(diagnostics, store);
27962
+ }
27963
+ return store;
27964
+ }
27965
+
27966
+ // src/settings/harness-installation-guides.ts
27967
+ function harnessHasInstallCommands(plugin) {
27968
+ return (plugin?.installation?.commands.length ?? 0) > 0;
27969
+ }
27970
+ function harnessInstallationGuide(plugin, locale) {
27971
+ const guide = plugin?.installation;
27972
+ const text = (value) => value?.[locale] ?? value?.en;
27973
+ return {
27974
+ url: plugin?.links?.installation ?? plugin?.links?.documentation ?? plugin?.links?.website,
27975
+ commands: guide?.commands ?? [],
27976
+ downloads: guide?.downloads ?? [],
27977
+ before: text(guide?.before),
27978
+ after: text(guide?.after)
27979
+ };
27980
+ }
27981
+
27982
+ // src/settings/harness-installation-panel.ts
27983
+ function createHarnessInstallationPanel(document2, plugin, hostId2, messages, copy, installation) {
27984
+ const zh = messages.locale === "zh-CN";
27985
+ const guide = harnessInstallationGuide(plugin, messages.locale);
27986
+ const panel = document2.createElement("div");
27987
+ panel.className = "settings-harness-installation";
27988
+ const paragraph = (text) => {
27989
+ const p = document2.createElement("p");
27990
+ p.textContent = text;
27991
+ panel.append(p);
27992
+ };
27993
+ if (hostId2 !== "local") {
27994
+ paragraph(zh ? "\u8BF7\u5728\u8FDC\u7A0B Host \u4E0A\u5B89\u88C5\u3002" : "Install on the remote Host.");
27995
+ }
27996
+ if (guide.before) paragraph(guide.before);
27997
+ const install = installation && guide.commands.length > 0 ? document2.createElement("button") : null;
27998
+ if (install && installation) {
27999
+ install.type = "button";
28000
+ install.className = "settings-command-button";
28001
+ install.dataset.connectionAction = "install";
28002
+ install.disabled = installation.status !== "idle";
28003
+ install.textContent = installation.status === "installing" ? messages.connectionStatusInstalling : installation.status === "checking" ? messages.connectionStatusChecking : zh ? "\u4E00\u952E\u5B89\u88C5" : "Install automatically";
28004
+ install.addEventListener("click", () => {
28005
+ if (install.disabled) return;
28006
+ install.disabled = true;
28007
+ install.textContent = messages.connectionStatusInstalling;
28008
+ installation.run();
28009
+ });
28010
+ if (guide.commands.length > 1) panel.append(install);
28011
+ }
28012
+ for (const { terminal, command } of guide.commands) {
28013
+ const block = document2.createElement("div");
28014
+ block.className = "settings-harness-installation-command";
28015
+ const label = document2.createElement("strong");
28016
+ label.textContent = terminal;
28017
+ const pre = document2.createElement("pre");
28018
+ const code = document2.createElement("code");
28019
+ code.textContent = command;
28020
+ pre.append(code);
28021
+ const button2 = document2.createElement("button");
28022
+ button2.type = "button";
28023
+ button2.className = "settings-command-button settings-command-button--secondary";
28024
+ button2.dataset.connectionAction = "copy-install";
28025
+ const copyLabel = zh ? "\u590D\u5236\u547D\u4EE4" : "Copy command";
28026
+ button2.setAttribute("aria-label", `${copyLabel}: ${terminal}`);
28027
+ button2.append(createRendererSettingsIcon("copy", 16), copyLabel);
28028
+ button2.addEventListener("click", () => copy(button2, command, copyLabel));
28029
+ const actions = document2.createElement("div");
28030
+ actions.className = "settings-harness-installation-actions";
28031
+ if (install && guide.commands.length === 1) actions.append(install);
28032
+ actions.append(button2);
28033
+ block.append(label, pre, actions);
28034
+ panel.append(block);
28035
+ }
28036
+ for (const download2 of guide.downloads ?? []) {
28037
+ const link = document2.createElement("a");
28038
+ link.className = "settings-command-button settings-command-button--secondary";
28039
+ link.href = download2.url;
28040
+ link.target = "_blank";
28041
+ link.rel = "noopener noreferrer";
28042
+ link.textContent = zh ? "\u4E0B\u8F7D" : "Download";
28043
+ link.setAttribute("aria-label", `${link.textContent} ${download2.label}`);
28044
+ panel.append(link);
28045
+ }
28046
+ if (guide.after) paragraph(guide.after);
28047
+ if (!plugin?.installation && guide.url) {
28048
+ const link = document2.createElement("a");
28049
+ link.href = guide.url;
28050
+ link.target = "_blank";
28051
+ link.rel = "noopener noreferrer";
28052
+ link.textContent = zh ? "\u5B89\u88C5\u8BF4\u660E" : "Installation instructions";
28053
+ panel.append(link);
28054
+ }
28055
+ return panel;
28056
+ }
28057
+
28058
+ // src/settings/harness-launch-controls.ts
28059
+ function createHarnessLaunchControls(document2, messages, agent, settings) {
28060
+ const section = document2.createElement("section");
28061
+ section.className = "settings-harness-launch";
28062
+ section.dataset.harnessLaunch = agent;
28063
+ const label = document2.createElement("label");
28064
+ label.textContent = messages.launchPathLabel;
28065
+ const input = document2.createElement("input");
28066
+ input.type = "text";
28067
+ input.autocomplete = "off";
28068
+ input.spellcheck = false;
28069
+ input.placeholder = messages.locale === "zh-CN" ? "\u5E94\u7528\u5B89\u88C5\u76EE\u5F55\u7684\u7EDD\u5BF9\u8DEF\u5F84" : "Absolute installation directory";
28070
+ input.setAttribute("aria-label", messages.launchPathLabel);
28071
+ label.append(input);
28072
+ const help = document2.createElement("p");
28073
+ 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.";
28074
+ const actions = document2.createElement("div");
28075
+ actions.className = "settings-harness-launch__actions";
28076
+ const save = document2.createElement("button");
28077
+ save.type = "button";
28078
+ save.className = "settings-command-button";
28079
+ save.textContent = messages.launchPathSave;
28080
+ const reset = document2.createElement("button");
28081
+ reset.type = "button";
28082
+ reset.className = "settings-command-button settings-command-button--secondary";
28083
+ reset.textContent = messages.launchPathReset;
28084
+ const status = document2.createElement("p");
28085
+ status.setAttribute("role", "status");
28086
+ status.setAttribute("aria-live", "polite");
28087
+ actions.append(save, reset);
28088
+ section.append(label, help, actions, status);
28089
+ let busy = true;
28090
+ let loaded = false;
28091
+ const controls = () => {
28092
+ input.disabled = busy || !loaded;
28093
+ save.disabled = busy || !loaded || !input.value.trim();
28094
+ reset.disabled = busy || !loaded;
27648
28095
  };
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 };
28096
+ const show = (value) => {
28097
+ input.value = value.path ?? "";
28098
+ status.textContent = value.restartRequired ? messages.launchPathRestart : value.path ? messages.launchPathSaved : messages.launchPathAutomatic;
28099
+ };
28100
+ const persist = async (value) => {
28101
+ if (busy || !loaded) return;
28102
+ busy = true;
28103
+ controls();
28104
+ status.textContent = messages.launchPathSaving;
28105
+ try {
28106
+ show(await settings.set(value));
28107
+ } catch {
28108
+ status.textContent = messages.launchPathSaveError;
28109
+ } finally {
28110
+ busy = false;
28111
+ controls();
27672
28112
  }
27673
28113
  };
28114
+ input.addEventListener("input", controls);
28115
+ save.addEventListener("click", () => {
28116
+ if (input.value.trim()) void persist(input.value.trim());
28117
+ });
28118
+ reset.addEventListener("click", () => {
28119
+ void persist(null);
28120
+ });
28121
+ controls();
28122
+ status.textContent = messages.launchPathLoading;
28123
+ void settings.get().then((value) => {
28124
+ loaded = true;
28125
+ show(value);
28126
+ }).catch(() => {
28127
+ loaded = true;
28128
+ status.textContent = messages.launchPathLoadError;
28129
+ }).finally(() => {
28130
+ busy = false;
28131
+ controls();
28132
+ });
28133
+ return section;
27674
28134
  }
27675
28135
 
27676
28136
  // src/settings/connections-page.ts
27677
28137
  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
28138
  function diagnosticText(hostId2, item) {
27698
28139
  const error51 = item.error;
27699
28140
  return [
@@ -27789,148 +28230,21 @@ ${error51.stderrTail}`] : []
27789
28230
  tabs.addEventListener("wheel", onWheel, { passive: false });
27790
28231
  const ownerWindow = document2.defaultView;
27791
28232
  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);
28233
+ const refreshLayout = () => {
28234
+ ownerWindow?.setTimeout(updateButtons, 0);
28235
+ updateButtons();
28236
+ };
28237
+ refreshLayout();
28238
+ return {
28239
+ update: refreshLayout,
28240
+ dispose() {
28241
+ left.removeEventListener("click", onLeft);
28242
+ right.removeEventListener("click", onRight);
28243
+ tabs.removeEventListener("scroll", updateButtons);
28244
+ tabs.removeEventListener("wheel", onWheel);
28245
+ ownerWindow?.removeEventListener("resize", updateButtons);
28246
+ }
27800
28247
  };
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
28248
  }
27935
28249
  function createInspectorHeader(document2, item, messages) {
27936
28250
  const header = document2.createElement("header");
@@ -27960,6 +28274,29 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
27960
28274
  header.append(identity2, status);
27961
28275
  return header;
27962
28276
  }
28277
+ function inspectorRenderSignature(hostId2, item, messages, diagnostics) {
28278
+ const plugin = item.agentSnapshot?.plugin;
28279
+ const notice = plugin?.notice ? plugin.notice[messages.locale] ?? plugin.notice.en : "";
28280
+ const websiteUrl = plugin?.links?.website ?? plugin?.links?.documentation ?? "";
28281
+ const hasLaunchControls = hostId2 === "local" && Boolean(item.agentSnapshot?.agent) && Boolean(plugin?.launchCommand) && Boolean(diagnostics?.getLaunchSettings && diagnostics?.setLaunchSettings);
28282
+ return JSON.stringify([
28283
+ hostId2,
28284
+ item.key,
28285
+ item.name,
28286
+ item.availability,
28287
+ item.agentSnapshot?.availability ?? null,
28288
+ String(plugin?.icon ?? ""),
28289
+ String(plugin?.iconStyle ?? ""),
28290
+ websiteUrl,
28291
+ notice,
28292
+ item.installError ?? "",
28293
+ Boolean(item.install),
28294
+ plugin?.installation ?? null,
28295
+ Boolean(item.openWebUi),
28296
+ hasLaunchControls,
28297
+ item.error ? diagnosticText(hostId2, item) : ""
28298
+ ]);
28299
+ }
27963
28300
  function renderConnectionInspector(document2, inspector, item, hostId2, messages, diagnostics, existingLaunchControls, refresh) {
27964
28301
  inspector.replaceChildren(createInspectorHeader(document2, item, messages));
27965
28302
  const body = document2.createElement("div");
@@ -28122,11 +28459,10 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28122
28459
  ];
28123
28460
  }
28124
28461
  var pendingFocusAgent = null;
28125
- function createGroupDivider(document2, messages, count3) {
28462
+ function createGroupDivider(document2) {
28126
28463
  const divider = document2.createElement("div");
28127
28464
  divider.className = "settings-connection-group-divider";
28128
28465
  divider.setAttribute("role", "presentation");
28129
- divider.textContent = `${messages.connectionGroupMoreLabel} (${count3})`;
28130
28466
  return divider;
28131
28467
  }
28132
28468
  function createGroupMoreHint(document2, messages) {
@@ -28179,11 +28515,13 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28179
28515
  context.content.append(header, syncMessage, content);
28180
28516
  let pending = false;
28181
28517
  let selectedHostId = null;
28518
+ let renderedHostId = null;
28182
28519
  let selectedItemKey = null;
28183
28520
  let launchControls = null;
28521
+ let renderedInspector = null;
28184
28522
  const hostNames = /* @__PURE__ */ new Map();
28523
+ const knownNotInstalled = /* @__PURE__ */ new Map();
28185
28524
  let latestSnapshot = null;
28186
- let disposeHostScroller = () => void 0;
28187
28525
  let disposed = false;
28188
28526
  let renderQueued = false;
28189
28527
  let renderFrame = null;
@@ -28217,7 +28555,99 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28217
28555
  scheduleRender
28218
28556
  );
28219
28557
  const installs = diagnostics ? harnessInstallStore(diagnostics) : null;
28220
- const updates = createConnectionUpdates(document2, messages, context.signal, scheduleRender);
28558
+ const updates = createConnectionUpdates(
28559
+ document2,
28560
+ messages,
28561
+ context.signal,
28562
+ scheduleRender,
28563
+ diagnostics
28564
+ );
28565
+ const panelId = "codexhost-settings-connection-host-panel";
28566
+ const empty = document2.createElement("div");
28567
+ empty.className = "settings-empty";
28568
+ empty.textContent = messages.connectionNoRuntime;
28569
+ const layout = document2.createElement("div");
28570
+ layout.className = "settings-connections-layout";
28571
+ const list = document2.createElement("section");
28572
+ list.className = "settings-connection-list";
28573
+ const hostStrip = document2.createElement("div");
28574
+ hostStrip.className = "settings-connection-host-strip";
28575
+ const scrollLeft = createHostScrollButton(document2, "left", messages);
28576
+ const tabs = document2.createElement("div");
28577
+ tabs.className = "settings-connection-host-tabs";
28578
+ tabs.setAttribute("role", "tablist");
28579
+ tabs.setAttribute("aria-label", messages.connectionHosts);
28580
+ const scrollRight = createHostScrollButton(document2, "right", messages);
28581
+ hostStrip.append(scrollLeft, tabs, scrollRight);
28582
+ const updateControls = updates.createControls("local", []);
28583
+ const hostHeader = document2.createElement("div");
28584
+ hostHeader.className = "settings-connection-host-header";
28585
+ hostHeader.append(hostStrip, updateControls.button);
28586
+ const tableHeader = document2.createElement("div");
28587
+ tableHeader.className = "settings-connection-table-header";
28588
+ tableHeader.setAttribute("role", "row");
28589
+ const componentHeading = document2.createElement("span");
28590
+ componentHeading.textContent = messages.connectionComponent;
28591
+ componentHeading.setAttribute("role", "columnheader");
28592
+ const statusHeading = document2.createElement("span");
28593
+ statusHeading.textContent = messages.connectionStatus;
28594
+ statusHeading.setAttribute("role", "columnheader");
28595
+ const actionHeading = document2.createElement("span");
28596
+ actionHeading.setAttribute("aria-hidden", "true");
28597
+ tableHeader.append(componentHeading, statusHeading, actionHeading);
28598
+ const rows = document2.createElement("div");
28599
+ rows.className = "settings-connection-rows";
28600
+ rows.id = panelId;
28601
+ rows.setAttribute("role", "rowgroup");
28602
+ list.append(hostHeader, updateControls.result, tableHeader, rows);
28603
+ const inspector = document2.createElement("aside");
28604
+ inspector.className = "settings-connection-inspector";
28605
+ inspector.setAttribute("aria-live", "polite");
28606
+ layout.append(list, inspector);
28607
+ const hostScroller = configureHostScroller(
28608
+ document2,
28609
+ hostStrip,
28610
+ tabs,
28611
+ scrollLeft,
28612
+ scrollRight
28613
+ );
28614
+ const hostTabElements = /* @__PURE__ */ new Map();
28615
+ const hostRowViews = /* @__PURE__ */ new Map();
28616
+ const groupDivider = createGroupDivider(document2);
28617
+ const moreHint = createGroupMoreHint(document2, messages);
28618
+ const moreZone = document2.createElement("div");
28619
+ moreZone.className = "settings-connection-group-more";
28620
+ moreZone.setAttribute("role", "presentation");
28621
+ const resetButton = createGroupResetButton(document2, messages, () => {
28622
+ groupPreference.resetToDefault();
28623
+ });
28624
+ let draggingAgent = null;
28625
+ let currentCatalog = [];
28626
+ let currentMainEntries = [];
28627
+ let currentMoreEntries = [];
28628
+ let currentHostRows = /* @__PURE__ */ new Map();
28629
+ const clearDropIndicators = () => {
28630
+ for (const view of currentHostRows.values()) {
28631
+ view.element.dataset.connectionDropIndicator = "";
28632
+ }
28633
+ moreZone.dataset.connectionDragOver = "false";
28634
+ };
28635
+ moreZone.addEventListener("dragover", (event) => {
28636
+ if (!draggingAgent) return;
28637
+ event.preventDefault();
28638
+ moreZone.dataset.connectionDragOver = "true";
28639
+ });
28640
+ moreZone.addEventListener("dragleave", () => {
28641
+ moreZone.dataset.connectionDragOver = "false";
28642
+ });
28643
+ moreZone.addEventListener("drop", (event) => {
28644
+ event.preventDefault();
28645
+ moreZone.dataset.connectionDragOver = "false";
28646
+ if (!draggingAgent) return;
28647
+ groupPreference.moveAgent(draggingAgent, "more", null, currentCatalog);
28648
+ draggingAgent = null;
28649
+ clearDropIndicators();
28650
+ });
28221
28651
  const runRefresh = () => {
28222
28652
  if (pending || !diagnostics) return;
28223
28653
  pending = true;
@@ -28230,6 +28660,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28230
28660
  success() {
28231
28661
  installs?.clearErrors();
28232
28662
  pending = false;
28663
+ renderedInspector = null;
28233
28664
  refresh.disabled = false;
28234
28665
  refresh.replaceChildren(
28235
28666
  createRendererSettingsIcon("diagnose", 16),
@@ -28239,6 +28670,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28239
28670
  },
28240
28671
  failure(error51) {
28241
28672
  pending = false;
28673
+ renderedInspector = null;
28242
28674
  refresh.disabled = false;
28243
28675
  refresh.replaceChildren(
28244
28676
  createRendererSettingsIcon("diagnose", 16),
@@ -28264,97 +28696,111 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28264
28696
  }
28265
28697
  });
28266
28698
  };
28699
+ const syncSelectedInspector = (hostId2, item) => {
28700
+ const currentDiagnostics = getDiagnostics();
28701
+ const signature = inspectorRenderSignature(hostId2, item, messages, currentDiagnostics);
28702
+ const versionElement = item.version?.element ?? null;
28703
+ if (renderedInspector?.signature === signature && renderedInspector.versionElement === versionElement) {
28704
+ return;
28705
+ }
28706
+ const existing = launchControls?.hostId === hostId2 && launchControls.itemKey === item.key ? launchControls.element : null;
28707
+ const element = renderConnectionInspector(
28708
+ document2,
28709
+ inspector,
28710
+ item,
28711
+ hostId2,
28712
+ messages,
28713
+ currentDiagnostics,
28714
+ existing,
28715
+ runRefresh
28716
+ );
28717
+ launchControls = { hostId: hostId2, itemKey: item.key, element };
28718
+ if (versionElement) inspector.append(versionElement);
28719
+ renderedInspector = { signature, versionElement };
28720
+ };
28267
28721
  const render = (snapshot) => {
28268
28722
  const syncStatus = groupPreference.syncStatus();
28269
28723
  const groupDisabled = syncStatus === "loading" || syncStatus === "saving";
28270
28724
  syncMessage.hidden = syncStatus === "ready";
28271
28725
  syncMessage.textContent = syncStatus === "error" ? messages.connectionGroupSyncFailed : syncStatus === "saving" ? messages.connectionGroupSaving : messages.connectionGroupLoading;
28272
28726
  latestSnapshot = snapshot;
28273
- disposeHostScroller();
28274
- disposeHostScroller = () => void 0;
28275
28727
  if (!snapshot) {
28276
- const empty = document2.createElement("div");
28277
- empty.className = "settings-empty";
28278
- empty.textContent = messages.connectionNoRuntime;
28279
- content.replaceChildren(empty);
28728
+ renderedHostId = null;
28729
+ renderedInspector = null;
28730
+ reconcileElementChildren(content, [empty]);
28280
28731
  return;
28281
28732
  }
28282
28733
  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
28734
  if (!selectedHost) return;
28284
28735
  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;
28736
+ const layoutFirstMount = content.children[0] !== layout;
28737
+ reconcileElementChildren(content, [layout]);
28738
+ let tabsChanged = tabs.children.length !== snapshot.hosts.length;
28739
+ const nextTabs = snapshot.hosts.map((host) => {
28740
+ let tab = hostTabElements.get(host.hostId);
28741
+ if (!tab) {
28742
+ tab = document2.createElement("button");
28743
+ tab.type = "button";
28744
+ tab.className = "settings-connection-host-tab";
28745
+ tab.dataset.connectionHostTab = host.hostId;
28746
+ tab.setAttribute("role", "tab");
28747
+ tab.setAttribute("aria-controls", panelId);
28748
+ tab.addEventListener("click", () => {
28749
+ selectedHostId = host.hostId;
28750
+ render(latestSnapshot);
28751
+ });
28752
+ tab.addEventListener("keydown", (event) => {
28753
+ if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
28754
+ event.preventDefault();
28755
+ const hosts = latestSnapshot?.hosts ?? [];
28756
+ const index = hosts.findIndex((candidate) => candidate.hostId === host.hostId);
28757
+ if (index < 0) return;
28758
+ const direction = event.key === "ArrowRight" ? 1 : -1;
28759
+ const next = hosts[(index + direction + hosts.length) % hosts.length];
28760
+ if (!next) return;
28761
+ selectedHostId = next.hostId;
28762
+ render(latestSnapshot);
28763
+ hostTabElements.get(next.hostId)?.focus();
28764
+ });
28765
+ hostTabElements.set(host.hostId, tab);
28766
+ tabsChanged = true;
28767
+ }
28768
+ const isSelected = host.hostId === selectedHost.hostId;
28769
+ const activeValue = String(host.active);
28770
+ if (tab.dataset.connectionHostActive !== activeValue) {
28771
+ tab.dataset.connectionHostActive = activeValue;
28772
+ }
28773
+ const selectedValue = String(isSelected);
28774
+ if (tab.getAttribute("aria-selected") !== selectedValue) {
28775
+ tab.setAttribute("aria-selected", selectedValue);
28776
+ }
28777
+ const nextTabIndex = isSelected ? 0 : -1;
28778
+ if (tab.tabIndex !== nextTabIndex) {
28779
+ tab.tabIndex = nextTabIndex;
28780
+ }
28308
28781
  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);
28782
+ if (tab.textContent !== hostName) {
28783
+ tab.textContent = hostName;
28784
+ tabsChanged = true;
28785
+ }
28786
+ const tabTitle = host.active ? `${hostName} \xB7 ${messages.connectionActiveHost}` : hostName;
28787
+ if (tab.title !== tabTitle) {
28788
+ tab.title = tabTitle;
28789
+ }
28790
+ return tab;
28329
28791
  });
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");
28792
+ reconcileElementChildren(tabs, nextTabs);
28793
+ if (rows.dataset.connectionHost !== selectedHost.hostId) {
28794
+ rows.dataset.connectionHost = selectedHost.hostId;
28795
+ }
28351
28796
  const items = connectionItems(snapshot, selectedHost, messages, diagnostics).map(
28352
28797
  (item) => {
28353
28798
  const agent = item.agentSnapshot?.agent;
28354
28799
  if (!agent) return item;
28355
28800
  const state = installs?.get(selectedHost.hostId, agent);
28356
28801
  const availability = state?.status ?? item.availability;
28357
- const version2 = item.agentSnapshot?.availability !== "notInstalled" && availability !== "installing" && availability !== "checking" ? versions.get(selectedHost.hostId, agent) : void 0;
28802
+ const updating = versions.isUpdating(selectedHost.hostId, agent);
28803
+ const version2 = updating || item.agentSnapshot?.availability !== "notInstalled" && availability !== "installing" && availability !== "checking" ? versions.get(selectedHost.hostId, agent) : void 0;
28358
28804
  return {
28359
28805
  ...item,
28360
28806
  ...state ? { availability: state.status } : {},
@@ -28376,66 +28822,66 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28376
28822
  (item) => item.agentSnapshot?.availability === "notInstalled" || item.error !== null
28377
28823
  )?.key ?? items[0]?.key ?? null;
28378
28824
  }
28379
- const rowElements = /* @__PURE__ */ new Map();
28825
+ let hostRows = hostRowViews.get(selectedHost.hostId);
28826
+ if (!hostRows) {
28827
+ hostRows = /* @__PURE__ */ new Map();
28828
+ hostRowViews.set(selectedHost.hostId, hostRows);
28829
+ }
28830
+ currentHostRows = hostRows;
28380
28831
  const selectItem = (item) => {
28381
28832
  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;
28833
+ for (const [key, view] of currentHostRows) {
28834
+ view.setSelected(key === item.key);
28386
28835
  }
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);
28836
+ syncSelectedInspector(selectedHost.hostId, item);
28400
28837
  };
28401
- const pinnedItem = items.find((item) => item.key === "renderer-adapter");
28402
- if (pinnedItem) {
28403
- const row = createConnectionRow(
28404
- document2,
28838
+ const ensureRowView = (key, groupable) => {
28839
+ let view = hostRows.get(key);
28840
+ if (!view) {
28841
+ view = createConnectionRowView(document2, messages, groupable);
28842
+ hostRows.set(key, view);
28843
+ }
28844
+ return view;
28845
+ };
28846
+ const activeKeys = /* @__PURE__ */ new Set();
28847
+ const nextRowChildren = [];
28848
+ const pinnedItems = items.filter((item) => item.agentSnapshot === void 0);
28849
+ for (const pinnedItem of pinnedItems) {
28850
+ activeKeys.add(pinnedItem.key);
28851
+ const view = ensureRowView(pinnedItem.key, false);
28852
+ view.update(
28405
28853
  pinnedItem,
28406
- messages,
28407
28854
  pinnedItem.key === selectedItemKey,
28408
- () => selectItem(pinnedItem)
28855
+ () => selectItem(pinnedItem),
28856
+ null
28409
28857
  );
28410
- rowElements.set(pinnedItem.key, row);
28411
- rows.append(row);
28858
+ nextRowChildren.push(view.element);
28412
28859
  }
28413
28860
  const groupableItems = items.filter(
28414
28861
  (item) => item.agentSnapshot !== void 0
28415
28862
  );
28416
28863
  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");
28864
+ currentCatalog = groupableItems.map((item) => ({ id: item.key, name: item.name }));
28865
+ const notInstalledAgents = /* @__PURE__ */ new Set();
28866
+ for (const item of groupableItems) {
28867
+ const agent = item.agentSnapshot.agent;
28868
+ const stateKey = `${selectedHost.hostId}:${agent}`;
28869
+ if (item.agentSnapshot.availability !== "checking") {
28870
+ knownNotInstalled.set(stateKey, item.agentSnapshot.availability === "notInstalled");
28871
+ }
28872
+ const isNotInstalled = item.agentSnapshot.availability === "checking" ? knownNotInstalled.get(stateKey) ?? false : item.agentSnapshot.availability === "notInstalled";
28873
+ if (isNotInstalled) notInstalledAgents.add(agent);
28874
+ }
28875
+ const preferenceOrder = groupPreference.list(notInstalledAgents, currentCatalog).filter((entry) => agentByKey.has(entry.agent));
28876
+ currentMainEntries = preferenceOrder.filter((entry) => entry.section === "main");
28877
+ currentMoreEntries = preferenceOrder.filter((entry) => entry.section === "more");
28426
28878
  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";
28879
+ const sectionEntries = section === "main" ? currentMainEntries : currentMoreEntries;
28880
+ const index = sectionEntries.findIndex((entry) => entry.agent === agent);
28881
+ return index >= 0 ? sectionEntries[index + 1]?.agent ?? null : null;
28436
28882
  };
28437
28883
  const dropTargetSection = (agent, event) => {
28438
- const row = rowElements.get(agent);
28884
+ const row = currentHostRows.get(agent)?.element;
28439
28885
  const rect = row && typeof row.getBoundingClientRect === "function" ? row.getBoundingClientRect() : null;
28440
28886
  const before = rect ? event.clientY - rect.top < rect.height / 2 : true;
28441
28887
  const section = row?.dataset.connectionGroupSection ?? "main";
@@ -28447,7 +28893,12 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28447
28893
  moveLabel: section === "main" ? messages.connectionGroupMoveToMore : messages.connectionGroupMoveToMain,
28448
28894
  dragHandleTitle: messages.connectionGroupDragHandle,
28449
28895
  toggleSection() {
28450
- groupPreference.moveAgent(agent, section === "main" ? "more" : "main", null, catalog);
28896
+ groupPreference.moveAgent(
28897
+ agent,
28898
+ section === "main" ? "more" : "main",
28899
+ null,
28900
+ currentCatalog
28901
+ );
28451
28902
  },
28452
28903
  onDragStart(event) {
28453
28904
  if (groupDisabled) {
@@ -28457,127 +28908,107 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28457
28908
  draggingAgent = agent;
28458
28909
  event.dataTransfer?.setData("text/plain", agent);
28459
28910
  if (event.dataTransfer) event.dataTransfer.effectAllowed = "move";
28460
- const row = rowElements.get(agent);
28911
+ const row = currentHostRows.get(agent)?.element;
28461
28912
  if (row) row.dataset.connectionDragging = "true";
28462
28913
  },
28463
28914
  onDragOver(event) {
28464
28915
  if (!draggingAgent || draggingAgent === agent) return;
28465
28916
  event.preventDefault();
28466
- const row = rowElements.get(agent);
28917
+ const row = currentHostRows.get(agent)?.element;
28467
28918
  if (!row) return;
28468
28919
  const { before } = dropTargetSection(agent, event);
28469
28920
  clearDropIndicators();
28470
28921
  row.dataset.connectionDropIndicator = before ? "before" : "after";
28471
28922
  },
28472
28923
  onDragLeave() {
28473
- const row = rowElements.get(agent);
28924
+ const row = currentHostRows.get(agent)?.element;
28474
28925
  if (row) row.dataset.connectionDropIndicator = "";
28475
28926
  },
28476
28927
  onDrop(event) {
28477
28928
  event.preventDefault();
28478
28929
  if (!draggingAgent) return;
28479
28930
  const { beforeAgent } = dropTargetSection(agent, event);
28480
- groupPreference.moveAgent(draggingAgent, section, beforeAgent, catalog);
28931
+ groupPreference.moveAgent(draggingAgent, section, beforeAgent, currentCatalog);
28481
28932
  draggingAgent = null;
28482
28933
  clearDropIndicators();
28483
28934
  },
28484
28935
  onDragEnd() {
28485
28936
  draggingAgent = null;
28486
- const row = rowElements.get(agent);
28937
+ const row = currentHostRows.get(agent)?.element;
28487
28938
  if (row) row.dataset.connectionDragging = "false";
28488
28939
  clearDropIndicators();
28940
+ scheduleRender();
28489
28941
  }
28490
28942
  });
28491
- const appendGroupRow = (agent, section) => {
28492
- const item = agentByKey.get(agent);
28493
- if (!item) return;
28494
- const row = createConnectionRow(
28495
- document2,
28943
+ for (const entry of currentMainEntries) {
28944
+ const item = agentByKey.get(entry.agent);
28945
+ if (!item) continue;
28946
+ activeKeys.add(item.key);
28947
+ const view = ensureRowView(item.key, true);
28948
+ view.update(
28496
28949
  item,
28497
- messages,
28498
28950
  item.key === selectedItemKey,
28499
28951
  () => selectItem(item),
28500
- createGroupController(agent, section)
28952
+ createGroupController(entry.agent, "main")
28501
28953
  );
28502
- rowElements.set(item.key, row);
28503
- rows.append(row);
28504
- };
28505
- for (const entry of mainEntries) appendGroupRow(entry.agent, "main");
28954
+ nextRowChildren.push(view.element);
28955
+ }
28506
28956
  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));
28957
+ const dividerText = `${messages.connectionGroupMoreLabel} (${currentMoreEntries.length})`;
28958
+ if (groupDivider.textContent !== dividerText) {
28959
+ groupDivider.textContent = dividerText;
28960
+ }
28961
+ nextRowChildren.push(groupDivider);
28962
+ const nextMoreChildren = [];
28963
+ if (currentMoreEntries.length === 0) {
28964
+ nextMoreChildren.push(moreHint);
28530
28965
  } else {
28531
- for (const entry of moreEntries) {
28966
+ for (const entry of currentMoreEntries) {
28532
28967
  const item = agentByKey.get(entry.agent);
28533
28968
  if (!item) continue;
28534
- const row = createConnectionRow(
28535
- document2,
28969
+ activeKeys.add(item.key);
28970
+ const view = ensureRowView(item.key, true);
28971
+ view.update(
28536
28972
  item,
28537
- messages,
28538
28973
  item.key === selectedItemKey,
28539
28974
  () => selectItem(item),
28540
28975
  createGroupController(entry.agent, "more")
28541
28976
  );
28542
- rowElements.set(item.key, row);
28543
- zone.append(row);
28977
+ nextMoreChildren.push(view.element);
28544
28978
  }
28545
28979
  }
28546
- rows.append(zone);
28547
- const reset = createGroupResetButton(document2, messages, () => {
28548
- groupPreference.resetToDefault();
28549
- });
28550
- reset.disabled = groupDisabled;
28551
- rows.append(reset);
28980
+ if (!draggingAgent || renderedHostId !== selectedHost.hostId) {
28981
+ reconcileElementChildren(moreZone, nextMoreChildren);
28982
+ }
28983
+ nextRowChildren.push(moreZone);
28984
+ resetButton.disabled = groupDisabled;
28985
+ nextRowChildren.push(resetButton);
28986
+ }
28987
+ for (const key of hostRows.keys()) {
28988
+ if (!activeKeys.has(key)) hostRows.delete(key);
28989
+ }
28990
+ if (!draggingAgent || renderedHostId !== selectedHost.hostId) {
28991
+ reconcileElementChildren(rows, nextRowChildren);
28552
28992
  }
28553
28993
  const selectedItem = items.find((item) => item.key === selectedItemKey) ?? items[0];
28554
28994
  if (selectedItem) selectItem(selectedItem);
28555
- const updateControls = updates.createControls(
28995
+ updateControls.update(
28556
28996
  selectedHost.hostId,
28557
28997
  items.flatMap((item) => item.version ? [item.version] : [])
28558
28998
  );
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;
28999
+ if (layoutFirstMount || tabsChanged) {
29000
+ hostScroller.update();
29001
+ }
29002
+ if (renderedHostId !== selectedHost.hostId) {
29003
+ renderedHostId = selectedHost.hostId;
29004
+ const selectedTab = hostTabElements.get(selectedHost.hostId);
29005
+ if (selectedTab) {
29006
+ const left = selectedTab.offsetLeft;
29007
+ const right = left + selectedTab.offsetWidth;
29008
+ if (left < tabs.scrollLeft) tabs.scrollLeft = left;
29009
+ else if (right > tabs.scrollLeft + tabs.clientWidth) {
29010
+ tabs.scrollLeft = right - tabs.clientWidth;
29011
+ }
28581
29012
  }
28582
29013
  }
28583
29014
  };
@@ -28598,7 +29029,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28598
29029
  refresh.disabled = true;
28599
29030
  return () => {
28600
29031
  cancelRender();
28601
- disposeHostScroller();
29032
+ hostScroller.dispose();
28602
29033
  unsubscribeGroup();
28603
29034
  };
28604
29035
  }
@@ -28607,7 +29038,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28607
29038
  const unsubscribeInstalls = installs?.subscribe(scheduleRender);
28608
29039
  return () => {
28609
29040
  cancelRender();
28610
- disposeHostScroller();
29041
+ hostScroller.dispose();
28611
29042
  unsubscribeInstalls?.();
28612
29043
  unsubscribe();
28613
29044
  unsubscribeGroup();
@@ -30251,9 +30682,13 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
30251
30682
  resets: "Resets",
30252
30683
  details: "Account limit details",
30253
30684
  weekly: "Weekly limit",
30685
+ weeklyShort: "Weekly",
30254
30686
  monthly: "Monthly limit",
30687
+ monthlyShort: "Monthly",
30255
30688
  fiveHour: "5-hour limit",
30689
+ fiveHourShort: "5-hour",
30256
30690
  sevenDay: "7-day limit",
30691
+ sevenDayShort: "7-day",
30257
30692
  account: "Account limit"
30258
30693
  });
30259
30694
  var CHINESE_CREDITS_MESSAGES = Object.freeze({
@@ -30261,9 +30696,13 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
30261
30696
  resets: "\u91CD\u7F6E",
30262
30697
  details: "\u8D26\u53F7\u989D\u5EA6\u8BE6\u60C5",
30263
30698
  weekly: "\u5468\u989D\u5EA6",
30699
+ weeklyShort: "\u5468\u989D\u5EA6",
30264
30700
  monthly: "\u6708\u989D\u5EA6",
30701
+ monthlyShort: "\u6708\u989D\u5EA6",
30265
30702
  fiveHour: "5 \u5C0F\u65F6\u989D\u5EA6",
30703
+ fiveHourShort: "5 \u5C0F\u65F6",
30266
30704
  sevenDay: "7 \u5929\u989D\u5EA6",
30705
+ sevenDayShort: "7 \u5929",
30267
30706
  account: "\u8D26\u53F7\u989D\u5EA6"
30268
30707
  });
30269
30708
  function formatRendererCreditsReset(value, now = /* @__PURE__ */ new Date(), locale = "en") {
@@ -33238,6 +33677,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
33238
33677
  .settings-connection-inspector {
33239
33678
  position: sticky;
33240
33679
  top: 18px;
33680
+ overflow-anchor: none;
33241
33681
  }
33242
33682
 
33243
33683
  .settings-connection-inspector__header {