@liberseek/boft-cli-win32-arm64 0.8.7 → 0.8.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +59 -6
  4. package/app/console-web.js +1376 -1053
  5. package/app/desktop-controller.mjs +239 -57
  6. package/app/host-runtime.mjs +32921 -24901
  7. package/app/plugins/antigravity/assets/icon.svg +1 -1
  8. package/app/plugins/antigravity/plugin.mjs +9491 -4266
  9. package/app/plugins/claude-code/plugin.mjs +580 -116
  10. package/app/plugins/codebuddy/plugin.mjs +85 -8
  11. package/app/plugins/codex-usage/plugin.mjs +70 -6
  12. package/app/plugins/copilot/plugin.mjs +62 -6
  13. package/app/plugins/cursor-cli/plugin.mjs +62 -6
  14. package/app/plugins/deepseek-harness/plugin.mjs +87 -11
  15. package/app/plugins/devin/plugin.mjs +61 -6
  16. package/app/plugins/grok/plugin.mjs +320 -223
  17. package/app/plugins/hermes/plugin.mjs +61 -6
  18. package/app/plugins/kimi-code/plugin.mjs +87 -16
  19. package/app/plugins/kiro-cli/plugin.mjs +62 -6
  20. package/app/plugins/muse/plugin.mjs +61 -6
  21. package/app/plugins/omp/plugin.mjs +195 -31
  22. package/app/plugins/opencode/plugin.mjs +88 -15
  23. package/app/plugins/pi/plugin.mjs +207 -32
  24. package/app/plugins/qoder/plugin.mjs +99 -7
  25. package/app/plugins/qoder-cn/plugin.mjs +99 -7
  26. package/app/plugins/qwen-code/plugin.mjs +62 -6
  27. package/app/plugins/workbuddy/plugin.mjs +89 -11
  28. package/app/plugins/zcode/plugin.mjs +70 -6
  29. package/app/renderer-extension.js +1767 -1187
  30. package/app/web/assets/index-C2OA-eHT.js +201 -0
  31. package/app/web/assets/index-DJW4bmyx.css +1 -0
  32. package/app/web/assets/langs/{graphql-B8vkg11W.js → graphql-ChAeyPkT.js} +1 -1
  33. package/app/web/assets/langs/{http-DmoDEjMt.js → http-BvreBIbD.js} +1 -1
  34. package/app/web/assets/langs/{php-DJ5ovfAM.js → php-D8omCIuJ.js} +1 -1
  35. package/app/web/assets/langs/{rst-U5-R5x3p.js → rst-Do7RLLCS.js} +1 -1
  36. package/app/web/assets/langs/{ruby-VKVsnS0H.js → ruby-rH_O_vse.js} +1 -1
  37. package/app/web/assets/langs/{svelte-C20lOv9V.js → svelte-xZy73wAj.js} +1 -1
  38. package/app/web/assets/langs/{vue-z6Y-lzP-.js → vue-C4DW8agZ.js} +1 -1
  39. package/app/web/assets/{vendor-dSL872WO.js → vendor-C9g2bw8s.js} +3 -3
  40. package/app/web/codexhost-settings.js +1383 -1056
  41. package/app/web/index.html +4 -3
  42. package/app/web/plugins/deepseek-ai__dsh-api-gateway/client.js +2 -2
  43. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
  44. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +11 -11
  45. package/app/web/plugins/deepseek-ai__dsh-client-connection/client.js +1 -1
  46. package/app/web/plugins/deepseek-ai__dsh-client-locale/client.js +3 -3
  47. package/app/web/plugins/deepseek-ai__dsh-client-ui-attachment/client.js +1 -1
  48. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +74 -69
  49. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +3 -3
  50. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +28 -28
  51. package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
  52. package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
  53. package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +1 -1
  54. package/app/web/plugins/deepseek-ai__dsh-client-ui-session/client.js +1 -1
  55. package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
  56. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar/client.js +1 -1
  57. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +9 -9
  58. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-files/client.js +1 -1
  59. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
  60. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +11 -11
  61. package/app/web-modules/server.mjs +2458 -1615
  62. package/bin/boft.exe +0 -0
  63. package/libexec/boft-node-repl.exe +0 -0
  64. package/libexec/boft-shim.exe +0 -0
  65. package/libexec/boft-updater.exe +0 -0
  66. package/package.json +1 -1
  67. package/app/web/assets/index-CP6wY-1D.css +0 -1
  68. package/app/web/assets/index-Da35Phrd.js +0 -199
@@ -14912,13 +14912,25 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14912
14912
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
14913
14913
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
14914
14914
  var cacheHitRatePercentSchema = external_exports.number().finite().min(0).max(100);
14915
+ var usageOutputTimingSchema = external_exports.object({
14916
+ version: external_exports.union([external_exports.literal(3), external_exports.literal(4)]).optional(),
14917
+ requestId: external_exports.string().min(1),
14918
+ turnId: external_exports.string().min(1).max(1024),
14919
+ outputTokens: nonNegativeSafeIntegerSchema,
14920
+ startedAtMs: nonNegativeSafeIntegerSchema,
14921
+ completedAtMs: nonNegativeSafeIntegerSchema
14922
+ }).strict().refine((value) => value.completedAtMs > value.startedAtMs);
14915
14923
  var usageMeasurementSchema = external_exports.object({
14924
+ version: external_exports.union([external_exports.literal(2), external_exports.literal(3), external_exports.literal(4)]).optional(),
14916
14925
  value: finiteNonNegativeNumberSchema,
14917
14926
  turnId: external_exports.string().min(1).max(1024),
14918
14927
  at: nonNegativeSafeIntegerSchema
14919
14928
  }).strict();
14920
14929
  var usageMeasurementsSchema = external_exports.object({
14921
- outputTokensPerSecond: usageMeasurementSchema.optional(),
14930
+ // Older intervals can omit hidden thinking time; do not restore them into averages.
14931
+ outputTimings: external_exports.array(usageOutputTimingSchema).transform((values) => values.filter((value) => value.version === 4)).optional(),
14932
+ // Retain independent TTFT facts when dropping incompatible speed measurements.
14933
+ outputTokensPerSecond: usageMeasurementSchema.refine((value) => value.version === 4).optional().catch(void 0),
14922
14934
  timeToFirstOutputMs: usageMeasurementSchema.extend({ value: nonNegativeSafeIntegerSchema }).optional()
14923
14935
  }).strict();
14924
14936
  var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text) => text.length <= maximum));
@@ -14938,6 +14950,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14938
14950
  cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
14939
14951
  outputTokens: nonNegativeSafeIntegerSchema.optional(),
14940
14952
  outputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
14953
+ sessionOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
14941
14954
  apiOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
14942
14955
  reasoningOutputTokens: nonNegativeSafeIntegerSchema.optional(),
14943
14956
  totalTokens: nonNegativeSafeIntegerSchema.optional(),
@@ -15380,11 +15393,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15380
15393
  delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
15381
15394
  }).strict();
15382
15395
 
15396
+ // ../shared-contracts/dist/thread-archive-confirm.js
15397
+ var threadArchiveConfirmParamsSchema = external_exports.object({ threadId: hostThreadIdSchema }).strict();
15398
+ var threadArchiveConfirmResultSchema = external_exports.object({ confirmed: external_exports.boolean() }).strict();
15399
+
15383
15400
  // ../shared-contracts/dist/client-channel.js
15384
15401
  var CLIENT_CHANNEL_VERSION = 1;
15385
15402
  var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
15386
15403
  var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
15387
15404
  var clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict();
15405
+ var clientThreadTreeReadParamsSchema = external_exports.object({}).strict();
15406
+ var clientThreadTreeSchema = external_exports.object({
15407
+ parents: external_exports.record(external_exports.string().min(1), external_exports.string().min(1))
15408
+ }).strict();
15388
15409
  var clientProjectlessWorkspaceSchema = external_exports.object({
15389
15410
  prompt: external_exports.string().max(16384).optional()
15390
15411
  }).strict();
@@ -15406,6 +15427,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15406
15427
  cursor: clientChannelCursorSchema,
15407
15428
  cwd: external_exports.string().optional()
15408
15429
  }),
15430
+ external_exports.object({
15431
+ type: external_exports.literal("harness-inspection-changed"),
15432
+ cursor: clientChannelCursorSchema,
15433
+ harnessId: external_exports.string().min(1)
15434
+ }),
15409
15435
  external_exports.object({ type: external_exports.literal("display-settings-changed"), cursor: clientChannelCursorSchema }),
15410
15436
  external_exports.object({
15411
15437
  type: external_exports.literal("preferences-changed"),
@@ -15477,6 +15503,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15477
15503
  var clientTurnSchema = external_exports.object({
15478
15504
  id: external_exports.string().min(1),
15479
15505
  status: external_exports.string().min(1),
15506
+ /** Native history has no terminal evidence; Desktop's status vocabulary cannot express this. */
15507
+ codexhostTurnOutcome: external_exports.object({ status: external_exports.literal("unknown"), reason: external_exports.string() }).optional(),
15480
15508
  items: external_exports.array(external_exports.object({ id: external_exports.string().min(1), type: external_exports.string().min(1) }).passthrough()),
15481
15509
  /** Original file operations, independent of the cumulative Desktop fileChange card.
15482
15510
  * Insert before the named non-file Item; null appends at the end of the Turn.
@@ -15515,7 +15543,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15515
15543
  /** Current interruptible Host Turn, including command Turns omitted from client history. */
15516
15544
  activeTurnId: external_exports.string().min(1).nullable().optional(),
15517
15545
  /** Most recent explicit command in this Host process; not native conversation history. */
15518
- command: external_exports.object({ name: external_exports.string().min(1), turn: clientTurnSchema }).optional(),
15546
+ command: external_exports.object({
15547
+ name: external_exports.string().min(1),
15548
+ turn: clientTurnSchema,
15549
+ /** First ordinary Turn started after this command; its retained result is not a new event. */
15550
+ subsequentTurnId: external_exports.string().min(1).optional()
15551
+ }).optional(),
15519
15552
  thread: external_exports.object({
15520
15553
  id: external_exports.string().min(1),
15521
15554
  cwd: external_exports.string(),
@@ -15766,7 +15799,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15766
15799
  quotaUntil: external_exports.string().optional()
15767
15800
  }).strict().optional()
15768
15801
  }).strict();
15769
- var webLocalAccessRequiredDetailsSchema = external_exports.object({ url: external_exports.string() }).strict();
15770
15802
 
15771
15803
  // ../shared-contracts/dist/delegation-read.js
15772
15804
  var REMOTE_THREAD_REPLY_MAX_BYTES = 16 * 1024 * 1024;
@@ -15776,8 +15808,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15776
15808
  var delegationReadParamsSchema = external_exports.strictObject({
15777
15809
  threadId: external_exports.string().min(1).max(1024),
15778
15810
  view: external_exports.enum(["result", "messages"]),
15779
- cursor: external_exports.string().min(1).max(8192).optional(),
15780
- limit: external_exports.number().int().min(1).max(100).optional()
15811
+ from: external_exports.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional(),
15812
+ to: external_exports.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional()
15781
15813
  });
15782
15814
 
15783
15815
  // ../shared-contracts/dist/credential-imports.js
@@ -15949,6 +15981,135 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15949
15981
  ...window2.localizations ? { localizations: window2.localizations } : {}
15950
15982
  }, locale).label;
15951
15983
  }
15984
+ function periodOrder(periodType) {
15985
+ if (periodType === "five_hour")
15986
+ return 0;
15987
+ if (periodType === "seven_day")
15988
+ return 1;
15989
+ if (periodType === "weekly")
15990
+ return 2;
15991
+ if (periodType === "monthly")
15992
+ return 3;
15993
+ return 4;
15994
+ }
15995
+ function groupAccountCreditsWindows(credits, locale, periodLabel, groupedPeriodLabel = periodLabel) {
15996
+ const entries = [
15997
+ {
15998
+ label: credits.label,
15999
+ periodType: credits.periodType,
16000
+ scope: credits.scope,
16001
+ localizations: credits.localizations,
16002
+ usedPercent: credits.usedPercent,
16003
+ used: credits.used,
16004
+ limit: credits.limit,
16005
+ unit: credits.unit,
16006
+ resetsAt: credits.resetsAt,
16007
+ isPrimary: true
16008
+ },
16009
+ ...(credits.productUsage ?? []).map((item) => ({
16010
+ product: item.product,
16011
+ periodType: item.periodType,
16012
+ scope: item.scope,
16013
+ localizations: item.localizations,
16014
+ usedPercent: item.usagePercent,
16015
+ used: item.used,
16016
+ limit: item.limit,
16017
+ unit: item.unit,
16018
+ resetsAt: item.resetsAt,
16019
+ isPrimary: false
16020
+ }))
16021
+ ];
16022
+ const scopeCounts = /* @__PURE__ */ new Map();
16023
+ for (const entry of entries) {
16024
+ if (entry.scope)
16025
+ scopeCounts.set(entry.scope.id, (scopeCounts.get(entry.scope.id) ?? 0) + 1);
16026
+ }
16027
+ const sections = /* @__PURE__ */ new Map();
16028
+ for (const entry of entries) {
16029
+ const groupedScope = entry.scope && (scopeCounts.get(entry.scope.id) ?? 0) >= 2 ? entry.scope : void 0;
16030
+ const key = groupedScope ? `scope:${groupedScope.id}` : "default";
16031
+ let section = sections.get(key);
16032
+ if (!section) {
16033
+ section = groupedScope ? {
16034
+ id: groupedScope.id,
16035
+ title: localizeHarnessPresentation(groupedScope, locale).label,
16036
+ windows: []
16037
+ } : { windows: [] };
16038
+ sections.set(key, section);
16039
+ }
16040
+ const inlineScope = !groupedScope && entry.scope && entry.periodType && entry.periodType !== "unknown" ? localizeHarnessPresentation(entry.scope, locale).label : void 0;
16041
+ const label = groupedScope && entry.periodType && entry.periodType !== "unknown" ? groupedPeriodLabel(entry.periodType) : inlineScope && entry.periodType && entry.periodType !== "unknown" ? periodLabel(entry.periodType) : accountCreditsWindowLabel(entry, locale, periodLabel);
16042
+ section.windows.push({
16043
+ order: groupedScope ? periodOrder(entry.periodType) : 0,
16044
+ window: {
16045
+ label,
16046
+ ...inlineScope ? { scopeLabel: inlineScope } : {},
16047
+ usedPercent: entry.usedPercent ?? 0,
16048
+ ...entry.used === void 0 ? {} : { used: entry.used },
16049
+ ...entry.limit === void 0 ? {} : { limit: entry.limit },
16050
+ ...entry.unit === void 0 ? {} : { unit: entry.unit },
16051
+ ...entry.resetsAt === void 0 ? {} : { resetsAt: entry.resetsAt },
16052
+ isPrimary: entry.isPrimary
16053
+ }
16054
+ });
16055
+ }
16056
+ return [...sections.values()].map(({ windows, ...section }) => ({
16057
+ ...section,
16058
+ windows: (section.title !== void 0 ? [...windows].sort((left, right) => left.order - right.order) : windows).map((item) => item.window)
16059
+ }));
16060
+ }
16061
+ function countdownMinutes(value, nowMs) {
16062
+ const timestamp = typeof value === "number" ? value * 1e3 : Date.parse(value);
16063
+ if (!Number.isFinite(timestamp))
16064
+ return null;
16065
+ return Math.max(0, Math.ceil((timestamp - nowMs) / 6e4));
16066
+ }
16067
+ function isChineseLocale(locale) {
16068
+ return locale === "zh-CN" || locale.startsWith("zh-");
16069
+ }
16070
+ function compactDurationText(minutes) {
16071
+ if (minutes >= 1440) {
16072
+ const days = Math.floor(minutes / 1440);
16073
+ const hours2 = Math.floor(minutes % 1440 / 60);
16074
+ return hours2 > 0 ? `${days}d${hours2}h` : `${days}d`;
16075
+ }
16076
+ const hours = Math.floor(minutes / 60);
16077
+ const mins = minutes % 60;
16078
+ if (hours > 0)
16079
+ return mins > 0 ? `${hours}h${mins}m` : `${hours}h`;
16080
+ return `${mins}m`;
16081
+ }
16082
+ function formatAccountCreditsResetCountdown(value, locale, nowMs = Date.now()) {
16083
+ const minutes = countdownMinutes(value, nowMs);
16084
+ if (minutes === null)
16085
+ return null;
16086
+ const chinese = isChineseLocale(locale);
16087
+ if (minutes === 0)
16088
+ return chinese ? "\u5373\u5C06\u91CD\u7F6E" : "Resets soon";
16089
+ if (minutes >= 1440) {
16090
+ const days = Math.floor(minutes / 1440);
16091
+ const hours2 = Math.floor(minutes % 1440 / 60);
16092
+ if (chinese)
16093
+ return hours2 > 0 ? `${days} \u5929 ${hours2} \u5C0F\u65F6\u540E\u91CD\u7F6E` : `${days} \u5929\u540E\u91CD\u7F6E`;
16094
+ return hours2 > 0 ? `Resets in ${days}d ${hours2}h` : `Resets in ${days}d`;
16095
+ }
16096
+ const hours = Math.floor(minutes / 60);
16097
+ const mins = minutes % 60;
16098
+ if (hours > 0) {
16099
+ if (chinese)
16100
+ return mins > 0 ? `${hours} \u5C0F\u65F6 ${mins} \u5206\u540E\u91CD\u7F6E` : `${hours} \u5C0F\u65F6\u540E\u91CD\u7F6E`;
16101
+ return mins > 0 ? `Resets in ${hours}h ${mins}m` : `Resets in ${hours}h`;
16102
+ }
16103
+ return chinese ? `${mins} \u5206\u949F\u540E\u91CD\u7F6E` : `Resets in ${mins}m`;
16104
+ }
16105
+ function formatAccountCreditsCompactCountdown(value, locale, nowMs = Date.now()) {
16106
+ const minutes = countdownMinutes(value, nowMs);
16107
+ if (minutes === null)
16108
+ return null;
16109
+ if (minutes === 0)
16110
+ return isChineseLocale(locale) ? "\u5373\u5C06\u91CD\u7F6E" : "Resets soon";
16111
+ return compactDurationText(minutes);
16112
+ }
15952
16113
 
15953
16114
  // ../shared-contracts/dist/model-price-overrides.js
15954
16115
  var MODEL_PRICE_OVERRIDES_GET_METHOD = "codexhost/usage/model-prices/get";
@@ -16859,6 +17020,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16859
17020
  "completed",
16860
17021
  "failed",
16861
17022
  "interrupted",
17023
+ "needsInput",
16862
17024
  "timedOut",
16863
17025
  "unreadable",
16864
17026
  "notFound"
@@ -16908,13 +17070,26 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16908
17070
  var thread = { ...target, threadId: identity };
16909
17071
  var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
16910
17072
  external_exports.strictObject({ kind: external_exports.literal("hosts") }),
17073
+ external_exports.strictObject({ kind: external_exports.literal("status"), ...thread }),
16911
17074
  external_exports.strictObject({
16912
17075
  kind: external_exports.literal("list"),
16913
17076
  ...target,
16914
17077
  cursor: external_exports.string().nullable(),
16915
17078
  archived: external_exports.boolean()
16916
17079
  }),
16917
- external_exports.strictObject({ kind: external_exports.literal("read"), ...thread }),
17080
+ external_exports.strictObject({
17081
+ kind: external_exports.literal("read"),
17082
+ ...thread,
17083
+ page: external_exports.strictObject({
17084
+ cursor: external_exports.string().min(1).max(8192).nullable(),
17085
+ epoch: identity.optional(),
17086
+ sortDirection: external_exports.enum(["asc", "desc"]).optional(),
17087
+ limit: external_exports.number().int().min(1).max(20).optional()
17088
+ }).refine((page) => page.cursor === null || page.epoch !== void 0, {
17089
+ message: "A history continuation requires its connection epoch"
17090
+ }).optional()
17091
+ }),
17092
+ external_exports.strictObject({ kind: external_exports.literal("usage"), ...thread, epoch: identity }),
16918
17093
  external_exports.strictObject({
16919
17094
  kind: external_exports.literal("configure"),
16920
17095
  ...thread,
@@ -16995,6 +17170,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16995
17170
  external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
16996
17171
  ]);
16997
17172
 
17173
+ // ../shared-contracts/dist/thread-title.js
17174
+ var threadTitleInputSchema = external_exports.strictObject({
17175
+ prompt: external_exports.string().trim().min(1).max(2e3),
17176
+ cwd: external_exports.string().max(4096).nullable()
17177
+ });
17178
+ var threadTitleResultSchema = external_exports.string().trim().min(1).max(60).nullable();
17179
+
16998
17180
  // ../shared-contracts/dist/web-ui-extensions.js
16999
17181
  var webUiExtensionIdSchema = external_exports.string().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u);
17000
17182
  var localizedTextSchema2 = external_exports.union([
@@ -19755,240 +19937,717 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19755
19937
  return icon2;
19756
19938
  }
19757
19939
 
19758
- // src/settings/harness-launch-controls.ts
19759
- function createHarnessLaunchControls(document2, messages, agent, settings) {
19760
- const section = document2.createElement("section");
19761
- section.className = "settings-harness-launch";
19762
- section.dataset.harnessLaunch = agent;
19763
- const label = document2.createElement("label");
19764
- label.textContent = messages.launchPathLabel;
19765
- const input = document2.createElement("input");
19766
- input.type = "text";
19767
- input.autocomplete = "off";
19768
- input.spellcheck = false;
19769
- input.placeholder = messages.locale === "zh-CN" ? "\u5E94\u7528\u5B89\u88C5\u76EE\u5F55\u7684\u7EDD\u5BF9\u8DEF\u5F84" : "Absolute installation directory";
19770
- input.setAttribute("aria-label", messages.launchPathLabel);
19771
- label.append(input);
19772
- const help = document2.createElement("p");
19773
- 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.";
19774
- const actions = document2.createElement("div");
19775
- actions.className = "settings-harness-launch__actions";
19776
- const save = document2.createElement("button");
19777
- save.type = "button";
19778
- save.className = "settings-command-button";
19779
- save.textContent = messages.launchPathSave;
19780
- const reset = document2.createElement("button");
19781
- reset.type = "button";
19782
- reset.className = "settings-command-button settings-command-button--secondary";
19783
- reset.textContent = messages.launchPathReset;
19784
- const status = document2.createElement("p");
19785
- status.setAttribute("role", "status");
19786
- status.setAttribute("aria-live", "polite");
19787
- actions.append(save, reset);
19788
- section.append(label, help, actions, status);
19789
- let busy = true;
19790
- let loaded = false;
19791
- const controls = () => {
19792
- input.disabled = busy || !loaded;
19793
- save.disabled = busy || !loaded || !input.value.trim();
19794
- reset.disabled = busy || !loaded;
19795
- };
19796
- const show = (value) => {
19797
- input.value = value.path ?? "";
19798
- status.textContent = value.restartRequired ? messages.launchPathRestart : value.path ? messages.launchPathSaved : messages.launchPathAutomatic;
19799
- };
19800
- const persist = async (value) => {
19801
- if (busy || !loaded) return;
19802
- busy = true;
19803
- controls();
19804
- status.textContent = messages.launchPathSaving;
19805
- try {
19806
- show(await settings.set(value));
19807
- } catch {
19808
- status.textContent = messages.launchPathSaveError;
19809
- } finally {
19810
- busy = false;
19811
- controls();
19812
- }
19813
- };
19814
- input.addEventListener("input", controls);
19815
- save.addEventListener("click", () => {
19816
- if (input.value.trim()) void persist(input.value.trim());
19817
- });
19818
- reset.addEventListener("click", () => {
19819
- void persist(null);
19820
- });
19821
- controls();
19822
- status.textContent = messages.launchPathLoading;
19823
- void settings.get().then((value) => {
19824
- loaded = true;
19825
- show(value);
19826
- }).catch(() => {
19827
- loaded = true;
19828
- status.textContent = messages.launchPathLoadError;
19829
- }).finally(() => {
19830
- busy = false;
19831
- controls();
19832
- });
19833
- return section;
19940
+ // src/settings/harness-version-messages.ts
19941
+ var harnessVersionEnglish = Object.freeze({
19942
+ locale: "en",
19943
+ unknown: "Unknown",
19944
+ trackingBranch: "Tracking branch (new commits)",
19945
+ notes: Object.freeze({
19946
+ "original-installer": "Use the original installer, package manager, or launcher to update this installation."
19947
+ })
19948
+ });
19949
+ var harnessVersionChinese = Object.freeze({
19950
+ locale: "zh-CN",
19951
+ unknown: "\u672A\u77E5",
19952
+ trackingBranch: "\u8DDF\u8E2A\u5206\u652F\uFF08\u6709\u65B0\u63D0\u4EA4\uFF09",
19953
+ notes: Object.freeze({
19954
+ "original-installer": "\u8BF7\u4F7F\u7528\u539F\u5B89\u88C5\u7A0B\u5E8F\u3001\u5305\u7BA1\u7406\u5668\u6216\u542F\u52A8\u5668\u66F4\u65B0\u6B64\u5B89\u88C5\u3002"
19955
+ })
19956
+ });
19957
+ function harnessVersionLabel(state, messages) {
19958
+ if (!state) return "\u2014";
19959
+ if (state.latestVersionKind === "unknown" || state.latestVersion === "Unknown")
19960
+ return messages.unknown;
19961
+ if (state.latestVersionKind === "tracking-branch" || state.latestVersion === "Tracking branch (new commits)")
19962
+ return messages.trackingBranch;
19963
+ return state.latestVersion;
19964
+ }
19965
+ function harnessVersionNote(state, messages) {
19966
+ if (state?.notice) return localizeHarnessText(state.notice, messages.locale);
19967
+ const code = state?.messageCode;
19968
+ return code && Object.hasOwn(messages.notes, code) ? messages.notes[code] : void 0;
19834
19969
  }
19835
19970
 
19836
- // src/settings/claude-long-context-control.ts
19837
- var CLAUDE_LONG_CONTEXT_MODELS = [{ id: "claude-opus-5-5", window: "1M" }];
19838
- var tooltipSequence = 0;
19839
- function popoverOpen(tooltip) {
19840
- try {
19841
- return tooltip.matches(":popover-open");
19842
- } catch {
19843
- return false;
19971
+ // src/settings/connection-row.ts
19972
+ function connectionStatusLabel(availability, messages, hasError = false) {
19973
+ if (availability === "updating") return messages.connectionStatusUpdating;
19974
+ if (hasError && availability !== "notInstalled") return messages.connectionStatusError;
19975
+ if (availability === "ready") return messages.connectionStatusReady;
19976
+ if (availability === "checking") return messages.connectionStatusChecking;
19977
+ if (availability === "notInstalled") return messages.connectionStatusNotInstalled;
19978
+ if (availability === "unavailable" || availability === "error") {
19979
+ return availability === "error" ? messages.connectionStatusError : messages.connectionStatusUnavailable;
19844
19980
  }
19981
+ return availability === "installing" ? messages.connectionStatusInstalling : messages.connectionStatusUnsupported;
19845
19982
  }
19846
- function createClaudeLongContextControl(document2, messages, actions) {
19847
- const control = document2.createElement("span");
19848
- control.className = "settings-connection-long-context";
19849
- const label = document2.createElement("label");
19850
- label.className = "settings-connection-long-context__control";
19851
- const text = document2.createElement("span");
19852
- text.textContent = messages.connectionLongContextLabel;
19853
- const input = document2.createElement("input");
19854
- input.type = "checkbox";
19855
- input.checked = true;
19856
- input.setAttribute("role", "switch");
19857
- input.setAttribute("aria-checked", "true");
19858
- input.setAttribute("aria-label", messages.connectionLongContextLabel);
19859
- input.dataset.connectionAction = "long-context";
19860
- const tooltip = document2.createElement("div");
19861
- tooltip.id = `settings-long-context-tooltip-${++tooltipSequence}`;
19862
- tooltip.className = "settings-connection-long-context__tooltip";
19863
- tooltip.setAttribute("role", "tooltip");
19864
- tooltip.setAttribute("popover", "manual");
19865
- tooltip.hidden = true;
19866
- const on = document2.createElement("p");
19867
- on.textContent = messages.connectionLongContextOn;
19868
- const off = document2.createElement("p");
19869
- off.textContent = messages.connectionLongContextOff;
19870
- const modelsLabel = document2.createElement("p");
19871
- modelsLabel.textContent = messages.connectionLongContextModelsLabel;
19872
- const models = document2.createElement("ul");
19873
- for (const model2 of CLAUDE_LONG_CONTEXT_MODELS) {
19874
- const item = document2.createElement("li");
19875
- item.textContent = `${model2.id} (${model2.window})`;
19876
- models.append(item);
19983
+ function connectionStatusTone(availability, hasError = false) {
19984
+ if (availability === "updating") return "checking";
19985
+ if (hasError && availability !== "notInstalled") return "failed";
19986
+ if (availability === "ready") return "ready";
19987
+ if (availability === "checking" || availability === "installing") return "checking";
19988
+ if (availability === "notInstalled") return "setup";
19989
+ return "failed";
19990
+ }
19991
+ function createConnectionIdentityIcon(document2, item, size) {
19992
+ const container = document2.createElement("span");
19993
+ container.className = item.agentSnapshot ? "settings-connection-row__mark settings-connection-row__mark--logo" : "settings-connection-row__mark";
19994
+ container.setAttribute("aria-hidden", "true");
19995
+ if (item.agentSnapshot) {
19996
+ container.append(
19997
+ createRendererAgentIcon(item.agentSnapshot.agent, size, document2, item.agentSnapshot.plugin)
19998
+ );
19999
+ } else {
20000
+ container.textContent = "CH";
19877
20001
  }
19878
- tooltip.append(on, off, modelsLabel, models);
19879
- input.setAttribute("aria-describedby", tooltip.id);
19880
- const stop = (event) => {
19881
- event.stopPropagation();
19882
- };
19883
- control.addEventListener("click", stop);
19884
- label.addEventListener("click", stop);
19885
- input.addEventListener("click", stop);
19886
- let surfaceReady = false;
19887
- const applyTooltipSurface = () => {
19888
- if (surfaceReady) return;
19889
- const probe = document2.createElement("span");
19890
- probe.style.cssText = "position:absolute;visibility:hidden;color:var(--settings-text);background-color:var(--settings-elevated);border-top-color:var(--settings-border)";
19891
- control.append(probe);
19892
- const computed = document2.defaultView?.getComputedStyle(probe);
19893
- const color = computed?.color;
19894
- const background = computed?.backgroundColor;
19895
- const borderColor = computed?.borderTopColor;
19896
- probe.remove();
19897
- if (color) tooltip.style.color = color;
19898
- if (background && background !== "rgba(0, 0, 0, 0)") tooltip.style.backgroundColor = background;
19899
- if (borderColor) tooltip.style.border = `1px solid ${borderColor}`;
19900
- surfaceReady = true;
19901
- };
19902
- const showTooltip = () => {
19903
- const root = control.getRootNode();
19904
- const host = root instanceof ShadowRoot ? root : document2.body ?? control;
19905
- if (tooltip.parentNode !== host) host.append(tooltip);
19906
- applyTooltipSurface();
19907
- tooltip.hidden = false;
19908
- if (typeof tooltip.showPopover === "function" && !popoverOpen(tooltip)) {
19909
- try {
19910
- tooltip.showPopover();
19911
- } catch {
19912
- tooltip.removeAttribute("popover");
19913
- }
20002
+ return container;
20003
+ }
20004
+ function sameElementChildren(container, next) {
20005
+ if (container.children.length !== next.length) return false;
20006
+ for (let index = 0; index < next.length; index++) {
20007
+ if (container.children[index] !== next[index]) return false;
20008
+ }
20009
+ return true;
20010
+ }
20011
+ function reconcileElementChildren(container, next) {
20012
+ if (sameElementChildren(container, next)) return;
20013
+ if (typeof container.insertBefore !== "function") {
20014
+ container.replaceChildren(...next);
20015
+ return;
20016
+ }
20017
+ const nextSet = new Set(next);
20018
+ for (const child of [...container.children]) {
20019
+ if (!nextSet.has(child)) child.remove();
20020
+ }
20021
+ for (let index = 0; index < next.length; index++) {
20022
+ const desired = next[index];
20023
+ if (!desired) continue;
20024
+ const current = container.children[index] ?? null;
20025
+ if (current !== desired) {
20026
+ container.insertBefore(desired, current);
19914
20027
  }
19915
- tooltip.style.position = "fixed";
19916
- tooltip.style.inset = "auto";
19917
- tooltip.style.zIndex = "80";
19918
- tooltip.style.margin = "0";
19919
- tooltip.style.height = "auto";
19920
- tooltip.style.overflow = "visible";
19921
- const rect = control.getBoundingClientRect();
19922
- const margin = 8;
19923
- const width = Math.min(280, Math.max(160, window.innerWidth - margin * 2));
19924
- tooltip.style.width = `${width}px`;
19925
- const preferredLeft = Math.min(
19926
- Math.max(margin, rect.right - width),
19927
- window.innerWidth - width - margin
19928
- );
19929
- const height = tooltip.offsetHeight;
19930
- const below = rect.bottom + 8;
19931
- const preferredTop = below + height <= window.innerHeight - margin ? below : Math.max(margin, rect.top - height - 8);
19932
- tooltip.style.left = `${preferredLeft}px`;
19933
- tooltip.style.top = `${preferredTop}px`;
19934
- const placed = tooltip.getBoundingClientRect();
19935
- const shiftX = preferredLeft - placed.left;
19936
- const shiftY = preferredTop - placed.top;
19937
- if (Math.abs(shiftX) > 0.5 || Math.abs(shiftY) > 0.5) {
19938
- tooltip.style.left = `${preferredLeft + shiftX}px`;
19939
- tooltip.style.top = `${preferredTop + shiftY}px`;
20028
+ }
20029
+ }
20030
+ function identityIconSignature(item) {
20031
+ if (!item.agentSnapshot) return "adapter";
20032
+ const plugin = item.agentSnapshot.plugin;
20033
+ return `${item.agentSnapshot.agent}:${String(plugin?.icon ?? "")}:${String(plugin?.iconStyle ?? "")}`;
20034
+ }
20035
+ function createConnectionRowView(document2, messages, groupable) {
20036
+ const row = document2.createElement("div");
20037
+ row.className = "settings-connection-row";
20038
+ row.setAttribute("role", "row");
20039
+ const identity3 = document2.createElement("div");
20040
+ identity3.className = "settings-connection-row__identity";
20041
+ identity3.setAttribute("role", "cell");
20042
+ let handle = null;
20043
+ if (groupable) {
20044
+ handle = document2.createElement("span");
20045
+ handle.className = "settings-connection-row__handle";
20046
+ handle.setAttribute("aria-hidden", "true");
20047
+ handle.append(createRendererSettingsIcon("grip-vertical", 15));
20048
+ identity3.append(handle);
20049
+ }
20050
+ let iconElement = null;
20051
+ let renderedIconKey = null;
20052
+ const label = document2.createElement("strong");
20053
+ const status = document2.createElement("span");
20054
+ status.className = "settings-connection-row__status";
20055
+ status.setAttribute("role", "cell");
20056
+ const action = document2.createElement("div");
20057
+ action.className = "settings-connection-row__action";
20058
+ action.setAttribute("role", "cell");
20059
+ row.append(identity3, status, action);
20060
+ let currentItem = null;
20061
+ let currentSelect = () => void 0;
20062
+ let currentGroup = null;
20063
+ let dragArmed = false;
20064
+ handle?.addEventListener("pointerdown", (event) => {
20065
+ if (event.button !== 0 || currentGroup?.disabled) return;
20066
+ dragArmed = true;
20067
+ row.draggable = true;
20068
+ });
20069
+ row.addEventListener("pointerup", () => {
20070
+ dragArmed = false;
20071
+ row.draggable = false;
20072
+ });
20073
+ row.addEventListener("pointercancel", () => {
20074
+ dragArmed = false;
20075
+ row.draggable = false;
20076
+ });
20077
+ let viewErrorButton = null;
20078
+ let versionAvailableBadge = null;
20079
+ let updateButton = null;
20080
+ let groupToggleButton = null;
20081
+ let groupToggleSection = null;
20082
+ row.addEventListener("click", (event) => {
20083
+ const target2 = event.target;
20084
+ if (target2?.closest?.("a")) return;
20085
+ currentSelect();
20086
+ });
20087
+ row.addEventListener("keydown", (event) => {
20088
+ if (event.target?.closest?.("button, a")) return;
20089
+ if (event.key !== "Enter" && event.key !== " ") return;
20090
+ event.preventDefault();
20091
+ currentSelect();
20092
+ });
20093
+ if (groupable) {
20094
+ row.addEventListener("dragstart", (event) => {
20095
+ if (!dragArmed) {
20096
+ event.preventDefault();
20097
+ return;
20098
+ }
20099
+ currentGroup?.onDragStart(event);
20100
+ });
20101
+ row.addEventListener("dragover", (event) => currentGroup?.onDragOver(event));
20102
+ row.addEventListener("dragleave", (event) => currentGroup?.onDragLeave(event));
20103
+ row.addEventListener("drop", (event) => currentGroup?.onDrop(event));
20104
+ row.addEventListener("dragend", (event) => {
20105
+ dragArmed = false;
20106
+ row.draggable = false;
20107
+ currentGroup?.onDragEnd(event);
20108
+ });
20109
+ }
20110
+ const setSelected = (selected) => {
20111
+ const nextSelected = String(selected);
20112
+ if (row.dataset.connectionSelected !== nextSelected) {
20113
+ row.dataset.connectionSelected = nextSelected;
20114
+ }
20115
+ const nextTabIndex = selected ? 0 : -1;
20116
+ if (row.tabIndex !== nextTabIndex) {
20117
+ row.tabIndex = nextTabIndex;
19940
20118
  }
19941
20119
  };
19942
- const hideTooltip = () => {
19943
- if (typeof tooltip.hidePopover === "function" && popoverOpen(tooltip)) {
19944
- try {
19945
- tooltip.hidePopover();
19946
- } catch {
20120
+ return {
20121
+ element: row,
20122
+ setSelected,
20123
+ update(item, selected, select, group) {
20124
+ currentItem = item;
20125
+ currentSelect = select;
20126
+ currentGroup = group;
20127
+ if (row.dataset.connectionItem !== item.key) {
20128
+ row.dataset.connectionItem = item.key;
20129
+ }
20130
+ setSelected(selected);
20131
+ const nextIconKey = identityIconSignature(item);
20132
+ if (renderedIconKey !== nextIconKey || !iconElement) {
20133
+ renderedIconKey = nextIconKey;
20134
+ iconElement = createConnectionIdentityIcon(document2, item, 19);
20135
+ reconcileElementChildren(
20136
+ identity3,
20137
+ handle ? [handle, iconElement, label] : [iconElement, label]
20138
+ );
20139
+ }
20140
+ if (handle && group && handle.title !== group.dragHandleTitle) {
20141
+ handle.title = group.dragHandleTitle;
20142
+ }
20143
+ if (label.textContent !== item.name) {
20144
+ label.textContent = item.name;
20145
+ }
20146
+ const tone = connectionStatusTone(item.availability, item.error !== null);
20147
+ if (status.dataset.connectionTone !== tone) {
20148
+ status.dataset.connectionTone = tone;
20149
+ }
20150
+ const statusText = item.error?.code === "authenticationRequired" ? messages.connectionLoginRequired : item.error?.code === "configurationRequired" ? messages.connectionConfigurationRequired : connectionStatusLabel(item.availability, messages, item.error !== null);
20151
+ if (status.textContent !== statusText) {
20152
+ status.textContent = statusText;
20153
+ }
20154
+ const nextActions = [];
20155
+ if (item.error) {
20156
+ if (!viewErrorButton) {
20157
+ const button2 = document2.createElement("button");
20158
+ button2.type = "button";
20159
+ button2.className = "settings-connection-view-error";
20160
+ button2.textContent = messages.connectionViewError;
20161
+ button2.addEventListener("click", (event) => {
20162
+ event.stopPropagation();
20163
+ currentSelect();
20164
+ });
20165
+ viewErrorButton = button2;
20166
+ }
20167
+ nextActions.push(viewErrorButton);
20168
+ }
20169
+ const version2 = item.version;
20170
+ if (item.accessory) nextActions.push(item.accessory);
20171
+ if (version2?.state?.updateAvailable && !version2.updating) {
20172
+ if (!versionAvailableBadge) {
20173
+ const badge = document2.createElement("span");
20174
+ badge.className = "settings-connection-version-available";
20175
+ badge.textContent = messages.harnessVersionAvailable;
20176
+ versionAvailableBadge = badge;
20177
+ }
20178
+ const badgeTitle = `${messages.harnessVersionCurrent}: ${version2.state.currentVersion ?? "\u2014"}
20179
+ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages.harnessVersion)}`;
20180
+ if (versionAvailableBadge.title !== badgeTitle) {
20181
+ versionAvailableBadge.title = badgeTitle;
20182
+ }
20183
+ nextActions.push(versionAvailableBadge);
20184
+ }
20185
+ if (version2?.state?.updateAvailable && version2.state.canUpdate) {
20186
+ if (!updateButton) {
20187
+ const button2 = document2.createElement("button");
20188
+ button2.type = "button";
20189
+ button2.className = "settings-connection-install-link";
20190
+ button2.dataset.connectionAction = "update";
20191
+ button2.append(createRendererSettingsIcon("download", 17));
20192
+ button2.addEventListener("click", (event) => {
20193
+ event.stopPropagation();
20194
+ if (button2.disabled) return;
20195
+ void currentItem?.version?.update();
20196
+ currentSelect();
20197
+ });
20198
+ updateButton = button2;
20199
+ }
20200
+ updateButton.disabled = version2.updating;
20201
+ const updateTitle = `${messages.harnessVersionUpdate}: ${item.name}
20202
+ ${messages.harnessVersionCurrent}: ${version2.state.currentVersion ?? "\u2014"}
20203
+ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages.harnessVersion)}`;
20204
+ if (updateButton.title !== updateTitle) {
20205
+ updateButton.title = updateTitle;
20206
+ }
20207
+ const updateAriaLabel = `${messages.harnessVersionUpdate}: ${item.name}`;
20208
+ if (updateButton.getAttribute("aria-label") !== updateAriaLabel) {
20209
+ updateButton.setAttribute("aria-label", updateAriaLabel);
20210
+ }
20211
+ nextActions.push(updateButton);
20212
+ }
20213
+ if (group) {
20214
+ if (!groupToggleButton) {
20215
+ const button2 = document2.createElement("button");
20216
+ button2.type = "button";
20217
+ button2.className = "settings-connection-row__group-toggle";
20218
+ button2.addEventListener("click", (event) => {
20219
+ event.stopPropagation();
20220
+ currentGroup?.toggleSection();
20221
+ });
20222
+ groupToggleButton = button2;
20223
+ }
20224
+ groupToggleButton.disabled = group.disabled;
20225
+ if (groupToggleButton.title !== group.moveLabel) {
20226
+ groupToggleButton.title = group.moveLabel;
20227
+ }
20228
+ if (groupToggleButton.getAttribute("aria-label") !== group.moveLabel) {
20229
+ groupToggleButton.setAttribute("aria-label", group.moveLabel);
20230
+ }
20231
+ if (groupToggleSection !== group.section) {
20232
+ groupToggleSection = group.section;
20233
+ groupToggleButton.replaceChildren(
20234
+ createRendererSettingsIcon(
20235
+ group.section === "main" ? "chevron-down" : "chevron-up",
20236
+ 15
20237
+ )
20238
+ );
20239
+ }
20240
+ nextActions.push(groupToggleButton);
20241
+ }
20242
+ reconcileElementChildren(action, nextActions);
20243
+ if (group) {
20244
+ if (group.disabled) {
20245
+ dragArmed = false;
20246
+ row.draggable = false;
20247
+ }
20248
+ if (row.dataset.connectionGroupSection !== group.section) {
20249
+ row.dataset.connectionGroupSection = group.section;
20250
+ }
19947
20251
  }
19948
20252
  }
19949
- tooltip.hidden = true;
19950
20253
  };
19951
- control.addEventListener("mouseenter", showTooltip);
19952
- control.addEventListener("mouseleave", hideTooltip);
19953
- control.addEventListener("focusin", showTooltip);
19954
- control.addEventListener("focusout", (event) => {
19955
- const next = event.relatedTarget;
19956
- if (next instanceof Node && control.contains(next)) return;
19957
- hideTooltip();
19958
- });
19959
- let generation = 0;
19960
- input.addEventListener("change", () => {
19961
- const next = input.checked;
19962
- generation += 1;
19963
- const request = generation;
19964
- input.disabled = true;
19965
- input.setAttribute("aria-checked", String(next));
19966
- void actions.set(next).then(
19967
- (result) => {
19968
- if (request !== generation) return;
19969
- input.checked = result.enabled;
19970
- input.setAttribute("aria-checked", String(result.enabled));
19971
- input.disabled = false;
19972
- },
20254
+ }
20255
+
20256
+ // src/settings/connection-updates.ts
20257
+ var sharedBatchStores = /* @__PURE__ */ new WeakMap();
20258
+ function getBatchStore(diagnostics) {
20259
+ if (!diagnostics) {
20260
+ return { batches: /* @__PURE__ */ new Map(), listeners: /* @__PURE__ */ new Set() };
20261
+ }
20262
+ let store = sharedBatchStores.get(diagnostics);
20263
+ if (!store) {
20264
+ store = { batches: /* @__PURE__ */ new Map(), listeners: /* @__PURE__ */ new Set() };
20265
+ sharedBatchStores.set(diagnostics, store);
20266
+ }
20267
+ return store;
20268
+ }
20269
+ function createConnectionUpdates(document2, messages, signal, onChange, diagnostics = null) {
20270
+ const store = getBatchStore(diagnostics);
20271
+ const notify2 = () => {
20272
+ for (const listener of [...store.listeners]) listener();
20273
+ };
20274
+ if (!signal.aborted) {
20275
+ const listener = () => {
20276
+ if (!signal.aborted) onChange();
20277
+ };
20278
+ store.listeners.add(listener);
20279
+ signal.addEventListener(
20280
+ "abort",
19973
20281
  () => {
19974
- if (request !== generation) return;
19975
- input.checked = !next;
19976
- input.setAttribute("aria-checked", String(!next));
19977
- input.disabled = false;
19978
- }
20282
+ store.listeners.delete(listener);
20283
+ },
20284
+ { once: true }
20285
+ );
20286
+ }
20287
+ const eligible = (panels) => panels.filter((panel) => panel.state?.updateAvailable && panel.state.canUpdate);
20288
+ const start = async (hostId2, panels) => {
20289
+ if (signal.aborted || store.batches.get(hostId2)?.running) return;
20290
+ const targets = eligible(panels);
20291
+ if (!targets.length) return;
20292
+ const batch = { running: true, total: targets.length, succeeded: 0, failed: 0 };
20293
+ store.batches.set(hostId2, batch);
20294
+ notify2();
20295
+ await Promise.all(
20296
+ targets.map(async (panel) => {
20297
+ try {
20298
+ if (await panel.update()) batch.succeeded++;
20299
+ else batch.failed++;
20300
+ } catch {
20301
+ batch.failed++;
20302
+ }
20303
+ notify2();
20304
+ })
19979
20305
  );
20306
+ batch.running = false;
20307
+ notify2();
20308
+ };
20309
+ return {
20310
+ createControls(hostId2, panels) {
20311
+ let currentHostId = hostId2;
20312
+ let currentPanels = panels;
20313
+ let renderedLabel = null;
20314
+ const button2 = document2.createElement("button");
20315
+ button2.type = "button";
20316
+ button2.className = "settings-command-button settings-command-button--secondary settings-connection-update-all";
20317
+ button2.dataset.connectionAction = "update-all";
20318
+ button2.title = messages.harnessUpdateAllDescription;
20319
+ button2.addEventListener("click", () => {
20320
+ if (!button2.disabled) void start(currentHostId, currentPanels);
20321
+ });
20322
+ const result = document2.createElement("p");
20323
+ result.className = "settings-connection-update-result";
20324
+ result.setAttribute("role", "status");
20325
+ const update = (nextHostId, nextPanels) => {
20326
+ currentHostId = nextHostId;
20327
+ currentPanels = nextPanels;
20328
+ const batch = store.batches.get(nextHostId);
20329
+ const count3 = eligible(nextPanels).length;
20330
+ button2.disabled = signal.aborted || Boolean(batch?.running) || !count3;
20331
+ const label = batch?.running ? `${messages.harnessUpdateAllProgress} ${batch.succeeded + batch.failed}/${batch.total}` : count3 ? `${messages.harnessUpdateAll} (${count3})` : messages.harnessUpdateAll;
20332
+ if (renderedLabel !== label) {
20333
+ renderedLabel = label;
20334
+ button2.replaceChildren(createRendererSettingsIcon("download", 15), label);
20335
+ }
20336
+ const hidden = !batch || batch.running;
20337
+ result.hidden = hidden;
20338
+ const resultText = batch && !batch.running ? messages.harnessUpdateAllResult.replace("{succeeded}", String(batch.succeeded)).replace("{failed}", String(batch.failed)) : "";
20339
+ if (result.textContent !== resultText) {
20340
+ result.textContent = resultText;
20341
+ }
20342
+ };
20343
+ update(hostId2, panels);
20344
+ return { button: button2, result, update };
20345
+ }
20346
+ };
20347
+ }
20348
+
20349
+ // src/settings/harness-version-panel.ts
20350
+ function isUnsupportedInstallationError(error51) {
20351
+ return typeof error51 === "object" && error51 !== null && "code" in error51 && (error51.code === -32601 || error51.code === -32078);
20352
+ }
20353
+ function createHarnessVersionSession(client, options) {
20354
+ let state;
20355
+ let statusKind = "checking";
20356
+ let checkPromise = null;
20357
+ let updatePromise = null;
20358
+ const listeners = /* @__PURE__ */ new Set();
20359
+ const signal = options?.signal;
20360
+ const notify2 = (pageChange) => {
20361
+ if (signal?.aborted) return;
20362
+ for (const listener of [...listeners]) listener(pageChange);
20363
+ };
20364
+ const check2 = () => {
20365
+ if (signal?.aborted || updatePromise) return Promise.resolve();
20366
+ if (checkPromise) return checkPromise;
20367
+ statusKind = "checking";
20368
+ notify2(false);
20369
+ checkPromise = (async () => {
20370
+ try {
20371
+ const result = await client.run("check");
20372
+ if (signal?.aborted || updatePromise) return;
20373
+ state = result;
20374
+ statusKind = "idle";
20375
+ } catch (error51) {
20376
+ if (signal?.aborted || updatePromise) return;
20377
+ statusKind = isUnsupportedInstallationError(error51) ? "unsupported" : "failed";
20378
+ if (state) state = { ...state, canUpdate: false };
20379
+ } finally {
20380
+ checkPromise = null;
20381
+ if (!signal?.aborted && !updatePromise) {
20382
+ notify2(true);
20383
+ }
20384
+ }
20385
+ })();
20386
+ return checkPromise;
20387
+ };
20388
+ const update = () => {
20389
+ if (updatePromise) return updatePromise;
20390
+ updatePromise = (async () => {
20391
+ if (signal?.aborted) return false;
20392
+ if (checkPromise) await checkPromise;
20393
+ if (signal?.aborted || statusKind === "unsupported" || !state?.canUpdate || !state.updateAvailable) {
20394
+ return false;
20395
+ }
20396
+ statusKind = "updating";
20397
+ notify2(true);
20398
+ try {
20399
+ const result = await client.run("update");
20400
+ if (signal?.aborted) return false;
20401
+ state = result;
20402
+ statusKind = !result.canUpdate ? "updated" : result.updateAvailable ? "failed" : "updated";
20403
+ return result.canUpdate && !result.updateAvailable;
20404
+ } catch (error51) {
20405
+ if (signal?.aborted) return false;
20406
+ statusKind = isUnsupportedInstallationError(error51) ? "unsupported" : "failed";
20407
+ if (state) state = { ...state, canUpdate: false };
20408
+ return false;
20409
+ } finally {
20410
+ updatePromise = null;
20411
+ if (!signal?.aborted) {
20412
+ notify2(true);
20413
+ }
20414
+ }
20415
+ })();
20416
+ return updatePromise;
20417
+ };
20418
+ return {
20419
+ get state() {
20420
+ return state;
20421
+ },
20422
+ get statusKind() {
20423
+ return statusKind;
20424
+ },
20425
+ get updating() {
20426
+ return statusKind === "updating";
20427
+ },
20428
+ prepareMount() {
20429
+ if (updatePromise || checkPromise) return false;
20430
+ statusKind = "checking";
20431
+ return true;
20432
+ },
20433
+ check: check2,
20434
+ update,
20435
+ subscribe(listener) {
20436
+ listeners.add(listener);
20437
+ return () => {
20438
+ listeners.delete(listener);
20439
+ };
20440
+ }
20441
+ };
20442
+ }
20443
+ function createHarnessVersionPanel(document2, messages, signal, agent, client, onChange = () => void 0, sharedSession) {
20444
+ const session = sharedSession ?? createHarnessVersionSession(client, { signal });
20445
+ const shouldScheduleCheck = session.prepareMount();
20446
+ const panel = document2.createElement("section");
20447
+ panel.className = "settings-harness-version";
20448
+ panel.dataset.harnessVersion = agent;
20449
+ const heading = document2.createElement("strong");
20450
+ heading.textContent = messages.harnessVersionTitle;
20451
+ const versions = document2.createElement("div");
20452
+ versions.className = "settings-harness-version__values";
20453
+ const current = document2.createElement("span");
20454
+ const latest = document2.createElement("span");
20455
+ versions.append(current, latest);
20456
+ const status = document2.createElement("p");
20457
+ status.setAttribute("role", "status");
20458
+ const actions = document2.createElement("div");
20459
+ actions.className = "settings-connection-error-actions";
20460
+ const update = document2.createElement("button");
20461
+ update.type = "button";
20462
+ update.className = "settings-command-button settings-command-button--secondary";
20463
+ update.dataset.harnessVersionAction = "update";
20464
+ const note = document2.createElement("p");
20465
+ note.className = "settings-connection-issue-note";
20466
+ note.textContent = messages.harnessVersionNote;
20467
+ actions.append(update);
20468
+ panel.append(heading, versions, status, actions, note);
20469
+ const render = () => {
20470
+ const state = session.state;
20471
+ const statusKind = session.statusKind;
20472
+ const busy = statusKind === "checking" || statusKind === "updating";
20473
+ heading.textContent = state?.versionKind === "application" ? messages.harnessVersionApplicationTitle : messages.harnessVersionTitle;
20474
+ current.textContent = `${messages.harnessVersionCurrent}: ${state?.currentVersion ?? "\u2014"}`;
20475
+ latest.textContent = `${messages.harnessVersionLatest}: ${harnessVersionLabel(state, messages.harnessVersion)}`;
20476
+ 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 : "";
20477
+ update.disabled = busy || signal.aborted || !state?.canUpdate || !state.updateAvailable;
20478
+ const manualUrl = !state?.canUpdate && state?.updateAvailable ? state.manualUpdateUrl : void 0;
20479
+ actions.replaceChildren(update);
20480
+ update.hidden = !busy && !signal.aborted && Boolean(manualUrl);
20481
+ if (update.hidden && manualUrl) {
20482
+ const download2 = document2.createElement("a");
20483
+ download2.className = "settings-command-button settings-command-button--secondary";
20484
+ download2.dataset.harnessVersionAction = "download-update";
20485
+ download2.textContent = messages.harnessVersionDownloadUpdate;
20486
+ download2.href = manualUrl;
20487
+ download2.target = "_blank";
20488
+ download2.rel = "noopener noreferrer";
20489
+ actions.append(download2);
20490
+ }
20491
+ update.textContent = state?.canUpdate && state.latestVersion !== "Unknown" && !state.updateAvailable ? messages.harnessVersionUpToDate : messages.harnessVersionUpdate;
20492
+ const detail = harnessVersionNote(state, messages.harnessVersion);
20493
+ note.textContent = detail ? !state?.canUpdate ? detail : `${detail} ${messages.harnessVersionNote}` : messages.harnessVersionNote;
20494
+ };
20495
+ update.addEventListener("click", () => {
20496
+ if (!signal.aborted) void session.update();
19980
20497
  });
19981
- void actions.get().then(
19982
- (result) => {
19983
- if (generation !== 0) return;
19984
- input.checked = result.enabled;
19985
- input.setAttribute("aria-checked", String(result.enabled));
20498
+ const unsubscribe = session.subscribe((pageChange) => {
20499
+ if (signal.aborted) return;
20500
+ render();
20501
+ if (pageChange) onChange();
20502
+ });
20503
+ const owner = document2.defaultView;
20504
+ let checkFrame = null;
20505
+ let checkTimer = null;
20506
+ signal.addEventListener(
20507
+ "abort",
20508
+ () => {
20509
+ unsubscribe();
20510
+ if (checkFrame !== null) owner?.cancelAnimationFrame(checkFrame);
20511
+ if (checkTimer !== null) owner?.clearTimeout(checkTimer);
20512
+ render();
19986
20513
  },
19987
- () => void 0
20514
+ { once: true }
19988
20515
  );
19989
- label.append(text, input);
19990
- control.append(label, tooltip);
19991
- return control;
20516
+ render();
20517
+ if (shouldScheduleCheck && !signal.aborted) {
20518
+ if (owner?.requestAnimationFrame) {
20519
+ checkFrame = owner.requestAnimationFrame(() => {
20520
+ checkFrame = null;
20521
+ if (signal.aborted) return;
20522
+ checkTimer = owner.setTimeout(() => {
20523
+ checkTimer = null;
20524
+ if (!signal.aborted) void session.check();
20525
+ }, 0);
20526
+ });
20527
+ } else {
20528
+ void session.check();
20529
+ }
20530
+ }
20531
+ return {
20532
+ element: panel,
20533
+ get state() {
20534
+ return session.state;
20535
+ },
20536
+ get updating() {
20537
+ return session.updating;
20538
+ },
20539
+ update: () => signal.aborted ? Promise.resolve(false) : session.update()
20540
+ };
20541
+ }
20542
+
20543
+ // src/settings/connection-versions.ts
20544
+ var sessionStores = /* @__PURE__ */ new WeakMap();
20545
+ function getSessionStore(diagnostics) {
20546
+ let store = sessionStores.get(diagnostics);
20547
+ if (!store) {
20548
+ store = /* @__PURE__ */ new Map();
20549
+ sessionStores.set(diagnostics, store);
20550
+ }
20551
+ return store;
20552
+ }
20553
+ function createConnectionVersions(document2, messages, signal, diagnostics, onChange) {
20554
+ const panels = /* @__PURE__ */ new Map();
20555
+ const installation = diagnostics?.installation?.bind(diagnostics);
20556
+ const sessions = diagnostics ? getSessionStore(diagnostics) : null;
20557
+ const sessionKey = (hostId2, agent) => JSON.stringify([hostId2, agent]);
20558
+ return {
20559
+ isUpdating(hostId2, agent) {
20560
+ return Boolean(sessions?.get(sessionKey(hostId2, agent))?.updating);
20561
+ },
20562
+ get(hostId2, agent) {
20563
+ if (!installation || signal.aborted) return void 0;
20564
+ const key = sessionKey(hostId2, agent);
20565
+ let panel = panels.get(key);
20566
+ if (!panel) {
20567
+ const run = (action) => installation(hostId2, agent, action);
20568
+ let session = sessions?.get(key);
20569
+ if (!session) {
20570
+ session = createHarnessVersionSession({ run });
20571
+ sessions?.set(key, session);
20572
+ }
20573
+ panel = createHarnessVersionPanel(
20574
+ document2,
20575
+ messages,
20576
+ signal,
20577
+ agent,
20578
+ { run },
20579
+ onChange,
20580
+ session
20581
+ );
20582
+ panels.set(key, panel);
20583
+ }
20584
+ return panel;
20585
+ }
20586
+ };
20587
+ }
20588
+
20589
+ // src/settings/harness-install-store.ts
20590
+ function errorMessage(error51) {
20591
+ 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.";
20592
+ }
20593
+ function unknownInstallOutcome(message2) {
20594
+ return /outcome is unknown|do not retry automatically|did not answer in time/i.test(message2);
20595
+ }
20596
+ var stores = /* @__PURE__ */ new WeakMap();
20597
+ function createStore(diagnostics) {
20598
+ const states2 = /* @__PURE__ */ new Map();
20599
+ const listeners = /* @__PURE__ */ new Set();
20600
+ const key = (host, agent) => JSON.stringify([host, agent]);
20601
+ const notify2 = () => listeners.forEach((listener) => listener());
20602
+ return {
20603
+ get: (host, agent) => states2.get(key(host, agent)),
20604
+ clearErrors() {
20605
+ for (const [id, state] of states2) if (state.status === "error") states2.delete(id);
20606
+ notify2();
20607
+ },
20608
+ subscribe(listener) {
20609
+ listeners.add(listener);
20610
+ return () => {
20611
+ listeners.delete(listener);
20612
+ };
20613
+ },
20614
+ async install(host, agent) {
20615
+ const id = key(host, agent);
20616
+ const previous = states2.get(id);
20617
+ if (!diagnostics.installation || previous && previous.status !== "error") return;
20618
+ states2.set(id, { status: "installing" });
20619
+ notify2();
20620
+ let failure;
20621
+ try {
20622
+ await diagnostics.installation(host, agent, "install");
20623
+ states2.set(id, { status: "checking" });
20624
+ notify2();
20625
+ } catch (error51) {
20626
+ failure = errorMessage(error51);
20627
+ }
20628
+ try {
20629
+ await diagnostics.refresh(host);
20630
+ const refreshed = diagnostics.snapshot().hosts.find((candidate) => candidate.hostId === host)?.agents.find((candidate) => candidate.agent === agent);
20631
+ if (refreshed?.availability === "ready") failure = void 0;
20632
+ else if (failure && unknownInstallOutcome(failure) && refreshed && refreshed.availability !== "notInstalled") {
20633
+ failure = void 0;
20634
+ }
20635
+ } catch (error51) {
20636
+ failure ??= errorMessage(error51);
20637
+ }
20638
+ if (failure) states2.set(id, { status: "error", error: failure });
20639
+ else states2.delete(id);
20640
+ notify2();
20641
+ }
20642
+ };
20643
+ }
20644
+ function harnessInstallStore(diagnostics) {
20645
+ let store = stores.get(diagnostics);
20646
+ if (!store) {
20647
+ store = createStore(diagnostics);
20648
+ stores.set(diagnostics, store);
20649
+ }
20650
+ return store;
19992
20651
  }
19993
20652
 
19994
20653
  // src/settings/harness-installation-guides.ts
@@ -20074,447 +20733,262 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
20074
20733
  link(
20075
20734
  download2.url,
20076
20735
  `${download2.label} \xB7 ${zh ? "\u4E0B\u8F7D\u4E0E\u5B89\u88C5\u6307\u5357" : "Download and installation guide"}`
20077
- );
20078
- }
20079
- if (guide.after) paragraph(guide.after);
20080
- if (!plugin?.installation && guide.url) {
20081
- const link2 = document2.createElement("a");
20082
- link2.href = guide.url;
20083
- link2.target = "_blank";
20084
- link2.rel = "noopener noreferrer";
20085
- link2.textContent = zh ? "\u5B89\u88C5\u8BF4\u660E" : "Installation instructions";
20086
- panel.append(link2);
20087
- }
20088
- return panel;
20089
- }
20090
-
20091
- // src/settings/harness-install-store.ts
20092
- function errorMessage(error51) {
20093
- 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.";
20094
- }
20095
- function unknownInstallOutcome(message2) {
20096
- return /outcome is unknown|do not retry automatically|did not answer in time/i.test(message2);
20097
- }
20098
- var stores = /* @__PURE__ */ new WeakMap();
20099
- function createStore(diagnostics) {
20100
- const states2 = /* @__PURE__ */ new Map();
20101
- const listeners = /* @__PURE__ */ new Set();
20102
- const key = (host, agent) => JSON.stringify([host, agent]);
20103
- const notify2 = () => listeners.forEach((listener) => listener());
20104
- return {
20105
- get: (host, agent) => states2.get(key(host, agent)),
20106
- clearErrors() {
20107
- for (const [id, state] of states2) if (state.status === "error") states2.delete(id);
20108
- notify2();
20109
- },
20110
- subscribe(listener) {
20111
- listeners.add(listener);
20112
- return () => {
20113
- listeners.delete(listener);
20114
- };
20115
- },
20116
- async install(host, agent) {
20117
- const id = key(host, agent);
20118
- const previous = states2.get(id);
20119
- if (!diagnostics.installation || previous && previous.status !== "error") return;
20120
- states2.set(id, { status: "installing" });
20121
- notify2();
20122
- let failure;
20123
- try {
20124
- await diagnostics.installation(host, agent, "install");
20125
- states2.set(id, { status: "checking" });
20126
- notify2();
20127
- } catch (error51) {
20128
- failure = errorMessage(error51);
20129
- }
20130
- try {
20131
- await diagnostics.refresh(host);
20132
- const refreshed = diagnostics.snapshot().hosts.find((candidate) => candidate.hostId === host)?.agents.find((candidate) => candidate.agent === agent);
20133
- if (refreshed?.availability === "ready") failure = void 0;
20134
- else if (failure && unknownInstallOutcome(failure) && refreshed && refreshed.availability !== "notInstalled") {
20135
- failure = void 0;
20136
- }
20137
- } catch (error51) {
20138
- failure ??= errorMessage(error51);
20139
- }
20140
- if (failure) states2.set(id, { status: "error", error: failure });
20141
- else states2.delete(id);
20142
- notify2();
20143
- }
20144
- };
20145
- }
20146
- function harnessInstallStore(diagnostics) {
20147
- let store = stores.get(diagnostics);
20148
- if (!store) {
20149
- store = createStore(diagnostics);
20150
- stores.set(diagnostics, store);
20151
- }
20152
- return store;
20153
- }
20154
-
20155
- // src/settings/harness-version-messages.ts
20156
- var harnessVersionEnglish = Object.freeze({
20157
- locale: "en",
20158
- unknown: "Unknown",
20159
- trackingBranch: "Tracking branch (new commits)",
20160
- notes: Object.freeze({
20161
- "original-installer": "Use the original installer, package manager, or launcher to update this installation."
20162
- })
20163
- });
20164
- var harnessVersionChinese = Object.freeze({
20165
- locale: "zh-CN",
20166
- unknown: "\u672A\u77E5",
20167
- trackingBranch: "\u8DDF\u8E2A\u5206\u652F\uFF08\u6709\u65B0\u63D0\u4EA4\uFF09",
20168
- notes: Object.freeze({
20169
- "original-installer": "\u8BF7\u4F7F\u7528\u539F\u5B89\u88C5\u7A0B\u5E8F\u3001\u5305\u7BA1\u7406\u5668\u6216\u542F\u52A8\u5668\u66F4\u65B0\u6B64\u5B89\u88C5\u3002"
20170
- })
20171
- });
20172
- function harnessVersionLabel(state, messages) {
20173
- if (!state) return "\u2014";
20174
- if (state.latestVersionKind === "unknown" || state.latestVersion === "Unknown")
20175
- return messages.unknown;
20176
- if (state.latestVersionKind === "tracking-branch" || state.latestVersion === "Tracking branch (new commits)")
20177
- return messages.trackingBranch;
20178
- return state.latestVersion;
20179
- }
20180
- function harnessVersionNote(state, messages) {
20181
- if (state?.notice) return localizeHarnessText(state.notice, messages.locale);
20182
- const code = state?.messageCode;
20183
- return code && Object.hasOwn(messages.notes, code) ? messages.notes[code] : void 0;
20736
+ );
20737
+ }
20738
+ if (guide.after) paragraph(guide.after);
20739
+ if (!plugin?.installation && guide.url) {
20740
+ const link2 = document2.createElement("a");
20741
+ link2.href = guide.url;
20742
+ link2.target = "_blank";
20743
+ link2.rel = "noopener noreferrer";
20744
+ link2.textContent = zh ? "\u5B89\u88C5\u8BF4\u660E" : "Installation instructions";
20745
+ panel.append(link2);
20746
+ }
20747
+ return panel;
20184
20748
  }
20185
20749
 
20186
- // src/settings/harness-version-panel.ts
20187
- function createHarnessVersionPanel(document2, messages, signal, agent, client, onChange = () => void 0) {
20188
- const panel = document2.createElement("section");
20189
- panel.className = "settings-harness-version";
20190
- panel.dataset.harnessVersion = agent;
20191
- const heading = document2.createElement("strong");
20192
- heading.textContent = messages.harnessVersionTitle;
20193
- const versions = document2.createElement("div");
20194
- versions.className = "settings-harness-version__values";
20195
- const current = document2.createElement("span");
20196
- const latest = document2.createElement("span");
20197
- versions.append(current, latest);
20750
+ // src/settings/harness-launch-controls.ts
20751
+ function createHarnessLaunchControls(document2, messages, agent, settings) {
20752
+ const section = document2.createElement("section");
20753
+ section.className = "settings-harness-launch";
20754
+ section.dataset.harnessLaunch = agent;
20755
+ const label = document2.createElement("label");
20756
+ label.textContent = messages.launchPathLabel;
20757
+ const input = document2.createElement("input");
20758
+ input.type = "text";
20759
+ input.autocomplete = "off";
20760
+ input.spellcheck = false;
20761
+ input.placeholder = messages.locale === "zh-CN" ? "\u5E94\u7528\u5B89\u88C5\u76EE\u5F55\u7684\u7EDD\u5BF9\u8DEF\u5F84" : "Absolute installation directory";
20762
+ input.setAttribute("aria-label", messages.launchPathLabel);
20763
+ label.append(input);
20764
+ const help = document2.createElement("p");
20765
+ 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.";
20766
+ const actions = document2.createElement("div");
20767
+ actions.className = "settings-harness-launch__actions";
20768
+ const save = document2.createElement("button");
20769
+ save.type = "button";
20770
+ save.className = "settings-command-button";
20771
+ save.textContent = messages.launchPathSave;
20772
+ const reset = document2.createElement("button");
20773
+ reset.type = "button";
20774
+ reset.className = "settings-command-button settings-command-button--secondary";
20775
+ reset.textContent = messages.launchPathReset;
20198
20776
  const status = document2.createElement("p");
20199
20777
  status.setAttribute("role", "status");
20200
- const actions = document2.createElement("div");
20201
- actions.className = "settings-connection-error-actions";
20202
- const update = document2.createElement("button");
20203
- update.type = "button";
20204
- update.className = "settings-command-button settings-command-button--secondary";
20205
- update.dataset.harnessVersionAction = "update";
20206
- const note = document2.createElement("p");
20207
- note.className = "settings-connection-issue-note";
20208
- note.textContent = messages.harnessVersionNote;
20209
- actions.append(update);
20210
- panel.append(heading, versions, status, actions, note);
20211
- let state;
20212
- let busy = false;
20213
- let updating = false;
20214
- let unsupported = false;
20215
- let updatePromise = null;
20216
- const render = () => {
20217
- heading.textContent = state?.versionKind === "application" ? messages.harnessVersionApplicationTitle : messages.harnessVersionTitle;
20218
- current.textContent = `${messages.harnessVersionCurrent}: ${state?.currentVersion ?? "\u2014"}`;
20219
- latest.textContent = `${messages.harnessVersionLatest}: ${harnessVersionLabel(state, messages.harnessVersion)}`;
20220
- update.disabled = busy || signal.aborted || !state?.canUpdate || !state.updateAvailable;
20221
- const manualUrl = !state?.canUpdate && state?.updateAvailable ? state.manualUpdateUrl : void 0;
20222
- actions.replaceChildren(update);
20223
- update.hidden = !busy && !signal.aborted && Boolean(manualUrl);
20224
- if (update.hidden && manualUrl) {
20225
- const download2 = document2.createElement("a");
20226
- download2.className = "settings-command-button settings-command-button--secondary";
20227
- download2.dataset.harnessVersionAction = "download-update";
20228
- download2.textContent = messages.harnessVersionDownloadUpdate;
20229
- download2.href = manualUrl;
20230
- download2.target = "_blank";
20231
- download2.rel = "noopener noreferrer";
20232
- actions.append(download2);
20233
- }
20234
- update.textContent = state?.canUpdate && state.latestVersion !== "Unknown" && !state.updateAvailable ? messages.harnessVersionUpToDate : messages.harnessVersionUpdate;
20235
- const detail = harnessVersionNote(state, messages.harnessVersion);
20236
- note.textContent = detail ? !state?.canUpdate ? detail : `${detail} ${messages.harnessVersionNote}` : messages.harnessVersionNote;
20778
+ status.setAttribute("aria-live", "polite");
20779
+ actions.append(save, reset);
20780
+ section.append(label, help, actions, status);
20781
+ let busy = true;
20782
+ let loaded = false;
20783
+ const controls = () => {
20784
+ input.disabled = busy || !loaded;
20785
+ save.disabled = busy || !loaded || !input.value.trim();
20786
+ reset.disabled = busy || !loaded;
20787
+ };
20788
+ const show = (value) => {
20789
+ input.value = value.path ?? "";
20790
+ status.textContent = value.restartRequired ? messages.launchPathRestart : value.path ? messages.launchPathSaved : messages.launchPathAutomatic;
20237
20791
  };
20238
- const run = async (action) => {
20239
- if (busy || unsupported || signal.aborted) return false;
20240
- if (action === "update" && (!state?.canUpdate || !state.updateAvailable)) return false;
20792
+ const persist = async (value) => {
20793
+ if (busy || !loaded) return;
20241
20794
  busy = true;
20242
- updating = action === "update";
20243
- onChange();
20244
- status.textContent = action === "check" ? messages.harnessVersionChecking : messages.harnessVersionUpdating;
20245
- render();
20795
+ controls();
20796
+ status.textContent = messages.launchPathSaving;
20246
20797
  try {
20247
- const result = await client.run(action);
20248
- if (signal.aborted) return false;
20249
- state = result;
20250
- status.textContent = !result.canUpdate ? messages.harnessVersionManual : action === "update" ? result.updateAvailable ? messages.harnessVersionFailed : messages.harnessVersionUpdated : "";
20251
- return result.canUpdate && !result.updateAvailable;
20252
- } catch (error51) {
20253
- if (signal.aborted) return false;
20254
- unsupported = typeof error51 === "object" && error51 !== null && "code" in error51 && (error51.code === -32601 || error51.code === -32078);
20255
- status.textContent = unsupported ? messages.harnessVersionUnsupported : messages.harnessVersionFailed;
20256
- if (state) state = { ...state, canUpdate: false };
20257
- return false;
20798
+ show(await settings.set(value));
20799
+ } catch {
20800
+ status.textContent = messages.launchPathSaveError;
20258
20801
  } finally {
20259
20802
  busy = false;
20260
- updating = false;
20261
- if (!signal.aborted) {
20262
- render();
20263
- onChange();
20264
- }
20803
+ controls();
20265
20804
  }
20266
20805
  };
20267
- const updateVersion = () => {
20268
- updatePromise ??= run("update").finally(() => {
20269
- updatePromise = null;
20270
- });
20271
- return updatePromise;
20272
- };
20273
- update.addEventListener("click", () => void updateVersion());
20274
- const owner = document2.defaultView;
20275
- let checkFrame = null;
20276
- let checkTimer = null;
20277
- signal.addEventListener(
20278
- "abort",
20279
- () => {
20280
- if (checkFrame !== null) owner?.cancelAnimationFrame(checkFrame);
20281
- if (checkTimer !== null) owner?.clearTimeout(checkTimer);
20282
- render();
20283
- },
20284
- { once: true }
20285
- );
20286
- status.textContent = messages.harnessVersionChecking;
20287
- render();
20288
- if (!signal.aborted && owner?.requestAnimationFrame) {
20289
- checkFrame = owner.requestAnimationFrame(() => {
20290
- checkFrame = null;
20291
- if (signal.aborted) return;
20292
- checkTimer = owner.setTimeout(() => {
20293
- checkTimer = null;
20294
- void run("check");
20295
- }, 0);
20296
- });
20297
- } else {
20298
- void run("check");
20299
- }
20300
- return {
20301
- element: panel,
20302
- get state() {
20303
- return state;
20304
- },
20305
- get updating() {
20306
- return updating;
20307
- },
20308
- update: updateVersion
20309
- };
20806
+ input.addEventListener("input", controls);
20807
+ save.addEventListener("click", () => {
20808
+ if (input.value.trim()) void persist(input.value.trim());
20809
+ });
20810
+ reset.addEventListener("click", () => {
20811
+ void persist(null);
20812
+ });
20813
+ controls();
20814
+ status.textContent = messages.launchPathLoading;
20815
+ void settings.get().then((value) => {
20816
+ loaded = true;
20817
+ show(value);
20818
+ }).catch(() => {
20819
+ loaded = true;
20820
+ status.textContent = messages.launchPathLoadError;
20821
+ }).finally(() => {
20822
+ busy = false;
20823
+ controls();
20824
+ });
20825
+ return section;
20310
20826
  }
20311
20827
 
20312
- // src/settings/connection-versions.ts
20313
- function createConnectionVersions(document2, messages, signal, diagnostics, onChange) {
20314
- const panels = /* @__PURE__ */ new Map();
20315
- const installation = diagnostics?.installation?.bind(diagnostics);
20316
- return {
20317
- get(hostId2, agent) {
20318
- if (!installation || signal.aborted) return void 0;
20319
- const key = JSON.stringify([hostId2, agent]);
20320
- let panel = panels.get(key);
20321
- if (!panel) {
20322
- panel = createHarnessVersionPanel(
20323
- document2,
20324
- messages,
20325
- signal,
20326
- agent,
20327
- {
20328
- run: (action) => installation(hostId2, agent, action)
20329
- },
20330
- onChange
20331
- );
20332
- panels.set(key, panel);
20828
+ // src/settings/claude-long-context-control.ts
20829
+ var CLAUDE_LONG_CONTEXT_MODELS = [{ id: "claude-opus-5-5", window: "1M" }];
20830
+ var tooltipSequence = 0;
20831
+ function popoverOpen(tooltip) {
20832
+ try {
20833
+ return tooltip.matches(":popover-open");
20834
+ } catch {
20835
+ return false;
20836
+ }
20837
+ }
20838
+ function createClaudeLongContextControl(document2, messages, actions) {
20839
+ const control = document2.createElement("span");
20840
+ control.className = "settings-connection-long-context";
20841
+ const label = document2.createElement("label");
20842
+ label.className = "settings-connection-long-context__control";
20843
+ const text = document2.createElement("span");
20844
+ text.textContent = messages.connectionLongContextLabel;
20845
+ const input = document2.createElement("input");
20846
+ input.type = "checkbox";
20847
+ input.checked = true;
20848
+ input.setAttribute("role", "switch");
20849
+ input.setAttribute("aria-checked", "true");
20850
+ input.setAttribute("aria-label", messages.connectionLongContextLabel);
20851
+ input.dataset.connectionAction = "long-context";
20852
+ const tooltip = document2.createElement("div");
20853
+ tooltip.id = `settings-long-context-tooltip-${++tooltipSequence}`;
20854
+ tooltip.className = "settings-connection-long-context__tooltip";
20855
+ tooltip.setAttribute("role", "tooltip");
20856
+ tooltip.setAttribute("popover", "manual");
20857
+ tooltip.hidden = true;
20858
+ const on = document2.createElement("p");
20859
+ on.textContent = messages.connectionLongContextOn;
20860
+ const off = document2.createElement("p");
20861
+ off.textContent = messages.connectionLongContextOff;
20862
+ const modelsLabel = document2.createElement("p");
20863
+ modelsLabel.textContent = messages.connectionLongContextModelsLabel;
20864
+ const models = document2.createElement("ul");
20865
+ for (const model2 of CLAUDE_LONG_CONTEXT_MODELS) {
20866
+ const item = document2.createElement("li");
20867
+ item.textContent = `${model2.id} (${model2.window})`;
20868
+ models.append(item);
20869
+ }
20870
+ tooltip.append(on, off, modelsLabel, models);
20871
+ input.setAttribute("aria-describedby", tooltip.id);
20872
+ const stop = (event) => {
20873
+ event.stopPropagation();
20874
+ };
20875
+ control.addEventListener("click", stop);
20876
+ label.addEventListener("click", stop);
20877
+ input.addEventListener("click", stop);
20878
+ let surfaceReady = false;
20879
+ const applyTooltipSurface = () => {
20880
+ if (surfaceReady) return;
20881
+ const probe = document2.createElement("span");
20882
+ probe.style.cssText = "position:absolute;visibility:hidden;color:var(--settings-text);background-color:var(--settings-elevated);border-top-color:var(--settings-border)";
20883
+ control.append(probe);
20884
+ const computed = document2.defaultView?.getComputedStyle(probe);
20885
+ const color = computed?.color;
20886
+ const background = computed?.backgroundColor;
20887
+ const borderColor = computed?.borderTopColor;
20888
+ probe.remove();
20889
+ if (color) tooltip.style.color = color;
20890
+ if (background && background !== "rgba(0, 0, 0, 0)") tooltip.style.backgroundColor = background;
20891
+ if (borderColor) tooltip.style.border = `1px solid ${borderColor}`;
20892
+ surfaceReady = true;
20893
+ };
20894
+ const showTooltip = () => {
20895
+ const root = control.getRootNode();
20896
+ const host = root instanceof ShadowRoot ? root : document2.body ?? control;
20897
+ if (tooltip.parentNode !== host) host.append(tooltip);
20898
+ applyTooltipSurface();
20899
+ tooltip.hidden = false;
20900
+ if (typeof tooltip.showPopover === "function" && !popoverOpen(tooltip)) {
20901
+ try {
20902
+ tooltip.showPopover();
20903
+ } catch {
20904
+ tooltip.removeAttribute("popover");
20333
20905
  }
20334
- return panel;
20335
20906
  }
20336
- };
20337
- }
20338
-
20339
- // src/settings/connection-updates.ts
20340
- function createConnectionUpdates(document2, messages, signal, onChange) {
20341
- const batches = /* @__PURE__ */ new Map();
20342
- const eligible = (panels) => panels.filter((panel) => panel.state?.updateAvailable && panel.state.canUpdate);
20343
- const start = async (hostId2, panels) => {
20344
- if (signal.aborted || batches.get(hostId2)?.running) return;
20345
- const targets = eligible(panels);
20346
- if (!targets.length) return;
20347
- const batch = { running: true, total: targets.length, succeeded: 0, failed: 0 };
20348
- batches.set(hostId2, batch);
20349
- onChange();
20350
- await Promise.all(
20351
- targets.map(async (panel) => {
20352
- try {
20353
- if (await panel.update()) batch.succeeded++;
20354
- else batch.failed++;
20355
- } catch {
20356
- batch.failed++;
20357
- }
20358
- if (!signal.aborted) onChange();
20359
- })
20907
+ tooltip.style.position = "fixed";
20908
+ tooltip.style.inset = "auto";
20909
+ tooltip.style.zIndex = "80";
20910
+ tooltip.style.margin = "0";
20911
+ tooltip.style.height = "auto";
20912
+ tooltip.style.overflow = "visible";
20913
+ const rect = control.getBoundingClientRect();
20914
+ const margin = 8;
20915
+ const width = Math.min(280, Math.max(160, window.innerWidth - margin * 2));
20916
+ tooltip.style.width = `${width}px`;
20917
+ const preferredLeft = Math.min(
20918
+ Math.max(margin, rect.right - width),
20919
+ window.innerWidth - width - margin
20360
20920
  );
20361
- batch.running = false;
20362
- if (!signal.aborted) onChange();
20921
+ const height = tooltip.offsetHeight;
20922
+ const below = rect.bottom + 8;
20923
+ const preferredTop = below + height <= window.innerHeight - margin ? below : Math.max(margin, rect.top - height - 8);
20924
+ tooltip.style.left = `${preferredLeft}px`;
20925
+ tooltip.style.top = `${preferredTop}px`;
20926
+ const placed = tooltip.getBoundingClientRect();
20927
+ const shiftX = preferredLeft - placed.left;
20928
+ const shiftY = preferredTop - placed.top;
20929
+ if (Math.abs(shiftX) > 0.5 || Math.abs(shiftY) > 0.5) {
20930
+ tooltip.style.left = `${preferredLeft + shiftX}px`;
20931
+ tooltip.style.top = `${preferredTop + shiftY}px`;
20932
+ }
20363
20933
  };
20364
- return {
20365
- createControls(hostId2, panels) {
20366
- const batch = batches.get(hostId2);
20367
- const count3 = eligible(panels).length;
20368
- const button2 = document2.createElement("button");
20369
- button2.type = "button";
20370
- button2.className = "settings-command-button settings-command-button--secondary settings-connection-update-all";
20371
- button2.dataset.connectionAction = "update-all";
20372
- button2.disabled = signal.aborted || Boolean(batch?.running) || !count3;
20373
- button2.title = messages.harnessUpdateAllDescription;
20374
- const label = batch?.running ? `${messages.harnessUpdateAllProgress} ${batch.succeeded + batch.failed}/${batch.total}` : count3 ? `${messages.harnessUpdateAll} (${count3})` : messages.harnessUpdateAll;
20375
- button2.append(createRendererSettingsIcon("download", 15), label);
20376
- button2.addEventListener("click", () => {
20377
- if (!button2.disabled) void start(hostId2, panels);
20378
- });
20379
- const result = document2.createElement("p");
20380
- result.className = "settings-connection-update-result";
20381
- result.setAttribute("role", "status");
20382
- result.hidden = !batch || batch.running;
20383
- if (batch && !batch.running) {
20384
- result.textContent = messages.harnessUpdateAllResult.replace("{succeeded}", String(batch.succeeded)).replace("{failed}", String(batch.failed));
20385
- }
20386
- return { button: button2, result };
20387
- }
20388
- };
20389
- }
20390
-
20391
- // src/settings/selection-scroll.ts
20392
- var SELECTION_CONTROL_SELECTOR = "button, a, input, textarea, select, label";
20393
- function upwardScrollTop(saved, current) {
20394
- return current < saved ? saved : current;
20395
- }
20396
- function isPrimaryPointer(event) {
20397
- return "button" in event && event.button === 0;
20398
- }
20399
- function canScrollVertically(element) {
20400
- if (element.scrollHeight <= element.clientHeight + 1) return false;
20401
- const view = element.ownerDocument.defaultView;
20402
- if (!view) return false;
20403
- const overflow = view.getComputedStyle(element).overflowY;
20404
- return overflow === "auto" || overflow === "scroll" || overflow === "overlay";
20405
- }
20406
- function verticalScrollers(target2, page) {
20407
- const scrollers = [];
20408
- let node = target2;
20409
- while (node) {
20410
- if (node instanceof HTMLElement && canScrollVertically(node)) scrollers.push(node);
20411
- if (node === page) break;
20412
- node = node.parentElement;
20413
- }
20414
- if (!scrollers.includes(page) && canScrollVertically(page)) scrollers.push(page);
20415
- return scrollers;
20416
- }
20417
- function pointerOnScrollbar(target2, scroller, event) {
20418
- return target2 === scroller && event.offsetX >= scroller.clientWidth;
20419
- }
20420
- function keepPageStillDuringTextSelection(region) {
20421
- const view = () => region.ownerDocument.defaultView;
20422
- let session = null;
20423
- const detach = () => {
20424
- if (!session) return;
20425
- const document2 = region.ownerDocument;
20426
- for (const scroller of session.tops.keys()) {
20427
- scroller.removeEventListener("scroll", session.onScroll);
20428
- }
20429
- document2.removeEventListener("pointerup", session.onPointerUp);
20430
- document2.removeEventListener("pointercancel", session.onCancel);
20431
- document2.removeEventListener("wheel", session.onWheel);
20432
- if (session.frame) view()?.cancelAnimationFrame(session.frame);
20433
- session = null;
20434
- };
20435
- let restoring = false;
20436
- const restore = () => {
20437
- if (!session || restoring) return;
20438
- restoring = true;
20439
- try {
20440
- for (const [scroller, top] of session.tops) {
20441
- const next = upwardScrollTop(top, scroller.scrollTop);
20442
- if (next !== scroller.scrollTop) scroller.scrollTop = next;
20443
- else if (scroller.scrollTop > top) session.tops.set(scroller, scroller.scrollTop);
20934
+ const hideTooltip = () => {
20935
+ if (typeof tooltip.hidePopover === "function" && popoverOpen(tooltip)) {
20936
+ try {
20937
+ tooltip.hidePopover();
20938
+ } catch {
20444
20939
  }
20445
- } finally {
20446
- restoring = false;
20447
20940
  }
20941
+ tooltip.hidden = true;
20448
20942
  };
20449
- region.addEventListener("pointerdown", (event) => {
20450
- if (!isPrimaryPointer(event)) return;
20451
- const target2 = event.target;
20452
- if (!(target2 instanceof Element) || target2.closest(SELECTION_CONTROL_SELECTOR)) return;
20453
- const page = region.closest(".settings-page");
20454
- if (!(page instanceof HTMLElement)) return;
20455
- detach();
20456
- const tops = /* @__PURE__ */ new Map();
20457
- for (const scroller of verticalScrollers(target2, page)) {
20458
- if (pointerOnScrollbar(target2, scroller, event)) continue;
20459
- tops.set(scroller, scroller.scrollTop);
20460
- }
20461
- if (tops.size === 0) return;
20462
- const onScroll = () => restore();
20463
- const onPointerUp = () => {
20464
- restore();
20465
- if (!session) return;
20466
- session.framesLeft = 2;
20467
- const finish = () => {
20468
- if (!session) return;
20469
- restore();
20470
- session.framesLeft -= 1;
20471
- const owner2 = view();
20472
- if (session.framesLeft > 0 && owner2?.requestAnimationFrame) {
20473
- session.frame = owner2.requestAnimationFrame(finish);
20474
- return;
20475
- }
20476
- detach();
20477
- };
20478
- const owner = view();
20479
- if (owner?.requestAnimationFrame) session.frame = owner.requestAnimationFrame(finish);
20480
- else detach();
20481
- };
20482
- const onCancel = () => detach();
20483
- const onWheel = () => detach();
20484
- session = { tops, frame: 0, framesLeft: 0, onScroll, onPointerUp, onCancel, onWheel };
20485
- const document2 = region.ownerDocument;
20486
- for (const scroller of tops.keys()) scroller.addEventListener("scroll", onScroll);
20487
- document2.addEventListener("pointerup", onPointerUp);
20488
- document2.addEventListener("pointercancel", onCancel);
20489
- document2.addEventListener("wheel", onWheel, { passive: true });
20943
+ control.addEventListener("mouseenter", showTooltip);
20944
+ control.addEventListener("mouseleave", hideTooltip);
20945
+ control.addEventListener("focusin", showTooltip);
20946
+ control.addEventListener("focusout", (event) => {
20947
+ const next = event.relatedTarget;
20948
+ if (next instanceof Node && control.contains(next)) return;
20949
+ hideTooltip();
20950
+ });
20951
+ let generation = 0;
20952
+ input.addEventListener("change", () => {
20953
+ const next = input.checked;
20954
+ generation += 1;
20955
+ const request = generation;
20956
+ input.disabled = true;
20957
+ input.setAttribute("aria-checked", String(next));
20958
+ void actions.set(next).then(
20959
+ (result) => {
20960
+ if (request !== generation) return;
20961
+ input.checked = result.enabled;
20962
+ input.setAttribute("aria-checked", String(result.enabled));
20963
+ input.disabled = false;
20964
+ },
20965
+ () => {
20966
+ if (request !== generation) return;
20967
+ input.checked = !next;
20968
+ input.setAttribute("aria-checked", String(!next));
20969
+ input.disabled = false;
20970
+ }
20971
+ );
20490
20972
  });
20973
+ void actions.get().then(
20974
+ (result) => {
20975
+ if (generation !== 0) return;
20976
+ input.checked = result.enabled;
20977
+ input.setAttribute("aria-checked", String(result.enabled));
20978
+ },
20979
+ () => void 0
20980
+ );
20981
+ label.append(text, input);
20982
+ control.append(label, tooltip);
20983
+ return control;
20491
20984
  }
20492
20985
 
20493
20986
  // src/settings/connections-page.ts
20494
20987
  var CODEXHOST_GITHUB_ISSUES_NEW_URL = "https://github.com/LIBERSEEK/BOFT-CLI/issues/new";
20495
- function connectionStatusLabel(availability, messages, hasError = false) {
20496
- if (availability === "updating") return messages.connectionStatusUpdating;
20497
- if (hasError && availability !== "notInstalled") return messages.connectionStatusError;
20498
- if (availability === "ready") return messages.connectionStatusReady;
20499
- if (availability === "checking") return messages.connectionStatusChecking;
20500
- if (availability === "notInstalled") return messages.connectionStatusNotInstalled;
20501
- if (availability === "unavailable" || availability === "error") {
20502
- return availability === "error" ? messages.connectionStatusError : messages.connectionStatusUnavailable;
20503
- }
20504
- return availability === "installing" ? messages.connectionStatusInstalling : messages.connectionStatusUnsupported;
20505
- }
20506
- function connectionStatusTone(availability, hasError = false) {
20507
- if (availability === "updating") return "checking";
20508
- if (hasError && availability !== "notInstalled") return "failed";
20509
- if (availability === "ready") return "ready";
20510
- if (availability === "checking" || availability === "installing") return "checking";
20511
- if (availability === "notInstalled") return "setup";
20512
- return "failed";
20513
- }
20514
20988
  function diagnosticText(hostId2, item) {
20515
20989
  const error51 = item.error;
20516
20990
  return [
20517
- "BOFT CLI connection diagnostics",
20991
+ "codexhost connection diagnostics",
20518
20992
  `host: ${hostId2}`,
20519
20993
  `agent: ${item.name}`,
20520
20994
  `status: ${item.availability}`,
@@ -20548,205 +21022,79 @@ ${error51.stderrTail}`] : []
20548
21022
  void clipboard.writeText(report).then(
20549
21023
  () => showCopyButtonFeedback(button2, messages.connectionCopied, restoreLabel),
20550
21024
  () => showCopyButtonFeedback(button2, messages.connectionCopyFailed, restoreLabel)
20551
- );
20552
- }
20553
- function connectionHostName(hostId2, messages) {
20554
- if (hostId2 === "local") return messages.connectionLocalHost;
20555
- const separator = hostId2.lastIndexOf(":");
20556
- const encodedName = separator >= 0 ? hostId2.slice(separator + 1) : hostId2;
20557
- try {
20558
- return decodeURIComponent(encodedName);
20559
- } catch {
20560
- return encodedName;
20561
- }
20562
- }
20563
- function createHostScrollButton(document2, direction, messages) {
20564
- const button2 = document2.createElement("button");
20565
- button2.type = "button";
20566
- button2.className = "settings-connection-host-scroll";
20567
- button2.dataset.connectionHostScroll = direction;
20568
- const label = direction === "left" ? messages.connectionHostsScrollLeft : messages.connectionHostsScrollRight;
20569
- button2.setAttribute("aria-label", label);
20570
- button2.title = label;
20571
- button2.append(
20572
- createRendererSettingsIcon(direction === "left" ? "chevron-left" : "chevron-right", 16)
20573
- );
20574
- return button2;
20575
- }
20576
- function configureHostScroller(document2, strip, tabs, left, right) {
20577
- const maxScrollLeft = () => Math.max(0, (tabs.scrollWidth || 0) - (tabs.clientWidth || 0));
20578
- const updateButtons = () => {
20579
- const maximum = maxScrollLeft();
20580
- strip.dataset.connectionHostOverflow = String(maximum > 1);
20581
- left.disabled = tabs.scrollLeft <= 1;
20582
- right.disabled = maximum <= 1 || tabs.scrollLeft >= maximum - 1;
20583
- };
20584
- const scroll = (direction) => {
20585
- const distance = Math.max(180, Math.round((tabs.clientWidth || 250) * 0.72));
20586
- if (typeof tabs.scrollBy === "function") {
20587
- tabs.scrollBy({ left: direction * distance, behavior: "smooth" });
20588
- } else {
20589
- tabs.scrollLeft += direction * distance;
20590
- updateButtons();
20591
- }
20592
- };
20593
- const onLeft = () => scroll(-1);
20594
- const onRight = () => scroll(1);
20595
- const onWheel = (event) => {
20596
- const delta = Math.abs(event.deltaX) > Math.abs(event.deltaY) ? event.deltaX : event.deltaY;
20597
- const maximum = maxScrollLeft();
20598
- const canScroll = delta < 0 ? tabs.scrollLeft > 1 : tabs.scrollLeft < maximum - 1;
20599
- if (!delta || maximum <= 1 || !canScroll) return;
20600
- event.preventDefault();
20601
- tabs.scrollLeft += delta;
20602
- };
20603
- left.addEventListener("click", onLeft);
20604
- right.addEventListener("click", onRight);
20605
- tabs.addEventListener("scroll", updateButtons, { passive: true });
20606
- tabs.addEventListener("wheel", onWheel, { passive: false });
20607
- const ownerWindow = document2.defaultView;
20608
- ownerWindow?.addEventListener("resize", updateButtons);
20609
- ownerWindow?.setTimeout(updateButtons, 0);
20610
- updateButtons();
20611
- return () => {
20612
- left.removeEventListener("click", onLeft);
20613
- right.removeEventListener("click", onRight);
20614
- tabs.removeEventListener("scroll", updateButtons);
20615
- tabs.removeEventListener("wheel", onWheel);
20616
- ownerWindow?.removeEventListener("resize", updateButtons);
20617
- };
20618
- }
20619
- function createConnectionIdentityIcon(document2, item, size) {
20620
- const container = document2.createElement("span");
20621
- container.className = item.agentSnapshot ? "settings-connection-row__mark settings-connection-row__mark--logo" : "settings-connection-row__mark";
20622
- container.setAttribute("aria-hidden", "true");
20623
- if (item.agentSnapshot) {
20624
- container.append(
20625
- createRendererAgentIcon(item.agentSnapshot.agent, size, document2, item.agentSnapshot.plugin)
20626
- );
20627
- } else {
20628
- container.textContent = "CH";
20629
- }
20630
- return container;
20631
- }
20632
- function createConnectionRow(document2, item, messages, selected, select, group = null, longContext = null) {
20633
- const row = document2.createElement("div");
20634
- row.className = "settings-connection-row";
20635
- row.dataset.connectionItem = item.key;
20636
- row.dataset.connectionSelected = String(selected);
20637
- row.tabIndex = selected ? 0 : -1;
20638
- row.setAttribute("role", "row");
20639
- const identity3 = document2.createElement("div");
20640
- identity3.className = "settings-connection-row__identity";
20641
- identity3.setAttribute("role", "cell");
20642
- const handle = group ? document2.createElement("span") : null;
20643
- if (group && handle) {
20644
- handle.className = "settings-connection-row__handle";
20645
- handle.setAttribute("aria-hidden", "true");
20646
- handle.title = group.dragHandleTitle;
20647
- handle.append(createRendererSettingsIcon("grip-vertical", 15));
20648
- identity3.append(handle);
20649
- }
20650
- const label = document2.createElement("strong");
20651
- label.textContent = item.name;
20652
- identity3.append(createConnectionIdentityIcon(document2, item, 19), label);
20653
- const status = document2.createElement("span");
20654
- status.className = "settings-connection-row__status";
20655
- status.dataset.connectionTone = connectionStatusTone(item.availability, item.error !== null);
20656
- status.setAttribute("role", "cell");
20657
- status.textContent = item.error?.code === "authenticationRequired" ? messages.connectionLoginRequired : item.error?.code === "configurationRequired" ? messages.connectionConfigurationRequired : connectionStatusLabel(item.availability, messages, item.error !== null);
20658
- const version2 = item.version;
20659
- const action = document2.createElement("div");
20660
- action.className = "settings-connection-row__action";
20661
- action.setAttribute("role", "cell");
20662
- if (item.error && item.agentSnapshot?.availability !== "notInstalled") {
20663
- const viewError = document2.createElement("button");
20664
- viewError.type = "button";
20665
- viewError.className = "settings-connection-view-error";
20666
- viewError.textContent = messages.connectionViewError;
20667
- viewError.addEventListener("click", (event) => {
20668
- event.stopPropagation();
20669
- select();
20670
- });
20671
- action.append(viewError);
20672
- }
20673
- if (longContext) action.append(longContext);
20674
- if (version2?.state?.updateAvailable && version2.state.canUpdate) {
20675
- const update = document2.createElement("button");
20676
- update.type = "button";
20677
- update.className = "settings-connection-install-link";
20678
- update.dataset.connectionAction = "update";
20679
- update.disabled = version2.updating;
20680
- update.title = `${messages.harnessVersionUpdate}: ${item.name}
20681
- ${messages.harnessVersionCurrent}: ${version2.state.currentVersion ?? "\u2014"}
20682
- ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages.harnessVersion)}`;
20683
- update.setAttribute("aria-label", `${messages.harnessVersionUpdate}: ${item.name}`);
20684
- update.append(createRendererSettingsIcon("download", 15));
20685
- update.addEventListener("click", (event) => {
20686
- event.stopPropagation();
20687
- if (update.disabled) return;
20688
- void version2.update();
20689
- select();
20690
- });
20691
- action.append(update);
20692
- }
20693
- if (group) {
20694
- const toggle = document2.createElement("button");
20695
- toggle.type = "button";
20696
- toggle.disabled = group.disabled;
20697
- toggle.className = "settings-connection-row__group-toggle";
20698
- toggle.title = group.moveLabel;
20699
- toggle.setAttribute("aria-label", group.moveLabel);
20700
- toggle.append(
20701
- createRendererSettingsIcon(group.section === "main" ? "chevron-down" : "chevron-up", 15)
20702
- );
20703
- toggle.addEventListener("click", (event) => {
20704
- event.stopPropagation();
20705
- group.toggleSection();
20706
- });
20707
- action.append(toggle);
20708
- }
20709
- row.addEventListener("click", (event) => {
20710
- const target2 = event.target;
20711
- if (target2?.closest?.("a, input, label")) return;
20712
- select();
20713
- });
20714
- row.addEventListener("keydown", (event) => {
20715
- if (event.target?.closest?.("button, a")) return;
20716
- if (event.key !== "Enter" && event.key !== " ") return;
20717
- event.preventDefault();
20718
- select();
20719
- });
20720
- if (group && handle) {
20721
- row.draggable = false;
20722
- row.dataset.connectionGroupSection = group.section;
20723
- handle.addEventListener("pointerdown", (event) => {
20724
- if (group.disabled || event.button !== 0) return;
20725
- row.draggable = true;
20726
- });
20727
- const releaseDrag = () => {
20728
- if (row.dataset.connectionDragging === "true") return;
20729
- row.draggable = false;
20730
- };
20731
- row.addEventListener("pointerup", releaseDrag);
20732
- row.addEventListener("pointercancel", releaseDrag);
20733
- row.addEventListener("dragstart", (event) => {
20734
- if (!row.draggable) {
20735
- event.preventDefault();
20736
- return;
20737
- }
20738
- group.onDragStart(event);
20739
- });
20740
- row.addEventListener("dragover", group.onDragOver);
20741
- row.addEventListener("dragleave", group.onDragLeave);
20742
- row.addEventListener("drop", group.onDrop);
20743
- row.addEventListener("dragend", (event) => {
20744
- row.draggable = false;
20745
- group.onDragEnd(event);
20746
- });
21025
+ );
21026
+ }
21027
+ function connectionHostName(hostId2, messages) {
21028
+ if (hostId2 === "local") return messages.connectionLocalHost;
21029
+ const separator = hostId2.lastIndexOf(":");
21030
+ const encodedName = separator >= 0 ? hostId2.slice(separator + 1) : hostId2;
21031
+ try {
21032
+ return decodeURIComponent(encodedName);
21033
+ } catch {
21034
+ return encodedName;
20747
21035
  }
20748
- row.append(identity3, status, action);
20749
- return row;
21036
+ }
21037
+ function createHostScrollButton(document2, direction, messages) {
21038
+ const button2 = document2.createElement("button");
21039
+ button2.type = "button";
21040
+ button2.className = "settings-connection-host-scroll";
21041
+ button2.dataset.connectionHostScroll = direction;
21042
+ const label = direction === "left" ? messages.connectionHostsScrollLeft : messages.connectionHostsScrollRight;
21043
+ button2.setAttribute("aria-label", label);
21044
+ button2.title = label;
21045
+ button2.append(
21046
+ createRendererSettingsIcon(direction === "left" ? "chevron-left" : "chevron-right", 16)
21047
+ );
21048
+ return button2;
21049
+ }
21050
+ function configureHostScroller(document2, strip, tabs, left, right) {
21051
+ const maxScrollLeft = () => Math.max(0, (tabs.scrollWidth || 0) - (tabs.clientWidth || 0));
21052
+ const updateButtons = () => {
21053
+ const maximum = maxScrollLeft();
21054
+ strip.dataset.connectionHostOverflow = String(maximum > 1);
21055
+ left.disabled = tabs.scrollLeft <= 1;
21056
+ right.disabled = maximum <= 1 || tabs.scrollLeft >= maximum - 1;
21057
+ };
21058
+ const scroll = (direction) => {
21059
+ const distance = Math.max(180, Math.round((tabs.clientWidth || 250) * 0.72));
21060
+ if (typeof tabs.scrollBy === "function") {
21061
+ tabs.scrollBy({ left: direction * distance, behavior: "smooth" });
21062
+ } else {
21063
+ tabs.scrollLeft += direction * distance;
21064
+ updateButtons();
21065
+ }
21066
+ };
21067
+ const onLeft = () => scroll(-1);
21068
+ const onRight = () => scroll(1);
21069
+ const onWheel = (event) => {
21070
+ const delta = Math.abs(event.deltaX) > Math.abs(event.deltaY) ? event.deltaX : event.deltaY;
21071
+ const maximum = maxScrollLeft();
21072
+ const canScroll = delta < 0 ? tabs.scrollLeft > 1 : tabs.scrollLeft < maximum - 1;
21073
+ if (!delta || maximum <= 1 || !canScroll) return;
21074
+ event.preventDefault();
21075
+ tabs.scrollLeft += delta;
21076
+ };
21077
+ left.addEventListener("click", onLeft);
21078
+ right.addEventListener("click", onRight);
21079
+ tabs.addEventListener("scroll", updateButtons, { passive: true });
21080
+ tabs.addEventListener("wheel", onWheel, { passive: false });
21081
+ const ownerWindow = document2.defaultView;
21082
+ ownerWindow?.addEventListener("resize", updateButtons);
21083
+ const refreshLayout = () => {
21084
+ ownerWindow?.setTimeout(updateButtons, 0);
21085
+ updateButtons();
21086
+ };
21087
+ refreshLayout();
21088
+ return {
21089
+ update: refreshLayout,
21090
+ dispose() {
21091
+ left.removeEventListener("click", onLeft);
21092
+ right.removeEventListener("click", onRight);
21093
+ tabs.removeEventListener("scroll", updateButtons);
21094
+ tabs.removeEventListener("wheel", onWheel);
21095
+ ownerWindow?.removeEventListener("resize", updateButtons);
21096
+ }
21097
+ };
20750
21098
  }
20751
21099
  function createInspectorHeader(document2, item, messages) {
20752
21100
  const header = document2.createElement("header");
@@ -20776,7 +21124,30 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
20776
21124
  header.append(identity3, status);
20777
21125
  return header;
20778
21126
  }
20779
- function renderConnectionInspector(document2, inspector, item, hostId2, messages, diagnostics, existingLaunchControls, refresh, openExternalUrl) {
21127
+ function inspectorRenderSignature(hostId2, item, messages, diagnostics) {
21128
+ const plugin = item.agentSnapshot?.plugin;
21129
+ const notice = plugin?.notice ? plugin.notice[messages.locale] ?? plugin.notice.en : "";
21130
+ const websiteUrl = plugin?.links?.website ?? plugin?.links?.documentation ?? "";
21131
+ const hasLaunchControls = hostId2 === "local" && Boolean(item.agentSnapshot?.agent) && Boolean(plugin?.launchCommand) && Boolean(diagnostics?.getLaunchSettings && diagnostics?.setLaunchSettings);
21132
+ return JSON.stringify([
21133
+ hostId2,
21134
+ item.key,
21135
+ item.name,
21136
+ item.availability,
21137
+ item.agentSnapshot?.availability ?? null,
21138
+ String(plugin?.icon ?? ""),
21139
+ String(plugin?.iconStyle ?? ""),
21140
+ websiteUrl,
21141
+ notice,
21142
+ item.installError ?? "",
21143
+ Boolean(item.install),
21144
+ plugin?.installation ?? null,
21145
+ Boolean(item.openWebUi),
21146
+ hasLaunchControls,
21147
+ item.error ? diagnosticText(hostId2, item) : ""
21148
+ ]);
21149
+ }
21150
+ function renderConnectionInspector(document2, inspector, item, hostId2, messages, diagnostics, existingLaunchControls, refresh, getOpenExternalUrl) {
20780
21151
  inspector.replaceChildren(createInspectorHeader(document2, item, messages));
20781
21152
  const body = document2.createElement("div");
20782
21153
  body.className = "settings-connection-inspector__body";
@@ -20862,14 +21233,10 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
20862
21233
  issue2.target = "_blank";
20863
21234
  issue2.rel = "noopener noreferrer";
20864
21235
  issue2.addEventListener("click", (event) => {
20865
- const open = openExternalUrl();
20866
- if (!open) return;
21236
+ const openExternalUrl = getOpenExternalUrl?.();
21237
+ if (!openExternalUrl) return;
20867
21238
  event.preventDefault();
20868
- const url2 = issue2.href;
20869
- void open(url2).catch((error51) => {
20870
- console.error("codexhost external URL open failed", error51);
20871
- document2.defaultView?.open(url2, "_blank", "noopener,noreferrer");
20872
- });
21239
+ void openExternalUrl(CODEXHOST_GITHUB_ISSUES_NEW_URL);
20873
21240
  });
20874
21241
  issue2.append(messages.connectionOpenIssue, createRendererSettingsIcon("external-link", 14));
20875
21242
  actions.append(issue2);
@@ -20921,12 +21288,6 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
20921
21288
  }
20922
21289
  function connectionItems(snapshot, host, messages, diagnostics) {
20923
21290
  return [
20924
- {
20925
- key: "renderer-adapter",
20926
- name: messages.connectionAdapter,
20927
- availability: snapshot.adapter.state,
20928
- error: null
20929
- },
20930
21291
  ...host.directoryError ? [
20931
21292
  {
20932
21293
  key: "plugin-directory",
@@ -20951,11 +21312,10 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
20951
21312
  function requestConnectionsPageFocus(agentKey) {
20952
21313
  pendingFocusAgent = agentKey;
20953
21314
  }
20954
- function createGroupDivider(document2, messages, count3) {
21315
+ function createGroupDivider(document2) {
20955
21316
  const divider = document2.createElement("div");
20956
21317
  divider.className = "settings-connection-group-divider";
20957
21318
  divider.setAttribute("role", "presentation");
20958
- divider.textContent = `${messages.connectionGroupMoreLabel} (${count3})`;
20959
21319
  return divider;
20960
21320
  }
20961
21321
  function createGroupMoreHint(document2, messages) {
@@ -20977,7 +21337,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
20977
21337
  button2.addEventListener("click", onReset);
20978
21338
  return button2;
20979
21339
  }
20980
- function createConnectionsSettingsPage(messages, getDiagnostics, groupPreference = getSharedAgentGroupPreferenceStore(), getRemoteConnections = () => null, openExternalUrl = () => void 0) {
21340
+ function createConnectionsSettingsPage(messages, getDiagnostics, groupPreference = getSharedAgentGroupPreferenceStore(), getRemoteConnections = () => null, getOpenExternalUrl) {
20981
21341
  return Object.freeze({
20982
21342
  id: "connections",
20983
21343
  label: messages.pageLabels.connections,
@@ -21008,12 +21368,14 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
21008
21368
  context2.content.append(header, syncMessage, content);
21009
21369
  let pending2 = false;
21010
21370
  let selectedHostId = null;
21371
+ let renderedHostId = null;
21011
21372
  let selectedItemKey = null;
21012
- let launchControls = null;
21013
21373
  const longContextControls = /* @__PURE__ */ new Map();
21374
+ let launchControls = null;
21375
+ let renderedInspector = null;
21014
21376
  const hostNames = /* @__PURE__ */ new Map();
21377
+ const knownNotInstalled = /* @__PURE__ */ new Map();
21015
21378
  let latestSnapshot = null;
21016
- let disposeHostScroller = () => void 0;
21017
21379
  let disposed = false;
21018
21380
  let renderQueued = false;
21019
21381
  let renderFrame = null;
@@ -21038,13 +21400,14 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
21038
21400
  if (renderFrame !== null) document2.defaultView?.cancelAnimationFrame(renderFrame);
21039
21401
  renderFrame = null;
21040
21402
  };
21403
+ const diagnostics = getDiagnostics();
21041
21404
  const longContextControlFor = (hostId2, item) => {
21042
21405
  const agent = item.agentSnapshot?.agent;
21043
21406
  const availability = item.agentSnapshot?.availability;
21044
21407
  const getLongContext = diagnostics?.getLongContext;
21045
21408
  const setLongContext = diagnostics?.setLongContext;
21046
21409
  if (agent !== "claude-code" || availability === "notInstalled" || availability === "checking" || !getLongContext || !setLongContext) {
21047
- return null;
21410
+ return void 0;
21048
21411
  }
21049
21412
  const key = JSON.stringify([hostId2, agent]);
21050
21413
  const cached2 = longContextControls.get(key);
@@ -21056,7 +21419,6 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
21056
21419
  longContextControls.set(key, element);
21057
21420
  return element;
21058
21421
  };
21059
- const diagnostics = getDiagnostics();
21060
21422
  const versions = createConnectionVersions(
21061
21423
  document2,
21062
21424
  messages,
@@ -21065,7 +21427,99 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
21065
21427
  scheduleRender
21066
21428
  );
21067
21429
  const installs = diagnostics ? harnessInstallStore(diagnostics) : null;
21068
- const updates = createConnectionUpdates(document2, messages, context2.signal, scheduleRender);
21430
+ const updates = createConnectionUpdates(
21431
+ document2,
21432
+ messages,
21433
+ context2.signal,
21434
+ scheduleRender,
21435
+ diagnostics
21436
+ );
21437
+ const panelId = "codexhost-settings-connection-host-panel";
21438
+ const empty = document2.createElement("div");
21439
+ empty.className = "settings-empty";
21440
+ empty.textContent = messages.connectionNoRuntime;
21441
+ const layout = document2.createElement("div");
21442
+ layout.className = "settings-connections-layout";
21443
+ const list = document2.createElement("section");
21444
+ list.className = "settings-connection-list";
21445
+ const hostStrip = document2.createElement("div");
21446
+ hostStrip.className = "settings-connection-host-strip";
21447
+ const scrollLeft = createHostScrollButton(document2, "left", messages);
21448
+ const tabs = document2.createElement("div");
21449
+ tabs.className = "settings-connection-host-tabs";
21450
+ tabs.setAttribute("role", "tablist");
21451
+ tabs.setAttribute("aria-label", messages.connectionHosts);
21452
+ const scrollRight = createHostScrollButton(document2, "right", messages);
21453
+ hostStrip.append(scrollLeft, tabs, scrollRight);
21454
+ const updateControls = updates.createControls("local", []);
21455
+ const hostHeader = document2.createElement("div");
21456
+ hostHeader.className = "settings-connection-host-header";
21457
+ hostHeader.append(hostStrip, updateControls.button);
21458
+ const tableHeader = document2.createElement("div");
21459
+ tableHeader.className = "settings-connection-table-header";
21460
+ tableHeader.setAttribute("role", "row");
21461
+ const componentHeading = document2.createElement("span");
21462
+ componentHeading.textContent = messages.connectionComponent;
21463
+ componentHeading.setAttribute("role", "columnheader");
21464
+ const statusHeading = document2.createElement("span");
21465
+ statusHeading.textContent = messages.connectionStatus;
21466
+ statusHeading.setAttribute("role", "columnheader");
21467
+ const actionHeading = document2.createElement("span");
21468
+ actionHeading.setAttribute("aria-hidden", "true");
21469
+ tableHeader.append(componentHeading, statusHeading, actionHeading);
21470
+ const rows = document2.createElement("div");
21471
+ rows.className = "settings-connection-rows";
21472
+ rows.id = panelId;
21473
+ rows.setAttribute("role", "rowgroup");
21474
+ list.append(hostHeader, updateControls.result, tableHeader, rows);
21475
+ const inspector = document2.createElement("aside");
21476
+ inspector.className = "settings-connection-inspector";
21477
+ inspector.setAttribute("aria-live", "polite");
21478
+ layout.append(list, inspector);
21479
+ const hostScroller = configureHostScroller(
21480
+ document2,
21481
+ hostStrip,
21482
+ tabs,
21483
+ scrollLeft,
21484
+ scrollRight
21485
+ );
21486
+ const hostTabElements = /* @__PURE__ */ new Map();
21487
+ const hostRowViews = /* @__PURE__ */ new Map();
21488
+ const groupDivider = createGroupDivider(document2);
21489
+ const moreHint = createGroupMoreHint(document2, messages);
21490
+ const moreZone = document2.createElement("div");
21491
+ moreZone.className = "settings-connection-group-more";
21492
+ moreZone.setAttribute("role", "presentation");
21493
+ const resetButton = createGroupResetButton(document2, messages, () => {
21494
+ groupPreference.resetToDefault();
21495
+ });
21496
+ let draggingAgent = null;
21497
+ let currentCatalog = [];
21498
+ let currentMainEntries = [];
21499
+ let currentMoreEntries = [];
21500
+ let currentHostRows = /* @__PURE__ */ new Map();
21501
+ const clearDropIndicators = () => {
21502
+ for (const view of currentHostRows.values()) {
21503
+ view.element.dataset.connectionDropIndicator = "";
21504
+ }
21505
+ moreZone.dataset.connectionDragOver = "false";
21506
+ };
21507
+ moreZone.addEventListener("dragover", (event) => {
21508
+ if (!draggingAgent) return;
21509
+ event.preventDefault();
21510
+ moreZone.dataset.connectionDragOver = "true";
21511
+ });
21512
+ moreZone.addEventListener("dragleave", () => {
21513
+ moreZone.dataset.connectionDragOver = "false";
21514
+ });
21515
+ moreZone.addEventListener("drop", (event) => {
21516
+ event.preventDefault();
21517
+ moreZone.dataset.connectionDragOver = "false";
21518
+ if (!draggingAgent) return;
21519
+ groupPreference.moveAgent(draggingAgent, "more", null, currentCatalog);
21520
+ draggingAgent = null;
21521
+ clearDropIndicators();
21522
+ });
21069
21523
  const runRefresh = () => {
21070
21524
  if (pending2 || !diagnostics) return;
21071
21525
  pending2 = true;
@@ -21078,6 +21532,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
21078
21532
  success() {
21079
21533
  installs?.clearErrors();
21080
21534
  pending2 = false;
21535
+ renderedInspector = null;
21081
21536
  refresh.disabled = false;
21082
21537
  refresh.replaceChildren(
21083
21538
  createRendererSettingsIcon("diagnose", 16),
@@ -21087,6 +21542,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
21087
21542
  },
21088
21543
  failure(error51) {
21089
21544
  pending2 = false;
21545
+ renderedInspector = null;
21090
21546
  refresh.disabled = false;
21091
21547
  refresh.replaceChildren(
21092
21548
  createRendererSettingsIcon("diagnose", 16),
@@ -21112,110 +21568,128 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
21112
21568
  }
21113
21569
  });
21114
21570
  };
21571
+ const syncSelectedInspector = (hostId2, item) => {
21572
+ const currentDiagnostics = getDiagnostics();
21573
+ const signature = inspectorRenderSignature(hostId2, item, messages, currentDiagnostics);
21574
+ const versionElement = item.version?.element ?? null;
21575
+ if (renderedInspector?.signature === signature && renderedInspector.versionElement === versionElement) {
21576
+ return;
21577
+ }
21578
+ const existing = launchControls?.hostId === hostId2 && launchControls.itemKey === item.key ? launchControls.element : null;
21579
+ const element = renderConnectionInspector(
21580
+ document2,
21581
+ inspector,
21582
+ item,
21583
+ hostId2,
21584
+ messages,
21585
+ currentDiagnostics,
21586
+ existing,
21587
+ runRefresh,
21588
+ getOpenExternalUrl
21589
+ );
21590
+ launchControls = { hostId: hostId2, itemKey: item.key, element };
21591
+ if (versionElement) inspector.append(versionElement);
21592
+ renderedInspector = { signature, versionElement };
21593
+ };
21115
21594
  const render = (snapshot) => {
21116
21595
  const syncStatus = groupPreference.syncStatus();
21117
21596
  const groupDisabled = syncStatus === "loading" || syncStatus === "saving";
21118
21597
  syncMessage.hidden = syncStatus === "ready";
21119
21598
  syncMessage.textContent = syncStatus === "error" ? messages.connectionGroupSyncFailed : syncStatus === "saving" ? messages.connectionGroupSaving : messages.connectionGroupLoading;
21120
21599
  latestSnapshot = snapshot;
21121
- disposeHostScroller();
21122
- disposeHostScroller = () => void 0;
21123
21600
  if (!snapshot) {
21124
- const empty = document2.createElement("div");
21125
- empty.className = "settings-empty";
21126
- empty.textContent = messages.connectionNoRuntime;
21127
- content.replaceChildren(empty);
21601
+ renderedHostId = null;
21602
+ renderedInspector = null;
21603
+ reconcileElementChildren(content, [empty]);
21128
21604
  return;
21129
21605
  }
21130
21606
  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];
21131
21607
  if (!selectedHost) return;
21132
21608
  selectedHostId = selectedHost.hostId;
21133
- const layout = document2.createElement("div");
21134
- layout.className = "settings-connections-layout";
21135
- const list = document2.createElement("section");
21136
- list.className = "settings-connection-list";
21137
- const hostStrip = document2.createElement("div");
21138
- hostStrip.className = "settings-connection-host-strip";
21139
- const scrollLeft = createHostScrollButton(document2, "left", messages);
21140
- const tabs = document2.createElement("div");
21141
- tabs.className = "settings-connection-host-tabs";
21142
- tabs.setAttribute("role", "tablist");
21143
- tabs.setAttribute("aria-label", messages.connectionHosts);
21144
- const scrollRight = createHostScrollButton(document2, "right", messages);
21145
- const panelId = "codexhost-settings-connection-host-panel";
21146
- snapshot.hosts.forEach((host, index) => {
21147
- const tab = document2.createElement("button");
21148
- tab.type = "button";
21149
- tab.className = "settings-connection-host-tab";
21150
- tab.dataset.connectionHostTab = host.hostId;
21151
- tab.dataset.connectionHostActive = String(host.active);
21152
- tab.setAttribute("role", "tab");
21153
- tab.setAttribute("aria-controls", panelId);
21154
- tab.setAttribute("aria-selected", String(host.hostId === selectedHost.hostId));
21155
- tab.tabIndex = host.hostId === selectedHost.hostId ? 0 : -1;
21609
+ const layoutFirstMount = content.children[0] !== layout;
21610
+ reconcileElementChildren(content, [layout]);
21611
+ let tabsChanged = tabs.children.length !== snapshot.hosts.length;
21612
+ const nextTabs = snapshot.hosts.map((host) => {
21613
+ let tab = hostTabElements.get(host.hostId);
21614
+ if (!tab) {
21615
+ tab = document2.createElement("button");
21616
+ tab.type = "button";
21617
+ tab.className = "settings-connection-host-tab";
21618
+ tab.dataset.connectionHostTab = host.hostId;
21619
+ tab.setAttribute("role", "tab");
21620
+ tab.setAttribute("aria-controls", panelId);
21621
+ tab.addEventListener("click", () => {
21622
+ selectedHostId = host.hostId;
21623
+ render(latestSnapshot);
21624
+ });
21625
+ tab.addEventListener("keydown", (event) => {
21626
+ if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
21627
+ event.preventDefault();
21628
+ const hosts = latestSnapshot?.hosts ?? [];
21629
+ const index = hosts.findIndex((candidate) => candidate.hostId === host.hostId);
21630
+ if (index < 0) return;
21631
+ const direction = event.key === "ArrowRight" ? 1 : -1;
21632
+ const next = hosts[(index + direction + hosts.length) % hosts.length];
21633
+ if (!next) return;
21634
+ selectedHostId = next.hostId;
21635
+ render(latestSnapshot);
21636
+ hostTabElements.get(next.hostId)?.focus();
21637
+ });
21638
+ hostTabElements.set(host.hostId, tab);
21639
+ tabsChanged = true;
21640
+ }
21641
+ const isSelected = host.hostId === selectedHost.hostId;
21642
+ const activeValue = String(host.active);
21643
+ if (tab.dataset.connectionHostActive !== activeValue) {
21644
+ tab.dataset.connectionHostActive = activeValue;
21645
+ }
21646
+ const selectedValue = String(isSelected);
21647
+ if (tab.getAttribute("aria-selected") !== selectedValue) {
21648
+ tab.setAttribute("aria-selected", selectedValue);
21649
+ }
21650
+ const nextTabIndex = isSelected ? 0 : -1;
21651
+ if (tab.tabIndex !== nextTabIndex) {
21652
+ tab.tabIndex = nextTabIndex;
21653
+ }
21156
21654
  const hostName = hostNames.get(host.hostId) || connectionHostName(host.hostId, messages);
21157
- tab.textContent = hostName;
21158
- tab.title = host.active ? `${hostName} \xB7 ${messages.connectionActiveHost}` : hostName;
21159
- tab.addEventListener("click", () => {
21160
- selectedHostId = host.hostId;
21161
- render(latestSnapshot);
21162
- });
21163
- tab.addEventListener("keydown", (event) => {
21164
- if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
21165
- event.preventDefault();
21166
- const direction = event.key === "ArrowRight" ? 1 : -1;
21167
- const next = snapshot.hosts[(index + direction + snapshot.hosts.length) % snapshot.hosts.length];
21168
- if (!next) return;
21169
- selectedHostId = next.hostId;
21170
- render(latestSnapshot);
21171
- const nextTab = [
21172
- ...content.querySelectorAll("[data-connection-host-tab]")
21173
- ].find((candidate) => candidate.dataset.connectionHostTab === next.hostId);
21174
- nextTab?.focus();
21175
- });
21176
- tabs.append(tab);
21177
- });
21178
- hostStrip.append(scrollLeft, tabs, scrollRight);
21179
- const tableHeader = document2.createElement("div");
21180
- tableHeader.className = "settings-connection-table-header";
21181
- tableHeader.setAttribute("role", "row");
21182
- const componentHeading = document2.createElement("span");
21183
- componentHeading.textContent = messages.connectionComponent;
21184
- componentHeading.setAttribute("role", "columnheader");
21185
- const statusHeading = document2.createElement("span");
21186
- statusHeading.textContent = messages.connectionStatus;
21187
- statusHeading.setAttribute("role", "columnheader");
21188
- const actionHeading = document2.createElement("span");
21189
- actionHeading.setAttribute("aria-hidden", "true");
21190
- tableHeader.append(componentHeading, statusHeading, actionHeading);
21191
- const rows = document2.createElement("div");
21192
- rows.className = "settings-connection-rows";
21193
- rows.id = panelId;
21194
- rows.dataset.connectionHost = selectedHost.hostId;
21195
- rows.setAttribute("role", "rowgroup");
21196
- const inspector = document2.createElement("aside");
21197
- inspector.className = "settings-connection-inspector";
21198
- inspector.setAttribute("aria-live", "polite");
21199
- keepPageStillDuringTextSelection(inspector);
21200
- const items = connectionItems(snapshot, selectedHost, messages, diagnostics).filter((item) => item.key !== "renderer-adapter").map((item) => {
21201
- const agent = item.agentSnapshot?.agent;
21202
- if (!agent) return item;
21203
- const state = installs?.get(selectedHost.hostId, agent);
21204
- const availability = state?.status ?? item.availability;
21205
- const version2 = item.agentSnapshot?.availability !== "notInstalled" && availability !== "installing" && availability !== "checking" ? versions.get(selectedHost.hostId, agent) : void 0;
21206
- return {
21207
- ...item,
21208
- ...state ? { availability: state.status } : {},
21209
- ...version2 ? { version: version2 } : {},
21210
- ...version2?.updating ? { availability: "updating" } : {},
21211
- ...state?.error ? { installError: state.error } : {},
21212
- ...diagnostics?.installation && harnessHasInstallCommands(item.agentSnapshot?.plugin) ? {
21213
- install: () => {
21214
- void installs?.install(selectedHost.hostId, agent);
21215
- }
21216
- } : {}
21217
- };
21655
+ if (tab.textContent !== hostName) {
21656
+ tab.textContent = hostName;
21657
+ tabsChanged = true;
21658
+ }
21659
+ const tabTitle = host.active ? `${hostName} \xB7 ${messages.connectionActiveHost}` : hostName;
21660
+ if (tab.title !== tabTitle) {
21661
+ tab.title = tabTitle;
21662
+ }
21663
+ return tab;
21218
21664
  });
21665
+ reconcileElementChildren(tabs, nextTabs);
21666
+ if (rows.dataset.connectionHost !== selectedHost.hostId) {
21667
+ rows.dataset.connectionHost = selectedHost.hostId;
21668
+ }
21669
+ const items = connectionItems(snapshot, selectedHost, messages, diagnostics).map(
21670
+ (item) => {
21671
+ const agent = item.agentSnapshot?.agent;
21672
+ if (!agent) return item;
21673
+ const state = installs?.get(selectedHost.hostId, agent);
21674
+ const availability = state?.status ?? item.availability;
21675
+ const updating = versions.isUpdating(selectedHost.hostId, agent);
21676
+ const version2 = updating || item.agentSnapshot?.availability !== "notInstalled" && availability !== "installing" && availability !== "checking" ? versions.get(selectedHost.hostId, agent) : void 0;
21677
+ const accessory = longContextControlFor(selectedHost.hostId, item);
21678
+ return {
21679
+ ...item,
21680
+ ...state ? { availability: state.status } : {},
21681
+ ...version2 ? { version: version2 } : {},
21682
+ ...version2?.updating ? { availability: "updating" } : {},
21683
+ ...state?.error ? { installError: state.error } : {},
21684
+ ...accessory ? { accessory } : {},
21685
+ ...diagnostics?.installation && harnessHasInstallCommands(item.agentSnapshot?.plugin) ? {
21686
+ install: () => {
21687
+ void installs?.install(selectedHost.hostId, agent);
21688
+ }
21689
+ } : {}
21690
+ };
21691
+ }
21692
+ );
21219
21693
  if (!items.some((item) => item.key === selectedItemKey)) {
21220
21694
  const requestedFocus = pendingFocusAgent;
21221
21695
  pendingFocusAgent = null;
@@ -21223,248 +21697,200 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
21223
21697
  (item) => item.agentSnapshot?.availability === "notInstalled" || item.error !== null
21224
21698
  )?.key ?? items[0]?.key ?? null;
21225
21699
  }
21226
- const rowElements = /* @__PURE__ */ new Map();
21700
+ let hostRows = hostRowViews.get(selectedHost.hostId);
21701
+ if (!hostRows) {
21702
+ hostRows = /* @__PURE__ */ new Map();
21703
+ hostRowViews.set(selectedHost.hostId, hostRows);
21704
+ }
21705
+ currentHostRows = hostRows;
21227
21706
  const selectItem = (item) => {
21228
21707
  selectedItemKey = item.key;
21229
- for (const [key, row] of rowElements) {
21230
- const selected = key === item.key;
21231
- row.dataset.connectionSelected = String(selected);
21232
- row.tabIndex = selected ? 0 : -1;
21708
+ for (const [key, view] of currentHostRows) {
21709
+ view.setSelected(key === item.key);
21233
21710
  }
21234
- const existing = launchControls?.hostId === selectedHost.hostId && launchControls.itemKey === item.key ? launchControls.element : null;
21235
- const element = renderConnectionInspector(
21236
- document2,
21237
- inspector,
21238
- item,
21239
- selectedHost.hostId,
21240
- messages,
21241
- getDiagnostics(),
21242
- existing,
21243
- runRefresh,
21244
- openExternalUrl
21245
- );
21246
- launchControls = { hostId: selectedHost.hostId, itemKey: item.key, element };
21247
- if (item.version) inspector.append(item.version.element);
21711
+ syncSelectedInspector(selectedHost.hostId, item);
21248
21712
  };
21249
- for (const pinnedItem of items.filter((item) => !item.agentSnapshot)) {
21250
- const row = createConnectionRow(
21251
- document2,
21713
+ const ensureRowView = (key, groupable) => {
21714
+ let view = hostRows.get(key);
21715
+ if (!view) {
21716
+ view = createConnectionRowView(document2, messages, groupable);
21717
+ hostRows.set(key, view);
21718
+ }
21719
+ return view;
21720
+ };
21721
+ const activeKeys = /* @__PURE__ */ new Set();
21722
+ const nextRowChildren = [];
21723
+ const pinnedItems = items.filter((item) => item.agentSnapshot === void 0);
21724
+ for (const pinnedItem of pinnedItems) {
21725
+ activeKeys.add(pinnedItem.key);
21726
+ const view = ensureRowView(pinnedItem.key, false);
21727
+ view.update(
21252
21728
  pinnedItem,
21253
- messages,
21254
21729
  pinnedItem.key === selectedItemKey,
21255
- () => selectItem(pinnedItem)
21730
+ () => selectItem(pinnedItem),
21731
+ null
21256
21732
  );
21257
- rowElements.set(pinnedItem.key, row);
21258
- rows.append(row);
21733
+ nextRowChildren.push(view.element);
21259
21734
  }
21260
21735
  const groupableItems = items.filter(
21261
21736
  (item) => item.agentSnapshot !== void 0
21262
21737
  );
21263
21738
  const agentByKey = new Map(groupableItems.map((item) => [item.key, item]));
21264
- const catalog = groupableItems.map((item) => ({ id: item.key, name: item.name }));
21265
- const preferenceOrder = groupPreference.list(
21266
- new Set(
21267
- groupableItems.filter((item) => item.agentSnapshot.availability === "notInstalled").map((item) => item.agentSnapshot.agent)
21268
- ),
21269
- catalog
21270
- ).filter((entry) => agentByKey.has(entry.agent));
21271
- const isInstalledAgent = (agent) => agentByKey.get(agent)?.agentSnapshot.availability !== "notInstalled";
21272
- const mainEntries = partitionAgentsByInstallStatus(
21273
- preferenceOrder.filter((entry) => entry.section === "main"),
21274
- isInstalledAgent
21275
- );
21276
- const moreEntries = partitionAgentsByInstallStatus(
21277
- preferenceOrder.filter((entry) => entry.section === "more"),
21278
- isInstalledAgent
21739
+ currentCatalog = groupableItems.map((item) => ({ id: item.key, name: item.name }));
21740
+ const notInstalledAgents = /* @__PURE__ */ new Set();
21741
+ for (const item of groupableItems) {
21742
+ const agent = item.agentSnapshot.agent;
21743
+ const stateKey = `${selectedHost.hostId}:${agent}`;
21744
+ if (item.agentSnapshot.availability !== "checking") {
21745
+ knownNotInstalled.set(stateKey, item.agentSnapshot.availability === "notInstalled");
21746
+ }
21747
+ const isNotInstalled = item.agentSnapshot.availability === "checking" ? knownNotInstalled.get(stateKey) ?? false : item.agentSnapshot.availability === "notInstalled";
21748
+ if (isNotInstalled) notInstalledAgents.add(agent);
21749
+ }
21750
+ const preferenceOrder = partitionAgentsByInstallStatus(
21751
+ groupPreference.list(notInstalledAgents, currentCatalog).filter((entry) => agentByKey.has(entry.agent)),
21752
+ (agent) => !notInstalledAgents.has(agent)
21279
21753
  );
21280
- groupPreference.reconcileOrder([...mainEntries, ...moreEntries], catalog);
21754
+ groupPreference.reconcileOrder(preferenceOrder, currentCatalog);
21755
+ currentMainEntries = preferenceOrder.filter((entry) => entry.section === "main");
21756
+ currentMoreEntries = preferenceOrder.filter((entry) => entry.section === "more");
21281
21757
  const nextInSection = (section, agent) => {
21282
- const list2 = section === "main" ? mainEntries : moreEntries;
21283
- const index = list2.findIndex((entry) => entry.agent === agent);
21284
- return index >= 0 ? list2[index + 1]?.agent ?? null : null;
21758
+ const sectionEntries = section === "main" ? currentMainEntries : currentMoreEntries;
21759
+ const index = sectionEntries.findIndex((entry) => entry.agent === agent);
21760
+ return index >= 0 ? sectionEntries[index + 1]?.agent ?? null : null;
21285
21761
  };
21286
- const beforeAgentForBucketAppend = (agent, targetSection) => {
21287
- const list2 = targetSection === "main" ? mainEntries : moreEntries;
21288
- const installed = isInstalledAgent(agent);
21289
- return list2.find(
21290
- (entry) => entry.agent !== agent && isInstalledAgent(entry.agent) !== installed
21291
- )?.agent ?? null;
21292
- };
21293
- let draggingAgent = null;
21294
- let moreZone = null;
21295
- const clearDropIndicators = () => {
21296
- for (const row of rowElements.values()) row.dataset.connectionDropIndicator = "";
21297
- if (moreZone) moreZone.dataset.connectionDragOver = "false";
21298
- };
21299
- const sameInstallBucket = (left, right) => isInstalledAgent(left) === isInstalledAgent(right);
21300
21762
  const dropTargetSection = (agent, event) => {
21301
- const row = rowElements.get(agent);
21763
+ const row = currentHostRows.get(agent)?.element;
21302
21764
  const rect = row && typeof row.getBoundingClientRect === "function" ? row.getBoundingClientRect() : null;
21303
21765
  const before = rect ? event.clientY - rect.top < rect.height / 2 : true;
21304
21766
  const section = row?.dataset.connectionGroupSection ?? "main";
21305
21767
  return { before, beforeAgent: before ? agent : nextInSection(section, agent) };
21306
21768
  };
21307
- const createGroupController = (agent, section) => ({
21308
- disabled: groupDisabled,
21309
- section,
21310
- moveLabel: section === "main" ? messages.connectionGroupMoveToMore : messages.connectionGroupMoveToMain,
21311
- dragHandleTitle: messages.connectionGroupDragHandle,
21312
- toggleSection() {
21313
- groupPreference.moveAgent(agent, section === "main" ? "more" : "main", null, catalog);
21314
- },
21315
- onDragStart(event) {
21316
- if (groupDisabled) {
21317
- event.preventDefault();
21318
- return;
21319
- }
21320
- draggingAgent = agent;
21321
- event.dataTransfer?.setData("text/plain", agent);
21322
- if (event.dataTransfer) event.dataTransfer.effectAllowed = "move";
21323
- const row = rowElements.get(agent);
21324
- if (row) row.dataset.connectionDragging = "true";
21325
- },
21326
- onDragOver(event) {
21327
- if (!draggingAgent || draggingAgent === agent) return;
21328
- const crossSection = groupPreference.sectionOf(draggingAgent) !== section;
21329
- if (!crossSection && !sameInstallBucket(draggingAgent, agent)) return;
21330
- event.preventDefault();
21331
- const row = rowElements.get(agent);
21332
- if (!row) return;
21333
- clearDropIndicators();
21334
- if (crossSection && !sameInstallBucket(draggingAgent, agent)) {
21335
- row.dataset.connectionDropIndicator = "before";
21336
- return;
21337
- }
21338
- const { before } = dropTargetSection(agent, event);
21339
- row.dataset.connectionDropIndicator = before ? "before" : "after";
21340
- },
21341
- onDragLeave() {
21342
- const row = rowElements.get(agent);
21343
- if (row) row.dataset.connectionDropIndicator = "";
21344
- },
21345
- onDrop(event) {
21346
- event.preventDefault();
21347
- event.stopPropagation();
21348
- if (!draggingAgent) return;
21349
- const crossSection = groupPreference.sectionOf(draggingAgent) !== section;
21350
- if (!crossSection && !sameInstallBucket(draggingAgent, agent)) {
21351
- draggingAgent = null;
21352
- clearDropIndicators();
21353
- return;
21354
- }
21355
- if (crossSection && !sameInstallBucket(draggingAgent, agent)) {
21769
+ const createGroupController = (agent, section) => {
21770
+ const disabled = groupDisabled;
21771
+ return {
21772
+ disabled,
21773
+ section,
21774
+ moveLabel: section === "main" ? messages.connectionGroupMoveToMore : messages.connectionGroupMoveToMain,
21775
+ dragHandleTitle: messages.connectionGroupDragHandle,
21776
+ toggleSection() {
21356
21777
  groupPreference.moveAgent(
21357
- draggingAgent,
21358
- section,
21359
- beforeAgentForBucketAppend(draggingAgent, section),
21360
- catalog
21778
+ agent,
21779
+ section === "main" ? "more" : "main",
21780
+ null,
21781
+ currentCatalog
21361
21782
  );
21362
- } else {
21783
+ },
21784
+ onDragStart(event) {
21785
+ if (disabled) {
21786
+ event.preventDefault();
21787
+ return;
21788
+ }
21789
+ draggingAgent = agent;
21790
+ event.dataTransfer?.setData("text/plain", agent);
21791
+ if (event.dataTransfer) event.dataTransfer.effectAllowed = "move";
21792
+ const row = currentHostRows.get(agent)?.element;
21793
+ if (row) row.dataset.connectionDragging = "true";
21794
+ },
21795
+ onDragOver(event) {
21796
+ if (!draggingAgent || draggingAgent === agent) return;
21797
+ event.preventDefault();
21798
+ const row = currentHostRows.get(agent)?.element;
21799
+ if (!row) return;
21800
+ const { before } = dropTargetSection(agent, event);
21801
+ clearDropIndicators();
21802
+ row.dataset.connectionDropIndicator = before ? "before" : "after";
21803
+ },
21804
+ onDragLeave() {
21805
+ const row = currentHostRows.get(agent)?.element;
21806
+ if (row) row.dataset.connectionDropIndicator = "";
21807
+ },
21808
+ onDrop(event) {
21809
+ event.preventDefault();
21810
+ if (!draggingAgent) return;
21363
21811
  const { beforeAgent } = dropTargetSection(agent, event);
21364
- groupPreference.moveAgent(draggingAgent, section, beforeAgent, catalog);
21812
+ groupPreference.moveAgent(draggingAgent, section, beforeAgent, currentCatalog);
21813
+ draggingAgent = null;
21814
+ clearDropIndicators();
21815
+ },
21816
+ onDragEnd() {
21817
+ draggingAgent = null;
21818
+ const row = currentHostRows.get(agent)?.element;
21819
+ if (row) row.dataset.connectionDragging = "false";
21820
+ clearDropIndicators();
21821
+ scheduleRender();
21365
21822
  }
21366
- draggingAgent = null;
21367
- clearDropIndicators();
21368
- },
21369
- onDragEnd() {
21370
- draggingAgent = null;
21371
- const row = rowElements.get(agent);
21372
- if (row) row.dataset.connectionDragging = "false";
21373
- clearDropIndicators();
21374
- }
21375
- });
21376
- const appendGroupRow = (agent, section) => {
21377
- const item = agentByKey.get(agent);
21378
- if (!item) return;
21379
- const row = createConnectionRow(
21380
- document2,
21823
+ };
21824
+ };
21825
+ for (const entry of currentMainEntries) {
21826
+ const item = agentByKey.get(entry.agent);
21827
+ if (!item) continue;
21828
+ activeKeys.add(item.key);
21829
+ const view = ensureRowView(item.key, true);
21830
+ view.update(
21381
21831
  item,
21382
- messages,
21383
21832
  item.key === selectedItemKey,
21384
21833
  () => selectItem(item),
21385
- createGroupController(agent, section),
21386
- longContextControlFor(selectedHost.hostId, item)
21834
+ createGroupController(entry.agent, "main")
21387
21835
  );
21388
- rowElements.set(item.key, row);
21389
- rows.append(row);
21390
- };
21391
- for (const entry of mainEntries) appendGroupRow(entry.agent, "main");
21836
+ nextRowChildren.push(view.element);
21837
+ }
21392
21838
  if (groupableItems.length > 0) {
21393
- rows.append(createGroupDivider(document2, messages, moreEntries.length));
21394
- const zone = document2.createElement("div");
21395
- moreZone = zone;
21396
- zone.className = "settings-connection-group-more";
21397
- zone.setAttribute("role", "presentation");
21398
- zone.addEventListener("dragover", (event) => {
21399
- if (!draggingAgent) return;
21400
- event.preventDefault();
21401
- zone.dataset.connectionDragOver = "true";
21402
- });
21403
- zone.addEventListener("dragleave", () => {
21404
- zone.dataset.connectionDragOver = "false";
21405
- });
21406
- zone.addEventListener("drop", (event) => {
21407
- event.preventDefault();
21408
- zone.dataset.connectionDragOver = "false";
21409
- if (!draggingAgent) return;
21410
- groupPreference.moveAgent(draggingAgent, "more", null, catalog);
21411
- draggingAgent = null;
21412
- clearDropIndicators();
21413
- });
21414
- if (moreEntries.length === 0) {
21415
- zone.append(createGroupMoreHint(document2, messages));
21839
+ const dividerText = `${messages.connectionGroupMoreLabel} (${currentMoreEntries.length})`;
21840
+ if (groupDivider.textContent !== dividerText) {
21841
+ groupDivider.textContent = dividerText;
21842
+ }
21843
+ nextRowChildren.push(groupDivider);
21844
+ const nextMoreChildren = [];
21845
+ if (currentMoreEntries.length === 0) {
21846
+ nextMoreChildren.push(moreHint);
21416
21847
  } else {
21417
- for (const entry of moreEntries) {
21848
+ for (const entry of currentMoreEntries) {
21418
21849
  const item = agentByKey.get(entry.agent);
21419
21850
  if (!item) continue;
21420
- const row = createConnectionRow(
21421
- document2,
21851
+ activeKeys.add(item.key);
21852
+ const view = ensureRowView(item.key, true);
21853
+ view.update(
21422
21854
  item,
21423
- messages,
21424
21855
  item.key === selectedItemKey,
21425
21856
  () => selectItem(item),
21426
- createGroupController(entry.agent, "more"),
21427
- longContextControlFor(selectedHost.hostId, item)
21857
+ createGroupController(entry.agent, "more")
21428
21858
  );
21429
- rowElements.set(item.key, row);
21430
- zone.append(row);
21859
+ nextMoreChildren.push(view.element);
21431
21860
  }
21432
21861
  }
21433
- rows.append(zone);
21434
- const reset = createGroupResetButton(document2, messages, () => {
21435
- groupPreference.resetToDefault();
21436
- });
21437
- reset.disabled = groupDisabled;
21438
- rows.append(reset);
21862
+ if (!draggingAgent || renderedHostId !== selectedHost.hostId) {
21863
+ reconcileElementChildren(moreZone, nextMoreChildren);
21864
+ }
21865
+ nextRowChildren.push(moreZone);
21866
+ resetButton.disabled = groupDisabled;
21867
+ nextRowChildren.push(resetButton);
21868
+ }
21869
+ for (const key of hostRows.keys()) {
21870
+ if (!activeKeys.has(key)) hostRows.delete(key);
21871
+ }
21872
+ if (!draggingAgent || renderedHostId !== selectedHost.hostId) {
21873
+ reconcileElementChildren(rows, nextRowChildren);
21439
21874
  }
21440
21875
  const selectedItem = items.find((item) => item.key === selectedItemKey) ?? items[0];
21441
21876
  if (selectedItem) selectItem(selectedItem);
21442
- const updateControls = updates.createControls(
21877
+ updateControls.update(
21443
21878
  selectedHost.hostId,
21444
21879
  items.flatMap((item) => item.version ? [item.version] : [])
21445
21880
  );
21446
- const hostHeader = document2.createElement("div");
21447
- hostHeader.className = "settings-connection-host-header";
21448
- hostHeader.append(hostStrip, updateControls.button);
21449
- list.append(hostHeader, updateControls.result, tableHeader, rows);
21450
- layout.append(list, inspector);
21451
- content.replaceChildren(layout);
21452
- disposeHostScroller = configureHostScroller(
21453
- document2,
21454
- hostStrip,
21455
- tabs,
21456
- scrollLeft,
21457
- scrollRight
21458
- );
21459
- const selectedTab = [...tabs.children].find(
21460
- (child) => child.getAttribute("aria-selected") === "true"
21461
- );
21462
- if (selectedTab) {
21463
- const left = selectedTab.offsetLeft;
21464
- const right = left + selectedTab.offsetWidth;
21465
- if (left < tabs.scrollLeft) tabs.scrollLeft = left;
21466
- else if (right > tabs.scrollLeft + tabs.clientWidth) {
21467
- tabs.scrollLeft = right - tabs.clientWidth;
21881
+ if (layoutFirstMount || tabsChanged) {
21882
+ hostScroller.update();
21883
+ }
21884
+ if (renderedHostId !== selectedHost.hostId) {
21885
+ renderedHostId = selectedHost.hostId;
21886
+ const selectedTab = hostTabElements.get(selectedHost.hostId);
21887
+ if (selectedTab) {
21888
+ const left = selectedTab.offsetLeft;
21889
+ const right = left + selectedTab.offsetWidth;
21890
+ if (left < tabs.scrollLeft) tabs.scrollLeft = left;
21891
+ else if (right > tabs.scrollLeft + tabs.clientWidth) {
21892
+ tabs.scrollLeft = right - tabs.clientWidth;
21893
+ }
21468
21894
  }
21469
21895
  }
21470
21896
  };
@@ -21485,7 +21911,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
21485
21911
  refresh.disabled = true;
21486
21912
  return () => {
21487
21913
  cancelRender();
21488
- disposeHostScroller();
21914
+ hostScroller.dispose();
21489
21915
  unsubscribeGroup();
21490
21916
  };
21491
21917
  }
@@ -21494,7 +21920,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
21494
21920
  const unsubscribeInstalls = installs?.subscribe(scheduleRender);
21495
21921
  return () => {
21496
21922
  cancelRender();
21497
- disposeHostScroller();
21923
+ hostScroller.dispose();
21498
21924
  unsubscribeInstalls?.();
21499
21925
  unsubscribe();
21500
21926
  unsubscribeGroup();
@@ -21578,9 +22004,11 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
21578
22004
  title: "Settings",
21579
22005
  close: "Close settings",
21580
22006
  sectionsLabel: "Settings sections",
21581
- connectionSection: "Connections",
22007
+ agentsSection: "Agents",
22008
+ accessSection: "Access",
22009
+ activitySection: "Sessions & activity",
21582
22010
  generalSection: "General",
21583
- otherSection: "Other",
22011
+ otherSection: "About",
21584
22012
  appearanceDescription: "Conversation display and local resource management.",
21585
22013
  appearanceGroup: "Appearance",
21586
22014
  loadedSessions: {
@@ -21896,9 +22324,11 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
21896
22324
  title: "\u8BBE\u7F6E",
21897
22325
  close: "\u5173\u95ED\u8BBE\u7F6E",
21898
22326
  sectionsLabel: "\u8BBE\u7F6E\u5206\u7C7B",
21899
- connectionSection: "\u8FDE\u63A5",
22327
+ agentsSection: "Agents",
22328
+ accessSection: "\u8BBF\u95EE\u4E0E\u8D26\u53F7",
22329
+ activitySection: "\u4F1A\u8BDD\u4E0E\u6D3B\u52A8",
21900
22330
  generalSection: "\u901A\u7528",
21901
- otherSection: "\u5176\u4ED6",
22331
+ otherSection: "\u5173\u4E8E",
21902
22332
  appearanceDescription: "\u4F1A\u8BDD\u663E\u793A\u4E0E\u672C\u5730\u8D44\u6E90\u7BA1\u7406\u3002",
21903
22333
  appearanceGroup: "\u5916\u89C2",
21904
22334
  loadedSessions: {
@@ -23040,6 +23470,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
23040
23470
  latestCacheHit: "Latest cache hit (CH)",
23041
23471
  sessionCacheHit: "Average cache hit",
23042
23472
  outputSpeed: "Output speed (TPS)",
23473
+ averageOutputSpeed: "Average output speed (TPS)",
23043
23474
  apiOutputSpeed: "API average speed",
23044
23475
  apiOutputSpeedDescription: "Output tokens / native API time, including first-token wait; not generation TPS.",
23045
23476
  timeToFirstOutput: "Time to first token (TTFT)",
@@ -23066,6 +23497,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
23066
23497
  latestCacheHit: "\u7F13\u5B58\u547D\u4E2D\u7387",
23067
23498
  sessionCacheHit: "\u5E73\u5747\u7F13\u5B58\u547D\u4E2D",
23068
23499
  outputSpeed: "\u8F93\u51FA\u901F\u5EA6\uFF08TPS\uFF09",
23500
+ averageOutputSpeed: "\u5E73\u5747\u8F93\u51FA\u901F\u5EA6\uFF08TPS\uFF09",
23069
23501
  apiOutputSpeed: "API \u5E73\u5747\u901F\u5EA6",
23070
23502
  apiOutputSpeedDescription: "\u8F93\u51FA Token \xF7 \u539F\u751F API \u8017\u65F6\uFF0C\u542B\u9996\u5B57\u7B49\u5F85\uFF1B\u4E0D\u662F\u751F\u6210 TPS\u3002",
23071
23503
  timeToFirstOutput: "\u9996 token\uFF08TTFT\uFF09",
@@ -23193,7 +23625,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
23193
23625
  return parts;
23194
23626
  }
23195
23627
  function rendererUsageHasDisplayData(usage) {
23196
- return usage?.cacheHitRatePercent !== void 0 || usage?.sessionCacheHitRatePercent !== void 0 || usage?.outputTokensPerSecond !== void 0 || usage?.apiOutputTokensPerSecond !== void 0 || usage?.timeToFirstOutputMs !== void 0 || usage?.totalCostUsd !== void 0 || usage?.totalCredits !== void 0 || usage?.contextUsagePercent !== void 0 || usage?.contextUsedTokens !== void 0 && usage.contextWindowTokens !== void 0 || usage?.totalTokens !== void 0 || usage?.inputTokens !== void 0 || usage?.cachedInputTokens !== void 0 || usage?.cacheWriteInputTokens !== void 0 || usage?.outputTokens !== void 0;
23628
+ return usage?.cacheHitRatePercent !== void 0 || usage?.sessionCacheHitRatePercent !== void 0 || usage?.sessionOutputTokensPerSecond !== void 0 || usage?.outputTokensPerSecond !== void 0 || usage?.apiOutputTokensPerSecond !== void 0 || usage?.timeToFirstOutputMs !== void 0 || usage?.totalCostUsd !== void 0 || usage?.totalCredits !== void 0 || usage?.contextUsagePercent !== void 0 || usage?.contextUsedTokens !== void 0 && usage.contextWindowTokens !== void 0 || usage?.totalTokens !== void 0 || usage?.inputTokens !== void 0 || usage?.cachedInputTokens !== void 0 || usage?.cacheWriteInputTokens !== void 0 || usage?.outputTokens !== void 0;
23197
23629
  }
23198
23630
  function applyRendererPopoverChrome(popover) {
23199
23631
  popover.style.border = "1px solid light-dark(rgba(15, 23, 42, 0.10), color-mix(in srgb, CanvasText 16%, transparent))";
@@ -23307,6 +23739,12 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
23307
23739
  formatRendererCacheHitRate(usage.sessionCacheHitRatePercent)
23308
23740
  ]);
23309
23741
  }
23742
+ if (usage?.sessionOutputTokensPerSecond !== void 0) {
23743
+ session.push([
23744
+ messages.averageOutputSpeed,
23745
+ formatRendererTokenRate(usage.sessionOutputTokensPerSecond, locale)
23746
+ ]);
23747
+ }
23310
23748
  if (usage?.cacheHitRatePercent !== void 0) {
23311
23749
  session.push([messages.latestCacheHit, formatRendererCacheHitRate(usage.cacheHitRatePercent)]);
23312
23750
  }
@@ -25257,9 +25695,13 @@ Codex Fast mode prioritizes requests and may increase usage.`
25257
25695
  resets: "Resets",
25258
25696
  details: "Account limit details",
25259
25697
  weekly: "Weekly limit",
25698
+ weeklyShort: "Weekly",
25260
25699
  monthly: "Monthly limit",
25700
+ monthlyShort: "Monthly",
25261
25701
  fiveHour: "5-hour limit",
25702
+ fiveHourShort: "5-hour",
25262
25703
  sevenDay: "7-day limit",
25704
+ sevenDayShort: "7-day",
25263
25705
  account: "Account limit"
25264
25706
  });
25265
25707
  var CHINESE_CREDITS_MESSAGES = Object.freeze({
@@ -25267,9 +25709,13 @@ Codex Fast mode prioritizes requests and may increase usage.`
25267
25709
  resets: "\u91CD\u7F6E",
25268
25710
  details: "\u8D26\u53F7\u989D\u5EA6\u8BE6\u60C5",
25269
25711
  weekly: "\u5468\u989D\u5EA6",
25712
+ weeklyShort: "\u5468\u989D\u5EA6",
25270
25713
  monthly: "\u6708\u989D\u5EA6",
25714
+ monthlyShort: "\u6708\u989D\u5EA6",
25271
25715
  fiveHour: "5 \u5C0F\u65F6\u989D\u5EA6",
25716
+ fiveHourShort: "5 \u5C0F\u65F6",
25272
25717
  sevenDay: "7 \u5929\u989D\u5EA6",
25718
+ sevenDayShort: "7 \u5929",
25273
25719
  account: "\u8D26\u53F7\u989D\u5EA6"
25274
25720
  });
25275
25721
  function rendererCreditsMessages(locale) {
@@ -25301,6 +25747,14 @@ Codex Fast mode prioritizes requests and may increase usage.`
25301
25747
  if (periodType === "seven_day") return messages.sevenDay;
25302
25748
  return messages.account;
25303
25749
  }
25750
+ function compactPeriodLabel(periodType, locale) {
25751
+ const messages = rendererCreditsMessages(locale);
25752
+ if (periodType === "weekly") return messages.weeklyShort;
25753
+ if (periodType === "monthly") return messages.monthlyShort;
25754
+ if (periodType === "five_hour") return messages.fiveHourShort;
25755
+ if (periodType === "seven_day") return messages.sevenDayShort;
25756
+ return messages.account;
25757
+ }
25304
25758
  function productLabel(product, locale = "en") {
25305
25759
  return accountCreditsWindowLabel(product, locale, (period) => creditsPeriodLabel(period, locale));
25306
25760
  }
@@ -25312,10 +25766,10 @@ Codex Fast mode prioritizes requests and may increase usage.`
25312
25766
  function remainingPercent(usedPercent) {
25313
25767
  return Math.min(100, Math.max(0, 100 - usedPercent));
25314
25768
  }
25315
- function renderCreditsBar(usagePercent, color) {
25769
+ function renderCreditsBar(usagePercent, color, height = "6px") {
25316
25770
  const track = document.createElement("div");
25317
25771
  track.dataset.codexhostCreditsBar = "";
25318
- track.style.height = "6px";
25772
+ track.style.height = height;
25319
25773
  track.style.borderRadius = "9999px";
25320
25774
  track.style.background = "color-mix(in srgb, currentColor 16%, transparent)";
25321
25775
  track.style.overflow = "hidden";
@@ -25332,6 +25786,34 @@ Codex Fast mode prioritizes requests and may increase usage.`
25332
25786
  const formatted = formatRendererCreditsReset(resetsAt, /* @__PURE__ */ new Date(), locale);
25333
25787
  return locale === "zh-CN" ? `${formatted} ${messages.resets}` : `${messages.resets} ${formatted}`;
25334
25788
  }
25789
+ function renderResetLine(resetsAt, fontSize, locale, messages) {
25790
+ const exact = resetLabel(resetsAt, locale, messages);
25791
+ const reset = document.createElement("div");
25792
+ reset.dataset.codexhostResetAt = resetsAt;
25793
+ reset.dataset.codexhostResetLocale = locale;
25794
+ reset.textContent = formatAccountCreditsResetCountdown(resetsAt, locale) ?? exact;
25795
+ reset.title = exact;
25796
+ reset.style.fontSize = fontSize;
25797
+ reset.style.color = "color-mix(in srgb, currentColor 62%, transparent)";
25798
+ return reset;
25799
+ }
25800
+ function refreshResetLines(popover) {
25801
+ if (typeof popover.querySelectorAll !== "function") return;
25802
+ const nowMs = Date.now();
25803
+ for (const element of popover.querySelectorAll("[data-codexhost-reset-at]")) {
25804
+ const resetsAt = element.dataset.codexhostResetAt;
25805
+ if (!resetsAt) continue;
25806
+ const locale = element.dataset.codexhostResetLocale === "zh-CN" ? "zh-CN" : "en";
25807
+ const exact = resetLabel(resetsAt, locale, rendererCreditsMessages(locale));
25808
+ if (element.dataset.codexhostResetCompact === "1") {
25809
+ const compact = formatAccountCreditsCompactCountdown(resetsAt, locale, nowMs);
25810
+ element.textContent = `\xB7 ${compact ?? exact}`;
25811
+ } else {
25812
+ element.textContent = formatAccountCreditsResetCountdown(resetsAt, locale, nowMs) ?? exact;
25813
+ }
25814
+ element.title = exact;
25815
+ }
25816
+ }
25335
25817
  function renderCreditsHeader(credits, locale, messages) {
25336
25818
  const wrapper = document.createElement("div");
25337
25819
  wrapper.style.marginBottom = "11px";
@@ -25348,11 +25830,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
25348
25830
  label.style.fontWeight = "600";
25349
25831
  left.append(label);
25350
25832
  if (credits.resetsAt) {
25351
- const reset = document.createElement("div");
25352
- reset.textContent = resetLabel(credits.resetsAt, locale, messages);
25353
- reset.style.fontSize = "11px";
25354
- reset.style.color = "color-mix(in srgb, currentColor 62%, transparent)";
25355
- left.append(reset);
25833
+ left.append(renderResetLine(credits.resetsAt, "11px", locale, messages));
25356
25834
  }
25357
25835
  if (credits.usedPercent === void 0) {
25358
25836
  wrapper.append(top);
@@ -25385,7 +25863,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
25385
25863
  const color = toneColor(rendererCreditsTone(usagePercent));
25386
25864
  const remaining = remainingPercent(usagePercent);
25387
25865
  const tile = document.createElement("div");
25388
- tile.style.marginBottom = "11px";
25866
+ tile.style.marginBottom = "9px";
25389
25867
  const top = document.createElement("div");
25390
25868
  top.style.display = "flex";
25391
25869
  top.style.alignItems = "flex-start";
@@ -25398,21 +25876,72 @@ Codex Fast mode prioritizes requests and may increase usage.`
25398
25876
  name.style.fontSize = "12px";
25399
25877
  left.append(name);
25400
25878
  if (resetsAt) {
25401
- const reset = document.createElement("div");
25402
- reset.textContent = resetLabel(resetsAt, locale, messages);
25403
- reset.style.fontSize = "10.5px";
25404
- reset.style.color = "color-mix(in srgb, currentColor 62%, transparent)";
25405
- left.append(reset);
25879
+ left.append(renderResetLine(resetsAt, "10.5px", locale, messages));
25406
25880
  }
25407
25881
  const percent2 = document.createElement("span");
25408
25882
  percent2.textContent = `${messages.remaining} ${formatRendererCreditsPercent(remaining)}`;
25409
25883
  percent2.style.fontSize = "12px";
25410
25884
  percent2.style.fontVariantNumeric = "tabular-nums";
25885
+ percent2.style.whiteSpace = "nowrap";
25411
25886
  percent2.style.color = color;
25412
25887
  top.append(left, percent2);
25413
25888
  tile.append(top, renderCreditsBar(remaining, color));
25414
25889
  return tile;
25415
25890
  }
25891
+ function renderCompactCreditsRow(label, usagePercent, locale, messages, resetsAt, hero = false) {
25892
+ const color = toneColor(rendererCreditsTone(usagePercent));
25893
+ const remaining = remainingPercent(usagePercent);
25894
+ const row = document.createElement("div");
25895
+ row.style.marginBottom = "8px";
25896
+ const top = document.createElement("div");
25897
+ top.style.display = "flex";
25898
+ top.style.alignItems = "baseline";
25899
+ top.style.justifyContent = "space-between";
25900
+ top.style.gap = "8px";
25901
+ top.style.marginBottom = "4px";
25902
+ const left = document.createElement("span");
25903
+ left.style.display = "inline-flex";
25904
+ left.style.alignItems = "baseline";
25905
+ left.style.gap = "6px";
25906
+ left.style.minWidth = "0";
25907
+ const name = document.createElement("span");
25908
+ name.textContent = label;
25909
+ name.style.fontSize = "12px";
25910
+ name.style.color = "color-mix(in srgb, currentColor 82%, transparent)";
25911
+ left.append(name);
25912
+ if (resetsAt) {
25913
+ const exact = resetLabel(resetsAt, locale, messages);
25914
+ if (usagePercent > 0) {
25915
+ const countdown = document.createElement("span");
25916
+ countdown.dataset.codexhostResetAt = resetsAt;
25917
+ countdown.dataset.codexhostResetLocale = locale;
25918
+ countdown.dataset.codexhostResetCompact = "1";
25919
+ const compact = formatAccountCreditsCompactCountdown(resetsAt, locale);
25920
+ countdown.textContent = `\xB7 ${compact ?? exact}`;
25921
+ countdown.title = exact;
25922
+ countdown.style.fontSize = "11px";
25923
+ countdown.style.color = "color-mix(in srgb, currentColor 52%, transparent)";
25924
+ countdown.style.whiteSpace = "nowrap";
25925
+ left.append(countdown);
25926
+ } else {
25927
+ left.title = exact;
25928
+ }
25929
+ }
25930
+ const percent2 = document.createElement("span");
25931
+ percent2.textContent = formatRendererCreditsPercent(remaining);
25932
+ percent2.style.fontSize = hero ? "22px" : "13px";
25933
+ percent2.style.fontWeight = hero ? "700" : "600";
25934
+ if (hero) {
25935
+ percent2.style.lineHeight = "1";
25936
+ percent2.style.marginTop = "-6px";
25937
+ }
25938
+ percent2.style.fontVariantNumeric = "tabular-nums";
25939
+ percent2.style.whiteSpace = "nowrap";
25940
+ percent2.style.color = color;
25941
+ top.append(left, percent2);
25942
+ row.append(top, renderCreditsBar(remaining, color, "4px"));
25943
+ return row;
25944
+ }
25416
25945
  function renderDetails2(popover, credits, locale) {
25417
25946
  const messages = rendererCreditsMessages(locale);
25418
25947
  if (credits.usedPercent === void 0) {
@@ -25431,19 +25960,65 @@ Codex Fast mode prioritizes requests and may increase usage.`
25431
25960
  popover.style.backgroundImage = `radial-gradient(160px 100px at 18% -10%, color-mix(in srgb, ${glowColor} 20%, transparent), transparent 70%)`;
25432
25961
  popover.setAttribute("aria-label", messages.details);
25433
25962
  popover.replaceChildren();
25434
- popover.append(renderCreditsHeader(credits, locale, messages));
25435
- const tiles = (credits.productUsage ?? []).map(
25436
- (product) => renderCreditsTile(
25437
- productLabel(product, locale),
25438
- product.usagePercent,
25439
- locale,
25440
- messages,
25441
- product.resetsAt
25442
- )
25963
+ const sections = groupAccountCreditsWindows(
25964
+ credits,
25965
+ locale,
25966
+ (period) => creditsPeriodLabel(period, locale),
25967
+ (period) => compactPeriodLabel(period, locale)
25443
25968
  );
25444
- const lastTile = tiles.at(-1);
25445
- if (lastTile) lastTile.style.marginBottom = "0";
25446
- popover.append(...tiles);
25969
+ const firstScopedIndex = sections.findIndex((section) => section.title !== void 0);
25970
+ if (firstScopedIndex === -1) {
25971
+ popover.append(renderCreditsHeader(credits, locale, messages));
25972
+ const tiles = (credits.productUsage ?? []).map(
25973
+ (product) => renderCreditsTile(
25974
+ productLabel(product, locale),
25975
+ product.usagePercent,
25976
+ locale,
25977
+ messages,
25978
+ product.resetsAt
25979
+ )
25980
+ );
25981
+ const lastTile = tiles.at(-1);
25982
+ if (lastTile) lastTile.style.marginBottom = "0";
25983
+ popover.append(...tiles);
25984
+ return;
25985
+ }
25986
+ sections.forEach((section, sectionIndex) => {
25987
+ const group = document.createElement("div");
25988
+ if (sectionIndex > 0) {
25989
+ group.style.marginTop = "11px";
25990
+ group.style.paddingTop = "10px";
25991
+ group.style.borderTop = "1px solid color-mix(in srgb, currentColor 12%, transparent)";
25992
+ }
25993
+ if (section.title) {
25994
+ const heading = document.createElement("div");
25995
+ heading.textContent = section.title;
25996
+ heading.style.marginBottom = "7px";
25997
+ heading.style.fontSize = "12px";
25998
+ heading.style.fontWeight = "600";
25999
+ group.append(heading);
26000
+ }
26001
+ const tiles = section.windows.map(
26002
+ (window2, windowIndex) => section.title ? renderCompactCreditsRow(
26003
+ window2.label,
26004
+ window2.usedPercent,
26005
+ locale,
26006
+ messages,
26007
+ window2.resetsAt,
26008
+ sectionIndex === firstScopedIndex && windowIndex === 0
26009
+ ) : renderCreditsTile(
26010
+ window2.scopeLabel ? `${window2.scopeLabel} \xB7 ${window2.label}` : window2.label,
26011
+ window2.usedPercent,
26012
+ locale,
26013
+ messages,
26014
+ window2.resetsAt
26015
+ )
26016
+ );
26017
+ const lastTile = tiles.at(-1);
26018
+ if (lastTile) lastTile.style.marginBottom = "0";
26019
+ group.append(...tiles);
26020
+ popover.append(group);
26021
+ });
25447
26022
  }
25448
26023
  function popoverIsOpen2(popover) {
25449
26024
  try {
@@ -25470,6 +26045,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
25470
26045
  control.trigger.setAttribute("aria-expanded", "false");
25471
26046
  }
25472
26047
  function openPopover2(control) {
26048
+ refreshResetLines(control.popover);
25473
26049
  positionPopover2(control);
25474
26050
  control.popover.hidden = false;
25475
26051
  if (typeof control.popover.showPopover === "function" && !popoverIsOpen2(control.popover)) {
@@ -37895,19 +38471,20 @@ ${detail}` : ""}`
37895
38471
  }
37896
38472
  var RENDERER_SETTINGS_NAV_SECTIONS = [
37897
38473
  {
37898
- id: "connection",
37899
- pageIds: [
37900
- "connections",
37901
- "mobile-web",
37902
- "remote-connections",
37903
- "accounts",
37904
- "session-import",
37905
- "usage-statistics"
37906
- ]
38474
+ id: "agents",
38475
+ pageIds: ["connections", "plugins"]
38476
+ },
38477
+ {
38478
+ id: "access",
38479
+ pageIds: ["accounts", "remote-connections", "mobile-web"]
38480
+ },
38481
+ {
38482
+ id: "activity",
38483
+ pageIds: ["session-import", "usage-statistics", "harness-schedules"]
37907
38484
  },
37908
38485
  {
37909
38486
  id: "general",
37910
- pageIds: ["appearance", "plugins", "updates"]
38487
+ pageIds: ["appearance", "updates"]
37911
38488
  },
37912
38489
  {
37913
38490
  id: "other",
@@ -37915,7 +38492,9 @@ ${detail}` : ""}`
37915
38492
  }
37916
38493
  ];
37917
38494
  function rendererSettingsNavSectionLabel(sectionId, messages) {
37918
- if (sectionId === "connection") return messages.connectionSection;
38495
+ if (sectionId === "agents") return messages.agentsSection;
38496
+ if (sectionId === "access") return messages.accessSection;
38497
+ if (sectionId === "activity") return messages.activitySection;
37919
38498
  if (sectionId === "general") return messages.generalSection;
37920
38499
  return messages.otherSection;
37921
38500
  }
@@ -40051,6 +40630,7 @@ ${detail}` : ""}`
40051
40630
  background: var(--settings-surface);
40052
40631
  border: 1px solid var(--settings-border);
40053
40632
  border-radius: 10px;
40633
+ overflow-anchor: none;
40054
40634
  }
40055
40635
 
40056
40636
  .settings-connection-inspector__header {