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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +59 -6
  4. package/app/console-web.js +1376 -1053
  5. package/app/desktop-controller.mjs +239 -57
  6. package/app/host-runtime.mjs +35964 -28304
  7. package/app/plugins/antigravity/assets/icon.svg +1 -1
  8. package/app/plugins/antigravity/plugin.mjs +9491 -4266
  9. package/app/plugins/claude-code/plugin.mjs +580 -116
  10. package/app/plugins/codebuddy/plugin.mjs +85 -8
  11. package/app/plugins/codex-usage/plugin.mjs +70 -6
  12. package/app/plugins/copilot/plugin.mjs +62 -6
  13. package/app/plugins/cursor-cli/plugin.mjs +62 -6
  14. package/app/plugins/deepseek-harness/plugin.mjs +87 -11
  15. package/app/plugins/devin/plugin.mjs +61 -6
  16. package/app/plugins/grok/plugin.mjs +320 -223
  17. package/app/plugins/hermes/plugin.mjs +61 -6
  18. package/app/plugins/kimi-code/plugin.mjs +87 -16
  19. package/app/plugins/kiro-cli/plugin.mjs +62 -6
  20. package/app/plugins/muse/plugin.mjs +61 -6
  21. package/app/plugins/omp/plugin.mjs +195 -31
  22. package/app/plugins/opencode/plugin.mjs +88 -15
  23. package/app/plugins/pi/plugin.mjs +207 -32
  24. package/app/plugins/qoder/plugin.mjs +99 -7
  25. package/app/plugins/qoder-cn/plugin.mjs +99 -7
  26. package/app/plugins/qwen-code/plugin.mjs +62 -6
  27. package/app/plugins/workbuddy/plugin.mjs +89 -11
  28. package/app/plugins/zcode/plugin.mjs +70 -6
  29. package/app/renderer-extension.js +1767 -1187
  30. package/app/web/assets/index-C2OA-eHT.js +201 -0
  31. package/app/web/assets/index-DJW4bmyx.css +1 -0
  32. package/app/web/assets/langs/{graphql-B8vkg11W.js → graphql-ChAeyPkT.js} +1 -1
  33. package/app/web/assets/langs/{http-DmoDEjMt.js → http-BvreBIbD.js} +1 -1
  34. package/app/web/assets/langs/{php-DJ5ovfAM.js → php-D8omCIuJ.js} +1 -1
  35. package/app/web/assets/langs/{rst-U5-R5x3p.js → rst-Do7RLLCS.js} +1 -1
  36. package/app/web/assets/langs/{ruby-VKVsnS0H.js → ruby-rH_O_vse.js} +1 -1
  37. package/app/web/assets/langs/{svelte-C20lOv9V.js → svelte-xZy73wAj.js} +1 -1
  38. package/app/web/assets/langs/{vue-z6Y-lzP-.js → vue-C4DW8agZ.js} +1 -1
  39. package/app/web/assets/{vendor-dSL872WO.js → vendor-C9g2bw8s.js} +3 -3
  40. package/app/web/codexhost-settings.js +1383 -1056
  41. package/app/web/index.html +4 -3
  42. package/app/web/plugins/deepseek-ai__dsh-api-gateway/client.js +2 -2
  43. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
  44. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +11 -11
  45. package/app/web/plugins/deepseek-ai__dsh-client-connection/client.js +1 -1
  46. package/app/web/plugins/deepseek-ai__dsh-client-locale/client.js +3 -3
  47. package/app/web/plugins/deepseek-ai__dsh-client-ui-attachment/client.js +1 -1
  48. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +74 -69
  49. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +3 -3
  50. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +28 -28
  51. package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
  52. package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
  53. package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +1 -1
  54. package/app/web/plugins/deepseek-ai__dsh-client-ui-session/client.js +1 -1
  55. package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
  56. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar/client.js +1 -1
  57. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +9 -9
  58. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-files/client.js +1 -1
  59. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
  60. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +11 -11
  61. package/app/web-modules/server.mjs +2458 -1615
  62. package/bin/boft +0 -0
  63. package/libexec/boft-shim +0 -0
  64. package/libexec/boft-updater +0 -0
  65. package/package.json +1 -1
  66. package/app/web/assets/index-CP6wY-1D.css +0 -1
  67. package/app/web/assets/index-Da35Phrd.js +0 -199
@@ -14765,13 +14765,25 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14765
14765
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
14766
14766
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
14767
14767
  var cacheHitRatePercentSchema = external_exports.number().finite().min(0).max(100);
14768
+ var usageOutputTimingSchema = external_exports.object({
14769
+ version: external_exports.union([external_exports.literal(3), external_exports.literal(4)]).optional(),
14770
+ requestId: external_exports.string().min(1),
14771
+ turnId: external_exports.string().min(1).max(1024),
14772
+ outputTokens: nonNegativeSafeIntegerSchema,
14773
+ startedAtMs: nonNegativeSafeIntegerSchema,
14774
+ completedAtMs: nonNegativeSafeIntegerSchema
14775
+ }).strict().refine((value) => value.completedAtMs > value.startedAtMs);
14768
14776
  var usageMeasurementSchema = external_exports.object({
14777
+ version: external_exports.union([external_exports.literal(2), external_exports.literal(3), external_exports.literal(4)]).optional(),
14769
14778
  value: finiteNonNegativeNumberSchema,
14770
14779
  turnId: external_exports.string().min(1).max(1024),
14771
14780
  at: nonNegativeSafeIntegerSchema
14772
14781
  }).strict();
14773
14782
  var usageMeasurementsSchema = external_exports.object({
14774
- outputTokensPerSecond: usageMeasurementSchema.optional(),
14783
+ // Older intervals can omit hidden thinking time; do not restore them into averages.
14784
+ outputTimings: external_exports.array(usageOutputTimingSchema).transform((values) => values.filter((value) => value.version === 4)).optional(),
14785
+ // Retain independent TTFT facts when dropping incompatible speed measurements.
14786
+ outputTokensPerSecond: usageMeasurementSchema.refine((value) => value.version === 4).optional().catch(void 0),
14775
14787
  timeToFirstOutputMs: usageMeasurementSchema.extend({ value: nonNegativeSafeIntegerSchema }).optional()
14776
14788
  }).strict();
14777
14789
  var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text) => text.length <= maximum));
@@ -14791,6 +14803,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14791
14803
  cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
14792
14804
  outputTokens: nonNegativeSafeIntegerSchema.optional(),
14793
14805
  outputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
14806
+ sessionOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
14794
14807
  apiOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
14795
14808
  reasoningOutputTokens: nonNegativeSafeIntegerSchema.optional(),
14796
14809
  totalTokens: nonNegativeSafeIntegerSchema.optional(),
@@ -15223,11 +15236,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15223
15236
  delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
15224
15237
  }).strict();
15225
15238
 
15239
+ // ../shared-contracts/dist/thread-archive-confirm.js
15240
+ var threadArchiveConfirmParamsSchema = external_exports.object({ threadId: hostThreadIdSchema }).strict();
15241
+ var threadArchiveConfirmResultSchema = external_exports.object({ confirmed: external_exports.boolean() }).strict();
15242
+
15226
15243
  // ../shared-contracts/dist/client-channel.js
15227
15244
  var CLIENT_CHANNEL_VERSION = 1;
15228
15245
  var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
15229
15246
  var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
15230
15247
  var clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict();
15248
+ var clientThreadTreeReadParamsSchema = external_exports.object({}).strict();
15249
+ var clientThreadTreeSchema = external_exports.object({
15250
+ parents: external_exports.record(external_exports.string().min(1), external_exports.string().min(1))
15251
+ }).strict();
15231
15252
  var clientProjectlessWorkspaceSchema = external_exports.object({
15232
15253
  prompt: external_exports.string().max(16384).optional()
15233
15254
  }).strict();
@@ -15249,6 +15270,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15249
15270
  cursor: clientChannelCursorSchema,
15250
15271
  cwd: external_exports.string().optional()
15251
15272
  }),
15273
+ external_exports.object({
15274
+ type: external_exports.literal("harness-inspection-changed"),
15275
+ cursor: clientChannelCursorSchema,
15276
+ harnessId: external_exports.string().min(1)
15277
+ }),
15252
15278
  external_exports.object({ type: external_exports.literal("display-settings-changed"), cursor: clientChannelCursorSchema }),
15253
15279
  external_exports.object({
15254
15280
  type: external_exports.literal("preferences-changed"),
@@ -15320,6 +15346,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15320
15346
  var clientTurnSchema = external_exports.object({
15321
15347
  id: external_exports.string().min(1),
15322
15348
  status: external_exports.string().min(1),
15349
+ /** Native history has no terminal evidence; Desktop's status vocabulary cannot express this. */
15350
+ codexhostTurnOutcome: external_exports.object({ status: external_exports.literal("unknown"), reason: external_exports.string() }).optional(),
15323
15351
  items: external_exports.array(external_exports.object({ id: external_exports.string().min(1), type: external_exports.string().min(1) }).passthrough()),
15324
15352
  /** Original file operations, independent of the cumulative Desktop fileChange card.
15325
15353
  * Insert before the named non-file Item; null appends at the end of the Turn.
@@ -15358,7 +15386,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15358
15386
  /** Current interruptible Host Turn, including command Turns omitted from client history. */
15359
15387
  activeTurnId: external_exports.string().min(1).nullable().optional(),
15360
15388
  /** Most recent explicit command in this Host process; not native conversation history. */
15361
- command: external_exports.object({ name: external_exports.string().min(1), turn: clientTurnSchema }).optional(),
15389
+ command: external_exports.object({
15390
+ name: external_exports.string().min(1),
15391
+ turn: clientTurnSchema,
15392
+ /** First ordinary Turn started after this command; its retained result is not a new event. */
15393
+ subsequentTurnId: external_exports.string().min(1).optional()
15394
+ }).optional(),
15362
15395
  thread: external_exports.object({
15363
15396
  id: external_exports.string().min(1),
15364
15397
  cwd: external_exports.string(),
@@ -15568,7 +15601,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15568
15601
  quotaUntil: external_exports.string().optional()
15569
15602
  }).strict().optional()
15570
15603
  }).strict();
15571
- var webLocalAccessRequiredDetailsSchema = external_exports.object({ url: external_exports.string() }).strict();
15572
15604
 
15573
15605
  // ../shared-contracts/dist/delegation-read.js
15574
15606
  var REMOTE_THREAD_REPLY_MAX_BYTES = 16 * 1024 * 1024;
@@ -15576,8 +15608,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15576
15608
  var delegationReadParamsSchema = external_exports.strictObject({
15577
15609
  threadId: external_exports.string().min(1).max(1024),
15578
15610
  view: external_exports.enum(["result", "messages"]),
15579
- cursor: external_exports.string().min(1).max(8192).optional(),
15580
- limit: external_exports.number().int().min(1).max(100).optional()
15611
+ from: external_exports.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional(),
15612
+ to: external_exports.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional()
15581
15613
  });
15582
15614
 
15583
15615
  // ../shared-contracts/dist/credential-imports.js
@@ -16592,6 +16624,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16592
16624
  "completed",
16593
16625
  "failed",
16594
16626
  "interrupted",
16627
+ "needsInput",
16595
16628
  "timedOut",
16596
16629
  "unreadable",
16597
16630
  "notFound"
@@ -16641,13 +16674,26 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16641
16674
  var thread = { ...target, threadId: identity };
16642
16675
  var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
16643
16676
  external_exports.strictObject({ kind: external_exports.literal("hosts") }),
16677
+ external_exports.strictObject({ kind: external_exports.literal("status"), ...thread }),
16644
16678
  external_exports.strictObject({
16645
16679
  kind: external_exports.literal("list"),
16646
16680
  ...target,
16647
16681
  cursor: external_exports.string().nullable(),
16648
16682
  archived: external_exports.boolean()
16649
16683
  }),
16650
- external_exports.strictObject({ kind: external_exports.literal("read"), ...thread }),
16684
+ external_exports.strictObject({
16685
+ kind: external_exports.literal("read"),
16686
+ ...thread,
16687
+ page: external_exports.strictObject({
16688
+ cursor: external_exports.string().min(1).max(8192).nullable(),
16689
+ epoch: identity.optional(),
16690
+ sortDirection: external_exports.enum(["asc", "desc"]).optional(),
16691
+ limit: external_exports.number().int().min(1).max(20).optional()
16692
+ }).refine((page) => page.cursor === null || page.epoch !== void 0, {
16693
+ message: "A history continuation requires its connection epoch"
16694
+ }).optional()
16695
+ }),
16696
+ external_exports.strictObject({ kind: external_exports.literal("usage"), ...thread, epoch: identity }),
16651
16697
  external_exports.strictObject({
16652
16698
  kind: external_exports.literal("configure"),
16653
16699
  ...thread,
@@ -16729,6 +16775,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16729
16775
  external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
16730
16776
  ]);
16731
16777
 
16778
+ // ../shared-contracts/dist/thread-title.js
16779
+ var threadTitleInputSchema = external_exports.strictObject({
16780
+ prompt: external_exports.string().trim().min(1).max(2e3),
16781
+ cwd: external_exports.string().max(4096).nullable()
16782
+ });
16783
+ var threadTitleResultSchema = external_exports.string().trim().min(1).max(60).nullable();
16784
+
16732
16785
  // ../shared-contracts/dist/web-ui-extensions.js
16733
16786
  var webUiExtensionIdSchema = external_exports.string().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u);
16734
16787
  var localizedTextSchema2 = external_exports.union([
@@ -17826,11 +17879,18 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17826
17879
  const webUi = /* @__PURE__ */ new Map();
17827
17880
  const listeners = /* @__PURE__ */ new Set();
17828
17881
  let pending = null;
17882
+ let queuedRefresh = null;
17829
17883
  const publish = () => {
17830
17884
  for (const listener of [...listeners]) listener();
17831
17885
  };
17832
17886
  const inspectAll = (refresh) => {
17833
- if (pending) return pending;
17887
+ if (pending) {
17888
+ if (!refresh) return pending;
17889
+ queuedRefresh ??= pending.then(() => inspectAll(true)).finally(() => {
17890
+ queuedRefresh = null;
17891
+ });
17892
+ return queuedRefresh;
17893
+ }
17834
17894
  pending = Promise.resolve().then(async () => {
17835
17895
  try {
17836
17896
  if (!client.listHarnessPlugins)
@@ -17848,7 +17908,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17848
17908
  await Promise.all(
17849
17909
  plugins.map(async ({ id }) => {
17850
17910
  try {
17851
- const inspection = await client.inspectHarness({ harnessId: id, refresh });
17911
+ const inspection = await client.inspectHarness({
17912
+ harnessId: id,
17913
+ refresh,
17914
+ purpose: "availability"
17915
+ });
17852
17916
  availability.set(id, inspection.status);
17853
17917
  webUi.set(id, inspection.status === "ready" && inspection.webUi?.open === true);
17854
17918
  const error51 = inspection.status === "ready" ? null : inspection.error;
@@ -22927,9 +22991,11 @@ th[aria-sort] .console-usage-sort__mark {
22927
22991
  title: "Settings",
22928
22992
  close: "Close settings",
22929
22993
  sectionsLabel: "Settings sections",
22930
- connectionSection: "Connections",
22994
+ agentsSection: "Agents",
22995
+ accessSection: "Access",
22996
+ activitySection: "Sessions & activity",
22931
22997
  generalSection: "General",
22932
- otherSection: "Other",
22998
+ otherSection: "About",
22933
22999
  appearanceDescription: "Conversation display and local resource management.",
22934
23000
  appearanceGroup: "Appearance",
22935
23001
  loadedSessions: {
@@ -23245,9 +23311,11 @@ th[aria-sort] .console-usage-sort__mark {
23245
23311
  title: "\u8BBE\u7F6E",
23246
23312
  close: "\u5173\u95ED\u8BBE\u7F6E",
23247
23313
  sectionsLabel: "\u8BBE\u7F6E\u5206\u7C7B",
23248
- connectionSection: "\u8FDE\u63A5",
23314
+ agentsSection: "Agents",
23315
+ accessSection: "\u8BBF\u95EE\u4E0E\u8D26\u53F7",
23316
+ activitySection: "\u4F1A\u8BDD\u4E0E\u6D3B\u52A8",
23249
23317
  generalSection: "\u901A\u7528",
23250
- otherSection: "\u5176\u4ED6",
23318
+ otherSection: "\u5173\u4E8E",
23251
23319
  appearanceDescription: "\u4F1A\u8BDD\u663E\u793A\u4E0E\u672C\u5730\u8D44\u6E90\u7BA1\u7406\u3002",
23252
23320
  appearanceGroup: "\u5916\u89C2",
23253
23321
  loadedSessions: {
@@ -23622,6 +23690,7 @@ th[aria-sort] .console-usage-sort__mark {
23622
23690
  latestCacheHit: "Latest cache hit (CH)",
23623
23691
  sessionCacheHit: "Average cache hit",
23624
23692
  outputSpeed: "Output speed (TPS)",
23693
+ averageOutputSpeed: "Average output speed (TPS)",
23625
23694
  apiOutputSpeed: "API average speed",
23626
23695
  apiOutputSpeedDescription: "Output tokens / native API time, including first-token wait; not generation TPS.",
23627
23696
  timeToFirstOutput: "Time to first token (TTFT)",
@@ -23648,6 +23717,7 @@ th[aria-sort] .console-usage-sort__mark {
23648
23717
  latestCacheHit: "\u7F13\u5B58\u547D\u4E2D\u7387",
23649
23718
  sessionCacheHit: "\u5E73\u5747\u7F13\u5B58\u547D\u4E2D",
23650
23719
  outputSpeed: "\u8F93\u51FA\u901F\u5EA6\uFF08TPS\uFF09",
23720
+ averageOutputSpeed: "\u5E73\u5747\u8F93\u51FA\u901F\u5EA6\uFF08TPS\uFF09",
23651
23721
  apiOutputSpeed: "API \u5E73\u5747\u901F\u5EA6",
23652
23722
  apiOutputSpeedDescription: "\u8F93\u51FA Token \xF7 \u539F\u751F API \u8017\u65F6\uFF0C\u542B\u9996\u5B57\u7B49\u5F85\uFF1B\u4E0D\u662F\u751F\u6210 TPS\u3002",
23653
23723
  timeToFirstOutput: "\u9996 token\uFF08TTFT\uFF09",
@@ -27387,248 +27457,694 @@ ${detail}` : ""}`
27387
27457
  return fallback;
27388
27458
  }
27389
27459
 
27390
- // src/settings/harness-launch-controls.ts
27391
- function createHarnessLaunchControls(document2, messages, agent, settings) {
27392
- const section = document2.createElement("section");
27393
- section.className = "settings-harness-launch";
27394
- section.dataset.harnessLaunch = agent;
27395
- const label = document2.createElement("label");
27396
- label.textContent = messages.launchPathLabel;
27397
- const input = document2.createElement("input");
27398
- input.type = "text";
27399
- input.autocomplete = "off";
27400
- input.spellcheck = false;
27401
- input.placeholder = messages.locale === "zh-CN" ? "\u5E94\u7528\u5B89\u88C5\u76EE\u5F55\u7684\u7EDD\u5BF9\u8DEF\u5F84" : "Absolute installation directory";
27402
- input.setAttribute("aria-label", messages.launchPathLabel);
27403
- label.append(input);
27404
- const help = document2.createElement("p");
27405
- 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.";
27406
- const actions = document2.createElement("div");
27407
- actions.className = "settings-harness-launch__actions";
27408
- const save = document2.createElement("button");
27409
- save.type = "button";
27410
- save.className = "settings-command-button";
27411
- save.textContent = messages.launchPathSave;
27412
- const reset = document2.createElement("button");
27413
- reset.type = "button";
27414
- reset.className = "settings-command-button settings-command-button--secondary";
27415
- reset.textContent = messages.launchPathReset;
27416
- const status = document2.createElement("p");
27417
- status.setAttribute("role", "status");
27418
- status.setAttribute("aria-live", "polite");
27419
- actions.append(save, reset);
27420
- section.append(label, help, actions, status);
27421
- let busy = true;
27422
- let loaded = false;
27423
- const controls = () => {
27424
- input.disabled = busy || !loaded;
27425
- save.disabled = busy || !loaded || !input.value.trim();
27426
- reset.disabled = busy || !loaded;
27427
- };
27428
- const show = (value) => {
27429
- input.value = value.path ?? "";
27430
- status.textContent = value.restartRequired ? messages.launchPathRestart : value.path ? messages.launchPathSaved : messages.launchPathAutomatic;
27431
- };
27432
- const persist = async (value) => {
27433
- if (busy || !loaded) return;
27434
- busy = true;
27435
- controls();
27436
- status.textContent = messages.launchPathSaving;
27437
- try {
27438
- show(await settings.set(value));
27439
- } catch {
27440
- status.textContent = messages.launchPathSaveError;
27441
- } finally {
27442
- busy = false;
27443
- controls();
27460
+ // src/settings/connection-row.ts
27461
+ function connectionStatusLabel(availability, messages, hasError = false) {
27462
+ if (availability === "updating") return messages.connectionStatusUpdating;
27463
+ if (hasError && availability !== "notInstalled") return messages.connectionStatusError;
27464
+ if (availability === "ready") return messages.connectionStatusReady;
27465
+ if (availability === "checking") return messages.connectionStatusChecking;
27466
+ if (availability === "notInstalled") return messages.connectionStatusNotInstalled;
27467
+ if (availability === "unavailable" || availability === "error") {
27468
+ return availability === "error" ? messages.connectionStatusError : messages.connectionStatusUnavailable;
27469
+ }
27470
+ return availability === "installing" ? messages.connectionStatusInstalling : messages.connectionStatusUnsupported;
27471
+ }
27472
+ function connectionStatusTone(availability, hasError = false) {
27473
+ if (availability === "updating") return "checking";
27474
+ if (hasError && availability !== "notInstalled") return "failed";
27475
+ if (availability === "ready") return "ready";
27476
+ if (availability === "checking" || availability === "installing") return "checking";
27477
+ if (availability === "notInstalled") return "setup";
27478
+ return "failed";
27479
+ }
27480
+ function createConnectionIdentityIcon(document2, item, size) {
27481
+ const container = document2.createElement("span");
27482
+ container.className = item.agentSnapshot ? "settings-connection-row__mark settings-connection-row__mark--logo" : "settings-connection-row__mark";
27483
+ container.setAttribute("aria-hidden", "true");
27484
+ if (item.agentSnapshot) {
27485
+ container.append(
27486
+ createRendererAgentIcon(item.agentSnapshot.agent, size, document2, item.agentSnapshot.plugin)
27487
+ );
27488
+ } else {
27489
+ container.textContent = "CH";
27490
+ }
27491
+ return container;
27492
+ }
27493
+ function sameElementChildren(container, next) {
27494
+ if (container.children.length !== next.length) return false;
27495
+ for (let index = 0; index < next.length; index++) {
27496
+ if (container.children[index] !== next[index]) return false;
27497
+ }
27498
+ return true;
27499
+ }
27500
+ function reconcileElementChildren(container, next) {
27501
+ if (sameElementChildren(container, next)) return;
27502
+ if (typeof container.insertBefore !== "function") {
27503
+ container.replaceChildren(...next);
27504
+ return;
27505
+ }
27506
+ const nextSet = new Set(next);
27507
+ for (const child of [...container.children]) {
27508
+ if (!nextSet.has(child)) child.remove();
27509
+ }
27510
+ for (let index = 0; index < next.length; index++) {
27511
+ const desired = next[index];
27512
+ if (!desired) continue;
27513
+ const current = container.children[index] ?? null;
27514
+ if (current !== desired) {
27515
+ container.insertBefore(desired, current);
27444
27516
  }
27445
- };
27446
- input.addEventListener("input", controls);
27447
- save.addEventListener("click", () => {
27448
- if (input.value.trim()) void persist(input.value.trim());
27517
+ }
27518
+ }
27519
+ function identityIconSignature(item) {
27520
+ if (!item.agentSnapshot) return "adapter";
27521
+ const plugin = item.agentSnapshot.plugin;
27522
+ return `${item.agentSnapshot.agent}:${String(plugin?.icon ?? "")}:${String(plugin?.iconStyle ?? "")}`;
27523
+ }
27524
+ function createConnectionRowView(document2, messages, groupable) {
27525
+ const row = document2.createElement("div");
27526
+ row.className = "settings-connection-row";
27527
+ row.setAttribute("role", "row");
27528
+ const identity2 = document2.createElement("div");
27529
+ identity2.className = "settings-connection-row__identity";
27530
+ identity2.setAttribute("role", "cell");
27531
+ let handle = null;
27532
+ if (groupable) {
27533
+ handle = document2.createElement("span");
27534
+ handle.className = "settings-connection-row__handle";
27535
+ handle.setAttribute("aria-hidden", "true");
27536
+ handle.append(createRendererSettingsIcon("grip-vertical", 15));
27537
+ identity2.append(handle);
27538
+ }
27539
+ let iconElement = null;
27540
+ let renderedIconKey = null;
27541
+ const label = document2.createElement("strong");
27542
+ const status = document2.createElement("span");
27543
+ status.className = "settings-connection-row__status";
27544
+ status.setAttribute("role", "cell");
27545
+ const action = document2.createElement("div");
27546
+ action.className = "settings-connection-row__action";
27547
+ action.setAttribute("role", "cell");
27548
+ row.append(identity2, status, action);
27549
+ let currentItem = null;
27550
+ let currentSelect = () => void 0;
27551
+ let currentGroup = null;
27552
+ let dragArmed = false;
27553
+ handle?.addEventListener("pointerdown", (event) => {
27554
+ if (event.button !== 0 || currentGroup?.disabled) return;
27555
+ dragArmed = true;
27556
+ row.draggable = true;
27557
+ });
27558
+ row.addEventListener("pointerup", () => {
27559
+ dragArmed = false;
27560
+ row.draggable = false;
27449
27561
  });
27450
- reset.addEventListener("click", () => {
27451
- void persist(null);
27562
+ row.addEventListener("pointercancel", () => {
27563
+ dragArmed = false;
27564
+ row.draggable = false;
27452
27565
  });
27453
- controls();
27454
- status.textContent = messages.launchPathLoading;
27455
- void settings.get().then((value) => {
27456
- loaded = true;
27457
- show(value);
27458
- }).catch(() => {
27459
- loaded = true;
27460
- status.textContent = messages.launchPathLoadError;
27461
- }).finally(() => {
27462
- busy = false;
27463
- controls();
27566
+ let viewErrorButton = null;
27567
+ let versionAvailableBadge = null;
27568
+ let updateButton = null;
27569
+ let groupToggleButton = null;
27570
+ let groupToggleSection = null;
27571
+ row.addEventListener("click", (event) => {
27572
+ const target2 = event.target;
27573
+ if (target2?.closest?.("a")) return;
27574
+ currentSelect();
27464
27575
  });
27465
- return section;
27576
+ row.addEventListener("keydown", (event) => {
27577
+ if (event.target?.closest?.("button, a")) return;
27578
+ if (event.key !== "Enter" && event.key !== " ") return;
27579
+ event.preventDefault();
27580
+ currentSelect();
27581
+ });
27582
+ if (groupable) {
27583
+ row.addEventListener("dragstart", (event) => {
27584
+ if (!dragArmed) {
27585
+ event.preventDefault();
27586
+ return;
27587
+ }
27588
+ currentGroup?.onDragStart(event);
27589
+ });
27590
+ row.addEventListener("dragover", (event) => currentGroup?.onDragOver(event));
27591
+ row.addEventListener("dragleave", (event) => currentGroup?.onDragLeave(event));
27592
+ row.addEventListener("drop", (event) => currentGroup?.onDrop(event));
27593
+ row.addEventListener("dragend", (event) => {
27594
+ dragArmed = false;
27595
+ row.draggable = false;
27596
+ currentGroup?.onDragEnd(event);
27597
+ });
27598
+ }
27599
+ const setSelected = (selected) => {
27600
+ const nextSelected = String(selected);
27601
+ if (row.dataset.connectionSelected !== nextSelected) {
27602
+ row.dataset.connectionSelected = nextSelected;
27603
+ }
27604
+ const nextTabIndex = selected ? 0 : -1;
27605
+ if (row.tabIndex !== nextTabIndex) {
27606
+ row.tabIndex = nextTabIndex;
27607
+ }
27608
+ };
27609
+ return {
27610
+ element: row,
27611
+ setSelected,
27612
+ update(item, selected, select, group) {
27613
+ currentItem = item;
27614
+ currentSelect = select;
27615
+ currentGroup = group;
27616
+ if (row.dataset.connectionItem !== item.key) {
27617
+ row.dataset.connectionItem = item.key;
27618
+ }
27619
+ setSelected(selected);
27620
+ const nextIconKey = identityIconSignature(item);
27621
+ if (renderedIconKey !== nextIconKey || !iconElement) {
27622
+ renderedIconKey = nextIconKey;
27623
+ iconElement = createConnectionIdentityIcon(document2, item, 19);
27624
+ reconcileElementChildren(
27625
+ identity2,
27626
+ handle ? [handle, iconElement, label] : [iconElement, label]
27627
+ );
27628
+ }
27629
+ if (handle && group && handle.title !== group.dragHandleTitle) {
27630
+ handle.title = group.dragHandleTitle;
27631
+ }
27632
+ if (label.textContent !== item.name) {
27633
+ label.textContent = item.name;
27634
+ }
27635
+ const tone = connectionStatusTone(item.availability, item.error !== null);
27636
+ if (status.dataset.connectionTone !== tone) {
27637
+ status.dataset.connectionTone = tone;
27638
+ }
27639
+ const statusText = item.error?.code === "authenticationRequired" ? messages.connectionLoginRequired : item.error?.code === "configurationRequired" ? messages.connectionConfigurationRequired : connectionStatusLabel(item.availability, messages, item.error !== null);
27640
+ if (status.textContent !== statusText) {
27641
+ status.textContent = statusText;
27642
+ }
27643
+ const nextActions = [];
27644
+ if (item.error) {
27645
+ if (!viewErrorButton) {
27646
+ const button2 = document2.createElement("button");
27647
+ button2.type = "button";
27648
+ button2.className = "settings-connection-view-error";
27649
+ button2.textContent = messages.connectionViewError;
27650
+ button2.addEventListener("click", (event) => {
27651
+ event.stopPropagation();
27652
+ currentSelect();
27653
+ });
27654
+ viewErrorButton = button2;
27655
+ }
27656
+ nextActions.push(viewErrorButton);
27657
+ }
27658
+ const version2 = item.version;
27659
+ if (item.accessory) nextActions.push(item.accessory);
27660
+ if (version2?.state?.updateAvailable && !version2.updating) {
27661
+ if (!versionAvailableBadge) {
27662
+ const badge = document2.createElement("span");
27663
+ badge.className = "settings-connection-version-available";
27664
+ badge.textContent = messages.harnessVersionAvailable;
27665
+ versionAvailableBadge = badge;
27666
+ }
27667
+ const badgeTitle = `${messages.harnessVersionCurrent}: ${version2.state.currentVersion ?? "\u2014"}
27668
+ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages.harnessVersion)}`;
27669
+ if (versionAvailableBadge.title !== badgeTitle) {
27670
+ versionAvailableBadge.title = badgeTitle;
27671
+ }
27672
+ nextActions.push(versionAvailableBadge);
27673
+ }
27674
+ if (version2?.state?.updateAvailable && version2.state.canUpdate) {
27675
+ if (!updateButton) {
27676
+ const button2 = document2.createElement("button");
27677
+ button2.type = "button";
27678
+ button2.className = "settings-connection-install-link";
27679
+ button2.dataset.connectionAction = "update";
27680
+ button2.append(createRendererSettingsIcon("download", 17));
27681
+ button2.addEventListener("click", (event) => {
27682
+ event.stopPropagation();
27683
+ if (button2.disabled) return;
27684
+ void currentItem?.version?.update();
27685
+ currentSelect();
27686
+ });
27687
+ updateButton = button2;
27688
+ }
27689
+ updateButton.disabled = version2.updating;
27690
+ const updateTitle = `${messages.harnessVersionUpdate}: ${item.name}
27691
+ ${messages.harnessVersionCurrent}: ${version2.state.currentVersion ?? "\u2014"}
27692
+ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages.harnessVersion)}`;
27693
+ if (updateButton.title !== updateTitle) {
27694
+ updateButton.title = updateTitle;
27695
+ }
27696
+ const updateAriaLabel = `${messages.harnessVersionUpdate}: ${item.name}`;
27697
+ if (updateButton.getAttribute("aria-label") !== updateAriaLabel) {
27698
+ updateButton.setAttribute("aria-label", updateAriaLabel);
27699
+ }
27700
+ nextActions.push(updateButton);
27701
+ }
27702
+ if (group) {
27703
+ if (!groupToggleButton) {
27704
+ const button2 = document2.createElement("button");
27705
+ button2.type = "button";
27706
+ button2.className = "settings-connection-row__group-toggle";
27707
+ button2.addEventListener("click", (event) => {
27708
+ event.stopPropagation();
27709
+ currentGroup?.toggleSection();
27710
+ });
27711
+ groupToggleButton = button2;
27712
+ }
27713
+ groupToggleButton.disabled = group.disabled;
27714
+ if (groupToggleButton.title !== group.moveLabel) {
27715
+ groupToggleButton.title = group.moveLabel;
27716
+ }
27717
+ if (groupToggleButton.getAttribute("aria-label") !== group.moveLabel) {
27718
+ groupToggleButton.setAttribute("aria-label", group.moveLabel);
27719
+ }
27720
+ if (groupToggleSection !== group.section) {
27721
+ groupToggleSection = group.section;
27722
+ groupToggleButton.replaceChildren(
27723
+ createRendererSettingsIcon(
27724
+ group.section === "main" ? "chevron-down" : "chevron-up",
27725
+ 15
27726
+ )
27727
+ );
27728
+ }
27729
+ nextActions.push(groupToggleButton);
27730
+ }
27731
+ reconcileElementChildren(action, nextActions);
27732
+ if (group) {
27733
+ if (group.disabled) {
27734
+ dragArmed = false;
27735
+ row.draggable = false;
27736
+ }
27737
+ if (row.dataset.connectionGroupSection !== group.section) {
27738
+ row.dataset.connectionGroupSection = group.section;
27739
+ }
27740
+ }
27741
+ }
27742
+ };
27466
27743
  }
27467
27744
 
27468
- // src/settings/claude-long-context-control.ts
27469
- var CLAUDE_LONG_CONTEXT_MODELS = [{ id: "claude-opus-5-5", window: "1M" }];
27470
- var tooltipSequence = 0;
27471
- function popoverOpen(tooltip) {
27472
- try {
27473
- return tooltip.matches(":popover-open");
27474
- } catch {
27475
- return false;
27745
+ // src/settings/connection-updates.ts
27746
+ var sharedBatchStores = /* @__PURE__ */ new WeakMap();
27747
+ function getBatchStore(diagnostics) {
27748
+ if (!diagnostics) {
27749
+ return { batches: /* @__PURE__ */ new Map(), listeners: /* @__PURE__ */ new Set() };
27476
27750
  }
27477
- }
27478
- function createClaudeLongContextControl(document2, messages, actions) {
27479
- const control = document2.createElement("span");
27480
- control.className = "settings-connection-long-context";
27481
- const label = document2.createElement("label");
27482
- label.className = "settings-connection-long-context__control";
27483
- const text = document2.createElement("span");
27484
- text.textContent = messages.connectionLongContextLabel;
27485
- const input = document2.createElement("input");
27486
- input.type = "checkbox";
27487
- input.checked = true;
27488
- input.setAttribute("role", "switch");
27489
- input.setAttribute("aria-checked", "true");
27490
- input.setAttribute("aria-label", messages.connectionLongContextLabel);
27491
- input.dataset.connectionAction = "long-context";
27492
- const tooltip = document2.createElement("div");
27493
- tooltip.id = `settings-long-context-tooltip-${++tooltipSequence}`;
27494
- tooltip.className = "settings-connection-long-context__tooltip";
27495
- tooltip.setAttribute("role", "tooltip");
27496
- tooltip.setAttribute("popover", "manual");
27497
- tooltip.hidden = true;
27498
- const on = document2.createElement("p");
27499
- on.textContent = messages.connectionLongContextOn;
27500
- const off = document2.createElement("p");
27501
- off.textContent = messages.connectionLongContextOff;
27502
- const modelsLabel = document2.createElement("p");
27503
- modelsLabel.textContent = messages.connectionLongContextModelsLabel;
27504
- const models = document2.createElement("ul");
27505
- for (const model2 of CLAUDE_LONG_CONTEXT_MODELS) {
27506
- const item = document2.createElement("li");
27507
- item.textContent = `${model2.id} (${model2.window})`;
27508
- models.append(item);
27751
+ let store = sharedBatchStores.get(diagnostics);
27752
+ if (!store) {
27753
+ store = { batches: /* @__PURE__ */ new Map(), listeners: /* @__PURE__ */ new Set() };
27754
+ sharedBatchStores.set(diagnostics, store);
27509
27755
  }
27510
- tooltip.append(on, off, modelsLabel, models);
27511
- input.setAttribute("aria-describedby", tooltip.id);
27512
- const stop = (event) => {
27513
- event.stopPropagation();
27756
+ return store;
27757
+ }
27758
+ function createConnectionUpdates(document2, messages, signal, onChange, diagnostics = null) {
27759
+ const store = getBatchStore(diagnostics);
27760
+ const notify2 = () => {
27761
+ for (const listener of [...store.listeners]) listener();
27514
27762
  };
27515
- control.addEventListener("click", stop);
27516
- label.addEventListener("click", stop);
27517
- input.addEventListener("click", stop);
27518
- let surfaceReady = false;
27519
- const applyTooltipSurface = () => {
27520
- if (surfaceReady) return;
27521
- const probe = document2.createElement("span");
27522
- probe.style.cssText = "position:absolute;visibility:hidden;color:var(--settings-text);background-color:var(--settings-elevated);border-top-color:var(--settings-border)";
27523
- control.append(probe);
27524
- const computed = document2.defaultView?.getComputedStyle(probe);
27525
- const color = computed?.color;
27526
- const background = computed?.backgroundColor;
27527
- const borderColor = computed?.borderTopColor;
27528
- probe.remove();
27529
- if (color) tooltip.style.color = color;
27530
- if (background && background !== "rgba(0, 0, 0, 0)") tooltip.style.backgroundColor = background;
27531
- if (borderColor) tooltip.style.border = `1px solid ${borderColor}`;
27532
- surfaceReady = true;
27763
+ if (!signal.aborted) {
27764
+ const listener = () => {
27765
+ if (!signal.aborted) onChange();
27766
+ };
27767
+ store.listeners.add(listener);
27768
+ signal.addEventListener(
27769
+ "abort",
27770
+ () => {
27771
+ store.listeners.delete(listener);
27772
+ },
27773
+ { once: true }
27774
+ );
27775
+ }
27776
+ const eligible = (panels) => panels.filter((panel) => panel.state?.updateAvailable && panel.state.canUpdate);
27777
+ const start = async (hostId2, panels) => {
27778
+ if (signal.aborted || store.batches.get(hostId2)?.running) return;
27779
+ const targets = eligible(panels);
27780
+ if (!targets.length) return;
27781
+ const batch = { running: true, total: targets.length, succeeded: 0, failed: 0 };
27782
+ store.batches.set(hostId2, batch);
27783
+ notify2();
27784
+ await Promise.all(
27785
+ targets.map(async (panel) => {
27786
+ try {
27787
+ if (await panel.update()) batch.succeeded++;
27788
+ else batch.failed++;
27789
+ } catch {
27790
+ batch.failed++;
27791
+ }
27792
+ notify2();
27793
+ })
27794
+ );
27795
+ batch.running = false;
27796
+ notify2();
27533
27797
  };
27534
- const showTooltip = () => {
27535
- const root = control.getRootNode();
27536
- const host = root instanceof ShadowRoot ? root : document2.body ?? control;
27537
- if (tooltip.parentNode !== host) host.append(tooltip);
27538
- applyTooltipSurface();
27539
- tooltip.hidden = false;
27540
- if (typeof tooltip.showPopover === "function" && !popoverOpen(tooltip)) {
27798
+ return {
27799
+ createControls(hostId2, panels) {
27800
+ let currentHostId = hostId2;
27801
+ let currentPanels = panels;
27802
+ let renderedLabel = null;
27803
+ const button2 = document2.createElement("button");
27804
+ button2.type = "button";
27805
+ button2.className = "settings-command-button settings-command-button--secondary settings-connection-update-all";
27806
+ button2.dataset.connectionAction = "update-all";
27807
+ button2.title = messages.harnessUpdateAllDescription;
27808
+ button2.addEventListener("click", () => {
27809
+ if (!button2.disabled) void start(currentHostId, currentPanels);
27810
+ });
27811
+ const result = document2.createElement("p");
27812
+ result.className = "settings-connection-update-result";
27813
+ result.setAttribute("role", "status");
27814
+ const update = (nextHostId, nextPanels) => {
27815
+ currentHostId = nextHostId;
27816
+ currentPanels = nextPanels;
27817
+ const batch = store.batches.get(nextHostId);
27818
+ const count3 = eligible(nextPanels).length;
27819
+ button2.disabled = signal.aborted || Boolean(batch?.running) || !count3;
27820
+ const label = batch?.running ? `${messages.harnessUpdateAllProgress} ${batch.succeeded + batch.failed}/${batch.total}` : count3 ? `${messages.harnessUpdateAll} (${count3})` : messages.harnessUpdateAll;
27821
+ if (renderedLabel !== label) {
27822
+ renderedLabel = label;
27823
+ button2.replaceChildren(createRendererSettingsIcon("download", 15), label);
27824
+ }
27825
+ const hidden = !batch || batch.running;
27826
+ result.hidden = hidden;
27827
+ const resultText = batch && !batch.running ? messages.harnessUpdateAllResult.replace("{succeeded}", String(batch.succeeded)).replace("{failed}", String(batch.failed)) : "";
27828
+ if (result.textContent !== resultText) {
27829
+ result.textContent = resultText;
27830
+ }
27831
+ };
27832
+ update(hostId2, panels);
27833
+ return { button: button2, result, update };
27834
+ }
27835
+ };
27836
+ }
27837
+
27838
+ // src/settings/harness-version-panel.ts
27839
+ function isUnsupportedInstallationError(error51) {
27840
+ return typeof error51 === "object" && error51 !== null && "code" in error51 && (error51.code === -32601 || error51.code === -32078);
27841
+ }
27842
+ function createHarnessVersionSession(client, options) {
27843
+ let state;
27844
+ let statusKind = "checking";
27845
+ let checkPromise = null;
27846
+ let updatePromise = null;
27847
+ const listeners = /* @__PURE__ */ new Set();
27848
+ const signal = options?.signal;
27849
+ const notify2 = (pageChange) => {
27850
+ if (signal?.aborted) return;
27851
+ for (const listener of [...listeners]) listener(pageChange);
27852
+ };
27853
+ const check2 = () => {
27854
+ if (signal?.aborted || updatePromise) return Promise.resolve();
27855
+ if (checkPromise) return checkPromise;
27856
+ statusKind = "checking";
27857
+ notify2(false);
27858
+ checkPromise = (async () => {
27541
27859
  try {
27542
- tooltip.showPopover();
27543
- } catch {
27544
- tooltip.removeAttribute("popover");
27860
+ const result = await client.run("check");
27861
+ if (signal?.aborted || updatePromise) return;
27862
+ state = result;
27863
+ statusKind = "idle";
27864
+ } catch (error51) {
27865
+ if (signal?.aborted || updatePromise) return;
27866
+ statusKind = isUnsupportedInstallationError(error51) ? "unsupported" : "failed";
27867
+ if (state) state = { ...state, canUpdate: false };
27868
+ } finally {
27869
+ checkPromise = null;
27870
+ if (!signal?.aborted && !updatePromise) {
27871
+ notify2(true);
27872
+ }
27545
27873
  }
27546
- }
27547
- tooltip.style.position = "fixed";
27548
- tooltip.style.inset = "auto";
27549
- tooltip.style.zIndex = "80";
27550
- tooltip.style.margin = "0";
27551
- tooltip.style.height = "auto";
27552
- tooltip.style.overflow = "visible";
27553
- const rect = control.getBoundingClientRect();
27554
- const margin = 8;
27555
- const width = Math.min(280, Math.max(160, window.innerWidth - margin * 2));
27556
- tooltip.style.width = `${width}px`;
27557
- const preferredLeft = Math.min(
27558
- Math.max(margin, rect.right - width),
27559
- window.innerWidth - width - margin
27560
- );
27561
- const height = tooltip.offsetHeight;
27562
- const below = rect.bottom + 8;
27563
- const preferredTop = below + height <= window.innerHeight - margin ? below : Math.max(margin, rect.top - height - 8);
27564
- tooltip.style.left = `${preferredLeft}px`;
27565
- tooltip.style.top = `${preferredTop}px`;
27566
- const placed = tooltip.getBoundingClientRect();
27567
- const shiftX = preferredLeft - placed.left;
27568
- const shiftY = preferredTop - placed.top;
27569
- if (Math.abs(shiftX) > 0.5 || Math.abs(shiftY) > 0.5) {
27570
- tooltip.style.left = `${preferredLeft + shiftX}px`;
27571
- tooltip.style.top = `${preferredTop + shiftY}px`;
27572
- }
27874
+ })();
27875
+ return checkPromise;
27573
27876
  };
27574
- const hideTooltip = () => {
27575
- if (typeof tooltip.hidePopover === "function" && popoverOpen(tooltip)) {
27877
+ const update = () => {
27878
+ if (updatePromise) return updatePromise;
27879
+ updatePromise = (async () => {
27880
+ if (signal?.aborted) return false;
27881
+ if (checkPromise) await checkPromise;
27882
+ if (signal?.aborted || statusKind === "unsupported" || !state?.canUpdate || !state.updateAvailable) {
27883
+ return false;
27884
+ }
27885
+ statusKind = "updating";
27886
+ notify2(true);
27576
27887
  try {
27577
- tooltip.hidePopover();
27578
- } catch {
27888
+ const result = await client.run("update");
27889
+ if (signal?.aborted) return false;
27890
+ state = result;
27891
+ statusKind = !result.canUpdate ? "updated" : result.updateAvailable ? "failed" : "updated";
27892
+ return result.canUpdate && !result.updateAvailable;
27893
+ } catch (error51) {
27894
+ if (signal?.aborted) return false;
27895
+ statusKind = isUnsupportedInstallationError(error51) ? "unsupported" : "failed";
27896
+ if (state) state = { ...state, canUpdate: false };
27897
+ return false;
27898
+ } finally {
27899
+ updatePromise = null;
27900
+ if (!signal?.aborted) {
27901
+ notify2(true);
27902
+ }
27579
27903
  }
27904
+ })();
27905
+ return updatePromise;
27906
+ };
27907
+ return {
27908
+ get state() {
27909
+ return state;
27910
+ },
27911
+ get statusKind() {
27912
+ return statusKind;
27913
+ },
27914
+ get updating() {
27915
+ return statusKind === "updating";
27916
+ },
27917
+ prepareMount() {
27918
+ if (updatePromise || checkPromise) return false;
27919
+ statusKind = "checking";
27920
+ return true;
27921
+ },
27922
+ check: check2,
27923
+ update,
27924
+ subscribe(listener) {
27925
+ listeners.add(listener);
27926
+ return () => {
27927
+ listeners.delete(listener);
27928
+ };
27580
27929
  }
27581
- tooltip.hidden = true;
27582
27930
  };
27583
- control.addEventListener("mouseenter", showTooltip);
27584
- control.addEventListener("mouseleave", hideTooltip);
27585
- control.addEventListener("focusin", showTooltip);
27586
- control.addEventListener("focusout", (event) => {
27587
- const next = event.relatedTarget;
27588
- if (next instanceof Node && control.contains(next)) return;
27589
- hideTooltip();
27931
+ }
27932
+ function createHarnessVersionPanel(document2, messages, signal, agent, client, onChange = () => void 0, sharedSession) {
27933
+ const session = sharedSession ?? createHarnessVersionSession(client, { signal });
27934
+ const shouldScheduleCheck = session.prepareMount();
27935
+ const panel = document2.createElement("section");
27936
+ panel.className = "settings-harness-version";
27937
+ panel.dataset.harnessVersion = agent;
27938
+ const heading = document2.createElement("strong");
27939
+ heading.textContent = messages.harnessVersionTitle;
27940
+ const versions = document2.createElement("div");
27941
+ versions.className = "settings-harness-version__values";
27942
+ const current = document2.createElement("span");
27943
+ const latest = document2.createElement("span");
27944
+ versions.append(current, latest);
27945
+ const status = document2.createElement("p");
27946
+ status.setAttribute("role", "status");
27947
+ const actions = document2.createElement("div");
27948
+ actions.className = "settings-connection-error-actions";
27949
+ const update = document2.createElement("button");
27950
+ update.type = "button";
27951
+ update.className = "settings-command-button settings-command-button--secondary";
27952
+ update.dataset.harnessVersionAction = "update";
27953
+ const note = document2.createElement("p");
27954
+ note.className = "settings-connection-issue-note";
27955
+ note.textContent = messages.harnessVersionNote;
27956
+ actions.append(update);
27957
+ panel.append(heading, versions, status, actions, note);
27958
+ const render = () => {
27959
+ const state = session.state;
27960
+ const statusKind = session.statusKind;
27961
+ const busy = statusKind === "checking" || statusKind === "updating";
27962
+ heading.textContent = state?.versionKind === "application" ? messages.harnessVersionApplicationTitle : messages.harnessVersionTitle;
27963
+ current.textContent = `${messages.harnessVersionCurrent}: ${state?.currentVersion ?? "\u2014"}`;
27964
+ latest.textContent = `${messages.harnessVersionLatest}: ${harnessVersionLabel(state, messages.harnessVersion)}`;
27965
+ 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 : "";
27966
+ update.disabled = busy || signal.aborted || !state?.canUpdate || !state.updateAvailable;
27967
+ const manualUrl = !state?.canUpdate && state?.updateAvailable ? state.manualUpdateUrl : void 0;
27968
+ actions.replaceChildren(update);
27969
+ update.hidden = !busy && !signal.aborted && Boolean(manualUrl);
27970
+ if (update.hidden && manualUrl) {
27971
+ const download2 = document2.createElement("a");
27972
+ download2.className = "settings-command-button settings-command-button--secondary";
27973
+ download2.dataset.harnessVersionAction = "download-update";
27974
+ download2.textContent = messages.harnessVersionDownloadUpdate;
27975
+ download2.href = manualUrl;
27976
+ download2.target = "_blank";
27977
+ download2.rel = "noopener noreferrer";
27978
+ actions.append(download2);
27979
+ }
27980
+ update.textContent = state?.canUpdate && state.latestVersion !== "Unknown" && !state.updateAvailable ? messages.harnessVersionUpToDate : messages.harnessVersionUpdate;
27981
+ const detail = harnessVersionNote(state, messages.harnessVersion);
27982
+ note.textContent = detail ? !state?.canUpdate ? detail : `${detail} ${messages.harnessVersionNote}` : messages.harnessVersionNote;
27983
+ };
27984
+ update.addEventListener("click", () => {
27985
+ if (!signal.aborted) void session.update();
27590
27986
  });
27591
- let generation = 0;
27592
- input.addEventListener("change", () => {
27593
- const next = input.checked;
27594
- generation += 1;
27595
- const request = generation;
27596
- input.disabled = true;
27597
- input.setAttribute("aria-checked", String(next));
27598
- void actions.set(next).then(
27599
- (result) => {
27600
- if (request !== generation) return;
27601
- input.checked = result.enabled;
27602
- input.setAttribute("aria-checked", String(result.enabled));
27603
- input.disabled = false;
27604
- },
27605
- () => {
27606
- if (request !== generation) return;
27607
- input.checked = !next;
27608
- input.setAttribute("aria-checked", String(!next));
27609
- input.disabled = false;
27610
- }
27611
- );
27987
+ const unsubscribe = session.subscribe((pageChange) => {
27988
+ if (signal.aborted) return;
27989
+ render();
27990
+ if (pageChange) onChange();
27612
27991
  });
27613
- void actions.get().then(
27614
- (result) => {
27615
- if (generation !== 0) return;
27616
- input.checked = result.enabled;
27617
- input.setAttribute("aria-checked", String(result.enabled));
27992
+ const owner = document2.defaultView;
27993
+ let checkFrame = null;
27994
+ let checkTimer = null;
27995
+ signal.addEventListener(
27996
+ "abort",
27997
+ () => {
27998
+ unsubscribe();
27999
+ if (checkFrame !== null) owner?.cancelAnimationFrame(checkFrame);
28000
+ if (checkTimer !== null) owner?.clearTimeout(checkTimer);
28001
+ render();
27618
28002
  },
27619
- () => void 0
28003
+ { once: true }
27620
28004
  );
27621
- label.append(text, input);
27622
- control.append(label, tooltip);
27623
- return control;
28005
+ render();
28006
+ if (shouldScheduleCheck && !signal.aborted) {
28007
+ if (owner?.requestAnimationFrame) {
28008
+ checkFrame = owner.requestAnimationFrame(() => {
28009
+ checkFrame = null;
28010
+ if (signal.aborted) return;
28011
+ checkTimer = owner.setTimeout(() => {
28012
+ checkTimer = null;
28013
+ if (!signal.aborted) void session.check();
28014
+ }, 0);
28015
+ });
28016
+ } else {
28017
+ void session.check();
28018
+ }
28019
+ }
28020
+ return {
28021
+ element: panel,
28022
+ get state() {
28023
+ return session.state;
28024
+ },
28025
+ get updating() {
28026
+ return session.updating;
28027
+ },
28028
+ update: () => signal.aborted ? Promise.resolve(false) : session.update()
28029
+ };
27624
28030
  }
27625
28031
 
27626
- // src/settings/harness-installation-guides.ts
27627
- function harnessHasInstallCommands(plugin) {
27628
- return (plugin?.installation?.commands.length ?? 0) > 0;
28032
+ // src/settings/connection-versions.ts
28033
+ var sessionStores = /* @__PURE__ */ new WeakMap();
28034
+ function getSessionStore(diagnostics) {
28035
+ let store = sessionStores.get(diagnostics);
28036
+ if (!store) {
28037
+ store = /* @__PURE__ */ new Map();
28038
+ sessionStores.set(diagnostics, store);
28039
+ }
28040
+ return store;
27629
28041
  }
27630
- function harnessInstallationGuide(plugin, locale) {
27631
- const guide = plugin?.installation;
28042
+ function createConnectionVersions(document2, messages, signal, diagnostics, onChange) {
28043
+ const panels = /* @__PURE__ */ new Map();
28044
+ const installation = diagnostics?.installation?.bind(diagnostics);
28045
+ const sessions = diagnostics ? getSessionStore(diagnostics) : null;
28046
+ const sessionKey = (hostId2, agent) => JSON.stringify([hostId2, agent]);
28047
+ return {
28048
+ isUpdating(hostId2, agent) {
28049
+ return Boolean(sessions?.get(sessionKey(hostId2, agent))?.updating);
28050
+ },
28051
+ get(hostId2, agent) {
28052
+ if (!installation || signal.aborted) return void 0;
28053
+ const key = sessionKey(hostId2, agent);
28054
+ let panel = panels.get(key);
28055
+ if (!panel) {
28056
+ const run = (action) => installation(hostId2, agent, action);
28057
+ let session = sessions?.get(key);
28058
+ if (!session) {
28059
+ session = createHarnessVersionSession({ run });
28060
+ sessions?.set(key, session);
28061
+ }
28062
+ panel = createHarnessVersionPanel(
28063
+ document2,
28064
+ messages,
28065
+ signal,
28066
+ agent,
28067
+ { run },
28068
+ onChange,
28069
+ session
28070
+ );
28071
+ panels.set(key, panel);
28072
+ }
28073
+ return panel;
28074
+ }
28075
+ };
28076
+ }
28077
+
28078
+ // src/settings/harness-install-store.ts
28079
+ function errorMessage2(error51) {
28080
+ 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.";
28081
+ }
28082
+ function unknownInstallOutcome(message2) {
28083
+ return /outcome is unknown|do not retry automatically|did not answer in time/i.test(message2);
28084
+ }
28085
+ var stores = /* @__PURE__ */ new WeakMap();
28086
+ function createStore(diagnostics) {
28087
+ const states2 = /* @__PURE__ */ new Map();
28088
+ const listeners = /* @__PURE__ */ new Set();
28089
+ const key = (host, agent) => JSON.stringify([host, agent]);
28090
+ const notify2 = () => listeners.forEach((listener) => listener());
28091
+ return {
28092
+ get: (host, agent) => states2.get(key(host, agent)),
28093
+ clearErrors() {
28094
+ for (const [id, state] of states2) if (state.status === "error") states2.delete(id);
28095
+ notify2();
28096
+ },
28097
+ subscribe(listener) {
28098
+ listeners.add(listener);
28099
+ return () => {
28100
+ listeners.delete(listener);
28101
+ };
28102
+ },
28103
+ async install(host, agent) {
28104
+ const id = key(host, agent);
28105
+ const previous = states2.get(id);
28106
+ if (!diagnostics.installation || previous && previous.status !== "error") return;
28107
+ states2.set(id, { status: "installing" });
28108
+ notify2();
28109
+ let failure;
28110
+ try {
28111
+ await diagnostics.installation(host, agent, "install");
28112
+ states2.set(id, { status: "checking" });
28113
+ notify2();
28114
+ } catch (error51) {
28115
+ failure = errorMessage2(error51);
28116
+ }
28117
+ try {
28118
+ await diagnostics.refresh(host);
28119
+ const refreshed = diagnostics.snapshot().hosts.find((candidate) => candidate.hostId === host)?.agents.find((candidate) => candidate.agent === agent);
28120
+ if (refreshed?.availability === "ready") failure = void 0;
28121
+ else if (failure && unknownInstallOutcome(failure) && refreshed && refreshed.availability !== "notInstalled") {
28122
+ failure = void 0;
28123
+ }
28124
+ } catch (error51) {
28125
+ failure ??= errorMessage2(error51);
28126
+ }
28127
+ if (failure) states2.set(id, { status: "error", error: failure });
28128
+ else states2.delete(id);
28129
+ notify2();
28130
+ }
28131
+ };
28132
+ }
28133
+ function harnessInstallStore(diagnostics) {
28134
+ let store = stores.get(diagnostics);
28135
+ if (!store) {
28136
+ store = createStore(diagnostics);
28137
+ stores.set(diagnostics, store);
28138
+ }
28139
+ return store;
28140
+ }
28141
+
28142
+ // src/settings/harness-installation-guides.ts
28143
+ function harnessHasInstallCommands(plugin) {
28144
+ return (plugin?.installation?.commands.length ?? 0) > 0;
28145
+ }
28146
+ function harnessInstallationGuide(plugin, locale) {
28147
+ const guide = plugin?.installation;
27632
28148
  const text = (value) => value?.[locale] ?? value?.en;
27633
28149
  return {
27634
28150
  url: plugin?.links?.installation ?? plugin?.links?.documentation ?? plugin?.links?.website,
@@ -27720,402 +28236,248 @@ ${detail}` : ""}`
27720
28236
  return panel;
27721
28237
  }
27722
28238
 
27723
- // src/settings/harness-install-store.ts
27724
- function errorMessage2(error51) {
27725
- 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.";
27726
- }
27727
- function unknownInstallOutcome(message2) {
27728
- return /outcome is unknown|do not retry automatically|did not answer in time/i.test(message2);
27729
- }
27730
- var stores = /* @__PURE__ */ new WeakMap();
27731
- function createStore(diagnostics) {
27732
- const states2 = /* @__PURE__ */ new Map();
27733
- const listeners = /* @__PURE__ */ new Set();
27734
- const key = (host, agent) => JSON.stringify([host, agent]);
27735
- const notify2 = () => listeners.forEach((listener) => listener());
27736
- return {
27737
- get: (host, agent) => states2.get(key(host, agent)),
27738
- clearErrors() {
27739
- for (const [id, state] of states2) if (state.status === "error") states2.delete(id);
27740
- notify2();
27741
- },
27742
- subscribe(listener) {
27743
- listeners.add(listener);
27744
- return () => {
27745
- listeners.delete(listener);
27746
- };
27747
- },
27748
- async install(host, agent) {
27749
- const id = key(host, agent);
27750
- const previous = states2.get(id);
27751
- if (!diagnostics.installation || previous && previous.status !== "error") return;
27752
- states2.set(id, { status: "installing" });
27753
- notify2();
27754
- let failure;
27755
- try {
27756
- await diagnostics.installation(host, agent, "install");
27757
- states2.set(id, { status: "checking" });
27758
- notify2();
27759
- } catch (error51) {
27760
- failure = errorMessage2(error51);
27761
- }
27762
- try {
27763
- await diagnostics.refresh(host);
27764
- const refreshed = diagnostics.snapshot().hosts.find((candidate) => candidate.hostId === host)?.agents.find((candidate) => candidate.agent === agent);
27765
- if (refreshed?.availability === "ready") failure = void 0;
27766
- else if (failure && unknownInstallOutcome(failure) && refreshed && refreshed.availability !== "notInstalled") {
27767
- failure = void 0;
27768
- }
27769
- } catch (error51) {
27770
- failure ??= errorMessage2(error51);
27771
- }
27772
- if (failure) states2.set(id, { status: "error", error: failure });
27773
- else states2.delete(id);
27774
- notify2();
27775
- }
27776
- };
27777
- }
27778
- function harnessInstallStore(diagnostics) {
27779
- let store = stores.get(diagnostics);
27780
- if (!store) {
27781
- store = createStore(diagnostics);
27782
- stores.set(diagnostics, store);
27783
- }
27784
- return store;
27785
- }
27786
-
27787
- // src/settings/harness-version-panel.ts
27788
- function createHarnessVersionPanel(document2, messages, signal, agent, client, onChange = () => void 0) {
27789
- const panel = document2.createElement("section");
27790
- panel.className = "settings-harness-version";
27791
- panel.dataset.harnessVersion = agent;
27792
- const heading = document2.createElement("strong");
27793
- heading.textContent = messages.harnessVersionTitle;
27794
- const versions = document2.createElement("div");
27795
- versions.className = "settings-harness-version__values";
27796
- const current = document2.createElement("span");
27797
- const latest = document2.createElement("span");
27798
- versions.append(current, latest);
28239
+ // src/settings/harness-launch-controls.ts
28240
+ function createHarnessLaunchControls(document2, messages, agent, settings) {
28241
+ const section = document2.createElement("section");
28242
+ section.className = "settings-harness-launch";
28243
+ section.dataset.harnessLaunch = agent;
28244
+ const label = document2.createElement("label");
28245
+ label.textContent = messages.launchPathLabel;
28246
+ const input = document2.createElement("input");
28247
+ input.type = "text";
28248
+ input.autocomplete = "off";
28249
+ input.spellcheck = false;
28250
+ input.placeholder = messages.locale === "zh-CN" ? "\u5E94\u7528\u5B89\u88C5\u76EE\u5F55\u7684\u7EDD\u5BF9\u8DEF\u5F84" : "Absolute installation directory";
28251
+ input.setAttribute("aria-label", messages.launchPathLabel);
28252
+ label.append(input);
28253
+ const help = document2.createElement("p");
28254
+ 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.";
28255
+ const actions = document2.createElement("div");
28256
+ actions.className = "settings-harness-launch__actions";
28257
+ const save = document2.createElement("button");
28258
+ save.type = "button";
28259
+ save.className = "settings-command-button";
28260
+ save.textContent = messages.launchPathSave;
28261
+ const reset = document2.createElement("button");
28262
+ reset.type = "button";
28263
+ reset.className = "settings-command-button settings-command-button--secondary";
28264
+ reset.textContent = messages.launchPathReset;
27799
28265
  const status = document2.createElement("p");
27800
28266
  status.setAttribute("role", "status");
27801
- const actions = document2.createElement("div");
27802
- actions.className = "settings-connection-error-actions";
27803
- const update = document2.createElement("button");
27804
- update.type = "button";
27805
- update.className = "settings-command-button settings-command-button--secondary";
27806
- update.dataset.harnessVersionAction = "update";
27807
- const note = document2.createElement("p");
27808
- note.className = "settings-connection-issue-note";
27809
- note.textContent = messages.harnessVersionNote;
27810
- actions.append(update);
27811
- panel.append(heading, versions, status, actions, note);
27812
- let state;
27813
- let busy = false;
27814
- let updating = false;
27815
- let unsupported = false;
27816
- let updatePromise = null;
27817
- const render = () => {
27818
- heading.textContent = state?.versionKind === "application" ? messages.harnessVersionApplicationTitle : messages.harnessVersionTitle;
27819
- current.textContent = `${messages.harnessVersionCurrent}: ${state?.currentVersion ?? "\u2014"}`;
27820
- latest.textContent = `${messages.harnessVersionLatest}: ${harnessVersionLabel(state, messages.harnessVersion)}`;
27821
- update.disabled = busy || signal.aborted || !state?.canUpdate || !state.updateAvailable;
27822
- const manualUrl = !state?.canUpdate && state?.updateAvailable ? state.manualUpdateUrl : void 0;
27823
- actions.replaceChildren(update);
27824
- update.hidden = !busy && !signal.aborted && Boolean(manualUrl);
27825
- if (update.hidden && manualUrl) {
27826
- const download2 = document2.createElement("a");
27827
- download2.className = "settings-command-button settings-command-button--secondary";
27828
- download2.dataset.harnessVersionAction = "download-update";
27829
- download2.textContent = messages.harnessVersionDownloadUpdate;
27830
- download2.href = manualUrl;
27831
- download2.target = "_blank";
27832
- download2.rel = "noopener noreferrer";
27833
- actions.append(download2);
27834
- }
27835
- update.textContent = state?.canUpdate && state.latestVersion !== "Unknown" && !state.updateAvailable ? messages.harnessVersionUpToDate : messages.harnessVersionUpdate;
27836
- const detail = harnessVersionNote(state, messages.harnessVersion);
27837
- note.textContent = detail ? !state?.canUpdate ? detail : `${detail} ${messages.harnessVersionNote}` : messages.harnessVersionNote;
28267
+ status.setAttribute("aria-live", "polite");
28268
+ actions.append(save, reset);
28269
+ section.append(label, help, actions, status);
28270
+ let busy = true;
28271
+ let loaded = false;
28272
+ const controls = () => {
28273
+ input.disabled = busy || !loaded;
28274
+ save.disabled = busy || !loaded || !input.value.trim();
28275
+ reset.disabled = busy || !loaded;
28276
+ };
28277
+ const show = (value) => {
28278
+ input.value = value.path ?? "";
28279
+ status.textContent = value.restartRequired ? messages.launchPathRestart : value.path ? messages.launchPathSaved : messages.launchPathAutomatic;
27838
28280
  };
27839
- const run = async (action) => {
27840
- if (busy || unsupported || signal.aborted) return false;
27841
- if (action === "update" && (!state?.canUpdate || !state.updateAvailable)) return false;
28281
+ const persist = async (value) => {
28282
+ if (busy || !loaded) return;
27842
28283
  busy = true;
27843
- updating = action === "update";
27844
- onChange();
27845
- status.textContent = action === "check" ? messages.harnessVersionChecking : messages.harnessVersionUpdating;
27846
- render();
28284
+ controls();
28285
+ status.textContent = messages.launchPathSaving;
27847
28286
  try {
27848
- const result = await client.run(action);
27849
- if (signal.aborted) return false;
27850
- state = result;
27851
- status.textContent = !result.canUpdate ? messages.harnessVersionManual : action === "update" ? result.updateAvailable ? messages.harnessVersionFailed : messages.harnessVersionUpdated : "";
27852
- return result.canUpdate && !result.updateAvailable;
27853
- } catch (error51) {
27854
- if (signal.aborted) return false;
27855
- unsupported = typeof error51 === "object" && error51 !== null && "code" in error51 && (error51.code === -32601 || error51.code === -32078);
27856
- status.textContent = unsupported ? messages.harnessVersionUnsupported : messages.harnessVersionFailed;
27857
- if (state) state = { ...state, canUpdate: false };
27858
- return false;
28287
+ show(await settings.set(value));
28288
+ } catch {
28289
+ status.textContent = messages.launchPathSaveError;
27859
28290
  } finally {
27860
28291
  busy = false;
27861
- updating = false;
27862
- if (!signal.aborted) {
27863
- render();
27864
- onChange();
27865
- }
28292
+ controls();
27866
28293
  }
27867
28294
  };
27868
- const updateVersion = () => {
27869
- updatePromise ??= run("update").finally(() => {
27870
- updatePromise = null;
27871
- });
27872
- return updatePromise;
27873
- };
27874
- update.addEventListener("click", () => void updateVersion());
27875
- const owner = document2.defaultView;
27876
- let checkFrame = null;
27877
- let checkTimer = null;
27878
- signal.addEventListener(
27879
- "abort",
27880
- () => {
27881
- if (checkFrame !== null) owner?.cancelAnimationFrame(checkFrame);
27882
- if (checkTimer !== null) owner?.clearTimeout(checkTimer);
27883
- render();
27884
- },
27885
- { once: true }
27886
- );
27887
- status.textContent = messages.harnessVersionChecking;
27888
- render();
27889
- if (!signal.aborted && owner?.requestAnimationFrame) {
27890
- checkFrame = owner.requestAnimationFrame(() => {
27891
- checkFrame = null;
27892
- if (signal.aborted) return;
27893
- checkTimer = owner.setTimeout(() => {
27894
- checkTimer = null;
27895
- void run("check");
27896
- }, 0);
27897
- });
27898
- } else {
27899
- void run("check");
27900
- }
27901
- return {
27902
- element: panel,
27903
- get state() {
27904
- return state;
27905
- },
27906
- get updating() {
27907
- return updating;
27908
- },
27909
- update: updateVersion
27910
- };
28295
+ input.addEventListener("input", controls);
28296
+ save.addEventListener("click", () => {
28297
+ if (input.value.trim()) void persist(input.value.trim());
28298
+ });
28299
+ reset.addEventListener("click", () => {
28300
+ void persist(null);
28301
+ });
28302
+ controls();
28303
+ status.textContent = messages.launchPathLoading;
28304
+ void settings.get().then((value) => {
28305
+ loaded = true;
28306
+ show(value);
28307
+ }).catch(() => {
28308
+ loaded = true;
28309
+ status.textContent = messages.launchPathLoadError;
28310
+ }).finally(() => {
28311
+ busy = false;
28312
+ controls();
28313
+ });
28314
+ return section;
27911
28315
  }
27912
28316
 
27913
- // src/settings/connection-versions.ts
27914
- function createConnectionVersions(document2, messages, signal, diagnostics, onChange) {
27915
- const panels = /* @__PURE__ */ new Map();
27916
- const installation = diagnostics?.installation?.bind(diagnostics);
27917
- return {
27918
- get(hostId2, agent) {
27919
- if (!installation || signal.aborted) return void 0;
27920
- const key = JSON.stringify([hostId2, agent]);
27921
- let panel = panels.get(key);
27922
- if (!panel) {
27923
- panel = createHarnessVersionPanel(
27924
- document2,
27925
- messages,
27926
- signal,
27927
- agent,
27928
- {
27929
- run: (action) => installation(hostId2, agent, action)
27930
- },
27931
- onChange
27932
- );
27933
- panels.set(key, panel);
28317
+ // src/settings/claude-long-context-control.ts
28318
+ var CLAUDE_LONG_CONTEXT_MODELS = [{ id: "claude-opus-5-5", window: "1M" }];
28319
+ var tooltipSequence = 0;
28320
+ function popoverOpen(tooltip) {
28321
+ try {
28322
+ return tooltip.matches(":popover-open");
28323
+ } catch {
28324
+ return false;
28325
+ }
28326
+ }
28327
+ function createClaudeLongContextControl(document2, messages, actions) {
28328
+ const control = document2.createElement("span");
28329
+ control.className = "settings-connection-long-context";
28330
+ const label = document2.createElement("label");
28331
+ label.className = "settings-connection-long-context__control";
28332
+ const text = document2.createElement("span");
28333
+ text.textContent = messages.connectionLongContextLabel;
28334
+ const input = document2.createElement("input");
28335
+ input.type = "checkbox";
28336
+ input.checked = true;
28337
+ input.setAttribute("role", "switch");
28338
+ input.setAttribute("aria-checked", "true");
28339
+ input.setAttribute("aria-label", messages.connectionLongContextLabel);
28340
+ input.dataset.connectionAction = "long-context";
28341
+ const tooltip = document2.createElement("div");
28342
+ tooltip.id = `settings-long-context-tooltip-${++tooltipSequence}`;
28343
+ tooltip.className = "settings-connection-long-context__tooltip";
28344
+ tooltip.setAttribute("role", "tooltip");
28345
+ tooltip.setAttribute("popover", "manual");
28346
+ tooltip.hidden = true;
28347
+ const on = document2.createElement("p");
28348
+ on.textContent = messages.connectionLongContextOn;
28349
+ const off = document2.createElement("p");
28350
+ off.textContent = messages.connectionLongContextOff;
28351
+ const modelsLabel = document2.createElement("p");
28352
+ modelsLabel.textContent = messages.connectionLongContextModelsLabel;
28353
+ const models = document2.createElement("ul");
28354
+ for (const model2 of CLAUDE_LONG_CONTEXT_MODELS) {
28355
+ const item = document2.createElement("li");
28356
+ item.textContent = `${model2.id} (${model2.window})`;
28357
+ models.append(item);
28358
+ }
28359
+ tooltip.append(on, off, modelsLabel, models);
28360
+ input.setAttribute("aria-describedby", tooltip.id);
28361
+ const stop = (event) => {
28362
+ event.stopPropagation();
28363
+ };
28364
+ control.addEventListener("click", stop);
28365
+ label.addEventListener("click", stop);
28366
+ input.addEventListener("click", stop);
28367
+ let surfaceReady = false;
28368
+ const applyTooltipSurface = () => {
28369
+ if (surfaceReady) return;
28370
+ const probe = document2.createElement("span");
28371
+ probe.style.cssText = "position:absolute;visibility:hidden;color:var(--settings-text);background-color:var(--settings-elevated);border-top-color:var(--settings-border)";
28372
+ control.append(probe);
28373
+ const computed = document2.defaultView?.getComputedStyle(probe);
28374
+ const color = computed?.color;
28375
+ const background = computed?.backgroundColor;
28376
+ const borderColor = computed?.borderTopColor;
28377
+ probe.remove();
28378
+ if (color) tooltip.style.color = color;
28379
+ if (background && background !== "rgba(0, 0, 0, 0)") tooltip.style.backgroundColor = background;
28380
+ if (borderColor) tooltip.style.border = `1px solid ${borderColor}`;
28381
+ surfaceReady = true;
28382
+ };
28383
+ const showTooltip = () => {
28384
+ const root = control.getRootNode();
28385
+ const host = root instanceof ShadowRoot ? root : document2.body ?? control;
28386
+ if (tooltip.parentNode !== host) host.append(tooltip);
28387
+ applyTooltipSurface();
28388
+ tooltip.hidden = false;
28389
+ if (typeof tooltip.showPopover === "function" && !popoverOpen(tooltip)) {
28390
+ try {
28391
+ tooltip.showPopover();
28392
+ } catch {
28393
+ tooltip.removeAttribute("popover");
27934
28394
  }
27935
- return panel;
27936
28395
  }
27937
- };
27938
- }
27939
-
27940
- // src/settings/connection-updates.ts
27941
- function createConnectionUpdates(document2, messages, signal, onChange) {
27942
- const batches = /* @__PURE__ */ new Map();
27943
- const eligible = (panels) => panels.filter((panel) => panel.state?.updateAvailable && panel.state.canUpdate);
27944
- const start = async (hostId2, panels) => {
27945
- if (signal.aborted || batches.get(hostId2)?.running) return;
27946
- const targets = eligible(panels);
27947
- if (!targets.length) return;
27948
- const batch = { running: true, total: targets.length, succeeded: 0, failed: 0 };
27949
- batches.set(hostId2, batch);
27950
- onChange();
27951
- await Promise.all(
27952
- targets.map(async (panel) => {
27953
- try {
27954
- if (await panel.update()) batch.succeeded++;
27955
- else batch.failed++;
27956
- } catch {
27957
- batch.failed++;
27958
- }
27959
- if (!signal.aborted) onChange();
27960
- })
28396
+ tooltip.style.position = "fixed";
28397
+ tooltip.style.inset = "auto";
28398
+ tooltip.style.zIndex = "80";
28399
+ tooltip.style.margin = "0";
28400
+ tooltip.style.height = "auto";
28401
+ tooltip.style.overflow = "visible";
28402
+ const rect = control.getBoundingClientRect();
28403
+ const margin = 8;
28404
+ const width = Math.min(280, Math.max(160, window.innerWidth - margin * 2));
28405
+ tooltip.style.width = `${width}px`;
28406
+ const preferredLeft = Math.min(
28407
+ Math.max(margin, rect.right - width),
28408
+ window.innerWidth - width - margin
27961
28409
  );
27962
- batch.running = false;
27963
- if (!signal.aborted) onChange();
28410
+ const height = tooltip.offsetHeight;
28411
+ const below = rect.bottom + 8;
28412
+ const preferredTop = below + height <= window.innerHeight - margin ? below : Math.max(margin, rect.top - height - 8);
28413
+ tooltip.style.left = `${preferredLeft}px`;
28414
+ tooltip.style.top = `${preferredTop}px`;
28415
+ const placed = tooltip.getBoundingClientRect();
28416
+ const shiftX = preferredLeft - placed.left;
28417
+ const shiftY = preferredTop - placed.top;
28418
+ if (Math.abs(shiftX) > 0.5 || Math.abs(shiftY) > 0.5) {
28419
+ tooltip.style.left = `${preferredLeft + shiftX}px`;
28420
+ tooltip.style.top = `${preferredTop + shiftY}px`;
28421
+ }
27964
28422
  };
27965
- return {
27966
- createControls(hostId2, panels) {
27967
- const batch = batches.get(hostId2);
27968
- const count3 = eligible(panels).length;
27969
- const button2 = document2.createElement("button");
27970
- button2.type = "button";
27971
- button2.className = "settings-command-button settings-command-button--secondary settings-connection-update-all";
27972
- button2.dataset.connectionAction = "update-all";
27973
- button2.disabled = signal.aborted || Boolean(batch?.running) || !count3;
27974
- button2.title = messages.harnessUpdateAllDescription;
27975
- const label = batch?.running ? `${messages.harnessUpdateAllProgress} ${batch.succeeded + batch.failed}/${batch.total}` : count3 ? `${messages.harnessUpdateAll} (${count3})` : messages.harnessUpdateAll;
27976
- button2.append(createRendererSettingsIcon("download", 15), label);
27977
- button2.addEventListener("click", () => {
27978
- if (!button2.disabled) void start(hostId2, panels);
27979
- });
27980
- const result = document2.createElement("p");
27981
- result.className = "settings-connection-update-result";
27982
- result.setAttribute("role", "status");
27983
- result.hidden = !batch || batch.running;
27984
- if (batch && !batch.running) {
27985
- result.textContent = messages.harnessUpdateAllResult.replace("{succeeded}", String(batch.succeeded)).replace("{failed}", String(batch.failed));
27986
- }
27987
- return { button: button2, result };
27988
- }
27989
- };
27990
- }
27991
-
27992
- // src/settings/selection-scroll.ts
27993
- var SELECTION_CONTROL_SELECTOR = "button, a, input, textarea, select, label";
27994
- function upwardScrollTop(saved, current) {
27995
- return current < saved ? saved : current;
27996
- }
27997
- function isPrimaryPointer(event) {
27998
- return "button" in event && event.button === 0;
27999
- }
28000
- function canScrollVertically(element) {
28001
- if (element.scrollHeight <= element.clientHeight + 1) return false;
28002
- const view = element.ownerDocument.defaultView;
28003
- if (!view) return false;
28004
- const overflow = view.getComputedStyle(element).overflowY;
28005
- return overflow === "auto" || overflow === "scroll" || overflow === "overlay";
28006
- }
28007
- function verticalScrollers(target2, page) {
28008
- const scrollers = [];
28009
- let node = target2;
28010
- while (node) {
28011
- if (node instanceof HTMLElement && canScrollVertically(node)) scrollers.push(node);
28012
- if (node === page) break;
28013
- node = node.parentElement;
28014
- }
28015
- if (!scrollers.includes(page) && canScrollVertically(page)) scrollers.push(page);
28016
- return scrollers;
28017
- }
28018
- function pointerOnScrollbar(target2, scroller, event) {
28019
- return target2 === scroller && event.offsetX >= scroller.clientWidth;
28020
- }
28021
- function keepPageStillDuringTextSelection(region) {
28022
- const view = () => region.ownerDocument.defaultView;
28023
- let session = null;
28024
- const detach = () => {
28025
- if (!session) return;
28026
- const document2 = region.ownerDocument;
28027
- for (const scroller of session.tops.keys()) {
28028
- scroller.removeEventListener("scroll", session.onScroll);
28029
- }
28030
- document2.removeEventListener("pointerup", session.onPointerUp);
28031
- document2.removeEventListener("pointercancel", session.onCancel);
28032
- document2.removeEventListener("wheel", session.onWheel);
28033
- if (session.frame) view()?.cancelAnimationFrame(session.frame);
28034
- session = null;
28035
- };
28036
- let restoring = false;
28037
- const restore = () => {
28038
- if (!session || restoring) return;
28039
- restoring = true;
28040
- try {
28041
- for (const [scroller, top] of session.tops) {
28042
- const next = upwardScrollTop(top, scroller.scrollTop);
28043
- if (next !== scroller.scrollTop) scroller.scrollTop = next;
28044
- else if (scroller.scrollTop > top) session.tops.set(scroller, scroller.scrollTop);
28423
+ const hideTooltip = () => {
28424
+ if (typeof tooltip.hidePopover === "function" && popoverOpen(tooltip)) {
28425
+ try {
28426
+ tooltip.hidePopover();
28427
+ } catch {
28428
+ }
28429
+ }
28430
+ tooltip.hidden = true;
28431
+ };
28432
+ control.addEventListener("mouseenter", showTooltip);
28433
+ control.addEventListener("mouseleave", hideTooltip);
28434
+ control.addEventListener("focusin", showTooltip);
28435
+ control.addEventListener("focusout", (event) => {
28436
+ const next = event.relatedTarget;
28437
+ if (next instanceof Node && control.contains(next)) return;
28438
+ hideTooltip();
28439
+ });
28440
+ let generation = 0;
28441
+ input.addEventListener("change", () => {
28442
+ const next = input.checked;
28443
+ generation += 1;
28444
+ const request = generation;
28445
+ input.disabled = true;
28446
+ input.setAttribute("aria-checked", String(next));
28447
+ void actions.set(next).then(
28448
+ (result) => {
28449
+ if (request !== generation) return;
28450
+ input.checked = result.enabled;
28451
+ input.setAttribute("aria-checked", String(result.enabled));
28452
+ input.disabled = false;
28453
+ },
28454
+ () => {
28455
+ if (request !== generation) return;
28456
+ input.checked = !next;
28457
+ input.setAttribute("aria-checked", String(!next));
28458
+ input.disabled = false;
28045
28459
  }
28046
- } finally {
28047
- restoring = false;
28048
- }
28049
- };
28050
- region.addEventListener("pointerdown", (event) => {
28051
- if (!isPrimaryPointer(event)) return;
28052
- const target2 = event.target;
28053
- if (!(target2 instanceof Element) || target2.closest(SELECTION_CONTROL_SELECTOR)) return;
28054
- const page = region.closest(".settings-page");
28055
- if (!(page instanceof HTMLElement)) return;
28056
- detach();
28057
- const tops = /* @__PURE__ */ new Map();
28058
- for (const scroller of verticalScrollers(target2, page)) {
28059
- if (pointerOnScrollbar(target2, scroller, event)) continue;
28060
- tops.set(scroller, scroller.scrollTop);
28061
- }
28062
- if (tops.size === 0) return;
28063
- const onScroll = () => restore();
28064
- const onPointerUp = () => {
28065
- restore();
28066
- if (!session) return;
28067
- session.framesLeft = 2;
28068
- const finish = () => {
28069
- if (!session) return;
28070
- restore();
28071
- session.framesLeft -= 1;
28072
- const owner2 = view();
28073
- if (session.framesLeft > 0 && owner2?.requestAnimationFrame) {
28074
- session.frame = owner2.requestAnimationFrame(finish);
28075
- return;
28076
- }
28077
- detach();
28078
- };
28079
- const owner = view();
28080
- if (owner?.requestAnimationFrame) session.frame = owner.requestAnimationFrame(finish);
28081
- else detach();
28082
- };
28083
- const onCancel = () => detach();
28084
- const onWheel = () => detach();
28085
- session = { tops, frame: 0, framesLeft: 0, onScroll, onPointerUp, onCancel, onWheel };
28086
- const document2 = region.ownerDocument;
28087
- for (const scroller of tops.keys()) scroller.addEventListener("scroll", onScroll);
28088
- document2.addEventListener("pointerup", onPointerUp);
28089
- document2.addEventListener("pointercancel", onCancel);
28090
- document2.addEventListener("wheel", onWheel, { passive: true });
28460
+ );
28091
28461
  });
28462
+ void actions.get().then(
28463
+ (result) => {
28464
+ if (generation !== 0) return;
28465
+ input.checked = result.enabled;
28466
+ input.setAttribute("aria-checked", String(result.enabled));
28467
+ },
28468
+ () => void 0
28469
+ );
28470
+ label.append(text, input);
28471
+ control.append(label, tooltip);
28472
+ return control;
28092
28473
  }
28093
28474
 
28094
28475
  // src/settings/connections-page.ts
28095
28476
  var CODEXHOST_GITHUB_ISSUES_NEW_URL = "https://github.com/LIBERSEEK/BOFT-CLI/issues/new";
28096
- function connectionStatusLabel(availability, messages, hasError = false) {
28097
- if (availability === "updating") return messages.connectionStatusUpdating;
28098
- if (hasError && availability !== "notInstalled") return messages.connectionStatusError;
28099
- if (availability === "ready") return messages.connectionStatusReady;
28100
- if (availability === "checking") return messages.connectionStatusChecking;
28101
- if (availability === "notInstalled") return messages.connectionStatusNotInstalled;
28102
- if (availability === "unavailable" || availability === "error") {
28103
- return availability === "error" ? messages.connectionStatusError : messages.connectionStatusUnavailable;
28104
- }
28105
- return availability === "installing" ? messages.connectionStatusInstalling : messages.connectionStatusUnsupported;
28106
- }
28107
- function connectionStatusTone(availability, hasError = false) {
28108
- if (availability === "updating") return "checking";
28109
- if (hasError && availability !== "notInstalled") return "failed";
28110
- if (availability === "ready") return "ready";
28111
- if (availability === "checking" || availability === "installing") return "checking";
28112
- if (availability === "notInstalled") return "setup";
28113
- return "failed";
28114
- }
28115
28477
  function diagnosticText(hostId2, item) {
28116
28478
  const error51 = item.error;
28117
28479
  return [
28118
- "BOFT CLI connection diagnostics",
28480
+ "codexhost connection diagnostics",
28119
28481
  `host: ${hostId2}`,
28120
28482
  `agent: ${item.name}`,
28121
28483
  `status: ${item.availability}`,
@@ -28207,147 +28569,21 @@ ${error51.stderrTail}`] : []
28207
28569
  tabs.addEventListener("wheel", onWheel, { passive: false });
28208
28570
  const ownerWindow = document2.defaultView;
28209
28571
  ownerWindow?.addEventListener("resize", updateButtons);
28210
- ownerWindow?.setTimeout(updateButtons, 0);
28211
- updateButtons();
28212
- return () => {
28213
- left.removeEventListener("click", onLeft);
28214
- right.removeEventListener("click", onRight);
28215
- tabs.removeEventListener("scroll", updateButtons);
28216
- tabs.removeEventListener("wheel", onWheel);
28217
- ownerWindow?.removeEventListener("resize", updateButtons);
28572
+ const refreshLayout = () => {
28573
+ ownerWindow?.setTimeout(updateButtons, 0);
28574
+ updateButtons();
28575
+ };
28576
+ refreshLayout();
28577
+ return {
28578
+ update: refreshLayout,
28579
+ dispose() {
28580
+ left.removeEventListener("click", onLeft);
28581
+ right.removeEventListener("click", onRight);
28582
+ tabs.removeEventListener("scroll", updateButtons);
28583
+ tabs.removeEventListener("wheel", onWheel);
28584
+ ownerWindow?.removeEventListener("resize", updateButtons);
28585
+ }
28218
28586
  };
28219
- }
28220
- function createConnectionIdentityIcon(document2, item, size) {
28221
- const container = document2.createElement("span");
28222
- container.className = item.agentSnapshot ? "settings-connection-row__mark settings-connection-row__mark--logo" : "settings-connection-row__mark";
28223
- container.setAttribute("aria-hidden", "true");
28224
- if (item.agentSnapshot) {
28225
- container.append(
28226
- createRendererAgentIcon(item.agentSnapshot.agent, size, document2, item.agentSnapshot.plugin)
28227
- );
28228
- } else {
28229
- container.textContent = "CH";
28230
- }
28231
- return container;
28232
- }
28233
- function createConnectionRow(document2, item, messages, selected, select, group = null, longContext = null) {
28234
- const row = document2.createElement("div");
28235
- row.className = "settings-connection-row";
28236
- row.dataset.connectionItem = item.key;
28237
- row.dataset.connectionSelected = String(selected);
28238
- row.tabIndex = selected ? 0 : -1;
28239
- row.setAttribute("role", "row");
28240
- const identity2 = document2.createElement("div");
28241
- identity2.className = "settings-connection-row__identity";
28242
- identity2.setAttribute("role", "cell");
28243
- const handle = group ? document2.createElement("span") : null;
28244
- if (group && handle) {
28245
- handle.className = "settings-connection-row__handle";
28246
- handle.setAttribute("aria-hidden", "true");
28247
- handle.title = group.dragHandleTitle;
28248
- handle.append(createRendererSettingsIcon("grip-vertical", 15));
28249
- identity2.append(handle);
28250
- }
28251
- const label = document2.createElement("strong");
28252
- label.textContent = item.name;
28253
- identity2.append(createConnectionIdentityIcon(document2, item, 19), label);
28254
- const status = document2.createElement("span");
28255
- status.className = "settings-connection-row__status";
28256
- status.dataset.connectionTone = connectionStatusTone(item.availability, item.error !== null);
28257
- status.setAttribute("role", "cell");
28258
- status.textContent = item.error?.code === "authenticationRequired" ? messages.connectionLoginRequired : item.error?.code === "configurationRequired" ? messages.connectionConfigurationRequired : connectionStatusLabel(item.availability, messages, item.error !== null);
28259
- const version2 = item.version;
28260
- const action = document2.createElement("div");
28261
- action.className = "settings-connection-row__action";
28262
- action.setAttribute("role", "cell");
28263
- if (item.error && item.agentSnapshot?.availability !== "notInstalled") {
28264
- const viewError = document2.createElement("button");
28265
- viewError.type = "button";
28266
- viewError.className = "settings-connection-view-error";
28267
- viewError.textContent = messages.connectionViewError;
28268
- viewError.addEventListener("click", (event) => {
28269
- event.stopPropagation();
28270
- select();
28271
- });
28272
- action.append(viewError);
28273
- }
28274
- if (longContext) action.append(longContext);
28275
- if (version2?.state?.updateAvailable && version2.state.canUpdate) {
28276
- const update = document2.createElement("button");
28277
- update.type = "button";
28278
- update.className = "settings-connection-install-link";
28279
- update.dataset.connectionAction = "update";
28280
- update.disabled = version2.updating;
28281
- update.title = `${messages.harnessVersionUpdate}: ${item.name}
28282
- ${messages.harnessVersionCurrent}: ${version2.state.currentVersion ?? "\u2014"}
28283
- ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages.harnessVersion)}`;
28284
- update.setAttribute("aria-label", `${messages.harnessVersionUpdate}: ${item.name}`);
28285
- update.append(createRendererSettingsIcon("download", 15));
28286
- update.addEventListener("click", (event) => {
28287
- event.stopPropagation();
28288
- if (update.disabled) return;
28289
- void version2.update();
28290
- select();
28291
- });
28292
- action.append(update);
28293
- }
28294
- if (group) {
28295
- const toggle = document2.createElement("button");
28296
- toggle.type = "button";
28297
- toggle.disabled = group.disabled;
28298
- toggle.className = "settings-connection-row__group-toggle";
28299
- toggle.title = group.moveLabel;
28300
- toggle.setAttribute("aria-label", group.moveLabel);
28301
- toggle.append(
28302
- createRendererSettingsIcon(group.section === "main" ? "chevron-down" : "chevron-up", 15)
28303
- );
28304
- toggle.addEventListener("click", (event) => {
28305
- event.stopPropagation();
28306
- group.toggleSection();
28307
- });
28308
- action.append(toggle);
28309
- }
28310
- row.addEventListener("click", (event) => {
28311
- const target2 = event.target;
28312
- if (target2?.closest?.("a, input, label")) return;
28313
- select();
28314
- });
28315
- row.addEventListener("keydown", (event) => {
28316
- if (event.target?.closest?.("button, a")) return;
28317
- if (event.key !== "Enter" && event.key !== " ") return;
28318
- event.preventDefault();
28319
- select();
28320
- });
28321
- if (group && handle) {
28322
- row.draggable = false;
28323
- row.dataset.connectionGroupSection = group.section;
28324
- handle.addEventListener("pointerdown", (event) => {
28325
- if (group.disabled || event.button !== 0) return;
28326
- row.draggable = true;
28327
- });
28328
- const releaseDrag = () => {
28329
- if (row.dataset.connectionDragging === "true") return;
28330
- row.draggable = false;
28331
- };
28332
- row.addEventListener("pointerup", releaseDrag);
28333
- row.addEventListener("pointercancel", releaseDrag);
28334
- row.addEventListener("dragstart", (event) => {
28335
- if (!row.draggable) {
28336
- event.preventDefault();
28337
- return;
28338
- }
28339
- group.onDragStart(event);
28340
- });
28341
- row.addEventListener("dragover", group.onDragOver);
28342
- row.addEventListener("dragleave", group.onDragLeave);
28343
- row.addEventListener("drop", group.onDrop);
28344
- row.addEventListener("dragend", (event) => {
28345
- row.draggable = false;
28346
- group.onDragEnd(event);
28347
- });
28348
- }
28349
- row.append(identity2, status, action);
28350
- return row;
28351
28587
  }
28352
28588
  function createInspectorHeader(document2, item, messages) {
28353
28589
  const header = document2.createElement("header");
@@ -28377,7 +28613,30 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28377
28613
  header.append(identity2, status);
28378
28614
  return header;
28379
28615
  }
28380
- function renderConnectionInspector(document2, inspector, item, hostId2, messages, diagnostics, existingLaunchControls, refresh, openExternalUrl) {
28616
+ function inspectorRenderSignature(hostId2, item, messages, diagnostics) {
28617
+ const plugin = item.agentSnapshot?.plugin;
28618
+ const notice = plugin?.notice ? plugin.notice[messages.locale] ?? plugin.notice.en : "";
28619
+ const websiteUrl = plugin?.links?.website ?? plugin?.links?.documentation ?? "";
28620
+ const hasLaunchControls = hostId2 === "local" && Boolean(item.agentSnapshot?.agent) && Boolean(plugin?.launchCommand) && Boolean(diagnostics?.getLaunchSettings && diagnostics?.setLaunchSettings);
28621
+ return JSON.stringify([
28622
+ hostId2,
28623
+ item.key,
28624
+ item.name,
28625
+ item.availability,
28626
+ item.agentSnapshot?.availability ?? null,
28627
+ String(plugin?.icon ?? ""),
28628
+ String(plugin?.iconStyle ?? ""),
28629
+ websiteUrl,
28630
+ notice,
28631
+ item.installError ?? "",
28632
+ Boolean(item.install),
28633
+ plugin?.installation ?? null,
28634
+ Boolean(item.openWebUi),
28635
+ hasLaunchControls,
28636
+ item.error ? diagnosticText(hostId2, item) : ""
28637
+ ]);
28638
+ }
28639
+ function renderConnectionInspector(document2, inspector, item, hostId2, messages, diagnostics, existingLaunchControls, refresh, getOpenExternalUrl) {
28381
28640
  inspector.replaceChildren(createInspectorHeader(document2, item, messages));
28382
28641
  const body = document2.createElement("div");
28383
28642
  body.className = "settings-connection-inspector__body";
@@ -28463,14 +28722,10 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28463
28722
  issue2.target = "_blank";
28464
28723
  issue2.rel = "noopener noreferrer";
28465
28724
  issue2.addEventListener("click", (event) => {
28466
- const open = openExternalUrl();
28467
- if (!open) return;
28725
+ const openExternalUrl = getOpenExternalUrl?.();
28726
+ if (!openExternalUrl) return;
28468
28727
  event.preventDefault();
28469
- const url2 = issue2.href;
28470
- void open(url2).catch((error51) => {
28471
- console.error("codexhost external URL open failed", error51);
28472
- document2.defaultView?.open(url2, "_blank", "noopener,noreferrer");
28473
- });
28728
+ void openExternalUrl(CODEXHOST_GITHUB_ISSUES_NEW_URL);
28474
28729
  });
28475
28730
  issue2.append(messages.connectionOpenIssue, createRendererSettingsIcon("external-link", 14));
28476
28731
  actions.append(issue2);
@@ -28522,12 +28777,6 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28522
28777
  }
28523
28778
  function connectionItems(snapshot, host, messages, diagnostics) {
28524
28779
  return [
28525
- {
28526
- key: "renderer-adapter",
28527
- name: messages.connectionAdapter,
28528
- availability: snapshot.adapter.state,
28529
- error: null
28530
- },
28531
28780
  ...host.directoryError ? [
28532
28781
  {
28533
28782
  key: "plugin-directory",
@@ -28549,11 +28798,10 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28549
28798
  ];
28550
28799
  }
28551
28800
  var pendingFocusAgent = null;
28552
- function createGroupDivider(document2, messages, count3) {
28801
+ function createGroupDivider(document2) {
28553
28802
  const divider = document2.createElement("div");
28554
28803
  divider.className = "settings-connection-group-divider";
28555
28804
  divider.setAttribute("role", "presentation");
28556
- divider.textContent = `${messages.connectionGroupMoreLabel} (${count3})`;
28557
28805
  return divider;
28558
28806
  }
28559
28807
  function createGroupMoreHint(document2, messages) {
@@ -28575,7 +28823,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28575
28823
  button2.addEventListener("click", onReset);
28576
28824
  return button2;
28577
28825
  }
28578
- function createConnectionsSettingsPage(messages, getDiagnostics, groupPreference = getSharedAgentGroupPreferenceStore(), getRemoteConnections = () => null, openExternalUrl = () => void 0) {
28826
+ function createConnectionsSettingsPage(messages, getDiagnostics, groupPreference = getSharedAgentGroupPreferenceStore(), getRemoteConnections = () => null, getOpenExternalUrl) {
28579
28827
  return Object.freeze({
28580
28828
  id: "connections",
28581
28829
  label: messages.pageLabels.connections,
@@ -28606,12 +28854,14 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28606
28854
  context.content.append(header, syncMessage, content);
28607
28855
  let pending = false;
28608
28856
  let selectedHostId = null;
28857
+ let renderedHostId = null;
28609
28858
  let selectedItemKey = null;
28610
- let launchControls = null;
28611
28859
  const longContextControls = /* @__PURE__ */ new Map();
28860
+ let launchControls = null;
28861
+ let renderedInspector = null;
28612
28862
  const hostNames = /* @__PURE__ */ new Map();
28863
+ const knownNotInstalled = /* @__PURE__ */ new Map();
28613
28864
  let latestSnapshot = null;
28614
- let disposeHostScroller = () => void 0;
28615
28865
  let disposed = false;
28616
28866
  let renderQueued = false;
28617
28867
  let renderFrame = null;
@@ -28636,13 +28886,14 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28636
28886
  if (renderFrame !== null) document2.defaultView?.cancelAnimationFrame(renderFrame);
28637
28887
  renderFrame = null;
28638
28888
  };
28889
+ const diagnostics = getDiagnostics();
28639
28890
  const longContextControlFor = (hostId2, item) => {
28640
28891
  const agent = item.agentSnapshot?.agent;
28641
28892
  const availability = item.agentSnapshot?.availability;
28642
28893
  const getLongContext = diagnostics?.getLongContext;
28643
28894
  const setLongContext = diagnostics?.setLongContext;
28644
28895
  if (agent !== "claude-code" || availability === "notInstalled" || availability === "checking" || !getLongContext || !setLongContext) {
28645
- return null;
28896
+ return void 0;
28646
28897
  }
28647
28898
  const key = JSON.stringify([hostId2, agent]);
28648
28899
  const cached2 = longContextControls.get(key);
@@ -28654,7 +28905,6 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28654
28905
  longContextControls.set(key, element);
28655
28906
  return element;
28656
28907
  };
28657
- const diagnostics = getDiagnostics();
28658
28908
  const versions = createConnectionVersions(
28659
28909
  document2,
28660
28910
  messages,
@@ -28663,7 +28913,99 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28663
28913
  scheduleRender
28664
28914
  );
28665
28915
  const installs = diagnostics ? harnessInstallStore(diagnostics) : null;
28666
- const updates = createConnectionUpdates(document2, messages, context.signal, scheduleRender);
28916
+ const updates = createConnectionUpdates(
28917
+ document2,
28918
+ messages,
28919
+ context.signal,
28920
+ scheduleRender,
28921
+ diagnostics
28922
+ );
28923
+ const panelId = "codexhost-settings-connection-host-panel";
28924
+ const empty = document2.createElement("div");
28925
+ empty.className = "settings-empty";
28926
+ empty.textContent = messages.connectionNoRuntime;
28927
+ const layout = document2.createElement("div");
28928
+ layout.className = "settings-connections-layout";
28929
+ const list = document2.createElement("section");
28930
+ list.className = "settings-connection-list";
28931
+ const hostStrip = document2.createElement("div");
28932
+ hostStrip.className = "settings-connection-host-strip";
28933
+ const scrollLeft = createHostScrollButton(document2, "left", messages);
28934
+ const tabs = document2.createElement("div");
28935
+ tabs.className = "settings-connection-host-tabs";
28936
+ tabs.setAttribute("role", "tablist");
28937
+ tabs.setAttribute("aria-label", messages.connectionHosts);
28938
+ const scrollRight = createHostScrollButton(document2, "right", messages);
28939
+ hostStrip.append(scrollLeft, tabs, scrollRight);
28940
+ const updateControls = updates.createControls("local", []);
28941
+ const hostHeader = document2.createElement("div");
28942
+ hostHeader.className = "settings-connection-host-header";
28943
+ hostHeader.append(hostStrip, updateControls.button);
28944
+ const tableHeader = document2.createElement("div");
28945
+ tableHeader.className = "settings-connection-table-header";
28946
+ tableHeader.setAttribute("role", "row");
28947
+ const componentHeading = document2.createElement("span");
28948
+ componentHeading.textContent = messages.connectionComponent;
28949
+ componentHeading.setAttribute("role", "columnheader");
28950
+ const statusHeading = document2.createElement("span");
28951
+ statusHeading.textContent = messages.connectionStatus;
28952
+ statusHeading.setAttribute("role", "columnheader");
28953
+ const actionHeading = document2.createElement("span");
28954
+ actionHeading.setAttribute("aria-hidden", "true");
28955
+ tableHeader.append(componentHeading, statusHeading, actionHeading);
28956
+ const rows = document2.createElement("div");
28957
+ rows.className = "settings-connection-rows";
28958
+ rows.id = panelId;
28959
+ rows.setAttribute("role", "rowgroup");
28960
+ list.append(hostHeader, updateControls.result, tableHeader, rows);
28961
+ const inspector = document2.createElement("aside");
28962
+ inspector.className = "settings-connection-inspector";
28963
+ inspector.setAttribute("aria-live", "polite");
28964
+ layout.append(list, inspector);
28965
+ const hostScroller = configureHostScroller(
28966
+ document2,
28967
+ hostStrip,
28968
+ tabs,
28969
+ scrollLeft,
28970
+ scrollRight
28971
+ );
28972
+ const hostTabElements = /* @__PURE__ */ new Map();
28973
+ const hostRowViews = /* @__PURE__ */ new Map();
28974
+ const groupDivider = createGroupDivider(document2);
28975
+ const moreHint = createGroupMoreHint(document2, messages);
28976
+ const moreZone = document2.createElement("div");
28977
+ moreZone.className = "settings-connection-group-more";
28978
+ moreZone.setAttribute("role", "presentation");
28979
+ const resetButton = createGroupResetButton(document2, messages, () => {
28980
+ groupPreference.resetToDefault();
28981
+ });
28982
+ let draggingAgent = null;
28983
+ let currentCatalog = [];
28984
+ let currentMainEntries = [];
28985
+ let currentMoreEntries = [];
28986
+ let currentHostRows = /* @__PURE__ */ new Map();
28987
+ const clearDropIndicators = () => {
28988
+ for (const view of currentHostRows.values()) {
28989
+ view.element.dataset.connectionDropIndicator = "";
28990
+ }
28991
+ moreZone.dataset.connectionDragOver = "false";
28992
+ };
28993
+ moreZone.addEventListener("dragover", (event) => {
28994
+ if (!draggingAgent) return;
28995
+ event.preventDefault();
28996
+ moreZone.dataset.connectionDragOver = "true";
28997
+ });
28998
+ moreZone.addEventListener("dragleave", () => {
28999
+ moreZone.dataset.connectionDragOver = "false";
29000
+ });
29001
+ moreZone.addEventListener("drop", (event) => {
29002
+ event.preventDefault();
29003
+ moreZone.dataset.connectionDragOver = "false";
29004
+ if (!draggingAgent) return;
29005
+ groupPreference.moveAgent(draggingAgent, "more", null, currentCatalog);
29006
+ draggingAgent = null;
29007
+ clearDropIndicators();
29008
+ });
28667
29009
  const runRefresh = () => {
28668
29010
  if (pending || !diagnostics) return;
28669
29011
  pending = true;
@@ -28676,6 +29018,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28676
29018
  success() {
28677
29019
  installs?.clearErrors();
28678
29020
  pending = false;
29021
+ renderedInspector = null;
28679
29022
  refresh.disabled = false;
28680
29023
  refresh.replaceChildren(
28681
29024
  createRendererSettingsIcon("diagnose", 16),
@@ -28685,6 +29028,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28685
29028
  },
28686
29029
  failure(error51) {
28687
29030
  pending = false;
29031
+ renderedInspector = null;
28688
29032
  refresh.disabled = false;
28689
29033
  refresh.replaceChildren(
28690
29034
  createRendererSettingsIcon("diagnose", 16),
@@ -28710,110 +29054,128 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28710
29054
  }
28711
29055
  });
28712
29056
  };
29057
+ const syncSelectedInspector = (hostId2, item) => {
29058
+ const currentDiagnostics = getDiagnostics();
29059
+ const signature = inspectorRenderSignature(hostId2, item, messages, currentDiagnostics);
29060
+ const versionElement = item.version?.element ?? null;
29061
+ if (renderedInspector?.signature === signature && renderedInspector.versionElement === versionElement) {
29062
+ return;
29063
+ }
29064
+ const existing = launchControls?.hostId === hostId2 && launchControls.itemKey === item.key ? launchControls.element : null;
29065
+ const element = renderConnectionInspector(
29066
+ document2,
29067
+ inspector,
29068
+ item,
29069
+ hostId2,
29070
+ messages,
29071
+ currentDiagnostics,
29072
+ existing,
29073
+ runRefresh,
29074
+ getOpenExternalUrl
29075
+ );
29076
+ launchControls = { hostId: hostId2, itemKey: item.key, element };
29077
+ if (versionElement) inspector.append(versionElement);
29078
+ renderedInspector = { signature, versionElement };
29079
+ };
28713
29080
  const render = (snapshot) => {
28714
29081
  const syncStatus = groupPreference.syncStatus();
28715
29082
  const groupDisabled = syncStatus === "loading" || syncStatus === "saving";
28716
29083
  syncMessage.hidden = syncStatus === "ready";
28717
29084
  syncMessage.textContent = syncStatus === "error" ? messages.connectionGroupSyncFailed : syncStatus === "saving" ? messages.connectionGroupSaving : messages.connectionGroupLoading;
28718
29085
  latestSnapshot = snapshot;
28719
- disposeHostScroller();
28720
- disposeHostScroller = () => void 0;
28721
29086
  if (!snapshot) {
28722
- const empty = document2.createElement("div");
28723
- empty.className = "settings-empty";
28724
- empty.textContent = messages.connectionNoRuntime;
28725
- content.replaceChildren(empty);
29087
+ renderedHostId = null;
29088
+ renderedInspector = null;
29089
+ reconcileElementChildren(content, [empty]);
28726
29090
  return;
28727
29091
  }
28728
29092
  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];
28729
29093
  if (!selectedHost) return;
28730
29094
  selectedHostId = selectedHost.hostId;
28731
- const layout = document2.createElement("div");
28732
- layout.className = "settings-connections-layout";
28733
- const list = document2.createElement("section");
28734
- list.className = "settings-connection-list";
28735
- const hostStrip = document2.createElement("div");
28736
- hostStrip.className = "settings-connection-host-strip";
28737
- const scrollLeft = createHostScrollButton(document2, "left", messages);
28738
- const tabs = document2.createElement("div");
28739
- tabs.className = "settings-connection-host-tabs";
28740
- tabs.setAttribute("role", "tablist");
28741
- tabs.setAttribute("aria-label", messages.connectionHosts);
28742
- const scrollRight = createHostScrollButton(document2, "right", messages);
28743
- const panelId = "codexhost-settings-connection-host-panel";
28744
- snapshot.hosts.forEach((host, index) => {
28745
- const tab = document2.createElement("button");
28746
- tab.type = "button";
28747
- tab.className = "settings-connection-host-tab";
28748
- tab.dataset.connectionHostTab = host.hostId;
28749
- tab.dataset.connectionHostActive = String(host.active);
28750
- tab.setAttribute("role", "tab");
28751
- tab.setAttribute("aria-controls", panelId);
28752
- tab.setAttribute("aria-selected", String(host.hostId === selectedHost.hostId));
28753
- tab.tabIndex = host.hostId === selectedHost.hostId ? 0 : -1;
29095
+ const layoutFirstMount = content.children[0] !== layout;
29096
+ reconcileElementChildren(content, [layout]);
29097
+ let tabsChanged = tabs.children.length !== snapshot.hosts.length;
29098
+ const nextTabs = snapshot.hosts.map((host) => {
29099
+ let tab = hostTabElements.get(host.hostId);
29100
+ if (!tab) {
29101
+ tab = document2.createElement("button");
29102
+ tab.type = "button";
29103
+ tab.className = "settings-connection-host-tab";
29104
+ tab.dataset.connectionHostTab = host.hostId;
29105
+ tab.setAttribute("role", "tab");
29106
+ tab.setAttribute("aria-controls", panelId);
29107
+ tab.addEventListener("click", () => {
29108
+ selectedHostId = host.hostId;
29109
+ render(latestSnapshot);
29110
+ });
29111
+ tab.addEventListener("keydown", (event) => {
29112
+ if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
29113
+ event.preventDefault();
29114
+ const hosts = latestSnapshot?.hosts ?? [];
29115
+ const index = hosts.findIndex((candidate) => candidate.hostId === host.hostId);
29116
+ if (index < 0) return;
29117
+ const direction = event.key === "ArrowRight" ? 1 : -1;
29118
+ const next = hosts[(index + direction + hosts.length) % hosts.length];
29119
+ if (!next) return;
29120
+ selectedHostId = next.hostId;
29121
+ render(latestSnapshot);
29122
+ hostTabElements.get(next.hostId)?.focus();
29123
+ });
29124
+ hostTabElements.set(host.hostId, tab);
29125
+ tabsChanged = true;
29126
+ }
29127
+ const isSelected = host.hostId === selectedHost.hostId;
29128
+ const activeValue = String(host.active);
29129
+ if (tab.dataset.connectionHostActive !== activeValue) {
29130
+ tab.dataset.connectionHostActive = activeValue;
29131
+ }
29132
+ const selectedValue = String(isSelected);
29133
+ if (tab.getAttribute("aria-selected") !== selectedValue) {
29134
+ tab.setAttribute("aria-selected", selectedValue);
29135
+ }
29136
+ const nextTabIndex = isSelected ? 0 : -1;
29137
+ if (tab.tabIndex !== nextTabIndex) {
29138
+ tab.tabIndex = nextTabIndex;
29139
+ }
28754
29140
  const hostName = hostNames.get(host.hostId) || connectionHostName(host.hostId, messages);
28755
- tab.textContent = hostName;
28756
- tab.title = host.active ? `${hostName} \xB7 ${messages.connectionActiveHost}` : hostName;
28757
- tab.addEventListener("click", () => {
28758
- selectedHostId = host.hostId;
28759
- render(latestSnapshot);
28760
- });
28761
- tab.addEventListener("keydown", (event) => {
28762
- if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
28763
- event.preventDefault();
28764
- const direction = event.key === "ArrowRight" ? 1 : -1;
28765
- const next = snapshot.hosts[(index + direction + snapshot.hosts.length) % snapshot.hosts.length];
28766
- if (!next) return;
28767
- selectedHostId = next.hostId;
28768
- render(latestSnapshot);
28769
- const nextTab = [
28770
- ...content.querySelectorAll("[data-connection-host-tab]")
28771
- ].find((candidate) => candidate.dataset.connectionHostTab === next.hostId);
28772
- nextTab?.focus();
28773
- });
28774
- tabs.append(tab);
28775
- });
28776
- hostStrip.append(scrollLeft, tabs, scrollRight);
28777
- const tableHeader = document2.createElement("div");
28778
- tableHeader.className = "settings-connection-table-header";
28779
- tableHeader.setAttribute("role", "row");
28780
- const componentHeading = document2.createElement("span");
28781
- componentHeading.textContent = messages.connectionComponent;
28782
- componentHeading.setAttribute("role", "columnheader");
28783
- const statusHeading = document2.createElement("span");
28784
- statusHeading.textContent = messages.connectionStatus;
28785
- statusHeading.setAttribute("role", "columnheader");
28786
- const actionHeading = document2.createElement("span");
28787
- actionHeading.setAttribute("aria-hidden", "true");
28788
- tableHeader.append(componentHeading, statusHeading, actionHeading);
28789
- const rows = document2.createElement("div");
28790
- rows.className = "settings-connection-rows";
28791
- rows.id = panelId;
28792
- rows.dataset.connectionHost = selectedHost.hostId;
28793
- rows.setAttribute("role", "rowgroup");
28794
- const inspector = document2.createElement("aside");
28795
- inspector.className = "settings-connection-inspector";
28796
- inspector.setAttribute("aria-live", "polite");
28797
- keepPageStillDuringTextSelection(inspector);
28798
- const items = connectionItems(snapshot, selectedHost, messages, diagnostics).filter((item) => item.key !== "renderer-adapter").map((item) => {
28799
- const agent = item.agentSnapshot?.agent;
28800
- if (!agent) return item;
28801
- const state = installs?.get(selectedHost.hostId, agent);
28802
- const availability = state?.status ?? item.availability;
28803
- const version2 = item.agentSnapshot?.availability !== "notInstalled" && availability !== "installing" && availability !== "checking" ? versions.get(selectedHost.hostId, agent) : void 0;
28804
- return {
28805
- ...item,
28806
- ...state ? { availability: state.status } : {},
28807
- ...version2 ? { version: version2 } : {},
28808
- ...version2?.updating ? { availability: "updating" } : {},
28809
- ...state?.error ? { installError: state.error } : {},
28810
- ...diagnostics?.installation && harnessHasInstallCommands(item.agentSnapshot?.plugin) ? {
28811
- install: () => {
28812
- void installs?.install(selectedHost.hostId, agent);
28813
- }
28814
- } : {}
28815
- };
29141
+ if (tab.textContent !== hostName) {
29142
+ tab.textContent = hostName;
29143
+ tabsChanged = true;
29144
+ }
29145
+ const tabTitle = host.active ? `${hostName} \xB7 ${messages.connectionActiveHost}` : hostName;
29146
+ if (tab.title !== tabTitle) {
29147
+ tab.title = tabTitle;
29148
+ }
29149
+ return tab;
28816
29150
  });
29151
+ reconcileElementChildren(tabs, nextTabs);
29152
+ if (rows.dataset.connectionHost !== selectedHost.hostId) {
29153
+ rows.dataset.connectionHost = selectedHost.hostId;
29154
+ }
29155
+ const items = connectionItems(snapshot, selectedHost, messages, diagnostics).map(
29156
+ (item) => {
29157
+ const agent = item.agentSnapshot?.agent;
29158
+ if (!agent) return item;
29159
+ const state = installs?.get(selectedHost.hostId, agent);
29160
+ const availability = state?.status ?? item.availability;
29161
+ const updating = versions.isUpdating(selectedHost.hostId, agent);
29162
+ const version2 = updating || item.agentSnapshot?.availability !== "notInstalled" && availability !== "installing" && availability !== "checking" ? versions.get(selectedHost.hostId, agent) : void 0;
29163
+ const accessory = longContextControlFor(selectedHost.hostId, item);
29164
+ return {
29165
+ ...item,
29166
+ ...state ? { availability: state.status } : {},
29167
+ ...version2 ? { version: version2 } : {},
29168
+ ...version2?.updating ? { availability: "updating" } : {},
29169
+ ...state?.error ? { installError: state.error } : {},
29170
+ ...accessory ? { accessory } : {},
29171
+ ...diagnostics?.installation && harnessHasInstallCommands(item.agentSnapshot?.plugin) ? {
29172
+ install: () => {
29173
+ void installs?.install(selectedHost.hostId, agent);
29174
+ }
29175
+ } : {}
29176
+ };
29177
+ }
29178
+ );
28817
29179
  if (!items.some((item) => item.key === selectedItemKey)) {
28818
29180
  const requestedFocus = pendingFocusAgent;
28819
29181
  pendingFocusAgent = null;
@@ -28821,248 +29183,200 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28821
29183
  (item) => item.agentSnapshot?.availability === "notInstalled" || item.error !== null
28822
29184
  )?.key ?? items[0]?.key ?? null;
28823
29185
  }
28824
- const rowElements = /* @__PURE__ */ new Map();
29186
+ let hostRows = hostRowViews.get(selectedHost.hostId);
29187
+ if (!hostRows) {
29188
+ hostRows = /* @__PURE__ */ new Map();
29189
+ hostRowViews.set(selectedHost.hostId, hostRows);
29190
+ }
29191
+ currentHostRows = hostRows;
28825
29192
  const selectItem = (item) => {
28826
29193
  selectedItemKey = item.key;
28827
- for (const [key, row] of rowElements) {
28828
- const selected = key === item.key;
28829
- row.dataset.connectionSelected = String(selected);
28830
- row.tabIndex = selected ? 0 : -1;
29194
+ for (const [key, view] of currentHostRows) {
29195
+ view.setSelected(key === item.key);
28831
29196
  }
28832
- const existing = launchControls?.hostId === selectedHost.hostId && launchControls.itemKey === item.key ? launchControls.element : null;
28833
- const element = renderConnectionInspector(
28834
- document2,
28835
- inspector,
28836
- item,
28837
- selectedHost.hostId,
28838
- messages,
28839
- getDiagnostics(),
28840
- existing,
28841
- runRefresh,
28842
- openExternalUrl
28843
- );
28844
- launchControls = { hostId: selectedHost.hostId, itemKey: item.key, element };
28845
- if (item.version) inspector.append(item.version.element);
29197
+ syncSelectedInspector(selectedHost.hostId, item);
28846
29198
  };
28847
- for (const pinnedItem of items.filter((item) => !item.agentSnapshot)) {
28848
- const row = createConnectionRow(
28849
- document2,
29199
+ const ensureRowView = (key, groupable) => {
29200
+ let view = hostRows.get(key);
29201
+ if (!view) {
29202
+ view = createConnectionRowView(document2, messages, groupable);
29203
+ hostRows.set(key, view);
29204
+ }
29205
+ return view;
29206
+ };
29207
+ const activeKeys = /* @__PURE__ */ new Set();
29208
+ const nextRowChildren = [];
29209
+ const pinnedItems = items.filter((item) => item.agentSnapshot === void 0);
29210
+ for (const pinnedItem of pinnedItems) {
29211
+ activeKeys.add(pinnedItem.key);
29212
+ const view = ensureRowView(pinnedItem.key, false);
29213
+ view.update(
28850
29214
  pinnedItem,
28851
- messages,
28852
29215
  pinnedItem.key === selectedItemKey,
28853
- () => selectItem(pinnedItem)
29216
+ () => selectItem(pinnedItem),
29217
+ null
28854
29218
  );
28855
- rowElements.set(pinnedItem.key, row);
28856
- rows.append(row);
29219
+ nextRowChildren.push(view.element);
28857
29220
  }
28858
29221
  const groupableItems = items.filter(
28859
29222
  (item) => item.agentSnapshot !== void 0
28860
29223
  );
28861
29224
  const agentByKey = new Map(groupableItems.map((item) => [item.key, item]));
28862
- const catalog = groupableItems.map((item) => ({ id: item.key, name: item.name }));
28863
- const preferenceOrder = groupPreference.list(
28864
- new Set(
28865
- groupableItems.filter((item) => item.agentSnapshot.availability === "notInstalled").map((item) => item.agentSnapshot.agent)
28866
- ),
28867
- catalog
28868
- ).filter((entry) => agentByKey.has(entry.agent));
28869
- const isInstalledAgent = (agent) => agentByKey.get(agent)?.agentSnapshot.availability !== "notInstalled";
28870
- const mainEntries = partitionAgentsByInstallStatus(
28871
- preferenceOrder.filter((entry) => entry.section === "main"),
28872
- isInstalledAgent
28873
- );
28874
- const moreEntries = partitionAgentsByInstallStatus(
28875
- preferenceOrder.filter((entry) => entry.section === "more"),
28876
- isInstalledAgent
29225
+ currentCatalog = groupableItems.map((item) => ({ id: item.key, name: item.name }));
29226
+ const notInstalledAgents = /* @__PURE__ */ new Set();
29227
+ for (const item of groupableItems) {
29228
+ const agent = item.agentSnapshot.agent;
29229
+ const stateKey = `${selectedHost.hostId}:${agent}`;
29230
+ if (item.agentSnapshot.availability !== "checking") {
29231
+ knownNotInstalled.set(stateKey, item.agentSnapshot.availability === "notInstalled");
29232
+ }
29233
+ const isNotInstalled = item.agentSnapshot.availability === "checking" ? knownNotInstalled.get(stateKey) ?? false : item.agentSnapshot.availability === "notInstalled";
29234
+ if (isNotInstalled) notInstalledAgents.add(agent);
29235
+ }
29236
+ const preferenceOrder = partitionAgentsByInstallStatus(
29237
+ groupPreference.list(notInstalledAgents, currentCatalog).filter((entry) => agentByKey.has(entry.agent)),
29238
+ (agent) => !notInstalledAgents.has(agent)
28877
29239
  );
28878
- groupPreference.reconcileOrder([...mainEntries, ...moreEntries], catalog);
29240
+ groupPreference.reconcileOrder(preferenceOrder, currentCatalog);
29241
+ currentMainEntries = preferenceOrder.filter((entry) => entry.section === "main");
29242
+ currentMoreEntries = preferenceOrder.filter((entry) => entry.section === "more");
28879
29243
  const nextInSection = (section, agent) => {
28880
- const list2 = section === "main" ? mainEntries : moreEntries;
28881
- const index = list2.findIndex((entry) => entry.agent === agent);
28882
- return index >= 0 ? list2[index + 1]?.agent ?? null : null;
28883
- };
28884
- const beforeAgentForBucketAppend = (agent, targetSection) => {
28885
- const list2 = targetSection === "main" ? mainEntries : moreEntries;
28886
- const installed = isInstalledAgent(agent);
28887
- return list2.find(
28888
- (entry) => entry.agent !== agent && isInstalledAgent(entry.agent) !== installed
28889
- )?.agent ?? null;
28890
- };
28891
- let draggingAgent = null;
28892
- let moreZone = null;
28893
- const clearDropIndicators = () => {
28894
- for (const row of rowElements.values()) row.dataset.connectionDropIndicator = "";
28895
- if (moreZone) moreZone.dataset.connectionDragOver = "false";
29244
+ const sectionEntries = section === "main" ? currentMainEntries : currentMoreEntries;
29245
+ const index = sectionEntries.findIndex((entry) => entry.agent === agent);
29246
+ return index >= 0 ? sectionEntries[index + 1]?.agent ?? null : null;
28896
29247
  };
28897
- const sameInstallBucket = (left, right) => isInstalledAgent(left) === isInstalledAgent(right);
28898
29248
  const dropTargetSection = (agent, event) => {
28899
- const row = rowElements.get(agent);
29249
+ const row = currentHostRows.get(agent)?.element;
28900
29250
  const rect = row && typeof row.getBoundingClientRect === "function" ? row.getBoundingClientRect() : null;
28901
29251
  const before = rect ? event.clientY - rect.top < rect.height / 2 : true;
28902
29252
  const section = row?.dataset.connectionGroupSection ?? "main";
28903
29253
  return { before, beforeAgent: before ? agent : nextInSection(section, agent) };
28904
29254
  };
28905
- const createGroupController = (agent, section) => ({
28906
- disabled: groupDisabled,
28907
- section,
28908
- moveLabel: section === "main" ? messages.connectionGroupMoveToMore : messages.connectionGroupMoveToMain,
28909
- dragHandleTitle: messages.connectionGroupDragHandle,
28910
- toggleSection() {
28911
- groupPreference.moveAgent(agent, section === "main" ? "more" : "main", null, catalog);
28912
- },
28913
- onDragStart(event) {
28914
- if (groupDisabled) {
28915
- event.preventDefault();
28916
- return;
28917
- }
28918
- draggingAgent = agent;
28919
- event.dataTransfer?.setData("text/plain", agent);
28920
- if (event.dataTransfer) event.dataTransfer.effectAllowed = "move";
28921
- const row = rowElements.get(agent);
28922
- if (row) row.dataset.connectionDragging = "true";
28923
- },
28924
- onDragOver(event) {
28925
- if (!draggingAgent || draggingAgent === agent) return;
28926
- const crossSection = groupPreference.sectionOf(draggingAgent) !== section;
28927
- if (!crossSection && !sameInstallBucket(draggingAgent, agent)) return;
28928
- event.preventDefault();
28929
- const row = rowElements.get(agent);
28930
- if (!row) return;
28931
- clearDropIndicators();
28932
- if (crossSection && !sameInstallBucket(draggingAgent, agent)) {
28933
- row.dataset.connectionDropIndicator = "before";
28934
- return;
28935
- }
28936
- const { before } = dropTargetSection(agent, event);
28937
- row.dataset.connectionDropIndicator = before ? "before" : "after";
28938
- },
28939
- onDragLeave() {
28940
- const row = rowElements.get(agent);
28941
- if (row) row.dataset.connectionDropIndicator = "";
28942
- },
28943
- onDrop(event) {
28944
- event.preventDefault();
28945
- event.stopPropagation();
28946
- if (!draggingAgent) return;
28947
- const crossSection = groupPreference.sectionOf(draggingAgent) !== section;
28948
- if (!crossSection && !sameInstallBucket(draggingAgent, agent)) {
28949
- draggingAgent = null;
28950
- clearDropIndicators();
28951
- return;
28952
- }
28953
- if (crossSection && !sameInstallBucket(draggingAgent, agent)) {
29255
+ const createGroupController = (agent, section) => {
29256
+ const disabled = groupDisabled;
29257
+ return {
29258
+ disabled,
29259
+ section,
29260
+ moveLabel: section === "main" ? messages.connectionGroupMoveToMore : messages.connectionGroupMoveToMain,
29261
+ dragHandleTitle: messages.connectionGroupDragHandle,
29262
+ toggleSection() {
28954
29263
  groupPreference.moveAgent(
28955
- draggingAgent,
28956
- section,
28957
- beforeAgentForBucketAppend(draggingAgent, section),
28958
- catalog
29264
+ agent,
29265
+ section === "main" ? "more" : "main",
29266
+ null,
29267
+ currentCatalog
28959
29268
  );
28960
- } else {
29269
+ },
29270
+ onDragStart(event) {
29271
+ if (disabled) {
29272
+ event.preventDefault();
29273
+ return;
29274
+ }
29275
+ draggingAgent = agent;
29276
+ event.dataTransfer?.setData("text/plain", agent);
29277
+ if (event.dataTransfer) event.dataTransfer.effectAllowed = "move";
29278
+ const row = currentHostRows.get(agent)?.element;
29279
+ if (row) row.dataset.connectionDragging = "true";
29280
+ },
29281
+ onDragOver(event) {
29282
+ if (!draggingAgent || draggingAgent === agent) return;
29283
+ event.preventDefault();
29284
+ const row = currentHostRows.get(agent)?.element;
29285
+ if (!row) return;
29286
+ const { before } = dropTargetSection(agent, event);
29287
+ clearDropIndicators();
29288
+ row.dataset.connectionDropIndicator = before ? "before" : "after";
29289
+ },
29290
+ onDragLeave() {
29291
+ const row = currentHostRows.get(agent)?.element;
29292
+ if (row) row.dataset.connectionDropIndicator = "";
29293
+ },
29294
+ onDrop(event) {
29295
+ event.preventDefault();
29296
+ if (!draggingAgent) return;
28961
29297
  const { beforeAgent } = dropTargetSection(agent, event);
28962
- groupPreference.moveAgent(draggingAgent, section, beforeAgent, catalog);
29298
+ groupPreference.moveAgent(draggingAgent, section, beforeAgent, currentCatalog);
29299
+ draggingAgent = null;
29300
+ clearDropIndicators();
29301
+ },
29302
+ onDragEnd() {
29303
+ draggingAgent = null;
29304
+ const row = currentHostRows.get(agent)?.element;
29305
+ if (row) row.dataset.connectionDragging = "false";
29306
+ clearDropIndicators();
29307
+ scheduleRender();
28963
29308
  }
28964
- draggingAgent = null;
28965
- clearDropIndicators();
28966
- },
28967
- onDragEnd() {
28968
- draggingAgent = null;
28969
- const row = rowElements.get(agent);
28970
- if (row) row.dataset.connectionDragging = "false";
28971
- clearDropIndicators();
28972
- }
28973
- });
28974
- const appendGroupRow = (agent, section) => {
28975
- const item = agentByKey.get(agent);
28976
- if (!item) return;
28977
- const row = createConnectionRow(
28978
- document2,
29309
+ };
29310
+ };
29311
+ for (const entry of currentMainEntries) {
29312
+ const item = agentByKey.get(entry.agent);
29313
+ if (!item) continue;
29314
+ activeKeys.add(item.key);
29315
+ const view = ensureRowView(item.key, true);
29316
+ view.update(
28979
29317
  item,
28980
- messages,
28981
29318
  item.key === selectedItemKey,
28982
29319
  () => selectItem(item),
28983
- createGroupController(agent, section),
28984
- longContextControlFor(selectedHost.hostId, item)
29320
+ createGroupController(entry.agent, "main")
28985
29321
  );
28986
- rowElements.set(item.key, row);
28987
- rows.append(row);
28988
- };
28989
- for (const entry of mainEntries) appendGroupRow(entry.agent, "main");
29322
+ nextRowChildren.push(view.element);
29323
+ }
28990
29324
  if (groupableItems.length > 0) {
28991
- rows.append(createGroupDivider(document2, messages, moreEntries.length));
28992
- const zone = document2.createElement("div");
28993
- moreZone = zone;
28994
- zone.className = "settings-connection-group-more";
28995
- zone.setAttribute("role", "presentation");
28996
- zone.addEventListener("dragover", (event) => {
28997
- if (!draggingAgent) return;
28998
- event.preventDefault();
28999
- zone.dataset.connectionDragOver = "true";
29000
- });
29001
- zone.addEventListener("dragleave", () => {
29002
- zone.dataset.connectionDragOver = "false";
29003
- });
29004
- zone.addEventListener("drop", (event) => {
29005
- event.preventDefault();
29006
- zone.dataset.connectionDragOver = "false";
29007
- if (!draggingAgent) return;
29008
- groupPreference.moveAgent(draggingAgent, "more", null, catalog);
29009
- draggingAgent = null;
29010
- clearDropIndicators();
29011
- });
29012
- if (moreEntries.length === 0) {
29013
- zone.append(createGroupMoreHint(document2, messages));
29325
+ const dividerText = `${messages.connectionGroupMoreLabel} (${currentMoreEntries.length})`;
29326
+ if (groupDivider.textContent !== dividerText) {
29327
+ groupDivider.textContent = dividerText;
29328
+ }
29329
+ nextRowChildren.push(groupDivider);
29330
+ const nextMoreChildren = [];
29331
+ if (currentMoreEntries.length === 0) {
29332
+ nextMoreChildren.push(moreHint);
29014
29333
  } else {
29015
- for (const entry of moreEntries) {
29334
+ for (const entry of currentMoreEntries) {
29016
29335
  const item = agentByKey.get(entry.agent);
29017
29336
  if (!item) continue;
29018
- const row = createConnectionRow(
29019
- document2,
29337
+ activeKeys.add(item.key);
29338
+ const view = ensureRowView(item.key, true);
29339
+ view.update(
29020
29340
  item,
29021
- messages,
29022
29341
  item.key === selectedItemKey,
29023
29342
  () => selectItem(item),
29024
- createGroupController(entry.agent, "more"),
29025
- longContextControlFor(selectedHost.hostId, item)
29343
+ createGroupController(entry.agent, "more")
29026
29344
  );
29027
- rowElements.set(item.key, row);
29028
- zone.append(row);
29345
+ nextMoreChildren.push(view.element);
29029
29346
  }
29030
29347
  }
29031
- rows.append(zone);
29032
- const reset = createGroupResetButton(document2, messages, () => {
29033
- groupPreference.resetToDefault();
29034
- });
29035
- reset.disabled = groupDisabled;
29036
- rows.append(reset);
29348
+ if (!draggingAgent || renderedHostId !== selectedHost.hostId) {
29349
+ reconcileElementChildren(moreZone, nextMoreChildren);
29350
+ }
29351
+ nextRowChildren.push(moreZone);
29352
+ resetButton.disabled = groupDisabled;
29353
+ nextRowChildren.push(resetButton);
29354
+ }
29355
+ for (const key of hostRows.keys()) {
29356
+ if (!activeKeys.has(key)) hostRows.delete(key);
29357
+ }
29358
+ if (!draggingAgent || renderedHostId !== selectedHost.hostId) {
29359
+ reconcileElementChildren(rows, nextRowChildren);
29037
29360
  }
29038
29361
  const selectedItem = items.find((item) => item.key === selectedItemKey) ?? items[0];
29039
29362
  if (selectedItem) selectItem(selectedItem);
29040
- const updateControls = updates.createControls(
29363
+ updateControls.update(
29041
29364
  selectedHost.hostId,
29042
29365
  items.flatMap((item) => item.version ? [item.version] : [])
29043
29366
  );
29044
- const hostHeader = document2.createElement("div");
29045
- hostHeader.className = "settings-connection-host-header";
29046
- hostHeader.append(hostStrip, updateControls.button);
29047
- list.append(hostHeader, updateControls.result, tableHeader, rows);
29048
- layout.append(list, inspector);
29049
- content.replaceChildren(layout);
29050
- disposeHostScroller = configureHostScroller(
29051
- document2,
29052
- hostStrip,
29053
- tabs,
29054
- scrollLeft,
29055
- scrollRight
29056
- );
29057
- const selectedTab = [...tabs.children].find(
29058
- (child) => child.getAttribute("aria-selected") === "true"
29059
- );
29060
- if (selectedTab) {
29061
- const left = selectedTab.offsetLeft;
29062
- const right = left + selectedTab.offsetWidth;
29063
- if (left < tabs.scrollLeft) tabs.scrollLeft = left;
29064
- else if (right > tabs.scrollLeft + tabs.clientWidth) {
29065
- tabs.scrollLeft = right - tabs.clientWidth;
29367
+ if (layoutFirstMount || tabsChanged) {
29368
+ hostScroller.update();
29369
+ }
29370
+ if (renderedHostId !== selectedHost.hostId) {
29371
+ renderedHostId = selectedHost.hostId;
29372
+ const selectedTab = hostTabElements.get(selectedHost.hostId);
29373
+ if (selectedTab) {
29374
+ const left = selectedTab.offsetLeft;
29375
+ const right = left + selectedTab.offsetWidth;
29376
+ if (left < tabs.scrollLeft) tabs.scrollLeft = left;
29377
+ else if (right > tabs.scrollLeft + tabs.clientWidth) {
29378
+ tabs.scrollLeft = right - tabs.clientWidth;
29379
+ }
29066
29380
  }
29067
29381
  }
29068
29382
  };
@@ -29083,7 +29397,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
29083
29397
  refresh.disabled = true;
29084
29398
  return () => {
29085
29399
  cancelRender();
29086
- disposeHostScroller();
29400
+ hostScroller.dispose();
29087
29401
  unsubscribeGroup();
29088
29402
  };
29089
29403
  }
@@ -29092,7 +29406,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
29092
29406
  const unsubscribeInstalls = installs?.subscribe(scheduleRender);
29093
29407
  return () => {
29094
29408
  cancelRender();
29095
- disposeHostScroller();
29409
+ hostScroller.dispose();
29096
29410
  unsubscribeInstalls?.();
29097
29411
  unsubscribe();
29098
29412
  unsubscribeGroup();
@@ -30902,9 +31216,13 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
30902
31216
  resets: "Resets",
30903
31217
  details: "Account limit details",
30904
31218
  weekly: "Weekly limit",
31219
+ weeklyShort: "Weekly",
30905
31220
  monthly: "Monthly limit",
31221
+ monthlyShort: "Monthly",
30906
31222
  fiveHour: "5-hour limit",
31223
+ fiveHourShort: "5-hour",
30907
31224
  sevenDay: "7-day limit",
31225
+ sevenDayShort: "7-day",
30908
31226
  account: "Account limit"
30909
31227
  });
30910
31228
  var CHINESE_CREDITS_MESSAGES = Object.freeze({
@@ -30912,9 +31230,13 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
30912
31230
  resets: "\u91CD\u7F6E",
30913
31231
  details: "\u8D26\u53F7\u989D\u5EA6\u8BE6\u60C5",
30914
31232
  weekly: "\u5468\u989D\u5EA6",
31233
+ weeklyShort: "\u5468\u989D\u5EA6",
30915
31234
  monthly: "\u6708\u989D\u5EA6",
31235
+ monthlyShort: "\u6708\u989D\u5EA6",
30916
31236
  fiveHour: "5 \u5C0F\u65F6\u989D\u5EA6",
31237
+ fiveHourShort: "5 \u5C0F\u65F6",
30917
31238
  sevenDay: "7 \u5929\u989D\u5EA6",
31239
+ sevenDayShort: "7 \u5929",
30918
31240
  account: "\u8D26\u53F7\u989D\u5EA6"
30919
31241
  });
30920
31242
  function formatRendererCreditsReset(value, now = /* @__PURE__ */ new Date(), locale = "en") {
@@ -34345,6 +34667,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
34345
34667
  background: var(--settings-surface);
34346
34668
  border: 1px solid var(--settings-border);
34347
34669
  border-radius: 10px;
34670
+ overflow-anchor: none;
34348
34671
  }
34349
34672
 
34350
34673
  .settings-connection-inspector__header {