@codexhost/cli-linux-arm64 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
@@ -14678,13 +14678,25 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14678
14678
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
14679
14679
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
14680
14680
  var cacheHitRatePercentSchema = external_exports.number().finite().min(0).max(100);
14681
+ var usageOutputTimingSchema = external_exports.object({
14682
+ version: external_exports.union([external_exports.literal(3), external_exports.literal(4)]).optional(),
14683
+ requestId: external_exports.string().min(1),
14684
+ turnId: external_exports.string().min(1).max(1024),
14685
+ outputTokens: nonNegativeSafeIntegerSchema,
14686
+ startedAtMs: nonNegativeSafeIntegerSchema,
14687
+ completedAtMs: nonNegativeSafeIntegerSchema
14688
+ }).strict().refine((value) => value.completedAtMs > value.startedAtMs);
14681
14689
  var usageMeasurementSchema = external_exports.object({
14690
+ version: external_exports.union([external_exports.literal(2), external_exports.literal(3), external_exports.literal(4)]).optional(),
14682
14691
  value: finiteNonNegativeNumberSchema,
14683
14692
  turnId: external_exports.string().min(1).max(1024),
14684
14693
  at: nonNegativeSafeIntegerSchema
14685
14694
  }).strict();
14686
14695
  var usageMeasurementsSchema = external_exports.object({
14687
- outputTokensPerSecond: usageMeasurementSchema.optional(),
14696
+ // Older intervals can omit hidden thinking time; do not restore them into averages.
14697
+ outputTimings: external_exports.array(usageOutputTimingSchema).transform((values) => values.filter((value) => value.version === 4)).optional(),
14698
+ // Retain independent TTFT facts when dropping incompatible speed measurements.
14699
+ outputTokensPerSecond: usageMeasurementSchema.refine((value) => value.version === 4).optional().catch(void 0),
14688
14700
  timeToFirstOutputMs: usageMeasurementSchema.extend({ value: nonNegativeSafeIntegerSchema }).optional()
14689
14701
  }).strict();
14690
14702
  var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text) => text.length <= maximum));
@@ -14704,6 +14716,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14704
14716
  cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
14705
14717
  outputTokens: nonNegativeSafeIntegerSchema.optional(),
14706
14718
  outputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
14719
+ sessionOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
14707
14720
  apiOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
14708
14721
  reasoningOutputTokens: nonNegativeSafeIntegerSchema.optional(),
14709
14722
  totalTokens: nonNegativeSafeIntegerSchema.optional(),
@@ -15116,6 +15129,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15116
15129
  delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
15117
15130
  }).strict();
15118
15131
 
15132
+ // ../shared-contracts/dist/thread-archive-confirm.js
15133
+ var threadArchiveConfirmParamsSchema = external_exports.object({ threadId: hostThreadIdSchema }).strict();
15134
+ var threadArchiveConfirmResultSchema = external_exports.object({ confirmed: external_exports.boolean() }).strict();
15135
+
15119
15136
  // ../shared-contracts/dist/client-channel.js
15120
15137
  var CLIENT_CHANNEL_VERSION = 1;
15121
15138
  var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
@@ -15146,6 +15163,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15146
15163
  cursor: clientChannelCursorSchema,
15147
15164
  cwd: external_exports.string().optional()
15148
15165
  }),
15166
+ external_exports.object({
15167
+ type: external_exports.literal("harness-inspection-changed"),
15168
+ cursor: clientChannelCursorSchema,
15169
+ harnessId: external_exports.string().min(1)
15170
+ }),
15149
15171
  external_exports.object({ type: external_exports.literal("display-settings-changed"), cursor: clientChannelCursorSchema }),
15150
15172
  external_exports.object({
15151
15173
  type: external_exports.literal("preferences-changed"),
@@ -15217,6 +15239,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15217
15239
  var clientTurnSchema = external_exports.object({
15218
15240
  id: external_exports.string().min(1),
15219
15241
  status: external_exports.string().min(1),
15242
+ /** Native history has no terminal evidence; Desktop's status vocabulary cannot express this. */
15243
+ codexhostTurnOutcome: external_exports.object({ status: external_exports.literal("unknown"), reason: external_exports.string() }).optional(),
15220
15244
  items: external_exports.array(external_exports.object({ id: external_exports.string().min(1), type: external_exports.string().min(1) }).passthrough()),
15221
15245
  /** Original file operations, independent of the cumulative Desktop fileChange card.
15222
15246
  * Insert before the named non-file Item; null appends at the end of the Turn.
@@ -15255,7 +15279,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15255
15279
  /** Current interruptible Host Turn, including command Turns omitted from client history. */
15256
15280
  activeTurnId: external_exports.string().min(1).nullable().optional(),
15257
15281
  /** Most recent explicit command in this Host process; not native conversation history. */
15258
- command: external_exports.object({ name: external_exports.string().min(1), turn: clientTurnSchema }).optional(),
15282
+ command: external_exports.object({
15283
+ name: external_exports.string().min(1),
15284
+ turn: clientTurnSchema,
15285
+ /** First ordinary Turn started after this command; its retained result is not a new event. */
15286
+ subsequentTurnId: external_exports.string().min(1).optional()
15287
+ }).optional(),
15259
15288
  thread: external_exports.object({
15260
15289
  id: external_exports.string().min(1),
15261
15290
  cwd: external_exports.string(),
@@ -15465,7 +15494,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15465
15494
  quotaUntil: external_exports.string().optional()
15466
15495
  }).strict().optional()
15467
15496
  }).strict();
15468
- var webLocalAccessRequiredDetailsSchema = external_exports.object({ url: external_exports.string() }).strict();
15469
15497
 
15470
15498
  // ../shared-contracts/dist/delegation-read.js
15471
15499
  var REMOTE_THREAD_REPLY_MAX_BYTES = 16 * 1024 * 1024;
@@ -16479,6 +16507,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16479
16507
  "completed",
16480
16508
  "failed",
16481
16509
  "interrupted",
16510
+ "needsInput",
16482
16511
  "timedOut",
16483
16512
  "unreadable",
16484
16513
  "notFound"
@@ -16528,13 +16557,25 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16528
16557
  var thread = { ...target, threadId: identity };
16529
16558
  var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
16530
16559
  external_exports.strictObject({ kind: external_exports.literal("hosts") }),
16560
+ external_exports.strictObject({ kind: external_exports.literal("status"), ...thread }),
16531
16561
  external_exports.strictObject({
16532
16562
  kind: external_exports.literal("list"),
16533
16563
  ...target,
16534
16564
  cursor: external_exports.string().nullable(),
16535
16565
  archived: external_exports.boolean()
16536
16566
  }),
16537
- external_exports.strictObject({ kind: external_exports.literal("read"), ...thread }),
16567
+ external_exports.strictObject({
16568
+ kind: external_exports.literal("read"),
16569
+ ...thread,
16570
+ page: external_exports.strictObject({
16571
+ cursor: external_exports.string().min(1).max(8192).nullable(),
16572
+ epoch: identity.optional(),
16573
+ sortDirection: external_exports.enum(["asc", "desc"]).optional(),
16574
+ limit: external_exports.number().int().min(1).max(20).optional()
16575
+ }).refine((page) => page.cursor === null || page.epoch !== void 0, {
16576
+ message: "A history continuation requires its connection epoch"
16577
+ }).optional()
16578
+ }),
16538
16579
  external_exports.strictObject({
16539
16580
  kind: external_exports.literal("configure"),
16540
16581
  ...thread,
@@ -16674,11 +16715,18 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16674
16715
  const webUi = /* @__PURE__ */ new Map();
16675
16716
  const listeners = /* @__PURE__ */ new Set();
16676
16717
  let pending = null;
16718
+ let queuedRefresh = null;
16677
16719
  const publish = () => {
16678
16720
  for (const listener of [...listeners]) listener();
16679
16721
  };
16680
16722
  const inspectAll = (refresh) => {
16681
- if (pending) return pending;
16723
+ if (pending) {
16724
+ if (!refresh) return pending;
16725
+ queuedRefresh ??= pending.then(() => inspectAll(true)).finally(() => {
16726
+ queuedRefresh = null;
16727
+ });
16728
+ return queuedRefresh;
16729
+ }
16682
16730
  pending = Promise.resolve().then(async () => {
16683
16731
  try {
16684
16732
  if (!client.listHarnessPlugins)
@@ -16696,7 +16744,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16696
16744
  await Promise.all(
16697
16745
  plugins.map(async ({ id }) => {
16698
16746
  try {
16699
- const inspection = await client.inspectHarness({ harnessId: id, refresh });
16747
+ const inspection = await client.inspectHarness({
16748
+ harnessId: id,
16749
+ refresh,
16750
+ purpose: "availability"
16751
+ });
16700
16752
  availability.set(id, inspection.status);
16701
16753
  webUi.set(id, inspection.status === "ready" && inspection.webUi?.open === true);
16702
16754
  const error51 = inspection.status === "ready" ? null : inspection.error;
@@ -21372,6 +21424,7 @@ th[aria-sort] .console-usage-sort__mark {
21372
21424
  latestCacheHit: "Latest cache hit (CH)",
21373
21425
  sessionCacheHit: "Average cache hit",
21374
21426
  outputSpeed: "Output speed (TPS)",
21427
+ averageOutputSpeed: "Average output speed (TPS)",
21375
21428
  apiOutputSpeed: "API average speed",
21376
21429
  apiOutputSpeedDescription: "Output tokens / native API time, including first-token wait; not generation TPS.",
21377
21430
  timeToFirstOutput: "Time to first token (TTFT)",
@@ -21397,6 +21450,7 @@ th[aria-sort] .console-usage-sort__mark {
21397
21450
  latestCacheHit: "\u6700\u8FD1\u7F13\u5B58\u547D\u4E2D\uFF08CH\uFF09",
21398
21451
  sessionCacheHit: "\u5E73\u5747\u7F13\u5B58\u547D\u4E2D",
21399
21452
  outputSpeed: "\u8F93\u51FA\u901F\u5EA6\uFF08TPS\uFF09",
21453
+ averageOutputSpeed: "\u5E73\u5747\u8F93\u51FA\u901F\u5EA6\uFF08TPS\uFF09",
21400
21454
  apiOutputSpeed: "API \u5E73\u5747\u901F\u5EA6",
21401
21455
  apiOutputSpeedDescription: "\u8F93\u51FA Token \xF7 \u539F\u751F API \u8017\u65F6\uFF0C\u542B\u9996\u5B57\u7B49\u5F85\uFF1B\u4E0D\u662F\u751F\u6210 TPS\u3002",
21402
21456
  timeToFirstOutput: "\u9996 token\uFF08TTFT\uFF09",
@@ -25413,242 +25467,474 @@ ${detail}` : ""}`
25413
25467
  return fallback;
25414
25468
  }
25415
25469
 
25416
- // src/settings/harness-launch-controls.ts
25417
- function createHarnessLaunchControls(document2, messages, agent, settings) {
25418
- const section = document2.createElement("section");
25419
- section.className = "settings-harness-launch";
25420
- section.dataset.harnessLaunch = agent;
25421
- const label = document2.createElement("label");
25422
- label.textContent = messages.launchPathLabel;
25423
- const input = document2.createElement("input");
25424
- input.type = "text";
25425
- input.autocomplete = "off";
25426
- input.spellcheck = false;
25427
- input.placeholder = messages.locale === "zh-CN" ? "\u5E94\u7528\u5B89\u88C5\u76EE\u5F55\u7684\u7EDD\u5BF9\u8DEF\u5F84" : "Absolute installation directory";
25428
- input.setAttribute("aria-label", messages.launchPathLabel);
25429
- label.append(input);
25430
- const help = document2.createElement("p");
25431
- 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.";
25432
- const actions = document2.createElement("div");
25433
- actions.className = "settings-harness-launch__actions";
25434
- const save = document2.createElement("button");
25435
- save.type = "button";
25436
- save.className = "settings-command-button";
25437
- save.textContent = messages.launchPathSave;
25438
- const reset = document2.createElement("button");
25439
- reset.type = "button";
25440
- reset.className = "settings-command-button settings-command-button--secondary";
25441
- reset.textContent = messages.launchPathReset;
25442
- const status = document2.createElement("p");
25443
- status.setAttribute("role", "status");
25444
- status.setAttribute("aria-live", "polite");
25445
- actions.append(save, reset);
25446
- section.append(label, help, actions, status);
25447
- let busy = true;
25448
- let loaded = false;
25449
- const controls = () => {
25450
- input.disabled = busy || !loaded;
25451
- save.disabled = busy || !loaded || !input.value.trim();
25452
- reset.disabled = busy || !loaded;
25453
- };
25454
- const show = (value) => {
25455
- input.value = value.path ?? "";
25456
- status.textContent = value.restartRequired ? messages.launchPathRestart : value.path ? messages.launchPathSaved : messages.launchPathAutomatic;
25457
- };
25458
- const persist = async (value) => {
25459
- if (busy || !loaded) return;
25460
- busy = true;
25461
- controls();
25462
- status.textContent = messages.launchPathSaving;
25463
- try {
25464
- show(await settings.set(value));
25465
- } catch {
25466
- status.textContent = messages.launchPathSaveError;
25467
- } finally {
25468
- busy = false;
25469
- controls();
25470
- }
25471
- };
25472
- input.addEventListener("input", controls);
25473
- save.addEventListener("click", () => {
25474
- if (input.value.trim()) void persist(input.value.trim());
25475
- });
25476
- reset.addEventListener("click", () => {
25477
- void persist(null);
25478
- });
25479
- controls();
25480
- status.textContent = messages.launchPathLoading;
25481
- void settings.get().then((value) => {
25482
- loaded = true;
25483
- show(value);
25484
- }).catch(() => {
25485
- loaded = true;
25486
- status.textContent = messages.launchPathLoadError;
25487
- }).finally(() => {
25488
- busy = false;
25489
- controls();
25490
- });
25491
- return section;
25492
- }
25493
-
25494
- // src/settings/harness-installation-guides.ts
25495
- function harnessHasInstallCommands(plugin) {
25496
- return (plugin?.installation?.commands.length ?? 0) > 0;
25470
+ // src/settings/connection-row.ts
25471
+ function connectionStatusLabel(availability, messages, hasError = false) {
25472
+ if (availability === "updating") return messages.connectionStatusUpdating;
25473
+ if (hasError && availability !== "notInstalled") return messages.connectionStatusError;
25474
+ if (availability === "ready") return messages.connectionStatusReady;
25475
+ if (availability === "checking") return messages.connectionStatusChecking;
25476
+ if (availability === "notInstalled") return messages.connectionStatusNotInstalled;
25477
+ if (availability === "unavailable" || availability === "error") {
25478
+ return availability === "error" ? messages.connectionStatusError : messages.connectionStatusUnavailable;
25479
+ }
25480
+ return availability === "installing" ? messages.connectionStatusInstalling : messages.connectionStatusUnsupported;
25497
25481
  }
25498
- function harnessInstallationGuide(plugin, locale) {
25499
- const guide = plugin?.installation;
25500
- const text = (value) => value?.[locale] ?? value?.en;
25501
- return {
25502
- url: plugin?.links?.installation ?? plugin?.links?.documentation ?? plugin?.links?.website,
25503
- commands: guide?.commands ?? [],
25504
- downloads: guide?.downloads ?? [],
25505
- before: text(guide?.before),
25506
- after: text(guide?.after)
25507
- };
25482
+ function connectionStatusTone(availability, hasError = false) {
25483
+ if (availability === "updating") return "checking";
25484
+ if (hasError && availability !== "notInstalled") return "failed";
25485
+ if (availability === "ready") return "ready";
25486
+ if (availability === "checking" || availability === "installing") return "checking";
25487
+ if (availability === "notInstalled") return "setup";
25488
+ return "failed";
25508
25489
  }
25509
-
25510
- // src/settings/harness-installation-panel.ts
25511
- function createHarnessInstallationPanel(document2, plugin, hostId2, messages, copy, installation) {
25512
- const zh = messages.locale === "zh-CN";
25513
- const guide = harnessInstallationGuide(plugin, messages.locale);
25514
- const panel = document2.createElement("div");
25515
- panel.className = "settings-harness-installation";
25516
- const paragraph = (text) => {
25517
- const p = document2.createElement("p");
25518
- p.textContent = text;
25519
- panel.append(p);
25520
- };
25521
- if (hostId2 !== "local") {
25522
- paragraph(zh ? "\u8BF7\u5728\u8FDC\u7A0B Host \u4E0A\u5B89\u88C5\u3002" : "Install on the remote Host.");
25490
+ function createConnectionIdentityIcon(document2, item, size) {
25491
+ const container = document2.createElement("span");
25492
+ container.className = item.agentSnapshot ? "settings-connection-row__mark settings-connection-row__mark--logo" : "settings-connection-row__mark";
25493
+ container.setAttribute("aria-hidden", "true");
25494
+ if (item.agentSnapshot) {
25495
+ container.append(
25496
+ createRendererAgentIcon(item.agentSnapshot.agent, size, document2, item.agentSnapshot.plugin)
25497
+ );
25498
+ } else {
25499
+ container.textContent = "CH";
25523
25500
  }
25524
- if (guide.before) paragraph(guide.before);
25525
- const install = installation && guide.commands.length > 0 ? document2.createElement("button") : null;
25526
- if (install && installation) {
25527
- install.type = "button";
25528
- install.className = "settings-command-button";
25529
- install.dataset.connectionAction = "install";
25530
- install.disabled = installation.status !== "idle";
25531
- install.textContent = installation.status === "installing" ? messages.connectionStatusInstalling : installation.status === "checking" ? messages.connectionStatusChecking : zh ? "\u4E00\u952E\u5B89\u88C5" : "Install automatically";
25532
- install.addEventListener("click", () => {
25533
- if (install.disabled) return;
25534
- install.disabled = true;
25535
- install.textContent = messages.connectionStatusInstalling;
25536
- installation.run();
25537
- });
25538
- if (guide.commands.length > 1) panel.append(install);
25501
+ return container;
25502
+ }
25503
+ function sameElementChildren(container, next) {
25504
+ if (container.children.length !== next.length) return false;
25505
+ for (let index = 0; index < next.length; index++) {
25506
+ if (container.children[index] !== next[index]) return false;
25539
25507
  }
25540
- for (const { terminal, command } of guide.commands) {
25541
- const block = document2.createElement("div");
25542
- block.className = "settings-harness-installation-command";
25543
- const label = document2.createElement("strong");
25544
- label.textContent = terminal;
25545
- const pre = document2.createElement("pre");
25546
- const code = document2.createElement("code");
25547
- code.textContent = command;
25548
- pre.append(code);
25549
- const button2 = document2.createElement("button");
25550
- button2.type = "button";
25551
- button2.className = "settings-command-button settings-command-button--secondary";
25552
- button2.dataset.connectionAction = "copy-install";
25553
- const copyLabel = zh ? "\u590D\u5236\u547D\u4EE4" : "Copy command";
25554
- button2.setAttribute("aria-label", `${copyLabel}: ${terminal}`);
25555
- button2.append(createRendererSettingsIcon("copy", 16), copyLabel);
25556
- button2.addEventListener("click", () => copy(button2, command, copyLabel));
25557
- const actions = document2.createElement("div");
25558
- actions.className = "settings-harness-installation-actions";
25559
- if (install && guide.commands.length === 1) actions.append(install);
25560
- actions.append(button2);
25561
- block.append(label, pre, actions);
25562
- panel.append(block);
25508
+ return true;
25509
+ }
25510
+ function reconcileElementChildren(container, next) {
25511
+ if (sameElementChildren(container, next)) return;
25512
+ if (typeof container.insertBefore !== "function") {
25513
+ container.replaceChildren(...next);
25514
+ return;
25563
25515
  }
25564
- for (const download2 of guide.downloads ?? []) {
25565
- const link = document2.createElement("a");
25566
- link.className = "settings-command-button settings-command-button--secondary";
25567
- link.href = download2.url;
25568
- link.target = "_blank";
25569
- link.rel = "noopener noreferrer";
25570
- link.textContent = zh ? "\u4E0B\u8F7D" : "Download";
25571
- link.setAttribute("aria-label", `${link.textContent} ${download2.label}`);
25572
- panel.append(link);
25516
+ const nextSet = new Set(next);
25517
+ for (const child of [...container.children]) {
25518
+ if (!nextSet.has(child)) child.remove();
25573
25519
  }
25574
- if (guide.after) paragraph(guide.after);
25575
- if (!plugin?.installation && guide.url) {
25576
- const link = document2.createElement("a");
25577
- link.href = guide.url;
25578
- link.target = "_blank";
25579
- link.rel = "noopener noreferrer";
25580
- link.textContent = zh ? "\u5B89\u88C5\u8BF4\u660E" : "Installation instructions";
25581
- panel.append(link);
25520
+ for (let index = 0; index < next.length; index++) {
25521
+ const desired = next[index];
25522
+ if (!desired) continue;
25523
+ const current = container.children[index] ?? null;
25524
+ if (current !== desired) {
25525
+ container.insertBefore(desired, current);
25526
+ }
25582
25527
  }
25583
- return panel;
25584
- }
25585
-
25586
- // src/settings/harness-install-store.ts
25587
- function errorMessage(error51) {
25588
- 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.";
25589
25528
  }
25590
- function unknownInstallOutcome(message2) {
25591
- return /outcome is unknown|do not retry automatically|did not answer in time/i.test(message2);
25529
+ function identityIconSignature(item) {
25530
+ if (!item.agentSnapshot) return "adapter";
25531
+ const plugin = item.agentSnapshot.plugin;
25532
+ return `${item.agentSnapshot.agent}:${String(plugin?.icon ?? "")}:${String(plugin?.iconStyle ?? "")}`;
25592
25533
  }
25593
- var stores = /* @__PURE__ */ new WeakMap();
25594
- function createStore(diagnostics) {
25595
- const states2 = /* @__PURE__ */ new Map();
25596
- const listeners = /* @__PURE__ */ new Set();
25597
- const key = (host, agent) => JSON.stringify([host, agent]);
25598
- const notify2 = () => listeners.forEach((listener) => listener());
25534
+ function createConnectionRowView(document2, messages, groupable) {
25535
+ const row = document2.createElement("div");
25536
+ row.className = "settings-connection-row";
25537
+ row.setAttribute("role", "row");
25538
+ const identity2 = document2.createElement("div");
25539
+ identity2.className = "settings-connection-row__identity";
25540
+ identity2.setAttribute("role", "cell");
25541
+ let handle = null;
25542
+ if (groupable) {
25543
+ handle = document2.createElement("span");
25544
+ handle.className = "settings-connection-row__handle";
25545
+ handle.setAttribute("aria-hidden", "true");
25546
+ handle.append(createRendererSettingsIcon("grip-vertical", 15));
25547
+ identity2.append(handle);
25548
+ }
25549
+ let iconElement = null;
25550
+ let renderedIconKey = null;
25551
+ const label = document2.createElement("strong");
25552
+ const status = document2.createElement("span");
25553
+ status.className = "settings-connection-row__status";
25554
+ status.setAttribute("role", "cell");
25555
+ const action = document2.createElement("div");
25556
+ action.className = "settings-connection-row__action";
25557
+ action.setAttribute("role", "cell");
25558
+ row.append(identity2, status, action);
25559
+ let currentItem = null;
25560
+ let currentSelect = () => void 0;
25561
+ let currentGroup = null;
25562
+ let installButton = null;
25563
+ let viewErrorButton = null;
25564
+ let versionAvailableBadge = null;
25565
+ let updateButton = null;
25566
+ let groupToggleButton = null;
25567
+ let groupToggleSection = null;
25568
+ row.addEventListener("click", (event) => {
25569
+ const target2 = event.target;
25570
+ if (target2?.closest?.("a")) return;
25571
+ currentSelect();
25572
+ });
25573
+ row.addEventListener("keydown", (event) => {
25574
+ if (event.target?.closest?.("button, a")) return;
25575
+ if (event.key !== "Enter" && event.key !== " ") return;
25576
+ event.preventDefault();
25577
+ currentSelect();
25578
+ });
25579
+ if (groupable) {
25580
+ row.addEventListener("dragstart", (event) => currentGroup?.onDragStart(event));
25581
+ row.addEventListener("dragover", (event) => currentGroup?.onDragOver(event));
25582
+ row.addEventListener("dragleave", (event) => currentGroup?.onDragLeave(event));
25583
+ row.addEventListener("drop", (event) => currentGroup?.onDrop(event));
25584
+ row.addEventListener("dragend", (event) => currentGroup?.onDragEnd(event));
25585
+ }
25586
+ const setSelected = (selected) => {
25587
+ const nextSelected = String(selected);
25588
+ if (row.dataset.connectionSelected !== nextSelected) {
25589
+ row.dataset.connectionSelected = nextSelected;
25590
+ }
25591
+ const nextTabIndex = selected ? 0 : -1;
25592
+ if (row.tabIndex !== nextTabIndex) {
25593
+ row.tabIndex = nextTabIndex;
25594
+ }
25595
+ };
25599
25596
  return {
25600
- get: (host, agent) => states2.get(key(host, agent)),
25601
- clearErrors() {
25602
- for (const [id, state] of states2) if (state.status === "error") states2.delete(id);
25603
- notify2();
25604
- },
25605
- subscribe(listener) {
25606
- listeners.add(listener);
25607
- return () => {
25608
- listeners.delete(listener);
25609
- };
25610
- },
25611
- async install(host, agent) {
25612
- const id = key(host, agent);
25613
- const previous = states2.get(id);
25614
- if (!diagnostics.installation || previous && previous.status !== "error") return;
25615
- states2.set(id, { status: "installing" });
25616
- notify2();
25617
- let failure;
25618
- try {
25619
- await diagnostics.installation(host, agent, "install");
25620
- states2.set(id, { status: "checking" });
25621
- notify2();
25622
- } catch (error51) {
25623
- failure = errorMessage(error51);
25597
+ element: row,
25598
+ setSelected,
25599
+ update(item, selected, select, group) {
25600
+ currentItem = item;
25601
+ currentSelect = select;
25602
+ currentGroup = group;
25603
+ if (row.dataset.connectionItem !== item.key) {
25604
+ row.dataset.connectionItem = item.key;
25605
+ }
25606
+ setSelected(selected);
25607
+ const nextIconKey = identityIconSignature(item);
25608
+ if (renderedIconKey !== nextIconKey || !iconElement) {
25609
+ renderedIconKey = nextIconKey;
25610
+ iconElement = createConnectionIdentityIcon(document2, item, 19);
25611
+ reconcileElementChildren(
25612
+ identity2,
25613
+ handle ? [handle, iconElement, label] : [iconElement, label]
25614
+ );
25624
25615
  }
25625
- try {
25626
- await diagnostics.refresh(host);
25627
- const refreshed = diagnostics.snapshot().hosts.find((candidate) => candidate.hostId === host)?.agents.find((candidate) => candidate.agent === agent);
25628
- if (refreshed?.availability === "ready") failure = void 0;
25629
- else if (failure && unknownInstallOutcome(failure) && refreshed && refreshed.availability !== "notInstalled") {
25630
- failure = void 0;
25616
+ if (handle && group && handle.title !== group.dragHandleTitle) {
25617
+ handle.title = group.dragHandleTitle;
25618
+ }
25619
+ if (label.textContent !== item.name) {
25620
+ label.textContent = item.name;
25621
+ }
25622
+ const tone = connectionStatusTone(item.availability, item.error !== null);
25623
+ if (status.dataset.connectionTone !== tone) {
25624
+ status.dataset.connectionTone = tone;
25625
+ }
25626
+ const statusText = item.error?.code === "authenticationRequired" ? messages.connectionLoginRequired : item.error?.code === "configurationRequired" ? messages.connectionConfigurationRequired : connectionStatusLabel(item.availability, messages, item.error !== null);
25627
+ if (status.textContent !== statusText) {
25628
+ status.textContent = statusText;
25629
+ }
25630
+ const nextActions = [];
25631
+ if (item.agentSnapshot?.availability === "notInstalled" && item.install) {
25632
+ if (!installButton) {
25633
+ const button2 = document2.createElement("button");
25634
+ button2.type = "button";
25635
+ button2.className = "settings-connection-install-link";
25636
+ button2.append(createRendererSettingsIcon("download", 17));
25637
+ button2.addEventListener("click", (event) => {
25638
+ event.stopPropagation();
25639
+ currentSelect();
25640
+ currentItem?.install?.();
25641
+ });
25642
+ installButton = button2;
25643
+ }
25644
+ installButton.disabled = item.availability === "installing" || item.availability === "checking";
25645
+ const installLabel = messages.connectionInstall;
25646
+ const ariaLabel = `${installLabel}: ${item.name}`;
25647
+ if (installButton.getAttribute("aria-label") !== ariaLabel) {
25648
+ installButton.setAttribute("aria-label", ariaLabel);
25649
+ }
25650
+ if (installButton.title !== installLabel) {
25651
+ installButton.title = installLabel;
25652
+ }
25653
+ nextActions.push(installButton);
25654
+ } else if (item.error) {
25655
+ if (!viewErrorButton) {
25656
+ const button2 = document2.createElement("button");
25657
+ button2.type = "button";
25658
+ button2.className = "settings-connection-view-error";
25659
+ button2.textContent = messages.connectionViewError;
25660
+ button2.addEventListener("click", (event) => {
25661
+ event.stopPropagation();
25662
+ currentSelect();
25663
+ });
25664
+ viewErrorButton = button2;
25665
+ }
25666
+ nextActions.push(viewErrorButton);
25667
+ }
25668
+ const version2 = item.version;
25669
+ if (version2?.state?.updateAvailable && !version2.updating) {
25670
+ if (!versionAvailableBadge) {
25671
+ const badge = document2.createElement("span");
25672
+ badge.className = "settings-connection-version-available";
25673
+ badge.textContent = messages.harnessVersionAvailable;
25674
+ versionAvailableBadge = badge;
25675
+ }
25676
+ const badgeTitle = `${messages.harnessVersionCurrent}: ${version2.state.currentVersion ?? "\u2014"}
25677
+ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages.harnessVersion)}`;
25678
+ if (versionAvailableBadge.title !== badgeTitle) {
25679
+ versionAvailableBadge.title = badgeTitle;
25680
+ }
25681
+ nextActions.push(versionAvailableBadge);
25682
+ }
25683
+ if (version2?.state?.updateAvailable && version2.state.canUpdate) {
25684
+ if (!updateButton) {
25685
+ const button2 = document2.createElement("button");
25686
+ button2.type = "button";
25687
+ button2.className = "settings-connection-install-link";
25688
+ button2.dataset.connectionAction = "update";
25689
+ button2.append(createRendererSettingsIcon("download", 17));
25690
+ button2.addEventListener("click", (event) => {
25691
+ event.stopPropagation();
25692
+ if (button2.disabled) return;
25693
+ void currentItem?.version?.update();
25694
+ currentSelect();
25695
+ });
25696
+ updateButton = button2;
25697
+ }
25698
+ updateButton.disabled = version2.updating;
25699
+ if (updateButton.title !== messages.harnessVersionUpdate) {
25700
+ updateButton.title = messages.harnessVersionUpdate;
25701
+ }
25702
+ const updateAriaLabel = `${messages.harnessVersionUpdate}: ${item.name}`;
25703
+ if (updateButton.getAttribute("aria-label") !== updateAriaLabel) {
25704
+ updateButton.setAttribute("aria-label", updateAriaLabel);
25705
+ }
25706
+ nextActions.push(updateButton);
25707
+ }
25708
+ if (group) {
25709
+ if (!groupToggleButton) {
25710
+ const button2 = document2.createElement("button");
25711
+ button2.type = "button";
25712
+ button2.className = "settings-connection-row__group-toggle";
25713
+ button2.addEventListener("click", (event) => {
25714
+ event.stopPropagation();
25715
+ currentGroup?.toggleSection();
25716
+ });
25717
+ groupToggleButton = button2;
25718
+ }
25719
+ groupToggleButton.disabled = group.disabled;
25720
+ if (groupToggleButton.title !== group.moveLabel) {
25721
+ groupToggleButton.title = group.moveLabel;
25722
+ }
25723
+ if (groupToggleButton.getAttribute("aria-label") !== group.moveLabel) {
25724
+ groupToggleButton.setAttribute("aria-label", group.moveLabel);
25725
+ }
25726
+ if (groupToggleSection !== group.section) {
25727
+ groupToggleSection = group.section;
25728
+ groupToggleButton.replaceChildren(
25729
+ createRendererSettingsIcon(
25730
+ group.section === "main" ? "chevron-down" : "chevron-up",
25731
+ 15
25732
+ )
25733
+ );
25734
+ }
25735
+ nextActions.push(groupToggleButton);
25736
+ }
25737
+ reconcileElementChildren(action, nextActions);
25738
+ if (group) {
25739
+ row.draggable = !group.disabled;
25740
+ if (row.dataset.connectionGroupSection !== group.section) {
25741
+ row.dataset.connectionGroupSection = group.section;
25631
25742
  }
25632
- } catch (error51) {
25633
- failure ??= errorMessage(error51);
25634
25743
  }
25635
- if (failure) states2.set(id, { status: "error", error: failure });
25636
- else states2.delete(id);
25637
- notify2();
25638
25744
  }
25639
25745
  };
25640
25746
  }
25641
- function harnessInstallStore(diagnostics) {
25642
- let store = stores.get(diagnostics);
25747
+
25748
+ // src/settings/connection-updates.ts
25749
+ var sharedBatchStores = /* @__PURE__ */ new WeakMap();
25750
+ function getBatchStore(diagnostics) {
25751
+ if (!diagnostics) {
25752
+ return { batches: /* @__PURE__ */ new Map(), listeners: /* @__PURE__ */ new Set() };
25753
+ }
25754
+ let store = sharedBatchStores.get(diagnostics);
25643
25755
  if (!store) {
25644
- store = createStore(diagnostics);
25645
- stores.set(diagnostics, store);
25756
+ store = { batches: /* @__PURE__ */ new Map(), listeners: /* @__PURE__ */ new Set() };
25757
+ sharedBatchStores.set(diagnostics, store);
25646
25758
  }
25647
25759
  return store;
25648
25760
  }
25761
+ function createConnectionUpdates(document2, messages, signal, onChange, diagnostics = null) {
25762
+ const store = getBatchStore(diagnostics);
25763
+ const notify2 = () => {
25764
+ for (const listener of [...store.listeners]) listener();
25765
+ };
25766
+ if (!signal.aborted) {
25767
+ const listener = () => {
25768
+ if (!signal.aborted) onChange();
25769
+ };
25770
+ store.listeners.add(listener);
25771
+ signal.addEventListener(
25772
+ "abort",
25773
+ () => {
25774
+ store.listeners.delete(listener);
25775
+ },
25776
+ { once: true }
25777
+ );
25778
+ }
25779
+ const eligible = (panels) => panels.filter((panel) => panel.state?.updateAvailable && panel.state.canUpdate);
25780
+ const start = async (hostId2, panels) => {
25781
+ if (signal.aborted || store.batches.get(hostId2)?.running) return;
25782
+ const targets = eligible(panels);
25783
+ if (!targets.length) return;
25784
+ const batch = { running: true, total: targets.length, succeeded: 0, failed: 0 };
25785
+ store.batches.set(hostId2, batch);
25786
+ notify2();
25787
+ await Promise.all(
25788
+ targets.map(async (panel) => {
25789
+ try {
25790
+ if (await panel.update()) batch.succeeded++;
25791
+ else batch.failed++;
25792
+ } catch {
25793
+ batch.failed++;
25794
+ }
25795
+ notify2();
25796
+ })
25797
+ );
25798
+ batch.running = false;
25799
+ notify2();
25800
+ };
25801
+ return {
25802
+ createControls(hostId2, panels) {
25803
+ let currentHostId = hostId2;
25804
+ let currentPanels = panels;
25805
+ let renderedLabel = null;
25806
+ const button2 = document2.createElement("button");
25807
+ button2.type = "button";
25808
+ button2.className = "settings-command-button settings-command-button--secondary settings-connection-update-all";
25809
+ button2.dataset.connectionAction = "update-all";
25810
+ button2.title = messages.harnessUpdateAllDescription;
25811
+ button2.addEventListener("click", () => {
25812
+ if (!button2.disabled) void start(currentHostId, currentPanels);
25813
+ });
25814
+ const result = document2.createElement("p");
25815
+ result.className = "settings-connection-update-result";
25816
+ result.setAttribute("role", "status");
25817
+ const update = (nextHostId, nextPanels) => {
25818
+ currentHostId = nextHostId;
25819
+ currentPanels = nextPanels;
25820
+ const batch = store.batches.get(nextHostId);
25821
+ const count3 = eligible(nextPanels).length;
25822
+ button2.disabled = signal.aborted || Boolean(batch?.running) || !count3;
25823
+ const label = batch?.running ? `${messages.harnessUpdateAllProgress} ${batch.succeeded + batch.failed}/${batch.total}` : count3 ? `${messages.harnessUpdateAll} (${count3})` : messages.harnessUpdateAll;
25824
+ if (renderedLabel !== label) {
25825
+ renderedLabel = label;
25826
+ button2.replaceChildren(createRendererSettingsIcon("download", 15), label);
25827
+ }
25828
+ const hidden = !batch || batch.running;
25829
+ result.hidden = hidden;
25830
+ const resultText = batch && !batch.running ? messages.harnessUpdateAllResult.replace("{succeeded}", String(batch.succeeded)).replace("{failed}", String(batch.failed)) : "";
25831
+ if (result.textContent !== resultText) {
25832
+ result.textContent = resultText;
25833
+ }
25834
+ };
25835
+ update(hostId2, panels);
25836
+ return { button: button2, result, update };
25837
+ }
25838
+ };
25839
+ }
25649
25840
 
25650
25841
  // src/settings/harness-version-panel.ts
25651
- function createHarnessVersionPanel(document2, messages, signal, agent, client, onChange = () => void 0) {
25842
+ function isUnsupportedInstallationError(error51) {
25843
+ return typeof error51 === "object" && error51 !== null && "code" in error51 && (error51.code === -32601 || error51.code === -32078);
25844
+ }
25845
+ function createHarnessVersionSession(client, options) {
25846
+ let state;
25847
+ let statusKind = "checking";
25848
+ let checkPromise = null;
25849
+ let updatePromise = null;
25850
+ const listeners = /* @__PURE__ */ new Set();
25851
+ const signal = options?.signal;
25852
+ const notify2 = (pageChange) => {
25853
+ if (signal?.aborted) return;
25854
+ for (const listener of [...listeners]) listener(pageChange);
25855
+ };
25856
+ const check2 = () => {
25857
+ if (signal?.aborted || updatePromise) return Promise.resolve();
25858
+ if (checkPromise) return checkPromise;
25859
+ statusKind = "checking";
25860
+ notify2(false);
25861
+ checkPromise = (async () => {
25862
+ try {
25863
+ const result = await client.run("check");
25864
+ if (signal?.aborted || updatePromise) return;
25865
+ state = result;
25866
+ statusKind = "idle";
25867
+ } catch (error51) {
25868
+ if (signal?.aborted || updatePromise) return;
25869
+ statusKind = isUnsupportedInstallationError(error51) ? "unsupported" : "failed";
25870
+ if (state) state = { ...state, canUpdate: false };
25871
+ } finally {
25872
+ checkPromise = null;
25873
+ if (!signal?.aborted && !updatePromise) {
25874
+ notify2(true);
25875
+ }
25876
+ }
25877
+ })();
25878
+ return checkPromise;
25879
+ };
25880
+ const update = () => {
25881
+ if (updatePromise) return updatePromise;
25882
+ updatePromise = (async () => {
25883
+ if (signal?.aborted) return false;
25884
+ if (checkPromise) await checkPromise;
25885
+ if (signal?.aborted || statusKind === "unsupported" || !state?.canUpdate || !state.updateAvailable) {
25886
+ return false;
25887
+ }
25888
+ statusKind = "updating";
25889
+ notify2(true);
25890
+ try {
25891
+ const result = await client.run("update");
25892
+ if (signal?.aborted) return false;
25893
+ state = result;
25894
+ statusKind = !result.canUpdate ? "updated" : result.updateAvailable ? "failed" : "updated";
25895
+ return result.canUpdate && !result.updateAvailable;
25896
+ } catch (error51) {
25897
+ if (signal?.aborted) return false;
25898
+ statusKind = isUnsupportedInstallationError(error51) ? "unsupported" : "failed";
25899
+ if (state) state = { ...state, canUpdate: false };
25900
+ return false;
25901
+ } finally {
25902
+ updatePromise = null;
25903
+ if (!signal?.aborted) {
25904
+ notify2(true);
25905
+ }
25906
+ }
25907
+ })();
25908
+ return updatePromise;
25909
+ };
25910
+ return {
25911
+ get state() {
25912
+ return state;
25913
+ },
25914
+ get statusKind() {
25915
+ return statusKind;
25916
+ },
25917
+ get updating() {
25918
+ return statusKind === "updating";
25919
+ },
25920
+ prepareMount() {
25921
+ if (updatePromise || checkPromise) return false;
25922
+ statusKind = "checking";
25923
+ return true;
25924
+ },
25925
+ check: check2,
25926
+ update,
25927
+ subscribe(listener) {
25928
+ listeners.add(listener);
25929
+ return () => {
25930
+ listeners.delete(listener);
25931
+ };
25932
+ }
25933
+ };
25934
+ }
25935
+ function createHarnessVersionPanel(document2, messages, signal, agent, client, onChange = () => void 0, sharedSession) {
25936
+ const session = sharedSession ?? createHarnessVersionSession(client, { signal });
25937
+ const shouldScheduleCheck = session.prepareMount();
25652
25938
  const panel = document2.createElement("section");
25653
25939
  panel.className = "settings-harness-version";
25654
25940
  panel.dataset.harnessVersion = agent;
@@ -25672,15 +25958,14 @@ ${detail}` : ""}`
25672
25958
  note.textContent = messages.harnessVersionNote;
25673
25959
  actions.append(update);
25674
25960
  panel.append(heading, versions, status, actions, note);
25675
- let state;
25676
- let busy = false;
25677
- let updating = false;
25678
- let unsupported = false;
25679
- let updatePromise = null;
25680
25961
  const render = () => {
25962
+ const state = session.state;
25963
+ const statusKind = session.statusKind;
25964
+ const busy = statusKind === "checking" || statusKind === "updating";
25681
25965
  heading.textContent = state?.versionKind === "application" ? messages.harnessVersionApplicationTitle : messages.harnessVersionTitle;
25682
25966
  current.textContent = `${messages.harnessVersionCurrent}: ${state?.currentVersion ?? "\u2014"}`;
25683
25967
  latest.textContent = `${messages.harnessVersionLatest}: ${harnessVersionLabel(state, messages.harnessVersion)}`;
25968
+ 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 : "";
25684
25969
  update.disabled = busy || signal.aborted || !state?.canUpdate || !state.updateAvailable;
25685
25970
  const manualUrl = !state?.canUpdate && state?.updateAvailable ? state.manualUpdateUrl : void 0;
25686
25971
  actions.replaceChildren(update);
@@ -25699,99 +25984,92 @@ ${detail}` : ""}`
25699
25984
  const detail = harnessVersionNote(state, messages.harnessVersion);
25700
25985
  note.textContent = detail ? !state?.canUpdate ? detail : `${detail} ${messages.harnessVersionNote}` : messages.harnessVersionNote;
25701
25986
  };
25702
- const run = async (action) => {
25703
- if (busy || unsupported || signal.aborted) return false;
25704
- if (action === "update" && (!state?.canUpdate || !state.updateAvailable)) return false;
25705
- busy = true;
25706
- updating = action === "update";
25707
- onChange();
25708
- status.textContent = action === "check" ? messages.harnessVersionChecking : messages.harnessVersionUpdating;
25987
+ update.addEventListener("click", () => {
25988
+ if (!signal.aborted) void session.update();
25989
+ });
25990
+ const unsubscribe = session.subscribe((pageChange) => {
25991
+ if (signal.aborted) return;
25709
25992
  render();
25710
- try {
25711
- const result = await client.run(action);
25712
- if (signal.aborted) return false;
25713
- state = result;
25714
- status.textContent = !result.canUpdate ? messages.harnessVersionManual : action === "update" ? result.updateAvailable ? messages.harnessVersionFailed : messages.harnessVersionUpdated : "";
25715
- return result.canUpdate && !result.updateAvailable;
25716
- } catch (error51) {
25717
- if (signal.aborted) return false;
25718
- unsupported = typeof error51 === "object" && error51 !== null && "code" in error51 && (error51.code === -32601 || error51.code === -32078);
25719
- status.textContent = unsupported ? messages.harnessVersionUnsupported : messages.harnessVersionFailed;
25720
- if (state) state = { ...state, canUpdate: false };
25721
- return false;
25722
- } finally {
25723
- busy = false;
25724
- updating = false;
25725
- if (!signal.aborted) {
25726
- render();
25727
- onChange();
25728
- }
25729
- }
25730
- };
25731
- const updateVersion = () => {
25732
- updatePromise ??= run("update").finally(() => {
25733
- updatePromise = null;
25734
- });
25735
- return updatePromise;
25736
- };
25737
- update.addEventListener("click", () => void updateVersion());
25993
+ if (pageChange) onChange();
25994
+ });
25738
25995
  const owner = document2.defaultView;
25739
25996
  let checkFrame = null;
25740
25997
  let checkTimer = null;
25741
25998
  signal.addEventListener(
25742
25999
  "abort",
25743
26000
  () => {
26001
+ unsubscribe();
25744
26002
  if (checkFrame !== null) owner?.cancelAnimationFrame(checkFrame);
25745
26003
  if (checkTimer !== null) owner?.clearTimeout(checkTimer);
25746
26004
  render();
25747
26005
  },
25748
26006
  { once: true }
25749
26007
  );
25750
- status.textContent = messages.harnessVersionChecking;
25751
26008
  render();
25752
- if (!signal.aborted && owner?.requestAnimationFrame) {
25753
- checkFrame = owner.requestAnimationFrame(() => {
25754
- checkFrame = null;
25755
- if (signal.aborted) return;
25756
- checkTimer = owner.setTimeout(() => {
25757
- checkTimer = null;
25758
- void run("check");
25759
- }, 0);
25760
- });
25761
- } else {
25762
- void run("check");
26009
+ if (shouldScheduleCheck && !signal.aborted) {
26010
+ if (owner?.requestAnimationFrame) {
26011
+ checkFrame = owner.requestAnimationFrame(() => {
26012
+ checkFrame = null;
26013
+ if (signal.aborted) return;
26014
+ checkTimer = owner.setTimeout(() => {
26015
+ checkTimer = null;
26016
+ if (!signal.aborted) void session.check();
26017
+ }, 0);
26018
+ });
26019
+ } else {
26020
+ void session.check();
26021
+ }
25763
26022
  }
25764
26023
  return {
25765
26024
  element: panel,
25766
26025
  get state() {
25767
- return state;
26026
+ return session.state;
25768
26027
  },
25769
26028
  get updating() {
25770
- return updating;
26029
+ return session.updating;
25771
26030
  },
25772
- update: updateVersion
26031
+ update: () => signal.aborted ? Promise.resolve(false) : session.update()
25773
26032
  };
25774
26033
  }
25775
26034
 
25776
26035
  // src/settings/connection-versions.ts
26036
+ var sessionStores = /* @__PURE__ */ new WeakMap();
26037
+ function getSessionStore(diagnostics) {
26038
+ let store = sessionStores.get(diagnostics);
26039
+ if (!store) {
26040
+ store = /* @__PURE__ */ new Map();
26041
+ sessionStores.set(diagnostics, store);
26042
+ }
26043
+ return store;
26044
+ }
25777
26045
  function createConnectionVersions(document2, messages, signal, diagnostics, onChange) {
25778
26046
  const panels = /* @__PURE__ */ new Map();
25779
26047
  const installation = diagnostics?.installation?.bind(diagnostics);
26048
+ const sessions = diagnostics ? getSessionStore(diagnostics) : null;
26049
+ const sessionKey = (hostId2, agent) => JSON.stringify([hostId2, agent]);
25780
26050
  return {
26051
+ isUpdating(hostId2, agent) {
26052
+ return Boolean(sessions?.get(sessionKey(hostId2, agent))?.updating);
26053
+ },
25781
26054
  get(hostId2, agent) {
25782
26055
  if (!installation || signal.aborted) return void 0;
25783
- const key = JSON.stringify([hostId2, agent]);
26056
+ const key = sessionKey(hostId2, agent);
25784
26057
  let panel = panels.get(key);
25785
26058
  if (!panel) {
26059
+ const run = (action) => installation(hostId2, agent, action);
26060
+ let session = sessions?.get(key);
26061
+ if (!session) {
26062
+ session = createHarnessVersionSession({ run });
26063
+ sessions?.set(key, session);
26064
+ }
25786
26065
  panel = createHarnessVersionPanel(
25787
26066
  document2,
25788
26067
  messages,
25789
26068
  signal,
25790
26069
  agent,
25791
- {
25792
- run: (action) => installation(hostId2, agent, action)
25793
- },
25794
- onChange
26070
+ { run },
26071
+ onChange,
26072
+ session
25795
26073
  );
25796
26074
  panels.set(key, panel);
25797
26075
  }
@@ -25800,79 +26078,242 @@ ${detail}` : ""}`
25800
26078
  };
25801
26079
  }
25802
26080
 
25803
- // src/settings/connection-updates.ts
25804
- function createConnectionUpdates(document2, messages, signal, onChange) {
25805
- const batches = /* @__PURE__ */ new Map();
25806
- const eligible = (panels) => panels.filter((panel) => panel.state?.updateAvailable && panel.state.canUpdate);
25807
- const start = async (hostId2, panels) => {
25808
- if (signal.aborted || batches.get(hostId2)?.running) return;
25809
- const targets = eligible(panels);
25810
- if (!targets.length) return;
25811
- const batch = { running: true, total: targets.length, succeeded: 0, failed: 0 };
25812
- batches.set(hostId2, batch);
25813
- onChange();
25814
- await Promise.all(
25815
- targets.map(async (panel) => {
25816
- try {
25817
- if (await panel.update()) batch.succeeded++;
25818
- else batch.failed++;
25819
- } catch {
25820
- batch.failed++;
25821
- }
25822
- if (!signal.aborted) onChange();
25823
- })
25824
- );
25825
- batch.running = false;
25826
- if (!signal.aborted) onChange();
26081
+ // src/settings/harness-install-store.ts
26082
+ function errorMessage(error51) {
26083
+ 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.";
26084
+ }
26085
+ function unknownInstallOutcome(message2) {
26086
+ return /outcome is unknown|do not retry automatically|did not answer in time/i.test(message2);
26087
+ }
26088
+ var stores = /* @__PURE__ */ new WeakMap();
26089
+ function createStore(diagnostics) {
26090
+ const states2 = /* @__PURE__ */ new Map();
26091
+ const listeners = /* @__PURE__ */ new Set();
26092
+ const key = (host, agent) => JSON.stringify([host, agent]);
26093
+ const notify2 = () => listeners.forEach((listener) => listener());
26094
+ return {
26095
+ get: (host, agent) => states2.get(key(host, agent)),
26096
+ clearErrors() {
26097
+ for (const [id, state] of states2) if (state.status === "error") states2.delete(id);
26098
+ notify2();
26099
+ },
26100
+ subscribe(listener) {
26101
+ listeners.add(listener);
26102
+ return () => {
26103
+ listeners.delete(listener);
26104
+ };
26105
+ },
26106
+ async install(host, agent) {
26107
+ const id = key(host, agent);
26108
+ const previous = states2.get(id);
26109
+ if (!diagnostics.installation || previous && previous.status !== "error") return;
26110
+ states2.set(id, { status: "installing" });
26111
+ notify2();
26112
+ let failure;
26113
+ try {
26114
+ await diagnostics.installation(host, agent, "install");
26115
+ states2.set(id, { status: "checking" });
26116
+ notify2();
26117
+ } catch (error51) {
26118
+ failure = errorMessage(error51);
26119
+ }
26120
+ try {
26121
+ await diagnostics.refresh(host);
26122
+ const refreshed = diagnostics.snapshot().hosts.find((candidate) => candidate.hostId === host)?.agents.find((candidate) => candidate.agent === agent);
26123
+ if (refreshed?.availability === "ready") failure = void 0;
26124
+ else if (failure && unknownInstallOutcome(failure) && refreshed && refreshed.availability !== "notInstalled") {
26125
+ failure = void 0;
26126
+ }
26127
+ } catch (error51) {
26128
+ failure ??= errorMessage(error51);
26129
+ }
26130
+ if (failure) states2.set(id, { status: "error", error: failure });
26131
+ else states2.delete(id);
26132
+ notify2();
26133
+ }
26134
+ };
26135
+ }
26136
+ function harnessInstallStore(diagnostics) {
26137
+ let store = stores.get(diagnostics);
26138
+ if (!store) {
26139
+ store = createStore(diagnostics);
26140
+ stores.set(diagnostics, store);
26141
+ }
26142
+ return store;
26143
+ }
26144
+
26145
+ // src/settings/harness-installation-guides.ts
26146
+ function harnessHasInstallCommands(plugin) {
26147
+ return (plugin?.installation?.commands.length ?? 0) > 0;
26148
+ }
26149
+ function harnessInstallationGuide(plugin, locale) {
26150
+ const guide = plugin?.installation;
26151
+ const text = (value) => value?.[locale] ?? value?.en;
26152
+ return {
26153
+ url: plugin?.links?.installation ?? plugin?.links?.documentation ?? plugin?.links?.website,
26154
+ commands: guide?.commands ?? [],
26155
+ downloads: guide?.downloads ?? [],
26156
+ before: text(guide?.before),
26157
+ after: text(guide?.after)
26158
+ };
26159
+ }
26160
+
26161
+ // src/settings/harness-installation-panel.ts
26162
+ function createHarnessInstallationPanel(document2, plugin, hostId2, messages, copy, installation) {
26163
+ const zh = messages.locale === "zh-CN";
26164
+ const guide = harnessInstallationGuide(plugin, messages.locale);
26165
+ const panel = document2.createElement("div");
26166
+ panel.className = "settings-harness-installation";
26167
+ const paragraph = (text) => {
26168
+ const p = document2.createElement("p");
26169
+ p.textContent = text;
26170
+ panel.append(p);
26171
+ };
26172
+ if (hostId2 !== "local") {
26173
+ paragraph(zh ? "\u8BF7\u5728\u8FDC\u7A0B Host \u4E0A\u5B89\u88C5\u3002" : "Install on the remote Host.");
26174
+ }
26175
+ if (guide.before) paragraph(guide.before);
26176
+ const install = installation && guide.commands.length > 0 ? document2.createElement("button") : null;
26177
+ if (install && installation) {
26178
+ install.type = "button";
26179
+ install.className = "settings-command-button";
26180
+ install.dataset.connectionAction = "install";
26181
+ install.disabled = installation.status !== "idle";
26182
+ install.textContent = installation.status === "installing" ? messages.connectionStatusInstalling : installation.status === "checking" ? messages.connectionStatusChecking : zh ? "\u4E00\u952E\u5B89\u88C5" : "Install automatically";
26183
+ install.addEventListener("click", () => {
26184
+ if (install.disabled) return;
26185
+ install.disabled = true;
26186
+ install.textContent = messages.connectionStatusInstalling;
26187
+ installation.run();
26188
+ });
26189
+ if (guide.commands.length > 1) panel.append(install);
26190
+ }
26191
+ for (const { terminal, command } of guide.commands) {
26192
+ const block = document2.createElement("div");
26193
+ block.className = "settings-harness-installation-command";
26194
+ const label = document2.createElement("strong");
26195
+ label.textContent = terminal;
26196
+ const pre = document2.createElement("pre");
26197
+ const code = document2.createElement("code");
26198
+ code.textContent = command;
26199
+ pre.append(code);
26200
+ const button2 = document2.createElement("button");
26201
+ button2.type = "button";
26202
+ button2.className = "settings-command-button settings-command-button--secondary";
26203
+ button2.dataset.connectionAction = "copy-install";
26204
+ const copyLabel = zh ? "\u590D\u5236\u547D\u4EE4" : "Copy command";
26205
+ button2.setAttribute("aria-label", `${copyLabel}: ${terminal}`);
26206
+ button2.append(createRendererSettingsIcon("copy", 16), copyLabel);
26207
+ button2.addEventListener("click", () => copy(button2, command, copyLabel));
26208
+ const actions = document2.createElement("div");
26209
+ actions.className = "settings-harness-installation-actions";
26210
+ if (install && guide.commands.length === 1) actions.append(install);
26211
+ actions.append(button2);
26212
+ block.append(label, pre, actions);
26213
+ panel.append(block);
26214
+ }
26215
+ for (const download2 of guide.downloads ?? []) {
26216
+ const link = document2.createElement("a");
26217
+ link.className = "settings-command-button settings-command-button--secondary";
26218
+ link.href = download2.url;
26219
+ link.target = "_blank";
26220
+ link.rel = "noopener noreferrer";
26221
+ link.textContent = zh ? "\u4E0B\u8F7D" : "Download";
26222
+ link.setAttribute("aria-label", `${link.textContent} ${download2.label}`);
26223
+ panel.append(link);
26224
+ }
26225
+ if (guide.after) paragraph(guide.after);
26226
+ if (!plugin?.installation && guide.url) {
26227
+ const link = document2.createElement("a");
26228
+ link.href = guide.url;
26229
+ link.target = "_blank";
26230
+ link.rel = "noopener noreferrer";
26231
+ link.textContent = zh ? "\u5B89\u88C5\u8BF4\u660E" : "Installation instructions";
26232
+ panel.append(link);
26233
+ }
26234
+ return panel;
26235
+ }
26236
+
26237
+ // src/settings/harness-launch-controls.ts
26238
+ function createHarnessLaunchControls(document2, messages, agent, settings) {
26239
+ const section = document2.createElement("section");
26240
+ section.className = "settings-harness-launch";
26241
+ section.dataset.harnessLaunch = agent;
26242
+ const label = document2.createElement("label");
26243
+ label.textContent = messages.launchPathLabel;
26244
+ const input = document2.createElement("input");
26245
+ input.type = "text";
26246
+ input.autocomplete = "off";
26247
+ input.spellcheck = false;
26248
+ input.placeholder = messages.locale === "zh-CN" ? "\u5E94\u7528\u5B89\u88C5\u76EE\u5F55\u7684\u7EDD\u5BF9\u8DEF\u5F84" : "Absolute installation directory";
26249
+ input.setAttribute("aria-label", messages.launchPathLabel);
26250
+ label.append(input);
26251
+ const help = document2.createElement("p");
26252
+ 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.";
26253
+ const actions = document2.createElement("div");
26254
+ actions.className = "settings-harness-launch__actions";
26255
+ const save = document2.createElement("button");
26256
+ save.type = "button";
26257
+ save.className = "settings-command-button";
26258
+ save.textContent = messages.launchPathSave;
26259
+ const reset = document2.createElement("button");
26260
+ reset.type = "button";
26261
+ reset.className = "settings-command-button settings-command-button--secondary";
26262
+ reset.textContent = messages.launchPathReset;
26263
+ const status = document2.createElement("p");
26264
+ status.setAttribute("role", "status");
26265
+ status.setAttribute("aria-live", "polite");
26266
+ actions.append(save, reset);
26267
+ section.append(label, help, actions, status);
26268
+ let busy = true;
26269
+ let loaded = false;
26270
+ const controls = () => {
26271
+ input.disabled = busy || !loaded;
26272
+ save.disabled = busy || !loaded || !input.value.trim();
26273
+ reset.disabled = busy || !loaded;
25827
26274
  };
25828
- return {
25829
- createControls(hostId2, panels) {
25830
- const batch = batches.get(hostId2);
25831
- const count3 = eligible(panels).length;
25832
- const button2 = document2.createElement("button");
25833
- button2.type = "button";
25834
- button2.className = "settings-command-button settings-command-button--secondary settings-connection-update-all";
25835
- button2.dataset.connectionAction = "update-all";
25836
- button2.disabled = signal.aborted || Boolean(batch?.running) || !count3;
25837
- button2.title = messages.harnessUpdateAllDescription;
25838
- const label = batch?.running ? `${messages.harnessUpdateAllProgress} ${batch.succeeded + batch.failed}/${batch.total}` : count3 ? `${messages.harnessUpdateAll} (${count3})` : messages.harnessUpdateAll;
25839
- button2.append(createRendererSettingsIcon("download", 15), label);
25840
- button2.addEventListener("click", () => {
25841
- if (!button2.disabled) void start(hostId2, panels);
25842
- });
25843
- const result = document2.createElement("p");
25844
- result.className = "settings-connection-update-result";
25845
- result.setAttribute("role", "status");
25846
- result.hidden = !batch || batch.running;
25847
- if (batch && !batch.running) {
25848
- result.textContent = messages.harnessUpdateAllResult.replace("{succeeded}", String(batch.succeeded)).replace("{failed}", String(batch.failed));
25849
- }
25850
- return { button: button2, result };
26275
+ const show = (value) => {
26276
+ input.value = value.path ?? "";
26277
+ status.textContent = value.restartRequired ? messages.launchPathRestart : value.path ? messages.launchPathSaved : messages.launchPathAutomatic;
26278
+ };
26279
+ const persist = async (value) => {
26280
+ if (busy || !loaded) return;
26281
+ busy = true;
26282
+ controls();
26283
+ status.textContent = messages.launchPathSaving;
26284
+ try {
26285
+ show(await settings.set(value));
26286
+ } catch {
26287
+ status.textContent = messages.launchPathSaveError;
26288
+ } finally {
26289
+ busy = false;
26290
+ controls();
25851
26291
  }
25852
26292
  };
26293
+ input.addEventListener("input", controls);
26294
+ save.addEventListener("click", () => {
26295
+ if (input.value.trim()) void persist(input.value.trim());
26296
+ });
26297
+ reset.addEventListener("click", () => {
26298
+ void persist(null);
26299
+ });
26300
+ controls();
26301
+ status.textContent = messages.launchPathLoading;
26302
+ void settings.get().then((value) => {
26303
+ loaded = true;
26304
+ show(value);
26305
+ }).catch(() => {
26306
+ loaded = true;
26307
+ status.textContent = messages.launchPathLoadError;
26308
+ }).finally(() => {
26309
+ busy = false;
26310
+ controls();
26311
+ });
26312
+ return section;
25853
26313
  }
25854
26314
 
25855
26315
  // src/settings/connections-page.ts
25856
26316
  var CODEXHOST_GITHUB_ISSUES_NEW_URL = "https://github.com/BytePioneer-AI/codex-host/issues/new";
25857
- function connectionStatusLabel(availability, messages, hasError = false) {
25858
- if (availability === "updating") return messages.connectionStatusUpdating;
25859
- if (hasError && availability !== "notInstalled") return messages.connectionStatusError;
25860
- if (availability === "ready") return messages.connectionStatusReady;
25861
- if (availability === "checking") return messages.connectionStatusChecking;
25862
- if (availability === "notInstalled") return messages.connectionStatusNotInstalled;
25863
- if (availability === "unavailable" || availability === "error") {
25864
- return availability === "error" ? messages.connectionStatusError : messages.connectionStatusUnavailable;
25865
- }
25866
- return availability === "installing" ? messages.connectionStatusInstalling : messages.connectionStatusUnsupported;
25867
- }
25868
- function connectionStatusTone(availability, hasError = false) {
25869
- if (availability === "updating") return "checking";
25870
- if (hasError && availability !== "notInstalled") return "failed";
25871
- if (availability === "ready") return "ready";
25872
- if (availability === "checking" || availability === "installing") return "checking";
25873
- if (availability === "notInstalled") return "setup";
25874
- return "failed";
25875
- }
25876
26317
  function diagnosticText(hostId2, item) {
25877
26318
  const error51 = item.error;
25878
26319
  return [
@@ -25968,148 +26409,21 @@ ${error51.stderrTail}`] : []
25968
26409
  tabs.addEventListener("wheel", onWheel, { passive: false });
25969
26410
  const ownerWindow = document2.defaultView;
25970
26411
  ownerWindow?.addEventListener("resize", updateButtons);
25971
- ownerWindow?.setTimeout(updateButtons, 0);
25972
- updateButtons();
25973
- return () => {
25974
- left.removeEventListener("click", onLeft);
25975
- right.removeEventListener("click", onRight);
25976
- tabs.removeEventListener("scroll", updateButtons);
25977
- tabs.removeEventListener("wheel", onWheel);
25978
- ownerWindow?.removeEventListener("resize", updateButtons);
26412
+ const refreshLayout = () => {
26413
+ ownerWindow?.setTimeout(updateButtons, 0);
26414
+ updateButtons();
26415
+ };
26416
+ refreshLayout();
26417
+ return {
26418
+ update: refreshLayout,
26419
+ dispose() {
26420
+ left.removeEventListener("click", onLeft);
26421
+ right.removeEventListener("click", onRight);
26422
+ tabs.removeEventListener("scroll", updateButtons);
26423
+ tabs.removeEventListener("wheel", onWheel);
26424
+ ownerWindow?.removeEventListener("resize", updateButtons);
26425
+ }
25979
26426
  };
25980
- }
25981
- function createConnectionIdentityIcon(document2, item, size) {
25982
- const container = document2.createElement("span");
25983
- container.className = item.agentSnapshot ? "settings-connection-row__mark settings-connection-row__mark--logo" : "settings-connection-row__mark";
25984
- container.setAttribute("aria-hidden", "true");
25985
- if (item.agentSnapshot) {
25986
- container.append(
25987
- createRendererAgentIcon(item.agentSnapshot.agent, size, document2, item.agentSnapshot.plugin)
25988
- );
25989
- } else {
25990
- container.textContent = "CH";
25991
- }
25992
- return container;
25993
- }
25994
- function createConnectionRow(document2, item, messages, selected, select, group = null) {
25995
- const row = document2.createElement("div");
25996
- row.className = "settings-connection-row";
25997
- row.dataset.connectionItem = item.key;
25998
- row.dataset.connectionSelected = String(selected);
25999
- row.tabIndex = selected ? 0 : -1;
26000
- row.setAttribute("role", "row");
26001
- const identity2 = document2.createElement("div");
26002
- identity2.className = "settings-connection-row__identity";
26003
- identity2.setAttribute("role", "cell");
26004
- if (group) {
26005
- const handle = document2.createElement("span");
26006
- handle.className = "settings-connection-row__handle";
26007
- handle.setAttribute("aria-hidden", "true");
26008
- handle.title = group.dragHandleTitle;
26009
- handle.append(createRendererSettingsIcon("grip-vertical", 15));
26010
- identity2.append(handle);
26011
- }
26012
- const label = document2.createElement("strong");
26013
- label.textContent = item.name;
26014
- identity2.append(createConnectionIdentityIcon(document2, item, 19), label);
26015
- const status = document2.createElement("span");
26016
- status.className = "settings-connection-row__status";
26017
- status.dataset.connectionTone = connectionStatusTone(item.availability, item.error !== null);
26018
- status.setAttribute("role", "cell");
26019
- status.textContent = item.error?.code === "authenticationRequired" ? messages.connectionLoginRequired : item.error?.code === "configurationRequired" ? messages.connectionConfigurationRequired : connectionStatusLabel(item.availability, messages, item.error !== null);
26020
- const version2 = item.version;
26021
- const action = document2.createElement("div");
26022
- action.className = "settings-connection-row__action";
26023
- action.setAttribute("role", "cell");
26024
- if (item.agentSnapshot?.availability === "notInstalled" && item.install) {
26025
- const install = document2.createElement("button");
26026
- install.type = "button";
26027
- install.className = "settings-connection-install-link";
26028
- install.addEventListener("click", (event) => {
26029
- event.stopPropagation();
26030
- select();
26031
- item.install?.();
26032
- });
26033
- install.disabled = item.availability === "installing" || item.availability === "checking";
26034
- const installLabel = messages.connectionInstall;
26035
- install.setAttribute("aria-label", `${installLabel}: ${item.name}`);
26036
- install.title = installLabel;
26037
- install.append(createRendererSettingsIcon("download", 17));
26038
- action.append(install);
26039
- } else if (item.error) {
26040
- const viewError = document2.createElement("button");
26041
- viewError.type = "button";
26042
- viewError.className = "settings-connection-view-error";
26043
- viewError.textContent = messages.connectionViewError;
26044
- viewError.addEventListener("click", (event) => {
26045
- event.stopPropagation();
26046
- select();
26047
- });
26048
- action.append(viewError);
26049
- }
26050
- if (version2?.state?.updateAvailable && !version2.updating) {
26051
- const available = document2.createElement("span");
26052
- available.className = "settings-connection-version-available";
26053
- available.textContent = messages.harnessVersionAvailable;
26054
- available.title = `${messages.harnessVersionCurrent}: ${version2.state.currentVersion ?? "\u2014"}
26055
- ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages.harnessVersion)}`;
26056
- action.append(available);
26057
- }
26058
- if (version2?.state?.updateAvailable && version2.state.canUpdate) {
26059
- const update = document2.createElement("button");
26060
- update.type = "button";
26061
- update.className = "settings-connection-install-link";
26062
- update.dataset.connectionAction = "update";
26063
- update.disabled = version2.updating;
26064
- update.title = messages.harnessVersionUpdate;
26065
- update.setAttribute("aria-label", `${messages.harnessVersionUpdate}: ${item.name}`);
26066
- update.append(createRendererSettingsIcon("download", 17));
26067
- update.addEventListener("click", (event) => {
26068
- event.stopPropagation();
26069
- if (update.disabled) return;
26070
- void version2.update();
26071
- select();
26072
- });
26073
- action.append(update);
26074
- }
26075
- if (group) {
26076
- const toggle = document2.createElement("button");
26077
- toggle.type = "button";
26078
- toggle.disabled = group.disabled;
26079
- toggle.className = "settings-connection-row__group-toggle";
26080
- toggle.title = group.moveLabel;
26081
- toggle.setAttribute("aria-label", group.moveLabel);
26082
- toggle.append(
26083
- createRendererSettingsIcon(group.section === "main" ? "chevron-down" : "chevron-up", 15)
26084
- );
26085
- toggle.addEventListener("click", (event) => {
26086
- event.stopPropagation();
26087
- group.toggleSection();
26088
- });
26089
- action.append(toggle);
26090
- }
26091
- row.addEventListener("click", (event) => {
26092
- const target2 = event.target;
26093
- if (target2?.closest?.("a")) return;
26094
- select();
26095
- });
26096
- row.addEventListener("keydown", (event) => {
26097
- if (event.target?.closest?.("button, a")) return;
26098
- if (event.key !== "Enter" && event.key !== " ") return;
26099
- event.preventDefault();
26100
- select();
26101
- });
26102
- if (group) {
26103
- row.draggable = !group.disabled;
26104
- row.dataset.connectionGroupSection = group.section;
26105
- row.addEventListener("dragstart", group.onDragStart);
26106
- row.addEventListener("dragover", group.onDragOver);
26107
- row.addEventListener("dragleave", group.onDragLeave);
26108
- row.addEventListener("drop", group.onDrop);
26109
- row.addEventListener("dragend", group.onDragEnd);
26110
- }
26111
- row.append(identity2, status, action);
26112
- return row;
26113
26427
  }
26114
26428
  function createInspectorHeader(document2, item, messages) {
26115
26429
  const header = document2.createElement("header");
@@ -26139,6 +26453,29 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26139
26453
  header.append(identity2, status);
26140
26454
  return header;
26141
26455
  }
26456
+ function inspectorRenderSignature(hostId2, item, messages, diagnostics) {
26457
+ const plugin = item.agentSnapshot?.plugin;
26458
+ const notice = plugin?.notice ? plugin.notice[messages.locale] ?? plugin.notice.en : "";
26459
+ const websiteUrl = plugin?.links?.website ?? plugin?.links?.documentation ?? "";
26460
+ const hasLaunchControls = hostId2 === "local" && Boolean(item.agentSnapshot?.agent) && Boolean(plugin?.launchCommand) && Boolean(diagnostics?.getLaunchSettings && diagnostics?.setLaunchSettings);
26461
+ return JSON.stringify([
26462
+ hostId2,
26463
+ item.key,
26464
+ item.name,
26465
+ item.availability,
26466
+ item.agentSnapshot?.availability ?? null,
26467
+ String(plugin?.icon ?? ""),
26468
+ String(plugin?.iconStyle ?? ""),
26469
+ websiteUrl,
26470
+ notice,
26471
+ item.installError ?? "",
26472
+ Boolean(item.install),
26473
+ plugin?.installation ?? null,
26474
+ Boolean(item.openWebUi),
26475
+ hasLaunchControls,
26476
+ item.error ? diagnosticText(hostId2, item) : ""
26477
+ ]);
26478
+ }
26142
26479
  function renderConnectionInspector(document2, inspector, item, hostId2, messages, diagnostics, existingLaunchControls, refresh) {
26143
26480
  inspector.replaceChildren(createInspectorHeader(document2, item, messages));
26144
26481
  const body = document2.createElement("div");
@@ -26301,11 +26638,10 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26301
26638
  ];
26302
26639
  }
26303
26640
  var pendingFocusAgent = null;
26304
- function createGroupDivider(document2, messages, count3) {
26641
+ function createGroupDivider(document2) {
26305
26642
  const divider = document2.createElement("div");
26306
26643
  divider.className = "settings-connection-group-divider";
26307
26644
  divider.setAttribute("role", "presentation");
26308
- divider.textContent = `${messages.connectionGroupMoreLabel} (${count3})`;
26309
26645
  return divider;
26310
26646
  }
26311
26647
  function createGroupMoreHint(document2, messages) {
@@ -26358,11 +26694,13 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26358
26694
  context.content.append(header, syncMessage, content);
26359
26695
  let pending = false;
26360
26696
  let selectedHostId = null;
26697
+ let renderedHostId = null;
26361
26698
  let selectedItemKey = null;
26362
26699
  let launchControls = null;
26700
+ let renderedInspector = null;
26363
26701
  const hostNames = /* @__PURE__ */ new Map();
26702
+ const knownNotInstalled = /* @__PURE__ */ new Map();
26364
26703
  let latestSnapshot = null;
26365
- let disposeHostScroller = () => void 0;
26366
26704
  let disposed = false;
26367
26705
  let renderQueued = false;
26368
26706
  let renderFrame = null;
@@ -26396,7 +26734,99 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26396
26734
  scheduleRender
26397
26735
  );
26398
26736
  const installs = diagnostics ? harnessInstallStore(diagnostics) : null;
26399
- const updates = createConnectionUpdates(document2, messages, context.signal, scheduleRender);
26737
+ const updates = createConnectionUpdates(
26738
+ document2,
26739
+ messages,
26740
+ context.signal,
26741
+ scheduleRender,
26742
+ diagnostics
26743
+ );
26744
+ const panelId = "codexhost-settings-connection-host-panel";
26745
+ const empty = document2.createElement("div");
26746
+ empty.className = "settings-empty";
26747
+ empty.textContent = messages.connectionNoRuntime;
26748
+ const layout = document2.createElement("div");
26749
+ layout.className = "settings-connections-layout";
26750
+ const list = document2.createElement("section");
26751
+ list.className = "settings-connection-list";
26752
+ const hostStrip = document2.createElement("div");
26753
+ hostStrip.className = "settings-connection-host-strip";
26754
+ const scrollLeft = createHostScrollButton(document2, "left", messages);
26755
+ const tabs = document2.createElement("div");
26756
+ tabs.className = "settings-connection-host-tabs";
26757
+ tabs.setAttribute("role", "tablist");
26758
+ tabs.setAttribute("aria-label", messages.connectionHosts);
26759
+ const scrollRight = createHostScrollButton(document2, "right", messages);
26760
+ hostStrip.append(scrollLeft, tabs, scrollRight);
26761
+ const updateControls = updates.createControls("local", []);
26762
+ const hostHeader = document2.createElement("div");
26763
+ hostHeader.className = "settings-connection-host-header";
26764
+ hostHeader.append(hostStrip, updateControls.button);
26765
+ const tableHeader = document2.createElement("div");
26766
+ tableHeader.className = "settings-connection-table-header";
26767
+ tableHeader.setAttribute("role", "row");
26768
+ const componentHeading = document2.createElement("span");
26769
+ componentHeading.textContent = messages.connectionComponent;
26770
+ componentHeading.setAttribute("role", "columnheader");
26771
+ const statusHeading = document2.createElement("span");
26772
+ statusHeading.textContent = messages.connectionStatus;
26773
+ statusHeading.setAttribute("role", "columnheader");
26774
+ const actionHeading = document2.createElement("span");
26775
+ actionHeading.setAttribute("aria-hidden", "true");
26776
+ tableHeader.append(componentHeading, statusHeading, actionHeading);
26777
+ const rows = document2.createElement("div");
26778
+ rows.className = "settings-connection-rows";
26779
+ rows.id = panelId;
26780
+ rows.setAttribute("role", "rowgroup");
26781
+ list.append(hostHeader, updateControls.result, tableHeader, rows);
26782
+ const inspector = document2.createElement("aside");
26783
+ inspector.className = "settings-connection-inspector";
26784
+ inspector.setAttribute("aria-live", "polite");
26785
+ layout.append(list, inspector);
26786
+ const hostScroller = configureHostScroller(
26787
+ document2,
26788
+ hostStrip,
26789
+ tabs,
26790
+ scrollLeft,
26791
+ scrollRight
26792
+ );
26793
+ const hostTabElements = /* @__PURE__ */ new Map();
26794
+ const hostRowViews = /* @__PURE__ */ new Map();
26795
+ const groupDivider = createGroupDivider(document2);
26796
+ const moreHint = createGroupMoreHint(document2, messages);
26797
+ const moreZone = document2.createElement("div");
26798
+ moreZone.className = "settings-connection-group-more";
26799
+ moreZone.setAttribute("role", "presentation");
26800
+ const resetButton = createGroupResetButton(document2, messages, () => {
26801
+ groupPreference.resetToDefault();
26802
+ });
26803
+ let draggingAgent = null;
26804
+ let currentCatalog = [];
26805
+ let currentMainEntries = [];
26806
+ let currentMoreEntries = [];
26807
+ let currentHostRows = /* @__PURE__ */ new Map();
26808
+ const clearDropIndicators = () => {
26809
+ for (const view of currentHostRows.values()) {
26810
+ view.element.dataset.connectionDropIndicator = "";
26811
+ }
26812
+ moreZone.dataset.connectionDragOver = "false";
26813
+ };
26814
+ moreZone.addEventListener("dragover", (event) => {
26815
+ if (!draggingAgent) return;
26816
+ event.preventDefault();
26817
+ moreZone.dataset.connectionDragOver = "true";
26818
+ });
26819
+ moreZone.addEventListener("dragleave", () => {
26820
+ moreZone.dataset.connectionDragOver = "false";
26821
+ });
26822
+ moreZone.addEventListener("drop", (event) => {
26823
+ event.preventDefault();
26824
+ moreZone.dataset.connectionDragOver = "false";
26825
+ if (!draggingAgent) return;
26826
+ groupPreference.moveAgent(draggingAgent, "more", null, currentCatalog);
26827
+ draggingAgent = null;
26828
+ clearDropIndicators();
26829
+ });
26400
26830
  const runRefresh = () => {
26401
26831
  if (pending || !diagnostics) return;
26402
26832
  pending = true;
@@ -26409,6 +26839,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26409
26839
  success() {
26410
26840
  installs?.clearErrors();
26411
26841
  pending = false;
26842
+ renderedInspector = null;
26412
26843
  refresh.disabled = false;
26413
26844
  refresh.replaceChildren(
26414
26845
  createRendererSettingsIcon("diagnose", 16),
@@ -26418,6 +26849,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26418
26849
  },
26419
26850
  failure(error51) {
26420
26851
  pending = false;
26852
+ renderedInspector = null;
26421
26853
  refresh.disabled = false;
26422
26854
  refresh.replaceChildren(
26423
26855
  createRendererSettingsIcon("diagnose", 16),
@@ -26443,97 +26875,111 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26443
26875
  }
26444
26876
  });
26445
26877
  };
26878
+ const syncSelectedInspector = (hostId2, item) => {
26879
+ const currentDiagnostics = getDiagnostics();
26880
+ const signature = inspectorRenderSignature(hostId2, item, messages, currentDiagnostics);
26881
+ const versionElement = item.version?.element ?? null;
26882
+ if (renderedInspector?.signature === signature && renderedInspector.versionElement === versionElement) {
26883
+ return;
26884
+ }
26885
+ const existing = launchControls?.hostId === hostId2 && launchControls.itemKey === item.key ? launchControls.element : null;
26886
+ const element = renderConnectionInspector(
26887
+ document2,
26888
+ inspector,
26889
+ item,
26890
+ hostId2,
26891
+ messages,
26892
+ currentDiagnostics,
26893
+ existing,
26894
+ runRefresh
26895
+ );
26896
+ launchControls = { hostId: hostId2, itemKey: item.key, element };
26897
+ if (versionElement) inspector.append(versionElement);
26898
+ renderedInspector = { signature, versionElement };
26899
+ };
26446
26900
  const render = (snapshot) => {
26447
26901
  const syncStatus = groupPreference.syncStatus();
26448
26902
  const groupDisabled = syncStatus === "loading" || syncStatus === "saving";
26449
26903
  syncMessage.hidden = syncStatus === "ready";
26450
26904
  syncMessage.textContent = syncStatus === "error" ? messages.connectionGroupSyncFailed : syncStatus === "saving" ? messages.connectionGroupSaving : messages.connectionGroupLoading;
26451
26905
  latestSnapshot = snapshot;
26452
- disposeHostScroller();
26453
- disposeHostScroller = () => void 0;
26454
26906
  if (!snapshot) {
26455
- const empty = document2.createElement("div");
26456
- empty.className = "settings-empty";
26457
- empty.textContent = messages.connectionNoRuntime;
26458
- content.replaceChildren(empty);
26907
+ renderedHostId = null;
26908
+ renderedInspector = null;
26909
+ reconcileElementChildren(content, [empty]);
26459
26910
  return;
26460
26911
  }
26461
26912
  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];
26462
26913
  if (!selectedHost) return;
26463
26914
  selectedHostId = selectedHost.hostId;
26464
- const layout = document2.createElement("div");
26465
- layout.className = "settings-connections-layout";
26466
- const list = document2.createElement("section");
26467
- list.className = "settings-connection-list";
26468
- const hostStrip = document2.createElement("div");
26469
- hostStrip.className = "settings-connection-host-strip";
26470
- const scrollLeft = createHostScrollButton(document2, "left", messages);
26471
- const tabs = document2.createElement("div");
26472
- tabs.className = "settings-connection-host-tabs";
26473
- tabs.setAttribute("role", "tablist");
26474
- tabs.setAttribute("aria-label", messages.connectionHosts);
26475
- const scrollRight = createHostScrollButton(document2, "right", messages);
26476
- const panelId = "codexhost-settings-connection-host-panel";
26477
- snapshot.hosts.forEach((host, index) => {
26478
- const tab = document2.createElement("button");
26479
- tab.type = "button";
26480
- tab.className = "settings-connection-host-tab";
26481
- tab.dataset.connectionHostTab = host.hostId;
26482
- tab.dataset.connectionHostActive = String(host.active);
26483
- tab.setAttribute("role", "tab");
26484
- tab.setAttribute("aria-controls", panelId);
26485
- tab.setAttribute("aria-selected", String(host.hostId === selectedHost.hostId));
26486
- tab.tabIndex = host.hostId === selectedHost.hostId ? 0 : -1;
26915
+ const layoutFirstMount = content.children[0] !== layout;
26916
+ reconcileElementChildren(content, [layout]);
26917
+ let tabsChanged = tabs.children.length !== snapshot.hosts.length;
26918
+ const nextTabs = snapshot.hosts.map((host) => {
26919
+ let tab = hostTabElements.get(host.hostId);
26920
+ if (!tab) {
26921
+ tab = document2.createElement("button");
26922
+ tab.type = "button";
26923
+ tab.className = "settings-connection-host-tab";
26924
+ tab.dataset.connectionHostTab = host.hostId;
26925
+ tab.setAttribute("role", "tab");
26926
+ tab.setAttribute("aria-controls", panelId);
26927
+ tab.addEventListener("click", () => {
26928
+ selectedHostId = host.hostId;
26929
+ render(latestSnapshot);
26930
+ });
26931
+ tab.addEventListener("keydown", (event) => {
26932
+ if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
26933
+ event.preventDefault();
26934
+ const hosts = latestSnapshot?.hosts ?? [];
26935
+ const index = hosts.findIndex((candidate) => candidate.hostId === host.hostId);
26936
+ if (index < 0) return;
26937
+ const direction = event.key === "ArrowRight" ? 1 : -1;
26938
+ const next = hosts[(index + direction + hosts.length) % hosts.length];
26939
+ if (!next) return;
26940
+ selectedHostId = next.hostId;
26941
+ render(latestSnapshot);
26942
+ hostTabElements.get(next.hostId)?.focus();
26943
+ });
26944
+ hostTabElements.set(host.hostId, tab);
26945
+ tabsChanged = true;
26946
+ }
26947
+ const isSelected = host.hostId === selectedHost.hostId;
26948
+ const activeValue = String(host.active);
26949
+ if (tab.dataset.connectionHostActive !== activeValue) {
26950
+ tab.dataset.connectionHostActive = activeValue;
26951
+ }
26952
+ const selectedValue = String(isSelected);
26953
+ if (tab.getAttribute("aria-selected") !== selectedValue) {
26954
+ tab.setAttribute("aria-selected", selectedValue);
26955
+ }
26956
+ const nextTabIndex = isSelected ? 0 : -1;
26957
+ if (tab.tabIndex !== nextTabIndex) {
26958
+ tab.tabIndex = nextTabIndex;
26959
+ }
26487
26960
  const hostName = hostNames.get(host.hostId) || connectionHostName(host.hostId, messages);
26488
- tab.textContent = hostName;
26489
- tab.title = host.active ? `${hostName} \xB7 ${messages.connectionActiveHost}` : hostName;
26490
- tab.addEventListener("click", () => {
26491
- selectedHostId = host.hostId;
26492
- render(latestSnapshot);
26493
- });
26494
- tab.addEventListener("keydown", (event) => {
26495
- if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
26496
- event.preventDefault();
26497
- const direction = event.key === "ArrowRight" ? 1 : -1;
26498
- const next = snapshot.hosts[(index + direction + snapshot.hosts.length) % snapshot.hosts.length];
26499
- if (!next) return;
26500
- selectedHostId = next.hostId;
26501
- render(latestSnapshot);
26502
- const nextTab = [
26503
- ...content.querySelectorAll("[data-connection-host-tab]")
26504
- ].find((candidate) => candidate.dataset.connectionHostTab === next.hostId);
26505
- nextTab?.focus();
26506
- });
26507
- tabs.append(tab);
26961
+ if (tab.textContent !== hostName) {
26962
+ tab.textContent = hostName;
26963
+ tabsChanged = true;
26964
+ }
26965
+ const tabTitle = host.active ? `${hostName} \xB7 ${messages.connectionActiveHost}` : hostName;
26966
+ if (tab.title !== tabTitle) {
26967
+ tab.title = tabTitle;
26968
+ }
26969
+ return tab;
26508
26970
  });
26509
- hostStrip.append(scrollLeft, tabs, scrollRight);
26510
- const tableHeader = document2.createElement("div");
26511
- tableHeader.className = "settings-connection-table-header";
26512
- tableHeader.setAttribute("role", "row");
26513
- const componentHeading = document2.createElement("span");
26514
- componentHeading.textContent = messages.connectionComponent;
26515
- componentHeading.setAttribute("role", "columnheader");
26516
- const statusHeading = document2.createElement("span");
26517
- statusHeading.textContent = messages.connectionStatus;
26518
- statusHeading.setAttribute("role", "columnheader");
26519
- const actionHeading = document2.createElement("span");
26520
- actionHeading.setAttribute("aria-hidden", "true");
26521
- tableHeader.append(componentHeading, statusHeading, actionHeading);
26522
- const rows = document2.createElement("div");
26523
- rows.className = "settings-connection-rows";
26524
- rows.id = panelId;
26525
- rows.dataset.connectionHost = selectedHost.hostId;
26526
- rows.setAttribute("role", "rowgroup");
26527
- const inspector = document2.createElement("aside");
26528
- inspector.className = "settings-connection-inspector";
26529
- inspector.setAttribute("aria-live", "polite");
26971
+ reconcileElementChildren(tabs, nextTabs);
26972
+ if (rows.dataset.connectionHost !== selectedHost.hostId) {
26973
+ rows.dataset.connectionHost = selectedHost.hostId;
26974
+ }
26530
26975
  const items = connectionItems(snapshot, selectedHost, messages, diagnostics).map(
26531
26976
  (item) => {
26532
26977
  const agent = item.agentSnapshot?.agent;
26533
26978
  if (!agent) return item;
26534
26979
  const state = installs?.get(selectedHost.hostId, agent);
26535
26980
  const availability = state?.status ?? item.availability;
26536
- const version2 = item.agentSnapshot?.availability !== "notInstalled" && availability !== "installing" && availability !== "checking" ? versions.get(selectedHost.hostId, agent) : void 0;
26981
+ const updating = versions.isUpdating(selectedHost.hostId, agent);
26982
+ const version2 = updating || item.agentSnapshot?.availability !== "notInstalled" && availability !== "installing" && availability !== "checking" ? versions.get(selectedHost.hostId, agent) : void 0;
26537
26983
  return {
26538
26984
  ...item,
26539
26985
  ...state ? { availability: state.status } : {},
@@ -26555,66 +27001,66 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26555
27001
  (item) => item.agentSnapshot?.availability === "notInstalled" || item.error !== null
26556
27002
  )?.key ?? items[0]?.key ?? null;
26557
27003
  }
26558
- const rowElements = /* @__PURE__ */ new Map();
27004
+ let hostRows = hostRowViews.get(selectedHost.hostId);
27005
+ if (!hostRows) {
27006
+ hostRows = /* @__PURE__ */ new Map();
27007
+ hostRowViews.set(selectedHost.hostId, hostRows);
27008
+ }
27009
+ currentHostRows = hostRows;
26559
27010
  const selectItem = (item) => {
26560
27011
  selectedItemKey = item.key;
26561
- for (const [key, row] of rowElements) {
26562
- const selected = key === item.key;
26563
- row.dataset.connectionSelected = String(selected);
26564
- row.tabIndex = selected ? 0 : -1;
27012
+ for (const [key, view] of currentHostRows) {
27013
+ view.setSelected(key === item.key);
26565
27014
  }
26566
- const existing = launchControls?.hostId === selectedHost.hostId && launchControls.itemKey === item.key ? launchControls.element : null;
26567
- const element = renderConnectionInspector(
26568
- document2,
26569
- inspector,
26570
- item,
26571
- selectedHost.hostId,
26572
- messages,
26573
- getDiagnostics(),
26574
- existing,
26575
- runRefresh
26576
- );
26577
- launchControls = { hostId: selectedHost.hostId, itemKey: item.key, element };
26578
- if (item.version) inspector.append(item.version.element);
27015
+ syncSelectedInspector(selectedHost.hostId, item);
26579
27016
  };
26580
- const pinnedItem = items.find((item) => item.key === "renderer-adapter");
26581
- if (pinnedItem) {
26582
- const row = createConnectionRow(
26583
- document2,
27017
+ const ensureRowView = (key, groupable) => {
27018
+ let view = hostRows.get(key);
27019
+ if (!view) {
27020
+ view = createConnectionRowView(document2, messages, groupable);
27021
+ hostRows.set(key, view);
27022
+ }
27023
+ return view;
27024
+ };
27025
+ const activeKeys = /* @__PURE__ */ new Set();
27026
+ const nextRowChildren = [];
27027
+ const pinnedItems = items.filter((item) => item.agentSnapshot === void 0);
27028
+ for (const pinnedItem of pinnedItems) {
27029
+ activeKeys.add(pinnedItem.key);
27030
+ const view = ensureRowView(pinnedItem.key, false);
27031
+ view.update(
26584
27032
  pinnedItem,
26585
- messages,
26586
27033
  pinnedItem.key === selectedItemKey,
26587
- () => selectItem(pinnedItem)
27034
+ () => selectItem(pinnedItem),
27035
+ null
26588
27036
  );
26589
- rowElements.set(pinnedItem.key, row);
26590
- rows.append(row);
27037
+ nextRowChildren.push(view.element);
26591
27038
  }
26592
27039
  const groupableItems = items.filter(
26593
27040
  (item) => item.agentSnapshot !== void 0
26594
27041
  );
26595
27042
  const agentByKey = new Map(groupableItems.map((item) => [item.key, item]));
26596
- const catalog = groupableItems.map((item) => ({ id: item.key, name: item.name }));
26597
- const preferenceOrder = groupPreference.list(
26598
- new Set(
26599
- groupableItems.filter((item) => item.agentSnapshot.availability === "notInstalled").map((item) => item.agentSnapshot.agent)
26600
- ),
26601
- catalog
26602
- ).filter((entry) => agentByKey.has(entry.agent));
26603
- const mainEntries = preferenceOrder.filter((entry) => entry.section === "main");
26604
- const moreEntries = preferenceOrder.filter((entry) => entry.section === "more");
27043
+ currentCatalog = groupableItems.map((item) => ({ id: item.key, name: item.name }));
27044
+ const notInstalledAgents = /* @__PURE__ */ new Set();
27045
+ for (const item of groupableItems) {
27046
+ const agent = item.agentSnapshot.agent;
27047
+ const stateKey = `${selectedHost.hostId}:${agent}`;
27048
+ if (item.agentSnapshot.availability !== "checking") {
27049
+ knownNotInstalled.set(stateKey, item.agentSnapshot.availability === "notInstalled");
27050
+ }
27051
+ const isNotInstalled = item.agentSnapshot.availability === "checking" ? knownNotInstalled.get(stateKey) ?? false : item.agentSnapshot.availability === "notInstalled";
27052
+ if (isNotInstalled) notInstalledAgents.add(agent);
27053
+ }
27054
+ const preferenceOrder = groupPreference.list(notInstalledAgents, currentCatalog).filter((entry) => agentByKey.has(entry.agent));
27055
+ currentMainEntries = preferenceOrder.filter((entry) => entry.section === "main");
27056
+ currentMoreEntries = preferenceOrder.filter((entry) => entry.section === "more");
26605
27057
  const nextInSection = (section, agent) => {
26606
- const list2 = section === "main" ? mainEntries : moreEntries;
26607
- const index = list2.findIndex((entry) => entry.agent === agent);
26608
- return index >= 0 ? list2[index + 1]?.agent ?? null : null;
26609
- };
26610
- let draggingAgent = null;
26611
- let moreZone = null;
26612
- const clearDropIndicators = () => {
26613
- for (const row of rowElements.values()) row.dataset.connectionDropIndicator = "";
26614
- if (moreZone) moreZone.dataset.connectionDragOver = "false";
27058
+ const sectionEntries = section === "main" ? currentMainEntries : currentMoreEntries;
27059
+ const index = sectionEntries.findIndex((entry) => entry.agent === agent);
27060
+ return index >= 0 ? sectionEntries[index + 1]?.agent ?? null : null;
26615
27061
  };
26616
27062
  const dropTargetSection = (agent, event) => {
26617
- const row = rowElements.get(agent);
27063
+ const row = currentHostRows.get(agent)?.element;
26618
27064
  const rect = row && typeof row.getBoundingClientRect === "function" ? row.getBoundingClientRect() : null;
26619
27065
  const before = rect ? event.clientY - rect.top < rect.height / 2 : true;
26620
27066
  const section = row?.dataset.connectionGroupSection ?? "main";
@@ -26626,7 +27072,12 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26626
27072
  moveLabel: section === "main" ? messages.connectionGroupMoveToMore : messages.connectionGroupMoveToMain,
26627
27073
  dragHandleTitle: messages.connectionGroupDragHandle,
26628
27074
  toggleSection() {
26629
- groupPreference.moveAgent(agent, section === "main" ? "more" : "main", null, catalog);
27075
+ groupPreference.moveAgent(
27076
+ agent,
27077
+ section === "main" ? "more" : "main",
27078
+ null,
27079
+ currentCatalog
27080
+ );
26630
27081
  },
26631
27082
  onDragStart(event) {
26632
27083
  if (groupDisabled) {
@@ -26636,127 +27087,107 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26636
27087
  draggingAgent = agent;
26637
27088
  event.dataTransfer?.setData("text/plain", agent);
26638
27089
  if (event.dataTransfer) event.dataTransfer.effectAllowed = "move";
26639
- const row = rowElements.get(agent);
27090
+ const row = currentHostRows.get(agent)?.element;
26640
27091
  if (row) row.dataset.connectionDragging = "true";
26641
27092
  },
26642
27093
  onDragOver(event) {
26643
27094
  if (!draggingAgent || draggingAgent === agent) return;
26644
27095
  event.preventDefault();
26645
- const row = rowElements.get(agent);
27096
+ const row = currentHostRows.get(agent)?.element;
26646
27097
  if (!row) return;
26647
27098
  const { before } = dropTargetSection(agent, event);
26648
27099
  clearDropIndicators();
26649
27100
  row.dataset.connectionDropIndicator = before ? "before" : "after";
26650
27101
  },
26651
27102
  onDragLeave() {
26652
- const row = rowElements.get(agent);
27103
+ const row = currentHostRows.get(agent)?.element;
26653
27104
  if (row) row.dataset.connectionDropIndicator = "";
26654
27105
  },
26655
27106
  onDrop(event) {
26656
27107
  event.preventDefault();
26657
27108
  if (!draggingAgent) return;
26658
27109
  const { beforeAgent } = dropTargetSection(agent, event);
26659
- groupPreference.moveAgent(draggingAgent, section, beforeAgent, catalog);
27110
+ groupPreference.moveAgent(draggingAgent, section, beforeAgent, currentCatalog);
26660
27111
  draggingAgent = null;
26661
27112
  clearDropIndicators();
26662
27113
  },
26663
27114
  onDragEnd() {
26664
27115
  draggingAgent = null;
26665
- const row = rowElements.get(agent);
27116
+ const row = currentHostRows.get(agent)?.element;
26666
27117
  if (row) row.dataset.connectionDragging = "false";
26667
27118
  clearDropIndicators();
27119
+ scheduleRender();
26668
27120
  }
26669
27121
  });
26670
- const appendGroupRow = (agent, section) => {
26671
- const item = agentByKey.get(agent);
26672
- if (!item) return;
26673
- const row = createConnectionRow(
26674
- document2,
27122
+ for (const entry of currentMainEntries) {
27123
+ const item = agentByKey.get(entry.agent);
27124
+ if (!item) continue;
27125
+ activeKeys.add(item.key);
27126
+ const view = ensureRowView(item.key, true);
27127
+ view.update(
26675
27128
  item,
26676
- messages,
26677
27129
  item.key === selectedItemKey,
26678
27130
  () => selectItem(item),
26679
- createGroupController(agent, section)
27131
+ createGroupController(entry.agent, "main")
26680
27132
  );
26681
- rowElements.set(item.key, row);
26682
- rows.append(row);
26683
- };
26684
- for (const entry of mainEntries) appendGroupRow(entry.agent, "main");
27133
+ nextRowChildren.push(view.element);
27134
+ }
26685
27135
  if (groupableItems.length > 0) {
26686
- rows.append(createGroupDivider(document2, messages, moreEntries.length));
26687
- const zone = document2.createElement("div");
26688
- moreZone = zone;
26689
- zone.className = "settings-connection-group-more";
26690
- zone.setAttribute("role", "presentation");
26691
- zone.addEventListener("dragover", (event) => {
26692
- if (!draggingAgent) return;
26693
- event.preventDefault();
26694
- zone.dataset.connectionDragOver = "true";
26695
- });
26696
- zone.addEventListener("dragleave", () => {
26697
- zone.dataset.connectionDragOver = "false";
26698
- });
26699
- zone.addEventListener("drop", (event) => {
26700
- event.preventDefault();
26701
- zone.dataset.connectionDragOver = "false";
26702
- if (!draggingAgent) return;
26703
- groupPreference.moveAgent(draggingAgent, "more", null, catalog);
26704
- draggingAgent = null;
26705
- clearDropIndicators();
26706
- });
26707
- if (moreEntries.length === 0) {
26708
- zone.append(createGroupMoreHint(document2, messages));
27136
+ const dividerText = `${messages.connectionGroupMoreLabel} (${currentMoreEntries.length})`;
27137
+ if (groupDivider.textContent !== dividerText) {
27138
+ groupDivider.textContent = dividerText;
27139
+ }
27140
+ nextRowChildren.push(groupDivider);
27141
+ const nextMoreChildren = [];
27142
+ if (currentMoreEntries.length === 0) {
27143
+ nextMoreChildren.push(moreHint);
26709
27144
  } else {
26710
- for (const entry of moreEntries) {
27145
+ for (const entry of currentMoreEntries) {
26711
27146
  const item = agentByKey.get(entry.agent);
26712
27147
  if (!item) continue;
26713
- const row = createConnectionRow(
26714
- document2,
27148
+ activeKeys.add(item.key);
27149
+ const view = ensureRowView(item.key, true);
27150
+ view.update(
26715
27151
  item,
26716
- messages,
26717
27152
  item.key === selectedItemKey,
26718
27153
  () => selectItem(item),
26719
27154
  createGroupController(entry.agent, "more")
26720
27155
  );
26721
- rowElements.set(item.key, row);
26722
- zone.append(row);
27156
+ nextMoreChildren.push(view.element);
26723
27157
  }
26724
27158
  }
26725
- rows.append(zone);
26726
- const reset = createGroupResetButton(document2, messages, () => {
26727
- groupPreference.resetToDefault();
26728
- });
26729
- reset.disabled = groupDisabled;
26730
- rows.append(reset);
27159
+ if (!draggingAgent || renderedHostId !== selectedHost.hostId) {
27160
+ reconcileElementChildren(moreZone, nextMoreChildren);
27161
+ }
27162
+ nextRowChildren.push(moreZone);
27163
+ resetButton.disabled = groupDisabled;
27164
+ nextRowChildren.push(resetButton);
27165
+ }
27166
+ for (const key of hostRows.keys()) {
27167
+ if (!activeKeys.has(key)) hostRows.delete(key);
27168
+ }
27169
+ if (!draggingAgent || renderedHostId !== selectedHost.hostId) {
27170
+ reconcileElementChildren(rows, nextRowChildren);
26731
27171
  }
26732
27172
  const selectedItem = items.find((item) => item.key === selectedItemKey) ?? items[0];
26733
27173
  if (selectedItem) selectItem(selectedItem);
26734
- const updateControls = updates.createControls(
27174
+ updateControls.update(
26735
27175
  selectedHost.hostId,
26736
27176
  items.flatMap((item) => item.version ? [item.version] : [])
26737
27177
  );
26738
- const hostHeader = document2.createElement("div");
26739
- hostHeader.className = "settings-connection-host-header";
26740
- hostHeader.append(hostStrip, updateControls.button);
26741
- list.append(hostHeader, updateControls.result, tableHeader, rows);
26742
- layout.append(list, inspector);
26743
- content.replaceChildren(layout);
26744
- disposeHostScroller = configureHostScroller(
26745
- document2,
26746
- hostStrip,
26747
- tabs,
26748
- scrollLeft,
26749
- scrollRight
26750
- );
26751
- const selectedTab = [...tabs.children].find(
26752
- (child) => child.getAttribute("aria-selected") === "true"
26753
- );
26754
- if (selectedTab) {
26755
- const left = selectedTab.offsetLeft;
26756
- const right = left + selectedTab.offsetWidth;
26757
- if (left < tabs.scrollLeft) tabs.scrollLeft = left;
26758
- else if (right > tabs.scrollLeft + tabs.clientWidth) {
26759
- tabs.scrollLeft = right - tabs.clientWidth;
27178
+ if (layoutFirstMount || tabsChanged) {
27179
+ hostScroller.update();
27180
+ }
27181
+ if (renderedHostId !== selectedHost.hostId) {
27182
+ renderedHostId = selectedHost.hostId;
27183
+ const selectedTab = hostTabElements.get(selectedHost.hostId);
27184
+ if (selectedTab) {
27185
+ const left = selectedTab.offsetLeft;
27186
+ const right = left + selectedTab.offsetWidth;
27187
+ if (left < tabs.scrollLeft) tabs.scrollLeft = left;
27188
+ else if (right > tabs.scrollLeft + tabs.clientWidth) {
27189
+ tabs.scrollLeft = right - tabs.clientWidth;
27190
+ }
26760
27191
  }
26761
27192
  }
26762
27193
  };
@@ -26777,7 +27208,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26777
27208
  refresh.disabled = true;
26778
27209
  return () => {
26779
27210
  cancelRender();
26780
- disposeHostScroller();
27211
+ hostScroller.dispose();
26781
27212
  unsubscribeGroup();
26782
27213
  };
26783
27214
  }
@@ -26786,7 +27217,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26786
27217
  const unsubscribeInstalls = installs?.subscribe(scheduleRender);
26787
27218
  return () => {
26788
27219
  cancelRender();
26789
- disposeHostScroller();
27220
+ hostScroller.dispose();
26790
27221
  unsubscribeInstalls?.();
26791
27222
  unsubscribe();
26792
27223
  unsubscribeGroup();
@@ -28343,9 +28774,13 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28343
28774
  resets: "Resets",
28344
28775
  details: "Account limit details",
28345
28776
  weekly: "Weekly limit",
28777
+ weeklyShort: "Weekly",
28346
28778
  monthly: "Monthly limit",
28779
+ monthlyShort: "Monthly",
28347
28780
  fiveHour: "5-hour limit",
28781
+ fiveHourShort: "5-hour",
28348
28782
  sevenDay: "7-day limit",
28783
+ sevenDayShort: "7-day",
28349
28784
  account: "Account limit"
28350
28785
  });
28351
28786
  var CHINESE_CREDITS_MESSAGES = Object.freeze({
@@ -28353,9 +28788,13 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28353
28788
  resets: "\u91CD\u7F6E",
28354
28789
  details: "\u8D26\u53F7\u989D\u5EA6\u8BE6\u60C5",
28355
28790
  weekly: "\u5468\u989D\u5EA6",
28791
+ weeklyShort: "\u5468\u989D\u5EA6",
28356
28792
  monthly: "\u6708\u989D\u5EA6",
28793
+ monthlyShort: "\u6708\u989D\u5EA6",
28357
28794
  fiveHour: "5 \u5C0F\u65F6\u989D\u5EA6",
28795
+ fiveHourShort: "5 \u5C0F\u65F6",
28358
28796
  sevenDay: "7 \u5929\u989D\u5EA6",
28797
+ sevenDayShort: "7 \u5929",
28359
28798
  account: "\u8D26\u53F7\u989D\u5EA6"
28360
28799
  });
28361
28800
  function formatRendererCreditsReset(value, now = /* @__PURE__ */ new Date(), locale = "en") {
@@ -31330,6 +31769,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
31330
31769
  .settings-connection-inspector {
31331
31770
  position: sticky;
31332
31771
  top: 18px;
31772
+ overflow-anchor: none;
31333
31773
  }
31334
31774
 
31335
31775
  .settings-connection-inspector__header {
@@ -32685,6 +33125,11 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
32685
33125
  // src/web-settings-entry.ts
32686
33126
  var WEB_LAYOUT_CSS = `.settings-page { background: transparent; overflow: visible; container: codexhost-settings-page / inline-size; }
32687
33127
  .settings-page__content { width: 100%; padding: 0; }`;
33128
+ var sharedConnectionDiagnostics = null;
33129
+ function getWebConnectionDiagnostics(client) {
33130
+ sharedConnectionDiagnostics ??= createConsoleConnectionDiagnostics(client);
33131
+ return sharedConnectionDiagnostics;
33132
+ }
32688
33133
  function resourcesPage(messages, client) {
32689
33134
  return {
32690
33135
  id: "resources",
@@ -32714,7 +33159,6 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
32714
33159
  () => modelClient,
32715
33160
  { migrateLegacy: false }
32716
33161
  );
32717
- const diagnostics = createConsoleConnectionDiagnostics(modelClient);
32718
33162
  const updateClient = {
32719
33163
  checkUpdate: () => modelClient.checkUpdate(),
32720
33164
  startUpdate: () => modelClient.startUpdate(),
@@ -32724,7 +33168,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
32724
33168
  ...createDefaultRendererSettingsPages(
32725
33169
  messages,
32726
33170
  () => updateClient,
32727
- () => diagnostics,
33171
+ () => getWebConnectionDiagnostics(modelClient),
32728
33172
  () => modelClient,
32729
33173
  () => null,
32730
33174
  null,