@codexhost/cli-darwin-x64 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +24 -3
- package/app/console-web.js +1095 -682
- package/app/desktop-controller.mjs +40 -4
- package/app/host-runtime.mjs +1572 -1120
- package/app/plugins/antigravity/plugin.mjs +8753 -4274
- package/app/plugins/claude-code/plugin.mjs +26 -3
- package/app/plugins/codebuddy/plugin.mjs +41 -5
- package/app/plugins/codex-usage/plugin.mjs +26 -3
- package/app/plugins/copilot/plugin.mjs +26 -3
- package/app/plugins/cursor-cli/plugin.mjs +26 -3
- package/app/plugins/deepseek-harness/plugin.mjs +26 -3
- package/app/plugins/devin/plugin.mjs +25 -3
- package/app/plugins/grok/plugin.mjs +26 -3
- package/app/plugins/hermes/plugin.mjs +25 -3
- package/app/plugins/kimi-code/plugin.mjs +26 -3
- package/app/plugins/kiro-cli/plugin.mjs +26 -3
- package/app/plugins/omp/plugin.mjs +44 -6
- package/app/plugins/opencode/plugin.mjs +26 -3
- package/app/plugins/pi/plugin.mjs +45 -6
- package/app/plugins/qoder/plugin.mjs +48 -4
- package/app/plugins/qoder-cn/plugin.mjs +48 -4
- package/app/plugins/qwen-code/plugin.mjs +26 -3
- package/app/plugins/workbuddy/plugin.mjs +45 -8
- package/app/plugins/zcode/plugin.mjs +26 -3
- package/app/renderer-extension.js +1411 -737
- package/app/web/assets/index-D6-hvggd.css +1 -0
- package/app/web/assets/index-D85gPBbQ.js +201 -0
- package/app/web/assets/langs/{graphql-B8vkg11W.js → graphql-ChAeyPkT.js} +1 -1
- package/app/web/assets/langs/{http-DmoDEjMt.js → http-BvreBIbD.js} +1 -1
- package/app/web/assets/langs/{php-DJ5ovfAM.js → php-D8omCIuJ.js} +1 -1
- package/app/web/assets/langs/{rst-U5-R5x3p.js → rst-Do7RLLCS.js} +1 -1
- package/app/web/assets/langs/{ruby-VKVsnS0H.js → ruby-rH_O_vse.js} +1 -1
- package/app/web/assets/langs/{svelte-C20lOv9V.js → svelte-xZy73wAj.js} +1 -1
- package/app/web/assets/langs/{vue-z6Y-lzP-.js → vue-C4DW8agZ.js} +1 -1
- package/app/web/assets/{vendor-dSL872WO.js → vendor-C9g2bw8s.js} +3 -3
- package/app/web/codexhost-settings.js +1101 -684
- package/app/web/index.html +4 -3
- package/app/web/plugins/deepseek-ai__dsh-api-gateway/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +8 -8
- package/app/web/plugins/deepseek-ai__dsh-client-connection/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +74 -69
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +3 -3
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +13 -13
- package/app/web/plugins/deepseek-ai__dsh-client-ui-session/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
- package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +7 -7
- package/app/web-modules/server.mjs +138 -70
- package/bin/codexhost +0 -0
- package/libexec/codexhost-shim +0 -0
- package/libexec/codexhost-updater +0 -0
- package/package.json +1 -1
- package/app/web/assets/index-BNQIOOHE.css +0 -1
- package/app/web/assets/index-Feo4BkqN.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.literal(3).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)]).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
|
-
|
|
14930
|
+
// Unversioned 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 === 3)).optional(),
|
|
14932
|
+
// Retain independent TTFT facts when dropping incompatible speed measurements.
|
|
14933
|
+
outputTokensPerSecond: usageMeasurementSchema.refine((value) => value.version === 3).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(),
|
|
@@ -15360,6 +15373,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
15360
15373
|
delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
|
|
15361
15374
|
}).strict();
|
|
15362
15375
|
|
|
15376
|
+
// ../shared-contracts/dist/thread-archive-confirm.js
|
|
15377
|
+
var threadArchiveConfirmParamsSchema = external_exports.object({ threadId: hostThreadIdSchema }).strict();
|
|
15378
|
+
var threadArchiveConfirmResultSchema = external_exports.object({ confirmed: external_exports.boolean() }).strict();
|
|
15379
|
+
|
|
15363
15380
|
// ../shared-contracts/dist/client-channel.js
|
|
15364
15381
|
var CLIENT_CHANNEL_VERSION = 1;
|
|
15365
15382
|
var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
|
|
@@ -15499,7 +15516,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
15499
15516
|
/** Current interruptible Host Turn, including command Turns omitted from client history. */
|
|
15500
15517
|
activeTurnId: external_exports.string().min(1).nullable().optional(),
|
|
15501
15518
|
/** Most recent explicit command in this Host process; not native conversation history. */
|
|
15502
|
-
command: external_exports.object({
|
|
15519
|
+
command: external_exports.object({
|
|
15520
|
+
name: external_exports.string().min(1),
|
|
15521
|
+
turn: clientTurnSchema,
|
|
15522
|
+
/** First ordinary Turn started after this command; its retained result is not a new event. */
|
|
15523
|
+
subsequentTurnId: external_exports.string().min(1).optional()
|
|
15524
|
+
}).optional(),
|
|
15503
15525
|
thread: external_exports.object({
|
|
15504
15526
|
id: external_exports.string().min(1),
|
|
15505
15527
|
cwd: external_exports.string(),
|
|
@@ -15750,7 +15772,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
15750
15772
|
quotaUntil: external_exports.string().optional()
|
|
15751
15773
|
}).strict().optional()
|
|
15752
15774
|
}).strict();
|
|
15753
|
-
var webLocalAccessRequiredDetailsSchema = external_exports.object({ url: external_exports.string() }).strict();
|
|
15754
15775
|
|
|
15755
15776
|
// ../shared-contracts/dist/delegation-read.js
|
|
15756
15777
|
var REMOTE_THREAD_REPLY_MAX_BYTES = 16 * 1024 * 1024;
|
|
@@ -15951,6 +15972,135 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
15951
15972
|
...window2.localizations ? { localizations: window2.localizations } : {}
|
|
15952
15973
|
}, locale).label;
|
|
15953
15974
|
}
|
|
15975
|
+
function periodOrder(periodType) {
|
|
15976
|
+
if (periodType === "five_hour")
|
|
15977
|
+
return 0;
|
|
15978
|
+
if (periodType === "seven_day")
|
|
15979
|
+
return 1;
|
|
15980
|
+
if (periodType === "weekly")
|
|
15981
|
+
return 2;
|
|
15982
|
+
if (periodType === "monthly")
|
|
15983
|
+
return 3;
|
|
15984
|
+
return 4;
|
|
15985
|
+
}
|
|
15986
|
+
function groupAccountCreditsWindows(credits, locale, periodLabel, groupedPeriodLabel = periodLabel) {
|
|
15987
|
+
const entries = [
|
|
15988
|
+
{
|
|
15989
|
+
label: credits.label,
|
|
15990
|
+
periodType: credits.periodType,
|
|
15991
|
+
scope: credits.scope,
|
|
15992
|
+
localizations: credits.localizations,
|
|
15993
|
+
usedPercent: credits.usedPercent,
|
|
15994
|
+
used: credits.used,
|
|
15995
|
+
limit: credits.limit,
|
|
15996
|
+
unit: credits.unit,
|
|
15997
|
+
resetsAt: credits.resetsAt,
|
|
15998
|
+
isPrimary: true
|
|
15999
|
+
},
|
|
16000
|
+
...(credits.productUsage ?? []).map((item) => ({
|
|
16001
|
+
product: item.product,
|
|
16002
|
+
periodType: item.periodType,
|
|
16003
|
+
scope: item.scope,
|
|
16004
|
+
localizations: item.localizations,
|
|
16005
|
+
usedPercent: item.usagePercent,
|
|
16006
|
+
used: item.used,
|
|
16007
|
+
limit: item.limit,
|
|
16008
|
+
unit: item.unit,
|
|
16009
|
+
resetsAt: item.resetsAt,
|
|
16010
|
+
isPrimary: false
|
|
16011
|
+
}))
|
|
16012
|
+
];
|
|
16013
|
+
const scopeCounts = /* @__PURE__ */ new Map();
|
|
16014
|
+
for (const entry of entries) {
|
|
16015
|
+
if (entry.scope)
|
|
16016
|
+
scopeCounts.set(entry.scope.id, (scopeCounts.get(entry.scope.id) ?? 0) + 1);
|
|
16017
|
+
}
|
|
16018
|
+
const sections = /* @__PURE__ */ new Map();
|
|
16019
|
+
for (const entry of entries) {
|
|
16020
|
+
const groupedScope = entry.scope && (scopeCounts.get(entry.scope.id) ?? 0) >= 2 ? entry.scope : void 0;
|
|
16021
|
+
const key = groupedScope ? `scope:${groupedScope.id}` : "default";
|
|
16022
|
+
let section = sections.get(key);
|
|
16023
|
+
if (!section) {
|
|
16024
|
+
section = groupedScope ? {
|
|
16025
|
+
id: groupedScope.id,
|
|
16026
|
+
title: localizeHarnessPresentation(groupedScope, locale).label,
|
|
16027
|
+
windows: []
|
|
16028
|
+
} : { windows: [] };
|
|
16029
|
+
sections.set(key, section);
|
|
16030
|
+
}
|
|
16031
|
+
const inlineScope = !groupedScope && entry.scope && entry.periodType && entry.periodType !== "unknown" ? localizeHarnessPresentation(entry.scope, locale).label : void 0;
|
|
16032
|
+
const label = groupedScope && entry.periodType && entry.periodType !== "unknown" ? groupedPeriodLabel(entry.periodType) : inlineScope && entry.periodType && entry.periodType !== "unknown" ? periodLabel(entry.periodType) : accountCreditsWindowLabel(entry, locale, periodLabel);
|
|
16033
|
+
section.windows.push({
|
|
16034
|
+
order: groupedScope ? periodOrder(entry.periodType) : 0,
|
|
16035
|
+
window: {
|
|
16036
|
+
label,
|
|
16037
|
+
...inlineScope ? { scopeLabel: inlineScope } : {},
|
|
16038
|
+
usedPercent: entry.usedPercent,
|
|
16039
|
+
...entry.used === void 0 ? {} : { used: entry.used },
|
|
16040
|
+
...entry.limit === void 0 ? {} : { limit: entry.limit },
|
|
16041
|
+
...entry.unit === void 0 ? {} : { unit: entry.unit },
|
|
16042
|
+
...entry.resetsAt === void 0 ? {} : { resetsAt: entry.resetsAt },
|
|
16043
|
+
isPrimary: entry.isPrimary
|
|
16044
|
+
}
|
|
16045
|
+
});
|
|
16046
|
+
}
|
|
16047
|
+
return [...sections.values()].map(({ windows, ...section }) => ({
|
|
16048
|
+
...section,
|
|
16049
|
+
windows: (section.title !== void 0 ? [...windows].sort((left, right) => left.order - right.order) : windows).map((item) => item.window)
|
|
16050
|
+
}));
|
|
16051
|
+
}
|
|
16052
|
+
function countdownMinutes(value, nowMs) {
|
|
16053
|
+
const timestamp = typeof value === "number" ? value * 1e3 : Date.parse(value);
|
|
16054
|
+
if (!Number.isFinite(timestamp))
|
|
16055
|
+
return null;
|
|
16056
|
+
return Math.max(0, Math.ceil((timestamp - nowMs) / 6e4));
|
|
16057
|
+
}
|
|
16058
|
+
function isChineseLocale(locale) {
|
|
16059
|
+
return locale === "zh-CN" || locale.startsWith("zh-");
|
|
16060
|
+
}
|
|
16061
|
+
function compactDurationText(minutes) {
|
|
16062
|
+
if (minutes >= 1440) {
|
|
16063
|
+
const days = Math.floor(minutes / 1440);
|
|
16064
|
+
const hours2 = Math.floor(minutes % 1440 / 60);
|
|
16065
|
+
return hours2 > 0 ? `${days}d${hours2}h` : `${days}d`;
|
|
16066
|
+
}
|
|
16067
|
+
const hours = Math.floor(minutes / 60);
|
|
16068
|
+
const mins = minutes % 60;
|
|
16069
|
+
if (hours > 0)
|
|
16070
|
+
return mins > 0 ? `${hours}h${mins}m` : `${hours}h`;
|
|
16071
|
+
return `${mins}m`;
|
|
16072
|
+
}
|
|
16073
|
+
function formatAccountCreditsResetCountdown(value, locale, nowMs = Date.now()) {
|
|
16074
|
+
const minutes = countdownMinutes(value, nowMs);
|
|
16075
|
+
if (minutes === null)
|
|
16076
|
+
return null;
|
|
16077
|
+
const chinese = isChineseLocale(locale);
|
|
16078
|
+
if (minutes === 0)
|
|
16079
|
+
return chinese ? "\u5373\u5C06\u91CD\u7F6E" : "Resets soon";
|
|
16080
|
+
if (minutes >= 1440) {
|
|
16081
|
+
const days = Math.floor(minutes / 1440);
|
|
16082
|
+
const hours2 = Math.floor(minutes % 1440 / 60);
|
|
16083
|
+
if (chinese)
|
|
16084
|
+
return hours2 > 0 ? `${days} \u5929 ${hours2} \u5C0F\u65F6\u540E\u91CD\u7F6E` : `${days} \u5929\u540E\u91CD\u7F6E`;
|
|
16085
|
+
return hours2 > 0 ? `Resets in ${days}d ${hours2}h` : `Resets in ${days}d`;
|
|
16086
|
+
}
|
|
16087
|
+
const hours = Math.floor(minutes / 60);
|
|
16088
|
+
const mins = minutes % 60;
|
|
16089
|
+
if (hours > 0) {
|
|
16090
|
+
if (chinese)
|
|
16091
|
+
return mins > 0 ? `${hours} \u5C0F\u65F6 ${mins} \u5206\u540E\u91CD\u7F6E` : `${hours} \u5C0F\u65F6\u540E\u91CD\u7F6E`;
|
|
16092
|
+
return mins > 0 ? `Resets in ${hours}h ${mins}m` : `Resets in ${hours}h`;
|
|
16093
|
+
}
|
|
16094
|
+
return chinese ? `${mins} \u5206\u949F\u540E\u91CD\u7F6E` : `Resets in ${mins}m`;
|
|
16095
|
+
}
|
|
16096
|
+
function formatAccountCreditsCompactCountdown(value, locale, nowMs = Date.now()) {
|
|
16097
|
+
const minutes = countdownMinutes(value, nowMs);
|
|
16098
|
+
if (minutes === null)
|
|
16099
|
+
return null;
|
|
16100
|
+
if (minutes === 0)
|
|
16101
|
+
return isChineseLocale(locale) ? "\u5373\u5C06\u91CD\u7F6E" : "Resets soon";
|
|
16102
|
+
return compactDurationText(minutes);
|
|
16103
|
+
}
|
|
15954
16104
|
|
|
15955
16105
|
// ../shared-contracts/dist/model-price-overrides.js
|
|
15956
16106
|
var MODEL_PRICE_OVERRIDES_GET_METHOD = "codexhost/usage/model-prices/get";
|
|
@@ -19091,6 +19241,37 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
19091
19241
|
return fallback;
|
|
19092
19242
|
}
|
|
19093
19243
|
|
|
19244
|
+
// src/settings/harness-version-messages.ts
|
|
19245
|
+
var harnessVersionEnglish = Object.freeze({
|
|
19246
|
+
locale: "en",
|
|
19247
|
+
unknown: "Unknown",
|
|
19248
|
+
trackingBranch: "Tracking branch (new commits)",
|
|
19249
|
+
notes: Object.freeze({
|
|
19250
|
+
"original-installer": "Use the original installer, package manager, or launcher to update this installation."
|
|
19251
|
+
})
|
|
19252
|
+
});
|
|
19253
|
+
var harnessVersionChinese = Object.freeze({
|
|
19254
|
+
locale: "zh-CN",
|
|
19255
|
+
unknown: "\u672A\u77E5",
|
|
19256
|
+
trackingBranch: "\u8DDF\u8E2A\u5206\u652F\uFF08\u6709\u65B0\u63D0\u4EA4\uFF09",
|
|
19257
|
+
notes: Object.freeze({
|
|
19258
|
+
"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"
|
|
19259
|
+
})
|
|
19260
|
+
});
|
|
19261
|
+
function harnessVersionLabel(state, messages) {
|
|
19262
|
+
if (!state) return "\u2014";
|
|
19263
|
+
if (state.latestVersionKind === "unknown" || state.latestVersion === "Unknown")
|
|
19264
|
+
return messages.unknown;
|
|
19265
|
+
if (state.latestVersionKind === "tracking-branch" || state.latestVersion === "Tracking branch (new commits)")
|
|
19266
|
+
return messages.trackingBranch;
|
|
19267
|
+
return state.latestVersion;
|
|
19268
|
+
}
|
|
19269
|
+
function harnessVersionNote(state, messages) {
|
|
19270
|
+
if (state?.notice) return localizeHarnessText(state.notice, messages.locale);
|
|
19271
|
+
const code = state?.messageCode;
|
|
19272
|
+
return code && Object.hasOwn(messages.notes, code) ? messages.notes[code] : void 0;
|
|
19273
|
+
}
|
|
19274
|
+
|
|
19094
19275
|
// ../../node_modules/lucide/dist/esm/icons/smartphone.mjs
|
|
19095
19276
|
var Smartphone = [
|
|
19096
19277
|
["rect", { width: "14", height: "20", x: "5", y: "2", rx: "2", ry: "2" }],
|
|
@@ -19564,273 +19745,474 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
19564
19745
|
return svg2;
|
|
19565
19746
|
}
|
|
19566
19747
|
|
|
19567
|
-
// src/settings/
|
|
19568
|
-
function
|
|
19569
|
-
|
|
19570
|
-
|
|
19571
|
-
|
|
19572
|
-
|
|
19573
|
-
|
|
19574
|
-
|
|
19575
|
-
|
|
19576
|
-
|
|
19577
|
-
|
|
19578
|
-
input.placeholder = messages.locale === "zh-CN" ? "\u5E94\u7528\u5B89\u88C5\u76EE\u5F55\u7684\u7EDD\u5BF9\u8DEF\u5F84" : "Absolute installation directory";
|
|
19579
|
-
input.setAttribute("aria-label", messages.launchPathLabel);
|
|
19580
|
-
label.append(input);
|
|
19581
|
-
const help = document2.createElement("p");
|
|
19582
|
-
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.";
|
|
19583
|
-
const actions = document2.createElement("div");
|
|
19584
|
-
actions.className = "settings-harness-launch__actions";
|
|
19585
|
-
const save = document2.createElement("button");
|
|
19586
|
-
save.type = "button";
|
|
19587
|
-
save.className = "settings-command-button";
|
|
19588
|
-
save.textContent = messages.launchPathSave;
|
|
19589
|
-
const reset = document2.createElement("button");
|
|
19590
|
-
reset.type = "button";
|
|
19591
|
-
reset.className = "settings-command-button settings-command-button--secondary";
|
|
19592
|
-
reset.textContent = messages.launchPathReset;
|
|
19593
|
-
const status = document2.createElement("p");
|
|
19594
|
-
status.setAttribute("role", "status");
|
|
19595
|
-
status.setAttribute("aria-live", "polite");
|
|
19596
|
-
actions.append(save, reset);
|
|
19597
|
-
section.append(label, help, actions, status);
|
|
19598
|
-
let busy = true;
|
|
19599
|
-
let loaded = false;
|
|
19600
|
-
const controls = () => {
|
|
19601
|
-
input.disabled = busy || !loaded;
|
|
19602
|
-
save.disabled = busy || !loaded || !input.value.trim();
|
|
19603
|
-
reset.disabled = busy || !loaded;
|
|
19604
|
-
};
|
|
19605
|
-
const show = (value) => {
|
|
19606
|
-
input.value = value.path ?? "";
|
|
19607
|
-
status.textContent = value.restartRequired ? messages.launchPathRestart : value.path ? messages.launchPathSaved : messages.launchPathAutomatic;
|
|
19608
|
-
};
|
|
19609
|
-
const persist = async (value) => {
|
|
19610
|
-
if (busy || !loaded) return;
|
|
19611
|
-
busy = true;
|
|
19612
|
-
controls();
|
|
19613
|
-
status.textContent = messages.launchPathSaving;
|
|
19614
|
-
try {
|
|
19615
|
-
show(await settings.set(value));
|
|
19616
|
-
} catch {
|
|
19617
|
-
status.textContent = messages.launchPathSaveError;
|
|
19618
|
-
} finally {
|
|
19619
|
-
busy = false;
|
|
19620
|
-
controls();
|
|
19621
|
-
}
|
|
19622
|
-
};
|
|
19623
|
-
input.addEventListener("input", controls);
|
|
19624
|
-
save.addEventListener("click", () => {
|
|
19625
|
-
if (input.value.trim()) void persist(input.value.trim());
|
|
19626
|
-
});
|
|
19627
|
-
reset.addEventListener("click", () => {
|
|
19628
|
-
void persist(null);
|
|
19629
|
-
});
|
|
19630
|
-
controls();
|
|
19631
|
-
status.textContent = messages.launchPathLoading;
|
|
19632
|
-
void settings.get().then((value) => {
|
|
19633
|
-
loaded = true;
|
|
19634
|
-
show(value);
|
|
19635
|
-
}).catch(() => {
|
|
19636
|
-
loaded = true;
|
|
19637
|
-
status.textContent = messages.launchPathLoadError;
|
|
19638
|
-
}).finally(() => {
|
|
19639
|
-
busy = false;
|
|
19640
|
-
controls();
|
|
19641
|
-
});
|
|
19642
|
-
return section;
|
|
19643
|
-
}
|
|
19644
|
-
|
|
19645
|
-
// src/settings/harness-installation-guides.ts
|
|
19646
|
-
function harnessHasInstallCommands(plugin) {
|
|
19647
|
-
return (plugin?.installation?.commands.length ?? 0) > 0;
|
|
19748
|
+
// src/settings/connection-row.ts
|
|
19749
|
+
function connectionStatusLabel(availability, messages, hasError = false) {
|
|
19750
|
+
if (availability === "updating") return messages.connectionStatusUpdating;
|
|
19751
|
+
if (hasError && availability !== "notInstalled") return messages.connectionStatusError;
|
|
19752
|
+
if (availability === "ready") return messages.connectionStatusReady;
|
|
19753
|
+
if (availability === "checking") return messages.connectionStatusChecking;
|
|
19754
|
+
if (availability === "notInstalled") return messages.connectionStatusNotInstalled;
|
|
19755
|
+
if (availability === "unavailable" || availability === "error") {
|
|
19756
|
+
return availability === "error" ? messages.connectionStatusError : messages.connectionStatusUnavailable;
|
|
19757
|
+
}
|
|
19758
|
+
return availability === "installing" ? messages.connectionStatusInstalling : messages.connectionStatusUnsupported;
|
|
19648
19759
|
}
|
|
19649
|
-
function
|
|
19650
|
-
|
|
19651
|
-
|
|
19652
|
-
return
|
|
19653
|
-
|
|
19654
|
-
|
|
19655
|
-
|
|
19656
|
-
before: text(guide?.before),
|
|
19657
|
-
after: text(guide?.after)
|
|
19658
|
-
};
|
|
19760
|
+
function connectionStatusTone(availability, hasError = false) {
|
|
19761
|
+
if (availability === "updating") return "checking";
|
|
19762
|
+
if (hasError && availability !== "notInstalled") return "failed";
|
|
19763
|
+
if (availability === "ready") return "ready";
|
|
19764
|
+
if (availability === "checking" || availability === "installing") return "checking";
|
|
19765
|
+
if (availability === "notInstalled") return "setup";
|
|
19766
|
+
return "failed";
|
|
19659
19767
|
}
|
|
19660
|
-
|
|
19661
|
-
|
|
19662
|
-
|
|
19663
|
-
|
|
19664
|
-
|
|
19665
|
-
|
|
19666
|
-
|
|
19667
|
-
|
|
19668
|
-
|
|
19669
|
-
|
|
19670
|
-
panel.append(p);
|
|
19671
|
-
};
|
|
19672
|
-
if (hostId2 !== "local") {
|
|
19673
|
-
paragraph(zh ? "\u8BF7\u5728\u8FDC\u7A0B Host \u4E0A\u5B89\u88C5\u3002" : "Install on the remote Host.");
|
|
19768
|
+
function createConnectionIdentityIcon(document2, item, size) {
|
|
19769
|
+
const container = document2.createElement("span");
|
|
19770
|
+
container.className = item.agentSnapshot ? "settings-connection-row__mark settings-connection-row__mark--logo" : "settings-connection-row__mark";
|
|
19771
|
+
container.setAttribute("aria-hidden", "true");
|
|
19772
|
+
if (item.agentSnapshot) {
|
|
19773
|
+
container.append(
|
|
19774
|
+
createRendererAgentIcon(item.agentSnapshot.agent, size, document2, item.agentSnapshot.plugin)
|
|
19775
|
+
);
|
|
19776
|
+
} else {
|
|
19777
|
+
container.textContent = "CH";
|
|
19674
19778
|
}
|
|
19675
|
-
|
|
19676
|
-
|
|
19677
|
-
|
|
19678
|
-
|
|
19679
|
-
|
|
19680
|
-
|
|
19681
|
-
install2.disabled = installation.status !== "idle";
|
|
19682
|
-
install2.textContent = installation.status === "installing" ? messages.connectionStatusInstalling : installation.status === "checking" ? messages.connectionStatusChecking : zh ? "\u4E00\u952E\u5B89\u88C5" : "Install automatically";
|
|
19683
|
-
install2.addEventListener("click", () => {
|
|
19684
|
-
if (install2.disabled) return;
|
|
19685
|
-
install2.disabled = true;
|
|
19686
|
-
install2.textContent = messages.connectionStatusInstalling;
|
|
19687
|
-
installation.run();
|
|
19688
|
-
});
|
|
19689
|
-
if (guide.commands.length > 1) panel.append(install2);
|
|
19779
|
+
return container;
|
|
19780
|
+
}
|
|
19781
|
+
function sameElementChildren(container, next) {
|
|
19782
|
+
if (container.children.length !== next.length) return false;
|
|
19783
|
+
for (let index = 0; index < next.length; index++) {
|
|
19784
|
+
if (container.children[index] !== next[index]) return false;
|
|
19690
19785
|
}
|
|
19691
|
-
|
|
19692
|
-
|
|
19693
|
-
|
|
19694
|
-
|
|
19695
|
-
|
|
19696
|
-
|
|
19697
|
-
|
|
19698
|
-
code.textContent = command;
|
|
19699
|
-
pre.append(code);
|
|
19700
|
-
const button2 = document2.createElement("button");
|
|
19701
|
-
button2.type = "button";
|
|
19702
|
-
button2.className = "settings-command-button settings-command-button--secondary";
|
|
19703
|
-
button2.dataset.connectionAction = "copy-install";
|
|
19704
|
-
const copyLabel = zh ? "\u590D\u5236\u547D\u4EE4" : "Copy command";
|
|
19705
|
-
button2.setAttribute("aria-label", `${copyLabel}: ${terminal}`);
|
|
19706
|
-
button2.append(createRendererSettingsIcon("copy", 16), copyLabel);
|
|
19707
|
-
button2.addEventListener("click", () => copy(button2, command, copyLabel));
|
|
19708
|
-
const actions = document2.createElement("div");
|
|
19709
|
-
actions.className = "settings-harness-installation-actions";
|
|
19710
|
-
if (install2 && guide.commands.length === 1) actions.append(install2);
|
|
19711
|
-
actions.append(button2);
|
|
19712
|
-
block.append(label, pre, actions);
|
|
19713
|
-
panel.append(block);
|
|
19786
|
+
return true;
|
|
19787
|
+
}
|
|
19788
|
+
function reconcileElementChildren(container, next) {
|
|
19789
|
+
if (sameElementChildren(container, next)) return;
|
|
19790
|
+
if (typeof container.insertBefore !== "function") {
|
|
19791
|
+
container.replaceChildren(...next);
|
|
19792
|
+
return;
|
|
19714
19793
|
}
|
|
19715
|
-
|
|
19716
|
-
|
|
19717
|
-
|
|
19718
|
-
link.href = download2.url;
|
|
19719
|
-
link.target = "_blank";
|
|
19720
|
-
link.rel = "noopener noreferrer";
|
|
19721
|
-
link.textContent = zh ? "\u4E0B\u8F7D" : "Download";
|
|
19722
|
-
link.setAttribute("aria-label", `${link.textContent} ${download2.label}`);
|
|
19723
|
-
panel.append(link);
|
|
19794
|
+
const nextSet = new Set(next);
|
|
19795
|
+
for (const child of [...container.children]) {
|
|
19796
|
+
if (!nextSet.has(child)) child.remove();
|
|
19724
19797
|
}
|
|
19725
|
-
|
|
19726
|
-
|
|
19727
|
-
|
|
19728
|
-
|
|
19729
|
-
|
|
19730
|
-
|
|
19731
|
-
|
|
19732
|
-
panel.append(link);
|
|
19798
|
+
for (let index = 0; index < next.length; index++) {
|
|
19799
|
+
const desired = next[index];
|
|
19800
|
+
if (!desired) continue;
|
|
19801
|
+
const current = container.children[index] ?? null;
|
|
19802
|
+
if (current !== desired) {
|
|
19803
|
+
container.insertBefore(desired, current);
|
|
19804
|
+
}
|
|
19733
19805
|
}
|
|
19734
|
-
return panel;
|
|
19735
|
-
}
|
|
19736
|
-
|
|
19737
|
-
// src/settings/harness-install-store.ts
|
|
19738
|
-
function errorMessage(error51) {
|
|
19739
|
-
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.";
|
|
19740
19806
|
}
|
|
19741
|
-
function
|
|
19742
|
-
|
|
19807
|
+
function identityIconSignature(item) {
|
|
19808
|
+
if (!item.agentSnapshot) return "adapter";
|
|
19809
|
+
const plugin = item.agentSnapshot.plugin;
|
|
19810
|
+
return `${item.agentSnapshot.agent}:${String(plugin?.icon ?? "")}:${String(plugin?.iconStyle ?? "")}`;
|
|
19743
19811
|
}
|
|
19744
|
-
|
|
19745
|
-
|
|
19746
|
-
|
|
19747
|
-
|
|
19748
|
-
const
|
|
19749
|
-
|
|
19750
|
-
|
|
19751
|
-
|
|
19752
|
-
|
|
19753
|
-
|
|
19754
|
-
|
|
19755
|
-
|
|
19756
|
-
|
|
19757
|
-
|
|
19758
|
-
|
|
19759
|
-
|
|
19760
|
-
|
|
19761
|
-
|
|
19762
|
-
|
|
19763
|
-
|
|
19764
|
-
|
|
19765
|
-
|
|
19766
|
-
|
|
19767
|
-
|
|
19768
|
-
|
|
19769
|
-
|
|
19770
|
-
|
|
19771
|
-
|
|
19772
|
-
|
|
19773
|
-
|
|
19774
|
-
|
|
19812
|
+
function createConnectionRowView(document2, messages, groupable) {
|
|
19813
|
+
const row = document2.createElement("div");
|
|
19814
|
+
row.className = "settings-connection-row";
|
|
19815
|
+
row.setAttribute("role", "row");
|
|
19816
|
+
const identity3 = document2.createElement("div");
|
|
19817
|
+
identity3.className = "settings-connection-row__identity";
|
|
19818
|
+
identity3.setAttribute("role", "cell");
|
|
19819
|
+
let handle = null;
|
|
19820
|
+
if (groupable) {
|
|
19821
|
+
handle = document2.createElement("span");
|
|
19822
|
+
handle.className = "settings-connection-row__handle";
|
|
19823
|
+
handle.setAttribute("aria-hidden", "true");
|
|
19824
|
+
handle.append(createRendererSettingsIcon("grip-vertical", 15));
|
|
19825
|
+
identity3.append(handle);
|
|
19826
|
+
}
|
|
19827
|
+
let iconElement = null;
|
|
19828
|
+
let renderedIconKey = null;
|
|
19829
|
+
const label = document2.createElement("strong");
|
|
19830
|
+
const status = document2.createElement("span");
|
|
19831
|
+
status.className = "settings-connection-row__status";
|
|
19832
|
+
status.setAttribute("role", "cell");
|
|
19833
|
+
const action = document2.createElement("div");
|
|
19834
|
+
action.className = "settings-connection-row__action";
|
|
19835
|
+
action.setAttribute("role", "cell");
|
|
19836
|
+
row.append(identity3, status, action);
|
|
19837
|
+
let currentItem = null;
|
|
19838
|
+
let currentSelect = () => void 0;
|
|
19839
|
+
let currentGroup = null;
|
|
19840
|
+
let installButton = null;
|
|
19841
|
+
let viewErrorButton = null;
|
|
19842
|
+
let versionAvailableBadge = null;
|
|
19843
|
+
let updateButton = null;
|
|
19844
|
+
let groupToggleButton = null;
|
|
19845
|
+
let groupToggleSection = null;
|
|
19846
|
+
row.addEventListener("click", (event) => {
|
|
19847
|
+
const target2 = event.target;
|
|
19848
|
+
if (target2?.closest?.("a")) return;
|
|
19849
|
+
currentSelect();
|
|
19850
|
+
});
|
|
19851
|
+
row.addEventListener("keydown", (event) => {
|
|
19852
|
+
if (event.target?.closest?.("button, a")) return;
|
|
19853
|
+
if (event.key !== "Enter" && event.key !== " ") return;
|
|
19854
|
+
event.preventDefault();
|
|
19855
|
+
currentSelect();
|
|
19856
|
+
});
|
|
19857
|
+
if (groupable) {
|
|
19858
|
+
row.addEventListener("dragstart", (event) => currentGroup?.onDragStart(event));
|
|
19859
|
+
row.addEventListener("dragover", (event) => currentGroup?.onDragOver(event));
|
|
19860
|
+
row.addEventListener("dragleave", (event) => currentGroup?.onDragLeave(event));
|
|
19861
|
+
row.addEventListener("drop", (event) => currentGroup?.onDrop(event));
|
|
19862
|
+
row.addEventListener("dragend", (event) => currentGroup?.onDragEnd(event));
|
|
19863
|
+
}
|
|
19864
|
+
const setSelected = (selected) => {
|
|
19865
|
+
const nextSelected = String(selected);
|
|
19866
|
+
if (row.dataset.connectionSelected !== nextSelected) {
|
|
19867
|
+
row.dataset.connectionSelected = nextSelected;
|
|
19868
|
+
}
|
|
19869
|
+
const nextTabIndex = selected ? 0 : -1;
|
|
19870
|
+
if (row.tabIndex !== nextTabIndex) {
|
|
19871
|
+
row.tabIndex = nextTabIndex;
|
|
19872
|
+
}
|
|
19873
|
+
};
|
|
19874
|
+
return {
|
|
19875
|
+
element: row,
|
|
19876
|
+
setSelected,
|
|
19877
|
+
update(item, selected, select, group) {
|
|
19878
|
+
currentItem = item;
|
|
19879
|
+
currentSelect = select;
|
|
19880
|
+
currentGroup = group;
|
|
19881
|
+
if (row.dataset.connectionItem !== item.key) {
|
|
19882
|
+
row.dataset.connectionItem = item.key;
|
|
19883
|
+
}
|
|
19884
|
+
setSelected(selected);
|
|
19885
|
+
const nextIconKey = identityIconSignature(item);
|
|
19886
|
+
if (renderedIconKey !== nextIconKey || !iconElement) {
|
|
19887
|
+
renderedIconKey = nextIconKey;
|
|
19888
|
+
iconElement = createConnectionIdentityIcon(document2, item, 19);
|
|
19889
|
+
reconcileElementChildren(
|
|
19890
|
+
identity3,
|
|
19891
|
+
handle ? [handle, iconElement, label] : [iconElement, label]
|
|
19892
|
+
);
|
|
19775
19893
|
}
|
|
19776
|
-
|
|
19777
|
-
|
|
19778
|
-
|
|
19779
|
-
|
|
19780
|
-
|
|
19781
|
-
|
|
19894
|
+
if (handle && group && handle.title !== group.dragHandleTitle) {
|
|
19895
|
+
handle.title = group.dragHandleTitle;
|
|
19896
|
+
}
|
|
19897
|
+
if (label.textContent !== item.name) {
|
|
19898
|
+
label.textContent = item.name;
|
|
19899
|
+
}
|
|
19900
|
+
const tone = connectionStatusTone(item.availability, item.error !== null);
|
|
19901
|
+
if (status.dataset.connectionTone !== tone) {
|
|
19902
|
+
status.dataset.connectionTone = tone;
|
|
19903
|
+
}
|
|
19904
|
+
const statusText = item.error?.code === "authenticationRequired" ? messages.connectionLoginRequired : item.error?.code === "configurationRequired" ? messages.connectionConfigurationRequired : connectionStatusLabel(item.availability, messages, item.error !== null);
|
|
19905
|
+
if (status.textContent !== statusText) {
|
|
19906
|
+
status.textContent = statusText;
|
|
19907
|
+
}
|
|
19908
|
+
const nextActions = [];
|
|
19909
|
+
if (item.agentSnapshot?.availability === "notInstalled" && item.install) {
|
|
19910
|
+
if (!installButton) {
|
|
19911
|
+
const button2 = document2.createElement("button");
|
|
19912
|
+
button2.type = "button";
|
|
19913
|
+
button2.className = "settings-connection-install-link";
|
|
19914
|
+
button2.append(createRendererSettingsIcon("download", 17));
|
|
19915
|
+
button2.addEventListener("click", (event) => {
|
|
19916
|
+
event.stopPropagation();
|
|
19917
|
+
currentSelect();
|
|
19918
|
+
currentItem?.install?.();
|
|
19919
|
+
});
|
|
19920
|
+
installButton = button2;
|
|
19921
|
+
}
|
|
19922
|
+
installButton.disabled = item.availability === "installing" || item.availability === "checking";
|
|
19923
|
+
const installLabel = messages.connectionInstall;
|
|
19924
|
+
const ariaLabel = `${installLabel}: ${item.name}`;
|
|
19925
|
+
if (installButton.getAttribute("aria-label") !== ariaLabel) {
|
|
19926
|
+
installButton.setAttribute("aria-label", ariaLabel);
|
|
19927
|
+
}
|
|
19928
|
+
if (installButton.title !== installLabel) {
|
|
19929
|
+
installButton.title = installLabel;
|
|
19930
|
+
}
|
|
19931
|
+
nextActions.push(installButton);
|
|
19932
|
+
} else if (item.error) {
|
|
19933
|
+
if (!viewErrorButton) {
|
|
19934
|
+
const button2 = document2.createElement("button");
|
|
19935
|
+
button2.type = "button";
|
|
19936
|
+
button2.className = "settings-connection-view-error";
|
|
19937
|
+
button2.textContent = messages.connectionViewError;
|
|
19938
|
+
button2.addEventListener("click", (event) => {
|
|
19939
|
+
event.stopPropagation();
|
|
19940
|
+
currentSelect();
|
|
19941
|
+
});
|
|
19942
|
+
viewErrorButton = button2;
|
|
19943
|
+
}
|
|
19944
|
+
nextActions.push(viewErrorButton);
|
|
19945
|
+
}
|
|
19946
|
+
const version2 = item.version;
|
|
19947
|
+
if (version2?.state?.updateAvailable && !version2.updating) {
|
|
19948
|
+
if (!versionAvailableBadge) {
|
|
19949
|
+
const badge = document2.createElement("span");
|
|
19950
|
+
badge.className = "settings-connection-version-available";
|
|
19951
|
+
badge.textContent = messages.harnessVersionAvailable;
|
|
19952
|
+
versionAvailableBadge = badge;
|
|
19953
|
+
}
|
|
19954
|
+
const badgeTitle = `${messages.harnessVersionCurrent}: ${version2.state.currentVersion ?? "\u2014"}
|
|
19955
|
+
${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages.harnessVersion)}`;
|
|
19956
|
+
if (versionAvailableBadge.title !== badgeTitle) {
|
|
19957
|
+
versionAvailableBadge.title = badgeTitle;
|
|
19958
|
+
}
|
|
19959
|
+
nextActions.push(versionAvailableBadge);
|
|
19960
|
+
}
|
|
19961
|
+
if (version2?.state?.updateAvailable && version2.state.canUpdate) {
|
|
19962
|
+
if (!updateButton) {
|
|
19963
|
+
const button2 = document2.createElement("button");
|
|
19964
|
+
button2.type = "button";
|
|
19965
|
+
button2.className = "settings-connection-install-link";
|
|
19966
|
+
button2.dataset.connectionAction = "update";
|
|
19967
|
+
button2.append(createRendererSettingsIcon("download", 17));
|
|
19968
|
+
button2.addEventListener("click", (event) => {
|
|
19969
|
+
event.stopPropagation();
|
|
19970
|
+
if (button2.disabled) return;
|
|
19971
|
+
void currentItem?.version?.update();
|
|
19972
|
+
currentSelect();
|
|
19973
|
+
});
|
|
19974
|
+
updateButton = button2;
|
|
19975
|
+
}
|
|
19976
|
+
updateButton.disabled = version2.updating;
|
|
19977
|
+
if (updateButton.title !== messages.harnessVersionUpdate) {
|
|
19978
|
+
updateButton.title = messages.harnessVersionUpdate;
|
|
19979
|
+
}
|
|
19980
|
+
const updateAriaLabel = `${messages.harnessVersionUpdate}: ${item.name}`;
|
|
19981
|
+
if (updateButton.getAttribute("aria-label") !== updateAriaLabel) {
|
|
19982
|
+
updateButton.setAttribute("aria-label", updateAriaLabel);
|
|
19983
|
+
}
|
|
19984
|
+
nextActions.push(updateButton);
|
|
19985
|
+
}
|
|
19986
|
+
if (group) {
|
|
19987
|
+
if (!groupToggleButton) {
|
|
19988
|
+
const button2 = document2.createElement("button");
|
|
19989
|
+
button2.type = "button";
|
|
19990
|
+
button2.className = "settings-connection-row__group-toggle";
|
|
19991
|
+
button2.addEventListener("click", (event) => {
|
|
19992
|
+
event.stopPropagation();
|
|
19993
|
+
currentGroup?.toggleSection();
|
|
19994
|
+
});
|
|
19995
|
+
groupToggleButton = button2;
|
|
19996
|
+
}
|
|
19997
|
+
groupToggleButton.disabled = group.disabled;
|
|
19998
|
+
if (groupToggleButton.title !== group.moveLabel) {
|
|
19999
|
+
groupToggleButton.title = group.moveLabel;
|
|
20000
|
+
}
|
|
20001
|
+
if (groupToggleButton.getAttribute("aria-label") !== group.moveLabel) {
|
|
20002
|
+
groupToggleButton.setAttribute("aria-label", group.moveLabel);
|
|
20003
|
+
}
|
|
20004
|
+
if (groupToggleSection !== group.section) {
|
|
20005
|
+
groupToggleSection = group.section;
|
|
20006
|
+
groupToggleButton.replaceChildren(
|
|
20007
|
+
createRendererSettingsIcon(
|
|
20008
|
+
group.section === "main" ? "chevron-down" : "chevron-up",
|
|
20009
|
+
15
|
|
20010
|
+
)
|
|
20011
|
+
);
|
|
20012
|
+
}
|
|
20013
|
+
nextActions.push(groupToggleButton);
|
|
20014
|
+
}
|
|
20015
|
+
reconcileElementChildren(action, nextActions);
|
|
20016
|
+
if (group) {
|
|
20017
|
+
row.draggable = !group.disabled;
|
|
20018
|
+
if (row.dataset.connectionGroupSection !== group.section) {
|
|
20019
|
+
row.dataset.connectionGroupSection = group.section;
|
|
19782
20020
|
}
|
|
19783
|
-
} catch (error51) {
|
|
19784
|
-
failure ??= errorMessage(error51);
|
|
19785
20021
|
}
|
|
19786
|
-
if (failure) states2.set(id, { status: "error", error: failure });
|
|
19787
|
-
else states2.delete(id);
|
|
19788
|
-
notify2();
|
|
19789
20022
|
}
|
|
19790
20023
|
};
|
|
19791
20024
|
}
|
|
19792
|
-
|
|
19793
|
-
|
|
20025
|
+
|
|
20026
|
+
// src/settings/connection-updates.ts
|
|
20027
|
+
var sharedBatchStores = /* @__PURE__ */ new WeakMap();
|
|
20028
|
+
function getBatchStore(diagnostics) {
|
|
20029
|
+
if (!diagnostics) {
|
|
20030
|
+
return { batches: /* @__PURE__ */ new Map(), listeners: /* @__PURE__ */ new Set() };
|
|
20031
|
+
}
|
|
20032
|
+
let store = sharedBatchStores.get(diagnostics);
|
|
19794
20033
|
if (!store) {
|
|
19795
|
-
store =
|
|
19796
|
-
|
|
20034
|
+
store = { batches: /* @__PURE__ */ new Map(), listeners: /* @__PURE__ */ new Set() };
|
|
20035
|
+
sharedBatchStores.set(diagnostics, store);
|
|
19797
20036
|
}
|
|
19798
20037
|
return store;
|
|
19799
20038
|
}
|
|
19800
|
-
|
|
19801
|
-
|
|
19802
|
-
|
|
19803
|
-
|
|
19804
|
-
|
|
19805
|
-
|
|
19806
|
-
|
|
19807
|
-
|
|
19808
|
-
|
|
19809
|
-
|
|
19810
|
-
|
|
19811
|
-
|
|
19812
|
-
|
|
19813
|
-
|
|
19814
|
-
|
|
19815
|
-
|
|
19816
|
-
|
|
19817
|
-
|
|
19818
|
-
|
|
19819
|
-
|
|
19820
|
-
|
|
19821
|
-
|
|
19822
|
-
|
|
19823
|
-
|
|
19824
|
-
|
|
19825
|
-
|
|
19826
|
-
|
|
19827
|
-
|
|
19828
|
-
|
|
19829
|
-
|
|
20039
|
+
function createConnectionUpdates(document2, messages, signal, onChange, diagnostics = null) {
|
|
20040
|
+
const store = getBatchStore(diagnostics);
|
|
20041
|
+
const notify2 = () => {
|
|
20042
|
+
for (const listener of [...store.listeners]) listener();
|
|
20043
|
+
};
|
|
20044
|
+
if (!signal.aborted) {
|
|
20045
|
+
const listener = () => {
|
|
20046
|
+
if (!signal.aborted) onChange();
|
|
20047
|
+
};
|
|
20048
|
+
store.listeners.add(listener);
|
|
20049
|
+
signal.addEventListener(
|
|
20050
|
+
"abort",
|
|
20051
|
+
() => {
|
|
20052
|
+
store.listeners.delete(listener);
|
|
20053
|
+
},
|
|
20054
|
+
{ once: true }
|
|
20055
|
+
);
|
|
20056
|
+
}
|
|
20057
|
+
const eligible = (panels) => panels.filter((panel) => panel.state?.updateAvailable && panel.state.canUpdate);
|
|
20058
|
+
const start = async (hostId2, panels) => {
|
|
20059
|
+
if (signal.aborted || store.batches.get(hostId2)?.running) return;
|
|
20060
|
+
const targets = eligible(panels);
|
|
20061
|
+
if (!targets.length) return;
|
|
20062
|
+
const batch = { running: true, total: targets.length, succeeded: 0, failed: 0 };
|
|
20063
|
+
store.batches.set(hostId2, batch);
|
|
20064
|
+
notify2();
|
|
20065
|
+
await Promise.all(
|
|
20066
|
+
targets.map(async (panel) => {
|
|
20067
|
+
try {
|
|
20068
|
+
if (await panel.update()) batch.succeeded++;
|
|
20069
|
+
else batch.failed++;
|
|
20070
|
+
} catch {
|
|
20071
|
+
batch.failed++;
|
|
20072
|
+
}
|
|
20073
|
+
notify2();
|
|
20074
|
+
})
|
|
20075
|
+
);
|
|
20076
|
+
batch.running = false;
|
|
20077
|
+
notify2();
|
|
20078
|
+
};
|
|
20079
|
+
return {
|
|
20080
|
+
createControls(hostId2, panels) {
|
|
20081
|
+
let currentHostId = hostId2;
|
|
20082
|
+
let currentPanels = panels;
|
|
20083
|
+
let renderedLabel = null;
|
|
20084
|
+
const button2 = document2.createElement("button");
|
|
20085
|
+
button2.type = "button";
|
|
20086
|
+
button2.className = "settings-command-button settings-command-button--secondary settings-connection-update-all";
|
|
20087
|
+
button2.dataset.connectionAction = "update-all";
|
|
20088
|
+
button2.title = messages.harnessUpdateAllDescription;
|
|
20089
|
+
button2.addEventListener("click", () => {
|
|
20090
|
+
if (!button2.disabled) void start(currentHostId, currentPanels);
|
|
20091
|
+
});
|
|
20092
|
+
const result = document2.createElement("p");
|
|
20093
|
+
result.className = "settings-connection-update-result";
|
|
20094
|
+
result.setAttribute("role", "status");
|
|
20095
|
+
const update = (nextHostId, nextPanels) => {
|
|
20096
|
+
currentHostId = nextHostId;
|
|
20097
|
+
currentPanels = nextPanels;
|
|
20098
|
+
const batch = store.batches.get(nextHostId);
|
|
20099
|
+
const count3 = eligible(nextPanels).length;
|
|
20100
|
+
button2.disabled = signal.aborted || Boolean(batch?.running) || !count3;
|
|
20101
|
+
const label = batch?.running ? `${messages.harnessUpdateAllProgress} ${batch.succeeded + batch.failed}/${batch.total}` : count3 ? `${messages.harnessUpdateAll} (${count3})` : messages.harnessUpdateAll;
|
|
20102
|
+
if (renderedLabel !== label) {
|
|
20103
|
+
renderedLabel = label;
|
|
20104
|
+
button2.replaceChildren(createRendererSettingsIcon("download", 15), label);
|
|
20105
|
+
}
|
|
20106
|
+
const hidden = !batch || batch.running;
|
|
20107
|
+
result.hidden = hidden;
|
|
20108
|
+
const resultText = batch && !batch.running ? messages.harnessUpdateAllResult.replace("{succeeded}", String(batch.succeeded)).replace("{failed}", String(batch.failed)) : "";
|
|
20109
|
+
if (result.textContent !== resultText) {
|
|
20110
|
+
result.textContent = resultText;
|
|
20111
|
+
}
|
|
20112
|
+
};
|
|
20113
|
+
update(hostId2, panels);
|
|
20114
|
+
return { button: button2, result, update };
|
|
20115
|
+
}
|
|
20116
|
+
};
|
|
19830
20117
|
}
|
|
19831
20118
|
|
|
19832
20119
|
// src/settings/harness-version-panel.ts
|
|
19833
|
-
function
|
|
20120
|
+
function isUnsupportedInstallationError(error51) {
|
|
20121
|
+
return typeof error51 === "object" && error51 !== null && "code" in error51 && (error51.code === -32601 || error51.code === -32078);
|
|
20122
|
+
}
|
|
20123
|
+
function createHarnessVersionSession(client, options) {
|
|
20124
|
+
let state;
|
|
20125
|
+
let statusKind = "checking";
|
|
20126
|
+
let checkPromise = null;
|
|
20127
|
+
let updatePromise = null;
|
|
20128
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
20129
|
+
const signal = options?.signal;
|
|
20130
|
+
const notify2 = (pageChange) => {
|
|
20131
|
+
if (signal?.aborted) return;
|
|
20132
|
+
for (const listener of [...listeners]) listener(pageChange);
|
|
20133
|
+
};
|
|
20134
|
+
const check2 = () => {
|
|
20135
|
+
if (signal?.aborted || updatePromise) return Promise.resolve();
|
|
20136
|
+
if (checkPromise) return checkPromise;
|
|
20137
|
+
statusKind = "checking";
|
|
20138
|
+
notify2(false);
|
|
20139
|
+
checkPromise = (async () => {
|
|
20140
|
+
try {
|
|
20141
|
+
const result = await client.run("check");
|
|
20142
|
+
if (signal?.aborted || updatePromise) return;
|
|
20143
|
+
state = result;
|
|
20144
|
+
statusKind = "idle";
|
|
20145
|
+
} catch (error51) {
|
|
20146
|
+
if (signal?.aborted || updatePromise) return;
|
|
20147
|
+
statusKind = isUnsupportedInstallationError(error51) ? "unsupported" : "failed";
|
|
20148
|
+
if (state) state = { ...state, canUpdate: false };
|
|
20149
|
+
} finally {
|
|
20150
|
+
checkPromise = null;
|
|
20151
|
+
if (!signal?.aborted && !updatePromise) {
|
|
20152
|
+
notify2(true);
|
|
20153
|
+
}
|
|
20154
|
+
}
|
|
20155
|
+
})();
|
|
20156
|
+
return checkPromise;
|
|
20157
|
+
};
|
|
20158
|
+
const update = () => {
|
|
20159
|
+
if (updatePromise) return updatePromise;
|
|
20160
|
+
updatePromise = (async () => {
|
|
20161
|
+
if (signal?.aborted) return false;
|
|
20162
|
+
if (checkPromise) await checkPromise;
|
|
20163
|
+
if (signal?.aborted || statusKind === "unsupported" || !state?.canUpdate || !state.updateAvailable) {
|
|
20164
|
+
return false;
|
|
20165
|
+
}
|
|
20166
|
+
statusKind = "updating";
|
|
20167
|
+
notify2(true);
|
|
20168
|
+
try {
|
|
20169
|
+
const result = await client.run("update");
|
|
20170
|
+
if (signal?.aborted) return false;
|
|
20171
|
+
state = result;
|
|
20172
|
+
statusKind = !result.canUpdate ? "updated" : result.updateAvailable ? "failed" : "updated";
|
|
20173
|
+
return result.canUpdate && !result.updateAvailable;
|
|
20174
|
+
} catch (error51) {
|
|
20175
|
+
if (signal?.aborted) return false;
|
|
20176
|
+
statusKind = isUnsupportedInstallationError(error51) ? "unsupported" : "failed";
|
|
20177
|
+
if (state) state = { ...state, canUpdate: false };
|
|
20178
|
+
return false;
|
|
20179
|
+
} finally {
|
|
20180
|
+
updatePromise = null;
|
|
20181
|
+
if (!signal?.aborted) {
|
|
20182
|
+
notify2(true);
|
|
20183
|
+
}
|
|
20184
|
+
}
|
|
20185
|
+
})();
|
|
20186
|
+
return updatePromise;
|
|
20187
|
+
};
|
|
20188
|
+
return {
|
|
20189
|
+
get state() {
|
|
20190
|
+
return state;
|
|
20191
|
+
},
|
|
20192
|
+
get statusKind() {
|
|
20193
|
+
return statusKind;
|
|
20194
|
+
},
|
|
20195
|
+
get updating() {
|
|
20196
|
+
return statusKind === "updating";
|
|
20197
|
+
},
|
|
20198
|
+
prepareMount() {
|
|
20199
|
+
if (updatePromise || checkPromise) return false;
|
|
20200
|
+
statusKind = "checking";
|
|
20201
|
+
return true;
|
|
20202
|
+
},
|
|
20203
|
+
check: check2,
|
|
20204
|
+
update,
|
|
20205
|
+
subscribe(listener) {
|
|
20206
|
+
listeners.add(listener);
|
|
20207
|
+
return () => {
|
|
20208
|
+
listeners.delete(listener);
|
|
20209
|
+
};
|
|
20210
|
+
}
|
|
20211
|
+
};
|
|
20212
|
+
}
|
|
20213
|
+
function createHarnessVersionPanel(document2, messages, signal, agent, client, onChange = () => void 0, sharedSession) {
|
|
20214
|
+
const session = sharedSession ?? createHarnessVersionSession(client, { signal });
|
|
20215
|
+
const shouldScheduleCheck = session.prepareMount();
|
|
19834
20216
|
const panel = document2.createElement("section");
|
|
19835
20217
|
panel.className = "settings-harness-version";
|
|
19836
20218
|
panel.dataset.harnessVersion = agent;
|
|
@@ -19854,15 +20236,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
19854
20236
|
note.textContent = messages.harnessVersionNote;
|
|
19855
20237
|
actions.append(update);
|
|
19856
20238
|
panel.append(heading, versions, status, actions, note);
|
|
19857
|
-
let state;
|
|
19858
|
-
let busy = false;
|
|
19859
|
-
let updating = false;
|
|
19860
|
-
let unsupported = false;
|
|
19861
|
-
let updatePromise = null;
|
|
19862
20239
|
const render = () => {
|
|
20240
|
+
const state = session.state;
|
|
20241
|
+
const statusKind = session.statusKind;
|
|
20242
|
+
const busy = statusKind === "checking" || statusKind === "updating";
|
|
19863
20243
|
heading.textContent = state?.versionKind === "application" ? messages.harnessVersionApplicationTitle : messages.harnessVersionTitle;
|
|
19864
20244
|
current.textContent = `${messages.harnessVersionCurrent}: ${state?.currentVersion ?? "\u2014"}`;
|
|
19865
20245
|
latest.textContent = `${messages.harnessVersionLatest}: ${harnessVersionLabel(state, messages.harnessVersion)}`;
|
|
20246
|
+
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 : "";
|
|
19866
20247
|
update.disabled = busy || signal.aborted || !state?.canUpdate || !state.updateAvailable;
|
|
19867
20248
|
const manualUrl = !state?.canUpdate && state?.updateAvailable ? state.manualUpdateUrl : void 0;
|
|
19868
20249
|
actions.replaceChildren(update);
|
|
@@ -19881,99 +20262,92 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
19881
20262
|
const detail = harnessVersionNote(state, messages.harnessVersion);
|
|
19882
20263
|
note.textContent = detail ? !state?.canUpdate ? detail : `${detail} ${messages.harnessVersionNote}` : messages.harnessVersionNote;
|
|
19883
20264
|
};
|
|
19884
|
-
|
|
19885
|
-
if (
|
|
19886
|
-
|
|
19887
|
-
|
|
19888
|
-
|
|
19889
|
-
onChange();
|
|
19890
|
-
status.textContent = action === "check" ? messages.harnessVersionChecking : messages.harnessVersionUpdating;
|
|
20265
|
+
update.addEventListener("click", () => {
|
|
20266
|
+
if (!signal.aborted) void session.update();
|
|
20267
|
+
});
|
|
20268
|
+
const unsubscribe = session.subscribe((pageChange) => {
|
|
20269
|
+
if (signal.aborted) return;
|
|
19891
20270
|
render();
|
|
19892
|
-
|
|
19893
|
-
|
|
19894
|
-
if (signal.aborted) return false;
|
|
19895
|
-
state = result;
|
|
19896
|
-
status.textContent = !result.canUpdate ? messages.harnessVersionManual : action === "update" ? result.updateAvailable ? messages.harnessVersionFailed : messages.harnessVersionUpdated : "";
|
|
19897
|
-
return result.canUpdate && !result.updateAvailable;
|
|
19898
|
-
} catch (error51) {
|
|
19899
|
-
if (signal.aborted) return false;
|
|
19900
|
-
unsupported = typeof error51 === "object" && error51 !== null && "code" in error51 && (error51.code === -32601 || error51.code === -32078);
|
|
19901
|
-
status.textContent = unsupported ? messages.harnessVersionUnsupported : messages.harnessVersionFailed;
|
|
19902
|
-
if (state) state = { ...state, canUpdate: false };
|
|
19903
|
-
return false;
|
|
19904
|
-
} finally {
|
|
19905
|
-
busy = false;
|
|
19906
|
-
updating = false;
|
|
19907
|
-
if (!signal.aborted) {
|
|
19908
|
-
render();
|
|
19909
|
-
onChange();
|
|
19910
|
-
}
|
|
19911
|
-
}
|
|
19912
|
-
};
|
|
19913
|
-
const updateVersion = () => {
|
|
19914
|
-
updatePromise ??= run("update").finally(() => {
|
|
19915
|
-
updatePromise = null;
|
|
19916
|
-
});
|
|
19917
|
-
return updatePromise;
|
|
19918
|
-
};
|
|
19919
|
-
update.addEventListener("click", () => void updateVersion());
|
|
20271
|
+
if (pageChange) onChange();
|
|
20272
|
+
});
|
|
19920
20273
|
const owner = document2.defaultView;
|
|
19921
20274
|
let checkFrame = null;
|
|
19922
20275
|
let checkTimer = null;
|
|
19923
20276
|
signal.addEventListener(
|
|
19924
20277
|
"abort",
|
|
19925
20278
|
() => {
|
|
20279
|
+
unsubscribe();
|
|
19926
20280
|
if (checkFrame !== null) owner?.cancelAnimationFrame(checkFrame);
|
|
19927
20281
|
if (checkTimer !== null) owner?.clearTimeout(checkTimer);
|
|
19928
20282
|
render();
|
|
19929
20283
|
},
|
|
19930
20284
|
{ once: true }
|
|
19931
20285
|
);
|
|
19932
|
-
status.textContent = messages.harnessVersionChecking;
|
|
19933
20286
|
render();
|
|
19934
|
-
if (!signal.aborted
|
|
19935
|
-
|
|
19936
|
-
checkFrame =
|
|
19937
|
-
|
|
19938
|
-
|
|
19939
|
-
checkTimer =
|
|
19940
|
-
|
|
19941
|
-
|
|
19942
|
-
|
|
19943
|
-
|
|
19944
|
-
|
|
20287
|
+
if (shouldScheduleCheck && !signal.aborted) {
|
|
20288
|
+
if (owner?.requestAnimationFrame) {
|
|
20289
|
+
checkFrame = owner.requestAnimationFrame(() => {
|
|
20290
|
+
checkFrame = null;
|
|
20291
|
+
if (signal.aborted) return;
|
|
20292
|
+
checkTimer = owner.setTimeout(() => {
|
|
20293
|
+
checkTimer = null;
|
|
20294
|
+
if (!signal.aborted) void session.check();
|
|
20295
|
+
}, 0);
|
|
20296
|
+
});
|
|
20297
|
+
} else {
|
|
20298
|
+
void session.check();
|
|
20299
|
+
}
|
|
19945
20300
|
}
|
|
19946
20301
|
return {
|
|
19947
20302
|
element: panel,
|
|
19948
20303
|
get state() {
|
|
19949
|
-
return state;
|
|
20304
|
+
return session.state;
|
|
19950
20305
|
},
|
|
19951
20306
|
get updating() {
|
|
19952
|
-
return updating;
|
|
20307
|
+
return session.updating;
|
|
19953
20308
|
},
|
|
19954
|
-
update:
|
|
20309
|
+
update: () => signal.aborted ? Promise.resolve(false) : session.update()
|
|
19955
20310
|
};
|
|
19956
20311
|
}
|
|
19957
20312
|
|
|
19958
20313
|
// src/settings/connection-versions.ts
|
|
20314
|
+
var sessionStores = /* @__PURE__ */ new WeakMap();
|
|
20315
|
+
function getSessionStore(diagnostics) {
|
|
20316
|
+
let store = sessionStores.get(diagnostics);
|
|
20317
|
+
if (!store) {
|
|
20318
|
+
store = /* @__PURE__ */ new Map();
|
|
20319
|
+
sessionStores.set(diagnostics, store);
|
|
20320
|
+
}
|
|
20321
|
+
return store;
|
|
20322
|
+
}
|
|
19959
20323
|
function createConnectionVersions(document2, messages, signal, diagnostics, onChange) {
|
|
19960
20324
|
const panels = /* @__PURE__ */ new Map();
|
|
19961
20325
|
const installation = diagnostics?.installation?.bind(diagnostics);
|
|
20326
|
+
const sessions = diagnostics ? getSessionStore(diagnostics) : null;
|
|
20327
|
+
const sessionKey = (hostId2, agent) => JSON.stringify([hostId2, agent]);
|
|
19962
20328
|
return {
|
|
20329
|
+
isUpdating(hostId2, agent) {
|
|
20330
|
+
return Boolean(sessions?.get(sessionKey(hostId2, agent))?.updating);
|
|
20331
|
+
},
|
|
19963
20332
|
get(hostId2, agent) {
|
|
19964
20333
|
if (!installation || signal.aborted) return void 0;
|
|
19965
|
-
const key =
|
|
20334
|
+
const key = sessionKey(hostId2, agent);
|
|
19966
20335
|
let panel = panels.get(key);
|
|
19967
20336
|
if (!panel) {
|
|
20337
|
+
const run = (action) => installation(hostId2, agent, action);
|
|
20338
|
+
let session = sessions?.get(key);
|
|
20339
|
+
if (!session) {
|
|
20340
|
+
session = createHarnessVersionSession({ run });
|
|
20341
|
+
sessions?.set(key, session);
|
|
20342
|
+
}
|
|
19968
20343
|
panel = createHarnessVersionPanel(
|
|
19969
20344
|
document2,
|
|
19970
20345
|
messages,
|
|
19971
20346
|
signal,
|
|
19972
20347
|
agent,
|
|
19973
|
-
{
|
|
19974
|
-
|
|
19975
|
-
|
|
19976
|
-
onChange
|
|
20348
|
+
{ run },
|
|
20349
|
+
onChange,
|
|
20350
|
+
session
|
|
19977
20351
|
);
|
|
19978
20352
|
panels.set(key, panel);
|
|
19979
20353
|
}
|
|
@@ -19982,79 +20356,242 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
19982
20356
|
};
|
|
19983
20357
|
}
|
|
19984
20358
|
|
|
19985
|
-
// src/settings/
|
|
19986
|
-
function
|
|
19987
|
-
|
|
19988
|
-
|
|
19989
|
-
|
|
19990
|
-
|
|
19991
|
-
|
|
19992
|
-
|
|
19993
|
-
|
|
19994
|
-
|
|
19995
|
-
|
|
19996
|
-
|
|
19997
|
-
|
|
19998
|
-
|
|
19999
|
-
|
|
20000
|
-
|
|
20001
|
-
|
|
20002
|
-
|
|
20359
|
+
// src/settings/harness-install-store.ts
|
|
20360
|
+
function errorMessage(error51) {
|
|
20361
|
+
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.";
|
|
20362
|
+
}
|
|
20363
|
+
function unknownInstallOutcome(message2) {
|
|
20364
|
+
return /outcome is unknown|do not retry automatically|did not answer in time/i.test(message2);
|
|
20365
|
+
}
|
|
20366
|
+
var stores = /* @__PURE__ */ new WeakMap();
|
|
20367
|
+
function createStore(diagnostics) {
|
|
20368
|
+
const states2 = /* @__PURE__ */ new Map();
|
|
20369
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
20370
|
+
const key = (host, agent) => JSON.stringify([host, agent]);
|
|
20371
|
+
const notify2 = () => listeners.forEach((listener) => listener());
|
|
20372
|
+
return {
|
|
20373
|
+
get: (host, agent) => states2.get(key(host, agent)),
|
|
20374
|
+
clearErrors() {
|
|
20375
|
+
for (const [id, state] of states2) if (state.status === "error") states2.delete(id);
|
|
20376
|
+
notify2();
|
|
20377
|
+
},
|
|
20378
|
+
subscribe(listener) {
|
|
20379
|
+
listeners.add(listener);
|
|
20380
|
+
return () => {
|
|
20381
|
+
listeners.delete(listener);
|
|
20382
|
+
};
|
|
20383
|
+
},
|
|
20384
|
+
async install(host, agent) {
|
|
20385
|
+
const id = key(host, agent);
|
|
20386
|
+
const previous = states2.get(id);
|
|
20387
|
+
if (!diagnostics.installation || previous && previous.status !== "error") return;
|
|
20388
|
+
states2.set(id, { status: "installing" });
|
|
20389
|
+
notify2();
|
|
20390
|
+
let failure;
|
|
20391
|
+
try {
|
|
20392
|
+
await diagnostics.installation(host, agent, "install");
|
|
20393
|
+
states2.set(id, { status: "checking" });
|
|
20394
|
+
notify2();
|
|
20395
|
+
} catch (error51) {
|
|
20396
|
+
failure = errorMessage(error51);
|
|
20397
|
+
}
|
|
20398
|
+
try {
|
|
20399
|
+
await diagnostics.refresh(host);
|
|
20400
|
+
const refreshed = diagnostics.snapshot().hosts.find((candidate) => candidate.hostId === host)?.agents.find((candidate) => candidate.agent === agent);
|
|
20401
|
+
if (refreshed?.availability === "ready") failure = void 0;
|
|
20402
|
+
else if (failure && unknownInstallOutcome(failure) && refreshed && refreshed.availability !== "notInstalled") {
|
|
20403
|
+
failure = void 0;
|
|
20003
20404
|
}
|
|
20004
|
-
|
|
20005
|
-
|
|
20006
|
-
|
|
20007
|
-
|
|
20008
|
-
|
|
20405
|
+
} catch (error51) {
|
|
20406
|
+
failure ??= errorMessage(error51);
|
|
20407
|
+
}
|
|
20408
|
+
if (failure) states2.set(id, { status: "error", error: failure });
|
|
20409
|
+
else states2.delete(id);
|
|
20410
|
+
notify2();
|
|
20411
|
+
}
|
|
20412
|
+
};
|
|
20413
|
+
}
|
|
20414
|
+
function harnessInstallStore(diagnostics) {
|
|
20415
|
+
let store = stores.get(diagnostics);
|
|
20416
|
+
if (!store) {
|
|
20417
|
+
store = createStore(diagnostics);
|
|
20418
|
+
stores.set(diagnostics, store);
|
|
20419
|
+
}
|
|
20420
|
+
return store;
|
|
20421
|
+
}
|
|
20422
|
+
|
|
20423
|
+
// src/settings/harness-installation-guides.ts
|
|
20424
|
+
function harnessHasInstallCommands(plugin) {
|
|
20425
|
+
return (plugin?.installation?.commands.length ?? 0) > 0;
|
|
20426
|
+
}
|
|
20427
|
+
function harnessInstallationGuide(plugin, locale) {
|
|
20428
|
+
const guide = plugin?.installation;
|
|
20429
|
+
const text = (value) => value?.[locale] ?? value?.en;
|
|
20430
|
+
return {
|
|
20431
|
+
url: plugin?.links?.installation ?? plugin?.links?.documentation ?? plugin?.links?.website,
|
|
20432
|
+
commands: guide?.commands ?? [],
|
|
20433
|
+
downloads: guide?.downloads ?? [],
|
|
20434
|
+
before: text(guide?.before),
|
|
20435
|
+
after: text(guide?.after)
|
|
20436
|
+
};
|
|
20437
|
+
}
|
|
20438
|
+
|
|
20439
|
+
// src/settings/harness-installation-panel.ts
|
|
20440
|
+
function createHarnessInstallationPanel(document2, plugin, hostId2, messages, copy, installation) {
|
|
20441
|
+
const zh = messages.locale === "zh-CN";
|
|
20442
|
+
const guide = harnessInstallationGuide(plugin, messages.locale);
|
|
20443
|
+
const panel = document2.createElement("div");
|
|
20444
|
+
panel.className = "settings-harness-installation";
|
|
20445
|
+
const paragraph = (text) => {
|
|
20446
|
+
const p = document2.createElement("p");
|
|
20447
|
+
p.textContent = text;
|
|
20448
|
+
panel.append(p);
|
|
20449
|
+
};
|
|
20450
|
+
if (hostId2 !== "local") {
|
|
20451
|
+
paragraph(zh ? "\u8BF7\u5728\u8FDC\u7A0B Host \u4E0A\u5B89\u88C5\u3002" : "Install on the remote Host.");
|
|
20452
|
+
}
|
|
20453
|
+
if (guide.before) paragraph(guide.before);
|
|
20454
|
+
const install2 = installation && guide.commands.length > 0 ? document2.createElement("button") : null;
|
|
20455
|
+
if (install2 && installation) {
|
|
20456
|
+
install2.type = "button";
|
|
20457
|
+
install2.className = "settings-command-button";
|
|
20458
|
+
install2.dataset.connectionAction = "install";
|
|
20459
|
+
install2.disabled = installation.status !== "idle";
|
|
20460
|
+
install2.textContent = installation.status === "installing" ? messages.connectionStatusInstalling : installation.status === "checking" ? messages.connectionStatusChecking : zh ? "\u4E00\u952E\u5B89\u88C5" : "Install automatically";
|
|
20461
|
+
install2.addEventListener("click", () => {
|
|
20462
|
+
if (install2.disabled) return;
|
|
20463
|
+
install2.disabled = true;
|
|
20464
|
+
install2.textContent = messages.connectionStatusInstalling;
|
|
20465
|
+
installation.run();
|
|
20466
|
+
});
|
|
20467
|
+
if (guide.commands.length > 1) panel.append(install2);
|
|
20468
|
+
}
|
|
20469
|
+
for (const { terminal, command } of guide.commands) {
|
|
20470
|
+
const block = document2.createElement("div");
|
|
20471
|
+
block.className = "settings-harness-installation-command";
|
|
20472
|
+
const label = document2.createElement("strong");
|
|
20473
|
+
label.textContent = terminal;
|
|
20474
|
+
const pre = document2.createElement("pre");
|
|
20475
|
+
const code = document2.createElement("code");
|
|
20476
|
+
code.textContent = command;
|
|
20477
|
+
pre.append(code);
|
|
20478
|
+
const button2 = document2.createElement("button");
|
|
20479
|
+
button2.type = "button";
|
|
20480
|
+
button2.className = "settings-command-button settings-command-button--secondary";
|
|
20481
|
+
button2.dataset.connectionAction = "copy-install";
|
|
20482
|
+
const copyLabel = zh ? "\u590D\u5236\u547D\u4EE4" : "Copy command";
|
|
20483
|
+
button2.setAttribute("aria-label", `${copyLabel}: ${terminal}`);
|
|
20484
|
+
button2.append(createRendererSettingsIcon("copy", 16), copyLabel);
|
|
20485
|
+
button2.addEventListener("click", () => copy(button2, command, copyLabel));
|
|
20486
|
+
const actions = document2.createElement("div");
|
|
20487
|
+
actions.className = "settings-harness-installation-actions";
|
|
20488
|
+
if (install2 && guide.commands.length === 1) actions.append(install2);
|
|
20489
|
+
actions.append(button2);
|
|
20490
|
+
block.append(label, pre, actions);
|
|
20491
|
+
panel.append(block);
|
|
20492
|
+
}
|
|
20493
|
+
for (const download2 of guide.downloads ?? []) {
|
|
20494
|
+
const link = document2.createElement("a");
|
|
20495
|
+
link.className = "settings-command-button settings-command-button--secondary";
|
|
20496
|
+
link.href = download2.url;
|
|
20497
|
+
link.target = "_blank";
|
|
20498
|
+
link.rel = "noopener noreferrer";
|
|
20499
|
+
link.textContent = zh ? "\u4E0B\u8F7D" : "Download";
|
|
20500
|
+
link.setAttribute("aria-label", `${link.textContent} ${download2.label}`);
|
|
20501
|
+
panel.append(link);
|
|
20502
|
+
}
|
|
20503
|
+
if (guide.after) paragraph(guide.after);
|
|
20504
|
+
if (!plugin?.installation && guide.url) {
|
|
20505
|
+
const link = document2.createElement("a");
|
|
20506
|
+
link.href = guide.url;
|
|
20507
|
+
link.target = "_blank";
|
|
20508
|
+
link.rel = "noopener noreferrer";
|
|
20509
|
+
link.textContent = zh ? "\u5B89\u88C5\u8BF4\u660E" : "Installation instructions";
|
|
20510
|
+
panel.append(link);
|
|
20511
|
+
}
|
|
20512
|
+
return panel;
|
|
20513
|
+
}
|
|
20514
|
+
|
|
20515
|
+
// src/settings/harness-launch-controls.ts
|
|
20516
|
+
function createHarnessLaunchControls(document2, messages, agent, settings) {
|
|
20517
|
+
const section = document2.createElement("section");
|
|
20518
|
+
section.className = "settings-harness-launch";
|
|
20519
|
+
section.dataset.harnessLaunch = agent;
|
|
20520
|
+
const label = document2.createElement("label");
|
|
20521
|
+
label.textContent = messages.launchPathLabel;
|
|
20522
|
+
const input = document2.createElement("input");
|
|
20523
|
+
input.type = "text";
|
|
20524
|
+
input.autocomplete = "off";
|
|
20525
|
+
input.spellcheck = false;
|
|
20526
|
+
input.placeholder = messages.locale === "zh-CN" ? "\u5E94\u7528\u5B89\u88C5\u76EE\u5F55\u7684\u7EDD\u5BF9\u8DEF\u5F84" : "Absolute installation directory";
|
|
20527
|
+
input.setAttribute("aria-label", messages.launchPathLabel);
|
|
20528
|
+
label.append(input);
|
|
20529
|
+
const help = document2.createElement("p");
|
|
20530
|
+
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.";
|
|
20531
|
+
const actions = document2.createElement("div");
|
|
20532
|
+
actions.className = "settings-harness-launch__actions";
|
|
20533
|
+
const save = document2.createElement("button");
|
|
20534
|
+
save.type = "button";
|
|
20535
|
+
save.className = "settings-command-button";
|
|
20536
|
+
save.textContent = messages.launchPathSave;
|
|
20537
|
+
const reset = document2.createElement("button");
|
|
20538
|
+
reset.type = "button";
|
|
20539
|
+
reset.className = "settings-command-button settings-command-button--secondary";
|
|
20540
|
+
reset.textContent = messages.launchPathReset;
|
|
20541
|
+
const status = document2.createElement("p");
|
|
20542
|
+
status.setAttribute("role", "status");
|
|
20543
|
+
status.setAttribute("aria-live", "polite");
|
|
20544
|
+
actions.append(save, reset);
|
|
20545
|
+
section.append(label, help, actions, status);
|
|
20546
|
+
let busy = true;
|
|
20547
|
+
let loaded = false;
|
|
20548
|
+
const controls = () => {
|
|
20549
|
+
input.disabled = busy || !loaded;
|
|
20550
|
+
save.disabled = busy || !loaded || !input.value.trim();
|
|
20551
|
+
reset.disabled = busy || !loaded;
|
|
20009
20552
|
};
|
|
20010
|
-
|
|
20011
|
-
|
|
20012
|
-
|
|
20013
|
-
|
|
20014
|
-
|
|
20015
|
-
|
|
20016
|
-
|
|
20017
|
-
|
|
20018
|
-
|
|
20019
|
-
|
|
20020
|
-
|
|
20021
|
-
|
|
20022
|
-
|
|
20023
|
-
|
|
20024
|
-
|
|
20025
|
-
|
|
20026
|
-
result.className = "settings-connection-update-result";
|
|
20027
|
-
result.setAttribute("role", "status");
|
|
20028
|
-
result.hidden = !batch || batch.running;
|
|
20029
|
-
if (batch && !batch.running) {
|
|
20030
|
-
result.textContent = messages.harnessUpdateAllResult.replace("{succeeded}", String(batch.succeeded)).replace("{failed}", String(batch.failed));
|
|
20031
|
-
}
|
|
20032
|
-
return { button: button2, result };
|
|
20553
|
+
const show = (value) => {
|
|
20554
|
+
input.value = value.path ?? "";
|
|
20555
|
+
status.textContent = value.restartRequired ? messages.launchPathRestart : value.path ? messages.launchPathSaved : messages.launchPathAutomatic;
|
|
20556
|
+
};
|
|
20557
|
+
const persist = async (value) => {
|
|
20558
|
+
if (busy || !loaded) return;
|
|
20559
|
+
busy = true;
|
|
20560
|
+
controls();
|
|
20561
|
+
status.textContent = messages.launchPathSaving;
|
|
20562
|
+
try {
|
|
20563
|
+
show(await settings.set(value));
|
|
20564
|
+
} catch {
|
|
20565
|
+
status.textContent = messages.launchPathSaveError;
|
|
20566
|
+
} finally {
|
|
20567
|
+
busy = false;
|
|
20568
|
+
controls();
|
|
20033
20569
|
}
|
|
20034
20570
|
};
|
|
20571
|
+
input.addEventListener("input", controls);
|
|
20572
|
+
save.addEventListener("click", () => {
|
|
20573
|
+
if (input.value.trim()) void persist(input.value.trim());
|
|
20574
|
+
});
|
|
20575
|
+
reset.addEventListener("click", () => {
|
|
20576
|
+
void persist(null);
|
|
20577
|
+
});
|
|
20578
|
+
controls();
|
|
20579
|
+
status.textContent = messages.launchPathLoading;
|
|
20580
|
+
void settings.get().then((value) => {
|
|
20581
|
+
loaded = true;
|
|
20582
|
+
show(value);
|
|
20583
|
+
}).catch(() => {
|
|
20584
|
+
loaded = true;
|
|
20585
|
+
status.textContent = messages.launchPathLoadError;
|
|
20586
|
+
}).finally(() => {
|
|
20587
|
+
busy = false;
|
|
20588
|
+
controls();
|
|
20589
|
+
});
|
|
20590
|
+
return section;
|
|
20035
20591
|
}
|
|
20036
20592
|
|
|
20037
20593
|
// src/settings/connections-page.ts
|
|
20038
20594
|
var CODEXHOST_GITHUB_ISSUES_NEW_URL = "https://github.com/BytePioneer-AI/codex-host/issues/new";
|
|
20039
|
-
function connectionStatusLabel(availability, messages, hasError = false) {
|
|
20040
|
-
if (availability === "updating") return messages.connectionStatusUpdating;
|
|
20041
|
-
if (hasError && availability !== "notInstalled") return messages.connectionStatusError;
|
|
20042
|
-
if (availability === "ready") return messages.connectionStatusReady;
|
|
20043
|
-
if (availability === "checking") return messages.connectionStatusChecking;
|
|
20044
|
-
if (availability === "notInstalled") return messages.connectionStatusNotInstalled;
|
|
20045
|
-
if (availability === "unavailable" || availability === "error") {
|
|
20046
|
-
return availability === "error" ? messages.connectionStatusError : messages.connectionStatusUnavailable;
|
|
20047
|
-
}
|
|
20048
|
-
return availability === "installing" ? messages.connectionStatusInstalling : messages.connectionStatusUnsupported;
|
|
20049
|
-
}
|
|
20050
|
-
function connectionStatusTone(availability, hasError = false) {
|
|
20051
|
-
if (availability === "updating") return "checking";
|
|
20052
|
-
if (hasError && availability !== "notInstalled") return "failed";
|
|
20053
|
-
if (availability === "ready") return "ready";
|
|
20054
|
-
if (availability === "checking" || availability === "installing") return "checking";
|
|
20055
|
-
if (availability === "notInstalled") return "setup";
|
|
20056
|
-
return "failed";
|
|
20057
|
-
}
|
|
20058
20595
|
function diagnosticText(hostId2, item) {
|
|
20059
20596
|
const error51 = item.error;
|
|
20060
20597
|
return [
|
|
@@ -20150,148 +20687,21 @@ ${error51.stderrTail}`] : []
|
|
|
20150
20687
|
tabs.addEventListener("wheel", onWheel, { passive: false });
|
|
20151
20688
|
const ownerWindow = document2.defaultView;
|
|
20152
20689
|
ownerWindow?.addEventListener("resize", updateButtons);
|
|
20153
|
-
|
|
20154
|
-
|
|
20155
|
-
|
|
20156
|
-
|
|
20157
|
-
|
|
20158
|
-
|
|
20159
|
-
|
|
20160
|
-
|
|
20690
|
+
const refreshLayout = () => {
|
|
20691
|
+
ownerWindow?.setTimeout(updateButtons, 0);
|
|
20692
|
+
updateButtons();
|
|
20693
|
+
};
|
|
20694
|
+
refreshLayout();
|
|
20695
|
+
return {
|
|
20696
|
+
update: refreshLayout,
|
|
20697
|
+
dispose() {
|
|
20698
|
+
left.removeEventListener("click", onLeft);
|
|
20699
|
+
right.removeEventListener("click", onRight);
|
|
20700
|
+
tabs.removeEventListener("scroll", updateButtons);
|
|
20701
|
+
tabs.removeEventListener("wheel", onWheel);
|
|
20702
|
+
ownerWindow?.removeEventListener("resize", updateButtons);
|
|
20703
|
+
}
|
|
20161
20704
|
};
|
|
20162
|
-
}
|
|
20163
|
-
function createConnectionIdentityIcon(document2, item, size) {
|
|
20164
|
-
const container = document2.createElement("span");
|
|
20165
|
-
container.className = item.agentSnapshot ? "settings-connection-row__mark settings-connection-row__mark--logo" : "settings-connection-row__mark";
|
|
20166
|
-
container.setAttribute("aria-hidden", "true");
|
|
20167
|
-
if (item.agentSnapshot) {
|
|
20168
|
-
container.append(
|
|
20169
|
-
createRendererAgentIcon(item.agentSnapshot.agent, size, document2, item.agentSnapshot.plugin)
|
|
20170
|
-
);
|
|
20171
|
-
} else {
|
|
20172
|
-
container.textContent = "CH";
|
|
20173
|
-
}
|
|
20174
|
-
return container;
|
|
20175
|
-
}
|
|
20176
|
-
function createConnectionRow(document2, item, messages, selected, select, group = null) {
|
|
20177
|
-
const row = document2.createElement("div");
|
|
20178
|
-
row.className = "settings-connection-row";
|
|
20179
|
-
row.dataset.connectionItem = item.key;
|
|
20180
|
-
row.dataset.connectionSelected = String(selected);
|
|
20181
|
-
row.tabIndex = selected ? 0 : -1;
|
|
20182
|
-
row.setAttribute("role", "row");
|
|
20183
|
-
const identity3 = document2.createElement("div");
|
|
20184
|
-
identity3.className = "settings-connection-row__identity";
|
|
20185
|
-
identity3.setAttribute("role", "cell");
|
|
20186
|
-
if (group) {
|
|
20187
|
-
const handle = document2.createElement("span");
|
|
20188
|
-
handle.className = "settings-connection-row__handle";
|
|
20189
|
-
handle.setAttribute("aria-hidden", "true");
|
|
20190
|
-
handle.title = group.dragHandleTitle;
|
|
20191
|
-
handle.append(createRendererSettingsIcon("grip-vertical", 15));
|
|
20192
|
-
identity3.append(handle);
|
|
20193
|
-
}
|
|
20194
|
-
const label = document2.createElement("strong");
|
|
20195
|
-
label.textContent = item.name;
|
|
20196
|
-
identity3.append(createConnectionIdentityIcon(document2, item, 19), label);
|
|
20197
|
-
const status = document2.createElement("span");
|
|
20198
|
-
status.className = "settings-connection-row__status";
|
|
20199
|
-
status.dataset.connectionTone = connectionStatusTone(item.availability, item.error !== null);
|
|
20200
|
-
status.setAttribute("role", "cell");
|
|
20201
|
-
status.textContent = item.error?.code === "authenticationRequired" ? messages.connectionLoginRequired : item.error?.code === "configurationRequired" ? messages.connectionConfigurationRequired : connectionStatusLabel(item.availability, messages, item.error !== null);
|
|
20202
|
-
const version2 = item.version;
|
|
20203
|
-
const action = document2.createElement("div");
|
|
20204
|
-
action.className = "settings-connection-row__action";
|
|
20205
|
-
action.setAttribute("role", "cell");
|
|
20206
|
-
if (item.agentSnapshot?.availability === "notInstalled" && item.install) {
|
|
20207
|
-
const install2 = document2.createElement("button");
|
|
20208
|
-
install2.type = "button";
|
|
20209
|
-
install2.className = "settings-connection-install-link";
|
|
20210
|
-
install2.addEventListener("click", (event) => {
|
|
20211
|
-
event.stopPropagation();
|
|
20212
|
-
select();
|
|
20213
|
-
item.install?.();
|
|
20214
|
-
});
|
|
20215
|
-
install2.disabled = item.availability === "installing" || item.availability === "checking";
|
|
20216
|
-
const installLabel = messages.connectionInstall;
|
|
20217
|
-
install2.setAttribute("aria-label", `${installLabel}: ${item.name}`);
|
|
20218
|
-
install2.title = installLabel;
|
|
20219
|
-
install2.append(createRendererSettingsIcon("download", 17));
|
|
20220
|
-
action.append(install2);
|
|
20221
|
-
} else if (item.error) {
|
|
20222
|
-
const viewError = document2.createElement("button");
|
|
20223
|
-
viewError.type = "button";
|
|
20224
|
-
viewError.className = "settings-connection-view-error";
|
|
20225
|
-
viewError.textContent = messages.connectionViewError;
|
|
20226
|
-
viewError.addEventListener("click", (event) => {
|
|
20227
|
-
event.stopPropagation();
|
|
20228
|
-
select();
|
|
20229
|
-
});
|
|
20230
|
-
action.append(viewError);
|
|
20231
|
-
}
|
|
20232
|
-
if (version2?.state?.updateAvailable && !version2.updating) {
|
|
20233
|
-
const available = document2.createElement("span");
|
|
20234
|
-
available.className = "settings-connection-version-available";
|
|
20235
|
-
available.textContent = messages.harnessVersionAvailable;
|
|
20236
|
-
available.title = `${messages.harnessVersionCurrent}: ${version2.state.currentVersion ?? "\u2014"}
|
|
20237
|
-
${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages.harnessVersion)}`;
|
|
20238
|
-
action.append(available);
|
|
20239
|
-
}
|
|
20240
|
-
if (version2?.state?.updateAvailable && version2.state.canUpdate) {
|
|
20241
|
-
const update = document2.createElement("button");
|
|
20242
|
-
update.type = "button";
|
|
20243
|
-
update.className = "settings-connection-install-link";
|
|
20244
|
-
update.dataset.connectionAction = "update";
|
|
20245
|
-
update.disabled = version2.updating;
|
|
20246
|
-
update.title = messages.harnessVersionUpdate;
|
|
20247
|
-
update.setAttribute("aria-label", `${messages.harnessVersionUpdate}: ${item.name}`);
|
|
20248
|
-
update.append(createRendererSettingsIcon("download", 17));
|
|
20249
|
-
update.addEventListener("click", (event) => {
|
|
20250
|
-
event.stopPropagation();
|
|
20251
|
-
if (update.disabled) return;
|
|
20252
|
-
void version2.update();
|
|
20253
|
-
select();
|
|
20254
|
-
});
|
|
20255
|
-
action.append(update);
|
|
20256
|
-
}
|
|
20257
|
-
if (group) {
|
|
20258
|
-
const toggle = document2.createElement("button");
|
|
20259
|
-
toggle.type = "button";
|
|
20260
|
-
toggle.disabled = group.disabled;
|
|
20261
|
-
toggle.className = "settings-connection-row__group-toggle";
|
|
20262
|
-
toggle.title = group.moveLabel;
|
|
20263
|
-
toggle.setAttribute("aria-label", group.moveLabel);
|
|
20264
|
-
toggle.append(
|
|
20265
|
-
createRendererSettingsIcon(group.section === "main" ? "chevron-down" : "chevron-up", 15)
|
|
20266
|
-
);
|
|
20267
|
-
toggle.addEventListener("click", (event) => {
|
|
20268
|
-
event.stopPropagation();
|
|
20269
|
-
group.toggleSection();
|
|
20270
|
-
});
|
|
20271
|
-
action.append(toggle);
|
|
20272
|
-
}
|
|
20273
|
-
row.addEventListener("click", (event) => {
|
|
20274
|
-
const target2 = event.target;
|
|
20275
|
-
if (target2?.closest?.("a")) return;
|
|
20276
|
-
select();
|
|
20277
|
-
});
|
|
20278
|
-
row.addEventListener("keydown", (event) => {
|
|
20279
|
-
if (event.target?.closest?.("button, a")) return;
|
|
20280
|
-
if (event.key !== "Enter" && event.key !== " ") return;
|
|
20281
|
-
event.preventDefault();
|
|
20282
|
-
select();
|
|
20283
|
-
});
|
|
20284
|
-
if (group) {
|
|
20285
|
-
row.draggable = !group.disabled;
|
|
20286
|
-
row.dataset.connectionGroupSection = group.section;
|
|
20287
|
-
row.addEventListener("dragstart", group.onDragStart);
|
|
20288
|
-
row.addEventListener("dragover", group.onDragOver);
|
|
20289
|
-
row.addEventListener("dragleave", group.onDragLeave);
|
|
20290
|
-
row.addEventListener("drop", group.onDrop);
|
|
20291
|
-
row.addEventListener("dragend", group.onDragEnd);
|
|
20292
|
-
}
|
|
20293
|
-
row.append(identity3, status, action);
|
|
20294
|
-
return row;
|
|
20295
20705
|
}
|
|
20296
20706
|
function createInspectorHeader(document2, item, messages) {
|
|
20297
20707
|
const header = document2.createElement("header");
|
|
@@ -20321,6 +20731,29 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
20321
20731
|
header.append(identity3, status);
|
|
20322
20732
|
return header;
|
|
20323
20733
|
}
|
|
20734
|
+
function inspectorRenderSignature(hostId2, item, messages, diagnostics) {
|
|
20735
|
+
const plugin = item.agentSnapshot?.plugin;
|
|
20736
|
+
const notice = plugin?.notice ? plugin.notice[messages.locale] ?? plugin.notice.en : "";
|
|
20737
|
+
const websiteUrl = plugin?.links?.website ?? plugin?.links?.documentation ?? "";
|
|
20738
|
+
const hasLaunchControls = hostId2 === "local" && Boolean(item.agentSnapshot?.agent) && Boolean(plugin?.launchCommand) && Boolean(diagnostics?.getLaunchSettings && diagnostics?.setLaunchSettings);
|
|
20739
|
+
return JSON.stringify([
|
|
20740
|
+
hostId2,
|
|
20741
|
+
item.key,
|
|
20742
|
+
item.name,
|
|
20743
|
+
item.availability,
|
|
20744
|
+
item.agentSnapshot?.availability ?? null,
|
|
20745
|
+
String(plugin?.icon ?? ""),
|
|
20746
|
+
String(plugin?.iconStyle ?? ""),
|
|
20747
|
+
websiteUrl,
|
|
20748
|
+
notice,
|
|
20749
|
+
item.installError ?? "",
|
|
20750
|
+
Boolean(item.install),
|
|
20751
|
+
plugin?.installation ?? null,
|
|
20752
|
+
Boolean(item.openWebUi),
|
|
20753
|
+
hasLaunchControls,
|
|
20754
|
+
item.error ? diagnosticText(hostId2, item) : ""
|
|
20755
|
+
]);
|
|
20756
|
+
}
|
|
20324
20757
|
function renderConnectionInspector(document2, inspector, item, hostId2, messages, diagnostics, existingLaunchControls, refresh) {
|
|
20325
20758
|
inspector.replaceChildren(createInspectorHeader(document2, item, messages));
|
|
20326
20759
|
const body = document2.createElement("div");
|
|
@@ -20486,11 +20919,10 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
20486
20919
|
function requestConnectionsPageFocus(agentKey) {
|
|
20487
20920
|
pendingFocusAgent = agentKey;
|
|
20488
20921
|
}
|
|
20489
|
-
function createGroupDivider(document2
|
|
20922
|
+
function createGroupDivider(document2) {
|
|
20490
20923
|
const divider = document2.createElement("div");
|
|
20491
20924
|
divider.className = "settings-connection-group-divider";
|
|
20492
20925
|
divider.setAttribute("role", "presentation");
|
|
20493
|
-
divider.textContent = `${messages.connectionGroupMoreLabel} (${count3})`;
|
|
20494
20926
|
return divider;
|
|
20495
20927
|
}
|
|
20496
20928
|
function createGroupMoreHint(document2, messages) {
|
|
@@ -20543,11 +20975,13 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
20543
20975
|
context2.content.append(header, syncMessage, content);
|
|
20544
20976
|
let pending2 = false;
|
|
20545
20977
|
let selectedHostId = null;
|
|
20978
|
+
let renderedHostId = null;
|
|
20546
20979
|
let selectedItemKey = null;
|
|
20547
20980
|
let launchControls = null;
|
|
20981
|
+
let renderedInspector = null;
|
|
20548
20982
|
const hostNames = /* @__PURE__ */ new Map();
|
|
20983
|
+
const knownNotInstalled = /* @__PURE__ */ new Map();
|
|
20549
20984
|
let latestSnapshot = null;
|
|
20550
|
-
let disposeHostScroller = () => void 0;
|
|
20551
20985
|
let disposed = false;
|
|
20552
20986
|
let renderQueued = false;
|
|
20553
20987
|
let renderFrame = null;
|
|
@@ -20581,7 +21015,99 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
20581
21015
|
scheduleRender
|
|
20582
21016
|
);
|
|
20583
21017
|
const installs = diagnostics ? harnessInstallStore(diagnostics) : null;
|
|
20584
|
-
const updates = createConnectionUpdates(
|
|
21018
|
+
const updates = createConnectionUpdates(
|
|
21019
|
+
document2,
|
|
21020
|
+
messages,
|
|
21021
|
+
context2.signal,
|
|
21022
|
+
scheduleRender,
|
|
21023
|
+
diagnostics
|
|
21024
|
+
);
|
|
21025
|
+
const panelId = "codexhost-settings-connection-host-panel";
|
|
21026
|
+
const empty = document2.createElement("div");
|
|
21027
|
+
empty.className = "settings-empty";
|
|
21028
|
+
empty.textContent = messages.connectionNoRuntime;
|
|
21029
|
+
const layout = document2.createElement("div");
|
|
21030
|
+
layout.className = "settings-connections-layout";
|
|
21031
|
+
const list = document2.createElement("section");
|
|
21032
|
+
list.className = "settings-connection-list";
|
|
21033
|
+
const hostStrip = document2.createElement("div");
|
|
21034
|
+
hostStrip.className = "settings-connection-host-strip";
|
|
21035
|
+
const scrollLeft = createHostScrollButton(document2, "left", messages);
|
|
21036
|
+
const tabs = document2.createElement("div");
|
|
21037
|
+
tabs.className = "settings-connection-host-tabs";
|
|
21038
|
+
tabs.setAttribute("role", "tablist");
|
|
21039
|
+
tabs.setAttribute("aria-label", messages.connectionHosts);
|
|
21040
|
+
const scrollRight = createHostScrollButton(document2, "right", messages);
|
|
21041
|
+
hostStrip.append(scrollLeft, tabs, scrollRight);
|
|
21042
|
+
const updateControls = updates.createControls("local", []);
|
|
21043
|
+
const hostHeader = document2.createElement("div");
|
|
21044
|
+
hostHeader.className = "settings-connection-host-header";
|
|
21045
|
+
hostHeader.append(hostStrip, updateControls.button);
|
|
21046
|
+
const tableHeader = document2.createElement("div");
|
|
21047
|
+
tableHeader.className = "settings-connection-table-header";
|
|
21048
|
+
tableHeader.setAttribute("role", "row");
|
|
21049
|
+
const componentHeading = document2.createElement("span");
|
|
21050
|
+
componentHeading.textContent = messages.connectionComponent;
|
|
21051
|
+
componentHeading.setAttribute("role", "columnheader");
|
|
21052
|
+
const statusHeading = document2.createElement("span");
|
|
21053
|
+
statusHeading.textContent = messages.connectionStatus;
|
|
21054
|
+
statusHeading.setAttribute("role", "columnheader");
|
|
21055
|
+
const actionHeading = document2.createElement("span");
|
|
21056
|
+
actionHeading.setAttribute("aria-hidden", "true");
|
|
21057
|
+
tableHeader.append(componentHeading, statusHeading, actionHeading);
|
|
21058
|
+
const rows = document2.createElement("div");
|
|
21059
|
+
rows.className = "settings-connection-rows";
|
|
21060
|
+
rows.id = panelId;
|
|
21061
|
+
rows.setAttribute("role", "rowgroup");
|
|
21062
|
+
list.append(hostHeader, updateControls.result, tableHeader, rows);
|
|
21063
|
+
const inspector = document2.createElement("aside");
|
|
21064
|
+
inspector.className = "settings-connection-inspector";
|
|
21065
|
+
inspector.setAttribute("aria-live", "polite");
|
|
21066
|
+
layout.append(list, inspector);
|
|
21067
|
+
const hostScroller = configureHostScroller(
|
|
21068
|
+
document2,
|
|
21069
|
+
hostStrip,
|
|
21070
|
+
tabs,
|
|
21071
|
+
scrollLeft,
|
|
21072
|
+
scrollRight
|
|
21073
|
+
);
|
|
21074
|
+
const hostTabElements = /* @__PURE__ */ new Map();
|
|
21075
|
+
const hostRowViews = /* @__PURE__ */ new Map();
|
|
21076
|
+
const groupDivider = createGroupDivider(document2);
|
|
21077
|
+
const moreHint = createGroupMoreHint(document2, messages);
|
|
21078
|
+
const moreZone = document2.createElement("div");
|
|
21079
|
+
moreZone.className = "settings-connection-group-more";
|
|
21080
|
+
moreZone.setAttribute("role", "presentation");
|
|
21081
|
+
const resetButton = createGroupResetButton(document2, messages, () => {
|
|
21082
|
+
groupPreference.resetToDefault();
|
|
21083
|
+
});
|
|
21084
|
+
let draggingAgent = null;
|
|
21085
|
+
let currentCatalog = [];
|
|
21086
|
+
let currentMainEntries = [];
|
|
21087
|
+
let currentMoreEntries = [];
|
|
21088
|
+
let currentHostRows = /* @__PURE__ */ new Map();
|
|
21089
|
+
const clearDropIndicators = () => {
|
|
21090
|
+
for (const view of currentHostRows.values()) {
|
|
21091
|
+
view.element.dataset.connectionDropIndicator = "";
|
|
21092
|
+
}
|
|
21093
|
+
moreZone.dataset.connectionDragOver = "false";
|
|
21094
|
+
};
|
|
21095
|
+
moreZone.addEventListener("dragover", (event) => {
|
|
21096
|
+
if (!draggingAgent) return;
|
|
21097
|
+
event.preventDefault();
|
|
21098
|
+
moreZone.dataset.connectionDragOver = "true";
|
|
21099
|
+
});
|
|
21100
|
+
moreZone.addEventListener("dragleave", () => {
|
|
21101
|
+
moreZone.dataset.connectionDragOver = "false";
|
|
21102
|
+
});
|
|
21103
|
+
moreZone.addEventListener("drop", (event) => {
|
|
21104
|
+
event.preventDefault();
|
|
21105
|
+
moreZone.dataset.connectionDragOver = "false";
|
|
21106
|
+
if (!draggingAgent) return;
|
|
21107
|
+
groupPreference.moveAgent(draggingAgent, "more", null, currentCatalog);
|
|
21108
|
+
draggingAgent = null;
|
|
21109
|
+
clearDropIndicators();
|
|
21110
|
+
});
|
|
20585
21111
|
const runRefresh = () => {
|
|
20586
21112
|
if (pending2 || !diagnostics) return;
|
|
20587
21113
|
pending2 = true;
|
|
@@ -20594,6 +21120,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
20594
21120
|
success() {
|
|
20595
21121
|
installs?.clearErrors();
|
|
20596
21122
|
pending2 = false;
|
|
21123
|
+
renderedInspector = null;
|
|
20597
21124
|
refresh.disabled = false;
|
|
20598
21125
|
refresh.replaceChildren(
|
|
20599
21126
|
createRendererSettingsIcon("diagnose", 16),
|
|
@@ -20603,6 +21130,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
20603
21130
|
},
|
|
20604
21131
|
failure(error51) {
|
|
20605
21132
|
pending2 = false;
|
|
21133
|
+
renderedInspector = null;
|
|
20606
21134
|
refresh.disabled = false;
|
|
20607
21135
|
refresh.replaceChildren(
|
|
20608
21136
|
createRendererSettingsIcon("diagnose", 16),
|
|
@@ -20628,97 +21156,111 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
20628
21156
|
}
|
|
20629
21157
|
});
|
|
20630
21158
|
};
|
|
21159
|
+
const syncSelectedInspector = (hostId2, item) => {
|
|
21160
|
+
const currentDiagnostics = getDiagnostics();
|
|
21161
|
+
const signature = inspectorRenderSignature(hostId2, item, messages, currentDiagnostics);
|
|
21162
|
+
const versionElement = item.version?.element ?? null;
|
|
21163
|
+
if (renderedInspector?.signature === signature && renderedInspector.versionElement === versionElement) {
|
|
21164
|
+
return;
|
|
21165
|
+
}
|
|
21166
|
+
const existing = launchControls?.hostId === hostId2 && launchControls.itemKey === item.key ? launchControls.element : null;
|
|
21167
|
+
const element = renderConnectionInspector(
|
|
21168
|
+
document2,
|
|
21169
|
+
inspector,
|
|
21170
|
+
item,
|
|
21171
|
+
hostId2,
|
|
21172
|
+
messages,
|
|
21173
|
+
currentDiagnostics,
|
|
21174
|
+
existing,
|
|
21175
|
+
runRefresh
|
|
21176
|
+
);
|
|
21177
|
+
launchControls = { hostId: hostId2, itemKey: item.key, element };
|
|
21178
|
+
if (versionElement) inspector.append(versionElement);
|
|
21179
|
+
renderedInspector = { signature, versionElement };
|
|
21180
|
+
};
|
|
20631
21181
|
const render = (snapshot) => {
|
|
20632
21182
|
const syncStatus = groupPreference.syncStatus();
|
|
20633
21183
|
const groupDisabled = syncStatus === "loading" || syncStatus === "saving";
|
|
20634
21184
|
syncMessage.hidden = syncStatus === "ready";
|
|
20635
21185
|
syncMessage.textContent = syncStatus === "error" ? messages.connectionGroupSyncFailed : syncStatus === "saving" ? messages.connectionGroupSaving : messages.connectionGroupLoading;
|
|
20636
21186
|
latestSnapshot = snapshot;
|
|
20637
|
-
disposeHostScroller();
|
|
20638
|
-
disposeHostScroller = () => void 0;
|
|
20639
21187
|
if (!snapshot) {
|
|
20640
|
-
|
|
20641
|
-
|
|
20642
|
-
empty
|
|
20643
|
-
content.replaceChildren(empty);
|
|
21188
|
+
renderedHostId = null;
|
|
21189
|
+
renderedInspector = null;
|
|
21190
|
+
reconcileElementChildren(content, [empty]);
|
|
20644
21191
|
return;
|
|
20645
21192
|
}
|
|
20646
21193
|
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];
|
|
20647
21194
|
if (!selectedHost) return;
|
|
20648
21195
|
selectedHostId = selectedHost.hostId;
|
|
20649
|
-
const
|
|
20650
|
-
|
|
20651
|
-
|
|
20652
|
-
|
|
20653
|
-
|
|
20654
|
-
|
|
20655
|
-
|
|
20656
|
-
|
|
20657
|
-
|
|
20658
|
-
|
|
20659
|
-
|
|
20660
|
-
|
|
20661
|
-
|
|
20662
|
-
|
|
20663
|
-
|
|
20664
|
-
|
|
20665
|
-
|
|
20666
|
-
|
|
20667
|
-
|
|
20668
|
-
|
|
20669
|
-
|
|
20670
|
-
|
|
20671
|
-
|
|
21196
|
+
const layoutFirstMount = content.children[0] !== layout;
|
|
21197
|
+
reconcileElementChildren(content, [layout]);
|
|
21198
|
+
let tabsChanged = tabs.children.length !== snapshot.hosts.length;
|
|
21199
|
+
const nextTabs = snapshot.hosts.map((host) => {
|
|
21200
|
+
let tab = hostTabElements.get(host.hostId);
|
|
21201
|
+
if (!tab) {
|
|
21202
|
+
tab = document2.createElement("button");
|
|
21203
|
+
tab.type = "button";
|
|
21204
|
+
tab.className = "settings-connection-host-tab";
|
|
21205
|
+
tab.dataset.connectionHostTab = host.hostId;
|
|
21206
|
+
tab.setAttribute("role", "tab");
|
|
21207
|
+
tab.setAttribute("aria-controls", panelId);
|
|
21208
|
+
tab.addEventListener("click", () => {
|
|
21209
|
+
selectedHostId = host.hostId;
|
|
21210
|
+
render(latestSnapshot);
|
|
21211
|
+
});
|
|
21212
|
+
tab.addEventListener("keydown", (event) => {
|
|
21213
|
+
if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
|
|
21214
|
+
event.preventDefault();
|
|
21215
|
+
const hosts = latestSnapshot?.hosts ?? [];
|
|
21216
|
+
const index = hosts.findIndex((candidate) => candidate.hostId === host.hostId);
|
|
21217
|
+
if (index < 0) return;
|
|
21218
|
+
const direction = event.key === "ArrowRight" ? 1 : -1;
|
|
21219
|
+
const next = hosts[(index + direction + hosts.length) % hosts.length];
|
|
21220
|
+
if (!next) return;
|
|
21221
|
+
selectedHostId = next.hostId;
|
|
21222
|
+
render(latestSnapshot);
|
|
21223
|
+
hostTabElements.get(next.hostId)?.focus();
|
|
21224
|
+
});
|
|
21225
|
+
hostTabElements.set(host.hostId, tab);
|
|
21226
|
+
tabsChanged = true;
|
|
21227
|
+
}
|
|
21228
|
+
const isSelected = host.hostId === selectedHost.hostId;
|
|
21229
|
+
const activeValue = String(host.active);
|
|
21230
|
+
if (tab.dataset.connectionHostActive !== activeValue) {
|
|
21231
|
+
tab.dataset.connectionHostActive = activeValue;
|
|
21232
|
+
}
|
|
21233
|
+
const selectedValue = String(isSelected);
|
|
21234
|
+
if (tab.getAttribute("aria-selected") !== selectedValue) {
|
|
21235
|
+
tab.setAttribute("aria-selected", selectedValue);
|
|
21236
|
+
}
|
|
21237
|
+
const nextTabIndex = isSelected ? 0 : -1;
|
|
21238
|
+
if (tab.tabIndex !== nextTabIndex) {
|
|
21239
|
+
tab.tabIndex = nextTabIndex;
|
|
21240
|
+
}
|
|
20672
21241
|
const hostName = hostNames.get(host.hostId) || connectionHostName(host.hostId, messages);
|
|
20673
|
-
tab.textContent
|
|
20674
|
-
|
|
20675
|
-
|
|
20676
|
-
|
|
20677
|
-
|
|
20678
|
-
|
|
20679
|
-
|
|
20680
|
-
|
|
20681
|
-
|
|
20682
|
-
const direction = event.key === "ArrowRight" ? 1 : -1;
|
|
20683
|
-
const next = snapshot.hosts[(index + direction + snapshot.hosts.length) % snapshot.hosts.length];
|
|
20684
|
-
if (!next) return;
|
|
20685
|
-
selectedHostId = next.hostId;
|
|
20686
|
-
render(latestSnapshot);
|
|
20687
|
-
const nextTab = [
|
|
20688
|
-
...content.querySelectorAll("[data-connection-host-tab]")
|
|
20689
|
-
].find((candidate) => candidate.dataset.connectionHostTab === next.hostId);
|
|
20690
|
-
nextTab?.focus();
|
|
20691
|
-
});
|
|
20692
|
-
tabs.append(tab);
|
|
21242
|
+
if (tab.textContent !== hostName) {
|
|
21243
|
+
tab.textContent = hostName;
|
|
21244
|
+
tabsChanged = true;
|
|
21245
|
+
}
|
|
21246
|
+
const tabTitle = host.active ? `${hostName} \xB7 ${messages.connectionActiveHost}` : hostName;
|
|
21247
|
+
if (tab.title !== tabTitle) {
|
|
21248
|
+
tab.title = tabTitle;
|
|
21249
|
+
}
|
|
21250
|
+
return tab;
|
|
20693
21251
|
});
|
|
20694
|
-
|
|
20695
|
-
|
|
20696
|
-
|
|
20697
|
-
|
|
20698
|
-
const componentHeading = document2.createElement("span");
|
|
20699
|
-
componentHeading.textContent = messages.connectionComponent;
|
|
20700
|
-
componentHeading.setAttribute("role", "columnheader");
|
|
20701
|
-
const statusHeading = document2.createElement("span");
|
|
20702
|
-
statusHeading.textContent = messages.connectionStatus;
|
|
20703
|
-
statusHeading.setAttribute("role", "columnheader");
|
|
20704
|
-
const actionHeading = document2.createElement("span");
|
|
20705
|
-
actionHeading.setAttribute("aria-hidden", "true");
|
|
20706
|
-
tableHeader.append(componentHeading, statusHeading, actionHeading);
|
|
20707
|
-
const rows = document2.createElement("div");
|
|
20708
|
-
rows.className = "settings-connection-rows";
|
|
20709
|
-
rows.id = panelId;
|
|
20710
|
-
rows.dataset.connectionHost = selectedHost.hostId;
|
|
20711
|
-
rows.setAttribute("role", "rowgroup");
|
|
20712
|
-
const inspector = document2.createElement("aside");
|
|
20713
|
-
inspector.className = "settings-connection-inspector";
|
|
20714
|
-
inspector.setAttribute("aria-live", "polite");
|
|
21252
|
+
reconcileElementChildren(tabs, nextTabs);
|
|
21253
|
+
if (rows.dataset.connectionHost !== selectedHost.hostId) {
|
|
21254
|
+
rows.dataset.connectionHost = selectedHost.hostId;
|
|
21255
|
+
}
|
|
20715
21256
|
const items = connectionItems(snapshot, selectedHost, messages, diagnostics).map(
|
|
20716
21257
|
(item) => {
|
|
20717
21258
|
const agent = item.agentSnapshot?.agent;
|
|
20718
21259
|
if (!agent) return item;
|
|
20719
21260
|
const state = installs?.get(selectedHost.hostId, agent);
|
|
20720
21261
|
const availability = state?.status ?? item.availability;
|
|
20721
|
-
const
|
|
21262
|
+
const updating = versions.isUpdating(selectedHost.hostId, agent);
|
|
21263
|
+
const version2 = updating || item.agentSnapshot?.availability !== "notInstalled" && availability !== "installing" && availability !== "checking" ? versions.get(selectedHost.hostId, agent) : void 0;
|
|
20722
21264
|
return {
|
|
20723
21265
|
...item,
|
|
20724
21266
|
...state ? { availability: state.status } : {},
|
|
@@ -20740,66 +21282,66 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
20740
21282
|
(item) => item.agentSnapshot?.availability === "notInstalled" || item.error !== null
|
|
20741
21283
|
)?.key ?? items[0]?.key ?? null;
|
|
20742
21284
|
}
|
|
20743
|
-
|
|
21285
|
+
let hostRows = hostRowViews.get(selectedHost.hostId);
|
|
21286
|
+
if (!hostRows) {
|
|
21287
|
+
hostRows = /* @__PURE__ */ new Map();
|
|
21288
|
+
hostRowViews.set(selectedHost.hostId, hostRows);
|
|
21289
|
+
}
|
|
21290
|
+
currentHostRows = hostRows;
|
|
20744
21291
|
const selectItem = (item) => {
|
|
20745
21292
|
selectedItemKey = item.key;
|
|
20746
|
-
for (const [key,
|
|
20747
|
-
|
|
20748
|
-
row.dataset.connectionSelected = String(selected);
|
|
20749
|
-
row.tabIndex = selected ? 0 : -1;
|
|
21293
|
+
for (const [key, view] of currentHostRows) {
|
|
21294
|
+
view.setSelected(key === item.key);
|
|
20750
21295
|
}
|
|
20751
|
-
|
|
20752
|
-
const element = renderConnectionInspector(
|
|
20753
|
-
document2,
|
|
20754
|
-
inspector,
|
|
20755
|
-
item,
|
|
20756
|
-
selectedHost.hostId,
|
|
20757
|
-
messages,
|
|
20758
|
-
getDiagnostics(),
|
|
20759
|
-
existing,
|
|
20760
|
-
runRefresh
|
|
20761
|
-
);
|
|
20762
|
-
launchControls = { hostId: selectedHost.hostId, itemKey: item.key, element };
|
|
20763
|
-
if (item.version) inspector.append(item.version.element);
|
|
21296
|
+
syncSelectedInspector(selectedHost.hostId, item);
|
|
20764
21297
|
};
|
|
20765
|
-
const
|
|
20766
|
-
|
|
20767
|
-
|
|
20768
|
-
document2,
|
|
21298
|
+
const ensureRowView = (key, groupable) => {
|
|
21299
|
+
let view = hostRows.get(key);
|
|
21300
|
+
if (!view) {
|
|
21301
|
+
view = createConnectionRowView(document2, messages, groupable);
|
|
21302
|
+
hostRows.set(key, view);
|
|
21303
|
+
}
|
|
21304
|
+
return view;
|
|
21305
|
+
};
|
|
21306
|
+
const activeKeys = /* @__PURE__ */ new Set();
|
|
21307
|
+
const nextRowChildren = [];
|
|
21308
|
+
const pinnedItems = items.filter((item) => item.agentSnapshot === void 0);
|
|
21309
|
+
for (const pinnedItem of pinnedItems) {
|
|
21310
|
+
activeKeys.add(pinnedItem.key);
|
|
21311
|
+
const view = ensureRowView(pinnedItem.key, false);
|
|
21312
|
+
view.update(
|
|
20769
21313
|
pinnedItem,
|
|
20770
|
-
messages,
|
|
20771
21314
|
pinnedItem.key === selectedItemKey,
|
|
20772
|
-
() => selectItem(pinnedItem)
|
|
21315
|
+
() => selectItem(pinnedItem),
|
|
21316
|
+
null
|
|
20773
21317
|
);
|
|
20774
|
-
|
|
20775
|
-
rows.append(row);
|
|
21318
|
+
nextRowChildren.push(view.element);
|
|
20776
21319
|
}
|
|
20777
21320
|
const groupableItems = items.filter(
|
|
20778
21321
|
(item) => item.agentSnapshot !== void 0
|
|
20779
21322
|
);
|
|
20780
21323
|
const agentByKey = new Map(groupableItems.map((item) => [item.key, item]));
|
|
20781
|
-
|
|
20782
|
-
const
|
|
20783
|
-
|
|
20784
|
-
|
|
20785
|
-
|
|
20786
|
-
|
|
20787
|
-
|
|
20788
|
-
|
|
20789
|
-
|
|
21324
|
+
currentCatalog = groupableItems.map((item) => ({ id: item.key, name: item.name }));
|
|
21325
|
+
const notInstalledAgents = /* @__PURE__ */ new Set();
|
|
21326
|
+
for (const item of groupableItems) {
|
|
21327
|
+
const agent = item.agentSnapshot.agent;
|
|
21328
|
+
const stateKey = `${selectedHost.hostId}:${agent}`;
|
|
21329
|
+
if (item.agentSnapshot.availability !== "checking") {
|
|
21330
|
+
knownNotInstalled.set(stateKey, item.agentSnapshot.availability === "notInstalled");
|
|
21331
|
+
}
|
|
21332
|
+
const isNotInstalled = item.agentSnapshot.availability === "checking" ? knownNotInstalled.get(stateKey) ?? false : item.agentSnapshot.availability === "notInstalled";
|
|
21333
|
+
if (isNotInstalled) notInstalledAgents.add(agent);
|
|
21334
|
+
}
|
|
21335
|
+
const preferenceOrder = groupPreference.list(notInstalledAgents, currentCatalog).filter((entry) => agentByKey.has(entry.agent));
|
|
21336
|
+
currentMainEntries = preferenceOrder.filter((entry) => entry.section === "main");
|
|
21337
|
+
currentMoreEntries = preferenceOrder.filter((entry) => entry.section === "more");
|
|
20790
21338
|
const nextInSection = (section, agent) => {
|
|
20791
|
-
const
|
|
20792
|
-
const index =
|
|
20793
|
-
return index >= 0 ?
|
|
20794
|
-
};
|
|
20795
|
-
let draggingAgent = null;
|
|
20796
|
-
let moreZone = null;
|
|
20797
|
-
const clearDropIndicators = () => {
|
|
20798
|
-
for (const row of rowElements.values()) row.dataset.connectionDropIndicator = "";
|
|
20799
|
-
if (moreZone) moreZone.dataset.connectionDragOver = "false";
|
|
21339
|
+
const sectionEntries = section === "main" ? currentMainEntries : currentMoreEntries;
|
|
21340
|
+
const index = sectionEntries.findIndex((entry) => entry.agent === agent);
|
|
21341
|
+
return index >= 0 ? sectionEntries[index + 1]?.agent ?? null : null;
|
|
20800
21342
|
};
|
|
20801
21343
|
const dropTargetSection = (agent, event) => {
|
|
20802
|
-
const row =
|
|
21344
|
+
const row = currentHostRows.get(agent)?.element;
|
|
20803
21345
|
const rect = row && typeof row.getBoundingClientRect === "function" ? row.getBoundingClientRect() : null;
|
|
20804
21346
|
const before = rect ? event.clientY - rect.top < rect.height / 2 : true;
|
|
20805
21347
|
const section = row?.dataset.connectionGroupSection ?? "main";
|
|
@@ -20811,7 +21353,12 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
20811
21353
|
moveLabel: section === "main" ? messages.connectionGroupMoveToMore : messages.connectionGroupMoveToMain,
|
|
20812
21354
|
dragHandleTitle: messages.connectionGroupDragHandle,
|
|
20813
21355
|
toggleSection() {
|
|
20814
|
-
groupPreference.moveAgent(
|
|
21356
|
+
groupPreference.moveAgent(
|
|
21357
|
+
agent,
|
|
21358
|
+
section === "main" ? "more" : "main",
|
|
21359
|
+
null,
|
|
21360
|
+
currentCatalog
|
|
21361
|
+
);
|
|
20815
21362
|
},
|
|
20816
21363
|
onDragStart(event) {
|
|
20817
21364
|
if (groupDisabled) {
|
|
@@ -20821,127 +21368,107 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
20821
21368
|
draggingAgent = agent;
|
|
20822
21369
|
event.dataTransfer?.setData("text/plain", agent);
|
|
20823
21370
|
if (event.dataTransfer) event.dataTransfer.effectAllowed = "move";
|
|
20824
|
-
const row =
|
|
21371
|
+
const row = currentHostRows.get(agent)?.element;
|
|
20825
21372
|
if (row) row.dataset.connectionDragging = "true";
|
|
20826
21373
|
},
|
|
20827
21374
|
onDragOver(event) {
|
|
20828
21375
|
if (!draggingAgent || draggingAgent === agent) return;
|
|
20829
21376
|
event.preventDefault();
|
|
20830
|
-
const row =
|
|
21377
|
+
const row = currentHostRows.get(agent)?.element;
|
|
20831
21378
|
if (!row) return;
|
|
20832
21379
|
const { before } = dropTargetSection(agent, event);
|
|
20833
21380
|
clearDropIndicators();
|
|
20834
21381
|
row.dataset.connectionDropIndicator = before ? "before" : "after";
|
|
20835
21382
|
},
|
|
20836
21383
|
onDragLeave() {
|
|
20837
|
-
const row =
|
|
21384
|
+
const row = currentHostRows.get(agent)?.element;
|
|
20838
21385
|
if (row) row.dataset.connectionDropIndicator = "";
|
|
20839
21386
|
},
|
|
20840
21387
|
onDrop(event) {
|
|
20841
21388
|
event.preventDefault();
|
|
20842
21389
|
if (!draggingAgent) return;
|
|
20843
21390
|
const { beforeAgent } = dropTargetSection(agent, event);
|
|
20844
|
-
groupPreference.moveAgent(draggingAgent, section, beforeAgent,
|
|
21391
|
+
groupPreference.moveAgent(draggingAgent, section, beforeAgent, currentCatalog);
|
|
20845
21392
|
draggingAgent = null;
|
|
20846
21393
|
clearDropIndicators();
|
|
20847
21394
|
},
|
|
20848
21395
|
onDragEnd() {
|
|
20849
21396
|
draggingAgent = null;
|
|
20850
|
-
const row =
|
|
21397
|
+
const row = currentHostRows.get(agent)?.element;
|
|
20851
21398
|
if (row) row.dataset.connectionDragging = "false";
|
|
20852
21399
|
clearDropIndicators();
|
|
21400
|
+
scheduleRender();
|
|
20853
21401
|
}
|
|
20854
21402
|
});
|
|
20855
|
-
const
|
|
20856
|
-
const item = agentByKey.get(agent);
|
|
20857
|
-
if (!item)
|
|
20858
|
-
|
|
20859
|
-
|
|
21403
|
+
for (const entry of currentMainEntries) {
|
|
21404
|
+
const item = agentByKey.get(entry.agent);
|
|
21405
|
+
if (!item) continue;
|
|
21406
|
+
activeKeys.add(item.key);
|
|
21407
|
+
const view = ensureRowView(item.key, true);
|
|
21408
|
+
view.update(
|
|
20860
21409
|
item,
|
|
20861
|
-
messages,
|
|
20862
21410
|
item.key === selectedItemKey,
|
|
20863
21411
|
() => selectItem(item),
|
|
20864
|
-
createGroupController(agent,
|
|
21412
|
+
createGroupController(entry.agent, "main")
|
|
20865
21413
|
);
|
|
20866
|
-
|
|
20867
|
-
|
|
20868
|
-
};
|
|
20869
|
-
for (const entry of mainEntries) appendGroupRow(entry.agent, "main");
|
|
21414
|
+
nextRowChildren.push(view.element);
|
|
21415
|
+
}
|
|
20870
21416
|
if (groupableItems.length > 0) {
|
|
20871
|
-
|
|
20872
|
-
|
|
20873
|
-
|
|
20874
|
-
|
|
20875
|
-
|
|
20876
|
-
|
|
20877
|
-
|
|
20878
|
-
|
|
20879
|
-
zone.dataset.connectionDragOver = "true";
|
|
20880
|
-
});
|
|
20881
|
-
zone.addEventListener("dragleave", () => {
|
|
20882
|
-
zone.dataset.connectionDragOver = "false";
|
|
20883
|
-
});
|
|
20884
|
-
zone.addEventListener("drop", (event) => {
|
|
20885
|
-
event.preventDefault();
|
|
20886
|
-
zone.dataset.connectionDragOver = "false";
|
|
20887
|
-
if (!draggingAgent) return;
|
|
20888
|
-
groupPreference.moveAgent(draggingAgent, "more", null, catalog);
|
|
20889
|
-
draggingAgent = null;
|
|
20890
|
-
clearDropIndicators();
|
|
20891
|
-
});
|
|
20892
|
-
if (moreEntries.length === 0) {
|
|
20893
|
-
zone.append(createGroupMoreHint(document2, messages));
|
|
21417
|
+
const dividerText = `${messages.connectionGroupMoreLabel} (${currentMoreEntries.length})`;
|
|
21418
|
+
if (groupDivider.textContent !== dividerText) {
|
|
21419
|
+
groupDivider.textContent = dividerText;
|
|
21420
|
+
}
|
|
21421
|
+
nextRowChildren.push(groupDivider);
|
|
21422
|
+
const nextMoreChildren = [];
|
|
21423
|
+
if (currentMoreEntries.length === 0) {
|
|
21424
|
+
nextMoreChildren.push(moreHint);
|
|
20894
21425
|
} else {
|
|
20895
|
-
for (const entry of
|
|
21426
|
+
for (const entry of currentMoreEntries) {
|
|
20896
21427
|
const item = agentByKey.get(entry.agent);
|
|
20897
21428
|
if (!item) continue;
|
|
20898
|
-
|
|
20899
|
-
|
|
21429
|
+
activeKeys.add(item.key);
|
|
21430
|
+
const view = ensureRowView(item.key, true);
|
|
21431
|
+
view.update(
|
|
20900
21432
|
item,
|
|
20901
|
-
messages,
|
|
20902
21433
|
item.key === selectedItemKey,
|
|
20903
21434
|
() => selectItem(item),
|
|
20904
21435
|
createGroupController(entry.agent, "more")
|
|
20905
21436
|
);
|
|
20906
|
-
|
|
20907
|
-
zone.append(row);
|
|
21437
|
+
nextMoreChildren.push(view.element);
|
|
20908
21438
|
}
|
|
20909
21439
|
}
|
|
20910
|
-
|
|
20911
|
-
|
|
20912
|
-
|
|
20913
|
-
|
|
20914
|
-
|
|
20915
|
-
|
|
21440
|
+
if (!draggingAgent || renderedHostId !== selectedHost.hostId) {
|
|
21441
|
+
reconcileElementChildren(moreZone, nextMoreChildren);
|
|
21442
|
+
}
|
|
21443
|
+
nextRowChildren.push(moreZone);
|
|
21444
|
+
resetButton.disabled = groupDisabled;
|
|
21445
|
+
nextRowChildren.push(resetButton);
|
|
21446
|
+
}
|
|
21447
|
+
for (const key of hostRows.keys()) {
|
|
21448
|
+
if (!activeKeys.has(key)) hostRows.delete(key);
|
|
21449
|
+
}
|
|
21450
|
+
if (!draggingAgent || renderedHostId !== selectedHost.hostId) {
|
|
21451
|
+
reconcileElementChildren(rows, nextRowChildren);
|
|
20916
21452
|
}
|
|
20917
21453
|
const selectedItem = items.find((item) => item.key === selectedItemKey) ?? items[0];
|
|
20918
21454
|
if (selectedItem) selectItem(selectedItem);
|
|
20919
|
-
|
|
21455
|
+
updateControls.update(
|
|
20920
21456
|
selectedHost.hostId,
|
|
20921
21457
|
items.flatMap((item) => item.version ? [item.version] : [])
|
|
20922
21458
|
);
|
|
20923
|
-
|
|
20924
|
-
|
|
20925
|
-
|
|
20926
|
-
|
|
20927
|
-
|
|
20928
|
-
|
|
20929
|
-
|
|
20930
|
-
|
|
20931
|
-
|
|
20932
|
-
|
|
20933
|
-
|
|
20934
|
-
|
|
20935
|
-
|
|
20936
|
-
const selectedTab = [...tabs.children].find(
|
|
20937
|
-
(child) => child.getAttribute("aria-selected") === "true"
|
|
20938
|
-
);
|
|
20939
|
-
if (selectedTab) {
|
|
20940
|
-
const left = selectedTab.offsetLeft;
|
|
20941
|
-
const right = left + selectedTab.offsetWidth;
|
|
20942
|
-
if (left < tabs.scrollLeft) tabs.scrollLeft = left;
|
|
20943
|
-
else if (right > tabs.scrollLeft + tabs.clientWidth) {
|
|
20944
|
-
tabs.scrollLeft = right - tabs.clientWidth;
|
|
21459
|
+
if (layoutFirstMount || tabsChanged) {
|
|
21460
|
+
hostScroller.update();
|
|
21461
|
+
}
|
|
21462
|
+
if (renderedHostId !== selectedHost.hostId) {
|
|
21463
|
+
renderedHostId = selectedHost.hostId;
|
|
21464
|
+
const selectedTab = hostTabElements.get(selectedHost.hostId);
|
|
21465
|
+
if (selectedTab) {
|
|
21466
|
+
const left = selectedTab.offsetLeft;
|
|
21467
|
+
const right = left + selectedTab.offsetWidth;
|
|
21468
|
+
if (left < tabs.scrollLeft) tabs.scrollLeft = left;
|
|
21469
|
+
else if (right > tabs.scrollLeft + tabs.clientWidth) {
|
|
21470
|
+
tabs.scrollLeft = right - tabs.clientWidth;
|
|
21471
|
+
}
|
|
20945
21472
|
}
|
|
20946
21473
|
}
|
|
20947
21474
|
};
|
|
@@ -20962,7 +21489,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
20962
21489
|
refresh.disabled = true;
|
|
20963
21490
|
return () => {
|
|
20964
21491
|
cancelRender();
|
|
20965
|
-
|
|
21492
|
+
hostScroller.dispose();
|
|
20966
21493
|
unsubscribeGroup();
|
|
20967
21494
|
};
|
|
20968
21495
|
}
|
|
@@ -20971,7 +21498,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
20971
21498
|
const unsubscribeInstalls = installs?.subscribe(scheduleRender);
|
|
20972
21499
|
return () => {
|
|
20973
21500
|
cancelRender();
|
|
20974
|
-
|
|
21501
|
+
hostScroller.dispose();
|
|
20975
21502
|
unsubscribeInstalls?.();
|
|
20976
21503
|
unsubscribe();
|
|
20977
21504
|
unsubscribeGroup();
|
|
@@ -22378,6 +22905,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
22378
22905
|
latestCacheHit: "Latest cache hit (CH)",
|
|
22379
22906
|
sessionCacheHit: "Average cache hit",
|
|
22380
22907
|
outputSpeed: "Output speed (TPS)",
|
|
22908
|
+
averageOutputSpeed: "Average output speed (TPS)",
|
|
22381
22909
|
apiOutputSpeed: "API average speed",
|
|
22382
22910
|
apiOutputSpeedDescription: "Output tokens / native API time, including first-token wait; not generation TPS.",
|
|
22383
22911
|
timeToFirstOutput: "Time to first token (TTFT)",
|
|
@@ -22403,6 +22931,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
22403
22931
|
latestCacheHit: "\u6700\u8FD1\u7F13\u5B58\u547D\u4E2D\uFF08CH\uFF09",
|
|
22404
22932
|
sessionCacheHit: "\u5E73\u5747\u7F13\u5B58\u547D\u4E2D",
|
|
22405
22933
|
outputSpeed: "\u8F93\u51FA\u901F\u5EA6\uFF08TPS\uFF09",
|
|
22934
|
+
averageOutputSpeed: "\u5E73\u5747\u8F93\u51FA\u901F\u5EA6\uFF08TPS\uFF09",
|
|
22406
22935
|
apiOutputSpeed: "API \u5E73\u5747\u901F\u5EA6",
|
|
22407
22936
|
apiOutputSpeedDescription: "\u8F93\u51FA Token \xF7 \u539F\u751F API \u8017\u65F6\uFF0C\u542B\u9996\u5B57\u7B49\u5F85\uFF1B\u4E0D\u662F\u751F\u6210 TPS\u3002",
|
|
22408
22937
|
timeToFirstOutput: "\u9996 token\uFF08TTFT\uFF09",
|
|
@@ -22500,7 +23029,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
22500
23029
|
return svg2;
|
|
22501
23030
|
}
|
|
22502
23031
|
function rendererUsageHasDisplayData(usage) {
|
|
22503
|
-
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;
|
|
23032
|
+
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;
|
|
22504
23033
|
}
|
|
22505
23034
|
function applyRendererPopoverChrome(popover) {
|
|
22506
23035
|
popover.style.border = "1px solid light-dark(rgba(15, 23, 42, 0.10), color-mix(in srgb, CanvasText 16%, transparent))";
|
|
@@ -22613,6 +23142,12 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
|
|
|
22613
23142
|
formatRendererCacheHitRate(usage.sessionCacheHitRatePercent)
|
|
22614
23143
|
]);
|
|
22615
23144
|
}
|
|
23145
|
+
if (usage?.sessionOutputTokensPerSecond !== void 0) {
|
|
23146
|
+
session.push([
|
|
23147
|
+
messages.averageOutputSpeed,
|
|
23148
|
+
formatRendererTokenRate(usage.sessionOutputTokensPerSecond, locale)
|
|
23149
|
+
]);
|
|
23150
|
+
}
|
|
22616
23151
|
if (usage?.cacheHitRatePercent !== void 0) {
|
|
22617
23152
|
session.push([messages.latestCacheHit, formatRendererCacheHitRate(usage.cacheHitRatePercent)]);
|
|
22618
23153
|
}
|
|
@@ -24439,9 +24974,13 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
24439
24974
|
resets: "Resets",
|
|
24440
24975
|
details: "Account limit details",
|
|
24441
24976
|
weekly: "Weekly limit",
|
|
24977
|
+
weeklyShort: "Weekly",
|
|
24442
24978
|
monthly: "Monthly limit",
|
|
24979
|
+
monthlyShort: "Monthly",
|
|
24443
24980
|
fiveHour: "5-hour limit",
|
|
24981
|
+
fiveHourShort: "5-hour",
|
|
24444
24982
|
sevenDay: "7-day limit",
|
|
24983
|
+
sevenDayShort: "7-day",
|
|
24445
24984
|
account: "Account limit"
|
|
24446
24985
|
});
|
|
24447
24986
|
var CHINESE_CREDITS_MESSAGES = Object.freeze({
|
|
@@ -24449,9 +24988,13 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
24449
24988
|
resets: "\u91CD\u7F6E",
|
|
24450
24989
|
details: "\u8D26\u53F7\u989D\u5EA6\u8BE6\u60C5",
|
|
24451
24990
|
weekly: "\u5468\u989D\u5EA6",
|
|
24991
|
+
weeklyShort: "\u5468\u989D\u5EA6",
|
|
24452
24992
|
monthly: "\u6708\u989D\u5EA6",
|
|
24993
|
+
monthlyShort: "\u6708\u989D\u5EA6",
|
|
24453
24994
|
fiveHour: "5 \u5C0F\u65F6\u989D\u5EA6",
|
|
24995
|
+
fiveHourShort: "5 \u5C0F\u65F6",
|
|
24454
24996
|
sevenDay: "7 \u5929\u989D\u5EA6",
|
|
24997
|
+
sevenDayShort: "7 \u5929",
|
|
24455
24998
|
account: "\u8D26\u53F7\u989D\u5EA6"
|
|
24456
24999
|
});
|
|
24457
25000
|
function rendererCreditsMessages(locale) {
|
|
@@ -24483,6 +25026,14 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
24483
25026
|
if (periodType === "seven_day") return messages.sevenDay;
|
|
24484
25027
|
return messages.account;
|
|
24485
25028
|
}
|
|
25029
|
+
function compactPeriodLabel(periodType, locale) {
|
|
25030
|
+
const messages = rendererCreditsMessages(locale);
|
|
25031
|
+
if (periodType === "weekly") return messages.weeklyShort;
|
|
25032
|
+
if (periodType === "monthly") return messages.monthlyShort;
|
|
25033
|
+
if (periodType === "five_hour") return messages.fiveHourShort;
|
|
25034
|
+
if (periodType === "seven_day") return messages.sevenDayShort;
|
|
25035
|
+
return messages.account;
|
|
25036
|
+
}
|
|
24486
25037
|
function productLabel(product, locale = "en") {
|
|
24487
25038
|
return accountCreditsWindowLabel(product, locale, (period) => creditsPeriodLabel(period, locale));
|
|
24488
25039
|
}
|
|
@@ -24494,10 +25045,10 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
24494
25045
|
function remainingPercent(usedPercent) {
|
|
24495
25046
|
return Math.min(100, Math.max(0, 100 - usedPercent));
|
|
24496
25047
|
}
|
|
24497
|
-
function renderCreditsBar(usagePercent, color) {
|
|
25048
|
+
function renderCreditsBar(usagePercent, color, height = "6px") {
|
|
24498
25049
|
const track = document.createElement("div");
|
|
24499
25050
|
track.dataset.codexhostCreditsBar = "";
|
|
24500
|
-
track.style.height =
|
|
25051
|
+
track.style.height = height;
|
|
24501
25052
|
track.style.borderRadius = "9999px";
|
|
24502
25053
|
track.style.background = "color-mix(in srgb, currentColor 16%, transparent)";
|
|
24503
25054
|
track.style.overflow = "hidden";
|
|
@@ -24514,6 +25065,34 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
24514
25065
|
const formatted = formatRendererCreditsReset(resetsAt, /* @__PURE__ */ new Date(), locale);
|
|
24515
25066
|
return locale === "zh-CN" ? `${formatted} ${messages.resets}` : `${messages.resets} ${formatted}`;
|
|
24516
25067
|
}
|
|
25068
|
+
function renderResetLine(resetsAt, fontSize, locale, messages) {
|
|
25069
|
+
const exact = resetLabel(resetsAt, locale, messages);
|
|
25070
|
+
const reset = document.createElement("div");
|
|
25071
|
+
reset.dataset.codexhostResetAt = resetsAt;
|
|
25072
|
+
reset.dataset.codexhostResetLocale = locale;
|
|
25073
|
+
reset.textContent = formatAccountCreditsResetCountdown(resetsAt, locale) ?? exact;
|
|
25074
|
+
reset.title = exact;
|
|
25075
|
+
reset.style.fontSize = fontSize;
|
|
25076
|
+
reset.style.color = "color-mix(in srgb, currentColor 62%, transparent)";
|
|
25077
|
+
return reset;
|
|
25078
|
+
}
|
|
25079
|
+
function refreshResetLines(popover) {
|
|
25080
|
+
if (typeof popover.querySelectorAll !== "function") return;
|
|
25081
|
+
const nowMs = Date.now();
|
|
25082
|
+
for (const element of popover.querySelectorAll("[data-codexhost-reset-at]")) {
|
|
25083
|
+
const resetsAt = element.dataset.codexhostResetAt;
|
|
25084
|
+
if (!resetsAt) continue;
|
|
25085
|
+
const locale = element.dataset.codexhostResetLocale === "zh-CN" ? "zh-CN" : "en";
|
|
25086
|
+
const exact = resetLabel(resetsAt, locale, rendererCreditsMessages(locale));
|
|
25087
|
+
if (element.dataset.codexhostResetCompact === "1") {
|
|
25088
|
+
const compact = formatAccountCreditsCompactCountdown(resetsAt, locale, nowMs);
|
|
25089
|
+
element.textContent = `\xB7 ${compact ?? exact}`;
|
|
25090
|
+
} else {
|
|
25091
|
+
element.textContent = formatAccountCreditsResetCountdown(resetsAt, locale, nowMs) ?? exact;
|
|
25092
|
+
}
|
|
25093
|
+
element.title = exact;
|
|
25094
|
+
}
|
|
25095
|
+
}
|
|
24517
25096
|
function renderCreditsHeader(credits, locale, messages) {
|
|
24518
25097
|
const wrapper = document.createElement("div");
|
|
24519
25098
|
wrapper.style.marginBottom = "11px";
|
|
@@ -24530,11 +25109,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
24530
25109
|
label.style.fontWeight = "600";
|
|
24531
25110
|
left.append(label);
|
|
24532
25111
|
if (credits.resetsAt) {
|
|
24533
|
-
|
|
24534
|
-
reset.textContent = resetLabel(credits.resetsAt, locale, messages);
|
|
24535
|
-
reset.style.fontSize = "11px";
|
|
24536
|
-
reset.style.color = "color-mix(in srgb, currentColor 62%, transparent)";
|
|
24537
|
-
left.append(reset);
|
|
25112
|
+
left.append(renderResetLine(credits.resetsAt, "11px", locale, messages));
|
|
24538
25113
|
}
|
|
24539
25114
|
const color = toneColor(rendererCreditsTone(credits.usedPercent));
|
|
24540
25115
|
const remaining = remainingPercent(credits.usedPercent);
|
|
@@ -24563,7 +25138,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
24563
25138
|
const color = toneColor(rendererCreditsTone(usagePercent));
|
|
24564
25139
|
const remaining = remainingPercent(usagePercent);
|
|
24565
25140
|
const tile = document.createElement("div");
|
|
24566
|
-
tile.style.marginBottom = "
|
|
25141
|
+
tile.style.marginBottom = "9px";
|
|
24567
25142
|
const top = document.createElement("div");
|
|
24568
25143
|
top.style.display = "flex";
|
|
24569
25144
|
top.style.alignItems = "flex-start";
|
|
@@ -24576,40 +25151,137 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
24576
25151
|
name.style.fontSize = "12px";
|
|
24577
25152
|
left.append(name);
|
|
24578
25153
|
if (resetsAt) {
|
|
24579
|
-
|
|
24580
|
-
reset.textContent = resetLabel(resetsAt, locale, messages);
|
|
24581
|
-
reset.style.fontSize = "10.5px";
|
|
24582
|
-
reset.style.color = "color-mix(in srgb, currentColor 62%, transparent)";
|
|
24583
|
-
left.append(reset);
|
|
25154
|
+
left.append(renderResetLine(resetsAt, "10.5px", locale, messages));
|
|
24584
25155
|
}
|
|
24585
25156
|
const percent2 = document.createElement("span");
|
|
24586
25157
|
percent2.textContent = `${messages.remaining} ${formatRendererCreditsPercent(remaining)}`;
|
|
24587
25158
|
percent2.style.fontSize = "12px";
|
|
24588
25159
|
percent2.style.fontVariantNumeric = "tabular-nums";
|
|
25160
|
+
percent2.style.whiteSpace = "nowrap";
|
|
24589
25161
|
percent2.style.color = color;
|
|
24590
25162
|
top.append(left, percent2);
|
|
24591
25163
|
tile.append(top, renderCreditsBar(remaining, color));
|
|
24592
25164
|
return tile;
|
|
24593
25165
|
}
|
|
25166
|
+
function renderCompactCreditsRow(label, usagePercent, locale, messages, resetsAt, hero = false) {
|
|
25167
|
+
const color = toneColor(rendererCreditsTone(usagePercent));
|
|
25168
|
+
const remaining = remainingPercent(usagePercent);
|
|
25169
|
+
const row = document.createElement("div");
|
|
25170
|
+
row.style.marginBottom = "8px";
|
|
25171
|
+
const top = document.createElement("div");
|
|
25172
|
+
top.style.display = "flex";
|
|
25173
|
+
top.style.alignItems = "baseline";
|
|
25174
|
+
top.style.justifyContent = "space-between";
|
|
25175
|
+
top.style.gap = "8px";
|
|
25176
|
+
top.style.marginBottom = "4px";
|
|
25177
|
+
const left = document.createElement("span");
|
|
25178
|
+
left.style.display = "inline-flex";
|
|
25179
|
+
left.style.alignItems = "baseline";
|
|
25180
|
+
left.style.gap = "6px";
|
|
25181
|
+
left.style.minWidth = "0";
|
|
25182
|
+
const name = document.createElement("span");
|
|
25183
|
+
name.textContent = label;
|
|
25184
|
+
name.style.fontSize = "12px";
|
|
25185
|
+
name.style.color = "color-mix(in srgb, currentColor 82%, transparent)";
|
|
25186
|
+
left.append(name);
|
|
25187
|
+
if (resetsAt) {
|
|
25188
|
+
const exact = resetLabel(resetsAt, locale, messages);
|
|
25189
|
+
if (usagePercent > 0) {
|
|
25190
|
+
const countdown = document.createElement("span");
|
|
25191
|
+
countdown.dataset.codexhostResetAt = resetsAt;
|
|
25192
|
+
countdown.dataset.codexhostResetLocale = locale;
|
|
25193
|
+
countdown.dataset.codexhostResetCompact = "1";
|
|
25194
|
+
const compact = formatAccountCreditsCompactCountdown(resetsAt, locale);
|
|
25195
|
+
countdown.textContent = `\xB7 ${compact ?? exact}`;
|
|
25196
|
+
countdown.title = exact;
|
|
25197
|
+
countdown.style.fontSize = "11px";
|
|
25198
|
+
countdown.style.color = "color-mix(in srgb, currentColor 52%, transparent)";
|
|
25199
|
+
countdown.style.whiteSpace = "nowrap";
|
|
25200
|
+
left.append(countdown);
|
|
25201
|
+
} else {
|
|
25202
|
+
left.title = exact;
|
|
25203
|
+
}
|
|
25204
|
+
}
|
|
25205
|
+
const percent2 = document.createElement("span");
|
|
25206
|
+
percent2.textContent = formatRendererCreditsPercent(remaining);
|
|
25207
|
+
percent2.style.fontSize = hero ? "22px" : "13px";
|
|
25208
|
+
percent2.style.fontWeight = hero ? "700" : "600";
|
|
25209
|
+
if (hero) {
|
|
25210
|
+
percent2.style.lineHeight = "1";
|
|
25211
|
+
percent2.style.marginTop = "-6px";
|
|
25212
|
+
}
|
|
25213
|
+
percent2.style.fontVariantNumeric = "tabular-nums";
|
|
25214
|
+
percent2.style.whiteSpace = "nowrap";
|
|
25215
|
+
percent2.style.color = color;
|
|
25216
|
+
top.append(left, percent2);
|
|
25217
|
+
row.append(top, renderCreditsBar(remaining, color, "4px"));
|
|
25218
|
+
return row;
|
|
25219
|
+
}
|
|
24594
25220
|
function renderDetails2(popover, credits, locale) {
|
|
24595
25221
|
const messages = rendererCreditsMessages(locale);
|
|
24596
25222
|
const glowColor = toneColor(rendererCreditsTone(credits.usedPercent));
|
|
24597
25223
|
popover.style.backgroundImage = `radial-gradient(160px 100px at 18% -10%, color-mix(in srgb, ${glowColor} 20%, transparent), transparent 70%)`;
|
|
24598
25224
|
popover.setAttribute("aria-label", messages.details);
|
|
24599
25225
|
popover.replaceChildren();
|
|
24600
|
-
|
|
24601
|
-
|
|
24602
|
-
|
|
24603
|
-
|
|
24604
|
-
|
|
24605
|
-
locale,
|
|
24606
|
-
messages,
|
|
24607
|
-
product.resetsAt
|
|
24608
|
-
)
|
|
25226
|
+
const sections = groupAccountCreditsWindows(
|
|
25227
|
+
credits,
|
|
25228
|
+
locale,
|
|
25229
|
+
(period) => creditsPeriodLabel(period, locale),
|
|
25230
|
+
(period) => compactPeriodLabel(period, locale)
|
|
24609
25231
|
);
|
|
24610
|
-
const
|
|
24611
|
-
if (
|
|
24612
|
-
|
|
25232
|
+
const firstScopedIndex = sections.findIndex((section) => section.title !== void 0);
|
|
25233
|
+
if (firstScopedIndex === -1) {
|
|
25234
|
+
popover.append(renderCreditsHeader(credits, locale, messages));
|
|
25235
|
+
const tiles = (credits.productUsage ?? []).map(
|
|
25236
|
+
(product) => renderCreditsTile(
|
|
25237
|
+
productLabel(product, locale),
|
|
25238
|
+
product.usagePercent,
|
|
25239
|
+
locale,
|
|
25240
|
+
messages,
|
|
25241
|
+
product.resetsAt
|
|
25242
|
+
)
|
|
25243
|
+
);
|
|
25244
|
+
const lastTile = tiles.at(-1);
|
|
25245
|
+
if (lastTile) lastTile.style.marginBottom = "0";
|
|
25246
|
+
popover.append(...tiles);
|
|
25247
|
+
return;
|
|
25248
|
+
}
|
|
25249
|
+
sections.forEach((section, sectionIndex) => {
|
|
25250
|
+
const group = document.createElement("div");
|
|
25251
|
+
if (sectionIndex > 0) {
|
|
25252
|
+
group.style.marginTop = "11px";
|
|
25253
|
+
group.style.paddingTop = "10px";
|
|
25254
|
+
group.style.borderTop = "1px solid color-mix(in srgb, currentColor 12%, transparent)";
|
|
25255
|
+
}
|
|
25256
|
+
if (section.title) {
|
|
25257
|
+
const heading = document.createElement("div");
|
|
25258
|
+
heading.textContent = section.title;
|
|
25259
|
+
heading.style.marginBottom = "7px";
|
|
25260
|
+
heading.style.fontSize = "12px";
|
|
25261
|
+
heading.style.fontWeight = "600";
|
|
25262
|
+
group.append(heading);
|
|
25263
|
+
}
|
|
25264
|
+
const tiles = section.windows.map(
|
|
25265
|
+
(window2, windowIndex) => section.title ? renderCompactCreditsRow(
|
|
25266
|
+
window2.label,
|
|
25267
|
+
window2.usedPercent,
|
|
25268
|
+
locale,
|
|
25269
|
+
messages,
|
|
25270
|
+
window2.resetsAt,
|
|
25271
|
+
sectionIndex === firstScopedIndex && windowIndex === 0
|
|
25272
|
+
) : renderCreditsTile(
|
|
25273
|
+
window2.scopeLabel ? `${window2.scopeLabel} \xB7 ${window2.label}` : window2.label,
|
|
25274
|
+
window2.usedPercent,
|
|
25275
|
+
locale,
|
|
25276
|
+
messages,
|
|
25277
|
+
window2.resetsAt
|
|
25278
|
+
)
|
|
25279
|
+
);
|
|
25280
|
+
const lastTile = tiles.at(-1);
|
|
25281
|
+
if (lastTile) lastTile.style.marginBottom = "0";
|
|
25282
|
+
group.append(...tiles);
|
|
25283
|
+
popover.append(group);
|
|
25284
|
+
});
|
|
24613
25285
|
}
|
|
24614
25286
|
function popoverIsOpen2(popover) {
|
|
24615
25287
|
try {
|
|
@@ -24636,6 +25308,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
|
|
|
24636
25308
|
control.trigger.setAttribute("aria-expanded", "false");
|
|
24637
25309
|
}
|
|
24638
25310
|
function openPopover2(control) {
|
|
25311
|
+
refreshResetLines(control.popover);
|
|
24639
25312
|
positionPopover2(control);
|
|
24640
25313
|
control.popover.hidden = false;
|
|
24641
25314
|
if (typeof control.popover.showPopover === "function" && !popoverIsOpen2(control.popover)) {
|
|
@@ -37784,6 +38457,7 @@ ${detail}` : ""}`
|
|
|
37784
38457
|
.settings-connection-inspector {
|
|
37785
38458
|
position: sticky;
|
|
37786
38459
|
top: 18px;
|
|
38460
|
+
overflow-anchor: none;
|
|
37787
38461
|
}
|
|
37788
38462
|
|
|
37789
38463
|
.settings-connection-inspector__header {
|