@codexhost/cli-darwin-x64 0.18.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +83 -5
  4. package/app/console-web.js +1172 -687
  5. package/app/desktop-controller.mjs +314 -15
  6. package/app/host-runtime.mjs +13158 -2853
  7. package/app/plugins/antigravity/plugin.mjs +8861 -3944
  8. package/app/plugins/claude-code/plugin.mjs +164 -14
  9. package/app/plugins/codebuddy/plugin.mjs +193 -25
  10. package/app/plugins/codex-usage/plugin.mjs +85 -5
  11. package/app/plugins/copilot/plugin.mjs +85 -5
  12. package/app/plugins/cursor-cli/plugin.mjs +160 -15
  13. package/app/plugins/deepseek-harness/manifest.json +2 -2
  14. package/app/plugins/deepseek-harness/plugin.mjs +112 -10
  15. package/app/plugins/devin/plugin.mjs +84 -5
  16. package/app/plugins/grok/plugin.mjs +418 -272
  17. package/app/plugins/hermes/plugin.mjs +163 -17
  18. package/app/plugins/kimi-code/plugin.mjs +85 -5
  19. package/app/plugins/kiro-cli/plugin.mjs +313 -21
  20. package/app/plugins/omp/plugin.mjs +1018 -819
  21. package/app/plugins/opencode/plugin.mjs +85 -5
  22. package/app/plugins/pi/plugin.mjs +828 -663
  23. package/app/plugins/qoder/plugin.mjs +109 -10
  24. package/app/plugins/qoder-cn/plugin.mjs +109 -10
  25. package/app/plugins/qwen-code/plugin.mjs +194 -97
  26. package/app/plugins/workbuddy/plugin.mjs +197 -28
  27. package/app/plugins/zcode/plugin.mjs +158 -8
  28. package/app/renderer-extension.js +2065 -1004
  29. package/app/web/assets/index-D6-hvggd.css +1 -0
  30. package/app/web/assets/index-D85gPBbQ.js +201 -0
  31. package/app/web/assets/langs/{graphql-B8vkg11W.js → graphql-ChAeyPkT.js} +1 -1
  32. package/app/web/assets/langs/{http-DmoDEjMt.js → http-BvreBIbD.js} +1 -1
  33. package/app/web/assets/langs/{php-DJ5ovfAM.js → php-D8omCIuJ.js} +1 -1
  34. package/app/web/assets/langs/{rst-U5-R5x3p.js → rst-Do7RLLCS.js} +1 -1
  35. package/app/web/assets/langs/{ruby-VKVsnS0H.js → ruby-rH_O_vse.js} +1 -1
  36. package/app/web/assets/langs/{svelte-C20lOv9V.js → svelte-xZy73wAj.js} +1 -1
  37. package/app/web/assets/langs/{vue-z6Y-lzP-.js → vue-C4DW8agZ.js} +1 -1
  38. package/app/web/assets/{vendor-dSL872WO.js → vendor-C9g2bw8s.js} +3 -3
  39. package/app/web/codexhost-settings.js +1178 -689
  40. package/app/web/index.html +4 -3
  41. package/app/web/plugins/deepseek-ai__dsh-api-gateway/client.js +2 -2
  42. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
  43. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +8 -8
  44. package/app/web/plugins/deepseek-ai__dsh-client-connection/client.js +1 -1
  45. package/app/web/plugins/deepseek-ai__dsh-client-file-upload/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 +134 -8
  49. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +65 -63
  50. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +95 -93
  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-documentpreview/client.excel.js +1 -1
  57. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-files/client.js +1 -1
  58. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
  59. package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +1 -1
  60. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +11 -11
  61. package/app/web-modules/server.mjs +2468 -1575
  62. package/bin/codexhost +0 -0
  63. package/libexec/codexhost-shim +0 -0
  64. package/libexec/codexhost-updater +0 -0
  65. package/package.json +1 -1
  66. package/app/web/assets/index-C0aXz2jD.js +0 -199
  67. package/app/web/assets/index-C3lniEH1.css +0 -1
@@ -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.literal(3).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)]).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
+ // Unversioned 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 === 3)).optional(),
14698
+ // Retain independent TTFT facts when dropping incompatible speed measurements.
14699
+ outputTokensPerSecond: usageMeasurementSchema.refine((value) => value.version === 3).optional().catch(void 0),
14688
14700
  timeToFirstOutputMs: usageMeasurementSchema.extend({ value: nonNegativeSafeIntegerSchema }).optional()
14689
14701
  }).strict();
14690
14702
  var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text) => text.length <= maximum));
@@ -14704,6 +14716,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14704
14716
  cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
14705
14717
  outputTokens: nonNegativeSafeIntegerSchema.optional(),
14706
14718
  outputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
14719
+ sessionOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
14707
14720
  apiOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
14708
14721
  reasoningOutputTokens: nonNegativeSafeIntegerSchema.optional(),
14709
14722
  totalTokens: nonNegativeSafeIntegerSchema.optional(),
@@ -15116,11 +15129,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15116
15129
  delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
15117
15130
  }).strict();
15118
15131
 
15132
+ // ../shared-contracts/dist/thread-archive-confirm.js
15133
+ var threadArchiveConfirmParamsSchema = external_exports.object({ threadId: hostThreadIdSchema }).strict();
15134
+ var threadArchiveConfirmResultSchema = external_exports.object({ confirmed: external_exports.boolean() }).strict();
15135
+
15119
15136
  // ../shared-contracts/dist/client-channel.js
15120
15137
  var CLIENT_CHANNEL_VERSION = 1;
15121
15138
  var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
15122
15139
  var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
15123
15140
  var clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict();
15141
+ var clientThreadTreeReadParamsSchema = external_exports.object({}).strict();
15142
+ var clientThreadTreeSchema = external_exports.object({
15143
+ parents: external_exports.record(external_exports.string().min(1), external_exports.string().min(1))
15144
+ }).strict();
15124
15145
  var clientProjectlessWorkspaceSchema = external_exports.object({
15125
15146
  prompt: external_exports.string().max(16384).optional()
15126
15147
  }).strict();
@@ -15137,6 +15158,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15137
15158
  sequence: external_exports.number().int().nonnegative()
15138
15159
  });
15139
15160
  var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
15161
+ external_exports.object({
15162
+ type: external_exports.literal("skills-changed"),
15163
+ cursor: clientChannelCursorSchema,
15164
+ cwd: external_exports.string().optional()
15165
+ }),
15140
15166
  external_exports.object({ type: external_exports.literal("display-settings-changed"), cursor: clientChannelCursorSchema }),
15141
15167
  external_exports.object({
15142
15168
  type: external_exports.literal("preferences-changed"),
@@ -15246,7 +15272,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15246
15272
  /** Current interruptible Host Turn, including command Turns omitted from client history. */
15247
15273
  activeTurnId: external_exports.string().min(1).nullable().optional(),
15248
15274
  /** Most recent explicit command in this Host process; not native conversation history. */
15249
- command: external_exports.object({ name: external_exports.string().min(1), turn: clientTurnSchema }).optional(),
15275
+ command: external_exports.object({
15276
+ name: external_exports.string().min(1),
15277
+ turn: clientTurnSchema,
15278
+ /** First ordinary Turn started after this command; its retained result is not a new event. */
15279
+ subsequentTurnId: external_exports.string().min(1).optional()
15280
+ }).optional(),
15250
15281
  thread: external_exports.object({
15251
15282
  id: external_exports.string().min(1),
15252
15283
  cwd: external_exports.string(),
@@ -15334,6 +15365,30 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15334
15365
  external_exports.object({ ok: external_exports.literal(false), error: external_exports.object({ code: voiceErrorCodeSchema }).strict() }).strict()
15335
15366
  ]);
15336
15367
 
15368
+ // ../shared-contracts/dist/skills.js
15369
+ var SKILLS_LIST_METHOD = "codexhost/skills/list";
15370
+ var SKILLS_CHANGED_METHOD = "codexhost/skills/changed";
15371
+ var skillsListParamsSchema = external_exports.object({
15372
+ threadId: hostThreadIdSchema.optional(),
15373
+ cwd: external_exports.string().min(1).optional()
15374
+ }).strict().refine((params) => !(params.threadId && params.cwd), {
15375
+ message: "Specify threadId or cwd, not both"
15376
+ });
15377
+ var librarySkillSchema = external_exports.object({
15378
+ name: external_exports.string().min(1).regex(/^[^\s[\]]+$/u),
15379
+ description: external_exports.string().optional(),
15380
+ path: external_exports.string().min(1),
15381
+ scope: external_exports.enum(["project", "global"]),
15382
+ source: external_exports.string().min(1)
15383
+ }).strict();
15384
+ var skillsListResultSchema = external_exports.object({
15385
+ revision: external_exports.number().int().nonnegative(),
15386
+ complete: external_exports.boolean(),
15387
+ skills: external_exports.array(librarySkillSchema),
15388
+ warnings: external_exports.array(external_exports.string()).optional()
15389
+ }).strict();
15390
+ var skillsChangedParamsSchema = external_exports.object({ cwd: external_exports.string().min(1).optional() }).strict();
15391
+
15337
15392
  // ../shared-contracts/dist/web-access-tokens.js
15338
15393
  var webNetworkAccessUrlSchema = external_exports.object({
15339
15394
  /**
@@ -15432,7 +15487,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15432
15487
  quotaUntil: external_exports.string().optional()
15433
15488
  }).strict().optional()
15434
15489
  }).strict();
15435
- var webLocalAccessRequiredDetailsSchema = external_exports.object({ url: external_exports.string() }).strict();
15436
15490
 
15437
15491
  // ../shared-contracts/dist/delegation-read.js
15438
15492
  var REMOTE_THREAD_REPLY_MAX_BYTES = 16 * 1024 * 1024;
@@ -15440,8 +15494,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15440
15494
  var delegationReadParamsSchema = external_exports.strictObject({
15441
15495
  threadId: external_exports.string().min(1).max(1024),
15442
15496
  view: external_exports.enum(["result", "messages"]),
15443
- cursor: external_exports.string().min(1).max(8192).optional(),
15444
- limit: external_exports.number().int().min(1).max(100).optional()
15497
+ from: external_exports.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional(),
15498
+ to: external_exports.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional()
15445
15499
  });
15446
15500
 
15447
15501
  // ../shared-contracts/dist/credential-imports.js
@@ -16441,6 +16495,17 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16441
16495
  status: updateStatusSchema.nullable()
16442
16496
  });
16443
16497
 
16498
+ // ../shared-contracts/dist/thread-watch-notice.js
16499
+ var THREAD_WATCH_NOTICE_OUTCOMES = [
16500
+ "completed",
16501
+ "failed",
16502
+ "interrupted",
16503
+ "timedOut",
16504
+ "unreadable",
16505
+ "notFound"
16506
+ ];
16507
+ var ENTRY_PATTERN = new RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)\): ` + `(${THREAD_WATCH_NOTICE_OUTCOMES.join("|")})(?:. (.+))?$`, "u");
16508
+
16444
16509
  // ../shared-contracts/dist/remote-runtime.js
16445
16510
  var RUNTIME_STATUS_METHOD = "codexhost/runtime/status";
16446
16511
  var REMOTE_UPDATE_METHOD = "codexhost/remote/update";
@@ -16491,6 +16556,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16491
16556
  archived: external_exports.boolean()
16492
16557
  }),
16493
16558
  external_exports.strictObject({ kind: external_exports.literal("read"), ...thread }),
16559
+ external_exports.strictObject({
16560
+ kind: external_exports.literal("configure"),
16561
+ ...thread,
16562
+ epoch: identity,
16563
+ modelId: identity.optional(),
16564
+ thinkingOptionId: identity.optional(),
16565
+ permissionModeId: identity.optional()
16566
+ }).refine((value) => [value.modelId, value.thinkingOptionId, value.permissionModeId].filter((v) => v !== void 0).length === 1, "Select exactly one remote setting"),
16494
16567
  external_exports.strictObject({
16495
16568
  kind: external_exports.literal("prompt"),
16496
16569
  ...thread,
@@ -16563,6 +16636,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16563
16636
  external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
16564
16637
  ]);
16565
16638
 
16639
+ // ../shared-contracts/dist/thread-title.js
16640
+ var threadTitleInputSchema = external_exports.strictObject({
16641
+ prompt: external_exports.string().trim().min(1).max(2e3),
16642
+ cwd: external_exports.string().max(4096).nullable()
16643
+ });
16644
+ var threadTitleResultSchema = external_exports.string().trim().min(1).max(60).nullable();
16645
+
16566
16646
  // ../shared-contracts/dist/web-ui-extensions.js
16567
16647
  var webUiExtensionIdSchema = external_exports.string().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u);
16568
16648
  var localizedTextSchema2 = external_exports.union([
@@ -16637,7 +16717,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16637
16717
  await Promise.all(
16638
16718
  plugins.map(async ({ id }) => {
16639
16719
  try {
16640
- const inspection = await client.inspectHarness({ harnessId: id, refresh });
16720
+ const inspection = await client.inspectHarness({
16721
+ harnessId: id,
16722
+ refresh,
16723
+ purpose: "availability"
16724
+ });
16641
16725
  availability.set(id, inspection.status);
16642
16726
  webUi.set(id, inspection.status === "ready" && inspection.webUi?.open === true);
16643
16727
  const error51 = inspection.status === "ready" ? null : inspection.error;
@@ -18724,6 +18808,19 @@ th[aria-sort] .console-usage-sort__mark {
18724
18808
  return externalThreadForkResultSchema.parse(result);
18725
18809
  },
18726
18810
  inspectHarness,
18811
+ async listSkills(params) {
18812
+ return skillsListResultSchema.parse(
18813
+ await manager.sendRequest(SKILLS_LIST_METHOD, skillsListParamsSchema.parse(params))
18814
+ );
18815
+ },
18816
+ subscribeSkillsChanged(listener) {
18817
+ return notificationTarget(source)?.addNotificationCallback?.(SKILLS_CHANGED_METHOD, (value) => {
18818
+ if (!isRecord2(value) || value.method !== SKILLS_CHANGED_METHOD) return;
18819
+ const parsed = skillsChangedParamsSchema.safeParse(value.params);
18820
+ if (parsed.success) listener(parsed.data);
18821
+ }) ?? (() => {
18822
+ });
18823
+ },
18727
18824
  async listHarnessPlugins() {
18728
18825
  return harnessPluginListResultSchema.parse(
18729
18826
  await manager.sendRequest(HARNESS_PLUGIN_LIST_METHOD, {})
@@ -20820,7 +20917,7 @@ th[aria-sort] .console-usage-sort__mark {
20820
20917
  launchPathSaveError: "Could not save. Enter an existing absolute installation folder on this Host and check configuration permissions.",
20821
20918
  connectionOfficialWebsite: "Visit official website",
20822
20919
  connectionOpenHarnessWeb: "Open DeepSeek Harness Web",
20823
- connectionDeepSeekTestedVersions: "Supported DSH versions: 0.1.7-rc.1, 0.1.7-rc.2, 0.2.0-rc.1, 0.2.0-rc.2, 0.2.1-rc.1, 0.2.1-rc.2, 0.2.1-rc.3, 0.2.1-rc.4, 0.2.1-rc.5 and 0.2.2-rc.1. Versions newer than 0.2.2-rc.1 can be tried, but compatibility may be limited; versions older than 0.1.7-rc.1 must be upgraded first.",
20920
+ connectionDeepSeekTestedVersions: "Supported DSH versions: 0.1.7-rc.1, 0.1.7-rc.2, 0.2.0-rc.1, 0.2.0-rc.2, 0.2.1-rc.1, 0.2.1-rc.2, 0.2.1-rc.3, 0.2.1-rc.4, 0.2.1-rc.5, 0.2.2-rc.1 and 0.2.2-rc.2. Versions newer than 0.2.2-rc.2 can be tried, but compatibility may be limited; versions older than 0.1.7-rc.1 must be upgraded first.",
20824
20921
  connectionInstall: "Install",
20825
20922
  connectionInstallDescription: "This Harness was not detected.",
20826
20923
  connectionInstallRunning: "Installing on the selected Host. You can leave this page; login or setup may still be required afterward.",
@@ -21102,7 +21199,7 @@ th[aria-sort] .console-usage-sort__mark {
21102
21199
  launchPathSaveError: "\u4FDD\u5B58\u5931\u8D25\u3002\u8BF7\u586B\u5199\u6B64 Host \u4E0A\u5B9E\u9645\u5B58\u5728\u7684\u5B89\u88C5\u76EE\u5F55\u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u5E76\u786E\u8BA4\u914D\u7F6E\u76EE\u5F55\u53EF\u5199\u3002",
21103
21200
  connectionOfficialWebsite: "\u8BBF\u95EE\u5B98\u7F51",
21104
21201
  connectionOpenHarnessWeb: "\u6253\u5F00 DeepSeek Harness Web",
21105
- connectionDeepSeekTestedVersions: "\u652F\u6301 DSH \u7248\u672C\uFF1A0.1.7-rc.1\u30010.1.7-rc.2\u30010.2.0-rc.1\u30010.2.0-rc.2\u30010.2.1-rc.1\u30010.2.1-rc.2\u30010.2.1-rc.3\u30010.2.1-rc.4\u30010.2.1-rc.5 \u548C 0.2.2-rc.1\u3002\u9AD8\u4E8E 0.2.2-rc.1 \u7684\u7248\u672C\u53EF\u4EE5\u5C1D\u8BD5\u8FDE\u63A5\uFF0C\u4F46\u9002\u914D\u5EA6\u53EF\u80FD\u6709\u9650\uFF1B\u4F4E\u4E8E 0.1.7-rc.1 \u7684\u7248\u672C\u9700\u8981\u5148\u5347\u7EA7\u3002",
21202
+ connectionDeepSeekTestedVersions: "\u652F\u6301 DSH \u7248\u672C\uFF1A0.1.7-rc.1\u30010.1.7-rc.2\u30010.2.0-rc.1\u30010.2.0-rc.2\u30010.2.1-rc.1\u30010.2.1-rc.2\u30010.2.1-rc.3\u30010.2.1-rc.4\u30010.2.1-rc.5\u30010.2.2-rc.1 \u548C 0.2.2-rc.2\u3002\u9AD8\u4E8E 0.2.2-rc.2 \u7684\u7248\u672C\u53EF\u4EE5\u5C1D\u8BD5\u8FDE\u63A5\uFF0C\u4F46\u9002\u914D\u5EA6\u53EF\u80FD\u6709\u9650\uFF1B\u4F4E\u4E8E 0.1.7-rc.1 \u7684\u7248\u672C\u9700\u8981\u5148\u5347\u7EA7\u3002",
21106
21203
  connectionInstall: "\u5B89\u88C5",
21107
21204
  connectionInstallDescription: "\u5C1A\u672A\u68C0\u6D4B\u5230\u8BE5 Harness\u3002",
21108
21205
  connectionInstallRunning: "\u6B63\u5728\u6240\u9009 Host \u4E0A\u5B89\u88C5\uFF0C\u79BB\u5F00\u9875\u9762\u4E0D\u4F1A\u4E2D\u65AD\u3002\u5B89\u88C5\u540E\u53EF\u80FD\u4ECD\u9700\u767B\u5F55\u6216\u914D\u7F6E\u3002",
@@ -21300,6 +21397,7 @@ th[aria-sort] .console-usage-sort__mark {
21300
21397
  latestCacheHit: "Latest cache hit (CH)",
21301
21398
  sessionCacheHit: "Average cache hit",
21302
21399
  outputSpeed: "Output speed (TPS)",
21400
+ averageOutputSpeed: "Average output speed (TPS)",
21303
21401
  apiOutputSpeed: "API average speed",
21304
21402
  apiOutputSpeedDescription: "Output tokens / native API time, including first-token wait; not generation TPS.",
21305
21403
  timeToFirstOutput: "Time to first token (TTFT)",
@@ -21325,6 +21423,7 @@ th[aria-sort] .console-usage-sort__mark {
21325
21423
  latestCacheHit: "\u6700\u8FD1\u7F13\u5B58\u547D\u4E2D\uFF08CH\uFF09",
21326
21424
  sessionCacheHit: "\u5E73\u5747\u7F13\u5B58\u547D\u4E2D",
21327
21425
  outputSpeed: "\u8F93\u51FA\u901F\u5EA6\uFF08TPS\uFF09",
21426
+ averageOutputSpeed: "\u5E73\u5747\u8F93\u51FA\u901F\u5EA6\uFF08TPS\uFF09",
21328
21427
  apiOutputSpeed: "API \u5E73\u5747\u901F\u5EA6",
21329
21428
  apiOutputSpeedDescription: "\u8F93\u51FA Token \xF7 \u539F\u751F API \u8017\u65F6\uFF0C\u542B\u9996\u5B57\u7B49\u5F85\uFF1B\u4E0D\u662F\u751F\u6210 TPS\u3002",
21330
21429
  timeToFirstOutput: "\u9996 token\uFF08TTFT\uFF09",
@@ -25341,242 +25440,474 @@ ${detail}` : ""}`
25341
25440
  return fallback;
25342
25441
  }
25343
25442
 
25344
- // src/settings/harness-launch-controls.ts
25345
- function createHarnessLaunchControls(document2, messages, agent, settings) {
25346
- const section = document2.createElement("section");
25347
- section.className = "settings-harness-launch";
25348
- section.dataset.harnessLaunch = agent;
25349
- const label = document2.createElement("label");
25350
- label.textContent = messages.launchPathLabel;
25351
- const input = document2.createElement("input");
25352
- input.type = "text";
25353
- input.autocomplete = "off";
25354
- input.spellcheck = false;
25355
- input.placeholder = messages.locale === "zh-CN" ? "\u5E94\u7528\u5B89\u88C5\u76EE\u5F55\u7684\u7EDD\u5BF9\u8DEF\u5F84" : "Absolute installation directory";
25356
- input.setAttribute("aria-label", messages.launchPathLabel);
25357
- label.append(input);
25358
- const help = document2.createElement("p");
25359
- 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.";
25360
- const actions = document2.createElement("div");
25361
- actions.className = "settings-harness-launch__actions";
25362
- const save = document2.createElement("button");
25363
- save.type = "button";
25364
- save.className = "settings-command-button";
25365
- save.textContent = messages.launchPathSave;
25366
- const reset = document2.createElement("button");
25367
- reset.type = "button";
25368
- reset.className = "settings-command-button settings-command-button--secondary";
25369
- reset.textContent = messages.launchPathReset;
25370
- const status = document2.createElement("p");
25371
- status.setAttribute("role", "status");
25372
- status.setAttribute("aria-live", "polite");
25373
- actions.append(save, reset);
25374
- section.append(label, help, actions, status);
25375
- let busy = true;
25376
- let loaded = false;
25377
- const controls = () => {
25378
- input.disabled = busy || !loaded;
25379
- save.disabled = busy || !loaded || !input.value.trim();
25380
- reset.disabled = busy || !loaded;
25381
- };
25382
- const show = (value) => {
25383
- input.value = value.path ?? "";
25384
- status.textContent = value.restartRequired ? messages.launchPathRestart : value.path ? messages.launchPathSaved : messages.launchPathAutomatic;
25385
- };
25386
- const persist = async (value) => {
25387
- if (busy || !loaded) return;
25388
- busy = true;
25389
- controls();
25390
- status.textContent = messages.launchPathSaving;
25391
- try {
25392
- show(await settings.set(value));
25393
- } catch {
25394
- status.textContent = messages.launchPathSaveError;
25395
- } finally {
25396
- busy = false;
25397
- controls();
25398
- }
25399
- };
25400
- input.addEventListener("input", controls);
25401
- save.addEventListener("click", () => {
25402
- if (input.value.trim()) void persist(input.value.trim());
25403
- });
25404
- reset.addEventListener("click", () => {
25405
- void persist(null);
25406
- });
25407
- controls();
25408
- status.textContent = messages.launchPathLoading;
25409
- void settings.get().then((value) => {
25410
- loaded = true;
25411
- show(value);
25412
- }).catch(() => {
25413
- loaded = true;
25414
- status.textContent = messages.launchPathLoadError;
25415
- }).finally(() => {
25416
- busy = false;
25417
- controls();
25418
- });
25419
- return section;
25420
- }
25421
-
25422
- // src/settings/harness-installation-guides.ts
25423
- function harnessHasInstallCommands(plugin) {
25424
- return (plugin?.installation?.commands.length ?? 0) > 0;
25443
+ // src/settings/connection-row.ts
25444
+ function connectionStatusLabel(availability, messages, hasError = false) {
25445
+ if (availability === "updating") return messages.connectionStatusUpdating;
25446
+ if (hasError && availability !== "notInstalled") return messages.connectionStatusError;
25447
+ if (availability === "ready") return messages.connectionStatusReady;
25448
+ if (availability === "checking") return messages.connectionStatusChecking;
25449
+ if (availability === "notInstalled") return messages.connectionStatusNotInstalled;
25450
+ if (availability === "unavailable" || availability === "error") {
25451
+ return availability === "error" ? messages.connectionStatusError : messages.connectionStatusUnavailable;
25452
+ }
25453
+ return availability === "installing" ? messages.connectionStatusInstalling : messages.connectionStatusUnsupported;
25425
25454
  }
25426
- function harnessInstallationGuide(plugin, locale) {
25427
- const guide = plugin?.installation;
25428
- const text = (value) => value?.[locale] ?? value?.en;
25429
- return {
25430
- url: plugin?.links?.installation ?? plugin?.links?.documentation ?? plugin?.links?.website,
25431
- commands: guide?.commands ?? [],
25432
- downloads: guide?.downloads ?? [],
25433
- before: text(guide?.before),
25434
- after: text(guide?.after)
25435
- };
25455
+ function connectionStatusTone(availability, hasError = false) {
25456
+ if (availability === "updating") return "checking";
25457
+ if (hasError && availability !== "notInstalled") return "failed";
25458
+ if (availability === "ready") return "ready";
25459
+ if (availability === "checking" || availability === "installing") return "checking";
25460
+ if (availability === "notInstalled") return "setup";
25461
+ return "failed";
25436
25462
  }
25437
-
25438
- // src/settings/harness-installation-panel.ts
25439
- function createHarnessInstallationPanel(document2, plugin, hostId2, messages, copy, installation) {
25440
- const zh = messages.locale === "zh-CN";
25441
- const guide = harnessInstallationGuide(plugin, messages.locale);
25442
- const panel = document2.createElement("div");
25443
- panel.className = "settings-harness-installation";
25444
- const paragraph = (text) => {
25445
- const p = document2.createElement("p");
25446
- p.textContent = text;
25447
- panel.append(p);
25448
- };
25449
- if (hostId2 !== "local") {
25450
- paragraph(zh ? "\u8BF7\u5728\u8FDC\u7A0B Host \u4E0A\u5B89\u88C5\u3002" : "Install on the remote Host.");
25463
+ function createConnectionIdentityIcon(document2, item, size) {
25464
+ const container = document2.createElement("span");
25465
+ container.className = item.agentSnapshot ? "settings-connection-row__mark settings-connection-row__mark--logo" : "settings-connection-row__mark";
25466
+ container.setAttribute("aria-hidden", "true");
25467
+ if (item.agentSnapshot) {
25468
+ container.append(
25469
+ createRendererAgentIcon(item.agentSnapshot.agent, size, document2, item.agentSnapshot.plugin)
25470
+ );
25471
+ } else {
25472
+ container.textContent = "CH";
25451
25473
  }
25452
- if (guide.before) paragraph(guide.before);
25453
- const install = installation && guide.commands.length > 0 ? document2.createElement("button") : null;
25454
- if (install && installation) {
25455
- install.type = "button";
25456
- install.className = "settings-command-button";
25457
- install.dataset.connectionAction = "install";
25458
- install.disabled = installation.status !== "idle";
25459
- install.textContent = installation.status === "installing" ? messages.connectionStatusInstalling : installation.status === "checking" ? messages.connectionStatusChecking : zh ? "\u4E00\u952E\u5B89\u88C5" : "Install automatically";
25460
- install.addEventListener("click", () => {
25461
- if (install.disabled) return;
25462
- install.disabled = true;
25463
- install.textContent = messages.connectionStatusInstalling;
25464
- installation.run();
25465
- });
25466
- if (guide.commands.length > 1) panel.append(install);
25474
+ return container;
25475
+ }
25476
+ function sameElementChildren(container, next) {
25477
+ if (container.children.length !== next.length) return false;
25478
+ for (let index = 0; index < next.length; index++) {
25479
+ if (container.children[index] !== next[index]) return false;
25467
25480
  }
25468
- for (const { terminal, command } of guide.commands) {
25469
- const block = document2.createElement("div");
25470
- block.className = "settings-harness-installation-command";
25471
- const label = document2.createElement("strong");
25472
- label.textContent = terminal;
25473
- const pre = document2.createElement("pre");
25474
- const code = document2.createElement("code");
25475
- code.textContent = command;
25476
- pre.append(code);
25477
- const button2 = document2.createElement("button");
25478
- button2.type = "button";
25479
- button2.className = "settings-command-button settings-command-button--secondary";
25480
- button2.dataset.connectionAction = "copy-install";
25481
- const copyLabel = zh ? "\u590D\u5236\u547D\u4EE4" : "Copy command";
25482
- button2.setAttribute("aria-label", `${copyLabel}: ${terminal}`);
25483
- button2.append(createRendererSettingsIcon("copy", 16), copyLabel);
25484
- button2.addEventListener("click", () => copy(button2, command, copyLabel));
25485
- const actions = document2.createElement("div");
25486
- actions.className = "settings-harness-installation-actions";
25487
- if (install && guide.commands.length === 1) actions.append(install);
25488
- actions.append(button2);
25489
- block.append(label, pre, actions);
25490
- panel.append(block);
25481
+ return true;
25482
+ }
25483
+ function reconcileElementChildren(container, next) {
25484
+ if (sameElementChildren(container, next)) return;
25485
+ if (typeof container.insertBefore !== "function") {
25486
+ container.replaceChildren(...next);
25487
+ return;
25491
25488
  }
25492
- for (const download2 of guide.downloads ?? []) {
25493
- const link = document2.createElement("a");
25494
- link.className = "settings-command-button settings-command-button--secondary";
25495
- link.href = download2.url;
25496
- link.target = "_blank";
25497
- link.rel = "noopener noreferrer";
25498
- link.textContent = zh ? "\u4E0B\u8F7D" : "Download";
25499
- link.setAttribute("aria-label", `${link.textContent} ${download2.label}`);
25500
- panel.append(link);
25489
+ const nextSet = new Set(next);
25490
+ for (const child of [...container.children]) {
25491
+ if (!nextSet.has(child)) child.remove();
25501
25492
  }
25502
- if (guide.after) paragraph(guide.after);
25503
- if (!plugin?.installation && guide.url) {
25504
- const link = document2.createElement("a");
25505
- link.href = guide.url;
25506
- link.target = "_blank";
25507
- link.rel = "noopener noreferrer";
25508
- link.textContent = zh ? "\u5B89\u88C5\u8BF4\u660E" : "Installation instructions";
25509
- panel.append(link);
25493
+ for (let index = 0; index < next.length; index++) {
25494
+ const desired = next[index];
25495
+ if (!desired) continue;
25496
+ const current = container.children[index] ?? null;
25497
+ if (current !== desired) {
25498
+ container.insertBefore(desired, current);
25499
+ }
25510
25500
  }
25511
- return panel;
25512
- }
25513
-
25514
- // src/settings/harness-install-store.ts
25515
- function errorMessage(error51) {
25516
- 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.";
25517
25501
  }
25518
- function unknownInstallOutcome(message2) {
25519
- return /outcome is unknown|do not retry automatically|did not answer in time/i.test(message2);
25502
+ function identityIconSignature(item) {
25503
+ if (!item.agentSnapshot) return "adapter";
25504
+ const plugin = item.agentSnapshot.plugin;
25505
+ return `${item.agentSnapshot.agent}:${String(plugin?.icon ?? "")}:${String(plugin?.iconStyle ?? "")}`;
25520
25506
  }
25521
- var stores = /* @__PURE__ */ new WeakMap();
25522
- function createStore(diagnostics) {
25523
- const states2 = /* @__PURE__ */ new Map();
25524
- const listeners = /* @__PURE__ */ new Set();
25525
- const key = (host, agent) => JSON.stringify([host, agent]);
25526
- const notify2 = () => listeners.forEach((listener) => listener());
25527
- return {
25528
- get: (host, agent) => states2.get(key(host, agent)),
25529
- clearErrors() {
25530
- for (const [id, state] of states2) if (state.status === "error") states2.delete(id);
25531
- notify2();
25532
- },
25533
- subscribe(listener) {
25534
- listeners.add(listener);
25535
- return () => {
25536
- listeners.delete(listener);
25537
- };
25538
- },
25539
- async install(host, agent) {
25540
- const id = key(host, agent);
25541
- const previous = states2.get(id);
25542
- if (!diagnostics.installation || previous && previous.status !== "error") return;
25543
- states2.set(id, { status: "installing" });
25544
- notify2();
25545
- let failure;
25546
- try {
25547
- await diagnostics.installation(host, agent, "install");
25548
- states2.set(id, { status: "checking" });
25549
- notify2();
25550
- } catch (error51) {
25551
- failure = errorMessage(error51);
25507
+ function createConnectionRowView(document2, messages, groupable) {
25508
+ const row = document2.createElement("div");
25509
+ row.className = "settings-connection-row";
25510
+ row.setAttribute("role", "row");
25511
+ const identity2 = document2.createElement("div");
25512
+ identity2.className = "settings-connection-row__identity";
25513
+ identity2.setAttribute("role", "cell");
25514
+ let handle = null;
25515
+ if (groupable) {
25516
+ handle = document2.createElement("span");
25517
+ handle.className = "settings-connection-row__handle";
25518
+ handle.setAttribute("aria-hidden", "true");
25519
+ handle.append(createRendererSettingsIcon("grip-vertical", 15));
25520
+ identity2.append(handle);
25521
+ }
25522
+ let iconElement = null;
25523
+ let renderedIconKey = null;
25524
+ const label = document2.createElement("strong");
25525
+ const status = document2.createElement("span");
25526
+ status.className = "settings-connection-row__status";
25527
+ status.setAttribute("role", "cell");
25528
+ const action = document2.createElement("div");
25529
+ action.className = "settings-connection-row__action";
25530
+ action.setAttribute("role", "cell");
25531
+ row.append(identity2, status, action);
25532
+ let currentItem = null;
25533
+ let currentSelect = () => void 0;
25534
+ let currentGroup = null;
25535
+ let installButton = null;
25536
+ let viewErrorButton = null;
25537
+ let versionAvailableBadge = null;
25538
+ let updateButton = null;
25539
+ let groupToggleButton = null;
25540
+ let groupToggleSection = null;
25541
+ row.addEventListener("click", (event) => {
25542
+ const target2 = event.target;
25543
+ if (target2?.closest?.("a")) return;
25544
+ currentSelect();
25545
+ });
25546
+ row.addEventListener("keydown", (event) => {
25547
+ if (event.target?.closest?.("button, a")) return;
25548
+ if (event.key !== "Enter" && event.key !== " ") return;
25549
+ event.preventDefault();
25550
+ currentSelect();
25551
+ });
25552
+ if (groupable) {
25553
+ row.addEventListener("dragstart", (event) => currentGroup?.onDragStart(event));
25554
+ row.addEventListener("dragover", (event) => currentGroup?.onDragOver(event));
25555
+ row.addEventListener("dragleave", (event) => currentGroup?.onDragLeave(event));
25556
+ row.addEventListener("drop", (event) => currentGroup?.onDrop(event));
25557
+ row.addEventListener("dragend", (event) => currentGroup?.onDragEnd(event));
25558
+ }
25559
+ const setSelected = (selected) => {
25560
+ const nextSelected = String(selected);
25561
+ if (row.dataset.connectionSelected !== nextSelected) {
25562
+ row.dataset.connectionSelected = nextSelected;
25563
+ }
25564
+ const nextTabIndex = selected ? 0 : -1;
25565
+ if (row.tabIndex !== nextTabIndex) {
25566
+ row.tabIndex = nextTabIndex;
25567
+ }
25568
+ };
25569
+ return {
25570
+ element: row,
25571
+ setSelected,
25572
+ update(item, selected, select, group) {
25573
+ currentItem = item;
25574
+ currentSelect = select;
25575
+ currentGroup = group;
25576
+ if (row.dataset.connectionItem !== item.key) {
25577
+ row.dataset.connectionItem = item.key;
25578
+ }
25579
+ setSelected(selected);
25580
+ const nextIconKey = identityIconSignature(item);
25581
+ if (renderedIconKey !== nextIconKey || !iconElement) {
25582
+ renderedIconKey = nextIconKey;
25583
+ iconElement = createConnectionIdentityIcon(document2, item, 19);
25584
+ reconcileElementChildren(
25585
+ identity2,
25586
+ handle ? [handle, iconElement, label] : [iconElement, label]
25587
+ );
25552
25588
  }
25553
- try {
25554
- await diagnostics.refresh(host);
25555
- const refreshed = diagnostics.snapshot().hosts.find((candidate) => candidate.hostId === host)?.agents.find((candidate) => candidate.agent === agent);
25556
- if (refreshed?.availability === "ready") failure = void 0;
25557
- else if (failure && unknownInstallOutcome(failure) && refreshed && refreshed.availability !== "notInstalled") {
25558
- failure = void 0;
25589
+ if (handle && group && handle.title !== group.dragHandleTitle) {
25590
+ handle.title = group.dragHandleTitle;
25591
+ }
25592
+ if (label.textContent !== item.name) {
25593
+ label.textContent = item.name;
25594
+ }
25595
+ const tone = connectionStatusTone(item.availability, item.error !== null);
25596
+ if (status.dataset.connectionTone !== tone) {
25597
+ status.dataset.connectionTone = tone;
25598
+ }
25599
+ const statusText = item.error?.code === "authenticationRequired" ? messages.connectionLoginRequired : item.error?.code === "configurationRequired" ? messages.connectionConfigurationRequired : connectionStatusLabel(item.availability, messages, item.error !== null);
25600
+ if (status.textContent !== statusText) {
25601
+ status.textContent = statusText;
25602
+ }
25603
+ const nextActions = [];
25604
+ if (item.agentSnapshot?.availability === "notInstalled" && item.install) {
25605
+ if (!installButton) {
25606
+ const button2 = document2.createElement("button");
25607
+ button2.type = "button";
25608
+ button2.className = "settings-connection-install-link";
25609
+ button2.append(createRendererSettingsIcon("download", 17));
25610
+ button2.addEventListener("click", (event) => {
25611
+ event.stopPropagation();
25612
+ currentSelect();
25613
+ currentItem?.install?.();
25614
+ });
25615
+ installButton = button2;
25616
+ }
25617
+ installButton.disabled = item.availability === "installing" || item.availability === "checking";
25618
+ const installLabel = messages.connectionInstall;
25619
+ const ariaLabel = `${installLabel}: ${item.name}`;
25620
+ if (installButton.getAttribute("aria-label") !== ariaLabel) {
25621
+ installButton.setAttribute("aria-label", ariaLabel);
25622
+ }
25623
+ if (installButton.title !== installLabel) {
25624
+ installButton.title = installLabel;
25625
+ }
25626
+ nextActions.push(installButton);
25627
+ } else if (item.error) {
25628
+ if (!viewErrorButton) {
25629
+ const button2 = document2.createElement("button");
25630
+ button2.type = "button";
25631
+ button2.className = "settings-connection-view-error";
25632
+ button2.textContent = messages.connectionViewError;
25633
+ button2.addEventListener("click", (event) => {
25634
+ event.stopPropagation();
25635
+ currentSelect();
25636
+ });
25637
+ viewErrorButton = button2;
25638
+ }
25639
+ nextActions.push(viewErrorButton);
25640
+ }
25641
+ const version2 = item.version;
25642
+ if (version2?.state?.updateAvailable && !version2.updating) {
25643
+ if (!versionAvailableBadge) {
25644
+ const badge = document2.createElement("span");
25645
+ badge.className = "settings-connection-version-available";
25646
+ badge.textContent = messages.harnessVersionAvailable;
25647
+ versionAvailableBadge = badge;
25648
+ }
25649
+ const badgeTitle = `${messages.harnessVersionCurrent}: ${version2.state.currentVersion ?? "\u2014"}
25650
+ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages.harnessVersion)}`;
25651
+ if (versionAvailableBadge.title !== badgeTitle) {
25652
+ versionAvailableBadge.title = badgeTitle;
25653
+ }
25654
+ nextActions.push(versionAvailableBadge);
25655
+ }
25656
+ if (version2?.state?.updateAvailable && version2.state.canUpdate) {
25657
+ if (!updateButton) {
25658
+ const button2 = document2.createElement("button");
25659
+ button2.type = "button";
25660
+ button2.className = "settings-connection-install-link";
25661
+ button2.dataset.connectionAction = "update";
25662
+ button2.append(createRendererSettingsIcon("download", 17));
25663
+ button2.addEventListener("click", (event) => {
25664
+ event.stopPropagation();
25665
+ if (button2.disabled) return;
25666
+ void currentItem?.version?.update();
25667
+ currentSelect();
25668
+ });
25669
+ updateButton = button2;
25670
+ }
25671
+ updateButton.disabled = version2.updating;
25672
+ if (updateButton.title !== messages.harnessVersionUpdate) {
25673
+ updateButton.title = messages.harnessVersionUpdate;
25674
+ }
25675
+ const updateAriaLabel = `${messages.harnessVersionUpdate}: ${item.name}`;
25676
+ if (updateButton.getAttribute("aria-label") !== updateAriaLabel) {
25677
+ updateButton.setAttribute("aria-label", updateAriaLabel);
25678
+ }
25679
+ nextActions.push(updateButton);
25680
+ }
25681
+ if (group) {
25682
+ if (!groupToggleButton) {
25683
+ const button2 = document2.createElement("button");
25684
+ button2.type = "button";
25685
+ button2.className = "settings-connection-row__group-toggle";
25686
+ button2.addEventListener("click", (event) => {
25687
+ event.stopPropagation();
25688
+ currentGroup?.toggleSection();
25689
+ });
25690
+ groupToggleButton = button2;
25691
+ }
25692
+ groupToggleButton.disabled = group.disabled;
25693
+ if (groupToggleButton.title !== group.moveLabel) {
25694
+ groupToggleButton.title = group.moveLabel;
25695
+ }
25696
+ if (groupToggleButton.getAttribute("aria-label") !== group.moveLabel) {
25697
+ groupToggleButton.setAttribute("aria-label", group.moveLabel);
25698
+ }
25699
+ if (groupToggleSection !== group.section) {
25700
+ groupToggleSection = group.section;
25701
+ groupToggleButton.replaceChildren(
25702
+ createRendererSettingsIcon(
25703
+ group.section === "main" ? "chevron-down" : "chevron-up",
25704
+ 15
25705
+ )
25706
+ );
25707
+ }
25708
+ nextActions.push(groupToggleButton);
25709
+ }
25710
+ reconcileElementChildren(action, nextActions);
25711
+ if (group) {
25712
+ row.draggable = !group.disabled;
25713
+ if (row.dataset.connectionGroupSection !== group.section) {
25714
+ row.dataset.connectionGroupSection = group.section;
25559
25715
  }
25560
- } catch (error51) {
25561
- failure ??= errorMessage(error51);
25562
25716
  }
25563
- if (failure) states2.set(id, { status: "error", error: failure });
25564
- else states2.delete(id);
25565
- notify2();
25566
25717
  }
25567
25718
  };
25568
25719
  }
25569
- function harnessInstallStore(diagnostics) {
25570
- let store = stores.get(diagnostics);
25720
+
25721
+ // src/settings/connection-updates.ts
25722
+ var sharedBatchStores = /* @__PURE__ */ new WeakMap();
25723
+ function getBatchStore(diagnostics) {
25724
+ if (!diagnostics) {
25725
+ return { batches: /* @__PURE__ */ new Map(), listeners: /* @__PURE__ */ new Set() };
25726
+ }
25727
+ let store = sharedBatchStores.get(diagnostics);
25571
25728
  if (!store) {
25572
- store = createStore(diagnostics);
25573
- stores.set(diagnostics, store);
25729
+ store = { batches: /* @__PURE__ */ new Map(), listeners: /* @__PURE__ */ new Set() };
25730
+ sharedBatchStores.set(diagnostics, store);
25574
25731
  }
25575
25732
  return store;
25576
25733
  }
25734
+ function createConnectionUpdates(document2, messages, signal, onChange, diagnostics = null) {
25735
+ const store = getBatchStore(diagnostics);
25736
+ const notify2 = () => {
25737
+ for (const listener of [...store.listeners]) listener();
25738
+ };
25739
+ if (!signal.aborted) {
25740
+ const listener = () => {
25741
+ if (!signal.aborted) onChange();
25742
+ };
25743
+ store.listeners.add(listener);
25744
+ signal.addEventListener(
25745
+ "abort",
25746
+ () => {
25747
+ store.listeners.delete(listener);
25748
+ },
25749
+ { once: true }
25750
+ );
25751
+ }
25752
+ const eligible = (panels) => panels.filter((panel) => panel.state?.updateAvailable && panel.state.canUpdate);
25753
+ const start = async (hostId2, panels) => {
25754
+ if (signal.aborted || store.batches.get(hostId2)?.running) return;
25755
+ const targets = eligible(panels);
25756
+ if (!targets.length) return;
25757
+ const batch = { running: true, total: targets.length, succeeded: 0, failed: 0 };
25758
+ store.batches.set(hostId2, batch);
25759
+ notify2();
25760
+ await Promise.all(
25761
+ targets.map(async (panel) => {
25762
+ try {
25763
+ if (await panel.update()) batch.succeeded++;
25764
+ else batch.failed++;
25765
+ } catch {
25766
+ batch.failed++;
25767
+ }
25768
+ notify2();
25769
+ })
25770
+ );
25771
+ batch.running = false;
25772
+ notify2();
25773
+ };
25774
+ return {
25775
+ createControls(hostId2, panels) {
25776
+ let currentHostId = hostId2;
25777
+ let currentPanels = panels;
25778
+ let renderedLabel = null;
25779
+ const button2 = document2.createElement("button");
25780
+ button2.type = "button";
25781
+ button2.className = "settings-command-button settings-command-button--secondary settings-connection-update-all";
25782
+ button2.dataset.connectionAction = "update-all";
25783
+ button2.title = messages.harnessUpdateAllDescription;
25784
+ button2.addEventListener("click", () => {
25785
+ if (!button2.disabled) void start(currentHostId, currentPanels);
25786
+ });
25787
+ const result = document2.createElement("p");
25788
+ result.className = "settings-connection-update-result";
25789
+ result.setAttribute("role", "status");
25790
+ const update = (nextHostId, nextPanels) => {
25791
+ currentHostId = nextHostId;
25792
+ currentPanels = nextPanels;
25793
+ const batch = store.batches.get(nextHostId);
25794
+ const count3 = eligible(nextPanels).length;
25795
+ button2.disabled = signal.aborted || Boolean(batch?.running) || !count3;
25796
+ const label = batch?.running ? `${messages.harnessUpdateAllProgress} ${batch.succeeded + batch.failed}/${batch.total}` : count3 ? `${messages.harnessUpdateAll} (${count3})` : messages.harnessUpdateAll;
25797
+ if (renderedLabel !== label) {
25798
+ renderedLabel = label;
25799
+ button2.replaceChildren(createRendererSettingsIcon("download", 15), label);
25800
+ }
25801
+ const hidden = !batch || batch.running;
25802
+ result.hidden = hidden;
25803
+ const resultText = batch && !batch.running ? messages.harnessUpdateAllResult.replace("{succeeded}", String(batch.succeeded)).replace("{failed}", String(batch.failed)) : "";
25804
+ if (result.textContent !== resultText) {
25805
+ result.textContent = resultText;
25806
+ }
25807
+ };
25808
+ update(hostId2, panels);
25809
+ return { button: button2, result, update };
25810
+ }
25811
+ };
25812
+ }
25577
25813
 
25578
25814
  // src/settings/harness-version-panel.ts
25579
- function createHarnessVersionPanel(document2, messages, signal, agent, client, onChange = () => void 0) {
25815
+ function isUnsupportedInstallationError(error51) {
25816
+ return typeof error51 === "object" && error51 !== null && "code" in error51 && (error51.code === -32601 || error51.code === -32078);
25817
+ }
25818
+ function createHarnessVersionSession(client, options) {
25819
+ let state;
25820
+ let statusKind = "checking";
25821
+ let checkPromise = null;
25822
+ let updatePromise = null;
25823
+ const listeners = /* @__PURE__ */ new Set();
25824
+ const signal = options?.signal;
25825
+ const notify2 = (pageChange) => {
25826
+ if (signal?.aborted) return;
25827
+ for (const listener of [...listeners]) listener(pageChange);
25828
+ };
25829
+ const check2 = () => {
25830
+ if (signal?.aborted || updatePromise) return Promise.resolve();
25831
+ if (checkPromise) return checkPromise;
25832
+ statusKind = "checking";
25833
+ notify2(false);
25834
+ checkPromise = (async () => {
25835
+ try {
25836
+ const result = await client.run("check");
25837
+ if (signal?.aborted || updatePromise) return;
25838
+ state = result;
25839
+ statusKind = "idle";
25840
+ } catch (error51) {
25841
+ if (signal?.aborted || updatePromise) return;
25842
+ statusKind = isUnsupportedInstallationError(error51) ? "unsupported" : "failed";
25843
+ if (state) state = { ...state, canUpdate: false };
25844
+ } finally {
25845
+ checkPromise = null;
25846
+ if (!signal?.aborted && !updatePromise) {
25847
+ notify2(true);
25848
+ }
25849
+ }
25850
+ })();
25851
+ return checkPromise;
25852
+ };
25853
+ const update = () => {
25854
+ if (updatePromise) return updatePromise;
25855
+ updatePromise = (async () => {
25856
+ if (signal?.aborted) return false;
25857
+ if (checkPromise) await checkPromise;
25858
+ if (signal?.aborted || statusKind === "unsupported" || !state?.canUpdate || !state.updateAvailable) {
25859
+ return false;
25860
+ }
25861
+ statusKind = "updating";
25862
+ notify2(true);
25863
+ try {
25864
+ const result = await client.run("update");
25865
+ if (signal?.aborted) return false;
25866
+ state = result;
25867
+ statusKind = !result.canUpdate ? "updated" : result.updateAvailable ? "failed" : "updated";
25868
+ return result.canUpdate && !result.updateAvailable;
25869
+ } catch (error51) {
25870
+ if (signal?.aborted) return false;
25871
+ statusKind = isUnsupportedInstallationError(error51) ? "unsupported" : "failed";
25872
+ if (state) state = { ...state, canUpdate: false };
25873
+ return false;
25874
+ } finally {
25875
+ updatePromise = null;
25876
+ if (!signal?.aborted) {
25877
+ notify2(true);
25878
+ }
25879
+ }
25880
+ })();
25881
+ return updatePromise;
25882
+ };
25883
+ return {
25884
+ get state() {
25885
+ return state;
25886
+ },
25887
+ get statusKind() {
25888
+ return statusKind;
25889
+ },
25890
+ get updating() {
25891
+ return statusKind === "updating";
25892
+ },
25893
+ prepareMount() {
25894
+ if (updatePromise || checkPromise) return false;
25895
+ statusKind = "checking";
25896
+ return true;
25897
+ },
25898
+ check: check2,
25899
+ update,
25900
+ subscribe(listener) {
25901
+ listeners.add(listener);
25902
+ return () => {
25903
+ listeners.delete(listener);
25904
+ };
25905
+ }
25906
+ };
25907
+ }
25908
+ function createHarnessVersionPanel(document2, messages, signal, agent, client, onChange = () => void 0, sharedSession) {
25909
+ const session = sharedSession ?? createHarnessVersionSession(client, { signal });
25910
+ const shouldScheduleCheck = session.prepareMount();
25580
25911
  const panel = document2.createElement("section");
25581
25912
  panel.className = "settings-harness-version";
25582
25913
  panel.dataset.harnessVersion = agent;
@@ -25600,15 +25931,14 @@ ${detail}` : ""}`
25600
25931
  note.textContent = messages.harnessVersionNote;
25601
25932
  actions.append(update);
25602
25933
  panel.append(heading, versions, status, actions, note);
25603
- let state;
25604
- let busy = false;
25605
- let updating = false;
25606
- let unsupported = false;
25607
- let updatePromise = null;
25608
25934
  const render = () => {
25935
+ const state = session.state;
25936
+ const statusKind = session.statusKind;
25937
+ const busy = statusKind === "checking" || statusKind === "updating";
25609
25938
  heading.textContent = state?.versionKind === "application" ? messages.harnessVersionApplicationTitle : messages.harnessVersionTitle;
25610
25939
  current.textContent = `${messages.harnessVersionCurrent}: ${state?.currentVersion ?? "\u2014"}`;
25611
25940
  latest.textContent = `${messages.harnessVersionLatest}: ${harnessVersionLabel(state, messages.harnessVersion)}`;
25941
+ 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 : "";
25612
25942
  update.disabled = busy || signal.aborted || !state?.canUpdate || !state.updateAvailable;
25613
25943
  const manualUrl = !state?.canUpdate && state?.updateAvailable ? state.manualUpdateUrl : void 0;
25614
25944
  actions.replaceChildren(update);
@@ -25627,99 +25957,92 @@ ${detail}` : ""}`
25627
25957
  const detail = harnessVersionNote(state, messages.harnessVersion);
25628
25958
  note.textContent = detail ? !state?.canUpdate ? detail : `${detail} ${messages.harnessVersionNote}` : messages.harnessVersionNote;
25629
25959
  };
25630
- const run = async (action) => {
25631
- if (busy || unsupported || signal.aborted) return false;
25632
- if (action === "update" && (!state?.canUpdate || !state.updateAvailable)) return false;
25633
- busy = true;
25634
- updating = action === "update";
25635
- onChange();
25636
- status.textContent = action === "check" ? messages.harnessVersionChecking : messages.harnessVersionUpdating;
25960
+ update.addEventListener("click", () => {
25961
+ if (!signal.aborted) void session.update();
25962
+ });
25963
+ const unsubscribe = session.subscribe((pageChange) => {
25964
+ if (signal.aborted) return;
25637
25965
  render();
25638
- try {
25639
- const result = await client.run(action);
25640
- if (signal.aborted) return false;
25641
- state = result;
25642
- status.textContent = !result.canUpdate ? messages.harnessVersionManual : action === "update" ? result.updateAvailable ? messages.harnessVersionFailed : messages.harnessVersionUpdated : "";
25643
- return result.canUpdate && !result.updateAvailable;
25644
- } catch (error51) {
25645
- if (signal.aborted) return false;
25646
- unsupported = typeof error51 === "object" && error51 !== null && "code" in error51 && (error51.code === -32601 || error51.code === -32078);
25647
- status.textContent = unsupported ? messages.harnessVersionUnsupported : messages.harnessVersionFailed;
25648
- if (state) state = { ...state, canUpdate: false };
25649
- return false;
25650
- } finally {
25651
- busy = false;
25652
- updating = false;
25653
- if (!signal.aborted) {
25654
- render();
25655
- onChange();
25656
- }
25657
- }
25658
- };
25659
- const updateVersion = () => {
25660
- updatePromise ??= run("update").finally(() => {
25661
- updatePromise = null;
25662
- });
25663
- return updatePromise;
25664
- };
25665
- update.addEventListener("click", () => void updateVersion());
25966
+ if (pageChange) onChange();
25967
+ });
25666
25968
  const owner = document2.defaultView;
25667
25969
  let checkFrame = null;
25668
25970
  let checkTimer = null;
25669
25971
  signal.addEventListener(
25670
25972
  "abort",
25671
25973
  () => {
25974
+ unsubscribe();
25672
25975
  if (checkFrame !== null) owner?.cancelAnimationFrame(checkFrame);
25673
25976
  if (checkTimer !== null) owner?.clearTimeout(checkTimer);
25674
25977
  render();
25675
25978
  },
25676
25979
  { once: true }
25677
25980
  );
25678
- status.textContent = messages.harnessVersionChecking;
25679
25981
  render();
25680
- if (!signal.aborted && owner?.requestAnimationFrame) {
25681
- checkFrame = owner.requestAnimationFrame(() => {
25682
- checkFrame = null;
25683
- if (signal.aborted) return;
25684
- checkTimer = owner.setTimeout(() => {
25685
- checkTimer = null;
25686
- void run("check");
25687
- }, 0);
25688
- });
25689
- } else {
25690
- void run("check");
25982
+ if (shouldScheduleCheck && !signal.aborted) {
25983
+ if (owner?.requestAnimationFrame) {
25984
+ checkFrame = owner.requestAnimationFrame(() => {
25985
+ checkFrame = null;
25986
+ if (signal.aborted) return;
25987
+ checkTimer = owner.setTimeout(() => {
25988
+ checkTimer = null;
25989
+ if (!signal.aborted) void session.check();
25990
+ }, 0);
25991
+ });
25992
+ } else {
25993
+ void session.check();
25994
+ }
25691
25995
  }
25692
25996
  return {
25693
25997
  element: panel,
25694
25998
  get state() {
25695
- return state;
25999
+ return session.state;
25696
26000
  },
25697
26001
  get updating() {
25698
- return updating;
26002
+ return session.updating;
25699
26003
  },
25700
- update: updateVersion
26004
+ update: () => signal.aborted ? Promise.resolve(false) : session.update()
25701
26005
  };
25702
26006
  }
25703
26007
 
25704
26008
  // src/settings/connection-versions.ts
26009
+ var sessionStores = /* @__PURE__ */ new WeakMap();
26010
+ function getSessionStore(diagnostics) {
26011
+ let store = sessionStores.get(diagnostics);
26012
+ if (!store) {
26013
+ store = /* @__PURE__ */ new Map();
26014
+ sessionStores.set(diagnostics, store);
26015
+ }
26016
+ return store;
26017
+ }
25705
26018
  function createConnectionVersions(document2, messages, signal, diagnostics, onChange) {
25706
26019
  const panels = /* @__PURE__ */ new Map();
25707
26020
  const installation = diagnostics?.installation?.bind(diagnostics);
26021
+ const sessions = diagnostics ? getSessionStore(diagnostics) : null;
26022
+ const sessionKey = (hostId2, agent) => JSON.stringify([hostId2, agent]);
25708
26023
  return {
26024
+ isUpdating(hostId2, agent) {
26025
+ return Boolean(sessions?.get(sessionKey(hostId2, agent))?.updating);
26026
+ },
25709
26027
  get(hostId2, agent) {
25710
26028
  if (!installation || signal.aborted) return void 0;
25711
- const key = JSON.stringify([hostId2, agent]);
26029
+ const key = sessionKey(hostId2, agent);
25712
26030
  let panel = panels.get(key);
25713
26031
  if (!panel) {
26032
+ const run = (action) => installation(hostId2, agent, action);
26033
+ let session = sessions?.get(key);
26034
+ if (!session) {
26035
+ session = createHarnessVersionSession({ run });
26036
+ sessions?.set(key, session);
26037
+ }
25714
26038
  panel = createHarnessVersionPanel(
25715
26039
  document2,
25716
26040
  messages,
25717
26041
  signal,
25718
26042
  agent,
25719
- {
25720
- run: (action) => installation(hostId2, agent, action)
25721
- },
25722
- onChange
26043
+ { run },
26044
+ onChange,
26045
+ session
25723
26046
  );
25724
26047
  panels.set(key, panel);
25725
26048
  }
@@ -25728,79 +26051,242 @@ ${detail}` : ""}`
25728
26051
  };
25729
26052
  }
25730
26053
 
25731
- // src/settings/connection-updates.ts
25732
- function createConnectionUpdates(document2, messages, signal, onChange) {
25733
- const batches = /* @__PURE__ */ new Map();
25734
- const eligible = (panels) => panels.filter((panel) => panel.state?.updateAvailable && panel.state.canUpdate);
25735
- const start = async (hostId2, panels) => {
25736
- if (signal.aborted || batches.get(hostId2)?.running) return;
25737
- const targets = eligible(panels);
25738
- if (!targets.length) return;
25739
- const batch = { running: true, total: targets.length, succeeded: 0, failed: 0 };
25740
- batches.set(hostId2, batch);
25741
- onChange();
25742
- await Promise.all(
25743
- targets.map(async (panel) => {
25744
- try {
25745
- if (await panel.update()) batch.succeeded++;
25746
- else batch.failed++;
25747
- } catch {
25748
- batch.failed++;
25749
- }
25750
- if (!signal.aborted) onChange();
25751
- })
25752
- );
25753
- batch.running = false;
25754
- if (!signal.aborted) onChange();
26054
+ // src/settings/harness-install-store.ts
26055
+ function errorMessage(error51) {
26056
+ 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.";
26057
+ }
26058
+ function unknownInstallOutcome(message2) {
26059
+ return /outcome is unknown|do not retry automatically|did not answer in time/i.test(message2);
26060
+ }
26061
+ var stores = /* @__PURE__ */ new WeakMap();
26062
+ function createStore(diagnostics) {
26063
+ const states2 = /* @__PURE__ */ new Map();
26064
+ const listeners = /* @__PURE__ */ new Set();
26065
+ const key = (host, agent) => JSON.stringify([host, agent]);
26066
+ const notify2 = () => listeners.forEach((listener) => listener());
26067
+ return {
26068
+ get: (host, agent) => states2.get(key(host, agent)),
26069
+ clearErrors() {
26070
+ for (const [id, state] of states2) if (state.status === "error") states2.delete(id);
26071
+ notify2();
26072
+ },
26073
+ subscribe(listener) {
26074
+ listeners.add(listener);
26075
+ return () => {
26076
+ listeners.delete(listener);
26077
+ };
26078
+ },
26079
+ async install(host, agent) {
26080
+ const id = key(host, agent);
26081
+ const previous = states2.get(id);
26082
+ if (!diagnostics.installation || previous && previous.status !== "error") return;
26083
+ states2.set(id, { status: "installing" });
26084
+ notify2();
26085
+ let failure;
26086
+ try {
26087
+ await diagnostics.installation(host, agent, "install");
26088
+ states2.set(id, { status: "checking" });
26089
+ notify2();
26090
+ } catch (error51) {
26091
+ failure = errorMessage(error51);
26092
+ }
26093
+ try {
26094
+ await diagnostics.refresh(host);
26095
+ const refreshed = diagnostics.snapshot().hosts.find((candidate) => candidate.hostId === host)?.agents.find((candidate) => candidate.agent === agent);
26096
+ if (refreshed?.availability === "ready") failure = void 0;
26097
+ else if (failure && unknownInstallOutcome(failure) && refreshed && refreshed.availability !== "notInstalled") {
26098
+ failure = void 0;
26099
+ }
26100
+ } catch (error51) {
26101
+ failure ??= errorMessage(error51);
26102
+ }
26103
+ if (failure) states2.set(id, { status: "error", error: failure });
26104
+ else states2.delete(id);
26105
+ notify2();
26106
+ }
26107
+ };
26108
+ }
26109
+ function harnessInstallStore(diagnostics) {
26110
+ let store = stores.get(diagnostics);
26111
+ if (!store) {
26112
+ store = createStore(diagnostics);
26113
+ stores.set(diagnostics, store);
26114
+ }
26115
+ return store;
26116
+ }
26117
+
26118
+ // src/settings/harness-installation-guides.ts
26119
+ function harnessHasInstallCommands(plugin) {
26120
+ return (plugin?.installation?.commands.length ?? 0) > 0;
26121
+ }
26122
+ function harnessInstallationGuide(plugin, locale) {
26123
+ const guide = plugin?.installation;
26124
+ const text = (value) => value?.[locale] ?? value?.en;
26125
+ return {
26126
+ url: plugin?.links?.installation ?? plugin?.links?.documentation ?? plugin?.links?.website,
26127
+ commands: guide?.commands ?? [],
26128
+ downloads: guide?.downloads ?? [],
26129
+ before: text(guide?.before),
26130
+ after: text(guide?.after)
26131
+ };
26132
+ }
26133
+
26134
+ // src/settings/harness-installation-panel.ts
26135
+ function createHarnessInstallationPanel(document2, plugin, hostId2, messages, copy, installation) {
26136
+ const zh = messages.locale === "zh-CN";
26137
+ const guide = harnessInstallationGuide(plugin, messages.locale);
26138
+ const panel = document2.createElement("div");
26139
+ panel.className = "settings-harness-installation";
26140
+ const paragraph = (text) => {
26141
+ const p = document2.createElement("p");
26142
+ p.textContent = text;
26143
+ panel.append(p);
26144
+ };
26145
+ if (hostId2 !== "local") {
26146
+ paragraph(zh ? "\u8BF7\u5728\u8FDC\u7A0B Host \u4E0A\u5B89\u88C5\u3002" : "Install on the remote Host.");
26147
+ }
26148
+ if (guide.before) paragraph(guide.before);
26149
+ const install = installation && guide.commands.length > 0 ? document2.createElement("button") : null;
26150
+ if (install && installation) {
26151
+ install.type = "button";
26152
+ install.className = "settings-command-button";
26153
+ install.dataset.connectionAction = "install";
26154
+ install.disabled = installation.status !== "idle";
26155
+ install.textContent = installation.status === "installing" ? messages.connectionStatusInstalling : installation.status === "checking" ? messages.connectionStatusChecking : zh ? "\u4E00\u952E\u5B89\u88C5" : "Install automatically";
26156
+ install.addEventListener("click", () => {
26157
+ if (install.disabled) return;
26158
+ install.disabled = true;
26159
+ install.textContent = messages.connectionStatusInstalling;
26160
+ installation.run();
26161
+ });
26162
+ if (guide.commands.length > 1) panel.append(install);
26163
+ }
26164
+ for (const { terminal, command } of guide.commands) {
26165
+ const block = document2.createElement("div");
26166
+ block.className = "settings-harness-installation-command";
26167
+ const label = document2.createElement("strong");
26168
+ label.textContent = terminal;
26169
+ const pre = document2.createElement("pre");
26170
+ const code = document2.createElement("code");
26171
+ code.textContent = command;
26172
+ pre.append(code);
26173
+ const button2 = document2.createElement("button");
26174
+ button2.type = "button";
26175
+ button2.className = "settings-command-button settings-command-button--secondary";
26176
+ button2.dataset.connectionAction = "copy-install";
26177
+ const copyLabel = zh ? "\u590D\u5236\u547D\u4EE4" : "Copy command";
26178
+ button2.setAttribute("aria-label", `${copyLabel}: ${terminal}`);
26179
+ button2.append(createRendererSettingsIcon("copy", 16), copyLabel);
26180
+ button2.addEventListener("click", () => copy(button2, command, copyLabel));
26181
+ const actions = document2.createElement("div");
26182
+ actions.className = "settings-harness-installation-actions";
26183
+ if (install && guide.commands.length === 1) actions.append(install);
26184
+ actions.append(button2);
26185
+ block.append(label, pre, actions);
26186
+ panel.append(block);
26187
+ }
26188
+ for (const download2 of guide.downloads ?? []) {
26189
+ const link = document2.createElement("a");
26190
+ link.className = "settings-command-button settings-command-button--secondary";
26191
+ link.href = download2.url;
26192
+ link.target = "_blank";
26193
+ link.rel = "noopener noreferrer";
26194
+ link.textContent = zh ? "\u4E0B\u8F7D" : "Download";
26195
+ link.setAttribute("aria-label", `${link.textContent} ${download2.label}`);
26196
+ panel.append(link);
26197
+ }
26198
+ if (guide.after) paragraph(guide.after);
26199
+ if (!plugin?.installation && guide.url) {
26200
+ const link = document2.createElement("a");
26201
+ link.href = guide.url;
26202
+ link.target = "_blank";
26203
+ link.rel = "noopener noreferrer";
26204
+ link.textContent = zh ? "\u5B89\u88C5\u8BF4\u660E" : "Installation instructions";
26205
+ panel.append(link);
26206
+ }
26207
+ return panel;
26208
+ }
26209
+
26210
+ // src/settings/harness-launch-controls.ts
26211
+ function createHarnessLaunchControls(document2, messages, agent, settings) {
26212
+ const section = document2.createElement("section");
26213
+ section.className = "settings-harness-launch";
26214
+ section.dataset.harnessLaunch = agent;
26215
+ const label = document2.createElement("label");
26216
+ label.textContent = messages.launchPathLabel;
26217
+ const input = document2.createElement("input");
26218
+ input.type = "text";
26219
+ input.autocomplete = "off";
26220
+ input.spellcheck = false;
26221
+ input.placeholder = messages.locale === "zh-CN" ? "\u5E94\u7528\u5B89\u88C5\u76EE\u5F55\u7684\u7EDD\u5BF9\u8DEF\u5F84" : "Absolute installation directory";
26222
+ input.setAttribute("aria-label", messages.launchPathLabel);
26223
+ label.append(input);
26224
+ const help = document2.createElement("p");
26225
+ 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.";
26226
+ const actions = document2.createElement("div");
26227
+ actions.className = "settings-harness-launch__actions";
26228
+ const save = document2.createElement("button");
26229
+ save.type = "button";
26230
+ save.className = "settings-command-button";
26231
+ save.textContent = messages.launchPathSave;
26232
+ const reset = document2.createElement("button");
26233
+ reset.type = "button";
26234
+ reset.className = "settings-command-button settings-command-button--secondary";
26235
+ reset.textContent = messages.launchPathReset;
26236
+ const status = document2.createElement("p");
26237
+ status.setAttribute("role", "status");
26238
+ status.setAttribute("aria-live", "polite");
26239
+ actions.append(save, reset);
26240
+ section.append(label, help, actions, status);
26241
+ let busy = true;
26242
+ let loaded = false;
26243
+ const controls = () => {
26244
+ input.disabled = busy || !loaded;
26245
+ save.disabled = busy || !loaded || !input.value.trim();
26246
+ reset.disabled = busy || !loaded;
25755
26247
  };
25756
- return {
25757
- createControls(hostId2, panels) {
25758
- const batch = batches.get(hostId2);
25759
- const count3 = eligible(panels).length;
25760
- const button2 = document2.createElement("button");
25761
- button2.type = "button";
25762
- button2.className = "settings-command-button settings-command-button--secondary settings-connection-update-all";
25763
- button2.dataset.connectionAction = "update-all";
25764
- button2.disabled = signal.aborted || Boolean(batch?.running) || !count3;
25765
- button2.title = messages.harnessUpdateAllDescription;
25766
- const label = batch?.running ? `${messages.harnessUpdateAllProgress} ${batch.succeeded + batch.failed}/${batch.total}` : count3 ? `${messages.harnessUpdateAll} (${count3})` : messages.harnessUpdateAll;
25767
- button2.append(createRendererSettingsIcon("download", 15), label);
25768
- button2.addEventListener("click", () => {
25769
- if (!button2.disabled) void start(hostId2, panels);
25770
- });
25771
- const result = document2.createElement("p");
25772
- result.className = "settings-connection-update-result";
25773
- result.setAttribute("role", "status");
25774
- result.hidden = !batch || batch.running;
25775
- if (batch && !batch.running) {
25776
- result.textContent = messages.harnessUpdateAllResult.replace("{succeeded}", String(batch.succeeded)).replace("{failed}", String(batch.failed));
25777
- }
25778
- return { button: button2, result };
26248
+ const show = (value) => {
26249
+ input.value = value.path ?? "";
26250
+ status.textContent = value.restartRequired ? messages.launchPathRestart : value.path ? messages.launchPathSaved : messages.launchPathAutomatic;
26251
+ };
26252
+ const persist = async (value) => {
26253
+ if (busy || !loaded) return;
26254
+ busy = true;
26255
+ controls();
26256
+ status.textContent = messages.launchPathSaving;
26257
+ try {
26258
+ show(await settings.set(value));
26259
+ } catch {
26260
+ status.textContent = messages.launchPathSaveError;
26261
+ } finally {
26262
+ busy = false;
26263
+ controls();
25779
26264
  }
25780
26265
  };
26266
+ input.addEventListener("input", controls);
26267
+ save.addEventListener("click", () => {
26268
+ if (input.value.trim()) void persist(input.value.trim());
26269
+ });
26270
+ reset.addEventListener("click", () => {
26271
+ void persist(null);
26272
+ });
26273
+ controls();
26274
+ status.textContent = messages.launchPathLoading;
26275
+ void settings.get().then((value) => {
26276
+ loaded = true;
26277
+ show(value);
26278
+ }).catch(() => {
26279
+ loaded = true;
26280
+ status.textContent = messages.launchPathLoadError;
26281
+ }).finally(() => {
26282
+ busy = false;
26283
+ controls();
26284
+ });
26285
+ return section;
25781
26286
  }
25782
26287
 
25783
26288
  // src/settings/connections-page.ts
25784
26289
  var CODEXHOST_GITHUB_ISSUES_NEW_URL = "https://github.com/BytePioneer-AI/codex-host/issues/new";
25785
- function connectionStatusLabel(availability, messages, hasError = false) {
25786
- if (availability === "updating") return messages.connectionStatusUpdating;
25787
- if (hasError && availability !== "notInstalled") return messages.connectionStatusError;
25788
- if (availability === "ready") return messages.connectionStatusReady;
25789
- if (availability === "checking") return messages.connectionStatusChecking;
25790
- if (availability === "notInstalled") return messages.connectionStatusNotInstalled;
25791
- if (availability === "unavailable" || availability === "error") {
25792
- return availability === "error" ? messages.connectionStatusError : messages.connectionStatusUnavailable;
25793
- }
25794
- return availability === "installing" ? messages.connectionStatusInstalling : messages.connectionStatusUnsupported;
25795
- }
25796
- function connectionStatusTone(availability, hasError = false) {
25797
- if (availability === "updating") return "checking";
25798
- if (hasError && availability !== "notInstalled") return "failed";
25799
- if (availability === "ready") return "ready";
25800
- if (availability === "checking" || availability === "installing") return "checking";
25801
- if (availability === "notInstalled") return "setup";
25802
- return "failed";
25803
- }
25804
26290
  function diagnosticText(hostId2, item) {
25805
26291
  const error51 = item.error;
25806
26292
  return [
@@ -25896,148 +26382,21 @@ ${error51.stderrTail}`] : []
25896
26382
  tabs.addEventListener("wheel", onWheel, { passive: false });
25897
26383
  const ownerWindow = document2.defaultView;
25898
26384
  ownerWindow?.addEventListener("resize", updateButtons);
25899
- ownerWindow?.setTimeout(updateButtons, 0);
25900
- updateButtons();
25901
- return () => {
25902
- left.removeEventListener("click", onLeft);
25903
- right.removeEventListener("click", onRight);
25904
- tabs.removeEventListener("scroll", updateButtons);
25905
- tabs.removeEventListener("wheel", onWheel);
25906
- ownerWindow?.removeEventListener("resize", updateButtons);
26385
+ const refreshLayout = () => {
26386
+ ownerWindow?.setTimeout(updateButtons, 0);
26387
+ updateButtons();
26388
+ };
26389
+ refreshLayout();
26390
+ return {
26391
+ update: refreshLayout,
26392
+ dispose() {
26393
+ left.removeEventListener("click", onLeft);
26394
+ right.removeEventListener("click", onRight);
26395
+ tabs.removeEventListener("scroll", updateButtons);
26396
+ tabs.removeEventListener("wheel", onWheel);
26397
+ ownerWindow?.removeEventListener("resize", updateButtons);
26398
+ }
25907
26399
  };
25908
- }
25909
- function createConnectionIdentityIcon(document2, item, size) {
25910
- const container = document2.createElement("span");
25911
- container.className = item.agentSnapshot ? "settings-connection-row__mark settings-connection-row__mark--logo" : "settings-connection-row__mark";
25912
- container.setAttribute("aria-hidden", "true");
25913
- if (item.agentSnapshot) {
25914
- container.append(
25915
- createRendererAgentIcon(item.agentSnapshot.agent, size, document2, item.agentSnapshot.plugin)
25916
- );
25917
- } else {
25918
- container.textContent = "CH";
25919
- }
25920
- return container;
25921
- }
25922
- function createConnectionRow(document2, item, messages, selected, select, group = null) {
25923
- const row = document2.createElement("div");
25924
- row.className = "settings-connection-row";
25925
- row.dataset.connectionItem = item.key;
25926
- row.dataset.connectionSelected = String(selected);
25927
- row.tabIndex = selected ? 0 : -1;
25928
- row.setAttribute("role", "row");
25929
- const identity2 = document2.createElement("div");
25930
- identity2.className = "settings-connection-row__identity";
25931
- identity2.setAttribute("role", "cell");
25932
- if (group) {
25933
- const handle = document2.createElement("span");
25934
- handle.className = "settings-connection-row__handle";
25935
- handle.setAttribute("aria-hidden", "true");
25936
- handle.title = group.dragHandleTitle;
25937
- handle.append(createRendererSettingsIcon("grip-vertical", 15));
25938
- identity2.append(handle);
25939
- }
25940
- const label = document2.createElement("strong");
25941
- label.textContent = item.name;
25942
- identity2.append(createConnectionIdentityIcon(document2, item, 19), label);
25943
- const status = document2.createElement("span");
25944
- status.className = "settings-connection-row__status";
25945
- status.dataset.connectionTone = connectionStatusTone(item.availability, item.error !== null);
25946
- status.setAttribute("role", "cell");
25947
- status.textContent = item.error?.code === "authenticationRequired" ? messages.connectionLoginRequired : item.error?.code === "configurationRequired" ? messages.connectionConfigurationRequired : connectionStatusLabel(item.availability, messages, item.error !== null);
25948
- const version2 = item.version;
25949
- const action = document2.createElement("div");
25950
- action.className = "settings-connection-row__action";
25951
- action.setAttribute("role", "cell");
25952
- if (item.agentSnapshot?.availability === "notInstalled" && item.install) {
25953
- const install = document2.createElement("button");
25954
- install.type = "button";
25955
- install.className = "settings-connection-install-link";
25956
- install.addEventListener("click", (event) => {
25957
- event.stopPropagation();
25958
- select();
25959
- item.install?.();
25960
- });
25961
- install.disabled = item.availability === "installing" || item.availability === "checking";
25962
- const installLabel = messages.connectionInstall;
25963
- install.setAttribute("aria-label", `${installLabel}: ${item.name}`);
25964
- install.title = installLabel;
25965
- install.append(createRendererSettingsIcon("download", 17));
25966
- action.append(install);
25967
- } else if (item.error) {
25968
- const viewError = document2.createElement("button");
25969
- viewError.type = "button";
25970
- viewError.className = "settings-connection-view-error";
25971
- viewError.textContent = messages.connectionViewError;
25972
- viewError.addEventListener("click", (event) => {
25973
- event.stopPropagation();
25974
- select();
25975
- });
25976
- action.append(viewError);
25977
- }
25978
- if (version2?.state?.updateAvailable && !version2.updating) {
25979
- const available = document2.createElement("span");
25980
- available.className = "settings-connection-version-available";
25981
- available.textContent = messages.harnessVersionAvailable;
25982
- available.title = `${messages.harnessVersionCurrent}: ${version2.state.currentVersion ?? "\u2014"}
25983
- ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages.harnessVersion)}`;
25984
- action.append(available);
25985
- }
25986
- if (version2?.state?.updateAvailable && version2.state.canUpdate) {
25987
- const update = document2.createElement("button");
25988
- update.type = "button";
25989
- update.className = "settings-connection-install-link";
25990
- update.dataset.connectionAction = "update";
25991
- update.disabled = version2.updating;
25992
- update.title = messages.harnessVersionUpdate;
25993
- update.setAttribute("aria-label", `${messages.harnessVersionUpdate}: ${item.name}`);
25994
- update.append(createRendererSettingsIcon("download", 17));
25995
- update.addEventListener("click", (event) => {
25996
- event.stopPropagation();
25997
- if (update.disabled) return;
25998
- void version2.update();
25999
- select();
26000
- });
26001
- action.append(update);
26002
- }
26003
- if (group) {
26004
- const toggle = document2.createElement("button");
26005
- toggle.type = "button";
26006
- toggle.disabled = group.disabled;
26007
- toggle.className = "settings-connection-row__group-toggle";
26008
- toggle.title = group.moveLabel;
26009
- toggle.setAttribute("aria-label", group.moveLabel);
26010
- toggle.append(
26011
- createRendererSettingsIcon(group.section === "main" ? "chevron-down" : "chevron-up", 15)
26012
- );
26013
- toggle.addEventListener("click", (event) => {
26014
- event.stopPropagation();
26015
- group.toggleSection();
26016
- });
26017
- action.append(toggle);
26018
- }
26019
- row.addEventListener("click", (event) => {
26020
- const target2 = event.target;
26021
- if (target2?.closest?.("a")) return;
26022
- select();
26023
- });
26024
- row.addEventListener("keydown", (event) => {
26025
- if (event.target?.closest?.("button, a")) return;
26026
- if (event.key !== "Enter" && event.key !== " ") return;
26027
- event.preventDefault();
26028
- select();
26029
- });
26030
- if (group) {
26031
- row.draggable = !group.disabled;
26032
- row.dataset.connectionGroupSection = group.section;
26033
- row.addEventListener("dragstart", group.onDragStart);
26034
- row.addEventListener("dragover", group.onDragOver);
26035
- row.addEventListener("dragleave", group.onDragLeave);
26036
- row.addEventListener("drop", group.onDrop);
26037
- row.addEventListener("dragend", group.onDragEnd);
26038
- }
26039
- row.append(identity2, status, action);
26040
- return row;
26041
26400
  }
26042
26401
  function createInspectorHeader(document2, item, messages) {
26043
26402
  const header = document2.createElement("header");
@@ -26067,6 +26426,29 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26067
26426
  header.append(identity2, status);
26068
26427
  return header;
26069
26428
  }
26429
+ function inspectorRenderSignature(hostId2, item, messages, diagnostics) {
26430
+ const plugin = item.agentSnapshot?.plugin;
26431
+ const notice = plugin?.notice ? plugin.notice[messages.locale] ?? plugin.notice.en : "";
26432
+ const websiteUrl = plugin?.links?.website ?? plugin?.links?.documentation ?? "";
26433
+ const hasLaunchControls = hostId2 === "local" && Boolean(item.agentSnapshot?.agent) && Boolean(plugin?.launchCommand) && Boolean(diagnostics?.getLaunchSettings && diagnostics?.setLaunchSettings);
26434
+ return JSON.stringify([
26435
+ hostId2,
26436
+ item.key,
26437
+ item.name,
26438
+ item.availability,
26439
+ item.agentSnapshot?.availability ?? null,
26440
+ String(plugin?.icon ?? ""),
26441
+ String(plugin?.iconStyle ?? ""),
26442
+ websiteUrl,
26443
+ notice,
26444
+ item.installError ?? "",
26445
+ Boolean(item.install),
26446
+ plugin?.installation ?? null,
26447
+ Boolean(item.openWebUi),
26448
+ hasLaunchControls,
26449
+ item.error ? diagnosticText(hostId2, item) : ""
26450
+ ]);
26451
+ }
26070
26452
  function renderConnectionInspector(document2, inspector, item, hostId2, messages, diagnostics, existingLaunchControls, refresh) {
26071
26453
  inspector.replaceChildren(createInspectorHeader(document2, item, messages));
26072
26454
  const body = document2.createElement("div");
@@ -26229,11 +26611,10 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26229
26611
  ];
26230
26612
  }
26231
26613
  var pendingFocusAgent = null;
26232
- function createGroupDivider(document2, messages, count3) {
26614
+ function createGroupDivider(document2) {
26233
26615
  const divider = document2.createElement("div");
26234
26616
  divider.className = "settings-connection-group-divider";
26235
26617
  divider.setAttribute("role", "presentation");
26236
- divider.textContent = `${messages.connectionGroupMoreLabel} (${count3})`;
26237
26618
  return divider;
26238
26619
  }
26239
26620
  function createGroupMoreHint(document2, messages) {
@@ -26286,11 +26667,13 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26286
26667
  context.content.append(header, syncMessage, content);
26287
26668
  let pending = false;
26288
26669
  let selectedHostId = null;
26670
+ let renderedHostId = null;
26289
26671
  let selectedItemKey = null;
26290
26672
  let launchControls = null;
26673
+ let renderedInspector = null;
26291
26674
  const hostNames = /* @__PURE__ */ new Map();
26675
+ const knownNotInstalled = /* @__PURE__ */ new Map();
26292
26676
  let latestSnapshot = null;
26293
- let disposeHostScroller = () => void 0;
26294
26677
  let disposed = false;
26295
26678
  let renderQueued = false;
26296
26679
  let renderFrame = null;
@@ -26324,7 +26707,99 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26324
26707
  scheduleRender
26325
26708
  );
26326
26709
  const installs = diagnostics ? harnessInstallStore(diagnostics) : null;
26327
- const updates = createConnectionUpdates(document2, messages, context.signal, scheduleRender);
26710
+ const updates = createConnectionUpdates(
26711
+ document2,
26712
+ messages,
26713
+ context.signal,
26714
+ scheduleRender,
26715
+ diagnostics
26716
+ );
26717
+ const panelId = "codexhost-settings-connection-host-panel";
26718
+ const empty = document2.createElement("div");
26719
+ empty.className = "settings-empty";
26720
+ empty.textContent = messages.connectionNoRuntime;
26721
+ const layout = document2.createElement("div");
26722
+ layout.className = "settings-connections-layout";
26723
+ const list = document2.createElement("section");
26724
+ list.className = "settings-connection-list";
26725
+ const hostStrip = document2.createElement("div");
26726
+ hostStrip.className = "settings-connection-host-strip";
26727
+ const scrollLeft = createHostScrollButton(document2, "left", messages);
26728
+ const tabs = document2.createElement("div");
26729
+ tabs.className = "settings-connection-host-tabs";
26730
+ tabs.setAttribute("role", "tablist");
26731
+ tabs.setAttribute("aria-label", messages.connectionHosts);
26732
+ const scrollRight = createHostScrollButton(document2, "right", messages);
26733
+ hostStrip.append(scrollLeft, tabs, scrollRight);
26734
+ const updateControls = updates.createControls("local", []);
26735
+ const hostHeader = document2.createElement("div");
26736
+ hostHeader.className = "settings-connection-host-header";
26737
+ hostHeader.append(hostStrip, updateControls.button);
26738
+ const tableHeader = document2.createElement("div");
26739
+ tableHeader.className = "settings-connection-table-header";
26740
+ tableHeader.setAttribute("role", "row");
26741
+ const componentHeading = document2.createElement("span");
26742
+ componentHeading.textContent = messages.connectionComponent;
26743
+ componentHeading.setAttribute("role", "columnheader");
26744
+ const statusHeading = document2.createElement("span");
26745
+ statusHeading.textContent = messages.connectionStatus;
26746
+ statusHeading.setAttribute("role", "columnheader");
26747
+ const actionHeading = document2.createElement("span");
26748
+ actionHeading.setAttribute("aria-hidden", "true");
26749
+ tableHeader.append(componentHeading, statusHeading, actionHeading);
26750
+ const rows = document2.createElement("div");
26751
+ rows.className = "settings-connection-rows";
26752
+ rows.id = panelId;
26753
+ rows.setAttribute("role", "rowgroup");
26754
+ list.append(hostHeader, updateControls.result, tableHeader, rows);
26755
+ const inspector = document2.createElement("aside");
26756
+ inspector.className = "settings-connection-inspector";
26757
+ inspector.setAttribute("aria-live", "polite");
26758
+ layout.append(list, inspector);
26759
+ const hostScroller = configureHostScroller(
26760
+ document2,
26761
+ hostStrip,
26762
+ tabs,
26763
+ scrollLeft,
26764
+ scrollRight
26765
+ );
26766
+ const hostTabElements = /* @__PURE__ */ new Map();
26767
+ const hostRowViews = /* @__PURE__ */ new Map();
26768
+ const groupDivider = createGroupDivider(document2);
26769
+ const moreHint = createGroupMoreHint(document2, messages);
26770
+ const moreZone = document2.createElement("div");
26771
+ moreZone.className = "settings-connection-group-more";
26772
+ moreZone.setAttribute("role", "presentation");
26773
+ const resetButton = createGroupResetButton(document2, messages, () => {
26774
+ groupPreference.resetToDefault();
26775
+ });
26776
+ let draggingAgent = null;
26777
+ let currentCatalog = [];
26778
+ let currentMainEntries = [];
26779
+ let currentMoreEntries = [];
26780
+ let currentHostRows = /* @__PURE__ */ new Map();
26781
+ const clearDropIndicators = () => {
26782
+ for (const view of currentHostRows.values()) {
26783
+ view.element.dataset.connectionDropIndicator = "";
26784
+ }
26785
+ moreZone.dataset.connectionDragOver = "false";
26786
+ };
26787
+ moreZone.addEventListener("dragover", (event) => {
26788
+ if (!draggingAgent) return;
26789
+ event.preventDefault();
26790
+ moreZone.dataset.connectionDragOver = "true";
26791
+ });
26792
+ moreZone.addEventListener("dragleave", () => {
26793
+ moreZone.dataset.connectionDragOver = "false";
26794
+ });
26795
+ moreZone.addEventListener("drop", (event) => {
26796
+ event.preventDefault();
26797
+ moreZone.dataset.connectionDragOver = "false";
26798
+ if (!draggingAgent) return;
26799
+ groupPreference.moveAgent(draggingAgent, "more", null, currentCatalog);
26800
+ draggingAgent = null;
26801
+ clearDropIndicators();
26802
+ });
26328
26803
  const runRefresh = () => {
26329
26804
  if (pending || !diagnostics) return;
26330
26805
  pending = true;
@@ -26337,6 +26812,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26337
26812
  success() {
26338
26813
  installs?.clearErrors();
26339
26814
  pending = false;
26815
+ renderedInspector = null;
26340
26816
  refresh.disabled = false;
26341
26817
  refresh.replaceChildren(
26342
26818
  createRendererSettingsIcon("diagnose", 16),
@@ -26346,6 +26822,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26346
26822
  },
26347
26823
  failure(error51) {
26348
26824
  pending = false;
26825
+ renderedInspector = null;
26349
26826
  refresh.disabled = false;
26350
26827
  refresh.replaceChildren(
26351
26828
  createRendererSettingsIcon("diagnose", 16),
@@ -26371,97 +26848,111 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26371
26848
  }
26372
26849
  });
26373
26850
  };
26851
+ const syncSelectedInspector = (hostId2, item) => {
26852
+ const currentDiagnostics = getDiagnostics();
26853
+ const signature = inspectorRenderSignature(hostId2, item, messages, currentDiagnostics);
26854
+ const versionElement = item.version?.element ?? null;
26855
+ if (renderedInspector?.signature === signature && renderedInspector.versionElement === versionElement) {
26856
+ return;
26857
+ }
26858
+ const existing = launchControls?.hostId === hostId2 && launchControls.itemKey === item.key ? launchControls.element : null;
26859
+ const element = renderConnectionInspector(
26860
+ document2,
26861
+ inspector,
26862
+ item,
26863
+ hostId2,
26864
+ messages,
26865
+ currentDiagnostics,
26866
+ existing,
26867
+ runRefresh
26868
+ );
26869
+ launchControls = { hostId: hostId2, itemKey: item.key, element };
26870
+ if (versionElement) inspector.append(versionElement);
26871
+ renderedInspector = { signature, versionElement };
26872
+ };
26374
26873
  const render = (snapshot) => {
26375
26874
  const syncStatus = groupPreference.syncStatus();
26376
26875
  const groupDisabled = syncStatus === "loading" || syncStatus === "saving";
26377
26876
  syncMessage.hidden = syncStatus === "ready";
26378
26877
  syncMessage.textContent = syncStatus === "error" ? messages.connectionGroupSyncFailed : syncStatus === "saving" ? messages.connectionGroupSaving : messages.connectionGroupLoading;
26379
26878
  latestSnapshot = snapshot;
26380
- disposeHostScroller();
26381
- disposeHostScroller = () => void 0;
26382
26879
  if (!snapshot) {
26383
- const empty = document2.createElement("div");
26384
- empty.className = "settings-empty";
26385
- empty.textContent = messages.connectionNoRuntime;
26386
- content.replaceChildren(empty);
26880
+ renderedHostId = null;
26881
+ renderedInspector = null;
26882
+ reconcileElementChildren(content, [empty]);
26387
26883
  return;
26388
26884
  }
26389
26885
  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];
26390
26886
  if (!selectedHost) return;
26391
26887
  selectedHostId = selectedHost.hostId;
26392
- const layout = document2.createElement("div");
26393
- layout.className = "settings-connections-layout";
26394
- const list = document2.createElement("section");
26395
- list.className = "settings-connection-list";
26396
- const hostStrip = document2.createElement("div");
26397
- hostStrip.className = "settings-connection-host-strip";
26398
- const scrollLeft = createHostScrollButton(document2, "left", messages);
26399
- const tabs = document2.createElement("div");
26400
- tabs.className = "settings-connection-host-tabs";
26401
- tabs.setAttribute("role", "tablist");
26402
- tabs.setAttribute("aria-label", messages.connectionHosts);
26403
- const scrollRight = createHostScrollButton(document2, "right", messages);
26404
- const panelId = "codexhost-settings-connection-host-panel";
26405
- snapshot.hosts.forEach((host, index) => {
26406
- const tab = document2.createElement("button");
26407
- tab.type = "button";
26408
- tab.className = "settings-connection-host-tab";
26409
- tab.dataset.connectionHostTab = host.hostId;
26410
- tab.dataset.connectionHostActive = String(host.active);
26411
- tab.setAttribute("role", "tab");
26412
- tab.setAttribute("aria-controls", panelId);
26413
- tab.setAttribute("aria-selected", String(host.hostId === selectedHost.hostId));
26414
- tab.tabIndex = host.hostId === selectedHost.hostId ? 0 : -1;
26888
+ const layoutFirstMount = content.children[0] !== layout;
26889
+ reconcileElementChildren(content, [layout]);
26890
+ let tabsChanged = tabs.children.length !== snapshot.hosts.length;
26891
+ const nextTabs = snapshot.hosts.map((host) => {
26892
+ let tab = hostTabElements.get(host.hostId);
26893
+ if (!tab) {
26894
+ tab = document2.createElement("button");
26895
+ tab.type = "button";
26896
+ tab.className = "settings-connection-host-tab";
26897
+ tab.dataset.connectionHostTab = host.hostId;
26898
+ tab.setAttribute("role", "tab");
26899
+ tab.setAttribute("aria-controls", panelId);
26900
+ tab.addEventListener("click", () => {
26901
+ selectedHostId = host.hostId;
26902
+ render(latestSnapshot);
26903
+ });
26904
+ tab.addEventListener("keydown", (event) => {
26905
+ if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
26906
+ event.preventDefault();
26907
+ const hosts = latestSnapshot?.hosts ?? [];
26908
+ const index = hosts.findIndex((candidate) => candidate.hostId === host.hostId);
26909
+ if (index < 0) return;
26910
+ const direction = event.key === "ArrowRight" ? 1 : -1;
26911
+ const next = hosts[(index + direction + hosts.length) % hosts.length];
26912
+ if (!next) return;
26913
+ selectedHostId = next.hostId;
26914
+ render(latestSnapshot);
26915
+ hostTabElements.get(next.hostId)?.focus();
26916
+ });
26917
+ hostTabElements.set(host.hostId, tab);
26918
+ tabsChanged = true;
26919
+ }
26920
+ const isSelected = host.hostId === selectedHost.hostId;
26921
+ const activeValue = String(host.active);
26922
+ if (tab.dataset.connectionHostActive !== activeValue) {
26923
+ tab.dataset.connectionHostActive = activeValue;
26924
+ }
26925
+ const selectedValue = String(isSelected);
26926
+ if (tab.getAttribute("aria-selected") !== selectedValue) {
26927
+ tab.setAttribute("aria-selected", selectedValue);
26928
+ }
26929
+ const nextTabIndex = isSelected ? 0 : -1;
26930
+ if (tab.tabIndex !== nextTabIndex) {
26931
+ tab.tabIndex = nextTabIndex;
26932
+ }
26415
26933
  const hostName = hostNames.get(host.hostId) || connectionHostName(host.hostId, messages);
26416
- tab.textContent = hostName;
26417
- tab.title = host.active ? `${hostName} \xB7 ${messages.connectionActiveHost}` : hostName;
26418
- tab.addEventListener("click", () => {
26419
- selectedHostId = host.hostId;
26420
- render(latestSnapshot);
26421
- });
26422
- tab.addEventListener("keydown", (event) => {
26423
- if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
26424
- event.preventDefault();
26425
- const direction = event.key === "ArrowRight" ? 1 : -1;
26426
- const next = snapshot.hosts[(index + direction + snapshot.hosts.length) % snapshot.hosts.length];
26427
- if (!next) return;
26428
- selectedHostId = next.hostId;
26429
- render(latestSnapshot);
26430
- const nextTab = [
26431
- ...content.querySelectorAll("[data-connection-host-tab]")
26432
- ].find((candidate) => candidate.dataset.connectionHostTab === next.hostId);
26433
- nextTab?.focus();
26434
- });
26435
- tabs.append(tab);
26934
+ if (tab.textContent !== hostName) {
26935
+ tab.textContent = hostName;
26936
+ tabsChanged = true;
26937
+ }
26938
+ const tabTitle = host.active ? `${hostName} \xB7 ${messages.connectionActiveHost}` : hostName;
26939
+ if (tab.title !== tabTitle) {
26940
+ tab.title = tabTitle;
26941
+ }
26942
+ return tab;
26436
26943
  });
26437
- hostStrip.append(scrollLeft, tabs, scrollRight);
26438
- const tableHeader = document2.createElement("div");
26439
- tableHeader.className = "settings-connection-table-header";
26440
- tableHeader.setAttribute("role", "row");
26441
- const componentHeading = document2.createElement("span");
26442
- componentHeading.textContent = messages.connectionComponent;
26443
- componentHeading.setAttribute("role", "columnheader");
26444
- const statusHeading = document2.createElement("span");
26445
- statusHeading.textContent = messages.connectionStatus;
26446
- statusHeading.setAttribute("role", "columnheader");
26447
- const actionHeading = document2.createElement("span");
26448
- actionHeading.setAttribute("aria-hidden", "true");
26449
- tableHeader.append(componentHeading, statusHeading, actionHeading);
26450
- const rows = document2.createElement("div");
26451
- rows.className = "settings-connection-rows";
26452
- rows.id = panelId;
26453
- rows.dataset.connectionHost = selectedHost.hostId;
26454
- rows.setAttribute("role", "rowgroup");
26455
- const inspector = document2.createElement("aside");
26456
- inspector.className = "settings-connection-inspector";
26457
- inspector.setAttribute("aria-live", "polite");
26944
+ reconcileElementChildren(tabs, nextTabs);
26945
+ if (rows.dataset.connectionHost !== selectedHost.hostId) {
26946
+ rows.dataset.connectionHost = selectedHost.hostId;
26947
+ }
26458
26948
  const items = connectionItems(snapshot, selectedHost, messages, diagnostics).map(
26459
26949
  (item) => {
26460
26950
  const agent = item.agentSnapshot?.agent;
26461
26951
  if (!agent) return item;
26462
26952
  const state = installs?.get(selectedHost.hostId, agent);
26463
26953
  const availability = state?.status ?? item.availability;
26464
- const version2 = item.agentSnapshot?.availability !== "notInstalled" && availability !== "installing" && availability !== "checking" ? versions.get(selectedHost.hostId, agent) : void 0;
26954
+ const updating = versions.isUpdating(selectedHost.hostId, agent);
26955
+ const version2 = updating || item.agentSnapshot?.availability !== "notInstalled" && availability !== "installing" && availability !== "checking" ? versions.get(selectedHost.hostId, agent) : void 0;
26465
26956
  return {
26466
26957
  ...item,
26467
26958
  ...state ? { availability: state.status } : {},
@@ -26483,66 +26974,66 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26483
26974
  (item) => item.agentSnapshot?.availability === "notInstalled" || item.error !== null
26484
26975
  )?.key ?? items[0]?.key ?? null;
26485
26976
  }
26486
- const rowElements = /* @__PURE__ */ new Map();
26977
+ let hostRows = hostRowViews.get(selectedHost.hostId);
26978
+ if (!hostRows) {
26979
+ hostRows = /* @__PURE__ */ new Map();
26980
+ hostRowViews.set(selectedHost.hostId, hostRows);
26981
+ }
26982
+ currentHostRows = hostRows;
26487
26983
  const selectItem = (item) => {
26488
26984
  selectedItemKey = item.key;
26489
- for (const [key, row] of rowElements) {
26490
- const selected = key === item.key;
26491
- row.dataset.connectionSelected = String(selected);
26492
- row.tabIndex = selected ? 0 : -1;
26985
+ for (const [key, view] of currentHostRows) {
26986
+ view.setSelected(key === item.key);
26493
26987
  }
26494
- const existing = launchControls?.hostId === selectedHost.hostId && launchControls.itemKey === item.key ? launchControls.element : null;
26495
- const element = renderConnectionInspector(
26496
- document2,
26497
- inspector,
26498
- item,
26499
- selectedHost.hostId,
26500
- messages,
26501
- getDiagnostics(),
26502
- existing,
26503
- runRefresh
26504
- );
26505
- launchControls = { hostId: selectedHost.hostId, itemKey: item.key, element };
26506
- if (item.version) inspector.append(item.version.element);
26988
+ syncSelectedInspector(selectedHost.hostId, item);
26507
26989
  };
26508
- const pinnedItem = items.find((item) => item.key === "renderer-adapter");
26509
- if (pinnedItem) {
26510
- const row = createConnectionRow(
26511
- document2,
26990
+ const ensureRowView = (key, groupable) => {
26991
+ let view = hostRows.get(key);
26992
+ if (!view) {
26993
+ view = createConnectionRowView(document2, messages, groupable);
26994
+ hostRows.set(key, view);
26995
+ }
26996
+ return view;
26997
+ };
26998
+ const activeKeys = /* @__PURE__ */ new Set();
26999
+ const nextRowChildren = [];
27000
+ const pinnedItems = items.filter((item) => item.agentSnapshot === void 0);
27001
+ for (const pinnedItem of pinnedItems) {
27002
+ activeKeys.add(pinnedItem.key);
27003
+ const view = ensureRowView(pinnedItem.key, false);
27004
+ view.update(
26512
27005
  pinnedItem,
26513
- messages,
26514
27006
  pinnedItem.key === selectedItemKey,
26515
- () => selectItem(pinnedItem)
27007
+ () => selectItem(pinnedItem),
27008
+ null
26516
27009
  );
26517
- rowElements.set(pinnedItem.key, row);
26518
- rows.append(row);
27010
+ nextRowChildren.push(view.element);
26519
27011
  }
26520
27012
  const groupableItems = items.filter(
26521
27013
  (item) => item.agentSnapshot !== void 0
26522
27014
  );
26523
27015
  const agentByKey = new Map(groupableItems.map((item) => [item.key, item]));
26524
- const catalog = groupableItems.map((item) => ({ id: item.key, name: item.name }));
26525
- const preferenceOrder = groupPreference.list(
26526
- new Set(
26527
- groupableItems.filter((item) => item.agentSnapshot.availability === "notInstalled").map((item) => item.agentSnapshot.agent)
26528
- ),
26529
- catalog
26530
- ).filter((entry) => agentByKey.has(entry.agent));
26531
- const mainEntries = preferenceOrder.filter((entry) => entry.section === "main");
26532
- const moreEntries = preferenceOrder.filter((entry) => entry.section === "more");
27016
+ currentCatalog = groupableItems.map((item) => ({ id: item.key, name: item.name }));
27017
+ const notInstalledAgents = /* @__PURE__ */ new Set();
27018
+ for (const item of groupableItems) {
27019
+ const agent = item.agentSnapshot.agent;
27020
+ const stateKey = `${selectedHost.hostId}:${agent}`;
27021
+ if (item.agentSnapshot.availability !== "checking") {
27022
+ knownNotInstalled.set(stateKey, item.agentSnapshot.availability === "notInstalled");
27023
+ }
27024
+ const isNotInstalled = item.agentSnapshot.availability === "checking" ? knownNotInstalled.get(stateKey) ?? false : item.agentSnapshot.availability === "notInstalled";
27025
+ if (isNotInstalled) notInstalledAgents.add(agent);
27026
+ }
27027
+ const preferenceOrder = groupPreference.list(notInstalledAgents, currentCatalog).filter((entry) => agentByKey.has(entry.agent));
27028
+ currentMainEntries = preferenceOrder.filter((entry) => entry.section === "main");
27029
+ currentMoreEntries = preferenceOrder.filter((entry) => entry.section === "more");
26533
27030
  const nextInSection = (section, agent) => {
26534
- const list2 = section === "main" ? mainEntries : moreEntries;
26535
- const index = list2.findIndex((entry) => entry.agent === agent);
26536
- return index >= 0 ? list2[index + 1]?.agent ?? null : null;
26537
- };
26538
- let draggingAgent = null;
26539
- let moreZone = null;
26540
- const clearDropIndicators = () => {
26541
- for (const row of rowElements.values()) row.dataset.connectionDropIndicator = "";
26542
- if (moreZone) moreZone.dataset.connectionDragOver = "false";
27031
+ const sectionEntries = section === "main" ? currentMainEntries : currentMoreEntries;
27032
+ const index = sectionEntries.findIndex((entry) => entry.agent === agent);
27033
+ return index >= 0 ? sectionEntries[index + 1]?.agent ?? null : null;
26543
27034
  };
26544
27035
  const dropTargetSection = (agent, event) => {
26545
- const row = rowElements.get(agent);
27036
+ const row = currentHostRows.get(agent)?.element;
26546
27037
  const rect = row && typeof row.getBoundingClientRect === "function" ? row.getBoundingClientRect() : null;
26547
27038
  const before = rect ? event.clientY - rect.top < rect.height / 2 : true;
26548
27039
  const section = row?.dataset.connectionGroupSection ?? "main";
@@ -26554,7 +27045,12 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26554
27045
  moveLabel: section === "main" ? messages.connectionGroupMoveToMore : messages.connectionGroupMoveToMain,
26555
27046
  dragHandleTitle: messages.connectionGroupDragHandle,
26556
27047
  toggleSection() {
26557
- groupPreference.moveAgent(agent, section === "main" ? "more" : "main", null, catalog);
27048
+ groupPreference.moveAgent(
27049
+ agent,
27050
+ section === "main" ? "more" : "main",
27051
+ null,
27052
+ currentCatalog
27053
+ );
26558
27054
  },
26559
27055
  onDragStart(event) {
26560
27056
  if (groupDisabled) {
@@ -26564,127 +27060,107 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26564
27060
  draggingAgent = agent;
26565
27061
  event.dataTransfer?.setData("text/plain", agent);
26566
27062
  if (event.dataTransfer) event.dataTransfer.effectAllowed = "move";
26567
- const row = rowElements.get(agent);
27063
+ const row = currentHostRows.get(agent)?.element;
26568
27064
  if (row) row.dataset.connectionDragging = "true";
26569
27065
  },
26570
27066
  onDragOver(event) {
26571
27067
  if (!draggingAgent || draggingAgent === agent) return;
26572
27068
  event.preventDefault();
26573
- const row = rowElements.get(agent);
27069
+ const row = currentHostRows.get(agent)?.element;
26574
27070
  if (!row) return;
26575
27071
  const { before } = dropTargetSection(agent, event);
26576
27072
  clearDropIndicators();
26577
27073
  row.dataset.connectionDropIndicator = before ? "before" : "after";
26578
27074
  },
26579
27075
  onDragLeave() {
26580
- const row = rowElements.get(agent);
27076
+ const row = currentHostRows.get(agent)?.element;
26581
27077
  if (row) row.dataset.connectionDropIndicator = "";
26582
27078
  },
26583
27079
  onDrop(event) {
26584
27080
  event.preventDefault();
26585
27081
  if (!draggingAgent) return;
26586
27082
  const { beforeAgent } = dropTargetSection(agent, event);
26587
- groupPreference.moveAgent(draggingAgent, section, beforeAgent, catalog);
27083
+ groupPreference.moveAgent(draggingAgent, section, beforeAgent, currentCatalog);
26588
27084
  draggingAgent = null;
26589
27085
  clearDropIndicators();
26590
27086
  },
26591
27087
  onDragEnd() {
26592
27088
  draggingAgent = null;
26593
- const row = rowElements.get(agent);
27089
+ const row = currentHostRows.get(agent)?.element;
26594
27090
  if (row) row.dataset.connectionDragging = "false";
26595
27091
  clearDropIndicators();
27092
+ scheduleRender();
26596
27093
  }
26597
27094
  });
26598
- const appendGroupRow = (agent, section) => {
26599
- const item = agentByKey.get(agent);
26600
- if (!item) return;
26601
- const row = createConnectionRow(
26602
- document2,
27095
+ for (const entry of currentMainEntries) {
27096
+ const item = agentByKey.get(entry.agent);
27097
+ if (!item) continue;
27098
+ activeKeys.add(item.key);
27099
+ const view = ensureRowView(item.key, true);
27100
+ view.update(
26603
27101
  item,
26604
- messages,
26605
27102
  item.key === selectedItemKey,
26606
27103
  () => selectItem(item),
26607
- createGroupController(agent, section)
27104
+ createGroupController(entry.agent, "main")
26608
27105
  );
26609
- rowElements.set(item.key, row);
26610
- rows.append(row);
26611
- };
26612
- for (const entry of mainEntries) appendGroupRow(entry.agent, "main");
27106
+ nextRowChildren.push(view.element);
27107
+ }
26613
27108
  if (groupableItems.length > 0) {
26614
- rows.append(createGroupDivider(document2, messages, moreEntries.length));
26615
- const zone = document2.createElement("div");
26616
- moreZone = zone;
26617
- zone.className = "settings-connection-group-more";
26618
- zone.setAttribute("role", "presentation");
26619
- zone.addEventListener("dragover", (event) => {
26620
- if (!draggingAgent) return;
26621
- event.preventDefault();
26622
- zone.dataset.connectionDragOver = "true";
26623
- });
26624
- zone.addEventListener("dragleave", () => {
26625
- zone.dataset.connectionDragOver = "false";
26626
- });
26627
- zone.addEventListener("drop", (event) => {
26628
- event.preventDefault();
26629
- zone.dataset.connectionDragOver = "false";
26630
- if (!draggingAgent) return;
26631
- groupPreference.moveAgent(draggingAgent, "more", null, catalog);
26632
- draggingAgent = null;
26633
- clearDropIndicators();
26634
- });
26635
- if (moreEntries.length === 0) {
26636
- zone.append(createGroupMoreHint(document2, messages));
27109
+ const dividerText = `${messages.connectionGroupMoreLabel} (${currentMoreEntries.length})`;
27110
+ if (groupDivider.textContent !== dividerText) {
27111
+ groupDivider.textContent = dividerText;
27112
+ }
27113
+ nextRowChildren.push(groupDivider);
27114
+ const nextMoreChildren = [];
27115
+ if (currentMoreEntries.length === 0) {
27116
+ nextMoreChildren.push(moreHint);
26637
27117
  } else {
26638
- for (const entry of moreEntries) {
27118
+ for (const entry of currentMoreEntries) {
26639
27119
  const item = agentByKey.get(entry.agent);
26640
27120
  if (!item) continue;
26641
- const row = createConnectionRow(
26642
- document2,
27121
+ activeKeys.add(item.key);
27122
+ const view = ensureRowView(item.key, true);
27123
+ view.update(
26643
27124
  item,
26644
- messages,
26645
27125
  item.key === selectedItemKey,
26646
27126
  () => selectItem(item),
26647
27127
  createGroupController(entry.agent, "more")
26648
27128
  );
26649
- rowElements.set(item.key, row);
26650
- zone.append(row);
27129
+ nextMoreChildren.push(view.element);
26651
27130
  }
26652
27131
  }
26653
- rows.append(zone);
26654
- const reset = createGroupResetButton(document2, messages, () => {
26655
- groupPreference.resetToDefault();
26656
- });
26657
- reset.disabled = groupDisabled;
26658
- rows.append(reset);
27132
+ if (!draggingAgent || renderedHostId !== selectedHost.hostId) {
27133
+ reconcileElementChildren(moreZone, nextMoreChildren);
27134
+ }
27135
+ nextRowChildren.push(moreZone);
27136
+ resetButton.disabled = groupDisabled;
27137
+ nextRowChildren.push(resetButton);
27138
+ }
27139
+ for (const key of hostRows.keys()) {
27140
+ if (!activeKeys.has(key)) hostRows.delete(key);
27141
+ }
27142
+ if (!draggingAgent || renderedHostId !== selectedHost.hostId) {
27143
+ reconcileElementChildren(rows, nextRowChildren);
26659
27144
  }
26660
27145
  const selectedItem = items.find((item) => item.key === selectedItemKey) ?? items[0];
26661
27146
  if (selectedItem) selectItem(selectedItem);
26662
- const updateControls = updates.createControls(
27147
+ updateControls.update(
26663
27148
  selectedHost.hostId,
26664
27149
  items.flatMap((item) => item.version ? [item.version] : [])
26665
27150
  );
26666
- const hostHeader = document2.createElement("div");
26667
- hostHeader.className = "settings-connection-host-header";
26668
- hostHeader.append(hostStrip, updateControls.button);
26669
- list.append(hostHeader, updateControls.result, tableHeader, rows);
26670
- layout.append(list, inspector);
26671
- content.replaceChildren(layout);
26672
- disposeHostScroller = configureHostScroller(
26673
- document2,
26674
- hostStrip,
26675
- tabs,
26676
- scrollLeft,
26677
- scrollRight
26678
- );
26679
- const selectedTab = [...tabs.children].find(
26680
- (child) => child.getAttribute("aria-selected") === "true"
26681
- );
26682
- if (selectedTab) {
26683
- const left = selectedTab.offsetLeft;
26684
- const right = left + selectedTab.offsetWidth;
26685
- if (left < tabs.scrollLeft) tabs.scrollLeft = left;
26686
- else if (right > tabs.scrollLeft + tabs.clientWidth) {
26687
- tabs.scrollLeft = right - tabs.clientWidth;
27151
+ if (layoutFirstMount || tabsChanged) {
27152
+ hostScroller.update();
27153
+ }
27154
+ if (renderedHostId !== selectedHost.hostId) {
27155
+ renderedHostId = selectedHost.hostId;
27156
+ const selectedTab = hostTabElements.get(selectedHost.hostId);
27157
+ if (selectedTab) {
27158
+ const left = selectedTab.offsetLeft;
27159
+ const right = left + selectedTab.offsetWidth;
27160
+ if (left < tabs.scrollLeft) tabs.scrollLeft = left;
27161
+ else if (right > tabs.scrollLeft + tabs.clientWidth) {
27162
+ tabs.scrollLeft = right - tabs.clientWidth;
27163
+ }
26688
27164
  }
26689
27165
  }
26690
27166
  };
@@ -26705,7 +27181,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26705
27181
  refresh.disabled = true;
26706
27182
  return () => {
26707
27183
  cancelRender();
26708
- disposeHostScroller();
27184
+ hostScroller.dispose();
26709
27185
  unsubscribeGroup();
26710
27186
  };
26711
27187
  }
@@ -26714,7 +27190,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
26714
27190
  const unsubscribeInstalls = installs?.subscribe(scheduleRender);
26715
27191
  return () => {
26716
27192
  cancelRender();
26717
- disposeHostScroller();
27193
+ hostScroller.dispose();
26718
27194
  unsubscribeInstalls?.();
26719
27195
  unsubscribe();
26720
27196
  unsubscribeGroup();
@@ -28271,9 +28747,13 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28271
28747
  resets: "Resets",
28272
28748
  details: "Account limit details",
28273
28749
  weekly: "Weekly limit",
28750
+ weeklyShort: "Weekly",
28274
28751
  monthly: "Monthly limit",
28752
+ monthlyShort: "Monthly",
28275
28753
  fiveHour: "5-hour limit",
28754
+ fiveHourShort: "5-hour",
28276
28755
  sevenDay: "7-day limit",
28756
+ sevenDayShort: "7-day",
28277
28757
  account: "Account limit"
28278
28758
  });
28279
28759
  var CHINESE_CREDITS_MESSAGES = Object.freeze({
@@ -28281,9 +28761,13 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28281
28761
  resets: "\u91CD\u7F6E",
28282
28762
  details: "\u8D26\u53F7\u989D\u5EA6\u8BE6\u60C5",
28283
28763
  weekly: "\u5468\u989D\u5EA6",
28764
+ weeklyShort: "\u5468\u989D\u5EA6",
28284
28765
  monthly: "\u6708\u989D\u5EA6",
28766
+ monthlyShort: "\u6708\u989D\u5EA6",
28285
28767
  fiveHour: "5 \u5C0F\u65F6\u989D\u5EA6",
28768
+ fiveHourShort: "5 \u5C0F\u65F6",
28286
28769
  sevenDay: "7 \u5929\u989D\u5EA6",
28770
+ sevenDayShort: "7 \u5929",
28287
28771
  account: "\u8D26\u53F7\u989D\u5EA6"
28288
28772
  });
28289
28773
  function formatRendererCreditsReset(value, now = /* @__PURE__ */ new Date(), locale = "en") {
@@ -31258,6 +31742,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
31258
31742
  .settings-connection-inspector {
31259
31743
  position: sticky;
31260
31744
  top: 18px;
31745
+ overflow-anchor: none;
31261
31746
  }
31262
31747
 
31263
31748
  .settings-connection-inspector__header {
@@ -32613,6 +33098,11 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
32613
33098
  // src/web-settings-entry.ts
32614
33099
  var WEB_LAYOUT_CSS = `.settings-page { background: transparent; overflow: visible; container: codexhost-settings-page / inline-size; }
32615
33100
  .settings-page__content { width: 100%; padding: 0; }`;
33101
+ var sharedConnectionDiagnostics = null;
33102
+ function getWebConnectionDiagnostics(client) {
33103
+ sharedConnectionDiagnostics ??= createConsoleConnectionDiagnostics(client);
33104
+ return sharedConnectionDiagnostics;
33105
+ }
32616
33106
  function resourcesPage(messages, client) {
32617
33107
  return {
32618
33108
  id: "resources",
@@ -32642,7 +33132,6 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
32642
33132
  () => modelClient,
32643
33133
  { migrateLegacy: false }
32644
33134
  );
32645
- const diagnostics = createConsoleConnectionDiagnostics(modelClient);
32646
33135
  const updateClient = {
32647
33136
  checkUpdate: () => modelClient.checkUpdate(),
32648
33137
  startUpdate: () => modelClient.startUpdate(),
@@ -32652,7 +33141,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
32652
33141
  ...createDefaultRendererSettingsPages(
32653
33142
  messages,
32654
33143
  () => updateClient,
32655
- () => diagnostics,
33144
+ () => getWebConnectionDiagnostics(modelClient),
32656
33145
  () => modelClient,
32657
33146
  () => null,
32658
33147
  null,