@liberseek/boft-cli-linux-x64 0.8.7 → 0.8.9

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 (67) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +59 -6
  4. package/app/console-web.js +1376 -1053
  5. package/app/desktop-controller.mjs +239 -57
  6. package/app/host-runtime.mjs +32921 -24901
  7. package/app/plugins/antigravity/assets/icon.svg +1 -1
  8. package/app/plugins/antigravity/plugin.mjs +9491 -4266
  9. package/app/plugins/claude-code/plugin.mjs +580 -116
  10. package/app/plugins/codebuddy/plugin.mjs +85 -8
  11. package/app/plugins/codex-usage/plugin.mjs +70 -6
  12. package/app/plugins/copilot/plugin.mjs +62 -6
  13. package/app/plugins/cursor-cli/plugin.mjs +62 -6
  14. package/app/plugins/deepseek-harness/plugin.mjs +87 -11
  15. package/app/plugins/devin/plugin.mjs +61 -6
  16. package/app/plugins/grok/plugin.mjs +320 -223
  17. package/app/plugins/hermes/plugin.mjs +61 -6
  18. package/app/plugins/kimi-code/plugin.mjs +87 -16
  19. package/app/plugins/kiro-cli/plugin.mjs +62 -6
  20. package/app/plugins/muse/plugin.mjs +61 -6
  21. package/app/plugins/omp/plugin.mjs +195 -31
  22. package/app/plugins/opencode/plugin.mjs +88 -15
  23. package/app/plugins/pi/plugin.mjs +207 -32
  24. package/app/plugins/qoder/plugin.mjs +99 -7
  25. package/app/plugins/qoder-cn/plugin.mjs +99 -7
  26. package/app/plugins/qwen-code/plugin.mjs +62 -6
  27. package/app/plugins/workbuddy/plugin.mjs +89 -11
  28. package/app/plugins/zcode/plugin.mjs +70 -6
  29. package/app/renderer-extension.js +1767 -1187
  30. package/app/web/assets/index-C2OA-eHT.js +201 -0
  31. package/app/web/assets/index-DJW4bmyx.css +1 -0
  32. package/app/web/assets/langs/{graphql-B8vkg11W.js → graphql-ChAeyPkT.js} +1 -1
  33. package/app/web/assets/langs/{http-DmoDEjMt.js → http-BvreBIbD.js} +1 -1
  34. package/app/web/assets/langs/{php-DJ5ovfAM.js → php-D8omCIuJ.js} +1 -1
  35. package/app/web/assets/langs/{rst-U5-R5x3p.js → rst-Do7RLLCS.js} +1 -1
  36. package/app/web/assets/langs/{ruby-VKVsnS0H.js → ruby-rH_O_vse.js} +1 -1
  37. package/app/web/assets/langs/{svelte-C20lOv9V.js → svelte-xZy73wAj.js} +1 -1
  38. package/app/web/assets/langs/{vue-z6Y-lzP-.js → vue-C4DW8agZ.js} +1 -1
  39. package/app/web/assets/{vendor-dSL872WO.js → vendor-C9g2bw8s.js} +3 -3
  40. package/app/web/codexhost-settings.js +1383 -1056
  41. package/app/web/index.html +4 -3
  42. package/app/web/plugins/deepseek-ai__dsh-api-gateway/client.js +2 -2
  43. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
  44. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +11 -11
  45. package/app/web/plugins/deepseek-ai__dsh-client-connection/client.js +1 -1
  46. package/app/web/plugins/deepseek-ai__dsh-client-locale/client.js +3 -3
  47. package/app/web/plugins/deepseek-ai__dsh-client-ui-attachment/client.js +1 -1
  48. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +74 -69
  49. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +3 -3
  50. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +28 -28
  51. package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
  52. package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
  53. package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +1 -1
  54. package/app/web/plugins/deepseek-ai__dsh-client-ui-session/client.js +1 -1
  55. package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
  56. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar/client.js +1 -1
  57. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +9 -9
  58. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-files/client.js +1 -1
  59. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
  60. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +11 -11
  61. package/app/web-modules/server.mjs +2458 -1615
  62. package/bin/boft +0 -0
  63. package/libexec/boft-shim +0 -0
  64. package/libexec/boft-updater +0 -0
  65. package/package.json +1 -1
  66. package/app/web/assets/index-CP6wY-1D.css +0 -1
  67. package/app/web/assets/index-Da35Phrd.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(),
@@ -15136,11 +15149,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15136
15149
  delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
15137
15150
  }).strict();
15138
15151
 
15152
+ // ../shared-contracts/dist/thread-archive-confirm.js
15153
+ var threadArchiveConfirmParamsSchema = external_exports.object({ threadId: hostThreadIdSchema }).strict();
15154
+ var threadArchiveConfirmResultSchema = external_exports.object({ confirmed: external_exports.boolean() }).strict();
15155
+
15139
15156
  // ../shared-contracts/dist/client-channel.js
15140
15157
  var CLIENT_CHANNEL_VERSION = 1;
15141
15158
  var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
15142
15159
  var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
15143
15160
  var clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict();
15161
+ var clientThreadTreeReadParamsSchema = external_exports.object({}).strict();
15162
+ var clientThreadTreeSchema = external_exports.object({
15163
+ parents: external_exports.record(external_exports.string().min(1), external_exports.string().min(1))
15164
+ }).strict();
15144
15165
  var clientProjectlessWorkspaceSchema = external_exports.object({
15145
15166
  prompt: external_exports.string().max(16384).optional()
15146
15167
  }).strict();
@@ -15162,6 +15183,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15162
15183
  cursor: clientChannelCursorSchema,
15163
15184
  cwd: external_exports.string().optional()
15164
15185
  }),
15186
+ external_exports.object({
15187
+ type: external_exports.literal("harness-inspection-changed"),
15188
+ cursor: clientChannelCursorSchema,
15189
+ harnessId: external_exports.string().min(1)
15190
+ }),
15165
15191
  external_exports.object({ type: external_exports.literal("display-settings-changed"), cursor: clientChannelCursorSchema }),
15166
15192
  external_exports.object({
15167
15193
  type: external_exports.literal("preferences-changed"),
@@ -15233,6 +15259,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15233
15259
  var clientTurnSchema = external_exports.object({
15234
15260
  id: external_exports.string().min(1),
15235
15261
  status: external_exports.string().min(1),
15262
+ /** Native history has no terminal evidence; Desktop's status vocabulary cannot express this. */
15263
+ codexhostTurnOutcome: external_exports.object({ status: external_exports.literal("unknown"), reason: external_exports.string() }).optional(),
15236
15264
  items: external_exports.array(external_exports.object({ id: external_exports.string().min(1), type: external_exports.string().min(1) }).passthrough()),
15237
15265
  /** Original file operations, independent of the cumulative Desktop fileChange card.
15238
15266
  * Insert before the named non-file Item; null appends at the end of the Turn.
@@ -15271,7 +15299,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15271
15299
  /** Current interruptible Host Turn, including command Turns omitted from client history. */
15272
15300
  activeTurnId: external_exports.string().min(1).nullable().optional(),
15273
15301
  /** Most recent explicit command in this Host process; not native conversation history. */
15274
- command: external_exports.object({ name: external_exports.string().min(1), turn: clientTurnSchema }).optional(),
15302
+ command: external_exports.object({
15303
+ name: external_exports.string().min(1),
15304
+ turn: clientTurnSchema,
15305
+ /** First ordinary Turn started after this command; its retained result is not a new event. */
15306
+ subsequentTurnId: external_exports.string().min(1).optional()
15307
+ }).optional(),
15275
15308
  thread: external_exports.object({
15276
15309
  id: external_exports.string().min(1),
15277
15310
  cwd: external_exports.string(),
@@ -15481,7 +15514,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15481
15514
  quotaUntil: external_exports.string().optional()
15482
15515
  }).strict().optional()
15483
15516
  }).strict();
15484
- var webLocalAccessRequiredDetailsSchema = external_exports.object({ url: external_exports.string() }).strict();
15485
15517
 
15486
15518
  // ../shared-contracts/dist/delegation-read.js
15487
15519
  var REMOTE_THREAD_REPLY_MAX_BYTES = 16 * 1024 * 1024;
@@ -15489,8 +15521,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15489
15521
  var delegationReadParamsSchema = external_exports.strictObject({
15490
15522
  threadId: external_exports.string().min(1).max(1024),
15491
15523
  view: external_exports.enum(["result", "messages"]),
15492
- cursor: external_exports.string().min(1).max(8192).optional(),
15493
- limit: external_exports.number().int().min(1).max(100).optional()
15524
+ from: external_exports.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional(),
15525
+ to: external_exports.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional()
15494
15526
  });
15495
15527
 
15496
15528
  // ../shared-contracts/dist/credential-imports.js
@@ -16505,6 +16537,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16505
16537
  "completed",
16506
16538
  "failed",
16507
16539
  "interrupted",
16540
+ "needsInput",
16508
16541
  "timedOut",
16509
16542
  "unreadable",
16510
16543
  "notFound"
@@ -16554,13 +16587,26 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16554
16587
  var thread = { ...target, threadId: identity };
16555
16588
  var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
16556
16589
  external_exports.strictObject({ kind: external_exports.literal("hosts") }),
16590
+ external_exports.strictObject({ kind: external_exports.literal("status"), ...thread }),
16557
16591
  external_exports.strictObject({
16558
16592
  kind: external_exports.literal("list"),
16559
16593
  ...target,
16560
16594
  cursor: external_exports.string().nullable(),
16561
16595
  archived: external_exports.boolean()
16562
16596
  }),
16563
- external_exports.strictObject({ kind: external_exports.literal("read"), ...thread }),
16597
+ external_exports.strictObject({
16598
+ kind: external_exports.literal("read"),
16599
+ ...thread,
16600
+ page: external_exports.strictObject({
16601
+ cursor: external_exports.string().min(1).max(8192).nullable(),
16602
+ epoch: identity.optional(),
16603
+ sortDirection: external_exports.enum(["asc", "desc"]).optional(),
16604
+ limit: external_exports.number().int().min(1).max(20).optional()
16605
+ }).refine((page) => page.cursor === null || page.epoch !== void 0, {
16606
+ message: "A history continuation requires its connection epoch"
16607
+ }).optional()
16608
+ }),
16609
+ external_exports.strictObject({ kind: external_exports.literal("usage"), ...thread, epoch: identity }),
16564
16610
  external_exports.strictObject({
16565
16611
  kind: external_exports.literal("configure"),
16566
16612
  ...thread,
@@ -16641,6 +16687,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16641
16687
  external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
16642
16688
  ]);
16643
16689
 
16690
+ // ../shared-contracts/dist/thread-title.js
16691
+ var threadTitleInputSchema = external_exports.strictObject({
16692
+ prompt: external_exports.string().trim().min(1).max(2e3),
16693
+ cwd: external_exports.string().max(4096).nullable()
16694
+ });
16695
+ var threadTitleResultSchema = external_exports.string().trim().min(1).max(60).nullable();
16696
+
16644
16697
  // ../shared-contracts/dist/web-ui-extensions.js
16645
16698
  var webUiExtensionIdSchema = external_exports.string().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u);
16646
16699
  var localizedTextSchema2 = external_exports.union([
@@ -16693,11 +16746,18 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16693
16746
  const webUi = /* @__PURE__ */ new Map();
16694
16747
  const listeners = /* @__PURE__ */ new Set();
16695
16748
  let pending = null;
16749
+ let queuedRefresh = null;
16696
16750
  const publish = () => {
16697
16751
  for (const listener of [...listeners]) listener();
16698
16752
  };
16699
16753
  const inspectAll = (refresh) => {
16700
- if (pending) return pending;
16754
+ if (pending) {
16755
+ if (!refresh) return pending;
16756
+ queuedRefresh ??= pending.then(() => inspectAll(true)).finally(() => {
16757
+ queuedRefresh = null;
16758
+ });
16759
+ return queuedRefresh;
16760
+ }
16701
16761
  pending = Promise.resolve().then(async () => {
16702
16762
  try {
16703
16763
  if (!client.listHarnessPlugins)
@@ -16715,7 +16775,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16715
16775
  await Promise.all(
16716
16776
  plugins.map(async ({ id }) => {
16717
16777
  try {
16718
- const inspection = await client.inspectHarness({ harnessId: id, refresh });
16778
+ const inspection = await client.inspectHarness({
16779
+ harnessId: id,
16780
+ refresh,
16781
+ purpose: "availability"
16782
+ });
16719
16783
  availability.set(id, inspection.status);
16720
16784
  webUi.set(id, inspection.status === "ready" && inspection.webUi?.open === true);
16721
16785
  const error51 = inspection.status === "ready" ? null : inspection.error;
@@ -20806,9 +20870,11 @@ th[aria-sort] .console-usage-sort__mark {
20806
20870
  title: "Settings",
20807
20871
  close: "Close settings",
20808
20872
  sectionsLabel: "Settings sections",
20809
- connectionSection: "Connections",
20873
+ agentsSection: "Agents",
20874
+ accessSection: "Access",
20875
+ activitySection: "Sessions & activity",
20810
20876
  generalSection: "General",
20811
- otherSection: "Other",
20877
+ otherSection: "About",
20812
20878
  appearanceDescription: "Conversation display and local resource management.",
20813
20879
  appearanceGroup: "Appearance",
20814
20880
  loadedSessions: {
@@ -21124,9 +21190,11 @@ th[aria-sort] .console-usage-sort__mark {
21124
21190
  title: "\u8BBE\u7F6E",
21125
21191
  close: "\u5173\u95ED\u8BBE\u7F6E",
21126
21192
  sectionsLabel: "\u8BBE\u7F6E\u5206\u7C7B",
21127
- connectionSection: "\u8FDE\u63A5",
21193
+ agentsSection: "Agents",
21194
+ accessSection: "\u8BBF\u95EE\u4E0E\u8D26\u53F7",
21195
+ activitySection: "\u4F1A\u8BDD\u4E0E\u6D3B\u52A8",
21128
21196
  generalSection: "\u901A\u7528",
21129
- otherSection: "\u5176\u4ED6",
21197
+ otherSection: "\u5173\u4E8E",
21130
21198
  appearanceDescription: "\u4F1A\u8BDD\u663E\u793A\u4E0E\u672C\u5730\u8D44\u6E90\u7BA1\u7406\u3002",
21131
21199
  appearanceGroup: "\u5916\u89C2",
21132
21200
  loadedSessions: {
@@ -21527,6 +21595,7 @@ th[aria-sort] .console-usage-sort__mark {
21527
21595
  latestCacheHit: "Latest cache hit (CH)",
21528
21596
  sessionCacheHit: "Average cache hit",
21529
21597
  outputSpeed: "Output speed (TPS)",
21598
+ averageOutputSpeed: "Average output speed (TPS)",
21530
21599
  apiOutputSpeed: "API average speed",
21531
21600
  apiOutputSpeedDescription: "Output tokens / native API time, including first-token wait; not generation TPS.",
21532
21601
  timeToFirstOutput: "Time to first token (TTFT)",
@@ -21553,6 +21622,7 @@ th[aria-sort] .console-usage-sort__mark {
21553
21622
  latestCacheHit: "\u7F13\u5B58\u547D\u4E2D\u7387",
21554
21623
  sessionCacheHit: "\u5E73\u5747\u7F13\u5B58\u547D\u4E2D",
21555
21624
  outputSpeed: "\u8F93\u51FA\u901F\u5EA6\uFF08TPS\uFF09",
21625
+ averageOutputSpeed: "\u5E73\u5747\u8F93\u51FA\u901F\u5EA6\uFF08TPS\uFF09",
21556
21626
  apiOutputSpeed: "API \u5E73\u5747\u901F\u5EA6",
21557
21627
  apiOutputSpeedDescription: "\u8F93\u51FA Token \xF7 \u539F\u751F API \u8017\u65F6\uFF0C\u542B\u9996\u5B57\u7B49\u5F85\uFF1B\u4E0D\u662F\u751F\u6210 TPS\u3002",
21558
21628
  timeToFirstOutput: "\u9996 token\uFF08TTFT\uFF09",
@@ -25569,249 +25639,695 @@ ${detail}` : ""}`
25569
25639
  return fallback;
25570
25640
  }
25571
25641
 
25572
- // src/settings/harness-launch-controls.ts
25573
- function createHarnessLaunchControls(document2, messages, agent, settings) {
25574
- const section = document2.createElement("section");
25575
- section.className = "settings-harness-launch";
25576
- section.dataset.harnessLaunch = agent;
25577
- const label = document2.createElement("label");
25578
- label.textContent = messages.launchPathLabel;
25579
- const input = document2.createElement("input");
25580
- input.type = "text";
25581
- input.autocomplete = "off";
25582
- input.spellcheck = false;
25583
- input.placeholder = messages.locale === "zh-CN" ? "\u5E94\u7528\u5B89\u88C5\u76EE\u5F55\u7684\u7EDD\u5BF9\u8DEF\u5F84" : "Absolute installation directory";
25584
- input.setAttribute("aria-label", messages.launchPathLabel);
25585
- label.append(input);
25586
- const help = document2.createElement("p");
25587
- 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.";
25588
- const actions = document2.createElement("div");
25589
- actions.className = "settings-harness-launch__actions";
25590
- const save = document2.createElement("button");
25591
- save.type = "button";
25592
- save.className = "settings-command-button";
25593
- save.textContent = messages.launchPathSave;
25594
- const reset = document2.createElement("button");
25595
- reset.type = "button";
25596
- reset.className = "settings-command-button settings-command-button--secondary";
25597
- reset.textContent = messages.launchPathReset;
25598
- const status = document2.createElement("p");
25599
- status.setAttribute("role", "status");
25600
- status.setAttribute("aria-live", "polite");
25601
- actions.append(save, reset);
25602
- section.append(label, help, actions, status);
25603
- let busy = true;
25604
- let loaded = false;
25605
- const controls = () => {
25606
- input.disabled = busy || !loaded;
25607
- save.disabled = busy || !loaded || !input.value.trim();
25608
- reset.disabled = busy || !loaded;
25609
- };
25610
- const show = (value) => {
25611
- input.value = value.path ?? "";
25612
- status.textContent = value.restartRequired ? messages.launchPathRestart : value.path ? messages.launchPathSaved : messages.launchPathAutomatic;
25613
- };
25614
- const persist = async (value) => {
25615
- if (busy || !loaded) return;
25616
- busy = true;
25617
- controls();
25618
- status.textContent = messages.launchPathSaving;
25619
- try {
25620
- show(await settings.set(value));
25621
- } catch {
25622
- status.textContent = messages.launchPathSaveError;
25623
- } finally {
25624
- busy = false;
25625
- controls();
25642
+ // src/settings/connection-row.ts
25643
+ function connectionStatusLabel(availability, messages, hasError = false) {
25644
+ if (availability === "updating") return messages.connectionStatusUpdating;
25645
+ if (hasError && availability !== "notInstalled") return messages.connectionStatusError;
25646
+ if (availability === "ready") return messages.connectionStatusReady;
25647
+ if (availability === "checking") return messages.connectionStatusChecking;
25648
+ if (availability === "notInstalled") return messages.connectionStatusNotInstalled;
25649
+ if (availability === "unavailable" || availability === "error") {
25650
+ return availability === "error" ? messages.connectionStatusError : messages.connectionStatusUnavailable;
25651
+ }
25652
+ return availability === "installing" ? messages.connectionStatusInstalling : messages.connectionStatusUnsupported;
25653
+ }
25654
+ function connectionStatusTone(availability, hasError = false) {
25655
+ if (availability === "updating") return "checking";
25656
+ if (hasError && availability !== "notInstalled") return "failed";
25657
+ if (availability === "ready") return "ready";
25658
+ if (availability === "checking" || availability === "installing") return "checking";
25659
+ if (availability === "notInstalled") return "setup";
25660
+ return "failed";
25661
+ }
25662
+ function createConnectionIdentityIcon(document2, item, size) {
25663
+ const container = document2.createElement("span");
25664
+ container.className = item.agentSnapshot ? "settings-connection-row__mark settings-connection-row__mark--logo" : "settings-connection-row__mark";
25665
+ container.setAttribute("aria-hidden", "true");
25666
+ if (item.agentSnapshot) {
25667
+ container.append(
25668
+ createRendererAgentIcon(item.agentSnapshot.agent, size, document2, item.agentSnapshot.plugin)
25669
+ );
25670
+ } else {
25671
+ container.textContent = "CH";
25672
+ }
25673
+ return container;
25674
+ }
25675
+ function sameElementChildren(container, next) {
25676
+ if (container.children.length !== next.length) return false;
25677
+ for (let index = 0; index < next.length; index++) {
25678
+ if (container.children[index] !== next[index]) return false;
25679
+ }
25680
+ return true;
25681
+ }
25682
+ function reconcileElementChildren(container, next) {
25683
+ if (sameElementChildren(container, next)) return;
25684
+ if (typeof container.insertBefore !== "function") {
25685
+ container.replaceChildren(...next);
25686
+ return;
25687
+ }
25688
+ const nextSet = new Set(next);
25689
+ for (const child of [...container.children]) {
25690
+ if (!nextSet.has(child)) child.remove();
25691
+ }
25692
+ for (let index = 0; index < next.length; index++) {
25693
+ const desired = next[index];
25694
+ if (!desired) continue;
25695
+ const current = container.children[index] ?? null;
25696
+ if (current !== desired) {
25697
+ container.insertBefore(desired, current);
25626
25698
  }
25627
- };
25628
- input.addEventListener("input", controls);
25629
- save.addEventListener("click", () => {
25630
- if (input.value.trim()) void persist(input.value.trim());
25699
+ }
25700
+ }
25701
+ function identityIconSignature(item) {
25702
+ if (!item.agentSnapshot) return "adapter";
25703
+ const plugin = item.agentSnapshot.plugin;
25704
+ return `${item.agentSnapshot.agent}:${String(plugin?.icon ?? "")}:${String(plugin?.iconStyle ?? "")}`;
25705
+ }
25706
+ function createConnectionRowView(document2, messages, groupable) {
25707
+ const row = document2.createElement("div");
25708
+ row.className = "settings-connection-row";
25709
+ row.setAttribute("role", "row");
25710
+ const identity2 = document2.createElement("div");
25711
+ identity2.className = "settings-connection-row__identity";
25712
+ identity2.setAttribute("role", "cell");
25713
+ let handle = null;
25714
+ if (groupable) {
25715
+ handle = document2.createElement("span");
25716
+ handle.className = "settings-connection-row__handle";
25717
+ handle.setAttribute("aria-hidden", "true");
25718
+ handle.append(createRendererSettingsIcon("grip-vertical", 15));
25719
+ identity2.append(handle);
25720
+ }
25721
+ let iconElement = null;
25722
+ let renderedIconKey = null;
25723
+ const label = document2.createElement("strong");
25724
+ const status = document2.createElement("span");
25725
+ status.className = "settings-connection-row__status";
25726
+ status.setAttribute("role", "cell");
25727
+ const action = document2.createElement("div");
25728
+ action.className = "settings-connection-row__action";
25729
+ action.setAttribute("role", "cell");
25730
+ row.append(identity2, status, action);
25731
+ let currentItem = null;
25732
+ let currentSelect = () => void 0;
25733
+ let currentGroup = null;
25734
+ let dragArmed = false;
25735
+ handle?.addEventListener("pointerdown", (event) => {
25736
+ if (event.button !== 0 || currentGroup?.disabled) return;
25737
+ dragArmed = true;
25738
+ row.draggable = true;
25739
+ });
25740
+ row.addEventListener("pointerup", () => {
25741
+ dragArmed = false;
25742
+ row.draggable = false;
25631
25743
  });
25632
- reset.addEventListener("click", () => {
25633
- void persist(null);
25744
+ row.addEventListener("pointercancel", () => {
25745
+ dragArmed = false;
25746
+ row.draggable = false;
25634
25747
  });
25635
- controls();
25636
- status.textContent = messages.launchPathLoading;
25637
- void settings.get().then((value) => {
25638
- loaded = true;
25639
- show(value);
25640
- }).catch(() => {
25641
- loaded = true;
25642
- status.textContent = messages.launchPathLoadError;
25643
- }).finally(() => {
25644
- busy = false;
25645
- controls();
25748
+ let viewErrorButton = null;
25749
+ let versionAvailableBadge = null;
25750
+ let updateButton = null;
25751
+ let groupToggleButton = null;
25752
+ let groupToggleSection = null;
25753
+ row.addEventListener("click", (event) => {
25754
+ const target2 = event.target;
25755
+ if (target2?.closest?.("a")) return;
25756
+ currentSelect();
25646
25757
  });
25647
- return section;
25758
+ row.addEventListener("keydown", (event) => {
25759
+ if (event.target?.closest?.("button, a")) return;
25760
+ if (event.key !== "Enter" && event.key !== " ") return;
25761
+ event.preventDefault();
25762
+ currentSelect();
25763
+ });
25764
+ if (groupable) {
25765
+ row.addEventListener("dragstart", (event) => {
25766
+ if (!dragArmed) {
25767
+ event.preventDefault();
25768
+ return;
25769
+ }
25770
+ currentGroup?.onDragStart(event);
25771
+ });
25772
+ row.addEventListener("dragover", (event) => currentGroup?.onDragOver(event));
25773
+ row.addEventListener("dragleave", (event) => currentGroup?.onDragLeave(event));
25774
+ row.addEventListener("drop", (event) => currentGroup?.onDrop(event));
25775
+ row.addEventListener("dragend", (event) => {
25776
+ dragArmed = false;
25777
+ row.draggable = false;
25778
+ currentGroup?.onDragEnd(event);
25779
+ });
25780
+ }
25781
+ const setSelected = (selected) => {
25782
+ const nextSelected = String(selected);
25783
+ if (row.dataset.connectionSelected !== nextSelected) {
25784
+ row.dataset.connectionSelected = nextSelected;
25785
+ }
25786
+ const nextTabIndex = selected ? 0 : -1;
25787
+ if (row.tabIndex !== nextTabIndex) {
25788
+ row.tabIndex = nextTabIndex;
25789
+ }
25790
+ };
25791
+ return {
25792
+ element: row,
25793
+ setSelected,
25794
+ update(item, selected, select, group) {
25795
+ currentItem = item;
25796
+ currentSelect = select;
25797
+ currentGroup = group;
25798
+ if (row.dataset.connectionItem !== item.key) {
25799
+ row.dataset.connectionItem = item.key;
25800
+ }
25801
+ setSelected(selected);
25802
+ const nextIconKey = identityIconSignature(item);
25803
+ if (renderedIconKey !== nextIconKey || !iconElement) {
25804
+ renderedIconKey = nextIconKey;
25805
+ iconElement = createConnectionIdentityIcon(document2, item, 19);
25806
+ reconcileElementChildren(
25807
+ identity2,
25808
+ handle ? [handle, iconElement, label] : [iconElement, label]
25809
+ );
25810
+ }
25811
+ if (handle && group && handle.title !== group.dragHandleTitle) {
25812
+ handle.title = group.dragHandleTitle;
25813
+ }
25814
+ if (label.textContent !== item.name) {
25815
+ label.textContent = item.name;
25816
+ }
25817
+ const tone = connectionStatusTone(item.availability, item.error !== null);
25818
+ if (status.dataset.connectionTone !== tone) {
25819
+ status.dataset.connectionTone = tone;
25820
+ }
25821
+ const statusText = item.error?.code === "authenticationRequired" ? messages.connectionLoginRequired : item.error?.code === "configurationRequired" ? messages.connectionConfigurationRequired : connectionStatusLabel(item.availability, messages, item.error !== null);
25822
+ if (status.textContent !== statusText) {
25823
+ status.textContent = statusText;
25824
+ }
25825
+ const nextActions = [];
25826
+ if (item.error) {
25827
+ if (!viewErrorButton) {
25828
+ const button2 = document2.createElement("button");
25829
+ button2.type = "button";
25830
+ button2.className = "settings-connection-view-error";
25831
+ button2.textContent = messages.connectionViewError;
25832
+ button2.addEventListener("click", (event) => {
25833
+ event.stopPropagation();
25834
+ currentSelect();
25835
+ });
25836
+ viewErrorButton = button2;
25837
+ }
25838
+ nextActions.push(viewErrorButton);
25839
+ }
25840
+ const version2 = item.version;
25841
+ if (item.accessory) nextActions.push(item.accessory);
25842
+ if (version2?.state?.updateAvailable && !version2.updating) {
25843
+ if (!versionAvailableBadge) {
25844
+ const badge = document2.createElement("span");
25845
+ badge.className = "settings-connection-version-available";
25846
+ badge.textContent = messages.harnessVersionAvailable;
25847
+ versionAvailableBadge = badge;
25848
+ }
25849
+ const badgeTitle = `${messages.harnessVersionCurrent}: ${version2.state.currentVersion ?? "\u2014"}
25850
+ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages.harnessVersion)}`;
25851
+ if (versionAvailableBadge.title !== badgeTitle) {
25852
+ versionAvailableBadge.title = badgeTitle;
25853
+ }
25854
+ nextActions.push(versionAvailableBadge);
25855
+ }
25856
+ if (version2?.state?.updateAvailable && version2.state.canUpdate) {
25857
+ if (!updateButton) {
25858
+ const button2 = document2.createElement("button");
25859
+ button2.type = "button";
25860
+ button2.className = "settings-connection-install-link";
25861
+ button2.dataset.connectionAction = "update";
25862
+ button2.append(createRendererSettingsIcon("download", 17));
25863
+ button2.addEventListener("click", (event) => {
25864
+ event.stopPropagation();
25865
+ if (button2.disabled) return;
25866
+ void currentItem?.version?.update();
25867
+ currentSelect();
25868
+ });
25869
+ updateButton = button2;
25870
+ }
25871
+ updateButton.disabled = version2.updating;
25872
+ const updateTitle = `${messages.harnessVersionUpdate}: ${item.name}
25873
+ ${messages.harnessVersionCurrent}: ${version2.state.currentVersion ?? "\u2014"}
25874
+ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages.harnessVersion)}`;
25875
+ if (updateButton.title !== updateTitle) {
25876
+ updateButton.title = updateTitle;
25877
+ }
25878
+ const updateAriaLabel = `${messages.harnessVersionUpdate}: ${item.name}`;
25879
+ if (updateButton.getAttribute("aria-label") !== updateAriaLabel) {
25880
+ updateButton.setAttribute("aria-label", updateAriaLabel);
25881
+ }
25882
+ nextActions.push(updateButton);
25883
+ }
25884
+ if (group) {
25885
+ if (!groupToggleButton) {
25886
+ const button2 = document2.createElement("button");
25887
+ button2.type = "button";
25888
+ button2.className = "settings-connection-row__group-toggle";
25889
+ button2.addEventListener("click", (event) => {
25890
+ event.stopPropagation();
25891
+ currentGroup?.toggleSection();
25892
+ });
25893
+ groupToggleButton = button2;
25894
+ }
25895
+ groupToggleButton.disabled = group.disabled;
25896
+ if (groupToggleButton.title !== group.moveLabel) {
25897
+ groupToggleButton.title = group.moveLabel;
25898
+ }
25899
+ if (groupToggleButton.getAttribute("aria-label") !== group.moveLabel) {
25900
+ groupToggleButton.setAttribute("aria-label", group.moveLabel);
25901
+ }
25902
+ if (groupToggleSection !== group.section) {
25903
+ groupToggleSection = group.section;
25904
+ groupToggleButton.replaceChildren(
25905
+ createRendererSettingsIcon(
25906
+ group.section === "main" ? "chevron-down" : "chevron-up",
25907
+ 15
25908
+ )
25909
+ );
25910
+ }
25911
+ nextActions.push(groupToggleButton);
25912
+ }
25913
+ reconcileElementChildren(action, nextActions);
25914
+ if (group) {
25915
+ if (group.disabled) {
25916
+ dragArmed = false;
25917
+ row.draggable = false;
25918
+ }
25919
+ if (row.dataset.connectionGroupSection !== group.section) {
25920
+ row.dataset.connectionGroupSection = group.section;
25921
+ }
25922
+ }
25923
+ }
25924
+ };
25648
25925
  }
25649
25926
 
25650
- // src/settings/claude-long-context-control.ts
25651
- var CLAUDE_LONG_CONTEXT_MODELS = [{ id: "claude-opus-5-5", window: "1M" }];
25652
- var tooltipSequence = 0;
25653
- function popoverOpen(tooltip) {
25654
- try {
25655
- return tooltip.matches(":popover-open");
25656
- } catch {
25657
- return false;
25927
+ // src/settings/connection-updates.ts
25928
+ var sharedBatchStores = /* @__PURE__ */ new WeakMap();
25929
+ function getBatchStore(diagnostics) {
25930
+ if (!diagnostics) {
25931
+ return { batches: /* @__PURE__ */ new Map(), listeners: /* @__PURE__ */ new Set() };
25658
25932
  }
25659
- }
25660
- function createClaudeLongContextControl(document2, messages, actions) {
25661
- const control = document2.createElement("span");
25662
- control.className = "settings-connection-long-context";
25663
- const label = document2.createElement("label");
25664
- label.className = "settings-connection-long-context__control";
25665
- const text = document2.createElement("span");
25666
- text.textContent = messages.connectionLongContextLabel;
25667
- const input = document2.createElement("input");
25668
- input.type = "checkbox";
25669
- input.checked = true;
25670
- input.setAttribute("role", "switch");
25671
- input.setAttribute("aria-checked", "true");
25672
- input.setAttribute("aria-label", messages.connectionLongContextLabel);
25673
- input.dataset.connectionAction = "long-context";
25674
- const tooltip = document2.createElement("div");
25675
- tooltip.id = `settings-long-context-tooltip-${++tooltipSequence}`;
25676
- tooltip.className = "settings-connection-long-context__tooltip";
25677
- tooltip.setAttribute("role", "tooltip");
25678
- tooltip.setAttribute("popover", "manual");
25679
- tooltip.hidden = true;
25680
- const on = document2.createElement("p");
25681
- on.textContent = messages.connectionLongContextOn;
25682
- const off = document2.createElement("p");
25683
- off.textContent = messages.connectionLongContextOff;
25684
- const modelsLabel = document2.createElement("p");
25685
- modelsLabel.textContent = messages.connectionLongContextModelsLabel;
25686
- const models = document2.createElement("ul");
25687
- for (const model2 of CLAUDE_LONG_CONTEXT_MODELS) {
25688
- const item = document2.createElement("li");
25689
- item.textContent = `${model2.id} (${model2.window})`;
25690
- models.append(item);
25933
+ let store = sharedBatchStores.get(diagnostics);
25934
+ if (!store) {
25935
+ store = { batches: /* @__PURE__ */ new Map(), listeners: /* @__PURE__ */ new Set() };
25936
+ sharedBatchStores.set(diagnostics, store);
25691
25937
  }
25692
- tooltip.append(on, off, modelsLabel, models);
25693
- input.setAttribute("aria-describedby", tooltip.id);
25694
- const stop = (event) => {
25695
- event.stopPropagation();
25938
+ return store;
25939
+ }
25940
+ function createConnectionUpdates(document2, messages, signal, onChange, diagnostics = null) {
25941
+ const store = getBatchStore(diagnostics);
25942
+ const notify2 = () => {
25943
+ for (const listener of [...store.listeners]) listener();
25696
25944
  };
25697
- control.addEventListener("click", stop);
25698
- label.addEventListener("click", stop);
25699
- input.addEventListener("click", stop);
25700
- let surfaceReady = false;
25701
- const applyTooltipSurface = () => {
25702
- if (surfaceReady) return;
25703
- const probe = document2.createElement("span");
25704
- probe.style.cssText = "position:absolute;visibility:hidden;color:var(--settings-text);background-color:var(--settings-elevated);border-top-color:var(--settings-border)";
25705
- control.append(probe);
25706
- const computed = document2.defaultView?.getComputedStyle(probe);
25707
- const color = computed?.color;
25708
- const background = computed?.backgroundColor;
25709
- const borderColor = computed?.borderTopColor;
25710
- probe.remove();
25711
- if (color) tooltip.style.color = color;
25712
- if (background && background !== "rgba(0, 0, 0, 0)") tooltip.style.backgroundColor = background;
25713
- if (borderColor) tooltip.style.border = `1px solid ${borderColor}`;
25714
- surfaceReady = true;
25945
+ if (!signal.aborted) {
25946
+ const listener = () => {
25947
+ if (!signal.aborted) onChange();
25948
+ };
25949
+ store.listeners.add(listener);
25950
+ signal.addEventListener(
25951
+ "abort",
25952
+ () => {
25953
+ store.listeners.delete(listener);
25954
+ },
25955
+ { once: true }
25956
+ );
25957
+ }
25958
+ const eligible = (panels) => panels.filter((panel) => panel.state?.updateAvailable && panel.state.canUpdate);
25959
+ const start = async (hostId2, panels) => {
25960
+ if (signal.aborted || store.batches.get(hostId2)?.running) return;
25961
+ const targets = eligible(panels);
25962
+ if (!targets.length) return;
25963
+ const batch = { running: true, total: targets.length, succeeded: 0, failed: 0 };
25964
+ store.batches.set(hostId2, batch);
25965
+ notify2();
25966
+ await Promise.all(
25967
+ targets.map(async (panel) => {
25968
+ try {
25969
+ if (await panel.update()) batch.succeeded++;
25970
+ else batch.failed++;
25971
+ } catch {
25972
+ batch.failed++;
25973
+ }
25974
+ notify2();
25975
+ })
25976
+ );
25977
+ batch.running = false;
25978
+ notify2();
25715
25979
  };
25716
- const showTooltip = () => {
25717
- const root = control.getRootNode();
25718
- const host = root instanceof ShadowRoot ? root : document2.body ?? control;
25719
- if (tooltip.parentNode !== host) host.append(tooltip);
25720
- applyTooltipSurface();
25721
- tooltip.hidden = false;
25722
- if (typeof tooltip.showPopover === "function" && !popoverOpen(tooltip)) {
25980
+ return {
25981
+ createControls(hostId2, panels) {
25982
+ let currentHostId = hostId2;
25983
+ let currentPanels = panels;
25984
+ let renderedLabel = null;
25985
+ const button2 = document2.createElement("button");
25986
+ button2.type = "button";
25987
+ button2.className = "settings-command-button settings-command-button--secondary settings-connection-update-all";
25988
+ button2.dataset.connectionAction = "update-all";
25989
+ button2.title = messages.harnessUpdateAllDescription;
25990
+ button2.addEventListener("click", () => {
25991
+ if (!button2.disabled) void start(currentHostId, currentPanels);
25992
+ });
25993
+ const result = document2.createElement("p");
25994
+ result.className = "settings-connection-update-result";
25995
+ result.setAttribute("role", "status");
25996
+ const update = (nextHostId, nextPanels) => {
25997
+ currentHostId = nextHostId;
25998
+ currentPanels = nextPanels;
25999
+ const batch = store.batches.get(nextHostId);
26000
+ const count3 = eligible(nextPanels).length;
26001
+ button2.disabled = signal.aborted || Boolean(batch?.running) || !count3;
26002
+ const label = batch?.running ? `${messages.harnessUpdateAllProgress} ${batch.succeeded + batch.failed}/${batch.total}` : count3 ? `${messages.harnessUpdateAll} (${count3})` : messages.harnessUpdateAll;
26003
+ if (renderedLabel !== label) {
26004
+ renderedLabel = label;
26005
+ button2.replaceChildren(createRendererSettingsIcon("download", 15), label);
26006
+ }
26007
+ const hidden = !batch || batch.running;
26008
+ result.hidden = hidden;
26009
+ const resultText = batch && !batch.running ? messages.harnessUpdateAllResult.replace("{succeeded}", String(batch.succeeded)).replace("{failed}", String(batch.failed)) : "";
26010
+ if (result.textContent !== resultText) {
26011
+ result.textContent = resultText;
26012
+ }
26013
+ };
26014
+ update(hostId2, panels);
26015
+ return { button: button2, result, update };
26016
+ }
26017
+ };
26018
+ }
26019
+
26020
+ // src/settings/harness-version-panel.ts
26021
+ function isUnsupportedInstallationError(error51) {
26022
+ return typeof error51 === "object" && error51 !== null && "code" in error51 && (error51.code === -32601 || error51.code === -32078);
26023
+ }
26024
+ function createHarnessVersionSession(client, options) {
26025
+ let state;
26026
+ let statusKind = "checking";
26027
+ let checkPromise = null;
26028
+ let updatePromise = null;
26029
+ const listeners = /* @__PURE__ */ new Set();
26030
+ const signal = options?.signal;
26031
+ const notify2 = (pageChange) => {
26032
+ if (signal?.aborted) return;
26033
+ for (const listener of [...listeners]) listener(pageChange);
26034
+ };
26035
+ const check2 = () => {
26036
+ if (signal?.aborted || updatePromise) return Promise.resolve();
26037
+ if (checkPromise) return checkPromise;
26038
+ statusKind = "checking";
26039
+ notify2(false);
26040
+ checkPromise = (async () => {
25723
26041
  try {
25724
- tooltip.showPopover();
25725
- } catch {
25726
- tooltip.removeAttribute("popover");
26042
+ const result = await client.run("check");
26043
+ if (signal?.aborted || updatePromise) return;
26044
+ state = result;
26045
+ statusKind = "idle";
26046
+ } catch (error51) {
26047
+ if (signal?.aborted || updatePromise) return;
26048
+ statusKind = isUnsupportedInstallationError(error51) ? "unsupported" : "failed";
26049
+ if (state) state = { ...state, canUpdate: false };
26050
+ } finally {
26051
+ checkPromise = null;
26052
+ if (!signal?.aborted && !updatePromise) {
26053
+ notify2(true);
26054
+ }
25727
26055
  }
25728
- }
25729
- tooltip.style.position = "fixed";
25730
- tooltip.style.inset = "auto";
25731
- tooltip.style.zIndex = "80";
25732
- tooltip.style.margin = "0";
25733
- tooltip.style.height = "auto";
25734
- tooltip.style.overflow = "visible";
25735
- const rect = control.getBoundingClientRect();
25736
- const margin = 8;
25737
- const width = Math.min(280, Math.max(160, window.innerWidth - margin * 2));
25738
- tooltip.style.width = `${width}px`;
25739
- const preferredLeft = Math.min(
25740
- Math.max(margin, rect.right - width),
25741
- window.innerWidth - width - margin
25742
- );
25743
- const height = tooltip.offsetHeight;
25744
- const below = rect.bottom + 8;
25745
- const preferredTop = below + height <= window.innerHeight - margin ? below : Math.max(margin, rect.top - height - 8);
25746
- tooltip.style.left = `${preferredLeft}px`;
25747
- tooltip.style.top = `${preferredTop}px`;
25748
- const placed = tooltip.getBoundingClientRect();
25749
- const shiftX = preferredLeft - placed.left;
25750
- const shiftY = preferredTop - placed.top;
25751
- if (Math.abs(shiftX) > 0.5 || Math.abs(shiftY) > 0.5) {
25752
- tooltip.style.left = `${preferredLeft + shiftX}px`;
25753
- tooltip.style.top = `${preferredTop + shiftY}px`;
25754
- }
26056
+ })();
26057
+ return checkPromise;
25755
26058
  };
25756
- const hideTooltip = () => {
25757
- if (typeof tooltip.hidePopover === "function" && popoverOpen(tooltip)) {
26059
+ const update = () => {
26060
+ if (updatePromise) return updatePromise;
26061
+ updatePromise = (async () => {
26062
+ if (signal?.aborted) return false;
26063
+ if (checkPromise) await checkPromise;
26064
+ if (signal?.aborted || statusKind === "unsupported" || !state?.canUpdate || !state.updateAvailable) {
26065
+ return false;
26066
+ }
26067
+ statusKind = "updating";
26068
+ notify2(true);
25758
26069
  try {
25759
- tooltip.hidePopover();
25760
- } catch {
26070
+ const result = await client.run("update");
26071
+ if (signal?.aborted) return false;
26072
+ state = result;
26073
+ statusKind = !result.canUpdate ? "updated" : result.updateAvailable ? "failed" : "updated";
26074
+ return result.canUpdate && !result.updateAvailable;
26075
+ } catch (error51) {
26076
+ if (signal?.aborted) return false;
26077
+ statusKind = isUnsupportedInstallationError(error51) ? "unsupported" : "failed";
26078
+ if (state) state = { ...state, canUpdate: false };
26079
+ return false;
26080
+ } finally {
26081
+ updatePromise = null;
26082
+ if (!signal?.aborted) {
26083
+ notify2(true);
26084
+ }
25761
26085
  }
26086
+ })();
26087
+ return updatePromise;
26088
+ };
26089
+ return {
26090
+ get state() {
26091
+ return state;
26092
+ },
26093
+ get statusKind() {
26094
+ return statusKind;
26095
+ },
26096
+ get updating() {
26097
+ return statusKind === "updating";
26098
+ },
26099
+ prepareMount() {
26100
+ if (updatePromise || checkPromise) return false;
26101
+ statusKind = "checking";
26102
+ return true;
26103
+ },
26104
+ check: check2,
26105
+ update,
26106
+ subscribe(listener) {
26107
+ listeners.add(listener);
26108
+ return () => {
26109
+ listeners.delete(listener);
26110
+ };
25762
26111
  }
25763
- tooltip.hidden = true;
25764
26112
  };
25765
- control.addEventListener("mouseenter", showTooltip);
25766
- control.addEventListener("mouseleave", hideTooltip);
25767
- control.addEventListener("focusin", showTooltip);
25768
- control.addEventListener("focusout", (event) => {
25769
- const next = event.relatedTarget;
25770
- if (next instanceof Node && control.contains(next)) return;
25771
- hideTooltip();
26113
+ }
26114
+ function createHarnessVersionPanel(document2, messages, signal, agent, client, onChange = () => void 0, sharedSession) {
26115
+ const session = sharedSession ?? createHarnessVersionSession(client, { signal });
26116
+ const shouldScheduleCheck = session.prepareMount();
26117
+ const panel = document2.createElement("section");
26118
+ panel.className = "settings-harness-version";
26119
+ panel.dataset.harnessVersion = agent;
26120
+ const heading = document2.createElement("strong");
26121
+ heading.textContent = messages.harnessVersionTitle;
26122
+ const versions = document2.createElement("div");
26123
+ versions.className = "settings-harness-version__values";
26124
+ const current = document2.createElement("span");
26125
+ const latest = document2.createElement("span");
26126
+ versions.append(current, latest);
26127
+ const status = document2.createElement("p");
26128
+ status.setAttribute("role", "status");
26129
+ const actions = document2.createElement("div");
26130
+ actions.className = "settings-connection-error-actions";
26131
+ const update = document2.createElement("button");
26132
+ update.type = "button";
26133
+ update.className = "settings-command-button settings-command-button--secondary";
26134
+ update.dataset.harnessVersionAction = "update";
26135
+ const note = document2.createElement("p");
26136
+ note.className = "settings-connection-issue-note";
26137
+ note.textContent = messages.harnessVersionNote;
26138
+ actions.append(update);
26139
+ panel.append(heading, versions, status, actions, note);
26140
+ const render = () => {
26141
+ const state = session.state;
26142
+ const statusKind = session.statusKind;
26143
+ const busy = statusKind === "checking" || statusKind === "updating";
26144
+ heading.textContent = state?.versionKind === "application" ? messages.harnessVersionApplicationTitle : messages.harnessVersionTitle;
26145
+ current.textContent = `${messages.harnessVersionCurrent}: ${state?.currentVersion ?? "\u2014"}`;
26146
+ latest.textContent = `${messages.harnessVersionLatest}: ${harnessVersionLabel(state, messages.harnessVersion)}`;
26147
+ 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 : "";
26148
+ update.disabled = busy || signal.aborted || !state?.canUpdate || !state.updateAvailable;
26149
+ const manualUrl = !state?.canUpdate && state?.updateAvailable ? state.manualUpdateUrl : void 0;
26150
+ actions.replaceChildren(update);
26151
+ update.hidden = !busy && !signal.aborted && Boolean(manualUrl);
26152
+ if (update.hidden && manualUrl) {
26153
+ const download2 = document2.createElement("a");
26154
+ download2.className = "settings-command-button settings-command-button--secondary";
26155
+ download2.dataset.harnessVersionAction = "download-update";
26156
+ download2.textContent = messages.harnessVersionDownloadUpdate;
26157
+ download2.href = manualUrl;
26158
+ download2.target = "_blank";
26159
+ download2.rel = "noopener noreferrer";
26160
+ actions.append(download2);
26161
+ }
26162
+ update.textContent = state?.canUpdate && state.latestVersion !== "Unknown" && !state.updateAvailable ? messages.harnessVersionUpToDate : messages.harnessVersionUpdate;
26163
+ const detail = harnessVersionNote(state, messages.harnessVersion);
26164
+ note.textContent = detail ? !state?.canUpdate ? detail : `${detail} ${messages.harnessVersionNote}` : messages.harnessVersionNote;
26165
+ };
26166
+ update.addEventListener("click", () => {
26167
+ if (!signal.aborted) void session.update();
25772
26168
  });
25773
- let generation = 0;
25774
- input.addEventListener("change", () => {
25775
- const next = input.checked;
25776
- generation += 1;
25777
- const request = generation;
25778
- input.disabled = true;
25779
- input.setAttribute("aria-checked", String(next));
25780
- void actions.set(next).then(
25781
- (result) => {
25782
- if (request !== generation) return;
25783
- input.checked = result.enabled;
25784
- input.setAttribute("aria-checked", String(result.enabled));
25785
- input.disabled = false;
25786
- },
25787
- () => {
25788
- if (request !== generation) return;
25789
- input.checked = !next;
25790
- input.setAttribute("aria-checked", String(!next));
25791
- input.disabled = false;
25792
- }
25793
- );
26169
+ const unsubscribe = session.subscribe((pageChange) => {
26170
+ if (signal.aborted) return;
26171
+ render();
26172
+ if (pageChange) onChange();
25794
26173
  });
25795
- void actions.get().then(
25796
- (result) => {
25797
- if (generation !== 0) return;
25798
- input.checked = result.enabled;
25799
- input.setAttribute("aria-checked", String(result.enabled));
26174
+ const owner = document2.defaultView;
26175
+ let checkFrame = null;
26176
+ let checkTimer = null;
26177
+ signal.addEventListener(
26178
+ "abort",
26179
+ () => {
26180
+ unsubscribe();
26181
+ if (checkFrame !== null) owner?.cancelAnimationFrame(checkFrame);
26182
+ if (checkTimer !== null) owner?.clearTimeout(checkTimer);
26183
+ render();
25800
26184
  },
25801
- () => void 0
26185
+ { once: true }
25802
26186
  );
25803
- label.append(text, input);
25804
- control.append(label, tooltip);
25805
- return control;
26187
+ render();
26188
+ if (shouldScheduleCheck && !signal.aborted) {
26189
+ if (owner?.requestAnimationFrame) {
26190
+ checkFrame = owner.requestAnimationFrame(() => {
26191
+ checkFrame = null;
26192
+ if (signal.aborted) return;
26193
+ checkTimer = owner.setTimeout(() => {
26194
+ checkTimer = null;
26195
+ if (!signal.aborted) void session.check();
26196
+ }, 0);
26197
+ });
26198
+ } else {
26199
+ void session.check();
26200
+ }
26201
+ }
26202
+ return {
26203
+ element: panel,
26204
+ get state() {
26205
+ return session.state;
26206
+ },
26207
+ get updating() {
26208
+ return session.updating;
26209
+ },
26210
+ update: () => signal.aborted ? Promise.resolve(false) : session.update()
26211
+ };
25806
26212
  }
25807
26213
 
25808
- // src/settings/harness-installation-guides.ts
25809
- function harnessHasInstallCommands(plugin) {
25810
- return (plugin?.installation?.commands.length ?? 0) > 0;
26214
+ // src/settings/connection-versions.ts
26215
+ var sessionStores = /* @__PURE__ */ new WeakMap();
26216
+ function getSessionStore(diagnostics) {
26217
+ let store = sessionStores.get(diagnostics);
26218
+ if (!store) {
26219
+ store = /* @__PURE__ */ new Map();
26220
+ sessionStores.set(diagnostics, store);
26221
+ }
26222
+ return store;
25811
26223
  }
25812
- function harnessInstallationGuide(plugin, locale) {
25813
- const guide = plugin?.installation;
25814
- const text = (value) => value?.[locale] ?? value?.en;
26224
+ function createConnectionVersions(document2, messages, signal, diagnostics, onChange) {
26225
+ const panels = /* @__PURE__ */ new Map();
26226
+ const installation = diagnostics?.installation?.bind(diagnostics);
26227
+ const sessions = diagnostics ? getSessionStore(diagnostics) : null;
26228
+ const sessionKey = (hostId2, agent) => JSON.stringify([hostId2, agent]);
26229
+ return {
26230
+ isUpdating(hostId2, agent) {
26231
+ return Boolean(sessions?.get(sessionKey(hostId2, agent))?.updating);
26232
+ },
26233
+ get(hostId2, agent) {
26234
+ if (!installation || signal.aborted) return void 0;
26235
+ const key = sessionKey(hostId2, agent);
26236
+ let panel = panels.get(key);
26237
+ if (!panel) {
26238
+ const run = (action) => installation(hostId2, agent, action);
26239
+ let session = sessions?.get(key);
26240
+ if (!session) {
26241
+ session = createHarnessVersionSession({ run });
26242
+ sessions?.set(key, session);
26243
+ }
26244
+ panel = createHarnessVersionPanel(
26245
+ document2,
26246
+ messages,
26247
+ signal,
26248
+ agent,
26249
+ { run },
26250
+ onChange,
26251
+ session
26252
+ );
26253
+ panels.set(key, panel);
26254
+ }
26255
+ return panel;
26256
+ }
26257
+ };
26258
+ }
26259
+
26260
+ // src/settings/harness-install-store.ts
26261
+ function errorMessage(error51) {
26262
+ 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.";
26263
+ }
26264
+ function unknownInstallOutcome(message2) {
26265
+ return /outcome is unknown|do not retry automatically|did not answer in time/i.test(message2);
26266
+ }
26267
+ var stores = /* @__PURE__ */ new WeakMap();
26268
+ function createStore(diagnostics) {
26269
+ const states2 = /* @__PURE__ */ new Map();
26270
+ const listeners = /* @__PURE__ */ new Set();
26271
+ const key = (host, agent) => JSON.stringify([host, agent]);
26272
+ const notify2 = () => listeners.forEach((listener) => listener());
26273
+ return {
26274
+ get: (host, agent) => states2.get(key(host, agent)),
26275
+ clearErrors() {
26276
+ for (const [id, state] of states2) if (state.status === "error") states2.delete(id);
26277
+ notify2();
26278
+ },
26279
+ subscribe(listener) {
26280
+ listeners.add(listener);
26281
+ return () => {
26282
+ listeners.delete(listener);
26283
+ };
26284
+ },
26285
+ async install(host, agent) {
26286
+ const id = key(host, agent);
26287
+ const previous = states2.get(id);
26288
+ if (!diagnostics.installation || previous && previous.status !== "error") return;
26289
+ states2.set(id, { status: "installing" });
26290
+ notify2();
26291
+ let failure;
26292
+ try {
26293
+ await diagnostics.installation(host, agent, "install");
26294
+ states2.set(id, { status: "checking" });
26295
+ notify2();
26296
+ } catch (error51) {
26297
+ failure = errorMessage(error51);
26298
+ }
26299
+ try {
26300
+ await diagnostics.refresh(host);
26301
+ const refreshed = diagnostics.snapshot().hosts.find((candidate) => candidate.hostId === host)?.agents.find((candidate) => candidate.agent === agent);
26302
+ if (refreshed?.availability === "ready") failure = void 0;
26303
+ else if (failure && unknownInstallOutcome(failure) && refreshed && refreshed.availability !== "notInstalled") {
26304
+ failure = void 0;
26305
+ }
26306
+ } catch (error51) {
26307
+ failure ??= errorMessage(error51);
26308
+ }
26309
+ if (failure) states2.set(id, { status: "error", error: failure });
26310
+ else states2.delete(id);
26311
+ notify2();
26312
+ }
26313
+ };
26314
+ }
26315
+ function harnessInstallStore(diagnostics) {
26316
+ let store = stores.get(diagnostics);
26317
+ if (!store) {
26318
+ store = createStore(diagnostics);
26319
+ stores.set(diagnostics, store);
26320
+ }
26321
+ return store;
26322
+ }
26323
+
26324
+ // src/settings/harness-installation-guides.ts
26325
+ function harnessHasInstallCommands(plugin) {
26326
+ return (plugin?.installation?.commands.length ?? 0) > 0;
26327
+ }
26328
+ function harnessInstallationGuide(plugin, locale) {
26329
+ const guide = plugin?.installation;
26330
+ const text = (value) => value?.[locale] ?? value?.en;
25815
26331
  return {
25816
26332
  url: plugin?.links?.installation ?? plugin?.links?.documentation ?? plugin?.links?.website,
25817
26333
  commands: guide?.commands ?? [],
@@ -25902,402 +26418,248 @@ ${detail}` : ""}`
25902
26418
  return panel;
25903
26419
  }
25904
26420
 
25905
- // src/settings/harness-install-store.ts
25906
- function errorMessage(error51) {
25907
- 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.";
25908
- }
25909
- function unknownInstallOutcome(message2) {
25910
- return /outcome is unknown|do not retry automatically|did not answer in time/i.test(message2);
25911
- }
25912
- var stores = /* @__PURE__ */ new WeakMap();
25913
- function createStore(diagnostics) {
25914
- const states2 = /* @__PURE__ */ new Map();
25915
- const listeners = /* @__PURE__ */ new Set();
25916
- const key = (host, agent) => JSON.stringify([host, agent]);
25917
- const notify2 = () => listeners.forEach((listener) => listener());
25918
- return {
25919
- get: (host, agent) => states2.get(key(host, agent)),
25920
- clearErrors() {
25921
- for (const [id, state] of states2) if (state.status === "error") states2.delete(id);
25922
- notify2();
25923
- },
25924
- subscribe(listener) {
25925
- listeners.add(listener);
25926
- return () => {
25927
- listeners.delete(listener);
25928
- };
25929
- },
25930
- async install(host, agent) {
25931
- const id = key(host, agent);
25932
- const previous = states2.get(id);
25933
- if (!diagnostics.installation || previous && previous.status !== "error") return;
25934
- states2.set(id, { status: "installing" });
25935
- notify2();
25936
- let failure;
25937
- try {
25938
- await diagnostics.installation(host, agent, "install");
25939
- states2.set(id, { status: "checking" });
25940
- notify2();
25941
- } catch (error51) {
25942
- failure = errorMessage(error51);
25943
- }
25944
- try {
25945
- await diagnostics.refresh(host);
25946
- const refreshed = diagnostics.snapshot().hosts.find((candidate) => candidate.hostId === host)?.agents.find((candidate) => candidate.agent === agent);
25947
- if (refreshed?.availability === "ready") failure = void 0;
25948
- else if (failure && unknownInstallOutcome(failure) && refreshed && refreshed.availability !== "notInstalled") {
25949
- failure = void 0;
25950
- }
25951
- } catch (error51) {
25952
- failure ??= errorMessage(error51);
25953
- }
25954
- if (failure) states2.set(id, { status: "error", error: failure });
25955
- else states2.delete(id);
25956
- notify2();
25957
- }
25958
- };
25959
- }
25960
- function harnessInstallStore(diagnostics) {
25961
- let store = stores.get(diagnostics);
25962
- if (!store) {
25963
- store = createStore(diagnostics);
25964
- stores.set(diagnostics, store);
25965
- }
25966
- return store;
25967
- }
25968
-
25969
- // src/settings/harness-version-panel.ts
25970
- function createHarnessVersionPanel(document2, messages, signal, agent, client, onChange = () => void 0) {
25971
- const panel = document2.createElement("section");
25972
- panel.className = "settings-harness-version";
25973
- panel.dataset.harnessVersion = agent;
25974
- const heading = document2.createElement("strong");
25975
- heading.textContent = messages.harnessVersionTitle;
25976
- const versions = document2.createElement("div");
25977
- versions.className = "settings-harness-version__values";
25978
- const current = document2.createElement("span");
25979
- const latest = document2.createElement("span");
25980
- versions.append(current, latest);
26421
+ // src/settings/harness-launch-controls.ts
26422
+ function createHarnessLaunchControls(document2, messages, agent, settings) {
26423
+ const section = document2.createElement("section");
26424
+ section.className = "settings-harness-launch";
26425
+ section.dataset.harnessLaunch = agent;
26426
+ const label = document2.createElement("label");
26427
+ label.textContent = messages.launchPathLabel;
26428
+ const input = document2.createElement("input");
26429
+ input.type = "text";
26430
+ input.autocomplete = "off";
26431
+ input.spellcheck = false;
26432
+ input.placeholder = messages.locale === "zh-CN" ? "\u5E94\u7528\u5B89\u88C5\u76EE\u5F55\u7684\u7EDD\u5BF9\u8DEF\u5F84" : "Absolute installation directory";
26433
+ input.setAttribute("aria-label", messages.launchPathLabel);
26434
+ label.append(input);
26435
+ const help = document2.createElement("p");
26436
+ 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.";
26437
+ const actions = document2.createElement("div");
26438
+ actions.className = "settings-harness-launch__actions";
26439
+ const save = document2.createElement("button");
26440
+ save.type = "button";
26441
+ save.className = "settings-command-button";
26442
+ save.textContent = messages.launchPathSave;
26443
+ const reset = document2.createElement("button");
26444
+ reset.type = "button";
26445
+ reset.className = "settings-command-button settings-command-button--secondary";
26446
+ reset.textContent = messages.launchPathReset;
25981
26447
  const status = document2.createElement("p");
25982
26448
  status.setAttribute("role", "status");
25983
- const actions = document2.createElement("div");
25984
- actions.className = "settings-connection-error-actions";
25985
- const update = document2.createElement("button");
25986
- update.type = "button";
25987
- update.className = "settings-command-button settings-command-button--secondary";
25988
- update.dataset.harnessVersionAction = "update";
25989
- const note = document2.createElement("p");
25990
- note.className = "settings-connection-issue-note";
25991
- note.textContent = messages.harnessVersionNote;
25992
- actions.append(update);
25993
- panel.append(heading, versions, status, actions, note);
25994
- let state;
25995
- let busy = false;
25996
- let updating = false;
25997
- let unsupported = false;
25998
- let updatePromise = null;
25999
- const render = () => {
26000
- heading.textContent = state?.versionKind === "application" ? messages.harnessVersionApplicationTitle : messages.harnessVersionTitle;
26001
- current.textContent = `${messages.harnessVersionCurrent}: ${state?.currentVersion ?? "\u2014"}`;
26002
- latest.textContent = `${messages.harnessVersionLatest}: ${harnessVersionLabel(state, messages.harnessVersion)}`;
26003
- update.disabled = busy || signal.aborted || !state?.canUpdate || !state.updateAvailable;
26004
- const manualUrl = !state?.canUpdate && state?.updateAvailable ? state.manualUpdateUrl : void 0;
26005
- actions.replaceChildren(update);
26006
- update.hidden = !busy && !signal.aborted && Boolean(manualUrl);
26007
- if (update.hidden && manualUrl) {
26008
- const download2 = document2.createElement("a");
26009
- download2.className = "settings-command-button settings-command-button--secondary";
26010
- download2.dataset.harnessVersionAction = "download-update";
26011
- download2.textContent = messages.harnessVersionDownloadUpdate;
26012
- download2.href = manualUrl;
26013
- download2.target = "_blank";
26014
- download2.rel = "noopener noreferrer";
26015
- actions.append(download2);
26016
- }
26017
- update.textContent = state?.canUpdate && state.latestVersion !== "Unknown" && !state.updateAvailable ? messages.harnessVersionUpToDate : messages.harnessVersionUpdate;
26018
- const detail = harnessVersionNote(state, messages.harnessVersion);
26019
- note.textContent = detail ? !state?.canUpdate ? detail : `${detail} ${messages.harnessVersionNote}` : messages.harnessVersionNote;
26449
+ status.setAttribute("aria-live", "polite");
26450
+ actions.append(save, reset);
26451
+ section.append(label, help, actions, status);
26452
+ let busy = true;
26453
+ let loaded = false;
26454
+ const controls = () => {
26455
+ input.disabled = busy || !loaded;
26456
+ save.disabled = busy || !loaded || !input.value.trim();
26457
+ reset.disabled = busy || !loaded;
26458
+ };
26459
+ const show = (value) => {
26460
+ input.value = value.path ?? "";
26461
+ status.textContent = value.restartRequired ? messages.launchPathRestart : value.path ? messages.launchPathSaved : messages.launchPathAutomatic;
26020
26462
  };
26021
- const run = async (action) => {
26022
- if (busy || unsupported || signal.aborted) return false;
26023
- if (action === "update" && (!state?.canUpdate || !state.updateAvailable)) return false;
26463
+ const persist = async (value) => {
26464
+ if (busy || !loaded) return;
26024
26465
  busy = true;
26025
- updating = action === "update";
26026
- onChange();
26027
- status.textContent = action === "check" ? messages.harnessVersionChecking : messages.harnessVersionUpdating;
26028
- render();
26466
+ controls();
26467
+ status.textContent = messages.launchPathSaving;
26029
26468
  try {
26030
- const result = await client.run(action);
26031
- if (signal.aborted) return false;
26032
- state = result;
26033
- status.textContent = !result.canUpdate ? messages.harnessVersionManual : action === "update" ? result.updateAvailable ? messages.harnessVersionFailed : messages.harnessVersionUpdated : "";
26034
- return result.canUpdate && !result.updateAvailable;
26035
- } catch (error51) {
26036
- if (signal.aborted) return false;
26037
- unsupported = typeof error51 === "object" && error51 !== null && "code" in error51 && (error51.code === -32601 || error51.code === -32078);
26038
- status.textContent = unsupported ? messages.harnessVersionUnsupported : messages.harnessVersionFailed;
26039
- if (state) state = { ...state, canUpdate: false };
26040
- return false;
26469
+ show(await settings.set(value));
26470
+ } catch {
26471
+ status.textContent = messages.launchPathSaveError;
26041
26472
  } finally {
26042
26473
  busy = false;
26043
- updating = false;
26044
- if (!signal.aborted) {
26045
- render();
26046
- onChange();
26047
- }
26474
+ controls();
26048
26475
  }
26049
26476
  };
26050
- const updateVersion = () => {
26051
- updatePromise ??= run("update").finally(() => {
26052
- updatePromise = null;
26053
- });
26054
- return updatePromise;
26055
- };
26056
- update.addEventListener("click", () => void updateVersion());
26057
- const owner = document2.defaultView;
26058
- let checkFrame = null;
26059
- let checkTimer = null;
26060
- signal.addEventListener(
26061
- "abort",
26062
- () => {
26063
- if (checkFrame !== null) owner?.cancelAnimationFrame(checkFrame);
26064
- if (checkTimer !== null) owner?.clearTimeout(checkTimer);
26065
- render();
26066
- },
26067
- { once: true }
26068
- );
26069
- status.textContent = messages.harnessVersionChecking;
26070
- render();
26071
- if (!signal.aborted && owner?.requestAnimationFrame) {
26072
- checkFrame = owner.requestAnimationFrame(() => {
26073
- checkFrame = null;
26074
- if (signal.aborted) return;
26075
- checkTimer = owner.setTimeout(() => {
26076
- checkTimer = null;
26077
- void run("check");
26078
- }, 0);
26079
- });
26080
- } else {
26081
- void run("check");
26082
- }
26083
- return {
26084
- element: panel,
26085
- get state() {
26086
- return state;
26087
- },
26088
- get updating() {
26089
- return updating;
26090
- },
26091
- update: updateVersion
26092
- };
26477
+ input.addEventListener("input", controls);
26478
+ save.addEventListener("click", () => {
26479
+ if (input.value.trim()) void persist(input.value.trim());
26480
+ });
26481
+ reset.addEventListener("click", () => {
26482
+ void persist(null);
26483
+ });
26484
+ controls();
26485
+ status.textContent = messages.launchPathLoading;
26486
+ void settings.get().then((value) => {
26487
+ loaded = true;
26488
+ show(value);
26489
+ }).catch(() => {
26490
+ loaded = true;
26491
+ status.textContent = messages.launchPathLoadError;
26492
+ }).finally(() => {
26493
+ busy = false;
26494
+ controls();
26495
+ });
26496
+ return section;
26093
26497
  }
26094
26498
 
26095
- // src/settings/connection-versions.ts
26096
- function createConnectionVersions(document2, messages, signal, diagnostics, onChange) {
26097
- const panels = /* @__PURE__ */ new Map();
26098
- const installation = diagnostics?.installation?.bind(diagnostics);
26099
- return {
26100
- get(hostId2, agent) {
26101
- if (!installation || signal.aborted) return void 0;
26102
- const key = JSON.stringify([hostId2, agent]);
26103
- let panel = panels.get(key);
26104
- if (!panel) {
26105
- panel = createHarnessVersionPanel(
26106
- document2,
26107
- messages,
26108
- signal,
26109
- agent,
26110
- {
26111
- run: (action) => installation(hostId2, agent, action)
26112
- },
26113
- onChange
26114
- );
26115
- panels.set(key, panel);
26499
+ // src/settings/claude-long-context-control.ts
26500
+ var CLAUDE_LONG_CONTEXT_MODELS = [{ id: "claude-opus-5-5", window: "1M" }];
26501
+ var tooltipSequence = 0;
26502
+ function popoverOpen(tooltip) {
26503
+ try {
26504
+ return tooltip.matches(":popover-open");
26505
+ } catch {
26506
+ return false;
26507
+ }
26508
+ }
26509
+ function createClaudeLongContextControl(document2, messages, actions) {
26510
+ const control = document2.createElement("span");
26511
+ control.className = "settings-connection-long-context";
26512
+ const label = document2.createElement("label");
26513
+ label.className = "settings-connection-long-context__control";
26514
+ const text = document2.createElement("span");
26515
+ text.textContent = messages.connectionLongContextLabel;
26516
+ const input = document2.createElement("input");
26517
+ input.type = "checkbox";
26518
+ input.checked = true;
26519
+ input.setAttribute("role", "switch");
26520
+ input.setAttribute("aria-checked", "true");
26521
+ input.setAttribute("aria-label", messages.connectionLongContextLabel);
26522
+ input.dataset.connectionAction = "long-context";
26523
+ const tooltip = document2.createElement("div");
26524
+ tooltip.id = `settings-long-context-tooltip-${++tooltipSequence}`;
26525
+ tooltip.className = "settings-connection-long-context__tooltip";
26526
+ tooltip.setAttribute("role", "tooltip");
26527
+ tooltip.setAttribute("popover", "manual");
26528
+ tooltip.hidden = true;
26529
+ const on = document2.createElement("p");
26530
+ on.textContent = messages.connectionLongContextOn;
26531
+ const off = document2.createElement("p");
26532
+ off.textContent = messages.connectionLongContextOff;
26533
+ const modelsLabel = document2.createElement("p");
26534
+ modelsLabel.textContent = messages.connectionLongContextModelsLabel;
26535
+ const models = document2.createElement("ul");
26536
+ for (const model2 of CLAUDE_LONG_CONTEXT_MODELS) {
26537
+ const item = document2.createElement("li");
26538
+ item.textContent = `${model2.id} (${model2.window})`;
26539
+ models.append(item);
26540
+ }
26541
+ tooltip.append(on, off, modelsLabel, models);
26542
+ input.setAttribute("aria-describedby", tooltip.id);
26543
+ const stop = (event) => {
26544
+ event.stopPropagation();
26545
+ };
26546
+ control.addEventListener("click", stop);
26547
+ label.addEventListener("click", stop);
26548
+ input.addEventListener("click", stop);
26549
+ let surfaceReady = false;
26550
+ const applyTooltipSurface = () => {
26551
+ if (surfaceReady) return;
26552
+ const probe = document2.createElement("span");
26553
+ probe.style.cssText = "position:absolute;visibility:hidden;color:var(--settings-text);background-color:var(--settings-elevated);border-top-color:var(--settings-border)";
26554
+ control.append(probe);
26555
+ const computed = document2.defaultView?.getComputedStyle(probe);
26556
+ const color = computed?.color;
26557
+ const background = computed?.backgroundColor;
26558
+ const borderColor = computed?.borderTopColor;
26559
+ probe.remove();
26560
+ if (color) tooltip.style.color = color;
26561
+ if (background && background !== "rgba(0, 0, 0, 0)") tooltip.style.backgroundColor = background;
26562
+ if (borderColor) tooltip.style.border = `1px solid ${borderColor}`;
26563
+ surfaceReady = true;
26564
+ };
26565
+ const showTooltip = () => {
26566
+ const root = control.getRootNode();
26567
+ const host = root instanceof ShadowRoot ? root : document2.body ?? control;
26568
+ if (tooltip.parentNode !== host) host.append(tooltip);
26569
+ applyTooltipSurface();
26570
+ tooltip.hidden = false;
26571
+ if (typeof tooltip.showPopover === "function" && !popoverOpen(tooltip)) {
26572
+ try {
26573
+ tooltip.showPopover();
26574
+ } catch {
26575
+ tooltip.removeAttribute("popover");
26116
26576
  }
26117
- return panel;
26118
26577
  }
26119
- };
26120
- }
26121
-
26122
- // src/settings/connection-updates.ts
26123
- function createConnectionUpdates(document2, messages, signal, onChange) {
26124
- const batches = /* @__PURE__ */ new Map();
26125
- const eligible = (panels) => panels.filter((panel) => panel.state?.updateAvailable && panel.state.canUpdate);
26126
- const start = async (hostId2, panels) => {
26127
- if (signal.aborted || batches.get(hostId2)?.running) return;
26128
- const targets = eligible(panels);
26129
- if (!targets.length) return;
26130
- const batch = { running: true, total: targets.length, succeeded: 0, failed: 0 };
26131
- batches.set(hostId2, batch);
26132
- onChange();
26133
- await Promise.all(
26134
- targets.map(async (panel) => {
26135
- try {
26136
- if (await panel.update()) batch.succeeded++;
26137
- else batch.failed++;
26138
- } catch {
26139
- batch.failed++;
26140
- }
26141
- if (!signal.aborted) onChange();
26142
- })
26578
+ tooltip.style.position = "fixed";
26579
+ tooltip.style.inset = "auto";
26580
+ tooltip.style.zIndex = "80";
26581
+ tooltip.style.margin = "0";
26582
+ tooltip.style.height = "auto";
26583
+ tooltip.style.overflow = "visible";
26584
+ const rect = control.getBoundingClientRect();
26585
+ const margin = 8;
26586
+ const width = Math.min(280, Math.max(160, window.innerWidth - margin * 2));
26587
+ tooltip.style.width = `${width}px`;
26588
+ const preferredLeft = Math.min(
26589
+ Math.max(margin, rect.right - width),
26590
+ window.innerWidth - width - margin
26143
26591
  );
26144
- batch.running = false;
26145
- if (!signal.aborted) onChange();
26592
+ const height = tooltip.offsetHeight;
26593
+ const below = rect.bottom + 8;
26594
+ const preferredTop = below + height <= window.innerHeight - margin ? below : Math.max(margin, rect.top - height - 8);
26595
+ tooltip.style.left = `${preferredLeft}px`;
26596
+ tooltip.style.top = `${preferredTop}px`;
26597
+ const placed = tooltip.getBoundingClientRect();
26598
+ const shiftX = preferredLeft - placed.left;
26599
+ const shiftY = preferredTop - placed.top;
26600
+ if (Math.abs(shiftX) > 0.5 || Math.abs(shiftY) > 0.5) {
26601
+ tooltip.style.left = `${preferredLeft + shiftX}px`;
26602
+ tooltip.style.top = `${preferredTop + shiftY}px`;
26603
+ }
26146
26604
  };
26147
- return {
26148
- createControls(hostId2, panels) {
26149
- const batch = batches.get(hostId2);
26150
- const count3 = eligible(panels).length;
26151
- const button2 = document2.createElement("button");
26152
- button2.type = "button";
26153
- button2.className = "settings-command-button settings-command-button--secondary settings-connection-update-all";
26154
- button2.dataset.connectionAction = "update-all";
26155
- button2.disabled = signal.aborted || Boolean(batch?.running) || !count3;
26156
- button2.title = messages.harnessUpdateAllDescription;
26157
- const label = batch?.running ? `${messages.harnessUpdateAllProgress} ${batch.succeeded + batch.failed}/${batch.total}` : count3 ? `${messages.harnessUpdateAll} (${count3})` : messages.harnessUpdateAll;
26158
- button2.append(createRendererSettingsIcon("download", 15), label);
26159
- button2.addEventListener("click", () => {
26160
- if (!button2.disabled) void start(hostId2, panels);
26161
- });
26162
- const result = document2.createElement("p");
26163
- result.className = "settings-connection-update-result";
26164
- result.setAttribute("role", "status");
26165
- result.hidden = !batch || batch.running;
26166
- if (batch && !batch.running) {
26167
- result.textContent = messages.harnessUpdateAllResult.replace("{succeeded}", String(batch.succeeded)).replace("{failed}", String(batch.failed));
26168
- }
26169
- return { button: button2, result };
26170
- }
26171
- };
26172
- }
26173
-
26174
- // src/settings/selection-scroll.ts
26175
- var SELECTION_CONTROL_SELECTOR = "button, a, input, textarea, select, label";
26176
- function upwardScrollTop(saved, current) {
26177
- return current < saved ? saved : current;
26178
- }
26179
- function isPrimaryPointer(event) {
26180
- return "button" in event && event.button === 0;
26181
- }
26182
- function canScrollVertically(element) {
26183
- if (element.scrollHeight <= element.clientHeight + 1) return false;
26184
- const view = element.ownerDocument.defaultView;
26185
- if (!view) return false;
26186
- const overflow = view.getComputedStyle(element).overflowY;
26187
- return overflow === "auto" || overflow === "scroll" || overflow === "overlay";
26188
- }
26189
- function verticalScrollers(target2, page) {
26190
- const scrollers = [];
26191
- let node = target2;
26192
- while (node) {
26193
- if (node instanceof HTMLElement && canScrollVertically(node)) scrollers.push(node);
26194
- if (node === page) break;
26195
- node = node.parentElement;
26196
- }
26197
- if (!scrollers.includes(page) && canScrollVertically(page)) scrollers.push(page);
26198
- return scrollers;
26199
- }
26200
- function pointerOnScrollbar(target2, scroller, event) {
26201
- return target2 === scroller && event.offsetX >= scroller.clientWidth;
26202
- }
26203
- function keepPageStillDuringTextSelection(region) {
26204
- const view = () => region.ownerDocument.defaultView;
26205
- let session = null;
26206
- const detach = () => {
26207
- if (!session) return;
26208
- const document2 = region.ownerDocument;
26209
- for (const scroller of session.tops.keys()) {
26210
- scroller.removeEventListener("scroll", session.onScroll);
26211
- }
26212
- document2.removeEventListener("pointerup", session.onPointerUp);
26213
- document2.removeEventListener("pointercancel", session.onCancel);
26214
- document2.removeEventListener("wheel", session.onWheel);
26215
- if (session.frame) view()?.cancelAnimationFrame(session.frame);
26216
- session = null;
26217
- };
26218
- let restoring = false;
26219
- const restore = () => {
26220
- if (!session || restoring) return;
26221
- restoring = true;
26222
- try {
26223
- for (const [scroller, top] of session.tops) {
26224
- const next = upwardScrollTop(top, scroller.scrollTop);
26225
- if (next !== scroller.scrollTop) scroller.scrollTop = next;
26226
- else if (scroller.scrollTop > top) session.tops.set(scroller, scroller.scrollTop);
26605
+ const hideTooltip = () => {
26606
+ if (typeof tooltip.hidePopover === "function" && popoverOpen(tooltip)) {
26607
+ try {
26608
+ tooltip.hidePopover();
26609
+ } catch {
26610
+ }
26611
+ }
26612
+ tooltip.hidden = true;
26613
+ };
26614
+ control.addEventListener("mouseenter", showTooltip);
26615
+ control.addEventListener("mouseleave", hideTooltip);
26616
+ control.addEventListener("focusin", showTooltip);
26617
+ control.addEventListener("focusout", (event) => {
26618
+ const next = event.relatedTarget;
26619
+ if (next instanceof Node && control.contains(next)) return;
26620
+ hideTooltip();
26621
+ });
26622
+ let generation = 0;
26623
+ input.addEventListener("change", () => {
26624
+ const next = input.checked;
26625
+ generation += 1;
26626
+ const request = generation;
26627
+ input.disabled = true;
26628
+ input.setAttribute("aria-checked", String(next));
26629
+ void actions.set(next).then(
26630
+ (result) => {
26631
+ if (request !== generation) return;
26632
+ input.checked = result.enabled;
26633
+ input.setAttribute("aria-checked", String(result.enabled));
26634
+ input.disabled = false;
26635
+ },
26636
+ () => {
26637
+ if (request !== generation) return;
26638
+ input.checked = !next;
26639
+ input.setAttribute("aria-checked", String(!next));
26640
+ input.disabled = false;
26227
26641
  }
26228
- } finally {
26229
- restoring = false;
26230
- }
26231
- };
26232
- region.addEventListener("pointerdown", (event) => {
26233
- if (!isPrimaryPointer(event)) return;
26234
- const target2 = event.target;
26235
- if (!(target2 instanceof Element) || target2.closest(SELECTION_CONTROL_SELECTOR)) return;
26236
- const page = region.closest(".settings-page");
26237
- if (!(page instanceof HTMLElement)) return;
26238
- detach();
26239
- const tops = /* @__PURE__ */ new Map();
26240
- for (const scroller of verticalScrollers(target2, page)) {
26241
- if (pointerOnScrollbar(target2, scroller, event)) continue;
26242
- tops.set(scroller, scroller.scrollTop);
26243
- }
26244
- if (tops.size === 0) return;
26245
- const onScroll = () => restore();
26246
- const onPointerUp = () => {
26247
- restore();
26248
- if (!session) return;
26249
- session.framesLeft = 2;
26250
- const finish = () => {
26251
- if (!session) return;
26252
- restore();
26253
- session.framesLeft -= 1;
26254
- const owner2 = view();
26255
- if (session.framesLeft > 0 && owner2?.requestAnimationFrame) {
26256
- session.frame = owner2.requestAnimationFrame(finish);
26257
- return;
26258
- }
26259
- detach();
26260
- };
26261
- const owner = view();
26262
- if (owner?.requestAnimationFrame) session.frame = owner.requestAnimationFrame(finish);
26263
- else detach();
26264
- };
26265
- const onCancel = () => detach();
26266
- const onWheel = () => detach();
26267
- session = { tops, frame: 0, framesLeft: 0, onScroll, onPointerUp, onCancel, onWheel };
26268
- const document2 = region.ownerDocument;
26269
- for (const scroller of tops.keys()) scroller.addEventListener("scroll", onScroll);
26270
- document2.addEventListener("pointerup", onPointerUp);
26271
- document2.addEventListener("pointercancel", onCancel);
26272
- document2.addEventListener("wheel", onWheel, { passive: true });
26642
+ );
26273
26643
  });
26644
+ void actions.get().then(
26645
+ (result) => {
26646
+ if (generation !== 0) return;
26647
+ input.checked = result.enabled;
26648
+ input.setAttribute("aria-checked", String(result.enabled));
26649
+ },
26650
+ () => void 0
26651
+ );
26652
+ label.append(text, input);
26653
+ control.append(label, tooltip);
26654
+ return control;
26274
26655
  }
26275
26656
 
26276
26657
  // src/settings/connections-page.ts
26277
26658
  var CODEXHOST_GITHUB_ISSUES_NEW_URL = "https://github.com/LIBERSEEK/BOFT-CLI/issues/new";
26278
- function connectionStatusLabel(availability, messages, hasError = false) {
26279
- if (availability === "updating") return messages.connectionStatusUpdating;
26280
- if (hasError && availability !== "notInstalled") return messages.connectionStatusError;
26281
- if (availability === "ready") return messages.connectionStatusReady;
26282
- if (availability === "checking") return messages.connectionStatusChecking;
26283
- if (availability === "notInstalled") return messages.connectionStatusNotInstalled;
26284
- if (availability === "unavailable" || availability === "error") {
26285
- return availability === "error" ? messages.connectionStatusError : messages.connectionStatusUnavailable;
26286
- }
26287
- return availability === "installing" ? messages.connectionStatusInstalling : messages.connectionStatusUnsupported;
26288
- }
26289
- function connectionStatusTone(availability, hasError = false) {
26290
- if (availability === "updating") return "checking";
26291
- if (hasError && availability !== "notInstalled") return "failed";
26292
- if (availability === "ready") return "ready";
26293
- if (availability === "checking" || availability === "installing") return "checking";
26294
- if (availability === "notInstalled") return "setup";
26295
- return "failed";
26296
- }
26297
26659
  function diagnosticText(hostId2, item) {
26298
26660
  const error51 = item.error;
26299
26661
  return [
26300
- "BOFT CLI connection diagnostics",
26662
+ "codexhost connection diagnostics",
26301
26663
  `host: ${hostId2}`,
26302
26664
  `agent: ${item.name}`,
26303
26665
  `status: ${item.availability}`,
@@ -26389,147 +26751,21 @@ ${error51.stderrTail}`] : []
26389
26751
  tabs.addEventListener("wheel", onWheel, { passive: false });
26390
26752
  const ownerWindow = document2.defaultView;
26391
26753
  ownerWindow?.addEventListener("resize", updateButtons);
26392
- ownerWindow?.setTimeout(updateButtons, 0);
26393
- updateButtons();
26394
- return () => {
26395
- left.removeEventListener("click", onLeft);
26396
- right.removeEventListener("click", onRight);
26397
- tabs.removeEventListener("scroll", updateButtons);
26398
- tabs.removeEventListener("wheel", onWheel);
26399
- ownerWindow?.removeEventListener("resize", updateButtons);
26754
+ const refreshLayout = () => {
26755
+ ownerWindow?.setTimeout(updateButtons, 0);
26756
+ updateButtons();
26757
+ };
26758
+ refreshLayout();
26759
+ return {
26760
+ update: refreshLayout,
26761
+ dispose() {
26762
+ left.removeEventListener("click", onLeft);
26763
+ right.removeEventListener("click", onRight);
26764
+ tabs.removeEventListener("scroll", updateButtons);
26765
+ tabs.removeEventListener("wheel", onWheel);
26766
+ ownerWindow?.removeEventListener("resize", updateButtons);
26767
+ }
26400
26768
  };
26401
- }
26402
- function createConnectionIdentityIcon(document2, item, size) {
26403
- const container = document2.createElement("span");
26404
- container.className = item.agentSnapshot ? "settings-connection-row__mark settings-connection-row__mark--logo" : "settings-connection-row__mark";
26405
- container.setAttribute("aria-hidden", "true");
26406
- if (item.agentSnapshot) {
26407
- container.append(
26408
- createRendererAgentIcon(item.agentSnapshot.agent, size, document2, item.agentSnapshot.plugin)
26409
- );
26410
- } else {
26411
- container.textContent = "CH";
26412
- }
26413
- return container;
26414
- }
26415
- function createConnectionRow(document2, item, messages, selected, select, group = null, longContext = null) {
26416
- const row = document2.createElement("div");
26417
- row.className = "settings-connection-row";
26418
- row.dataset.connectionItem = item.key;
26419
- row.dataset.connectionSelected = String(selected);
26420
- row.tabIndex = selected ? 0 : -1;
26421
- row.setAttribute("role", "row");
26422
- const identity2 = document2.createElement("div");
26423
- identity2.className = "settings-connection-row__identity";
26424
- identity2.setAttribute("role", "cell");
26425
- const handle = group ? document2.createElement("span") : null;
26426
- if (group && handle) {
26427
- handle.className = "settings-connection-row__handle";
26428
- handle.setAttribute("aria-hidden", "true");
26429
- handle.title = group.dragHandleTitle;
26430
- handle.append(createRendererSettingsIcon("grip-vertical", 15));
26431
- identity2.append(handle);
26432
- }
26433
- const label = document2.createElement("strong");
26434
- label.textContent = item.name;
26435
- identity2.append(createConnectionIdentityIcon(document2, item, 19), label);
26436
- const status = document2.createElement("span");
26437
- status.className = "settings-connection-row__status";
26438
- status.dataset.connectionTone = connectionStatusTone(item.availability, item.error !== null);
26439
- status.setAttribute("role", "cell");
26440
- status.textContent = item.error?.code === "authenticationRequired" ? messages.connectionLoginRequired : item.error?.code === "configurationRequired" ? messages.connectionConfigurationRequired : connectionStatusLabel(item.availability, messages, item.error !== null);
26441
- const version2 = item.version;
26442
- const action = document2.createElement("div");
26443
- action.className = "settings-connection-row__action";
26444
- action.setAttribute("role", "cell");
26445
- if (item.error && item.agentSnapshot?.availability !== "notInstalled") {
26446
- const viewError = document2.createElement("button");
26447
- viewError.type = "button";
26448
- viewError.className = "settings-connection-view-error";
26449
- viewError.textContent = messages.connectionViewError;
26450
- viewError.addEventListener("click", (event) => {
26451
- event.stopPropagation();
26452
- select();
26453
- });
26454
- action.append(viewError);
26455
- }
26456
- if (longContext) action.append(longContext);
26457
- if (version2?.state?.updateAvailable && version2.state.canUpdate) {
26458
- const update = document2.createElement("button");
26459
- update.type = "button";
26460
- update.className = "settings-connection-install-link";
26461
- update.dataset.connectionAction = "update";
26462
- update.disabled = version2.updating;
26463
- update.title = `${messages.harnessVersionUpdate}: ${item.name}
26464
- ${messages.harnessVersionCurrent}: ${version2.state.currentVersion ?? "\u2014"}
26465
- ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages.harnessVersion)}`;
26466
- update.setAttribute("aria-label", `${messages.harnessVersionUpdate}: ${item.name}`);
26467
- update.append(createRendererSettingsIcon("download", 15));
26468
- update.addEventListener("click", (event) => {
26469
- event.stopPropagation();
26470
- if (update.disabled) return;
26471
- void version2.update();
26472
- select();
26473
- });
26474
- action.append(update);
26475
- }
26476
- if (group) {
26477
- const toggle = document2.createElement("button");
26478
- toggle.type = "button";
26479
- toggle.disabled = group.disabled;
26480
- toggle.className = "settings-connection-row__group-toggle";
26481
- toggle.title = group.moveLabel;
26482
- toggle.setAttribute("aria-label", group.moveLabel);
26483
- toggle.append(
26484
- createRendererSettingsIcon(group.section === "main" ? "chevron-down" : "chevron-up", 15)
26485
- );
26486
- toggle.addEventListener("click", (event) => {
26487
- event.stopPropagation();
26488
- group.toggleSection();
26489
- });
26490
- action.append(toggle);
26491
- }
26492
- row.addEventListener("click", (event) => {
26493
- const target2 = event.target;
26494
- if (target2?.closest?.("a, input, label")) return;
26495
- select();
26496
- });
26497
- row.addEventListener("keydown", (event) => {
26498
- if (event.target?.closest?.("button, a")) return;
26499
- if (event.key !== "Enter" && event.key !== " ") return;
26500
- event.preventDefault();
26501
- select();
26502
- });
26503
- if (group && handle) {
26504
- row.draggable = false;
26505
- row.dataset.connectionGroupSection = group.section;
26506
- handle.addEventListener("pointerdown", (event) => {
26507
- if (group.disabled || event.button !== 0) return;
26508
- row.draggable = true;
26509
- });
26510
- const releaseDrag = () => {
26511
- if (row.dataset.connectionDragging === "true") return;
26512
- row.draggable = false;
26513
- };
26514
- row.addEventListener("pointerup", releaseDrag);
26515
- row.addEventListener("pointercancel", releaseDrag);
26516
- row.addEventListener("dragstart", (event) => {
26517
- if (!row.draggable) {
26518
- event.preventDefault();
26519
- return;
26520
- }
26521
- group.onDragStart(event);
26522
- });
26523
- row.addEventListener("dragover", group.onDragOver);
26524
- row.addEventListener("dragleave", group.onDragLeave);
26525
- row.addEventListener("drop", group.onDrop);
26526
- row.addEventListener("dragend", (event) => {
26527
- row.draggable = false;
26528
- group.onDragEnd(event);
26529
- });
26530
- }
26531
- row.append(identity2, status, action);
26532
- return row;
26533
26769
  }
26534
26770
  function createInspectorHeader(document2, item, messages) {
26535
26771
  const header = document2.createElement("header");
@@ -26559,7 +26795,30 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26559
26795
  header.append(identity2, status);
26560
26796
  return header;
26561
26797
  }
26562
- function renderConnectionInspector(document2, inspector, item, hostId2, messages, diagnostics, existingLaunchControls, refresh, openExternalUrl) {
26798
+ function inspectorRenderSignature(hostId2, item, messages, diagnostics) {
26799
+ const plugin = item.agentSnapshot?.plugin;
26800
+ const notice = plugin?.notice ? plugin.notice[messages.locale] ?? plugin.notice.en : "";
26801
+ const websiteUrl = plugin?.links?.website ?? plugin?.links?.documentation ?? "";
26802
+ const hasLaunchControls = hostId2 === "local" && Boolean(item.agentSnapshot?.agent) && Boolean(plugin?.launchCommand) && Boolean(diagnostics?.getLaunchSettings && diagnostics?.setLaunchSettings);
26803
+ return JSON.stringify([
26804
+ hostId2,
26805
+ item.key,
26806
+ item.name,
26807
+ item.availability,
26808
+ item.agentSnapshot?.availability ?? null,
26809
+ String(plugin?.icon ?? ""),
26810
+ String(plugin?.iconStyle ?? ""),
26811
+ websiteUrl,
26812
+ notice,
26813
+ item.installError ?? "",
26814
+ Boolean(item.install),
26815
+ plugin?.installation ?? null,
26816
+ Boolean(item.openWebUi),
26817
+ hasLaunchControls,
26818
+ item.error ? diagnosticText(hostId2, item) : ""
26819
+ ]);
26820
+ }
26821
+ function renderConnectionInspector(document2, inspector, item, hostId2, messages, diagnostics, existingLaunchControls, refresh, getOpenExternalUrl) {
26563
26822
  inspector.replaceChildren(createInspectorHeader(document2, item, messages));
26564
26823
  const body = document2.createElement("div");
26565
26824
  body.className = "settings-connection-inspector__body";
@@ -26645,14 +26904,10 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26645
26904
  issue2.target = "_blank";
26646
26905
  issue2.rel = "noopener noreferrer";
26647
26906
  issue2.addEventListener("click", (event) => {
26648
- const open = openExternalUrl();
26649
- if (!open) return;
26907
+ const openExternalUrl = getOpenExternalUrl?.();
26908
+ if (!openExternalUrl) return;
26650
26909
  event.preventDefault();
26651
- const url2 = issue2.href;
26652
- void open(url2).catch((error51) => {
26653
- console.error("codexhost external URL open failed", error51);
26654
- document2.defaultView?.open(url2, "_blank", "noopener,noreferrer");
26655
- });
26910
+ void openExternalUrl(CODEXHOST_GITHUB_ISSUES_NEW_URL);
26656
26911
  });
26657
26912
  issue2.append(messages.connectionOpenIssue, createRendererSettingsIcon("external-link", 14));
26658
26913
  actions.append(issue2);
@@ -26704,12 +26959,6 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26704
26959
  }
26705
26960
  function connectionItems(snapshot, host, messages, diagnostics) {
26706
26961
  return [
26707
- {
26708
- key: "renderer-adapter",
26709
- name: messages.connectionAdapter,
26710
- availability: snapshot.adapter.state,
26711
- error: null
26712
- },
26713
26962
  ...host.directoryError ? [
26714
26963
  {
26715
26964
  key: "plugin-directory",
@@ -26731,11 +26980,10 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26731
26980
  ];
26732
26981
  }
26733
26982
  var pendingFocusAgent = null;
26734
- function createGroupDivider(document2, messages, count3) {
26983
+ function createGroupDivider(document2) {
26735
26984
  const divider = document2.createElement("div");
26736
26985
  divider.className = "settings-connection-group-divider";
26737
26986
  divider.setAttribute("role", "presentation");
26738
- divider.textContent = `${messages.connectionGroupMoreLabel} (${count3})`;
26739
26987
  return divider;
26740
26988
  }
26741
26989
  function createGroupMoreHint(document2, messages) {
@@ -26757,7 +27005,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26757
27005
  button2.addEventListener("click", onReset);
26758
27006
  return button2;
26759
27007
  }
26760
- function createConnectionsSettingsPage(messages, getDiagnostics, groupPreference = getSharedAgentGroupPreferenceStore(), getRemoteConnections = () => null, openExternalUrl = () => void 0) {
27008
+ function createConnectionsSettingsPage(messages, getDiagnostics, groupPreference = getSharedAgentGroupPreferenceStore(), getRemoteConnections = () => null, getOpenExternalUrl) {
26761
27009
  return Object.freeze({
26762
27010
  id: "connections",
26763
27011
  label: messages.pageLabels.connections,
@@ -26788,12 +27036,14 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26788
27036
  context.content.append(header, syncMessage, content);
26789
27037
  let pending = false;
26790
27038
  let selectedHostId = null;
27039
+ let renderedHostId = null;
26791
27040
  let selectedItemKey = null;
26792
- let launchControls = null;
26793
27041
  const longContextControls = /* @__PURE__ */ new Map();
27042
+ let launchControls = null;
27043
+ let renderedInspector = null;
26794
27044
  const hostNames = /* @__PURE__ */ new Map();
27045
+ const knownNotInstalled = /* @__PURE__ */ new Map();
26795
27046
  let latestSnapshot = null;
26796
- let disposeHostScroller = () => void 0;
26797
27047
  let disposed = false;
26798
27048
  let renderQueued = false;
26799
27049
  let renderFrame = null;
@@ -26818,13 +27068,14 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26818
27068
  if (renderFrame !== null) document2.defaultView?.cancelAnimationFrame(renderFrame);
26819
27069
  renderFrame = null;
26820
27070
  };
27071
+ const diagnostics = getDiagnostics();
26821
27072
  const longContextControlFor = (hostId2, item) => {
26822
27073
  const agent = item.agentSnapshot?.agent;
26823
27074
  const availability = item.agentSnapshot?.availability;
26824
27075
  const getLongContext = diagnostics?.getLongContext;
26825
27076
  const setLongContext = diagnostics?.setLongContext;
26826
27077
  if (agent !== "claude-code" || availability === "notInstalled" || availability === "checking" || !getLongContext || !setLongContext) {
26827
- return null;
27078
+ return void 0;
26828
27079
  }
26829
27080
  const key = JSON.stringify([hostId2, agent]);
26830
27081
  const cached2 = longContextControls.get(key);
@@ -26836,7 +27087,6 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26836
27087
  longContextControls.set(key, element);
26837
27088
  return element;
26838
27089
  };
26839
- const diagnostics = getDiagnostics();
26840
27090
  const versions = createConnectionVersions(
26841
27091
  document2,
26842
27092
  messages,
@@ -26845,7 +27095,99 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26845
27095
  scheduleRender
26846
27096
  );
26847
27097
  const installs = diagnostics ? harnessInstallStore(diagnostics) : null;
26848
- const updates = createConnectionUpdates(document2, messages, context.signal, scheduleRender);
27098
+ const updates = createConnectionUpdates(
27099
+ document2,
27100
+ messages,
27101
+ context.signal,
27102
+ scheduleRender,
27103
+ diagnostics
27104
+ );
27105
+ const panelId = "codexhost-settings-connection-host-panel";
27106
+ const empty = document2.createElement("div");
27107
+ empty.className = "settings-empty";
27108
+ empty.textContent = messages.connectionNoRuntime;
27109
+ const layout = document2.createElement("div");
27110
+ layout.className = "settings-connections-layout";
27111
+ const list = document2.createElement("section");
27112
+ list.className = "settings-connection-list";
27113
+ const hostStrip = document2.createElement("div");
27114
+ hostStrip.className = "settings-connection-host-strip";
27115
+ const scrollLeft = createHostScrollButton(document2, "left", messages);
27116
+ const tabs = document2.createElement("div");
27117
+ tabs.className = "settings-connection-host-tabs";
27118
+ tabs.setAttribute("role", "tablist");
27119
+ tabs.setAttribute("aria-label", messages.connectionHosts);
27120
+ const scrollRight = createHostScrollButton(document2, "right", messages);
27121
+ hostStrip.append(scrollLeft, tabs, scrollRight);
27122
+ const updateControls = updates.createControls("local", []);
27123
+ const hostHeader = document2.createElement("div");
27124
+ hostHeader.className = "settings-connection-host-header";
27125
+ hostHeader.append(hostStrip, updateControls.button);
27126
+ const tableHeader = document2.createElement("div");
27127
+ tableHeader.className = "settings-connection-table-header";
27128
+ tableHeader.setAttribute("role", "row");
27129
+ const componentHeading = document2.createElement("span");
27130
+ componentHeading.textContent = messages.connectionComponent;
27131
+ componentHeading.setAttribute("role", "columnheader");
27132
+ const statusHeading = document2.createElement("span");
27133
+ statusHeading.textContent = messages.connectionStatus;
27134
+ statusHeading.setAttribute("role", "columnheader");
27135
+ const actionHeading = document2.createElement("span");
27136
+ actionHeading.setAttribute("aria-hidden", "true");
27137
+ tableHeader.append(componentHeading, statusHeading, actionHeading);
27138
+ const rows = document2.createElement("div");
27139
+ rows.className = "settings-connection-rows";
27140
+ rows.id = panelId;
27141
+ rows.setAttribute("role", "rowgroup");
27142
+ list.append(hostHeader, updateControls.result, tableHeader, rows);
27143
+ const inspector = document2.createElement("aside");
27144
+ inspector.className = "settings-connection-inspector";
27145
+ inspector.setAttribute("aria-live", "polite");
27146
+ layout.append(list, inspector);
27147
+ const hostScroller = configureHostScroller(
27148
+ document2,
27149
+ hostStrip,
27150
+ tabs,
27151
+ scrollLeft,
27152
+ scrollRight
27153
+ );
27154
+ const hostTabElements = /* @__PURE__ */ new Map();
27155
+ const hostRowViews = /* @__PURE__ */ new Map();
27156
+ const groupDivider = createGroupDivider(document2);
27157
+ const moreHint = createGroupMoreHint(document2, messages);
27158
+ const moreZone = document2.createElement("div");
27159
+ moreZone.className = "settings-connection-group-more";
27160
+ moreZone.setAttribute("role", "presentation");
27161
+ const resetButton = createGroupResetButton(document2, messages, () => {
27162
+ groupPreference.resetToDefault();
27163
+ });
27164
+ let draggingAgent = null;
27165
+ let currentCatalog = [];
27166
+ let currentMainEntries = [];
27167
+ let currentMoreEntries = [];
27168
+ let currentHostRows = /* @__PURE__ */ new Map();
27169
+ const clearDropIndicators = () => {
27170
+ for (const view of currentHostRows.values()) {
27171
+ view.element.dataset.connectionDropIndicator = "";
27172
+ }
27173
+ moreZone.dataset.connectionDragOver = "false";
27174
+ };
27175
+ moreZone.addEventListener("dragover", (event) => {
27176
+ if (!draggingAgent) return;
27177
+ event.preventDefault();
27178
+ moreZone.dataset.connectionDragOver = "true";
27179
+ });
27180
+ moreZone.addEventListener("dragleave", () => {
27181
+ moreZone.dataset.connectionDragOver = "false";
27182
+ });
27183
+ moreZone.addEventListener("drop", (event) => {
27184
+ event.preventDefault();
27185
+ moreZone.dataset.connectionDragOver = "false";
27186
+ if (!draggingAgent) return;
27187
+ groupPreference.moveAgent(draggingAgent, "more", null, currentCatalog);
27188
+ draggingAgent = null;
27189
+ clearDropIndicators();
27190
+ });
26849
27191
  const runRefresh = () => {
26850
27192
  if (pending || !diagnostics) return;
26851
27193
  pending = true;
@@ -26858,6 +27200,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26858
27200
  success() {
26859
27201
  installs?.clearErrors();
26860
27202
  pending = false;
27203
+ renderedInspector = null;
26861
27204
  refresh.disabled = false;
26862
27205
  refresh.replaceChildren(
26863
27206
  createRendererSettingsIcon("diagnose", 16),
@@ -26867,6 +27210,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26867
27210
  },
26868
27211
  failure(error51) {
26869
27212
  pending = false;
27213
+ renderedInspector = null;
26870
27214
  refresh.disabled = false;
26871
27215
  refresh.replaceChildren(
26872
27216
  createRendererSettingsIcon("diagnose", 16),
@@ -26892,110 +27236,128 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26892
27236
  }
26893
27237
  });
26894
27238
  };
27239
+ const syncSelectedInspector = (hostId2, item) => {
27240
+ const currentDiagnostics = getDiagnostics();
27241
+ const signature = inspectorRenderSignature(hostId2, item, messages, currentDiagnostics);
27242
+ const versionElement = item.version?.element ?? null;
27243
+ if (renderedInspector?.signature === signature && renderedInspector.versionElement === versionElement) {
27244
+ return;
27245
+ }
27246
+ const existing = launchControls?.hostId === hostId2 && launchControls.itemKey === item.key ? launchControls.element : null;
27247
+ const element = renderConnectionInspector(
27248
+ document2,
27249
+ inspector,
27250
+ item,
27251
+ hostId2,
27252
+ messages,
27253
+ currentDiagnostics,
27254
+ existing,
27255
+ runRefresh,
27256
+ getOpenExternalUrl
27257
+ );
27258
+ launchControls = { hostId: hostId2, itemKey: item.key, element };
27259
+ if (versionElement) inspector.append(versionElement);
27260
+ renderedInspector = { signature, versionElement };
27261
+ };
26895
27262
  const render = (snapshot) => {
26896
27263
  const syncStatus = groupPreference.syncStatus();
26897
27264
  const groupDisabled = syncStatus === "loading" || syncStatus === "saving";
26898
27265
  syncMessage.hidden = syncStatus === "ready";
26899
27266
  syncMessage.textContent = syncStatus === "error" ? messages.connectionGroupSyncFailed : syncStatus === "saving" ? messages.connectionGroupSaving : messages.connectionGroupLoading;
26900
27267
  latestSnapshot = snapshot;
26901
- disposeHostScroller();
26902
- disposeHostScroller = () => void 0;
26903
27268
  if (!snapshot) {
26904
- const empty = document2.createElement("div");
26905
- empty.className = "settings-empty";
26906
- empty.textContent = messages.connectionNoRuntime;
26907
- content.replaceChildren(empty);
27269
+ renderedHostId = null;
27270
+ renderedInspector = null;
27271
+ reconcileElementChildren(content, [empty]);
26908
27272
  return;
26909
27273
  }
26910
27274
  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];
26911
27275
  if (!selectedHost) return;
26912
27276
  selectedHostId = selectedHost.hostId;
26913
- const layout = document2.createElement("div");
26914
- layout.className = "settings-connections-layout";
26915
- const list = document2.createElement("section");
26916
- list.className = "settings-connection-list";
26917
- const hostStrip = document2.createElement("div");
26918
- hostStrip.className = "settings-connection-host-strip";
26919
- const scrollLeft = createHostScrollButton(document2, "left", messages);
26920
- const tabs = document2.createElement("div");
26921
- tabs.className = "settings-connection-host-tabs";
26922
- tabs.setAttribute("role", "tablist");
26923
- tabs.setAttribute("aria-label", messages.connectionHosts);
26924
- const scrollRight = createHostScrollButton(document2, "right", messages);
26925
- const panelId = "codexhost-settings-connection-host-panel";
26926
- snapshot.hosts.forEach((host, index) => {
26927
- const tab = document2.createElement("button");
26928
- tab.type = "button";
26929
- tab.className = "settings-connection-host-tab";
26930
- tab.dataset.connectionHostTab = host.hostId;
26931
- tab.dataset.connectionHostActive = String(host.active);
26932
- tab.setAttribute("role", "tab");
26933
- tab.setAttribute("aria-controls", panelId);
26934
- tab.setAttribute("aria-selected", String(host.hostId === selectedHost.hostId));
26935
- tab.tabIndex = host.hostId === selectedHost.hostId ? 0 : -1;
27277
+ const layoutFirstMount = content.children[0] !== layout;
27278
+ reconcileElementChildren(content, [layout]);
27279
+ let tabsChanged = tabs.children.length !== snapshot.hosts.length;
27280
+ const nextTabs = snapshot.hosts.map((host) => {
27281
+ let tab = hostTabElements.get(host.hostId);
27282
+ if (!tab) {
27283
+ tab = document2.createElement("button");
27284
+ tab.type = "button";
27285
+ tab.className = "settings-connection-host-tab";
27286
+ tab.dataset.connectionHostTab = host.hostId;
27287
+ tab.setAttribute("role", "tab");
27288
+ tab.setAttribute("aria-controls", panelId);
27289
+ tab.addEventListener("click", () => {
27290
+ selectedHostId = host.hostId;
27291
+ render(latestSnapshot);
27292
+ });
27293
+ tab.addEventListener("keydown", (event) => {
27294
+ if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
27295
+ event.preventDefault();
27296
+ const hosts = latestSnapshot?.hosts ?? [];
27297
+ const index = hosts.findIndex((candidate) => candidate.hostId === host.hostId);
27298
+ if (index < 0) return;
27299
+ const direction = event.key === "ArrowRight" ? 1 : -1;
27300
+ const next = hosts[(index + direction + hosts.length) % hosts.length];
27301
+ if (!next) return;
27302
+ selectedHostId = next.hostId;
27303
+ render(latestSnapshot);
27304
+ hostTabElements.get(next.hostId)?.focus();
27305
+ });
27306
+ hostTabElements.set(host.hostId, tab);
27307
+ tabsChanged = true;
27308
+ }
27309
+ const isSelected = host.hostId === selectedHost.hostId;
27310
+ const activeValue = String(host.active);
27311
+ if (tab.dataset.connectionHostActive !== activeValue) {
27312
+ tab.dataset.connectionHostActive = activeValue;
27313
+ }
27314
+ const selectedValue = String(isSelected);
27315
+ if (tab.getAttribute("aria-selected") !== selectedValue) {
27316
+ tab.setAttribute("aria-selected", selectedValue);
27317
+ }
27318
+ const nextTabIndex = isSelected ? 0 : -1;
27319
+ if (tab.tabIndex !== nextTabIndex) {
27320
+ tab.tabIndex = nextTabIndex;
27321
+ }
26936
27322
  const hostName = hostNames.get(host.hostId) || connectionHostName(host.hostId, messages);
26937
- tab.textContent = hostName;
26938
- tab.title = host.active ? `${hostName} \xB7 ${messages.connectionActiveHost}` : hostName;
26939
- tab.addEventListener("click", () => {
26940
- selectedHostId = host.hostId;
26941
- render(latestSnapshot);
26942
- });
26943
- tab.addEventListener("keydown", (event) => {
26944
- if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
26945
- event.preventDefault();
26946
- const direction = event.key === "ArrowRight" ? 1 : -1;
26947
- const next = snapshot.hosts[(index + direction + snapshot.hosts.length) % snapshot.hosts.length];
26948
- if (!next) return;
26949
- selectedHostId = next.hostId;
26950
- render(latestSnapshot);
26951
- const nextTab = [
26952
- ...content.querySelectorAll("[data-connection-host-tab]")
26953
- ].find((candidate) => candidate.dataset.connectionHostTab === next.hostId);
26954
- nextTab?.focus();
26955
- });
26956
- tabs.append(tab);
26957
- });
26958
- hostStrip.append(scrollLeft, tabs, scrollRight);
26959
- const tableHeader = document2.createElement("div");
26960
- tableHeader.className = "settings-connection-table-header";
26961
- tableHeader.setAttribute("role", "row");
26962
- const componentHeading = document2.createElement("span");
26963
- componentHeading.textContent = messages.connectionComponent;
26964
- componentHeading.setAttribute("role", "columnheader");
26965
- const statusHeading = document2.createElement("span");
26966
- statusHeading.textContent = messages.connectionStatus;
26967
- statusHeading.setAttribute("role", "columnheader");
26968
- const actionHeading = document2.createElement("span");
26969
- actionHeading.setAttribute("aria-hidden", "true");
26970
- tableHeader.append(componentHeading, statusHeading, actionHeading);
26971
- const rows = document2.createElement("div");
26972
- rows.className = "settings-connection-rows";
26973
- rows.id = panelId;
26974
- rows.dataset.connectionHost = selectedHost.hostId;
26975
- rows.setAttribute("role", "rowgroup");
26976
- const inspector = document2.createElement("aside");
26977
- inspector.className = "settings-connection-inspector";
26978
- inspector.setAttribute("aria-live", "polite");
26979
- keepPageStillDuringTextSelection(inspector);
26980
- const items = connectionItems(snapshot, selectedHost, messages, diagnostics).filter((item) => item.key !== "renderer-adapter").map((item) => {
26981
- const agent = item.agentSnapshot?.agent;
26982
- if (!agent) return item;
26983
- const state = installs?.get(selectedHost.hostId, agent);
26984
- const availability = state?.status ?? item.availability;
26985
- const version2 = item.agentSnapshot?.availability !== "notInstalled" && availability !== "installing" && availability !== "checking" ? versions.get(selectedHost.hostId, agent) : void 0;
26986
- return {
26987
- ...item,
26988
- ...state ? { availability: state.status } : {},
26989
- ...version2 ? { version: version2 } : {},
26990
- ...version2?.updating ? { availability: "updating" } : {},
26991
- ...state?.error ? { installError: state.error } : {},
26992
- ...diagnostics?.installation && harnessHasInstallCommands(item.agentSnapshot?.plugin) ? {
26993
- install: () => {
26994
- void installs?.install(selectedHost.hostId, agent);
26995
- }
26996
- } : {}
26997
- };
27323
+ if (tab.textContent !== hostName) {
27324
+ tab.textContent = hostName;
27325
+ tabsChanged = true;
27326
+ }
27327
+ const tabTitle = host.active ? `${hostName} \xB7 ${messages.connectionActiveHost}` : hostName;
27328
+ if (tab.title !== tabTitle) {
27329
+ tab.title = tabTitle;
27330
+ }
27331
+ return tab;
26998
27332
  });
27333
+ reconcileElementChildren(tabs, nextTabs);
27334
+ if (rows.dataset.connectionHost !== selectedHost.hostId) {
27335
+ rows.dataset.connectionHost = selectedHost.hostId;
27336
+ }
27337
+ const items = connectionItems(snapshot, selectedHost, messages, diagnostics).map(
27338
+ (item) => {
27339
+ const agent = item.agentSnapshot?.agent;
27340
+ if (!agent) return item;
27341
+ const state = installs?.get(selectedHost.hostId, agent);
27342
+ const availability = state?.status ?? item.availability;
27343
+ const updating = versions.isUpdating(selectedHost.hostId, agent);
27344
+ const version2 = updating || item.agentSnapshot?.availability !== "notInstalled" && availability !== "installing" && availability !== "checking" ? versions.get(selectedHost.hostId, agent) : void 0;
27345
+ const accessory = longContextControlFor(selectedHost.hostId, item);
27346
+ return {
27347
+ ...item,
27348
+ ...state ? { availability: state.status } : {},
27349
+ ...version2 ? { version: version2 } : {},
27350
+ ...version2?.updating ? { availability: "updating" } : {},
27351
+ ...state?.error ? { installError: state.error } : {},
27352
+ ...accessory ? { accessory } : {},
27353
+ ...diagnostics?.installation && harnessHasInstallCommands(item.agentSnapshot?.plugin) ? {
27354
+ install: () => {
27355
+ void installs?.install(selectedHost.hostId, agent);
27356
+ }
27357
+ } : {}
27358
+ };
27359
+ }
27360
+ );
26999
27361
  if (!items.some((item) => item.key === selectedItemKey)) {
27000
27362
  const requestedFocus = pendingFocusAgent;
27001
27363
  pendingFocusAgent = null;
@@ -27003,248 +27365,200 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
27003
27365
  (item) => item.agentSnapshot?.availability === "notInstalled" || item.error !== null
27004
27366
  )?.key ?? items[0]?.key ?? null;
27005
27367
  }
27006
- const rowElements = /* @__PURE__ */ new Map();
27368
+ let hostRows = hostRowViews.get(selectedHost.hostId);
27369
+ if (!hostRows) {
27370
+ hostRows = /* @__PURE__ */ new Map();
27371
+ hostRowViews.set(selectedHost.hostId, hostRows);
27372
+ }
27373
+ currentHostRows = hostRows;
27007
27374
  const selectItem = (item) => {
27008
27375
  selectedItemKey = item.key;
27009
- for (const [key, row] of rowElements) {
27010
- const selected = key === item.key;
27011
- row.dataset.connectionSelected = String(selected);
27012
- row.tabIndex = selected ? 0 : -1;
27376
+ for (const [key, view] of currentHostRows) {
27377
+ view.setSelected(key === item.key);
27013
27378
  }
27014
- const existing = launchControls?.hostId === selectedHost.hostId && launchControls.itemKey === item.key ? launchControls.element : null;
27015
- const element = renderConnectionInspector(
27016
- document2,
27017
- inspector,
27018
- item,
27019
- selectedHost.hostId,
27020
- messages,
27021
- getDiagnostics(),
27022
- existing,
27023
- runRefresh,
27024
- openExternalUrl
27025
- );
27026
- launchControls = { hostId: selectedHost.hostId, itemKey: item.key, element };
27027
- if (item.version) inspector.append(item.version.element);
27379
+ syncSelectedInspector(selectedHost.hostId, item);
27028
27380
  };
27029
- for (const pinnedItem of items.filter((item) => !item.agentSnapshot)) {
27030
- const row = createConnectionRow(
27031
- document2,
27381
+ const ensureRowView = (key, groupable) => {
27382
+ let view = hostRows.get(key);
27383
+ if (!view) {
27384
+ view = createConnectionRowView(document2, messages, groupable);
27385
+ hostRows.set(key, view);
27386
+ }
27387
+ return view;
27388
+ };
27389
+ const activeKeys = /* @__PURE__ */ new Set();
27390
+ const nextRowChildren = [];
27391
+ const pinnedItems = items.filter((item) => item.agentSnapshot === void 0);
27392
+ for (const pinnedItem of pinnedItems) {
27393
+ activeKeys.add(pinnedItem.key);
27394
+ const view = ensureRowView(pinnedItem.key, false);
27395
+ view.update(
27032
27396
  pinnedItem,
27033
- messages,
27034
27397
  pinnedItem.key === selectedItemKey,
27035
- () => selectItem(pinnedItem)
27398
+ () => selectItem(pinnedItem),
27399
+ null
27036
27400
  );
27037
- rowElements.set(pinnedItem.key, row);
27038
- rows.append(row);
27401
+ nextRowChildren.push(view.element);
27039
27402
  }
27040
27403
  const groupableItems = items.filter(
27041
27404
  (item) => item.agentSnapshot !== void 0
27042
27405
  );
27043
27406
  const agentByKey = new Map(groupableItems.map((item) => [item.key, item]));
27044
- const catalog = groupableItems.map((item) => ({ id: item.key, name: item.name }));
27045
- const preferenceOrder = groupPreference.list(
27046
- new Set(
27047
- groupableItems.filter((item) => item.agentSnapshot.availability === "notInstalled").map((item) => item.agentSnapshot.agent)
27048
- ),
27049
- catalog
27050
- ).filter((entry) => agentByKey.has(entry.agent));
27051
- const isInstalledAgent = (agent) => agentByKey.get(agent)?.agentSnapshot.availability !== "notInstalled";
27052
- const mainEntries = partitionAgentsByInstallStatus(
27053
- preferenceOrder.filter((entry) => entry.section === "main"),
27054
- isInstalledAgent
27055
- );
27056
- const moreEntries = partitionAgentsByInstallStatus(
27057
- preferenceOrder.filter((entry) => entry.section === "more"),
27058
- isInstalledAgent
27407
+ currentCatalog = groupableItems.map((item) => ({ id: item.key, name: item.name }));
27408
+ const notInstalledAgents = /* @__PURE__ */ new Set();
27409
+ for (const item of groupableItems) {
27410
+ const agent = item.agentSnapshot.agent;
27411
+ const stateKey = `${selectedHost.hostId}:${agent}`;
27412
+ if (item.agentSnapshot.availability !== "checking") {
27413
+ knownNotInstalled.set(stateKey, item.agentSnapshot.availability === "notInstalled");
27414
+ }
27415
+ const isNotInstalled = item.agentSnapshot.availability === "checking" ? knownNotInstalled.get(stateKey) ?? false : item.agentSnapshot.availability === "notInstalled";
27416
+ if (isNotInstalled) notInstalledAgents.add(agent);
27417
+ }
27418
+ const preferenceOrder = partitionAgentsByInstallStatus(
27419
+ groupPreference.list(notInstalledAgents, currentCatalog).filter((entry) => agentByKey.has(entry.agent)),
27420
+ (agent) => !notInstalledAgents.has(agent)
27059
27421
  );
27060
- groupPreference.reconcileOrder([...mainEntries, ...moreEntries], catalog);
27422
+ groupPreference.reconcileOrder(preferenceOrder, currentCatalog);
27423
+ currentMainEntries = preferenceOrder.filter((entry) => entry.section === "main");
27424
+ currentMoreEntries = preferenceOrder.filter((entry) => entry.section === "more");
27061
27425
  const nextInSection = (section, agent) => {
27062
- const list2 = section === "main" ? mainEntries : moreEntries;
27063
- const index = list2.findIndex((entry) => entry.agent === agent);
27064
- return index >= 0 ? list2[index + 1]?.agent ?? null : null;
27065
- };
27066
- const beforeAgentForBucketAppend = (agent, targetSection) => {
27067
- const list2 = targetSection === "main" ? mainEntries : moreEntries;
27068
- const installed = isInstalledAgent(agent);
27069
- return list2.find(
27070
- (entry) => entry.agent !== agent && isInstalledAgent(entry.agent) !== installed
27071
- )?.agent ?? null;
27072
- };
27073
- let draggingAgent = null;
27074
- let moreZone = null;
27075
- const clearDropIndicators = () => {
27076
- for (const row of rowElements.values()) row.dataset.connectionDropIndicator = "";
27077
- if (moreZone) moreZone.dataset.connectionDragOver = "false";
27426
+ const sectionEntries = section === "main" ? currentMainEntries : currentMoreEntries;
27427
+ const index = sectionEntries.findIndex((entry) => entry.agent === agent);
27428
+ return index >= 0 ? sectionEntries[index + 1]?.agent ?? null : null;
27078
27429
  };
27079
- const sameInstallBucket = (left, right) => isInstalledAgent(left) === isInstalledAgent(right);
27080
27430
  const dropTargetSection = (agent, event) => {
27081
- const row = rowElements.get(agent);
27431
+ const row = currentHostRows.get(agent)?.element;
27082
27432
  const rect = row && typeof row.getBoundingClientRect === "function" ? row.getBoundingClientRect() : null;
27083
27433
  const before = rect ? event.clientY - rect.top < rect.height / 2 : true;
27084
27434
  const section = row?.dataset.connectionGroupSection ?? "main";
27085
27435
  return { before, beforeAgent: before ? agent : nextInSection(section, agent) };
27086
27436
  };
27087
- const createGroupController = (agent, section) => ({
27088
- disabled: groupDisabled,
27089
- section,
27090
- moveLabel: section === "main" ? messages.connectionGroupMoveToMore : messages.connectionGroupMoveToMain,
27091
- dragHandleTitle: messages.connectionGroupDragHandle,
27092
- toggleSection() {
27093
- groupPreference.moveAgent(agent, section === "main" ? "more" : "main", null, catalog);
27094
- },
27095
- onDragStart(event) {
27096
- if (groupDisabled) {
27097
- event.preventDefault();
27098
- return;
27099
- }
27100
- draggingAgent = agent;
27101
- event.dataTransfer?.setData("text/plain", agent);
27102
- if (event.dataTransfer) event.dataTransfer.effectAllowed = "move";
27103
- const row = rowElements.get(agent);
27104
- if (row) row.dataset.connectionDragging = "true";
27105
- },
27106
- onDragOver(event) {
27107
- if (!draggingAgent || draggingAgent === agent) return;
27108
- const crossSection = groupPreference.sectionOf(draggingAgent) !== section;
27109
- if (!crossSection && !sameInstallBucket(draggingAgent, agent)) return;
27110
- event.preventDefault();
27111
- const row = rowElements.get(agent);
27112
- if (!row) return;
27113
- clearDropIndicators();
27114
- if (crossSection && !sameInstallBucket(draggingAgent, agent)) {
27115
- row.dataset.connectionDropIndicator = "before";
27116
- return;
27117
- }
27118
- const { before } = dropTargetSection(agent, event);
27119
- row.dataset.connectionDropIndicator = before ? "before" : "after";
27120
- },
27121
- onDragLeave() {
27122
- const row = rowElements.get(agent);
27123
- if (row) row.dataset.connectionDropIndicator = "";
27124
- },
27125
- onDrop(event) {
27126
- event.preventDefault();
27127
- event.stopPropagation();
27128
- if (!draggingAgent) return;
27129
- const crossSection = groupPreference.sectionOf(draggingAgent) !== section;
27130
- if (!crossSection && !sameInstallBucket(draggingAgent, agent)) {
27131
- draggingAgent = null;
27132
- clearDropIndicators();
27133
- return;
27134
- }
27135
- if (crossSection && !sameInstallBucket(draggingAgent, agent)) {
27437
+ const createGroupController = (agent, section) => {
27438
+ const disabled = groupDisabled;
27439
+ return {
27440
+ disabled,
27441
+ section,
27442
+ moveLabel: section === "main" ? messages.connectionGroupMoveToMore : messages.connectionGroupMoveToMain,
27443
+ dragHandleTitle: messages.connectionGroupDragHandle,
27444
+ toggleSection() {
27136
27445
  groupPreference.moveAgent(
27137
- draggingAgent,
27138
- section,
27139
- beforeAgentForBucketAppend(draggingAgent, section),
27140
- catalog
27446
+ agent,
27447
+ section === "main" ? "more" : "main",
27448
+ null,
27449
+ currentCatalog
27141
27450
  );
27142
- } else {
27451
+ },
27452
+ onDragStart(event) {
27453
+ if (disabled) {
27454
+ event.preventDefault();
27455
+ return;
27456
+ }
27457
+ draggingAgent = agent;
27458
+ event.dataTransfer?.setData("text/plain", agent);
27459
+ if (event.dataTransfer) event.dataTransfer.effectAllowed = "move";
27460
+ const row = currentHostRows.get(agent)?.element;
27461
+ if (row) row.dataset.connectionDragging = "true";
27462
+ },
27463
+ onDragOver(event) {
27464
+ if (!draggingAgent || draggingAgent === agent) return;
27465
+ event.preventDefault();
27466
+ const row = currentHostRows.get(agent)?.element;
27467
+ if (!row) return;
27468
+ const { before } = dropTargetSection(agent, event);
27469
+ clearDropIndicators();
27470
+ row.dataset.connectionDropIndicator = before ? "before" : "after";
27471
+ },
27472
+ onDragLeave() {
27473
+ const row = currentHostRows.get(agent)?.element;
27474
+ if (row) row.dataset.connectionDropIndicator = "";
27475
+ },
27476
+ onDrop(event) {
27477
+ event.preventDefault();
27478
+ if (!draggingAgent) return;
27143
27479
  const { beforeAgent } = dropTargetSection(agent, event);
27144
- groupPreference.moveAgent(draggingAgent, section, beforeAgent, catalog);
27480
+ groupPreference.moveAgent(draggingAgent, section, beforeAgent, currentCatalog);
27481
+ draggingAgent = null;
27482
+ clearDropIndicators();
27483
+ },
27484
+ onDragEnd() {
27485
+ draggingAgent = null;
27486
+ const row = currentHostRows.get(agent)?.element;
27487
+ if (row) row.dataset.connectionDragging = "false";
27488
+ clearDropIndicators();
27489
+ scheduleRender();
27145
27490
  }
27146
- draggingAgent = null;
27147
- clearDropIndicators();
27148
- },
27149
- onDragEnd() {
27150
- draggingAgent = null;
27151
- const row = rowElements.get(agent);
27152
- if (row) row.dataset.connectionDragging = "false";
27153
- clearDropIndicators();
27154
- }
27155
- });
27156
- const appendGroupRow = (agent, section) => {
27157
- const item = agentByKey.get(agent);
27158
- if (!item) return;
27159
- const row = createConnectionRow(
27160
- document2,
27491
+ };
27492
+ };
27493
+ for (const entry of currentMainEntries) {
27494
+ const item = agentByKey.get(entry.agent);
27495
+ if (!item) continue;
27496
+ activeKeys.add(item.key);
27497
+ const view = ensureRowView(item.key, true);
27498
+ view.update(
27161
27499
  item,
27162
- messages,
27163
27500
  item.key === selectedItemKey,
27164
27501
  () => selectItem(item),
27165
- createGroupController(agent, section),
27166
- longContextControlFor(selectedHost.hostId, item)
27502
+ createGroupController(entry.agent, "main")
27167
27503
  );
27168
- rowElements.set(item.key, row);
27169
- rows.append(row);
27170
- };
27171
- for (const entry of mainEntries) appendGroupRow(entry.agent, "main");
27504
+ nextRowChildren.push(view.element);
27505
+ }
27172
27506
  if (groupableItems.length > 0) {
27173
- rows.append(createGroupDivider(document2, messages, moreEntries.length));
27174
- const zone = document2.createElement("div");
27175
- moreZone = zone;
27176
- zone.className = "settings-connection-group-more";
27177
- zone.setAttribute("role", "presentation");
27178
- zone.addEventListener("dragover", (event) => {
27179
- if (!draggingAgent) return;
27180
- event.preventDefault();
27181
- zone.dataset.connectionDragOver = "true";
27182
- });
27183
- zone.addEventListener("dragleave", () => {
27184
- zone.dataset.connectionDragOver = "false";
27185
- });
27186
- zone.addEventListener("drop", (event) => {
27187
- event.preventDefault();
27188
- zone.dataset.connectionDragOver = "false";
27189
- if (!draggingAgent) return;
27190
- groupPreference.moveAgent(draggingAgent, "more", null, catalog);
27191
- draggingAgent = null;
27192
- clearDropIndicators();
27193
- });
27194
- if (moreEntries.length === 0) {
27195
- zone.append(createGroupMoreHint(document2, messages));
27507
+ const dividerText = `${messages.connectionGroupMoreLabel} (${currentMoreEntries.length})`;
27508
+ if (groupDivider.textContent !== dividerText) {
27509
+ groupDivider.textContent = dividerText;
27510
+ }
27511
+ nextRowChildren.push(groupDivider);
27512
+ const nextMoreChildren = [];
27513
+ if (currentMoreEntries.length === 0) {
27514
+ nextMoreChildren.push(moreHint);
27196
27515
  } else {
27197
- for (const entry of moreEntries) {
27516
+ for (const entry of currentMoreEntries) {
27198
27517
  const item = agentByKey.get(entry.agent);
27199
27518
  if (!item) continue;
27200
- const row = createConnectionRow(
27201
- document2,
27519
+ activeKeys.add(item.key);
27520
+ const view = ensureRowView(item.key, true);
27521
+ view.update(
27202
27522
  item,
27203
- messages,
27204
27523
  item.key === selectedItemKey,
27205
27524
  () => selectItem(item),
27206
- createGroupController(entry.agent, "more"),
27207
- longContextControlFor(selectedHost.hostId, item)
27525
+ createGroupController(entry.agent, "more")
27208
27526
  );
27209
- rowElements.set(item.key, row);
27210
- zone.append(row);
27527
+ nextMoreChildren.push(view.element);
27211
27528
  }
27212
27529
  }
27213
- rows.append(zone);
27214
- const reset = createGroupResetButton(document2, messages, () => {
27215
- groupPreference.resetToDefault();
27216
- });
27217
- reset.disabled = groupDisabled;
27218
- rows.append(reset);
27530
+ if (!draggingAgent || renderedHostId !== selectedHost.hostId) {
27531
+ reconcileElementChildren(moreZone, nextMoreChildren);
27532
+ }
27533
+ nextRowChildren.push(moreZone);
27534
+ resetButton.disabled = groupDisabled;
27535
+ nextRowChildren.push(resetButton);
27536
+ }
27537
+ for (const key of hostRows.keys()) {
27538
+ if (!activeKeys.has(key)) hostRows.delete(key);
27539
+ }
27540
+ if (!draggingAgent || renderedHostId !== selectedHost.hostId) {
27541
+ reconcileElementChildren(rows, nextRowChildren);
27219
27542
  }
27220
27543
  const selectedItem = items.find((item) => item.key === selectedItemKey) ?? items[0];
27221
27544
  if (selectedItem) selectItem(selectedItem);
27222
- const updateControls = updates.createControls(
27545
+ updateControls.update(
27223
27546
  selectedHost.hostId,
27224
27547
  items.flatMap((item) => item.version ? [item.version] : [])
27225
27548
  );
27226
- const hostHeader = document2.createElement("div");
27227
- hostHeader.className = "settings-connection-host-header";
27228
- hostHeader.append(hostStrip, updateControls.button);
27229
- list.append(hostHeader, updateControls.result, tableHeader, rows);
27230
- layout.append(list, inspector);
27231
- content.replaceChildren(layout);
27232
- disposeHostScroller = configureHostScroller(
27233
- document2,
27234
- hostStrip,
27235
- tabs,
27236
- scrollLeft,
27237
- scrollRight
27238
- );
27239
- const selectedTab = [...tabs.children].find(
27240
- (child) => child.getAttribute("aria-selected") === "true"
27241
- );
27242
- if (selectedTab) {
27243
- const left = selectedTab.offsetLeft;
27244
- const right = left + selectedTab.offsetWidth;
27245
- if (left < tabs.scrollLeft) tabs.scrollLeft = left;
27246
- else if (right > tabs.scrollLeft + tabs.clientWidth) {
27247
- tabs.scrollLeft = right - tabs.clientWidth;
27549
+ if (layoutFirstMount || tabsChanged) {
27550
+ hostScroller.update();
27551
+ }
27552
+ if (renderedHostId !== selectedHost.hostId) {
27553
+ renderedHostId = selectedHost.hostId;
27554
+ const selectedTab = hostTabElements.get(selectedHost.hostId);
27555
+ if (selectedTab) {
27556
+ const left = selectedTab.offsetLeft;
27557
+ const right = left + selectedTab.offsetWidth;
27558
+ if (left < tabs.scrollLeft) tabs.scrollLeft = left;
27559
+ else if (right > tabs.scrollLeft + tabs.clientWidth) {
27560
+ tabs.scrollLeft = right - tabs.clientWidth;
27561
+ }
27248
27562
  }
27249
27563
  }
27250
27564
  };
@@ -27265,7 +27579,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
27265
27579
  refresh.disabled = true;
27266
27580
  return () => {
27267
27581
  cancelRender();
27268
- disposeHostScroller();
27582
+ hostScroller.dispose();
27269
27583
  unsubscribeGroup();
27270
27584
  };
27271
27585
  }
@@ -27274,7 +27588,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
27274
27588
  const unsubscribeInstalls = installs?.subscribe(scheduleRender);
27275
27589
  return () => {
27276
27590
  cancelRender();
27277
- disposeHostScroller();
27591
+ hostScroller.dispose();
27278
27592
  unsubscribeInstalls?.();
27279
27593
  unsubscribe();
27280
27594
  unsubscribeGroup();
@@ -28997,9 +29311,13 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28997
29311
  resets: "Resets",
28998
29312
  details: "Account limit details",
28999
29313
  weekly: "Weekly limit",
29314
+ weeklyShort: "Weekly",
29000
29315
  monthly: "Monthly limit",
29316
+ monthlyShort: "Monthly",
29001
29317
  fiveHour: "5-hour limit",
29318
+ fiveHourShort: "5-hour",
29002
29319
  sevenDay: "7-day limit",
29320
+ sevenDayShort: "7-day",
29003
29321
  account: "Account limit"
29004
29322
  });
29005
29323
  var CHINESE_CREDITS_MESSAGES = Object.freeze({
@@ -29007,9 +29325,13 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
29007
29325
  resets: "\u91CD\u7F6E",
29008
29326
  details: "\u8D26\u53F7\u989D\u5EA6\u8BE6\u60C5",
29009
29327
  weekly: "\u5468\u989D\u5EA6",
29328
+ weeklyShort: "\u5468\u989D\u5EA6",
29010
29329
  monthly: "\u6708\u989D\u5EA6",
29330
+ monthlyShort: "\u6708\u989D\u5EA6",
29011
29331
  fiveHour: "5 \u5C0F\u65F6\u989D\u5EA6",
29332
+ fiveHourShort: "5 \u5C0F\u65F6",
29012
29333
  sevenDay: "7 \u5929\u989D\u5EA6",
29334
+ sevenDayShort: "7 \u5929",
29013
29335
  account: "\u8D26\u53F7\u989D\u5EA6"
29014
29336
  });
29015
29337
  function formatRendererCreditsReset(value, now = /* @__PURE__ */ new Date(), locale = "en") {
@@ -32440,6 +32762,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
32440
32762
  background: var(--settings-surface);
32441
32763
  border: 1px solid var(--settings-border);
32442
32764
  border-radius: 10px;
32765
+ overflow-anchor: none;
32443
32766
  }
32444
32767
 
32445
32768
  .settings-connection-inspector__header {
@@ -34038,6 +34361,11 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
34038
34361
  // src/web-settings-entry.ts
34039
34362
  var WEB_LAYOUT_CSS = `.settings-page { background: transparent; overflow: visible; container: codexhost-settings-page / inline-size; }
34040
34363
  .settings-page__content { width: 100%; padding: 0; }`;
34364
+ var sharedConnectionDiagnostics = null;
34365
+ function getWebConnectionDiagnostics(client) {
34366
+ sharedConnectionDiagnostics ??= createConsoleConnectionDiagnostics(client);
34367
+ return sharedConnectionDiagnostics;
34368
+ }
34041
34369
  function resourcesPage(messages, client) {
34042
34370
  return {
34043
34371
  id: "resources",
@@ -34067,7 +34395,6 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
34067
34395
  () => modelClient,
34068
34396
  { migrateLegacy: false }
34069
34397
  );
34070
- const diagnostics = createConsoleConnectionDiagnostics(modelClient);
34071
34398
  const updateClient = {
34072
34399
  checkUpdate: () => modelClient.checkUpdate(),
34073
34400
  startUpdate: () => modelClient.startUpdate(),
@@ -34077,7 +34404,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
34077
34404
  ...createDefaultRendererSettingsPages(
34078
34405
  messages,
34079
34406
  () => updateClient,
34080
- () => diagnostics,
34407
+ () => getWebConnectionDiagnostics(modelClient),
34081
34408
  () => modelClient,
34082
34409
  () => null,
34083
34410
  null,